dts-universal-report-module 1.3.14 → 1.3.15
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 +5883 -5926
- package/dist/index.js +31 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var wa=Object.defineProperty;var Ca=(e,r,n)=>r in e?wa(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var $i=(e,r,n)=>Ca(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),ja=require("xlsx"),_=require("@mui/icons-material"),o=require("@mui/material"),Ds=require("react-dom"),ka=require("@emotion/react"),sr=require("react-dnd"),pi=require("react-dnd-html5-backend");function _s(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 fn=_s(p),Ko=_s(ja),gt={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}},$s="urm_dev_config";function za(){try{const e=localStorage.getItem($s);if(!e)return gt;const r=JSON.parse(e),n={sort:{...gt.sort,...r.sort},filter:{...gt.filter,...r.filter},columns:{...gt.columns,...r.columns},grouping:{...gt.grouping,...r.grouping},export:{...gt.export,...r.export},views:{...gt.views,...r.views},dates:{...gt.dates,...r.dates},display:{...gt.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return gt}}function Ba(e){try{localStorage.setItem($s,JSON.stringify(e))}catch{}}function Ta(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 Ia=/^\d{4}-\d{2}-\d{2}$/,Ea=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Da=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,_a=9783072e5,$a=41024448e5,Oa=978307200,Ma=4102444800;function Aa(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=_a&&e<=$a?"timestamp_ms":Number.isInteger(e)&&e>=Oa&&e<=Ma?"timestamp_s":"unknown":typeof e!="string"?"unknown":Ea.test(e)||Ia.test(e)?"iso":Da.test(e.trim())?"locale_string":"unknown"}function Wa(e,r){const n=r.map(l=>l[e]).filter(l=>l!=null&&l!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const l of n){const d=Aa(l);i[d]++}const s=n.length,a=.7;for(const l of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[l]/s>=a)return l;return"unknown"}function Ra(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 Oi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Pa=["January","February","March","April","May","June","July","August","September","October","November","December"];function qe(e){return String(e).padStart(2,"0")}function Na(e){const r=Date.now()-e.getTime(),n=Math.abs(r),i=r>0,s=Math.floor(n/1e3),a=Math.floor(s/60),l=Math.floor(a/60),d=Math.floor(l/24),u=Math.floor(d/7),g=Math.floor(d/30),b=Math.floor(d/365);let x;return s<60?x="just now":a<60?x=`${a} minute${a!==1?"s":""}`:l<24?x=`${l} hour${l!==1?"s":""}`:d<7?x=`${d} day${d!==1?"s":""}`:u<5?x=`${u} week${u!==1?"s":""}`:g<12?x=`${g} month${g!==1?"s":""}`:x=`${b} year${b!==1?"s":""}`,s<60?x:i?`${x} ago`:`in ${x}`}function La(e,r){const n=e.getFullYear(),i=e.getMonth(),s=e.getDate(),a=e.getHours(),l=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${qe(i+1)}-${qe(s)}`;case"DD/MM/YYYY":return`${qe(s)}/${qe(i+1)}/${n}`;case"MM/DD/YYYY":return`${qe(i+1)}/${qe(s)}/${n}`;case"MMM DD, YYYY":return`${Oi[i]} ${qe(s)}, ${n}`;case"DD MMM YYYY":return`${qe(s)} ${Oi[i]} ${n}`;case"MMMM D, YYYY":return`${Pa[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${qe(i+1)}-${qe(s)} ${qe(a)}:${qe(l)}`;case"DD/MM/YYYY HH:mm":return`${qe(s)}/${qe(i+1)}/${n} ${qe(a)}:${qe(l)}`;case"MM/DD/YYYY HH:mm":return`${qe(i+1)}/${qe(s)}/${n} ${qe(a)}:${qe(l)}`;case"relative":return Na(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function Fa(e,r,n){if(!n||r==="unknown")return String(e);const i=Ra(e,r);return!i||isNaN(i.getTime())?String(e):La(i,n)}function Va(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 Os(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,l=e[s];l!==null&&typeof l=="object"&&!Array.isArray(l)&&n<2?Object.assign(i,Os(l,a,n+1)):i[a]=l}return i}function co(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:Os(r))}function jo(e){if(!Array.isArray(e)||e.length===0)return[];const r=co(e),n=new Set;r.forEach(l=>{typeof l=="object"&&l!==null&&Object.keys(l).forEach(d=>n.add(d))});const i=[];n.forEach(l=>{const d=new Set;let u=0;r.forEach(S=>{typeof S=="object"&&S!==null&&l in S&&(u++,d.add(Va(S[l])))});const g=u===r.length,b=d.size>1&&!d.has("null");let x="mixed";if(d.size===1)x=Array.from(d)[0];else if(d.size===2&&d.has("null")){const S=Array.from(d).filter(y=>y!=="null");S.length===1&&(x=S[0])}i.push({name:l,type:x,required:g,hasConflict:b})});const a=r.slice(0,50);for(const l of i){if(l.type!=="string"&&l.type!=="number")continue;const d=Wa(l.name,a);d!=="unknown"&&(l.type="date",l.dateFormat=d)}return i}function Mi(e,r){return!r||r.length===0?e:e.filter(n=>!r.includes(n.name))}function Ha(e){return e.some(r=>r.hasConflict)}function ut(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function Ai(e){return e==null}function Ua(e){return(r,n,i)=>{const s=Ai(r),a=Ai(n);if(s&&a)return 0;if(s)return 1;if(a)return-1;let l=0;switch(e){case"number":const d=Number(r),u=Number(n);l=d-u;break;case"boolean":l=(r?1:0)-(n?1:0);break;case"string":l=String(r).localeCompare(String(n));break;case"array":case"object":l=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:l=String(r).localeCompare(String(n));break}return i==="asc"?l:-l}}function hi(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 l of i){const d=r.find(b=>b.name===l.column);if(!d)continue;const g=Ua(d.type)(s[l.column],a[l.column],l.direction);if(g!==0)return g}return 0})}function Ga(e){return e===null?"asc":e==="asc"?"desc":null}function Ya(e){return e==="string"||e==="boolean"||e==="number"||e==="date"||e==="mixed"}function qa(e){return e.filter(r=>Ya(r.type))}function Ja(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,l)=>a+l,0))}}),n}function Ka(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=fi(e,n.levels,r);return Ms(i,n.collapsedGroups||[])}function fi(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,l=new Map;e.forEach(g=>{const b=g[a],x=b==null?"(empty)":String(b);l.has(x)||l.set(x,[]),l.get(x).push(g)});const d=[];return Array.from(l.keys()).sort().forEach(g=>{const b=l.get(g),x=`${a}:${g}`,S=i?`${i}|${x}`:x,y=Ja(b,n),I=s<r.length-1?fi(b,r,n,S,s+1):b,C={key:S,level:s,column:a,value:g,rowCount:b.length,aggregates:y,children:I};d.push(C)}),d}function Ms(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&&Ms(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 Wi(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=fi(e,n.levels,r),s=[],a=l=>{for(const d of l)"key"in d&&"level"in d&&"children"in d&&(s.push(d.key),a(d.children))};return a(i),s}function Xa(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function As(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Qa(e,r,n){const i=r?ut(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function po(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Qe(e){return"children"in e}function Pt(){return{id:po(),operator:"and",children:[]}}function Ue(e){return e?Array.isArray(e)?{id:po(),operator:"and",children:e.map(r=>({...r,id:r.id??po()}))}:e:Pt()}function Et(e){return e?Qe(e)?e.children.reduce((r,n)=>r+Et(n),0):1:0}function nn(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=nn(n,r);if(i)return i}}}function ho(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>Qe(i)?ho(i,r,n):i)}}function mi(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!Qe(i)?{...i,...n}:Qe(i)?mi(i,r,n):i)}}function xi(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>Qe(i)?xi(i,r,n):i)}}function gi(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>Qe(i)?gi(i,r):i).filter(i=>!Qe(i)||i.children.length>0);return{...e,children:n}}function ii(e,r){return e?Qe(e)?e.children.some(n=>ii(n,r)):e.column===r:!1}function Ws(e,r){const n=e.children.filter(i=>Qe(i)||i.column!==r).map(i=>Qe(i)?Ws(i,r):i).filter(i=>!Qe(i)||i.children.length>0);return{...e,children:n}}function Rs(e){return e?Qe(e)?e.children.flatMap(Rs):[e]:[]}function Mo(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(Mo)}}function To(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 yi(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=[],l=new Set(i),d=new Set(s);let u=0;for(const g of n)l.has(g)?a.push(g):d.has(g)&&u<s.length?(a.push(s[u]),u++):d.has(g)||a.push(g);for(let g=u;g<s.length;g++)a.includes(s[g])||a.push(s[g]);return a}return[...e]}function Yn(e){const r={},n=[],i={};return e.forEach(s=>{r[s.name]=!0,n.push(s.name),i[s.name]=170}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:Pt(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Za(e,r,n,i,s,a,l,d){const u={},g=[],b={};n.forEach(y=>{u[y.name]=!0,g.push(y.name),b[y.name]=170});const S=yi(s||g,l||null,d||g);return{filters:Ue(e),sortStack:r||[],columnVisibility:i||u,columnOrder:S,columnWidths:a||b,grouping:l||null}}function el(e,r){const n=y=>{if(y==null)return y;if(Array.isArray(y))return y.map(I=>n(I));if(typeof y=="object"){const I={};return Object.keys(y).sort().forEach(C=>{I[C]=n(y[C])}),I}return y},i=y=>JSON.stringify(n(y));if(i(Mo(e.filters))!==i(Mo(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 l=yi(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),d=[...l].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(d!==u)return!1;const g=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==g){if(l.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const y=[...l].sort().join(",");if(l.join(",")!==y)return!0}const x=e.columnWidths??{},S=r.columnWidths??{};return i(x)!==i(S)||i(e.grouping)!==i(r.grouping)}function tl(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function rl(e,r){var C,m,j;const n=[],i=JSON.stringify(Mo(e.filters)),s=JSON.stringify(Mo(r.filters));if(i!==s){const h=Et(e.filters),k=Et(r.filters);h>k?n.push({category:"filters",label:"Filters Added",description:`${h-k} new filter${h-k>1?"s":""} added`}):h<k?n.push({category:"filters",label:"Filters Removed",description:`${k-h} filter${k-h>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const a=JSON.stringify(e.sortStack),l=JSON.stringify(r.sortStack);if(a!==l){const h=e.sortStack.length,k=r.sortStack.length;h>k?n.push({category:"sorting",label:"Sorting Added",description:`${h-k} new sort rule${h-k>1?"s":""} added`}):h<k?n.push({category:"sorting",label:"Sorting Removed",description:`${k-h} sort rule${k-h>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const d=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(d!==u){const h=Object.values(e.columnVisibility).filter(T=>T).length,k=Object.values(r.columnVisibility).filter(T=>T).length;h>k?n.push({category:"visibility",label:"Columns Shown",description:`${h-k} column${h-k>1?"s":""} made visible`}):h<k?n.push({category:"visibility",label:"Columns Hidden",description:`${k-h} column${k-h>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const g=JSON.stringify(e.columnOrder),b=JSON.stringify(r.columnOrder);g!==b&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const x=JSON.stringify(e.columnWidths),S=JSON.stringify(r.columnWidths);if(x!==S){const h=Object.keys(e.columnWidths).filter(k=>e.columnWidths[k]!==r.columnWidths[k]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${h} column width${h>1?"s":""} modified`})}const y=JSON.stringify(e.grouping),I=JSON.stringify(r.grouping);if(y!==I){const h=(C=e.grouping)==null?void 0:C.enabled,k=(m=r.grouping)==null?void 0:m.enabled;if(h&&!k){const T=((j=e.grouping)==null?void 0:j.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${T} grouping level${T>1?"s":""} added`})}else!h&&k?n.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):n.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return n}function Ri(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Pi(e){return`[${e}]`}const Jt={warn(e,r,...n){Ri()&&console.warn(Pi(e),r,...n)},error(e,r,...n){Ri()&&console.error(Pi(e),r,...n)}},Ps="urm_report_";function ol(e,r){try{const n=`${Ps}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Jt.error("urm:persistence","Failed to save report state",n)}}function nl(e){try{const r=`${Ps}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Jt.error("urm:persistence","Failed to load report state",r),null}}function Wo(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 l=s.children[0];if(il(l)){const d=s.children,u=Wo(d,r,n+1);i.push(...u)}else{const d=s.children;for(const u of d)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function il(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 mn(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function xn(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0"),l=`${i}-${s}-${a}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${l}.${r}`}function an(e,r,n,i,s,a,l){let d,u;a?(d={...a},u=l||r.map(b=>b.name)):s?(d={...s.snapshot.columnVisibility},u=l||[...s.snapshot.columnOrder]):(d={},u=[],r.forEach(b=>{d[b.name]=!0,u.push(b.name)}));const g=Object.entries(d).filter(([b,x])=>!x).map(([b,x])=>b);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:d,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:g,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function ln(e,r="export",n){const{data:i,columnOrder:s,grouping:a}=e,l=s.filter(x=>e.columnVisibility[x]);let d;if(a&&a.enabled){const x=a.collapsedGroups??[],S=Wo(i,x);d=mn(S)}else d=i;const u=l.join(","),g=d.map(x=>l.map(S=>{const y=x[S];if(y==null)return"";const I=String(y);return I.includes(",")||I.includes('"')||I.includes(`
|
|
2
|
-
`)?`"${
|
|
3
|
-
`);
|
|
1
|
+
"use strict";var wa=Object.defineProperty;var Ca=(e,r,n)=>r in e?wa(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var _i=(e,r,n)=>Ca(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),h=require("react"),ja=require("xlsx"),_=require("@mui/icons-material"),o=require("@mui/material"),Es=require("react-dom"),ka=require("@emotion/react"),ur=require("react-dnd"),fi=require("react-dnd-html5-backend");function Ds(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 xn=Ds(h),Qo=Ds(ja),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}},_s="urm_dev_config";function za(){try{const e=localStorage.getItem(_s);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 Ta(e){try{localStorage.setItem(_s,JSON.stringify(e))}catch{}}function Ba(e,r,n){if(!n||!r)return e;const i={sort:{...e.sort,...r.sort},filter:{...e.filter,...r.filter},columns:{...e.columns,...r.columns},grouping:{...e.grouping,...r.grouping},export:{...e.export,...r.export},views:{...e.views,...r.views},dates:{...e.dates,...r.dates},display:{...e.display,...r.display}};return i.sort.maxLevels=Math.min(5,Math.max(1,i.sort.maxLevels)),i}const Ia=/^\d{4}-\d{2}-\d{2}$/,Ea=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Da=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,_a=9783072e5,$a=41024448e5,Oa=978307200,Ma=4102444800;function Aa(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=_a&&e<=$a?"timestamp_ms":Number.isInteger(e)&&e>=Oa&&e<=Ma?"timestamp_s":"unknown":typeof e!="string"?"unknown":Ea.test(e)||Ia.test(e)?"iso":Da.test(e.trim())?"locale_string":"unknown"}function Wa(e,r){const n=r.map(l=>l[e]).filter(l=>l!=null&&l!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const l of n){const d=Aa(l);i[d]++}const s=n.length,a=.7;for(const l of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[l]/s>=a)return l;return"unknown"}function Ra(e,r){if(e==null||e==="")return null;try{switch(r){case"timestamp_ms":{const n=new Date(Number(e));return isNaN(n.getTime())?null:n}case"timestamp_s":{const n=new Date(Number(e)*1e3);return isNaN(n.getTime())?null:n}case"iso":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}case"locale_string":{const n=new Date(String(e));return isNaN(n.getTime())?null:n}default:return null}}catch{return null}}const $i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Pa=["January","February","March","April","May","June","July","August","September","October","November","December"];function Je(e){return String(e).padStart(2,"0")}function Na(e){const r=Date.now()-e.getTime(),n=Math.abs(r),i=r>0,s=Math.floor(n/1e3),a=Math.floor(s/60),l=Math.floor(a/60),d=Math.floor(l/24),u=Math.floor(d/7),g=Math.floor(d/30),b=Math.floor(d/365);let f;return s<60?f="just now":a<60?f=`${a} minute${a!==1?"s":""}`:l<24?f=`${l} hour${l!==1?"s":""}`:d<7?f=`${d} day${d!==1?"s":""}`:u<5?f=`${u} week${u!==1?"s":""}`:g<12?f=`${g} month${g!==1?"s":""}`:f=`${b} year${b!==1?"s":""}`,s<60?f:i?`${f} ago`:`in ${f}`}function La(e,r){const n=e.getFullYear(),i=e.getMonth(),s=e.getDate(),a=e.getHours(),l=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${Je(i+1)}-${Je(s)}`;case"DD/MM/YYYY":return`${Je(s)}/${Je(i+1)}/${n}`;case"MM/DD/YYYY":return`${Je(i+1)}/${Je(s)}/${n}`;case"MMM DD, YYYY":return`${$i[i]} ${Je(s)}, ${n}`;case"DD MMM YYYY":return`${Je(s)} ${$i[i]} ${n}`;case"MMMM D, YYYY":return`${Pa[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Je(i+1)}-${Je(s)} ${Je(a)}:${Je(l)}`;case"DD/MM/YYYY HH:mm":return`${Je(s)}/${Je(i+1)}/${n} ${Je(a)}:${Je(l)}`;case"MM/DD/YYYY HH:mm":return`${Je(i+1)}/${Je(s)}/${n} ${Je(a)}:${Je(l)}`;case"relative":return Na(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function Fa(e,r,n){if(!n||r==="unknown")return String(e);const i=Ra(e,r);return!i||isNaN(i.getTime())?String(e):La(i,n)}function Va(e){return e==null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?"number":typeof e=="boolean"?"boolean":typeof e=="string"?"string":"mixed"}function $s(e,r="",n=0){if(n>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const a=r?`${r}.${s}`:s,l=e[s];l!==null&&typeof l=="object"&&!Array.isArray(l)&&n<2?Object.assign(i,$s(l,a,n+1)):i[a]=l}return i}function po(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:$s(r))}function To(e){if(!Array.isArray(e)||e.length===0)return[];const r=po(e),n=new Set;r.forEach(l=>{typeof l=="object"&&l!==null&&Object.keys(l).forEach(d=>n.add(d))});const i=[];n.forEach(l=>{const d=new Set;let u=0;r.forEach(S=>{typeof S=="object"&&S!==null&&l in S&&(u++,d.add(Va(S[l])))});const g=u===r.length,b=d.size>1&&!d.has("null");let f="mixed";if(d.size===1)f=Array.from(d)[0];else if(d.size===2&&d.has("null")){const S=Array.from(d).filter(y=>y!=="null");S.length===1&&(f=S[0])}i.push({name:l,type:f,required:g,hasConflict:b})});const a=r.slice(0,50);for(const l of i){if(l.type!=="string"&&l.type!=="number")continue;const d=Wa(l.name,a);d!=="unknown"&&(l.type="date",l.dateFormat=d)}return i}function Oi(e,r){return!r||r.length===0?e:e.filter(n=>!r.includes(n.name))}function Ha(e){return e.some(r=>r.hasConflict)}function ut(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return n.charAt(0).toUpperCase()+n.slice(1)}function Mi(e){return e==null}function Ua(e){return(r,n,i)=>{const s=Mi(r),a=Mi(n);if(s&&a)return 0;if(s)return 1;if(a)return-1;let l=0;switch(e){case"number":const d=Number(r),u=Number(n);l=d-u;break;case"boolean":l=(r?1:0)-(n?1:0);break;case"string":l=String(r).localeCompare(String(n));break;case"array":case"object":l=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:l=String(r).localeCompare(String(n));break}return i==="asc"?l:-l}}function xi(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 l of i){const d=r.find(b=>b.name===l.column);if(!d)continue;const g=Ua(d.type)(s[l.column],a[l.column],l.direction);if(g!==0)return g}return 0})}function Ga(e){return e===null?"asc":e==="asc"?"desc":null}function Ya(e){return e==="string"||e==="boolean"||e==="number"||e==="date"||e==="mixed"}function qa(e){return e.filter(r=>Ya(r.type))}function Ja(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,l)=>a+l,0))}}),n}function Os(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=gi(e,n.levels,r);return Ms(i,n.collapsedGroups||[])}function gi(e,r,n,i="",s=0){if(s>=r.length)return e;const a=r[s].column,l=new Map;e.forEach(g=>{const b=g[a],f=b==null?"(empty)":String(b);l.has(f)||l.set(f,[]),l.get(f).push(g)});const d=[];return Array.from(l.keys()).sort().forEach(g=>{const b=l.get(g),f=`${a}:${g}`,S=i?`${i}|${f}`:f,y=Ja(b,n),E=s<r.length-1?gi(b,r,n,S,s+1):b,j={key:S,level:s,column:a,value:g,rowCount:b.length,aggregates:y,children:E};d.push(j)}),d}function Ms(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&&Ms(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 Ai(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=gi(e,n.levels,r),s=[],a=l=>{for(const d of l)"key"in d&&"level"in d&&"children"in d&&(s.push(d.key),a(d.children))};return a(i),s}function Ka(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function As(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Xa(e,r,n){const i=r?ut(r):"",s=String(n??"");return i?`${i}: ${s}`:s}function mo(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Qe(e){return"children"in e}function Rt(){return{id:mo(),operator:"and",children:[]}}function Ge(e){return e?Array.isArray(e)?{id:mo(),operator:"and",children:e.map(r=>({...r,id:r.id??mo()}))}:e:Rt()}function Tt(e){return e?Qe(e)?e.children.reduce((r,n)=>r+Tt(n),0):1:0}function an(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=an(n,r);if(i)return i}}}function fo(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>Qe(i)?fo(i,r,n):i)}}function yi(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!Qe(i)?{...i,...n}:Qe(i)?yi(i,r,n):i)}}function bi(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>Qe(i)?bi(i,r,n):i)}}function vi(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>Qe(i)?vi(i,r):i).filter(i=>!Qe(i)||i.children.length>0);return{...e,children:n}}function li(e,r){return e?Qe(e)?e.children.some(n=>li(n,r)):e.column===r:!1}function Ws(e,r){const n=e.children.filter(i=>Qe(i)||i.column!==r).map(i=>Qe(i)?Ws(i,r):i).filter(i=>!Qe(i)||i.children.length>0);return{...e,children:n}}function Rs(e){return e?Qe(e)?e.children.flatMap(Rs):[e]:[]}function Ro(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(Ro)}}function Do(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 Si(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=[],l=new Set(i),d=new Set(s);let u=0;for(const g of n)l.has(g)?a.push(g):d.has(g)&&u<s.length?(a.push(s[u]),u++):d.has(g)||a.push(g);for(let g=u;g<s.length;g++)a.includes(s[g])||a.push(s[g]);return a}return[...e]}function Kn(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:Rt(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Qa(e,r,n,i,s,a,l,d){const u={},g=[],b={};n.forEach(y=>{u[y.name]=!0,g.push(y.name),b[y.name]=170});const S=Si(s||g,l||null,d||g);return{filters:Ge(e),sortStack:r||[],columnVisibility:i||u,columnOrder:S,columnWidths:a||b,grouping:l||null}}function Za(e,r){const n=y=>{if(y==null)return y;if(Array.isArray(y))return y.map(E=>n(E));if(typeof y=="object"){const E={};return Object.keys(y).sort().forEach(j=>{E[j]=n(y[j])}),E}return y},i=y=>JSON.stringify(n(y));if(i(Ro(e.filters))!==i(Ro(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 l=Si(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),d=[...l].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(d!==u)return!1;const g=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==g){if(l.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const y=[...l].sort().join(",");if(l.join(",")!==y)return!0}const f=e.columnWidths??{},S=r.columnWidths??{};return i(f)!==i(S)||i(e.grouping)!==i(r.grouping)}function el(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function tl(e,r){var j,m,w;const n=[],i=JSON.stringify(Ro(e.filters)),s=JSON.stringify(Ro(r.filters));if(i!==s){const x=Tt(e.filters),C=Tt(r.filters);x>C?n.push({category:"filters",label:"Filters Added",description:`${x-C} new filter${x-C>1?"s":""} added`}):x<C?n.push({category:"filters",label:"Filters Removed",description:`${C-x} filter${C-x>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const a=JSON.stringify(e.sortStack),l=JSON.stringify(r.sortStack);if(a!==l){const x=e.sortStack.length,C=r.sortStack.length;x>C?n.push({category:"sorting",label:"Sorting Added",description:`${x-C} new sort rule${x-C>1?"s":""} added`}):x<C?n.push({category:"sorting",label:"Sorting Removed",description:`${C-x} sort rule${C-x>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const d=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(d!==u){const x=Object.values(e.columnVisibility).filter(B=>B).length,C=Object.values(r.columnVisibility).filter(B=>B).length;x>C?n.push({category:"visibility",label:"Columns Shown",description:`${x-C} column${x-C>1?"s":""} made visible`}):x<C?n.push({category:"visibility",label:"Columns Hidden",description:`${C-x} column${C-x>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const g=JSON.stringify(e.columnOrder),b=JSON.stringify(r.columnOrder);g!==b&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const f=JSON.stringify(e.columnWidths),S=JSON.stringify(r.columnWidths);if(f!==S){const x=Object.keys(e.columnWidths).filter(C=>e.columnWidths[C]!==r.columnWidths[C]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${x} column width${x>1?"s":""} modified`})}const y=JSON.stringify(e.grouping),E=JSON.stringify(r.grouping);if(y!==E){const x=(j=e.grouping)==null?void 0:j.enabled,C=(m=r.grouping)==null?void 0:m.enabled;if(x&&!C){const B=((w=e.grouping)==null?void 0:w.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${B} grouping level${B>1?"s":""} added`})}else!x&&C?n.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):n.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return n}function Wi(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Ri(e){return`[${e}]`}const Qt={warn(e,r,...n){Wi()&&console.warn(Ri(e),r,...n)},error(e,r,...n){Wi()&&console.error(Ri(e),r,...n)}},Ps="urm_report_";function rl(e,r){try{const n=`${Ps}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Qt.error("urm:persistence","Failed to save report state",n)}}function ol(e){try{const r=`${Ps}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Qt.error("urm:persistence","Failed to load report state",r),null}}function gn(e,r,n){return!n||!n.enabled?e:(e.some(a=>a&&a.isGroupHeader===!0)?e:Os(e,r,n)).filter(a=>!a.isGroupHeader)}function yn(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0"),l=`${i}-${s}-${a}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${l}.${r}`}function cn(e,r,n,i,s,a,l){let d,u;a?(d={...a},u=l||r.map(b=>b.name)):s?(d={...s.snapshot.columnVisibility},u=l||[...s.snapshot.columnOrder]):(d={},u=[],r.forEach(b=>{d[b.name]=!0,u.push(b.name)}));const g=Object.entries(d).filter(([b,f])=>!f).map(([b,f])=>b);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:d,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:g,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function dn(e,r="export",n){const{data:i,schema:s,columnOrder:a,grouping:l}=e,d=a.filter(S=>e.columnVisibility[S]),u=gn(i,s,l),g=d.join(","),b=u.map(S=>d.map(y=>{const E=S[y];if(E==null)return"";const j=String(E);return j.includes(",")||j.includes('"')||j.includes(`
|
|
2
|
+
`)?`"${j.replace(/"/g,'""')}"`:j}).join(",")),f=[g,...b].join(`
|
|
3
|
+
`);wi(f,yn(r,"csv"),"text/csv;charset=utf-8;")}function un(e,r="export",n){const{data:i,schema:s,columnOrder:a,grouping:l}=e,d=a.filter(S=>e.columnVisibility[S]),u=gn(i,s,l),g=[d,...u.map(S=>d.map(y=>S[y]??""))],b=Qo.utils.aoa_to_sheet(g),f=Qo.utils.book_new();Qo.utils.book_append_sheet(f,b,"Data"),Qo.writeFile(f,yn(r,"xlsx"))}function pn(e,r="export",n){const{data:i,schema:s,appliedFilters:a,appliedSortStack:l,viewMeta:d,hiddenColumns:u,columnOrder:g,grouping:b}=e,f=g.filter(j=>e.columnVisibility[j]);let S=gn(i,s,b);S=S.map(j=>{const m={};return f.forEach(w=>{m[w]=j[w]}),m});const y={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(d==null?void 0:d.name)||"Default View",filters:Rs(a).map(j=>({field:j.column,operator:j.operator,value:j.value})),sortStack:l.map(j=>({field:j.column,direction:j.direction,priority:j.priority})),grouping:b||{},hiddenColumns:u,columnOrder:g,exportConfig:n||{scope:"visible"}},data:S},E=JSON.stringify(y,null,2);wi(E,yn(r,"json"),"application/json;charset=utf-8;")}function wi(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 Ci(e,r="export",n){var m;const{data:i,schema:s,columnOrder:a,grouping:l}=e,d=a.filter(w=>e.columnVisibility[w]),u=gn(i,s,l),g=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),b=d.map(w=>`<th>${Zo(w)}</th>`).join(""),f=u.map((w,x)=>{const C=d.map(B=>{const p=w[B],A=p==null?"":String(p);return`<td>${Zo(A)}</td>`}).join("");return`<tr class="${x%2===0?"even":"odd"}">${C}</tr>`}).join(""),S=`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8" />
|
|
7
|
-
<title>${
|
|
7
|
+
<title>${Zo(r)}</title>
|
|
8
8
|
<style>
|
|
9
9
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
10
10
|
body {
|
|
@@ -82,15 +82,15 @@
|
|
|
82
82
|
</head>
|
|
83
83
|
<body>
|
|
84
84
|
<div class="report-header">
|
|
85
|
-
<div class="report-title">${
|
|
85
|
+
<div class="report-title">${Zo(r)}</div>
|
|
86
86
|
<div class="report-meta">
|
|
87
|
-
${
|
|
88
|
-
Generated ${
|
|
87
|
+
${u.length.toLocaleString()} row${u.length!==1?"s":""}<br/>
|
|
88
|
+
Generated ${g}
|
|
89
89
|
</div>
|
|
90
90
|
</div>
|
|
91
91
|
<table>
|
|
92
|
-
<thead><tr>${
|
|
93
|
-
<tbody>${
|
|
92
|
+
<thead><tr>${b}</tr></thead>
|
|
93
|
+
<tbody>${f}</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 j=((C=m.contentWindow)==null?void 0:C.document)||m.contentDocument;if(j){j.open(),j.write(x),j.close(),setTimeout(()=>{var h,k;try{(h=m.contentWindow)==null||h.focus(),(k=m.contentWindow)==null||k.print()}catch{}setTimeout(()=>{document.body.removeChild(m)},3e3)},300);return}}catch{}const S=new Blob([x],{type:"text/html;charset=utf-8;"}),y=URL.createObjectURL(S);window.open(y,"_blank")||bi(x,xn(r,"html"),"text/html;charset=utf-8;")}function Xo(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ni=10;function sl(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>Ni&&(s=[...s].sort((l,d)=>l.isFavourite&&!d.isFavourite?-1:!l.isFavourite&&d.isFavourite?1:d.lastUsed-l.lastUsed).slice(0,Ni)),s}function al(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function ll(e,r){return e.filter(n=>n.query!==r)}function cl(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 dl={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 ul(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function Bt(e,r){return dl[r].includes(e)}function Tt(e){return`You do not have permission to ${{view_report:"view this report",edit_columns:"modify columns",edit_filters:"modify filters",edit_sorting:"modify sorting",edit_views:"edit views",create_views:"create views",delete_views:"delete views",delete_report:"delete this report",export_data:"export data",promote_global_view:"promote views to global"}[e]||"perform this action"}.`}function pl(e){return e==="viewer"}const Li=1e3;function si(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function qt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return si(n)}const hl={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 fl(e){if(!e||!e.column)return"a filter";const r=qt(e.column),n=hl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function qn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":fl(e):"a filter"}function Fi(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${qt(n.column)}"`).join(", ")}`}function ml(e){var s,a,l;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${qn(i)}`};case"filter_removed":return{summary:`Filter removed: ${qn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const d=n,u=i;return d!=null&&d.column&&(u!=null&&u.column)&&d.column!==u.column?{summary:`Filter changed on "${qt(u.column)}"`,detail:`Previously filtered "${qt(d.column)}"`}:{summary:`Filter updated: ${qn(u)}`}}case"filter_cleared":{const d=n&&typeof n=="object"&&"count"in n?n.count:0;return{summary:d>0?`All filters cleared (${d} filter${d!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const d=i!=null&&i.column?qt(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:d?`Sort added: "${d}" ${u}`:"Sort level added"}}case"sort_level_removed":{const d=n!=null&&n.column?qt(n.column):"";return{summary:d?`Sort removed: "${d}"`:"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: ${Fi(i)}`};case"group_level_removed":{const d=n,u=(a=(s=d==null?void 0:d.levels)==null?void 0:s[0])!=null&&a.column?qt(d.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Fi(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const d=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:d?`Column hidden: "${qt(d)}"`:"Column hidden"}}case"column_shown":{const d=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:d?`Column shown: "${qt(d)}"`:"Column made visible"}}case"column_reordered":{const d=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return d.length>0&&u.length>0?{summary:"Column order changed",detail:`${u.length} column${u.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const d=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:d?`Column resized: "${qt(d)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const d=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:d?`View created: "${d}"`:"New view created"}}case"view_updated":{const d=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:d?`View updated: "${d}"`:"View updated"}}case"view_deleted":{const d=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:d?`View deleted: "${d}"`:"View deleted"}}case"view_set_default":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Default view set to "${d}"`:"Default view changed"}}case"view_switched":{const d=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return d&&u?{summary:`Switched to view "${u}"`,detail:`From "${d}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":case"export_pdf":{const d=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",u=i==null?void 0:i.rowCount,g=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",b=(i==null?void 0:i.viewName)??"",x=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${d}${x}`,detail:b?`${si(g)} · View: "${b}"`:si(g)}}case"export_triggered":{const d=((l=i==null?void 0:i.format)==null?void 0:l.toUpperCase())??"";return{summary:d?`Export triggered: ${d}`:"Export triggered"}}case"preset_created":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Preset created: "${d}"`:"New preset created"}}case"preset_applied":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Preset applied: "${d}"`:"Preset applied"}}case"preset_deleted":{const d=(n==null?void 0:n.name)??"";return{summary:d?`Preset deleted: "${d}"`:"Preset deleted"}}case"preset_link_copied":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Preset link copied: "${d}"`:"Preset link copied to clipboard"}}case"row_edited":{const d=(i==null?void 0:i.id)??(n==null?void 0:n.id)??"",u=(i==null?void 0:i.label)??(n==null?void 0:n.label)??(d?`#${d}`:"");return{summary:u?`Row edited: "${u}"`:"Row edited"}}case"row_deleted":{const d=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(d?`#${d}`:"");return{summary:u?`Row deleted: "${u}"`:"Row deleted"}}case"row_duplicated":{const d=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(d?`#${d}`:"");return{summary:u?`Row duplicated: "${u}"`:"Row duplicated"}}case"theme_changed":{const d=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return d&&u?{summary:`Theme changed from "${d}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const d=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:d?`Details: ${String(d).slice(0,120)}`:void 0}}default:return{summary:gl(r)}}}function xl(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function _o(e,r,n,i,s,a){return{id:xl(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function $o(e,r){const n=[r,...e];return n.length>Li?n.slice(0,Li):n}function gl(e){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",export_pdf:"Exported as PDF",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",error_occurred:"Error Occurred"}[e]||e}function Jn(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",rows:"Rows",system:"System"}[e]||e}function yl(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),a=Math.floor(i/36e5),l=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`:l<7?`${l} day${l>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Vi=100;function bl(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function vl(e){var a;const r=(a=e.views)==null?void 0:a.find(l=>l.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=yi(i,e.grouping||null,n);return{filters:Ue(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 Sl(e,r,n,i){return{id:bl(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function wl(e,r){const n=e||[];if(n.length>=Vi)throw new Error(`Maximum of ${Vi} presets reached. Please delete old presets first.`);return[...n,r]}function Cl(e,r){return(e||[]).filter(i=>i.id!==r)}function Hi(e,r){if(e)return e.find(n=>n.id===r)}function jl(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function kl(e){const r=e.columnOrder,n=To(r,e.grouping);return{filters:Ue(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 zl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Jt.warn("urm:presets","Clipboard API blocked, using fallback method",r)}try{const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.width="2em",r.style.height="2em",r.style.padding="0",r.style.border="none",r.style.outline="none",r.style.boxShadow="none",r.style.background="transparent",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();let n=!1;try{n=document.execCommand("copy")}catch(i){Jt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Jt.error("urm:presets","Fallback copy method failed",r),!1}}function Bl(e,r){return{totalRows:e.length,totalColumns:r.length}}function vr(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:Tl(e,r)};return process.env.NODE_ENV==="development"&&Jt.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function Tl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function Il(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 El(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 Dl(e,r,n){n(e.id,{filters:Ue(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function _l(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 Ns(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 Ls(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(a=>a.name)),i=[],s=[];return e.levels.forEach(a=>{n.has(a.column)?i.push(a):s.push(a.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...e,levels:i},invalidColumns:s}}function $l(e,r){const n=[],i=new Set(r.map(a=>a.name)),s={...e};if(s.filters){const a=l=>{const d=l.children.filter(u=>{if(Qe(u))return!0;const g=i.has(u.column);return g||n.push(`Filter for column "${u.column}" ignored (column not found)`),g}).map(u=>Qe(u)?a(u):u).filter(u=>!Qe(u)||u.children.length>0);return{...l,children:d}};s.filters=a(Ue(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:l}=Ns(s.sortStack,r);l.length>0&&n.push(`Sort rules for columns ignored: ${l.join(", ")}`),s.sortStack=a.length>0?a:void 0}if(s.grouping){const{validGrouping:a,invalidColumns:l}=Ls(s.grouping,r);l.length>0&&n.push(`Grouping for columns ignored: ${l.join(", ")}`),s.grouping=a}if(s.columnVisibility){const a={};Object.entries(s.columnVisibility).forEach(([l,d])=>{i.has(l)?a[l]=d:n.push(`Column visibility for "${l}" 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(l=>{const d=i.has(l);return d||n.push(`Column "${l}" in order ignored (column not found)`),d});s.columnOrder=a.length>0?a:void 0}if(s.columnWidths){const a={};Object.entries(s.columnWidths).forEach(([l,d])=>{i.has(l)?a[l]=d:n.push(`Column width for "${l}" ignored (column not found)`)}),s.columnWidths=Object.keys(a).length>0?a:void 0}return{sanitizedConfig:s,warnings:n}}function Ol(e,r){return vr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Ui(e,r,n,i){const s=_o(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return $o(i||[],s)}function Ml(e){return e==null}function Al(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(Ml(e))return!1;if(n==="date"){const a=new Date(e).getTime(),l=new Date(s).getTime();switch(i){case"equals":return a===l;case"gt":return a>l;case"lt":return a<l;case"gte":return a>=l;case"lte":return a<=l;default:return!0}}switch(i){case"equals":return String(e).toLowerCase()===String(s).toLowerCase();case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function ai(e,r,n){var s;if(Qe(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>ai(e,a,n)):r.children.some(a=>ai(e,a,n));const i=((s=n.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return Al(e[r.column],r,i)}function Si(e,r,n){return!r||r.children.length===0?e:e.filter(i=>ai(i,r,n))}function un(e){switch(e){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"date":return[{value:"equals",label:"Is"},{value:"gt",label:"After"},{value:"lt",label:"Before"},{value:"gte",label:"On or after"},{value:"lte",label:"On or before"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function Wl(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Rl({data:e,filters:r,schema:n}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:Si(e,r,n),[e,r,n])}}function Pl(e,r){const n=e.length+1,i=r.length+1,s=Array.from({length:n},()=>new Array(i).fill(0));for(let a=0;a<n;a+=1)s[a][0]=a;for(let a=0;a<i;a+=1)s[0][a]=a;for(let a=1;a<n;a+=1)for(let l=1;l<i;l+=1){const d=e[a-1]===r[l-1]?0:1;s[a][l]=Math.min(s[a-1][l]+1,s[a][l-1]+1,s[a-1][l-1]+d)}return s[n-1][i-1]}function Nl(e,r){const n=e.split(/\s+/).filter(Boolean);return r.some(i=>{const s=i.length<=5?1:2;return n.some(a=>Pl(i,a)<=s)})}function Ll(e,r,n,i){if(!n||n.trim()==="")return e;const s=n.toLowerCase().trim(),a=s.split(/\s+/).filter(Boolean),l=r.filter(d=>i.includes(d.name));return e.filter(d=>l.some(u=>{const g=d[u.name];if(g==null)return!1;const b=String(g).toLowerCase();return b.includes(s)?!0:Nl(b,a)}))}function Fl({data:e,searchQuery:r,schema:n,visibleColumns:i,mode:s="client"}){return{searchedData:p.useMemo(()=>s==="server"||!r||r.trim()===""?e:Ll(e,n,r,i),[e,r,n,i,s])}}function Vl({data:e,sortStack:r,schema:n}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:hi(e,n,r),[e,r,n])}}function Hl({data:e,grouping:r,schema:n}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:Ka(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 Ul({schema:e,columnVisibility:r,columnOrder:n}){const i=p.useMemo(()=>n.filter(d=>r[d]!==!1),[n,r]),s=p.useMemo(()=>Object.entries(r).filter(([d,u])=>!u).map(([d,u])=>d),[r]),a=p.useMemo(()=>n.map(d=>e.find(g=>g.name===d)||{name:d,type:"string"}),[n,e]),l=p.useMemo(()=>i.map(d=>e.find(g=>g.name===d)||{name:d,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:l,hiddenCount:s.length}}function Gl({views:e,activeViewId:r,currentState:n}){const i=p.useMemo(()=>e.find(g=>g.id===r),[e,r]),s=p.useMemo(()=>i?el(n,i.snapshot):!1,[i,n]),a=p.useMemo(()=>e.find(g=>g.isDefault),[e]),l=p.useMemo(()=>e.filter(g=>!g.isDefault&&!g.isDeleted),[e]),d=p.useMemo(()=>e.filter(g=>g.isFavorite&&!g.isDeleted),[e]),u=p.useMemo(()=>e.filter(g=>g.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:l,favoriteViews:d,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Yl(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),l=a?s.groupLevel??0:s.__urm_group_level__??0;if(l===0&&a)return i;const d=l-1;if(d<0)return i;const u={};let g=d+1;for(let I=r-1;I>=0;I--){const C=e[I];if(C.__isGroupHeader||C.isGroupHeader){const m=C.groupLevel??0;if(m<=d&&u[m]===void 0&&(u[m]=C,g--,g<=0))break}}const b=[];for(let I=0;I<=d;I++)u[I]&&b.push({...u[I],__urm_is_continuation_header__:!0});const x=Math.max(0,n-r-b.length),S=r+x,y=e.slice(r,S);return[...b,...y]}function ql({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=p.useState(i),l=e.length,d=Math.max(1,Math.ceil(l/n));p.useEffect(()=>{s>d&&a(d)},[s,d]);const u=p.useMemo(()=>{if(!r)return e;const y=(s-1)*n,I=y+n;return Yl(e,y,I)},[e,r,s,n]),g=p.useCallback(y=>{const I=Math.max(1,Math.min(y,d));a(I)},[d]),b=p.useCallback(()=>{s<d&&a(y=>Math.min(y+1,d))},[d]),x=p.useCallback(()=>{s>1&&a(y=>Math.max(y-1,1))},[]),S=p.useCallback(()=>{a(1)},[]);return{paginatedData:u,currentPage:s,totalPages:d,pageSize:n,totalRows:l,goToPage:g,nextPage:b,prevPage:x,resetPage:S,hasNextPage:s<d,hasPrevPage:s>1}}function Jl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:a,searchQuery:l,searchMode:d,columnVisibility:u,columnOrder:g,columnWidths:b,views:x,activeViewId:S,pagination:y}=e,I=p.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:u,columnOrder:g,columnWidths:b}),[i,s,a,u,g,b]),C=Gl({views:x,activeViewId:S,currentState:I}),m=Ul({schema:n,columnVisibility:u,columnOrder:g}),{filteredData:j}=Rl({data:r,filters:i,schema:n}),{sortedData:h}=Vl({data:j,sortStack:s,schema:n}),{groupedData:k,isGrouped:T}=Hl({data:h,grouping:a,schema:n}),{searchedData:f}=Fl({data:k,searchQuery:l,schema:n,visibleColumns:m.visibleColumns,mode:d}),W=ql({data:f,enabled:(y==null?void 0:y.enabled)||!1,pageSize:(y==null?void 0:y.pageSize)||100,initialPage:(y==null?void 0:y.currentPage)||1}),N=y!=null&&y.enabled?W.paginatedData:f,E=p.useMemo(()=>({totalRows:r.length,filteredRows:j.length,sortedRows:h.length,groupedRows:T?k.length:h.length,searchedRows:f.length,visibleRows:N.length,hiddenColumns:m.hiddenCount,activeFilters:Et(i),activeSorts:s.length,isGrouped:T}),[r.length,j.length,h.length,k.length,f.length,N.length,m.hiddenCount,i,s.length,T]);return{data:N,filteredData:j,sortedData:h,groupedData:k,searchedData:f,viewEngine:C,columnEngine:m,paginationEngine:W,metrics:E,isGrouped:T,isPaginated:(y==null?void 0:y.enabled)||!1}}let Kl=0;function Xl(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):Kl++,writable:!1,enumerable:!1,configurable:!1})}const Rt="user-demo-001";function Ql(e={}){var Jo,Ti,Ii,Ei,Di;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:l,scheduler:d,reportName:u,reportId:g,sharedReportId:b,sharedViewId:x,viewPersistence:S,permissions:y,config:I={},devConfig:C}=e,m=(S==null?void 0:S.mode)??"local",j=(a==null?void 0:a.mode)??"client",h=(l==null?void 0:l.mode)??"client",[k,T]=p.useState([]),f=C??gt,[W,N]=p.useState(""),[E,X]=p.useState(!1),[te,A]=p.useState(!1),[v,O]=p.useState({message:"",severity:"info",open:!1}),B=(z,D="info")=>{O({message:z,severity:D,open:!0})},q=()=>O(z=>({...z,open:!1})),Y=I.notifDurationMs,c=k.find(z=>z.id===W),[re,se]=p.useState("idle"),[V,Z]=p.useState(!1),[ue,le]=p.useState(!1),[Q,pe]=p.useState(!1),[ie,R]=p.useState(!1),[oe,G]=p.useState(!1),[ae,De]=p.useState(void 0),[ee,Ne]=p.useState(null),[Te,$t]=p.useState(null),[Fr,Kt]=p.useState(!1),[Cr,Ot]=p.useState(!1),[pt,Xt]=p.useState(null),[Ze,Mt]=p.useState(!1),[jr,at]=p.useState(!1),[Qt,fo]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[lr,mo]=p.useState(""),[Zt,kr]=p.useState(""),[jt,Je]=p.useState(new Set),[zr,ht]=p.useState(1),[rt,Nt]=p.useState(15),[cr,xo]=p.useState(!1),[Vr,dr]=p.useState(!1),[Ke,Ce]=p.useState(!1),[At,Br]=p.useState(null),[Hr,ur]=p.useState(!1),[Tr,Ur]=p.useState(null),[pr,et]=p.useState(null),Lt=p.useRef(null),Se=p.useMemo(()=>c?ul(c.permissions,Rt):"owner",[c]),Lo=pl(Se),me=p.useMemo(()=>!(c!=null&&c.uploadedData)||!(c!=null&&c.schema)?{totalRows:0,totalColumns:0}:Bl(c.uploadedData,c.schema),[c==null?void 0:c.uploadedData,c==null?void 0:c.schema]),kt=p.useCallback(()=>{c&&(Lt.current=El(c))},[c]),H=p.useCallback((z,D)=>{T(P=>P.map(M=>M.id===z?{...M,...D}:M))},[]),vt=p.useCallback(z=>{if(!c)return;et(z);const D=Ui(c.id,Rt,z,c.auditHistory||[]);H(c.id,{auditHistory:D}),B(z.message,"error"),z.recoverable&&Lt.current&&setTimeout(()=>{Dl(c,Lt.current,H),B("Previous state restored","success")},100)},[c,H]),ce=p.useCallback((z,D,P,M)=>{if(!c)return;const K=_o(c.id,Rt,z,D,P,M),J=c.auditHistory||[],de=$o(J,K);setTimeout(()=>{H(c.id,{auditHistory:de})},0)},[c,H]);p.useEffect(()=>{if(c!=null&&c.schemaLocked&&c.schema&&(!c.views||c.views.length===0)){const z=Yn(c.schema);(()=>{try{const D=localStorage.getItem("urm_dev_config");return D?JSON.parse(D):null}catch{return null}})(),H(c.id,{views:[z],activeViewId:z.id,filters:z.snapshot.filters,sortStack:z.snapshot.sortStack,columnVisibility:z.snapshot.columnVisibility,columnOrder:z.snapshot.columnOrder,columnWidths:z.snapshot.columnWidths,grouping:z.snapshot.grouping})}},[c==null?void 0:c.schemaLocked,c==null?void 0:c.schema,c==null?void 0:c.id,H]),p.useEffect(()=>{if(i&&n&&!te&&k.length===0){const z=co(i),D={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:z,schema:Mi(jo(z),I.hiddenColumns),permissions:y??{owner:Rt,editors:[],viewers:[]}};T([D]),N(D.id),A(!0),se("confirmed")}},[i,n,te,k.length,r,u,g]),p.useEffect(()=>{j!=="server"||!te||!W||H(W,{uploadedData:co(i||[])})},[i,j,te,W]),p.useEffect(()=>{j==="server"&&((a==null?void 0:a.page)!==void 0&&ht(a.page),(a==null?void 0:a.pageSize)!==void 0&&Nt(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,j]),p.useEffect(()=>{if(!s||te)return;let z=!1,D=null;const P=async()=>{try{se("uploading");let M;if(s.type==="api"){const J=await fetch(s.url,{headers:s.headers||{}});if(!J.ok)throw new Error(`HTTP ${J.status}: ${J.statusText}`);M=await J.json()}else M=await s.fetch();if(z)return;if(!Array.isArray(M))throw new Error("Data source must return an array of objects");const K=jo(M);if(te)T(J=>J.map(de=>de.id===W?{...de,uploadedData:co(M)}:de)),se("confirmed");else{const J={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:co(M),schema:Mi(jo(co(M)),I.hiddenColumns),permissions:y??{owner:Rt,editors:[],viewers:[]}};T([J]),N(J.id),A(!0),se("confirmed")}}catch(M){z||(se("error"),c&&H(c.id,{uploadError:(M==null?void 0:M.message)||"Failed to load data from source"}))}};return P(),s.refreshInterval&&s.refreshInterval>0&&(D=setInterval(P,s.refreshInterval)),()=>{z=!0,D&&clearInterval(D)}},[s,u,r,g]);const lt=(Jo=c==null?void 0:c.views)==null?void 0:Jo.find(z=>z.id===c.activeViewId),Ir=p.useMemo(()=>c!=null&&c.uploadedData?(c.uploadedData.forEach(z=>Xl(z,I.getRowId)),c.uploadedData):[],[c==null?void 0:c.uploadedData]);p.useEffect(()=>{Je(z=>{if(z.size===0)return z;const D=new Set(Ir.map(M=>M==null?void 0:M.__urm_row_id__)),P=new Set(Array.from(z).filter(M=>D.has(M==null?void 0:M.__urm_row_id__)));return P.size===z.size?z:P})},[Ir]);const zt=Jl({rawData:Ir,schema:(c==null?void 0:c.schema)||[],filters:Ue(c==null?void 0:c.filters),sortStack:(c==null?void 0:c.sortStack)||[],grouping:(c==null?void 0:c.grouping)||null,searchQuery:Zt||"",searchMode:h,columnVisibility:(c==null?void 0:c.columnVisibility)||(lt==null?void 0:lt.snapshot.columnVisibility)||{},columnOrder:(c==null?void 0:c.columnOrder)||(lt==null?void 0:lt.snapshot.columnOrder)||[],columnWidths:(c==null?void 0:c.columnWidths)||(lt==null?void 0:lt.snapshot.columnWidths)||{},views:(c==null?void 0:c.views)||[],activeViewId:(c==null?void 0:c.activeViewId)||"",pagination:{enabled:j==="client",pageSize:rt,currentPage:zr}}),{data:Gr=[],searchedData:hr=[],groupedData:Er=[],sortedData:Ft=[],metrics:fr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Dr=!1,paginationEngine:we}=zt||{},ft=j==="server"?(a==null?void 0:a.totalRows)??0:Dr?fr.totalRows:fr.searchedRows,mt=j==="server"?Math.max(1,Math.ceil(((a==null?void 0:a.totalRows)??0)/rt)):(we==null?void 0:we.totalPages)??1,U=((Ti=zt.viewEngine)==null?void 0:Ti.activeView)||lt,Oe=((Ii=zt.viewEngine)==null?void 0:Ii.isDirty)||!1;p.useEffect(()=>{if(!(!U||!c)&&!c.columnOrder){const z=U.snapshot.columnOrder,D=To(z,U.snapshot.grouping);H(c.id,{columnOrder:D})}},[c==null?void 0:c.activeViewId]);const Me=p.useMemo(()=>!(c!=null&&c.schema)||!U?null:Za(c.filters,c.sortStack||[],c.schema,c.columnVisibility,c.columnOrder,c.columnWidths,c.grouping,U.snapshot.columnOrder),[c==null?void 0:c.filters,c==null?void 0:c.sortStack,c==null?void 0:c.schema,c==null?void 0:c.columnVisibility,c==null?void 0:c.columnOrder,c==null?void 0:c.columnWidths,c==null?void 0:c.grouping,U]),_r=p.useMemo(()=>!U||!Me||!Oe?[]:rl(Me,U.snapshot),[U,Me,Oe]),$r=p.useCallback((z,D,P)=>{const M={id:`report-${Date.now()}`,name:z,description:D,schemaLocked:!1,permissions:{owner:Rt,editors:[],viewers:[]}};if(P&&Array.isArray(P)&&P.length>0){const K=jo(P),J=Yn(K);M.uploadedData=P,M.schema=K,M.schemaLocked=!0,M.views=[J],M.activeViewId=J.id,M.sortStack=J.snapshot.sortStack,M.filters=J.snapshot.filters,M.columnVisibility=J.snapshot.columnVisibility,M.columnOrder=J.snapshot.columnOrder,M.columnWidths=J.snapshot.columnWidths,M.grouping=J.snapshot.grouping}T(K=>[...K,M]),N(M.id),X(!1),se("confirmed")},[]),Yr=p.useCallback(z=>{c&&(se("uploading"),setTimeout(()=>{const D=jo(z);H(c.id,{uploadedData:z,schema:D,uploadError:void 0}),se("preview")},500))},[c,H]),go=p.useCallback(z=>{c&&(H(c.id,{uploadError:z}),se("idle"))},[c,H]),Vt=p.useCallback(()=>{c&&(H(c.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),se("idle"))},[c,H]),yo=p.useCallback(()=>{c&&(H(c.id,{schemaLocked:!0}),se("confirmed"))},[c,H]),qr=p.useCallback(z=>{if(!c)return;if(!Bt("edit_sorting",Se)){B(Tt("edit_sorting"),"error");return}const D=c.sortStack??[],P=D.find(M=>M.column===z);if(P){const M=Ga(P.direction);if(M===null){const K=D.filter(J=>J.column!==z).map((J,de)=>({...J,priority:de+1}));ce("sorting","sort_level_removed",P,null),H(c.id,{sortStack:K.length>0?K:void 0})}else{const K=M,J=D.map(de=>de.column===z?{...de,direction:K}:de);ce("sorting","sort_reordered",{column:z,direction:P.direction},{column:z,direction:K}),H(c.id,{sortStack:J})}}else{if(D.length>=f.sort.maxLevels){B(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:z,direction:"asc",priority:D.length+1};ce("sorting","sort_level_added",null,M),H(c.id,{sortStack:[...D,M]})}},[c,Se,H,ce]),Wt=p.useCallback(z=>{if(!c)return;const D=c.sortStack??[],P=z.length===0?"sort_cleared":"sort_reordered";if(c.schema){const{validRules:M,invalidColumns:K}=Ns(z,c.schema);K.length>0&&B(`Removed invalid sort columns: ${K.join(", ")}`),kt();try{ce("sorting",P,D,M.length>0?M:null),H(c.id,{sortStack:M.length>0?M:void 0})}catch(J){const de=vr("processing","sorting",J);vt(de)}}else ce("sorting",P,D,z.length>0?z:null),H(c.id,{sortStack:z.length>0?z:void 0})},[c,H,kt,vt,ce]),Or=p.useCallback(z=>{if(!c)return;const D=c.sortStack??[],P=D.find(M=>M.column===z);if(!(P&&P.direction==="asc"))if(P){const M=D.map(K=>K.column===z?{...K,direction:"asc"}:K);ce("sorting","sort_reordered",{column:z,direction:P.direction},{column:z,direction:"asc"}),H(c.id,{sortStack:M})}else{if(D.length>=f.sort.maxLevels){B(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:z,direction:"asc",priority:D.length+1};ce("sorting","sort_level_added",null,M),H(c.id,{sortStack:[...D,M]})}},[c,H,ce]),je=p.useCallback(z=>{if(!c)return;const D=c.sortStack??[],P=D.find(M=>M.column===z);if(!(P&&P.direction==="desc"))if(P){const M=D.map(K=>K.column===z?{...K,direction:"desc"}:K);ce("sorting","sort_reordered",{column:z,direction:P.direction},{column:z,direction:"desc"}),H(c.id,{sortStack:M})}else{if(D.length>=f.sort.maxLevels){B(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:z,direction:"desc",priority:D.length+1};ce("sorting","sort_level_added",null,M),H(c.id,{sortStack:[...D,M]})}},[c,H,ce]),Ye=p.useCallback((z,D)=>{var M;if(!c)return;if(!Bt("edit_filters",Se)){B(Tt("edit_filters"),"error");return}const P=(M=c.schema)==null?void 0:M.find(K=>K.name===D.column);if(P&&D.value!==void 0){const K=_l(P.type,D.operator,D.value);if(!K.isValid){B(K.errorMessage||"Invalid filter value","error");return}}kt();try{const K=Ue(c.filters),J={...D,id:po()},de=ho(K,z,J);ce("filters","filter_added",null,J),H(c.id,{filters:de})}catch(K){const J=vr("processing","filters",K);vt(J)}},[c,Se,H,kt,vt,ce]),Mr=p.useCallback(z=>{if(!c)return;if(!Bt("edit_filters",Se)){B(Tt("edit_filters"),"error");return}const D=Ue(c.filters),P=ho(D,z,Pt());ce("filters","filter_added",null,"a condition group"),H(c.id,{filters:P})},[c,Se,H,ce]),ct=p.useCallback((z,D)=>{if(!c)return;if(!Bt("edit_filters",Se)){B(Tt("edit_filters"),"error");return}const P=Ue(c.filters),M=nn(P,z),K=mi(P,z,D),J=nn(K,z);ce("filters","filter_updated",M,J),H(c.id,{filters:K})},[c,Se,H,ce]),er=p.useCallback((z,D)=>{if(!c)return;if(!Bt("edit_filters",Se)){B(Tt("edit_filters"),"error");return}const P=Ue(c.filters),M=xi(P,z,D);ce("filters","filter_updated",null,`group operator changed to ${D.toUpperCase()}`),H(c.id,{filters:M})},[c,Se,H,ce]),fe=p.useCallback(z=>{if(!c)return;if(!Bt("edit_filters",Se)){B(Tt("edit_filters"),"error");return}const D=Ue(c.filters),P=nn(D,z),M=gi(D,z);ce("filters","filter_removed",P,null),H(c.id,{filters:M})},[c,Se,H,ce]),xe=p.useCallback(()=>{if(!c)return;if(!Bt("edit_filters",Se)){B(Tt("edit_filters"),"error");return}const z=Ue(c.filters);ce("filters","filter_cleared",{count:Et(z)},null),H(c.id,{filters:Pt()})},[c,Se,H,ce]),Ae=p.useCallback(z=>{if(!c)return;if(!Bt("edit_filters",Se)){B(Tt("edit_filters"),"error");return}const D=Ue(c.filters);ce("filters","filter_cleared",{count:Et(D)},{count:Et(z)}),H(c.id,{filters:z})},[c,Se,H,ce]),We=p.useCallback(z=>{var K;if(!c)return;const D=(K=c.views)==null?void 0:K.find(J=>J.id===z);if(!D)return;const P=D.snapshot.columnOrder,M=To(P,D.snapshot.grouping);ce("views","view_switched",{previousViewId:c.activeViewId},{viewId:z,name:D.name}),H(c.id,{filters:D.snapshot.filters,sortStack:D.snapshot.sortStack.length>0?[...D.snapshot.sortStack]:void 0,columnVisibility:{...D.snapshot.columnVisibility},columnOrder:M,columnWidths:{...D.snapshot.columnWidths},grouping:D.snapshot.grouping,activeViewId:z}),Je(new Set)},[c,H,ce]),st=p.useCallback((z,D,P)=>{var ve;if(!(c!=null&&c.schema)||!Me)return;const M=c.views??[],K=M.filter(Gt=>!Gt.isDeleted).length,J=((ve=f.views)==null?void 0:ve.maxViews)??10;if(K>=J){B(`View limit reached — you can have at most ${J} saved views. Delete an existing view to create a new one.`,"error");return}const de={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:z,description:D||void 0,isDefault:P,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:Rt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Me}},ye=P?M.map(Gt=>({...Gt,isDefault:!1})):M;ce("views","view_created",null,{viewId:de.id,name:z,isDefault:P}),H(c.id,{views:[...ye,de],activeViewId:de.id}),B(`"${z}" view created`,"success")},[c,Me,H,ce]),dt=p.useCallback(z=>{var de;if(!(c!=null&&c.views))return;const D=c.views.find(ye=>ye.id===z);if(!D)return;const P=c.views,M=P.filter(ye=>!ye.isDeleted).length,K=((de=f.views)==null?void 0:de.maxViews)??10;if(M>=K){B(`View limit reached — you can have at most ${K} saved views. Delete an existing view to create a new one.`,"error");return}const J={...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:Rt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...D.snapshot}};H(c.id,{views:[...P,J]}),B(`"${J.name}" created`,"success")},[c,f,H]),xt=p.useCallback(()=>{var D;if(!U||!Me||!c)return;const z=(D=c.views)==null?void 0:D.map(P=>P.id===U.id?{...P,snapshot:{...Me}}:P);H(c.id,{views:z}),B(`"${U.name}" view updated`,"success")},[U,Me,c,H]),Jr=p.useCallback(z=>{var M;if(!U||!Me||!c)return;const D=z??Me.columnWidths,P=(M=c.views)==null?void 0:M.map(K=>K.id===U.id?{...K,snapshot:{...K.snapshot,columnVisibility:Me.columnVisibility,columnOrder:Me.columnOrder,columnWidths:D},updatedAt:Date.now()}:K);H(c.id,{views:P,columnWidths:D}),B(`Column configuration saved to "${U.name}"`,"success")},[U,Me,c,H]),tr=p.useCallback(z=>{var J,de;if(!Me||!c||!U)return;const D=z??Me.columnWidths,P={...U,snapshot:{...U.snapshot,columnVisibility:Me.columnVisibility,columnOrder:Me.columnOrder,columnWidths:D},updatedAt:Date.now()},M=(J=c.views)==null?void 0:J.map(ye=>ye.id===U.id?P:{...ye,snapshot:{...ye.snapshot,columnVisibility:Me.columnVisibility,columnOrder:Me.columnOrder,columnWidths:D},updatedAt:Date.now()});H(c.id,{views:M,columnWidths:D});const K=(((de=c.views)==null?void 0:de.length)||0)-1;B(`Column configuration saved to current view and ${K} other view${K===1?"":"s"}`,"success")},[Me,c,U,H]),rr=p.useCallback(()=>{pe(!0)},[]),Ar=p.useCallback(()=>{if(!U||!c)return;const z=U.snapshot.columnOrder,D=To(z,U.snapshot.grouping);H(c.id,{filters:U.snapshot.filters,sortStack:U.snapshot.sortStack.length>0?[...U.snapshot.sortStack]:void 0,columnVisibility:{...U.snapshot.columnVisibility},columnOrder:D,columnWidths:{...U.snapshot.columnWidths},grouping:U.snapshot.grouping}),B("Changes reverted to last saved state","success")},[U,c,H]),mr=p.useCallback(z=>{if(!(c!=null&&c.views))return;const D=c.views.map(M=>({...M,isDefault:M.id===z}));H(c.id,{views:D});const P=c.views.find(M=>M.id===z);P&&B(`"${P.name}" set as default view`,"success")},[c,H]),bo=p.useCallback(z=>{if(!(c!=null&&c.views))return;const D=c.views.map(M=>M.id===z?{...M,isFavorite:!M.isFavorite,updatedAt:Date.now()}:M);H(c.id,{views:D});const P=c.views.find(M=>M.id===z);P&&!P.isFavorite?B(`"${P.name}" added to favorites`,"success"):P&&B(`"${P.name}" removed from favorites`,"info")},[c,H]),$n=p.useCallback(z=>{if(!(c!=null&&c.views))return;const D=c.views.find(ve=>ve.id===z),P=c.views.filter(ve=>!ve.isDeleted||ve.id===z);if((D==null?void 0:D.isDefault)&&P.filter(ve=>ve.isDefault).length===1){B("Cannot delete the last default view","error");return}const K=c.views.map(ve=>ve.id===z?{...ve,isDeleted:!0,updatedAt:Date.now()}:ve),J=c.activeViewId===z,de=K.find(ve=>ve.isDefault&&!ve.isDeleted);H(c.id,{views:K,activeViewId:J&&de?de.id:c.activeViewId,filters:J&&de?de.snapshot.filters:c.filters,sortStack:J&&de?de.snapshot.sortStack.length>0?de.snapshot.sortStack:void 0:c.sortStack});const ye=c.views.find(ve=>ve.id===z);ye&&B(`"${ye.name}" moved to Recently Deleted`,"info")},[c,H]),Fo=p.useCallback(z=>{if(!(c!=null&&c.views))return;const D=c.views.map(M=>M.id===z?{...M,isDeleted:!1,updatedAt:Date.now()}:M);H(c.id,{views:D});const P=c.views.find(M=>M.id===z);P&&B(`"${P.name}" restored`,"success")},[c,H]),Kr=p.useCallback(z=>{if(!(c!=null&&c.views))return;const D=c.views.find(ye=>ye.id===z),P=c.views.filter(ye=>!ye.isDeleted||ye.id===z);if((D==null?void 0:D.isDefault)&&P.filter(ye=>ye.isDefault).length===1){B("Cannot delete the last default view","error");return}const K=c.views.filter(ye=>ye.id!==z),J=c.activeViewId===z,de=K.find(ye=>ye.isDefault&&!ye.isDeleted);H(c.id,{views:K,activeViewId:J&&de?de.id:c.activeViewId,filters:J&&de?de.snapshot.filters:c.filters,sortStack:J&&de?de.snapshot.sortStack.length>0?de.snapshot.sortStack:void 0:c.sortStack}),D&&B(`"${D.name}" permanently deleted`,"success")},[c,H]),Vo=p.useCallback(z=>{Ne(z),R(!0)},[]),Xr=p.useCallback(async z=>{if(!c)return;const D=new URLSearchParams(window.location.search);D.set("reportId",c.id),D.set("view",z);const P=`${window.location.origin}${window.location.pathname}?${D.toString()}`,M=await zl(P);B(M?"Link copied to clipboard":"Failed to copy link",M?"success":"error")},[c]),vo=p.useCallback((z,D)=>{if(!ee||!(c!=null&&c.views))return;const P=c.views.map(M=>M.id===ee?{...M,name:z,description:D||void 0}:M);H(c.id,{views:P}),Ne(null)},[ee,c,H]),Ho=p.useCallback(z=>{$t(z),G(!0)},[]),Qr=p.useCallback(()=>{if(!Te||!(c!=null&&c.views))return;const z=c.views.find(K=>K.id===Te),D=c.views.filter(K=>K.id!==Te),P=c.activeViewId===Te,M=D.find(K=>K.isDefault);ce("views","view_deleted",{viewId:Te,name:z==null?void 0:z.name},null),H(c.id,{views:D,activeViewId:P&&M?M.id:c.activeViewId,filters:P&&M?M.snapshot.filters:c.filters,sortStack:P&&M?M.snapshot.sortStack.length>0?M.snapshot.sortStack:void 0:c.sortStack}),$t(null),G(!1)},[Te,c,H,ce]),Zr=p.useCallback(z=>{var K;if(!(c!=null&&c.views))return;if(!(((K=f.views)==null?void 0:K.isAdmin)??!1)){B("Only administrators can promote views to Global.","error");return}const P=c.views.find(J=>J.id===z);if(!P)return;if(P.scope==="global"){B(`"${P.name}" is already a Global View.`,"info");return}const M=c.views.map(J=>J.id===z?{...J,scope:"global",isDefault:!0,updatedAt:Date.now()}:J.scope==="global"&&J.isDefault?{...J,isDefault:!1}:J);H(c.id,{views:M}),B(`"${P.name}" promoted to Global View and set as default.`,"success")},[c,f,H]),xr=p.useCallback((z,D)=>{if(!(c!=null&&c.views))return;const P=c.views.find(J=>J.id===z);if(!P)return;const M=c.views.map(J=>J.id===z?{...J,isDefaultForAllUsers:D,updatedAt:Date.now()}:D&&J.isDefaultForAllUsers?{...J,isDefaultForAllUsers:!1}:J);ce("views",D?"view_set_default":"view_updated",{viewId:z,isDefaultForAllUsers:!D},{viewId:z,isDefaultForAllUsers:D}),H(c.id,{views:M}),B(`"${P.name}" ${D?"set as":"removed from"} default for all users.`,"success")},[c,H,ce]),So=p.useRef(!0);p.useEffect(()=>{var z;if(So.current){So.current=!1;return}if(j==="server"){ht(1),(z=a==null?void 0:a.onPaginationChange)==null||z.call(a,1,rt);return}we!=null&&we.resetPage?we.resetPage():ht(1)},[c==null?void 0:c.filters,Zt,c==null?void 0:c.activeViewId]);const eo=p.useCallback(z=>{var D;if(j==="server"){ht(z),(D=a==null?void 0:a.onPaginationChange)==null||D.call(a,z,rt);return}we!=null&&we.goToPage&&we.goToPage(z)},[j,a,rt,we]),On=p.useCallback(z=>{var K;const P=((j==="server"?zr:(we==null?void 0:we.currentPage)||1)-1)*rt,M=Math.floor(P/z)+1;if(j==="server"){Nt(z),ht(M),(K=a==null?void 0:a.onPaginationChange)==null||K.call(a,M,z);return}Nt(z),we==null||we.goToPage(M)},[zr,rt,j,a,we]),Mn=p.useCallback((z,D)=>{if(!c)return;if(!Bt("edit_columns",Se)){B(Tt("edit_columns"),"error");return}const M={...c.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{},[z]:D};ce("columns",D?"column_shown":"column_hidden",{columnName:z,visible:!D},{columnName:z,visible:D}),H(c.id,{columnVisibility:M})},[c,U,Se,H,ce]),An=p.useCallback(z=>{if(c){if(!Bt("edit_columns",Se)){B(Tt("edit_columns"),"error");return}ce("columns","column_reordered",c.columnOrder,z),H(c.id,{columnOrder:z})}},[c,Se,H,ce]),Wn=p.useCallback((z,D)=>{if(!c)return;if(!Bt("edit_columns",Se)){B(Tt("edit_columns"),"error");return}const P=c.columnWidths||(U==null?void 0:U.snapshot.columnWidths)||{},M={...P,[z]:D};ce("columns","column_resized",{columnName:z,width:P[z]},{columnName:z,width:D}),H(c.id,{columnWidths:M})},[c,U,Se,H,ce]),Rn=p.useCallback(z=>{if(!c)return;const D=Ue(c.filters),P=Ws(D,z);H(c.id,{filters:P})},[c,H]),Pn=p.useCallback(()=>{if(!U||!(c!=null&&c.schema))return;const z={},D=[],P={};c.schema.forEach(M=>{z[M.name]=!0,D.push(M.name),P[M.name]=170}),H(c.id,{columnVisibility:z,columnOrder:D,columnWidths:P,filters:void 0,sortStack:void 0}),B("Reset to default layout - all filters and sorts cleared","success")},[U,c,H]);p.useEffect(()=>{const z=setTimeout(()=>kr(lr),300);return()=>clearTimeout(z)},[lr]),p.useEffect(()=>{var z;h==="server"&&((z=l==null?void 0:l.onSearchChange)==null||z.call(l,Zt))},[Zt,h,l]);const Nn=p.useCallback(z=>{mo(z),ht(1)},[]),Ln=p.useCallback(z=>{if(!z.trim()||!c)return;const D=c.searchHistory||[],P=sl(D,z);H(c.id,{searchHistory:P})},[c,H]),Fn=p.useCallback(z=>{if(!c)return;const D=c.searchHistory||[],P=al(D,z);H(c.id,{searchHistory:P})},[c,H]),to=p.useCallback(z=>{if(!c)return;const D=c.searchHistory||[],P=ll(D,z);H(c.id,{searchHistory:P})},[c,H]);p.useEffect(()=>{if(!I.onSelectionChange)return;const z=Array.from(jt);I.onSelectionChange(z,z.map(D=>D==null?void 0:D.__urm_row_id__))},[jt,I.onSelectionChange]);const or=p.useCallback(z=>{const D=z==null?void 0:z.__urm_row_id__;Je(P=>{const M=new Set(P);let K;return D!==void 0?K=Array.from(M).find(J=>(J==null?void 0:J.__urm_row_id__)===D):K=Array.from(M).find(J=>J===z),K!==void 0?M.delete(K):M.add(z),M})},[]),Vn=p.useCallback((z,D)=>{Je(P=>{const M=new Set(P),K=D.filter(J=>!J.isGroupHeader);for(const J of K){const de=J==null?void 0:J.__urm_row_id__;if(z){let ye;de!==void 0?ye=Array.from(M).find(ve=>(ve==null?void 0:ve.__urm_row_id__)===de):ye=Array.from(M).find(ve=>ve===J),ye===void 0&&M.add(J)}else{let ye;de!==void 0?ye=Array.from(M).find(ve=>(ve==null?void 0:ve.__urm_row_id__)===de):ye=Array.from(M).find(ve=>ve===J),ye!==void 0&&M.delete(ye)}}return M})},[]),Hn=p.useCallback((z,D,P)=>{Je(M=>{const K=new Set(M),J=P.filter(ve=>!ve.isGroupHeader),de=Math.min(z,D),ye=Math.max(z,D);for(let ve=de;ve<=ye;ve++){const Gt=J[ve];if(!Gt)continue;const _i=Gt==null?void 0:Gt.__urm_row_id__;let Gn;_i!==void 0?Gn=Array.from(K).find(Co=>(Co==null?void 0:Co.__urm_row_id__)===_i):Gn=Array.from(K).find(Co=>Co===Gt),Gn===void 0&&K.add(Gt)}return K})},[]),He=p.useCallback(()=>{Je(new Set)},[]),tt=p.useCallback(z=>{const D=z==null?void 0:z.__urm_row_id__;Je(P=>{const M=new Set(P);if(D!==void 0){const K=Array.from(M).find(J=>(J==null?void 0:J.__urm_row_id__)===D);K!==void 0&&M.delete(K)}else M.delete(z);return M})},[]),wo=p.useCallback(z=>{var D,P;if(c){if(!Bt("edit_columns",Se)){B(Tt("edit_columns"),"error");return}if(z&&c.schema){const{validGrouping:M,invalidColumns:K}=Ls(z,c.schema);K.length>0&&B(`Removed invalid grouping columns: ${K.join(", ")}`,"warning"),kt();try{const J=c.grouping;M===null?ce("grouping","group_cleared",J,null):J?ce("grouping","group_reordered",J,M):ce("grouping","group_level_added",null,M);const de=(U==null?void 0:U.snapshot.columnOrder)||c.columnOrder||[],ye=To(de,M),ve=M.levels.length>0?{...M,collapsedGroups:Wi(Ft,c.schema,M)}:M;H(c.id,{grouping:ve,columnOrder:ye}),j==="server"?(ht(1),(D=a==null?void 0:a.onPaginationChange)==null||D.call(a,1,rt)):we==null||we.resetPage(),JSON.stringify(ye)!==JSON.stringify(c.columnOrder)&&ce("columns","column_reordered",c.columnOrder,ye),at(!1)}catch(J){const de=vr("processing","grouping",J);vt(de)}}else{const M=c.grouping;ce("grouping","group_cleared",M,null);const K=(U==null?void 0:U.snapshot.columnOrder)||c.columnOrder||[];H(c.id,{grouping:z,columnOrder:K}),j==="server"?(ht(1),(P=a==null?void 0:a.onPaginationChange)==null||P.call(a,1,rt)):we==null||we.resetPage(),JSON.stringify(K)!==JSON.stringify(c.columnOrder)&&ce("columns","column_reordered",c.columnOrder,K),at(!1)}}},[c,U,Se,H,kt,vt,ce,Ft]),ro=p.useCallback(z=>{if(!c||!f.grouping.allowCollapse)return;const D=c.grouping;if(!D)return;const P=Xa(D,z);H(c.id,{grouping:P})},[c,f,H]),Uo=p.useCallback(()=>{!(c!=null&&c.grouping)||!f.grouping.allowCollapse||H(c.id,{grouping:{...c.grouping,collapsedGroups:[]}})},[c,f,H]),Un=p.useCallback(()=>{if(!(c!=null&&c.grouping)||!c.schema||!f.grouping.allowCollapse)return;const z=Wi(Ft,c.schema,c.grouping);H(c.id,{grouping:{...c.grouping,collapsedGroups:z}})},[c,Ft,f,H]),nr=p.useCallback(()=>{ur(!0)},[]),St=p.useCallback(z=>{c!=null&&c.schema&&(Kt(!0),setTimeout(()=>{try{let D;z.scope==="visible"?D=hr:D=c.uploadedData||[];let P;z.columnScope==="all"?(P={},(c.schema??[]).forEach(ye=>{P[ye.name]=!0})):P=c.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{};const M=c.columnOrder||(U==null?void 0:U.snapshot.columnOrder),K=an(D,c.schema,Ue(c.filters),c.sortStack??[],U,P,M),J=c.name;let de;switch(z.format){case"csv":ln(K,J,z),de="export_csv";break;case"excel":cn(K,J,z),de="export_excel";break;case"json":dn(K,J,z),de="export_json";break;case"pdf":vi(K,J,z),de="export_pdf";break}ce("export",de,null,{format:z.format,scope:z.scope,columnScope:z.columnScope,rowCount:D.length,viewName:(U==null?void 0:U.name)||"Default View"}),B(`Export completed successfully (${z.format.toUpperCase()})`,"success")}catch(D){const P=Ol(D,{onRetry:()=>St(z)});B(`Export failed: ${P.message}. Click Export to retry.`,"error");const M=Ui(c.id,Rt,P,c.auditHistory||[]);H(c.id,{auditHistory:M}),Jt.error("urm:report-engine","Export failed",D)}finally{Kt(!1)}},500))},[c,U,hr,H,ce]),Go=p.useCallback(z=>{if(c!=null&&c.schema){if(Oe&&U&&!U.isDefault){Xt(z.format),Ot(!0),ur(!1);return}St(z),ur(!1)}},[c,U,Oe,St]),oo=p.useCallback(z=>{St({format:z,scope:"visible",columnScope:"visible"})},[St]),Yo=p.useCallback(()=>{pt&&oo(pt),Ot(!1),Xt(null)},[pt,oo]),qo=p.useCallback(()=>{xt(),pt&&oo(pt),Ot(!1),Xt(null)},[xt,pt,oo]),w=p.useCallback(()=>{Ot(!1),Xt(null)},[]),L=p.useCallback(z=>{!(c!=null&&c.schema)||jt.size===0||(Kt(!0),setTimeout(()=>{try{const D=Array.from(jt),P=an(D,c.schema,Ue(c.filters),c.sortStack??[],U),M=`${c.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(z){case"csv":ln(P,M);break;case"excel":cn(P,M);break;case"json":dn(P,M);break}B(`Exported ${D.length} selected rows`,"info")}catch(D){B("Export failed. Please try again.","error"),Jt.error("urm:report-engine","Bulk export failed",D)}finally{Kt(!1)}},500))},[c,U,jt,Er]),ne=p.useCallback((z,D)=>{if(c)try{const P=vl(c),M=Sl(z,D,Rt,P),K=wl(c.presets,M);H(c.id,{presets:K}),ce("presets","preset_created",null,{presetId:M.id,name:M.name}),dr(!1),B(`Preset "${z}" saved successfully`,"success")}catch(P){B(P instanceof Error?P.message:"Failed to create preset","error")}},[c,H,ce]),ke=p.useCallback(()=>{Br(null),B("Exited preset view","info")},[]),Le=p.useCallback(()=>{Ce(!0)},[]),ot=p.useCallback((z,D)=>{if(!c)return;const P=Cl(c.presets,z);H(c.id,{presets:P}),ce("presets","preset_deleted",{presetId:z,name:D},null),At===z&&Br(null),B(`Preset "${D}" deleted`,"success")},[c,At,H,ce]);p.useEffect(()=>{if(!b||k.length===0)return;const z=k.find(D=>D.id===b);z&&z.id!==W&&N(z.id)},[b,k,W]);const Xe=p.useRef(!1);p.useEffect(()=>{var D;if(!x||Xe.current||!c||c.id!==b)return;const z=(D=c.views)==null?void 0:D.find(P=>P.id===x&&!P.isDeleted);z&&We(z.id),Xe.current=!0},[x,b,c,We]),p.useEffect(()=>{if(!c)return;const z=jl();if(z&&c.presets&&c.schemaLocked&&c.schema){const D=Hi(c.presets,z);if(D){const{sanitizedConfig:P,warnings:M}=$l(D.config,c.schema);M.length>0&&M.forEach(J=>B(J,"warning"));const K=kl(P);H(c.id,K),Br(z),ce("presets","preset_applied",null,{presetId:D.id,name:D.name}),B(`Loaded preset: ${D.name}`,"info")}else B("Preset not found","info")}},[c==null?void 0:c.schemaLocked]);const ge=At?Hi(c==null?void 0:c.presets,At):void 0;p.useEffect(()=>{var z;c!=null&&c.views&&c.views.length>0&&c.activeViewId&&((z=S==null?void 0:S.onViewsChange)==null||z.call(S,c.views,c.activeViewId),m!=="api"&&ol(c.id,{views:c.views,activeViewId:c.activeViewId}))},[c==null?void 0:c.views,c==null?void 0:c.activeViewId,c==null?void 0:c.id,m,S]),p.useEffect(()=>{if(c!=null&&c.schemaLocked&&c.schema&&(!c.views||c.views.length===0)){const z=m==="api"?S!=null&&S.views&&S.views.length>0?{views:S.views,activeViewId:S.activeViewId??S.views[0].id}:null:nl(c.id);if(z&&z.views.length>0){const D=z.views.find(P=>P.id===z.activeViewId);if(D)H(c.id,{views:z.views,activeViewId:z.activeViewId,filters:Ue(D.snapshot.filters),sortStack:D.snapshot.sortStack.length>0?D.snapshot.sortStack:void 0});else{const P=z.views.find(M=>M.isDefault)||Yn(c.schema);H(c.id,{views:z.views,activeViewId:P.id,filters:Ue(P.snapshot.filters),sortStack:P.snapshot.sortStack.length>0?P.snapshot.sortStack:void 0})}}}},[c==null?void 0:c.schemaLocked,c==null?void 0:c.schema,c==null?void 0:c.id,m,S]);const Ht=p.useCallback(z=>{var M;const D=Ue(c==null?void 0:c.filters),P=((M=f.filter)==null?void 0:M.maxConditions)??3;if(Et(D)>=P){B(`Filter limit reached — maximum ${P} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}De(z),Z(!0)},[c,f,B]),Ut=p.useCallback(()=>{Z(!1),De(void 0)},[]),Re=(Ei=c==null?void 0:c.views)==null?void 0:Ei.find(z=>z.id===ee),gr=(Di=c==null?void 0:c.views)==null?void 0:Di.find(z=>z.id===Te);return{reports:k,activeReport:c,activeReportId:W,setActiveReportId:N,isModalOpen:E,setIsModalOpen:X,createReport:$r,updateReport:H,uploadState:re,handleFileUpload:Yr,handleUploadError:go,handleRetry:Vt,handleConfirm:yo,paginatedData:Gr,processedData:hr,displayData:Er,tableMetrics:fr,isGrouped:Dr,tableEngine:zt,activeView:U,isDirty:Oe,currentTableState:Me,viewChanges:_r,filters:c==null?void 0:c.filters,showFilterPanel:V,setShowFilterPanel:Z,filterFocusColumn:ae,handleAddCondition:Ye,handleAddGroup:Mr,handleUpdateCondition:ct,handleSetGroupOperator:er,handleRemoveFilterNode:fe,handleClearAllFilters:xe,handleReplaceFilters:Ae,handleOpenFilterForColumn:Ht,handleCloseFilterPanel:Ut,handleClearFiltersForColumn:Rn,sortStack:c==null?void 0:c.sortStack,showSortPanel:ue,setShowSortPanel:le,handleSort:qr,handleUpdateSortStack:Wt,handleSortAscending:Or,handleSortDescending:je,views:c==null?void 0:c.views,showCreateViewModal:Q,setShowCreateViewModal:pe,showEditViewModal:ie,setShowEditViewModal:R,showDeleteConfirmation:oe,setShowDeleteConfirmation:G,editingView:Re,deletingView:gr,editingViewId:ee,deletingViewId:Te,handleSelectView:We,handleCreateView:st,handleCloneView:dt,handleUpdateCurrentView:xt,handleSaveColumnConfigToCurrentView:Jr,handleSaveColumnConfigToAllViews:tr,handleSaveAsNewView:rr,handleRevertChanges:Ar,handleToggleDefault:mr,handleToggleFavorite:bo,handleSoftDelete:$n,handleRestoreView:Fo,handlePermanentDelete:Kr,handleEditView:Vo,handleCopyViewLink:Xr,handleSaveEditView:vo,handleDeleteView:Ho,handleConfirmDelete:Qr,handlePromoteToGlobal:Zr,handleSetDefaultForAllUsers:xr,showManageColumns:Ze,setShowManageColumns:Mt,columnVisibility:c==null?void 0:c.columnVisibility,columnOrder:c==null?void 0:c.columnOrder,columnWidths:c==null?void 0:c.columnWidths,handleUpdateColumnVisibility:Mn,handleUpdateColumnOrder:An,handleUpdateColumnWidth:Wn,handleResetColumnLayout:Pn,showGroupPanel:jr,setShowGroupPanel:at,grouping:c==null?void 0:c.grouping,groupingState:Qt,handleGroup:wo,handleToggleGroupCollapse:ro,handleExpandAllGroups:Uo,handleCollapseAllGroups:Un,searchQuery:lr,debouncedSearchQuery:Zt,searchHistory:cl((c==null?void 0:c.searchHistory)||[]),handleSearchChange:Nn,handleAddToSearchHistory:Ln,handleToggleSearchFavourite:Fn,handleDeleteSearchHistory:to,selectedRowIds:jt,handleToggleRowSelection:or,handleToggleAllRows:Vn,handleRangeSelection:Hn,handleClearSelection:He,handleUpdateSelectionAfterDelete:tt,currentPage:j==="server"?zr:(we==null?void 0:we.currentPage)||1,pageSize:rt,paginationEngine:we,paginationMode:j,paginationTotalRows:ft,paginationTotalPages:mt,handlePageChange:eo,handlePageSizeChange:On,isExporting:Fr,showExportModal:Hr,setShowExportModal:ur,showDirtyExportWarning:Cr,handleExport:nr,handleExportWithConfig:Go,handleExportSelected:L,handleExportAnyway:Yo,handleSaveAndExport:qo,handleCancelExport:w,showAuditHistory:cr,setShowAuditHistory:xo,auditHistory:c==null?void 0:c.auditHistory,showCreatePreset:Vr,setShowCreatePreset:dr,showManagePresets:Ke,setShowManagePresets:Ce,activePreset:ge,activePresetId:At,handleOpenManagePresets:Le,handleCreatePreset:ne,handleClearActivePreset:ke,handleDeletePresetById:ot,userRole:Se,isViewerRole:Lo,currentUserId:Rt,permissions:c==null?void 0:c.permissions,featureLimitWarning:Tr,setFeatureLimitWarning:Ur,datasetMeta:me,reportError:pr,setReportError:et,handleError:vt,schema:c==null?void 0:c.schema,hasSchemaConflicts:c!=null&&c.schema?Ha(c.schema):!1,snack:v,handleSnackClose:q,showSnack:B,snackDurationMs:Y,config:I,scheduler:d}}const Fs=p.createContext(gt);function Nr(){return p.useContext(Fs)}const Vs=p.createContext(void 0);function wi(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:l,pagination:d,search:u,scheduler:g,mode:b="builder",autoLoad:x=!0,config:S,devConfig:y,showDevPanel:I=!1,sharedReportId:C,sharedViewId:m,viewPersistence:j,permissions:h}=e,k=i||n,[T,f]=p.useState(()=>za()),W=(()=>{const A=Ta(T,y,!!y);return{...A,display:{...A.display,showDevPanel:I||A.display.showDevPanel}}})(),N=Ql({mode:b,autoLoad:x,initialData:k,dataSource:l,pagination:d,search:u,scheduler:g,reportName:s,reportId:a,sharedReportId:C,sharedViewId:m,viewPersistence:j,permissions:h,config:S,devConfig:W}),E=p.useCallback(te=>{f(te),Ba(te)},[]),X={...N,activeDevConfig:W,handleDevConfigChange:E};return t.jsx(Fs.Provider,{value:W,children:t.jsx(Vs.Provider,{value:X,children:r})})}function gn(){const e=p.useContext(Vs);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Zl({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 b,x,S;const l=((S=(x=(b=a.components)==null?void 0:b.MuiCardHeader)==null?void 0:x.styleOverrides)==null?void 0:S.root)||{},d=l.backgroundColor&&l.backgroundColor!=="transparent"?l.backgroundColor:a.palette.background.paper,u=l.borderBottom&&l.borderBottom!=="none"?l.borderBottom:"1px solid",g=l.boxShadow&&l.boxShadow!=="none"?l.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:u,borderColor:u!=="none"?"divider":void 0,boxShadow:g,bgcolor:d}},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 Pr(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 ec="$$material";function tc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qo={exports:{}},Zo={exports:{}},ze={};/** @license React v16.13.1
|
|
105
|
+
</html>`;try{const w=document.createElement("iframe");w.style.position="fixed",w.style.right="0",w.style.bottom="0",w.style.width="0",w.style.height="0",w.style.border="0",document.body.appendChild(w);const x=((m=w.contentWindow)==null?void 0:m.document)||w.contentDocument;if(x){x.open(),x.write(S),x.close(),setTimeout(()=>{var C,B;try{(C=w.contentWindow)==null||C.focus(),(B=w.contentWindow)==null||B.print()}catch{}setTimeout(()=>{document.body.removeChild(w)},3e3)},300);return}}catch{}const y=new Blob([S],{type:"text/html;charset=utf-8;"}),E=URL.createObjectURL(y);window.open(E,"_blank")||wi(S,yn(r,"html"),"text/html;charset=utf-8;")}function Zo(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Pi=10;function nl(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>Pi&&(s=[...s].sort((l,d)=>l.isFavourite&&!d.isFavourite?-1:!l.isFavourite&&d.isFavourite?1:d.lastUsed-l.lastUsed).slice(0,Pi)),s}function il(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function sl(e,r){return e.filter(n=>n.query!==r)}function al(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 ll={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 cl(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function jt(e,r){return ll[r].includes(e)}function kt(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 dl(e){return e==="viewer"}const Ni=1e3;function ci(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Xt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return ci(n)}const ul={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 pl(e){if(!e||!e.column)return"a filter";const r=Xt(e.column),n=ul[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function Xn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":pl(e):"a filter"}function Li(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${Xt(n.column)}"`).join(", ")}`}function hl(e){var s,a,l;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${Xn(i)}`};case"filter_removed":return{summary:`Filter removed: ${Xn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const d=n,u=i;return d!=null&&d.column&&(u!=null&&u.column)&&d.column!==u.column?{summary:`Filter changed on "${Xt(u.column)}"`,detail:`Previously filtered "${Xt(d.column)}"`}:{summary:`Filter updated: ${Xn(u)}`}}case"filter_cleared":{const d=n&&typeof n=="object"&&"count"in n?n.count:0;return{summary:d>0?`All filters cleared (${d} filter${d!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const d=i!=null&&i.column?Xt(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:d?`Sort added: "${d}" ${u}`:"Sort level added"}}case"sort_level_removed":{const d=n!=null&&n.column?Xt(n.column):"";return{summary:d?`Sort removed: "${d}"`:"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: ${Li(i)}`};case"group_level_removed":{const d=n,u=(a=(s=d==null?void 0:d.levels)==null?void 0:s[0])!=null&&a.column?Xt(d.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Li(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const d=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:d?`Column hidden: "${Xt(d)}"`:"Column hidden"}}case"column_shown":{const d=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:d?`Column shown: "${Xt(d)}"`:"Column made visible"}}case"column_reordered":{const d=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return d.length>0&&u.length>0?{summary:"Column order changed",detail:`${u.length} column${u.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const d=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:d?`Column resized: "${Xt(d)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const d=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:d?`View created: "${d}"`:"New view created"}}case"view_updated":{const d=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:d?`View updated: "${d}"`:"View updated"}}case"view_deleted":{const d=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:d?`View deleted: "${d}"`:"View deleted"}}case"view_set_default":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Default view set to "${d}"`:"Default view changed"}}case"view_switched":{const d=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return d&&u?{summary:`Switched to view "${u}"`,detail:`From "${d}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":case"export_pdf":{const d=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",u=i==null?void 0:i.rowCount,g=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",b=(i==null?void 0:i.viewName)??"",f=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${d}${f}`,detail:b?`${ci(g)} · View: "${b}"`:ci(g)}}case"export_triggered":{const d=((l=i==null?void 0:i.format)==null?void 0:l.toUpperCase())??"";return{summary:d?`Export triggered: ${d}`:"Export triggered"}}case"preset_created":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Preset created: "${d}"`:"New preset created"}}case"preset_applied":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Preset applied: "${d}"`:"Preset applied"}}case"preset_deleted":{const d=(n==null?void 0:n.name)??"";return{summary:d?`Preset deleted: "${d}"`:"Preset deleted"}}case"preset_link_copied":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Preset link copied: "${d}"`:"Preset link copied to clipboard"}}case"row_edited":{const d=(i==null?void 0:i.id)??(n==null?void 0:n.id)??"",u=(i==null?void 0:i.label)??(n==null?void 0:n.label)??(d?`#${d}`:"");return{summary:u?`Row edited: "${u}"`:"Row edited"}}case"row_deleted":{const d=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(d?`#${d}`:"");return{summary:u?`Row deleted: "${u}"`:"Row deleted"}}case"row_duplicated":{const d=(n==null?void 0:n.id)??"",u=(n==null?void 0:n.label)??(d?`#${d}`:"");return{summary:u?`Row duplicated: "${u}"`:"Row duplicated"}}case"theme_changed":{const d=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return d&&u?{summary:`Theme changed from "${d}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const d=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:d?`Details: ${String(d).slice(0,120)}`:void 0}}default:return{summary:fl(r)}}}function ml(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Mo(e,r,n,i,s,a){return{id:ml(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function Ao(e,r){const n=[r,...e];return n.length>Ni?n.slice(0,Ni):n}function fl(e){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",export_pdf:"Exported as PDF",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",error_occurred:"Error Occurred"}[e]||e}function Qn(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",rows:"Rows",system:"System"}[e]||e}function xl(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),a=Math.floor(i/36e5),l=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`:l<7?`${l} day${l>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Fi=100;function gl(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function yl(e){var a;const r=(a=e.views)==null?void 0:a.find(l=>l.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=Si(i,e.grouping||null,n);return{filters:Ge(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 bl(e,r,n,i){return{id:gl(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function vl(e,r){const n=e||[];if(n.length>=Fi)throw new Error(`Maximum of ${Fi} presets reached. Please delete old presets first.`);return[...n,r]}function Sl(e,r){return(e||[]).filter(i=>i.id!==r)}function Vi(e,r){if(e)return e.find(n=>n.id===r)}function wl(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Cl(e){const r=e.columnOrder,n=Do(r,e.grouping);return{filters:Ge(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 jl(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Qt.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){Qt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Qt.error("urm:presets","Fallback copy method failed",r),!1}}function kl(e,r){return{totalRows:e.length,totalColumns:r.length}}function wr(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:zl(e,r)};return process.env.NODE_ENV==="development"&&Qt.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function zl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function Tl(e){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[e.context]||"An error occurred";return e.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function Bl(e){return{filters:e.filters,sortStack:e.sortStack?[...e.sortStack]:void 0,grouping:e.grouping?{...e.grouping}:void 0,columnVisibility:e.columnVisibility?{...e.columnVisibility}:void 0,columnOrder:e.columnOrder?[...e.columnOrder]:void 0,columnWidths:e.columnWidths?{...e.columnWidths}:void 0,activeViewId:e.activeViewId}}function Il(e,r,n){n(e.id,{filters:Ge(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function El(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 Ns(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 Ls(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 Dl(e,r){const n=[],i=new Set(r.map(a=>a.name)),s={...e};if(s.filters){const a=l=>{const d=l.children.filter(u=>{if(Qe(u))return!0;const g=i.has(u.column);return g||n.push(`Filter for column "${u.column}" ignored (column not found)`),g}).map(u=>Qe(u)?a(u):u).filter(u=>!Qe(u)||u.children.length>0);return{...l,children:d}};s.filters=a(Ge(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:l}=Ns(s.sortStack,r);l.length>0&&n.push(`Sort rules for columns ignored: ${l.join(", ")}`),s.sortStack=a.length>0?a:void 0}if(s.grouping){const{validGrouping:a,invalidColumns:l}=Ls(s.grouping,r);l.length>0&&n.push(`Grouping for columns ignored: ${l.join(", ")}`),s.grouping=a}if(s.columnVisibility){const a={};Object.entries(s.columnVisibility).forEach(([l,d])=>{i.has(l)?a[l]=d:n.push(`Column visibility for "${l}" 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(l=>{const d=i.has(l);return d||n.push(`Column "${l}" in order ignored (column not found)`),d});s.columnOrder=a.length>0?a:void 0}if(s.columnWidths){const a={};Object.entries(s.columnWidths).forEach(([l,d])=>{i.has(l)?a[l]=d:n.push(`Column width for "${l}" ignored (column not found)`)}),s.columnWidths=Object.keys(a).length>0?a:void 0}return{sanitizedConfig:s,warnings:n}}function _l(e,r){return wr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Hi(e,r,n,i){const s=Mo(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return Ao(i||[],s)}function $l(e){return e==null}function Ol(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if($l(e))return!1;if(n==="date"){const a=new Date(e).getTime(),l=new Date(s).getTime();switch(i){case"equals":return a===l;case"gt":return a>l;case"lt":return a<l;case"gte":return a>=l;case"lte":return a<=l;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 di(e,r,n){var s;if(Qe(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>di(e,a,n)):r.children.some(a=>di(e,a,n));const i=((s=n.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return Ol(e[r.column],r,i)}function ji(e,r,n){return!r||r.children.length===0?e:e.filter(i=>di(i,r,n))}function hn(e){switch(e){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"date":return[{value:"equals",label:"Is"},{value:"gt",label:"After"},{value:"lt",label:"Before"},{value:"gte",label:"On or after"},{value:"lte",label:"On or before"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function Ml(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Al({data:e,filters:r,schema:n}){return{filteredData:h.useMemo(()=>!r||r.children.length===0?e:ji(e,r,n),[e,r,n])}}function Wl(e,r){const n=e.length+1,i=r.length+1,s=Array.from({length:n},()=>new Array(i).fill(0));for(let a=0;a<n;a+=1)s[a][0]=a;for(let a=0;a<i;a+=1)s[0][a]=a;for(let a=1;a<n;a+=1)for(let l=1;l<i;l+=1){const d=e[a-1]===r[l-1]?0:1;s[a][l]=Math.min(s[a-1][l]+1,s[a][l-1]+1,s[a-1][l-1]+d)}return s[n-1][i-1]}function Rl(e,r){const n=e.split(/\s+/).filter(Boolean);return r.some(i=>{const s=i.length<=5?1:2;return n.some(a=>Wl(i,a)<=s)})}function Pl(e,r,n,i){if(!n||n.trim()==="")return e;const s=n.toLowerCase().trim(),a=s.split(/\s+/).filter(Boolean),l=r.filter(d=>i.includes(d.name));return e.filter(d=>l.some(u=>{const g=d[u.name];if(g==null)return!1;const b=String(g).toLowerCase();return b.includes(s)?!0:Rl(b,a)}))}function Nl({data:e,searchQuery:r,schema:n,visibleColumns:i,mode:s="client"}){return{searchedData:h.useMemo(()=>s==="server"||!r||r.trim()===""?e:Pl(e,n,r,i),[e,r,n,i,s])}}function Ll({data:e,sortStack:r,schema:n}){return{sortedData:h.useMemo(()=>!r||r.length===0?e:xi(e,n,r),[e,r,n])}}function Fl({data:e,grouping:r,schema:n}){const i=h.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:Os(e,n,r),[e,r,n]),s=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function Vl({schema:e,columnVisibility:r,columnOrder:n}){const i=h.useMemo(()=>n.filter(d=>r[d]!==!1),[n,r]),s=h.useMemo(()=>Object.entries(r).filter(([d,u])=>!u).map(([d,u])=>d),[r]),a=h.useMemo(()=>n.map(d=>e.find(g=>g.name===d)||{name:d,type:"string"}),[n,e]),l=h.useMemo(()=>i.map(d=>e.find(g=>g.name===d)||{name:d,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:l,hiddenCount:s.length}}function Hl({views:e,activeViewId:r,currentState:n}){const i=h.useMemo(()=>e.find(g=>g.id===r),[e,r]),s=h.useMemo(()=>i?Za(n,i.snapshot):!1,[i,n]),a=h.useMemo(()=>e.find(g=>g.isDefault),[e]),l=h.useMemo(()=>e.filter(g=>!g.isDefault&&!g.isDeleted),[e]),d=h.useMemo(()=>e.filter(g=>g.isFavorite&&!g.isDeleted),[e]),u=h.useMemo(()=>e.filter(g=>g.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:l,favoriteViews:d,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Ul(e,r,n){if(!e||e.length===0)return[];if(r<=0)return e.slice(0,n);const i=e.slice(r,n);if(i.length===0)return[];const s=i[0],a=!!(s.__isGroupHeader||s.isGroupHeader),l=a?s.groupLevel??0:s.__urm_group_level__??0;if(l===0&&a)return i;const d=l-1;if(d<0)return i;const u={};let g=d+1;for(let E=r-1;E>=0;E--){const j=e[E];if(j.__isGroupHeader||j.isGroupHeader){const m=j.groupLevel??0;if(m<=d&&u[m]===void 0&&(u[m]=j,g--,g<=0))break}}const b=[];for(let E=0;E<=d;E++)u[E]&&b.push({...u[E],__urm_is_continuation_header__:!0});const f=Math.max(0,n-r-b.length),S=r+f,y=e.slice(r,S);return[...b,...y]}function Gl({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,a]=h.useState(i),l=e.length,d=Math.max(1,Math.ceil(l/n));h.useEffect(()=>{s>d&&a(d)},[s,d]);const u=h.useMemo(()=>{if(!r)return e;const y=(s-1)*n,E=y+n;return Ul(e,y,E)},[e,r,s,n]),g=h.useCallback(y=>{const E=Math.max(1,Math.min(y,d));a(E)},[d]),b=h.useCallback(()=>{s<d&&a(y=>Math.min(y+1,d))},[d]),f=h.useCallback(()=>{s>1&&a(y=>Math.max(y-1,1))},[]),S=h.useCallback(()=>{a(1)},[]);return{paginatedData:u,currentPage:s,totalPages:d,pageSize:n,totalRows:l,goToPage:g,nextPage:b,prevPage:f,resetPage:S,hasNextPage:s<d,hasPrevPage:s>1}}function Yl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:a,searchQuery:l,searchMode:d,columnVisibility:u,columnOrder:g,columnWidths:b,views:f,activeViewId:S,pagination:y}=e,E=h.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:u,columnOrder:g,columnWidths:b}),[i,s,a,u,g,b]),j=Hl({views:f,activeViewId:S,currentState:E}),m=Vl({schema:n,columnVisibility:u,columnOrder:g}),{filteredData:w}=Al({data:r,filters:i,schema:n}),{sortedData:x}=Ll({data:w,sortStack:s,schema:n}),{groupedData:C,isGrouped:B}=Fl({data:x,grouping:a,schema:n}),{searchedData:p}=Nl({data:C,searchQuery:l,schema:n,visibleColumns:m.visibleColumns,mode:d}),A=Gl({data:p,enabled:(y==null?void 0:y.enabled)||!1,pageSize:(y==null?void 0:y.pageSize)||100,initialPage:(y==null?void 0:y.currentPage)||1}),L=y!=null&&y.enabled?A.paginatedData:p,I=h.useMemo(()=>({totalRows:r.length,filteredRows:w.length,sortedRows:x.length,groupedRows:B?C.length:x.length,searchedRows:p.length,visibleRows:L.length,hiddenColumns:m.hiddenCount,activeFilters:Tt(i),activeSorts:s.length,isGrouped:B}),[r.length,w.length,x.length,C.length,p.length,L.length,m.hiddenCount,i,s.length,B]);return{data:L,filteredData:w,sortedData:x,groupedData:C,searchedData:p,viewEngine:j,columnEngine:m,paginationEngine:A,metrics:I,isGrouped:B,isPaginated:(y==null?void 0:y.enabled)||!1}}let ql=0;function Jl(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):ql++,writable:!1,enumerable:!1,configurable:!1})}const Wt="user-demo-001";function Kl(e={}){var Mt,At,Oe,cr,Xo;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,pagination:a,search:l,scheduler:d,reportName:u,reportId:g,sharedReportId:b,sharedViewId:f,viewPersistence:S,permissions:y,config:E={},devConfig:j}=e,m=(S==null?void 0:S.mode)??"local",w=(a==null?void 0:a.mode)??"client",x=(l==null?void 0:l.mode)??"client",[C,B]=h.useState([]),p=j??mt,[A,L]=h.useState(""),[I,Q]=h.useState(!1),[ee,W]=h.useState(!1),[v,O]=h.useState({message:"",severity:"info",open:!1}),z=(T,D="info")=>{O({message:T,severity:D,open:!0})},q=()=>O(T=>({...T,open:!1})),Y=E.notifDurationMs,c=C.find(T=>T.id===A),[re,ae]=h.useState("idle"),[G,te]=h.useState(!1),[ue,le]=h.useState(!1),[Z,de]=h.useState(!1),[ie,P]=h.useState(!1),[oe,me]=h.useState(!1),[pe,Me]=h.useState(void 0),[N,Se]=h.useState(null),[Ae,it]=h.useState(null),[We,st]=h.useState(!1),[Ze,Nt]=h.useState(!1),[Et,Zt]=h.useState(null),[Nr,er]=h.useState(!1),[Lr,qe]=h.useState(!1),[Dt,Fr]=h.useState({enabled:!1,levels:[],collapsedGroups:[]}),[lt,tr]=h.useState(""),[Lt,Vr]=h.useState(""),[Ft,_t]=h.useState(new Set),[Vt,ct]=h.useState(1),[Ne,Hr]=h.useState(15),[Ur,hr]=h.useState(!1),[mr,rr]=h.useState(!1),[xo,kr]=h.useState(!1),[$t,He]=h.useState(null),[we,Ht]=h.useState(!1),[go,yo]=h.useState(null),[Gr,Yr]=h.useState(null),or=h.useRef(null),ke=h.useMemo(()=>c?cl(c.permissions,Wt):"owner",[c]),fr=dl(ke),rt=h.useMemo(()=>!(c!=null&&c.uploadedData)||!(c!=null&&c.schema)?{totalRows:0,totalColumns:0}:kl(c.uploadedData,c.schema),[c==null?void 0:c.uploadedData,c==null?void 0:c.schema]),gt=h.useCallback(()=>{c&&(or.current=Bl(c))},[c]),H=h.useCallback((T,D)=>{B(R=>R.map(M=>M.id===T?{...M,...D}:M))},[]),Ot=h.useCallback(T=>{if(!c)return;Yr(T);const D=Hi(c.id,Wt,T,c.auditHistory||[]);H(c.id,{auditHistory:D}),z(T.message,"error"),T.recoverable&&or.current&&setTimeout(()=>{Il(c,or.current,H),z("Previous state restored","success")},100)},[c,H]),K=h.useCallback((T,D,R,M)=>{if(!c)return;const X=Mo(c.id,Wt,T,D,R,M),J=c.auditHistory||[],ce=Ao(J,X);setTimeout(()=>{H(c.id,{auditHistory:ce})},0)},[c,H]);h.useEffect(()=>{if(c!=null&&c.schemaLocked&&c.schema&&(!c.views||c.views.length===0)){const T=Kn(c.schema);(()=>{try{const D=localStorage.getItem("urm_dev_config");return D?JSON.parse(D):null}catch{return null}})(),H(c.id,{views:[T],activeViewId:T.id,filters:T.snapshot.filters,sortStack:T.snapshot.sortStack,columnVisibility:T.snapshot.columnVisibility,columnOrder:T.snapshot.columnOrder,columnWidths:T.snapshot.columnWidths,grouping:T.snapshot.grouping})}},[c==null?void 0:c.schemaLocked,c==null?void 0:c.schema,c==null?void 0:c.id,H]),h.useEffect(()=>{if(i&&n&&!ee&&C.length===0){const T=po(i),D={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:T,schema:Oi(To(T),E.hiddenColumns),permissions:y??{owner:Wt,editors:[],viewers:[]}};B([D]),L(D.id),W(!0),ae("confirmed")}},[i,n,ee,C.length,r,u,g]),h.useEffect(()=>{w!=="server"||!ee||!A||H(A,{uploadedData:po(i||[])})},[i,w,ee,A]),h.useEffect(()=>{w==="server"&&((a==null?void 0:a.page)!==void 0&&ct(a.page),(a==null?void 0:a.pageSize)!==void 0&&Hr(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,w]),h.useEffect(()=>{if(!s||ee)return;let T=!1,D=null;const R=async()=>{try{ae("uploading");let M;if(s.type==="api"){const J=await fetch(s.url,{headers:s.headers||{}});if(!J.ok)throw new Error(`HTTP ${J.status}: ${J.statusText}`);M=await J.json()}else M=await s.fetch();if(T)return;if(!Array.isArray(M))throw new Error("Data source must return an array of objects");const X=To(M);if(ee)B(J=>J.map(ce=>ce.id===A?{...ce,uploadedData:po(M)}:ce)),ae("confirmed");else{const J={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:po(M),schema:Oi(To(po(M)),E.hiddenColumns),permissions:y??{owner:Wt,editors:[],viewers:[]}};B([J]),L(J.id),W(!0),ae("confirmed")}}catch(M){T||(ae("error"),c&&H(c.id,{uploadError:(M==null?void 0:M.message)||"Failed to load data from source"}))}};return R(),s.refreshInterval&&s.refreshInterval>0&&(D=setInterval(R,s.refreshInterval)),()=>{T=!0,D&&clearInterval(D)}},[s,u,r,g]);const at=(Mt=c==null?void 0:c.views)==null?void 0:Mt.find(T=>T.id===c.activeViewId),xr=h.useMemo(()=>c!=null&&c.uploadedData?(c.uploadedData.forEach(T=>Jl(T,E.getRowId)),c.uploadedData):[],[c==null?void 0:c.uploadedData]);h.useEffect(()=>{_t(T=>{if(T.size===0)return T;const D=new Set(xr.map(M=>M==null?void 0:M.__urm_row_id__)),R=new Set(Array.from(T).filter(M=>D.has(M==null?void 0:M.__urm_row_id__)));return R.size===T.size?T:R})},[xr]);const nr=Yl({rawData:xr,schema:(c==null?void 0:c.schema)||[],filters:Ge(c==null?void 0:c.filters),sortStack:(c==null?void 0:c.sortStack)||[],grouping:(c==null?void 0:c.grouping)||null,searchQuery:Lt||"",searchMode:x,columnVisibility:(c==null?void 0:c.columnVisibility)||(at==null?void 0:at.snapshot.columnVisibility)||{},columnOrder:(c==null?void 0:c.columnOrder)||(at==null?void 0:at.snapshot.columnOrder)||[],columnWidths:(c==null?void 0:c.columnWidths)||(at==null?void 0:at.snapshot.columnWidths)||{},views:(c==null?void 0:c.views)||[],activeViewId:(c==null?void 0:c.activeViewId)||"",pagination:{enabled:w==="client",pageSize:Ne,currentPage:Vt}}),{data:bo=[],searchedData:gr=[],groupedData:zr=[],sortedData:St=[],metrics:ir={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Tr=!1,paginationEngine:ve}=nr||{},wt=w==="server"?(a==null?void 0:a.totalRows)??0:Tr?ir.totalRows:ir.searchedRows,qr=w==="server"?Math.max(1,Math.ceil(((a==null?void 0:a.totalRows)??0)/Ne)):(ve==null?void 0:ve.totalPages)??1,U=((At=nr.viewEngine)==null?void 0:At.activeView)||at,Ke=((Oe=nr.viewEngine)==null?void 0:Oe.isDirty)||!1;h.useEffect(()=>{if(!(!U||!c)&&!c.columnOrder){const T=U.snapshot.columnOrder,D=Do(T,U.snapshot.grouping);H(c.id,{columnOrder:D})}},[c==null?void 0:c.activeViewId]);const Te=h.useMemo(()=>!(c!=null&&c.schema)||!U?null:Qa(c.filters,c.sortStack||[],c.schema,c.columnVisibility,c.columnOrder,c.columnWidths,c.grouping,U.snapshot.columnOrder),[c==null?void 0:c.filters,c==null?void 0:c.sortStack,c==null?void 0:c.schema,c==null?void 0:c.columnVisibility,c==null?void 0:c.columnOrder,c==null?void 0:c.columnWidths,c==null?void 0:c.grouping,U]),pt=h.useMemo(()=>!U||!Te||!Ke?[]:tl(Te,U.snapshot),[U,Te,Ke]),Br=h.useCallback((T,D,R)=>{const M={id:`report-${Date.now()}`,name:T,description:D,schemaLocked:!1,permissions:{owner:Wt,editors:[],viewers:[]}};if(R&&Array.isArray(R)&&R.length>0){const X=To(R),J=Kn(X);M.uploadedData=R,M.schema=X,M.schemaLocked=!0,M.views=[J],M.activeViewId=J.id,M.sortStack=J.snapshot.sortStack,M.filters=J.snapshot.filters,M.columnVisibility=J.snapshot.columnVisibility,M.columnOrder=J.snapshot.columnOrder,M.columnWidths=J.snapshot.columnWidths,M.grouping=J.snapshot.grouping}B(X=>[...X,M]),L(M.id),Q(!1),ae("confirmed")},[]),yt=h.useCallback(T=>{c&&(ae("uploading"),setTimeout(()=>{const D=To(T);H(c.id,{uploadedData:T,schema:D,uploadError:void 0}),ae("preview")},500))},[c,H]),vo=h.useCallback(T=>{c&&(H(c.id,{uploadError:T}),ae("idle"))},[c,H]),Ut=h.useCallback(()=>{c&&(H(c.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),ae("idle"))},[c,H]),Ir=h.useCallback(()=>{c&&(H(c.id,{schemaLocked:!0}),ae("confirmed"))},[c,H]),Jr=h.useCallback(T=>{if(!c)return;if(!jt("edit_sorting",ke)){z(kt("edit_sorting"),"error");return}const D=c.sortStack??[],R=D.find(M=>M.column===T);if(R){const M=Ga(R.direction);if(M===null){const X=D.filter(J=>J.column!==T).map((J,ce)=>({...J,priority:ce+1}));K("sorting","sort_level_removed",R,null),H(c.id,{sortStack:X.length>0?X:void 0})}else{const X=M,J=D.map(ce=>ce.column===T?{...ce,direction:X}:ce);K("sorting","sort_reordered",{column:T,direction:R.direction},{column:T,direction:X}),H(c.id,{sortStack:J})}}else{if(D.length>=p.sort.maxLevels){z(`Sort limit reached — maximum ${p.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:T,direction:"asc",priority:D.length+1};K("sorting","sort_level_added",null,M),H(c.id,{sortStack:[...D,M]})}},[c,ke,H,K]),Gt=h.useCallback(T=>{if(!c)return;const D=c.sortStack??[],R=T.length===0?"sort_cleared":"sort_reordered";if(c.schema){const{validRules:M,invalidColumns:X}=Ns(T,c.schema);X.length>0&&z(`Removed invalid sort columns: ${X.join(", ")}`),gt();try{K("sorting",R,D,M.length>0?M:null),H(c.id,{sortStack:M.length>0?M:void 0})}catch(J){const ce=wr("processing","sorting",J);Ot(ce)}}else K("sorting",R,D,T.length>0?T:null),H(c.id,{sortStack:T.length>0?T:void 0})},[c,H,gt,Ot,K]),Er=h.useCallback(T=>{if(!c)return;const D=c.sortStack??[],R=D.find(M=>M.column===T);if(!(R&&R.direction==="asc"))if(R){const M=D.map(X=>X.column===T?{...X,direction:"asc"}:X);K("sorting","sort_reordered",{column:T,direction:R.direction},{column:T,direction:"asc"}),H(c.id,{sortStack:M})}else{if(D.length>=p.sort.maxLevels){z(`Sort limit reached — maximum ${p.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:T,direction:"asc",priority:D.length+1};K("sorting","sort_level_added",null,M),H(c.id,{sortStack:[...D,M]})}},[c,H,K]),Kr=h.useCallback(T=>{if(!c)return;const D=c.sortStack??[],R=D.find(M=>M.column===T);if(!(R&&R.direction==="desc"))if(R){const M=D.map(X=>X.column===T?{...X,direction:"desc"}:X);K("sorting","sort_reordered",{column:T,direction:R.direction},{column:T,direction:"desc"}),H(c.id,{sortStack:M})}else{if(D.length>=p.sort.maxLevels){z(`Sort limit reached — maximum ${p.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const M={column:T,direction:"desc",priority:D.length+1};K("sorting","sort_level_added",null,M),H(c.id,{sortStack:[...D,M]})}},[c,H,K]),Dr=h.useCallback((T,D)=>{var M;if(!c)return;if(!jt("edit_filters",ke)){z(kt("edit_filters"),"error");return}const R=(M=c.schema)==null?void 0:M.find(X=>X.name===D.column);if(R&&D.value!==void 0){const X=El(R.type,D.operator,D.value);if(!X.isValid){z(X.errorMessage||"Invalid filter value","error");return}}gt();try{const X=Ge(c.filters),J={...D,id:mo()},ce=fo(X,T,J);K("filters","filter_added",null,J),H(c.id,{filters:ce})}catch(X){const J=wr("processing","filters",X);Ot(J)}},[c,ke,H,gt,Ot,K]),_r=h.useCallback(T=>{if(!c)return;if(!jt("edit_filters",ke)){z(kt("edit_filters"),"error");return}const D=Ge(c.filters),R=fo(D,T,Rt());K("filters","filter_added",null,"a condition group"),H(c.id,{filters:R})},[c,ke,H,K]),$r=h.useCallback((T,D)=>{if(!c)return;if(!jt("edit_filters",ke)){z(kt("edit_filters"),"error");return}const R=Ge(c.filters),M=an(R,T),X=yi(R,T,D),J=an(X,T);K("filters","filter_updated",M,J),H(c.id,{filters:X})},[c,ke,H,K]),Ce=h.useCallback((T,D)=>{if(!c)return;if(!jt("edit_filters",ke)){z(kt("edit_filters"),"error");return}const R=Ge(c.filters),M=bi(R,T,D);K("filters","filter_updated",null,`group operator changed to ${D.toUpperCase()}`),H(c.id,{filters:M})},[c,ke,H,K]),se=h.useCallback(T=>{if(!c)return;if(!jt("edit_filters",ke)){z(kt("edit_filters"),"error");return}const D=Ge(c.filters),R=an(D,T),M=vi(D,T);K("filters","filter_removed",R,null),H(c.id,{filters:M})},[c,ke,H,K]),fe=h.useCallback(()=>{if(!c)return;if(!jt("edit_filters",ke)){z(kt("edit_filters"),"error");return}const T=Ge(c.filters);K("filters","filter_cleared",{count:Tt(T)},null),H(c.id,{filters:Rt()})},[c,ke,H,K]),je=h.useCallback(T=>{if(!c)return;if(!jt("edit_filters",ke)){z(kt("edit_filters"),"error");return}const D=Ge(c.filters);K("filters","filter_cleared",{count:Tt(D)},{count:Tt(T)}),H(c.id,{filters:T})},[c,ke,H,K]),Pe=h.useCallback(T=>{var X;if(!c)return;const D=(X=c.views)==null?void 0:X.find(J=>J.id===T);if(!D)return;const R=D.snapshot.columnOrder,M=Do(R,D.snapshot.grouping);K("views","view_switched",{previousViewId:c.activeViewId},{viewId:T,name:D.name}),H(c.id,{filters:D.snapshot.filters,sortStack:D.snapshot.sortStack.length>0?[...D.snapshot.sortStack]:void 0,columnVisibility:{...D.snapshot.columnVisibility},columnOrder:M,columnWidths:{...D.snapshot.columnWidths},grouping:D.snapshot.grouping,activeViewId:T}),_t(new Set)},[c,H,K]),Xe=h.useCallback((T,D,R)=>{var be;if(!(c!=null&&c.schema)||!Te)return;const M=c.views??[],X=M.filter(Jt=>!Jt.isDeleted).length,J=((be=p.views)==null?void 0:be.maxViews)??10;if(X>=J){z(`View limit reached — you can have at most ${J} saved views. Delete an existing view to create a new one.`,"error");return}const ce={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:T,description:D||void 0,isDefault:R,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:Wt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Te}},ge=R?M.map(Jt=>({...Jt,isDefault:!1})):M;K("views","view_created",null,{viewId:ce.id,name:T,isDefault:R}),H(c.id,{views:[...ge,ce],activeViewId:ce.id}),z(`"${T}" view created`,"success")},[c,Te,H,K]),ht=h.useCallback(T=>{var ce;if(!(c!=null&&c.views))return;const D=c.views.find(ge=>ge.id===T);if(!D)return;const R=c.views,M=R.filter(ge=>!ge.isDeleted).length,X=((ce=p.views)==null?void 0:ce.maxViews)??10;if(M>=X){z(`View limit reached — you can have at most ${X} saved views. Delete an existing view to create a new one.`,"error");return}const J={...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:Wt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...D.snapshot}};H(c.id,{views:[...R,J]}),z(`"${J.name}" created`,"success")},[c,p,H]),dt=h.useCallback(()=>{var D;if(!U||!Te||!c)return;const T=(D=c.views)==null?void 0:D.map(R=>R.id===U.id?{...R,snapshot:{...Te}}:R);H(c.id,{views:T}),z(`"${U.name}" view updated`,"success")},[U,Te,c,H]),Ct=h.useCallback(T=>{var M;if(!U||!Te||!c)return;const D=T??Te.columnWidths,R=(M=c.views)==null?void 0:M.map(X=>X.id===U.id?{...X,snapshot:{...X.snapshot,columnVisibility:Te.columnVisibility,columnOrder:Te.columnOrder,columnWidths:D},updatedAt:Date.now()}:X);H(c.id,{views:R,columnWidths:D}),z(`Column configuration saved to "${U.name}"`,"success")},[U,Te,c,H]),Yt=h.useCallback(T=>{var J,ce;if(!Te||!c||!U)return;const D=T??Te.columnWidths,R={...U,snapshot:{...U.snapshot,columnVisibility:Te.columnVisibility,columnOrder:Te.columnOrder,columnWidths:D},updatedAt:Date.now()},M=(J=c.views)==null?void 0:J.map(ge=>ge.id===U.id?R:{...ge,snapshot:{...ge.snapshot,columnVisibility:Te.columnVisibility,columnOrder:Te.columnOrder,columnWidths:D},updatedAt:Date.now()});H(c.id,{views:M,columnWidths:D});const X=(((ce=c.views)==null?void 0:ce.length)||0)-1;z(`Column configuration saved to current view and ${X} other view${X===1?"":"s"}`,"success")},[Te,c,U,H]),yr=h.useCallback(()=>{de(!0)},[]),Or=h.useCallback(()=>{if(!U||!c)return;const T=U.snapshot.columnOrder,D=Do(T,U.snapshot.grouping);H(c.id,{filters:U.snapshot.filters,sortStack:U.snapshot.sortStack.length>0?[...U.snapshot.sortStack]:void 0,columnVisibility:{...U.snapshot.columnVisibility},columnOrder:D,columnWidths:{...U.snapshot.columnWidths},grouping:U.snapshot.grouping}),z("Changes reverted to last saved state","success")},[U,c,H]),So=h.useCallback(T=>{if(!(c!=null&&c.views))return;const D=c.views.map(M=>({...M,isDefault:M.id===T}));H(c.id,{views:D});const R=c.views.find(M=>M.id===T);R&&z(`"${R.name}" set as default view`,"success")},[c,H]),Vo=h.useCallback(T=>{if(!(c!=null&&c.views))return;const D=c.views.map(M=>M.id===T?{...M,isFavorite:!M.isFavorite,updatedAt:Date.now()}:M);H(c.id,{views:D});const R=c.views.find(M=>M.id===T);R&&!R.isFavorite?z(`"${R.name}" added to favorites`,"success"):R&&z(`"${R.name}" removed from favorites`,"info")},[c,H]),Xr=h.useCallback(T=>{if(!(c!=null&&c.views))return;const D=c.views.find(be=>be.id===T),R=c.views.filter(be=>!be.isDeleted||be.id===T);if((D==null?void 0:D.isDefault)&&R.filter(be=>be.isDefault).length===1){z("Cannot delete the last default view","error");return}const X=c.views.map(be=>be.id===T?{...be,isDeleted:!0,updatedAt:Date.now()}:be),J=c.activeViewId===T,ce=X.find(be=>be.isDefault&&!be.isDeleted);H(c.id,{views:X,activeViewId:J&&ce?ce.id:c.activeViewId,filters:J&&ce?ce.snapshot.filters:c.filters,sortStack:J&&ce?ce.snapshot.sortStack.length>0?ce.snapshot.sortStack:void 0:c.sortStack});const ge=c.views.find(be=>be.id===T);ge&&z(`"${ge.name}" moved to Recently Deleted`,"info")},[c,H]),Mn=h.useCallback(T=>{if(!(c!=null&&c.views))return;const D=c.views.map(M=>M.id===T?{...M,isDeleted:!1,updatedAt:Date.now()}:M);H(c.id,{views:D});const R=c.views.find(M=>M.id===T);R&&z(`"${R.name}" restored`,"success")},[c,H]),Qr=h.useCallback(T=>{if(!(c!=null&&c.views))return;const D=c.views.find(ge=>ge.id===T),R=c.views.filter(ge=>!ge.isDeleted||ge.id===T);if((D==null?void 0:D.isDefault)&&R.filter(ge=>ge.isDefault).length===1){z("Cannot delete the last default view","error");return}const X=c.views.filter(ge=>ge.id!==T),J=c.activeViewId===T,ce=X.find(ge=>ge.isDefault&&!ge.isDeleted);H(c.id,{views:X,activeViewId:J&&ce?ce.id:c.activeViewId,filters:J&&ce?ce.snapshot.filters:c.filters,sortStack:J&&ce?ce.snapshot.sortStack.length>0?ce.snapshot.sortStack:void 0:c.sortStack}),D&&z(`"${D.name}" permanently deleted`,"success")},[c,H]),wo=h.useCallback(T=>{Se(T),P(!0)},[]),An=h.useCallback(async T=>{if(!c)return;const D=new URLSearchParams(window.location.search);D.set("reportId",c.id),D.set("view",T);const R=`${window.location.origin}${window.location.pathname}?${D.toString()}`,M=await jl(R);z(M?"Link copied to clipboard":"Failed to copy link",M?"success":"error")},[c]),Ho=h.useCallback((T,D)=>{if(!N||!(c!=null&&c.views))return;const R=c.views.map(M=>M.id===N?{...M,name:T,description:D||void 0}:M);H(c.id,{views:R}),Se(null)},[N,c,H]),Zr=h.useCallback(T=>{it(T),me(!0)},[]),Uo=h.useCallback(()=>{if(!Ae||!(c!=null&&c.views))return;const T=c.views.find(X=>X.id===Ae),D=c.views.filter(X=>X.id!==Ae),R=c.activeViewId===Ae,M=D.find(X=>X.isDefault);K("views","view_deleted",{viewId:Ae,name:T==null?void 0:T.name},null),H(c.id,{views:D,activeViewId:R&&M?M.id:c.activeViewId,filters:R&&M?M.snapshot.filters:c.filters,sortStack:R&&M?M.snapshot.sortStack.length>0?M.snapshot.sortStack:void 0:c.sortStack}),it(null),me(!1)},[Ae,c,H,K]),eo=h.useCallback(T=>{var X;if(!(c!=null&&c.views))return;if(!(((X=p.views)==null?void 0:X.isAdmin)??!1)){z("Only administrators can promote views to Global.","error");return}const R=c.views.find(J=>J.id===T);if(!R)return;if(R.scope==="global"){z(`"${R.name}" is already a Global View.`,"info");return}const M=c.views.map(J=>J.id===T?{...J,scope:"global",isDefault:!0,updatedAt:Date.now()}:J.scope==="global"&&J.isDefault?{...J,isDefault:!1}:J);H(c.id,{views:M}),z(`"${R.name}" promoted to Global View and set as default.`,"success")},[c,p,H]),Co=h.useCallback((T,D)=>{if(!(c!=null&&c.views))return;const R=c.views.find(J=>J.id===T);if(!R)return;const M=c.views.map(J=>J.id===T?{...J,isDefaultForAllUsers:D,updatedAt:Date.now()}:D&&J.isDefaultForAllUsers?{...J,isDefaultForAllUsers:!1}:J);K("views",D?"view_set_default":"view_updated",{viewId:T,isDefaultForAllUsers:!D},{viewId:T,isDefaultForAllUsers:D}),H(c.id,{views:M}),z(`"${R.name}" ${D?"set as":"removed from"} default for all users.`,"success")},[c,H,K]),jo=h.useRef(!0);h.useEffect(()=>{var T;if(jo.current){jo.current=!1;return}if(w==="server"){ct(1),(T=a==null?void 0:a.onPaginationChange)==null||T.call(a,1,Ne);return}ve!=null&&ve.resetPage?ve.resetPage():ct(1)},[c==null?void 0:c.filters,Lt,c==null?void 0:c.activeViewId]);const to=h.useCallback(T=>{var D;if(w==="server"){ct(T),(D=a==null?void 0:a.onPaginationChange)==null||D.call(a,T,Ne);return}ve!=null&&ve.goToPage&&ve.goToPage(T)},[w,a,Ne,ve]),ro=h.useCallback(T=>{var X;const R=((w==="server"?Vt:(ve==null?void 0:ve.currentPage)||1)-1)*Ne,M=Math.floor(R/T)+1;if(w==="server"){Hr(T),ct(M),(X=a==null?void 0:a.onPaginationChange)==null||X.call(a,M,T);return}Hr(T),ve==null||ve.goToPage(M)},[Vt,Ne,w,a,ve]),br=h.useCallback((T,D)=>{if(!c)return;if(!jt("edit_columns",ke)){z(kt("edit_columns"),"error");return}const M={...c.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{},[T]:D};K("columns",D?"column_shown":"column_hidden",{columnName:T,visible:!D},{columnName:T,visible:D}),H(c.id,{columnVisibility:M})},[c,U,ke,H,K]),Go=h.useCallback(T=>{if(c){if(!jt("edit_columns",ke)){z(kt("edit_columns"),"error");return}K("columns","column_reordered",c.columnOrder,T),H(c.id,{columnOrder:T})}},[c,ke,H,K]),oo=h.useCallback((T,D)=>{if(!c)return;if(!jt("edit_columns",ke)){z(kt("edit_columns"),"error");return}const R=c.columnWidths||(U==null?void 0:U.snapshot.columnWidths)||{},M={...R,[T]:D};K("columns","column_resized",{columnName:T,width:R[T]},{columnName:T,width:D}),H(c.id,{columnWidths:M})},[c,U,ke,H,K]),Wn=h.useCallback(T=>{if(!c)return;const D=Ge(c.filters),R=Ws(D,T);H(c.id,{filters:R})},[c,H]),Rn=h.useCallback(()=>{if(!U||!(c!=null&&c.schema))return;const T={},D=[],R={};c.schema.forEach(M=>{T[M.name]=!0,D.push(M.name),R[M.name]=170}),H(c.id,{columnVisibility:T,columnOrder:D,columnWidths:R,filters:void 0,sortStack:void 0}),z("Reset to default layout - all filters and sorts cleared","success")},[U,c,H]);h.useEffect(()=>{const T=setTimeout(()=>Vr(lt),300);return()=>clearTimeout(T)},[lt]),h.useEffect(()=>{var T;x==="server"&&((T=l==null?void 0:l.onSearchChange)==null||T.call(l,Lt))},[Lt,x,l]);const Pn=h.useCallback(T=>{tr(T),ct(1)},[]),Nn=h.useCallback(T=>{if(!T.trim()||!c)return;const D=c.searchHistory||[],R=nl(D,T);H(c.id,{searchHistory:R})},[c,H]),Ln=h.useCallback(T=>{if(!c)return;const D=c.searchHistory||[],R=il(D,T);H(c.id,{searchHistory:R})},[c,H]),Fn=h.useCallback(T=>{if(!c)return;const D=c.searchHistory||[],R=sl(D,T);H(c.id,{searchHistory:R})},[c,H]);h.useEffect(()=>{if(!E.onSelectionChange)return;const T=Array.from(Ft);E.onSelectionChange(T,T.map(D=>D==null?void 0:D.__urm_row_id__))},[Ft,E.onSelectionChange]);const Vn=h.useCallback(T=>{const D=T==null?void 0:T.__urm_row_id__;_t(R=>{const M=new Set(R);let X;return D!==void 0?X=Array.from(M).find(J=>(J==null?void 0:J.__urm_row_id__)===D):X=Array.from(M).find(J=>J===T),X!==void 0?M.delete(X):M.add(T),M})},[]),Hn=h.useCallback((T,D)=>{_t(R=>{const M=new Set(R),X=D.filter(J=>!J.isGroupHeader);for(const J of X){const ce=J==null?void 0:J.__urm_row_id__;if(T){let ge;ce!==void 0?ge=Array.from(M).find(be=>(be==null?void 0:be.__urm_row_id__)===ce):ge=Array.from(M).find(be=>be===J),ge===void 0&&M.add(J)}else{let ge;ce!==void 0?ge=Array.from(M).find(be=>(be==null?void 0:be.__urm_row_id__)===ce):ge=Array.from(M).find(be=>be===J),ge!==void 0&&M.delete(ge)}}return M})},[]),Un=h.useCallback((T,D,R)=>{_t(M=>{const X=new Set(M),J=R.filter(be=>!be.isGroupHeader),ce=Math.min(T,D),ge=Math.max(T,D);for(let be=ce;be<=ge;be++){const Jt=J[be];if(!Jt)continue;const Di=Jt==null?void 0:Jt.__urm_row_id__;let Jn;Di!==void 0?Jn=Array.from(X).find(zo=>(zo==null?void 0:zo.__urm_row_id__)===Di):Jn=Array.from(X).find(zo=>zo===Jt),Jn===void 0&&X.add(Jt)}return X})},[]),no=h.useCallback(()=>{_t(new Set)},[]),sr=h.useCallback(T=>{const D=T==null?void 0:T.__urm_row_id__;_t(R=>{const M=new Set(R);if(D!==void 0){const X=Array.from(M).find(J=>(J==null?void 0:J.__urm_row_id__)===D);X!==void 0&&M.delete(X)}else M.delete(T);return M})},[]),Gn=h.useCallback(T=>{var D,R;if(c){if(!jt("edit_columns",ke)){z(kt("edit_columns"),"error");return}if(T&&c.schema){const{validGrouping:M,invalidColumns:X}=Ls(T,c.schema);X.length>0&&z(`Removed invalid grouping columns: ${X.join(", ")}`,"warning"),gt();try{const J=c.grouping;M===null?K("grouping","group_cleared",J,null):J?K("grouping","group_reordered",J,M):K("grouping","group_level_added",null,M);const ce=(U==null?void 0:U.snapshot.columnOrder)||c.columnOrder||[],ge=Do(ce,M),be=M.levels.length>0?{...M,collapsedGroups:Ai(St,c.schema,M)}:M;H(c.id,{grouping:be,columnOrder:ge}),w==="server"?(ct(1),(D=a==null?void 0:a.onPaginationChange)==null||D.call(a,1,Ne)):ve==null||ve.resetPage(),JSON.stringify(ge)!==JSON.stringify(c.columnOrder)&&K("columns","column_reordered",c.columnOrder,ge),qe(!1)}catch(J){const ce=wr("processing","grouping",J);Ot(ce)}}else{const M=c.grouping;K("grouping","group_cleared",M,null);const X=(U==null?void 0:U.snapshot.columnOrder)||c.columnOrder||[];H(c.id,{grouping:T,columnOrder:X}),w==="server"?(ct(1),(R=a==null?void 0:a.onPaginationChange)==null||R.call(a,1,Ne)):ve==null||ve.resetPage(),JSON.stringify(X)!==JSON.stringify(c.columnOrder)&&K("columns","column_reordered",c.columnOrder,X),qe(!1)}}},[c,U,ke,H,gt,Ot,K,St]),Yn=h.useCallback(T=>{if(!c||!p.grouping.allowCollapse)return;const D=c.grouping;if(!D)return;const R=Ka(D,T);H(c.id,{grouping:R})},[c,p,H]),Ue=h.useCallback(()=>{!(c!=null&&c.grouping)||!p.grouping.allowCollapse||H(c.id,{grouping:{...c.grouping,collapsedGroups:[]}})},[c,p,H]),et=h.useCallback(()=>{if(!(c!=null&&c.grouping)||!c.schema||!p.grouping.allowCollapse)return;const T=Ai(St,c.schema,c.grouping);H(c.id,{grouping:{...c.grouping,collapsedGroups:T}})},[c,St,p,H]),ko=h.useCallback(()=>{Ht(!0)},[]),qt=h.useCallback(T=>{c!=null&&c.schema&&(st(!0),setTimeout(()=>{try{let D;T.scope==="visible"?D=gr:D=c.uploadedData||[];let R;T.columnScope==="all"?(R={},(c.schema??[]).forEach(ge=>{R[ge.name]=!0})):R=c.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{};const M=c.columnOrder||(U==null?void 0:U.snapshot.columnOrder),X=cn(D,c.schema,Ge(c.filters),c.sortStack??[],U,R,M),J=c.name;let ce;switch(T.format){case"csv":dn(X,J,T),ce="export_csv";break;case"excel":un(X,J,T),ce="export_excel";break;case"json":pn(X,J,T),ce="export_json";break;case"pdf":Ci(X,J,T),ce="export_pdf";break}K("export",ce,null,{format:T.format,scope:T.scope,columnScope:T.columnScope,rowCount:D.length,viewName:(U==null?void 0:U.name)||"Default View"}),z(`Export completed successfully (${T.format.toUpperCase()})`,"success")}catch(D){const R=_l(D,{onRetry:()=>qt(T)});z(`Export failed: ${R.message}. Click Export to retry.`,"error");const M=Hi(c.id,Wt,R,c.auditHistory||[]);H(c.id,{auditHistory:M}),Qt.error("urm:report-engine","Export failed",D)}finally{st(!1)}},500))},[c,U,gr,H,K]),Yo=h.useCallback(T=>{if(c!=null&&c.schema){if(Ke&&U&&!U.isDefault){Zt(T.format),Nt(!0),Ht(!1);return}qt(T),Ht(!1)}},[c,U,Ke,qt]),io=h.useCallback(T=>{qt({format:T,scope:"visible",columnScope:"visible"})},[qt]),ar=h.useCallback(()=>{Et&&io(Et),Nt(!1),Zt(null)},[Et,io]),lr=h.useCallback(()=>{dt(),Et&&io(Et),Nt(!1),Zt(null)},[dt,Et,io]),qo=h.useCallback(()=>{Nt(!1),Zt(null)},[]),qn=h.useCallback(T=>{!(c!=null&&c.schema)||Ft.size===0||(st(!0),setTimeout(()=>{try{const D=Array.from(Ft),R=cn(D,c.schema,Ge(c.filters),c.sortStack??[],U),M=`${c.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(T){case"csv":dn(R,M);break;case"excel":un(R,M);break;case"json":pn(R,M);break}z(`Exported ${D.length} selected rows`,"info")}catch(D){z("Export failed. Please try again.","error"),Qt.error("urm:report-engine","Bulk export failed",D)}finally{st(!1)}},500))},[c,U,Ft,zr]),Jo=h.useCallback((T,D)=>{if(c)try{const R=yl(c),M=bl(T,D,Wt,R),X=vl(c.presets,M);H(c.id,{presets:X}),K("presets","preset_created",null,{presetId:M.id,name:M.name}),rr(!1),z(`Preset "${T}" saved successfully`,"success")}catch(R){z(R instanceof Error?R.message:"Failed to create preset","error")}},[c,H,K]),Ko=h.useCallback(()=>{He(null),z("Exited preset view","info")},[]),k=h.useCallback(()=>{kr(!0)},[]),F=h.useCallback((T,D)=>{if(!c)return;const R=Sl(c.presets,T);H(c.id,{presets:R}),K("presets","preset_deleted",{presetId:T,name:D},null),$t===T&&He(null),z(`Preset "${D}" deleted`,"success")},[c,$t,H,K]);h.useEffect(()=>{if(!b||C.length===0)return;const T=C.find(D=>D.id===b);T&&T.id!==A&&L(T.id)},[b,C,A]);const ne=h.useRef(!1);h.useEffect(()=>{var D;if(!f||ne.current||!c||c.id!==b)return;const T=(D=c.views)==null?void 0:D.find(R=>R.id===f&&!R.isDeleted);T&&Pe(T.id),ne.current=!0},[f,b,c,Pe]),h.useEffect(()=>{if(!c)return;const T=wl();if(T&&c.presets&&c.schemaLocked&&c.schema){const D=Vi(c.presets,T);if(D){const{sanitizedConfig:R,warnings:M}=Dl(D.config,c.schema);M.length>0&&M.forEach(J=>z(J,"warning"));const X=Cl(R);H(c.id,X),He(T),K("presets","preset_applied",null,{presetId:D.id,name:D.name}),z(`Loaded preset: ${D.name}`,"info")}else z("Preset not found","info")}},[c==null?void 0:c.schemaLocked]);const ze=$t?Vi(c==null?void 0:c.presets,$t):void 0;h.useEffect(()=>{var T;c!=null&&c.views&&c.views.length>0&&c.activeViewId&&((T=S==null?void 0:S.onViewsChange)==null||T.call(S,c.views,c.activeViewId),m!=="api"&&rl(c.id,{views:c.views,activeViewId:c.activeViewId}))},[c==null?void 0:c.views,c==null?void 0:c.activeViewId,c==null?void 0:c.id,m,S]),h.useEffect(()=>{if(c!=null&&c.schemaLocked&&c.schema&&(!c.views||c.views.length===0)){const T=m==="api"?S!=null&&S.views&&S.views.length>0?{views:S.views,activeViewId:S.activeViewId??S.views[0].id}:null:ol(c.id);if(T&&T.views.length>0){const D=T.views.find(R=>R.id===T.activeViewId);if(D)H(c.id,{views:T.views,activeViewId:T.activeViewId,filters:Ge(D.snapshot.filters),sortStack:D.snapshot.sortStack.length>0?D.snapshot.sortStack:void 0});else{const R=T.views.find(M=>M.isDefault)||Kn(c.schema);H(c.id,{views:T.views,activeViewId:R.id,filters:Ge(R.snapshot.filters),sortStack:R.snapshot.sortStack.length>0?R.snapshot.sortStack:void 0})}}}},[c==null?void 0:c.schemaLocked,c==null?void 0:c.schema,c==null?void 0:c.id,m,S]);const Le=h.useCallback(T=>{var M;const D=Ge(c==null?void 0:c.filters),R=((M=p.filter)==null?void 0:M.maxConditions)??3;if(Tt(D)>=R){z(`Filter limit reached — maximum ${R} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}Me(T),te(!0)},[c,p,z]),ot=h.useCallback(()=>{te(!1),Me(void 0)},[]),tt=(cr=c==null?void 0:c.views)==null?void 0:cr.find(T=>T.id===N),xe=(Xo=c==null?void 0:c.views)==null?void 0:Xo.find(T=>T.id===Ae);return{reports:C,activeReport:c,activeReportId:A,setActiveReportId:L,isModalOpen:I,setIsModalOpen:Q,createReport:Br,updateReport:H,uploadState:re,handleFileUpload:yt,handleUploadError:vo,handleRetry:Ut,handleConfirm:Ir,paginatedData:bo,processedData:gr,displayData:zr,tableMetrics:ir,isGrouped:Tr,tableEngine:nr,activeView:U,isDirty:Ke,currentTableState:Te,viewChanges:pt,filters:c==null?void 0:c.filters,showFilterPanel:G,setShowFilterPanel:te,filterFocusColumn:pe,handleAddCondition:Dr,handleAddGroup:_r,handleUpdateCondition:$r,handleSetGroupOperator:Ce,handleRemoveFilterNode:se,handleClearAllFilters:fe,handleReplaceFilters:je,handleOpenFilterForColumn:Le,handleCloseFilterPanel:ot,handleClearFiltersForColumn:Wn,sortStack:c==null?void 0:c.sortStack,showSortPanel:ue,setShowSortPanel:le,handleSort:Jr,handleUpdateSortStack:Gt,handleSortAscending:Er,handleSortDescending:Kr,views:c==null?void 0:c.views,showCreateViewModal:Z,setShowCreateViewModal:de,showEditViewModal:ie,setShowEditViewModal:P,showDeleteConfirmation:oe,setShowDeleteConfirmation:me,editingView:tt,deletingView:xe,editingViewId:N,deletingViewId:Ae,handleSelectView:Pe,handleCreateView:Xe,handleCloneView:ht,handleUpdateCurrentView:dt,handleSaveColumnConfigToCurrentView:Ct,handleSaveColumnConfigToAllViews:Yt,handleSaveAsNewView:yr,handleRevertChanges:Or,handleToggleDefault:So,handleToggleFavorite:Vo,handleSoftDelete:Xr,handleRestoreView:Mn,handlePermanentDelete:Qr,handleEditView:wo,handleCopyViewLink:An,handleSaveEditView:Ho,handleDeleteView:Zr,handleConfirmDelete:Uo,handlePromoteToGlobal:eo,handleSetDefaultForAllUsers:Co,showManageColumns:Nr,setShowManageColumns:er,columnVisibility:c==null?void 0:c.columnVisibility,columnOrder:c==null?void 0:c.columnOrder,columnWidths:c==null?void 0:c.columnWidths,handleUpdateColumnVisibility:br,handleUpdateColumnOrder:Go,handleUpdateColumnWidth:oo,handleResetColumnLayout:Rn,showGroupPanel:Lr,setShowGroupPanel:qe,grouping:c==null?void 0:c.grouping,groupingState:Dt,handleGroup:Gn,handleToggleGroupCollapse:Yn,handleExpandAllGroups:Ue,handleCollapseAllGroups:et,searchQuery:lt,debouncedSearchQuery:Lt,searchHistory:al((c==null?void 0:c.searchHistory)||[]),handleSearchChange:Pn,handleAddToSearchHistory:Nn,handleToggleSearchFavourite:Ln,handleDeleteSearchHistory:Fn,selectedRowIds:Ft,handleToggleRowSelection:Vn,handleToggleAllRows:Hn,handleRangeSelection:Un,handleClearSelection:no,handleUpdateSelectionAfterDelete:sr,currentPage:w==="server"?Vt:(ve==null?void 0:ve.currentPage)||1,pageSize:Ne,paginationEngine:ve,paginationMode:w,paginationTotalRows:wt,paginationTotalPages:qr,handlePageChange:to,handlePageSizeChange:ro,isExporting:We,showExportModal:we,setShowExportModal:Ht,showDirtyExportWarning:Ze,handleExport:ko,handleExportWithConfig:Yo,handleExportSelected:qn,handleExportAnyway:ar,handleSaveAndExport:lr,handleCancelExport:qo,showAuditHistory:Ur,setShowAuditHistory:hr,auditHistory:c==null?void 0:c.auditHistory,showCreatePreset:mr,setShowCreatePreset:rr,showManagePresets:xo,setShowManagePresets:kr,activePreset:ze,activePresetId:$t,handleOpenManagePresets:k,handleCreatePreset:Jo,handleClearActivePreset:Ko,handleDeletePresetById:F,userRole:ke,isViewerRole:fr,currentUserId:Wt,permissions:c==null?void 0:c.permissions,featureLimitWarning:go,setFeatureLimitWarning:yo,datasetMeta:rt,reportError:Gr,setReportError:Yr,handleError:Ot,schema:c==null?void 0:c.schema,hasSchemaConflicts:c!=null&&c.schema?Ha(c.schema):!1,snack:v,handleSnackClose:q,showSnack:z,snackDurationMs:Y,config:E,scheduler:d}}const Fs=h.createContext(mt);function Rr(){return h.useContext(Fs)}const Vs=h.createContext(void 0);function ki(e){const{children:r,initialData:n,data:i,reportName:s,reportId:a,dataSource:l,pagination:d,search:u,scheduler:g,mode:b="builder",autoLoad:f=!0,config:S,devConfig:y,showDevPanel:E=!1,sharedReportId:j,sharedViewId:m,viewPersistence:w,permissions:x}=e,C=i||n,[B,p]=h.useState(()=>za()),A=(()=>{const W=Ba(B,y,!!y);return{...W,display:{...W.display,showDevPanel:E||W.display.showDevPanel}}})(),L=Kl({mode:b,autoLoad:f,initialData:C,dataSource:l,pagination:d,search:u,scheduler:g,reportName:s,reportId:a,sharedReportId:j,sharedViewId:m,viewPersistence:w,permissions:x,config:S,devConfig:A}),I=h.useCallback(ee=>{p(ee),Ta(ee)},[]),Q={...L,activeDevConfig:A,handleDevConfigChange:I};return t.jsx(Fs.Provider,{value:A,children:t.jsx(Vs.Provider,{value:Q,children:r})})}function bn(){const e=h.useContext(Vs);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Xl({onCreateReport:e,reports:r=[],activeReportId:n,onReportClick:i}){const s=r.find(a=>a.id===n);return t.jsx(o.Box,{component:"header",sx:a=>{var b,f,S;const l=((S=(f=(b=a.components)==null?void 0:b.MuiCardHeader)==null?void 0:f.styleOverrides)==null?void 0:S.root)||{},d=l.backgroundColor&&l.backgroundColor!=="transparent"?l.backgroundColor:a.palette.background.paper,u=l.borderBottom&&l.borderBottom!=="none"?l.borderBottom:"1px solid",g=l.boxShadow&&l.boxShadow!=="none"?l.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:u,borderColor:u!=="none"?"divider":void 0,boxShadow:g,bgcolor:d}},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 Wr(e,...r){const n=new URL(`https://mui.com/production-error/?code=${e}`);return r.forEach(i=>n.searchParams.append("args[]",i)),`Minified MUI error #${e}; visit ${n} for the full message.`}const Ql="$$material";function Zl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var en={exports:{}},tn={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 Ui;function ec(){if(Ui)return Be;Ui=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,l=e?Symbol.for("react.provider"):60109,d=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,g=e?Symbol.for("react.concurrent_mode"):60111,b=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,S=e?Symbol.for("react.suspense_list"):60120,y=e?Symbol.for("react.memo"):60115,E=e?Symbol.for("react.lazy"):60116,j=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,w=e?Symbol.for("react.responder"):60118,x=e?Symbol.for("react.scope"):60119;function C(p){if(typeof p=="object"&&p!==null){var A=p.$$typeof;switch(A){case r:switch(p=p.type,p){case u:case g:case i:case a:case s:case f:return p;default:switch(p=p&&p.$$typeof,p){case d:case b:case E:case y:case l:return p;default:return A}}case n:return A}}}function B(p){return C(p)===g}return Be.AsyncMode=u,Be.ConcurrentMode=g,Be.ContextConsumer=d,Be.ContextProvider=l,Be.Element=r,Be.ForwardRef=b,Be.Fragment=i,Be.Lazy=E,Be.Memo=y,Be.Portal=n,Be.Profiler=a,Be.StrictMode=s,Be.Suspense=f,Be.isAsyncMode=function(p){return B(p)||C(p)===u},Be.isConcurrentMode=B,Be.isContextConsumer=function(p){return C(p)===d},Be.isContextProvider=function(p){return C(p)===l},Be.isElement=function(p){return typeof p=="object"&&p!==null&&p.$$typeof===r},Be.isForwardRef=function(p){return C(p)===b},Be.isFragment=function(p){return C(p)===i},Be.isLazy=function(p){return C(p)===E},Be.isMemo=function(p){return C(p)===y},Be.isPortal=function(p){return C(p)===n},Be.isProfiler=function(p){return C(p)===a},Be.isStrictMode=function(p){return C(p)===s},Be.isSuspense=function(p){return C(p)===f},Be.isValidElementType=function(p){return typeof p=="string"||typeof p=="function"||p===i||p===g||p===a||p===s||p===f||p===S||typeof p=="object"&&p!==null&&(p.$$typeof===E||p.$$typeof===y||p.$$typeof===l||p.$$typeof===d||p.$$typeof===b||p.$$typeof===m||p.$$typeof===w||p.$$typeof===x||p.$$typeof===j)},Be.typeOf=C,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 Gi;function tc(){return Gi||(Gi=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,l=e?Symbol.for("react.provider"):60109,d=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,g=e?Symbol.for("react.concurrent_mode"):60111,b=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,S=e?Symbol.for("react.suspense_list"):60120,y=e?Symbol.for("react.memo"):60115,E=e?Symbol.for("react.lazy"):60116,j=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,w=e?Symbol.for("react.responder"):60118,x=e?Symbol.for("react.scope"):60119;function C(N){return typeof N=="string"||typeof N=="function"||N===i||N===g||N===a||N===s||N===f||N===S||typeof N=="object"&&N!==null&&(N.$$typeof===E||N.$$typeof===y||N.$$typeof===l||N.$$typeof===d||N.$$typeof===b||N.$$typeof===m||N.$$typeof===w||N.$$typeof===x||N.$$typeof===j)}function B(N){if(typeof N=="object"&&N!==null){var Se=N.$$typeof;switch(Se){case r:var Ae=N.type;switch(Ae){case u:case g:case i:case a:case s:case f:return Ae;default:var it=Ae&&Ae.$$typeof;switch(it){case d:case b:case E:case y:case l:return it;default:return Se}}case n:return Se}}}var p=u,A=g,L=d,I=l,Q=r,ee=b,W=i,v=E,O=y,z=n,q=a,Y=s,c=f,re=!1;function ae(N){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.")),G(N)||B(N)===u}function G(N){return B(N)===g}function te(N){return B(N)===d}function ue(N){return B(N)===l}function le(N){return typeof N=="object"&&N!==null&&N.$$typeof===r}function Z(N){return B(N)===b}function de(N){return B(N)===i}function ie(N){return B(N)===E}function P(N){return B(N)===y}function oe(N){return B(N)===n}function me(N){return B(N)===a}function pe(N){return B(N)===s}function Me(N){return B(N)===f}Ie.AsyncMode=p,Ie.ConcurrentMode=A,Ie.ContextConsumer=L,Ie.ContextProvider=I,Ie.Element=Q,Ie.ForwardRef=ee,Ie.Fragment=W,Ie.Lazy=v,Ie.Memo=O,Ie.Portal=z,Ie.Profiler=q,Ie.StrictMode=Y,Ie.Suspense=c,Ie.isAsyncMode=ae,Ie.isConcurrentMode=G,Ie.isContextConsumer=te,Ie.isContextProvider=ue,Ie.isElement=le,Ie.isForwardRef=Z,Ie.isFragment=de,Ie.isLazy=ie,Ie.isMemo=P,Ie.isPortal=oe,Ie.isProfiler=me,Ie.isStrictMode=pe,Ie.isSuspense=Me,Ie.isValidElementType=C,Ie.typeOf=B})()),Ie}var Yi;function Hs(){return Yi||(Yi=1,process.env.NODE_ENV==="production"?tn.exports=ec():tn.exports=tc()),tn.exports}/*
|
|
120
120
|
object-assign
|
|
121
121
|
(c) Sindre Sorhus
|
|
122
122
|
@license MIT
|
|
123
|
-
*/var
|
|
124
|
-
Valid keys: `+JSON.stringify(Object.keys(
|
|
123
|
+
*/var Zn,qi;function rc(){if(qi)return Zn;qi=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 l={},d=0;d<10;d++)l["_"+String.fromCharCode(d)]=d;var u=Object.getOwnPropertyNames(l).map(function(b){return l[b]});if(u.join("")!=="0123456789")return!1;var g={};return"abcdefghijklmnopqrst".split("").forEach(function(b){g[b]=b}),Object.keys(Object.assign({},g)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Zn=s()?Object.assign:function(a,l){for(var d,u=i(a),g,b=1;b<arguments.length;b++){d=Object(arguments[b]);for(var f in d)r.call(d,f)&&(u[f]=d[f]);if(e){g=e(d);for(var S=0;S<g.length;S++)n.call(d,g[S])&&(u[g[S]]=d[g[S]])}}return u},Zn}var ei,Ji;function zi(){if(Ji)return ei;Ji=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ei=e,ei}var ti,Ki;function Us(){return Ki||(Ki=1,ti=Function.call.bind(Object.prototype.hasOwnProperty)),ti}var ri,Xi;function oc(){if(Xi)return ri;Xi=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=zi(),n={},i=Us();e=function(a){var l="Warning: "+a;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}}}function s(a,l,d,u,g){if(process.env.NODE_ENV!=="production"){for(var b in a)if(i(a,b)){var f;try{if(typeof a[b]!="function"){var S=Error((u||"React class")+": "+d+" type `"+b+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[b]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw S.name="Invariant Violation",S}f=a[b](l,b,u,d,null,r)}catch(E){f=E}if(f&&!(f instanceof Error)&&e((u||"React class")+": type specification of "+d+" `"+b+"` 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 y=g?g():"";e("Failed "+d+" type: "+f.message+(y??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},ri=s,ri}var oi,Qi;function nc(){if(Qi)return oi;Qi=1;var e=Hs(),r=rc(),n=zi(),i=Us(),s=oc(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(d){var u="Warning: "+d;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function l(){return null}return oi=function(d,u){var g=typeof Symbol=="function"&&Symbol.iterator,b="@@iterator";function f(G){var te=G&&(g&&G[g]||G[b]);if(typeof te=="function")return te}var S="<<anonymous>>",y={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:x(),arrayOf:C,element:B(),elementType:p(),instanceOf:A,node:ee(),objectOf:I,oneOf:L,oneOfType:Q,shape:v,exact:O};function E(G,te){return G===te?G!==0||1/G===1/te:G!==G&&te!==te}function j(G,te){this.message=G,this.data=te&&typeof te=="object"?te:{},this.stack=""}j.prototype=Error.prototype;function m(G){if(process.env.NODE_ENV!=="production")var te={},ue=0;function le(de,ie,P,oe,me,pe,Me){if(oe=oe||S,pe=pe||P,Me!==n){if(u){var N=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 N.name="Invariant Violation",N}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Se=oe+":"+P;!te[Se]&&ue<3&&(a("You are manually calling a React.PropTypes validation function for the `"+pe+"` prop on `"+oe+"`. 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."),te[Se]=!0,ue++)}}return ie[P]==null?de?ie[P]===null?new j("The "+me+" `"+pe+"` is marked as required "+("in `"+oe+"`, but its value is `null`.")):new j("The "+me+" `"+pe+"` is marked as required in "+("`"+oe+"`, but its value is `undefined`.")):null:G(ie,P,oe,me,pe)}var Z=le.bind(null,!1);return Z.isRequired=le.bind(null,!0),Z}function w(G){function te(ue,le,Z,de,ie,P){var oe=ue[le],me=Y(oe);if(me!==G){var pe=c(oe);return new j("Invalid "+de+" `"+ie+"` of type "+("`"+pe+"` supplied to `"+Z+"`, expected ")+("`"+G+"`."),{expectedType:G})}return null}return m(te)}function x(){return m(l)}function C(G){function te(ue,le,Z,de,ie){if(typeof G!="function")return new j("Property `"+ie+"` of component `"+Z+"` has invalid PropType notation inside arrayOf.");var P=ue[le];if(!Array.isArray(P)){var oe=Y(P);return new j("Invalid "+de+" `"+ie+"` of type "+("`"+oe+"` supplied to `"+Z+"`, expected an array."))}for(var me=0;me<P.length;me++){var pe=G(P,me,Z,de,ie+"["+me+"]",n);if(pe instanceof Error)return pe}return null}return m(te)}function B(){function G(te,ue,le,Z,de){var ie=te[ue];if(!d(ie)){var P=Y(ie);return new j("Invalid "+Z+" `"+de+"` of type "+("`"+P+"` supplied to `"+le+"`, expected a single ReactElement."))}return null}return m(G)}function p(){function G(te,ue,le,Z,de){var ie=te[ue];if(!e.isValidElementType(ie)){var P=Y(ie);return new j("Invalid "+Z+" `"+de+"` of type "+("`"+P+"` supplied to `"+le+"`, expected a single ReactElement type."))}return null}return m(G)}function A(G){function te(ue,le,Z,de,ie){if(!(ue[le]instanceof G)){var P=G.name||S,oe=ae(ue[le]);return new j("Invalid "+de+" `"+ie+"` of type "+("`"+oe+"` supplied to `"+Z+"`, expected ")+("instance of `"+P+"`."))}return null}return m(te)}function L(G){if(!Array.isArray(G))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.")),l;function te(ue,le,Z,de,ie){for(var P=ue[le],oe=0;oe<G.length;oe++)if(E(P,G[oe]))return null;var me=JSON.stringify(G,function(Me,N){var Se=c(N);return Se==="symbol"?String(N):N});return new j("Invalid "+de+" `"+ie+"` of value `"+String(P)+"` "+("supplied to `"+Z+"`, expected one of "+me+"."))}return m(te)}function I(G){function te(ue,le,Z,de,ie){if(typeof G!="function")return new j("Property `"+ie+"` of component `"+Z+"` has invalid PropType notation inside objectOf.");var P=ue[le],oe=Y(P);if(oe!=="object")return new j("Invalid "+de+" `"+ie+"` of type "+("`"+oe+"` supplied to `"+Z+"`, expected an object."));for(var me in P)if(i(P,me)){var pe=G(P,me,Z,de,ie+"."+me,n);if(pe instanceof Error)return pe}return null}return m(te)}function Q(G){if(!Array.isArray(G))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),l;for(var te=0;te<G.length;te++){var ue=G[te];if(typeof ue!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+re(ue)+" at index "+te+"."),l}function le(Z,de,ie,P,oe){for(var me=[],pe=0;pe<G.length;pe++){var Me=G[pe],N=Me(Z,de,ie,P,oe,n);if(N==null)return null;N.data&&i(N.data,"expectedType")&&me.push(N.data.expectedType)}var Se=me.length>0?", expected one of type ["+me.join(", ")+"]":"";return new j("Invalid "+P+" `"+oe+"` supplied to "+("`"+ie+"`"+Se+"."))}return m(le)}function ee(){function G(te,ue,le,Z,de){return z(te[ue])?null:new j("Invalid "+Z+" `"+de+"` supplied to "+("`"+le+"`, expected a ReactNode."))}return m(G)}function W(G,te,ue,le,Z){return new j((G||"React class")+": "+te+" type `"+ue+"."+le+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+Z+"`.")}function v(G){function te(ue,le,Z,de,ie){var P=ue[le],oe=Y(P);if(oe!=="object")return new j("Invalid "+de+" `"+ie+"` of type `"+oe+"` "+("supplied to `"+Z+"`, expected `object`."));for(var me in G){var pe=G[me];if(typeof pe!="function")return W(Z,de,ie,me,c(pe));var Me=pe(P,me,Z,de,ie+"."+me,n);if(Me)return Me}return null}return m(te)}function O(G){function te(ue,le,Z,de,ie){var P=ue[le],oe=Y(P);if(oe!=="object")return new j("Invalid "+de+" `"+ie+"` of type `"+oe+"` "+("supplied to `"+Z+"`, expected `object`."));var me=r({},ue[le],G);for(var pe in me){var Me=G[pe];if(i(G,pe)&&typeof Me!="function")return W(Z,de,ie,pe,c(Me));if(!Me)return new j("Invalid "+de+" `"+ie+"` key `"+pe+"` supplied to `"+Z+"`.\nBad object: "+JSON.stringify(ue[le],null," ")+`
|
|
124
|
+
Valid keys: `+JSON.stringify(Object.keys(G),null," "));var N=Me(P,pe,Z,de,ie+"."+pe,n);if(N)return N}return null}return m(te)}function z(G){switch(typeof G){case"number":case"string":case"undefined":return!0;case"boolean":return!G;case"object":if(Array.isArray(G))return G.every(z);if(G===null||d(G))return!0;var te=f(G);if(te){var ue=te.call(G),le;if(te!==G.entries){for(;!(le=ue.next()).done;)if(!z(le.value))return!1}else for(;!(le=ue.next()).done;){var Z=le.value;if(Z&&!z(Z[1]))return!1}}else return!1;return!0;default:return!1}}function q(G,te){return G==="symbol"?!0:te?te["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&te instanceof Symbol:!1}function Y(G){var te=typeof G;return Array.isArray(G)?"array":G instanceof RegExp?"object":q(te,G)?"symbol":te}function c(G){if(typeof G>"u"||G===null)return""+G;var te=Y(G);if(te==="object"){if(G instanceof Date)return"date";if(G instanceof RegExp)return"regexp"}return te}function re(G){var te=c(G);switch(te){case"array":case"object":return"an "+te;case"boolean":case"date":case"regexp":return"a "+te;default:return te}}function ae(G){return!G.constructor||!G.constructor.name?S:G.constructor.name}return y.checkPropTypes=s,y.resetWarningCache=s.resetWarningCache,y.PropTypes=y,y},oi}var ni,Zi;function ic(){if(Zi)return ni;Zi=1;var e=zi();function r(){}function n(){}return n.resetWarningCache=r,ni=function(){function i(l,d,u,g,b,f){if(f!==e){var S=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw S.name="Invariant Violation",S}}i.isRequired=i;function s(){return i}var a={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:n,resetWarningCache:r};return a.PropTypes=a,a},ni}var es;function sc(){if(es)return en.exports;if(es=1,process.env.NODE_ENV!=="production"){var e=Hs(),r=!0;en.exports=nc()(e.isElement,r)}else en.exports=ic()();return en.exports}var ac=sc();const Bo=Zl(ac);var rn={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 ee=De(R,ae,Q,pe,ie+"
|
|
|
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 ts;function lc(){if(ts)return _e;ts=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"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),y=Symbol.for("react.client.reference");function E(j){if(typeof j=="object"&&j!==null){var m=j.$$typeof;switch(m){case e:switch(j=j.type,j){case n:case s:case i:case u:case g:case S:return j;default:switch(j=j&&j.$$typeof,j){case l:case d:case f:case b:return j;case a:return j;default:return m}}case r:return m}}}return _e.ContextConsumer=a,_e.ContextProvider=l,_e.Element=e,_e.ForwardRef=d,_e.Fragment=n,_e.Lazy=f,_e.Memo=b,_e.Portal=r,_e.Profiler=s,_e.StrictMode=i,_e.Suspense=u,_e.SuspenseList=g,_e.isContextConsumer=function(j){return E(j)===a},_e.isContextProvider=function(j){return E(j)===l},_e.isElement=function(j){return typeof j=="object"&&j!==null&&j.$$typeof===e},_e.isForwardRef=function(j){return E(j)===d},_e.isFragment=function(j){return E(j)===n},_e.isLazy=function(j){return E(j)===f},_e.isMemo=function(j){return E(j)===b},_e.isPortal=function(j){return E(j)===r},_e.isProfiler=function(j){return E(j)===s},_e.isStrictMode=function(j){return E(j)===i},_e.isSuspense=function(j){return E(j)===u},_e.isSuspenseList=function(j){return E(j)===g},_e.isValidElementType=function(j){return typeof j=="string"||typeof j=="function"||j===n||j===s||j===i||j===u||j===g||typeof j=="object"&&j!==null&&(j.$$typeof===f||j.$$typeof===b||j.$$typeof===l||j.$$typeof===a||j.$$typeof===d||j.$$typeof===y||j.getModuleId!==void 0)},_e.typeOf=E,_e}var $e={};/**
|
|
133
133
|
* @license React
|
|
134
134
|
* react-is.development.js
|
|
135
135
|
*
|
|
@@ -137,15 +137,15 @@ Valid keys: `+JSON.stringify(Object.keys(V),null," "));var ee=De(R,ae,Q,pe,ie+"
|
|
|
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
|
|
140
|
+
*/var rs;function cc(){return rs||(rs=1,process.env.NODE_ENV!=="production"&&(function(){function e(j){if(typeof j=="object"&&j!==null){var m=j.$$typeof;switch(m){case r:switch(j=j.type,j){case i:case a:case s:case g:case b:case y:return j;default:switch(j=j&&j.$$typeof,j){case d:case u:case S:case f:return j;case l:return j;default:return m}}case n:return m}}}var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),d=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),b=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),y=Symbol.for("react.view_transition"),E=Symbol.for("react.client.reference");$e.ContextConsumer=l,$e.ContextProvider=d,$e.Element=r,$e.ForwardRef=u,$e.Fragment=i,$e.Lazy=S,$e.Memo=f,$e.Portal=n,$e.Profiler=a,$e.StrictMode=s,$e.Suspense=g,$e.SuspenseList=b,$e.isContextConsumer=function(j){return e(j)===l},$e.isContextProvider=function(j){return e(j)===d},$e.isElement=function(j){return typeof j=="object"&&j!==null&&j.$$typeof===r},$e.isForwardRef=function(j){return e(j)===u},$e.isFragment=function(j){return e(j)===i},$e.isLazy=function(j){return e(j)===S},$e.isMemo=function(j){return e(j)===f},$e.isPortal=function(j){return e(j)===n},$e.isProfiler=function(j){return e(j)===a},$e.isStrictMode=function(j){return e(j)===s},$e.isSuspense=function(j){return e(j)===g},$e.isSuspenseList=function(j){return e(j)===b},$e.isValidElementType=function(j){return typeof j=="string"||typeof j=="function"||j===i||j===a||j===s||j===g||j===b||typeof j=="object"&&j!==null&&(j.$$typeof===S||j.$$typeof===f||j.$$typeof===d||j.$$typeof===l||j.$$typeof===u||j.$$typeof===E||j.getModuleId!==void 0)},$e.typeOf=e})()),$e}var os;function dc(){return os||(os=1,process.env.NODE_ENV==="production"?rn.exports=lc():rn.exports=cc()),rn.exports}var Gs=dc();function Sr(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 Ys(e){if(xn.isValidElement(e)||Gs.isValidElementType(e)||!Sr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=Ys(e[n])}),r}function vt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return Sr(e)&&Sr(r)&&Object.keys(r).forEach(s=>{xn.isValidElement(r[s])||Gs.isValidElementType(r[s])?i[s]=r[s]:Sr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&Sr(e[s])?i[s]=vt(e[s],r[s],n):n.clone?i[s]=Sr(r[s])?Ys(r[s]):r[s]:i[s]=r[s]}),i}const uc=e=>{const r=Object.keys(e).map(n=>({key:n,val:e[n]}))||[];return r.sort((n,i)=>n.val-i.val),r.reduce((n,i)=>({...n,[i.key]:i.val}),{})};function pc(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,a=uc(r),l=Object.keys(a);function d(S){return`@media (min-width:${typeof r[S]=="number"?r[S]:S}${n})`}function u(S){return`@media (max-width:${(typeof r[S]=="number"?r[S]:S)-i/100}${n})`}function g(S,y){const E=l.indexOf(y);return`@media (min-width:${typeof r[S]=="number"?r[S]:S}${n}) and (max-width:${(E!==-1&&typeof r[l[E]]=="number"?r[l[E]]:y)-i/100}${n})`}function b(S){return l.indexOf(S)+1<l.length?g(S,l[l.indexOf(S)+1]):d(S)}function f(S){const y=l.indexOf(S);return y===0?d(l[1]):y===l.length-1?u(l[y]):g(S,l[l.indexOf(S)+1]).replace("@media","@media not all and")}return{keys:l,values:a,up:d,down:u,between:g,only:b,not:f,unit:n,...s}}function ns(e,r){if(!e.containerQueries)return r;const n=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var l,d;const a=/min-width:\s*([0-9.]+)/;return+(((l=i.match(a))==null?void 0:l[1])||0)-+(((d=s.match(a))==null?void 0:d[1])||0)});return n.length?n.reduce((i,s)=>{const a=r[s];return delete i[s],i[s]=a,i},{...r}):r}function hc(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function mc(e,r){const n=r.match(/^@([^/]+)?\/?(.+)?$/);if(!n){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${r})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
|
|
141
|
+
For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,a=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(a)}function fc(e){const r=(a,l)=>a.replace("@media",l?`@container ${l}`:"@container");function n(a,l){a.up=(...d)=>r(e.breakpoints.up(...d),l),a.down=(...d)=>r(e.breakpoints.down(...d),l),a.between=(...d)=>r(e.breakpoints.between(...d),l),a.only=(...d)=>r(e.breakpoints.only(...d),l),a.not=(...d)=>{const u=r(e.breakpoints.not(...d),l);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=a=>(n(i,a),i);return n(s),{...e,containerQueries:s}}const xc={borderRadius:4},jr=process.env.NODE_ENV!=="production"?Bo.oneOfType([Bo.number,Bo.string,Bo.object,Bo.array]):{};function Wo(e,r){return r?vt(e,r,{clone:!1}):e}const vn={xs:0,sm:600,md:900,lg:1200,xl:1536},is={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${vn[e]}px)`},gc={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:vn[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function pr(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||is;return r.reduce((l,d,u)=>(l[a.up(a.keys[u])]=n(r[u]),l),{})}if(typeof r=="object"){const a=i.breakpoints||is;return Object.keys(r).reduce((l,d)=>{if(hc(a.keys,d)){const u=mc(i.containerQueries?i:gc,d);u&&(l[u]=n(r[d],d))}else if(Object.keys(a.values||vn).includes(d)){const u=a.up(d);l[u]=n(r[d],d)}else{const u=d;l[u]=r[u]}return l},{})}return n(r)}function yc(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function ss(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function qs(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Wr(7));return e.charAt(0).toUpperCase()+e.slice(1)}function Sn(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 mn(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=Sn(e,n)||i,r&&(s=r(s,i,e)),s}function Ye(e){const{prop:r,cssProperty:n=e.prop,themeKey:i,transform:s}=e,a=l=>{if(l[r]==null)return null;const d=l[r],u=l.theme,g=Sn(u,i)||{};return pr(l,d,f=>{let S=mn(g,s,f);return f===S&&typeof f=="string"&&(S=mn(g,s,`${r}${f==="default"?"":qs(f)}`,f)),n===!1?S:{[n]:S}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:jr}:{},a.filterProps=[r],a}function bc(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const vc={m:"margin",p:"padding"},Sc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},as={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},wc=bc(e=>{if(e.length>2)if(as[e])e=as[e];else return[e];const[r,n]=e.split(""),i=vc[r],s=Sc[n]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),wn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],Cn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],Cc=[...wn,...Cn];function No(e,r,n,i){const s=Sn(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 l=Math.abs(a);process.env.NODE_ENV!=="production"&&(Number.isInteger(l)?l>s.length-1&&console.error([`MUI: The value provided (${l}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${l} > ${s.length-1}, you need to add the missing values.`].join(`
|
|
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 d=s[l];return a>=0?d:typeof d=="number"?-d:typeof d=="string"&&d.startsWith("var(")?`calc(-1 * ${d})`:`-${d}`}: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 ji(e){return Ro(e,"spacing",8,"spacing")}function Po(e,r){return typeof r=="string"||r==null?r:e(r)}function zc(e,r){return n=>e.reduce((i,s)=>(i[s]=Po(r,n),i),{})}function Bc(e,r,n,i){if(!r.includes(n))return null;const s=jc(n),a=zc(s,i),l=e[n];return ar(e,l,a)}function Js(e,r){const n=ji(e.theme);return Object.keys(e).map(i=>Bc(e,r,i,n)).reduce(Oo,{})}function Fe(e){return Js(e,vn)}Fe.propTypes=process.env.NODE_ENV!=="production"?vn.reduce((e,r)=>(e[r]=wr,e),{}):{};Fe.filterProps=vn;function Ve(e){return Js(e,Sn)}Ve.propTypes=process.env.NODE_ENV!=="production"?Sn.reduce((e,r)=>(e[r]=wr,e),{}):{};Ve.filterProps=Sn;process.env.NODE_ENV!=="production"&&kc.reduce((e,r)=>(e[r]=wr,e),{});function Ks(e=8,r=ji({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 l=r(a);return typeof l=="number"?`${l}px`:l}).join(" "));return n.mui=!0,n}function wn(...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]?Oo(s,r[a](i)):s,{});return n.propTypes=process.env.NODE_ENV!=="production"?e.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},n.filterProps=e.reduce((i,s)=>i.concat(s.filterProps),[]),n}function It(e){return typeof e!="number"?e:`${e}px solid`}function _t(e,r){return Ge({prop:e,themeKey:"borders",transform:r})}const Tc=_t("border",It),Ic=_t("borderTop",It),Ec=_t("borderRight",It),Dc=_t("borderBottom",It),_c=_t("borderLeft",It),$c=_t("borderColor"),Oc=_t("borderTopColor"),Mc=_t("borderRightColor"),Ac=_t("borderBottomColor"),Wc=_t("borderLeftColor"),Rc=_t("outline",It),Pc=_t("outlineColor"),Cn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=Ro(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Po(r,i)});return ar(e,e.borderRadius,n)}return null};Cn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:wr}:{};Cn.filterProps=["borderRadius"];wn(Tc,Ic,Ec,Dc,_c,$c,Oc,Mc,Ac,Wc,Cn,Rc,Pc);const jn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=Ro(e.theme,"spacing",8,"gap"),n=i=>({gap:Po(r,i)});return ar(e,e.gap,n)}return null};jn.propTypes=process.env.NODE_ENV!=="production"?{gap:wr}:{};jn.filterProps=["gap"];const kn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=Ro(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Po(r,i)});return ar(e,e.columnGap,n)}return null};kn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:wr}:{};kn.filterProps=["columnGap"];const zn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=Ro(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Po(r,i)});return ar(e,e.rowGap,n)}return null};zn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:wr}:{};zn.filterProps=["rowGap"];const Nc=Ge({prop:"gridColumn"}),Lc=Ge({prop:"gridRow"}),Fc=Ge({prop:"gridAutoFlow"}),Vc=Ge({prop:"gridAutoColumns"}),Hc=Ge({prop:"gridAutoRows"}),Uc=Ge({prop:"gridTemplateColumns"}),Gc=Ge({prop:"gridTemplateRows"}),Yc=Ge({prop:"gridTemplateAreas"}),qc=Ge({prop:"gridArea"});wn(jn,kn,zn,Nc,Lc,Fc,Vc,Hc,Uc,Gc,Yc,qc);function uo(e,r){return r==="grey"?r:e}const Jc=Ge({prop:"color",themeKey:"palette",transform:uo}),Kc=Ge({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:uo}),Xc=Ge({prop:"backgroundColor",themeKey:"palette",transform:uo});wn(Jc,Kc,Xc);function wt(e){return e<=1&&e!==0?`${e*100}%`:e}const Qc=Ge({prop:"width",transform:wt}),ki=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,a,l,d,u;const i=((l=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:l[n])||yn[n];return i?((u=(d=e.theme)==null?void 0:d.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:wt(n)}};return ar(e,e.maxWidth,r)}return null};ki.filterProps=["maxWidth"];const Zc=Ge({prop:"minWidth",transform:wt}),ed=Ge({prop:"height",transform:wt}),td=Ge({prop:"maxHeight",transform:wt}),rd=Ge({prop:"minHeight",transform:wt});Ge({prop:"size",cssProperty:"width",transform:wt});Ge({prop:"size",cssProperty:"height",transform:wt});const od=Ge({prop:"boxSizing"});wn(Qc,ki,Zc,ed,td,rd,od);const Bn={border:{themeKey:"borders",transform:It},borderTop:{themeKey:"borders",transform:It},borderRight:{themeKey:"borders",transform:It},borderBottom:{themeKey:"borders",transform:It},borderLeft:{themeKey:"borders",transform:It},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:It},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Cn},color:{themeKey:"palette",transform:uo},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:uo},backgroundColor:{themeKey:"palette",transform:uo},p:{style:Ve},pt:{style:Ve},pr:{style:Ve},pb:{style:Ve},pl:{style:Ve},px:{style:Ve},py:{style:Ve},padding:{style:Ve},paddingTop:{style:Ve},paddingRight:{style:Ve},paddingBottom:{style:Ve},paddingLeft:{style:Ve},paddingX:{style:Ve},paddingY:{style:Ve},paddingInline:{style:Ve},paddingInlineStart:{style:Ve},paddingInlineEnd:{style:Ve},paddingBlock:{style:Ve},paddingBlockStart:{style:Ve},paddingBlockEnd:{style:Ve},m:{style:Fe},mt:{style:Fe},mr:{style:Fe},mb:{style:Fe},ml:{style:Fe},mx:{style:Fe},my:{style:Fe},margin:{style:Fe},marginTop:{style:Fe},marginRight:{style:Fe},marginBottom:{style:Fe},marginLeft:{style:Fe},marginX:{style:Fe},marginY:{style:Fe},marginInline:{style:Fe},marginInlineStart:{style:Fe},marginInlineEnd:{style:Fe},marginBlock:{style:Fe},marginBlockStart:{style:Fe},marginBlockEnd:{style:Fe},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:jn},rowGap:{style:zn},columnGap:{style:kn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:wt},maxWidth:{style:ki},minWidth:{transform:wt},height:{transform:wt},maxHeight:{transform:wt},minHeight:{transform:wt},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 nd(...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 id(e,r){return typeof e=="function"?e(r):e}function sd(){function e(n,i,s,a){const l={[n]:i,theme:s},d=a[n];if(!d)return{[n]:i};const{cssProperty:u=n,themeKey:g,transform:b,style:x}=d;if(i==null)return null;if(g==="typography"&&i==="inherit")return{[n]:i};const S=bn(s,g)||{};return x?x(l):ar(l,i,I=>{let C=pn(S,b,I);return I===C&&typeof I=="string"&&(C=pn(S,b,`${n}${I==="default"?"":qs(I)}`,I)),u===!1?C:{[u]:C}})}function r(n){const{sx:i,theme:s={},nested:a}=n||{};if(!i)return null;const l=s.unstable_sxConfig??Bn;function d(u){let g=u;if(typeof u=="function")g=u(s);else if(typeof u!="object")return u;if(!g)return null;const b=vc(s.breakpoints),x=Object.keys(b);let S=b;return Object.keys(g).forEach(y=>{const I=id(g[y],s);if(I!=null)if(typeof I=="object")if(l[y])S=Oo(S,e(y,I,s,l));else{const C=ar({theme:s},I,m=>({[y]:m}));nd(C,I)?S[y]=r({sx:I,theme:s,nested:!0}):S=Oo(S,C)}else S=Oo(S,e(y,I,s,l))}),!a&&s.modularCssLayers?{"@layer sx":is(s,as(x,S))}:is(s,as(x,S))}return Array.isArray(i)?i.map(d):d(i)}return r}const Tn=sd();Tn.filterProps=["sx"];function ad(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 Xs(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:a={},...l}=e,d=fc(n),u=Ks(s);let g=Ct({breakpoints:d,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...yc,...a}},l);return g=gc(g),g.applyStyles=ad,g=r.reduce((b,x)=>Ct(b,x),g),g.unstable_sxConfig={...Bn,...l==null?void 0:l.unstable_sxConfig},g.unstable_sx=function(x){return Tn({sx:x,theme:this})},g}function ld(e){return Object.keys(e).length===0}function cd(e=null){const r=fn.useContext(ka.ThemeContext);return!r||ld(r)?e:r}const dd=Xs();function ud(e=dd){return cd(e)}const cs=e=>e,pd=()=>{let e=cs;return{configure(r){e=r},generate(r){return e(r)},reset(){e=cs}}},hd=pd(),fd={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 md(e,r,n="Mui"){const i=fd[r];return i?`${n}-${i}`:`${hd.generate(e)}-${r}`}function xd(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function zi(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}].`),xd(e,r,n)}function gd(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 Sr(e){if(e.type)return e;if(e.charAt(0)==="#")return Sr(gd(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 \`${
|
|
144
|
+
`)),()=>{})}function Ti(e){return No(e,"spacing",8,"spacing")}function Lo(e,r){return typeof r=="string"||r==null?r:e(r)}function jc(e,r){return n=>e.reduce((i,s)=>(i[s]=Lo(r,n),i),{})}function kc(e,r,n,i){if(!r.includes(n))return null;const s=wc(n),a=jc(s,i),l=e[n];return pr(e,l,a)}function Js(e,r){const n=Ti(e.theme);return Object.keys(e).map(i=>kc(e,r,i,n)).reduce(Wo,{})}function Fe(e){return Js(e,wn)}Fe.propTypes=process.env.NODE_ENV!=="production"?wn.reduce((e,r)=>(e[r]=jr,e),{}):{};Fe.filterProps=wn;function Ve(e){return Js(e,Cn)}Ve.propTypes=process.env.NODE_ENV!=="production"?Cn.reduce((e,r)=>(e[r]=jr,e),{}):{};Ve.filterProps=Cn;process.env.NODE_ENV!=="production"&&Cc.reduce((e,r)=>(e[r]=jr,e),{});function Ks(e=8,r=Ti({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 l=r(a);return typeof l=="number"?`${l}px`:l}).join(" "));return n.mui=!0,n}function jn(...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]?Wo(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 zt(e){return typeof e!="number"?e:`${e}px solid`}function It(e,r){return Ye({prop:e,themeKey:"borders",transform:r})}const zc=It("border",zt),Tc=It("borderTop",zt),Bc=It("borderRight",zt),Ic=It("borderBottom",zt),Ec=It("borderLeft",zt),Dc=It("borderColor"),_c=It("borderTopColor"),$c=It("borderRightColor"),Oc=It("borderBottomColor"),Mc=It("borderLeftColor"),Ac=It("outline",zt),Wc=It("outlineColor"),kn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=No(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:Lo(r,i)});return pr(e,e.borderRadius,n)}return null};kn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:jr}:{};kn.filterProps=["borderRadius"];jn(zc,Tc,Bc,Ic,Ec,Dc,_c,$c,Oc,Mc,kn,Ac,Wc);const zn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=No(e.theme,"spacing",8,"gap"),n=i=>({gap:Lo(r,i)});return pr(e,e.gap,n)}return null};zn.propTypes=process.env.NODE_ENV!=="production"?{gap:jr}:{};zn.filterProps=["gap"];const Tn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=No(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:Lo(r,i)});return pr(e,e.columnGap,n)}return null};Tn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:jr}:{};Tn.filterProps=["columnGap"];const Bn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=No(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:Lo(r,i)});return pr(e,e.rowGap,n)}return null};Bn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:jr}:{};Bn.filterProps=["rowGap"];const Rc=Ye({prop:"gridColumn"}),Pc=Ye({prop:"gridRow"}),Nc=Ye({prop:"gridAutoFlow"}),Lc=Ye({prop:"gridAutoColumns"}),Fc=Ye({prop:"gridAutoRows"}),Vc=Ye({prop:"gridTemplateColumns"}),Hc=Ye({prop:"gridTemplateRows"}),Uc=Ye({prop:"gridTemplateAreas"}),Gc=Ye({prop:"gridArea"});jn(zn,Tn,Bn,Rc,Pc,Nc,Lc,Fc,Vc,Hc,Uc,Gc);function ho(e,r){return r==="grey"?r:e}const Yc=Ye({prop:"color",themeKey:"palette",transform:ho}),qc=Ye({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:ho}),Jc=Ye({prop:"backgroundColor",themeKey:"palette",transform:ho});jn(Yc,qc,Jc);function bt(e){return e<=1&&e!==0?`${e*100}%`:e}const Kc=Ye({prop:"width",transform:bt}),Bi=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,a,l,d,u;const i=((l=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:l[n])||vn[n];return i?((u=(d=e.theme)==null?void 0:d.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:bt(n)}};return pr(e,e.maxWidth,r)}return null};Bi.filterProps=["maxWidth"];const Xc=Ye({prop:"minWidth",transform:bt}),Qc=Ye({prop:"height",transform:bt}),Zc=Ye({prop:"maxHeight",transform:bt}),ed=Ye({prop:"minHeight",transform:bt});Ye({prop:"size",cssProperty:"width",transform:bt});Ye({prop:"size",cssProperty:"height",transform:bt});const td=Ye({prop:"boxSizing"});jn(Kc,Bi,Xc,Qc,Zc,ed,td);const In={border:{themeKey:"borders",transform:zt},borderTop:{themeKey:"borders",transform:zt},borderRight:{themeKey:"borders",transform:zt},borderBottom:{themeKey:"borders",transform:zt},borderLeft:{themeKey:"borders",transform:zt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:zt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:kn},color:{themeKey:"palette",transform:ho},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:ho},backgroundColor:{themeKey:"palette",transform:ho},p:{style:Ve},pt:{style:Ve},pr:{style:Ve},pb:{style:Ve},pl:{style:Ve},px:{style:Ve},py:{style:Ve},padding:{style:Ve},paddingTop:{style:Ve},paddingRight:{style:Ve},paddingBottom:{style:Ve},paddingLeft:{style:Ve},paddingX:{style:Ve},paddingY:{style:Ve},paddingInline:{style:Ve},paddingInlineStart:{style:Ve},paddingInlineEnd:{style:Ve},paddingBlock:{style:Ve},paddingBlockStart:{style:Ve},paddingBlockEnd:{style:Ve},m:{style:Fe},mt:{style:Fe},mr:{style:Fe},mb:{style:Fe},ml:{style:Fe},mx:{style:Fe},my:{style:Fe},margin:{style:Fe},marginTop:{style:Fe},marginRight:{style:Fe},marginBottom:{style:Fe},marginLeft:{style:Fe},marginX:{style:Fe},marginY:{style:Fe},marginInline:{style:Fe},marginInlineStart:{style:Fe},marginInlineEnd:{style:Fe},marginBlock:{style:Fe},marginBlockStart:{style:Fe},marginBlockEnd:{style:Fe},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:zn},rowGap:{style:Bn},columnGap:{style:Tn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:bt},maxWidth:{style:Bi},minWidth:{transform:bt},height:{transform:bt},maxHeight:{transform:bt},minHeight:{transform:bt},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function rd(...e){const r=e.reduce((i,s)=>i.concat(Object.keys(s)),[]),n=new Set(r);return e.every(i=>n.size===Object.keys(i).length)}function od(e,r){return typeof e=="function"?e(r):e}function nd(){function e(n,i,s,a){const l={[n]:i,theme:s},d=a[n];if(!d)return{[n]:i};const{cssProperty:u=n,themeKey:g,transform:b,style:f}=d;if(i==null)return null;if(g==="typography"&&i==="inherit")return{[n]:i};const S=Sn(s,g)||{};return f?f(l):pr(l,i,E=>{let j=mn(S,b,E);return E===j&&typeof E=="string"&&(j=mn(S,b,`${n}${E==="default"?"":qs(E)}`,E)),u===!1?j:{[u]:j}})}function r(n){const{sx:i,theme:s={},nested:a}=n||{};if(!i)return null;const l=s.unstable_sxConfig??In;function d(u){let g=u;if(typeof u=="function")g=u(s);else if(typeof u!="object")return u;if(!g)return null;const b=yc(s.breakpoints),f=Object.keys(b);let S=b;return Object.keys(g).forEach(y=>{const E=od(g[y],s);if(E!=null)if(typeof E=="object")if(l[y])S=Wo(S,e(y,E,s,l));else{const j=pr({theme:s},E,m=>({[y]:m}));rd(j,E)?S[y]=r({sx:E,theme:s,nested:!0}):S=Wo(S,j)}else S=Wo(S,e(y,E,s,l))}),!a&&s.modularCssLayers?{"@layer sx":ns(s,ss(f,S))}:ns(s,ss(f,S))}return Array.isArray(i)?i.map(d):d(i)}return r}const En=nd();En.filterProps=["sx"];function id(e,r){var i;const n=this;if(n.vars){if(!((i=n.colorSchemes)!=null&&i[e])||typeof n.getColorSchemeSelector!="function")return{};let s=n.getColorSchemeSelector(e);return s==="&"?r:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:r})}return n.palette.mode===e?r:{}}function Xs(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:a={},...l}=e,d=pc(n),u=Ks(s);let g=vt({breakpoints:d,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...xc,...a}},l);return g=fc(g),g.applyStyles=id,g=r.reduce((b,f)=>vt(b,f),g),g.unstable_sxConfig={...In,...l==null?void 0:l.unstable_sxConfig},g.unstable_sx=function(f){return En({sx:f,theme:this})},g}function sd(e){return Object.keys(e).length===0}function ad(e=null){const r=xn.useContext(ka.ThemeContext);return!r||sd(r)?e:r}const ld=Xs();function cd(e=ld){return ad(e)}const ls=e=>e,dd=()=>{let e=ls;return{configure(r){e=r},generate(r){return e(r)},reset(){e=ls}}},ud=dd(),pd={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function hd(e,r,n="Mui"){const i=pd[r];return i?`${n}-${i}`:`${ud.generate(e)}-${r}`}function md(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function Ii(e,r=0,n=1){return process.env.NODE_ENV!=="production"&&(e<r||e>n)&&console.error(`MUI: The value provided ${e} is out of range [${r}, ${n}].`),md(e,r,n)}function fd(e){e=e.slice(1);const r=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(r);return n&&n[0].length===1&&(n=n.map(i=>i+i)),process.env.NODE_ENV!=="production"&&e.length!==e.trim().length&&console.error(`MUI: The color: "${e}" is invalid. Make sure the color input doesn't contain leading/trailing space.`),n?`rgb${n.length===4?"a":""}(${n.map((i,s)=>s<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function Cr(e){if(e.type)return e;if(e.charAt(0)==="#")return Cr(fd(e));const r=e.indexOf("("),n=e.substring(0,r);if(!["rgb","rgba","hsl","hsla","color"].includes(n))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${e}\` color.
|
|
145
|
+
The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Wr(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.`:Wr(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:n,values:i,colorSpace:s}}const xd=e=>{const r=Cr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},_o=(e,r)=>{try{return xd(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function Dn(e){const{type:r,colorSpace:n}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,a)=>a<3?parseInt(s,10):s):r.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),r.includes("color")?i=`${n} ${i.join(" ")}`:i=`${i.join(", ")}`,`${r}(${i})`}function Qs(e){e=Cr(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),l=(g,b=(g+n/30)%12)=>s-a*Math.max(Math.min(b-3,9-b,1),-1);let d="rgb";const u=[Math.round(l(0)*255),Math.round(l(8)*255),Math.round(l(4)*255)];return e.type==="hsla"&&(d+="a",u.push(r[3])),Dn({type:d,values:u})}function ui(e){e=Cr(e);let r=e.type==="hsl"||e.type==="hsla"?Cr(Qs(e)).values:e.values;return r=r.map(n=>(e.type!=="color"&&(n/=255),n<=.03928?n/12.92:((n+.055)/1.055)**2.4)),Number((.2126*r[0]+.7152*r[1]+.0722*r[2]).toFixed(3))}function cs(e,r){const n=ui(e),i=ui(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function $(e,r){return e=Cr(e),r=Ii(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,Dn(e)}function Mr(e,r,n){try{return $(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function _n(e,r){if(e=Cr(e),r=Ii(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 Dn(e)}function Ee(e,r,n){try{return _n(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function $n(e,r){if(e=Cr(e),r=Ii(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 Dn(e)}function De(e,r,n){try{return $n(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function gd(e,r=.15){return ui(e)>.5?_n(e,r):$n(e,r)}function on(e,r,n){try{return gd(e,r)}catch{return e}}function yd(e=""){function r(...i){if(!i.length)return"";const s=i[0];return typeof s=="string"&&!s.match(/(#|\(|\)|(-?(\d*\.)?\d+)(px|em|%|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))|^(-?(\d*\.)?\d+)$|(\d+ \d+ \d+)/)?`, var(--${e?`${e}-`:""}${s}${r(...i.slice(1))})`:`, ${s}`}return(i,...s)=>`var(--${e?`${e}-`:""}${i}${r(...s)})`}const ds=(e,r,n,i=[])=>{let s=e;r.forEach((a,l)=>{l===r.length-1?Array.isArray(s)?s[Number(a)]=n:s&&typeof s=="object"&&(s[a]=n):s&&typeof s=="object"&&(s[a]||(s[a]=i.includes(a)?[]:{}),s=s[a])})},bd=(e,r,n)=>{function i(s,a=[],l=[]){Object.entries(s).forEach(([d,u])=>{(!n||n&&!n([...a,d]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...a,d],Array.isArray(u)?[...l,d]:l):r([...a,d],u,l))})}i(e)},vd=(e,r)=>typeof r=="number"?["lineHeight","fontWeight","opacity","zIndex"].some(i=>e.includes(i))||e[e.length-1].toLowerCase().includes("opacity")?r:`${r}px`:r;function ii(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},a={},l={};return bd(e,(d,u,g)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(d,u))){const b=`--${n?`${n}-`:""}${d.join("-")}`,f=vd(d,u);Object.assign(s,{[b]:f}),ds(a,d,`var(${b})`,g),ds(l,d,`var(${b}, ${f})`,g)}},d=>d[0]==="vars"),{css:s,vars:a,varsWithDefaults:l}}function Sd(e,r={}){const{getSelector:n=w,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:l={},components:d,defaultColorScheme:u="light",...g}=e,{vars:b,css:f,varsWithDefaults:S}=ii(g,r);let y=S;const E={},{[u]:j,...m}=l;if(Object.entries(m||{}).forEach(([B,p])=>{const{vars:A,css:L,varsWithDefaults:I}=ii(p,r);y=vt(y,I),E[B]={css:L,vars:A}}),j){const{css:B,vars:p,varsWithDefaults:A}=ii(j,r);y=vt(y,A),E[u]={css:B,vars:p}}function w(B,p){var L,I;let A=s;if(s==="class"&&(A=".%s"),s==="data"&&(A="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(A=`[${s}="%s"]`),B){if(A==="media")return e.defaultColorScheme===B?":root":{[`@media (prefers-color-scheme: ${((I=(L=l[B])==null?void 0:L.palette)==null?void 0:I.mode)||B})`]:{":root":p}};if(A)return e.defaultColorScheme===B?`:root, ${A.replace("%s",String(B))}`:A.replace("%s",String(B))}return":root"}return{vars:y,generateThemeVars:()=>{let B={...b};return Object.entries(E).forEach(([,{vars:p}])=>{B=vt(B,p)}),B},generateStyleSheets:()=>{var Q,ee;const B=[],p=e.defaultColorScheme||"light";function A(W,v){Object.keys(v).length&&B.push(typeof W=="string"?{[W]:{...v}}:W)}A(n(void 0,{...f}),f);const{[p]:L,...I}=E;if(L){const{css:W}=L,v=(ee=(Q=l[p])==null?void 0:Q.palette)==null?void 0:ee.mode,O=!i&&v?{colorScheme:v,...W}:{...W};A(n(p,{...O}),O)}return Object.entries(I).forEach(([W,{css:v}])=>{var q,Y;const O=(Y=(q=l[W])==null?void 0:q.palette)==null?void 0:Y.mode,z=!i&&O?{colorScheme:O,...v}:{...v};A(n(W,{...z}),z)}),a&&B.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)"}}),B}}}function wd(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 Po={black:"#000",white:"#fff"},Cd={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"},so={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},ao={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Io={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},lo={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},co={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},uo={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Zs(){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:Po.white,default:Po.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 ea=Zs();function ta(){return{text:{primary:Po.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:Po.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 pi=ta();function us(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=$n(e.main,s):r==="dark"&&(e.dark=_n(e.main,a)))}function ps(e,r,n,i,s){const a=s.light||s,l=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 ${(l*100).toFixed(0)}%)`))}function jd(e="light"){return e==="dark"?{main:lo[200],light:lo[50],dark:lo[400]}:{main:lo[700],light:lo[400],dark:lo[800]}}function kd(e="light"){return e==="dark"?{main:so[200],light:so[50],dark:so[400]}:{main:so[500],light:so[300],dark:so[700]}}function zd(e="light"){return e==="dark"?{main:ao[500],light:ao[300],dark:ao[700]}:{main:ao[700],light:ao[400],dark:ao[800]}}function Td(e="light"){return e==="dark"?{main:co[400],light:co[300],dark:co[700]}:{main:co[700],light:co[500],dark:co[900]}}function Bd(e="light"){return e==="dark"?{main:uo[400],light:uo[300],dark:uo[700]}:{main:uo[800],light:uo[500],dark:uo[900]}}function Id(e="light"){return e==="dark"?{main:Io[400],light:Io[300],dark:Io[700]}:{main:"#ed6c02",light:Io[500],dark:Io[900]}}function Ed(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function Ei(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...a}=e,l=e.primary||jd(r),d=e.secondary||kd(r),u=e.error||zd(r),g=e.info||Td(r),b=e.success||Bd(r),f=e.warning||Id(r);function S(m){if(s)return Ed(m);const w=cs(m,pi.text.primary)>=n?pi.text.primary:ea.text.primary;if(process.env.NODE_ENV!=="production"){const x=cs(m,w);x<3&&console.error([`MUI: The contrast ratio of ${x}:1 for ${w} on ${m}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
|
|
147
|
+
`))}return w}const y=({color:m,name:w,mainShade:x=500,lightShade:C=300,darkShade:B=700})=>{if(m={...m},!m.main&&m[x]&&(m.main=m[x]),!m.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 \`${x}\` property.`:Wr(11,w?` (${w})`:"",x));if(typeof m.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${w?` (${w})`:""} provided to augmentColor(color) is invalid.
|
|
149
149
|
\`color.main\` should be a string, but \`${JSON.stringify(m.main)}\` was provided instead.
|
|
150
150
|
|
|
151
151
|
Did you intend to use one of the following approaches?
|
|
@@ -158,17 +158,17 @@ const theme1 = createTheme({ palette: {
|
|
|
158
158
|
|
|
159
159
|
const theme2 = createTheme({ palette: {
|
|
160
160
|
primary: { main: green[500] },
|
|
161
|
-
} });`:
|
|
162
|
-
`)),Object.keys(g).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(g).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(b=>`${b} ${typeof l=="string"?l:
|
|
161
|
+
} });`:Wr(12,w?` (${w})`:"",JSON.stringify(m.main)));return s?(ps(s,m,"light",C,i),ps(s,m,"dark",B,i)):(us(m,"light",C,i),us(m,"dark",B,i)),m.contrastText||(m.contrastText=S(m.main)),m};let E;return r==="light"?E=Zs():r==="dark"&&(E=ta()),process.env.NODE_ENV!=="production"&&(E||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),vt({common:{...Po},mode:r,primary:y({color:l,name:"primary"}),secondary:y({color:d,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:y({color:u,name:"error"}),warning:y({color:f,name:"warning"}),info:y({color:g,name:"info"}),success:y({color:b,name:"success"}),grey:Cd,contrastThreshold:n,getContrastText:S,augmentColor:y,tonalOffset:i,...E},a)}function Dd(e){const r={};return Object.entries(e).forEach(i=>{const[s,a]=i;typeof a=="object"&&(r[s]=`${a.fontStyle?`${a.fontStyle} `:""}${a.fontVariant?`${a.fontVariant} `:""}${a.fontWeight?`${a.fontWeight} `:""}${a.fontStretch?`${a.fontStretch} `:""}${a.fontSize||""}${a.lineHeight?`/${a.lineHeight} `:""}${a.fontFamily||""}`)}),r}function _d(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function $d(e){return Math.round(e*1e5)/1e5}const hs={textTransform:"uppercase"},ms='"Roboto", "Helvetica", "Arial", sans-serif';function Od(e,r){const{fontFamily:n=ms,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:l=500,fontWeightBold:d=700,htmlFontSize:u=16,allVariants:g,pxToRem:b,...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 u!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const S=i/14,y=b||(m=>`${m/u*S}rem`),E=(m,w,x,C,B)=>({fontFamily:n,fontWeight:m,fontSize:y(w),lineHeight:x,...n===ms?{letterSpacing:`${$d(C/w)}em`}:{},...B,...g}),j={h1:E(s,96,1.167,-1.5),h2:E(s,60,1.2,-.5),h3:E(a,48,1.167,0),h4:E(a,34,1.235,.25),h5:E(a,24,1.334,0),h6:E(l,20,1.6,.15),subtitle1:E(a,16,1.75,.15),subtitle2:E(l,14,1.57,.1),body1:E(a,16,1.5,.15),body2:E(a,14,1.43,.15),button:E(l,14,1.75,.4,hs),caption:E(a,12,1.66,.4),overline:E(a,12,2.66,1,hs),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return vt({htmlFontSize:u,pxToRem:y,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:l,fontWeightBold:d,...j},f,{clone:!1})}const Md=.2,Ad=.14,Wd=.12;function Re(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${Md})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Ad})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Wd})`].join(",")}const Rd=["none",Re(0,2,1,-1,0,1,1,0,0,1,3,0),Re(0,3,1,-2,0,2,2,0,0,1,5,0),Re(0,3,3,-2,0,3,4,0,0,1,8,0),Re(0,2,4,-1,0,4,5,0,0,1,10,0),Re(0,3,5,-1,0,5,8,0,0,1,14,0),Re(0,3,5,-1,0,6,10,0,0,1,18,0),Re(0,4,5,-2,0,7,10,1,0,2,16,1),Re(0,5,5,-3,0,8,10,1,0,3,14,2),Re(0,5,6,-3,0,9,12,1,0,3,16,2),Re(0,6,6,-3,0,10,14,1,0,4,18,3),Re(0,6,7,-4,0,11,15,1,0,4,20,3),Re(0,7,8,-4,0,12,17,2,0,5,22,4),Re(0,7,8,-4,0,13,19,2,0,5,24,4),Re(0,7,9,-4,0,14,21,2,0,5,26,4),Re(0,8,9,-5,0,15,22,2,0,6,28,5),Re(0,8,10,-5,0,16,24,2,0,6,30,5),Re(0,8,11,-5,0,17,26,2,0,6,32,5),Re(0,9,11,-5,0,18,28,2,0,7,34,6),Re(0,9,12,-6,0,19,29,2,0,7,36,6),Re(0,10,13,-6,0,20,31,3,0,8,38,7),Re(0,10,13,-6,0,21,33,3,0,8,40,7),Re(0,10,14,-6,0,22,35,3,0,8,42,7),Re(0,11,14,-7,0,23,36,3,0,9,44,8),Re(0,11,15,-7,0,24,38,3,0,9,46,8)],Pd={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},Nd={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function fs(e){return`${Math.round(e)}ms`}function Ld(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function Fd(e){const r={...Pd,...e.easing},n={...Nd,...e.duration};return{getAutoHeightDuration:Ld,create:(s=["all"],a={})=>{const{duration:l=n.standard,easing:d=r.easeInOut,delay:u=0,...g}=a;if(process.env.NODE_ENV!=="production"){const b=S=>typeof S=="string",f=S=>!Number.isNaN(parseFloat(S));!b(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!f(l)&&!b(l)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${l}.`),b(d)||console.error('MUI: Argument "easing" must be a string.'),!f(u)&&!b(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof a!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
|
|
162
|
+
`)),Object.keys(g).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(g).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(b=>`${b} ${typeof l=="string"?l:fs(l)} ${d} ${typeof u=="string"?u:fs(u)}`).join(",")},...e,easing:r,duration:n}}const Vd={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Hd(e){return Sr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function ra(e={}){const r={...e};function n(i){const s=Object.entries(i);for(let a=0;a<s.length;a++){const[l,d]=s[a];!Hd(d)||l.startsWith("unstable_")?delete i[l]:Sr(d)&&(i[l]={...d},n(i[l]))}}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 ru(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Yt=e=>{try{return e()}catch{}},ou=(e="mui")=>vd(e);function oi(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const a=s==="dark"?"dark":"light";if(!i){r[s]=Xd({...n,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:l,...d}=di({...i,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:l,opacity:{...oa(a),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||na(a)},d}function nu(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:l=!1,shouldSkipGeneratingVar:d=Qd,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:g=":root",...b}=e,x=Object.keys(n)[0],S=i||(n.light&&x!=="light"?"light":x),y=ou(a),{[S]:I,light:C,dark:m,...j}=n,h={...j};let k=I;if((S==="dark"&&!("dark"in n)||S==="light"&&!("light"in n))&&(k=!0),!k)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${S}\` option is either missing or invalid.`:Pr(21,S));let T;l&&(T="oklch");const f=oi(T,h,k,b,S);C&&!h.light&&oi(T,h,C,void 0,"light"),m&&!h.dark&&oi(T,h,m,void 0,"dark");let W={defaultColorScheme:S,...f,cssVarPrefix:a,colorSchemeSelector:u,rootSelector:g,getCssVar:y,colorSchemes:h,font:{...$d(f.typography),...f.font},spacing:ru(b.spacing)};Object.keys(W.colorSchemes).forEach(A=>{const v=W.colorSchemes[A].palette,O=q=>{const Y=q.split("-"),c=Y[1],re=Y[2];return y(q,v[c][re])};v.mode==="light"&&(F(v.common,"background","#fff"),F(v.common,"onBackground","#000")),v.mode==="dark"&&(F(v.common,"background","#000"),F(v.common,"onBackground","#fff"));function B(q,Y,c){if(T){let re;return q===Wr&&(re=`transparent ${((1-c)*100).toFixed(0)}%`),q===Ie&&(re=`#000 ${(c*100).toFixed(0)}%`),q===Ee&&(re=`#fff ${(c*100).toFixed(0)}%`),`color-mix(in ${T}, ${Y}, ${re})`}return q(Y,c)}if(tu(v,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),v.mode==="light"){F(v.Alert,"errorColor",B(Ie,l?y("palette-error-light"):v.error.light,.6)),F(v.Alert,"infoColor",B(Ie,l?y("palette-info-light"):v.info.light,.6)),F(v.Alert,"successColor",B(Ie,l?y("palette-success-light"):v.success.light,.6)),F(v.Alert,"warningColor",B(Ie,l?y("palette-warning-light"):v.warning.light,.6)),F(v.Alert,"errorFilledBg",O("palette-error-main")),F(v.Alert,"infoFilledBg",O("palette-info-main")),F(v.Alert,"successFilledBg",O("palette-success-main")),F(v.Alert,"warningFilledBg",O("palette-warning-main")),F(v.Alert,"errorFilledColor",Yt(()=>v.getContrastText(v.error.main))),F(v.Alert,"infoFilledColor",Yt(()=>v.getContrastText(v.info.main))),F(v.Alert,"successFilledColor",Yt(()=>v.getContrastText(v.success.main))),F(v.Alert,"warningFilledColor",Yt(()=>v.getContrastText(v.warning.main))),F(v.Alert,"errorStandardBg",B(Ee,l?y("palette-error-light"):v.error.light,.9)),F(v.Alert,"infoStandardBg",B(Ee,l?y("palette-info-light"):v.info.light,.9)),F(v.Alert,"successStandardBg",B(Ee,l?y("palette-success-light"):v.success.light,.9)),F(v.Alert,"warningStandardBg",B(Ee,l?y("palette-warning-light"):v.warning.light,.9)),F(v.Alert,"errorIconColor",O("palette-error-main")),F(v.Alert,"infoIconColor",O("palette-info-main")),F(v.Alert,"successIconColor",O("palette-success-main")),F(v.Alert,"warningIconColor",O("palette-warning-main")),F(v.AppBar,"defaultBg",O("palette-grey-100")),F(v.Avatar,"defaultBg",O("palette-grey-400")),F(v.Button,"inheritContainedBg",O("palette-grey-300")),F(v.Button,"inheritContainedHoverBg",O("palette-grey-A100")),F(v.Chip,"defaultBorder",O("palette-grey-400")),F(v.Chip,"defaultAvatarColor",O("palette-grey-700")),F(v.Chip,"defaultIconColor",O("palette-grey-700")),F(v.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),F(v.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),F(v.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),F(v.LinearProgress,"primaryBg",B(Ee,l?y("palette-primary-main"):v.primary.main,.62)),F(v.LinearProgress,"secondaryBg",B(Ee,l?y("palette-secondary-main"):v.secondary.main,.62)),F(v.LinearProgress,"errorBg",B(Ee,l?y("palette-error-main"):v.error.main,.62)),F(v.LinearProgress,"infoBg",B(Ee,l?y("palette-info-main"):v.info.main,.62)),F(v.LinearProgress,"successBg",B(Ee,l?y("palette-success-main"):v.success.main,.62)),F(v.LinearProgress,"warningBg",B(Ee,l?y("palette-warning-light"):v.warning.main,.62)),F(v.Skeleton,"bg",T?B(Wr,l?y("palette-text-primary"):v.text.primary,.11):`rgba(${O("palette-text-primaryChannel")} / 0.11)`),F(v.Slider,"primaryTrack",B(Ee,l?y("palette-primary-main"):v.primary.main,.62)),F(v.Slider,"secondaryTrack",B(Ee,l?y("palette-secondary-main"):v.secondary.main,.62)),F(v.Slider,"errorTrack",B(Ee,l?y("palette-error-main"):v.error.main,.62)),F(v.Slider,"infoTrack",B(Ee,l?y("palette-info-main"):v.info.main,.62)),F(v.Slider,"successTrack",B(Ee,l?y("palette-success-main"):v.success.main,.62)),F(v.Slider,"warningTrack",B(Ee,l?y("palette-warning-main"):v.warning.main,.62));const q=T?B(Ie,l?y("palette-background-default"):v.background.default,.6825):tn(v.background.default,.8);F(v.SnackbarContent,"bg",q),F(v.SnackbarContent,"color",Yt(()=>T?ci.text.primary:v.getContrastText(q))),F(v.SpeedDialAction,"fabHoverBg",tn(v.background.paper,.15)),F(v.StepConnector,"border",O("palette-grey-400")),F(v.StepContent,"border",O("palette-grey-400")),F(v.Switch,"defaultColor",O("palette-common-white")),F(v.Switch,"defaultDisabledColor",O("palette-grey-100")),F(v.Switch,"primaryDisabledColor",B(Ee,l?y("palette-primary-main"):v.primary.main,.62)),F(v.Switch,"secondaryDisabledColor",B(Ee,l?y("palette-secondary-main"):v.secondary.main,.62)),F(v.Switch,"errorDisabledColor",B(Ee,l?y("palette-error-main"):v.error.main,.62)),F(v.Switch,"infoDisabledColor",B(Ee,l?y("palette-info-main"):v.info.main,.62)),F(v.Switch,"successDisabledColor",B(Ee,l?y("palette-success-main"):v.success.main,.62)),F(v.Switch,"warningDisabledColor",B(Ee,l?y("palette-warning-main"):v.warning.main,.62)),F(v.TableCell,"border",B(Ee,Wr(l?y("palette-divider"):v.divider,1),.88)),F(v.Tooltip,"bg",B(Wr,l?y("palette-grey-700"):v.grey[700],.92))}if(v.mode==="dark"){F(v.Alert,"errorColor",B(Ee,l?y("palette-error-light"):v.error.light,.6)),F(v.Alert,"infoColor",B(Ee,l?y("palette-info-light"):v.info.light,.6)),F(v.Alert,"successColor",B(Ee,l?y("palette-success-light"):v.success.light,.6)),F(v.Alert,"warningColor",B(Ee,l?y("palette-warning-light"):v.warning.light,.6)),F(v.Alert,"errorFilledBg",O("palette-error-dark")),F(v.Alert,"infoFilledBg",O("palette-info-dark")),F(v.Alert,"successFilledBg",O("palette-success-dark")),F(v.Alert,"warningFilledBg",O("palette-warning-dark")),F(v.Alert,"errorFilledColor",Yt(()=>v.getContrastText(v.error.dark))),F(v.Alert,"infoFilledColor",Yt(()=>v.getContrastText(v.info.dark))),F(v.Alert,"successFilledColor",Yt(()=>v.getContrastText(v.success.dark))),F(v.Alert,"warningFilledColor",Yt(()=>v.getContrastText(v.warning.dark))),F(v.Alert,"errorStandardBg",B(Ie,l?y("palette-error-light"):v.error.light,.9)),F(v.Alert,"infoStandardBg",B(Ie,l?y("palette-info-light"):v.info.light,.9)),F(v.Alert,"successStandardBg",B(Ie,l?y("palette-success-light"):v.success.light,.9)),F(v.Alert,"warningStandardBg",B(Ie,l?y("palette-warning-light"):v.warning.light,.9)),F(v.Alert,"errorIconColor",O("palette-error-main")),F(v.Alert,"infoIconColor",O("palette-info-main")),F(v.Alert,"successIconColor",O("palette-success-main")),F(v.Alert,"warningIconColor",O("palette-warning-main")),F(v.AppBar,"defaultBg",O("palette-grey-900")),F(v.AppBar,"darkBg",O("palette-background-paper")),F(v.AppBar,"darkColor",O("palette-text-primary")),F(v.Avatar,"defaultBg",O("palette-grey-600")),F(v.Button,"inheritContainedBg",O("palette-grey-800")),F(v.Button,"inheritContainedHoverBg",O("palette-grey-700")),F(v.Chip,"defaultBorder",O("palette-grey-700")),F(v.Chip,"defaultAvatarColor",O("palette-grey-300")),F(v.Chip,"defaultIconColor",O("palette-grey-300")),F(v.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),F(v.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),F(v.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),F(v.LinearProgress,"primaryBg",B(Ie,l?y("palette-primary-main"):v.primary.main,.5)),F(v.LinearProgress,"secondaryBg",B(Ie,l?y("palette-secondary-main"):v.secondary.main,.5)),F(v.LinearProgress,"errorBg",B(Ie,l?y("palette-error-main"):v.error.main,.5)),F(v.LinearProgress,"infoBg",B(Ie,l?y("palette-info-main"):v.info.main,.5)),F(v.LinearProgress,"successBg",B(Ie,l?y("palette-success-main"):v.success.main,.5)),F(v.LinearProgress,"warningBg",B(Ie,l?y("palette-warning-main"):v.warning.main,.5)),F(v.Skeleton,"bg",T?B(Wr,l?y("palette-text-primary"):v.text.primary,.13):`rgba(${O("palette-text-primaryChannel")} / 0.13)`),F(v.Slider,"primaryTrack",B(Ie,l?y("palette-primary-main"):v.primary.main,.5)),F(v.Slider,"secondaryTrack",B(Ie,l?y("palette-secondary-main"):v.secondary.main,.5)),F(v.Slider,"errorTrack",B(Ie,l?y("palette-error-main"):v.error.main,.5)),F(v.Slider,"infoTrack",B(Ie,l?y("palette-info-main"):v.info.main,.5)),F(v.Slider,"successTrack",B(Ie,l?y("palette-success-main"):v.success.main,.5)),F(v.Slider,"warningTrack",B(Ie,l?y("palette-warning-light"):v.warning.main,.5));const q=T?B(Ee,l?y("palette-background-default"):v.background.default,.985):tn(v.background.default,.98);F(v.SnackbarContent,"bg",q),F(v.SnackbarContent,"color",Yt(()=>T?ea.text.primary:v.getContrastText(q))),F(v.SpeedDialAction,"fabHoverBg",tn(v.background.paper,.15)),F(v.StepConnector,"border",O("palette-grey-600")),F(v.StepContent,"border",O("palette-grey-600")),F(v.Switch,"defaultColor",O("palette-grey-300")),F(v.Switch,"defaultDisabledColor",O("palette-grey-600")),F(v.Switch,"primaryDisabledColor",B(Ie,l?y("palette-primary-main"):v.primary.main,.55)),F(v.Switch,"secondaryDisabledColor",B(Ie,l?y("palette-secondary-main"):v.secondary.main,.55)),F(v.Switch,"errorDisabledColor",B(Ie,l?y("palette-error-main"):v.error.main,.55)),F(v.Switch,"infoDisabledColor",B(Ie,l?y("palette-info-main"):v.info.main,.55)),F(v.Switch,"successDisabledColor",B(Ie,l?y("palette-success-main"):v.success.main,.55)),F(v.Switch,"warningDisabledColor",B(Ie,l?y("palette-warning-light"):v.warning.main,.55)),F(v.TableCell,"border",B(Ie,Wr(l?y("palette-divider"):v.divider,1),.68)),F(v.Tooltip,"bg",B(Wr,l?y("palette-grey-700"):v.grey[700],.92))}l||(ir(v.background,"default"),ir(v.background,"paper"),ir(v.common,"background"),ir(v.common,"onBackground"),ir(v,"divider")),Object.keys(v).forEach(q=>{const Y=v[q];q!=="tonalOffset"&&!l&&Y&&typeof Y=="object"&&(Y.main&&F(v[q],"mainChannel",Io(Eo(Y.main))),Y.light&&F(v[q],"lightChannel",Io(Eo(Y.light))),Y.dark&&F(v[q],"darkChannel",Io(Eo(Y.dark))),Y.contrastText&&F(v[q],"contrastTextChannel",Io(Eo(Y.contrastText))),q==="text"&&(ir(v[q],"primary"),ir(v[q],"secondary")),q==="action"&&(Y.active&&ir(v[q],"active"),Y.selected&&ir(v[q],"selected")))})}),W=r.reduce((A,v)=>Ct(A,v),W);const N={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:d,getSelector:eu(W),enableContrastVars:l},{vars:E,generateThemeVars:X,generateStyleSheets:te}=Cd(W,N);return W.vars=E,Object.entries(W.colorSchemes[W.defaultColorScheme]).forEach(([A,v])=>{W[A]=v}),W.generateThemeVars=X,W.generateStyleSheets=te,W.generateSpacing=function(){return Ks(b.spacing,ji(this))},W.getColorSchemeSelector=jd(u),W.spacing=W.generateSpacing(),W.shouldSkipGeneratingVar=d,W.unstable_sxConfig={...Bn,...b==null?void 0:b.unstable_sxConfig},W.unstable_sx=function(v){return Tn({sx:v,theme:this})},W.toRuntimeSource=ra,W}function ys(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:Bi({...n===!0?{}:n.palette,mode:r})})}function iu(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:a=n==null?void 0:n.mode,...l}=e,d=a||"light",u=s==null?void 0:s[d],g={...s,...n?{[d]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return di(e,...r);let b=n;"palette"in e||g[d]&&(g[d]!==!0?b=g[d].palette:d==="dark"&&(b={mode:"dark"}));const x=di({...e,palette:b},...r);return x.defaultColorScheme=d,x.colorSchemes=g,x.palette.mode==="light"&&(x.colorSchemes.light={...g.light!==!0&&g.light,palette:x.palette},ys(x,"dark",g.dark)),x.palette.mode==="dark"&&(x.colorSchemes.dark={...g.dark!==!0&&g.dark,palette:x.palette},ys(x,"light",g.light)),x}return!n&&!("light"in g)&&d==="light"&&(g.light=!0),nu({...l,colorSchemes:g,defaultColorScheme:d,...typeof i!="boolean"&&i},...r)}const su=iu();function bt(){const e=ud(su);return process.env.NODE_ENV!=="production"&&fn.useDebugValue(e),e[ec]||e}async function au(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 l;try{l=await fetch(e,{headers:i,signal:s.signal})}catch(g){throw clearTimeout(a),(g==null?void 0:g.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(l.status===401)throw new Error("Authentication failed (401) — check your API key");if(l.status===429){const g=l.headers.get("Retry-After"),b=g&&/^\d+$/.test(g)?` — retry after ${g}s`:"";throw new Error(`Rate limit exceeded (429 Too Many Requests)${b}`)}if(!l.ok){const g=l.statusText?`: ${l.statusText}`:"";throw new Error(`API error ${l.status}${g}`)}let d;try{d=await l.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(d))u=d;else if(n&&d[n]&&Array.isArray(d[n]))u=d[n];else{const b=["data","results","items","records"].find(x=>d[x]&&Array.isArray(d[x]));if(b)u=d[b];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:e,fetchedAt:new Date().toISOString()}}function lu(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 cu={menu:[{x:0,y:8,blur:16,spread:4,opacity:.12},{x:0,y:4,blur:16,spread:0,opacity:.08},{x:0,y:0,blur:0,spread:1,opacity:.05}],restButton:[{x:0,y:1,blur:2,spread:0,opacity:.3},{x:0,y:1,blur:3,spread:1,opacity:.15}],restButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1},{x:0,y:1,blur:3,spread:1,opacity:.05}],hoverButton:[{x:0,y:1,blur:3,spread:0,opacity:.3},{x:0,y:4,blur:8,spread:3,opacity:.15}],pressedButton:[{x:0,y:1,blur:2,spread:0,opacity:.3}],pressedButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1}],small:[{x:0,y:2,blur:6,spread:0,opacity:.15}],cardRest:[{x:0,y:1,blur:3,spread:0,opacity:.08},{x:0,y:1,blur:2,spread:0,opacity:.06}],cardHover:[{x:0,y:4,blur:16,spread:0,opacity:.15},{x:0,y:1,blur:4,spread:0,opacity:.08}],popover:[{x:0,y:4,blur:20,spread:0,opacity:.15},{x:0,y:1,blur:6,spread:0,opacity:.1}],flatHover:[{x:0,y:1,blur:2,spread:0,opacity:.06}]};function be(e,r){return lu(e,cu[r])}function it(e){return`${Number(e.shape.borderRadius)*1.5}px`}function No(e){return`${Number(e.shape.borderRadius)}px`}function bs(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 nt(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 he(e,r="menu"){const n=e.tokens;return{paper:{boxShadow:(n==null?void 0:n.cardBodyShadow)||be(e,r),border:n!=null&&n.cardBodyBorder&&n.cardBodyBorder!=="none"?n.cardBodyBorder:"none"},header:{backgroundColor:(n==null?void 0:n.cardHdrBg)||"transparent",borderBottom:(n==null?void 0:n.cardHdrBorder)||"none",boxShadow:(n==null?void 0:n.cardHdrAccent)||"none"}}}function du({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[a,l]=p.useState(""),[d,u]=p.useState(!1),[g,b]=p.useState(""),[x,S]=p.useState(null),[y,I]=p.useState(null),[C,m]=p.useState(!1),[j,h]=p.useState(""),k=p.useRef(null),[T,f]=p.useState("json"),[W,N]=p.useState(""),[E,X]=p.useState(""),[te,A]=p.useState(""),[v,O]=p.useState("idle"),[B,q]=p.useState(""),[Y,c]=p.useState(null),[re,se]=p.useState(0),V=async R=>{if(h(""),!R.name.endsWith(".json")){h("Only .json files are allowed");return}const oe=10*1024*1024;if(R.size>oe){h("File size exceeds 10MB limit");return}try{const G=await R.text();let ae;try{ae=JSON.parse(G)}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}S(R),I(ae)}catch{h("Network error — please try again")}},Z=R=>{R.preventDefault();const oe=R.dataTransfer.files[0];oe&&V(oe)},ue=async()=>{if(W.trim()){O("loading"),q("");try{const R=await au(W.trim(),E.trim()||void 0,te.trim()||void 0);c(R.data),se(R.data.length),O("ready")}catch(R){q((R==null?void 0:R.message)||"Connection failed"),O("error")}}},le=()=>{if(!a.trim()){u(!0);return}const R=T==="api"?Y:i||y;R&&(n(a.trim(),g.trim(),R),Q())},Q=()=>{l(""),u(!1),b(""),S(null),I(null),h(""),f("json"),N(""),X(""),A(""),O("idle"),q(""),c(null),se(0),r()},pe=i||y,ie=d&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:Q,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:R=>({borderRadius:it(R),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...he(R).paper})},children:[t.jsxs(o.DialogTitle,{sx:R=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:oe=>oe.typography.h4.fontWeight||500,fontSize:oe=>oe.typography.h4.fontSize||"1.125rem",color:"text.primary",letterSpacing:"-0.01em",...he(R).header}),children:["Create new report",t.jsx(o.IconButton,{onClick:Q,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:R=>{l(R.target.value),d&&R.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:ie,helperText:ie?"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:g,onChange:R=>b(R.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:(R,oe)=>{f(oe===0?"json":"api"),O("idle"),q("")},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:R=>`var(--highlight-hover, ${$(R.palette.primary.main,.15)})`},"&:hover":{bgcolor:R=>`var(--highlight-hover, ${$(R.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:R=>`var(--highlight-hover, ${$(R.palette.primary.main,.15)})`},"&:hover":{bgcolor:R=>`var(--highlight-hover, ${$(R.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:R=>$(R.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:R=>$(R.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:Z,onDragOver:R=>R.preventDefault(),onPaste:R=>R.preventDefault(),onClick:()=>{var R;return(R=k.current)==null?void 0:R.click()},sx:{position:"relative",border:"1.5px",borderStyle:y?"solid":"dashed",borderColor:y?"success.main":j?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:y?R=>$(R.palette.success.main,.04):j?R=>$(R.palette.error.main,.04):R=>$(R.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:y?R=>$(R.palette.success.main,.08):j?R=>$(R.palette.error.main,.08):R=>$(R.palette.primary.main,.08),borderColor:y?"success.dark":j?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:k,type:"file",accept:".json",sx:{display:"none"},onChange:R=>{var oe;return((oe=R.target.files)==null?void 0:oe[0])&&V(R.target.files[0])}}),y?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:R=>$(R.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:x==null?void 0:x.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:R=>$(R.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"}),j&&t.jsx(o.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:R=>$(R.palette.error.main,.08),border:1,borderColor:R=>$(R.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:j})})]})]})]})}),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:W,onChange:R=>{N(R.target.value),O("idle")},placeholder:"http://localhost:8000/api/reports/sales-pipeline/data/flat",sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(o.TextField,{label:"API Key (optional)",fullWidth:!0,size:"small",value:E,onChange:R=>X(R.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:te,onChange:R=>A(R.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:!W.trim()||v==="loading",onClick:ue,startIcon:v==="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:R=>$(R.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:v==="loading"?"Connecting...":"Test Connection & Load Data"}),v==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:R=>$(R.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:W})]})]}),v==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:R=>$(R.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:B})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:Q,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:R=>`${R.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:R=>$(R.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:le,disabled:T==="json"&&!pe||T==="api"&&v!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:R=>`${R.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:C,onClose:()=>m(!1),maxWidth:"sm",PaperProps:{sx:R=>({borderRadius:3,width:560,maxHeight:"80vh",...he(R).paper})},children:[t.jsxs(o.DialogTitle,{sx:R=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:oe=>oe.typography.h4.fontWeight||500,fontSize:oe=>oe.typography.h4.fontSize||"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...he(R).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 xs(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Ud=e=>{if(!Number.isNaN(+e))return+e;const r=e.match(/\d*\.?\d+/g);if(!r)return 0;let n=0;for(let i=0;i<r.length;i+=1)n+=+r[i];return n};function Gd(e){Object.assign(e,{alpha(r,n){const i=this||e;return i.colorSpace?`oklch(from ${r} l c h / ${typeof n=="string"?`calc(${n})`:n})`:i.vars?`rgba(${r.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof n=="string"?`calc(${n})`:n})`:$(r,Ud(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${xs(n)})`:$n(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${xs(n)})`:_n(r,n)}})}function hi(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:a={},transitions:l={},typography:d={},shape:u,colorSpace:g,...b}=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://v7.mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":Wr(20));const f=Ei({...a,colorSpace:g}),S=Xs(e);let y=vt(S,{mixins:_d(S.breakpoints,i),palette:f,shadows:Rd.slice(),typography:Od(f,d),transitions:Fd(l),zIndex:{...Vd}});if(y=vt(y,b),y=r.reduce((E,j)=>vt(E,j),y),process.env.NODE_ENV!=="production"){const E=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],j=(m,w)=>{let x;for(x in m){const C=m[x];if(E.includes(x)&&Object.keys(C).length>0){if(process.env.NODE_ENV!=="production"){const B=hd("",x);console.error([`MUI: The \`${w}\` component increases the CSS specificity of the \`${x}\` internal state.`,"You can not override it like this: ",JSON.stringify(m,null,2),"",`Instead, you need to use the '&.${B}' syntax:`,JSON.stringify({root:{[`&.${B}`]:C}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
|
|
170
|
+
`))}m[x]={}}}};Object.keys(y.components).forEach(m=>{const w=y.components[m].styleOverrides;w&&m.startsWith("Mui")&&j(w,m)})}return y.unstable_sxConfig={...In,...b==null?void 0:b.unstable_sxConfig},y.unstable_sx=function(j){return En({sx:j,theme:this})},y.toRuntimeSource=ra,Gd(y),y}function Yd(e){let r;return e<1?r=5.11916*e**2:r=4.5*Math.log(e+1)+2,Math.round(r*10)/1e3}const qd=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=Yd(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function oa(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function na(e){return e==="dark"?qd:[]}function Jd(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...a}=e,l=Ei({...r,colorSpace:s});return{palette:l,opacity:{...oa(l.mode),...n},overlays:i||na(l.mode),...a}}function Kd(e){var r;return!!e[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!e[0].match(/sxConfig$/)||e[0]==="palette"&&!!((r=e[1])!=null&&r.match(/(mode|contrastThreshold|tonalOffset)/))}const Xd=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Qd=e=>(r,n)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const l={};return Xd(e.cssVarPrefix).forEach(d=>{l[d]=n[d],delete n[d]}),a==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:l}}:a?{[a.replace("%s",r)]:l,[`${i}, ${a.replace("%s",r)}`]:n}:{[i]:{...n,...l}}}if(a&&a!=="media")return`${i}, ${a.replace("%s",String(r))}`}else if(r){if(a==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(a)return a.replace("%s",String(r))}return i};function Zd(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function V(e,r,n){!e[r]&&n&&(e[r]=n)}function $o(e){return typeof e!="string"||!e.startsWith("hsl")?e:Qs(e)}function dr(e,r){`${r}Channel`in e||(e[`${r}Channel`]=_o($o(e[r]),`MUI: Can't create \`palette.${r}Channel\` because \`palette.${r}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
|
|
171
|
+
To suppress this warning, you need to explicitly provide the \`palette.${r}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function eu(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Kt=e=>{try{return e()}catch{}},tu=(e="mui")=>yd(e);function si(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const a=s==="dark"?"dark":"light";if(!i){r[s]=Jd({...n,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:l,...d}=hi({...i,palette:{mode:a,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:l,opacity:{...oa(a),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||na(a)},d}function ru(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:l=!1,shouldSkipGeneratingVar:d=Kd,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:g=":root",...b}=e,f=Object.keys(n)[0],S=i||(n.light&&f!=="light"?"light":f),y=tu(a),{[S]:E,light:j,dark:m,...w}=n,x={...w};let C=E;if((S==="dark"&&!("dark"in n)||S==="light"&&!("light"in n))&&(C=!0),!C)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${S}\` option is either missing or invalid.`:Wr(21,S));let B;l&&(B="oklch");const p=si(B,x,C,b,S);j&&!x.light&&si(B,x,j,void 0,"light"),m&&!x.dark&&si(B,x,m,void 0,"dark");let A={defaultColorScheme:S,...p,cssVarPrefix:a,colorSchemeSelector:u,rootSelector:g,getCssVar:y,colorSchemes:x,font:{...Dd(p.typography),...p.font},spacing:eu(b.spacing)};Object.keys(A.colorSchemes).forEach(W=>{const v=A.colorSchemes[W].palette,O=q=>{const Y=q.split("-"),c=Y[1],re=Y[2];return y(q,v[c][re])};v.mode==="light"&&(V(v.common,"background","#fff"),V(v.common,"onBackground","#000")),v.mode==="dark"&&(V(v.common,"background","#000"),V(v.common,"onBackground","#fff"));function z(q,Y,c){if(B){let re;return q===Mr&&(re=`transparent ${((1-c)*100).toFixed(0)}%`),q===Ee&&(re=`#000 ${(c*100).toFixed(0)}%`),q===De&&(re=`#fff ${(c*100).toFixed(0)}%`),`color-mix(in ${B}, ${Y}, ${re})`}return q(Y,c)}if(Zd(v,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),v.mode==="light"){V(v.Alert,"errorColor",z(Ee,l?y("palette-error-light"):v.error.light,.6)),V(v.Alert,"infoColor",z(Ee,l?y("palette-info-light"):v.info.light,.6)),V(v.Alert,"successColor",z(Ee,l?y("palette-success-light"):v.success.light,.6)),V(v.Alert,"warningColor",z(Ee,l?y("palette-warning-light"):v.warning.light,.6)),V(v.Alert,"errorFilledBg",O("palette-error-main")),V(v.Alert,"infoFilledBg",O("palette-info-main")),V(v.Alert,"successFilledBg",O("palette-success-main")),V(v.Alert,"warningFilledBg",O("palette-warning-main")),V(v.Alert,"errorFilledColor",Kt(()=>v.getContrastText(v.error.main))),V(v.Alert,"infoFilledColor",Kt(()=>v.getContrastText(v.info.main))),V(v.Alert,"successFilledColor",Kt(()=>v.getContrastText(v.success.main))),V(v.Alert,"warningFilledColor",Kt(()=>v.getContrastText(v.warning.main))),V(v.Alert,"errorStandardBg",z(De,l?y("palette-error-light"):v.error.light,.9)),V(v.Alert,"infoStandardBg",z(De,l?y("palette-info-light"):v.info.light,.9)),V(v.Alert,"successStandardBg",z(De,l?y("palette-success-light"):v.success.light,.9)),V(v.Alert,"warningStandardBg",z(De,l?y("palette-warning-light"):v.warning.light,.9)),V(v.Alert,"errorIconColor",O("palette-error-main")),V(v.Alert,"infoIconColor",O("palette-info-main")),V(v.Alert,"successIconColor",O("palette-success-main")),V(v.Alert,"warningIconColor",O("palette-warning-main")),V(v.AppBar,"defaultBg",O("palette-grey-100")),V(v.Avatar,"defaultBg",O("palette-grey-400")),V(v.Button,"inheritContainedBg",O("palette-grey-300")),V(v.Button,"inheritContainedHoverBg",O("palette-grey-A100")),V(v.Chip,"defaultBorder",O("palette-grey-400")),V(v.Chip,"defaultAvatarColor",O("palette-grey-700")),V(v.Chip,"defaultIconColor",O("palette-grey-700")),V(v.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),V(v.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),V(v.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),V(v.LinearProgress,"primaryBg",z(De,l?y("palette-primary-main"):v.primary.main,.62)),V(v.LinearProgress,"secondaryBg",z(De,l?y("palette-secondary-main"):v.secondary.main,.62)),V(v.LinearProgress,"errorBg",z(De,l?y("palette-error-main"):v.error.main,.62)),V(v.LinearProgress,"infoBg",z(De,l?y("palette-info-main"):v.info.main,.62)),V(v.LinearProgress,"successBg",z(De,l?y("palette-success-main"):v.success.main,.62)),V(v.LinearProgress,"warningBg",z(De,l?y("palette-warning-light"):v.warning.main,.62)),V(v.Skeleton,"bg",B?z(Mr,l?y("palette-text-primary"):v.text.primary,.11):`rgba(${O("palette-text-primaryChannel")} / 0.11)`),V(v.Slider,"primaryTrack",z(De,l?y("palette-primary-main"):v.primary.main,.62)),V(v.Slider,"secondaryTrack",z(De,l?y("palette-secondary-main"):v.secondary.main,.62)),V(v.Slider,"errorTrack",z(De,l?y("palette-error-main"):v.error.main,.62)),V(v.Slider,"infoTrack",z(De,l?y("palette-info-main"):v.info.main,.62)),V(v.Slider,"successTrack",z(De,l?y("palette-success-main"):v.success.main,.62)),V(v.Slider,"warningTrack",z(De,l?y("palette-warning-main"):v.warning.main,.62));const q=B?z(Ee,l?y("palette-background-default"):v.background.default,.6825):on(v.background.default,.8);V(v.SnackbarContent,"bg",q),V(v.SnackbarContent,"color",Kt(()=>B?pi.text.primary:v.getContrastText(q))),V(v.SpeedDialAction,"fabHoverBg",on(v.background.paper,.15)),V(v.StepConnector,"border",O("palette-grey-400")),V(v.StepContent,"border",O("palette-grey-400")),V(v.Switch,"defaultColor",O("palette-common-white")),V(v.Switch,"defaultDisabledColor",O("palette-grey-100")),V(v.Switch,"primaryDisabledColor",z(De,l?y("palette-primary-main"):v.primary.main,.62)),V(v.Switch,"secondaryDisabledColor",z(De,l?y("palette-secondary-main"):v.secondary.main,.62)),V(v.Switch,"errorDisabledColor",z(De,l?y("palette-error-main"):v.error.main,.62)),V(v.Switch,"infoDisabledColor",z(De,l?y("palette-info-main"):v.info.main,.62)),V(v.Switch,"successDisabledColor",z(De,l?y("palette-success-main"):v.success.main,.62)),V(v.Switch,"warningDisabledColor",z(De,l?y("palette-warning-main"):v.warning.main,.62)),V(v.TableCell,"border",z(De,Mr(l?y("palette-divider"):v.divider,1),.88)),V(v.Tooltip,"bg",z(Mr,l?y("palette-grey-700"):v.grey[700],.92))}if(v.mode==="dark"){V(v.Alert,"errorColor",z(De,l?y("palette-error-light"):v.error.light,.6)),V(v.Alert,"infoColor",z(De,l?y("palette-info-light"):v.info.light,.6)),V(v.Alert,"successColor",z(De,l?y("palette-success-light"):v.success.light,.6)),V(v.Alert,"warningColor",z(De,l?y("palette-warning-light"):v.warning.light,.6)),V(v.Alert,"errorFilledBg",O("palette-error-dark")),V(v.Alert,"infoFilledBg",O("palette-info-dark")),V(v.Alert,"successFilledBg",O("palette-success-dark")),V(v.Alert,"warningFilledBg",O("palette-warning-dark")),V(v.Alert,"errorFilledColor",Kt(()=>v.getContrastText(v.error.dark))),V(v.Alert,"infoFilledColor",Kt(()=>v.getContrastText(v.info.dark))),V(v.Alert,"successFilledColor",Kt(()=>v.getContrastText(v.success.dark))),V(v.Alert,"warningFilledColor",Kt(()=>v.getContrastText(v.warning.dark))),V(v.Alert,"errorStandardBg",z(Ee,l?y("palette-error-light"):v.error.light,.9)),V(v.Alert,"infoStandardBg",z(Ee,l?y("palette-info-light"):v.info.light,.9)),V(v.Alert,"successStandardBg",z(Ee,l?y("palette-success-light"):v.success.light,.9)),V(v.Alert,"warningStandardBg",z(Ee,l?y("palette-warning-light"):v.warning.light,.9)),V(v.Alert,"errorIconColor",O("palette-error-main")),V(v.Alert,"infoIconColor",O("palette-info-main")),V(v.Alert,"successIconColor",O("palette-success-main")),V(v.Alert,"warningIconColor",O("palette-warning-main")),V(v.AppBar,"defaultBg",O("palette-grey-900")),V(v.AppBar,"darkBg",O("palette-background-paper")),V(v.AppBar,"darkColor",O("palette-text-primary")),V(v.Avatar,"defaultBg",O("palette-grey-600")),V(v.Button,"inheritContainedBg",O("palette-grey-800")),V(v.Button,"inheritContainedHoverBg",O("palette-grey-700")),V(v.Chip,"defaultBorder",O("palette-grey-700")),V(v.Chip,"defaultAvatarColor",O("palette-grey-300")),V(v.Chip,"defaultIconColor",O("palette-grey-300")),V(v.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),V(v.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),V(v.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),V(v.LinearProgress,"primaryBg",z(Ee,l?y("palette-primary-main"):v.primary.main,.5)),V(v.LinearProgress,"secondaryBg",z(Ee,l?y("palette-secondary-main"):v.secondary.main,.5)),V(v.LinearProgress,"errorBg",z(Ee,l?y("palette-error-main"):v.error.main,.5)),V(v.LinearProgress,"infoBg",z(Ee,l?y("palette-info-main"):v.info.main,.5)),V(v.LinearProgress,"successBg",z(Ee,l?y("palette-success-main"):v.success.main,.5)),V(v.LinearProgress,"warningBg",z(Ee,l?y("palette-warning-main"):v.warning.main,.5)),V(v.Skeleton,"bg",B?z(Mr,l?y("palette-text-primary"):v.text.primary,.13):`rgba(${O("palette-text-primaryChannel")} / 0.13)`),V(v.Slider,"primaryTrack",z(Ee,l?y("palette-primary-main"):v.primary.main,.5)),V(v.Slider,"secondaryTrack",z(Ee,l?y("palette-secondary-main"):v.secondary.main,.5)),V(v.Slider,"errorTrack",z(Ee,l?y("palette-error-main"):v.error.main,.5)),V(v.Slider,"infoTrack",z(Ee,l?y("palette-info-main"):v.info.main,.5)),V(v.Slider,"successTrack",z(Ee,l?y("palette-success-main"):v.success.main,.5)),V(v.Slider,"warningTrack",z(Ee,l?y("palette-warning-light"):v.warning.main,.5));const q=B?z(De,l?y("palette-background-default"):v.background.default,.985):on(v.background.default,.98);V(v.SnackbarContent,"bg",q),V(v.SnackbarContent,"color",Kt(()=>B?ea.text.primary:v.getContrastText(q))),V(v.SpeedDialAction,"fabHoverBg",on(v.background.paper,.15)),V(v.StepConnector,"border",O("palette-grey-600")),V(v.StepContent,"border",O("palette-grey-600")),V(v.Switch,"defaultColor",O("palette-grey-300")),V(v.Switch,"defaultDisabledColor",O("palette-grey-600")),V(v.Switch,"primaryDisabledColor",z(Ee,l?y("palette-primary-main"):v.primary.main,.55)),V(v.Switch,"secondaryDisabledColor",z(Ee,l?y("palette-secondary-main"):v.secondary.main,.55)),V(v.Switch,"errorDisabledColor",z(Ee,l?y("palette-error-main"):v.error.main,.55)),V(v.Switch,"infoDisabledColor",z(Ee,l?y("palette-info-main"):v.info.main,.55)),V(v.Switch,"successDisabledColor",z(Ee,l?y("palette-success-main"):v.success.main,.55)),V(v.Switch,"warningDisabledColor",z(Ee,l?y("palette-warning-light"):v.warning.main,.55)),V(v.TableCell,"border",z(Ee,Mr(l?y("palette-divider"):v.divider,1),.68)),V(v.Tooltip,"bg",z(Mr,l?y("palette-grey-700"):v.grey[700],.92))}l||(dr(v.background,"default"),dr(v.background,"paper"),dr(v.common,"background"),dr(v.common,"onBackground"),dr(v,"divider")),Object.keys(v).forEach(q=>{const Y=v[q];q!=="tonalOffset"&&!l&&Y&&typeof Y=="object"&&(Y.main&&V(v[q],"mainChannel",_o($o(Y.main))),Y.light&&V(v[q],"lightChannel",_o($o(Y.light))),Y.dark&&V(v[q],"darkChannel",_o($o(Y.dark))),Y.contrastText&&V(v[q],"contrastTextChannel",_o($o(Y.contrastText))),q==="text"&&(dr(v[q],"primary"),dr(v[q],"secondary")),q==="action"&&(Y.active&&dr(v[q],"active"),Y.selected&&dr(v[q],"selected")))})}),A=r.reduce((W,v)=>vt(W,v),A);const L={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:d,getSelector:Qd(A),enableContrastVars:l},{vars:I,generateThemeVars:Q,generateStyleSheets:ee}=Sd(A,L);return A.vars=I,Object.entries(A.colorSchemes[A.defaultColorScheme]).forEach(([W,v])=>{A[W]=v}),A.generateThemeVars=Q,A.generateStyleSheets=ee,A.generateSpacing=function(){return Ks(b.spacing,Ti(this))},A.getColorSchemeSelector=wd(u),A.spacing=A.generateSpacing(),A.shouldSkipGeneratingVar=d,A.unstable_sxConfig={...In,...b==null?void 0:b.unstable_sxConfig},A.unstable_sx=function(v){return En({sx:v,theme:this})},A.toRuntimeSource=ra,A}function gs(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:Ei({...n===!0?{}:n.palette,mode:r})})}function ou(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:a=n==null?void 0:n.mode,...l}=e,d=a||"light",u=s==null?void 0:s[d],g={...s,...n?{[d]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return hi(e,...r);let b=n;"palette"in e||g[d]&&(g[d]!==!0?b=g[d].palette:d==="dark"&&(b={mode:"dark"}));const f=hi({...e,palette:b},...r);return f.defaultColorScheme=d,f.colorSchemes=g,f.palette.mode==="light"&&(f.colorSchemes.light={...g.light!==!0&&g.light,palette:f.palette},gs(f,"dark",g.dark)),f.palette.mode==="dark"&&(f.colorSchemes.dark={...g.dark!==!0&&g.dark,palette:f.palette},gs(f,"light",g.light)),f}return!n&&!("light"in g)&&d==="light"&&(g.light=!0),ru({...l,colorSchemes:g,defaultColorScheme:d,...typeof i!="boolean"&&i},...r)}const nu=ou();function xt(){const e=cd(nu);return process.env.NODE_ENV!=="production"&&xn.useDebugValue(e),e[Ql]||e}async function iu(e,r,n){try{new URL(e)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};r&&(i.Authorization=`Bearer ${r}`);const s=new AbortController,a=setTimeout(()=>s.abort(),3e4);let l;try{l=await fetch(e,{headers:i,signal:s.signal})}catch(g){throw clearTimeout(a),(g==null?void 0:g.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(l.status===401)throw new Error("Authentication failed (401) — check your API key");if(l.status===429){const g=l.headers.get("Retry-After"),b=g&&/^\d+$/.test(g)?` — retry after ${g}s`:"";throw new Error(`Rate limit exceeded (429 Too Many Requests)${b}`)}if(!l.ok){const g=l.statusText?`: ${l.statusText}`:"";throw new Error(`API error ${l.status}${g}`)}let d;try{d=await l.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(d))u=d;else if(n&&d[n]&&Array.isArray(d[n]))u=d[n];else{const b=["data","results","items","records"].find(f=>d[f]&&Array.isArray(d[f]));if(b)u=d[b];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:e,fetchedAt:new Date().toISOString()}}function su(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${$(e.palette.common.black,n.opacity)}`).join(", ")}const au={menu:[{x:0,y:8,blur:16,spread:4,opacity:.12},{x:0,y:4,blur:16,spread:0,opacity:.08},{x:0,y:0,blur:0,spread:1,opacity:.05}],restButton:[{x:0,y:1,blur:2,spread:0,opacity:.3},{x:0,y:1,blur:3,spread:1,opacity:.15}],restButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1},{x:0,y:1,blur:3,spread:1,opacity:.05}],hoverButton:[{x:0,y:1,blur:3,spread:0,opacity:.3},{x:0,y:4,blur:8,spread:3,opacity:.15}],pressedButton:[{x:0,y:1,blur:2,spread:0,opacity:.3}],pressedButtonLight:[{x:0,y:1,blur:2,spread:0,opacity:.1}],small:[{x:0,y:2,blur:6,spread:0,opacity:.15}],cardRest:[{x:0,y:1,blur:3,spread:0,opacity:.08},{x:0,y:1,blur:2,spread:0,opacity:.06}],cardHover:[{x:0,y:4,blur:16,spread:0,opacity:.15},{x:0,y:1,blur:4,spread:0,opacity:.08}],popover:[{x:0,y:4,blur:20,spread:0,opacity:.15},{x:0,y:1,blur:6,spread:0,opacity:.1}],flatHover:[{x:0,y:1,blur:2,spread:0,opacity:.06}]};function ye(e,r){return su(e,au[r])}function nt(e){return`${Number(e.shape.borderRadius)*1.5}px`}function Fo(e){return`${Number(e.shape.borderRadius)}px`}function ys(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 Pt(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 he(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 lu({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[a,l]=h.useState(""),[d,u]=h.useState(!1),[g,b]=h.useState(""),[f,S]=h.useState(null),[y,E]=h.useState(null),[j,m]=h.useState(!1),[w,x]=h.useState(""),C=h.useRef(null),[B,p]=h.useState("json"),[A,L]=h.useState(""),[I,Q]=h.useState(""),[ee,W]=h.useState(""),[v,O]=h.useState("idle"),[z,q]=h.useState(""),[Y,c]=h.useState(null),[re,ae]=h.useState(0),G=async P=>{if(x(""),!P.name.endsWith(".json")){x("Only .json files are allowed");return}const oe=10*1024*1024;if(P.size>oe){x("File size exceeds 10MB limit");return}try{const me=await P.text();let pe;try{pe=JSON.parse(me)}catch{x("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(pe)){x("JSON must be an array of objects");return}if(pe.length===0){x("No data rows found in JSON file");return}S(P),E(pe)}catch{x("Network error — please try again")}},te=P=>{P.preventDefault();const oe=P.dataTransfer.files[0];oe&&G(oe)},ue=async()=>{if(A.trim()){O("loading"),q("");try{const P=await iu(A.trim(),I.trim()||void 0,ee.trim()||void 0);c(P.data),ae(P.data.length),O("ready")}catch(P){q((P==null?void 0:P.message)||"Connection failed"),O("error")}}},le=()=>{if(!a.trim()){u(!0);return}const P=B==="api"?Y:i||y;P&&(n(a.trim(),g.trim(),P),Z())},Z=()=>{l(""),u(!1),b(""),S(null),E(null),x(""),p("json"),L(""),Q(""),W(""),O("idle"),q(""),c(null),ae(0),r()},de=i||y,ie=d&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:Z,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:P=>({borderRadius:nt(P),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",...he(P).paper})},children:[t.jsxs(o.DialogTitle,{sx:P=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:oe=>oe.typography.h4.fontWeight||500,fontSize:oe=>oe.typography.h4.fontSize||"1.125rem",color:"text.primary",letterSpacing:"-0.01em",...he(P).header}),children:["Create new report",t.jsx(o.IconButton,{onClick:Z,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:P=>{l(P.target.value),d&&P.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:ie,helperText:ie?"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:g,onChange:P=>b(P.target.value),placeholder:"Add details about this report",inputProps:{maxLength:500},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsxs(o.Tabs,{value:B==="json"?0:1,onChange:(P,oe)=>{p(oe===0?"json":"api"),O("idle"),q("")},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:P=>`var(--highlight-hover, ${$(P.palette.primary.main,.15)})`},"&:hover":{bgcolor:P=>`var(--highlight-hover, ${$(P.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:P=>`var(--highlight-hover, ${$(P.palette.primary.main,.15)})`},"&:hover":{bgcolor:P=>`var(--highlight-hover, ${$(P.palette.primary.main,.08)})`}}})]}),B==="json"&&t.jsx(o.Box,{children:i?t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:P=>$(P.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:P=>$(P.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:te,onDragOver:P=>P.preventDefault(),onPaste:P=>P.preventDefault(),onClick:()=>{var P;return(P=C.current)==null?void 0:P.click()},sx:{position:"relative",border:"1.5px",borderStyle:y?"solid":"dashed",borderColor:y?"success.main":w?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:y?P=>$(P.palette.success.main,.04):w?P=>$(P.palette.error.main,.04):P=>$(P.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:y?P=>$(P.palette.success.main,.08):w?P=>$(P.palette.error.main,.08):P=>$(P.palette.primary.main,.08),borderColor:y?"success.dark":w?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:C,type:"file",accept:".json",sx:{display:"none"},onChange:P=>{var oe;return((oe=P.target.files)==null?void 0:oe[0])&&G(P.target.files[0])}}),y?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:P=>$(P.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:P=>$(P.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:P=>$(P.palette.error.main,.08),border:1,borderColor:P=>$(P.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:w})})]})]})]})}),B==="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:A,onChange:P=>{L(P.target.value),O("idle")},placeholder:"http://localhost:8000/api/reports/sales-pipeline/data/flat",sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(o.TextField,{label:"API Key (optional)",fullWidth:!0,size:"small",value:I,onChange:P=>Q(P.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:ee,onChange:P=>W(P.target.value),placeholder:"data (leave blank if API returns a plain array)",helperText:'If your API returns { "data": [...] }, enter: data',sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:0}}}),t.jsx(o.Button,{variant:"outlined",fullWidth:!0,disabled:!A.trim()||v==="loading",onClick:ue,startIcon:v==="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:P=>$(P.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:v==="loading"?"Connecting...":"Test Connection & Load Data"}),v==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:P=>$(P.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:A})]})]}),v==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:P=>$(P.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:z})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:Z,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:P=>$(P.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:le,disabled:B==="json"&&!de||B==="api"&&v!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:j,onClose:()=>m(!1),maxWidth:"sm",PaperProps:{sx:P=>({borderRadius:3,width:560,maxHeight:"80vh",...he(P).paper})},children:[t.jsxs(o.DialogTitle,{sx:P=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:oe=>oe.typography.h4.fontWeight||500,fontSize:oe=>oe.typography.h4.fontSize||"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...he(P).header}),children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>m(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(_.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{sx:{px:3,py:2},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem",lineHeight:1.5},children:"Your JSON file must be an array of objects. Each object represents a row, and all should have the same field names."})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),t.jsx(o.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
|
|
172
172
|
{
|
|
173
173
|
"id": 1,
|
|
174
174
|
"customerName": "John Smith",
|
|
@@ -178,7 +178,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
|
|
|
178
178
|
"memberSince": "2024-01-15",
|
|
179
179
|
"status": "active"
|
|
180
180
|
}
|
|
181
|
-
]`})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:2},children:t.jsx(o.Button,{onClick:()=>m(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:
|
|
181
|
+
]`})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:2},children:t.jsx(o.Button,{onClick:()=>m(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:P=>`${P.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function ia({isOpen:e,onClose:r,content:n,title:i="JSON Format Guide"}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:s=>({borderRadius:nt(s),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...he(s).paper})},children:[t.jsxs(o.DialogTitle,{sx:s=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,fontSize:s.typography.h4.fontSize||"1.125rem",fontWeight:s.typography.h4.fontWeight||500,...he(s).header}),children:[i,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:n?typeof n=="string"?t.jsx(o.Typography,{variant:"body2",sx:{whiteSpace:"pre-wrap"},children:n}):n:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",t.jsx("strong",{children:"array of objects"}),". Each object represents a single row in your report, and the keys of each object become the column names."]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(o.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
|
|
182
182
|
{
|
|
183
183
|
"Active Sessions": 33,
|
|
184
184
|
"Active State": true,
|
|
@@ -188,10 +188,10 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
|
|
|
188
188
|
"Region": "Europe",
|
|
189
189
|
"Subscription Type": "Basic"
|
|
190
190
|
}
|
|
191
|
-
]`})})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Number:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Boolean:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"String:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),","," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:i=>i.typography.body2.fontWeight||500,fontSize:i=>i.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Date:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[t.jsx("li",{children:"Each object in the array represents one row in the report."}),t.jsx("li",{children:"The keys of the JSON objects become report columns."}),t.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),t.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>be(i,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:i=>be(i,"hoverButton")},"&:active":{boxShadow:i=>be(i,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function uu({onFileUpload:e,onError:r,isUploading:n,jsonGuideContent:i}){const[s,a]=p.useState(!1),[l,d]=p.useState(""),[u,g]=p.useState(!1),b=p.useRef(null),x=async h=>{if(!h.name.endsWith(".json")){r("Only .json files are allowed");return}const k=10*1024*1024;if(h.size>k){r("File size exceeds 10MB limit");return}d(h.name);try{const T=await h.text();let f;try{f=JSON.parse(T)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(f)){r("JSON must be an array of objects");return}if(f.length===0){r("No data rows found in JSON file");return}e(f)}catch{r("Network error — please try again")}finally{d("")}},S=h=>{h.preventDefault(),a(!0)},y=h=>{h.preventDefault(),a(!1)},I=h=>{h.preventDefault(),a(!1);const k=h.dataTransfer.files[0];k&&x(k)},C=()=>{var h;(h=b.current)==null||h.click()},m=h=>{var T;const k=(T=h.target.files)==null?void 0:T[0];k&&x(k)},j=h=>{h.stopPropagation(),g(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:S,onDragLeave:y,onDrop:I,onPaste:h=>h.preventDefault(),onClick:C,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:s?"primary.main":"divider",bgcolor:s?h=>$(h.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:s?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:b,type:"file",accept:".json",onChange:m,sx:{display:"none"}}),n?t.jsxs(t.Fragment,{children:[t.jsx(o.CircularProgress,{size:32,sx:{mb:2}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||500,fontSize:h=>h.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),l&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:l})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:h=>$(h.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(_.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:j,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(ia,{isOpen:u,onClose:()=>g(!1),content:i})]})}function pu({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:"h4",sx:{fontWeight:i=>i.typography.h4.fontWeight||600,fontSize:i=>i.typography.h4.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 hu({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:"h4",color:"error.main",sx:{fontWeight:n=>n.typography.h4.fontWeight||600,fontSize:n=>n.typography.h4.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 sa({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 fu({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:l}){const[d,u]=p.useState(!1),[g,b]=p.useState(!1),[x,S]=p.useState(-1),y=p.useRef(null),I=p.useRef(null);p.useEffect(()=>{function E(X){y.current&&!y.current.contains(X.target)&&(u(!1),b(!1))}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const C=p.useCallback(()=>{b(!0),S(-1),n.length>0&&u(!0)},[n.length]),m=p.useCallback(E=>{r(E),S(-1)},[r]),j=p.useCallback(E=>{var X;r(E),i(E),u(!1),(X=I.current)==null||X.blur()},[r,i]),h=p.useCallback(E=>{S(-1),j(E)},[j]),k=p.useCallback(E=>{var X;E.key==="Enter"?x>=0&&x<n.length?(E.preventDefault(),h(n[x].query)):e.trim()&&j(e.trim()):E.key==="Escape"?(u(!1),S(-1),(X=I.current)==null||X.blur()):E.key==="ArrowDown"?(E.preventDefault(),n.length>0&&(d||u(!0),S(te=>te<n.length-1?te+1:te))):E.key==="ArrowUp"&&(E.preventDefault(),S(te=>te>0?te-1:-1))},[x,n,e,d,h,j]),T=p.useCallback(()=>{var E;r(""),(E=I.current)==null||E.focus()},[r]),f=p.useMemo(()=>n.filter(E=>E.isFavourite),[n]),W=p.useMemo(()=>n.filter(E=>!E.isFavourite),[n]),N=d&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:y,children:[t.jsx(o.TextField,{inputRef:I,size:"small",fullWidth:!0,value:e,onChange:E=>m(E.target.value),onFocus:C,onKeyDown:k,placeholder:"Search data...",disabled:l,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:E=>$(E.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:E=>$(E.palette.text.primary,.5)},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px",color:"text.primary"}},InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx(_.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}}),N&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[f.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:E=>E.typography.caption.fontWeight||600,fontSize:E=>E.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),f.map((E,X)=>t.jsx(vs,{entry:E,isSelected:x===X,onClick:()=>h(E.query),onToggleFavourite:()=>s(E.query),onDelete:()=>a(E.query)},`fav-${E.query}`))]}),W.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[f.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:E=>E.typography.caption.fontWeight||600,fontSize:E=>E.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),W.map((E,X)=>{const te=f.length+X;return t.jsx(vs,{entry:E,isSelected:x===te,onClick:()=>h(E.query),onToggleFavourite:()=>s(E.query),onDelete:()=>a(E.query)},`recent-${E.query}`)})]})]})]})}const vs=p.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const l=p.useCallback(u=>{u.stopPropagation(),s()},[s]),d=p.useCallback(u=>{u.stopPropagation(),a()},[a]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>$(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>$(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(o.IconButton,{size:"small",onClick:l,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:d,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(_.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function mu({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:l,onRestoreView:d,onPermanentDelete:u,onEditView:g,onCloneView:b,onCopyLink:x,onDeleteView:S,onPromoteToGlobal:y,onSetDefaultForAllUsers:I,isReadOnly:C,isAdmin:m=!1,hideViewMenuActions:j}){const h=bt(),[k,T]=p.useState(!1),[f,W]=p.useState(!1),[N,E]=p.useState({top:0,left:0}),[X,te]=p.useState(null),[A,v]=p.useState(null),O=p.useRef(null),B=p.useRef(null),q=e.find(G=>G.id===r),Y=q==null?void 0:q.isDefault,c=(G,ae)=>G.name.localeCompare(ae.name),re=e.filter(G=>G.scope==="global"&&!G.isDeleted).sort(c),se=e.filter(G=>G.scope!=="global"&&!G.isDeleted).sort(c),V=e.filter(G=>G.isFavorite&&!G.isDeleted).sort(c),Z=e.filter(G=>G.isDeleted);p.useEffect(()=>{if(k&&B.current){const G=B.current.getBoundingClientRect();E({top:G.bottom+window.scrollY+8,left:G.right+window.scrollX-320})}},[k]),p.useEffect(()=>{const G=ae=>{O.current&&!O.current.contains(ae.target)&&B.current&&!B.current.contains(ae.target)&&T(!1)};return k&&document.addEventListener("mousedown",G),()=>{document.removeEventListener("mousedown",G)}},[k]);const ue=G=>{if(n&&G!==r){te(G),T(!1);return}i(G),T(!1)},le=()=>{X&&(i(X),te(null))},Q=()=>{te(null)},pe=(G,ae=!1)=>{const De=G.scope==="global",ee=!C&&(!De||m),Ne=m&&!De;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===G.id?nt(h).bg:"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===G.id?nt(h).hoverBg:h.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>ue(G.id),sx:{display:"flex",alignItems:"center",gap:1,flex:1,textAlign:"left",minWidth:0,justifyContent:"flex-start",color:"inherit",p:0,"&:hover":{backgroundColor:"transparent"}},children:[r===G.id&&t.jsx(_.Check,{sx:{fontSize:16,flexShrink:0}}),r!==G.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===G.id?h.palette.primary.dark:h.palette.text.primary,fontWeight:r===G.id?Te=>Te.typography.body2.fontWeight||500:400,fontSize:Te=>Te.typography.body2.fontSize||"0.875rem"},children:G.name}),ae&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:h.palette.text.secondary,backgroundColor:h.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[ee&&l&&t.jsx(o.IconButton,{onClick:Te=>{Te.stopPropagation(),l(G.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:G.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(_.Star,{sx:{fontSize:16}})}),ee&&a&&!G.isDefault&&t.jsx(o.IconButton,{onClick:Te=>{Te.stopPropagation(),a(G.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Set as default",children:t.jsx(_.RadioButtonUnchecked,{sx:{fontSize:16}})}),(ee||Ne)&&(g||b||x||S||Ne&&y)&&t.jsx(o.IconButton,{onClick:Te=>{Te.stopPropagation(),v({el:Te.currentTarget,view:G})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"More actions",children:t.jsx(_.MoreVert,{sx:{fontSize:16}})})]})]},G.id)},ie=G=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:h.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:h.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:G.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[d&&t.jsx(o.IconButton,{onClick:ae=>{ae.stopPropagation(),d(G.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Restore view",children:t.jsx(_.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(o.IconButton,{onClick:ae=>{ae.stopPropagation(),u(G.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Delete permanently",children:t.jsx(_.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},G.id),R=n||!Y,oe=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:B,onClick:()=>T(!k),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:R?"warning.main":"text.primary",borderColor:R?"warning.main":"divider",bgcolor:R?$(h.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:R?"warning.dark":"primary.main",bgcolor:R?$(h.palette.warning.main,.2):$(h.palette.text.primary,.06),color:R?"warning.dark":"text.primary"}},title:`View: ${(q==null?void 0:q.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(q==null?void 0:q.name)||"Default View"}),oe&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),k&&Ds.createPortal(t.jsxs(o.Box,{ref:O,sx:{position:"fixed",width:"320px",backgroundColor:h.palette.background.paper,border:`1px solid ${h.palette.divider}`,borderRadius:1,boxShadow:h.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:N.top,left:N.left},children:[re.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:G=>G.typography.caption.fontSize||"caption.fontSize",fontWeight:G=>G.typography.caption.fontWeight||600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),re.map(G=>pe(G,G.isDefault))]}),V.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx(_.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),V.map(G=>pe(G))]})]}),se.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:G=>G.typography.caption.fontSize||"caption.fontSize",fontWeight:G=>G.typography.caption.fontWeight||600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),se.map(G=>pe(G))]})]}),Z.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>W(!f),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",Z.length,")"]}),t.jsx(_.ChevronRight,{sx:{fontSize:16}})]}),f&&t.jsx(o.Box,{sx:{backgroundColor:h.palette.action.hover},children:Z.map(G=>ie(G))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),T(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:h.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},children:[t.jsx(_.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!A,anchorEl:(A==null?void 0:A.el)||null,onClose:()=>v(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[g&&t.jsxs(o.MenuItem,{onClick:()=>{A&&g(A.view.id),v(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Edit,{sx:{fontSize:18}}),"Edit"]}),x&&t.jsxs(o.MenuItem,{onClick:()=>{A&&x(A.view.id),v(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Link,{sx:{fontSize:18}}),"Copy Link"]}),b&&t.jsxs(o.MenuItem,{onClick:()=>{A&&b(A.view.id),v(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),y&&m&&(A==null?void 0:A.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{A&&y(A.view.id),v(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Language,{sx:{fontSize:18}}),"Promote to Global"]}),I&&A&&!(j!=null&&j.includes("setDefaultForAllUsers"))?t.jsxs(o.MenuItem,{onClick:()=>{A&&I(A.view.id,!A.view.isDefaultForAllUsers),v(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Star,{sx:{fontSize:18,color:A.view.isDefaultForAllUsers?"warning.main":"inherit"}}),A.view.isDefaultForAllUsers?"Remove from":"Set as"," Default for All Users"]}):null,S&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{A&&S(A.view.id),v(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:X!==null,onClose:Q,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:No(h)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1,fontSize:h.typography.h4.fontSize||"1.125rem",fontWeight:h.typography.h4.fontWeight||500},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:Q,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:le,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function xu({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:l=!1,position:d,onSortAscending:u,onSortDescending:g,onRemoveSort:b,onFilter:x,onClearFilter:S,onGroupByColumn:y,onHideColumn:I,onManageColumns:C,onResetLayout:m,onClose:j}){const h=bt(),k=h.palette,T=p.useRef(null);p.useEffect(()=>{if(!T.current)return;const te=T.current,A=te.getBoundingClientRect(),v=window.innerWidth,O=window.innerHeight;A.right>v-8&&(te.style.left=`${v-A.width-8}px`),A.bottom>O-8&&(te.style.top=`${O-A.height-8}px`)},[d]),p.useEffect(()=>{const te=v=>{T.current&&!T.current.contains(v.target)&&j()},A=v=>{v.key==="Escape"&&j()};return document.addEventListener("mousedown",te),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",te),document.removeEventListener("keydown",A)}},[j]);const f=p.useCallback(te=>()=>{te(),j()},[j]),W=(n==null?void 0:n.direction)==="asc",N=(n==null?void 0:n.direction)==="desc",E=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",X=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return Ds.createPortal(t.jsxs(o.Paper,{ref:T,elevation:0,sx:{position:"fixed",left:`${d.x}px`,top:`${d.y}px`,zIndex:h.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:No(h),overflow:"hidden",boxShadow:`0 4px 20px ${$(k.common.black,.12)}, 0 1px 4px ${$(k.common.black,.06)}`},children:[!a&&t.jsxs(o.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsx(o.Typography,{sx:{fontSize:te=>te.typography.body2.fontSize||"0.8125rem",fontWeight:te=>te.typography.body2.fontWeight||500,color:"text.primary"},children:"Sorting"}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[t.jsx(o.Tooltip,{title:`Sort Ascending (${E})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:f(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:W?"primary.main":"text.secondary",bgcolor:W?$(k.primary.main,.1):"transparent","&:hover":{bgcolor:$(k.primary.main,.08),color:"primary.main"}},children:t.jsx(_.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${X})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:f(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:N?"primary.main":"text.secondary",bgcolor:N?$(k.primary.main,.1):"transparent","&:hover":{bgcolor:$(k.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:f(()=>b(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:$(k.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx(_.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:f(()=>x(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:f(()=>S(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:$(k.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(_.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!a&&y&&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:f(()=>y(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:f(()=>I(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:f(C),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:$(k.primary.main,.08),color:"primary.main"}},children:t.jsx(_.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:f(C),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&&l&&m&&t.jsxs(o.MenuItem,{onClick:f(m),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:$(k.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(_.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const gu=176,Ss="COLUMN_HEADER",yu=p.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:l=!1,hasModifications:d=!1,width:u,onColumnClick:g,onMoveColumn:b,onColumnDragEnd:x,onResizeStart:S,onSortAscending:y,onSortDescending:I,onRemoveSort:C,onOpenFilterForColumn:m,onClearFiltersForColumn:j,onGroupByColumn:h,onHideColumn:k,onManageColumns:T,onResetLayout:f}){const N=bt().urmTable,E=p.useRef(null),[X,te]=p.useState(!1),[A,v]=p.useState({x:0,y:0}),[{handlerId:O,isOver:B},q]=sr.useDrop({accept:Ss,collect(Q){return{handlerId:Q.getHandlerId(),isOver:Q.isOver()}},hover(Q,pe){var ee;if(!E.current)return;const ie=Q.index,R=n;if(ie===R)return;const oe=(ee=E.current)==null?void 0:ee.getBoundingClientRect(),G=(oe.right-oe.left)/2,ae=pe.getClientOffset(),De=((ae==null?void 0:ae.x)??0)-oe.left;ie<R&&De<G||ie>R&&De>G||(b(ie,R),Q.index=R)}}),[{isDragging:Y},c]=sr.useDrag({type:Ss,item:()=>({index:n,columnName:r.name}),collect:Q=>({isDragging:Q.isDragging()}),end:()=>{x==null||x()}});c(q(E));const re=p.useCallback(Q=>{Q.preventDefault(),Q.stopPropagation(),v({x:Q.clientX,y:Q.clientY}),te(!0)},[]),se=p.useCallback(()=>te(!1),[]),V=p.useCallback(()=>{g(r.name)},[g,r.name]),Z=p.useCallback(Q=>{Q.stopPropagation(),m(r.name)},[m,r.name]),ue=p.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx(_.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]),le=p.useCallback(()=>s?t.jsx(_.FilterList,{onClick:Z,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,Z]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:E,"data-handler-id":O,"data-column-index":n,onClick:V,onContextMenu:re,sx:{position:"sticky",top:0,zIndex:5,textAlign:(N==null?void 0:N.cellAlignH)??"left",verticalAlign:(N==null?void 0:N.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(N==null?void 0:N.headerColor)??"text.secondary",opacity:Y?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:B?Q=>$(Q.palette.primary.main,.08):(N==null?void 0:N.headerBg)??"action.hover",boxShadow:Q=>`0 1px 0 ${$(Q.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(N==null?void 0:N.rowDivider)??"1px solid",borderRight:N==null?void 0:N.colDivider,borderColor:"divider",py:0,px:(N==null?void 0:N.cellPaddingX)??2,"&:hover":{bgcolor:Q=>$(Q.palette.primary.main,.1),color:"text.primary"},width:u?`${u}px`:`${gu}px`},children:[t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[ut(r.name),ue(),le()]}),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"}})}),B&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),X&&t.jsx(xu,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:l,hasModifications:d,position:A,onSortAscending:y,onSortDescending:I,onRemoveSort:C,onFilter:m,onClearFilter:j,onGroupByColumn:h,onHideColumn:k,onManageColumns:T,onResetLayout:f,onClose:se})]})}),bu={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"},vu={error:"err",warning:"warn",info:"info",success:"suc"};function hn(e,r){var l,d;const n=bu[r.toLowerCase().trim()];if(!n||n==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.tokens,s=vu[n],a=e.palette[n];return{bg:((l=i==null?void 0:i.status)==null?void 0:l[`${s}Soft`])??$(a.main,e.palette.mode==="dark"?.24:.12),color:((d=i==null?void 0:i.status)==null?void 0:d[`${s}Txt`])??(e.palette.mode==="dark"?a.light:a.dark)}}function Su(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 wu={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"},rows:{hue:"primary",shade:"main"}};function ws(e,r){const n=wu[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function Dt(e){return $(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function Cu(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=>hn(n,r).bg,color:n=>hn(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function ju(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 Cu(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:a=>{const l=Su(a,s);return l?{color:l,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 ku(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 zu({row:e,rowIndex:r,visibleColumns:n,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:l,onOpenRowMenu:d,onToggleSelection:u,hideCheckbox:g}){const[b,x]=p.useState(!1),{primaryCol:S,idCol:y,bodyColumns:I}=p.useMemo(()=>ku(n),[n]),C=S?e[S.name]:null,m=y?e[y.name]:null,j=b||i;return t.jsxs(o.Box,{onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),onClick:h=>s(r,h),onDoubleClick:h=>a(e,r,h),onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),l(e,r,h)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:h=>{var T,f,W,N;const k=(N=(W=(f=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:f.styleOverrides)==null?void 0:W.root)==null?void 0:N.border;return i?"2px solid":k&&k!=="none"?k:"1px solid"},borderColor:i?h=>nt(h).main:h=>{var T,f,W,N;const k=(N=(W=(f=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:f.styleOverrides)==null?void 0:W.root)==null?void 0:N.border;return k&&k!=="none"?"inherit":$(h.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:h=>{var T,f,W,N;const k=(N=(W=(f=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:f.styleOverrides)==null?void 0:W.root)==null?void 0:N.borderRadius;return k!==void 0?typeof k=="number"?`${k}px`:k:`${h.shape.borderRadius}px`},cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?h=>`0 0 0 3px ${$(nt(h).main,.15)}, 0 2px 8px ${$(h.palette.common.black,.08)}`:b?h=>{var T,f,W,N;const k=(N=(W=(f=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:f.styleOverrides)==null?void 0:W.root)==null?void 0:N.boxShadow;return k&&k!=="none"?k:be(h,"cardHover")}:h=>{var T,f,W,N;const k=(N=(W=(f=(T=h.components)==null?void 0:T.MuiCard)==null?void 0:f.styleOverrides)==null?void 0:W.root)==null?void 0:N.boxShadow;return k&&k!=="none"?k:be(h,"cardRest")},transform:b&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:h=>$(nt(h).main,.03)}},children:[t.jsxs(o.Box,{sx:h=>{var N,E,X,te;const k=((X=(E=(N=h.components)==null?void 0:N.MuiCardHeader)==null?void 0:E.styleOverrides)==null?void 0:X.root)||{},T=(k.backgroundColor&&k.backgroundColor!=="transparent"?k.backgroundColor:void 0)??((te=h.tokens)==null?void 0:te.cardHdrHex)??"transparent",f=k.borderBottom&&k.borderBottom!=="none"?k.borderBottom:void 0,W=k.boxShadow&&k.boxShadow!=="none"?k.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:T,borderBottom:f,boxShadow:W,display:"flex",alignItems:"center",gap:.5}},children:[!g&&j&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:h=>h.stopPropagation(),onChange:()=>u(e),sx:{p:.25}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||600,fontSize:h=>h.typography.body1.fontSize||"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:C!=null&&C!==""?String(C):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(o.Box,{sx:h=>{var f,W,N;const k=((N=(W=(f=h.components)==null?void 0:f.MuiCardHeader)==null?void 0:W.styleOverrides)==null?void 0:N.root)||{};return k.borderBottom&&k.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[I.map(h=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:k=>k.typography.body2.fontWeight||500,fontSize:k=>k.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:ut(h.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[h.name]??""),children:ju(h,e[h.name])})]},h.name)),I.length===0&&t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic",gridColumn:"1 / -1"},children:"No additional fields visible"})]}),t.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:h=>$(h.palette.action.hover,.1),minHeight:40},children:[t.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:m?.85:0,userSelect:"none"},children:m?String(m):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:j?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(),d(e,r,h.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:h=>$(h.palette.text.primary,.08)}},children:t.jsx(_.MoreVert,{sx:{fontSize:17}})})})})]})]})}function Bu({row:e,grouping:r,onToggleCollapse:n}){var i;return t.jsxs(o.Box,{onClick:()=>n(e.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:s=>be(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:Qa(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])=>As(a)).filter(Boolean).join(" • ")})]})}function Tu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:l,onCardDoubleClick:d,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:b,hideSelectionCheckboxes:x}){const S=p.useMemo(()=>{const y=new Set;return i.forEach(I=>{const C=I==null?void 0:I.__urm_row_id__;C!==void 0&&y.add(C)}),y},[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:y=>y.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:y=>bs(y).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:y=>bs(y).cardGap,alignContent:"start"},children:e.map((y,I)=>s&&y.isGroupHeader?t.jsx(Bu,{row:y,grouping:n,onToggleCollapse:a||(()=>{})},`group-${y.groupKey}`):t.jsx(zu,{row:y,rowIndex:I,visibleColumns:r,isSelected:S.has(y==null?void 0:y.__urm_row_id__),onCardClick:l,onCardDoubleClick:d,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:b,hideCheckbox:x},`card-${I}`))})})}const Cs=[10,15,25,50,100];function Iu(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 Eu({currentPage:e,pageSize:r,totalRows:n,totalPages:i,totalFields:s,selectedCount:a,onClearSelection:l,onPageChange:d,onPageSizeChange:u}){const b=bt().palette,x=i??Math.max(1,Math.ceil(n/r)),[S,y]=p.useState(String(e)),[I,C]=p.useState(null),[m,j]=p.useState(!1),h=p.useRef(null);p.useEffect(()=>{m||(y(String(e)),C(null))},[e,m]);const k=p.useCallback(()=>{const Y=Iu(S,x);if(Y){C(Y);return}const c=parseInt(S.trim(),10);C(null),j(!1),c!==e&&d(c)},[S,x,e,d]),T=p.useCallback(Y=>{var c;Y.key==="Enter"?(Y.preventDefault(),k()):Y.key==="Escape"&&(y(String(e)),C(null),j(!1),(c=h.current)==null||c.blur())},[k,e]),f=p.useCallback(()=>{y(String(e)),C(null),j(!1)},[e]),W=p.useCallback(()=>{j(!0),C(null),setTimeout(()=>{var Y;return(Y=h.current)==null?void 0:Y.select()},0)},[]);if(n<=Math.min(...Cs))return null;const N=()=>{y(String(e)),C(null),j(!1)},E=()=>{N(),d(1)},X=()=>{N(),e>1&&d(e-1)},te=()=>{N(),e<x&&d(e+1)},A=()=>{N(),d(x)},v=(e-1)*r+1,O=Math.min(e*r,n),B=`${Math.max(2,String(x).length+.5)}ch`,q={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:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),s!==void 0&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:s})]}),!!a&&a>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"primary.main",fontWeight:600},children:[a," selected"]}),l&&t.jsx(o.Button,{size:"small",onClick:l,sx:{fontSize:"0.75rem",p:0,minWidth:"auto",color:"text.secondary"},children:"Clear"})]})]}),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:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:Y=>u(Number(Y.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:Cs.map(Y=>t.jsx(o.MenuItem,{value:Y,sx:{fontSize:"0.8125rem"},children:Y},Y))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[v,"–",O," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[I&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:$(b.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${$(b.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:$(b.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:Y=>Y.typography.caption.fontSize||"0.6875rem",fontWeight:Y=>Y.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:I})}),t.jsx(o.InputBase,{inputRef:h,value:S,onChange:Y=>{y(Y.target.value),I&&C(null)},onKeyDown:T,onFocus:W,onBlur:f,inputProps:{"aria-label":`Page number, 1 to ${x}`,style:{textAlign:"center",padding:"2px 0",width:B,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:I?"error.main":"text.primary",border:"1px solid",borderColor:I?"error.main":m?"primary.main":"divider",borderRadius:"4px",bgcolor:I?$(b.error.main,.04):m?$(b.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:I?"error.main":"text.secondary"},"&:focus-within":{boxShadow:I?`0 0 0 2px ${$(b.error.main,.2)}`:`0 0 0 2px ${$(b.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",x]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:E,disabled:e===1,size:"small",title:"First page",sx:q,children:t.jsx(_.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:X,disabled:e===1,size:"small",title:"Previous page",sx:q,children:t.jsx(_.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:te,disabled:e===x,size:"small",title:"Next page",sx:q,children:t.jsx(_.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:A,disabled:e===x,size:"small",title:"Last page",sx:q,children:t.jsx(_.LastPage,{sx:{fontSize:20}})})]})]})]})}function Du(){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 aa="urm_hint_seen_";function _u(e){try{return localStorage.getItem(aa+e)==="true"}catch{return!1}}function $u(e){try{localStorage.setItem(aa+e,"true")}catch{}}const la={"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:"8px"},"& .MuiInputLabel-root":{fontSize:"0.875rem"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:.5},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}};function ui(e,r){if(e==null||e==="")return"";if(r==="boolean")return e?"True":"False";if(r==="object"||r==="array")try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}function ca({row:e,schema:r}){const i=bt().palette,s=r.filter(d=>d.name in e),a=s.filter(d=>d.type!=="object"&&d.type!=="array"),l=s.filter(d=>d.type==="object"||d.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[a.map(d=>t.jsx(o.TextField,{label:ut(d.name),value:ui(e[d.name],d.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:la},d.name)),l.map(d=>{const u=ui(e[d.name],d.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:g=>g.typography.caption.fontWeight||500,fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:ut(d.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:$(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:u?"text.primary":"text.disabled",fontStyle:u?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:u||"No value"})]},d.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3,fontSize:d=>d.typography.body2.fontSize||"0.875rem"},children:"No fields to display"})]})}function Ou({open:e,onClose:r,row:n,schema:i,reportName:s}){const a=bt(),l=a.palette;if(!n)return null;const d=i.filter(g=>g.name in n).length,u=he(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:it(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...u.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...u.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:$(l.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:"h4",sx:{fontSize:g=>g.typography.h4.fontSize||"1rem",fontWeight:g=>g.typography.h4.fontWeight||600,color:g=>g.typography.h4.color||"text.primary",lineHeight:1.3},children:"View Record"}),s&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",d," ",d===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:$(l.text.primary,.015)},children:t.jsx(ca,{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:g=>`${g.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function Mu({open:e,onClose:r,onConfirm:n,row:i,schema:s}){const a=bt(),l=he(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:it(a),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",...l.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",...l.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:d=>$(d.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:"h4",sx:{fontSize:d=>d.typography.h4.fontSize||"1.125rem",fontWeight:d=>d.typography.h4.fontWeight||500,color:d=>d.typography.h4.color||"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:d=>d.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(ca,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:d=>$(d.palette.error.main,.1),border:d=>`1px solid ${$(d.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:d=>d.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:d=>d.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:d=>`${d.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:d=>`${d.shape.borderRadius}px`,boxShadow:d=>be(d,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:d=>be(d,"hoverButton")},"&:active":{boxShadow:d=>be(d,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Au({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var j;const l=bt(),d=l.palette,[u,g]=p.useState({});if(p.useEffect(()=>{e&&i&&g({...i})},[e,i]),!i)return null;const b=s.filter(h=>h.name in i),x=b.filter(h=>h.type!=="object"&&h.type!=="array"),S=b.filter(h=>h.type==="object"||h.type==="array"),y=(h,k)=>{g(T=>({...T,[h]:k}))},I=()=>{const h={...u};b.forEach(k=>{const T=u[k.name];if(k.type==="number"){const f=Number(T);h[k.name]=isNaN(f)?i[k.name]:f}else k.type==="boolean"&&(h[k.name]=!!T)}),n(h),r()},C=b.length,m=he(l);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:it(l),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:$(((j=d.warning)==null?void 0:j.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,{variant:"h4",sx:{fontSize:h=>h.typography.h4.fontSize||"1rem",fontWeight:h=>h.typography.h4.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," · ",C," ",C===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.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[x.map(h=>{const k=u[h.name];return h.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:T=>T.typography.caption.fontWeight||500,fontSize:T=>T.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:ut(h.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!k,onChange:T=>y(h.name,T.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:T=>T.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:k?"Enabled":"Disabled"})]})]},h.name):t.jsx(o.TextField,{label:ut(h.name),value:k??"",onChange:T=>y(h.name,T.target.value),type:h.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:la},h.name)}),S.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:S.map(h=>{const k=ui(i[h.name],h.type);return t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:T=>T.typography.caption.fontSize||"0.75rem",fontWeight:T=>T.typography.caption.fontWeight||500,color:"text.secondary"},children:ut(h.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:$(d.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.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:k?"text.primary":"text.disabled",fontStyle:k?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:k||"No value"})]},h.name)})}),b.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:I,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 Wu=176,Ru=170,Pu=40;function da(e){return e.type==="date"?180:Wu}function Nu(e,r){return r!=null&&r!==Ru&&r!==da(e)}function Lu(e,r,n){return p.useMemo(()=>{const i=e.map(x=>({name:x.name,width:r[x.name]??da(x),explicit:Nu(x,r[x.name])})),s={};i.forEach(x=>{s[x.name]=x.width});const a=i.reduce((x,S)=>x+S.width,0),d=Math.max(0,n-Pu)-a;if(d<=0)return{widths:s,fillerWidth:0};const u=i.filter(x=>!x.explicit);if(u.length===0)return{widths:s,fillerWidth:d};const g=u.reduce((x,S)=>x+S.width,0)||1;let b=0;return u.forEach((x,S)=>{const I=S===u.length-1?x.width+d-b:Math.round(x.width+d*x.width/g);s[x.name]=I,b+=I-x.width}),{widths:s,fillerWidth:0}},[e,r,n])}const js=176,Fu=Pt(),Vu={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Hu(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=>hn(n,r).bg,color:n=>hn(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Uu(e){const r=e.toLowerCase().trim(),n=Vu[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Gu(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,l)=>a.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:a},l):a)}function Yu(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 Hu(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Uu(s);if(e.type==="date"){const d=e.dateFormat??"iso",u=Fa(r,d,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}if(e.type==="number"&&typeof r=="number")return r.toLocaleString();if(typeof r=="boolean")return r?"Yes":"No";if(Array.isArray(r)){if(r.length===0)return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const d=r.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return t.jsxs(o.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[d,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const d=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:d,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:d.length>40?d.slice(0,40)+"…":d})}return Gu(s,i)}function qu({schema:e,data:r,sortStack:n=[],filters:i=Fu,views:s=[],activeViewId:a="",isDirty:l=!1,isExporting:d=!1,columnVisibility:u={},columnOrder:g=[],columnWidths:b={},grouping:x=null,classTokens:S={},onSort:y,onSortAscending:I,onSortDescending:C,onOpenFilters:m,onOpenSort:j,onOpenFilterForColumn:h,onSelectView:k,onCreateView:T,onUpdateCurrentView:f,onSaveAsNewView:W,onDiscardChanges:N,onToggleDefault:E,onToggleFavorite:X,onRestoreView:te,onPermanentDelete:A,onEditView:v,onCloneView:O,onCopyLink:B,onDeleteView:q,onPromoteToGlobal:Y,onSetDefaultForAllUsers:c,isAdmin:re=!1,hideViewMenuActions:se,onExport:V,onOpenColumns:Z,onUpdateColumnWidth:ue,onUpdateColumnOrder:le,onUpdateColumnVisibility:Q,onClearFiltersForColumn:pe,onResetLayout:ie,onOpenGroup:R,onGroupByColumn:oe,onToggleGroupCollapse:G,onExpandAllGroups:ae,onCollapseAllGroups:De,onOpenAuditHistory:ee,onOpenScheduledReports:Ne,searchQuery:Te,highlightQuery:$t="",searchHistory:Fr=[],onAddToSearchHistory:Kt,onToggleSearchFavourite:Cr,onDeleteSearchHistory:Ot,selectedRowIds:pt=new Set,onSearchChange:Xt,onToggleRowSelection:Ze,onToggleAllRows:Mt,onRangeSelection:jr,onClearSelection:at,onExportSelected:Qt,currentPage:fo=1,pageSize:lr=15,totalRowsBeforePagination:mo=r.length,totalPagesOverride:Zt,onPageChange:kr,onPageSizeChange:jt,isReadOnly:Je=!1,userRole:zr,reportName:ht,onEditRow:rt,onDuplicateRow:Nt,onDeleteRow:cr,showDevPanel:xo=!1,onOpenDevConfig:Vr,rowActions:dr,hideDefaultRowActions:Ke,hideToolbarActions:Ce,customSettingsActions:At,jsonGuideContent:Br,viewOptions:Hr,defaultViewMode:ur,bulkActions:Tr,hideSelectionCheckboxes:Ur,rowClickBehavior:pr="select",openModalOn:et,onRowClick:Lt,onRowRightClick:Se}){var qo;const me=bt().urmTable,[kt,H]=p.useState(null),[vt,ce]=p.useState(0),[lt,Ir]=p.useState(0),[zt,Gr]=p.useState(null),hr=Nr(),Er=((qo=hr.dates)==null?void 0:qo.displayFormat)??null,[Ft,fr]=p.useState(null),[Dr,we]=p.useState(null),[ft,mt]=p.useState(null),[U,Oe]=p.useState(!1),[Me,_r]=p.useState(!1),[$r,Yr]=p.useState(null),[go,Vt]=p.useState(!1),[yo,qr]=p.useState(null),[Wt,Or]=p.useState(null),[je,Ye]=p.useState(null),[Mr,ct]=p.useState(null),er=p.useRef(null),fe=p.useCallback(()=>{er.current&&(clearTimeout(er.current),er.current=null)},[]),xe=p.useCallback(()=>{fe(),er.current=setTimeout(()=>ct(null),200)},[fe]);p.useEffect(()=>fe,[fe]);const[Ae,We]=p.useState(null),st=p.useMemo(()=>Hr??["list","grid"],[Hr]),[dt,xt]=p.useState(()=>ur??st[0]??"list"),[Jr,tr]=p.useState(!1),[rr,Ar]=p.useState(()=>!_u("toolbar_search")),mr=p.useRef(null),bo=p.useRef(null),[$n,Fo]=p.useState(0);p.useLayoutEffect(()=>{const w=mr.current;if(!w)return;Fo(w.clientWidth);const L=new ResizeObserver(ne=>{Fo(ne[0].contentRect.width)});return L.observe(w),()=>L.disconnect()},[]);const Kr=p.useCallback(()=>{$u("toolbar_search"),Ar(!1)},[]);p.useEffect(()=>{if(!rr)return;const w=setTimeout(Kr,2e3);return()=>clearTimeout(w)},[rr,Kr]);const Vo=p.useMemo(()=>{const w=zt??g;return w.length>0?w.map(L=>e.find(ne=>ne.name===L)).filter(L=>L!==void 0):e},[zt,g,e]),Xr=p.useMemo(()=>Vo.filter(w=>u[w.name]!==!1),[Vo,u]),vo=p.useMemo(()=>new Set(((x==null?void 0:x.levels)??[]).map(w=>w.column)),[x]),Ho=!!(x!=null&&x.enabled&&(x!=null&&x.levels)&&x.levels.length>0),Qr=p.useMemo(()=>{if(!Ho)return Xr;const w=((x==null?void 0:x.levels)??[]).map(ne=>e.find(ke=>ke.name===ne.column)).filter(ne=>ne!==void 0),L=Xr.filter(ne=>!vo.has(ne.name));return[...w,...L]},[Xr,Ho,vo,x,e]),{widths:Zr}=Lu(Qr,b,$n),xr=p.useMemo(()=>e.filter(w=>u[w.name]===!1).length,[e,u]),So=p.useMemo(()=>e.map(w=>w.name),[e]),eo=p.useMemo(()=>g.length===0?!1:JSON.stringify(g)!==JSON.stringify(So),[g,So]),On=p.useCallback((w,L)=>{w.preventDefault(),w.stopPropagation(),H(L),ce(w.clientX),Ir(b[L]||150)},[b]);p.useEffect(()=>{if(!kt)return;const w=ne=>{const ke=ne.clientX-vt,Le=Math.max(100,Math.min(600,lt+ke));ue==null||ue(kt,Le)},L=()=>{H(null)};return document.addEventListener("mousemove",w),document.addEventListener("mouseup",L),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",L)}},[kt,vt,lt,ue]);const Mn=p.useCallback(w=>w==null?"-":typeof w=="object"?JSON.stringify(w):typeof w=="boolean"?w?"true":"false":String(w),[]);p.useCallback(w=>{const L=n.find(ne=>ne.column===w);return L?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[L.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:L.priority})]}):null},[n]),p.useCallback(w=>ii(i,w)?t.jsx(o.IconButton,{size:"small",onClick:ne=>{ne.stopPropagation(),h==null||h(w)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx(_.FilterList,{sx:{fontSize:14}})}):null,[i,h]);const An=p.useCallback(w=>{y&&y(w)},[y]),Wn=p.useCallback((w,L)=>{Gr(ne=>{const Le=[...ne??(g.length>0?g:e.map(Xe=>Xe.name))],[ot]=Le.splice(w,1);return Le.splice(L,0,ot),Le})},[g,e]),Rn=p.useCallback(()=>{zt&&le&&le(zt),Gr(null)},[zt,le]),Pn=p.useCallback(w=>{if(!y)return;const L=n.find(ne=>ne.column===w);(!L||L.direction!=="asc")&&y(w)},[y,n]),Nn=p.useCallback(w=>{if(!y)return;const L=n.find(ne=>ne.column===w);L?L.direction==="asc"&&y(w):(y(w),setTimeout(()=>y(w),0))},[y,n]),Ln=p.useCallback(w=>{if(!y)return;const L=n.find(ne=>ne.column===w);L&&(L.direction==="asc"?(y(w),setTimeout(()=>y(w),0)):L.direction==="desc"&&y(w))},[y,n]),Fn=p.useCallback(w=>{Q&&Q(w,!1)},[Q]),to=!!(x!=null&&x.enabled&&(x!=null&&x.levels)&&x.levels.length>0),or=p.useMemo(()=>Et(i),[i]),Vn=n.length>0||or>0||((x==null?void 0:x.enabled)??!1)||Object.values(u).some(w=>w===!1),Hn=(fo-1)*lr,He=r,tt=p.useMemo(()=>{const w=new Set;return pt.forEach(L=>{const ne=L==null?void 0:L.__urm_row_id__;ne!==void 0&&w.add(ne)}),w},[pt]);p.useEffect(()=>{const w=L=>{!Mt||!at||L.target instanceof HTMLInputElement||L.target instanceof HTMLTextAreaElement||((L.ctrlKey||L.metaKey)&&L.key==="a"&&(L.preventDefault(),Mt(!0,He)),L.key==="Escape"&&(L.preventDefault(),at()))};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[Mt,at,He]);const wo=p.useCallback((w,L)=>{Lt==null||Lt(He[w],w,L),(pr==="activate"||pr==="both")&&(mt(He[w]),Oe(!0)),pr!=="activate"&&Ze&&(L.shiftKey&&Ft!==null?(L.preventDefault(),jr&&jr(Ft,w,He)):(Ze(He[w]),fr(w)))},[Ze,Ft,jr,He,Lt,pr,mt,Oe]),ro=p.useMemo(()=>He.filter(w=>!w.isGroupHeader),[He]),Uo=p.useMemo(()=>ro.length>0&&tt.size>0&&ro.every(w=>tt.has(w==null?void 0:w.__urm_row_id__)),[ro,tt]),Un=!Uo&&ro.some(w=>tt.has(w==null?void 0:w.__urm_row_id__)),nr=!!(Ze&&Mt&&!Ur),St=p.useMemo(()=>Qr,[Qr]),Go=p.useMemo(()=>{const w=new Map;if(!(x!=null&&x.enabled)||!He)return w;let L=[];for(const ne of He)if(ne.__isGroupHeader||ne.isGroupHeader){const ke=ne.groupLevel??0;L[ke]=ne.groupKey,L=L.slice(0,ke+1),w.has(ne.groupKey)||w.set(ne.groupKey,[])}else if(ne.__urm_is_grouped_data_row__)for(const ke of L)ke&&w.has(ke)&&w.get(ke).push(ne);return w},[x,He]),oo=p.useCallback(w=>{const L=w.groupLevel,ne=L===0?S.groupRowLevel0||"urm-group-level-0":L===1?S.groupRowLevel1||"urm-group-level-1":S.groupRowLevel2||"urm-group-level-2",ke=L===0?Re=>Re.palette.mode==="dark"?$(Re.palette.action.hover,.12):"#f1f5f9":Re=>Re.palette.mode==="dark"?$(Re.palette.action.hover,.06):"#f8fafc",Le=String(w.groupValue??"(empty)"),ot=`${w.rowCount} ${w.rowCount===1?"item":"items"}`,Xe=Go.get(w.groupKey)||[],ge=Xe.filter(Re=>tt.has(Re==null?void 0:Re.__urm_row_id__)).length,Ht=Xe.length>0&&ge===Xe.length,Ut=ge>0&&ge<Xe.length;return t.jsxs(o.TableRow,{onClick:()=>G==null?void 0:G(w.groupKey),className:`urm-group-header-row urm-group-level-${L} ${ne} ${S.groupRow||""}`,sx:{bgcolor:ke,"&:hover":{bgcolor:Re=>$(Re.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[nr&&t.jsx(o.TableCell,{padding:"checkbox",onClick:Re=>Re.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Ht,indeterminate:Ut,onChange:()=>{if(!Ze)return;const Re=!Ht;Xe.forEach(gr=>{const Jo=tt.has(gr==null?void 0:gr.__urm_row_id__);Re!==Jo&&Ze(gr)})}})}),t.jsxs(o.TableCell,{colSpan:St.length,className:`urm-group-cell ${S.groupCellFirst||""} ${S.groupCell||""}`,sx:{pl:`${L*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[L>0&&t.jsx(o.Box,{sx:{position:"absolute",left:`${L*24+4}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsxs(o.Box,{className:`urm-group-content ${S.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${S.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:w.isCollapsed?t.jsx(_.ChevronRight,{sx:{fontSize:18}}):t.jsx(_.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"h5",className:`urm-group-title ${S.groupTitle||""}`,sx:{fontWeight:L===0?600:500,fontSize:L===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Le}),!w.isCollapsed&&t.jsx(o.Box,{className:"urm-group-column-heading-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Re=>$(Re.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:Re=>$(Re.palette.primary.main,.2),ml:.5},children:ut(w.groupColumn||"")}),!!w.__urm_is_continuation_header__&&t.jsx(o.Box,{className:"urm-group-continuation-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Re=>$(Re.palette.text.secondary,.05),color:"text.secondary",borderRadius:"10px",border:"1px dashed",borderColor:"divider",ml:.5},children:"Continued"}),t.jsx(o.Box,{className:`urm-group-count ${S.groupBadge||""} ${S.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Re=>$(Re.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:ot}),Object.keys(w.aggregates||{}).length>0&&t.jsxs(o.Typography,{variant:"caption",className:`urm-group-aggregates ${S.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(w.aggregates).map(([Re,gr])=>As(gr)).filter(Boolean).join(" • "),")"]})]})]})]},w.groupKey)},[St,nr,x,e,G,S,me,Go,tt,Ze]),Yo=p.useCallback((w,L)=>{const ne=tt.has(w==null?void 0:w.__urm_row_id__),ke=Dr===L,Le=U&&(w==null?void 0:w.__urm_row_id__)===(ft==null?void 0:ft.__urm_row_id__),ot=!!(w!=null&&w.__urm_is_grouped_data_row__),Xe=ot?w.__urm_group_level__??(x==null?void 0:x.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":L,className:ot?`urm-data-row-grouped ${S.dataRowGrouped||""}`:"",onMouseEnter:()=>we(L),onMouseLeave:()=>we(null),onClick:ge=>{ge.target.closest("[data-row-action-btn]")||wo(L,ge)},onDoubleClick:()=>{et!=null&&et.includes("doubleClick")&&(mt(w),Oe(!0))},onContextMenu:ge=>{ge.preventDefault(),ge.stopPropagation(),Se==null||Se(w,L,ge),ct(null),Ye({mouseX:ge.clientX,mouseY:ge.clientY,row:w,rowIndex:L}),et!=null&&et.includes("rightClick")&&(mt(w),Oe(!0))},sx:{cursor:"pointer",bgcolor:ne?ge=>nt(ge).bg:Le?ge=>$(ge.palette.info.main,.12):me!=null&&me.striped&&L%2===1?me.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:ne?ge=>nt(ge).hoverBg:Le?ge=>$(ge.palette.info.main,.2):ge=>`var(--highlight-hover-row, ${$(nt(ge).main,.04)})`},borderBottom:(me==null?void 0:me.rowDivider)??"1px solid",borderColor:"divider"},children:[nr&&t.jsx(o.TableCell,{padding:"checkbox",onClick:ge=>ge.stopPropagation(),sx:{borderBottom:(me==null?void 0:me.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(me==null?void 0:me.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:ne,onChange:()=>Ze==null?void 0:Ze(w)})}),St.map((ge,Ht)=>{const Ut=Ht===0;return t.jsxs(o.TableCell,{className:ot&&Ut?`urm-data-cell-grouped ${S.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(me==null?void 0:me.rowPaddingY)??"6px",px:(me==null?void 0:me.cellPaddingX)??2,pl:ot&&Ut?`${Xe*24}px`:void 0,position:"relative",textAlign:(me==null?void 0:me.cellAlignH)??"left",verticalAlign:(me==null?void 0:me.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(me==null?void 0:me.rowDivider)??"1px solid",borderRight:me==null?void 0:me.colDivider,borderColor:"divider",minWidth:b[ge.name]?`${b[ge.name]}px`:`${ge.type==="date"?Math.max(js,180):js}px`},children:[ot&&Ut&&Xe>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%"},children:t.jsx("span",{className:`urm-item-title ${S.itemTitle||""}`,children:Yu(ge,w[ge.name],Er,$t)})})]},ge.name)}),t.jsx(o.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:0,minWidth:0,maxWidth:0,p:0,border:"none",background:"transparent",opacity:ke?1:0,transition:"opacity 0.12s ease",zIndex:10},children:t.jsx(o.Box,{sx:{position:"absolute",right:8,top:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"flex-end",zIndex:10},children:t.jsx(o.IconButton,{"data-row-action-btn":"true",size:"small",onClick:ge=>{ge.stopPropagation(),ge.preventDefault(),ct(null),Ye({anchorEl:ge.currentTarget,row:w,rowIndex:L})},sx:{color:"text.secondary",opacity:ke?1:0,transition:"opacity 0.12s ease",pointerEvents:ke?"auto":"none","&:hover":{bgcolor:ge=>$(ge.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(_.MoreVert,{sx:{fontSize:18}})})})})]},L)},[pt,Hn,Dr,wo,Qr,b,$t,Mn,rt,Nt,cr,Ze,nr,mt,Oe,ft,U,Ye,to,vo,Se,et,tt,me,S]);return t.jsxs(sr.DndProvider,{backend:pi.HTML5Backend,children:[t.jsxs(o.Box,{sx:w=>{var ot,Xe,ge;const L=((ge=(Xe=(ot=w.components)==null?void 0:ot.MuiCard)==null?void 0:Xe.styleOverrides)==null?void 0:ge.root)||{},ne=L.border&&L.border!=="none"?L.border:"1px solid",ke=L.borderRadius!==void 0?typeof L.borderRadius=="number"?`${L.borderRadius}px`:L.borderRadius:`${w.shape.borderRadius}px`,Le=L.boxShadow&&L.boxShadow!=="none"?L.boxShadow:be(w,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:ne,borderColor:ne!=="none"?"divider":void 0,borderRadius:ke,boxShadow:Le,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:w=>{var ot,Xe,ge,Ht,Ut;const L=((ge=(Xe=(ot=w.components)==null?void 0:ot.MuiCardHeader)==null?void 0:Xe.styleOverrides)==null?void 0:ge.root)||{},ne=(L.backgroundColor&&L.backgroundColor!=="transparent"?L.backgroundColor:void 0)??((Ht=w.tokens)==null?void 0:Ht.cardHdrHex)??((Ut=w.urmTable)==null?void 0:Ut.headerBg)??w.palette.background.paper,ke=L.borderBottom&&L.borderBottom!=="none"?L.borderBottom:"1px solid",Le=L.boxShadow&&L.boxShadow!=="none"?L.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:ne,borderBottom:ke,borderColor:ke!=="none"?"divider":void 0,boxShadow:Le,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Je&&t.jsx(Du,{}),Xt&&Kt&&Cr&&Ot&&!(Ce!=null&&Ce.includes("search"))&&t.jsx(o.Tooltip,{open:rr,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",fontWeight:w=>w.typography.caption.fontWeight||500,mb:.25},children:"💡 Search tip"}),t.jsx(o.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:Kr},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(fu,{value:Te||"",onChange:w=>{rr&&Kr(),Xt(w)},searchHistory:Fr,onAddToHistory:Kt,onToggleFavourite:Cr,onDeleteHistory:Ot,disabled:Je})})}),!(Ce!=null&&Ce.includes("jsonGuide"))&&t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>tr(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:w=>$(w.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:20}})})}),k&&T&&f&&s.length>0&&t.jsx(mu,{views:s||[],activeViewId:a||"",isDirty:l,onSelectView:k,onCreateView:T,onToggleDefault:E,onToggleFavorite:X,onRestoreView:te,onPermanentDelete:A,onEditView:v,onCloneView:O,onCopyLink:B,onDeleteView:q,onPromoteToGlobal:Y,onSetDefaultForAllUsers:c,isAdmin:re,hideViewMenuActions:se,isReadOnly:Je}),l&&!Je&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[f&&t.jsx(o.Button,{onClick:f,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:w=>`var(--urm-btn-save-current-bg, ${w.palette.primary.main})`,color:w=>`var(--urm-btn-save-current-color, ${w.palette.primary.contrastText})`,textTransform:"none",boxShadow:w=>be(w,"restButton"),"&:hover":{bgcolor:w=>`var(--urm-btn-save-current-hover-bg, ${w.palette.primary.dark})`,boxShadow:w=>be(w,"hoverButton")}},children:"Save current view"}),W&&t.jsx(o.Button,{onClick:W,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:w=>`var(--urm-btn-save-new-border, ${w.palette.primary.main})`,color:w=>`var(--urm-btn-save-new-color, ${w.palette.primary.main})`,bgcolor:w=>`var(--urm-btn-save-new-bg, ${w.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:w=>`var(--urm-btn-save-new-hover-border, ${w.palette.primary.dark})`,bgcolor:w=>`var(--urm-btn-save-new-hover-bg, ${$(w.palette.primary.main,.08)})`}},children:"Save new view"}),N&&t.jsx(o.Button,{onClick:N,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:w=>`var(--urm-btn-discard-bg, ${$(w.palette.text.primary,.12)})`,color:w=>`var(--urm-btn-discard-color, ${w.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:w=>`var(--urm-btn-discard-hover-bg, ${$(w.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),xo&&Vr&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:Vr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:w=>$(w.palette.text.secondary,.3),"&:hover":{bgcolor:w=>$(w.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&&j&&!(Ce!=null&&Ce.includes("sort"))&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:j,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?w=>Dt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?w=>$(w.palette.primary.main,.2):w=>$(w.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&&!(Ce!=null&&Ce.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:m,size:"small",sx:{position:"relative",color:or>0?"primary.main":"text.secondary",bgcolor:or>0?w=>Dt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:or>0?w=>$(w.palette.primary.main,.2):w=>$(w.palette.text.primary,.06),color:or>0?"primary.main":"text.primary"}},children:[t.jsx(_.FilterList,{sx:{fontSize:20}}),or>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:or})]})}),!Je&&Z&&!(Ce!=null&&Ce.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:Z,size:"small",sx:{position:"relative",color:xr>0||eo?"primary.main":"text.secondary",bgcolor:xr>0||eo?w=>Dt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:xr>0||eo?w=>$(w.palette.primary.main,.2):w=>$(w.palette.text.primary,.06),color:xr>0||eo?"primary.main":"text.primary"}},children:[t.jsx(_.ViewColumn,{sx:{fontSize:20}}),xr>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:xr})]})}),to&&(ae||De)&&(()=>{var ne;const w=(((ne=x==null?void 0:x.collapsedGroups)==null?void 0:ne.length)??0)>0,L=w?ae:De;return L?t.jsx(o.Tooltip,{title:w?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:L,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:ke=>$(ke.palette.text.primary,.06),color:"text.primary"}},children:w?t.jsx(_.UnfoldMore,{sx:{fontSize:20}}):t.jsx(_.UnfoldLess,{sx:{fontSize:20}})})}):null})(),st.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),st.map(w=>{const L=dt===w,ne=w==="list"?t.jsx(_.TableRows,{sx:{fontSize:20}}):t.jsx(_.GridView,{sx:{fontSize:20}}),ke=w==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:ke,children:t.jsx(o.IconButton,{size:"small",onClick:()=>xt(w),sx:{borderRadius:1,color:L?"primary.main":"text.secondary",bgcolor:L?Le=>Dt(Le):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:L?Le=>$(Le.palette.primary.main,.2):Le=>$(Le.palette.text.primary,.06),color:L?"primary.main":"text.primary"}},children:ne})},w)})]}),!(Ce!=null&&Ce.includes("settings"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),t.jsx(o.Tooltip,{title:"Settings",children:t.jsx(o.IconButton,{onClick:w=>We(w.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:w=>$(w.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(_.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!Ae,anchorEl:Ae,onClose:()=>We(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:[V&&!(Ce!=null&&Ce.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{V(),We(null)},disabled:d,sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.Download,{sx:{fontSize:w=>w.typography.body1.fontSize,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Je&&R&&!(Ce!=null&&Ce.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{R(),We(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"})]}),ee&&!(Ce!=null&&Ce.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ee(),We(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"})]}),Ne&&!(Ce!=null&&Ce.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ne(),We(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"})]}),At==null?void 0:At.map(w=>t.jsxs(o.MenuItem,{dense:!0,disabled:w.disabled,onClick:()=>{w.onClick(),We(null)},sx:{py:1,px:2,gap:1.5},children:[w.icon,t.jsx(o.Typography,{variant:"body2",children:w.label})]},w.key))]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Tr&&Tr.length>0&&tt.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:w=>nt(w).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:w=>w.typography.body2.fontWeight||600,mr:1},children:[tt.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>at==null?void 0:at(),children:"Clear"}),Tr.map(w=>{var ne,ke;const L=Array.from(pt);return(ne=w.hidden)!=null&&ne.call(w,L)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:w.icon,disabled:(ke=w.disabled)==null?void 0:ke.call(w,L),onClick:()=>w.onClick(L),children:w.label},w.key)})]}),dt!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(Tu,{data:He,visibleColumns:Xr,grouping:x,selectedRowIds:pt,isGrouped:!!to,onToggleGroupCollapse:G,onCardClick:(w,L)=>wo(w,L),onCardDoubleClick:w=>{et!=null&&et.includes("doubleClick")&&(mt(w),Oe(!0))},onCardContextMenu:(w,L,ne)=>{Se==null||Se(w,L,ne),ct(null),Ye({mouseX:ne.clientX,mouseY:ne.clientY,row:w,rowIndex:L}),et!=null&&et.includes("rightClick")&&(mt(w),Oe(!0))},onOpenRowMenu:(w,L,ne)=>Ye({anchorEl:ne,row:w,rowIndex:L}),onToggleSelection:w=>Ze==null?void 0:Ze(w),hideSelectionCheckboxes:Ur})}),dt==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:mr,onScroll:w=>{bo.current&&(bo.current.scrollLeft=w.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Zr).reduce((w,L)=>w+L,0)}px`},children:[t.jsxs("colgroup",{children:[nr&&t.jsx("col",{style:{width:"40px"}}),St.map(w=>t.jsx("col",{style:{width:`${Zr[w.name]}px`}},w.name))]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(me==null?void 0:me.headerBg)??"action.hover",borderBottom:(me==null?void 0:me.rowDivider)??"1px solid",borderColor:"divider"},children:[nr&&t.jsx(o.TableCell,{padding:"checkbox",sx:{borderBottom:(me==null?void 0:me.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(me==null?void 0:me.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:Uo,indeterminate:Un,onChange:w=>Mt==null?void 0:Mt(w.target.checked,He)})}),St.map((w,L)=>t.jsx(yu,{column:w,index:L,sortRule:n.find(ne=>ne.column===w.name),hasFilters:ii(i,w.name),isInSortStack:n.some(ne=>ne.column===w.name),isReadOnly:Je,hasModifications:Vn,width:b[w.name],onColumnClick:An,onMoveColumn:Wn,onColumnDragEnd:Rn,onResizeStart:On,onSortAscending:I||Pn,onSortDescending:C||Nn,onRemoveSort:Ln,onOpenFilterForColumn:h||(()=>{}),onClearFiltersForColumn:pe||(()=>{}),onGroupByColumn:oe,onHideColumn:Fn,onManageColumns:Z||(()=>{}),onResetLayout:ie},w.name))]})})]})}),t.jsx(o.Box,{ref:bo,onScroll:w=>{mr.current&&(mr.current.scrollLeft=w.target.scrollLeft)},sx:{flex:1,overflowY:"auto",overflowX:"auto",minHeight:0,bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:w=>$(w.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:w=>$(w.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Zr).reduce((w,L)=>w+L,0)}px`},children:[t.jsxs("colgroup",{children:[nr&&t.jsx("col",{style:{width:"40px"}}),St.map(w=>t.jsx("col",{style:{width:`${Zr[w.name]}px`}},w.name))]}),t.jsx(o.TableBody,{children:He.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:St.length,align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):to?He.map((w,L)=>w.isGroupHeader?oo(w):Yo(w,L)):He.map((w,L)=>Yo(w,L))})]})})]}),kr&&jt&&t.jsx(Eu,{currentPage:fo,pageSize:lr,totalRows:mo,totalPages:Zt,totalFields:e.length,selectedCount:tt.size,onClearSelection:at,onPageChange:kr,onPageSizeChange:jt}),!(kr&&jt)&&t.jsxs(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider",display:"flex",alignItems:"center",gap:1.5},children:[t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",He.length," ",He.length===1?"row":"rows"]}),tt.size>0&&t.jsxs(t.Fragment,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{color:"primary.main",fontWeight:600},children:["· ",tt.size," selected"]}),at&&t.jsx(o.Button,{size:"small",onClick:at,sx:{fontSize:"0.75rem",p:0,minWidth:"auto",color:"text.secondary"},children:"Clear"})]})]})]})]}),t.jsxs(o.Popover,{open:!!je,onClose:()=>{Ye(null),ct(null)},anchorEl:(je==null?void 0:je.anchorEl)||null,anchorReference:je!=null&&je.anchorEl?"anchorEl":"anchorPosition",anchorPosition:je&&!je.anchorEl?{top:je.mouseY,left:je.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:je!=null&&je.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(Ke!=null&&Ke.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(mt(je.row),Oe(!0)),Ye(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"})]}),!(Ke!=null&&Ke.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(qr(je.row),Or(je.rowIndex),Vt(!0)),Ye(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"})]}),!(Ke!=null&&Ke.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(Nt==null||Nt(je.rowIndex,je.row)),Ye(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"})]}),je&&(dr==null?void 0:dr.map(w=>{var L,ne;return(L=w.hidden)!=null&&L.call(w,je.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(ne=w.disabled)==null?void 0:ne.call(w,je.row),onClick:()=>{w.onClick(je.row,je.rowIndex),Ye(null)},sx:{py:1,px:2,gap:1.5},children:[w.icon,t.jsx(o.Typography,{variant:"body2",children:w.label})]},w.key)})),tt.size>0&&Qt&&!(Ke!=null&&Ke.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:w=>{fe(),ct(w.currentTarget)},onMouseLeave:xe,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between",flexWrap:"wrap"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(_.Download,{sx:{fontSize:w=>w.typography.body1.fontSize,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",tt.size,")"]})]}),t.jsx(_.ChevronRight,{sx:{fontSize:w=>w.typography.body1.fontSize,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!Mr,anchorEl:Mr,placement:"right-start",transition:!0,sx:{zIndex:w=>w.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:w})=>t.jsx(o.Grow,{...w,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:fe,onMouseLeave:xe,sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3},children:t.jsxs(o.MenuList,{dense:!0,autoFocusItem:!1,children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Qt("csv"),ct(null),Ye(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:()=>{Qt("excel"),ct(null),Ye(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:()=>{Qt("json"),ct(null),Ye(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"})]}),hr.export.allowedFormats.includes("pdf")&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Qt("pdf"),ct(null),Ye(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.PictureAsPdf,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",children:"PDF"})]})]})})})})]}),!(Ke!=null&&Ke.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{je&&(Yr(je.row),_r(!0)),Ye(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(Ou,{open:U,onClose:()=>{Oe(!1),mt(null)},row:ft,schema:e,reportName:ht}),t.jsx(Au,{open:go,onClose:()=>{Vt(!1),qr(null),Or(null)},onSave:w=>{Wt!==null&&(rt==null||rt(Wt,w))},row:yo,schema:e,reportName:ht}),t.jsx(Mu,{open:Me,onClose:()=>{_r(!1),Yr(null)},onConfirm:()=>{$r!==null&&(cr==null||cr($r))},row:$r,schema:e}),t.jsx(ia,{isOpen:Jr,onClose:()=>tr(!1),content:Br})]})}function yt({content:e,isDev:r=!1}){const[n,i]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(o.IconButton,{size:"small",onClick:s=>i(s.currentTarget),"aria-label":`Help: ${e.title}`,sx:{p:.375,color:"text.disabled","&:hover":{color:"primary.main",bgcolor:s=>$(s.palette.primary.main,.08)}},children:t.jsx(_.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 Lr={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it","24-hour format · Tab must be open for the schedule to fire","Opens your device's email app when the schedule fires. If you added email.","The data columns visible on the selected view will be send as a report"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}},ni=40;function Ju({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 Ku({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const a=r.find(u=>u.name===e.column),l=p.useMemo(()=>{const u=a?un(a.type):[],g=i.filter.allowedOperators;return g.length>0?u.filter(b=>g.includes(b.value)):u},[a,i]),d=Wl(e.operator);return t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},children:[t.jsx(o.FormControl,{size:"small",sx:{minWidth:150,flex:"1 1 150px"},children:t.jsx(o.Select,{value:e.column,onChange:u=>{var x;const g=r.find(S=>S.name===u.target.value),b=g?un(g.type):[];s({column:u.target.value,operator:((x=b[0])==null?void 0:x.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:n.map(u=>t.jsx(o.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:ut(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:l.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),d&&(a==null?void 0:a.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:u=>s({value:u.target.value}),sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}}),d&&(a==null?void 0:a.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(a==null?void 0:a.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(a==null?void 0:a.type)==="number"?Number(u.target.value):u.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function ua({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:l,onChange:d}){const u=l>=a;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((g,b)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:ni,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[b<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),b>0&&t.jsx(Ju,{operator:e.operator,onSelect:x=>d(S=>xi(S,e.id,x))}),b>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:ni/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:b>0?1:0},children:Qe(g)?t.jsx(Xu,{group:g,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:l,onChange:d}):t.jsx(Ku,{condition:g,schema:n,availableColumns:i,devConfig:s,onUpdate:x=>d(S=>mi(S,g.id,x))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>d(x=>gi(x,g.id)),sx:{mt:b>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx(_.Close,{sx:{fontSize:16}})})]},g.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${ni}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>d(g=>{var b,x,S;return ho(g,e.id,{id:po(),column:((b=i[0])==null?void 0:b.name)??"",operator:((S=un(((x=i[0])==null?void 0:x.type)??"string")[0])==null?void 0:S.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(o.Button,{size:"small",disabled:u,onClick:()=>d(g=>ho(g,e.id,Pt())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Xu(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(ua,{...e})})}function Qu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[l,d]=p.useState(r??Pt()),u=Nr(),g=p.useMemo(()=>e.filter(j=>j.type!=="mixed"&&j.type!=="null"&&j.type!=="array"&&j.type!=="object"),[e]);p.useEffect(()=>{var h;const j=r??Pt();if(s&&j.children.length===0){const k=e.find(T=>T.name===s);if(k){d(ho(j,j.id,{id:po(),column:s,operator:((h=un(k.type)[0])==null?void 0:h.value)??"equals"}));return}}d(j)},[r,s,e]);const b=Et(l),x=u.filter.maxConditions,S=p.useCallback(j=>{d(h=>j(h))},[]),y=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r??Pt()),[l,r]),I=p.useCallback(()=>{n(l),i()},[l,n,i]),C=p.useCallback(()=>{d(r??Pt()),i()},[r,i]),m=p.useCallback(()=>{n(Pt()),i()},[n,i]);return t.jsx(o.Box,{onClick:C,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:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:j=>it(j),bgcolor:"background.paper",outline:"none",boxShadow:j=>he(j).paper.boxShadow,border:j=>he(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=>he(j).header.backgroundColor,borderBottom:j=>he(j).header.borderBottom,boxShadow:j=>he(j).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:j=>j.typography.h4.fontSize||"1.125rem",fontWeight:j=>j.typography.h4.fontWeight||500,color:j=>j.typography.h4.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(yt,{content:Lr.filter,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[a&&t.jsx(o.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.Settings,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{onClick:C,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:[b===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:j=>j.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${ut(s)}"`:"","."]}),t.jsx(ua,{group:l,depth:0,schema:e,availableColumns:g,devConfig:u,maxConditions:x,totalConditions:b,onChange:S}),b>=x&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:j=>j.typography.caption.fontSize||"0.75rem",fontWeight:j=>j.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",x," 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.Tooltip,{title:"Removes all applied filters and closes this panel",arrow:!0,children:t.jsx("span",{children:t.jsx(o.Button,{onClick:m,disabled:b===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:C,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:I,disabled:!y,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:j=>`${j.shape.borderRadius}px`,boxShadow:j=>be(j,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const ks="SORT_RULE";function Zu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=p.useRef(null),[{handlerId:l},d]=sr.useDrop({accept:ks,collect(b){return{handlerId:b.getHandlerId()}},hover(b,x){var h;if(!a.current)return;const S=b.index,y=r;if(S===y)return;const I=(h=a.current)==null?void 0:h.getBoundingClientRect(),C=(I.bottom-I.top)/2,m=x.getClientOffset(),j=((m==null?void 0:m.y)??0)-I.top;S<y&&j<C||S>y&&j>C||(s(S,y),b.index=y)}}),[{isDragging:u},g]=sr.useDrag({type:ks,item:()=>({index:r}),collect:b=>({isDragging:b.isDragging()})});return g(d(a)),t.jsxs(o.Box,{ref:a,"data-handler-id":l,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:b=>be(b,"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:b=>`0 1px 2px 0 ${$(b.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:b=>b.typography.body2.fontSize||"0.875rem",fontWeight:b=>b.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:b=>n(r,b.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:b=>Dt(b),"&:hover":{bgcolor:b=>$(b.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:b=>Dt(b),"&:hover":{bgcolor:b=>$(b.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:b=>$(b.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx(_.Close,{sx:{fontSize:18}})})]})}function ep({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i,onOpenDevConfig:s}){const[a,l]=p.useState(""),[d,u]=p.useState([]);p.useEffect(()=>{u([...r])},[r]);const g=p.useMemo(()=>JSON.stringify(d)!==JSON.stringify(r),[d,r]),b=Nr(),x=p.useCallback(k=>{if(!k||d.length>=b.sort.maxLevels)return;const T={column:k,direction:"asc",priority:d.length+1};u([...d,T]),l(""),setTimeout(()=>{var f;return(f=document.activeElement)==null?void 0:f.blur()},0)},[d,b.sort.maxLevels]),S=p.useCallback(k=>{const f=d.filter((W,N)=>N!==k).map((W,N)=>({...W,priority:N+1}));u(f)},[d]),y=p.useCallback((k,T)=>{const f=[...d];f[k]={...f[k],direction:T},u(f)},[d]),I=p.useCallback((k,T)=>{const f=[...d],[W]=f.splice(k,1);f.splice(T,0,W);const N=f.map((E,X)=>({...E,priority:X+1}));u(N)},[d]),C=p.useCallback(()=>{n([]),i()},[n,i]),m=p.useCallback(()=>{n(d),i()},[d,n,i]),j=p.useCallback(()=>{u([...r]),l(""),i()},[r,i]),h=e.filter(k=>!d.some(T=>T.column===k.name));return t.jsx(sr.DndProvider,{backend:pi.HTML5Backend,children:t.jsx(o.Box,{onClick:j,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:k=>$(k.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:k=>k.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:k=>k.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:k=>it(k),bgcolor:"background.paper",outline:"none",boxShadow:k=>he(k).paper.boxShadow,border:k=>he(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=>he(k).header.backgroundColor,borderBottom:k=>he(k).header.borderBottom,boxShadow:k=>he(k).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:k=>k.typography.h4.fontSize||"1.125rem",fontWeight:k=>k.typography.h4.fontWeight||500,color:k=>k.typography.h4.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(yt,{content:Lr.sort,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.Settings,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{onClick:j,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:k=>$(k.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:k=>$(k.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:k=>k.typography.caption.fontSize||"0.6875rem",fontWeight:k=>k.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:d.length>=b.sort.maxLevels,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(o.Select,{value:a,onChange:k=>x(k.target.value),label:"Select column...",sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:h.map(k=>t.jsx(o.MenuItem,{value:k.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:T=>Dt(T),"&:hover":{bgcolor:T=>$(T.palette.primary.main,.2)}}},children:ut(k.name)},k.name))})]}),d.length>=b.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:k=>k.typography.caption.fontSize||"0.75rem",fontWeight:k=>k.typography.caption.fontWeight||500},children:["Maximum ",b.sort.maxLevels," sort levels allowed"]})]}),d.length>0&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Typography,{variant:"overline",sx:{fontSize:k=>k.typography.caption.fontSize||"0.6875rem",fontWeight:k=>k.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",d.length,"/",b.sort.maxLevels,")"]}),t.jsx(o.Tooltip,{title:"Removes all applied sorting and closes this panel",arrow:!0,children:t.jsx(o.Button,{onClick:C,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:d.map((k,T)=>t.jsx(Zu,{rule:k,index:T,onToggleDirection:y,onRemove:S,onMove:I},`${k.column}-${T}`))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:j,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",disabled:!g||d.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,boxShadow:k=>be(k,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:k=>be(k,"hoverButton")},"&:active":{boxShadow:k=>be(k,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const rn=50;function zs({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:l=!1,atViewLimit:d=!1,maxViews:u=10}){const[g,b]=p.useState(s),[x,S]=p.useState(!1),[y,I]=p.useState(a),[C,m]=p.useState(l),j=()=>{if(!g.trim()){S(!0);return}if(g.trim().length>rn){S(!0);return}r(g.trim(),y.trim(),C),n()},h=T=>{T.key==="Enter"&&!T.shiftKey?j():T.key==="Escape"&&n()},k=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:T=>({mt:8,borderRadius:it(T),...he(T).paper})},children:[t.jsxs(o.DialogTitle,{sx:T=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,fontSize:T.typography.h4.fontSize||"1.125rem",fontWeight:T.typography.h4.fontWeight||500,...he(T).header}),children:[k(),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:[d&&!i&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px"},children:["You have reached the maximum of ",u," saved views. Delete an existing view before creating a new one."]}),t.jsx(o.TextField,{label:"View Name",required:!0,value:g,onChange:T=>{T.target.value.length<=rn&&b(T.target.value),x&&T.target.value.trim()&&S(!1)},onKeyDown:h,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:d&&!i,inputProps:{maxLength:rn},error:x&&!g.trim(),helperText:x&&!g.trim()?"View name is required":`${g.length} / ${rn}`}),t.jsx(o.TextField,{label:"Description (optional)",value:y,onChange:T=>I(T.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),t.jsxs(o.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:T=>T.typography.body2.fontWeight||500,mb:1},children:"This view will capture:"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[t.jsxs("li",{children:[Et(e.filters)," filter",Et(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",tl(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:C,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:j,variant:"contained",disabled:d&&!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=>be(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>be(T,"hoverButton")},"&:active":{boxShadow:T=>be(T,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function tp({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:it(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",...he(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,fontSize:i.typography.h4.fontSize||"1.125rem",fontWeight:i.typography.h4.fontWeight||500,...he(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=>be(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>be(i,"hoverButton")},"&:active":{boxShadow:i=>be(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const Bs="COLUMN";function rp({column:e,index:r,isVisible:n,width:i,minColumnWidth:s,maxColumnWidth:a,canToggleOn:l,onToggleVisibility:d,onWidthChange:u,moveColumn:g}){const b=p.useRef(null),[x,S]=p.useState(i.toString());p.useEffect(()=>{S(i.toString())},[i]);const[{handlerId:y},I]=sr.useDrop({accept:Bs,collect(f){return{handlerId:f.getHandlerId()}},hover(f,W){var O;if(!b.current)return;const N=f.index,E=r;if(N===E)return;const X=(O=b.current)==null?void 0:O.getBoundingClientRect(),te=(X.bottom-X.top)/2,A=W.getClientOffset(),v=((A==null?void 0:A.y)??0)-X.top;N<E&&v<te||N>E&&v>te||(g(N,E),f.index=E)}}),[{isDragging:C},m]=sr.useDrag({type:Bs,item:()=>({index:r}),collect:f=>({isDragging:f.isDragging()})});m(I(b));const j=()=>{const f=parseInt(x);if(isNaN(f)){S(i.toString()),u(e.name,i);return}const W=Math.max(s,Math.min(a,f));S(W.toString()),u(e.name,W)},h=f=>{if(f===""||/^\d+$/.test(f)){S(f);const W=parseInt(f);if(!isNaN(W)&&W>=s){const N=Math.min(a,W);u(e.name,N)}}},k=f=>{f.key==="Enter"&&(f.preventDefault(),j(),f.target.blur())},T=f=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[f]||"text.secondary";return t.jsxs(o.TableRow,{ref:b,"data-handler-id":y,sx:{opacity:C?.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:f=>f.typography.body2.fontWeight||400,fontSize:f=>f.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:ut(e.name)})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsx(o.Chip,{label:e.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${T(e.type)}15`,color:T(e.type),border:`1px solid ${T(e.type)}30`,"& .MuiChip-label":{px:1}}})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.TextField,{type:"number",value:x,onChange:f=>h(f.target.value),onBlur:j,onKeyDown:k,placeholder:"150",size:"small",inputProps:{min:s,max:a,step:10},sx:{width:90,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"},"& input[type=number]::-webkit-inner-spin-button":{opacity:1},"& input[type=number]::-webkit-outer-spin-button":{opacity:1}}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:f=>f.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:()=>d(e.name,!n),disabled:!n&&!l,title:n?"Hide column":l?"Show column":"Max visible columns reached",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover:not(:disabled)":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"},"&:disabled":{opacity:.5,cursor:"not-allowed"}},children:n?t.jsx(_.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?f=>$(f.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function op({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:l,onUpdateColumnOrder:d,onUpdateColumnWidth:u,onResetLayout:g,onClose:b}){const x=Nr(),[S,y]=p.useState(!1),[I,C]=p.useState(n),[m,j]=p.useState(i),[h,k]=p.useState("all");p.useEffect(()=>{C(n)},[n]),p.useEffect(()=>{j(i)},[i]);const T=(O,B)=>{j(q=>({...q,[O]:B})),u==null||u(O,B)},f=(O,B)=>{const q=[...I],[Y]=q.splice(O,1);q.splice(B,0,Y),C(q),d(q)},W=()=>{g(),y(!1)},E=I.map(O=>e.find(B=>B.name===O)).filter(O=>O!==void 0).filter(O=>{const B=r[O.name]??!0;return h==="active"?B:h==="hidden"?!B:!0}),X=Object.values(r).filter(O=>O).length,te=e.length,A=s.find(O=>O.id===a),v=p.useMemo(()=>{if(!A)return!1;const O=A.snapshot,B=O.columnVisibility??{},q=JSON.stringify(r)!==JSON.stringify(B),Y=O.columnOrder??[],c=n??[],re=JSON.stringify(c)!==JSON.stringify(Y)&&!(c.length===0&&Y.length===0),se=O.columnWidths??{},V=JSON.stringify(m)!==JSON.stringify(se);return q||re||V},[A,r,n,m]);return t.jsx(sr.DndProvider,{backend:pi.HTML5Backend,children:t.jsx(o.Box,{onClick:b,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:O=>$(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:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:O=>it(O),bgcolor:"background.paper",outline:"none",boxShadow:O=>he(O).paper.boxShadow,border:O=>he(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:{px:3,pt:2,pb:1.5,flexShrink:0,bgcolor:O=>he(O).header.backgroundColor,borderBottom:O=>he(O).header.borderBottom,boxShadow:O=>he(O).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:O=>O.typography.h4.fontSize||"1.125rem",fontWeight:O=>O.typography.h4.fontWeight||500,color:O=>O.typography.h4.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage columns"}),t.jsx(yt,{content:Lr.columns,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:b,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:h,onChange:(O,B)=>k(B),sx:{minHeight:36,mt:1.5,"& .MuiTabs-indicator":{bgcolor:O=>nt(O).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:O=>nt(O).hoverBg},"&:hover":{color:"text.primary",bgcolor:O=>nt(O).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:O=>nt(O).hoverBg},"&:hover":{color:"text.primary",bgcolor:O=>nt(O).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:O=>nt(O).hoverBg},"&:hover":{color:"text.primary",bgcolor:O=>nt(O).bg}}})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:O=>$(O.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:O=>$(O.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{stickyHeader:!0,sx:{minWidth:650},children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Column name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:"Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:"1px solid divider"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",t.jsx(o.Tooltip,{title:`Column width in pixels (min: ${x.columns.minColumnWidth}px, max: ${x.columns.maxColumnWidth}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:E.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:O=>O.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):E.map((O,B)=>{const q=r[O.name]??!0,Y=q||X<x.columns.maxVisible;return t.jsx(rp,{column:O,index:B,isVisible:q,width:m[O.name]||170,minColumnWidth:x.columns.minColumnWidth,maxColumnWidth:x.columns.maxColumnWidth,canToggleOn:Y,onToggleVisibility:l,onWidthChange:T,moveColumn:f},O.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:O=>O.typography.body2.fontSize||"0.8125rem",color:"text.secondary"},children:[X," of ",te," 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:()=>y(!0),disabled:!v,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:O=>`${O.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),S&&t.jsx(o.Box,{onClick:()=>y(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:O=>$(O.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:O=>O.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:O=>O.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:O=>No(O),bgcolor:"background.paper",boxShadow:O=>he(O).paper.boxShadow,border:O=>he(O).paper.border},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:O=>O.typography.h4.fontSize||"1rem",fontWeight:O=>O.typography.h4.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:()=>y(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:O=>`${O.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:O=>`${O.shape.borderRadius}px`,boxShadow:O=>be(O,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:O=>be(O,"hoverButton")},"&:active":{boxShadow:O=>be(O,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function np({schema:e,grouping:r,onApply:n,onClose:i,onOpenDevConfig:s}){var N;const[a,l]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[d,u]=p.useState(""),[g,b]=p.useState(null),x=p.useMemo(()=>qa(e),[e]),S=p.useMemo(()=>x.filter(E=>!a.levels.some((X,te)=>X.column===E.name&&te!==g)),[x,a.levels,g]),y=Nr(),I=a.levels.length<y.grouping.maxLevels&&S.length>0&&(y.grouping.allowNested||a.levels.length===0),C=p.useCallback(E=>{!I||!E||(l({...a,levels:[...a.levels,{column:E}],enabled:!0}),u(""),setTimeout(()=>{var X;return(X=document.activeElement)==null?void 0:X.blur()},0))},[I,a]),m=p.useCallback(E=>{const X=a.levels.filter((te,A)=>A!==E);if(X.length===0){n(null),i();return}l({...a,levels:X,enabled:X.length>0})},[a,n,i]),j=p.useCallback(E=>{b(E),u(a.levels[E].column)},[a.levels]),h=p.useCallback(()=>{if(g===null||!d)return;const E=[...a.levels];E[g]={column:d},l({...a,levels:E}),b(null),u("")},[g,d,a]),k=p.useCallback(()=>{b(null),u("")},[]),T=p.useCallback((E,X)=>{const te=X==="up"?E-1:E+1;if(te<0||te>=a.levels.length)return;const A=[...a.levels],[v]=A.splice(E,1);A.splice(te,0,v),l({...a,levels:A})},[a]),f=p.useCallback(()=>{n(null),i()},[n,i]),W=p.useCallback(()=>{a.levels.length===0?n(null):n({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:E=>$(E.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:E=>E.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:E=>E.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:E=>it(E),bgcolor:"background.paper",outline:"none",boxShadow:E=>he(E).paper.boxShadow,border:E=>he(E).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:E=>he(E).header.backgroundColor,borderBottom:E=>he(E).header.borderBottom,boxShadow:E=>he(E).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:E=>E.typography.h4.fontSize||"1.125rem",fontWeight:E=>E.typography.h4.fontWeight||500,color:E=>E.typography.h4.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(yt,{content:Lr.grouping,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.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:E=>$(E.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:E=>$(E.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[g===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:E=>E.typography.caption.fontSize||"0.6875rem",fontWeight:E=>E.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:d,onChange:E=>C(E.target.value),disabled:!I,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),S.map(E=>t.jsxs(o.MenuItem,{value:E.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:X=>Dt(X),"&:hover":{bgcolor:X=>$(X.palette.primary.main,.2)}}},children:[ut(E.name)," (",E.type.toUpperCase(),")"]},E.name))]})}),a.levels.length>=y.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:E=>E.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),x.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:E=>E.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),g!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:E=>`1px solid ${$(E.palette.warning.main,.5)}`,bgcolor:E=>$(E.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:E=>E.typography.body2.fontWeight||500,mb:1.5,fontSize:E=>E.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",g+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:d,onChange:E=>u(E.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:a.levels[g].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:E=>Dt(E)}},children:[a.levels[g].column," (",(N=e.find(E=>E.name===a.levels[g].column))==null?void 0:N.type.toUpperCase(),")"]}),S.filter(E=>E.name!==a.levels[g].column).map(E=>t.jsxs(o.MenuItem,{value:E.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:X=>Dt(X)}},children:[ut(E.name)," (",E.type.toUpperCase(),")"]},E.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:h,disabled:!d,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:E=>be(E,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:k,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),a.levels.length>0&&g===null&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:E=>E.typography.caption.fontSize||"0.6875rem",fontWeight:E=>E.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Tooltip,{title:"Removes all applied grouping and closes this panel",arrow:!0,children:t.jsx(o.Button,{onClick:f,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})})]}),t.jsx(o.Stack,{spacing:1.5,children:a.levels.map((E,X)=>{const te=e.find(A=>A.name===E.column);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:A=>be(A,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${X+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:A=>`0 1px 2px 0 ${$(A.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:A=>A.typography.body2.fontWeight||500,fontSize:A=>A.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:E.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:A=>A.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:te==null?void 0:te.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>T(X,"up"),disabled:X===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:()=>T(X,"down"),disabled:X===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:()=>j(X),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:()=>m(X),sx:{color:"text.secondary","&:hover":{bgcolor:A=>$(A.palette.error.main,.08),color:"error.main"}},children:t.jsx(_.Delete,{sx:{fontSize:18}})})]})]},X)})})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:W,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,boxShadow:E=>be(E,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:E=>be(E,"hoverButton")},"&:active":{boxShadow:E=>be(E,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function ip({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:i=>i.typography.body1.fontSize}}),size:"small",children:"Export Anyway"})]})]})})}const Ts=[{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 sp(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 ap(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function lp({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=bt(),s=i.palette,[a,l]=p.useState("1h"),[d,u]=p.useState(!1),[g,b]=p.useState("all"),[x,S]=p.useState(!0),[y,I]=p.useState(!1),[C,m]=p.useState(!1),j=[...e].sort((A,v)=>{const O=new Date(A.timestamp).getTime()-new Date(v.timestamp).getTime();return y?O:-O}),h=j.reduce((A,v)=>(A[v.feature]=(A[v.feature]??0)+1,A),{}),k=Object.keys(h).sort((A,v)=>(h[v]??0)-(h[A]??0)),T=g==="all"?j:j.filter(A=>A.feature===g),f=Ts.find(A=>A.key===a),W=sp(e,f.ms),N=()=>u(!0),E=()=>{n&&(n(ap(e,f.ms)),u(!1))},X=A=>{const v=ws(i,A.feature),{summary:O,detail:B}=ml(A);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:Jn(A.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:$(v,.1),color:v,border:`1px solid ${$(v,.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:O}),B&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:B}),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:yl(A.timestamp)})]}),A.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:A.user})]})]})]})]},A.id)},te=C?k.map(A=>({feature:A,events:T.filter(v=>v.feature===A)})).filter(A=>A.events.length>0):[];return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:$(s.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:A=>A.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:it(i),bgcolor:"background.paper",overflow:"hidden",...he(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,...he(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:A=>A.typography.body1.fontSize||"0.9375rem",fontWeight:A=>A.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx(yt,{content:Lr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:A=>A.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[T.length," event",T.length!==1?"s":""," recorded"]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[n&&e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Select,{value:a,onChange:A=>l(A.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:Ts.map(A=>t.jsx(o.MenuItem,{value:A.key,sx:{fontSize:"0.8125rem"},children:A.label},A.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(_.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:N,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:$(s.error.main,.5),"&:hover":{bgcolor:$(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),k.length>1&&t.jsx(o.IconButton,{onClick:()=>S(A=>!A),size:"small",title:x?"Hide category filter":"Show category filter",sx:{color:x?"primary.main":"text.secondary",bgcolor:x?$(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:x?$(s.primary.main,.16):"action.hover"}},children:t.jsx(_.FilterAltOutlined,{sx:{fontSize:17}})}),t.jsx(o.IconButton,{onClick:()=>I(A=>!A),size:"small",title:y?"Sorted oldest first":"Sorted newest first",sx:{color:y?"primary.main":"text.secondary",bgcolor:y?$(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:y?$(s.primary.main,.16):"action.hover"}},children:t.jsx(_.SortOutlined,{sx:{fontSize:17,transform:y?"scaleY(-1)":"none"}})}),t.jsx(o.IconButton,{onClick:()=>m(A=>!A),size:"small",title:C?"Ungroup events":"Group by category",sx:{color:C?"primary.main":"text.secondary",bgcolor:C?$(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:C?$(s.primary.main,.16):"action.hover"}},children:t.jsx(_.WorkspacesOutlined,{sx:{fontSize:17}})}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.Close,{sx:{fontSize:17}})})]})]}),k.length>1&&x&&t.jsxs(o.Tabs,{value:g,onChange:(A,v)=>b(v),variant:"scrollable",scrollButtons:"auto",sx:{minHeight:36,flexShrink:0,borderBottom:"1px solid",borderColor:"divider",px:1.5,"& .MuiTabs-indicator":{height:2}},children:[t.jsx(o.Tab,{value:"all",label:`All (${j.length})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}}),k.map(A=>t.jsx(o.Tab,{value:A,label:`${Jn(A)} (${h[A]})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}},A))]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:$(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:$(s.text.primary,.14),borderRadius:3}},children:T.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx(_.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:A=>A.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:A=>A.typography.body2.fontWeight||500},children:j.length===0?"No audit events yet":"No events in this category"}),t.jsx(o.Typography,{sx:{fontSize:A=>A.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:j.length===0?"Changes to this report will appear here":"Try a different category tab"})]}):C?t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:te.map(({feature:A,events:v})=>t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75,px:.25},children:[t.jsx(o.Box,{sx:{width:6,height:6,borderRadius:"50%",bgcolor:ws(i,A)}}),t.jsxs(o.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"text.secondary"},children:[Jn(A)," (",v.length,")"]})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:v.map(X)})]},A))}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:T.map(X)})})]})}),t.jsxs(o.Dialog,{open:d,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:No(i),...he(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:A=>A.typography.body1.fontSize||"0.9375rem",fontWeight:A=>A.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:A=>A.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:[W," audit record",W!==1?"s":""]})," ",f.key==="all"?"from all time":`from the ${f.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:E,variant:"contained",color:"error",startIcon:t.jsx(_.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",W," Record",W!==1?"s":""]})]})]})]})}function cp({onSave:e,onClose:r}){const[n,i]=p.useState(""),[s,a]=p.useState(""),[l,d]=p.useState(""),[u,g]=p.useState([]),[b,x]=p.useState(""),[S,y]=p.useState(""),I=f=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f),C=()=>{const f=l.trim();if(f){if(!I(f)){y("Please enter a valid email address");return}if(u.includes(f)){y("This email is already added");return}g([...u,f]),d(""),y("")}},m=f=>{g(u.filter(W=>W!==f))},j=f=>{f.key==="Enter"&&(f.preventDefault(),C())},h=()=>{if(!n.trim()){x("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},k=f=>{i(f),b&&x("")},T=f=>{d(f),S&&y("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:f=>$(f.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:f=>f.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:f=>f.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:f=>it(f),bgcolor:"background.paper",outline:"none",boxShadow:f=>he(f).paper.boxShadow,border:f=>he(f).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:f=>he(f).header.backgroundColor,borderBottom:f=>he(f).header.borderBottom,boxShadow:f=>he(f).header.boxShadow,flexShrink:0},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:f=>f.typography.h4.fontSize||"1.125rem",fontWeight:f=>f.typography.h4.fontWeight||500,color:f=>f.typography.h4.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:f=>$(f.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:f=>$(f.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:f=>`1px solid ${$(f.palette.primary.main,.3)}`,bgcolor:f=>Dt(f),"& .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:f=>f.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:f=>f.typography.caption.fontSize||"0.6875rem",fontWeight:f=>f.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:f=>k(f.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!b,helperText:b,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:f=>f.typography.caption.fontSize||"0.6875rem",fontWeight:f=>f.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:f=>a(f.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:f=>f.typography.caption.fontSize||"0.6875rem",fontWeight:f=>f.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:l,onChange:f=>T(f.target.value),onKeyPress:j,placeholder:"Enter email address",error:!!S,helperText:S,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:C,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:f=>`${f.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(f=>t.jsx(o.Chip,{label:f,onDelete:()=>m(f),deleteIcon:t.jsx(_.Delete,{sx:{fontSize:16}}),sx:{bgcolor:W=>Dt(W),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},f))}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:u.length>0?`An email with the shareable link will be sent to ${u.length} recipient${u.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:f=>`${f.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:f=>`${f.shape.borderRadius}px`,boxShadow:f=>be(f,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:f=>be(f,"hoverButton")},"&:active":{boxShadow:f=>be(f,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function dp({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 up({presets:e,reportId:r,onOpenPreset:n,onDeletePreset:i,onClose:s}){const a=l=>new Date(l).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:l=>$(l.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:l=>l.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:l=>l.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:l=>it(l),bgcolor:"background.paper",outline:"none",boxShadow:l=>he(l).paper.boxShadow,border:l=>he(l).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:l=>he(l).header.backgroundColor,borderBottom:l=>he(l).header.borderBottom,boxShadow:l=>he(l).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:l=>l.typography.h4.fontSize||"1.125rem",fontWeight:l=>l.typography.h4.fontWeight||500,color:l=>l.typography.h4.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:l=>l.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:l=>$(l.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:l=>l.typography.body2.fontSize||"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.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(l=>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:d=>be(d,"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:d=>d.typography.body1.fontSize||"0.9375rem",fontWeight:d=>d.typography.h6.fontWeight||500,color:"text.primary",mb:.5},children:l.name}),l.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:d=>d.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.5},children:l.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${a(l.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 ${l.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(l.id,l.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:d=>`${d.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:d=>$(d.palette.error.main,.04)}},children:"Delete"})})]},l.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:l=>`${l.shape.borderRadius}px`,boxShadow:l=>be(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:l=>be(l,"hoverButton")},"&:active":{boxShadow:l=>be(l,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const pa={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},pp=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],hp=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function fp(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=hp.some(d=>d.test(i.name));let a=!1;const l=r.slice(0,10).map(d=>d[i.name]).filter(d=>typeof d=="string"&&d.length>0);l.length>0&&(a=l.filter(u=>pp.some(g=>g.test(u))).length/l.length>.6),(s||a)&&n.push(i.name)}return n}function _n(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(l=>{const d=n.map(g=>String(g[l]??"")).filter(g=>g.length>0);if(d.length===0)return 5;const u=d.reduce((g,b)=>g+b.length,0);return Math.ceil(u/d.length)+1}).reduce((l,d)=>l+d,0)+1;return r.reduce((l,d)=>l+d.length+1,0)+s*e.length}function mp(e,r){const n=_n(e,r);return Math.ceil(n*3.5)}function xp(e,r){const n=_n(e,r);return Math.ceil(n*.7)}function gp(e,r){const n=_n(e,r);return Math.ceil(n*2)}function yp(e,r,n){switch(e){case"csv":return _n(r,n);case"excel":return xp(r,n);case"json":return mp(r,n);case"pdf":return gp(r,n)}}function Is(e,r){return Math.ceil(e/r)}function bp(e,r,n,i,s=pa){const a=[],l=yp(e,r,n),d=r.length;if(d>s.maxRowsHard){const b=Is(d,s.maxRows);a.push({type:"row_count",severity:"error",message:`Export blocked: ${d.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${b} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:b,value:d,limit:s.maxRowsHard})}else if(d>s.maxRows){const b=Is(d,s.maxRows);a.push({type:"row_count",severity:"warning",message:`Large export: ${d.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${b} smaller export${b>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:b,value:d,limit:s.maxRows})}if(l>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${Do(l)} exceeds the ${Do(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:l,limit:s.maxFileSizeHardBytes}):l>s.maxFileSizeBytes&&a.push({type:"file_size",severity:"warning",message:`Large file: estimated ${Do(l)}`,detail:`This exceeds the recommended ${Do(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:l,limit:s.maxFileSizeBytes}),e!=="excel"){const b=fp(i.filter(x=>n.includes(x.name)),r);if(b.length>0){const x=b.length>s.maxImageColumns;a.push({type:"image_columns",severity:x?"error":"warning",message:`Image column${b.length>1?"s":""} detected: ${b.map(S=>`"${S.replace(/_/g," ")}"`).join(", ")}`,detail:x?`Exporting ${b.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:b.length,limit:s.maxImageColumns})}}const u=a.some(b=>b.severity==="error"),g=a.some(b=>b.severity==="warning");return{violations:a,hasBlockingViolation:u,hasWarning:g,estimatedBytes:l}}function Do(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function vp({violation:e}){const n=bt().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=$(i?n.error.main:n.warning.main,.06),l=i?$(n.error.main,.25):$(n.warning.main,.3),d=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:l},children:[t.jsx(d,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.body2.fontSize||"0.8125rem",fontWeight:u=>u.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:e.detail}),e.suggestedBatches&&e.suggestedBatches>1&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[t.jsx(_.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:u=>u.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function Sp({format:e}){const r=bt(),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 Es({checked:e}){const r=bt();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 wp({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:l=[],allRows:d=[],processedRows:u=[],initialFormat:g,initialScope:b="visible",initialColumnScope:x="visible",classTokens:S={},onExport:y,onClose:I}){const C=bt(),m=C.palette,j=Nr(),h=p.useMemo(()=>{var ue,le,Q,pe,ie;const c=((Q=(le=(ue=C.components)==null?void 0:ue.MuiCard)==null?void 0:le.styleOverrides)==null?void 0:Q.root)||{},re=c.border&&c.border!=="none"?c.border:(pe=C.tokens)!=null&&pe.cardBodyBorder&&C.tokens.cardBodyBorder!=="none"?C.tokens.cardBodyBorder:m.divider,se=c.borderRadius!==void 0?typeof c.borderRadius=="number"?`${c.borderRadius}px`:c.borderRadius:`${C.shape.borderRadius}px`,V=c.boxShadow&&c.boxShadow!=="none"?c.boxShadow:((ie=C.tokens)==null?void 0:ie.cardBodyShadow)||be(C,"menu"),Z=nt(C);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:se,cardShadow:V,cardHoverBg:`var(--urm-export-card-hover-bg, ${m.mode==="dark"?$(m.common.white,.08):$(m.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${$(Z.main,m.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${Z.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, ${C.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${C.spacing(1.5)})`}},[m,C]),k=g||(j.export.allowedFormats.includes("pdf")?"pdf":j.export.allowedFormats[0]||"csv"),[T,f]=p.useState(k),[W,N]=p.useState(b),[E,X]=p.useState(x),te=W==="visible"?r:e,A=E==="visible"?i:s,v=p.useMemo(()=>W==="visible"?u.length>0?u:new Array(r):d.length>0?d:new Array(e),[W,r,e,u,d]),O=p.useMemo(()=>E==="all"?a.map(c=>c.name):a.map(c=>c.name).slice(0,i),[E,a,i]),B=p.useMemo(()=>bp(T,v,O,a,pa),[T,v,O,a]),q=()=>{B.hasBlockingViolation||(y({format:T,scope:W,columnScope:E}),I())},Y={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:I,className:`urm-export-backdrop ${S.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:$(m.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:C.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:c=>c.stopPropagation(),elevation:0,className:`urm-export-paper ${S.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:it(C),bgcolor:h.sectionTitleBg,overflow:"hidden",border:`1px solid ${h.cardBorder}`,boxShadow:h.cardShadow,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{className:`urm-export-header ${S.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0,bgcolor:c=>he(c).header.backgroundColor,borderBottom:c=>he(c).header.borderBottom,boxShadow:c=>he(c).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"h4",className:`urm-export-title ${S.modalTitle||""}`,sx:{fontSize:c=>c.typography.h4.fontSize||"1.125rem",fontWeight:c=>c.typography.h4.fontWeight||700,color:m.text.primary},children:"Export Report"}),t.jsx(yt,{content:Lr.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:I,size:"small",className:`urm-export-close ${S.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 ${S.modalContent||""}`,sx:{flex:1,overflowY:"auto",px:3,pb:2.5,pt:.5,display:"flex",flexDirection:"column",gap:h.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:$(m.text.primary,.15),borderRadius:3}},children:[B.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:B.violations.map((c,re)=>t.jsx(vp,{violation:c},re))}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:h.optionGap},children:[{id:"csv",title:"CSV",info:"Comma-separated values, compatible with Excel",allowed:j.export.allowedFormats.includes("csv")},{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:j.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:j.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:j.export.allowedFormats.includes("pdf")}].filter(c=>c.allowed).map(c=>{const re=T===c.id;return t.jsxs(o.Box,{onClick:()=>f(c.id),className:`urm-export-format-card ${re?S.formatCardSelected||"":S.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:$(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 ${$(m.primary.main,.3)}`},children:t.jsx(_.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(Sp,{format:c.id}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:re?h.cardSelectedColor:m.text.primary},children:c.title}),t.jsx(o.Tooltip,{title:c.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:se=>se.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:13}})})})]})]},c.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:h.optionGap},children:[{value:"visible",label:"Visible rows",icon:t.jsx(_.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(c=>{const re=W===c.value;return t.jsxs(o.Box,{onClick:()=>N(c.value),className:`urm-export-row-card ${re?S.rowCardSelected||"":S.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:$(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(Es,{checked:re}),t.jsx(o.Box,{sx:{color:re?h.cardSelectedColor:m.text.secondary,display:"flex"},children:c.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?h.cardSelectedColor:m.text.primary},children:c.label})]}),t.jsx(o.Tooltip,{title:c.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:se=>se.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:16}})})})]},c.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:h.optionGap},children:[{value:"visible",label:"Visible columns",icon:t.jsx(_.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(c=>{const re=E===c.value;return t.jsxs(o.Box,{onClick:()=>X(c.value),className:`urm-export-column-card ${re?S.columnCardSelected||"":S.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:h.cardRadius,border:re?`2px solid ${h.cardSelectedBorder}`:`1px solid ${h.cardBorder}`,boxShadow:re?void 0:h.cardShadow,bgcolor:re?h.cardSelectedBg:h.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?h.cardSelectedBorder:$(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(Es,{checked:re}),t.jsx(o.Box,{sx:{color:re?h.cardSelectedColor:m.text.secondary,display:"flex"},children:c.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?h.cardSelectedColor:m.text.primary},children:c.label})]}),t.jsx(o.Tooltip,{title:c.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:se=>se.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:16}})})})]},c.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${S.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${h.sectionBorder}`,borderRadius:"12px",p:h.sectionPadding,pt:2.25,bgcolor:h.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:h.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:h.sectionTitleColor,lineHeight:1,zIndex:1},children:"Export Summary"}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[{icon:t.jsx(_.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Format",value:Y[T]},{icon:t.jsx(_.FormatListNumberedOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Rows to Export",value:te.toLocaleString()},{icon:t.jsx(_.SwapVertOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Columns to Export",value:String(A)},{icon:t.jsx(_.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Estimated File Size",value:`~${Do(B.estimatedBytes)}`,highlight:B.hasBlockingViolation?"error.main":B.hasWarning?"warning.main":void 0}].map(({icon:c,label:re,value:se,highlight:V})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${S.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[c,t.jsx(o.Typography,{className:`urm-export-summary-label ${S.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:m.text.secondary,fontWeight:500},children:re})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${S.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:V??m.text.primary},children:se})]},re))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${S.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",flexWrap:"wrap",gap:1.5,flexShrink:0},children:[B.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:c=>c.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:c=>c.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:I,variant:"outlined",className:`urm-export-cancel-btn ${S.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:$(m.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:q,disabled:B.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${S.downloadButton||""}`,startIcon:t.jsx(_.Download,{sx:{fontSize:c=>c.typography.body1.fontSize}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:h.primaryBtnBg,color:h.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${$(m.primary.main,.25)}`,"&:hover":{bgcolor:h.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:$(m.primary.main,.4),color:h.primaryBtnColor}},children:["Download ",Y[T]]})]})]})})}function Cp({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 jp({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=3e4}){p.useEffect(()=>{if(n){const d=setTimeout(()=>{r()},i);return()=>clearTimeout(d)}},[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}})}}})(),l=Il(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:d=>d.typography.h6.fontWeight||600,fontSize:d=>d.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:l}),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 kp extends p.Component{constructor(n){super(n);$i(this,"handleReset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,i){Jt.error("urm:error-boundary","Caught unhandled component error",n,i),this.props.onError&&this.props.onError(n,i)}render(){var n,i;return this.state.hasError?this.props.fallback?this.props.fallback:t.jsx(o.Paper,{sx:{bgcolor:s=>$(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(_.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"h4",sx:{color:"error.main",fontWeight:s=>s.typography.h4.fontWeight||600,fontSize:s=>s.typography.h4.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 zp({feature:e}){const[r,n]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>n(!1),5e3);return()=>clearTimeout(i)},[]),t.jsx(o.Collapse,{in:r,unmountOnExit:!0,children:t.jsxs(o.Alert,{severity:"warning",sx:{m:1},icon:t.jsx(_.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 on({children:e,feature:r,onError:n}){return t.jsx(kp,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(zp,{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"}],Tp=[{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"}],Rr={sortMaxLevels:{title:"Maximum Sort Levels",description:"Limits the number of columns users can sort by simultaneously. Restricts multi-level sort depth.",tips:['"Add sort column" button is disabled at this limit',"Prevents adding more sort levels to the active sort stack","Default: 5 levels (range: 1–10)"]},filterMaxConditions:{title:"Maximum Filter Conditions",description:"Limits the total number of active filter conditions users can apply at once.",tips:['"Add condition" button is disabled at this limit',"Prevents performance degradation on large datasets","Default: 3 conditions (range: 1–20)"]},filterAllowedOperators:{title:"Allowed Filter Operators",description:"Controls which comparison operators appear in the filter UI. Unchecked operators are hidden from all dropdowns.",tips:["Simplifies the UI by hiding advanced operators your users don't need","At least one operator per data type must remain checked","Operators grouped by type: Text, Numeric, Boolean, Null checks"]},columnsMaxVisible:{title:"Maximum Visible Columns",description:"Limits the number of columns users can display at once in the data table.",tips:["Column visibility toggle is disabled when this limit is reached","Forces users to be selective about which columns to show","Default: 20 columns (range: 1–50)"]},columnsWidthRange:{title:"Column Width Constraints",description:"Sets minimum and maximum pixel widths for column resizing. Prevents columns from becoming too narrow or too wide.",tips:["Users cannot drag column borders outside this range","Min default: 60px, Max default: 800px","Ensures readable content and consistent layout"]},exportAllowedFormats:{title:"Allowed Export Formats",description:"Determines which export formats appear in the Export dialog and row-level export menus. At least one must be enabled.",tips:["Disabled formats don't appear in any export UI","PDF is now available as a print-ready export option","Unchecked formats are completely hidden from end users"]},groupingMaxLevels:{title:"Maximum Group Levels",description:"Limits how deeply users can nest grouped data. Enforced when adding new group levels.",tips:['"Add group level" button is hidden at this limit',"Range: 1 (single group only) to 3 (triple nested groups)","Prevents overly complex grouping hierarchies"]}};function Bo({children:e,active:r}){return t.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5,height:"200px",width:"100%"},children:e})}function Ip({open:e,onClose:r,config:n,onApply:i}){const[s,a]=p.useState(0),[l,d]=p.useState(n),u=()=>d(n),g=()=>d(gt),b=()=>{i(l),r()},x={sort:m=>d(j=>({...j,sort:{...j.sort,...m}})),filter:m=>d(j=>({...j,filter:{...j.filter,...m}})),columns:m=>d(j=>({...j,columns:{...j.columns,...m}})),grouping:m=>d(j=>({...j,grouping:{...j.grouping,...m}})),export:m=>d(j=>({...j,export:{...j.export,...m}}))},S=m=>{const j=l.filter.allowedOperators,h=j.includes(m)?j.filter(k=>k!==m):[...j,m];h.length!==0&&x.filter({allowedOperators:h})},y=m=>{const j=l.export.allowedFormats,h=j.includes(m)?j.filter(k=>k!==m):[...j,m];h.length!==0&&x.export({allowedFormats:h})},I=[{label:"Sort",icon:t.jsx(_.SwapVert,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Filter",icon:t.jsx(_.FilterList,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Columns",icon:t.jsx(_.ViewColumn,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Grouping",icon:t.jsx(_.Layers,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Export",icon:t.jsx(_.Download,{sx:{fontSize:m=>m.typography.body1.fontSize}})}],C=m=>JSON.stringify(l[m])===JSON.stringify(gt[m]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:m=>it(m),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:m=>m.shadows[8]}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(o.Box,{sx:{width:32,height:32,borderRadius:m=>m.shape.borderRadius,bgcolor:m=>$(m.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:m=>m.typography.h5.fontSize},children:"⚙️"}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h4",sx:{fontWeight:m=>m.typography.h4.fontWeight||600,fontSize:m=>m.typography.h4.fontSize,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,j)=>a(j),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:m=>m.typography.caption.fontSize,textTransform:"none",fontWeight:m=>m.typography.button.fontWeight,gap:.5}},children:I.map((m,j)=>t.jsx(o.Tab,{label:m.label,icon:m.icon,iconPosition:"start"},j))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0,minHeight:300},children:[t.jsx(Bo,{active:s===0,children:t.jsxs(o.Box,{children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),t.jsx(yt,{content:Rr.sortMaxLevels,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.Slider,{value:l.sort.maxLevels,onChange:(m,j)=>x.sort({maxLevels:j}),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(Bo,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),t.jsx(yt,{content:Rr.filterMaxConditions,isDev:process.env.NODE_ENV==="development"})]}),!C("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Slider,{value:l.filter.maxConditions,onChange:(m,j)=>x.filter({maxConditions:j}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed filter operators"}),t.jsx(yt,{content:Rr.filterAllowedOperators,isDev:process.env.NODE_ENV==="development"})]}),["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:j=>j.typography.overline.fontSize,display:"block",mb:.5},children:m}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:Bp.filter(j=>j.group===m).map(j=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:l.filter.allowedOperators.includes(j.value),onChange:()=>S(j.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:j.label}),sx:{mr:1.5}},j.value))})]},m))]})]}),t.jsxs(Bo,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),t.jsx(yt,{content:Rr.columnsMaxVisible,isDev:process.env.NODE_ENV==="development"})]}),!C("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Slider,{value:l.columns.maxVisible,onChange:(m,j)=>x.columns({maxVisible:j}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:2},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Column width range (px)"}),t.jsx(yt,{content:Rr.columnsWidthRange,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(o.Slider,{value:l.columns.minColumnWidth,onChange:(m,j)=>x.columns({minColumnWidth:j}),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:l.columns.maxColumnWidth,onChange:(m,j)=>x.columns({maxColumnWidth:j}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}px`})]})]})]})]}),t.jsx(Bo,{active:s===3,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),t.jsx(yt,{content:Rr.groupingMaxLevels,isDev:process.env.NODE_ENV==="development"})]}),!C("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:()=>x.grouping({maxLevels:m}),sx:{flex:1,py:2.5,borderRadius:j=>Number(j.shape.borderRadius||0)*1.25,border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:l.grouping.maxLevels===m?"primary.main":"divider",bgcolor:l.grouping.maxLevels===m?j=>$(j.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:j=>$(j.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:l.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:l.grouping.allowNested,onChange:m=>x.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:l.grouping.allowCollapse,onChange:m=>x.grouping({allowCollapse:m.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]})}),t.jsx(Bo,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),t.jsx(yt,{content:Rr.exportAllowedFormats,isDev:process.env.NODE_ENV==="development"})]}),!C("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.FormGroup,{sx:{gap:1},children:Tp.map(m=>t.jsxs(o.Box,{onClick:()=>y(m.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:j=>j.shape.borderRadius,border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:l.export.allowedFormats.includes(m.value)?"primary.main":"divider",bgcolor:l.export.allowedFormats.includes(m.value)?j=>$(j.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:l.export.allowedFormats.includes(m.value),onChange:()=>y(m.value),onClick:j=>j.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=>$(m.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx(_.RestartAlt,{sx:{fontSize:18}}),onClick:g,size:"small",sx:{fontSize:m=>m.typography.body2.fontSize,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:m=>$(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:m=>m.typography.body2.fontSize,color:"text.secondary",px:2,borderRadius:m=>Number(m.shape.borderRadius)*2.25},children:"Cancel"}),t.jsx(o.Button,{onClick:b,size:"small",variant:"contained",sx:{fontSize:m=>m.typography.body2.fontSize,px:2.5,borderRadius:m=>Number(m.shape.borderRadius)*2.25},children:"Apply"})]})]})]})}const Ep=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Dp={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 sn(e,r,n,i,s=new Date){const[a,l]=r.split(":").map(Number),d=new Date(s);if(d.setSeconds(0,0),d.setHours(a,l,0,0),e==="daily")return d<=s&&d.setDate(d.getDate()+1),d.toISOString();if(e==="weekly"){const u=n??1,g=d.getDay();let b=u-g;return b<0&&(b+=7),b===0&&d<=s&&(b=7),d.setDate(d.getDate()+b),d.toISOString()}if(e==="monthly"){const u=Math.min(i??1,28);return d.setDate(u),d<=s&&(d.setMonth(d.getMonth()+1),d.setDate(u)),d.toISOString()}return d.toISOString()}function _p(e){const r=ha(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${Ep[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${Dp[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function ha(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function $p(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 Op(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=ha(`${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 fa(e){return`urm_schedules_${e}`}function ma(e){try{const r=localStorage.getItem(fa(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 xa(e,r){try{localStorage.setItem(fa(e),JSON.stringify(r))}catch{}}const Mp=[{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"}],Ap=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ga={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",emails:[],viewId:""},yr={"& .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 Wp(e){const r=(n,i)=>n.name.localeCompare(i.name);return{globalViews:e.filter(n=>n.scope==="global"&&!n.isDeleted).sort(r),favoriteViews:e.filter(n=>n.isFavorite&&!n.isDeleted).sort(r),personalViews:e.filter(n=>n.scope!=="global"&&!n.isDeleted).sort(r)}}function Rp({initial:e=ga,isEditing:r=!1,views:n,onSave:i,onBack:s}){const[a,l]=p.useState(e),[d,u]=p.useState(!1),[g,b]=p.useState(""),[x,S]=p.useState(""),{globalViews:y,favoriteViews:I,personalViews:C}=Wp(n),m=(f,W)=>l(N=>({...N,[f]:W})),j=()=>{const f=g.trim();if(f){if(!Ap.test(f)){S("Please enter a valid email address");return}if(a.emails.includes(f)){S("This email is already added");return}m("emails",[...a.emails,f]),b(""),S("")}},h=f=>{m("emails",a.emails.filter(W=>W!==f))},k=f=>{f.key==="Enter"&&(f.preventDefault(),j())},T=a.name.trim().length>0&&/^\d{2}:\d{2}$/.test(a.time)&&(a.frequency!=="monthly"||a.dayOfMonth>=1&&a.dayOfMonth<=28);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:s,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:f=>$(f.palette.text.primary,.06)}},children:t.jsx(_.ArrowBack,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:f=>f.typography.body2.fontWeight||600,fontSize:f=>f.typography.body2.fontSize||"0.875rem"},children:r?"Edit schedule":"New schedule"})]}),t.jsx(o.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:a.name,onChange:f=>{m("name",f.target.value),d&&f.target.value.trim()&&u(!1)},onBlur:()=>u(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:d&&!a.name.trim(),helperText:d&&!a.name.trim()?"Schedule name is required":`${a.name.length}/50`,sx:yr}),t.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2},children:[t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:yr,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:a.frequency,label:"Frequency",onChange:f=>m("frequency",f.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"})]})]}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:a.time,onChange:f=>m("time",f.target.value),InputLabelProps:{shrink:!0},sx:yr})]}),a.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:yr,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:a.dayOfWeek,label:"Day of week",onChange:f=>m("dayOfWeek",Number(f.target.value)),children:Mp.map(f=>t.jsx(o.MenuItem,{value:f.value,children:f.label},f.value))})]}),a.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:a.dayOfMonth,onChange:f=>m("dayOfMonth",Number(f.target.value)),inputProps:{min:1,max:28},error:a.dayOfMonth<1||a.dayOfMonth>28,helperText:a.dayOfMonth<1||a.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:yr}),t.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2},children:[t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:yr,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:a.format,label:"Export format",onChange:f=>m("format",f.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.FormControl,{size:"small",fullWidth:!0,sx:yr,children:[t.jsx(o.InputLabel,{children:"Report view"}),t.jsx(o.Select,{value:a.viewId,label:"Report view",onChange:f=>m("viewId",f.target.value),startAdornment:t.jsx(_.Visibility,{sx:{fontSize:15,color:"text.disabled",ml:.5,mr:.5}}),MenuProps:{PaperProps:{sx:{maxHeight:280}}},renderValue:f=>{var W;return((W=n.find(N=>N.id===f))==null?void 0:W.name)||"Select view"},children:[["Global Views",y],["Favorite Views",I],["Personal Views",C]].flatMap(([f,W])=>W.length===0?[]:[t.jsx(o.ListSubheader,{sx:{fontSize:"caption.fontSize",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.05em",lineHeight:"32px"},children:f},`${f}-header`),...W.map(N=>t.jsxs(o.MenuItem,{value:N.id,sx:{fontSize:"0.8125rem",gap:1},children:[a.viewId===N.id?t.jsx(_.Check,{sx:{fontSize:16,flexShrink:0}}):t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Box,{component:"span",sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:N.name}),N.isDefault&&t.jsx(o.Box,{component:"span",sx:{fontSize:"caption.fontSize",color:"text.secondary",bgcolor:"action.selected",px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]},N.id))])})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Email recipients (optional)"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.TextField,{size:"small",fullWidth:!0,type:"email",value:g,onChange:f=>{b(f.target.value),x&&S("")},onKeyPress:k,placeholder:"user@company.com",error:!!x,helperText:x||void 0,InputProps:{startAdornment:t.jsx(_.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:yr}),t.jsx(o.Button,{onClick:j,variant:"outlined",size:"small",startIcon:t.jsx(_.Add,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",borderRadius:"8px",px:1.5,flexShrink:0,height:40},children:"Add"})]}),a.emails.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.75,mt:1},children:a.emails.map(f=>t.jsx(o.Chip,{label:f,size:"small",onDelete:()=>h(f),sx:{fontSize:"0.75rem",bgcolor:W=>$(W.palette.primary.main,.08),color:"primary.main"}},f))})]}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(o.Button,{onClick:s,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:f=>$(f.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>T&&i(a),disabled:!T,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function Pp({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:No(i),...he(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 Np({schedule:e,tick:r,onToggle:n,onRunNow:i,onEdit:s,onDelete:a}){var d;const l=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:l?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:l?u=>$(u.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:l?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:l?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:l?u=>$(u.palette.success.main,.1):u=>$(u.palette.text.primary,.06),color:l?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:_p(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:u=>$(u.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:u=>$(u.palette.text.primary,.06),color:"text.secondary"}}),e.viewName&&t.jsx(o.Chip,{icon:t.jsx(_.Visibility,{sx:{fontSize:11}}),label:e.viewName,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:160,bgcolor:u=>$(u.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}}),(d=e.emails)==null?void 0:d.map(u=>t.jsx(o.Chip,{icon:t.jsx(_.Email,{sx:{fontSize:11}}),label:u,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:g=>$(g.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}},u))]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[l&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",$p(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Op(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:u=>$(u.palette.primary.main,.08)}},children:t.jsx(_.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:l?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:l?"warning.main":"success.main","&:hover":{bgcolor:l?u=>$(u.palette.warning.main,.08):u=>$(u.palette.success.main,.08)}},children:l?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:u=>$(u.palette.primary.main,.08)}},children:t.jsx(_.Download,{sx:{fontSize:u=>u.typography.body1.fontSize}})})}),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:u=>$(u.palette.error.main,.08)}},children:t.jsx(_.Delete,{sx:{fontSize:15}})})})]})]})]})}function Lp({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s,views:a,schedulerConfig:l}){var v,O;const u=((l==null?void 0:l.mode)??"local")==="api",[g,b]=p.useState([]),x=u?(l==null?void 0:l.schedules)??[]:g,[S,y]=p.useState({type:"list"}),[I,C]=p.useState(0),[m,j]=p.useState(null);p.useEffect(()=>{e&&(u||b(ma(n)),y({type:"list"}))},[e,n,u]),p.useEffect(()=>{if(!e)return;const B=setInterval(()=>C(q=>q+1),3e4);return()=>clearInterval(B)},[e]);const h=p.useCallback(B=>{b(B),xa(n,B)},[n]),k=B=>{var c,re;const q=sn(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth),Y={id:`sched-${Date.now()}`,reportId:n,name:B.name.trim(),frequency:B.frequency,dayOfWeek:B.frequency==="weekly"?B.dayOfWeek:void 0,dayOfMonth:B.frequency==="monthly"?B.dayOfMonth:void 0,time:B.time,format:B.format,scope:B.scope,emails:B.emails.length>0?B.emails:void 0,viewId:B.viewId||void 0,viewName:B.viewId?(c=a.find(se=>se.id===B.viewId))==null?void 0:c.name:void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:q,runCount:0};u?(re=l==null?void 0:l.onScheduleCreate)==null||re.call(l,Y):h([...x,Y]),y({type:"list"})},T=B=>{var re,se;if(S.type!=="edit")return;const q=S.schedule,Y=sn(B.frequency,B.time,B.dayOfWeek,B.dayOfMonth),c={...q,name:B.name.trim(),frequency:B.frequency,dayOfWeek:B.frequency==="weekly"?B.dayOfWeek:void 0,dayOfMonth:B.frequency==="monthly"?B.dayOfMonth:void 0,time:B.time,format:B.format,scope:B.scope,emails:B.emails.length>0?B.emails:void 0,viewId:B.viewId||void 0,viewName:B.viewId?(re=a.find(V=>V.id===B.viewId))==null?void 0:re.name:void 0,nextRunAt:Y};u?(se=l==null?void 0:l.onScheduleUpdate)==null||se.call(l,c):h(x.map(V=>V.id===q.id?c:V)),y({type:"list"})},f=B=>{var se;const q=x.find(V=>V.id===B);if(!q)return;const Y=!q.isActive,c=Y?sn(q.frequency,q.time,q.dayOfWeek,q.dayOfMonth):q.nextRunAt,re={...q,isActive:Y,nextRunAt:c};u?(se=l==null?void 0:l.onScheduleToggle)==null||se.call(l,B,Y):h(x.map(V=>V.id===B?re:V))},W=B=>{if(s(B),!u){const q=new Date().toISOString();h(x.map(Y=>Y.id===B.id?{...Y,lastRunAt:q,runCount:Y.runCount+1}:Y))}},N=B=>{const q=x.find(Y=>Y.id===B)??null;j(q)},E=()=>{var B;m&&(u?(B=l==null?void 0:l.onScheduleDelete)==null||B.call(l,m.id):h(x.filter(q=>q.id!==m.id)),j(null))},X=B=>{var q,Y;return{name:B.name,frequency:B.frequency,dayOfWeek:B.dayOfWeek??1,dayOfMonth:B.dayOfMonth??1,time:B.time,format:B.format,scope:B.scope,emails:B.emails??[],viewId:B.viewId||((q=a.find(c=>c.isDefault))==null?void 0:q.id)||((Y=a[0])==null?void 0:Y.id)||""}},te=S.type!=="list",A=x.filter(B=>B.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:te,PaperProps:{sx:B=>({borderRadius:it(B),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...he(B).paper})},children:[t.jsxs(o.DialogTitle,{sx:B=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...he(B).header}),children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:"7px",bgcolor:B=>$(B.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:"h4",sx:{fontWeight:B=>B.typography.h4.fontWeight||600,fontSize:B=>B.typography.h4.fontSize||"0.875rem",lineHeight:1},children:"Scheduled Reports"}),t.jsx(yt,{content:Lr.schedule,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary","&:hover":{bgcolor:B=>$(B.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:[te&&t.jsx(Rp,{initial:S.type==="edit"?X(S.schedule):{...ga,viewId:((v=a.find(B=>B.isDefault))==null?void 0:v.id)||((O=a[0])==null?void 0:O.id)||""},isEditing:S.type==="edit",views:a,onSave:S.type==="edit"?T:k,onBack:()=>y({type:"list"})}),S.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:x.length===0?"No schedules yet":`${A} of ${x.length} active`}),t.jsx(o.Button,{startIcon:t.jsx(_.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>y({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),x.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:B=>B.typography.body2.fontWeight||500,fontSize:B=>B.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No scheduled reports yet"}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:x.map(B=>t.jsx(Np,{schedule:B,tick:I,onToggle:f,onRunNow:W,onEdit:q=>y({type:"edit",schedule:q}),onDelete:N},B.id))})]})]}),S.type==="list"&&t.jsx(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:B=>$(B.palette.text.primary,.06)}},children:"Close"})})]}),m&&t.jsx(Pp,{scheduleName:m.name,onConfirm:E,onCancel:()=>j(null)})]})}const Fp=6e4;function Vp({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,views:l,columnVisibility:d,columnOrder:u,filters:g,sortStack:b,onFired:x,schedulerConfig:S}){const y=(S==null?void 0:S.mode)??"local",I=p.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,views:l,columnVisibility:d,columnOrder:u,filters:g,sortStack:b,onFired:x,schedulerConfig:S,schedulerMode:y});p.useEffect(()=>{I.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,views:l,columnVisibility:d,columnOrder:u,filters:g,sortStack:b,onFired:x,schedulerConfig:S,schedulerMode:y}});const C=p.useCallback(m=>{var O,B,q,Y,c,re;const{reportName:j,uploadedData:h,processedData:k,schema:T,activeView:f,views:W,columnVisibility:N,columnOrder:E,filters:X,sortStack:te,schedulerConfig:A,schedulerMode:v}=I.current;try{const se=m.viewId?W.find(R=>R.id===m.viewId):void 0,V=se?se.snapshot.filters:X,Z=se?se.snapshot.sortStack:te,ue=se?se.snapshot.columnVisibility:N,le=se?se.snapshot.columnOrder:E,Q=m.scope==="all"?h:se?hi(Si(h,V,T),T,Z):k;if(v==="api"){const R=(le.length>0?le:T.map(G=>G.name)).filter(G=>ue[G]!==!1),oe={schedule:m,triggeredAt:new Date().toISOString(),rows:Q,columns:R,format:m.format,reportName:j};(O=A==null?void 0:A.onScheduleFire)==null||O.call(A,oe),(q=(B=I.current).onFired)==null||q.call(B,m);return}const pe=an(Q,T,V,Z,se||f,ue,le),ie=`${m.name}_scheduled`;switch(m.format){case"csv":ln(pe,ie,{scope:m.scope});break;case"excel":cn(pe,ie,{scope:m.scope});break;case"json":dn(pe,ie,{scope:m.scope});break;case"pdf":vi(pe,ie,{scope:m.scope});break}if(A!=null&&A.onScheduleFire){const R=(le.length>0?le:T.map(oe=>oe.name)).filter(oe=>ue[oe]!==!1);A.onScheduleFire({schedule:m,triggeredAt:new Date().toISOString(),rows:Q,columns:R,format:m.format,reportName:j})}if((Y=m.emails)!=null&&Y.length){const R=encodeURIComponent(`Scheduled Report: ${m.name}`),oe=encodeURIComponent(`Your scheduled report "${m.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:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.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:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.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:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.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:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.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:s=>`${s.shape.borderRadius}px`,boxShadow:s=>ye(s,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:s=>ye(s,"hoverButton")},"&:active":{boxShadow:s=>ye(s,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function cu({onFileUpload:e,onError:r,isUploading:n,jsonGuideContent:i,jsonGuideTitle:s}){const[a,l]=h.useState(!1),[d,u]=h.useState(""),[g,b]=h.useState(!1),f=h.useRef(null),S=async C=>{if(!C.name.endsWith(".json")){r("Only .json files are allowed");return}const B=10*1024*1024;if(C.size>B){r("File size exceeds 10MB limit");return}u(C.name);try{const p=await C.text();let A;try{A=JSON.parse(p)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(A)){r("JSON must be an array of objects");return}if(A.length===0){r("No data rows found in JSON file");return}e(A)}catch{r("Network error — please try again")}finally{u("")}},y=C=>{C.preventDefault(),l(!0)},E=C=>{C.preventDefault(),l(!1)},j=C=>{C.preventDefault(),l(!1);const B=C.dataTransfer.files[0];B&&S(B)},m=()=>{var C;(C=f.current)==null||C.click()},w=C=>{var p;const B=(p=C.target.files)==null?void 0:p[0];B&&S(B)},x=C=>{C.stopPropagation(),b(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:y,onDragLeave:E,onDrop:j,onPaste:C=>C.preventDefault(),onClick:m,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:a?"primary.main":"divider",bgcolor:a?C=>$(C.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:a?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:f,type:"file",accept:".json",onChange:w,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:C=>C.typography.body2.fontWeight||500,fontSize:C=>C.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),d&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:d})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:C=>$(C.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:x,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(ia,{isOpen:g,onClose:()=>b(!1),content:i,title:s})]})}function du({schema:e,onConfirm:r,hasConflicts:n}){return t.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[t.jsxs(o.Box,{sx:{mb:2},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontWeight:i=>i.typography.h4.fontWeight||600,fontSize:i=>i.typography.h4.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 uu({error:e,onRetry:r}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>$(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:"h4",color:"error.main",sx:{fontWeight:n=>n.typography.h4.fontWeight||600,fontSize:n=>n.typography.h4.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 sa({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 pu({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:l}){const[d,u]=h.useState(!1),[g,b]=h.useState(!1),[f,S]=h.useState(-1),y=h.useRef(null),E=h.useRef(null);h.useEffect(()=>{function I(Q){y.current&&!y.current.contains(Q.target)&&(u(!1),b(!1))}return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]);const j=h.useCallback(()=>{b(!0),S(-1),n.length>0&&u(!0)},[n.length]),m=h.useCallback(I=>{r(I),S(-1)},[r]),w=h.useCallback(I=>{var Q;r(I),i(I),u(!1),(Q=E.current)==null||Q.blur()},[r,i]),x=h.useCallback(I=>{S(-1),w(I)},[w]),C=h.useCallback(I=>{var Q;I.key==="Enter"?f>=0&&f<n.length?(I.preventDefault(),x(n[f].query)):e.trim()&&w(e.trim()):I.key==="Escape"?(u(!1),S(-1),(Q=E.current)==null||Q.blur()):I.key==="ArrowDown"?(I.preventDefault(),n.length>0&&(d||u(!0),S(ee=>ee<n.length-1?ee+1:ee))):I.key==="ArrowUp"&&(I.preventDefault(),S(ee=>ee>0?ee-1:-1))},[f,n,e,d,x,w]),B=h.useCallback(()=>{var I;r(""),(I=E.current)==null||I.focus()},[r]),p=h.useMemo(()=>n.filter(I=>I.isFavourite),[n]),A=h.useMemo(()=>n.filter(I=>!I.isFavourite),[n]),L=d&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:y,children:[t.jsx(o.TextField,{inputRef:E,size:"small",fullWidth:!0,value:e,onChange:I=>m(I.target.value),onFocus:j,onKeyDown:C,placeholder:"Search data...",disabled:l,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:I=>$(I.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:I=>$(I.palette.text.primary,.5)},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px",color:"text.primary"}},InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx(_.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:B,edge:"end",sx:{mr:-.5},children:t.jsx(_.Close,{sx:{fontSize:16}})})}):null}}),L&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[p.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:I=>I.typography.caption.fontWeight||600,fontSize:I=>I.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),p.map((I,Q)=>t.jsx(bs,{entry:I,isSelected:f===Q,onClick:()=>x(I.query),onToggleFavourite:()=>s(I.query),onDelete:()=>a(I.query)},`fav-${I.query}`))]}),A.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[p.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:I=>I.typography.caption.fontWeight||600,fontSize:I=>I.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),A.map((I,Q)=>{const ee=p.length+Q;return t.jsx(bs,{entry:I,isSelected:f===ee,onClick:()=>x(I.query),onToggleFavourite:()=>s(I.query),onDelete:()=>a(I.query)},`recent-${I.query}`)})]})]})]})}const bs=h.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:a}){const l=h.useCallback(u=>{u.stopPropagation(),s()},[s]),d=h.useCallback(u=>{u.stopPropagation(),a()},[a]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>$(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>$(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(o.IconButton,{size:"small",onClick:l,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:d,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(_.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function hu({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:l,onRestoreView:d,onPermanentDelete:u,onEditView:g,onCloneView:b,onCopyLink:f,onDeleteView:S,onPromoteToGlobal:y,onSetDefaultForAllUsers:E,isReadOnly:j,isAdmin:m=!1,hideViewMenuActions:w,customViewMenuActions:x,viewMenuActionData:C,viewMenuActionTableState:B}){const p=xt(),[A,L]=h.useState(!1),[I,Q]=h.useState(!1),[ee,W]=h.useState({top:0,left:0}),[v,O]=h.useState(null),[z,q]=h.useState(null),Y=h.useRef(null),c=h.useRef(null),re=e.find(N=>N.id===r),ae=re==null?void 0:re.isDefault,G=(N,Se)=>N.name.localeCompare(Se.name),te=e.filter(N=>N.scope==="global"&&!N.isDeleted).sort(G),ue=e.filter(N=>N.scope!=="global"&&!N.isDeleted).sort(G),le=e.filter(N=>N.isFavorite&&!N.isDeleted).sort(G),Z=e.filter(N=>N.isDeleted);h.useEffect(()=>{if(A&&c.current){const N=c.current.getBoundingClientRect();W({top:N.bottom+window.scrollY+8,left:N.right+window.scrollX-320})}},[A]),h.useEffect(()=>{const N=Se=>{Y.current&&!Y.current.contains(Se.target)&&c.current&&!c.current.contains(Se.target)&&L(!1)};return A&&document.addEventListener("mousedown",N),()=>{document.removeEventListener("mousedown",N)}},[A]);const de=N=>{if(n&&N!==r){O(N),L(!1);return}i(N),L(!1)},ie=()=>{v&&(i(v),O(null))},P=()=>{O(null)},oe=(N,Se=!1)=>{const Ae=N.scope==="global",it=!j&&(!Ae||m),We=m&&!Ae,st=((x==null?void 0:x.length)??0)>0;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===N.id?Pt(p).bg:"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===N.id?Pt(p).hoverBg:p.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>de(N.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===N.id&&t.jsx(_.Check,{sx:{fontSize:16,flexShrink:0}}),r!==N.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===N.id?p.palette.primary.dark:p.palette.text.primary,fontWeight:r===N.id?Ze=>Ze.typography.body2.fontWeight||500:400,fontSize:Ze=>Ze.typography.body2.fontSize||"0.875rem"},children:N.name}),Se&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:p.palette.text.secondary,backgroundColor:p.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:[it&&l&&t.jsx(o.IconButton,{onClick:Ze=>{Ze.stopPropagation(),l(N.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:p.palette.action.hover}},title:N.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(_.Star,{sx:{fontSize:16}})}),it&&a&&!N.isDefault&&t.jsx(o.IconButton,{onClick:Ze=>{Ze.stopPropagation(),a(N.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:p.palette.action.hover}},title:"Set as default",children:t.jsx(_.RadioButtonUnchecked,{sx:{fontSize:16}})}),(st||(it||We)&&(g||b||f||S||We&&y))&&t.jsx(o.IconButton,{onClick:Ze=>{Ze.stopPropagation(),q({el:Ze.currentTarget,view:N})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:p.palette.action.hover}},title:"More actions",children:t.jsx(_.MoreVert,{sx:{fontSize:16}})})]})]},N.id)},me=N=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:p.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:p.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:N.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[d&&t.jsx(o.IconButton,{onClick:Se=>{Se.stopPropagation(),d(N.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:p.palette.action.hover}},title:"Restore view",children:t.jsx(_.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(o.IconButton,{onClick:Se=>{Se.stopPropagation(),u(N.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:p.palette.action.hover}},title:"Delete permanently",children:t.jsx(_.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},N.id),pe=n||!ae,Me=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:c,onClick:()=>L(!A),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:pe?"warning.main":"text.primary",borderColor:pe?"warning.main":"divider",bgcolor:pe?$(p.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:pe?"warning.dark":"primary.main",bgcolor:pe?$(p.palette.warning.main,.2):$(p.palette.text.primary,.06),color:pe?"warning.dark":"text.primary"}},title:`View: ${(re==null?void 0:re.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(re==null?void 0:re.name)||"Default View"}),Me&&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"}})]}),A&&Es.createPortal(t.jsxs(o.Box,{ref:Y,sx:{position:"fixed",width:"320px",backgroundColor:p.palette.background.paper,border:`1px solid ${p.palette.divider}`,borderRadius:1,boxShadow:p.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:ee.top,left:ee.left},children:[te.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:N=>N.typography.caption.fontSize||"caption.fontSize",fontWeight:N=>N.typography.caption.fontWeight||600,color:p.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),te.map(N=>oe(N,N.isDefault))]}),le.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${p.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:p.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"})]}),le.map(N=>oe(N))]})]}),ue.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${p.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:N=>N.typography.caption.fontSize||"caption.fontSize",fontWeight:N=>N.typography.caption.fontWeight||600,color:p.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),ue.map(N=>oe(N))]})]}),Z.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${p.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>Q(!I),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:p.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:p.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",Z.length,")"]}),t.jsx(_.ChevronRight,{sx:{fontSize:16}})]}),I&&t.jsx(o.Box,{sx:{backgroundColor:p.palette.action.hover},children:Z.map(N=>me(N))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${p.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),L(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:p.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:p.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:!!z,anchorEl:(z==null?void 0:z.el)||null,onClose:()=>q(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[g&&t.jsxs(o.MenuItem,{onClick:()=>{z&&g(z.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Edit,{sx:{fontSize:18}}),"Edit"]}),f&&t.jsxs(o.MenuItem,{onClick:()=>{z&&f(z.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Link,{sx:{fontSize:18}}),"Copy Link"]}),b&&t.jsxs(o.MenuItem,{onClick:()=>{z&&b(z.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),y&&m&&(z==null?void 0:z.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{z&&y(z.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Language,{sx:{fontSize:18}}),"Promote to Global"]}),E&&z&&!(w!=null&&w.includes("setDefaultForAllUsers"))?t.jsxs(o.MenuItem,{onClick:()=>{z&&E(z.view.id,!z.view.isDefaultForAllUsers),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Star,{sx:{fontSize:18,color:z.view.isDefaultForAllUsers?"warning.main":"inherit"}}),z.view.isDefaultForAllUsers?"Remove from":"Set as"," Default for All Users"]}):null,x&&x.length>0&&z&&(()=>{const N=z.view,Se={allViews:e,activeView:e.find(We=>We.id===r),currentTableState:B??null,data:C??[],closeMenu:()=>q(null)},Ae=x.filter(We=>{var st;return!((st=We.hidden)!=null&&st.call(We,N,Se))});return Ae.length===0?null:[!!(g||f||b||y&&m&&N.scope!=="global"||E&&!(w!=null&&w.includes("setDefaultForAllUsers")))?t.jsx(o.Divider,{},"custom-view-actions-divider"):null,...Ae.map(We=>{var st;return t.jsxs(o.MenuItem,{disabled:(st=We.disabled)==null?void 0:st.call(We,N,Se),onClick:()=>{We.onClick(N,Se),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[We.icon,We.label]},We.key)})]})(),S&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{z&&S(z.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx(_.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:v!==null,onClose:P,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Fo(p)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1,fontSize:p.typography.h4.fontSize||"1.125rem",fontWeight:p.typography.h4.fontWeight||500},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:P,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:ie,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function mu({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:l=!1,position:d,onSortAscending:u,onSortDescending:g,onRemoveSort:b,onFilter:f,onClearFilter:S,onGroupByColumn:y,onHideColumn:E,onManageColumns:j,onResetLayout:m,onClose:w}){const x=xt(),C=x.palette,B=h.useRef(null);h.useEffect(()=>{if(!B.current)return;const ee=B.current,W=ee.getBoundingClientRect(),v=window.innerWidth,O=window.innerHeight;W.right>v-8&&(ee.style.left=`${v-W.width-8}px`),W.bottom>O-8&&(ee.style.top=`${O-W.height-8}px`)},[d]),h.useEffect(()=>{const ee=v=>{B.current&&!B.current.contains(v.target)&&w()},W=v=>{v.key==="Escape"&&w()};return document.addEventListener("mousedown",ee),document.addEventListener("keydown",W),()=>{document.removeEventListener("mousedown",ee),document.removeEventListener("keydown",W)}},[w]);const p=h.useCallback(ee=>()=>{ee(),w()},[w]),A=(n==null?void 0:n.direction)==="asc",L=(n==null?void 0:n.direction)==="desc",I=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",Q=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return Es.createPortal(t.jsxs(o.Paper,{ref:B,elevation:0,sx:{position:"fixed",left:`${d.x}px`,top:`${d.y}px`,zIndex:x.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:Fo(x),overflow:"hidden",boxShadow:`0 4px 20px ${$(C.common.black,.12)}, 0 1px 4px ${$(C.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:ee=>ee.typography.body2.fontSize||"0.8125rem",fontWeight:ee=>ee.typography.body2.fontWeight||500,color:"text.primary"},children:"Sorting"}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[t.jsx(o.Tooltip,{title:`Sort Ascending (${I})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:p(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:A?"primary.main":"text.secondary",bgcolor:A?$(C.primary.main,.1):"transparent","&:hover":{bgcolor:$(C.primary.main,.08),color:"primary.main"}},children:t.jsx(_.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${Q})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:p(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:L?"primary.main":"text.secondary",bgcolor:L?$(C.primary.main,.1):"transparent","&:hover":{bgcolor:$(C.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:p(()=>b(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:$(C.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:p(()=>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:p(()=>S(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:$(C.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&&y&&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:p(()=>y(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:p(()=>E(e)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(_.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:p(j),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:$(C.primary.main,.08),color:"primary.main"}},children:t.jsx(_.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(o.MenuItem,{onClick:p(j),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&&l&&m&&t.jsxs(o.MenuItem,{onClick:p(m),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:$(C.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 fu=176,vs="COLUMN_HEADER",xu=h.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:l=!1,hasModifications:d=!1,width:u,onColumnClick:g,onMoveColumn:b,onColumnDragEnd:f,onResizeStart:S,onSortAscending:y,onSortDescending:E,onRemoveSort:j,onOpenFilterForColumn:m,onClearFiltersForColumn:w,onGroupByColumn:x,onHideColumn:C,onManageColumns:B,onResetLayout:p}){const L=xt().urmTable,I=h.useRef(null),[Q,ee]=h.useState(!1),[W,v]=h.useState({x:0,y:0}),[{handlerId:O,isOver:z},q]=ur.useDrop({accept:vs,collect(Z){return{handlerId:Z.getHandlerId(),isOver:Z.isOver()}},hover(Z,de){var N;if(!I.current)return;const ie=Z.index,P=n;if(ie===P)return;const oe=(N=I.current)==null?void 0:N.getBoundingClientRect(),me=(oe.right-oe.left)/2,pe=de.getClientOffset(),Me=((pe==null?void 0:pe.x)??0)-oe.left;ie<P&&Me<me||ie>P&&Me>me||(b(ie,P),Z.index=P)}}),[{isDragging:Y},c]=ur.useDrag({type:vs,item:()=>({index:n,columnName:r.name}),collect:Z=>({isDragging:Z.isDragging()}),end:()=>{f==null||f()}});c(q(I));const re=h.useCallback(Z=>{Z.preventDefault(),Z.stopPropagation(),v({x:Z.clientX,y:Z.clientY}),ee(!0)},[]),ae=h.useCallback(()=>ee(!1),[]),G=h.useCallback(()=>{g(r.name)},[g,r.name]),te=h.useCallback(Z=>{Z.stopPropagation(),m(r.name)},[m,r.name]),ue=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]),le=h.useCallback(()=>s?t.jsx(_.FilterList,{onClick:te,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,te]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:I,"data-handler-id":O,"data-column-index":n,onClick:G,onContextMenu:re,sx:{position:"sticky",top:0,zIndex:5,textAlign:(L==null?void 0:L.cellAlignH)??"left",verticalAlign:(L==null?void 0:L.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(L==null?void 0:L.headerColor)??"text.secondary",opacity:Y?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:z?Z=>$(Z.palette.primary.main,.08):(L==null?void 0:L.headerBg)??"action.hover",boxShadow:Z=>`0 1px 0 ${$(Z.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(L==null?void 0:L.rowDivider)??"1px solid",borderRight:L==null?void 0:L.colDivider,borderColor:"divider",py:0,px:(L==null?void 0:L.cellPaddingX)??2,"&:hover":{bgcolor:Z=>$(Z.palette.primary.main,.1),color:"text.primary"},width:u?`${u}px`:`${fu}px`},children:[t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[ut(r.name),ue(),le()]}),t.jsx(o.Box,{draggable:!1,onDragStart:Z=>Z.preventDefault(),sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center","&:hover > div":{opacity:1}},onMouseDown:Z=>{Z.preventDefault(),Z.stopPropagation(),S(Z,r.name)},onClick:Z=>Z.stopPropagation(),children:t.jsx(o.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),z&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),Q&&t.jsx(mu,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:l,hasModifications:d,position:W,onSortAscending:y,onSortDescending:E,onRemoveSort:j,onFilter:m,onClearFilter:w,onGroupByColumn:x,onHideColumn:C,onManageColumns:B,onResetLayout:p,onClose:ae})]})}),gu={active:"success",completed:"success",approved:"success",success:"success",done:"success",contract:"info","in progress":"info","in review":"info",review:"info",pending:"info","on leave":"error","on hold":"warning",probation:"warning",cancelled:"error",rejected:"error",blocked:"error",inactive:"neutral","not started":"neutral",paused:"neutral"},yu={error:"err",warning:"warn",info:"info",success:"suc"};function fn(e,r){var l,d;const n=gu[r.toLowerCase().trim()];if(!n||n==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.tokens,s=yu[n],a=e.palette[n];return{bg:((l=i==null?void 0:i.status)==null?void 0:l[`${s}Soft`])??$(a.main,e.palette.mode==="dark"?.24:.12),color:((d=i==null?void 0:i.status)==null?void 0:d[`${s}Txt`])??(e.palette.mode==="dark"?a.light:a.dark)}}function bu(e,r){switch(r.toLowerCase().trim()){case"low":return e.palette.text.secondary;case"medium":return e.palette.warning.main;case"high":return e.palette.mode==="dark"?e.palette.warning.light:e.palette.warning.dark;case"critical":case"urgent":return e.palette.error.main;default:return}}const vu={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"},rows:{hue:"primary",shade:"main"}};function Ss(e,r){const n=vu[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function Bt(e){return $(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function Su(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:"10px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>fn(n,r).bg,color:n=>fn(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function wu(e,r){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.875rem"},children:"—"});const n=String(r),i=e.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return Su(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:a=>{const l=bu(a,s);return l?{color:l,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 Cu(e){const r=e.find(s=>{const a=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(a)})||e[0]||null,n=e.find(s=>{const a=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(a)&&s!==r})||null,i=e.filter(s=>s!==r&&s!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function ju({row:e,rowIndex:r,visibleColumns:n,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:l,onOpenRowMenu:d,onToggleSelection:u,hideCheckbox:g}){const[b,f]=h.useState(!1),{primaryCol:S,idCol:y,bodyColumns:E}=h.useMemo(()=>Cu(n),[n]),j=S?e[S.name]:null,m=y?e[y.name]:null,w=b||i;return t.jsxs(o.Box,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onClick:x=>s(r,x),onDoubleClick:x=>a(e,r,x),onContextMenu:x=>{x.preventDefault(),x.stopPropagation(),l(e,r,x)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:x=>{var B,p,A,L;const C=(L=(A=(p=(B=x.components)==null?void 0:B.MuiCard)==null?void 0:p.styleOverrides)==null?void 0:A.root)==null?void 0:L.border;return i?"2px solid":C&&C!=="none"?C:"1px solid"},borderColor:i?x=>Pt(x).main:x=>{var B,p,A,L;const C=(L=(A=(p=(B=x.components)==null?void 0:B.MuiCard)==null?void 0:p.styleOverrides)==null?void 0:A.root)==null?void 0:L.border;return C&&C!=="none"?"inherit":$(x.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:x=>{var B,p,A,L;const C=(L=(A=(p=(B=x.components)==null?void 0:B.MuiCard)==null?void 0:p.styleOverrides)==null?void 0:A.root)==null?void 0:L.borderRadius;return C!==void 0?typeof C=="number"?`${C}px`:C:`${x.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?x=>`0 0 0 3px ${$(Pt(x).main,.15)}, 0 2px 8px ${$(x.palette.common.black,.08)}`:b?x=>{var B,p,A,L;const C=(L=(A=(p=(B=x.components)==null?void 0:B.MuiCard)==null?void 0:p.styleOverrides)==null?void 0:A.root)==null?void 0:L.boxShadow;return C&&C!=="none"?C:ye(x,"cardHover")}:x=>{var B,p,A,L;const C=(L=(A=(p=(B=x.components)==null?void 0:B.MuiCard)==null?void 0:p.styleOverrides)==null?void 0:A.root)==null?void 0:L.boxShadow;return C&&C!=="none"?C:ye(x,"cardRest")},transform:b&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:x=>$(Pt(x).main,.03)}},children:[t.jsxs(o.Box,{sx:x=>{var L,I,Q,ee;const C=((Q=(I=(L=x.components)==null?void 0:L.MuiCardHeader)==null?void 0:I.styleOverrides)==null?void 0:Q.root)||{},B=(C.backgroundColor&&C.backgroundColor!=="transparent"?C.backgroundColor:void 0)??((ee=x.tokens)==null?void 0:ee.cardHdrHex)??"transparent",p=C.borderBottom&&C.borderBottom!=="none"?C.borderBottom:void 0,A=C.boxShadow&&C.boxShadow!=="none"?C.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:B,borderBottom:p,boxShadow:A,display:"flex",alignItems:"center",gap:.5}},children:[!g&&w&&t.jsx(o.Checkbox,{size:"small",checked:i,onClick:x=>x.stopPropagation(),onChange:()=>u(e),sx:{p:.25}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:x=>x.typography.body2.fontWeight||600,fontSize:x=>x.typography.body1.fontSize||"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:j!=null&&j!==""?String(j):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(o.Box,{sx:x=>{var p,A,L;const C=((L=(A=(p=x.components)==null?void 0:p.MuiCardHeader)==null?void 0:A.styleOverrides)==null?void 0:L.root)||{};return C.borderBottom&&C.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[E.map(x=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:C=>C.typography.body2.fontWeight||500,fontSize:C=>C.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:ut(x.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[x.name]??""),children:wu(x,e[x.name])})]},x.name)),E.length===0&&t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic",gridColumn:"1 / -1"},children:"No additional fields visible"})]}),t.jsxs(o.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:x=>$(x.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:w?1:0,transition:"opacity 0.15s ease"},onClick:x=>x.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:x=>{x.stopPropagation(),d(e,r,x.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:x=>$(x.palette.text.primary,.08)}},children:t.jsx(_.MoreVert,{sx:{fontSize:17}})})})})]})]})}function ku({row:e,grouping:r,onToggleCollapse:n}){var i;return t.jsxs(o.Box,{onClick:()=>n(e.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:s=>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:Xa(e.groupLevel,((i=r==null?void 0:r.levels[e.groupLevel])==null?void 0:i.column)||"",e.groupValue)}),t.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>$(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])=>As(a)).filter(Boolean).join(" • ")})]})}function zu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:l,onCardDoubleClick:d,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:b,hideSelectionCheckboxes:f}){const S=h.useMemo(()=>{const y=new Set;return i.forEach(E=>{const j=E==null?void 0:E.__urm_row_id__;j!==void 0&&y.add(j)}),y},[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:y=>y.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:y=>ys(y).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:y=>ys(y).cardGap,alignContent:"start"},children:e.map((y,E)=>s&&y.isGroupHeader?t.jsx(ku,{row:y,grouping:n,onToggleCollapse:a||(()=>{})},`group-${y.groupKey}`):t.jsx(ju,{row:y,rowIndex:E,visibleColumns:r,isSelected:S.has(y==null?void 0:y.__urm_row_id__),onCardClick:l,onCardDoubleClick:d,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:b,hideCheckbox:f},`card-${E}`))})})}const ws=[10,15,25,50,100];function Tu(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 Bu({currentPage:e,pageSize:r,totalRows:n,totalPages:i,totalFields:s,selectedCount:a,onClearSelection:l,onPageChange:d,onPageSizeChange:u}){const b=xt().palette,f=i??Math.max(1,Math.ceil(n/r)),[S,y]=h.useState(String(e)),[E,j]=h.useState(null),[m,w]=h.useState(!1),x=h.useRef(null);h.useEffect(()=>{m||(y(String(e)),j(null))},[e,m]);const C=h.useCallback(()=>{const Y=Tu(S,f);if(Y){j(Y);return}const c=parseInt(S.trim(),10);j(null),w(!1),c!==e&&d(c)},[S,f,e,d]),B=h.useCallback(Y=>{var c;Y.key==="Enter"?(Y.preventDefault(),C()):Y.key==="Escape"&&(y(String(e)),j(null),w(!1),(c=x.current)==null||c.blur())},[C,e]),p=h.useCallback(()=>{y(String(e)),j(null),w(!1)},[e]),A=h.useCallback(()=>{w(!0),j(null),setTimeout(()=>{var Y;return(Y=x.current)==null?void 0:Y.select()},0)},[]);if(n<=Math.min(...ws))return null;const L=()=>{y(String(e)),j(null),w(!1)},I=()=>{L(),d(1)},Q=()=>{L(),e>1&&d(e-1)},ee=()=>{L(),e<f&&d(e+1)},W=()=>{L(),d(f)},v=(e-1)*r+1,O=Math.min(e*r,n),z=`${Math.max(2,String(f).length+.5)}ch`,q={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:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),s!==void 0&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:s})]}),!!a&&a>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"primary.main",fontWeight:600},children:[a," selected"]}),l&&t.jsx(o.Button,{size:"small",onClick:l,sx:{fontSize:"0.75rem",p:0,minWidth:"auto",color:"text.secondary"},children:"Clear"})]})]}),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:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:Y=>u(Number(Y.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:ws.map(Y=>t.jsx(o.MenuItem,{value:Y,sx:{fontSize:"0.8125rem"},children:Y},Y))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[v,"–",O," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[E&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:$(b.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${$(b.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:$(b.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:Y=>Y.typography.caption.fontSize||"0.6875rem",fontWeight:Y=>Y.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:E})}),t.jsx(o.InputBase,{inputRef:x,value:S,onChange:Y=>{y(Y.target.value),E&&j(null)},onKeyDown:B,onFocus:A,onBlur:p,inputProps:{"aria-label":`Page number, 1 to ${f}`,style:{textAlign:"center",padding:"2px 0",width:z,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:E?"error.main":"text.primary",border:"1px solid",borderColor:E?"error.main":m?"primary.main":"divider",borderRadius:"4px",bgcolor:E?$(b.error.main,.04):m?$(b.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:E?"error.main":"text.secondary"},"&:focus-within":{boxShadow:E?`0 0 0 2px ${$(b.error.main,.2)}`:`0 0 0 2px ${$(b.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:Y=>Y.typography.body2.fontSize||"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",f]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:I,disabled:e===1,size:"small",title:"First page",sx:q,children:t.jsx(_.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:Q,disabled:e===1,size:"small",title:"Previous page",sx:q,children:t.jsx(_.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:ee,disabled:e===f,size:"small",title:"Next page",sx:q,children:t.jsx(_.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:W,disabled:e===f,size:"small",title:"Last page",sx:q,children:t.jsx(_.LastPage,{sx:{fontSize:20}})})]})]})]})}function Iu(){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 aa="urm_hint_seen_";function Eu(e){try{return localStorage.getItem(aa+e)==="true"}catch{return!1}}function Du(e){try{localStorage.setItem(aa+e,"true")}catch{}}const la={"& .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 mi(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 ca({row:e,schema:r}){const i=xt().palette,s=r.filter(d=>d.name in e),a=s.filter(d=>d.type!=="object"&&d.type!=="array"),l=s.filter(d=>d.type==="object"||d.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[a.map(d=>t.jsx(o.TextField,{label:ut(d.name),value:mi(e[d.name],d.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:la},d.name)),l.map(d=>{const u=mi(e[d.name],d.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:g=>g.typography.caption.fontWeight||500,fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:ut(d.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:$(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:u?"text.primary":"text.disabled",fontStyle:u?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:u||"No value"})]},d.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3,fontSize:d=>d.typography.body2.fontSize||"0.875rem"},children:"No fields to display"})]})}function _u({open:e,onClose:r,row:n,schema:i,reportName:s}){const a=xt(),l=a.palette;if(!n)return null;const d=i.filter(g=>g.name in n).length,u=he(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:nt(a),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",overflow:"hidden",...u.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0,...u.header},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:$(l.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:"h4",sx:{fontSize:g=>g.typography.h4.fontSize||"1rem",fontWeight:g=>g.typography.h4.fontWeight||600,color:g=>g.typography.h4.color||"text.primary",lineHeight:1.3},children:"View Record"}),s&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",d," ",d===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:$(l.text.primary,.015)},children:t.jsx(ca,{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:g=>`${g.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function $u({open:e,onClose:r,onConfirm:n,row:i,schema:s}){const a=xt(),l=he(a);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:nt(a),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",...l.paper}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between",...l.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:d=>$(d.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:"h4",sx:{fontSize:d=>d.typography.h4.fontSize||"1.125rem",fontWeight:d=>d.typography.h4.fontWeight||500,color:d=>d.typography.h4.color||"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:d=>d.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(ca,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:d=>$(d.palette.error.main,.1),border:d=>`1px solid ${$(d.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:d=>d.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:d=>d.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:d=>`${d.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:d=>`${d.shape.borderRadius}px`,boxShadow:d=>ye(d,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:d=>ye(d,"hoverButton")},"&:active":{boxShadow:d=>ye(d,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function Ou({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:a}){var w;const l=xt(),d=l.palette,[u,g]=h.useState({});if(h.useEffect(()=>{e&&i&&g({...i})},[e,i]),!i)return null;const b=s.filter(x=>x.name in i),f=b.filter(x=>x.type!=="object"&&x.type!=="array"),S=b.filter(x=>x.type==="object"||x.type==="array"),y=(x,C)=>{g(B=>({...B,[x]:C}))},E=()=>{const x={...u};b.forEach(C=>{const B=u[C.name];if(C.type==="number"){const p=Number(B);x[C.name]=isNaN(p)?i[C.name]:p}else C.type==="boolean"&&(x[C.name]=!!B)}),n(x),r()},j=b.length,m=he(l);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:nt(l),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:$(((w=d.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,{variant:"h4",sx:{fontSize:x=>x.typography.h4.fontSize||"1rem",fontWeight:x=>x.typography.h4.fontWeight||600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),a&&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:[a," · ",j," ",j===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.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[f.map(x=>{const C=u[x.name];return x.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:B=>B.typography.caption.fontWeight||500,fontSize:B=>B.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:ut(x.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!C,onChange:B=>y(x.name,B.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:B=>B.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:C?"Enabled":"Disabled"})]})]},x.name):t.jsx(o.TextField,{label:ut(x.name),value:C??"",onChange:B=>y(x.name,B.target.value),type:x.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:la},x.name)}),S.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:S.map(x=>{const C=mi(i[x.name],x.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:B=>B.typography.caption.fontSize||"0.75rem",fontWeight:B=>B.typography.caption.fontWeight||500,color:"text.secondary"},children:ut(x.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:$(d.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.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:C?"text.primary":"text.disabled",fontStyle:C?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:C||"No value"})]},x.name)})}),b.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:x=>`${x.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:E,variant:"contained",startIcon:t.jsx(_.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:x=>`${x.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const Mu=176,Au=170,Wu=40;function da(e){return e.type==="date"?180:Mu}function Ru(e,r){return r!=null&&r!==Au&&r!==da(e)}function Pu(e,r,n){return h.useMemo(()=>{const i=e.map(f=>({name:f.name,width:r[f.name]??da(f),explicit:Ru(f,r[f.name])})),s={};i.forEach(f=>{s[f.name]=f.width});const a=i.reduce((f,S)=>f+S.width,0),d=Math.max(0,n-Wu)-a;if(d<=0)return{widths:s,fillerWidth:0};const u=i.filter(f=>!f.explicit);if(u.length===0)return{widths:s,fillerWidth:d};const g=u.reduce((f,S)=>f+S.width,0)||1;let b=0;return u.forEach((f,S)=>{const E=S===u.length-1?f.width+d-b:Math.round(f.width+d*f.width/g);s[f.name]=E,b+=E-f.width}),{widths:s,fillerWidth:0}},[e,r,n])}const Cs=176,Nu=Rt(),Lu={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Fu(e){const r=e.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",px:1.25,py:.375,borderRadius:"12px",fontSize:"0.75rem",fontWeight:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>fn(n,r).bg,color:n=>fn(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Vu(e){const r=e.toLowerCase().trim(),n=Lu[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Hu(e,r){const n=r.trim();if(!n)return e;const i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.split(new RegExp(`(${i})`,"gi"));return s.length===1?e:s.map((a,l)=>a.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:a},l):a)}function Uu(e,r,n,i=""){if(r==null||r==="")return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"—"});const s=String(r);if(/\b(status|state|stage|employmenttype|contracttype|availability)\b/.test(e.name.toLowerCase()))return Fu(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Vu(s);if(e.type==="date"){const d=e.dateFormat??"iso",u=Fa(r,d,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}if(e.type==="number"&&typeof r=="number")return r.toLocaleString();if(typeof r=="boolean")return r?"Yes":"No";if(Array.isArray(r)){if(r.length===0)return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const d=r.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return t.jsxs(o.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[d,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const d=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:d,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:d.length>40?d.slice(0,40)+"…":d})}return Hu(s,i)}function Gu({schema:e,data:r,sortStack:n=[],filters:i=Nu,views:s=[],activeViewId:a="",isDirty:l=!1,isExporting:d=!1,columnVisibility:u={},columnOrder:g=[],columnWidths:b={},grouping:f=null,classTokens:S={},onSort:y,onSortAscending:E,onSortDescending:j,onOpenFilters:m,onOpenSort:w,onOpenFilterForColumn:x,onSelectView:C,onCreateView:B,onUpdateCurrentView:p,onSaveAsNewView:A,onDiscardChanges:L,onToggleDefault:I,onToggleFavorite:Q,onRestoreView:ee,onPermanentDelete:W,onEditView:v,onCloneView:O,onCopyLink:z,onDeleteView:q,onPromoteToGlobal:Y,onSetDefaultForAllUsers:c,isAdmin:re=!1,hideViewMenuActions:ae,customViewMenuActions:G,viewMenuActionData:te,viewMenuActionTableState:ue,onExport:le,onOpenColumns:Z,onUpdateColumnWidth:de,onUpdateColumnOrder:ie,onUpdateColumnVisibility:P,onClearFiltersForColumn:oe,onResetLayout:me,onOpenGroup:pe,onGroupByColumn:Me,onToggleGroupCollapse:N,onExpandAllGroups:Se,onCollapseAllGroups:Ae,onOpenAuditHistory:it,onOpenScheduledReports:We,searchQuery:st,highlightQuery:Ze="",searchHistory:Nt=[],onAddToSearchHistory:Et,onToggleSearchFavourite:Zt,onDeleteSearchHistory:Nr,selectedRowIds:er=new Set,onSearchChange:Lr,onToggleRowSelection:qe,onToggleAllRows:Dt,onRangeSelection:Fr,onClearSelection:lt,onExportSelected:tr,currentPage:Lt=1,pageSize:Vr=15,totalRowsBeforePagination:Ft=r.length,totalPagesOverride:_t,onPageChange:Vt,onPageSizeChange:ct,isReadOnly:Ne=!1,userRole:Hr,reportName:Ur,onEditRow:hr,onDuplicateRow:mr,onDeleteRow:rr,showDevPanel:xo=!1,onOpenDevConfig:kr,rowActions:$t,hideDefaultRowActions:He,hideToolbarActions:we,customSettingsActions:Ht,jsonGuideContent:go,jsonGuideTitle:yo,viewOptions:Gr,defaultViewMode:Yr,bulkActions:or,hideSelectionCheckboxes:ke,rowClickBehavior:fr="select",openModalOn:rt,onRowClick:gt,onRowRightClick:H}){var Ko;const K=xt().urmTable,[at,xr]=h.useState(null),[nr,bo]=h.useState(0),[gr,zr]=h.useState(0),[St,ir]=h.useState(null),Tr=Rr(),ve=((Ko=Tr.dates)==null?void 0:Ko.displayFormat)??null,[wt,qr]=h.useState(null),[U,Ke]=h.useState(null),[Te,pt]=h.useState(null),[Br,yt]=h.useState(!1),[vo,Ut]=h.useState(!1),[Ir,Jr]=h.useState(null),[Gt,Er]=h.useState(!1),[Kr,Dr]=h.useState(null),[_r,$r]=h.useState(null),[Ce,se]=h.useState(null),[fe,je]=h.useState(null),Pe=h.useRef(null),Xe=h.useCallback(()=>{Pe.current&&(clearTimeout(Pe.current),Pe.current=null)},[]),ht=h.useCallback(()=>{Xe(),Pe.current=setTimeout(()=>je(null),200)},[Xe]);h.useEffect(()=>Xe,[Xe]);const[dt,Ct]=h.useState(null),Yt=h.useMemo(()=>Gr??["list","grid"],[Gr]),[yr,Or]=h.useState(()=>Yr??Yt[0]??"list"),[So,Vo]=h.useState(!1),[Xr,Mn]=h.useState(()=>!Eu("toolbar_search")),Qr=h.useRef(null),wo=h.useRef(null),[An,Ho]=h.useState(0);h.useLayoutEffect(()=>{const k=Qr.current;if(!k)return;Ho(k.clientWidth);const F=new ResizeObserver(ne=>{Ho(ne[0].contentRect.width)});return F.observe(k),()=>F.disconnect()},[]);const Zr=h.useCallback(()=>{Du("toolbar_search"),Mn(!1)},[]);h.useEffect(()=>{if(!Xr)return;const k=setTimeout(Zr,2e3);return()=>clearTimeout(k)},[Xr,Zr]);const Uo=h.useMemo(()=>{const k=St??g;return k.length>0?k.map(F=>e.find(ne=>ne.name===F)).filter(F=>F!==void 0):e},[St,g,e]),eo=h.useMemo(()=>Uo.filter(k=>u[k.name]!==!1),[Uo,u]),Co=h.useMemo(()=>new Set(((f==null?void 0:f.levels)??[]).map(k=>k.column)),[f]),jo=!!(f!=null&&f.enabled&&(f!=null&&f.levels)&&f.levels.length>0),to=h.useMemo(()=>{if(!jo)return eo;const k=((f==null?void 0:f.levels)??[]).map(ne=>e.find(ze=>ze.name===ne.column)).filter(ne=>ne!==void 0),F=eo.filter(ne=>!Co.has(ne.name));return[...k,...F]},[eo,jo,Co,f,e]),{widths:ro}=Pu(to,b,An),br=h.useMemo(()=>e.filter(k=>u[k.name]===!1).length,[e,u]),Go=h.useMemo(()=>e.map(k=>k.name),[e]),oo=h.useMemo(()=>g.length===0?!1:JSON.stringify(g)!==JSON.stringify(Go),[g,Go]),Wn=h.useCallback((k,F)=>{k.preventDefault(),k.stopPropagation(),xr(F),bo(k.clientX),zr(b[F]||150)},[b]);h.useEffect(()=>{if(!at)return;const k=ne=>{const ze=ne.clientX-nr,Le=Math.max(100,Math.min(600,gr+ze));de==null||de(at,Le)},F=()=>{xr(null)};return document.addEventListener("mousemove",k),document.addEventListener("mouseup",F),()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",F)}},[at,nr,gr,de]);const Rn=h.useCallback(k=>k==null?"-":typeof k=="object"?JSON.stringify(k):typeof k=="boolean"?k?"true":"false":String(k),[]);h.useCallback(k=>{const F=n.find(ne=>ne.column===k);return F?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[F.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:F.priority})]}):null},[n]),h.useCallback(k=>li(i,k)?t.jsx(o.IconButton,{size:"small",onClick:ne=>{ne.stopPropagation(),x==null||x(k)},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,x]);const Pn=h.useCallback(k=>{y&&y(k)},[y]),Nn=h.useCallback((k,F)=>{ir(ne=>{const Le=[...ne??(g.length>0?g:e.map(tt=>tt.name))],[ot]=Le.splice(k,1);return Le.splice(F,0,ot),Le})},[g,e]),Ln=h.useCallback(()=>{St&&ie&&ie(St),ir(null)},[St,ie]),Fn=h.useCallback(k=>{if(!y)return;const F=n.find(ne=>ne.column===k);(!F||F.direction!=="asc")&&y(k)},[y,n]),Vn=h.useCallback(k=>{if(!y)return;const F=n.find(ne=>ne.column===k);F?F.direction==="asc"&&y(k):(y(k),setTimeout(()=>y(k),0))},[y,n]),Hn=h.useCallback(k=>{if(!y)return;const F=n.find(ne=>ne.column===k);F&&(F.direction==="asc"?(y(k),setTimeout(()=>y(k),0)):F.direction==="desc"&&y(k))},[y,n]),Un=h.useCallback(k=>{P&&P(k,!1)},[P]),no=!!(f!=null&&f.enabled&&(f!=null&&f.levels)&&f.levels.length>0),sr=h.useMemo(()=>Tt(i),[i]),Gn=n.length>0||sr>0||((f==null?void 0:f.enabled)??!1)||Object.values(u).some(k=>k===!1),Yn=(Lt-1)*Vr,Ue=r,et=h.useMemo(()=>{const k=new Set;return er.forEach(F=>{const ne=F==null?void 0:F.__urm_row_id__;ne!==void 0&&k.add(ne)}),k},[er]);h.useEffect(()=>{const k=F=>{!Dt||!lt||F.target instanceof HTMLInputElement||F.target instanceof HTMLTextAreaElement||((F.ctrlKey||F.metaKey)&&F.key==="a"&&(F.preventDefault(),Dt(!0,Ue)),F.key==="Escape"&&(F.preventDefault(),lt()))};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[Dt,lt,Ue]);const ko=h.useCallback((k,F)=>{gt==null||gt(Ue[k],k,F),(fr==="activate"||fr==="both")&&(pt(Ue[k]),yt(!0)),fr!=="activate"&&qe&&(F.shiftKey&&wt!==null?(F.preventDefault(),Fr&&Fr(wt,k,Ue)):(qe(Ue[k]),qr(k)))},[qe,wt,Fr,Ue,gt,fr,pt,yt]),qt=h.useMemo(()=>Ue.filter(k=>!k.isGroupHeader),[Ue]),Yo=h.useMemo(()=>qt.length>0&&et.size>0&&qt.every(k=>et.has(k==null?void 0:k.__urm_row_id__)),[qt,et]),io=!Yo&&qt.some(k=>et.has(k==null?void 0:k.__urm_row_id__)),ar=!!(qe&&Dt&&!ke),lr=h.useMemo(()=>to,[to]),qo=h.useMemo(()=>{const k=new Map;if(!(f!=null&&f.enabled)||!Ue)return k;let F=[];for(const ne of Ue)if(ne.__isGroupHeader||ne.isGroupHeader){const ze=ne.groupLevel??0;F[ze]=ne.groupKey,F=F.slice(0,ze+1),k.has(ne.groupKey)||k.set(ne.groupKey,[])}else if(ne.__urm_is_grouped_data_row__)for(const ze of F)ze&&k.has(ze)&&k.get(ze).push(ne);return k},[f,Ue]),qn=h.useCallback(k=>{const F=k.groupLevel,ne=F===0?S.groupRowLevel0||"urm-group-level-0":F===1?S.groupRowLevel1||"urm-group-level-1":S.groupRowLevel2||"urm-group-level-2",ze=F===0?Oe=>Oe.palette.mode==="dark"?$(Oe.palette.action.hover,.12):"#f1f5f9":Oe=>Oe.palette.mode==="dark"?$(Oe.palette.action.hover,.06):"#f8fafc",Le=String(k.groupValue??"(empty)"),ot=`${k.rowCount} ${k.rowCount===1?"item":"items"}`,tt=qo.get(k.groupKey)||[],xe=tt.filter(Oe=>et.has(Oe==null?void 0:Oe.__urm_row_id__)).length,Mt=tt.length>0&&xe===tt.length,At=xe>0&&xe<tt.length;return t.jsxs(o.TableRow,{onClick:()=>N==null?void 0:N(k.groupKey),className:`urm-group-header-row urm-group-level-${F} ${ne} ${S.groupRow||""}`,sx:{bgcolor:ze,"&:hover":{bgcolor:Oe=>$(Oe.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[ar&&t.jsx(o.TableCell,{padding:"checkbox",onClick:Oe=>Oe.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(o.Checkbox,{size:"small",checked:Mt,indeterminate:At,onChange:()=>{if(!qe)return;const Oe=!Mt;tt.forEach(cr=>{const Xo=et.has(cr==null?void 0:cr.__urm_row_id__);Oe!==Xo&&qe(cr)})}})}),t.jsxs(o.TableCell,{colSpan:lr.length,className:`urm-group-cell ${S.groupCellFirst||""} ${S.groupCell||""}`,sx:{pl:`${F*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[F>0&&t.jsx(o.Box,{sx:{position:"absolute",left:`${F*24+4}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsxs(o.Box,{className:`urm-group-content ${S.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${S.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:k.isCollapsed?t.jsx(_.ChevronRight,{sx:{fontSize:18}}):t.jsx(_.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"h5",className:`urm-group-title ${S.groupTitle||""}`,sx:{fontWeight:F===0?600:500,fontSize:F===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:Le}),!k.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:Oe=>$(Oe.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:Oe=>$(Oe.palette.primary.main,.2),ml:.5},children:ut(k.groupColumn||"")}),!!k.__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:Oe=>$(Oe.palette.text.secondary,.05),color:"text.secondary",borderRadius:"10px",border:"1px dashed",borderColor:"divider",ml:.5},children:"Continued"}),t.jsx(o.Box,{className:`urm-group-count ${S.groupBadge||""} ${S.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Oe=>$(Oe.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:ot}),Object.keys(k.aggregates||{}).length>0&&t.jsxs(o.Typography,{variant:"caption",className:`urm-group-aggregates ${S.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(k.aggregates).map(([Oe,cr])=>As(cr)).filter(Boolean).join(" • "),")"]})]})]})]},k.groupKey)},[lr,ar,f,e,N,S,K,qo,et,qe]),Jo=h.useCallback((k,F)=>{const ne=et.has(k==null?void 0:k.__urm_row_id__),ze=U===F,Le=Br&&(k==null?void 0:k.__urm_row_id__)===(Te==null?void 0:Te.__urm_row_id__),ot=!!(k!=null&&k.__urm_is_grouped_data_row__),tt=ot?k.__urm_group_level__??(f==null?void 0:f.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":F,className:ot?`urm-data-row-grouped ${S.dataRowGrouped||""}`:"",onMouseEnter:()=>Ke(F),onMouseLeave:()=>Ke(null),onClick:xe=>{xe.target.closest("[data-row-action-btn]")||ko(F,xe)},onDoubleClick:()=>{rt!=null&&rt.includes("doubleClick")&&(pt(k),yt(!0))},onContextMenu:xe=>{xe.preventDefault(),xe.stopPropagation(),H==null||H(k,F,xe),je(null),se({mouseX:xe.clientX,mouseY:xe.clientY,row:k,rowIndex:F}),rt!=null&&rt.includes("rightClick")&&(pt(k),yt(!0))},sx:{cursor:"pointer",bgcolor:ne?xe=>Pt(xe).bg:Le?xe=>$(xe.palette.info.main,.12):K!=null&&K.striped&&F%2===1?K.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:ne?xe=>Pt(xe).hoverBg:Le?xe=>$(xe.palette.info.main,.2):xe=>`var(--highlight-hover-row, ${$(Pt(xe).main,.04)})`},borderBottom:(K==null?void 0:K.rowDivider)??"1px solid",borderColor:"divider"},children:[ar&&t.jsx(o.TableCell,{padding:"checkbox",onClick:xe=>xe.stopPropagation(),sx:{borderBottom:(K==null?void 0:K.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(K==null?void 0:K.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:ne,onChange:()=>qe==null?void 0:qe(k)})}),lr.map((xe,Mt)=>{const At=Mt===0;return t.jsxs(o.TableCell,{className:ot&&At?`urm-data-cell-grouped ${S.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(K==null?void 0:K.rowPaddingY)??"6px",px:(K==null?void 0:K.cellPaddingX)??2,pl:ot&&At?`${tt*24}px`:void 0,position:"relative",textAlign:(K==null?void 0:K.cellAlignH)??"left",verticalAlign:(K==null?void 0:K.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(K==null?void 0:K.rowDivider)??"1px solid",borderRight:K==null?void 0:K.colDivider,borderColor:"divider",minWidth:b[xe.name]?`${b[xe.name]}px`:`${xe.type==="date"?Math.max(Cs,180):Cs}px`},children:[ot&&At&&tt>0&&t.jsx(o.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsx(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%"},children:t.jsx("span",{className:`urm-item-title ${S.itemTitle||""}`,children:Uu(xe,k[xe.name],ve,Ze)})})]},xe.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:ze?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:xe=>{xe.stopPropagation(),xe.preventDefault(),je(null),se({anchorEl:xe.currentTarget,row:k,rowIndex:F})},sx:{color:"text.secondary",opacity:ze?1:0,transition:"opacity 0.12s ease",pointerEvents:ze?"auto":"none","&:hover":{bgcolor:xe=>$(xe.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(_.MoreVert,{sx:{fontSize:18}})})})})]},F)},[er,Yn,U,ko,to,b,Ze,Rn,hr,mr,rr,qe,ar,pt,yt,Te,Br,se,no,Co,H,rt,et,K,S]);return t.jsxs(ur.DndProvider,{backend:fi.HTML5Backend,children:[t.jsxs(o.Box,{sx:k=>{var ot,tt,xe;const F=((xe=(tt=(ot=k.components)==null?void 0:ot.MuiCard)==null?void 0:tt.styleOverrides)==null?void 0:xe.root)||{},ne=F.border&&F.border!=="none"?F.border:"1px solid",ze=F.borderRadius!==void 0?typeof F.borderRadius=="number"?`${F.borderRadius}px`:F.borderRadius:`${k.shape.borderRadius}px`,Le=F.boxShadow&&F.boxShadow!=="none"?F.boxShadow:ye(k,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:ne,borderColor:ne!=="none"?"divider":void 0,borderRadius:ze,boxShadow:Le,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:k=>{var ot,tt,xe,Mt,At;const F=((xe=(tt=(ot=k.components)==null?void 0:ot.MuiCardHeader)==null?void 0:tt.styleOverrides)==null?void 0:xe.root)||{},ne=(F.backgroundColor&&F.backgroundColor!=="transparent"?F.backgroundColor:void 0)??((Mt=k.tokens)==null?void 0:Mt.cardHdrHex)??((At=k.urmTable)==null?void 0:At.headerBg)??k.palette.background.paper,ze=F.borderBottom&&F.borderBottom!=="none"?F.borderBottom:"1px solid",Le=F.boxShadow&&F.boxShadow!=="none"?F.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:ne,borderBottom:ze,borderColor:ze!=="none"?"divider":void 0,boxShadow:Le,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Ne&&t.jsx(Iu,{}),Lr&&Et&&Zt&&Nr&&!(we!=null&&we.includes("search"))&&t.jsx(o.Tooltip,{open:Xr,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",fontWeight:k=>k.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:Zr},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:t.jsx(o.Box,{component:"span",children:t.jsx(pu,{value:st||"",onChange:k=>{Xr&&Zr(),Lr(k)},searchHistory:Nt,onAddToHistory:Et,onToggleFavourite:Zt,onDeleteHistory:Nr,disabled:Ne})})}),!(we!=null&&we.includes("jsonGuide"))&&t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>Vo(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:k=>$(k.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:20}})})}),C&&B&&p&&s.length>0&&t.jsx(hu,{views:s||[],activeViewId:a||"",isDirty:l,onSelectView:C,onCreateView:B,onToggleDefault:I,onToggleFavorite:Q,onRestoreView:ee,onPermanentDelete:W,onEditView:v,onCloneView:O,onCopyLink:z,onDeleteView:q,onPromoteToGlobal:Y,onSetDefaultForAllUsers:c,isAdmin:re,hideViewMenuActions:ae,customViewMenuActions:G,viewMenuActionData:te,viewMenuActionTableState:ue,isReadOnly:Ne}),l&&!Ne&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[p&&t.jsx(o.Button,{onClick:p,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:k=>`var(--urm-btn-save-current-bg, ${k.palette.primary.main})`,color:k=>`var(--urm-btn-save-current-color, ${k.palette.primary.contrastText})`,textTransform:"none",boxShadow:k=>ye(k,"restButton"),"&:hover":{bgcolor:k=>`var(--urm-btn-save-current-hover-bg, ${k.palette.primary.dark})`,boxShadow:k=>ye(k,"hoverButton")}},children:"Save current view"}),A&&t.jsx(o.Button,{onClick:A,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:k=>`var(--urm-btn-save-new-border, ${k.palette.primary.main})`,color:k=>`var(--urm-btn-save-new-color, ${k.palette.primary.main})`,bgcolor:k=>`var(--urm-btn-save-new-bg, ${k.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:k=>`var(--urm-btn-save-new-hover-border, ${k.palette.primary.dark})`,bgcolor:k=>`var(--urm-btn-save-new-hover-bg, ${$(k.palette.primary.main,.08)})`}},children:"Save new view"}),L&&t.jsx(o.Button,{onClick:L,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:k=>`var(--urm-btn-discard-bg, ${$(k.palette.text.primary,.12)})`,color:k=>`var(--urm-btn-discard-color, ${k.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:k=>`var(--urm-btn-discard-hover-bg, ${$(k.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),xo&&kr&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:kr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:k=>$(k.palette.text.secondary,.3),"&:hover":{bgcolor:k=>$(k.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx(_.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!Ne&&w&&!(we!=null&&we.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?k=>Bt(k):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?k=>$(k.palette.primary.main,.2):k=>$(k.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})]})}),!Ne&&m&&!(we!=null&&we.includes("filter"))&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:m,size:"small",sx:{position:"relative",color:sr>0?"primary.main":"text.secondary",bgcolor:sr>0?k=>Bt(k):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:sr>0?k=>$(k.palette.primary.main,.2):k=>$(k.palette.text.primary,.06),color:sr>0?"primary.main":"text.primary"}},children:[t.jsx(_.FilterList,{sx:{fontSize:20}}),sr>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:sr})]})}),!Ne&&Z&&!(we!=null&&we.includes("columns"))&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:Z,size:"small",sx:{position:"relative",color:br>0||oo?"primary.main":"text.secondary",bgcolor:br>0||oo?k=>Bt(k):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:br>0||oo?k=>$(k.palette.primary.main,.2):k=>$(k.palette.text.primary,.06),color:br>0||oo?"primary.main":"text.primary"}},children:[t.jsx(_.ViewColumn,{sx:{fontSize:20}}),br>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:br})]})}),no&&(Se||Ae)&&(()=>{var ne;const k=(((ne=f==null?void 0:f.collapsedGroups)==null?void 0:ne.length)??0)>0,F=k?Se:Ae;return F?t.jsx(o.Tooltip,{title:k?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:F,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:ze=>$(ze.palette.text.primary,.06),color:"text.primary"}},children:k?t.jsx(_.UnfoldMore,{sx:{fontSize:20}}):t.jsx(_.UnfoldLess,{sx:{fontSize:20}})})}):null})(),Yt.length>1&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),Yt.map(k=>{const F=yr===k,ne=k==="list"?t.jsx(_.TableRows,{sx:{fontSize:20}}):t.jsx(_.GridView,{sx:{fontSize:20}}),ze=k==="list"?"List view":"Grid view";return t.jsx(o.Tooltip,{title:ze,children:t.jsx(o.IconButton,{size:"small",onClick:()=>Or(k),sx:{borderRadius:1,color:F?"primary.main":"text.secondary",bgcolor:F?Le=>Bt(Le):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:F?Le=>$(Le.palette.primary.main,.2):Le=>$(Le.palette.text.primary,.06),color:F?"primary.main":"text.primary"}},children:ne})},k)})]}),!(we!=null&&we.includes("settings"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),t.jsx(o.Tooltip,{title:"Settings",children:t.jsx(o.IconButton,{onClick:k=>Ct(k.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:k=>$(k.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(_.Settings,{sx:{fontSize:20}})})})]})]}),t.jsxs(o.Popover,{open:!!dt,anchorEl:dt,onClose:()=>Ct(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:200,py:.5,borderRadius:1.5,boxShadow:3}},children:[le&&!(we!=null&&we.includes("export"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{le(),Ct(null)},disabled:d,sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.Download,{sx:{fontSize:k=>k.typography.body1.fontSize,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Ne&&pe&&!(we!=null&&we.includes("grouping"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{pe(),Ct(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"})]}),it&&!(we!=null&&we.includes("auditHistory"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{it(),Ct(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"})]}),We&&!(we!=null&&we.includes("scheduledReports"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{We(),Ct(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"})]}),Ht==null?void 0:Ht.map(k=>t.jsxs(o.MenuItem,{dense:!0,disabled:k.disabled,onClick:()=>{k.onClick(),Ct(null)},sx:{py:1,px:2,gap:1.5},children:[k.icon,t.jsx(o.Typography,{variant:"body2",children:k.label})]},k.key))]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[or&&or.length>0&&et.size>0&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:k=>Pt(k).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:k=>k.typography.body2.fontWeight||600,mr:1},children:[et.size," selected"]}),t.jsx(o.Button,{size:"small",onClick:()=>lt==null?void 0:lt(),children:"Clear"}),or.map(k=>{var ne,ze;const F=Array.from(er);return(ne=k.hidden)!=null&&ne.call(k,F)?null:t.jsx(o.Button,{size:"small",variant:"outlined",startIcon:k.icon,disabled:(ze=k.disabled)==null?void 0:ze.call(k,F),onClick:()=>k.onClick(F),children:k.label},k.key)})]}),yr!=="list"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(zu,{data:Ue,visibleColumns:eo,grouping:f,selectedRowIds:er,isGrouped:!!no,onToggleGroupCollapse:N,onCardClick:(k,F)=>ko(k,F),onCardDoubleClick:k=>{rt!=null&&rt.includes("doubleClick")&&(pt(k),yt(!0))},onCardContextMenu:(k,F,ne)=>{H==null||H(k,F,ne),je(null),se({mouseX:ne.clientX,mouseY:ne.clientY,row:k,rowIndex:F}),rt!=null&&rt.includes("rightClick")&&(pt(k),yt(!0))},onOpenRowMenu:(k,F,ne)=>se({anchorEl:ne,row:k,rowIndex:F}),onToggleSelection:k=>qe==null?void 0:qe(k),hideSelectionCheckboxes:ke})}),yr==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:Qr,onScroll:k=>{wo.current&&(wo.current.scrollLeft=k.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(ro).reduce((k,F)=>k+F,0)}px`},children:[t.jsxs("colgroup",{children:[ar&&t.jsx("col",{style:{width:"40px"}}),lr.map(k=>t.jsx("col",{style:{width:`${ro[k.name]}px`}},k.name))]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(K==null?void 0:K.headerBg)??"action.hover",borderBottom:(K==null?void 0:K.rowDivider)??"1px solid",borderColor:"divider"},children:[ar&&t.jsx(o.TableCell,{padding:"checkbox",sx:{borderBottom:(K==null?void 0:K.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(K==null?void 0:K.cellAlignV)??"middle"},children:t.jsx(o.Checkbox,{size:"small",checked:Yo,indeterminate:io,onChange:k=>Dt==null?void 0:Dt(k.target.checked,Ue)})}),lr.map((k,F)=>t.jsx(xu,{column:k,index:F,sortRule:n.find(ne=>ne.column===k.name),hasFilters:li(i,k.name),isInSortStack:n.some(ne=>ne.column===k.name),isReadOnly:Ne,hasModifications:Gn,width:b[k.name],onColumnClick:Pn,onMoveColumn:Nn,onColumnDragEnd:Ln,onResizeStart:Wn,onSortAscending:E||Fn,onSortDescending:j||Vn,onRemoveSort:Hn,onOpenFilterForColumn:x||(()=>{}),onClearFiltersForColumn:oe||(()=>{}),onGroupByColumn:Me,onHideColumn:Un,onManageColumns:Z||(()=>{}),onResetLayout:me},k.name))]})})]})}),t.jsx(o.Box,{ref:wo,onScroll:k=>{Qr.current&&(Qr.current.scrollLeft=k.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:k=>$(k.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:k=>$(k.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(ro).reduce((k,F)=>k+F,0)}px`},children:[t.jsxs("colgroup",{children:[ar&&t.jsx("col",{style:{width:"40px"}}),lr.map(k=>t.jsx("col",{style:{width:`${ro[k.name]}px`}},k.name))]}),t.jsx(o.TableBody,{children:Ue.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:lr.length,align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):no?Ue.map((k,F)=>k.isGroupHeader?qn(k):Jo(k,F)):Ue.map((k,F)=>Jo(k,F))})]})})]}),Vt&&ct&&t.jsx(Bu,{currentPage:Lt,pageSize:Vr,totalRows:Ft,totalPages:_t,totalFields:e.length,selectedCount:et.size,onClearSelection:lt,onPageChange:Vt,onPageSizeChange:ct}),!(Vt&&ct)&&t.jsxs(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider",display:"flex",alignItems:"center",gap:1.5},children:[t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",Ue.length," ",Ue.length===1?"row":"rows"]}),et.size>0&&t.jsxs(t.Fragment,{children:[t.jsxs(o.Typography,{variant:"body2",sx:{color:"primary.main",fontWeight:600},children:["· ",et.size," selected"]}),lt&&t.jsx(o.Button,{size:"small",onClick:lt,sx:{fontSize:"0.75rem",p:0,minWidth:"auto",color:"text.secondary"},children:"Clear"})]})]})]})]}),t.jsxs(o.Popover,{open:!!Ce,onClose:()=>{se(null),je(null)},anchorEl:(Ce==null?void 0:Ce.anchorEl)||null,anchorReference:Ce!=null&&Ce.anchorEl?"anchorEl":"anchorPosition",anchorPosition:Ce&&!Ce.anchorEl?{top:Ce.mouseY,left:Ce.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:Ce!=null&&Ce.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(He!=null&&He.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(pt(Ce.row),yt(!0)),se(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!(He!=null&&He.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(Dr(Ce.row),$r(Ce.rowIndex),Er(!0)),se(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!(He!=null&&He.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(mr==null||mr(Ce.rowIndex,Ce.row)),se(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"})]}),Ce&&($t==null?void 0:$t.map(k=>{var F,ne;return(F=k.hidden)!=null&&F.call(k,Ce.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(ne=k.disabled)==null?void 0:ne.call(k,Ce.row),onClick:()=>{k.onClick(Ce.row,Ce.rowIndex),se(null)},sx:{py:1,px:2,gap:1.5},children:[k.icon,t.jsx(o.Typography,{variant:"body2",children:k.label})]},k.key)})),et.size>0&&tr&&!(He!=null&&He.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:k=>{Xe(),je(k.currentTarget)},onMouseLeave:ht,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between",flexWrap:"wrap"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(_.Download,{sx:{fontSize:k=>k.typography.body1.fontSize,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",et.size,")"]})]}),t.jsx(_.ChevronRight,{sx:{fontSize:k=>k.typography.body1.fontSize,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!fe,anchorEl:fe,placement:"right-start",transition:!0,sx:{zIndex:k=>k.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:k})=>t.jsx(o.Grow,{...k,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:Xe,onMouseLeave:ht,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"),je(null),se(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"),je(null),se(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"),je(null),se(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"})]}),Tr.export.allowedFormats.includes("pdf")&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{tr("pdf"),je(null),se(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.PictureAsPdf,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",children:"PDF"})]})]})})})})]}),!(He!=null&&He.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Ce&&(Jr(Ce.row),Ut(!0)),se(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(_u,{open:Br,onClose:()=>{yt(!1),pt(null)},row:Te,schema:e,reportName:Ur}),t.jsx(Ou,{open:Gt,onClose:()=>{Er(!1),Dr(null),$r(null)},onSave:k=>{_r!==null&&(hr==null||hr(_r,k))},row:Kr,schema:e,reportName:Ur}),t.jsx($u,{open:vo,onClose:()=>{Ut(!1),Jr(null)},onConfirm:()=>{Ir!==null&&(rr==null||rr(Ir))},row:Ir,schema:e}),t.jsx(ia,{isOpen:So,onClose:()=>Vo(!1),content:go,title:yo})]})}function ft({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 Pr={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it","24-hour format · Tab must be open for the schedule to fire","Opens your device's email app when the schedule fires. If you added email.","The data columns visible on the selected view will be send as a report"],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."}},ai=40;function Yu({operator:e,onSelect:r}){return t.jsxs(o.Select,{value:e,onChange:n=>r(n.target.value),size:"small",variant:"outlined",sx:{position:"relative",zIndex:1,mt:1,width:58,height:24,fontSize:"0.6875rem",fontWeight:700,color:"primary.main",bgcolor:"background.paper",borderRadius:"6px","& .MuiSelect-select":{py:0,px:1,display:"flex",alignItems:"center"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}},children:[t.jsx(o.MenuItem,{value:"and",sx:{fontSize:"0.75rem",fontWeight:600},children:"AND"}),t.jsx(o.MenuItem,{value:"or",sx:{fontSize:"0.75rem",fontWeight:600},children:"OR"})]})}function qu({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const a=r.find(u=>u.name===e.column),l=h.useMemo(()=>{const u=a?hn(a.type):[],g=i.filter.allowedOperators;return g.length>0?u.filter(b=>g.includes(b.value)):u},[a,i]),d=Ml(e.operator);return t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},children:[t.jsx(o.FormControl,{size:"small",sx:{minWidth:150,flex:"1 1 150px"},children:t.jsx(o.Select,{value:e.column,onChange:u=>{var f;const g=r.find(S=>S.name===u.target.value),b=g?hn(g.type):[];s({column:u.target.value,operator:((f=b[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(u=>t.jsx(o.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:ut(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:l.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),d&&(a==null?void 0:a.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:u=>s({value:u.target.value}),sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}}),d&&(a==null?void 0:a.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(a==null?void 0:a.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(a==null?void 0:a.type)==="number"?Number(u.target.value):u.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function ua({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:l,onChange:d}){const u=l>=a;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((g,b)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:ai,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[b<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),b>0&&t.jsx(Yu,{operator:e.operator,onSelect:f=>d(S=>bi(S,e.id,f))}),b>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:ai/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:b>0?1:0},children:Qe(g)?t.jsx(Ju,{group:g,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:l,onChange:d}):t.jsx(qu,{condition:g,schema:n,availableColumns:i,devConfig:s,onUpdate:f=>d(S=>yi(S,g.id,f))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>d(f=>vi(f,g.id)),sx:{mt:b>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx(_.Close,{sx:{fontSize:16}})})]},g.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${ai}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>d(g=>{var b,f,S;return fo(g,e.id,{id:mo(),column:((b=i[0])==null?void 0:b.name)??"",operator:((S=hn(((f=i[0])==null?void 0:f.type)??"string")[0])==null?void 0:S.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(o.Button,{size:"small",disabled:u,onClick:()=>d(g=>fo(g,e.id,Rt())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Ju(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>$(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(ua,{...e})})}function Ku({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[l,d]=h.useState(r??Rt()),u=Rr(),g=h.useMemo(()=>e.filter(w=>w.type!=="mixed"&&w.type!=="null"&&w.type!=="array"&&w.type!=="object"),[e]);h.useEffect(()=>{var x;const w=r??Rt();if(s&&w.children.length===0){const C=e.find(B=>B.name===s);if(C){d(fo(w,w.id,{id:mo(),column:s,operator:((x=hn(C.type)[0])==null?void 0:x.value)??"equals"}));return}}d(w)},[r,s,e]);const b=Tt(l),f=u.filter.maxConditions,S=h.useCallback(w=>{d(x=>w(x))},[]),y=h.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r??Rt()),[l,r]),E=h.useCallback(()=>{n(l),i()},[l,n,i]),j=h.useCallback(()=>{d(r??Rt()),i()},[r,i]),m=h.useCallback(()=>{n(Rt()),i()},[n,i]);return t.jsx(o.Box,{onClick:j,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=>nt(w),bgcolor:"background.paper",outline:"none",boxShadow:w=>he(w).paper.boxShadow,border:w=>he(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=>he(w).header.backgroundColor,borderBottom:w=>he(w).header.borderBottom,boxShadow:w=>he(w).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:w=>w.typography.h4.fontSize||"1.125rem",fontWeight:w=>w.typography.h4.fontWeight||500,color:w=>w.typography.h4.color||"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(ft,{content:Pr.filter,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[a&&t.jsx(o.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.Settings,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{onClick:j,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:[b===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 "${ut(s)}"`:"","."]}),t.jsx(ua,{group:l,depth:0,schema:e,availableColumns:g,devConfig:u,maxConditions:f,totalConditions:b,onChange:S}),b>=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.Tooltip,{title:"Removes all applied filters and closes this panel",arrow:!0,children:t.jsx("span",{children:t.jsx(o.Button,{onClick:m,disabled:b===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:j,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:E,disabled:!y,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 js="SORT_RULE";function Xu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const a=h.useRef(null),[{handlerId:l},d]=ur.useDrop({accept:js,collect(b){return{handlerId:b.getHandlerId()}},hover(b,f){var x;if(!a.current)return;const S=b.index,y=r;if(S===y)return;const E=(x=a.current)==null?void 0:x.getBoundingClientRect(),j=(E.bottom-E.top)/2,m=f.getClientOffset(),w=((m==null?void 0:m.y)??0)-E.top;S<y&&w<j||S>y&&w>j||(s(S,y),b.index=y)}}),[{isDragging:u},g]=ur.useDrag({type:js,item:()=>({index:r}),collect:b=>({isDragging:b.isDragging()})});return g(d(a)),t.jsxs(o.Box,{ref:a,"data-handler-id":l,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:b=>ye(b,"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:b=>`0 1px 2px 0 ${$(b.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:b=>b.typography.body2.fontSize||"0.875rem",fontWeight:b=>b.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:b=>n(r,b.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:b=>Bt(b),"&:hover":{bgcolor:b=>$(b.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:b=>Bt(b),"&:hover":{bgcolor:b=>$(b.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:b=>$(b.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx(_.Close,{sx:{fontSize:18}})})]})}function Qu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i,onOpenDevConfig:s}){const[a,l]=h.useState(""),[d,u]=h.useState([]);h.useEffect(()=>{u([...r])},[r]);const g=h.useMemo(()=>JSON.stringify(d)!==JSON.stringify(r),[d,r]),b=Rr(),f=h.useCallback(C=>{if(!C||d.length>=b.sort.maxLevels)return;const B={column:C,direction:"asc",priority:d.length+1};u([...d,B]),l(""),setTimeout(()=>{var p;return(p=document.activeElement)==null?void 0:p.blur()},0)},[d,b.sort.maxLevels]),S=h.useCallback(C=>{const p=d.filter((A,L)=>L!==C).map((A,L)=>({...A,priority:L+1}));u(p)},[d]),y=h.useCallback((C,B)=>{const p=[...d];p[C]={...p[C],direction:B},u(p)},[d]),E=h.useCallback((C,B)=>{const p=[...d],[A]=p.splice(C,1);p.splice(B,0,A);const L=p.map((I,Q)=>({...I,priority:Q+1}));u(L)},[d]),j=h.useCallback(()=>{n([]),i()},[n,i]),m=h.useCallback(()=>{n(d),i()},[d,n,i]),w=h.useCallback(()=>{u([...r]),l(""),i()},[r,i]),x=e.filter(C=>!d.some(B=>B.column===C.name));return t.jsx(ur.DndProvider,{backend:fi.HTML5Backend,children:t.jsx(o.Box,{onClick:w,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:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:C=>nt(C),bgcolor:"background.paper",outline:"none",boxShadow:C=>he(C).paper.boxShadow,border:C=>he(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=>he(C).header.backgroundColor,borderBottom:C=>he(C).header.borderBottom,boxShadow:C=>he(C).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:C=>C.typography.h4.fontSize||"1.125rem",fontWeight:C=>C.typography.h4.fontWeight||500,color:C=>C.typography.h4.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(ft,{content:Pr.sort,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.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:C=>$(C.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:C=>$(C.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:C=>C.typography.caption.fontSize||"0.6875rem",fontWeight:C=>C.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:d.length>=b.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:C=>f(C.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:x.map(C=>t.jsx(o.MenuItem,{value:C.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:B=>Bt(B),"&:hover":{bgcolor:B=>$(B.palette.primary.main,.2)}}},children:ut(C.name)},C.name))})]}),d.length>=b.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:C=>C.typography.caption.fontSize||"0.75rem",fontWeight:C=>C.typography.caption.fontWeight||500},children:["Maximum ",b.sort.maxLevels," sort levels allowed"]})]}),d.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:C=>C.typography.caption.fontSize||"0.6875rem",fontWeight:C=>C.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",d.length,"/",b.sort.maxLevels,")"]}),t.jsx(o.Tooltip,{title:"Removes all applied sorting and closes this panel",arrow:!0,children:t.jsx(o.Button,{onClick:j,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:d.map((C,B)=>t.jsx(Xu,{rule:C,index:B,onToggleDirection:y,onRemove:S,onMove:E},`${C.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:w,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:C=>`${C.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:m,variant:"contained",disabled:!g||d.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,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:"Apply sort"})]})]})})})}const nn=50;function ks({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:l=!1,atViewLimit:d=!1,maxViews:u=10}){const[g,b]=h.useState(s),[f,S]=h.useState(!1),[y,E]=h.useState(a),[j,m]=h.useState(l),w=()=>{if(!g.trim()){S(!0);return}if(g.trim().length>nn){S(!0);return}r(g.trim(),y.trim(),j),n()},x=B=>{B.key==="Enter"&&!B.shiftKey?w():B.key==="Escape"&&n()},C=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:B=>({mt:8,borderRadius:nt(B),...he(B).paper})},children:[t.jsxs(o.DialogTitle,{sx:B=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,fontSize:B.typography.h4.fontSize||"1.125rem",fontWeight:B.typography.h4.fontWeight||500,...he(B).header}),children:[C(),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:[d&&!i&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px"},children:["You have reached the maximum of ",u," saved views. Delete an existing view before creating a new one."]}),t.jsx(o.TextField,{label:"View Name",required:!0,value:g,onChange:B=>{B.target.value.length<=nn&&b(B.target.value),f&&B.target.value.trim()&&S(!1)},onKeyDown:x,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:d&&!i,inputProps:{maxLength:nn},error:f&&!g.trim(),helperText:f&&!g.trim()?"View name is required":`${g.length} / ${nn}`}),t.jsx(o.TextField,{label:"Description (optional)",value:y,onChange:B=>E(B.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:B=>B.typography.body2.fontWeight||500,mb:1},children:"This view will capture:"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[t.jsxs("li",{children:[Tt(e.filters)," filter",Tt(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",el(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:j,onChange:B=>m(B.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:B=>`${B.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:d&&!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:B=>`${B.shape.borderRadius}px`,boxShadow:B=>ye(B,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:B=>ye(B,"hoverButton")},"&:active":{boxShadow:B=>ye(B,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function Zu({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:nt(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",...he(i).paper})},children:[t.jsxs(o.DialogTitle,{sx:i=>({display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,fontSize:i.typography.h4.fontSize||"1.125rem",fontWeight:i.typography.h4.fontWeight||500,...he(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 ep=[{label:"All",value:"all"},{label:"Visible",value:"active"},{label:"Hidden",value:"hidden"}],zs="COLUMN";function tp({column:e,index:r,isVisible:n,width:i,minColumnWidth:s,maxColumnWidth:a,canToggleOn:l,onToggleVisibility:d,onWidthChange:u,moveColumn:g}){const b=h.useRef(null),[f,S]=h.useState(i.toString());h.useEffect(()=>{S(i.toString())},[i]);const[{handlerId:y},E]=ur.useDrop({accept:zs,collect(p){return{handlerId:p.getHandlerId()}},hover(p,A){var O;if(!b.current)return;const L=p.index,I=r;if(L===I)return;const Q=(O=b.current)==null?void 0:O.getBoundingClientRect(),ee=(Q.bottom-Q.top)/2,W=A.getClientOffset(),v=((W==null?void 0:W.y)??0)-Q.top;L<I&&v<ee||L>I&&v>ee||(g(L,I),p.index=I)}}),[{isDragging:j},m]=ur.useDrag({type:zs,item:()=>({index:r}),collect:p=>({isDragging:p.isDragging()})});m(E(b));const w=()=>{const p=parseInt(f);if(isNaN(p)){S(i.toString()),u(e.name,i);return}const A=Math.max(s,Math.min(a,p));S(A.toString()),u(e.name,A)},x=p=>{if(p===""||/^\d+$/.test(p)){S(p);const A=parseInt(p);if(!isNaN(A)&&A>=s){const L=Math.min(a,A);u(e.name,L)}}},C=p=>{p.key==="Enter"&&(p.preventDefault(),w(),p.target.blur())},B=p=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[p]||"text.secondary";return t.jsxs(o.TableRow,{ref:b,"data-handler-id":y,sx:{opacity:j?.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:p=>`1px solid ${p.palette.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:p=>p.typography.body2.fontWeight||400,fontSize:p=>p.typography.body2.fontSize||"0.875rem",color:n?"text.primary":"text.secondary"},children:ut(e.name)})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsx(o.Chip,{label:e.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${B(e.type)}15`,color:B(e.type),border:`1px solid ${B(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:f,onChange:p=>x(p.target.value),onBlur:w,onKeyDown:C,placeholder:"150",size:"small",inputProps:{min:s,max:a,step:10},sx:{width:90,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"},"& input[type=number]::-webkit-inner-spin-button":{opacity:1},"& input[type=number]::-webkit-outer-spin-button":{opacity:1}}}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:p=>p.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:()=>d(e.name,!n),disabled:!n&&!l,title:n?"Hide column":l?"Show column":"Max visible columns reached",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover:not(:disabled)":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"},"&:disabled":{opacity:.5,cursor:"not-allowed"}},children:n?t.jsx(_.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?p=>$(p.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function rp({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:l,onUpdateColumnOrder:d,onUpdateColumnWidth:u,onResetLayout:g,onClose:b}){const f=Rr(),[S,y]=h.useState(!1),[E,j]=h.useState(n),[m,w]=h.useState(i),[x,C]=h.useState("all");h.useEffect(()=>{j(n)},[n]),h.useEffect(()=>{w(i)},[i]);const B=(O,z)=>{w(q=>({...q,[O]:z})),u==null||u(O,z)},p=(O,z)=>{const q=[...E],[Y]=q.splice(O,1);q.splice(z,0,Y),j(q),d(q)},A=()=>{g(),y(!1)},I=E.map(O=>e.find(z=>z.name===O)).filter(O=>O!==void 0).filter(O=>{const z=r[O.name]??!0;return x==="active"?z:x==="hidden"?!z:!0}),Q=Object.values(r).filter(O=>O).length,ee=e.length,W=s.find(O=>O.id===a),v=h.useMemo(()=>{if(!W)return!1;const O=W.snapshot,z=O.columnVisibility??{},q=JSON.stringify(r)!==JSON.stringify(z),Y=O.columnOrder??[],c=n??[],re=JSON.stringify(c)!==JSON.stringify(Y)&&!(c.length===0&&Y.length===0),ae=O.columnWidths??{},G=JSON.stringify(m)!==JSON.stringify(ae);return q||re||G},[W,r,n,m]);return t.jsx(ur.DndProvider,{backend:fi.HTML5Backend,children:t.jsx(o.Box,{onClick:b,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:O=>$(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:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:O=>nt(O),bgcolor:"background.paper",outline:"none",boxShadow:O=>he(O).paper.boxShadow,border:O=>he(O).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"translateY(-12px)"},to:{opacity:1,transform:"translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2,pb:0,flexShrink:0,bgcolor:O=>he(O).header.backgroundColor,borderBottom:O=>he(O).header.borderBottom,boxShadow:O=>he(O).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:O=>O.typography.h4.fontSize||"1.125rem",fontWeight:O=>O.typography.h4.fontWeight||500,color:O=>O.typography.h4.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage columns"}),t.jsx(ft,{content:Pr.columns,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:b,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Tabs,{value:x,onChange:(O,z)=>C(z),sx:{minHeight:32,mt:1.5,ml:-2,"& .MuiTabs-indicator":{bgcolor:O=>Pt(O).main,height:2}},children:ep.map(({label:O,value:z})=>t.jsx(o.Tab,{label:O,value:z,sx:{minHeight:32,py:.5,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"text.primary",fontWeight:600},"&:hover":{color:"text.primary"}}},z))})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:O=>$(O.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:O=>$(O.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{stickyHeader:!0,sx:{minWidth:650},children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"0.6875rem",color:"text.secondary",bgcolor:"background.paper",letterSpacing:"0.1em",py:1.5,px:2.5,borderBottom:O=>`1px solid ${O.palette.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:O=>`1px solid ${O.palette.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:O=>`1px solid ${O.palette.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: ${f.columns.minColumnWidth}px, max: ${f.columns.maxColumnWidth}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:O=>`1px solid ${O.palette.divider}`},children:"Visibility"})]})}),t.jsx(o.TableBody,{children:I.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:O=>O.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):I.map((O,z)=>{const q=r[O.name]??!0,Y=q||Q<f.columns.maxVisible;return t.jsx(tp,{column:O,index:z,isVisible:q,width:m[O.name]||170,minColumnWidth:f.columns.minColumnWidth,maxColumnWidth:f.columns.maxColumnWidth,canToggleOn:Y,onToggleVisibility:l,onWidthChange:B,moveColumn:p},O.name)})})]})}),t.jsx(o.Box,{sx:{px:3,py:1,borderTop:O=>`1px solid ${O.palette.divider}`,bgcolor:"background.default",flexShrink:0},children:t.jsxs(o.Typography,{variant:"body2",sx:{fontSize:O=>O.typography.body2.fontSize||"0.8125rem",color:"text.secondary"},children:[Q," of ",ee," columns visible • Drag to reorder"]})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:O=>`1px solid ${O.palette.divider}`,display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:t.jsx(o.Button,{onClick:()=>y(!0),disabled:!v,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:O=>`${O.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),S&&t.jsx(o.Box,{onClick:()=>y(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:O=>$(O.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:O=>O.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:O=>O.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:O=>Fo(O),bgcolor:"background.paper",boxShadow:O=>he(O).paper.boxShadow,border:O=>he(O).paper.border},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:O=>O.typography.h4.fontSize||"1rem",fontWeight:O=>O.typography.h4.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:O=>`1px solid ${O.palette.divider}`,display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:()=>y(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:O=>`${O.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:A,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:O=>`${O.shape.borderRadius}px`,boxShadow:O=>ye(O,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:O=>ye(O,"hoverButton")},"&:active":{boxShadow:O=>ye(O,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function op({schema:e,grouping:r,onApply:n,onClose:i,onOpenDevConfig:s}){var L;const[a,l]=h.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[d,u]=h.useState(""),[g,b]=h.useState(null),f=h.useMemo(()=>qa(e),[e]),S=h.useMemo(()=>f.filter(I=>!a.levels.some((Q,ee)=>Q.column===I.name&&ee!==g)),[f,a.levels,g]),y=Rr(),E=a.levels.length<y.grouping.maxLevels&&S.length>0&&(y.grouping.allowNested||a.levels.length===0),j=h.useCallback(I=>{!E||!I||(l({...a,levels:[...a.levels,{column:I}],enabled:!0}),u(""),setTimeout(()=>{var Q;return(Q=document.activeElement)==null?void 0:Q.blur()},0))},[E,a]),m=h.useCallback(I=>{const Q=a.levels.filter((ee,W)=>W!==I);if(Q.length===0){n(null),i();return}l({...a,levels:Q,enabled:Q.length>0})},[a,n,i]),w=h.useCallback(I=>{b(I),u(a.levels[I].column)},[a.levels]),x=h.useCallback(()=>{if(g===null||!d)return;const I=[...a.levels];I[g]={column:d},l({...a,levels:I}),b(null),u("")},[g,d,a]),C=h.useCallback(()=>{b(null),u("")},[]),B=h.useCallback((I,Q)=>{const ee=Q==="up"?I-1:I+1;if(ee<0||ee>=a.levels.length)return;const W=[...a.levels],[v]=W.splice(I,1);W.splice(ee,0,v),l({...a,levels:W})},[a]),p=h.useCallback(()=>{n(null),i()},[n,i]),A=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:I=>$(I.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:I=>I.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:I=>I.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:I=>nt(I),bgcolor:"background.paper",outline:"none",boxShadow:I=>he(I).paper.boxShadow,border:I=>he(I).paper.border,overflow:"hidden",animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,bgcolor:I=>he(I).header.backgroundColor,borderBottom:I=>he(I).header.borderBottom,boxShadow:I=>he(I).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:I=>I.typography.h4.fontSize||"1.125rem",fontWeight:I=>I.typography.h4.fontWeight||500,color:I=>I.typography.h4.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(ft,{content:Pr.grouping,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[s&&t.jsx(o.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.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:I=>$(I.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:I=>$(I.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[g===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:I=>I.typography.caption.fontSize||"0.6875rem",fontWeight:I=>I.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:d,onChange:I=>j(I.target.value),disabled:!E,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),S.map(I=>t.jsxs(o.MenuItem,{value:I.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:Q=>Bt(Q),"&:hover":{bgcolor:Q=>$(Q.palette.primary.main,.2)}}},children:[ut(I.name)," (",I.type.toUpperCase(),")"]},I.name))]})}),a.levels.length>=y.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:I=>I.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),f.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:I=>I.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),g!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:I=>`1px solid ${$(I.palette.warning.main,.5)}`,bgcolor:I=>$(I.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:I=>I.typography.body2.fontWeight||500,mb:1.5,fontSize:I=>I.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",g+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:d,onChange:I=>u(I.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:a.levels[g].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:I=>Bt(I)}},children:[a.levels[g].column," (",(L=e.find(I=>I.name===a.levels[g].column))==null?void 0:L.type.toUpperCase(),")"]}),S.filter(I=>I.name!==a.levels[g].column).map(I=>t.jsxs(o.MenuItem,{value:I.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:Q=>Bt(Q)}},children:[ut(I.name)," (",I.type.toUpperCase(),")"]},I.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:x,disabled:!d,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:I=>ye(I,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:C,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&&g===null&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:I=>I.typography.caption.fontSize||"0.6875rem",fontWeight:I=>I.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Tooltip,{title:"Removes all applied grouping and closes this panel",arrow:!0,children:t.jsx(o.Button,{onClick:p,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})})]}),t.jsx(o.Stack,{spacing:1.5,children:a.levels.map((I,Q)=>{const ee=e.find(W=>W.name===I.column);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:W=>ye(W,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${Q+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:W=>`0 1px 2px 0 ${$(W.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:W=>W.typography.body2.fontWeight||500,fontSize:W=>W.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:I.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:W=>W.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:ee==null?void 0:ee.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>B(Q,"up"),disabled:Q===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(Q,"down"),disabled:Q===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(Q),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:()=>m(Q),sx:{color:"text.secondary","&:hover":{bgcolor:W=>$(W.palette.error.main,.08),color:"error.main"}},children:t.jsx(_.Delete,{sx:{fontSize:18}})})]})]},Q)})})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:A,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,boxShadow:I=>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)"}},children:"Apply grouping"})]})]})})}function np({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:i=>i.typography.body1.fontSize}}),size:"small",children:"Export Anyway"})]})]})})}const Ts=[{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 ip(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 sp(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function ap({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=xt(),s=i.palette,[a,l]=h.useState("1h"),[d,u]=h.useState(!1),[g,b]=h.useState("all"),[f,S]=h.useState(!0),[y,E]=h.useState(!1),[j,m]=h.useState(!1),w=[...e].sort((W,v)=>{const O=new Date(W.timestamp).getTime()-new Date(v.timestamp).getTime();return y?O:-O}),x=w.reduce((W,v)=>(W[v.feature]=(W[v.feature]??0)+1,W),{}),C=Object.keys(x).sort((W,v)=>(x[v]??0)-(x[W]??0)),B=g==="all"?w:w.filter(W=>W.feature===g),p=Ts.find(W=>W.key===a),A=ip(e,p.ms),L=()=>u(!0),I=()=>{n&&(n(sp(e,p.ms)),u(!1))},Q=W=>{const v=Ss(i,W.feature),{summary:O,detail:z}=hl(W);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transition:"border-color 0.15s","&:hover":{borderColor:$(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:Qn(W.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:$(v,.1),color:v,border:`1px solid ${$(v,.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:O}),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:xl(W.timestamp)})]}),W.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:W.user})]})]})]})]},W.id)},ee=j?C.map(W=>({feature:W,events:B.filter(v=>v.feature===W)})).filter(W=>W.events.length>0):[];return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:$(s.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:W=>W.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:nt(i),bgcolor:"background.paper",overflow:"hidden",...he(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,...he(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:W=>W.typography.body1.fontSize||"0.9375rem",fontWeight:W=>W.typography.h6.fontWeight||600,color:"text.primary"},children:"Audit History"}),t.jsx(ft,{content:Pr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:W=>W.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.125},children:[B.length," event",B.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:W=>l(W.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:Ts.map(W=>t.jsx(o.MenuItem,{value:W.key,sx:{fontSize:"0.8125rem"},children:W.label},W.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(_.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:L,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"})]}),C.length>1&&t.jsx(o.IconButton,{onClick:()=>S(W=>!W),size:"small",title:f?"Hide category filter":"Show category filter",sx:{color:f?"primary.main":"text.secondary",bgcolor:f?$(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:f?$(s.primary.main,.16):"action.hover"}},children:t.jsx(_.FilterAltOutlined,{sx:{fontSize:17}})}),t.jsx(o.IconButton,{onClick:()=>E(W=>!W),size:"small",title:y?"Sorted oldest first":"Sorted newest first",sx:{color:y?"primary.main":"text.secondary",bgcolor:y?$(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:y?$(s.primary.main,.16):"action.hover"}},children:t.jsx(_.SortOutlined,{sx:{fontSize:17,transform:y?"scaleY(-1)":"none"}})}),t.jsx(o.IconButton,{onClick:()=>m(W=>!W),size:"small",title:j?"Ungroup events":"Group by category",sx:{color:j?"primary.main":"text.secondary",bgcolor:j?$(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:j?$(s.primary.main,.16):"action.hover"}},children:t.jsx(_.WorkspacesOutlined,{sx:{fontSize:17}})}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.Close,{sx:{fontSize:17}})})]})]}),C.length>1&&f&&t.jsxs(o.Tabs,{value:g,onChange:(W,v)=>b(v),variant:"scrollable",scrollButtons:"auto",sx:{minHeight:36,flexShrink:0,borderBottom:"1px solid",borderColor:"divider",px:1.5,"& .MuiTabs-indicator":{height:2}},children:[t.jsx(o.Tab,{value:"all",label:`All (${w.length})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}}),C.map(W=>t.jsx(o.Tab,{value:W,label:`${Qn(W)} (${x[W]})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}},W))]}),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:B.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:W=>W.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:W=>W.typography.body2.fontWeight||500},children:w.length===0?"No audit events yet":"No events in this category"}),t.jsx(o.Typography,{sx:{fontSize:W=>W.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:w.length===0?"Changes to this report will appear here":"Try a different category tab"})]}):j?t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:ee.map(({feature:W,events:v})=>t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75,px:.25},children:[t.jsx(o.Box,{sx:{width:6,height:6,borderRadius:"50%",bgcolor:Ss(i,W)}}),t.jsxs(o.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"text.secondary"},children:[Qn(W)," (",v.length,")"]})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:v.map(Q)})]},W))}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:B.map(Q)})})]})}),t.jsxs(o.Dialog,{open:d,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Fo(i),...he(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:W=>W.typography.body1.fontSize||"0.9375rem",fontWeight:W=>W.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:W=>W.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:[A," audit record",A!==1?"s":""]})," ",p.key==="all"?"from all time":`from the ${p.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:I,variant:"contained",color:"error",startIcon:t.jsx(_.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",A," Record",A!==1?"s":""]})]})]})]})}function lp({onSave:e,onClose:r}){const[n,i]=h.useState(""),[s,a]=h.useState(""),[l,d]=h.useState(""),[u,g]=h.useState([]),[b,f]=h.useState(""),[S,y]=h.useState(""),E=p=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p),j=()=>{const p=l.trim();if(p){if(!E(p)){y("Please enter a valid email address");return}if(u.includes(p)){y("This email is already added");return}g([...u,p]),d(""),y("")}},m=p=>{g(u.filter(A=>A!==p))},w=p=>{p.key==="Enter"&&(p.preventDefault(),j())},x=()=>{if(!n.trim()){f("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},C=p=>{i(p),b&&f("")},B=p=>{d(p),S&&y("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:p=>$(p.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:p=>p.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:p=>p.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:p=>nt(p),bgcolor:"background.paper",outline:"none",boxShadow:p=>he(p).paper.boxShadow,border:p=>he(p).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:p=>he(p).header.backgroundColor,borderBottom:p=>he(p).header.borderBottom,boxShadow:p=>he(p).header.boxShadow,flexShrink:0},children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:p=>p.typography.h4.fontSize||"1.125rem",fontWeight:p=>p.typography.h4.fontWeight||500,color:p=>p.typography.h4.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:p=>$(p.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:p=>$(p.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:p=>`1px solid ${$(p.palette.primary.main,.3)}`,bgcolor:p=>Bt(p),"& .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:p=>p.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:p=>p.typography.caption.fontSize||"0.6875rem",fontWeight:p=>p.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:p=>C(p.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!b,helperText:b,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:p=>p.typography.caption.fontSize||"0.6875rem",fontWeight:p=>p.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:p=>a(p.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:p=>p.typography.caption.fontSize||"0.6875rem",fontWeight:p=>p.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:l,onChange:p=>B(p.target.value),onKeyPress:w,placeholder:"Enter email address",error:!!S,helperText:S,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:j,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:p=>`${p.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(p=>t.jsx(o.Chip,{label:p,onDelete:()=>m(p),deleteIcon:t.jsx(_.Delete,{sx:{fontSize:16}}),sx:{bgcolor:A=>Bt(A),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},p))}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children:u.length>0?`An email with the shareable link will be sent to ${u.length} recipient${u.length>1?"s":""}`:"Add email addresses to send the shareable link automatically"})]})]})}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:p=>`${p.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:x,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:p=>`${p.shape.borderRadius}px`,boxShadow:p=>ye(p,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:p=>ye(p,"hoverButton")},"&:active":{boxShadow:p=>ye(p,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function cp({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 dp({presets:e,reportId:r,onOpenPreset:n,onDeletePreset:i,onClose:s}){const a=l=>new Date(l).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:l=>$(l.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:l=>l.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:l=>l.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:l=>nt(l),bgcolor:"background.paper",outline:"none",boxShadow:l=>he(l).paper.boxShadow,border:l=>he(l).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:l=>he(l).header.backgroundColor,borderBottom:l=>he(l).header.borderBottom,boxShadow:l=>he(l).header.boxShadow,flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h4",sx:{fontSize:l=>l.typography.h4.fontSize||"1.125rem",fontWeight:l=>l.typography.h4.fontWeight||500,color:l=>l.typography.h4.color||"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:l=>l.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:l=>$(l.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:l=>l.typography.body2.fontSize||"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:l=>l.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(l=>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:d=>ye(d,"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:d=>d.typography.body1.fontSize||"0.9375rem",fontWeight:d=>d.typography.h6.fontWeight||500,color:"text.primary",mb:.5},children:l.name}),l.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:d=>d.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.5},children:l.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${a(l.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 ${l.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(l.id,l.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:d=>`${d.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:d=>$(d.palette.error.main,.04)}},children:"Delete"})})]},l.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:l=>`${l.shape.borderRadius}px`,boxShadow:l=>ye(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:l=>ye(l,"hoverButton")},"&:active":{boxShadow:l=>ye(l,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const pa={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},up=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],pp=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function hp(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=pp.some(d=>d.test(i.name));let a=!1;const l=r.slice(0,10).map(d=>d[i.name]).filter(d=>typeof d=="string"&&d.length>0);l.length>0&&(a=l.filter(u=>up.some(g=>g.test(u))).length/l.length>.6),(s||a)&&n.push(i.name)}return n}function On(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(l=>{const d=n.map(g=>String(g[l]??"")).filter(g=>g.length>0);if(d.length===0)return 5;const u=d.reduce((g,b)=>g+b.length,0);return Math.ceil(u/d.length)+1}).reduce((l,d)=>l+d,0)+1;return r.reduce((l,d)=>l+d.length+1,0)+s*e.length}function mp(e,r){const n=On(e,r);return Math.ceil(n*3.5)}function fp(e,r){const n=On(e,r);return Math.ceil(n*.7)}function xp(e,r){const n=On(e,r);return Math.ceil(n*2)}function gp(e,r,n){switch(e){case"csv":return On(r,n);case"excel":return fp(r,n);case"json":return mp(r,n);case"pdf":return xp(r,n)}}function Bs(e,r){return Math.ceil(e/r)}function yp(e,r,n,i,s=pa){const a=[],l=gp(e,r,n),d=r.length;if(d>s.maxRowsHard){const b=Bs(d,s.maxRows);a.push({type:"row_count",severity:"error",message:`Export blocked: ${d.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${b} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:b,value:d,limit:s.maxRowsHard})}else if(d>s.maxRows){const b=Bs(d,s.maxRows);a.push({type:"row_count",severity:"warning",message:`Large export: ${d.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${b} smaller export${b>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:b,value:d,limit:s.maxRows})}if(l>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${Oo(l)} exceeds the ${Oo(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:l,limit:s.maxFileSizeHardBytes}):l>s.maxFileSizeBytes&&a.push({type:"file_size",severity:"warning",message:`Large file: estimated ${Oo(l)}`,detail:`This exceeds the recommended ${Oo(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:l,limit:s.maxFileSizeBytes}),e!=="excel"){const b=hp(i.filter(f=>n.includes(f.name)),r);if(b.length>0){const f=b.length>s.maxImageColumns;a.push({type:"image_columns",severity:f?"error":"warning",message:`Image column${b.length>1?"s":""} detected: ${b.map(S=>`"${S.replace(/_/g," ")}"`).join(", ")}`,detail:f?`Exporting ${b.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:b.length,limit:s.maxImageColumns})}}const u=a.some(b=>b.severity==="error"),g=a.some(b=>b.severity==="warning");return{violations:a,hasBlockingViolation:u,hasWarning:g,estimatedBytes:l}}function Oo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function bp({violation:e}){const n=xt().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,a=$(i?n.error.main:n.warning.main,.06),l=i?$(n.error.main,.25):$(n.warning.main,.3),d=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:l},children:[t.jsx(d,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.body2.fontSize||"0.8125rem",fontWeight:u=>u.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:e.detail}),e.suggestedBatches&&e.suggestedBatches>1&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[t.jsx(_.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:u=>u.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function vp({format:e}){const r=xt(),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 Is({checked:e}){const r=xt();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 Sp({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:l=[],allRows:d=[],processedRows:u=[],initialFormat:g,initialScope:b="visible",initialColumnScope:f="visible",classTokens:S={},onExport:y,onClose:E}){const j=xt(),m=j.palette,w=Rr(),x=h.useMemo(()=>{var ue,le,Z,de,ie;const c=((Z=(le=(ue=j.components)==null?void 0:ue.MuiCard)==null?void 0:le.styleOverrides)==null?void 0:Z.root)||{},re=c.border&&c.border!=="none"?c.border:(de=j.tokens)!=null&&de.cardBodyBorder&&j.tokens.cardBodyBorder!=="none"?j.tokens.cardBodyBorder:m.divider,ae=c.borderRadius!==void 0?typeof c.borderRadius=="number"?`${c.borderRadius}px`:c.borderRadius:`${j.shape.borderRadius}px`,G=c.boxShadow&&c.boxShadow!=="none"?c.boxShadow:((ie=j.tokens)==null?void 0:ie.cardBodyShadow)||ye(j,"menu"),te=Pt(j);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:ae,cardShadow:G,cardHoverBg:`var(--urm-export-card-hover-bg, ${m.mode==="dark"?$(m.common.white,.08):$(m.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${$(te.main,m.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${te.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, ${j.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${j.spacing(1.5)})`}},[m,j]),C=g||(w.export.allowedFormats.includes("pdf")?"pdf":w.export.allowedFormats[0]||"csv"),[B,p]=h.useState(C),[A,L]=h.useState(b),[I,Q]=h.useState(f),ee=A==="visible"?r:e,W=I==="visible"?i:s,v=h.useMemo(()=>A==="visible"?u.length>0?u:new Array(r):d.length>0?d:new Array(e),[A,r,e,u,d]),O=h.useMemo(()=>I==="all"?a.map(c=>c.name):a.map(c=>c.name).slice(0,i),[I,a,i]),z=h.useMemo(()=>yp(B,v,O,a,pa),[B,v,O,a]),q=()=>{z.hasBlockingViolation||(y({format:B,scope:A,columnScope:I}),E())},Y={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(o.Box,{onClick:E,className:`urm-export-backdrop ${S.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:$(m.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:j.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:c=>c.stopPropagation(),elevation:0,className:`urm-export-paper ${S.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:nt(j),bgcolor:x.sectionTitleBg,overflow:"hidden",border:`1px solid ${x.cardBorder}`,boxShadow:x.cardShadow,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{className:`urm-export-header ${S.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0,bgcolor:c=>he(c).header.backgroundColor,borderBottom:c=>he(c).header.borderBottom,boxShadow:c=>he(c).header.boxShadow},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"h4",className:`urm-export-title ${S.modalTitle||""}`,sx:{fontSize:c=>c.typography.h4.fontSize||"1.125rem",fontWeight:c=>c.typography.h4.fontWeight||700,color:m.text.primary},children:"Export Report"}),t.jsx(ft,{content:Pr.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:E,size:"small",className:`urm-export-close ${S.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 ${S.modalContent||""}`,sx:{flex:1,overflowY:"auto",px:3,pb:2.5,pt:.5,display:"flex",flexDirection:"column",gap:x.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:$(m.text.primary,.15),borderRadius:3}},children:[z.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:z.violations.map((c,re)=>t.jsx(bp,{violation:c},re))}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:x.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(c=>c.allowed).map(c=>{const re=B===c.id;return t.jsxs(o.Box,{onClick:()=>p(c.id),className:`urm-export-format-card ${re?S.formatCardSelected||"":S.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:x.cardRadius,border:re?`2px solid ${x.cardSelectedBorder}`:`1px solid ${x.cardBorder}`,boxShadow:re?void 0:x.cardShadow,bgcolor:re?x.cardSelectedBg:x.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?x.cardSelectedBorder:$(m.text.primary,.25),bgcolor:re?x.cardSelectedBg:x.cardHoverBg}},children:[re&&t.jsx(o.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:x.cardSelectedBorder,color:m.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${$(m.primary.main,.3)}`},children:t.jsx(_.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(vp,{format:c.id}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:re?x.cardSelectedColor:m.text.primary},children:c.title}),t.jsx(o.Tooltip,{title:c.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ae=>ae.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:13}})})})]})]},c.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:x.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(c=>{const re=A===c.value;return t.jsxs(o.Box,{onClick:()=>L(c.value),className:`urm-export-row-card ${re?S.rowCardSelected||"":S.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:x.cardRadius,border:re?`2px solid ${x.cardSelectedBorder}`:`1px solid ${x.cardBorder}`,boxShadow:re?void 0:x.cardShadow,bgcolor:re?x.cardSelectedBg:x.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?x.cardSelectedBorder:$(m.text.primary,.25),bgcolor:re?x.cardSelectedBg:x.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(Is,{checked:re}),t.jsx(o.Box,{sx:{color:re?x.cardSelectedColor:m.text.secondary,display:"flex"},children:c.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?x.cardSelectedColor:m.text.primary},children:c.label})]}),t.jsx(o.Tooltip,{title:c.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ae=>ae.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:16}})})})]},c.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:x.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(c=>{const re=I===c.value;return t.jsxs(o.Box,{onClick:()=>Q(c.value),className:`urm-export-column-card ${re?S.columnCardSelected||"":S.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:x.cardRadius,border:re?`2px solid ${x.cardSelectedBorder}`:`1px solid ${x.cardBorder}`,boxShadow:re?void 0:x.cardShadow,bgcolor:re?x.cardSelectedBg:x.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?x.cardSelectedBorder:$(m.text.primary,.25),bgcolor:re?x.cardSelectedBg:x.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(Is,{checked:re}),t.jsx(o.Box,{sx:{color:re?x.cardSelectedColor:m.text.secondary,display:"flex"},children:c.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?x.cardSelectedColor:m.text.primary},children:c.label})]}),t.jsx(o.Tooltip,{title:c.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:ae=>ae.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:16}})})})]},c.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${S.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${x.sectionBorder}`,borderRadius:"12px",p:x.sectionPadding,pt:2.25,bgcolor:x.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:x.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:x.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:Y[B]},{icon:t.jsx(_.FormatListNumberedOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Rows to Export",value:ee.toLocaleString()},{icon:t.jsx(_.SwapVertOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Columns to Export",value:String(W)},{icon:t.jsx(_.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Estimated File Size",value:`~${Oo(z.estimatedBytes)}`,highlight:z.hasBlockingViolation?"error.main":z.hasWarning?"warning.main":void 0}].map(({icon:c,label:re,value:ae,highlight:G})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${S.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[c,t.jsx(o.Typography,{className:`urm-export-summary-label ${S.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:m.text.secondary,fontWeight:500},children:re})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${S.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:G??m.text.primary},children:ae})]},re))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${S.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",flexWrap:"wrap",gap:1.5,flexShrink:0},children:[z.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:c=>c.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:c=>c.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:E,variant:"outlined",className:`urm-export-cancel-btn ${S.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:m.text.primary,borderColor:x.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:x.cardHoverBg,borderColor:$(m.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:q,disabled:z.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${S.downloadButton||""}`,startIcon:t.jsx(_.Download,{sx:{fontSize:c=>c.typography.body1.fontSize}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:x.primaryBtnBg,color:x.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${$(m.primary.main,.25)}`,"&:hover":{bgcolor:x.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:$(m.primary.main,.4),color:x.primaryBtnColor}},children:["Download ",Y[B]]})]})]})})}function wp({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 Cp({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=3e4}){h.useEffect(()=>{if(n){const d=setTimeout(()=>{r()},i);return()=>clearTimeout(d)}},[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}})}}})(),l=Tl(e);return t.jsx(o.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx(_.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${a.severity}.main`,boxShadow:3},children:[t.jsxs(o.AlertTitle,{sx:{fontWeight:d=>d.typography.h6.fontWeight||600,fontSize:d=>d.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:l}),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 jp extends h.Component{constructor(n){super(n);_i(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){Qt.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:"h4",sx:{color:"error.main",fontWeight:s=>s.typography.h4.fontWeight||600,fontSize:s=>s.typography.h4.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 kp({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 sn({children:e,feature:r,onError:n}){return t.jsx(jp,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(kp,{feature:r}),children:e})}const zp=[{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"}],Tp=[{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"}],Ar={sortMaxLevels:{title:"Maximum Sort Levels",description:"Limits the number of columns users can sort by simultaneously. Restricts multi-level sort depth.",tips:['"Add sort column" button is disabled at this limit',"Prevents adding more sort levels to the active sort stack","Default: 5 levels (range: 1–10)"]},filterMaxConditions:{title:"Maximum Filter Conditions",description:"Limits the total number of active filter conditions users can apply at once.",tips:['"Add condition" button is disabled at this limit',"Prevents performance degradation on large datasets","Default: 3 conditions (range: 1–20)"]},filterAllowedOperators:{title:"Allowed Filter Operators",description:"Controls which comparison operators appear in the filter UI. Unchecked operators are hidden from all dropdowns.",tips:["Simplifies the UI by hiding advanced operators your users don't need","At least one operator per data type must remain checked","Operators grouped by type: Text, Numeric, Boolean, Null checks"]},columnsMaxVisible:{title:"Maximum Visible Columns",description:"Limits the number of columns users can display at once in the data table.",tips:["Column visibility toggle is disabled when this limit is reached","Forces users to be selective about which columns to show","Default: 20 columns (range: 1–50)"]},columnsWidthRange:{title:"Column Width Constraints",description:"Sets minimum and maximum pixel widths for column resizing. Prevents columns from becoming too narrow or too wide.",tips:["Users cannot drag column borders outside this range","Min default: 60px, Max default: 800px","Ensures readable content and consistent layout"]},exportAllowedFormats:{title:"Allowed Export Formats",description:"Determines which export formats appear in the Export dialog and row-level export menus. At least one must be enabled.",tips:["Disabled formats don't appear in any export UI","PDF is now available as a print-ready export option","Unchecked formats are completely hidden from end users"]},groupingMaxLevels:{title:"Maximum Group Levels",description:"Limits how deeply users can nest grouped data. Enforced when adding new group levels.",tips:['"Add group level" button is hidden at this limit',"Range: 1 (single group only) to 3 (triple nested groups)","Prevents overly complex grouping hierarchies"]}};function Eo({children:e,active:r}){return t.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5,height:"200px",width:"100%"},children:e})}function Bp({open:e,onClose:r,config:n,onApply:i}){const[s,a]=h.useState(0),[l,d]=h.useState(n),u=()=>d(n),g=()=>d(mt),b=()=>{i(l),r()},f={sort:m=>d(w=>({...w,sort:{...w.sort,...m}})),filter:m=>d(w=>({...w,filter:{...w.filter,...m}})),columns:m=>d(w=>({...w,columns:{...w.columns,...m}})),grouping:m=>d(w=>({...w,grouping:{...w.grouping,...m}})),export:m=>d(w=>({...w,export:{...w.export,...m}}))},S=m=>{const w=l.filter.allowedOperators,x=w.includes(m)?w.filter(C=>C!==m):[...w,m];x.length!==0&&f.filter({allowedOperators:x})},y=m=>{const w=l.export.allowedFormats,x=w.includes(m)?w.filter(C=>C!==m):[...w,m];x.length!==0&&f.export({allowedFormats:x})},E=[{label:"Sort",icon:t.jsx(_.SwapVert,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Filter",icon:t.jsx(_.FilterList,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Columns",icon:t.jsx(_.ViewColumn,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Grouping",icon:t.jsx(_.Layers,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Export",icon:t.jsx(_.Download,{sx:{fontSize:m=>m.typography.body1.fontSize}})}],j=m=>JSON.stringify(l[m])===JSON.stringify(mt[m]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:m=>nt(m),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:m=>m.shadows[8]}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(o.Box,{sx:{width:32,height:32,borderRadius:m=>m.shape.borderRadius,bgcolor:m=>$(m.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:m=>m.typography.h5.fontSize},children:"⚙️"}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h4",sx:{fontWeight:m=>m.typography.h4.fontWeight||600,fontSize:m=>m.typography.h4.fontSize,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,w)=>a(w),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:m=>m.typography.caption.fontSize,textTransform:"none",fontWeight:m=>m.typography.button.fontWeight,gap:.5}},children:E.map((m,w)=>t.jsx(o.Tab,{label:m.label,icon:m.icon,iconPosition:"start"},w))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0,minHeight:300},children:[t.jsx(Eo,{active:s===0,children:t.jsxs(o.Box,{children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),t.jsx(ft,{content:Ar.sortMaxLevels,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.Slider,{value:l.sort.maxLevels,onChange:(m,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(Eo,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),t.jsx(ft,{content:Ar.filterMaxConditions,isDev:process.env.NODE_ENV==="development"})]}),!j("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Slider,{value:l.filter.maxConditions,onChange:(m,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.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed filter operators"}),t.jsx(ft,{content:Ar.filterAllowedOperators,isDev:process.env.NODE_ENV==="development"})]}),["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:w=>w.typography.overline.fontSize,display:"block",mb:.5},children:m}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:zp.filter(w=>w.group===m).map(w=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:l.filter.allowedOperators.includes(w.value),onChange:()=>S(w.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:w.label}),sx:{mr:1.5}},w.value))})]},m))]})]}),t.jsxs(Eo,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),t.jsx(ft,{content:Ar.columnsMaxVisible,isDev:process.env.NODE_ENV==="development"})]}),!j("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Slider,{value:l.columns.maxVisible,onChange:(m,w)=>f.columns({maxVisible:w}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:2},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Column width range (px)"}),t.jsx(ft,{content:Ar.columnsWidthRange,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(o.Slider,{value:l.columns.minColumnWidth,onChange:(m,w)=>f.columns({minColumnWidth:w}),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:l.columns.maxColumnWidth,onChange:(m,w)=>f.columns({maxColumnWidth:w}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}px`})]})]})]})]}),t.jsx(Eo,{active:s===3,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),t.jsx(ft,{content:Ar.groupingMaxLevels,isDev:process.env.NODE_ENV==="development"})]}),!j("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:()=>f.grouping({maxLevels:m}),sx:{flex:1,py:2.5,borderRadius:w=>Number(w.shape.borderRadius||0)*1.25,border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:l.grouping.maxLevels===m?"primary.main":"divider",bgcolor:l.grouping.maxLevels===m?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:l.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:l.grouping.allowNested,onChange:m=>f.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:l.grouping.allowCollapse,onChange:m=>f.grouping({allowCollapse:m.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]})}),t.jsx(Eo,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),t.jsx(ft,{content:Ar.exportAllowedFormats,isDev:process.env.NODE_ENV==="development"})]}),!j("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.FormGroup,{sx:{gap:1},children:Tp.map(m=>t.jsxs(o.Box,{onClick:()=>y(m.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:w=>w.shape.borderRadius,border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:l.export.allowedFormats.includes(m.value)?"primary.main":"divider",bgcolor:l.export.allowedFormats.includes(m.value)?w=>$(w.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:l.export.allowedFormats.includes(m.value),onChange:()=>y(m.value),onClick:w=>w.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=>$(m.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx(_.RestartAlt,{sx:{fontSize:18}}),onClick:g,size:"small",sx:{fontSize:m=>m.typography.body2.fontSize,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:m=>$(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:m=>m.typography.body2.fontSize,color:"text.secondary",px:2,borderRadius:m=>Number(m.shape.borderRadius)*2.25},children:"Cancel"}),t.jsx(o.Button,{onClick:b,size:"small",variant:"contained",sx:{fontSize:m=>m.typography.body2.fontSize,px:2.5,borderRadius:m=>Number(m.shape.borderRadius)*2.25},children:"Apply"})]})]})]})}const Ip=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ep={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 ln(e,r,n,i,s=new Date){const[a,l]=r.split(":").map(Number),d=new Date(s);if(d.setSeconds(0,0),d.setHours(a,l,0,0),e==="daily")return d<=s&&d.setDate(d.getDate()+1),d.toISOString();if(e==="weekly"){const u=n??1,g=d.getDay();let b=u-g;return b<0&&(b+=7),b===0&&d<=s&&(b=7),d.setDate(d.getDate()+b),d.toISOString()}if(e==="monthly"){const u=Math.min(i??1,28);return d.setDate(u),d<=s&&(d.setMonth(d.getMonth()+1),d.setDate(u)),d.toISOString()}return d.toISOString()}function Dp(e){const r=ha(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${Ip[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${Ep[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function ha(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function _p(e){const r=new Date(e).getTime()-Date.now();if(r<=0)return"now";const n=Math.floor(r/1e3),i=Math.floor(n/86400),s=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${a}m`:a>0?`in ${a}m`:"in less than a minute"}function $p(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=ha(`${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 ma(e){return`urm_schedules_${e}`}function fa(e){try{const r=localStorage.getItem(ma(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 xa(e,r){try{localStorage.setItem(ma(e),JSON.stringify(r))}catch{}}const Op=[{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"}],Mp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ga={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",emails:[],viewId:""},vr={"& .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 Ap(e){const r=(n,i)=>n.name.localeCompare(i.name);return{globalViews:e.filter(n=>n.scope==="global"&&!n.isDeleted).sort(r),favoriteViews:e.filter(n=>n.isFavorite&&!n.isDeleted).sort(r),personalViews:e.filter(n=>n.scope!=="global"&&!n.isDeleted).sort(r)}}function Wp({initial:e=ga,isEditing:r=!1,views:n,onSave:i,onBack:s}){const[a,l]=h.useState(e),[d,u]=h.useState(!1),[g,b]=h.useState(""),[f,S]=h.useState(""),{globalViews:y,favoriteViews:E,personalViews:j}=Ap(n),m=(p,A)=>l(L=>({...L,[p]:A})),w=()=>{const p=g.trim();if(p){if(!Mp.test(p)){S("Please enter a valid email address");return}if(a.emails.includes(p)){S("This email is already added");return}m("emails",[...a.emails,p]),b(""),S("")}},x=p=>{m("emails",a.emails.filter(A=>A!==p))},C=p=>{p.key==="Enter"&&(p.preventDefault(),w())},B=a.name.trim().length>0&&/^\d{2}:\d{2}$/.test(a.time)&&(a.frequency!=="monthly"||a.dayOfMonth>=1&&a.dayOfMonth<=28);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:s,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:p=>$(p.palette.text.primary,.06)}},children:t.jsx(_.ArrowBack,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:p=>p.typography.body2.fontWeight||600,fontSize:p=>p.typography.body2.fontSize||"0.875rem"},children:r?"Edit schedule":"New schedule"})]}),t.jsx(o.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:a.name,onChange:p=>{m("name",p.target.value),d&&p.target.value.trim()&&u(!1)},onBlur:()=>u(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:d&&!a.name.trim(),helperText:d&&!a.name.trim()?"Schedule name is required":`${a.name.length}/50`,sx:vr}),t.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2},children:[t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:vr,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:a.frequency,label:"Frequency",onChange:p=>m("frequency",p.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"})]})]}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:a.time,onChange:p=>m("time",p.target.value),InputLabelProps:{shrink:!0},sx:vr})]}),a.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:vr,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:a.dayOfWeek,label:"Day of week",onChange:p=>m("dayOfWeek",Number(p.target.value)),children:Op.map(p=>t.jsx(o.MenuItem,{value:p.value,children:p.label},p.value))})]}),a.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:a.dayOfMonth,onChange:p=>m("dayOfMonth",Number(p.target.value)),inputProps:{min:1,max:28},error:a.dayOfMonth<1||a.dayOfMonth>28,helperText:a.dayOfMonth<1||a.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:vr}),t.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2},children:[t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:vr,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:a.format,label:"Export format",onChange:p=>m("format",p.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.FormControl,{size:"small",fullWidth:!0,sx:vr,children:[t.jsx(o.InputLabel,{children:"Report view"}),t.jsx(o.Select,{value:a.viewId,label:"Report view",onChange:p=>m("viewId",p.target.value),startAdornment:t.jsx(_.Visibility,{sx:{fontSize:15,color:"text.disabled",ml:.5,mr:.5}}),MenuProps:{PaperProps:{sx:{maxHeight:280}}},renderValue:p=>{var A;return((A=n.find(L=>L.id===p))==null?void 0:A.name)||"Select view"},children:[["Global Views",y],["Favorite Views",E],["Personal Views",j]].flatMap(([p,A])=>A.length===0?[]:[t.jsx(o.ListSubheader,{sx:{fontSize:"caption.fontSize",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.05em",lineHeight:"32px"},children:p},`${p}-header`),...A.map(L=>t.jsxs(o.MenuItem,{value:L.id,sx:{fontSize:"0.8125rem",gap:1},children:[a.viewId===L.id?t.jsx(_.Check,{sx:{fontSize:16,flexShrink:0}}):t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Box,{component:"span",sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:L.name}),L.isDefault&&t.jsx(o.Box,{component:"span",sx:{fontSize:"caption.fontSize",color:"text.secondary",bgcolor:"action.selected",px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]},L.id))])})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Email recipients (optional)"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.TextField,{size:"small",fullWidth:!0,type:"email",value:g,onChange:p=>{b(p.target.value),f&&S("")},onKeyPress:C,placeholder:"user@company.com",error:!!f,helperText:f||void 0,InputProps:{startAdornment:t.jsx(_.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:vr}),t.jsx(o.Button,{onClick:w,variant:"outlined",size:"small",startIcon:t.jsx(_.Add,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",borderRadius:"8px",px:1.5,flexShrink:0,height:40},children:"Add"})]}),a.emails.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.75,mt:1},children:a.emails.map(p=>t.jsx(o.Chip,{label:p,size:"small",onDelete:()=>x(p),sx:{fontSize:"0.75rem",bgcolor:A=>$(A.palette.primary.main,.08),color:"primary.main"}},p))})]}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(o.Button,{onClick:s,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:p=>$(p.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>B&&i(a),disabled:!B,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function Rp({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:Fo(i),...he(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 Pp({schedule:e,tick:r,onToggle:n,onRunNow:i,onEdit:s,onDelete:a}){var d;const l=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:l?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:l?u=>$(u.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:l?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:l?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:l?u=>$(u.palette.success.main,.1):u=>$(u.palette.text.primary,.06),color:l?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Dp(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:u=>$(u.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:u=>$(u.palette.text.primary,.06),color:"text.secondary"}}),e.viewName&&t.jsx(o.Chip,{icon:t.jsx(_.Visibility,{sx:{fontSize:11}}),label:e.viewName,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:160,bgcolor:u=>$(u.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}}),(d=e.emails)==null?void 0:d.map(u=>t.jsx(o.Chip,{icon:t.jsx(_.Email,{sx:{fontSize:11}}),label:u,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:g=>$(g.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}},u))]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[l&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",_p(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",$p(e.lastRunAt)," · ",e.runCount," run",e.runCount!==1?"s":""]}):t.jsx(o.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[t.jsx(o.Tooltip,{title:"Edit",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>s(e),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:u=>$(u.palette.primary.main,.08)}},children:t.jsx(_.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:l?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:l?"warning.main":"success.main","&:hover":{bgcolor:l?u=>$(u.palette.warning.main,.08):u=>$(u.palette.success.main,.08)}},children:l?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:u=>$(u.palette.primary.main,.08)}},children:t.jsx(_.Download,{sx:{fontSize:u=>u.typography.body1.fontSize}})})}),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:u=>$(u.palette.error.main,.08)}},children:t.jsx(_.Delete,{sx:{fontSize:15}})})})]})]})]})}function Np({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s,views:a,schedulerConfig:l}){var v,O;const u=((l==null?void 0:l.mode)??"local")==="api",[g,b]=h.useState([]),f=u?(l==null?void 0:l.schedules)??[]:g,[S,y]=h.useState({type:"list"}),[E,j]=h.useState(0),[m,w]=h.useState(null);h.useEffect(()=>{e&&(u||b(fa(n)),y({type:"list"}))},[e,n,u]),h.useEffect(()=>{if(!e)return;const z=setInterval(()=>j(q=>q+1),3e4);return()=>clearInterval(z)},[e]);const x=h.useCallback(z=>{b(z),xa(n,z)},[n]),C=z=>{var c,re;const q=ln(z.frequency,z.time,z.dayOfWeek,z.dayOfMonth),Y={id:`sched-${Date.now()}`,reportId:n,name:z.name.trim(),frequency:z.frequency,dayOfWeek:z.frequency==="weekly"?z.dayOfWeek:void 0,dayOfMonth:z.frequency==="monthly"?z.dayOfMonth:void 0,time:z.time,format:z.format,scope:z.scope,emails:z.emails.length>0?z.emails:void 0,viewId:z.viewId||void 0,viewName:z.viewId?(c=a.find(ae=>ae.id===z.viewId))==null?void 0:c.name:void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:q,runCount:0};u?(re=l==null?void 0:l.onScheduleCreate)==null||re.call(l,Y):x([...f,Y]),y({type:"list"})},B=z=>{var re,ae;if(S.type!=="edit")return;const q=S.schedule,Y=ln(z.frequency,z.time,z.dayOfWeek,z.dayOfMonth),c={...q,name:z.name.trim(),frequency:z.frequency,dayOfWeek:z.frequency==="weekly"?z.dayOfWeek:void 0,dayOfMonth:z.frequency==="monthly"?z.dayOfMonth:void 0,time:z.time,format:z.format,scope:z.scope,emails:z.emails.length>0?z.emails:void 0,viewId:z.viewId||void 0,viewName:z.viewId?(re=a.find(G=>G.id===z.viewId))==null?void 0:re.name:void 0,nextRunAt:Y};u?(ae=l==null?void 0:l.onScheduleUpdate)==null||ae.call(l,c):x(f.map(G=>G.id===q.id?c:G)),y({type:"list"})},p=z=>{var ae;const q=f.find(G=>G.id===z);if(!q)return;const Y=!q.isActive,c=Y?ln(q.frequency,q.time,q.dayOfWeek,q.dayOfMonth):q.nextRunAt,re={...q,isActive:Y,nextRunAt:c};u?(ae=l==null?void 0:l.onScheduleToggle)==null||ae.call(l,z,Y):x(f.map(G=>G.id===z?re:G))},A=z=>{if(s(z),!u){const q=new Date().toISOString();x(f.map(Y=>Y.id===z.id?{...Y,lastRunAt:q,runCount:Y.runCount+1}:Y))}},L=z=>{const q=f.find(Y=>Y.id===z)??null;w(q)},I=()=>{var z;m&&(u?(z=l==null?void 0:l.onScheduleDelete)==null||z.call(l,m.id):x(f.filter(q=>q.id!==m.id)),w(null))},Q=z=>{var q,Y;return{name:z.name,frequency:z.frequency,dayOfWeek:z.dayOfWeek??1,dayOfMonth:z.dayOfMonth??1,time:z.time,format:z.format,scope:z.scope,emails:z.emails??[],viewId:z.viewId||((q=a.find(c=>c.isDefault))==null?void 0:q.id)||((Y=a[0])==null?void 0:Y.id)||""}},ee=S.type!=="list",W=f.filter(z=>z.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:ee,PaperProps:{sx:z=>({borderRadius:nt(z),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",...he(z).paper})},children:[t.jsxs(o.DialogTitle,{sx:z=>({display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,flexShrink:0,minHeight:0,...he(z).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:z=>$(z.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:"h4",sx:{fontWeight:z=>z.typography.h4.fontWeight||600,fontSize:z=>z.typography.h4.fontSize||"0.875rem",lineHeight:1},children:"Scheduled Reports"}),t.jsx(ft,{content:Pr.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:z=>$(z.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:[ee&&t.jsx(Wp,{initial:S.type==="edit"?Q(S.schedule):{...ga,viewId:((v=a.find(z=>z.isDefault))==null?void 0:v.id)||((O=a[0])==null?void 0:O.id)||""},isEditing:S.type==="edit",views:a,onSave:S.type==="edit"?B:C,onBack:()=>y({type:"list"})}),S.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:f.length===0?"No schedules yet":`${W} of ${f.length} active`}),t.jsx(o.Button,{startIcon:t.jsx(_.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>y({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),f.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:z=>z.typography.body2.fontWeight||500,fontSize:z=>z.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:f.map(z=>t.jsx(Pp,{schedule:z,tick:E,onToggle:p,onRunNow:A,onEdit:q=>y({type:"edit",schedule:q}),onDelete:L},z.id))})]})]}),S.type==="list"&&t.jsx(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:z=>$(z.palette.text.primary,.06)}},children:"Close"})})]}),m&&t.jsx(Rp,{scheduleName:m.name,onConfirm:I,onCancel:()=>w(null)})]})}const Lp=6e4;function Fp({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,views:l,columnVisibility:d,columnOrder:u,filters:g,sortStack:b,onFired:f,schedulerConfig:S}){const y=(S==null?void 0:S.mode)??"local",E=h.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,views:l,columnVisibility:d,columnOrder:u,filters:g,sortStack:b,onFired:f,schedulerConfig:S,schedulerMode:y});h.useEffect(()=>{E.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:a,views:l,columnVisibility:d,columnOrder:u,filters:g,sortStack:b,onFired:f,schedulerConfig:S,schedulerMode:y}});const j=h.useCallback(m=>{var O,z,q,Y,c,re;const{reportName:w,uploadedData:x,processedData:C,schema:B,activeView:p,views:A,columnVisibility:L,columnOrder:I,filters:Q,sortStack:ee,schedulerConfig:W,schedulerMode:v}=E.current;try{const ae=m.viewId?A.find(P=>P.id===m.viewId):void 0,G=ae?ae.snapshot.filters:Q,te=ae?ae.snapshot.sortStack:ee,ue=ae?ae.snapshot.columnVisibility:L,le=ae?ae.snapshot.columnOrder:I,Z=m.scope==="all"?x:ae?xi(ji(x,G,B),B,te):C;if(v==="api"){const P=(le.length>0?le:B.map(me=>me.name)).filter(me=>ue[me]!==!1),oe={schedule:m,triggeredAt:new Date().toISOString(),rows:Z,columns:P,format:m.format,reportName:w};(O=W==null?void 0:W.onScheduleFire)==null||O.call(W,oe),(q=(z=E.current).onFired)==null||q.call(z,m);return}const de=cn(Z,B,G,te,ae||p,ue,le),ie=`${m.name}_scheduled`;switch(m.format){case"csv":dn(de,ie,{scope:m.scope});break;case"excel":un(de,ie,{scope:m.scope});break;case"json":pn(de,ie,{scope:m.scope});break;case"pdf":Ci(de,ie,{scope:m.scope});break}if(W!=null&&W.onScheduleFire){const P=(le.length>0?le:B.map(oe=>oe.name)).filter(oe=>ue[oe]!==!1);W.onScheduleFire({schedule:m,triggeredAt:new Date().toISOString(),rows:Z,columns:P,format:m.format,reportName:w})}if((Y=m.emails)!=null&&Y.length){const P=encodeURIComponent(`Scheduled Report: ${m.name}`),oe=encodeURIComponent(`Your scheduled report "${m.name}" has been generated.
|
|
192
192
|
|
|
193
|
-
Report: ${
|
|
193
|
+
Report: ${w}
|
|
194
194
|
Format: ${m.format.toUpperCase()}
|
|
195
195
|
Generated: ${new Date().toLocaleString()}
|
|
196
196
|
|
|
197
|
-
The file has been downloaded to your device.`);window.open(`mailto:${m.emails.join(",")}?subject=${R}&body=${oe}`,"_blank")}(re=(c=I.current).onFired)==null||re.call(c,m)}catch(se){Jt.error("urm:scheduler",`Export failed for schedule: ${m.name}`,se)}},[]);p.useEffect(()=>{if(!e)return;const m=()=>{const{reportId:h,schedulerMode:k,schedulerConfig:T}=I.current;if(!h)return;const f=k==="api"?(T==null?void 0:T.schedules)??[]:ma(h),W=new Date;let N=!1;const E=f.map(X=>{if(!X.isActive)return X;if(new Date(X.nextRunAt)<=W){C(X);const A=sn(X.frequency,X.time,X.dayOfWeek,X.dayOfMonth,W);return N=!0,{...X,lastRunAt:W.toISOString(),nextRunAt:A,runCount:X.runCount+1}}return X});N&&k==="local"&&xa(h,E)};m();const j=setInterval(m,Fp);return()=>clearInterval(j)},[e,C])}function ya({reportEngine:e}){var Or,je,Ye,Mr,ct,er;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:l,isDirty:d,currentTableState:u,showFilterPanel:g,setShowFilterPanel:b,filterFocusColumn:x,handleReplaceFilters:S,handleOpenFilterForColumn:y,handleCloseFilterPanel:I,handleClearFiltersForColumn:C,showSortPanel:m,setShowSortPanel:j,handleSort:h,handleUpdateSortStack:k,handleSortAscending:T,handleSortDescending:f,showCreateViewModal:W,setShowCreateViewModal:N,showEditViewModal:E,setShowEditViewModal:X,showDeleteConfirmation:te,setShowDeleteConfirmation:A,editingView:v,deletingView:O,handleSelectView:B,handleCreateView:q,handleUpdateCurrentView:Y,handleSaveAsNewView:c,handleRevertChanges:re,handleToggleDefault:se,handleToggleFavorite:V,handleSoftDelete:Z,handleRestoreView:ue,handlePermanentDelete:le,handleEditView:Q,handleCloneView:pe,handleCopyViewLink:ie,handleSaveEditView:R,handleConfirmDelete:oe,handlePromoteToGlobal:G,handleSetDefaultForAllUsers:ae,showManageColumns:De,setShowManageColumns:ee,handleUpdateColumnVisibility:Ne,handleUpdateColumnOrder:Te,handleUpdateColumnWidth:$t,handleResetColumnLayout:Fr,showGroupPanel:Kt,setShowGroupPanel:Cr,handleGroup:Ot,handleToggleGroupCollapse:pt,handleExpandAllGroups:Xt,handleCollapseAllGroups:Ze,searchQuery:Mt,debouncedSearchQuery:jr,searchHistory:at,handleSearchChange:Qt,handleAddToSearchHistory:fo,handleToggleSearchFavourite:lr,handleDeleteSearchHistory:mo,selectedRowIds:Zt,handleToggleRowSelection:kr,handleToggleAllRows:jt,handleRangeSelection:Je,handleClearSelection:zr,handleUpdateSelectionAfterDelete:ht,currentPage:rt,pageSize:Nt,paginationTotalRows:cr,paginationTotalPages:xo,handlePageChange:Vr,handlePageSizeChange:dr,isExporting:Ke,showExportModal:Ce,setShowExportModal:At,showDirtyExportWarning:Br,handleExport:Hr,handleExportWithConfig:ur,handleExportSelected:Tr,handleExportAnyway:Ur,handleSaveAndExport:pr,handleCancelExport:et,showAuditHistory:Lt,setShowAuditHistory:Se,showCreatePreset:Lo,setShowCreatePreset:me,showManagePresets:kt,setShowManagePresets:H,activePreset:vt,handleCreatePreset:ce,handleClearActivePreset:lt,handleOpenPresetById:Ir,handleDeletePresetById:zt,isViewerRole:Gr,userRole:hr,featureLimitWarning:Er,setFeatureLimitWarning:Ft,reportError:fr,setReportError:Dr,handleError:we,updateReport:ft,showSnack:mt,config:U,scheduler:Oe}=e,[Me,_r]=p.useState(!1);Vp({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:l,views:(r==null?void 0:r.views)||[],columnVisibility:(r==null?void 0:r.columnVisibility)||((Or=l==null?void 0:l.snapshot)==null?void 0:Or.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((je=l==null?void 0:l.snapshot)==null?void 0:je.columnOrder)||[],filters:Ue(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:fe=>{mt(`Scheduled export "${fe.name}" completed`,"success")},schedulerConfig:Oe});const $r=p.useCallback((fe,xe)=>{if(!(r!=null&&r.uploadedData))return;const Ae=r.uploadedData[fe],We=[...r.uploadedData];We[fe]=xe;const st=_o(r.id,"user","rows","row_edited",Ae,xe),dt=$o(r.auditHistory||[],st);ft(r.id,{uploadedData:We,auditHistory:dt})},[r,ft]),Yr=p.useCallback(fe=>{if(!(r!=null&&r.uploadedData))return;const xe=r.uploadedData.indexOf(fe);if(xe===-1)return;const Ae=r.uploadedData.filter((dt,xt)=>xt!==xe),We=_o(r.id,"user","rows","row_deleted",fe,null),st=$o(r.auditHistory||[],We);ft(r.id,{uploadedData:Ae,auditHistory:st}),ht(fe)},[r,ft,ht]),go=p.useCallback((fe,xe)=>{if(!(r!=null&&r.uploadedData))return;const Ae=r.uploadedData.indexOf(xe),We=Ae!==-1?Ae+1:fe+1,st=[...r.uploadedData];st.splice(We,0,{...xe});const dt=_o(r.id,"user","rows","row_duplicated",xe,{...xe}),xt=$o(r.auditHistory||[],dt);ft(r.id,{uploadedData:st,auditHistory:xt})},[r,ft]),Vt=Nr(),{handleDevConfigChange:yo}=gn(),[qr,Wt]=p.useState(!1);return p.useEffect(()=>{const fe=xe=>{xe.ctrlKey&&xe.shiftKey&&xe.key==="D"&&(xe.preventDefault(),Wt(!0))};return document.addEventListener("keydown",fe),()=>document.removeEventListener("keydown",fe)},[]),!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:[Er&&t.jsx(Cp,{warning:Er,onDismiss:()=>Ft(null)}),fr&&t.jsx(jp,{error:fr,onDismiss:()=>Dr(null)}),Br&&t.jsx(ip,{onExportAnyway:Ur,onSaveAndExport:pr,onCancel:et}),t.jsx(qu,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:d,isExporting:Ke,columnVisibility:r.columnVisibility||(l==null?void 0:l.snapshot.columnVisibility),columnOrder:r.columnOrder||(l==null?void 0:l.snapshot.columnOrder),columnWidths:r.columnWidths||(l==null?void 0:l.snapshot.columnWidths),grouping:r.grouping,onSort:h,onSortAscending:T,onSortDescending:f,onOpenFilters:()=>b(!0),onOpenSort:()=>j(!0),onOpenFilterForColumn:y,onSelectView:B,onCreateView:()=>N(!0),onUpdateCurrentView:Y,onSaveAsNewView:c,onDiscardChanges:re,onToggleDefault:se,onToggleFavorite:V,onRestoreView:ue,onPermanentDelete:le,onEditView:Q,onCloneView:pe,onCopyLink:ie,onDeleteView:Z,onPromoteToGlobal:G,onSetDefaultForAllUsers:ae,isAdmin:((Ye=Vt.views)==null?void 0:Ye.isAdmin)??!1,hideViewMenuActions:U==null?void 0:U.hideViewMenuActions,onExport:Hr,onOpenColumns:()=>ee(!0),onUpdateColumnWidth:$t,onUpdateColumnOrder:Te,onUpdateColumnVisibility:Ne,onClearFiltersForColumn:C,onResetLayout:Fr,onOpenGroup:()=>Cr(!0),onGroupByColumn:(Mr=U==null?void 0:U.hideToolbarActions)!=null&&Mr.includes("grouping")?void 0:fe=>{var We;const xe=r==null?void 0:r.grouping;if(!((xe==null?void 0:xe.enabled)&&(xe==null?void 0:xe.levels)&&xe.levels.length>0))Ot({enabled:!0,levels:[{column:fe}],collapsedGroups:[]});else{if(xe.levels.some(xt=>xt.column===fe))return;const dt=((We=Vt.grouping)==null?void 0:We.maxLevels)??3;if(xe.levels.length>=dt)return;Ot({enabled:!0,levels:[...xe.levels,{column:fe}],collapsedGroups:xe.collapsedGroups})}},onToggleGroupCollapse:pt,onExpandAllGroups:Xt,onCollapseAllGroups:Ze,onOpenAuditHistory:()=>Se(!0),onOpenScheduledReports:()=>_r(!0),searchQuery:Mt,highlightQuery:jr,searchHistory:at,onAddToSearchHistory:fo,onToggleSearchFavourite:lr,onDeleteSearchHistory:mo,selectedRowIds:Zt,onSearchChange:Qt,onToggleRowSelection:kr,onToggleAllRows:jt,onRangeSelection:Je,onClearSelection:zr,onExportSelected:Tr,currentPage:rt,pageSize:Nt,onPageChange:Vr,onPageSizeChange:dr,totalRowsBeforePagination:cr,totalPagesOverride:xo,isReadOnly:Gr,userRole:hr,reportName:r.name,onEditRow:$r,onDeleteRow:Yr,onDuplicateRow:go,rowActions:U==null?void 0:U.rowActions,hideDefaultRowActions:U==null?void 0:U.hideDefaultRowActions,hideToolbarActions:U==null?void 0:U.hideToolbarActions,customSettingsActions:U==null?void 0:U.customSettingsActions,jsonGuideContent:U==null?void 0:U.jsonGuideContent,viewOptions:U==null?void 0:U.viewOptions,defaultViewMode:U==null?void 0:U.defaultViewMode,bulkActions:U==null?void 0:U.bulkActions,hideSelectionCheckboxes:U==null?void 0:U.hideSelectionCheckboxes,rowClickBehavior:U==null?void 0:U.rowClickBehavior,openModalOn:U==null?void 0:U.openModalOn,onRowClick:U==null?void 0:U.onRowClick,onRowRightClick:U==null?void 0:U.onRowRightClick,showDevPanel:Vt.display.showDevPanel,onOpenDevConfig:()=>Wt(!0)})]}),g&&t.jsx(on,{feature:"Filters",onError:fe=>{const xe=vr("ui","filters",fe);we(xe)},children:t.jsx(Qu,{schema:r.schema,filters:r.filters,onReplaceFilters:S,onClose:I,focusColumn:x,onOpenDevConfig:()=>Wt(!0)})}),m&&t.jsx(on,{feature:"Sorting",onError:fe=>{const xe=vr("ui","sorting",fe);we(xe)},children:t.jsx(ep,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:k,onClose:()=>j(!1),onOpenDevConfig:()=>Wt(!0)})}),W&&u&&(()=>{var Ae;const fe=(r.views??[]).filter(We=>!We.isDeleted).length,xe=((Ae=Vt.views)==null?void 0:Ae.maxViews)??10;return t.jsx(zs,{currentSnapshot:u,onSave:q,onClose:()=>N(!1),atViewLimit:fe>=xe,maxViews:xe})})(),E&&v&&t.jsx(zs,{currentSnapshot:v.snapshot,onSave:R,onClose:()=>{X(!1)},isEditMode:!0,initialName:v.name,initialDescription:v.description,initialIsDefault:v.isDefault}),te&&O&&t.jsx(tp,{viewName:O.name,onConfirm:oe,onCancel:()=>{A(!1)}}),De&&l&&t.jsx(op,{schema:r.schema,columnVisibility:r.columnVisibility||l.snapshot.columnVisibility,columnOrder:r.columnOrder||l.snapshot.columnOrder,columnWidths:r.columnWidths||l.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:Ne,onUpdateColumnOrder:Te,onUpdateColumnWidth:$t,onResetLayout:Fr,onClose:()=>ee(!1)}),Kt&&t.jsx(on,{feature:"Grouping",onError:fe=>{const xe=vr("ui","grouping",fe);we(xe)},children:t.jsx(np,{schema:r.schema,grouping:r.grouping||null,onApply:Ot,onClose:()=>Cr(!1),onOpenDevConfig:()=>Wt(!0)})}),Lt&&t.jsx(lp,{auditHistory:r.auditHistory||[],onClose:()=>Se(!1)}),Lo&&t.jsx(cp,{onSave:ce,onClose:()=>me(!1)}),kt&&t.jsx(up,{presets:r.presets||[],reportId:r.id,onOpenPreset:Ir,onDeletePreset:zt,onClose:()=>H(!1)}),vt&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(dp,{presetName:vt.name,onClear:lt})}),Ce&&t.jsx(on,{feature:"Export",onError:fe=>{const xe=vr("ui","export",fe);we(xe)},children:t.jsx(wp,{totalRows:(s==null?void 0:s.totalRows)||((ct=r.uploadedData)==null?void 0:ct.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((er=a==null?void 0:a.columnEngine)==null?void 0:er.visibleColumns.length)||r.schema.length,totalColumnsCount:r.schema.length,hasGrouping:(s==null?void 0:s.isGrouped)||!1,schema:r.schema,allRows:r.uploadedData||[],processedRows:i||[],onExport:ur,onClose:()=>{At(!1)}})}),r&&t.jsx(Lp,{open:Me,onClose:()=>_r(!1),reportId:r.id,reportName:r.name,views:r.views||[],schedulerConfig:Oe,onRunNow:fe=>{var rr;const xe=(Oe==null?void 0:Oe.mode)??"local",Ae=fe.viewId?(r.views||[]).find(Ar=>Ar.id===fe.viewId):void 0,We=Ae?Ae.snapshot.filters:Ue(r.filters),st=Ae?Ae.snapshot.sortStack:r.sortStack||[],dt=Ae?Ae.snapshot.columnVisibility:r.columnVisibility,xt=Ae?Ae.snapshot.columnOrder:r.columnOrder,Jr=fe.scope==="all"?r.uploadedData||[]:Ae?hi(Si(r.uploadedData||[],We,r.schema||[]),r.schema||[],st):i||[],tr=an(Jr,r.schema||[],We,st,Ae||l,dt,xt);if(xe==="api"){const Ar=(xt||[]).filter(mr=>(dt??{})[mr]!==!1);(rr=Oe==null?void 0:Oe.onScheduleFire)==null||rr.call(Oe,{schedule:fe,triggeredAt:new Date().toISOString(),rows:Jr,columns:Ar,format:fe.format,reportName:r.name})}else fe.format==="csv"&&ln(tr,fe.name),fe.format==="excel"&&cn(tr,fe.name),fe.format==="json"&&dn(tr,fe.name),fe.format==="pdf"&&vi(tr,fe.name);mt(`"${fe.name}" exported successfully`,"success")}}),t.jsx(Ip,{open:qr,onClose:()=>Wt(!1),config:Vt,onApply:yo})]})}const Hp={error:"err",warning:"warn",info:"info",success:"suc"};function ba({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var k,T,f,W;const a=o.useTheme(),l=a.tokens,d=(l==null?void 0:l.notifPosition)??"bottom-right",u=(l==null?void 0:l.notifStyle)??"toast",g=(l==null?void 0:l.notifAccent)??"severity",b=(l==null?void 0:l.notifAutoDismiss)??!0,x=(l==null?void 0:l.toastW)??252,S=d.startsWith("top")?"top":"bottom",y=d.endsWith("center")?"center":d.endsWith("left")?"left":"right",I=Hp[n],C=((k=l==null?void 0:l.status)==null?void 0:k[`${I}Soft`])??a.palette[n].light,m=((T=l==null?void 0:l.status)==null?void 0:T[`${I}Txt`])??a.palette[n].dark,j=g==="primary"?a.palette.primary.main:g==="mono"?a.palette.text.secondary:m,h=u==="toast"?(l==null?void 0:l.toastBg)??a.palette.background.paper:C;return t.jsx(o.Snackbar,{open:e,autoHideDuration:b?s??(l!=null&&l.autoDismissSec?l.autoDismissSec*1e3:3e4):void 0,onClose:(N,E)=>{E!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:S,horizontal:y},children:t.jsx(o.Alert,{severity:n,icon:u==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((f=l==null?void 0:l.status)==null?void 0:f[`${I}Soft`])??a.palette[n].light,color:((W=l==null?void 0:l.status)==null?void 0:W[`${I}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:[b&&(l==null?void 0:l.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:$(j,.14),color:j,fontSize:"0.7rem",fontWeight:800,fontVariantNumeric:"tabular-nums"},children:`${l.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:x,alignItems:"flex-start",bgcolor:h,color:m,boxShadow:u==="inline"?"none":(l==null?void 0:l.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(l==null?void 0:l.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${j}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:j}},children:t.jsxs(o.Box,{children:[u==="toast"&&t.jsx(o.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:a.palette.text.primary},children:n==="error"?"Error":n==="warning"?"Warning":n==="success"?"Success":"Info"}),t.jsx(o.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function va({hasExternalData:e=!1}){const r=gn(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:l,isModalOpen:d,setIsModalOpen:u,setActiveReportId:g,createReport:b,handleFileUpload:x,handleUploadError:S,handleRetry:y,handleConfirm:I,snack:C,handleSnackClose:m,snackDurationMs:j,config:h}=r,k=e&&a==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Zl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:g}),t.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:k?t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[t.jsx(o.CircularProgress,{size:40,thickness:3}),t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):n.length===0?t.jsx(sa,{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(ya,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(pu,{schema:s.schema,onConfirm:I,hasConflicts:l}):s.uploadError?t.jsx(hu,{error:s.uploadError,onRetry:y}):t.jsx(uu,{onFileUpload:x,onError:S,isUploading:a==="uploading",jsonGuideContent:h==null?void 0:h.jsonGuideContent})})}):null}),!e&&t.jsx(du,{isOpen:d,onClose:()=>u(!1),onCreate:b}),t.jsx(ba,{open:C.open,message:C.message,severity:C.severity,onClose:m,autoHideDurationMs:j})]})}function Up({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:l=!0,config:d}={}){return t.jsx(wi,{mode:"builder",data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:l,config:d,children:t.jsx(va,{hasExternalData:!!(e||r)})})}function Sa(){const e=gn(),{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(ya,{reportEngine:e}):t.jsx(sa,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(ba,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function Gp({data:e,reportId:r,pagination:n,search:i,autoLoad:s=!0,config:a}){return t.jsx(wi,{data:e,reportId:r,pagination:n,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(Sa,{})})}exports.URMBuilder=Up;exports.URMBuilderRaw=va;exports.URMProvider=wi;exports.URMViewer=Gp;exports.URMViewerRaw=Sa;exports.useURMContext=gn;
|
|
197
|
+
The file has been downloaded to your device.`);window.open(`mailto:${m.emails.join(",")}?subject=${P}&body=${oe}`,"_blank")}(re=(c=E.current).onFired)==null||re.call(c,m)}catch(ae){Qt.error("urm:scheduler",`Export failed for schedule: ${m.name}`,ae)}},[]);h.useEffect(()=>{if(!e)return;const m=()=>{const{reportId:x,schedulerMode:C,schedulerConfig:B}=E.current;if(!x)return;const p=C==="api"?(B==null?void 0:B.schedules)??[]:fa(x),A=new Date;let L=!1;const I=p.map(Q=>{if(!Q.isActive)return Q;if(new Date(Q.nextRunAt)<=A){j(Q);const W=ln(Q.frequency,Q.time,Q.dayOfWeek,Q.dayOfMonth,A);return L=!0,{...Q,lastRunAt:A.toISOString(),nextRunAt:W,runCount:Q.runCount+1}}return Q});L&&C==="local"&&xa(x,I)};m();const w=setInterval(m,Lp);return()=>clearInterval(w)},[e,j])}function ya({reportEngine:e}){var Er,Kr,Dr,_r,$r,Ce;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:a,activeView:l,isDirty:d,currentTableState:u,showFilterPanel:g,setShowFilterPanel:b,filterFocusColumn:f,handleReplaceFilters:S,handleOpenFilterForColumn:y,handleCloseFilterPanel:E,handleClearFiltersForColumn:j,showSortPanel:m,setShowSortPanel:w,handleSort:x,handleUpdateSortStack:C,handleSortAscending:B,handleSortDescending:p,showCreateViewModal:A,setShowCreateViewModal:L,showEditViewModal:I,setShowEditViewModal:Q,showDeleteConfirmation:ee,setShowDeleteConfirmation:W,editingView:v,deletingView:O,handleSelectView:z,handleCreateView:q,handleUpdateCurrentView:Y,handleSaveAsNewView:c,handleRevertChanges:re,handleToggleDefault:ae,handleToggleFavorite:G,handleSoftDelete:te,handleRestoreView:ue,handlePermanentDelete:le,handleEditView:Z,handleCloneView:de,handleCopyViewLink:ie,handleSaveEditView:P,handleConfirmDelete:oe,handlePromoteToGlobal:me,handleSetDefaultForAllUsers:pe,showManageColumns:Me,setShowManageColumns:N,handleUpdateColumnVisibility:Se,handleUpdateColumnOrder:Ae,handleUpdateColumnWidth:it,handleResetColumnLayout:We,showGroupPanel:st,setShowGroupPanel:Ze,handleGroup:Nt,handleToggleGroupCollapse:Et,handleExpandAllGroups:Zt,handleCollapseAllGroups:Nr,searchQuery:er,debouncedSearchQuery:Lr,searchHistory:qe,handleSearchChange:Dt,handleAddToSearchHistory:Fr,handleToggleSearchFavourite:lt,handleDeleteSearchHistory:tr,selectedRowIds:Lt,handleToggleRowSelection:Vr,handleToggleAllRows:Ft,handleRangeSelection:_t,handleClearSelection:Vt,handleUpdateSelectionAfterDelete:ct,currentPage:Ne,pageSize:Hr,paginationTotalRows:Ur,paginationTotalPages:hr,handlePageChange:mr,handlePageSizeChange:rr,isExporting:xo,showExportModal:kr,setShowExportModal:$t,showDirtyExportWarning:He,handleExport:we,handleExportWithConfig:Ht,handleExportSelected:go,handleExportAnyway:yo,handleSaveAndExport:Gr,handleCancelExport:Yr,showAuditHistory:or,setShowAuditHistory:ke,showCreatePreset:fr,setShowCreatePreset:rt,showManagePresets:gt,setShowManagePresets:H,activePreset:Ot,handleCreatePreset:K,handleClearActivePreset:at,handleOpenPresetById:xr,handleDeletePresetById:nr,isViewerRole:bo,userRole:gr,featureLimitWarning:zr,setFeatureLimitWarning:St,reportError:ir,setReportError:Tr,handleError:ve,updateReport:wt,showSnack:qr,config:U,scheduler:Ke}=e,[Te,pt]=h.useState(!1);Fp({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:l,views:(r==null?void 0:r.views)||[],columnVisibility:(r==null?void 0:r.columnVisibility)||((Er=l==null?void 0:l.snapshot)==null?void 0:Er.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((Kr=l==null?void 0:l.snapshot)==null?void 0:Kr.columnOrder)||[],filters:Ge(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:se=>{qr(`Scheduled export "${se.name}" completed`,"success")},schedulerConfig:Ke});const Br=h.useCallback((se,fe)=>{if(!(r!=null&&r.uploadedData))return;const je=r.uploadedData[se],Pe=[...r.uploadedData];Pe[se]=fe;const Xe=Mo(r.id,"user","rows","row_edited",je,fe),ht=Ao(r.auditHistory||[],Xe);wt(r.id,{uploadedData:Pe,auditHistory:ht})},[r,wt]),yt=h.useCallback(se=>{if(!(r!=null&&r.uploadedData))return;const fe=r.uploadedData.indexOf(se);if(fe===-1)return;const je=r.uploadedData.filter((ht,dt)=>dt!==fe),Pe=Mo(r.id,"user","rows","row_deleted",se,null),Xe=Ao(r.auditHistory||[],Pe);wt(r.id,{uploadedData:je,auditHistory:Xe}),ct(se)},[r,wt,ct]),vo=h.useCallback((se,fe)=>{if(!(r!=null&&r.uploadedData))return;const je=r.uploadedData.indexOf(fe),Pe=je!==-1?je+1:se+1,Xe=[...r.uploadedData];Xe.splice(Pe,0,{...fe});const ht=Mo(r.id,"user","rows","row_duplicated",fe,{...fe}),dt=Ao(r.auditHistory||[],ht);wt(r.id,{uploadedData:Xe,auditHistory:dt})},[r,wt]),Ut=Rr(),{handleDevConfigChange:Ir}=bn(),[Jr,Gt]=h.useState(!1);return h.useEffect(()=>{const se=fe=>{fe.ctrlKey&&fe.shiftKey&&fe.key==="D"&&(fe.preventDefault(),Gt(!0))};return document.addEventListener("keydown",se),()=>document.removeEventListener("keydown",se)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[zr&&t.jsx(wp,{warning:zr,onDismiss:()=>St(null)}),ir&&t.jsx(Cp,{error:ir,onDismiss:()=>Tr(null)}),He&&t.jsx(np,{onExportAnyway:yo,onSaveAndExport:Gr,onCancel:Yr}),t.jsx(Gu,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:d,isExporting:xo,columnVisibility:r.columnVisibility||(l==null?void 0:l.snapshot.columnVisibility),columnOrder:r.columnOrder||(l==null?void 0:l.snapshot.columnOrder),columnWidths:r.columnWidths||(l==null?void 0:l.snapshot.columnWidths),grouping:r.grouping,onSort:x,onSortAscending:B,onSortDescending:p,onOpenFilters:()=>b(!0),onOpenSort:()=>w(!0),onOpenFilterForColumn:y,onSelectView:z,onCreateView:()=>L(!0),onUpdateCurrentView:Y,onSaveAsNewView:c,onDiscardChanges:re,onToggleDefault:ae,onToggleFavorite:G,onRestoreView:ue,onPermanentDelete:le,onEditView:Z,onCloneView:de,onCopyLink:ie,onDeleteView:te,onPromoteToGlobal:me,onSetDefaultForAllUsers:pe,isAdmin:((Dr=Ut.views)==null?void 0:Dr.isAdmin)??!1,hideViewMenuActions:U==null?void 0:U.hideViewMenuActions,customViewMenuActions:U==null?void 0:U.customViewMenuActions,viewMenuActionData:i,viewMenuActionTableState:u??null,onExport:we,onOpenColumns:()=>N(!0),onUpdateColumnWidth:it,onUpdateColumnOrder:Ae,onUpdateColumnVisibility:Se,onClearFiltersForColumn:j,onResetLayout:We,onOpenGroup:()=>Ze(!0),onGroupByColumn:(_r=U==null?void 0:U.hideToolbarActions)!=null&&_r.includes("grouping")?void 0:se=>{var Pe;const fe=r==null?void 0:r.grouping;if(!((fe==null?void 0:fe.enabled)&&(fe==null?void 0:fe.levels)&&fe.levels.length>0))Nt({enabled:!0,levels:[{column:se}],collapsedGroups:[]});else{if(fe.levels.some(dt=>dt.column===se))return;const ht=((Pe=Ut.grouping)==null?void 0:Pe.maxLevels)??3;if(fe.levels.length>=ht)return;Nt({enabled:!0,levels:[...fe.levels,{column:se}],collapsedGroups:fe.collapsedGroups})}},onToggleGroupCollapse:Et,onExpandAllGroups:Zt,onCollapseAllGroups:Nr,onOpenAuditHistory:()=>ke(!0),onOpenScheduledReports:()=>pt(!0),searchQuery:er,highlightQuery:Lr,searchHistory:qe,onAddToSearchHistory:Fr,onToggleSearchFavourite:lt,onDeleteSearchHistory:tr,selectedRowIds:Lt,onSearchChange:Dt,onToggleRowSelection:Vr,onToggleAllRows:Ft,onRangeSelection:_t,onClearSelection:Vt,onExportSelected:go,currentPage:Ne,pageSize:Hr,onPageChange:mr,onPageSizeChange:rr,totalRowsBeforePagination:Ur,totalPagesOverride:hr,isReadOnly:bo,userRole:gr,reportName:r.name,onEditRow:Br,onDeleteRow:yt,onDuplicateRow:vo,rowActions:U==null?void 0:U.rowActions,hideDefaultRowActions:U==null?void 0:U.hideDefaultRowActions,hideToolbarActions:U==null?void 0:U.hideToolbarActions,customSettingsActions:U==null?void 0:U.customSettingsActions,jsonGuideContent:U==null?void 0:U.jsonGuideContent,jsonGuideTitle:U==null?void 0:U.jsonGuideTitle,viewOptions:U==null?void 0:U.viewOptions,defaultViewMode:U==null?void 0:U.defaultViewMode,bulkActions:U==null?void 0:U.bulkActions,hideSelectionCheckboxes:U==null?void 0:U.hideSelectionCheckboxes,rowClickBehavior:U==null?void 0:U.rowClickBehavior,openModalOn:U==null?void 0:U.openModalOn,onRowClick:U==null?void 0:U.onRowClick,onRowRightClick:U==null?void 0:U.onRowRightClick,showDevPanel:Ut.display.showDevPanel,onOpenDevConfig:()=>Gt(!0)})]}),g&&t.jsx(sn,{feature:"Filters",onError:se=>{const fe=wr("ui","filters",se);ve(fe)},children:t.jsx(Ku,{schema:r.schema,filters:r.filters,onReplaceFilters:S,onClose:E,focusColumn:f,onOpenDevConfig:()=>Gt(!0)})}),m&&t.jsx(sn,{feature:"Sorting",onError:se=>{const fe=wr("ui","sorting",se);ve(fe)},children:t.jsx(Qu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:C,onClose:()=>w(!1),onOpenDevConfig:()=>Gt(!0)})}),A&&u&&(()=>{var je;const se=(r.views??[]).filter(Pe=>!Pe.isDeleted).length,fe=((je=Ut.views)==null?void 0:je.maxViews)??10;return t.jsx(ks,{currentSnapshot:u,onSave:q,onClose:()=>L(!1),atViewLimit:se>=fe,maxViews:fe})})(),I&&v&&t.jsx(ks,{currentSnapshot:v.snapshot,onSave:P,onClose:()=>{Q(!1)},isEditMode:!0,initialName:v.name,initialDescription:v.description,initialIsDefault:v.isDefault}),ee&&O&&t.jsx(Zu,{viewName:O.name,onConfirm:oe,onCancel:()=>{W(!1)}}),Me&&l&&t.jsx(rp,{schema:r.schema,columnVisibility:r.columnVisibility||l.snapshot.columnVisibility,columnOrder:r.columnOrder||l.snapshot.columnOrder,columnWidths:r.columnWidths||l.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:Se,onUpdateColumnOrder:Ae,onUpdateColumnWidth:it,onResetLayout:We,onClose:()=>N(!1)}),st&&t.jsx(sn,{feature:"Grouping",onError:se=>{const fe=wr("ui","grouping",se);ve(fe)},children:t.jsx(op,{schema:r.schema,grouping:r.grouping||null,onApply:Nt,onClose:()=>Ze(!1),onOpenDevConfig:()=>Gt(!0)})}),or&&t.jsx(ap,{auditHistory:r.auditHistory||[],onClose:()=>ke(!1)}),fr&&t.jsx(lp,{onSave:K,onClose:()=>rt(!1)}),gt&&t.jsx(dp,{presets:r.presets||[],reportId:r.id,onOpenPreset:xr,onDeletePreset:nr,onClose:()=>H(!1)}),Ot&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(cp,{presetName:Ot.name,onClear:at})}),kr&&t.jsx(sn,{feature:"Export",onError:se=>{const fe=wr("ui","export",se);ve(fe)},children:t.jsx(Sp,{totalRows:(s==null?void 0:s.totalRows)||(($r=r.uploadedData)==null?void 0:$r.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((Ce=a==null?void 0:a.columnEngine)==null?void 0:Ce.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:()=>{$t(!1)}})}),r&&t.jsx(Np,{open:Te,onClose:()=>pt(!1),reportId:r.id,reportName:r.name,views:r.views||[],schedulerConfig:Ke,onRunNow:se=>{var yr;const fe=(Ke==null?void 0:Ke.mode)??"local",je=se.viewId?(r.views||[]).find(Or=>Or.id===se.viewId):void 0,Pe=je?je.snapshot.filters:Ge(r.filters),Xe=je?je.snapshot.sortStack:r.sortStack||[],ht=je?je.snapshot.columnVisibility:r.columnVisibility,dt=je?je.snapshot.columnOrder:r.columnOrder,Ct=se.scope==="all"?r.uploadedData||[]:je?xi(ji(r.uploadedData||[],Pe,r.schema||[]),r.schema||[],Xe):i||[],Yt=cn(Ct,r.schema||[],Pe,Xe,je||l,ht,dt);if(fe==="api"){const Or=(dt||[]).filter(So=>(ht??{})[So]!==!1);(yr=Ke==null?void 0:Ke.onScheduleFire)==null||yr.call(Ke,{schedule:se,triggeredAt:new Date().toISOString(),rows:Ct,columns:Or,format:se.format,reportName:r.name})}else se.format==="csv"&&dn(Yt,se.name),se.format==="excel"&&un(Yt,se.name),se.format==="json"&&pn(Yt,se.name),se.format==="pdf"&&Ci(Yt,se.name);qr(`"${se.name}" exported successfully`,"success")}}),t.jsx(Bp,{open:Jr,onClose:()=>Gt(!1),config:Ut,onApply:Ir})]})}const Vp={error:"err",warning:"warn",info:"info",success:"suc"};function ba({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var C,B,p,A;const a=o.useTheme(),l=a.tokens,d=(l==null?void 0:l.notifPosition)??"bottom-right",u=(l==null?void 0:l.notifStyle)??"toast",g=(l==null?void 0:l.notifAccent)??"severity",b=(l==null?void 0:l.notifAutoDismiss)??!0,f=(l==null?void 0:l.toastW)??252,S=d.startsWith("top")?"top":"bottom",y=d.endsWith("center")?"center":d.endsWith("left")?"left":"right",E=Vp[n],j=((C=l==null?void 0:l.status)==null?void 0:C[`${E}Soft`])??a.palette[n].light,m=((B=l==null?void 0:l.status)==null?void 0:B[`${E}Txt`])??a.palette[n].dark,w=g==="primary"?a.palette.primary.main:g==="mono"?a.palette.text.secondary:m,x=u==="toast"?(l==null?void 0:l.toastBg)??a.palette.background.paper:j;return t.jsx(o.Snackbar,{open:e,autoHideDuration:b?s??(l!=null&&l.autoDismissSec?l.autoDismissSec*1e3:3e4):void 0,onClose:(L,I)=>{I!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:S,horizontal:y},children:t.jsx(o.Alert,{severity:n,icon:u==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((p=l==null?void 0:l.status)==null?void 0:p[`${E}Soft`])??a.palette[n].light,color:((A=l==null?void 0:l.status)==null?void 0:A[`${E}Txt`])??a.palette[n].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:n==="error"||n==="warning"?"!":n==="success"?"✓":"i"}):void 0,action:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[b&&(l==null?void 0:l.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:`${l.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:x,color:m,boxShadow:u==="inline"?"none":(l==null?void 0:l.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(l==null?void 0:l.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${w}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:w}},children:t.jsxs(o.Box,{children:[u==="toast"&&t.jsx(o.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:a.palette.text.primary},children:n==="error"?"Error":n==="warning"?"Warning":n==="success"?"Success":"Info"}),t.jsx(o.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function va({hasExternalData:e=!1}){const r=bn(),{reports:n,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:l,isModalOpen:d,setIsModalOpen:u,setActiveReportId:g,createReport:b,handleFileUpload:f,handleUploadError:S,handleRetry:y,handleConfirm:E,snack:j,handleSnackClose:m,snackDurationMs:w,config:x}=r,C=e&&a==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(Xl,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:g}),t.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:C?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(sa,{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(ya,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(du,{schema:s.schema,onConfirm:E,hasConflicts:l}):s.uploadError?t.jsx(uu,{error:s.uploadError,onRetry:y}):t.jsx(cu,{onFileUpload:f,onError:S,isUploading:a==="uploading",jsonGuideContent:x==null?void 0:x.jsonGuideContent,jsonGuideTitle:x==null?void 0:x.jsonGuideTitle})})}):null}),!e&&t.jsx(lu,{isOpen:d,onClose:()=>u(!1),onCreate:b}),t.jsx(ba,{open:j.open,message:j.message,severity:j.severity,onClose:m,autoHideDurationMs:w})]})}function Hp({data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:l=!0,config:d}={}){return t.jsx(ki,{mode:"builder",data:e,dataSource:r,pagination:n,search:i,reportName:s,reportId:a,autoLoad:l,config:d,children:t.jsx(va,{hasExternalData:!!(e||r)})})}function Sa(){const e=bn(),{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(ya,{reportEngine:e}):t.jsx(sa,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(ba,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function Up({data:e,reportId:r,pagination:n,search:i,autoLoad:s=!0,config:a}){return t.jsx(ki,{data:e,reportId:r,pagination:n,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(Sa,{})})}exports.URMBuilder=Hp;exports.URMBuilderRaw=va;exports.URMProvider=ki;exports.URMViewer=Up;exports.URMViewerRaw=Sa;exports.useURMContext=bn;
|