dts-universal-report-module 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.esm.js +7805 -7434
  2. package/dist/index.js +25 -25
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
1
- "use strict";var Xs=Object.defineProperty;var Qs=(e,r,n)=>r in e?Xs(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Kn=(e,r,n)=>Qs(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),Zs=require("xlsx"),T=require("@mui/icons-material"),o=require("@mui/material"),Vi=require("react-dom"),ea=require("@emotion/react"),Pt=require("react-dnd"),zn=require("react-dnd-html5-backend");function Hi(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 Do=Hi(p),po=Hi(Zs),Ke={sort:{maxLevels:5},filter:{maxConditions:3,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0},export:{allowedFormats:["csv","excel","json"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},Ui="urm_dev_config";function ta(){try{const e=localStorage.getItem(Ui);if(!e)return Ke;const r=JSON.parse(e),n={sort:{...Ke.sort,...r.sort},filter:{...Ke.filter,...r.filter},columns:{...Ke.columns,...r.columns},grouping:{...Ke.grouping,...r.grouping},export:{...Ke.export,...r.export},views:{...Ke.views,...r.views},dates:{...Ke.dates,...r.dates},display:{...Ke.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return Ke}}function ra(e){try{localStorage.setItem(Ui,JSON.stringify(e))}catch{}}function oa(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 Gi=p.createContext(Ke);function Sr(){return p.useContext(Gi)}const na=/^\d{4}-\d{2}-\d{2}$/,ia=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,sa=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,aa=9783072e5,la=41024448e5,ca=978307200,da=4102444800;function ua(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=aa&&e<=la?"timestamp_ms":Number.isInteger(e)&&e>=ca&&e<=da?"timestamp_s":"unknown":typeof e!="string"?"unknown":ia.test(e)||na.test(e)?"iso":sa.test(e.trim())?"locale_string":"unknown"}function pa(e,r){const n=r.map(d=>d[e]).filter(d=>d!=null&&d!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const d of n){const c=ua(d);i[c]++}const s=n.length,l=.7;for(const d of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[d]/s>=l)return d;return"unknown"}function xa(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 Xn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ma=["January","February","March","April","May","June","July","August","September","October","November","December"];function _e(e){return String(e).padStart(2,"0")}function fa(e){const r=Date.now()-e.getTime(),n=Math.abs(r),i=r>0,s=Math.floor(n/1e3),l=Math.floor(s/60),d=Math.floor(l/60),c=Math.floor(d/24),u=Math.floor(c/7),m=Math.floor(c/30),f=Math.floor(c/365);let x;return s<60?x="just now":l<60?x=`${l} minute${l!==1?"s":""}`:d<24?x=`${d} hour${d!==1?"s":""}`:c<7?x=`${c} day${c!==1?"s":""}`:u<5?x=`${u} week${u!==1?"s":""}`:m<12?x=`${m} month${m!==1?"s":""}`:x=`${f} year${f!==1?"s":""}`,s<60?x:i?`${x} ago`:`in ${x}`}function ha(e,r){const n=e.getFullYear(),i=e.getMonth(),s=e.getDate(),l=e.getHours(),d=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${_e(i+1)}-${_e(s)}`;case"DD/MM/YYYY":return`${_e(s)}/${_e(i+1)}/${n}`;case"MM/DD/YYYY":return`${_e(i+1)}/${_e(s)}/${n}`;case"MMM DD, YYYY":return`${Xn[i]} ${_e(s)}, ${n}`;case"DD MMM YYYY":return`${_e(s)} ${Xn[i]} ${n}`;case"MMMM D, YYYY":return`${ma[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${_e(i+1)}-${_e(s)} ${_e(l)}:${_e(d)}`;case"DD/MM/YYYY HH:mm":return`${_e(s)}/${_e(i+1)}/${n} ${_e(l)}:${_e(d)}`;case"MM/DD/YYYY HH:mm":return`${_e(i+1)}/${_e(s)}/${n} ${_e(l)}:${_e(d)}`;case"relative":return fa(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function ga(e,r,n){if(!n||r==="unknown")return String(e);const i=xa(e,r);return!i||isNaN(i.getTime())?String(e):ha(i,n)}function ya(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 Yi(e,r="",n=0){if(n>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const l=r?`${r}.${s}`:s,d=e[s];d!==null&&typeof d=="object"&&!Array.isArray(d)&&n<2?Object.assign(i,Yi(d,l,n+1)):i[l]=d}return i}function bo(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:Yi(r))}function Hr(e){if(!Array.isArray(e)||e.length===0)return[];const r=bo(e),n=new Set;r.forEach(d=>{typeof d=="object"&&d!==null&&Object.keys(d).forEach(c=>n.add(c))});const i=[];n.forEach(d=>{const c=new Set;let u=0;r.forEach(v=>{typeof v=="object"&&v!==null&&d in v&&(u++,c.add(ya(v[d])))});const m=u===r.length,f=c.size>1&&!c.has("null");let x="mixed";if(c.size===1)x=Array.from(c)[0];else if(c.size===2&&c.has("null")){const v=Array.from(c).filter(b=>b!=="null");v.length===1&&(x=v[0])}i.push({name:d,type:x,required:m,hasConflict:f})});const l=r.slice(0,50);for(const d of i){if(d.type!=="string"&&d.type!=="number")continue;const c=pa(d.name,l);c!=="unknown"&&(d.type="date",d.dateFormat=c)}return i}function ba(e){return e.some(r=>r.hasConflict)}function Qe(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 Qn(e){return e==null}function va(e){return(r,n,i)=>{const s=Qn(r),l=Qn(n);if(s&&l)return 0;if(s)return 1;if(l)return-1;let d=0;switch(e){case"number":const c=Number(r),u=Number(n);d=c-u;break;case"boolean":d=(r?1:0)-(n?1:0);break;case"string":d=String(r).localeCompare(String(n));break;case"array":case"object":d=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:d=String(r).localeCompare(String(n));break}return i==="asc"?d:-d}}function Sa(e,r,n){if(!n||n.length===0)return e;const i=[...n].sort((s,l)=>s.priority-l.priority);return[...e].sort((s,l)=>{for(const d of i){const c=r.find(f=>f.name===d.column);if(!c)continue;const m=va(c.type)(s[d.column],l[d.column],d.direction);if(m!==0)return m}return 0})}function Ca(e){return e===null?"asc":e==="asc"?"desc":null}function ja(e){return e==="string"||e==="boolean"}function wa(e){return e.filter(r=>ja(r.type))}function ka(e,r){const n={};return r.forEach(i=>{if(i.type==="number"){const s=e.map(l=>l[i.name]).filter(l=>typeof l=="number");s.length>0&&(n[i.name]=s.reduce((l,d)=>l+d,0))}}),n}function Ta(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=En(e,n.levels,r);return qi(i,n.collapsedGroups||[])}function En(e,r,n,i="",s=0){if(s>=r.length)return e;const l=r[s].column,d=new Map;e.forEach(m=>{const f=m[l],x=f==null?"(empty)":String(f);d.has(x)||d.set(x,[]),d.get(x).push(m)});const c=[];return Array.from(d.keys()).sort().forEach(m=>{const f=d.get(m),x=`${l}:${m}`,v=i?`${i}|${x}`:x,b=ka(f,n),z=s<r.length-1?En(f,r,n,v,s+1):f,S={key:v,level:s,column:l,value:m,rowCount:f.length,aggregates:b,children:z};c.push(S)}),c}function qi(e,r,n=[]){for(const i of e)if("key"in i&&"level"in i&&"children"in i){const s=r.includes(i.key);n.push({isGroupHeader:!0,groupKey:i.key,groupLevel:i.level,groupColumn:i.column,groupValue:i.value,rowCount:i.rowCount,aggregates:i.aggregates,isCollapsed:s}),!s&&i.children&&qi(i.children,r,n)}else n.push(i);return n}function Ia(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=En(e,n.levels,r),s=[],l=d=>{for(const c of d)"key"in c&&"level"in c&&"children"in c&&(s.push(c.key),l(c.children))};return l(i),s}function za(e,r){const n=e.collapsedGroups||[],i=n.includes(r)?n.filter(s=>s!==r):[...n,r];return{...e,collapsedGroups:i}}function Ji(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function Ki(e,r,n){return`${r}: ${n}`}function Wr(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Re(e){return"children"in e}function St(){return{id:Wr(),operator:"and",children:[]}}function Oe(e){return e?Array.isArray(e)?{id:Wr(),operator:"and",children:e.map(r=>({...r,id:r.id??Wr()}))}:e:St()}function dt(e){return e?Re(e)?e.children.reduce((r,n)=>r+dt(n),0):1:0}function vo(e,r){if(e.id===r)return e;for(const n of e.children){if(n.id===r)return n;if(Re(n)){const i=vo(n,r);if(i)return i}}}function Pr(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>Re(i)?Pr(i,r,n):i)}}function Bn(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!Re(i)?{...i,...n}:Re(i)?Bn(i,r,n):i)}}function Dn(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>Re(i)?Dn(i,r,n):i)}}function On(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>Re(i)?On(i,r):i).filter(i=>!Re(i)||i.children.length>0);return{...e,children:n}}function Sn(e,r){return e?Re(e)?e.children.some(n=>Sn(n,r)):e.column===r:!1}function Xi(e,r){const n=e.children.filter(i=>Re(i)||i.column!==r).map(i=>Re(i)?Xi(i,r):i).filter(i=>!Re(i)||i.children.length>0);return{...e,children:n}}function Qi(e){return e?Re(e)?e.children.flatMap(Qi):[e]:[]}function Zr(e){if(!e)return null;if(!Re(e)){const{id:i,...s}=e;return s}const{id:r,...n}=e;return{...n,children:e.children.map(Zr)}}function qr(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 $n(e,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(l=>l.column),s=e.filter(l=>!i.includes(l));if(n){const l=[],d=new Set(i),c=new Set(s);let u=0;for(const m of n)d.has(m)?l.push(m):c.has(m)&&u<s.length?(l.push(s[u]),u++):c.has(m)||l.push(m);for(let m=u;m<s.length;m++)l.includes(s[m])||l.push(s[m]);return l}return[...e]}function ln(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:St(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Ea(e,r,n,i,s,l,d,c){const u={},m=[],f={};n.forEach(b=>{u[b.name]=!0,m.push(b.name),f[b.name]=170});const v=$n(s||m,d||null,c||m);return{filters:Oe(e),sortStack:r||[],columnVisibility:i||u,columnOrder:v,columnWidths:l||f,grouping:d||null}}function Ba(e,r){const n=b=>{if(b==null)return b;if(Array.isArray(b))return b.map(z=>n(z));if(typeof b=="object"){const z={};return Object.keys(b).sort().forEach(S=>{z[S]=n(b[S])}),z}return b},i=b=>JSON.stringify(n(b));if(i(Zr(e.filters))!==i(Zr(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},l=r.columnVisibility??{};if(i(s)!==i(l))return!0;const d=$n(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),c=[...d].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(c!==u)return!1;const m=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==m){if(d.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const b=[...d].sort().join(",");if(d.join(",")!==b)return!0}const x=e.columnWidths??{},v=r.columnWidths??{};return i(x)!==i(v)||i(e.grouping)!==i(r.grouping)}function Da(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function Oa(e,r){var S,y,w;const n=[],i=JSON.stringify(Zr(e.filters)),s=JSON.stringify(Zr(r.filters));if(i!==s){const C=dt(e.filters),E=dt(r.filters);C>E?n.push({category:"filters",label:"Filters Added",description:`${C-E} new filter${C-E>1?"s":""} added`}):C<E?n.push({category:"filters",label:"Filters Removed",description:`${E-C} filter${E-C>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const l=JSON.stringify(e.sortStack),d=JSON.stringify(r.sortStack);if(l!==d){const C=e.sortStack.length,E=r.sortStack.length;C>E?n.push({category:"sorting",label:"Sorting Added",description:`${C-E} new sort rule${C-E>1?"s":""} added`}):C<E?n.push({category:"sorting",label:"Sorting Removed",description:`${E-C} sort rule${E-C>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const c=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(c!==u){const C=Object.values(e.columnVisibility).filter(g=>g).length,E=Object.values(r.columnVisibility).filter(g=>g).length;C>E?n.push({category:"visibility",label:"Columns Shown",description:`${C-E} column${C-E>1?"s":""} made visible`}):C<E?n.push({category:"visibility",label:"Columns Hidden",description:`${E-C} column${E-C>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const m=JSON.stringify(e.columnOrder),f=JSON.stringify(r.columnOrder);m!==f&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const x=JSON.stringify(e.columnWidths),v=JSON.stringify(r.columnWidths);if(x!==v){const C=Object.keys(e.columnWidths).filter(E=>e.columnWidths[E]!==r.columnWidths[E]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${C} column width${C>1?"s":""} modified`})}const b=JSON.stringify(e.grouping),z=JSON.stringify(r.grouping);if(b!==z){const C=(S=e.grouping)==null?void 0:S.enabled,E=(y=r.grouping)==null?void 0:y.enabled;if(C&&!E){const g=((w=e.grouping)==null?void 0:w.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${g} grouping level${g>1?"s":""} added`})}else!C&&E?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 Zn(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function ei(e){return`[${e}]`}const Et={warn(e,r,...n){Zn()&&console.warn(ei(e),r,...n)},error(e,r,...n){Zn()&&console.error(ei(e),r,...n)}},Zi="urm_report_";function $a(e,r){try{const n=`${Zi}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Et.error("urm:persistence","Failed to save report state",n)}}function Aa(e){try{const r=`${Zi}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Et.error("urm:persistence","Failed to load report state",r),null}}function Oo(e,r,n=0){const i=[];for(const s of e){const l=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:l}),!l&&s.children&&s.children.length>0){const d=s.children[0];if(_a(d)){const c=s.children,u=Oo(c,r,n+1);i.push(...u)}else{const c=s.children;for(const u of c)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function _a(e){return e&&typeof e=="object"&&"key"in e&&"level"in e&&"column"in e&&"value"in e&&"rowCount"in e&&"aggregates"in e&&"children"in e}function An(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function _n(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),l=String(n.getDate()).padStart(2,"0"),d=`${i}-${s}-${l}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${d}.${r}`}function wo(e,r,n,i,s,l,d){let c,u;l?(c={...l},u=d||r.map(f=>f.name)):s?(c={...s.snapshot.columnVisibility},u=d||[...s.snapshot.columnOrder]):(c={},u=[],r.forEach(f=>{c[f.name]=!0,u.push(f.name)}));const m=Object.entries(c).filter(([f,x])=>!x).map(([f,x])=>f);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:c,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:m,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function ko(e,r="export",n){const{data:i,columnOrder:s,grouping:l}=e,d=s.filter(x=>e.columnVisibility[x]);let c;if(l&&l.enabled){const x=l.collapsedGroups??[],v=Oo(i,x);c=An(v)}else c=i;const u=d.join(","),m=c.map(x=>d.map(v=>{const b=x[v];if(b==null)return"";const z=String(b);return z.includes(",")||z.includes('"')||z.includes(`
2
- `)?`"${z.replace(/"/g,'""')}"`:z}).join(",")),f=[u,...m].join(`
3
- `);es(f,_n(r,"csv"),"text/csv;charset=utf-8;")}function To(e,r="export",n){const{data:i,columnOrder:s,grouping:l}=e,d=s.filter(x=>e.columnVisibility[x]);let c;if(l&&l.enabled){const x=l.collapsedGroups??[],v=Oo(i,x);c=An(v)}else c=i;const u=[d,...c.map(x=>d.map(v=>x[v]??""))],m=po.utils.aoa_to_sheet(u),f=po.utils.book_new();po.utils.book_append_sheet(f,m,"Data"),po.writeFile(f,_n(r,"xlsx"))}function Io(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:l,viewMeta:d,hiddenColumns:c,columnOrder:u,grouping:m}=e;let f;if(m&&m.enabled){const b=m.collapsedGroups??[],z=Oo(i,b);f=An(z)}else f=i;const x={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(d==null?void 0:d.name)||"Default View",filters:Qi(s).map(b=>({field:b.column,operator:b.operator,value:b.value})),sortStack:l.map(b=>({field:b.column,direction:b.direction,priority:b.priority})),grouping:m||{},hiddenColumns:c,columnOrder:u,exportConfig:n||{scope:"visible"}},data:f},v=JSON.stringify(x,null,2);es(v,_n(r,"json"),"application/json;charset=utf-8;")}function es(e,r,n){const i=new Blob([e],{type:n}),s=URL.createObjectURL(i),l=document.createElement("a");l.href=s,l.download=r,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(s)}const ti=10;function Ma(e,r){const n=r.trim();if(!n)return e;const i=e.findIndex(l=>l.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>ti&&(s=[...s].sort((d,c)=>d.isFavourite&&!c.isFavourite?-1:!d.isFavourite&&c.isFavourite?1:c.lastUsed-d.lastUsed).slice(0,ti)),s}function Ra(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function Wa(e,r){return e.filter(n=>n.query!==r)}function Pa(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 Na={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 La(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function at(e,r){return Na[r].includes(e)}function lt(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 Fa(e){return e==="viewer"}const ri=1e3;function Cn(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function zt(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return Cn(n)}const Va={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 Ha(e){if(!e||!e.column)return"a filter";const r=zt(e.column),n=Va[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function cn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":Ha(e):"a filter"}function oi(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${zt(n.column)}"`).join(", ")}`}function Ua(e){var s,l,d;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${cn(i)}`};case"filter_removed":return{summary:`Filter removed: ${cn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const c=n,u=i;return c!=null&&c.column&&(u!=null&&u.column)&&c.column!==u.column?{summary:`Filter changed on "${zt(u.column)}"`,detail:`Previously filtered "${zt(c.column)}"`}:{summary:`Filter updated: ${cn(u)}`}}case"filter_cleared":{const c=n&&typeof n=="object"&&"count"in n?n.count:0;return{summary:c>0?`All filters cleared (${c} filter${c!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const c=i!=null&&i.column?zt(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:c?`Sort added: "${c}" ${u}`:"Sort level added"}}case"sort_level_removed":{const c=n!=null&&n.column?zt(n.column):"";return{summary:c?`Sort removed: "${c}"`:"Sort level removed"}}case"sort_reordered":return{summary:"Sort order changed"};case"sort_cleared":return{summary:"All sorting cleared"};case"group_level_added":return{summary:`Grouping applied: ${oi(i)}`};case"group_level_removed":{const c=n,u=(l=(s=c==null?void 0:c.levels)==null?void 0:s[0])!=null&&l.column?zt(c.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${oi(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const c=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:c?`Column hidden: "${zt(c)}"`:"Column hidden"}}case"column_shown":{const c=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:c?`Column shown: "${zt(c)}"`:"Column made visible"}}case"column_reordered":{const c=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return c.length>0&&u.length>0?{summary:"Column order changed",detail:`${u.length} column${u.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const c=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:c?`Column resized: "${zt(c)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const c=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:c?`View created: "${c}"`:"New view created"}}case"view_updated":{const c=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:c?`View updated: "${c}"`:"View updated"}}case"view_deleted":{const c=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:c?`View deleted: "${c}"`:"View deleted"}}case"view_set_default":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Default view set to "${c}"`:"Default view changed"}}case"view_switched":{const c=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return c&&u?{summary:`Switched to view "${u}"`,detail:`From "${c}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":{const c=r==="export_csv"?"CSV":r==="export_excel"?"Excel":"JSON",u=i==null?void 0:i.rowCount,m=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",f=(i==null?void 0:i.viewName)??"",x=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${c}${x}`,detail:f?`${Cn(m)} · View: "${f}"`:Cn(m)}}case"export_triggered":{const c=((d=i==null?void 0:i.format)==null?void 0:d.toUpperCase())??"";return{summary:c?`Export triggered: ${c}`:"Export triggered"}}case"preset_created":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset created: "${c}"`:"New preset created"}}case"preset_applied":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset applied: "${c}"`:"Preset applied"}}case"preset_deleted":{const c=(n==null?void 0:n.name)??"";return{summary:c?`Preset deleted: "${c}"`:"Preset deleted"}}case"preset_link_copied":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset link copied: "${c}"`:"Preset link copied to clipboard"}}case"theme_changed":{const c=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return c&&u?{summary:`Theme changed from "${c}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const c=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:c?`Details: ${String(c).slice(0,120)}`:void 0}}default:return{summary:Ya(r)}}}function Ga(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function ts(e,r,n,i,s,l){return{id:Ga(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:l}}function rs(e,r){const n=[r,...e];return n.length>ri?n.slice(0,ri):n}function Ya(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",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",error_occurred:"Error Occurred"}[e]||e}function qa(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[e]||e}function Ja(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),l=Math.floor(i/36e5),d=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:l<24?`${l} hour${l>1?"s":""} ago`:d<7?`${d} day${d>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const ni=100;function Ka(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Xa(e){var l;const r=(l=e.views)==null?void 0:l.find(d=>d.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=$n(i,e.grouping||null,n);return{filters:Oe(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 Qa(e,r,n,i){return{id:Ka(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function Za(e,r){const n=e||[];if(n.length>=ni)throw new Error(`Maximum of ${ni} presets reached. Please delete old presets first.`);return[...n,r]}function el(e,r){return(e||[]).filter(i=>i.id!==r)}function ii(e,r){if(e)return e.find(n=>n.id===r)}function tl(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function rl(e){const r=e.columnOrder,n=qr(r,e.grouping);return{filters:Oe(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 ol(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Et.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){Et.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Et.error("urm:presets","Fallback copy method failed",r),!1}}function nl(e,r){return{totalRows:e.length,totalColumns:r.length}}function Zt(e,r,n,i){const s=n instanceof Error?n.message:n,l={type:e,context:r,message:s,details:i,timestamp:Date.now(),recoverable:il(e,r)};return process.env.NODE_ENV==="development"&&Et.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),l}function il(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function sl(e){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[e.context]||"An error occurred";return e.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function al(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 ll(e,r,n){n(e.id,{filters:Oe(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function cl(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 os(e,r){const n=[],i=[],s=new Set(r.map(l=>l.name));return e.forEach(l=>{s.has(l.column)?n.push(l):i.push(l.column)}),{validRules:n,invalidColumns:i}}function ns(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(l=>l.name)),i=[],s=[];return e.levels.forEach(l=>{n.has(l.column)?i.push(l):s.push(l.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(l=>l.name)),s={...e};if(s.filters){const l=d=>{const c=d.children.filter(u=>{if(Re(u))return!0;const m=i.has(u.column);return m||n.push(`Filter for column "${u.column}" ignored (column not found)`),m}).map(u=>Re(u)?l(u):u).filter(u=>!Re(u)||u.children.length>0);return{...d,children:c}};s.filters=l(Oe(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:l,invalidColumns:d}=os(s.sortStack,r);d.length>0&&n.push(`Sort rules for columns ignored: ${d.join(", ")}`),s.sortStack=l.length>0?l:void 0}if(s.grouping){const{validGrouping:l,invalidColumns:d}=ns(s.grouping,r);d.length>0&&n.push(`Grouping for columns ignored: ${d.join(", ")}`),s.grouping=l}if(s.columnVisibility){const l={};Object.entries(s.columnVisibility).forEach(([d,c])=>{i.has(d)?l[d]=c:n.push(`Column visibility for "${d}" ignored (column not found)`)}),s.columnVisibility=Object.keys(l).length>0?l:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const l=s.columnOrder.filter(d=>{const c=i.has(d);return c||n.push(`Column "${d}" in order ignored (column not found)`),c});s.columnOrder=l.length>0?l:void 0}if(s.columnWidths){const l={};Object.entries(s.columnWidths).forEach(([d,c])=>{i.has(d)?l[d]=c:n.push(`Column width for "${d}" ignored (column not found)`)}),s.columnWidths=Object.keys(l).length>0?l:void 0}return{sanitizedConfig:s,warnings:n}}function ul(e,r){return Zt("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function si(e,r,n,i){const s=ts(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return rs(i||[],s)}function pl(e){return e==null}function xl(e,r,n){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(pl(e))return!1;if(n==="date"){const l=new Date(e).getTime(),d=new Date(s).getTime();switch(i){case"equals":return l===d;case"gt":return l>d;case"lt":return l<d;case"gte":return l>=d;case"lte":return l<=d;default:return!0}}switch(i){case"equals":return String(e)===String(s);case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function jn(e,r,n){var s;if(Re(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(l=>jn(e,l,n)):r.children.some(l=>jn(e,l,n));const i=((s=n.find(l=>l.name===r.column))==null?void 0:s.type)??"string";return xl(e[r.column],r,i)}function ml(e,r,n){return!r||r.children.length===0?e:e.filter(i=>jn(i,r,n))}function zo(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 fl(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function hl({data:e,filters:r,schema:n}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:ml(e,r,n),[e,r,n])}}function gl(e,r,n,i){if(!n||n.trim()==="")return e;const s=n.toLowerCase().trim(),l=r.filter(d=>i.includes(d.name));return e.filter(d=>l.some(c=>{const u=d[c.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function yl({data:e,searchQuery:r,schema:n,visibleColumns:i}){return{searchedData:p.useMemo(()=>!r||r.trim()===""?e:gl(e,n,r,i),[e,r,n,i])}}function bl({data:e,sortStack:r,schema:n}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:Sa(e,n,r),[e,r,n])}}function vl({data:e,grouping:r,schema:n}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:Ta(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 Sl({schema:e,columnVisibility:r,columnOrder:n}){const i=p.useMemo(()=>n.filter(c=>r[c]!==!1),[n,r]),s=p.useMemo(()=>Object.entries(r).filter(([c,u])=>!u).map(([c,u])=>c),[r]),l=p.useMemo(()=>n.map(c=>e.find(m=>m.name===c)||{name:c,type:"string"}),[n,e]),d=p.useMemo(()=>i.map(c=>e.find(m=>m.name===c)||{name:c,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:l,visibleColumnSchemas:d,hiddenCount:s.length}}function Cl({views:e,activeViewId:r,currentState:n}){const i=p.useMemo(()=>e.find(m=>m.id===r),[e,r]),s=p.useMemo(()=>i?Ba(n,i.snapshot):!1,[i,n]),l=p.useMemo(()=>e.find(m=>m.isDefault),[e]),d=p.useMemo(()=>e.filter(m=>!m.isDefault&&!m.isDeleted),[e]),c=p.useMemo(()=>e.filter(m=>m.isFavorite&&!m.isDeleted),[e]),u=p.useMemo(()=>e.filter(m=>m.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:l,customViews:d,favoriteViews:c,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function jl({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,l]=p.useState(i),d=e.length,c=Math.ceil(d/n),u=p.useMemo(()=>{if(!r)return e;const b=(s-1)*n,z=b+n;return e.slice(b,z)},[e,r,s,n]),m=p.useCallback(b=>{const z=Math.max(1,Math.min(b,c));l(z)},[c]),f=p.useCallback(()=>{s<c&&l(s+1)},[s,c]),x=p.useCallback(()=>{s>1&&l(s-1)},[s]),v=p.useCallback(()=>{l(1)},[]);return{paginatedData:u,currentPage:s,totalPages:c,pageSize:n,totalRows:d,goToPage:m,nextPage:f,prevPage:x,resetPage:v,hasNextPage:s<c,hasPrevPage:s>1}}function wl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:l,searchQuery:d,columnVisibility:c,columnOrder:u,columnWidths:m,views:f,activeViewId:x,pagination:v}=e,b=p.useMemo(()=>({filters:i,sortStack:s,grouping:l,columnVisibility:c,columnOrder:u,columnWidths:m}),[i,s,l,c,u,m]),z=Cl({views:f,activeViewId:x,currentState:b}),S=Sl({schema:n,columnVisibility:c,columnOrder:u}),{filteredData:y}=hl({data:r,filters:i,schema:n}),{sortedData:w}=bl({data:y,sortStack:s,schema:n}),{groupedData:C,isGrouped:E}=vl({data:w,grouping:l,schema:n}),{searchedData:g}=yl({data:C,searchQuery:d,schema:n,visibleColumns:S.visibleColumns}),k=jl({data:g,enabled:(v==null?void 0:v.enabled)||!1,pageSize:(v==null?void 0:v.pageSize)||100,initialPage:(v==null?void 0:v.currentPage)||1}),L=v!=null&&v.enabled?k.paginatedData:g,a=p.useMemo(()=>({totalRows:r.length,filteredRows:y.length,sortedRows:w.length,groupedRows:E?C.length:w.length,searchedRows:g.length,visibleRows:L.length,hiddenColumns:S.hiddenCount,activeFilters:dt(i),activeSorts:s.length,isGrouped:E}),[r.length,y.length,w.length,C.length,g.length,L.length,S.hiddenCount,i,s.length,E]);return{data:L,filteredData:y,sortedData:w,groupedData:C,searchedData:g,viewEngine:z,columnEngine:S,paginationEngine:k,metrics:a,isGrouped:E,isPaginated:(v==null?void 0:v.enabled)||!1}}let kl=0;function Tl(e){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:kl++,writable:!1,enumerable:!1,configurable:!1})}const vt="user-demo-001";function Il(e={}){var Un,Gn,Yn,qn,Jn;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:l,sharedReportId:d,sharedViewId:c,config:u={}}=e,[m,f]=p.useState([]),x=Sr(),[v,b]=p.useState(""),[z,S]=p.useState(!1),[y,w]=p.useState(!1),[C,E]=p.useState({message:"",severity:"info",open:!1}),g=(j,I="info")=>{E({message:j,severity:I,open:!0})},k=()=>E(j=>({...j,open:!1})),L=u.notifDurationMs??2e3,a=m.find(j=>j.id===v),[_,F]=p.useState("idle"),[X,re]=p.useState(!1),[h,V]=p.useState(!1),[W,Q]=p.useState(!1),[Z,pe]=p.useState(!1),[he,N]=p.useState(!1),[R,H]=p.useState(void 0),[G,ae]=p.useState(null),[ee,ne]=p.useState(null),[oe,O]=p.useState(!1),[te,ce]=p.useState(!1),[ie,Ie]=p.useState(null),[q,Me]=p.useState(!1),[et,tt]=p.useState(!1),[rr,Ft]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[Vt,rt]=p.useState(""),[pt,or]=p.useState(""),[Ct,Je]=p.useState(new Set),[jt,Bt]=p.useState(1),[Ht,nr]=p.useState(15),[ir,He]=p.useState(!1),[no,sr]=p.useState(!1),[Ut,ot]=p.useState(!1),[nt,ar]=p.useState(null),[lr,wt]=p.useState(!1),[wr,xt]=p.useState(null),[Nr,cr]=p.useState(null),dr=p.useRef(null),me=p.useMemo(()=>a?La(a.permissions,vt):"owner",[a]),kr=Fa(me),io=p.useMemo(()=>!(a!=null&&a.uploadedData)||!(a!=null&&a.schema)?{totalRows:0,totalColumns:0}:nl(a.uploadedData,a.schema),[a==null?void 0:a.uploadedData,a==null?void 0:a.schema]),kt=p.useCallback(()=>{a&&(dr.current=al(a))},[a]),P=p.useCallback((j,I)=>{f(A=>A.map($=>$.id===j?{...$,...I}:$))},[]),mt=p.useCallback(j=>{if(!a)return;cr(j);const I=si(a.id,vt,j,a.auditHistory||[]);P(a.id,{auditHistory:I}),g(j.message,"error"),j.recoverable&&dr.current&&setTimeout(()=>{ll(a,dr.current,P),g("Previous state restored","success")},100)},[a,P]),fe=p.useCallback((j,I,A,$)=>{if(!a)return;const U=ts(a.id,vt,j,I,A,$),Y=a.auditHistory||[],de=rs(Y,U);setTimeout(()=>{P(a.id,{auditHistory:de})},0)},[a,P]);p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const j=ln(a.schema);(()=>{try{const I=localStorage.getItem("urm_dev_config");return I?JSON.parse(I):null}catch{return null}})(),P(a.id,{views:[j],activeViewId:j.id,filters:j.snapshot.filters,sortStack:j.snapshot.sortStack,columnVisibility:j.snapshot.columnVisibility,columnOrder:j.snapshot.columnOrder,columnWidths:j.snapshot.columnWidths,grouping:j.snapshot.grouping})}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id,P]),p.useEffect(()=>{if(i&&n&&!y&&m.length===0){const j=bo(i),I={id:`auto-report-${Date.now()}`,name:l||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:j,schema:Hr(j),permissions:{owner:vt,editors:[],viewers:[]}};f([I]),b(I.id),w(!0),F("confirmed")}},[i,n,y,m.length,r,l]),p.useEffect(()=>{if(!s||y)return;let j=!1,I=null;const A=async()=>{try{F("uploading");let $;if(s.type==="api"){const Y=await fetch(s.url,{headers:s.headers||{}});if(!Y.ok)throw new Error(`HTTP ${Y.status}: ${Y.statusText}`);$=await Y.json()}else $=await s.fetch();if(j)return;if(!Array.isArray($))throw new Error("Data source must return an array of objects");const U=Hr($);if(y)f(Y=>Y.map(de=>de.id===v?{...de,uploadedData:$}:de)),F("confirmed");else{const Y={id:`auto-report-${Date.now()}`,name:l||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:bo($),schema:Hr(bo($)),permissions:{owner:vt,editors:[],viewers:[]}};f([Y]),b(Y.id),w(!0),F("confirmed")}}catch($){j||(F("error"),a&&P(a.id,{uploadError:($==null?void 0:$.message)||"Failed to load data from source"}))}};return A(),s.refreshInterval&&s.refreshInterval>0&&(I=setInterval(A,s.refreshInterval)),()=>{j=!0,I&&clearInterval(I)}},[s,l,r]);const Le=(Un=a==null?void 0:a.views)==null?void 0:Un.find(j=>j.id===a.activeViewId),Dt=p.useMemo(()=>a!=null&&a.uploadedData?(a.uploadedData.forEach(Tl),a.uploadedData):[],[a==null?void 0:a.uploadedData]),ft=wl({rawData:Dt,schema:(a==null?void 0:a.schema)||[],filters:Oe(a==null?void 0:a.filters),sortStack:(a==null?void 0:a.sortStack)||[],grouping:(a==null?void 0:a.grouping)||null,searchQuery:pt||"",columnVisibility:(a==null?void 0:a.columnVisibility)||(Le==null?void 0:Le.snapshot.columnVisibility)||{},columnOrder:(a==null?void 0:a.columnOrder)||(Le==null?void 0:Le.snapshot.columnOrder)||[],columnWidths:(a==null?void 0:a.columnWidths)||(Le==null?void 0:Le.snapshot.columnWidths)||{},views:(a==null?void 0:a.views)||[],activeViewId:(a==null?void 0:a.activeViewId)||"",pagination:{enabled:!0,pageSize:Ht,currentPage:jt}}),{data:Gt=[],searchedData:Tt=[],groupedData:Tr=[],sortedData:Yt=[],metrics:ur={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:qt=!1,paginationEngine:ze}=ft||{},K=((Gn=ft.viewEngine)==null?void 0:Gn.activeView)||Le,Ot=((Yn=ft.viewEngine)==null?void 0:Yn.isDirty)||!1;p.useEffect(()=>{if(!(!K||!a)&&!a.columnOrder){const j=K.snapshot.columnOrder,I=qr(j,K.snapshot.grouping);P(a.id,{columnOrder:I})}},[a==null?void 0:a.activeViewId]);const we=p.useMemo(()=>!(a!=null&&a.schema)||!K?null:Ea(a.filters,a.sortStack||[],a.schema,a.columnVisibility,a.columnOrder,a.columnWidths,a.grouping,K.snapshot.columnOrder),[a==null?void 0:a.filters,a==null?void 0:a.sortStack,a==null?void 0:a.schema,a==null?void 0:a.columnVisibility,a==null?void 0:a.columnOrder,a==null?void 0:a.columnWidths,a==null?void 0:a.grouping,K]),Ir=p.useMemo(()=>!K||!we||!Ot?[]:Oa(we,K.snapshot),[K,we,Ot]),pr=p.useCallback((j,I,A)=>{const $={id:`report-${Date.now()}`,name:j,description:I,schemaLocked:!1,permissions:{owner:vt,editors:[],viewers:[]}};if(A&&Array.isArray(A)&&A.length>0){const U=Hr(A),Y=ln(U);$.uploadedData=A,$.schema=U,$.schemaLocked=!0,$.views=[Y],$.activeViewId=Y.id,$.sortStack=Y.snapshot.sortStack,$.filters=Y.snapshot.filters,$.columnVisibility=Y.snapshot.columnVisibility,$.columnOrder=Y.snapshot.columnOrder,$.columnWidths=Y.snapshot.columnWidths,$.grouping=Y.snapshot.grouping}f(U=>[...U,$]),b($.id),S(!1),F("confirmed")},[]),Se=p.useCallback(j=>{a&&(F("uploading"),setTimeout(()=>{const I=Hr(j);P(a.id,{uploadedData:j,schema:I,uploadError:void 0}),F("preview")},500))},[a,P]),Fe=p.useCallback(j=>{a&&(P(a.id,{uploadError:j}),F("idle"))},[a,P]),xr=p.useCallback(()=>{a&&(P(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),F("idle"))},[a,P]),it=p.useCallback(()=>{a&&(P(a.id,{schemaLocked:!0}),F("confirmed"))},[a,P]),ht=p.useCallback(j=>{if(!a)return;if(!at("edit_sorting",me)){g(lt("edit_sorting"),"error");return}const I=a.sortStack??[],A=I.find($=>$.column===j);if(A){const $=Ca(A.direction);if($===null){const U=I.filter(Y=>Y.column!==j).map((Y,de)=>({...Y,priority:de+1}));P(a.id,{sortStack:U.length>0?U:void 0})}else{const U=$,Y=I.map(de=>de.column===j?{...de,direction:U}:de);P(a.id,{sortStack:Y})}}else{if(I.length>=x.sort.maxLevels){g(`Sort limit reached — maximum ${x.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:j,direction:"asc",priority:I.length+1};P(a.id,{sortStack:[...I,$]})}},[a,me,P]),Ve=p.useCallback(j=>{if(a)if(a.schema){const{validRules:I,invalidColumns:A}=os(j,a.schema);A.length>0&&g(`Removed invalid sort columns: ${A.join(", ")}`),kt();try{P(a.id,{sortStack:I.length>0?I:void 0})}catch($){const U=Zt("processing","sorting",$);mt(U)}}else P(a.id,{sortStack:j.length>0?j:void 0})},[a,P,kt,mt]),mr=p.useCallback(j=>{if(!a)return;const I=a.sortStack??[],A=I.find($=>$.column===j);if(!(A&&A.direction==="asc"))if(A){const $=I.map(U=>U.column===j?{...U,direction:"asc"}:U);P(a.id,{sortStack:$})}else{if(I.length>=x.sort.maxLevels){g(`Sort limit reached — maximum ${x.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:j,direction:"asc",priority:I.length+1};P(a.id,{sortStack:[...I,$]})}},[a,P]),zr=p.useCallback(j=>{if(!a)return;const I=a.sortStack??[],A=I.find($=>$.column===j);if(!(A&&A.direction==="desc"))if(A){const $=I.map(U=>U.column===j?{...U,direction:"desc"}:U);P(a.id,{sortStack:$})}else{if(I.length>=x.sort.maxLevels){g(`Sort limit reached — maximum ${x.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const $={column:j,direction:"desc",priority:I.length+1};P(a.id,{sortStack:[...I,$]})}},[a,P]),gt=p.useCallback((j,I)=>{var $;if(!a)return;if(!at("edit_filters",me)){g(lt("edit_filters"),"error");return}const A=($=a.schema)==null?void 0:$.find(U=>U.name===I.column);if(A&&I.value!==void 0){const U=cl(A.type,I.operator,I.value);if(!U.isValid){g(U.errorMessage||"Invalid filter value","error");return}}kt();try{const U=Oe(a.filters),Y={...I,id:Wr()},de=Pr(U,j,Y);fe("filters","filter_added",null,Y),P(a.id,{filters:de})}catch(U){const Y=Zt("processing","filters",U);mt(Y)}},[a,me,P,kt,mt,fe]),Ue=p.useCallback(j=>{if(!a)return;if(!at("edit_filters",me)){g(lt("edit_filters"),"error");return}const I=Oe(a.filters),A=Pr(I,j,St());fe("filters","filter_added",null,"a condition group"),P(a.id,{filters:A})},[a,me,P,fe]),Er=p.useCallback((j,I)=>{if(!a)return;if(!at("edit_filters",me)){g(lt("edit_filters"),"error");return}const A=Oe(a.filters),$=vo(A,j),U=Bn(A,j,I),Y=vo(U,j);fe("filters","filter_updated",$,Y),P(a.id,{filters:U})},[a,me,P,fe]),Lr=p.useCallback((j,I)=>{if(!a)return;if(!at("edit_filters",me)){g(lt("edit_filters"),"error");return}const A=Oe(a.filters),$=Dn(A,j,I);fe("filters","filter_updated",null,`group operator changed to ${I.toUpperCase()}`),P(a.id,{filters:$})},[a,me,P,fe]),$t=p.useCallback(j=>{if(!a)return;if(!at("edit_filters",me)){g(lt("edit_filters"),"error");return}const I=Oe(a.filters),A=vo(I,j),$=On(I,j);fe("filters","filter_removed",A,null),P(a.id,{filters:$})},[a,me,P,fe]),Jt=p.useCallback(()=>{if(!a)return;if(!at("edit_filters",me)){g(lt("edit_filters"),"error");return}const j=Oe(a.filters);fe("filters","filter_cleared",{count:dt(j)},null),P(a.id,{filters:St()})},[a,me,P,fe]),Fr=p.useCallback(j=>{if(!a)return;if(!at("edit_filters",me)){g(lt("edit_filters"),"error");return}const I=Oe(a.filters);fe("filters","filter_cleared",{count:dt(I)},{count:dt(j)}),P(a.id,{filters:j})},[a,me,P,fe]),st=p.useCallback(j=>{var U;if(!a)return;const I=(U=a.views)==null?void 0:U.find(Y=>Y.id===j);if(!I)return;const A=I.snapshot.columnOrder,$=qr(A,I.snapshot.grouping);P(a.id,{filters:I.snapshot.filters,sortStack:I.snapshot.sortStack.length>0?[...I.snapshot.sortStack]:void 0,columnVisibility:{...I.snapshot.columnVisibility},columnOrder:$,columnWidths:{...I.snapshot.columnWidths},grouping:I.snapshot.grouping,activeViewId:j}),Je(new Set)},[a,P]),Kt=p.useCallback((j,I,A)=>{var We;if(!(a!=null&&a.schema)||!we)return;const $=a.views??[],U=$.filter(an=>!an.isDeleted).length,Y=((We=x.views)==null?void 0:We.maxViews)??10;if(U>=Y){g(`View limit reached — you can have at most ${Y} 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:j,description:I||void 0,isDefault:A,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:vt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...we}},ye=A?$.map(an=>({...an,isDefault:!1})):$;P(a.id,{views:[...ye,de],activeViewId:de.id}),g(`"${j}" view created`,"success")},[a,we,P]),Br=p.useCallback(j=>{var de;if(!(a!=null&&a.views))return;const I=a.views.find(ye=>ye.id===j);if(!I)return;const A=a.views,$=A.filter(ye=>!ye.isDeleted).length,U=((de=x.views)==null?void 0:de.maxViews)??10;if($>=U){g(`View limit reached — you can have at most ${U} saved views. Delete an existing view to create a new one.`,"error");return}const Y={...I,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${I.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:vt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...I.snapshot}};P(a.id,{views:[...A,Y]}),g(`"${Y.name}" created`,"success")},[a,x,P]),At=p.useCallback(()=>{var I;if(!K||!we||!a)return;const j=(I=a.views)==null?void 0:I.map(A=>A.id===K.id?{...A,snapshot:{...we}}:A);P(a.id,{views:j}),g(`"${K.name}" view updated`,"success")},[K,we,a,P]),_t=p.useCallback(j=>{var $;if(!K||!we||!a)return;const I=j??we.columnWidths,A=($=a.views)==null?void 0:$.map(U=>U.id===K.id?{...U,snapshot:{...U.snapshot,columnVisibility:we.columnVisibility,columnOrder:we.columnOrder,columnWidths:I},updatedAt:Date.now()}:U);P(a.id,{views:A,columnWidths:I}),g(`Column configuration saved to "${K.name}"`,"success")},[K,we,a,P]),fr=p.useCallback(j=>{var Y,de;if(!we||!a||!K)return;const I=j??we.columnWidths,A={...K,snapshot:{...K.snapshot,columnVisibility:we.columnVisibility,columnOrder:we.columnOrder,columnWidths:I},updatedAt:Date.now()},$=(Y=a.views)==null?void 0:Y.map(ye=>ye.id===K.id?A:{...ye,snapshot:{...ye.snapshot,columnVisibility:we.columnVisibility,columnOrder:we.columnOrder,columnWidths:I},updatedAt:Date.now()});P(a.id,{views:$,columnWidths:I});const U=(((de=a.views)==null?void 0:de.length)||0)-1;g(`Column configuration saved to current view and ${U} other view${U===1?"":"s"}`,"success")},[we,a,K,P]),le=p.useCallback(()=>{Q(!0)},[]),ge=p.useCallback(()=>{if(!K||!a)return;const j=K.snapshot.columnOrder,I=qr(j,K.snapshot.grouping);P(a.id,{filters:K.snapshot.filters,sortStack:K.snapshot.sortStack.length>0?[...K.snapshot.sortStack]:void 0,columnVisibility:{...K.snapshot.columnVisibility},columnOrder:I,columnWidths:{...K.snapshot.columnWidths},grouping:K.snapshot.grouping}),g("Changes reverted to last saved state","success")},[K,a,P]),Ae=p.useCallback(j=>{if(!(a!=null&&a.views))return;const I=a.views.map($=>({...$,isDefault:$.id===j}));P(a.id,{views:I});const A=a.views.find($=>$.id===j);A&&g(`"${A.name}" set as default view`,"success")},[a,P]),yt=p.useCallback(j=>{if(!(a!=null&&a.views))return;const I=a.views.map($=>$.id===j?{...$,isFavorite:!$.isFavorite,updatedAt:Date.now()}:$);P(a.id,{views:I});const A=a.views.find($=>$.id===j);A&&!A.isFavorite?g(`"${A.name}" added to favorites`,"success"):A&&g(`"${A.name}" removed from favorites`,"info")},[a,P]),bt=p.useCallback(j=>{if(!(a!=null&&a.views))return;const I=a.views.find(We=>We.id===j),A=a.views.filter(We=>!We.isDeleted||We.id===j);if((I==null?void 0:I.isDefault)&&A.filter(We=>We.isDefault).length===1){g("Cannot delete the last default view","error");return}const U=a.views.map(We=>We.id===j?{...We,isDeleted:!0,updatedAt:Date.now()}:We),Y=a.activeViewId===j,de=U.find(We=>We.isDefault&&!We.isDeleted);P(a.id,{views:U,activeViewId:Y&&de?de.id:a.activeViewId,filters:Y&&de?de.snapshot.filters:a.filters,sortStack:Y&&de?de.snapshot.sortStack.length>0?de.snapshot.sortStack:void 0:a.sortStack});const ye=a.views.find(We=>We.id===j);ye&&g(`"${ye.name}" moved to Recently Deleted`,"info")},[a,P]),Xt=p.useCallback(j=>{if(!(a!=null&&a.views))return;const I=a.views.map($=>$.id===j?{...$,isDeleted:!1,updatedAt:Date.now()}:$);P(a.id,{views:I});const A=a.views.find($=>$.id===j);A&&g(`"${A.name}" restored`,"success")},[a,P]),so=p.useCallback(j=>{if(!(a!=null&&a.views))return;const I=a.views.find(ye=>ye.id===j),A=a.views.filter(ye=>!ye.isDeleted||ye.id===j);if((I==null?void 0:I.isDefault)&&A.filter(ye=>ye.isDefault).length===1){g("Cannot delete the last default view","error");return}const U=a.views.filter(ye=>ye.id!==j),Y=a.activeViewId===j,de=U.find(ye=>ye.isDefault&&!ye.isDeleted);P(a.id,{views:U,activeViewId:Y&&de?de.id:a.activeViewId,filters:Y&&de?de.snapshot.filters:a.filters,sortStack:Y&&de?de.snapshot.sortStack.length>0?de.snapshot.sortStack:void 0:a.sortStack}),I&&g(`"${I.name}" permanently deleted`,"success")},[a,P]),Dr=p.useCallback(j=>{ae(j),pe(!0)},[]),qo=p.useCallback(async j=>{if(!a)return;const I=new URLSearchParams(window.location.search);I.set("reportId",a.id),I.set("view",j);const A=`${window.location.origin}${window.location.pathname}?${I.toString()}`,$=await ol(A);g($?"Link copied to clipboard":"Failed to copy link",$?"success":"error")},[a]),Jo=p.useCallback((j,I)=>{if(!G||!(a!=null&&a.views))return;const A=a.views.map($=>$.id===G?{...$,name:j,description:I||void 0}:$);P(a.id,{views:A}),ae(null)},[G,a,P]),Ko=p.useCallback(j=>{ne(j),N(!0)},[]),Xo=p.useCallback(()=>{if(!ee||!(a!=null&&a.views))return;const j=a.views.filter($=>$.id!==ee),I=a.activeViewId===ee,A=j.find($=>$.isDefault);P(a.id,{views:j,activeViewId:I&&A?A.id:a.activeViewId,filters:I&&A?A.snapshot.filters:a.filters,sortStack:I&&A?A.snapshot.sortStack.length>0?A.snapshot.sortStack:void 0:a.sortStack}),ne(null),N(!1)},[ee,a,P]),Qo=p.useCallback(j=>{var U;if(!(a!=null&&a.views))return;if(!(((U=x.views)==null?void 0:U.isAdmin)??!1)){g("Only administrators can promote views to Global.","error");return}const A=a.views.find(Y=>Y.id===j);if(!A)return;if(A.scope==="global"){g(`"${A.name}" is already a Global View.`,"info");return}const $=a.views.map(Y=>Y.id===j?{...Y,scope:"global",isDefault:!0,updatedAt:Date.now()}:Y.scope==="global"&&Y.isDefault?{...Y,isDefault:!1}:Y);P(a.id,{views:$}),g(`"${A.name}" promoted to Global View and set as default.`,"success")},[a,x,P]);p.useEffect(()=>{ze!=null&&ze.resetPage?ze.resetPage():Bt(1)},[a==null?void 0:a.filters,pt,a==null?void 0:a.activeViewId]),p.useEffect(()=>{ze&&ze.currentPage!==jt&&Bt(ze.currentPage)},[ze==null?void 0:ze.currentPage]);const Zo=p.useCallback(j=>{ze!=null&&ze.goToPage&&ze.goToPage(j),Bt(j)},[ze]),en=p.useCallback(j=>{const I=(jt-1)*Ht,A=Math.floor(I/j)+1;nr(j),Bt(A),ze==null||ze.goToPage(A)},[jt,Ht,ze]),tn=p.useCallback((j,I)=>{if(!a)return;if(!at("edit_columns",me)){g(lt("edit_columns"),"error");return}const $={...a.columnVisibility||(K==null?void 0:K.snapshot.columnVisibility)||{},[j]:I};P(a.id,{columnVisibility:$})},[a,K,me,P]),rn=p.useCallback(j=>{if(a){if(!at("edit_columns",me)){g(lt("edit_columns"),"error");return}P(a.id,{columnOrder:j})}},[a,me,P]),hr=p.useCallback((j,I)=>{if(!a)return;if(!at("edit_columns",me)){g(lt("edit_columns"),"error");return}const $={...a.columnWidths||(K==null?void 0:K.snapshot.columnWidths)||{},[j]:I};P(a.id,{columnWidths:$})},[a,K,me,P]),Mt=p.useCallback(j=>{if(!a)return;const I=Oe(a.filters),A=Xi(I,j);P(a.id,{filters:A})},[a,P]),on=p.useCallback(()=>{if(!K||!(a!=null&&a.schema))return;const j={},I=[],A={};a.schema.forEach($=>{j[$.name]=!0,I.push($.name),A[$.name]=170}),P(a.id,{columnVisibility:j,columnOrder:I,columnWidths:A,filters:void 0,sortStack:void 0}),g("Reset to default layout - all filters and sorts cleared","success")},[K,a,P]);p.useEffect(()=>{const j=setTimeout(()=>or(Vt),300);return()=>clearTimeout(j)},[Vt]);const nn=p.useCallback(j=>{rt(j)},[]),Pe=p.useCallback(j=>{if(!j.trim()||!a)return;const I=a.searchHistory||[],A=Ma(I,j);P(a.id,{searchHistory:A})},[a,P]),Rt=p.useCallback(j=>{if(!a)return;const I=a.searchHistory||[],A=Ra(I,j);P(a.id,{searchHistory:A})},[a,P]),ao=p.useCallback(j=>{if(!a)return;const I=a.searchHistory||[],A=Wa(I,j);P(a.id,{searchHistory:A})},[a,P]),Vn=p.useCallback(j=>{const I=j==null?void 0:j.__urm_row_id__;Je(A=>{const $=new Set(A);if(I!==void 0){const U=Array.from($).find(Y=>(Y==null?void 0:Y.__urm_row_id__)===I);U!==void 0?$.delete(U):$.add(j)}else{const U=JSON.stringify(j),Y=Array.from($).find(de=>JSON.stringify(de)===U);Y!==void 0?$.delete(Y):$.add(j)}return $})},[]),Vr=p.useCallback((j,I)=>{Je(A=>{const $=new Set(A);for(const U of I)j?$.add(U):$.delete(U);return $})},[]),sn=p.useCallback((j,I,A)=>{Je($=>{const U=new Set($),Y=Math.min(j,I),de=Math.max(j,I);for(let ye=Y;ye<=de;ye++)A[ye]!==void 0&&U.add(A[ye]);return U})},[]),lo=p.useCallback(()=>{Je(new Set)},[]),co=p.useCallback(j=>{const I=j==null?void 0:j.__urm_row_id__;Je(A=>{const $=new Set(A);if(I!==void 0){const U=Array.from($).find(Y=>(Y==null?void 0:Y.__urm_row_id__)===I);U!==void 0&&$.delete(U)}else $.delete(j);return $})},[]),B=p.useCallback(j=>{if(a){if(!at("edit_columns",me)){g(lt("edit_columns"),"error");return}if(j&&a.schema){const{validGrouping:I,invalidColumns:A}=ns(j,a.schema);A.length>0&&g(`Removed invalid grouping columns: ${A.join(", ")}`,"warning"),kt();try{const $=a.grouping;I===null?fe("grouping","group_cleared",$,null):$?fe("grouping","group_reordered",$,I):fe("grouping","group_level_added",null,I);const U=(K==null?void 0:K.snapshot.columnOrder)||a.columnOrder||[],Y=qr(U,I);P(a.id,{grouping:I,columnOrder:Y}),JSON.stringify(Y)!==JSON.stringify(a.columnOrder)&&fe("columns","column_reordered",a.columnOrder,Y),tt(!1)}catch($){const U=Zt("processing","grouping",$);mt(U)}}else{const I=a.grouping;fe("grouping","group_cleared",I,null);const A=(K==null?void 0:K.snapshot.columnOrder)||a.columnOrder||[];P(a.id,{grouping:j,columnOrder:[...A]}),JSON.stringify(A)!==JSON.stringify(a.columnOrder)&&fe("columns","column_reordered",a.columnOrder,A),tt(!1)}}},[a,K,me,P,kt,mt,fe]),J=p.useCallback(j=>{if(!a)return;const I=a.grouping;if(!I)return;const A=za(I,j);P(a.id,{grouping:A})},[a,P]),xe=p.useCallback(()=>{a!=null&&a.grouping&&P(a.id,{grouping:{...a.grouping,collapsedGroups:[]}})},[a,P]),Ge=p.useCallback(()=>{if(!(a!=null&&a.grouping)||!a.schema)return;const j=Ia(Yt,a.schema,a.grouping);P(a.id,{grouping:{...a.grouping,collapsedGroups:j}})},[a,Yt,P]),Ye=p.useCallback(()=>{wt(!0)},[]),ue=p.useCallback(j=>{a!=null&&a.schema&&(O(!0),setTimeout(()=>{try{let I;j.scope==="visible"?I=Tt:I=a.uploadedData||[];let A;j.columnScope==="all"?(A={},(a.schema??[]).forEach(ye=>{A[ye.name]=!0})):A=a.columnVisibility||(K==null?void 0:K.snapshot.columnVisibility)||{};const $=a.columnOrder||(K==null?void 0:K.snapshot.columnOrder),U=wo(I,a.schema,Oe(a.filters),a.sortStack??[],K,A,$),Y=a.name;let de;switch(j.format){case"csv":ko(U,Y,j),de="export_csv";break;case"excel":To(U,Y,j),de="export_excel";break;case"json":Io(U,Y,j),de="export_json";break}fe("export",de,null,{format:j.format,scope:j.scope,columnScope:j.columnScope,rowCount:I.length,viewName:(K==null?void 0:K.name)||"Default View"}),g(`Export completed successfully (${j.format.toUpperCase()})`,"success")}catch(I){const A=ul(I,{onRetry:()=>ue(j)});g(`Export failed: ${A.message}. Click Export to retry.`,"error");const $=si(a.id,vt,A,a.auditHistory||[]);P(a.id,{auditHistory:$}),Et.error("urm:report-engine","Export failed",I)}finally{O(!1)}},500))},[a,K,Tt,P,fe]),gr=p.useCallback(j=>{if(a!=null&&a.schema){if(Ot&&K&&!K.isDefault){Ie(j.format),ce(!0),wt(!1);return}ue(j),wt(!1)}},[a,K,Ot,ue]),uo=p.useCallback(j=>{ue({format:j,scope:"visible",columnScope:"visible"})},[ue]),Ws=p.useCallback(()=>{ie&&uo(ie),ce(!1),Ie(null)},[ie,uo]),Ps=p.useCallback(()=>{At(),ie&&uo(ie),ce(!1),Ie(null)},[At,ie,uo]),Ns=p.useCallback(()=>{ce(!1),Ie(null)},[]),Ls=p.useCallback(j=>{!(a!=null&&a.schema)||Ct.size===0||(O(!0),setTimeout(()=>{try{const I=Array.from(Ct),A=wo(I,a.schema,Oe(a.filters),a.sortStack??[],K),$=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(j){case"csv":ko(A,$);break;case"excel":To(A,$);break;case"json":Io(A,$);break}g(`Exported ${I.length} selected rows`,"info")}catch(I){g("Export failed. Please try again.","error"),Et.error("urm:report-engine","Bulk export failed",I)}finally{O(!1)}},500))},[a,K,Ct,Tr]),Fs=p.useCallback((j,I)=>{if(a)try{const A=Xa(a),$=Qa(j,I,vt,A),U=Za(a.presets,$);P(a.id,{presets:U}),fe("presets","preset_created",null,{presetId:$.id,name:$.name}),sr(!1),g(`Preset "${j}" saved successfully`,"success")}catch(A){g(A instanceof Error?A.message:"Failed to create preset","error")}},[a,P,fe]),Vs=p.useCallback(()=>{ar(null),g("Exited preset view","info")},[]),Hs=p.useCallback(()=>{ot(!0)},[]),Us=p.useCallback((j,I)=>{if(!a)return;const A=el(a.presets,j);P(a.id,{presets:A}),fe("presets","preset_deleted",{presetId:j,name:I},null),nt===j&&ar(null),g(`Preset "${I}" deleted`,"success")},[a,nt,P,fe]);p.useEffect(()=>{if(!d||m.length===0)return;const j=m.find(I=>I.id===d);j&&j.id!==v&&b(j.id)},[d,m,v]);const Hn=p.useRef(!1);p.useEffect(()=>{var I;if(!c||Hn.current||!a||a.id!==d)return;const j=(I=a.views)==null?void 0:I.find(A=>A.id===c&&!A.isDeleted);j&&st(j.id),Hn.current=!0},[c,d,a,st]),p.useEffect(()=>{if(!a)return;const j=tl();if(j&&a.presets&&a.schemaLocked&&a.schema){const I=ii(a.presets,j);if(I){const{sanitizedConfig:A,warnings:$}=dl(I.config,a.schema);$.length>0&&$.forEach(Y=>g(Y,"warning"));const U=rl(A);P(a.id,U),ar(j),fe("presets","preset_applied",null,{presetId:I.id,name:I.name}),g(`Loaded preset: ${I.name}`,"info")}else g("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const Gs=nt?ii(a==null?void 0:a.presets,nt):void 0;p.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&$a(a.id,{views:a.views,activeViewId:a.activeViewId})},[a==null?void 0:a.views,a==null?void 0:a.activeViewId,a==null?void 0:a.id]),p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const j=Aa(a.id);if(j&&j.views.length>0){const I=j.views.find(A=>A.id===j.activeViewId);if(I)P(a.id,{views:j.views,activeViewId:j.activeViewId,filters:Oe(I.snapshot.filters),sortStack:I.snapshot.sortStack.length>0?I.snapshot.sortStack:void 0});else{const A=j.views.find($=>$.isDefault)||ln(a.schema);P(a.id,{views:j.views,activeViewId:A.id,filters:Oe(A.snapshot.filters),sortStack:A.snapshot.sortStack.length>0?A.snapshot.sortStack:void 0})}}}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id]);const Ys=p.useCallback(j=>{var $;const I=Oe(a==null?void 0:a.filters),A=(($=x.filter)==null?void 0:$.maxConditions)??3;if(dt(I)>=A){g(`Filter limit reached — maximum ${A} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}H(j),re(!0)},[a,x,g]),qs=p.useCallback(()=>{re(!1),H(void 0)},[]),Js=(qn=a==null?void 0:a.views)==null?void 0:qn.find(j=>j.id===G),Ks=(Jn=a==null?void 0:a.views)==null?void 0:Jn.find(j=>j.id===ee);return{reports:m,activeReport:a,activeReportId:v,setActiveReportId:b,isModalOpen:z,setIsModalOpen:S,createReport:pr,updateReport:P,uploadState:_,handleFileUpload:Se,handleUploadError:Fe,handleRetry:xr,handleConfirm:it,paginatedData:Gt,processedData:Tt,displayData:Tr,tableMetrics:ur,isGrouped:qt,tableEngine:ft,activeView:K,isDirty:Ot,currentTableState:we,viewChanges:Ir,filters:a==null?void 0:a.filters,showFilterPanel:X,setShowFilterPanel:re,filterFocusColumn:R,handleAddCondition:gt,handleAddGroup:Ue,handleUpdateCondition:Er,handleSetGroupOperator:Lr,handleRemoveFilterNode:$t,handleClearAllFilters:Jt,handleReplaceFilters:Fr,handleOpenFilterForColumn:Ys,handleCloseFilterPanel:qs,handleClearFiltersForColumn:Mt,sortStack:a==null?void 0:a.sortStack,showSortPanel:h,setShowSortPanel:V,handleSort:ht,handleUpdateSortStack:Ve,handleSortAscending:mr,handleSortDescending:zr,views:a==null?void 0:a.views,showCreateViewModal:W,setShowCreateViewModal:Q,showEditViewModal:Z,setShowEditViewModal:pe,showDeleteConfirmation:he,setShowDeleteConfirmation:N,editingView:Js,deletingView:Ks,editingViewId:G,deletingViewId:ee,handleSelectView:st,handleCreateView:Kt,handleCloneView:Br,handleUpdateCurrentView:At,handleSaveColumnConfigToCurrentView:_t,handleSaveColumnConfigToAllViews:fr,handleSaveAsNewView:le,handleRevertChanges:ge,handleToggleDefault:Ae,handleToggleFavorite:yt,handleSoftDelete:bt,handleRestoreView:Xt,handlePermanentDelete:so,handleEditView:Dr,handleCopyViewLink:qo,handleSaveEditView:Jo,handleDeleteView:Ko,handleConfirmDelete:Xo,handlePromoteToGlobal:Qo,showManageColumns:q,setShowManageColumns:Me,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:tn,handleUpdateColumnOrder:rn,handleUpdateColumnWidth:hr,handleResetColumnLayout:on,showGroupPanel:et,setShowGroupPanel:tt,grouping:a==null?void 0:a.grouping,groupingState:rr,handleGroup:B,handleToggleGroupCollapse:J,handleExpandAllGroups:xe,handleCollapseAllGroups:Ge,searchQuery:Vt,debouncedSearchQuery:pt,searchHistory:Pa((a==null?void 0:a.searchHistory)||[]),handleSearchChange:nn,handleAddToSearchHistory:Pe,handleToggleSearchFavourite:Rt,handleDeleteSearchHistory:ao,selectedRowIds:Ct,handleToggleRowSelection:Vn,handleToggleAllRows:Vr,handleRangeSelection:sn,handleClearSelection:lo,handleUpdateSelectionAfterDelete:co,currentPage:jt,pageSize:Ht,paginationEngine:ze,handlePageChange:Zo,handlePageSizeChange:en,isExporting:oe,showExportModal:lr,setShowExportModal:wt,showDirtyExportWarning:te,handleExport:Ye,handleExportWithConfig:gr,handleExportSelected:Ls,handleExportAnyway:Ws,handleSaveAndExport:Ps,handleCancelExport:Ns,showAuditHistory:ir,setShowAuditHistory:He,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:no,setShowCreatePreset:sr,showManagePresets:Ut,setShowManagePresets:ot,activePreset:Gs,activePresetId:nt,handleOpenManagePresets:Hs,handleCreatePreset:Fs,handleClearActivePreset:Vs,handleDeletePresetById:Us,userRole:me,isViewerRole:kr,currentUserId:vt,featureLimitWarning:wr,setFeatureLimitWarning:xt,datasetMeta:io,reportError:Nr,setReportError:cr,handleError:mt,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?ba(a.schema):!1,snack:C,handleSnackClose:k,showSnack:g,snackDurationMs:L}}const is=p.createContext(void 0);function Mn(e){const{children:r,initialData:n,data:i,reportName:s,dataSource:l,mode:d="builder",autoLoad:c=!0,config:u,devConfig:m,showDevPanel:f=!1,sharedReportId:x,sharedViewId:v}=e,z=Il({mode:d,autoLoad:c,initialData:i||n,dataSource:l,reportName:s,sharedReportId:x,sharedViewId:v,config:u}),[S,y]=p.useState(()=>ta()),w=(()=>{const k=oa(S,m,!!m);return{...k,display:{...k.display,showDevPanel:f||k.display.showDevPanel}}})(),C=p.useCallback(g=>{y(g),ra(g)},[]),E={...z,activeDevConfig:w,handleDevConfigChange:C};return t.jsx(Gi.Provider,{value:w,children:t.jsx(is.Provider,{value:E,children:r})})}function $o(){const e=p.useContext(is);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(l=>l.id===n);return t.jsx(o.Box,{component:"header",sx:{position:"sticky",top:0,zIndex:50,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper"},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(T.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:500,fontSize:"1.375rem",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:500,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(T.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(T.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function vr(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 El="$$material";function Bl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xo={exports:{}},mo={exports:{}},be={};/** @license React v16.13.1
1
+ "use strict";var Zs=Object.defineProperty;var ea=(e,r,n)=>r in e?Zs(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var ii=(e,r,n)=>ea(e,typeof r!="symbol"?r+"":r,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),ta=require("xlsx"),z=require("@mui/icons-material"),o=require("@mui/material"),ts=require("react-dom"),ra=require("@emotion/react"),Vt=require("react-dnd"),Rn=require("react-dnd-html5-backend");function rs(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 Fo=rs(p),Co=rs(ta),Xe={sort:{maxLevels:5},filter:{maxConditions:3,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0},export:{allowedFormats:["csv","excel","json"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},os="urm_dev_config";function oa(){try{const e=localStorage.getItem(os);if(!e)return Xe;const r=JSON.parse(e),n={sort:{...Xe.sort,...r.sort},filter:{...Xe.filter,...r.filter},columns:{...Xe.columns,...r.columns},grouping:{...Xe.grouping,...r.grouping},export:{...Xe.export,...r.export},views:{...Xe.views,...r.views},dates:{...Xe.dates,...r.dates},display:{...Xe.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return Xe}}function na(e){try{localStorage.setItem(os,JSON.stringify(e))}catch{}}function ia(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 ns=p.createContext(Xe);function Sr(){return p.useContext(ns)}const sa=/^\d{4}-\d{2}-\d{2}$/,aa=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,la=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,ca=9783072e5,da=41024448e5,ua=978307200,pa=4102444800;function xa(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=ca&&e<=da?"timestamp_ms":Number.isInteger(e)&&e>=ua&&e<=pa?"timestamp_s":"unknown":typeof e!="string"?"unknown":aa.test(e)||sa.test(e)?"iso":la.test(e.trim())?"locale_string":"unknown"}function ma(e,r){const n=r.map(d=>d[e]).filter(d=>d!=null&&d!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const d of n){const c=xa(d);i[c]++}const s=n.length,l=.7;for(const d of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[d]/s>=l)return d;return"unknown"}function fa(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 si=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ha=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ae(e){return String(e).padStart(2,"0")}function ga(e){const r=Date.now()-e.getTime(),n=Math.abs(r),i=r>0,s=Math.floor(n/1e3),l=Math.floor(s/60),d=Math.floor(l/60),c=Math.floor(d/24),u=Math.floor(c/7),h=Math.floor(c/30),g=Math.floor(c/365);let f;return s<60?f="just now":l<60?f=`${l} minute${l!==1?"s":""}`:d<24?f=`${d} hour${d!==1?"s":""}`:c<7?f=`${c} day${c!==1?"s":""}`:u<5?f=`${u} week${u!==1?"s":""}`:h<12?f=`${h} month${h!==1?"s":""}`:f=`${g} year${g!==1?"s":""}`,s<60?f:i?`${f} ago`:`in ${f}`}function ya(e,r){const n=e.getFullYear(),i=e.getMonth(),s=e.getDate(),l=e.getHours(),d=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${Ae(i+1)}-${Ae(s)}`;case"DD/MM/YYYY":return`${Ae(s)}/${Ae(i+1)}/${n}`;case"MM/DD/YYYY":return`${Ae(i+1)}/${Ae(s)}/${n}`;case"MMM DD, YYYY":return`${si[i]} ${Ae(s)}, ${n}`;case"DD MMM YYYY":return`${Ae(s)} ${si[i]} ${n}`;case"MMMM D, YYYY":return`${ha[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Ae(i+1)}-${Ae(s)} ${Ae(l)}:${Ae(d)}`;case"DD/MM/YYYY HH:mm":return`${Ae(s)}/${Ae(i+1)}/${n} ${Ae(l)}:${Ae(d)}`;case"MM/DD/YYYY HH:mm":return`${Ae(i+1)}/${Ae(s)}/${n} ${Ae(l)}:${Ae(d)}`;case"relative":return ga(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function ba(e,r,n){if(!n||r==="unknown")return String(e);const i=fa(e,r);return!i||isNaN(i.getTime())?String(e):ya(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 is(e,r="",n=0){if(n>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const l=r?`${r}.${s}`:s,d=e[s];d!==null&&typeof d=="object"&&!Array.isArray(d)&&n<2?Object.assign(i,is(d,l,n+1)):i[l]=d}return i}function Eo(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:is(r))}function to(e){if(!Array.isArray(e)||e.length===0)return[];const r=Eo(e),n=new Set;r.forEach(d=>{typeof d=="object"&&d!==null&&Object.keys(d).forEach(c=>n.add(c))});const i=[];n.forEach(d=>{const c=new Set;let u=0;r.forEach(b=>{typeof b=="object"&&b!==null&&d in b&&(u++,c.add(va(b[d])))});const h=u===r.length,g=c.size>1&&!c.has("null");let f="mixed";if(c.size===1)f=Array.from(c)[0];else if(c.size===2&&c.has("null")){const b=Array.from(c).filter(v=>v!=="null");b.length===1&&(f=b[0])}i.push({name:d,type:f,required:h,hasConflict:g})});const l=r.slice(0,50);for(const d of i){if(d.type!=="string"&&d.type!=="number")continue;const c=ma(d.name,l);c!=="unknown"&&(d.type="date",d.dateFormat=c)}return i}function Sa(e){return e.some(r=>r.hasConflict)}function et(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 Ca(e){return(r,n,i)=>{const s=ai(r),l=ai(n);if(s&&l)return 0;if(s)return 1;if(l)return-1;let d=0;switch(e){case"number":const c=Number(r),u=Number(n);d=c-u;break;case"boolean":d=(r?1:0)-(n?1:0);break;case"string":d=String(r).localeCompare(String(n));break;case"array":case"object":d=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:d=String(r).localeCompare(String(n));break}return i==="asc"?d:-d}}function ja(e,r,n){if(!n||n.length===0)return e;const i=[...n].sort((s,l)=>s.priority-l.priority);return[...e].sort((s,l)=>{for(const d of i){const c=r.find(g=>g.name===d.column);if(!c)continue;const h=Ca(c.type)(s[d.column],l[d.column],d.direction);if(h!==0)return h}return 0})}function wa(e){return e===null?"asc":e==="asc"?"desc":null}function ka(e){return e==="string"||e==="boolean"}function Ta(e){return e.filter(r=>ka(r.type))}function Ba(e,r){const n={};return r.forEach(i=>{if(i.type==="number"){const s=e.map(l=>l[i.name]).filter(l=>typeof l=="number");s.length>0&&(n[i.name]=s.reduce((l,d)=>l+d,0))}}),n}function Ia(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=Wn(e,n.levels,r);return ss(i,n.collapsedGroups||[])}function Wn(e,r,n,i="",s=0){if(s>=r.length)return e;const l=r[s].column,d=new Map;e.forEach(h=>{const g=h[l],f=g==null?"(empty)":String(g);d.has(f)||d.set(f,[]),d.get(f).push(h)});const c=[];return Array.from(d.keys()).sort().forEach(h=>{const g=d.get(h),f=`${l}:${h}`,b=i?`${i}|${f}`:f,v=Ba(g,n),T=s<r.length-1?Wn(g,r,n,b,s+1):g,C={key:b,level:s,column:l,value:h,rowCount:g.length,aggregates:v,children:T};c.push(C)}),c}function ss(e,r,n=[],i=0){for(const s of e)if("key"in s&&"level"in s&&"children"in s){const l=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:l}),!l&&s.children&&ss(s.children,r,n,i+1)}else n.push({...s,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return n}function za(e,r,n){if(!n.enabled||n.levels.length===0)return[];const i=Wn(e,n.levels,r),s=[],l=d=>{for(const c of d)"key"in c&&"level"in c&&"children"in c&&(s.push(c.key),l(c.children))};return l(i),s}function Ea(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 ls(e,r,n){return String(n??"")}function Yr(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function We(e){return"children"in e}function Ct(){return{id:Yr(),operator:"and",children:[]}}function Oe(e){return e?Array.isArray(e)?{id:Yr(),operator:"and",children:e.map(r=>({...r,id:r.id??Yr()}))}:e:Ct()}function mt(e){return e?We(e)?e.children.reduce((r,n)=>r+mt(n),0):1:0}function Do(e,r){if(e.id===r)return e;for(const n of e.children){if(n.id===r)return n;if(We(n)){const i=Do(n,r);if(i)return i}}}function qr(e,r,n){return e.id===r?{...e,children:[...e.children,n]}:{...e,children:e.children.map(i=>We(i)?qr(i,r,n):i)}}function Pn(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!We(i)?{...i,...n}:We(i)?Pn(i,r,n):i)}}function Nn(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>We(i)?Nn(i,r,n):i)}}function Ln(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>We(i)?Ln(i,r):i).filter(i=>!We(i)||i.children.length>0);return{...e,children:n}}function En(e,r){return e?We(e)?e.children.some(n=>En(n,r)):e.column===r:!1}function cs(e,r){const n=e.children.filter(i=>We(i)||i.column!==r).map(i=>We(i)?cs(i,r):i).filter(i=>!We(i)||i.children.length>0);return{...e,children:n}}function ds(e){return e?We(e)?e.children.flatMap(ds):[e]:[]}function uo(e){if(!e)return null;if(!We(e)){const{id:i,...s}=e;return s}const{id:r,...n}=e;return{...n,children:e.children.map(uo)}}function io(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 Fn(e,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(l=>l.column),s=e.filter(l=>!i.includes(l));if(n){const l=[],d=new Set(i),c=new Set(s);let u=0;for(const h of n)d.has(h)?l.push(h):c.has(h)&&u<s.length?(l.push(s[u]),u++):c.has(h)||l.push(h);for(let h=u;h<s.length;h++)l.includes(s[h])||l.push(s[h]);return l}return[...e]}function bn(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:Ct(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Da(e,r,n,i,s,l,d,c){const u={},h=[],g={};n.forEach(v=>{u[v.name]=!0,h.push(v.name),g[v.name]=170});const b=Fn(s||h,d||null,c||h);return{filters:Oe(e),sortStack:r||[],columnVisibility:i||u,columnOrder:b,columnWidths:l||g,grouping:d||null}}function $a(e,r){const n=v=>{if(v==null)return v;if(Array.isArray(v))return v.map(T=>n(T));if(typeof v=="object"){const T={};return Object.keys(v).sort().forEach(C=>{T[C]=n(v[C])}),T}return v},i=v=>JSON.stringify(n(v));if(i(uo(e.filters))!==i(uo(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},l=r.columnVisibility??{};if(i(s)!==i(l))return!0;const d=Fn(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),c=[...d].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(c!==u)return!1;const h=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==h){if(d.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const v=[...d].sort().join(",");if(d.join(",")!==v)return!0}const f=e.columnWidths??{},b=r.columnWidths??{};return i(f)!==i(b)||i(e.grouping)!==i(r.grouping)}function Oa(e){return!e||e.length===0?"None":e.sort((r,n)=>r.priority-n.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function _a(e,r){var C,m,j;const n=[],i=JSON.stringify(uo(e.filters)),s=JSON.stringify(uo(r.filters));if(i!==s){const y=mt(e.filters),$=mt(r.filters);y>$?n.push({category:"filters",label:"Filters Added",description:`${y-$} new filter${y-$>1?"s":""} added`}):y<$?n.push({category:"filters",label:"Filters Removed",description:`${$-y} filter${$-y>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const l=JSON.stringify(e.sortStack),d=JSON.stringify(r.sortStack);if(l!==d){const y=e.sortStack.length,$=r.sortStack.length;y>$?n.push({category:"sorting",label:"Sorting Added",description:`${y-$} new sort rule${y-$>1?"s":""} added`}):y<$?n.push({category:"sorting",label:"Sorting Removed",description:`${$-y} sort rule${$-y>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const c=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(c!==u){const y=Object.values(e.columnVisibility).filter(S=>S).length,$=Object.values(r.columnVisibility).filter(S=>S).length;y>$?n.push({category:"visibility",label:"Columns Shown",description:`${y-$} column${y-$>1?"s":""} made visible`}):y<$?n.push({category:"visibility",label:"Columns Hidden",description:`${$-y} column${$-y>1?"s":""} hidden`}):n.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const h=JSON.stringify(e.columnOrder),g=JSON.stringify(r.columnOrder);h!==g&&n.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const f=JSON.stringify(e.columnWidths),b=JSON.stringify(r.columnWidths);if(f!==b){const y=Object.keys(e.columnWidths).filter($=>e.columnWidths[$]!==r.columnWidths[$]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${y} column width${y>1?"s":""} modified`})}const v=JSON.stringify(e.grouping),T=JSON.stringify(r.grouping);if(v!==T){const y=(C=e.grouping)==null?void 0:C.enabled,$=(m=r.grouping)==null?void 0:m.enabled;if(y&&!$){const S=((j=e.grouping)==null?void 0:j.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${S} grouping level${S>1?"s":""} added`})}else!y&&$?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 li(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function ci(e){return`[${e}]`}const Ot={warn(e,r,...n){li()&&console.warn(ci(e),r,...n)},error(e,r,...n){li()&&console.error(ci(e),r,...n)}},us="urm_report_";function Aa(e,r){try{const n=`${us}${e}`;localStorage.setItem(n,JSON.stringify(r))}catch(n){Ot.error("urm:persistence","Failed to save report state",n)}}function Ma(e){try{const r=`${us}${e}`,n=localStorage.getItem(r);return n?JSON.parse(n):null}catch(r){return Ot.error("urm:persistence","Failed to load report state",r),null}}function Vo(e,r,n=0){const i=[];for(const s of e){const l=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:l}),!l&&s.children&&s.children.length>0){const d=s.children[0];if(Ra(d)){const c=s.children,u=Vo(c,r,n+1);i.push(...u)}else{const c=s.children;for(const u of c)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function Ra(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 Vn(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function Hn(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),l=String(n.getDate()).padStart(2,"0"),d=`${i}-${s}-${l}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${d}.${r}`}function Ao(e,r,n,i,s,l,d){let c,u;l?(c={...l},u=d||r.map(g=>g.name)):s?(c={...s.snapshot.columnVisibility},u=d||[...s.snapshot.columnOrder]):(c={},u=[],r.forEach(g=>{c[g.name]=!0,u.push(g.name)}));const h=Object.entries(c).filter(([g,f])=>!f).map(([g,f])=>g);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:c,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:h,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function Mo(e,r="export",n){const{data:i,columnOrder:s,grouping:l}=e,d=s.filter(f=>e.columnVisibility[f]);let c;if(l&&l.enabled){const f=l.collapsedGroups??[],b=Vo(i,f);c=Vn(b)}else c=i;const u=d.join(","),h=c.map(f=>d.map(b=>{const v=f[b];if(v==null)return"";const T=String(v);return T.includes(",")||T.includes('"')||T.includes(`
2
+ `)?`"${T.replace(/"/g,'""')}"`:T}).join(",")),g=[u,...h].join(`
3
+ `);ps(g,Hn(r,"csv"),"text/csv;charset=utf-8;")}function Ro(e,r="export",n){const{data:i,columnOrder:s,grouping:l}=e,d=s.filter(f=>e.columnVisibility[f]);let c;if(l&&l.enabled){const f=l.collapsedGroups??[],b=Vo(i,f);c=Vn(b)}else c=i;const u=[d,...c.map(f=>d.map(b=>f[b]??""))],h=Co.utils.aoa_to_sheet(u),g=Co.utils.book_new();Co.utils.book_append_sheet(g,h,"Data"),Co.writeFile(g,Hn(r,"xlsx"))}function Wo(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:l,viewMeta:d,hiddenColumns:c,columnOrder:u,grouping:h}=e;let g;if(h&&h.enabled){const v=h.collapsedGroups??[],T=Vo(i,v);g=Vn(T)}else g=i;const f={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(d==null?void 0:d.name)||"Default View",filters:ds(s).map(v=>({field:v.column,operator:v.operator,value:v.value})),sortStack:l.map(v=>({field:v.column,direction:v.direction,priority:v.priority})),grouping:h||{},hiddenColumns:c,columnOrder:u,exportConfig:n||{scope:"visible"}},data:g},b=JSON.stringify(f,null,2);ps(b,Hn(r,"json"),"application/json;charset=utf-8;")}function ps(e,r,n){const i=new Blob([e],{type:n}),s=URL.createObjectURL(i),l=document.createElement("a");l.href=s,l.download=r,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(s)}const di=10;function Wa(e,r){const n=r.trim();if(!n)return e;const i=e.findIndex(l=>l.query.toLowerCase()===n.toLowerCase());let s;return i!==-1?s=[{...e[i],lastUsed:Date.now()},...e.slice(0,i),...e.slice(i+1)]:s=[{query:n,isFavourite:!1,lastUsed:Date.now()},...e],s.length>di&&(s=[...s].sort((d,c)=>d.isFavourite&&!c.isFavourite?-1:!d.isFavourite&&c.isFavourite?1:c.lastUsed-d.lastUsed).slice(0,di)),s}function Pa(e,r){return e.map(n=>n.query===r?{...n,isFavourite:!n.isFavourite}:n)}function Na(e,r){return e.filter(n=>n.query!==r)}function La(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 Fa={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 Va(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function ut(e,r){return Fa[r].includes(e)}function pt(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 Ha(e){return e==="viewer"}const ui=1e3;function Dn(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function $t(e){if(!e)return"";const n=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return Dn(n)}const Ua={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 Ga(e){if(!e||!e.column)return"a filter";const r=$t(e.column),n=Ua[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${n}`:`"${r}" ${n} "${e.value}"`}function vn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":Ga(e):"a filter"}function pi(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(n=>`"${$t(n.column)}"`).join(", ")}`}function Ya(e){var s,l,d;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${vn(i)}`};case"filter_removed":return{summary:`Filter removed: ${vn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const c=n,u=i;return c!=null&&c.column&&(u!=null&&u.column)&&c.column!==u.column?{summary:`Filter changed on "${$t(u.column)}"`,detail:`Previously filtered "${$t(c.column)}"`}:{summary:`Filter updated: ${vn(u)}`}}case"filter_cleared":{const c=n&&typeof n=="object"&&"count"in n?n.count:0;return{summary:c>0?`All filters cleared (${c} filter${c!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const c=i!=null&&i.column?$t(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:c?`Sort added: "${c}" ${u}`:"Sort level added"}}case"sort_level_removed":{const c=n!=null&&n.column?$t(n.column):"";return{summary:c?`Sort removed: "${c}"`:"Sort level removed"}}case"sort_reordered":return{summary:"Sort order changed"};case"sort_cleared":return{summary:"All sorting cleared"};case"group_level_added":return{summary:`Grouping applied: ${pi(i)}`};case"group_level_removed":{const c=n,u=(l=(s=c==null?void 0:c.levels)==null?void 0:s[0])!=null&&l.column?$t(c.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${pi(i)}`};case"group_cleared":return{summary:"Grouping removed"};case"column_hidden":{const c=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:c?`Column hidden: "${$t(c)}"`:"Column hidden"}}case"column_shown":{const c=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:c?`Column shown: "${$t(c)}"`:"Column made visible"}}case"column_reordered":{const c=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return c.length>0&&u.length>0?{summary:"Column order changed",detail:`${u.length} column${u.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const c=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:c?`Column resized: "${$t(c)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const c=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:c?`View created: "${c}"`:"New view created"}}case"view_updated":{const c=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:c?`View updated: "${c}"`:"View updated"}}case"view_deleted":{const c=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:c?`View deleted: "${c}"`:"View deleted"}}case"view_set_default":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Default view set to "${c}"`:"Default view changed"}}case"view_switched":{const c=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return c&&u?{summary:`Switched to view "${u}"`,detail:`From "${c}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":{const c=r==="export_csv"?"CSV":r==="export_excel"?"Excel":"JSON",u=i==null?void 0:i.rowCount,h=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",g=(i==null?void 0:i.viewName)??"",f=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${c}${f}`,detail:g?`${Dn(h)} · View: "${g}"`:Dn(h)}}case"export_triggered":{const c=((d=i==null?void 0:i.format)==null?void 0:d.toUpperCase())??"";return{summary:c?`Export triggered: ${c}`:"Export triggered"}}case"preset_created":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset created: "${c}"`:"New preset created"}}case"preset_applied":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset applied: "${c}"`:"Preset applied"}}case"preset_deleted":{const c=(n==null?void 0:n.name)??"";return{summary:c?`Preset deleted: "${c}"`:"Preset deleted"}}case"preset_link_copied":{const c=(i==null?void 0:i.name)??"";return{summary:c?`Preset link copied: "${c}"`:"Preset link copied to clipboard"}}case"theme_changed":{const c=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return c&&u?{summary:`Theme changed from "${c}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const c=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:c?`Details: ${String(c).slice(0,120)}`:void 0}}default:return{summary:Ja(r)}}}function qa(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function xs(e,r,n,i,s,l){return{id:qa(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:l}}function ms(e,r){const n=[r,...e];return n.length>ui?n.slice(0,ui):n}function Ja(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",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",error_occurred:"Error Occurred"}[e]||e}function Ka(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",system:"System"}[e]||e}function Xa(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),l=Math.floor(i/36e5),d=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:l<24?`${l} hour${l>1?"s":""} ago`:d<7?`${d} day${d>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const xi=100;function Qa(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Za(e){var l;const r=(l=e.views)==null?void 0:l.find(d=>d.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=Fn(i,e.grouping||null,n);return{filters:Oe(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 el(e,r,n,i){return{id:Qa(),name:e,description:r,createdBy:n,createdAt:Date.now(),config:i}}function tl(e,r){const n=e||[];if(n.length>=xi)throw new Error(`Maximum of ${xi} presets reached. Please delete old presets first.`);return[...n,r]}function rl(e,r){return(e||[]).filter(i=>i.id!==r)}function mi(e,r){if(e)return e.find(n=>n.id===r)}function ol(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function nl(e){const r=e.columnOrder,n=io(r,e.grouping);return{filters:Oe(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 il(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Ot.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){Ot.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),n}catch(r){return Ot.error("urm:presets","Fallback copy method failed",r),!1}}function sl(e,r){return{totalRows:e.length,totalColumns:r.length}}function rr(e,r,n,i){const s=n instanceof Error?n.message:n,l={type:e,context:r,message:s,details:i,timestamp:Date.now(),recoverable:al(e,r)};return process.env.NODE_ENV==="development"&&Ot.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),l}function al(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function ll(e){const n={filters:"There was an issue applying filters",sorting:"Sorting could not be applied",grouping:"Grouping configuration failed",columns:"Column configuration could not be updated",views:"View operation failed",presets:"Preset could not be applied",export:"Export failed",upload:"File upload failed",search:"Search operation failed"}[e.context]||"An error occurred";return e.recoverable?`${n}. Your previous state has been restored.`:`${n}. Please refresh the page.`}function cl(e){return{filters:e.filters,sortStack:e.sortStack?[...e.sortStack]:void 0,grouping:e.grouping?{...e.grouping}:void 0,columnVisibility:e.columnVisibility?{...e.columnVisibility}:void 0,columnOrder:e.columnOrder?[...e.columnOrder]:void 0,columnWidths:e.columnWidths?{...e.columnWidths}:void 0,activeViewId:e.activeViewId}}function dl(e,r,n){n(e.id,{filters:Oe(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function ul(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 fs(e,r){const n=[],i=[],s=new Set(r.map(l=>l.name));return e.forEach(l=>{s.has(l.column)?n.push(l):i.push(l.column)}),{validRules:n,invalidColumns:i}}function hs(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const n=new Set(r.map(l=>l.name)),i=[],s=[];return e.levels.forEach(l=>{n.has(l.column)?i.push(l):s.push(l.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...e,levels:i},invalidColumns:s}}function pl(e,r){const n=[],i=new Set(r.map(l=>l.name)),s={...e};if(s.filters){const l=d=>{const c=d.children.filter(u=>{if(We(u))return!0;const h=i.has(u.column);return h||n.push(`Filter for column "${u.column}" ignored (column not found)`),h}).map(u=>We(u)?l(u):u).filter(u=>!We(u)||u.children.length>0);return{...d,children:c}};s.filters=l(Oe(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:l,invalidColumns:d}=fs(s.sortStack,r);d.length>0&&n.push(`Sort rules for columns ignored: ${d.join(", ")}`),s.sortStack=l.length>0?l:void 0}if(s.grouping){const{validGrouping:l,invalidColumns:d}=hs(s.grouping,r);d.length>0&&n.push(`Grouping for columns ignored: ${d.join(", ")}`),s.grouping=l}if(s.columnVisibility){const l={};Object.entries(s.columnVisibility).forEach(([d,c])=>{i.has(d)?l[d]=c:n.push(`Column visibility for "${d}" ignored (column not found)`)}),s.columnVisibility=Object.keys(l).length>0?l:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const l=s.columnOrder.filter(d=>{const c=i.has(d);return c||n.push(`Column "${d}" in order ignored (column not found)`),c});s.columnOrder=l.length>0?l:void 0}if(s.columnWidths){const l={};Object.entries(s.columnWidths).forEach(([d,c])=>{i.has(d)?l[d]=c:n.push(`Column width for "${d}" ignored (column not found)`)}),s.columnWidths=Object.keys(l).length>0?l:void 0}return{sanitizedConfig:s,warnings:n}}function xl(e,r){return rr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function fi(e,r,n,i){const s=xs(e,r,"system","error_occurred",null,{errorType:n.type,errorContext:n.context,errorMessage:n.message,recoverable:n.recoverable,timestamp:n.timestamp});return ms(i||[],s)}function ml(e){return e==null}function fl(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 l=new Date(e).getTime(),d=new Date(s).getTime();switch(i){case"equals":return l===d;case"gt":return l>d;case"lt":return l<d;case"gte":return l>=d;case"lte":return l<=d;default:return!0}}switch(i){case"equals":return String(e)===String(s);case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function $n(e,r,n){var s;if(We(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(l=>$n(e,l,n)):r.children.some(l=>$n(e,l,n));const i=((s=n.find(l=>l.name===r.column))==null?void 0:s.type)??"string";return fl(e[r.column],r,i)}function hl(e,r,n){return!r||r.children.length===0?e:e.filter(i=>$n(i,r,n))}function Po(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 gl(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function yl({data:e,filters:r,schema:n}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:hl(e,r,n),[e,r,n])}}function bl(e,r,n,i){if(!n||n.trim()==="")return e;const s=n.toLowerCase().trim(),l=r.filter(d=>i.includes(d.name));return e.filter(d=>l.some(c=>{const u=d[c.name];return u==null?!1:String(u).toLowerCase().includes(s)}))}function vl({data:e,searchQuery:r,schema:n,visibleColumns:i}){return{searchedData:p.useMemo(()=>!r||r.trim()===""?e:bl(e,n,r,i),[e,r,n,i])}}function Sl({data:e,sortStack:r,schema:n}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:ja(e,n,r),[e,r,n])}}function Cl({data:e,grouping:r,schema:n}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:Ia(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 jl({schema:e,columnVisibility:r,columnOrder:n}){const i=p.useMemo(()=>n.filter(c=>r[c]!==!1),[n,r]),s=p.useMemo(()=>Object.entries(r).filter(([c,u])=>!u).map(([c,u])=>c),[r]),l=p.useMemo(()=>n.map(c=>e.find(h=>h.name===c)||{name:c,type:"string"}),[n,e]),d=p.useMemo(()=>i.map(c=>e.find(h=>h.name===c)||{name:c,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:l,visibleColumnSchemas:d,hiddenCount:s.length}}function wl({views:e,activeViewId:r,currentState:n}){const i=p.useMemo(()=>e.find(h=>h.id===r),[e,r]),s=p.useMemo(()=>i?$a(n,i.snapshot):!1,[i,n]),l=p.useMemo(()=>e.find(h=>h.isDefault),[e]),d=p.useMemo(()=>e.filter(h=>!h.isDefault&&!h.isDeleted),[e]),c=p.useMemo(()=>e.filter(h=>h.isFavorite&&!h.isDeleted),[e]),u=p.useMemo(()=>e.filter(h=>h.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:l,customViews:d,favoriteViews:c,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function kl({data:e,enabled:r=!1,pageSize:n=100,initialPage:i=1}){const[s,l]=p.useState(i),d=e.length,c=Math.ceil(d/n),u=p.useMemo(()=>{if(!r)return e;const v=(s-1)*n,T=v+n;return e.slice(v,T)},[e,r,s,n]),h=p.useCallback(v=>{const T=Math.max(1,Math.min(v,c));l(T)},[c]),g=p.useCallback(()=>{s<c&&l(s+1)},[s,c]),f=p.useCallback(()=>{s>1&&l(s-1)},[s]),b=p.useCallback(()=>{l(1)},[]);return{paginatedData:u,currentPage:s,totalPages:c,pageSize:n,totalRows:d,goToPage:h,nextPage:g,prevPage:f,resetPage:b,hasNextPage:s<c,hasPrevPage:s>1}}function Tl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:l,searchQuery:d,columnVisibility:c,columnOrder:u,columnWidths:h,views:g,activeViewId:f,pagination:b}=e,v=p.useMemo(()=>({filters:i,sortStack:s,grouping:l,columnVisibility:c,columnOrder:u,columnWidths:h}),[i,s,l,c,u,h]),T=wl({views:g,activeViewId:f,currentState:v}),C=jl({schema:n,columnVisibility:c,columnOrder:u}),{filteredData:m}=yl({data:r,filters:i,schema:n}),{sortedData:j}=Sl({data:m,sortStack:s,schema:n}),{groupedData:y,isGrouped:$}=Cl({data:j,grouping:l,schema:n}),{searchedData:S}=vl({data:y,searchQuery:d,schema:n,visibleColumns:C.visibleColumns}),I=kl({data:S,enabled:(b==null?void 0:b.enabled)||!1,pageSize:(b==null?void 0:b.pageSize)||100,initialPage:(b==null?void 0:b.currentPage)||1}),N=b!=null&&b.enabled?I.paginatedData:S,a=p.useMemo(()=>({totalRows:r.length,filteredRows:m.length,sortedRows:j.length,groupedRows:$?y.length:j.length,searchedRows:S.length,visibleRows:N.length,hiddenColumns:C.hiddenCount,activeFilters:mt(i),activeSorts:s.length,isGrouped:$}),[r.length,m.length,j.length,y.length,S.length,N.length,C.hiddenCount,i,s.length,$]);return{data:N,filteredData:m,sortedData:j,groupedData:y,searchedData:S,viewEngine:T,columnEngine:C,paginationEngine:I,metrics:a,isGrouped:$,isPaginated:(b==null?void 0:b.enabled)||!1}}let Bl=0;function Il(e){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:Bl++,writable:!1,enumerable:!1,configurable:!1})}const St="user-demo-001";function zl(e={}){var ei,ti,ri,oi,ni;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:l,sharedReportId:d,sharedViewId:c,config:u={}}=e,[h,g]=p.useState([]),f=Sr(),[b,v]=p.useState(""),[T,C]=p.useState(!1),[m,j]=p.useState(!1),[y,$]=p.useState({message:"",severity:"info",open:!1}),S=(w,E="info")=>{$({message:w,severity:E,open:!0})},I=()=>$(w=>({...w,open:!1})),N=u.notifDurationMs??2e3,a=h.find(w=>w.id===b),[A,F]=p.useState("idle"),[J,ee]=p.useState(!1),[x,R]=p.useState(!1),[P,te]=p.useState(!1),[ae,Q]=p.useState(!1),[re,he]=p.useState(!1),[L,K]=p.useState(void 0),[ne,le]=p.useState(null),[U,se]=p.useState(null),[ie,D]=p.useState(!1),[Z,de]=p.useState(!1),[oe,ye]=p.useState(null),[G,Me]=p.useState(!1),[ht,ot]=p.useState(!1),[wr,kr]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[gt,Tr]=p.useState(""),[nt,Ut]=p.useState(""),[jt,it]=p.useState(new Set),[st,_t]=p.useState(1),[At,Jr]=p.useState(15),[ir,sr]=p.useState(!1),[Ye,Kr]=p.useState(!1),[Br,Mt]=p.useState(!1),[Ve,wt]=p.useState(null),[Xr,qe]=p.useState(!1),[ar,Re]=p.useState(null),[Gt,Rt]=p.useState(null),Ir=p.useRef(null),H=p.useMemo(()=>a?Va(a.permissions,St):"owner",[a]),lr=Ha(H),zr=p.useMemo(()=>!(a!=null&&a.uploadedData)||!(a!=null&&a.schema)?{totalRows:0,totalColumns:0}:sl(a.uploadedData,a.schema),[a==null?void 0:a.uploadedData,a==null?void 0:a.schema]),yt=p.useCallback(()=>{a&&(Ir.current=cl(a))},[a]),W=p.useCallback((w,E)=>{g(_=>_.map(O=>O.id===w?{...O,...E}:O))},[]),at=p.useCallback(w=>{if(!a)return;Rt(w);const E=fi(a.id,St,w,a.auditHistory||[]);W(a.id,{auditHistory:E}),S(w.message,"error"),w.recoverable&&Ir.current&&setTimeout(()=>{dl(a,Ir.current,W),S("Previous state restored","success")},100)},[a,W]),ge=p.useCallback((w,E,_,O)=>{if(!a)return;const Y=xs(a.id,St,w,E,_,O),q=a.auditHistory||[],ue=ms(q,Y);setTimeout(()=>{W(a.id,{auditHistory:ue})},0)},[a,W]);p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const w=bn(a.schema);(()=>{try{const E=localStorage.getItem("urm_dev_config");return E?JSON.parse(E):null}catch{return null}})(),W(a.id,{views:[w],activeViewId:w.id,filters:w.snapshot.filters,sortStack:w.snapshot.sortStack,columnVisibility:w.snapshot.columnVisibility,columnOrder:w.snapshot.columnOrder,columnWidths:w.snapshot.columnWidths,grouping:w.snapshot.grouping})}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id,W]),p.useEffect(()=>{if(i&&n&&!m&&h.length===0){const w=Eo(i),E={id:`auto-report-${Date.now()}`,name:l||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:w,schema:to(w),permissions:{owner:St,editors:[],viewers:[]}};g([E]),v(E.id),j(!0),F("confirmed")}},[i,n,m,h.length,r,l]),p.useEffect(()=>{if(!s||m)return;let w=!1,E=null;const _=async()=>{try{F("uploading");let O;if(s.type==="api"){const q=await fetch(s.url,{headers:s.headers||{}});if(!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);O=await q.json()}else O=await s.fetch();if(w)return;if(!Array.isArray(O))throw new Error("Data source must return an array of objects");const Y=to(O);if(m)g(q=>q.map(ue=>ue.id===b?{...ue,uploadedData:O}:ue)),F("confirmed");else{const q={id:`auto-report-${Date.now()}`,name:l||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:Eo(O),schema:to(Eo(O)),permissions:{owner:St,editors:[],viewers:[]}};g([q]),v(q.id),j(!0),F("confirmed")}}catch(O){w||(F("error"),a&&W(a.id,{uploadError:(O==null?void 0:O.message)||"Failed to load data from source"}))}};return _(),s.refreshInterval&&s.refreshInterval>0&&(E=setInterval(_,s.refreshInterval)),()=>{w=!0,E&&clearInterval(E)}},[s,l,r]);const Pe=(ei=a==null?void 0:a.views)==null?void 0:ei.find(w=>w.id===a.activeViewId),cr=p.useMemo(()=>a!=null&&a.uploadedData?(a.uploadedData.forEach(Il),a.uploadedData):[],[a==null?void 0:a.uploadedData]),dr=Tl({rawData:cr,schema:(a==null?void 0:a.schema)||[],filters:Oe(a==null?void 0:a.filters),sortStack:(a==null?void 0:a.sortStack)||[],grouping:(a==null?void 0:a.grouping)||null,searchQuery:nt||"",columnVisibility:(a==null?void 0:a.columnVisibility)||(Pe==null?void 0:Pe.snapshot.columnVisibility)||{},columnOrder:(a==null?void 0:a.columnOrder)||(Pe==null?void 0:Pe.snapshot.columnOrder)||[],columnWidths:(a==null?void 0:a.columnWidths)||(Pe==null?void 0:Pe.snapshot.columnWidths)||{},views:(a==null?void 0:a.views)||[],activeViewId:(a==null?void 0:a.activeViewId)||"",pagination:{enabled:!0,pageSize:At,currentPage:st}}),{data:Er=[],searchedData:Wt=[],groupedData:Dr=[],sortedData:Yt=[],metrics:$r={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Pt=!1,paginationEngine:Be}=dr||{},X=((ti=dr.viewEngine)==null?void 0:ti.activeView)||Pe,lt=((ri=dr.viewEngine)==null?void 0:ri.isDirty)||!1;p.useEffect(()=>{if(!(!X||!a)&&!a.columnOrder){const w=X.snapshot.columnOrder,E=io(w,X.snapshot.grouping);W(a.id,{columnOrder:E})}},[a==null?void 0:a.activeViewId]);const Ie=p.useMemo(()=>!(a!=null&&a.schema)||!X?null:Da(a.filters,a.sortStack||[],a.schema,a.columnVisibility,a.columnOrder,a.columnWidths,a.grouping,X.snapshot.columnOrder),[a==null?void 0:a.filters,a==null?void 0:a.sortStack,a==null?void 0:a.schema,a==null?void 0:a.columnVisibility,a==null?void 0:a.columnOrder,a==null?void 0:a.columnWidths,a==null?void 0:a.grouping,X]),qt=p.useMemo(()=>!X||!Ie||!lt?[]:_a(Ie,X.snapshot),[X,Ie,lt]),ur=p.useCallback((w,E,_)=>{const O={id:`report-${Date.now()}`,name:w,description:E,schemaLocked:!1,permissions:{owner:St,editors:[],viewers:[]}};if(_&&Array.isArray(_)&&_.length>0){const Y=to(_),q=bn(Y);O.uploadedData=_,O.schema=Y,O.schemaLocked=!0,O.views=[q],O.activeViewId=q.id,O.sortStack=q.snapshot.sortStack,O.filters=q.snapshot.filters,O.columnVisibility=q.snapshot.columnVisibility,O.columnOrder=q.snapshot.columnOrder,O.columnWidths=q.snapshot.columnWidths,O.grouping=q.snapshot.grouping}g(Y=>[...Y,O]),v(O.id),C(!1),F("confirmed")},[]),Jt=p.useCallback(w=>{a&&(F("uploading"),setTimeout(()=>{const E=to(w);W(a.id,{uploadedData:w,schema:E,uploadError:void 0}),F("preview")},500))},[a,W]),Qr=p.useCallback(w=>{a&&(W(a.id,{uploadError:w}),F("idle"))},[a,W]),kt=p.useCallback(()=>{a&&(W(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),F("idle"))},[a,W]),Tt=p.useCallback(()=>{a&&(W(a.id,{schemaLocked:!0}),F("confirmed"))},[a,W]),Kt=p.useCallback(w=>{if(!a)return;if(!ut("edit_sorting",H)){S(pt("edit_sorting"),"error");return}const E=a.sortStack??[],_=E.find(O=>O.column===w);if(_){const O=wa(_.direction);if(O===null){const Y=E.filter(q=>q.column!==w).map((q,ue)=>({...q,priority:ue+1}));W(a.id,{sortStack:Y.length>0?Y:void 0})}else{const Y=O,q=E.map(ue=>ue.column===w?{...ue,direction:Y}:ue);W(a.id,{sortStack:q})}}else{if(E.length>=f.sort.maxLevels){S(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:w,direction:"asc",priority:E.length+1};W(a.id,{sortStack:[...E,O]})}},[a,H,W]),Fe=p.useCallback(w=>{if(a)if(a.schema){const{validRules:E,invalidColumns:_}=fs(w,a.schema);_.length>0&&S(`Removed invalid sort columns: ${_.join(", ")}`),yt();try{W(a.id,{sortStack:E.length>0?E:void 0})}catch(O){const Y=rr("processing","sorting",O);at(Y)}}else W(a.id,{sortStack:w.length>0?w:void 0})},[a,W,yt,at]),pr=p.useCallback(w=>{if(!a)return;const E=a.sortStack??[],_=E.find(O=>O.column===w);if(!(_&&_.direction==="asc"))if(_){const O=E.map(Y=>Y.column===w?{...Y,direction:"asc"}:Y);W(a.id,{sortStack:O})}else{if(E.length>=f.sort.maxLevels){S(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:w,direction:"asc",priority:E.length+1};W(a.id,{sortStack:[...E,O]})}},[a,W]),fe=p.useCallback(w=>{if(!a)return;const E=a.sortStack??[],_=E.find(O=>O.column===w);if(!(_&&_.direction==="desc"))if(_){const O=E.map(Y=>Y.column===w?{...Y,direction:"desc"}:Y);W(a.id,{sortStack:O})}else{if(E.length>=f.sort.maxLevels){S(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const O={column:w,direction:"desc",priority:E.length+1};W(a.id,{sortStack:[...E,O]})}},[a,W]),He=p.useCallback((w,E)=>{var O;if(!a)return;if(!ut("edit_filters",H)){S(pt("edit_filters"),"error");return}const _=(O=a.schema)==null?void 0:O.find(Y=>Y.name===E.column);if(_&&E.value!==void 0){const Y=ul(_.type,E.operator,E.value);if(!Y.isValid){S(Y.errorMessage||"Invalid filter value","error");return}}yt();try{const Y=Oe(a.filters),q={...E,id:Yr()},ue=qr(Y,w,q);ge("filters","filter_added",null,q),W(a.id,{filters:ue})}catch(Y){const q=rr("processing","filters",Y);at(q)}},[a,H,W,yt,at,ge]),Or=p.useCallback(w=>{if(!a)return;if(!ut("edit_filters",H)){S(pt("edit_filters"),"error");return}const E=Oe(a.filters),_=qr(E,w,Ct());ge("filters","filter_added",null,"a condition group"),W(a.id,{filters:_})},[a,H,W,ge]),ct=p.useCallback((w,E)=>{if(!a)return;if(!ut("edit_filters",H)){S(pt("edit_filters"),"error");return}const _=Oe(a.filters),O=Do(_,w),Y=Pn(_,w,E),q=Do(Y,w);ge("filters","filter_updated",O,q),W(a.id,{filters:Y})},[a,H,W,ge]),bt=p.useCallback((w,E)=>{if(!a)return;if(!ut("edit_filters",H)){S(pt("edit_filters"),"error");return}const _=Oe(a.filters),O=Nn(_,w,E);ge("filters","filter_updated",null,`group operator changed to ${E.toUpperCase()}`),W(a.id,{filters:O})},[a,H,W,ge]),Bt=p.useCallback(w=>{if(!a)return;if(!ut("edit_filters",H)){S(pt("edit_filters"),"error");return}const E=Oe(a.filters),_=Do(E,w),O=Ln(E,w);ge("filters","filter_removed",_,null),W(a.id,{filters:O})},[a,H,W,ge]),_r=p.useCallback(()=>{if(!a)return;if(!ut("edit_filters",H)){S(pt("edit_filters"),"error");return}const w=Oe(a.filters);ge("filters","filter_cleared",{count:mt(w)},null),W(a.id,{filters:Ct()})},[a,H,W,ge]),Xt=p.useCallback(w=>{if(!a)return;if(!ut("edit_filters",H)){S(pt("edit_filters"),"error");return}const E=Oe(a.filters);ge("filters","filter_cleared",{count:mt(E)},{count:mt(w)}),W(a.id,{filters:w})},[a,H,W,ge]),Je=p.useCallback(w=>{var Y;if(!a)return;const E=(Y=a.views)==null?void 0:Y.find(q=>q.id===w);if(!E)return;const _=E.snapshot.columnOrder,O=io(_,E.snapshot.grouping);W(a.id,{filters:E.snapshot.filters,sortStack:E.snapshot.sortStack.length>0?[...E.snapshot.sortStack]:void 0,columnVisibility:{...E.snapshot.columnVisibility},columnOrder:O,columnWidths:{...E.snapshot.columnWidths},grouping:E.snapshot.grouping,activeViewId:w}),it(new Set)},[a,W]),Ge=p.useCallback((w,E,_)=>{var Le;if(!(a!=null&&a.schema)||!Ie)return;const O=a.views??[],Y=O.filter(yn=>!yn.isDeleted).length,q=((Le=f.views)==null?void 0:Le.maxViews)??10;if(Y>=q){S(`View limit reached — you can have at most ${q} saved views. Delete an existing view to create a new one.`,"error");return}const ue={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:w,description:E||void 0,isDefault:_,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:St,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Ie}},be=_?O.map(yn=>({...yn,isDefault:!1})):O;W(a.id,{views:[...be,ue],activeViewId:ue.id}),S(`"${w}" view created`,"success")},[a,Ie,W]),xr=p.useCallback(w=>{var ue;if(!(a!=null&&a.views))return;const E=a.views.find(be=>be.id===w);if(!E)return;const _=a.views,O=_.filter(be=>!be.isDeleted).length,Y=((ue=f.views)==null?void 0:ue.maxViews)??10;if(O>=Y){S(`View limit reached — you can have at most ${Y} saved views. Delete an existing view to create a new one.`,"error");return}const q={...E,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${E.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:St,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...E.snapshot}};W(a.id,{views:[..._,q]}),S(`"${q.name}" created`,"success")},[a,f,W]),Qt=p.useCallback(()=>{var E;if(!X||!Ie||!a)return;const w=(E=a.views)==null?void 0:E.map(_=>_.id===X.id?{..._,snapshot:{...Ie}}:_);W(a.id,{views:w}),S(`"${X.name}" view updated`,"success")},[X,Ie,a,W]),mr=p.useCallback(w=>{var O;if(!X||!Ie||!a)return;const E=w??Ie.columnWidths,_=(O=a.views)==null?void 0:O.map(Y=>Y.id===X.id?{...Y,snapshot:{...Y.snapshot,columnVisibility:Ie.columnVisibility,columnOrder:Ie.columnOrder,columnWidths:E},updatedAt:Date.now()}:Y);W(a.id,{views:_,columnWidths:E}),S(`Column configuration saved to "${X.name}"`,"success")},[X,Ie,a,W]),xe=p.useCallback(w=>{var q,ue;if(!Ie||!a||!X)return;const E=w??Ie.columnWidths,_={...X,snapshot:{...X.snapshot,columnVisibility:Ie.columnVisibility,columnOrder:Ie.columnOrder,columnWidths:E},updatedAt:Date.now()},O=(q=a.views)==null?void 0:q.map(be=>be.id===X.id?_:{...be,snapshot:{...be.snapshot,columnVisibility:Ie.columnVisibility,columnOrder:Ie.columnOrder,columnWidths:E},updatedAt:Date.now()});W(a.id,{views:O,columnWidths:E});const Y=(((ue=a.views)==null?void 0:ue.length)||0)-1;S(`Column configuration saved to current view and ${Y} other view${Y===1?"":"s"}`,"success")},[Ie,a,X,W]),Ce=p.useCallback(()=>{te(!0)},[]),$e=p.useCallback(()=>{if(!X||!a)return;const w=X.snapshot.columnOrder,E=io(w,X.snapshot.grouping);W(a.id,{filters:X.snapshot.filters,sortStack:X.snapshot.sortStack.length>0?[...X.snapshot.sortStack]:void 0,columnVisibility:{...X.snapshot.columnVisibility},columnOrder:E,columnWidths:{...X.snapshot.columnWidths},grouping:X.snapshot.grouping}),S("Changes reverted to last saved state","success")},[X,a,W]),It=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map(O=>({...O,isDefault:O.id===w}));W(a.id,{views:E});const _=a.views.find(O=>O.id===w);_&&S(`"${_.name}" set as default view`,"success")},[a,W]),Zt=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map(O=>O.id===w?{...O,isFavorite:!O.isFavorite,updatedAt:Date.now()}:O);W(a.id,{views:E});const _=a.views.find(O=>O.id===w);_&&!_.isFavorite?S(`"${_.name}" added to favorites`,"success"):_&&S(`"${_.name}" removed from favorites`,"info")},[a,W]),ho=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.find(Le=>Le.id===w),_=a.views.filter(Le=>!Le.isDeleted||Le.id===w);if((E==null?void 0:E.isDefault)&&_.filter(Le=>Le.isDefault).length===1){S("Cannot delete the last default view","error");return}const Y=a.views.map(Le=>Le.id===w?{...Le,isDeleted:!0,updatedAt:Date.now()}:Le),q=a.activeViewId===w,ue=Y.find(Le=>Le.isDefault&&!Le.isDeleted);W(a.id,{views:Y,activeViewId:q&&ue?ue.id:a.activeViewId,filters:q&&ue?ue.snapshot.filters:a.filters,sortStack:q&&ue?ue.snapshot.sortStack.length>0?ue.snapshot.sortStack:void 0:a.sortStack});const be=a.views.find(Le=>Le.id===w);be&&S(`"${be.name}" moved to Recently Deleted`,"info")},[a,W]),Ar=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.map(O=>O.id===w?{...O,isDeleted:!1,updatedAt:Date.now()}:O);W(a.id,{views:E});const _=a.views.find(O=>O.id===w);_&&S(`"${_.name}" restored`,"success")},[a,W]),go=p.useCallback(w=>{if(!(a!=null&&a.views))return;const E=a.views.find(be=>be.id===w),_=a.views.filter(be=>!be.isDeleted||be.id===w);if((E==null?void 0:E.isDefault)&&_.filter(be=>be.isDefault).length===1){S("Cannot delete the last default view","error");return}const Y=a.views.filter(be=>be.id!==w),q=a.activeViewId===w,ue=Y.find(be=>be.isDefault&&!be.isDeleted);W(a.id,{views:Y,activeViewId:q&&ue?ue.id:a.activeViewId,filters:q&&ue?ue.snapshot.filters:a.filters,sortStack:q&&ue?ue.snapshot.sortStack.length>0?ue.snapshot.sortStack:void 0:a.sortStack}),E&&S(`"${E.name}" permanently deleted`,"success")},[a,W]),fr=p.useCallback(w=>{le(w),Q(!0)},[]),Zr=p.useCallback(async w=>{if(!a)return;const E=new URLSearchParams(window.location.search);E.set("reportId",a.id),E.set("view",w);const _=`${window.location.origin}${window.location.pathname}?${E.toString()}`,O=await il(_);S(O?"Link copied to clipboard":"Failed to copy link",O?"success":"error")},[a]),yo=p.useCallback((w,E)=>{if(!ne||!(a!=null&&a.views))return;const _=a.views.map(O=>O.id===ne?{...O,name:w,description:E||void 0}:O);W(a.id,{views:_}),le(null)},[ne,a,W]),vt=p.useCallback(w=>{se(w),he(!0)},[]),Mr=p.useCallback(()=>{if(!U||!(a!=null&&a.views))return;const w=a.views.filter(O=>O.id!==U),E=a.activeViewId===U,_=w.find(O=>O.isDefault);W(a.id,{views:w,activeViewId:E&&_?_.id:a.activeViewId,filters:E&&_?_.snapshot.filters:a.filters,sortStack:E&&_?_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0:a.sortStack}),se(null),he(!1)},[U,a,W]),Rr=p.useCallback(w=>{var Y;if(!(a!=null&&a.views))return;if(!(((Y=f.views)==null?void 0:Y.isAdmin)??!1)){S("Only administrators can promote views to Global.","error");return}const _=a.views.find(q=>q.id===w);if(!_)return;if(_.scope==="global"){S(`"${_.name}" is already a Global View.`,"info");return}const O=a.views.map(q=>q.id===w?{...q,scope:"global",isDefault:!0,updatedAt:Date.now()}:q.scope==="global"&&q.isDefault?{...q,isDefault:!1}:q);W(a.id,{views:O}),S(`"${_.name}" promoted to Global View and set as default.`,"success")},[a,f,W]);p.useEffect(()=>{Be!=null&&Be.resetPage?Be.resetPage():_t(1)},[a==null?void 0:a.filters,nt,a==null?void 0:a.activeViewId]),p.useEffect(()=>{Be&&Be.currentPage!==st&&_t(Be.currentPage)},[Be==null?void 0:Be.currentPage]);const er=p.useCallback(w=>{Be!=null&&Be.goToPage&&Be.goToPage(w),_t(w)},[Be]),bo=p.useCallback(w=>{const E=(st-1)*At,_=Math.floor(E/w)+1;Jr(w),_t(_),Be==null||Be.goToPage(_)},[st,At,Be]),Wr=p.useCallback((w,E)=>{if(!a)return;if(!ut("edit_columns",H)){S(pt("edit_columns"),"error");return}const O={...a.columnVisibility||(X==null?void 0:X.snapshot.columnVisibility)||{},[w]:E};W(a.id,{columnVisibility:O})},[a,X,H,W]),sn=p.useCallback(w=>{if(a){if(!ut("edit_columns",H)){S(pt("edit_columns"),"error");return}W(a.id,{columnOrder:w})}},[a,H,W]),an=p.useCallback((w,E)=>{if(!a)return;if(!ut("edit_columns",H)){S(pt("edit_columns"),"error");return}const O={...a.columnWidths||(X==null?void 0:X.snapshot.columnWidths)||{},[w]:E};W(a.id,{columnWidths:O})},[a,X,H,W]),ln=p.useCallback(w=>{if(!a)return;const E=Oe(a.filters),_=cs(E,w);W(a.id,{filters:_})},[a,W]),cn=p.useCallback(()=>{if(!X||!(a!=null&&a.schema))return;const w={},E=[],_={};a.schema.forEach(O=>{w[O.name]=!0,E.push(O.name),_[O.name]=170}),W(a.id,{columnVisibility:w,columnOrder:E,columnWidths:_,filters:void 0,sortStack:void 0}),S("Reset to default layout - all filters and sorts cleared","success")},[X,a,W]);p.useEffect(()=>{const w=setTimeout(()=>Ut(gt),300);return()=>clearTimeout(w)},[gt]);const dn=p.useCallback(w=>{Tr(w)},[]),un=p.useCallback(w=>{if(!w.trim()||!a)return;const E=a.searchHistory||[],_=Wa(E,w);W(a.id,{searchHistory:_})},[a,W]),pn=p.useCallback(w=>{if(!a)return;const E=a.searchHistory||[],_=Pa(E,w);W(a.id,{searchHistory:_})},[a,W]),xn=p.useCallback(w=>{if(!a)return;const E=a.searchHistory||[],_=Na(E,w);W(a.id,{searchHistory:_})},[a,W]),mn=p.useCallback(w=>{const E=w==null?void 0:w.__urm_row_id__;it(_=>{const O=new Set(_);if(E!==void 0){const Y=Array.from(O).find(q=>(q==null?void 0:q.__urm_row_id__)===E);Y!==void 0?O.delete(Y):O.add(w)}else{const Y=JSON.stringify(w),q=Array.from(O).find(ue=>JSON.stringify(ue)===Y);q!==void 0?O.delete(q):O.add(w)}return O})},[]),Pr=p.useCallback((w,E)=>{it(_=>{const O=new Set(_);for(const Y of E)w?O.add(Y):O.delete(Y);return O})},[]),Nt=p.useCallback((w,E,_)=>{it(O=>{const Y=new Set(O),q=Math.min(w,E),ue=Math.max(w,E);for(let be=q;be<=ue;be++)_[be]!==void 0&&Y.add(_[be]);return Y})},[]),fn=p.useCallback(()=>{it(new Set)},[]),hn=p.useCallback(w=>{const E=w==null?void 0:w.__urm_row_id__;it(_=>{const O=new Set(_);if(E!==void 0){const Y=Array.from(O).find(q=>(q==null?void 0:q.__urm_row_id__)===E);Y!==void 0&&O.delete(Y)}else O.delete(w);return O})},[]),Ne=p.useCallback(w=>{if(a){if(!ut("edit_columns",H)){S(pt("edit_columns"),"error");return}if(w&&a.schema){const{validGrouping:E,invalidColumns:_}=hs(w,a.schema);_.length>0&&S(`Removed invalid grouping columns: ${_.join(", ")}`,"warning"),yt();try{const O=a.grouping;E===null?ge("grouping","group_cleared",O,null):O?ge("grouping","group_reordered",O,E):ge("grouping","group_level_added",null,E);const Y=(X==null?void 0:X.snapshot.columnOrder)||a.columnOrder||[],q=io(Y,E);W(a.id,{grouping:E,columnOrder:q}),JSON.stringify(q)!==JSON.stringify(a.columnOrder)&&ge("columns","column_reordered",a.columnOrder,q),ot(!1)}catch(O){const Y=rr("processing","grouping",O);at(Y)}}else{const E=a.grouping;ge("grouping","group_cleared",E,null);const _=(X==null?void 0:X.snapshot.columnOrder)||a.columnOrder||[];W(a.id,{grouping:w,columnOrder:[..._]}),JSON.stringify(_)!==JSON.stringify(a.columnOrder)&&ge("columns","column_reordered",a.columnOrder,_),ot(!1)}}},[a,X,H,W,yt,at,ge]),Lt=p.useCallback(w=>{if(!a)return;const E=a.grouping;if(!E)return;const _=Ea(E,w);W(a.id,{grouping:_})},[a,W]),vo=p.useCallback(()=>{a!=null&&a.grouping&&W(a.id,{grouping:{...a.grouping,collapsedGroups:[]}})},[a,W]),Qn=p.useCallback(()=>{if(!(a!=null&&a.grouping)||!a.schema)return;const w=za(Yt,a.schema,a.grouping);W(a.id,{grouping:{...a.grouping,collapsedGroups:w}})},[a,Yt,W]),eo=p.useCallback(()=>{qe(!0)},[]),hr=p.useCallback(w=>{a!=null&&a.schema&&(D(!0),setTimeout(()=>{try{let E;w.scope==="visible"?E=Wt:E=a.uploadedData||[];let _;w.columnScope==="all"?(_={},(a.schema??[]).forEach(be=>{_[be.name]=!0})):_=a.columnVisibility||(X==null?void 0:X.snapshot.columnVisibility)||{};const O=a.columnOrder||(X==null?void 0:X.snapshot.columnOrder),Y=Ao(E,a.schema,Oe(a.filters),a.sortStack??[],X,_,O),q=a.name;let ue;switch(w.format){case"csv":Mo(Y,q,w),ue="export_csv";break;case"excel":Ro(Y,q,w),ue="export_excel";break;case"json":Wo(Y,q,w),ue="export_json";break}ge("export",ue,null,{format:w.format,scope:w.scope,columnScope:w.columnScope,rowCount:E.length,viewName:(X==null?void 0:X.name)||"Default View"}),S(`Export completed successfully (${w.format.toUpperCase()})`,"success")}catch(E){const _=xl(E,{onRetry:()=>hr(w)});S(`Export failed: ${_.message}. Click Export to retry.`,"error");const O=fi(a.id,St,_,a.auditHistory||[]);W(a.id,{auditHistory:O}),Ot.error("urm:report-engine","Export failed",E)}finally{D(!1)}},500))},[a,X,Wt,W,ge]),So=p.useCallback(w=>{if(a!=null&&a.schema){if(lt&&X&&!X.isDefault){ye(w.format),de(!0),qe(!1);return}hr(w),qe(!1)}},[a,X,lt,hr]),gr=p.useCallback(w=>{hr({format:w,scope:"visible",columnScope:"visible"})},[hr]),k=p.useCallback(()=>{oe&&gr(oe),de(!1),ye(null)},[oe,gr]),V=p.useCallback(()=>{Qt(),oe&&gr(oe),de(!1),ye(null)},[Qt,oe,gr]),me=p.useCallback(()=>{de(!1),ye(null)},[]),Ke=p.useCallback(w=>{!(a!=null&&a.schema)||jt.size===0||(D(!0),setTimeout(()=>{try{const E=Array.from(jt),_=Ao(E,a.schema,Oe(a.filters),a.sortStack??[],X),O=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(w){case"csv":Mo(_,O);break;case"excel":Ro(_,O);break;case"json":Wo(_,O);break}S(`Exported ${E.length} selected rows`,"info")}catch(E){S("Export failed. Please try again.","error"),Ot.error("urm:report-engine","Bulk export failed",E)}finally{D(!1)}},500))},[a,X,jt,Dr]),dt=p.useCallback((w,E)=>{if(a)try{const _=Za(a),O=el(w,E,St,_),Y=tl(a.presets,O);W(a.id,{presets:Y}),ge("presets","preset_created",null,{presetId:O.id,name:O.name}),Kr(!1),S(`Preset "${w}" saved successfully`,"success")}catch(_){S(_ instanceof Error?_.message:"Failed to create preset","error")}},[a,W,ge]),zt=p.useCallback(()=>{wt(null),S("Exited preset view","info")},[]),Et=p.useCallback(()=>{Mt(!0)},[]),pe=p.useCallback((w,E)=>{if(!a)return;const _=rl(a.presets,w);W(a.id,{presets:_}),ge("presets","preset_deleted",{presetId:w,name:E},null),Ve===w&&wt(null),S(`Preset "${E}" deleted`,"success")},[a,Ve,W,ge]);p.useEffect(()=>{if(!d||h.length===0)return;const w=h.find(E=>E.id===d);w&&w.id!==b&&v(w.id)},[d,h,b]);const Nr=p.useRef(!1);p.useEffect(()=>{var E;if(!c||Nr.current||!a||a.id!==d)return;const w=(E=a.views)==null?void 0:E.find(_=>_.id===c&&!_.isDeleted);w&&Je(w.id),Nr.current=!0},[c,d,a,Je]),p.useEffect(()=>{if(!a)return;const w=ol();if(w&&a.presets&&a.schemaLocked&&a.schema){const E=mi(a.presets,w);if(E){const{sanitizedConfig:_,warnings:O}=pl(E.config,a.schema);O.length>0&&O.forEach(q=>S(q,"warning"));const Y=nl(_);W(a.id,Y),wt(w),ge("presets","preset_applied",null,{presetId:E.id,name:E.name}),S(`Loaded preset: ${E.name}`,"info")}else S("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const Zn=Ve?mi(a==null?void 0:a.presets,Ve):void 0;p.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&Aa(a.id,{views:a.views,activeViewId:a.activeViewId})},[a==null?void 0:a.views,a==null?void 0:a.activeViewId,a==null?void 0:a.id]),p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const w=Ma(a.id);if(w&&w.views.length>0){const E=w.views.find(_=>_.id===w.activeViewId);if(E)W(a.id,{views:w.views,activeViewId:w.activeViewId,filters:Oe(E.snapshot.filters),sortStack:E.snapshot.sortStack.length>0?E.snapshot.sortStack:void 0});else{const _=w.views.find(O=>O.isDefault)||bn(a.schema);W(a.id,{views:w.views,activeViewId:_.id,filters:Oe(_.snapshot.filters),sortStack:_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0})}}}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id]);const gn=p.useCallback(w=>{var O;const E=Oe(a==null?void 0:a.filters),_=((O=f.filter)==null?void 0:O.maxConditions)??3;if(mt(E)>=_){S(`Filter limit reached — maximum ${_} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}K(w),ee(!0)},[a,f,S]),Ks=p.useCallback(()=>{ee(!1),K(void 0)},[]),Xs=(oi=a==null?void 0:a.views)==null?void 0:oi.find(w=>w.id===ne),Qs=(ni=a==null?void 0:a.views)==null?void 0:ni.find(w=>w.id===U);return{reports:h,activeReport:a,activeReportId:b,setActiveReportId:v,isModalOpen:T,setIsModalOpen:C,createReport:ur,updateReport:W,uploadState:A,handleFileUpload:Jt,handleUploadError:Qr,handleRetry:kt,handleConfirm:Tt,paginatedData:Er,processedData:Wt,displayData:Dr,tableMetrics:$r,isGrouped:Pt,tableEngine:dr,activeView:X,isDirty:lt,currentTableState:Ie,viewChanges:qt,filters:a==null?void 0:a.filters,showFilterPanel:J,setShowFilterPanel:ee,filterFocusColumn:L,handleAddCondition:He,handleAddGroup:Or,handleUpdateCondition:ct,handleSetGroupOperator:bt,handleRemoveFilterNode:Bt,handleClearAllFilters:_r,handleReplaceFilters:Xt,handleOpenFilterForColumn:gn,handleCloseFilterPanel:Ks,handleClearFiltersForColumn:ln,sortStack:a==null?void 0:a.sortStack,showSortPanel:x,setShowSortPanel:R,handleSort:Kt,handleUpdateSortStack:Fe,handleSortAscending:pr,handleSortDescending:fe,views:a==null?void 0:a.views,showCreateViewModal:P,setShowCreateViewModal:te,showEditViewModal:ae,setShowEditViewModal:Q,showDeleteConfirmation:re,setShowDeleteConfirmation:he,editingView:Xs,deletingView:Qs,editingViewId:ne,deletingViewId:U,handleSelectView:Je,handleCreateView:Ge,handleCloneView:xr,handleUpdateCurrentView:Qt,handleSaveColumnConfigToCurrentView:mr,handleSaveColumnConfigToAllViews:xe,handleSaveAsNewView:Ce,handleRevertChanges:$e,handleToggleDefault:It,handleToggleFavorite:Zt,handleSoftDelete:ho,handleRestoreView:Ar,handlePermanentDelete:go,handleEditView:fr,handleCopyViewLink:Zr,handleSaveEditView:yo,handleDeleteView:vt,handleConfirmDelete:Mr,handlePromoteToGlobal:Rr,showManageColumns:G,setShowManageColumns:Me,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:Wr,handleUpdateColumnOrder:sn,handleUpdateColumnWidth:an,handleResetColumnLayout:cn,showGroupPanel:ht,setShowGroupPanel:ot,grouping:a==null?void 0:a.grouping,groupingState:wr,handleGroup:Ne,handleToggleGroupCollapse:Lt,handleExpandAllGroups:vo,handleCollapseAllGroups:Qn,searchQuery:gt,debouncedSearchQuery:nt,searchHistory:La((a==null?void 0:a.searchHistory)||[]),handleSearchChange:dn,handleAddToSearchHistory:un,handleToggleSearchFavourite:pn,handleDeleteSearchHistory:xn,selectedRowIds:jt,handleToggleRowSelection:mn,handleToggleAllRows:Pr,handleRangeSelection:Nt,handleClearSelection:fn,handleUpdateSelectionAfterDelete:hn,currentPage:st,pageSize:At,paginationEngine:Be,handlePageChange:er,handlePageSizeChange:bo,isExporting:ie,showExportModal:Xr,setShowExportModal:qe,showDirtyExportWarning:Z,handleExport:eo,handleExportWithConfig:So,handleExportSelected:Ke,handleExportAnyway:k,handleSaveAndExport:V,handleCancelExport:me,showAuditHistory:ir,setShowAuditHistory:sr,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:Ye,setShowCreatePreset:Kr,showManagePresets:Br,setShowManagePresets:Mt,activePreset:Zn,activePresetId:Ve,handleOpenManagePresets:Et,handleCreatePreset:dt,handleClearActivePreset:zt,handleDeletePresetById:pe,userRole:H,isViewerRole:lr,currentUserId:St,featureLimitWarning:ar,setFeatureLimitWarning:Re,datasetMeta:zr,reportError:Gt,setReportError:Rt,handleError:at,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?Sa(a.schema):!1,snack:y,handleSnackClose:I,showSnack:S,snackDurationMs:N,config:u}}const gs=p.createContext(void 0);function Un(e){const{children:r,initialData:n,data:i,reportName:s,dataSource:l,mode:d="builder",autoLoad:c=!0,config:u,devConfig:h,showDevPanel:g=!1,sharedReportId:f,sharedViewId:b}=e,T=zl({mode:d,autoLoad:c,initialData:i||n,dataSource:l,reportName:s,sharedReportId:f,sharedViewId:b,config:u}),[C,m]=p.useState(()=>oa()),j=(()=>{const I=ia(C,h,!!h);return{...I,display:{...I.display,showDevPanel:g||I.display.showDevPanel}}})(),y=p.useCallback(S=>{m(S),na(S)},[]),$={...T,activeDevConfig:j,handleDevConfigChange:y};return t.jsx(ns.Provider,{value:j,children:t.jsx(gs.Provider,{value:$,children:r})})}function Ho(){const e=p.useContext(gs);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function El({onCreateReport:e,reports:r=[],activeReportId:n,onReportClick:i}){const s=r.find(l=>l.id===n);return t.jsx(o.Box,{component:"header",sx:{position:"sticky",top:0,zIndex:50,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper"},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(z.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[t.jsx(o.Typography,{variant:"h6",component:"h1",sx:{fontWeight:500,fontSize:"1.375rem",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:500,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(z.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(z.Add,{sx:{fontSize:18}}),onClick:e,sx:{borderRadius:"20px",px:3,fontSize:"0.875rem",py:.75},children:"New Report"})})]})})}function vr(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 Dl="$$material";function $l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jo={exports:{}},wo={exports:{}},ve={};/** @license React v16.13.1
4
4
  * react-is.production.min.js
5
5
  *
6
6
  * Copyright (c) Facebook, Inc. and its affiliates.
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var ai;function Dl(){if(ai)return be;ai=1;var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,l=e?Symbol.for("react.profiler"):60114,d=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,m=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,x=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,b=e?Symbol.for("react.memo"):60115,z=e?Symbol.for("react.lazy"):60116,S=e?Symbol.for("react.block"):60121,y=e?Symbol.for("react.fundamental"):60117,w=e?Symbol.for("react.responder"):60118,C=e?Symbol.for("react.scope"):60119;function E(k){if(typeof k=="object"&&k!==null){var L=k.$$typeof;switch(L){case r:switch(k=k.type,k){case u:case m:case i:case l:case s:case x:return k;default:switch(k=k&&k.$$typeof,k){case c:case f:case z:case b:case d:return k;default:return L}}case n:return L}}}function g(k){return E(k)===m}return be.AsyncMode=u,be.ConcurrentMode=m,be.ContextConsumer=c,be.ContextProvider=d,be.Element=r,be.ForwardRef=f,be.Fragment=i,be.Lazy=z,be.Memo=b,be.Portal=n,be.Profiler=l,be.StrictMode=s,be.Suspense=x,be.isAsyncMode=function(k){return g(k)||E(k)===u},be.isConcurrentMode=g,be.isContextConsumer=function(k){return E(k)===c},be.isContextProvider=function(k){return E(k)===d},be.isElement=function(k){return typeof k=="object"&&k!==null&&k.$$typeof===r},be.isForwardRef=function(k){return E(k)===f},be.isFragment=function(k){return E(k)===i},be.isLazy=function(k){return E(k)===z},be.isMemo=function(k){return E(k)===b},be.isPortal=function(k){return E(k)===n},be.isProfiler=function(k){return E(k)===l},be.isStrictMode=function(k){return E(k)===s},be.isSuspense=function(k){return E(k)===x},be.isValidElementType=function(k){return typeof k=="string"||typeof k=="function"||k===i||k===m||k===l||k===s||k===x||k===v||typeof k=="object"&&k!==null&&(k.$$typeof===z||k.$$typeof===b||k.$$typeof===d||k.$$typeof===c||k.$$typeof===f||k.$$typeof===y||k.$$typeof===w||k.$$typeof===C||k.$$typeof===S)},be.typeOf=E,be}var ve={};/** @license React v16.13.1
10
+ */var hi;function Ol(){if(hi)return ve;hi=1;var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,l=e?Symbol.for("react.profiler"):60114,d=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,h=e?Symbol.for("react.concurrent_mode"):60111,g=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,b=e?Symbol.for("react.suspense_list"):60120,v=e?Symbol.for("react.memo"):60115,T=e?Symbol.for("react.lazy"):60116,C=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,j=e?Symbol.for("react.responder"):60118,y=e?Symbol.for("react.scope"):60119;function $(I){if(typeof I=="object"&&I!==null){var N=I.$$typeof;switch(N){case r:switch(I=I.type,I){case u:case h:case i:case l:case s:case f:return I;default:switch(I=I&&I.$$typeof,I){case c:case g:case T:case v:case d:return I;default:return N}}case n:return N}}}function S(I){return $(I)===h}return ve.AsyncMode=u,ve.ConcurrentMode=h,ve.ContextConsumer=c,ve.ContextProvider=d,ve.Element=r,ve.ForwardRef=g,ve.Fragment=i,ve.Lazy=T,ve.Memo=v,ve.Portal=n,ve.Profiler=l,ve.StrictMode=s,ve.Suspense=f,ve.isAsyncMode=function(I){return S(I)||$(I)===u},ve.isConcurrentMode=S,ve.isContextConsumer=function(I){return $(I)===c},ve.isContextProvider=function(I){return $(I)===d},ve.isElement=function(I){return typeof I=="object"&&I!==null&&I.$$typeof===r},ve.isForwardRef=function(I){return $(I)===g},ve.isFragment=function(I){return $(I)===i},ve.isLazy=function(I){return $(I)===T},ve.isMemo=function(I){return $(I)===v},ve.isPortal=function(I){return $(I)===n},ve.isProfiler=function(I){return $(I)===l},ve.isStrictMode=function(I){return $(I)===s},ve.isSuspense=function(I){return $(I)===f},ve.isValidElementType=function(I){return typeof I=="string"||typeof I=="function"||I===i||I===h||I===l||I===s||I===f||I===b||typeof I=="object"&&I!==null&&(I.$$typeof===T||I.$$typeof===v||I.$$typeof===d||I.$$typeof===c||I.$$typeof===g||I.$$typeof===m||I.$$typeof===j||I.$$typeof===y||I.$$typeof===C)},ve.typeOf=$,ve}var Se={};/** @license React v16.13.1
11
11
  * react-is.development.js
12
12
  *
13
13
  * Copyright (c) Facebook, Inc. and its affiliates.
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var li;function Ol(){return li||(li=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,l=e?Symbol.for("react.profiler"):60114,d=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,m=e?Symbol.for("react.concurrent_mode"):60111,f=e?Symbol.for("react.forward_ref"):60112,x=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,b=e?Symbol.for("react.memo"):60115,z=e?Symbol.for("react.lazy"):60116,S=e?Symbol.for("react.block"):60121,y=e?Symbol.for("react.fundamental"):60117,w=e?Symbol.for("react.responder"):60118,C=e?Symbol.for("react.scope"):60119;function E(q){return typeof q=="string"||typeof q=="function"||q===i||q===m||q===l||q===s||q===x||q===v||typeof q=="object"&&q!==null&&(q.$$typeof===z||q.$$typeof===b||q.$$typeof===d||q.$$typeof===c||q.$$typeof===f||q.$$typeof===y||q.$$typeof===w||q.$$typeof===C||q.$$typeof===S)}function g(q){if(typeof q=="object"&&q!==null){var Me=q.$$typeof;switch(Me){case r:var et=q.type;switch(et){case u:case m:case i:case l:case s:case x:return et;default:var tt=et&&et.$$typeof;switch(tt){case c:case f:case z:case b:case d:return tt;default:return Me}}case n:return Me}}}var k=u,L=m,a=c,_=d,F=r,X=f,re=i,h=z,V=b,W=n,Q=l,Z=s,pe=x,he=!1;function N(q){return he||(he=!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.")),R(q)||g(q)===u}function R(q){return g(q)===m}function H(q){return g(q)===c}function G(q){return g(q)===d}function ae(q){return typeof q=="object"&&q!==null&&q.$$typeof===r}function ee(q){return g(q)===f}function ne(q){return g(q)===i}function oe(q){return g(q)===z}function O(q){return g(q)===b}function te(q){return g(q)===n}function ce(q){return g(q)===l}function ie(q){return g(q)===s}function Ie(q){return g(q)===x}ve.AsyncMode=k,ve.ConcurrentMode=L,ve.ContextConsumer=a,ve.ContextProvider=_,ve.Element=F,ve.ForwardRef=X,ve.Fragment=re,ve.Lazy=h,ve.Memo=V,ve.Portal=W,ve.Profiler=Q,ve.StrictMode=Z,ve.Suspense=pe,ve.isAsyncMode=N,ve.isConcurrentMode=R,ve.isContextConsumer=H,ve.isContextProvider=G,ve.isElement=ae,ve.isForwardRef=ee,ve.isFragment=ne,ve.isLazy=oe,ve.isMemo=O,ve.isPortal=te,ve.isProfiler=ce,ve.isStrictMode=ie,ve.isSuspense=Ie,ve.isValidElementType=E,ve.typeOf=g})()),ve}var ci;function ss(){return ci||(ci=1,process.env.NODE_ENV==="production"?mo.exports=Dl():mo.exports=Ol()),mo.exports}/*
17
+ */var gi;function _l(){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,l=e?Symbol.for("react.profiler"):60114,d=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,h=e?Symbol.for("react.concurrent_mode"):60111,g=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,b=e?Symbol.for("react.suspense_list"):60120,v=e?Symbol.for("react.memo"):60115,T=e?Symbol.for("react.lazy"):60116,C=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,j=e?Symbol.for("react.responder"):60118,y=e?Symbol.for("react.scope"):60119;function $(G){return typeof G=="string"||typeof G=="function"||G===i||G===h||G===l||G===s||G===f||G===b||typeof G=="object"&&G!==null&&(G.$$typeof===T||G.$$typeof===v||G.$$typeof===d||G.$$typeof===c||G.$$typeof===g||G.$$typeof===m||G.$$typeof===j||G.$$typeof===y||G.$$typeof===C)}function S(G){if(typeof G=="object"&&G!==null){var Me=G.$$typeof;switch(Me){case r:var ht=G.type;switch(ht){case u:case h:case i:case l:case s:case f:return ht;default:var ot=ht&&ht.$$typeof;switch(ot){case c:case g:case T:case v:case d:return ot;default:return Me}}case n:return Me}}}var I=u,N=h,a=c,A=d,F=r,J=g,ee=i,x=T,R=v,P=n,te=l,ae=s,Q=f,re=!1;function he(G){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.")),L(G)||S(G)===u}function L(G){return S(G)===h}function K(G){return S(G)===c}function ne(G){return S(G)===d}function le(G){return typeof G=="object"&&G!==null&&G.$$typeof===r}function U(G){return S(G)===g}function se(G){return S(G)===i}function ie(G){return S(G)===T}function D(G){return S(G)===v}function Z(G){return S(G)===n}function de(G){return S(G)===l}function oe(G){return S(G)===s}function ye(G){return S(G)===f}Se.AsyncMode=I,Se.ConcurrentMode=N,Se.ContextConsumer=a,Se.ContextProvider=A,Se.Element=F,Se.ForwardRef=J,Se.Fragment=ee,Se.Lazy=x,Se.Memo=R,Se.Portal=P,Se.Profiler=te,Se.StrictMode=ae,Se.Suspense=Q,Se.isAsyncMode=he,Se.isConcurrentMode=L,Se.isContextConsumer=K,Se.isContextProvider=ne,Se.isElement=le,Se.isForwardRef=U,Se.isFragment=se,Se.isLazy=ie,Se.isMemo=D,Se.isPortal=Z,Se.isProfiler=de,Se.isStrictMode=oe,Se.isSuspense=ye,Se.isValidElementType=$,Se.typeOf=S})()),Se}var yi;function ys(){return yi||(yi=1,process.env.NODE_ENV==="production"?wo.exports=Ol():wo.exports=_l()),wo.exports}/*
18
18
  object-assign
19
19
  (c) Sindre Sorhus
20
20
  @license MIT
21
- */var dn,di;function $l(){if(di)return dn;di=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function s(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var d={},c=0;c<10;c++)d["_"+String.fromCharCode(c)]=c;var u=Object.getOwnPropertyNames(d).map(function(f){return d[f]});if(u.join("")!=="0123456789")return!1;var m={};return"abcdefghijklmnopqrst".split("").forEach(function(f){m[f]=f}),Object.keys(Object.assign({},m)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return dn=s()?Object.assign:function(l,d){for(var c,u=i(l),m,f=1;f<arguments.length;f++){c=Object(arguments[f]);for(var x in c)r.call(c,x)&&(u[x]=c[x]);if(e){m=e(c);for(var v=0;v<m.length;v++)n.call(c,m[v])&&(u[m[v]]=c[m[v]])}}return u},dn}var un,ui;function Rn(){if(ui)return un;ui=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return un=e,un}var pn,pi;function as(){return pi||(pi=1,pn=Function.call.bind(Object.prototype.hasOwnProperty)),pn}var xn,xi;function Al(){if(xi)return xn;xi=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=Rn(),n={},i=as();e=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function s(l,d,c,u,m){if(process.env.NODE_ENV!=="production"){for(var f in l)if(i(l,f)){var x;try{if(typeof l[f]!="function"){var v=Error((u||"React class")+": "+c+" type `"+f+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[f]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}x=l[f](d,f,u,c,null,r)}catch(z){x=z}if(x&&!(x instanceof Error)&&e((u||"React class")+": type specification of "+c+" `"+f+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof x+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),x instanceof Error&&!(x.message in n)){n[x.message]=!0;var b=m?m():"";e("Failed "+c+" type: "+x.message+(b??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},xn=s,xn}var mn,mi;function _l(){if(mi)return mn;mi=1;var e=ss(),r=$l(),n=Rn(),i=as(),s=Al(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var u="Warning: "+c;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function d(){return null}return mn=function(c,u){var m=typeof Symbol=="function"&&Symbol.iterator,f="@@iterator";function x(R){var H=R&&(m&&R[m]||R[f]);if(typeof H=="function")return H}var v="<<anonymous>>",b={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:C(),arrayOf:E,element:g(),elementType:k(),instanceOf:L,node:X(),objectOf:_,oneOf:a,oneOfType:F,shape:h,exact:V};function z(R,H){return R===H?R!==0||1/R===1/H:R!==R&&H!==H}function S(R,H){this.message=R,this.data=H&&typeof H=="object"?H:{},this.stack=""}S.prototype=Error.prototype;function y(R){if(process.env.NODE_ENV!=="production")var H={},G=0;function ae(ne,oe,O,te,ce,ie,Ie){if(te=te||v,ie=ie||O,Ie!==n){if(u){var q=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw q.name="Invariant Violation",q}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Me=te+":"+O;!H[Me]&&G<3&&(l("You are manually calling a React.PropTypes validation function for the `"+ie+"` prop on `"+te+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),H[Me]=!0,G++)}}return oe[O]==null?ne?oe[O]===null?new S("The "+ce+" `"+ie+"` is marked as required "+("in `"+te+"`, but its value is `null`.")):new S("The "+ce+" `"+ie+"` is marked as required in "+("`"+te+"`, but its value is `undefined`.")):null:R(oe,O,te,ce,ie)}var ee=ae.bind(null,!1);return ee.isRequired=ae.bind(null,!0),ee}function w(R){function H(G,ae,ee,ne,oe,O){var te=G[ae],ce=Z(te);if(ce!==R){var ie=pe(te);return new S("Invalid "+ne+" `"+oe+"` of type "+("`"+ie+"` supplied to `"+ee+"`, expected ")+("`"+R+"`."),{expectedType:R})}return null}return y(H)}function C(){return y(d)}function E(R){function H(G,ae,ee,ne,oe){if(typeof R!="function")return new S("Property `"+oe+"` of component `"+ee+"` has invalid PropType notation inside arrayOf.");var O=G[ae];if(!Array.isArray(O)){var te=Z(O);return new S("Invalid "+ne+" `"+oe+"` of type "+("`"+te+"` supplied to `"+ee+"`, expected an array."))}for(var ce=0;ce<O.length;ce++){var ie=R(O,ce,ee,ne,oe+"["+ce+"]",n);if(ie instanceof Error)return ie}return null}return y(H)}function g(){function R(H,G,ae,ee,ne){var oe=H[G];if(!c(oe)){var O=Z(oe);return new S("Invalid "+ee+" `"+ne+"` of type "+("`"+O+"` supplied to `"+ae+"`, expected a single ReactElement."))}return null}return y(R)}function k(){function R(H,G,ae,ee,ne){var oe=H[G];if(!e.isValidElementType(oe)){var O=Z(oe);return new S("Invalid "+ee+" `"+ne+"` of type "+("`"+O+"` supplied to `"+ae+"`, expected a single ReactElement type."))}return null}return y(R)}function L(R){function H(G,ae,ee,ne,oe){if(!(G[ae]instanceof R)){var O=R.name||v,te=N(G[ae]);return new S("Invalid "+ne+" `"+oe+"` of type "+("`"+te+"` supplied to `"+ee+"`, expected ")+("instance of `"+O+"`."))}return null}return y(H)}function a(R){if(!Array.isArray(R))return process.env.NODE_ENV!=="production"&&(arguments.length>1?l("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])."):l("Invalid argument supplied to oneOf, expected an array.")),d;function H(G,ae,ee,ne,oe){for(var O=G[ae],te=0;te<R.length;te++)if(z(O,R[te]))return null;var ce=JSON.stringify(R,function(Ie,q){var Me=pe(q);return Me==="symbol"?String(q):q});return new S("Invalid "+ne+" `"+oe+"` of value `"+String(O)+"` "+("supplied to `"+ee+"`, expected one of "+ce+"."))}return y(H)}function _(R){function H(G,ae,ee,ne,oe){if(typeof R!="function")return new S("Property `"+oe+"` of component `"+ee+"` has invalid PropType notation inside objectOf.");var O=G[ae],te=Z(O);if(te!=="object")return new S("Invalid "+ne+" `"+oe+"` of type "+("`"+te+"` supplied to `"+ee+"`, expected an object."));for(var ce in O)if(i(O,ce)){var ie=R(O,ce,ee,ne,oe+"."+ce,n);if(ie instanceof Error)return ie}return null}return y(H)}function F(R){if(!Array.isArray(R))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var H=0;H<R.length;H++){var G=R[H];if(typeof G!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+he(G)+" at index "+H+"."),d}function ae(ee,ne,oe,O,te){for(var ce=[],ie=0;ie<R.length;ie++){var Ie=R[ie],q=Ie(ee,ne,oe,O,te,n);if(q==null)return null;q.data&&i(q.data,"expectedType")&&ce.push(q.data.expectedType)}var Me=ce.length>0?", expected one of type ["+ce.join(", ")+"]":"";return new S("Invalid "+O+" `"+te+"` supplied to "+("`"+oe+"`"+Me+"."))}return y(ae)}function X(){function R(H,G,ae,ee,ne){return W(H[G])?null:new S("Invalid "+ee+" `"+ne+"` supplied to "+("`"+ae+"`, expected a ReactNode."))}return y(R)}function re(R,H,G,ae,ee){return new S((R||"React class")+": "+H+" type `"+G+"."+ae+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+ee+"`.")}function h(R){function H(G,ae,ee,ne,oe){var O=G[ae],te=Z(O);if(te!=="object")return new S("Invalid "+ne+" `"+oe+"` of type `"+te+"` "+("supplied to `"+ee+"`, expected `object`."));for(var ce in R){var ie=R[ce];if(typeof ie!="function")return re(ee,ne,oe,ce,pe(ie));var Ie=ie(O,ce,ee,ne,oe+"."+ce,n);if(Ie)return Ie}return null}return y(H)}function V(R){function H(G,ae,ee,ne,oe){var O=G[ae],te=Z(O);if(te!=="object")return new S("Invalid "+ne+" `"+oe+"` of type `"+te+"` "+("supplied to `"+ee+"`, expected `object`."));var ce=r({},G[ae],R);for(var ie in ce){var Ie=R[ie];if(i(R,ie)&&typeof Ie!="function")return re(ee,ne,oe,ie,pe(Ie));if(!Ie)return new S("Invalid "+ne+" `"+oe+"` key `"+ie+"` supplied to `"+ee+"`.\nBad object: "+JSON.stringify(G[ae],null," ")+`
22
- Valid keys: `+JSON.stringify(Object.keys(R),null," "));var q=Ie(O,ie,ee,ne,oe+"."+ie,n);if(q)return q}return null}return y(H)}function W(R){switch(typeof R){case"number":case"string":case"undefined":return!0;case"boolean":return!R;case"object":if(Array.isArray(R))return R.every(W);if(R===null||c(R))return!0;var H=x(R);if(H){var G=H.call(R),ae;if(H!==R.entries){for(;!(ae=G.next()).done;)if(!W(ae.value))return!1}else for(;!(ae=G.next()).done;){var ee=ae.value;if(ee&&!W(ee[1]))return!1}}else return!1;return!0;default:return!1}}function Q(R,H){return R==="symbol"?!0:H?H["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&H instanceof Symbol:!1}function Z(R){var H=typeof R;return Array.isArray(R)?"array":R instanceof RegExp?"object":Q(H,R)?"symbol":H}function pe(R){if(typeof R>"u"||R===null)return""+R;var H=Z(R);if(H==="object"){if(R instanceof Date)return"date";if(R instanceof RegExp)return"regexp"}return H}function he(R){var H=pe(R);switch(H){case"array":case"object":return"an "+H;case"boolean":case"date":case"regexp":return"a "+H;default:return H}}function N(R){return!R.constructor||!R.constructor.name?v:R.constructor.name}return b.checkPropTypes=s,b.resetWarningCache=s.resetWarningCache,b.PropTypes=b,b},mn}var fn,fi;function Ml(){if(fi)return fn;fi=1;var e=Rn();function r(){}function n(){}return n.resetWarningCache=r,fn=function(){function i(d,c,u,m,f,x){if(x!==e){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}i.isRequired=i;function s(){return i}var l={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 l.PropTypes=l,l},fn}var hi;function Rl(){if(hi)return xo.exports;if(hi=1,process.env.NODE_ENV!=="production"){var e=ss(),r=!0;xo.exports=_l()(e.isElement,r)}else xo.exports=Ml()();return xo.exports}var Wl=Rl();const Ur=Bl(Wl);var fo={exports:{}},ke={};/**
21
+ */var Sn,bi;function Al(){if(bi)return Sn;bi=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(l){if(l==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(l)}function s(){try{if(!Object.assign)return!1;var l=new String("abc");if(l[5]="de",Object.getOwnPropertyNames(l)[0]==="5")return!1;for(var d={},c=0;c<10;c++)d["_"+String.fromCharCode(c)]=c;var u=Object.getOwnPropertyNames(d).map(function(g){return d[g]});if(u.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(g){h[g]=g}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Sn=s()?Object.assign:function(l,d){for(var c,u=i(l),h,g=1;g<arguments.length;g++){c=Object(arguments[g]);for(var f in c)r.call(c,f)&&(u[f]=c[f]);if(e){h=e(c);for(var b=0;b<h.length;b++)n.call(c,h[b])&&(u[h[b]]=c[h[b]])}}return u},Sn}var Cn,vi;function Gn(){if(vi)return Cn;vi=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Cn=e,Cn}var jn,Si;function bs(){return Si||(Si=1,jn=Function.call.bind(Object.prototype.hasOwnProperty)),jn}var wn,Ci;function Ml(){if(Ci)return wn;Ci=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=Gn(),n={},i=bs();e=function(l){var d="Warning: "+l;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function s(l,d,c,u,h){if(process.env.NODE_ENV!=="production"){for(var g in l)if(i(l,g)){var f;try{if(typeof l[g]!="function"){var b=Error((u||"React class")+": "+c+" type `"+g+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof l[g]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw b.name="Invariant Violation",b}f=l[g](d,g,u,c,null,r)}catch(T){f=T}if(f&&!(f instanceof Error)&&e((u||"React class")+": type specification of "+c+" `"+g+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof f+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),f instanceof Error&&!(f.message in n)){n[f.message]=!0;var v=h?h():"";e("Failed "+c+" type: "+f.message+(v??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},wn=s,wn}var kn,ji;function Rl(){if(ji)return kn;ji=1;var e=ys(),r=Al(),n=Gn(),i=bs(),s=Ml(),l=function(){};process.env.NODE_ENV!=="production"&&(l=function(c){var u="Warning: "+c;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function d(){return null}return kn=function(c,u){var h=typeof Symbol=="function"&&Symbol.iterator,g="@@iterator";function f(L){var K=L&&(h&&L[h]||L[g]);if(typeof K=="function")return K}var b="<<anonymous>>",v={array:j("array"),bigint:j("bigint"),bool:j("boolean"),func:j("function"),number:j("number"),object:j("object"),string:j("string"),symbol:j("symbol"),any:y(),arrayOf:$,element:S(),elementType:I(),instanceOf:N,node:J(),objectOf:A,oneOf:a,oneOfType:F,shape:x,exact:R};function T(L,K){return L===K?L!==0||1/L===1/K:L!==L&&K!==K}function C(L,K){this.message=L,this.data=K&&typeof K=="object"?K:{},this.stack=""}C.prototype=Error.prototype;function m(L){if(process.env.NODE_ENV!=="production")var K={},ne=0;function le(se,ie,D,Z,de,oe,ye){if(Z=Z||b,oe=oe||D,ye!==n){if(u){var G=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 G.name="Invariant Violation",G}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Me=Z+":"+D;!K[Me]&&ne<3&&(l("You are manually calling a React.PropTypes validation function for the `"+oe+"` prop on `"+Z+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),K[Me]=!0,ne++)}}return ie[D]==null?se?ie[D]===null?new C("The "+de+" `"+oe+"` is marked as required "+("in `"+Z+"`, but its value is `null`.")):new C("The "+de+" `"+oe+"` is marked as required in "+("`"+Z+"`, but its value is `undefined`.")):null:L(ie,D,Z,de,oe)}var U=le.bind(null,!1);return U.isRequired=le.bind(null,!0),U}function j(L){function K(ne,le,U,se,ie,D){var Z=ne[le],de=ae(Z);if(de!==L){var oe=Q(Z);return new C("Invalid "+se+" `"+ie+"` of type "+("`"+oe+"` supplied to `"+U+"`, expected ")+("`"+L+"`."),{expectedType:L})}return null}return m(K)}function y(){return m(d)}function $(L){function K(ne,le,U,se,ie){if(typeof L!="function")return new C("Property `"+ie+"` of component `"+U+"` has invalid PropType notation inside arrayOf.");var D=ne[le];if(!Array.isArray(D)){var Z=ae(D);return new C("Invalid "+se+" `"+ie+"` of type "+("`"+Z+"` supplied to `"+U+"`, expected an array."))}for(var de=0;de<D.length;de++){var oe=L(D,de,U,se,ie+"["+de+"]",n);if(oe instanceof Error)return oe}return null}return m(K)}function S(){function L(K,ne,le,U,se){var ie=K[ne];if(!c(ie)){var D=ae(ie);return new C("Invalid "+U+" `"+se+"` of type "+("`"+D+"` supplied to `"+le+"`, expected a single ReactElement."))}return null}return m(L)}function I(){function L(K,ne,le,U,se){var ie=K[ne];if(!e.isValidElementType(ie)){var D=ae(ie);return new C("Invalid "+U+" `"+se+"` of type "+("`"+D+"` supplied to `"+le+"`, expected a single ReactElement type."))}return null}return m(L)}function N(L){function K(ne,le,U,se,ie){if(!(ne[le]instanceof L)){var D=L.name||b,Z=he(ne[le]);return new C("Invalid "+se+" `"+ie+"` of type "+("`"+Z+"` supplied to `"+U+"`, expected ")+("instance of `"+D+"`."))}return null}return m(K)}function a(L){if(!Array.isArray(L))return process.env.NODE_ENV!=="production"&&(arguments.length>1?l("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])."):l("Invalid argument supplied to oneOf, expected an array.")),d;function K(ne,le,U,se,ie){for(var D=ne[le],Z=0;Z<L.length;Z++)if(T(D,L[Z]))return null;var de=JSON.stringify(L,function(ye,G){var Me=Q(G);return Me==="symbol"?String(G):G});return new C("Invalid "+se+" `"+ie+"` of value `"+String(D)+"` "+("supplied to `"+U+"`, expected one of "+de+"."))}return m(K)}function A(L){function K(ne,le,U,se,ie){if(typeof L!="function")return new C("Property `"+ie+"` of component `"+U+"` has invalid PropType notation inside objectOf.");var D=ne[le],Z=ae(D);if(Z!=="object")return new C("Invalid "+se+" `"+ie+"` of type "+("`"+Z+"` supplied to `"+U+"`, expected an object."));for(var de in D)if(i(D,de)){var oe=L(D,de,U,se,ie+"."+de,n);if(oe instanceof Error)return oe}return null}return m(K)}function F(L){if(!Array.isArray(L))return process.env.NODE_ENV!=="production"&&l("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var K=0;K<L.length;K++){var ne=L[K];if(typeof ne!="function")return l("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+re(ne)+" at index "+K+"."),d}function le(U,se,ie,D,Z){for(var de=[],oe=0;oe<L.length;oe++){var ye=L[oe],G=ye(U,se,ie,D,Z,n);if(G==null)return null;G.data&&i(G.data,"expectedType")&&de.push(G.data.expectedType)}var Me=de.length>0?", expected one of type ["+de.join(", ")+"]":"";return new C("Invalid "+D+" `"+Z+"` supplied to "+("`"+ie+"`"+Me+"."))}return m(le)}function J(){function L(K,ne,le,U,se){return P(K[ne])?null:new C("Invalid "+U+" `"+se+"` supplied to "+("`"+le+"`, expected a ReactNode."))}return m(L)}function ee(L,K,ne,le,U){return new C((L||"React class")+": "+K+" type `"+ne+"."+le+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+U+"`.")}function x(L){function K(ne,le,U,se,ie){var D=ne[le],Z=ae(D);if(Z!=="object")return new C("Invalid "+se+" `"+ie+"` of type `"+Z+"` "+("supplied to `"+U+"`, expected `object`."));for(var de in L){var oe=L[de];if(typeof oe!="function")return ee(U,se,ie,de,Q(oe));var ye=oe(D,de,U,se,ie+"."+de,n);if(ye)return ye}return null}return m(K)}function R(L){function K(ne,le,U,se,ie){var D=ne[le],Z=ae(D);if(Z!=="object")return new C("Invalid "+se+" `"+ie+"` of type `"+Z+"` "+("supplied to `"+U+"`, expected `object`."));var de=r({},ne[le],L);for(var oe in de){var ye=L[oe];if(i(L,oe)&&typeof ye!="function")return ee(U,se,ie,oe,Q(ye));if(!ye)return new C("Invalid "+se+" `"+ie+"` key `"+oe+"` supplied to `"+U+"`.\nBad object: "+JSON.stringify(ne[le],null," ")+`
22
+ Valid keys: `+JSON.stringify(Object.keys(L),null," "));var G=ye(D,oe,U,se,ie+"."+oe,n);if(G)return G}return null}return m(K)}function P(L){switch(typeof L){case"number":case"string":case"undefined":return!0;case"boolean":return!L;case"object":if(Array.isArray(L))return L.every(P);if(L===null||c(L))return!0;var K=f(L);if(K){var ne=K.call(L),le;if(K!==L.entries){for(;!(le=ne.next()).done;)if(!P(le.value))return!1}else for(;!(le=ne.next()).done;){var U=le.value;if(U&&!P(U[1]))return!1}}else return!1;return!0;default:return!1}}function te(L,K){return L==="symbol"?!0:K?K["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&K instanceof Symbol:!1}function ae(L){var K=typeof L;return Array.isArray(L)?"array":L instanceof RegExp?"object":te(K,L)?"symbol":K}function Q(L){if(typeof L>"u"||L===null)return""+L;var K=ae(L);if(K==="object"){if(L instanceof Date)return"date";if(L instanceof RegExp)return"regexp"}return K}function re(L){var K=Q(L);switch(K){case"array":case"object":return"an "+K;case"boolean":case"date":case"regexp":return"a "+K;default:return K}}function he(L){return!L.constructor||!L.constructor.name?b:L.constructor.name}return v.checkPropTypes=s,v.resetWarningCache=s.resetWarningCache,v.PropTypes=v,v},kn}var Tn,wi;function Wl(){if(wi)return Tn;wi=1;var e=Gn();function r(){}function n(){}return n.resetWarningCache=r,Tn=function(){function i(d,c,u,h,g,f){if(f!==e){var b=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 b.name="Invariant Violation",b}}i.isRequired=i;function s(){return i}var l={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 l.PropTypes=l,l},Tn}var ki;function Pl(){if(ki)return jo.exports;if(ki=1,process.env.NODE_ENV!=="production"){var e=ys(),r=!0;jo.exports=Rl()(e.isElement,r)}else jo.exports=Wl()();return jo.exports}var Nl=Pl();const ro=$l(Nl);var ko={exports:{}},ke={};/**
23
23
  * @license React
24
24
  * react-is.production.js
25
25
  *
@@ -27,7 +27,7 @@ Valid keys: `+JSON.stringify(Object.keys(R),null," "));var q=Ie(O,ie,ee,ne,oe+"
27
27
  *
28
28
  * This source code is licensed under the MIT license found in the
29
29
  * LICENSE file in the root directory of this source tree.
30
- */var gi;function Pl(){if(gi)return ke;gi=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),d=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),m=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),b=Symbol.for("react.client.reference");function z(S){if(typeof S=="object"&&S!==null){var y=S.$$typeof;switch(y){case e:switch(S=S.type,S){case n:case s:case i:case u:case m:case v:return S;default:switch(S=S&&S.$$typeof,S){case d:case c:case x:case f:return S;case l:return S;default:return y}}case r:return y}}}return ke.ContextConsumer=l,ke.ContextProvider=d,ke.Element=e,ke.ForwardRef=c,ke.Fragment=n,ke.Lazy=x,ke.Memo=f,ke.Portal=r,ke.Profiler=s,ke.StrictMode=i,ke.Suspense=u,ke.SuspenseList=m,ke.isContextConsumer=function(S){return z(S)===l},ke.isContextProvider=function(S){return z(S)===d},ke.isElement=function(S){return typeof S=="object"&&S!==null&&S.$$typeof===e},ke.isForwardRef=function(S){return z(S)===c},ke.isFragment=function(S){return z(S)===n},ke.isLazy=function(S){return z(S)===x},ke.isMemo=function(S){return z(S)===f},ke.isPortal=function(S){return z(S)===r},ke.isProfiler=function(S){return z(S)===s},ke.isStrictMode=function(S){return z(S)===i},ke.isSuspense=function(S){return z(S)===u},ke.isSuspenseList=function(S){return z(S)===m},ke.isValidElementType=function(S){return typeof S=="string"||typeof S=="function"||S===n||S===s||S===i||S===u||S===m||typeof S=="object"&&S!==null&&(S.$$typeof===x||S.$$typeof===f||S.$$typeof===d||S.$$typeof===l||S.$$typeof===c||S.$$typeof===b||S.getModuleId!==void 0)},ke.typeOf=z,ke}var Te={};/**
30
+ */var Ti;function Ll(){if(Ti)return ke;Ti=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"),l=Symbol.for("react.consumer"),d=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),b=Symbol.for("react.view_transition"),v=Symbol.for("react.client.reference");function T(C){if(typeof C=="object"&&C!==null){var m=C.$$typeof;switch(m){case e:switch(C=C.type,C){case n:case s:case i:case u:case h:case b:return C;default:switch(C=C&&C.$$typeof,C){case d:case c:case f:case g:return C;case l:return C;default:return m}}case r:return m}}}return ke.ContextConsumer=l,ke.ContextProvider=d,ke.Element=e,ke.ForwardRef=c,ke.Fragment=n,ke.Lazy=f,ke.Memo=g,ke.Portal=r,ke.Profiler=s,ke.StrictMode=i,ke.Suspense=u,ke.SuspenseList=h,ke.isContextConsumer=function(C){return T(C)===l},ke.isContextProvider=function(C){return T(C)===d},ke.isElement=function(C){return typeof C=="object"&&C!==null&&C.$$typeof===e},ke.isForwardRef=function(C){return T(C)===c},ke.isFragment=function(C){return T(C)===n},ke.isLazy=function(C){return T(C)===f},ke.isMemo=function(C){return T(C)===g},ke.isPortal=function(C){return T(C)===r},ke.isProfiler=function(C){return T(C)===s},ke.isStrictMode=function(C){return T(C)===i},ke.isSuspense=function(C){return T(C)===u},ke.isSuspenseList=function(C){return T(C)===h},ke.isValidElementType=function(C){return typeof C=="string"||typeof C=="function"||C===n||C===s||C===i||C===u||C===h||typeof C=="object"&&C!==null&&(C.$$typeof===f||C.$$typeof===g||C.$$typeof===d||C.$$typeof===l||C.$$typeof===c||C.$$typeof===v||C.getModuleId!==void 0)},ke.typeOf=T,ke}var Te={};/**
31
31
  * @license React
32
32
  * react-is.development.js
33
33
  *
@@ -35,16 +35,16 @@ Valid keys: `+JSON.stringify(Object.keys(R),null," "));var q=Ie(O,ie,ee,ne,oe+"
35
35
  *
36
36
  * This source code is licensed under the MIT license found in the
37
37
  * LICENSE file in the root directory of this source tree.
38
- */var yi;function Nl(){return yi||(yi=1,process.env.NODE_ENV!=="production"&&(function(){function e(S){if(typeof S=="object"&&S!==null){var y=S.$$typeof;switch(y){case r:switch(S=S.type,S){case i:case l:case s:case m:case f:case b:return S;default:switch(S=S&&S.$$typeof,S){case c:case u:case v:case x:return S;case d:return S;default:return y}}case n:return y}}}var r=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),b=Symbol.for("react.view_transition"),z=Symbol.for("react.client.reference");Te.ContextConsumer=d,Te.ContextProvider=c,Te.Element=r,Te.ForwardRef=u,Te.Fragment=i,Te.Lazy=v,Te.Memo=x,Te.Portal=n,Te.Profiler=l,Te.StrictMode=s,Te.Suspense=m,Te.SuspenseList=f,Te.isContextConsumer=function(S){return e(S)===d},Te.isContextProvider=function(S){return e(S)===c},Te.isElement=function(S){return typeof S=="object"&&S!==null&&S.$$typeof===r},Te.isForwardRef=function(S){return e(S)===u},Te.isFragment=function(S){return e(S)===i},Te.isLazy=function(S){return e(S)===v},Te.isMemo=function(S){return e(S)===x},Te.isPortal=function(S){return e(S)===n},Te.isProfiler=function(S){return e(S)===l},Te.isStrictMode=function(S){return e(S)===s},Te.isSuspense=function(S){return e(S)===m},Te.isSuspenseList=function(S){return e(S)===f},Te.isValidElementType=function(S){return typeof S=="string"||typeof S=="function"||S===i||S===l||S===s||S===m||S===f||typeof S=="object"&&S!==null&&(S.$$typeof===v||S.$$typeof===x||S.$$typeof===c||S.$$typeof===d||S.$$typeof===u||S.$$typeof===z||S.getModuleId!==void 0)},Te.typeOf=e})()),Te}var bi;function Ll(){return bi||(bi=1,process.env.NODE_ENV==="production"?fo.exports=Pl():fo.exports=Nl()),fo.exports}var ls=Ll();function Qt(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 cs(e){if(Do.isValidElement(e)||ls.isValidElementType(e)||!Qt(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=cs(e[n])}),r}function Ze(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return Qt(e)&&Qt(r)&&Object.keys(r).forEach(s=>{Do.isValidElement(r[s])||ls.isValidElementType(r[s])?i[s]=r[s]:Qt(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&Qt(e[s])?i[s]=Ze(e[s],r[s],n):n.clone?i[s]=Qt(r[s])?cs(r[s]):r[s]:i[s]=r[s]}),i}const Fl=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 Vl(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,l=Fl(r),d=Object.keys(l);function c(v){return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n})`}function u(v){return`@media (max-width:${(typeof r[v]=="number"?r[v]:v)-i/100}${n})`}function m(v,b){const z=d.indexOf(b);return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n}) and (max-width:${(z!==-1&&typeof r[d[z]]=="number"?r[d[z]]:b)-i/100}${n})`}function f(v){return d.indexOf(v)+1<d.length?m(v,d[d.indexOf(v)+1]):c(v)}function x(v){const b=d.indexOf(v);return b===0?c(d[1]):b===d.length-1?u(d[b]):m(v,d[d.indexOf(v)+1]).replace("@media","@media not all and")}return{keys:d,values:l,up:c,down:u,between:m,only:f,not:x,unit:n,...s}}function vi(e,r){if(!e.containerQueries)return r;const n=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var d,c;const l=/min-width:\s*([0-9.]+)/;return+(((d=i.match(l))==null?void 0:d[1])||0)-+(((c=s.match(l))==null?void 0:c[1])||0)});return n.length?n.reduce((i,s)=>{const l=r[s];return delete i[s],i[s]=l,i},{...r}):r}function Hl(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function Ul(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>\`.
39
- For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,l=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(l)}function Gl(e){const r=(l,d)=>l.replace("@media",d?`@container ${d}`:"@container");function n(l,d){l.up=(...c)=>r(e.breakpoints.up(...c),d),l.down=(...c)=>r(e.breakpoints.down(...c),d),l.between=(...c)=>r(e.breakpoints.between(...c),d),l.only=(...c)=>r(e.breakpoints.only(...c),d),l.not=(...c)=>{const u=r(e.breakpoints.not(...c),d);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=l=>(n(i,l),i);return n(s),{...e,containerQueries:s}}const Yl={borderRadius:4},tr=process.env.NODE_ENV!=="production"?Ur.oneOfType([Ur.number,Ur.string,Ur.object,Ur.array]):{};function Qr(e,r){return r?Ze(e,r,{clone:!1}):e}const Ao={xs:0,sm:600,md:900,lg:1200,xl:1536},Si={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${Ao[e]}px)`},ql={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:Ao[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function Nt(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const l=i.breakpoints||Si;return r.reduce((d,c,u)=>(d[l.up(l.keys[u])]=n(r[u]),d),{})}if(typeof r=="object"){const l=i.breakpoints||Si;return Object.keys(r).reduce((d,c)=>{if(Hl(l.keys,c)){const u=Ul(i.containerQueries?i:ql,c);u&&(d[u]=n(r[c],c))}else if(Object.keys(l.values||Ao).includes(c)){const u=l.up(c);d[u]=n(r[c],c)}else{const u=c;d[u]=r[u]}return d},{})}return n(r)}function Jl(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const l=e.up(s);return i[l]={},i},{}))||{}}function Ci(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function ds(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":vr(7));return e.charAt(0).toUpperCase()+e.slice(1)}function _o(e,r,n=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&n){const i=`vars.${r}`.split(".").reduce((s,l)=>s&&s[l]?s[l]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function Eo(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=_o(e,n)||i,r&&(s=r(s,i,e)),s}function $e(e){const{prop:r,cssProperty:n=e.prop,themeKey:i,transform:s}=e,l=d=>{if(d[r]==null)return null;const c=d[r],u=d.theme,m=_o(u,i)||{};return Nt(d,c,x=>{let v=Eo(m,s,x);return x===v&&typeof x=="string"&&(v=Eo(m,s,`${r}${x==="default"?"":ds(x)}`,x)),n===!1?v:{[n]:v}})};return l.propTypes=process.env.NODE_ENV!=="production"?{[r]:tr}:{},l.filterProps=[r],l}function Kl(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const Xl={m:"margin",p:"padding"},Ql={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},ji={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Zl=Kl(e=>{if(e.length>2)if(ji[e])e=ji[e];else return[e];const[r,n]=e.split(""),i=Xl[r],s=Ql[n]||"";return Array.isArray(s)?s.map(l=>i+l):[i+s]}),Mo=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],Ro=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],ec=[...Mo,...Ro];function to(e,r,n,i){const s=_o(e,r,!0)??n;return typeof s=="number"||typeof s=="string"?l=>typeof l=="string"?l:(process.env.NODE_ENV!=="production"&&typeof l!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${l}.`),typeof s=="string"?s.startsWith("var(")&&l===0?0:s.startsWith("var(")&&l===1?s:`calc(${l} * ${s})`:s*l):Array.isArray(s)?l=>{if(typeof l=="string")return l;const d=Math.abs(l);process.env.NODE_ENV!=="production"&&(Number.isInteger(d)?d>s.length-1&&console.error([`MUI: The value provided (${d}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${d} > ${s.length-1}, you need to add the missing values.`].join(`
38
+ */var Bi;function Fl(){return Bi||(Bi=1,process.env.NODE_ENV!=="production"&&(function(){function e(C){if(typeof C=="object"&&C!==null){var m=C.$$typeof;switch(m){case r:switch(C=C.type,C){case i:case l:case s:case h:case g:case v:return C;default:switch(C=C&&C.$$typeof,C){case c:case u:case b:case f:return C;case d:return C;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"),l=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),v=Symbol.for("react.view_transition"),T=Symbol.for("react.client.reference");Te.ContextConsumer=d,Te.ContextProvider=c,Te.Element=r,Te.ForwardRef=u,Te.Fragment=i,Te.Lazy=b,Te.Memo=f,Te.Portal=n,Te.Profiler=l,Te.StrictMode=s,Te.Suspense=h,Te.SuspenseList=g,Te.isContextConsumer=function(C){return e(C)===d},Te.isContextProvider=function(C){return e(C)===c},Te.isElement=function(C){return typeof C=="object"&&C!==null&&C.$$typeof===r},Te.isForwardRef=function(C){return e(C)===u},Te.isFragment=function(C){return e(C)===i},Te.isLazy=function(C){return e(C)===b},Te.isMemo=function(C){return e(C)===f},Te.isPortal=function(C){return e(C)===n},Te.isProfiler=function(C){return e(C)===l},Te.isStrictMode=function(C){return e(C)===s},Te.isSuspense=function(C){return e(C)===h},Te.isSuspenseList=function(C){return e(C)===g},Te.isValidElementType=function(C){return typeof C=="string"||typeof C=="function"||C===i||C===l||C===s||C===h||C===g||typeof C=="object"&&C!==null&&(C.$$typeof===b||C.$$typeof===f||C.$$typeof===c||C.$$typeof===d||C.$$typeof===u||C.$$typeof===T||C.getModuleId!==void 0)},Te.typeOf=e})()),Te}var Ii;function Vl(){return Ii||(Ii=1,process.env.NODE_ENV==="production"?ko.exports=Ll():ko.exports=Fl()),ko.exports}var vs=Vl();function tr(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 Ss(e){if(Fo.isValidElement(e)||vs.isValidElementType(e)||!tr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=Ss(e[n])}),r}function tt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return tr(e)&&tr(r)&&Object.keys(r).forEach(s=>{Fo.isValidElement(r[s])||vs.isValidElementType(r[s])?i[s]=r[s]:tr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&tr(e[s])?i[s]=tt(e[s],r[s],n):n.clone?i[s]=tr(r[s])?Ss(r[s]):r[s]:i[s]=r[s]}),i}const Hl=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 Ul(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:i=5,...s}=e,l=Hl(r),d=Object.keys(l);function c(b){return`@media (min-width:${typeof r[b]=="number"?r[b]:b}${n})`}function u(b){return`@media (max-width:${(typeof r[b]=="number"?r[b]:b)-i/100}${n})`}function h(b,v){const T=d.indexOf(v);return`@media (min-width:${typeof r[b]=="number"?r[b]:b}${n}) and (max-width:${(T!==-1&&typeof r[d[T]]=="number"?r[d[T]]:v)-i/100}${n})`}function g(b){return d.indexOf(b)+1<d.length?h(b,d[d.indexOf(b)+1]):c(b)}function f(b){const v=d.indexOf(b);return v===0?c(d[1]):v===d.length-1?u(d[v]):h(b,d[d.indexOf(b)+1]).replace("@media","@media not all and")}return{keys:d,values:l,up:c,down:u,between:h,only:g,not:f,unit:n,...s}}function zi(e,r){if(!e.containerQueries)return r;const n=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var d,c;const l=/min-width:\s*([0-9.]+)/;return+(((d=i.match(l))==null?void 0:d[1])||0)-+(((c=s.match(l))==null?void 0:c[1])||0)});return n.length?n.reduce((i,s)=>{const l=r[s];return delete i[s],i[s]=l,i},{...r}):r}function Gl(e,r){return r==="@"||r.startsWith("@")&&(e.some(n=>r.startsWith(`@${n}`))||!!r.match(/^@\d/))}function Yl(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>\`.
39
+ For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=n,l=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(l)}function ql(e){const r=(l,d)=>l.replace("@media",d?`@container ${d}`:"@container");function n(l,d){l.up=(...c)=>r(e.breakpoints.up(...c),d),l.down=(...c)=>r(e.breakpoints.down(...c),d),l.between=(...c)=>r(e.breakpoints.between(...c),d),l.only=(...c)=>r(e.breakpoints.only(...c),d),l.not=(...c)=>{const u=r(e.breakpoints.not(...c),d);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=l=>(n(i,l),i);return n(s),{...e,containerQueries:s}}const Jl={borderRadius:4},nr=process.env.NODE_ENV!=="production"?ro.oneOfType([ro.number,ro.string,ro.object,ro.array]):{};function co(e,r){return r?tt(e,r,{clone:!1}):e}const Uo={xs:0,sm:600,md:900,lg:1200,xl:1536},Ei={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${Uo[e]}px)`},Kl={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:Uo[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function Ht(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const l=i.breakpoints||Ei;return r.reduce((d,c,u)=>(d[l.up(l.keys[u])]=n(r[u]),d),{})}if(typeof r=="object"){const l=i.breakpoints||Ei;return Object.keys(r).reduce((d,c)=>{if(Gl(l.keys,c)){const u=Yl(i.containerQueries?i:Kl,c);u&&(d[u]=n(r[c],c))}else if(Object.keys(l.values||Uo).includes(c)){const u=l.up(c);d[u]=n(r[c],c)}else{const u=c;d[u]=r[u]}return d},{})}return n(r)}function Xl(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const l=e.up(s);return i[l]={},i},{}))||{}}function Di(e,r){return e.reduce((n,i)=>{const s=n[i];return(!s||Object.keys(s).length===0)&&delete n[i],n},r)}function Cs(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":vr(7));return e.charAt(0).toUpperCase()+e.slice(1)}function Go(e,r,n=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&n){const i=`vars.${r}`.split(".").reduce((s,l)=>s&&s[l]?s[l]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function No(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=Go(e,n)||i,r&&(s=r(s,i,e)),s}function _e(e){const{prop:r,cssProperty:n=e.prop,themeKey:i,transform:s}=e,l=d=>{if(d[r]==null)return null;const c=d[r],u=d.theme,h=Go(u,i)||{};return Ht(d,c,f=>{let b=No(h,s,f);return f===b&&typeof f=="string"&&(b=No(h,s,`${r}${f==="default"?"":Cs(f)}`,f)),n===!1?b:{[n]:b}})};return l.propTypes=process.env.NODE_ENV!=="production"?{[r]:nr}:{},l.filterProps=[r],l}function Ql(e){const r={};return n=>(r[n]===void 0&&(r[n]=e(n)),r[n])}const Zl={m:"margin",p:"padding"},ec={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},$i={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},tc=Ql(e=>{if(e.length>2)if($i[e])e=$i[e];else return[e];const[r,n]=e.split(""),i=Zl[r],s=ec[n]||"";return Array.isArray(s)?s.map(l=>i+l):[i+s]}),Yo=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],qo=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],rc=[...Yo,...qo];function xo(e,r,n,i){const s=Go(e,r,!0)??n;return typeof s=="number"||typeof s=="string"?l=>typeof l=="string"?l:(process.env.NODE_ENV!=="production"&&typeof l!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${l}.`),typeof s=="string"?s.startsWith("var(")&&l===0?0:s.startsWith("var(")&&l===1?s:`calc(${l} * ${s})`:s*l):Array.isArray(s)?l=>{if(typeof l=="string")return l;const d=Math.abs(l);process.env.NODE_ENV!=="production"&&(Number.isInteger(d)?d>s.length-1&&console.error([`MUI: The value provided (${d}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${d} > ${s.length-1}, you need to add the missing values.`].join(`
40
40
  `)):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(`
41
41
  `)));const c=s[d];return l>=0?c:typeof c=="number"?-c:typeof c=="string"&&c.startsWith("var(")?`calc(-1 * ${c})`:`-${c}`}:typeof s=="function"?s:(process.env.NODE_ENV!=="production"&&console.error([`MUI: The \`theme.${r}\` value (${s}) is invalid.`,"It should be a number, an array or a function."].join(`
42
- `)),()=>{})}function Wn(e){return to(e,"spacing",8,"spacing")}function ro(e,r){return typeof r=="string"||r==null?r:e(r)}function tc(e,r){return n=>e.reduce((i,s)=>(i[s]=ro(r,n),i),{})}function rc(e,r,n,i){if(!r.includes(n))return null;const s=Zl(n),l=tc(s,i),d=e[n];return Nt(e,d,l)}function us(e,r){const n=Wn(e.theme);return Object.keys(e).map(i=>rc(e,r,i,n)).reduce(Qr,{})}function Be(e){return us(e,Mo)}Be.propTypes=process.env.NODE_ENV!=="production"?Mo.reduce((e,r)=>(e[r]=tr,e),{}):{};Be.filterProps=Mo;function De(e){return us(e,Ro)}De.propTypes=process.env.NODE_ENV!=="production"?Ro.reduce((e,r)=>(e[r]=tr,e),{}):{};De.filterProps=Ro;process.env.NODE_ENV!=="production"&&ec.reduce((e,r)=>(e[r]=tr,e),{});function ps(e=8,r=Wn({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(l=>{const d=r(l);return typeof d=="number"?`${d}px`:d}).join(" "));return n.mui=!0,n}function Wo(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(l=>{i[l]=s}),i),{}),n=i=>Object.keys(i).reduce((s,l)=>r[l]?Qr(s,r[l](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 ct(e){return typeof e!="number"?e:`${e}px solid`}function ut(e,r){return $e({prop:e,themeKey:"borders",transform:r})}const oc=ut("border",ct),nc=ut("borderTop",ct),ic=ut("borderRight",ct),sc=ut("borderBottom",ct),ac=ut("borderLeft",ct),lc=ut("borderColor"),cc=ut("borderTopColor"),dc=ut("borderRightColor"),uc=ut("borderBottomColor"),pc=ut("borderLeftColor"),xc=ut("outline",ct),mc=ut("outlineColor"),Po=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=to(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:ro(r,i)});return Nt(e,e.borderRadius,n)}return null};Po.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:tr}:{};Po.filterProps=["borderRadius"];Wo(oc,nc,ic,sc,ac,lc,cc,dc,uc,pc,Po,xc,mc);const No=e=>{if(e.gap!==void 0&&e.gap!==null){const r=to(e.theme,"spacing",8,"gap"),n=i=>({gap:ro(r,i)});return Nt(e,e.gap,n)}return null};No.propTypes=process.env.NODE_ENV!=="production"?{gap:tr}:{};No.filterProps=["gap"];const Lo=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=to(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:ro(r,i)});return Nt(e,e.columnGap,n)}return null};Lo.propTypes=process.env.NODE_ENV!=="production"?{columnGap:tr}:{};Lo.filterProps=["columnGap"];const Fo=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=to(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:ro(r,i)});return Nt(e,e.rowGap,n)}return null};Fo.propTypes=process.env.NODE_ENV!=="production"?{rowGap:tr}:{};Fo.filterProps=["rowGap"];const fc=$e({prop:"gridColumn"}),hc=$e({prop:"gridRow"}),gc=$e({prop:"gridAutoFlow"}),yc=$e({prop:"gridAutoColumns"}),bc=$e({prop:"gridAutoRows"}),vc=$e({prop:"gridTemplateColumns"}),Sc=$e({prop:"gridTemplateRows"}),Cc=$e({prop:"gridTemplateAreas"}),jc=$e({prop:"gridArea"});Wo(No,Lo,Fo,fc,hc,gc,yc,bc,vc,Sc,Cc,jc);function Rr(e,r){return r==="grey"?r:e}const wc=$e({prop:"color",themeKey:"palette",transform:Rr}),kc=$e({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:Rr}),Tc=$e({prop:"backgroundColor",themeKey:"palette",transform:Rr});Wo(wc,kc,Tc);function Xe(e){return e<=1&&e!==0?`${e*100}%`:e}const Ic=$e({prop:"width",transform:Xe}),Pn=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,l,d,c,u;const i=((d=(l=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:l.values)==null?void 0:d[n])||Ao[n];return i?((u=(c=e.theme)==null?void 0:c.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Xe(n)}};return Nt(e,e.maxWidth,r)}return null};Pn.filterProps=["maxWidth"];const zc=$e({prop:"minWidth",transform:Xe}),Ec=$e({prop:"height",transform:Xe}),Bc=$e({prop:"maxHeight",transform:Xe}),Dc=$e({prop:"minHeight",transform:Xe});$e({prop:"size",cssProperty:"width",transform:Xe});$e({prop:"size",cssProperty:"height",transform:Xe});const Oc=$e({prop:"boxSizing"});Wo(Ic,Pn,zc,Ec,Bc,Dc,Oc);const Vo={border:{themeKey:"borders",transform:ct},borderTop:{themeKey:"borders",transform:ct},borderRight:{themeKey:"borders",transform:ct},borderBottom:{themeKey:"borders",transform:ct},borderLeft:{themeKey:"borders",transform:ct},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:ct},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Po},color:{themeKey:"palette",transform:Rr},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:Rr},backgroundColor:{themeKey:"palette",transform:Rr},p:{style:De},pt:{style:De},pr:{style:De},pb:{style:De},pl:{style:De},px:{style:De},py:{style:De},padding:{style:De},paddingTop:{style:De},paddingRight:{style:De},paddingBottom:{style:De},paddingLeft:{style:De},paddingX:{style:De},paddingY:{style:De},paddingInline:{style:De},paddingInlineStart:{style:De},paddingInlineEnd:{style:De},paddingBlock:{style:De},paddingBlockStart:{style:De},paddingBlockEnd:{style:De},m:{style:Be},mt:{style:Be},mr:{style:Be},mb:{style:Be},ml:{style:Be},mx:{style:Be},my:{style:Be},margin:{style:Be},marginTop:{style:Be},marginRight:{style:Be},marginBottom:{style:Be},marginLeft:{style:Be},marginX:{style:Be},marginY:{style:Be},marginInline:{style:Be},marginInlineStart:{style:Be},marginInlineEnd:{style:Be},marginBlock:{style:Be},marginBlockStart:{style:Be},marginBlockEnd:{style:Be},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:No},rowGap:{style:Fo},columnGap:{style:Lo},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Xe},maxWidth:{style:Pn},minWidth:{transform:Xe},height:{transform:Xe},maxHeight:{transform:Xe},minHeight:{transform:Xe},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function $c(...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 Ac(e,r){return typeof e=="function"?e(r):e}function _c(){function e(n,i,s,l){const d={[n]:i,theme:s},c=l[n];if(!c)return{[n]:i};const{cssProperty:u=n,themeKey:m,transform:f,style:x}=c;if(i==null)return null;if(m==="typography"&&i==="inherit")return{[n]:i};const v=_o(s,m)||{};return x?x(d):Nt(d,i,z=>{let S=Eo(v,f,z);return z===S&&typeof z=="string"&&(S=Eo(v,f,`${n}${z==="default"?"":ds(z)}`,z)),u===!1?S:{[u]:S}})}function r(n){const{sx:i,theme:s={},nested:l}=n||{};if(!i)return null;const d=s.unstable_sxConfig??Vo;function c(u){let m=u;if(typeof u=="function")m=u(s);else if(typeof u!="object")return u;if(!m)return null;const f=Jl(s.breakpoints),x=Object.keys(f);let v=f;return Object.keys(m).forEach(b=>{const z=Ac(m[b],s);if(z!=null)if(typeof z=="object")if(d[b])v=Qr(v,e(b,z,s,d));else{const S=Nt({theme:s},z,y=>({[b]:y}));$c(S,z)?v[b]=r({sx:z,theme:s,nested:!0}):v=Qr(v,S)}else v=Qr(v,e(b,z,s,d))}),!l&&s.modularCssLayers?{"@layer sx":vi(s,Ci(x,v))}:vi(s,Ci(x,v))}return Array.isArray(i)?i.map(c):c(i)}return r}const Ho=_c();Ho.filterProps=["sx"];function Mc(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:l={},...d}=e,c=Vl(n),u=ps(s);let m=Ze({breakpoints:c,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...Yl,...l}},d);return m=Gl(m),m.applyStyles=Mc,m=r.reduce((f,x)=>Ze(f,x),m),m.unstable_sxConfig={...Vo,...d==null?void 0:d.unstable_sxConfig},m.unstable_sx=function(x){return Ho({sx:x,theme:this})},m}function Rc(e){return Object.keys(e).length===0}function Wc(e=null){const r=Do.useContext(ea.ThemeContext);return!r||Rc(r)?e:r}const Pc=xs();function Nc(e=Pc){return Wc(e)}const wi=e=>e,Lc=()=>{let e=wi;return{configure(r){e=r},generate(r){return e(r)},reset(){e=wi}}},Fc=Lc(),Vc={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 Hc(e,r,n="Mui"){const i=Vc[r];return i?`${n}-${i}`:`${Fc.generate(e)}-${r}`}function Uc(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function Nn(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}].`),Uc(e,r,n)}function Gc(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 er(e){if(e.type)return e;if(e.charAt(0)==="#")return er(Gc(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.
42
+ `)),()=>{})}function Yn(e){return xo(e,"spacing",8,"spacing")}function mo(e,r){return typeof r=="string"||r==null?r:e(r)}function oc(e,r){return n=>e.reduce((i,s)=>(i[s]=mo(r,n),i),{})}function nc(e,r,n,i){if(!r.includes(n))return null;const s=tc(n),l=oc(s,i),d=e[n];return Ht(e,d,l)}function js(e,r){const n=Yn(e.theme);return Object.keys(e).map(i=>nc(e,r,i,n)).reduce(co,{})}function Ee(e){return js(e,Yo)}Ee.propTypes=process.env.NODE_ENV!=="production"?Yo.reduce((e,r)=>(e[r]=nr,e),{}):{};Ee.filterProps=Yo;function De(e){return js(e,qo)}De.propTypes=process.env.NODE_ENV!=="production"?qo.reduce((e,r)=>(e[r]=nr,e),{}):{};De.filterProps=qo;process.env.NODE_ENV!=="production"&&rc.reduce((e,r)=>(e[r]=nr,e),{});function ws(e=8,r=Yn({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(l=>{const d=r(l);return typeof d=="number"?`${d}px`:d}).join(" "));return n.mui=!0,n}function Jo(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(l=>{i[l]=s}),i),{}),n=i=>Object.keys(i).reduce((s,l)=>r[l]?co(s,r[l](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 xt(e){return typeof e!="number"?e:`${e}px solid`}function ft(e,r){return _e({prop:e,themeKey:"borders",transform:r})}const ic=ft("border",xt),sc=ft("borderTop",xt),ac=ft("borderRight",xt),lc=ft("borderBottom",xt),cc=ft("borderLeft",xt),dc=ft("borderColor"),uc=ft("borderTopColor"),pc=ft("borderRightColor"),xc=ft("borderBottomColor"),mc=ft("borderLeftColor"),fc=ft("outline",xt),hc=ft("outlineColor"),Ko=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=xo(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:mo(r,i)});return Ht(e,e.borderRadius,n)}return null};Ko.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:nr}:{};Ko.filterProps=["borderRadius"];Jo(ic,sc,ac,lc,cc,dc,uc,pc,xc,mc,Ko,fc,hc);const Xo=e=>{if(e.gap!==void 0&&e.gap!==null){const r=xo(e.theme,"spacing",8,"gap"),n=i=>({gap:mo(r,i)});return Ht(e,e.gap,n)}return null};Xo.propTypes=process.env.NODE_ENV!=="production"?{gap:nr}:{};Xo.filterProps=["gap"];const Qo=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=xo(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:mo(r,i)});return Ht(e,e.columnGap,n)}return null};Qo.propTypes=process.env.NODE_ENV!=="production"?{columnGap:nr}:{};Qo.filterProps=["columnGap"];const Zo=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=xo(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:mo(r,i)});return Ht(e,e.rowGap,n)}return null};Zo.propTypes=process.env.NODE_ENV!=="production"?{rowGap:nr}:{};Zo.filterProps=["rowGap"];const gc=_e({prop:"gridColumn"}),yc=_e({prop:"gridRow"}),bc=_e({prop:"gridAutoFlow"}),vc=_e({prop:"gridAutoColumns"}),Sc=_e({prop:"gridAutoRows"}),Cc=_e({prop:"gridTemplateColumns"}),jc=_e({prop:"gridTemplateRows"}),wc=_e({prop:"gridTemplateAreas"}),kc=_e({prop:"gridArea"});Jo(Xo,Qo,Zo,gc,yc,bc,vc,Sc,Cc,jc,wc,kc);function Gr(e,r){return r==="grey"?r:e}const Tc=_e({prop:"color",themeKey:"palette",transform:Gr}),Bc=_e({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:Gr}),Ic=_e({prop:"backgroundColor",themeKey:"palette",transform:Gr});Jo(Tc,Bc,Ic);function Qe(e){return e<=1&&e!==0?`${e*100}%`:e}const zc=_e({prop:"width",transform:Qe}),qn=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,l,d,c,u;const i=((d=(l=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:l.values)==null?void 0:d[n])||Uo[n];return i?((u=(c=e.theme)==null?void 0:c.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:Qe(n)}};return Ht(e,e.maxWidth,r)}return null};qn.filterProps=["maxWidth"];const Ec=_e({prop:"minWidth",transform:Qe}),Dc=_e({prop:"height",transform:Qe}),$c=_e({prop:"maxHeight",transform:Qe}),Oc=_e({prop:"minHeight",transform:Qe});_e({prop:"size",cssProperty:"width",transform:Qe});_e({prop:"size",cssProperty:"height",transform:Qe});const _c=_e({prop:"boxSizing"});Jo(zc,qn,Ec,Dc,$c,Oc,_c);const en={border:{themeKey:"borders",transform:xt},borderTop:{themeKey:"borders",transform:xt},borderRight:{themeKey:"borders",transform:xt},borderBottom:{themeKey:"borders",transform:xt},borderLeft:{themeKey:"borders",transform:xt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:xt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Ko},color:{themeKey:"palette",transform:Gr},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:Gr},backgroundColor:{themeKey:"palette",transform:Gr},p:{style:De},pt:{style:De},pr:{style:De},pb:{style:De},pl:{style:De},px:{style:De},py:{style:De},padding:{style:De},paddingTop:{style:De},paddingRight:{style:De},paddingBottom:{style:De},paddingLeft:{style:De},paddingX:{style:De},paddingY:{style:De},paddingInline:{style:De},paddingInlineStart:{style:De},paddingInlineEnd:{style:De},paddingBlock:{style:De},paddingBlockStart:{style:De},paddingBlockEnd:{style:De},m:{style:Ee},mt:{style:Ee},mr:{style:Ee},mb:{style:Ee},ml:{style:Ee},mx:{style:Ee},my:{style:Ee},margin:{style:Ee},marginTop:{style:Ee},marginRight:{style:Ee},marginBottom:{style:Ee},marginLeft:{style:Ee},marginX:{style:Ee},marginY:{style:Ee},marginInline:{style:Ee},marginInlineStart:{style:Ee},marginInlineEnd:{style:Ee},marginBlock:{style:Ee},marginBlockStart:{style:Ee},marginBlockEnd:{style:Ee},displayPrint:{cssProperty:!1,transform: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:Xo},rowGap:{style:Zo},columnGap:{style:Qo},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:Qe},maxWidth:{style:qn},minWidth:{transform:Qe},height:{transform:Qe},maxHeight:{transform:Qe},minHeight:{transform:Qe},boxSizing:{},font:{themeKey:"font"},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}};function Ac(...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 Mc(e,r){return typeof e=="function"?e(r):e}function Rc(){function e(n,i,s,l){const d={[n]:i,theme:s},c=l[n];if(!c)return{[n]:i};const{cssProperty:u=n,themeKey:h,transform:g,style:f}=c;if(i==null)return null;if(h==="typography"&&i==="inherit")return{[n]:i};const b=Go(s,h)||{};return f?f(d):Ht(d,i,T=>{let C=No(b,g,T);return T===C&&typeof T=="string"&&(C=No(b,g,`${n}${T==="default"?"":Cs(T)}`,T)),u===!1?C:{[u]:C}})}function r(n){const{sx:i,theme:s={},nested:l}=n||{};if(!i)return null;const d=s.unstable_sxConfig??en;function c(u){let h=u;if(typeof u=="function")h=u(s);else if(typeof u!="object")return u;if(!h)return null;const g=Xl(s.breakpoints),f=Object.keys(g);let b=g;return Object.keys(h).forEach(v=>{const T=Mc(h[v],s);if(T!=null)if(typeof T=="object")if(d[v])b=co(b,e(v,T,s,d));else{const C=Ht({theme:s},T,m=>({[v]:m}));Ac(C,T)?b[v]=r({sx:T,theme:s,nested:!0}):b=co(b,C)}else b=co(b,e(v,T,s,d))}),!l&&s.modularCssLayers?{"@layer sx":zi(s,Di(f,b))}:zi(s,Di(f,b))}return Array.isArray(i)?i.map(c):c(i)}return r}const tn=Rc();tn.filterProps=["sx"];function Wc(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 ks(e={},...r){const{breakpoints:n={},palette:i={},spacing:s,shape:l={},...d}=e,c=Ul(n),u=ws(s);let h=tt({breakpoints:c,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...Jl,...l}},d);return h=ql(h),h.applyStyles=Wc,h=r.reduce((g,f)=>tt(g,f),h),h.unstable_sxConfig={...en,...d==null?void 0:d.unstable_sxConfig},h.unstable_sx=function(f){return tn({sx:f,theme:this})},h}function Pc(e){return Object.keys(e).length===0}function Nc(e=null){const r=Fo.useContext(ra.ThemeContext);return!r||Pc(r)?e:r}const Lc=ks();function Fc(e=Lc){return Nc(e)}const Oi=e=>e,Vc=()=>{let e=Oi;return{configure(r){e=r},generate(r){return e(r)},reset(){e=Oi}}},Hc=Vc(),Uc={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 Gc(e,r,n="Mui"){const i=Uc[r];return i?`${n}-${i}`:`${Hc.generate(e)}-${r}`}function Yc(e,r=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,n))}function Jn(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}].`),Yc(e,r,n)}function qc(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 or(e){if(e.type)return e;if(e.charAt(0)==="#")return or(qc(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.
43
43
  The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:vr(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.
44
- The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:vr(10,s))}else i=i.split(",");return i=i.map(l=>parseFloat(l)),{type:n,values:i,colorSpace:s}}const Yc=e=>{const r=er(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},Jr=(e,r)=>{try{return Yc(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function Uo(e){const{type:r,colorSpace:n}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,l)=>l<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 ms(e){e=er(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,l=i*Math.min(s,1-s),d=(m,f=(m+n/30)%12)=>s-l*Math.max(Math.min(f-3,9-f,1),-1);let c="rgb";const u=[Math.round(d(0)*255),Math.round(d(8)*255),Math.round(d(4)*255)];return e.type==="hsla"&&(c+="a",u.push(r[3])),Uo({type:c,values:u})}function wn(e){e=er(e);let r=e.type==="hsl"||e.type==="hsla"?er(ms(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 ki(e,r){const n=wn(e),i=wn(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function D(e,r){return e=er(e),r=Nn(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,Uo(e)}function yr(e,r,n){try{return D(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function Go(e,r){if(e=er(e),r=Nn(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 Uo(e)}function Ce(e,r,n){try{return Go(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function Yo(e,r){if(e=er(e),r=Nn(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 Uo(e)}function je(e,r,n){try{return Yo(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function qc(e,r=.15){return wn(e)>.5?Go(e,r):Yo(e,r)}function ho(e,r,n){try{return qc(e,r)}catch{return e}}function Jc(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 Ti=(e,r,n,i=[])=>{let s=e;r.forEach((l,d)=>{d===r.length-1?Array.isArray(s)?s[Number(l)]=n:s&&typeof s=="object"&&(s[l]=n):s&&typeof s=="object"&&(s[l]||(s[l]=i.includes(l)?[]:{}),s=s[l])})},Kc=(e,r,n)=>{function i(s,l=[],d=[]){Object.entries(s).forEach(([c,u])=>{(!n||n&&!n([...l,c]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...l,c],Array.isArray(u)?[...d,c]:d):r([...l,c],u,d))})}i(e)},Xc=(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 hn(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},l={},d={};return Kc(e,(c,u,m)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(c,u))){const f=`--${n?`${n}-`:""}${c.join("-")}`,x=Xc(c,u);Object.assign(s,{[f]:x}),Ti(l,c,`var(${f})`,m),Ti(d,c,`var(${f}, ${x})`,m)}},c=>c[0]==="vars"),{css:s,vars:l,varsWithDefaults:d}}function Qc(e,r={}){const{getSelector:n=w,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:l}=r,{colorSchemes:d={},components:c,defaultColorScheme:u="light",...m}=e,{vars:f,css:x,varsWithDefaults:v}=hn(m,r);let b=v;const z={},{[u]:S,...y}=d;if(Object.entries(y||{}).forEach(([g,k])=>{const{vars:L,css:a,varsWithDefaults:_}=hn(k,r);b=Ze(b,_),z[g]={css:a,vars:L}}),S){const{css:g,vars:k,varsWithDefaults:L}=hn(S,r);b=Ze(b,L),z[u]={css:g,vars:k}}function w(g,k){var a,_;let L=s;if(s==="class"&&(L=".%s"),s==="data"&&(L="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(L=`[${s}="%s"]`),g){if(L==="media")return e.defaultColorScheme===g?":root":{[`@media (prefers-color-scheme: ${((_=(a=d[g])==null?void 0:a.palette)==null?void 0:_.mode)||g})`]:{":root":k}};if(L)return e.defaultColorScheme===g?`:root, ${L.replace("%s",String(g))}`:L.replace("%s",String(g))}return":root"}return{vars:b,generateThemeVars:()=>{let g={...f};return Object.entries(z).forEach(([,{vars:k}])=>{g=Ze(g,k)}),g},generateStyleSheets:()=>{var F,X;const g=[],k=e.defaultColorScheme||"light";function L(re,h){Object.keys(h).length&&g.push(typeof re=="string"?{[re]:{...h}}:re)}L(n(void 0,{...x}),x);const{[k]:a,..._}=z;if(a){const{css:re}=a,h=(X=(F=d[k])==null?void 0:F.palette)==null?void 0:X.mode,V=!i&&h?{colorScheme:h,...re}:{...re};L(n(k,{...V}),V)}return Object.entries(_).forEach(([re,{css:h}])=>{var Q,Z;const V=(Z=(Q=d[re])==null?void 0:Q.palette)==null?void 0:Z.mode,W=!i&&V?{colorScheme:V,...h}:{...h};L(n(re,{...W}),W)}),l&&g.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)"}}),g}}}function Zc(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 eo={black:"#000",white:"#fff"},ed={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"},Or={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},$r={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},Gr={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},Ar={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},_r={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},Mr={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function fs(){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:eo.white,default:eo.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}}}const hs=fs();function gs(){return{text:{primary:eo.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:eo.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 kn=gs();function Ii(e,r,n,i){const s=i.light||i,l=i.dark||i*1.5;e[r]||(e.hasOwnProperty(n)?e[r]=e[n]:r==="light"?e.light=Yo(e.main,s):r==="dark"&&(e.dark=Go(e.main,l)))}function zi(e,r,n,i,s){const l=s.light||s,d=s.dark||s*1.5;r[n]||(r.hasOwnProperty(i)?r[n]=r[i]:n==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(l*100).toFixed(0)}%)`:n==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(d*100).toFixed(0)}%)`))}function td(e="light"){return e==="dark"?{main:Ar[200],light:Ar[50],dark:Ar[400]}:{main:Ar[700],light:Ar[400],dark:Ar[800]}}function rd(e="light"){return e==="dark"?{main:Or[200],light:Or[50],dark:Or[400]}:{main:Or[500],light:Or[300],dark:Or[700]}}function od(e="light"){return e==="dark"?{main:$r[500],light:$r[300],dark:$r[700]}:{main:$r[700],light:$r[400],dark:$r[800]}}function nd(e="light"){return e==="dark"?{main:_r[400],light:_r[300],dark:_r[700]}:{main:_r[700],light:_r[500],dark:_r[900]}}function id(e="light"){return e==="dark"?{main:Mr[400],light:Mr[300],dark:Mr[700]}:{main:Mr[800],light:Mr[500],dark:Mr[900]}}function sd(e="light"){return e==="dark"?{main:Gr[400],light:Gr[300],dark:Gr[700]}:{main:"#ed6c02",light:Gr[500],dark:Gr[900]}}function ad(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function Ln(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...l}=e,d=e.primary||td(r),c=e.secondary||rd(r),u=e.error||od(r),m=e.info||nd(r),f=e.success||id(r),x=e.warning||sd(r);function v(y){if(s)return ad(y);const w=ki(y,kn.text.primary)>=n?kn.text.primary:hs.text.primary;if(process.env.NODE_ENV!=="production"){const C=ki(y,w);C<3&&console.error([`MUI: The contrast ratio of ${C}:1 for ${w} on ${y}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
45
- `))}return w}const b=({color:y,name:w,mainShade:C=500,lightShade:E=300,darkShade:g=700})=>{if(y={...y},!y.main&&y[C]&&(y.main=y[C]),!y.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${w?` (${w})`:""} provided to augmentColor(color) is invalid.
46
- The color object needs to have a \`main\` property or a \`${C}\` property.`:vr(11,w?` (${w})`:"",C));if(typeof y.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${w?` (${w})`:""} provided to augmentColor(color) is invalid.
47
- \`color.main\` should be a string, but \`${JSON.stringify(y.main)}\` was provided instead.
44
+ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:vr(10,s))}else i=i.split(",");return i=i.map(l=>parseFloat(l)),{type:n,values:i,colorSpace:s}}const Jc=e=>{const r=or(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},so=(e,r)=>{try{return Jc(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function rn(e){const{type:r,colorSpace:n}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,l)=>l<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 Ts(e){e=or(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,l=i*Math.min(s,1-s),d=(h,g=(h+n/30)%12)=>s-l*Math.max(Math.min(g-3,9-g,1),-1);let c="rgb";const u=[Math.round(d(0)*255),Math.round(d(8)*255),Math.round(d(4)*255)];return e.type==="hsla"&&(c+="a",u.push(r[3])),rn({type:c,values:u})}function On(e){e=or(e);let r=e.type==="hsl"||e.type==="hsla"?or(Ts(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 _i(e,r){const n=On(e),i=On(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function B(e,r){return e=or(e),r=Jn(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,rn(e)}function yr(e,r,n){try{return B(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function on(e,r){if(e=or(e),r=Jn(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 rn(e)}function je(e,r,n){try{return on(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function nn(e,r){if(e=or(e),r=Jn(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 rn(e)}function we(e,r,n){try{return nn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function Kc(e,r=.15){return On(e)>.5?on(e,r):nn(e,r)}function To(e,r,n){try{return Kc(e,r)}catch{return e}}function Xc(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 Ai=(e,r,n,i=[])=>{let s=e;r.forEach((l,d)=>{d===r.length-1?Array.isArray(s)?s[Number(l)]=n:s&&typeof s=="object"&&(s[l]=n):s&&typeof s=="object"&&(s[l]||(s[l]=i.includes(l)?[]:{}),s=s[l])})},Qc=(e,r,n)=>{function i(s,l=[],d=[]){Object.entries(s).forEach(([c,u])=>{(!n||n&&!n([...l,c]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...l,c],Array.isArray(u)?[...d,c]:d):r([...l,c],u,d))})}i(e)},Zc=(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 Bn(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},l={},d={};return Qc(e,(c,u,h)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(c,u))){const g=`--${n?`${n}-`:""}${c.join("-")}`,f=Zc(c,u);Object.assign(s,{[g]:f}),Ai(l,c,`var(${g})`,h),Ai(d,c,`var(${g}, ${f})`,h)}},c=>c[0]==="vars"),{css:s,vars:l,varsWithDefaults:d}}function ed(e,r={}){const{getSelector:n=j,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:l}=r,{colorSchemes:d={},components:c,defaultColorScheme:u="light",...h}=e,{vars:g,css:f,varsWithDefaults:b}=Bn(h,r);let v=b;const T={},{[u]:C,...m}=d;if(Object.entries(m||{}).forEach(([S,I])=>{const{vars:N,css:a,varsWithDefaults:A}=Bn(I,r);v=tt(v,A),T[S]={css:a,vars:N}}),C){const{css:S,vars:I,varsWithDefaults:N}=Bn(C,r);v=tt(v,N),T[u]={css:S,vars:I}}function j(S,I){var a,A;let N=s;if(s==="class"&&(N=".%s"),s==="data"&&(N="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(N=`[${s}="%s"]`),S){if(N==="media")return e.defaultColorScheme===S?":root":{[`@media (prefers-color-scheme: ${((A=(a=d[S])==null?void 0:a.palette)==null?void 0:A.mode)||S})`]:{":root":I}};if(N)return e.defaultColorScheme===S?`:root, ${N.replace("%s",String(S))}`:N.replace("%s",String(S))}return":root"}return{vars:v,generateThemeVars:()=>{let S={...g};return Object.entries(T).forEach(([,{vars:I}])=>{S=tt(S,I)}),S},generateStyleSheets:()=>{var F,J;const S=[],I=e.defaultColorScheme||"light";function N(ee,x){Object.keys(x).length&&S.push(typeof ee=="string"?{[ee]:{...x}}:ee)}N(n(void 0,{...f}),f);const{[I]:a,...A}=T;if(a){const{css:ee}=a,x=(J=(F=d[I])==null?void 0:F.palette)==null?void 0:J.mode,R=!i&&x?{colorScheme:x,...ee}:{...ee};N(n(I,{...R}),R)}return Object.entries(A).forEach(([ee,{css:x}])=>{var te,ae;const R=(ae=(te=d[ee])==null?void 0:te.palette)==null?void 0:ae.mode,P=!i&&R?{colorScheme:R,...x}:{...x};N(n(ee,{...P}),P)}),l&&S.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)"}}),S}}}function td(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"},rd={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"},Lr={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},Fr={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},oo={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},Vr={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},Hr={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},Ur={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function Bs(){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 Is=Bs();function zs(){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 _n=zs();function Mi(e,r,n,i){const s=i.light||i,l=i.dark||i*1.5;e[r]||(e.hasOwnProperty(n)?e[r]=e[n]:r==="light"?e.light=nn(e.main,s):r==="dark"&&(e.dark=on(e.main,l)))}function Ri(e,r,n,i,s){const l=s.light||s,d=s.dark||s*1.5;r[n]||(r.hasOwnProperty(i)?r[n]=r[i]:n==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(l*100).toFixed(0)}%)`:n==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(d*100).toFixed(0)}%)`))}function od(e="light"){return e==="dark"?{main:Vr[200],light:Vr[50],dark:Vr[400]}:{main:Vr[700],light:Vr[400],dark:Vr[800]}}function nd(e="light"){return e==="dark"?{main:Lr[200],light:Lr[50],dark:Lr[400]}:{main:Lr[500],light:Lr[300],dark:Lr[700]}}function id(e="light"){return e==="dark"?{main:Fr[500],light:Fr[300],dark:Fr[700]}:{main:Fr[700],light:Fr[400],dark:Fr[800]}}function sd(e="light"){return e==="dark"?{main:Hr[400],light:Hr[300],dark:Hr[700]}:{main:Hr[700],light:Hr[500],dark:Hr[900]}}function ad(e="light"){return e==="dark"?{main:Ur[400],light:Ur[300],dark:Ur[700]}:{main:Ur[800],light:Ur[500],dark:Ur[900]}}function ld(e="light"){return e==="dark"?{main:oo[400],light:oo[300],dark:oo[700]}:{main:"#ed6c02",light:oo[500],dark:oo[900]}}function cd(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function Kn(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...l}=e,d=e.primary||od(r),c=e.secondary||nd(r),u=e.error||id(r),h=e.info||sd(r),g=e.success||ad(r),f=e.warning||ld(r);function b(m){if(s)return cd(m);const j=_i(m,_n.text.primary)>=n?_n.text.primary:Is.text.primary;if(process.env.NODE_ENV!=="production"){const y=_i(m,j);y<3&&console.error([`MUI: The contrast ratio of ${y}:1 for ${j} 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(`
45
+ `))}return j}const v=({color:m,name:j,mainShade:y=500,lightShade:$=300,darkShade:S=700})=>{if(m={...m},!m.main&&m[y]&&(m.main=m[y]),!m.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${j?` (${j})`:""} provided to augmentColor(color) is invalid.
46
+ The color object needs to have a \`main\` property or a \`${y}\` property.`:vr(11,j?` (${j})`:"",y));if(typeof m.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${j?` (${j})`:""} provided to augmentColor(color) is invalid.
47
+ \`color.main\` should be a string, but \`${JSON.stringify(m.main)}\` was provided instead.
48
48
 
49
49
  Did you intend to use one of the following approaches?
50
50
 
@@ -56,17 +56,17 @@ const theme1 = createTheme({ palette: {
56
56
 
57
57
  const theme2 = createTheme({ palette: {
58
58
  primary: { main: green[500] },
59
- } });`:vr(12,w?` (${w})`:"",JSON.stringify(y.main)));return s?(zi(s,y,"light",E,i),zi(s,y,"dark",g,i)):(Ii(y,"light",E,i),Ii(y,"dark",g,i)),y.contrastText||(y.contrastText=v(y.main)),y};let z;return r==="light"?z=fs():r==="dark"&&(z=gs()),process.env.NODE_ENV!=="production"&&(z||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),Ze({common:{...eo},mode:r,primary:b({color:d,name:"primary"}),secondary:b({color:c,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:b({color:u,name:"error"}),warning:b({color:x,name:"warning"}),info:b({color:m,name:"info"}),success:b({color:f,name:"success"}),grey:ed,contrastThreshold:n,getContrastText:v,augmentColor:b,tonalOffset:i,...z},l)}function ld(e){const r={};return Object.entries(e).forEach(i=>{const[s,l]=i;typeof l=="object"&&(r[s]=`${l.fontStyle?`${l.fontStyle} `:""}${l.fontVariant?`${l.fontVariant} `:""}${l.fontWeight?`${l.fontWeight} `:""}${l.fontStretch?`${l.fontStretch} `:""}${l.fontSize||""}${l.lineHeight?`/${l.lineHeight} `:""}${l.fontFamily||""}`)}),r}function cd(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function dd(e){return Math.round(e*1e5)/1e5}const Ei={textTransform:"uppercase"},Bi='"Roboto", "Helvetica", "Arial", sans-serif';function ud(e,r){const{fontFamily:n=Bi,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:l=400,fontWeightMedium:d=500,fontWeightBold:c=700,htmlFontSize:u=16,allVariants:m,pxToRem:f,...x}=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 v=i/14,b=f||(y=>`${y/u*v}rem`),z=(y,w,C,E,g)=>({fontFamily:n,fontWeight:y,fontSize:b(w),lineHeight:C,...n===Bi?{letterSpacing:`${dd(E/w)}em`}:{},...g,...m}),S={h1:z(s,96,1.167,-1.5),h2:z(s,60,1.2,-.5),h3:z(l,48,1.167,0),h4:z(l,34,1.235,.25),h5:z(l,24,1.334,0),h6:z(d,20,1.6,.15),subtitle1:z(l,16,1.75,.15),subtitle2:z(d,14,1.57,.1),body1:z(l,16,1.5,.15),body2:z(l,14,1.43,.15),button:z(d,14,1.75,.4,Ei),caption:z(l,12,1.66,.4),overline:z(l,12,2.66,1,Ei),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Ze({htmlFontSize:u,pxToRem:b,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:l,fontWeightMedium:d,fontWeightBold:c,...S},x,{clone:!1})}const pd=.2,xd=.14,md=.12;function Ee(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${pd})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${xd})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${md})`].join(",")}const fd=["none",Ee(0,2,1,-1,0,1,1,0,0,1,3,0),Ee(0,3,1,-2,0,2,2,0,0,1,5,0),Ee(0,3,3,-2,0,3,4,0,0,1,8,0),Ee(0,2,4,-1,0,4,5,0,0,1,10,0),Ee(0,3,5,-1,0,5,8,0,0,1,14,0),Ee(0,3,5,-1,0,6,10,0,0,1,18,0),Ee(0,4,5,-2,0,7,10,1,0,2,16,1),Ee(0,5,5,-3,0,8,10,1,0,3,14,2),Ee(0,5,6,-3,0,9,12,1,0,3,16,2),Ee(0,6,6,-3,0,10,14,1,0,4,18,3),Ee(0,6,7,-4,0,11,15,1,0,4,20,3),Ee(0,7,8,-4,0,12,17,2,0,5,22,4),Ee(0,7,8,-4,0,13,19,2,0,5,24,4),Ee(0,7,9,-4,0,14,21,2,0,5,26,4),Ee(0,8,9,-5,0,15,22,2,0,6,28,5),Ee(0,8,10,-5,0,16,24,2,0,6,30,5),Ee(0,8,11,-5,0,17,26,2,0,6,32,5),Ee(0,9,11,-5,0,18,28,2,0,7,34,6),Ee(0,9,12,-6,0,19,29,2,0,7,36,6),Ee(0,10,13,-6,0,20,31,3,0,8,38,7),Ee(0,10,13,-6,0,21,33,3,0,8,40,7),Ee(0,10,14,-6,0,22,35,3,0,8,42,7),Ee(0,11,14,-7,0,23,36,3,0,9,44,8),Ee(0,11,15,-7,0,24,38,3,0,9,46,8)],hd={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)"},gd={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function Di(e){return`${Math.round(e)}ms`}function yd(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function bd(e){const r={...hd,...e.easing},n={...gd,...e.duration};return{getAutoHeightDuration:yd,create:(s=["all"],l={})=>{const{duration:d=n.standard,easing:c=r.easeInOut,delay:u=0,...m}=l;if(process.env.NODE_ENV!=="production"){const f=v=>typeof v=="string",x=v=>!Number.isNaN(parseFloat(v));!f(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!x(d)&&!f(d)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${d}.`),f(c)||console.error('MUI: Argument "easing" must be a string.'),!x(u)&&!f(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof l!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
60
- `)),Object.keys(m).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(m).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(f=>`${f} ${typeof d=="string"?d:Di(d)} ${c} ${typeof u=="string"?u:Di(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 Sd(e){return Qt(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function ys(e={}){const r={...e};function n(i){const s=Object.entries(i);for(let l=0;l<s.length;l++){const[d,c]=s[l];!Sd(c)||d.startsWith("unstable_")?delete i[d]:Qt(c)&&(i[d]={...c},n(i[d]))}}return n(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
59
+ } });`:vr(12,j?` (${j})`:"",JSON.stringify(m.main)));return s?(Ri(s,m,"light",$,i),Ri(s,m,"dark",S,i)):(Mi(m,"light",$,i),Mi(m,"dark",S,i)),m.contrastText||(m.contrastText=b(m.main)),m};let T;return r==="light"?T=Bs():r==="dark"&&(T=zs()),process.env.NODE_ENV!=="production"&&(T||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),tt({common:{...po},mode:r,primary:v({color:d,name:"primary"}),secondary:v({color:c,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:v({color:u,name:"error"}),warning:v({color:f,name:"warning"}),info:v({color:h,name:"info"}),success:v({color:g,name:"success"}),grey:rd,contrastThreshold:n,getContrastText:b,augmentColor:v,tonalOffset:i,...T},l)}function dd(e){const r={};return Object.entries(e).forEach(i=>{const[s,l]=i;typeof l=="object"&&(r[s]=`${l.fontStyle?`${l.fontStyle} `:""}${l.fontVariant?`${l.fontVariant} `:""}${l.fontWeight?`${l.fontWeight} `:""}${l.fontStretch?`${l.fontStretch} `:""}${l.fontSize||""}${l.lineHeight?`/${l.lineHeight} `:""}${l.fontFamily||""}`)}),r}function ud(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function pd(e){return Math.round(e*1e5)/1e5}const Wi={textTransform:"uppercase"},Pi='"Roboto", "Helvetica", "Arial", sans-serif';function xd(e,r){const{fontFamily:n=Pi,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:l=400,fontWeightMedium:d=500,fontWeightBold:c=700,htmlFontSize:u=16,allVariants:h,pxToRem:g,...f}=typeof r=="function"?r(e):r;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof u!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const b=i/14,v=g||(m=>`${m/u*b}rem`),T=(m,j,y,$,S)=>({fontFamily:n,fontWeight:m,fontSize:v(j),lineHeight:y,...n===Pi?{letterSpacing:`${pd($/j)}em`}:{},...S,...h}),C={h1:T(s,96,1.167,-1.5),h2:T(s,60,1.2,-.5),h3:T(l,48,1.167,0),h4:T(l,34,1.235,.25),h5:T(l,24,1.334,0),h6:T(d,20,1.6,.15),subtitle1:T(l,16,1.75,.15),subtitle2:T(d,14,1.57,.1),body1:T(l,16,1.5,.15),body2:T(l,14,1.43,.15),button:T(d,14,1.75,.4,Wi),caption:T(l,12,1.66,.4),overline:T(l,12,2.66,1,Wi),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return tt({htmlFontSize:u,pxToRem:v,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:l,fontWeightMedium:d,fontWeightBold:c,...C},f,{clone:!1})}const md=.2,fd=.14,hd=.12;function ze(...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,${fd})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${hd})`].join(",")}const gd=["none",ze(0,2,1,-1,0,1,1,0,0,1,3,0),ze(0,3,1,-2,0,2,2,0,0,1,5,0),ze(0,3,3,-2,0,3,4,0,0,1,8,0),ze(0,2,4,-1,0,4,5,0,0,1,10,0),ze(0,3,5,-1,0,5,8,0,0,1,14,0),ze(0,3,5,-1,0,6,10,0,0,1,18,0),ze(0,4,5,-2,0,7,10,1,0,2,16,1),ze(0,5,5,-3,0,8,10,1,0,3,14,2),ze(0,5,6,-3,0,9,12,1,0,3,16,2),ze(0,6,6,-3,0,10,14,1,0,4,18,3),ze(0,6,7,-4,0,11,15,1,0,4,20,3),ze(0,7,8,-4,0,12,17,2,0,5,22,4),ze(0,7,8,-4,0,13,19,2,0,5,24,4),ze(0,7,9,-4,0,14,21,2,0,5,26,4),ze(0,8,9,-5,0,15,22,2,0,6,28,5),ze(0,8,10,-5,0,16,24,2,0,6,30,5),ze(0,8,11,-5,0,17,26,2,0,6,32,5),ze(0,9,11,-5,0,18,28,2,0,7,34,6),ze(0,9,12,-6,0,19,29,2,0,7,36,6),ze(0,10,13,-6,0,20,31,3,0,8,38,7),ze(0,10,13,-6,0,21,33,3,0,8,40,7),ze(0,10,14,-6,0,22,35,3,0,8,42,7),ze(0,11,14,-7,0,23,36,3,0,9,44,8),ze(0,11,15,-7,0,24,38,3,0,9,46,8)],yd={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)"},bd={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function Ni(e){return`${Math.round(e)}ms`}function vd(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function Sd(e){const r={...yd,...e.easing},n={...bd,...e.duration};return{getAutoHeightDuration:vd,create:(s=["all"],l={})=>{const{duration:d=n.standard,easing:c=r.easeInOut,delay:u=0,...h}=l;if(process.env.NODE_ENV!=="production"){const g=b=>typeof b=="string",f=b=>!Number.isNaN(parseFloat(b));!g(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!f(d)&&!g(d)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${d}.`),g(c)||console.error('MUI: Argument "easing" must be a string.'),!f(u)&&!g(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof l!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
60
+ `)),Object.keys(h).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(h).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(g=>`${g} ${typeof d=="string"?d:Ni(d)} ${c} ${typeof u=="string"?u:Ni(u)}`).join(",")},...e,easing:r,duration:n}}const Cd={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function jd(e){return tr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function Es(e={}){const r={...e};function n(i){const s=Object.entries(i);for(let l=0;l<s.length;l++){const[d,c]=s[l];!jd(c)||d.startsWith("unstable_")?delete i[d]:tr(c)&&(i[d]={...c},n(i[d]))}}return n(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
61
61
 
62
62
  const theme = ${JSON.stringify(r,null,2)};
63
63
 
64
64
  theme.breakpoints = createBreakpoints(theme.breakpoints || {});
65
65
  theme.transitions = createTransitions(theme.transitions || {});
66
66
 
67
- export default theme;`}function Oi(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Cd=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 jd(e){Object.assign(e,{alpha(r,n){const i=this||e;return i.colorSpace?`oklch(from ${r} l c h / ${typeof n=="string"?`calc(${n})`:n})`:i.vars?`rgba(${r.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof n=="string"?`calc(${n})`:n})`:D(r,Cd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${Oi(n)})`:Yo(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${Oi(n)})`:Go(r,n)}})}function Tn(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:l={},transitions:d={},typography:c={},shape:u,colorSpace:m,...f}=e;if(e.vars&&e.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":vr(20));const x=Ln({...l,colorSpace:m}),v=xs(e);let b=Ze(v,{mixins:cd(v.breakpoints,i),palette:x,shadows:fd.slice(),typography:ud(x,c),transitions:bd(d),zIndex:{...vd}});if(b=Ze(b,f),b=r.reduce((z,S)=>Ze(z,S),b),process.env.NODE_ENV!=="production"){const z=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],S=(y,w)=>{let C;for(C in y){const E=y[C];if(z.includes(C)&&Object.keys(E).length>0){if(process.env.NODE_ENV!=="production"){const g=Hc("",C);console.error([`MUI: The \`${w}\` component increases the CSS specificity of the \`${C}\` internal state.`,"You can not override it like this: ",JSON.stringify(y,null,2),"",`Instead, you need to use the '&.${g}' syntax:`,JSON.stringify({root:{[`&.${g}`]:E}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
68
- `))}y[C]={}}}};Object.keys(b.components).forEach(y=>{const w=b.components[y].styleOverrides;w&&y.startsWith("Mui")&&S(w,y)})}return b.unstable_sxConfig={...Vo,...f==null?void 0:f.unstable_sxConfig},b.unstable_sx=function(S){return Ho({sx:S,theme:this})},b.toRuntimeSource=ys,jd(b),b}function wd(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 kd=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=wd(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function bs(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function vs(e){return e==="dark"?kd:[]}function Td(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...l}=e,d=Ln({...r,colorSpace:s});return{palette:d,opacity:{...bs(d.mode),...n},overlays:i||vs(d.mode),...l}}function Id(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 zd=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Ed=e=>(r,n)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let l=s;if(s==="class"&&(l=".%s"),s==="data"&&(l="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(l=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const d={};return zd(e.cssVarPrefix).forEach(c=>{d[c]=n[c],delete n[c]}),l==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:d}}:l?{[l.replace("%s",r)]:d,[`${i}, ${l.replace("%s",r)}`]:n}:{[i]:{...n,...d}}}if(l&&l!=="media")return`${i}, ${l.replace("%s",String(r))}`}else if(r){if(l==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(l)return l.replace("%s",String(r))}return i};function Bd(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function M(e,r,n){!e[r]&&n&&(e[r]=n)}function Kr(e){return typeof e!="string"||!e.startsWith("hsl")?e:ms(e)}function Wt(e,r){`${r}Channel`in e||(e[`${r}Channel`]=Jr(Kr(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().
69
- 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 Dd(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const It=e=>{try{return e()}catch{}},Od=(e="mui")=>Jc(e);function gn(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const l=s==="dark"?"dark":"light";if(!i){r[s]=Td({...n,palette:{mode:l,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:d,...c}=Tn({...i,palette:{mode:l,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:d,opacity:{...bs(l),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||vs(l)},c}function $d(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:l="mui",nativeColor:d=!1,shouldSkipGeneratingVar:c=Id,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:m=":root",...f}=e,x=Object.keys(n)[0],v=i||(n.light&&x!=="light"?"light":x),b=Od(l),{[v]:z,light:S,dark:y,...w}=n,C={...w};let E=z;if((v==="dark"&&!("dark"in n)||v==="light"&&!("light"in n))&&(E=!0),!E)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${v}\` option is either missing or invalid.`:vr(21,v));let g;d&&(g="oklch");const k=gn(g,C,E,f,v);S&&!C.light&&gn(g,C,S,void 0,"light"),y&&!C.dark&&gn(g,C,y,void 0,"dark");let L={defaultColorScheme:v,...k,cssVarPrefix:l,colorSchemeSelector:u,rootSelector:m,getCssVar:b,colorSchemes:C,font:{...ld(k.typography),...k.font},spacing:Dd(f.spacing)};Object.keys(L.colorSchemes).forEach(re=>{const h=L.colorSchemes[re].palette,V=Q=>{const Z=Q.split("-"),pe=Z[1],he=Z[2];return b(Q,h[pe][he])};h.mode==="light"&&(M(h.common,"background","#fff"),M(h.common,"onBackground","#000")),h.mode==="dark"&&(M(h.common,"background","#000"),M(h.common,"onBackground","#fff"));function W(Q,Z,pe){if(g){let he;return Q===yr&&(he=`transparent ${((1-pe)*100).toFixed(0)}%`),Q===Ce&&(he=`#000 ${(pe*100).toFixed(0)}%`),Q===je&&(he=`#fff ${(pe*100).toFixed(0)}%`),`color-mix(in ${g}, ${Z}, ${he})`}return Q(Z,pe)}if(Bd(h,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),h.mode==="light"){M(h.Alert,"errorColor",W(Ce,h.error.light,.6)),M(h.Alert,"infoColor",W(Ce,h.info.light,.6)),M(h.Alert,"successColor",W(Ce,h.success.light,.6)),M(h.Alert,"warningColor",W(Ce,h.warning.light,.6)),M(h.Alert,"errorFilledBg",V("palette-error-main")),M(h.Alert,"infoFilledBg",V("palette-info-main")),M(h.Alert,"successFilledBg",V("palette-success-main")),M(h.Alert,"warningFilledBg",V("palette-warning-main")),M(h.Alert,"errorFilledColor",It(()=>h.getContrastText(h.error.main))),M(h.Alert,"infoFilledColor",It(()=>h.getContrastText(h.info.main))),M(h.Alert,"successFilledColor",It(()=>h.getContrastText(h.success.main))),M(h.Alert,"warningFilledColor",It(()=>h.getContrastText(h.warning.main))),M(h.Alert,"errorStandardBg",W(je,h.error.light,.9)),M(h.Alert,"infoStandardBg",W(je,h.info.light,.9)),M(h.Alert,"successStandardBg",W(je,h.success.light,.9)),M(h.Alert,"warningStandardBg",W(je,h.warning.light,.9)),M(h.Alert,"errorIconColor",V("palette-error-main")),M(h.Alert,"infoIconColor",V("palette-info-main")),M(h.Alert,"successIconColor",V("palette-success-main")),M(h.Alert,"warningIconColor",V("palette-warning-main")),M(h.AppBar,"defaultBg",V("palette-grey-100")),M(h.Avatar,"defaultBg",V("palette-grey-400")),M(h.Button,"inheritContainedBg",V("palette-grey-300")),M(h.Button,"inheritContainedHoverBg",V("palette-grey-A100")),M(h.Chip,"defaultBorder",V("palette-grey-400")),M(h.Chip,"defaultAvatarColor",V("palette-grey-700")),M(h.Chip,"defaultIconColor",V("palette-grey-700")),M(h.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),M(h.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),M(h.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),M(h.LinearProgress,"primaryBg",W(je,h.primary.main,.62)),M(h.LinearProgress,"secondaryBg",W(je,h.secondary.main,.62)),M(h.LinearProgress,"errorBg",W(je,h.error.main,.62)),M(h.LinearProgress,"infoBg",W(je,h.info.main,.62)),M(h.LinearProgress,"successBg",W(je,h.success.main,.62)),M(h.LinearProgress,"warningBg",W(je,h.warning.main,.62)),M(h.Skeleton,"bg",g?W(yr,h.text.primary,.11):`rgba(${V("palette-text-primaryChannel")} / 0.11)`),M(h.Slider,"primaryTrack",W(je,h.primary.main,.62)),M(h.Slider,"secondaryTrack",W(je,h.secondary.main,.62)),M(h.Slider,"errorTrack",W(je,h.error.main,.62)),M(h.Slider,"infoTrack",W(je,h.info.main,.62)),M(h.Slider,"successTrack",W(je,h.success.main,.62)),M(h.Slider,"warningTrack",W(je,h.warning.main,.62));const Q=g?W(Ce,h.background.default,.6825):ho(h.background.default,.8);M(h.SnackbarContent,"bg",Q),M(h.SnackbarContent,"color",It(()=>g?kn.text.primary:h.getContrastText(Q))),M(h.SpeedDialAction,"fabHoverBg",ho(h.background.paper,.15)),M(h.StepConnector,"border",V("palette-grey-400")),M(h.StepContent,"border",V("palette-grey-400")),M(h.Switch,"defaultColor",V("palette-common-white")),M(h.Switch,"defaultDisabledColor",V("palette-grey-100")),M(h.Switch,"primaryDisabledColor",W(je,h.primary.main,.62)),M(h.Switch,"secondaryDisabledColor",W(je,h.secondary.main,.62)),M(h.Switch,"errorDisabledColor",W(je,h.error.main,.62)),M(h.Switch,"infoDisabledColor",W(je,h.info.main,.62)),M(h.Switch,"successDisabledColor",W(je,h.success.main,.62)),M(h.Switch,"warningDisabledColor",W(je,h.warning.main,.62)),M(h.TableCell,"border",W(je,W(yr,h.divider,1),.88)),M(h.Tooltip,"bg",W(yr,h.grey[700],.92))}if(h.mode==="dark"){M(h.Alert,"errorColor",W(je,h.error.light,.6)),M(h.Alert,"infoColor",W(je,h.info.light,.6)),M(h.Alert,"successColor",W(je,h.success.light,.6)),M(h.Alert,"warningColor",W(je,h.warning.light,.6)),M(h.Alert,"errorFilledBg",V("palette-error-dark")),M(h.Alert,"infoFilledBg",V("palette-info-dark")),M(h.Alert,"successFilledBg",V("palette-success-dark")),M(h.Alert,"warningFilledBg",V("palette-warning-dark")),M(h.Alert,"errorFilledColor",It(()=>h.getContrastText(h.error.dark))),M(h.Alert,"infoFilledColor",It(()=>h.getContrastText(h.info.dark))),M(h.Alert,"successFilledColor",It(()=>h.getContrastText(h.success.dark))),M(h.Alert,"warningFilledColor",It(()=>h.getContrastText(h.warning.dark))),M(h.Alert,"errorStandardBg",W(Ce,h.error.light,.9)),M(h.Alert,"infoStandardBg",W(Ce,h.info.light,.9)),M(h.Alert,"successStandardBg",W(Ce,h.success.light,.9)),M(h.Alert,"warningStandardBg",W(Ce,h.warning.light,.9)),M(h.Alert,"errorIconColor",V("palette-error-main")),M(h.Alert,"infoIconColor",V("palette-info-main")),M(h.Alert,"successIconColor",V("palette-success-main")),M(h.Alert,"warningIconColor",V("palette-warning-main")),M(h.AppBar,"defaultBg",V("palette-grey-900")),M(h.AppBar,"darkBg",V("palette-background-paper")),M(h.AppBar,"darkColor",V("palette-text-primary")),M(h.Avatar,"defaultBg",V("palette-grey-600")),M(h.Button,"inheritContainedBg",V("palette-grey-800")),M(h.Button,"inheritContainedHoverBg",V("palette-grey-700")),M(h.Chip,"defaultBorder",V("palette-grey-700")),M(h.Chip,"defaultAvatarColor",V("palette-grey-300")),M(h.Chip,"defaultIconColor",V("palette-grey-300")),M(h.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),M(h.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),M(h.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),M(h.LinearProgress,"primaryBg",W(Ce,h.primary.main,.5)),M(h.LinearProgress,"secondaryBg",W(Ce,h.secondary.main,.5)),M(h.LinearProgress,"errorBg",W(Ce,h.error.main,.5)),M(h.LinearProgress,"infoBg",W(Ce,h.info.main,.5)),M(h.LinearProgress,"successBg",W(Ce,h.success.main,.5)),M(h.LinearProgress,"warningBg",W(Ce,h.warning.main,.5)),M(h.Skeleton,"bg",g?W(yr,h.text.primary,.13):`rgba(${V("palette-text-primaryChannel")} / 0.13)`),M(h.Slider,"primaryTrack",W(Ce,h.primary.main,.5)),M(h.Slider,"secondaryTrack",W(Ce,h.secondary.main,.5)),M(h.Slider,"errorTrack",W(Ce,h.error.main,.5)),M(h.Slider,"infoTrack",W(Ce,h.info.main,.5)),M(h.Slider,"successTrack",W(Ce,h.success.main,.5)),M(h.Slider,"warningTrack",W(Ce,h.warning.main,.5));const Q=g?W(je,h.background.default,.985):ho(h.background.default,.98);M(h.SnackbarContent,"bg",Q),M(h.SnackbarContent,"color",It(()=>g?hs.text.primary:h.getContrastText(Q))),M(h.SpeedDialAction,"fabHoverBg",ho(h.background.paper,.15)),M(h.StepConnector,"border",V("palette-grey-600")),M(h.StepContent,"border",V("palette-grey-600")),M(h.Switch,"defaultColor",V("palette-grey-300")),M(h.Switch,"defaultDisabledColor",V("palette-grey-600")),M(h.Switch,"primaryDisabledColor",W(Ce,h.primary.main,.55)),M(h.Switch,"secondaryDisabledColor",W(Ce,h.secondary.main,.55)),M(h.Switch,"errorDisabledColor",W(Ce,h.error.main,.55)),M(h.Switch,"infoDisabledColor",W(Ce,h.info.main,.55)),M(h.Switch,"successDisabledColor",W(Ce,h.success.main,.55)),M(h.Switch,"warningDisabledColor",W(Ce,h.warning.main,.55)),M(h.TableCell,"border",W(Ce,W(yr,h.divider,1),.68)),M(h.Tooltip,"bg",W(yr,h.grey[700],.92))}Wt(h.background,"default"),Wt(h.background,"paper"),Wt(h.common,"background"),Wt(h.common,"onBackground"),Wt(h,"divider"),Object.keys(h).forEach(Q=>{const Z=h[Q];Q!=="tonalOffset"&&Z&&typeof Z=="object"&&(Z.main&&M(h[Q],"mainChannel",Jr(Kr(Z.main))),Z.light&&M(h[Q],"lightChannel",Jr(Kr(Z.light))),Z.dark&&M(h[Q],"darkChannel",Jr(Kr(Z.dark))),Z.contrastText&&M(h[Q],"contrastTextChannel",Jr(Kr(Z.contrastText))),Q==="text"&&(Wt(h[Q],"primary"),Wt(h[Q],"secondary")),Q==="action"&&(Z.active&&Wt(h[Q],"active"),Z.selected&&Wt(h[Q],"selected")))})}),L=r.reduce((re,h)=>Ze(re,h),L);const a={prefix:l,disableCssColorScheme:s,shouldSkipGeneratingVar:c,getSelector:Ed(L),enableContrastVars:d},{vars:_,generateThemeVars:F,generateStyleSheets:X}=Qc(L,a);return L.vars=_,Object.entries(L.colorSchemes[L.defaultColorScheme]).forEach(([re,h])=>{L[re]=h}),L.generateThemeVars=F,L.generateStyleSheets=X,L.generateSpacing=function(){return ps(f.spacing,Wn(this))},L.getColorSchemeSelector=Zc(u),L.spacing=L.generateSpacing(),L.shouldSkipGeneratingVar=c,L.unstable_sxConfig={...Vo,...f==null?void 0:f.unstable_sxConfig},L.unstable_sx=function(h){return Ho({sx:h,theme:this})},L.toRuntimeSource=ys,L}function $i(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:Ln({...n===!0?{}:n.palette,mode:r})})}function Ad(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:l=n==null?void 0:n.mode,...d}=e,c=l||"light",u=s==null?void 0:s[c],m={...s,...n?{[c]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return Tn(e,...r);let f=n;"palette"in e||m[c]&&(m[c]!==!0?f=m[c].palette:c==="dark"&&(f={mode:"dark"}));const x=Tn({...e,palette:f},...r);return x.defaultColorScheme=c,x.colorSchemes=m,x.palette.mode==="light"&&(x.colorSchemes.light={...m.light!==!0&&m.light,palette:x.palette},$i(x,"dark",m.dark)),x.palette.mode==="dark"&&(x.colorSchemes.dark={...m.dark!==!0&&m.dark,palette:x.palette},$i(x,"light",m.light)),x}return!n&&!("light"in m)&&c==="light"&&(m.light=!0),$d({...d,colorSchemes:m,defaultColorScheme:c,...typeof i!="boolean"&&i},...r)}const _d=Ad();function Lt(){const e=Nc(_d);return process.env.NODE_ENV!=="production"&&Do.useDebugValue(e),e[El]||e}async function Md(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,l=setTimeout(()=>s.abort(),3e4);let d;try{d=await fetch(e,{headers:i,signal:s.signal})}catch(m){throw clearTimeout(l),(m==null?void 0:m.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(l)}if(d.status===401)throw new Error("Authentication failed (401) — check your API key");if(!d.ok)throw new Error(`API error ${d.status}: ${d.statusText}`);let c;try{c=await d.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(c))u=c;else if(n&&c[n]&&Array.isArray(c[n]))u=c[n];else{const f=["data","results","items","records"].find(x=>c[x]&&Array.isArray(c[x]));if(f)u=c[f];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 Rd(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${D(e.palette.common.black,n.opacity)}`).join(", ")}const Wd={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 se(e,r){return Rd(e,Wd[r])}function Ne(e){return`${Number(e.shape.borderRadius)*1.5}px`}function oo(e){return`${Number(e.shape.borderRadius)}px`}function Pd({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[l,d]=p.useState(""),[c,u]=p.useState(!1),[m,f]=p.useState(""),[x,v]=p.useState(null),[b,z]=p.useState(null),[S,y]=p.useState(!1),[w,C]=p.useState(""),E=p.useRef(null),[g,k]=p.useState("json"),[L,a]=p.useState(""),[_,F]=p.useState(""),[X,re]=p.useState(""),[h,V]=p.useState("idle"),[W,Q]=p.useState(""),[Z,pe]=p.useState(null),[he,N]=p.useState(0),R=async O=>{if(C(""),!O.name.endsWith(".json")){C("Only .json files are allowed");return}const te=10*1024*1024;if(O.size>te){C("File size exceeds 10MB limit");return}try{const ce=await O.text();let ie;try{ie=JSON.parse(ce)}catch{C("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ie)){C("JSON must be an array of objects");return}if(ie.length===0){C("No data rows found in JSON file");return}v(O),z(ie)}catch{C("Network error — please try again")}},H=O=>{O.preventDefault();const te=O.dataTransfer.files[0];te&&R(te)},G=async()=>{if(L.trim()){V("loading"),Q("");try{const O=await Md(L.trim(),_.trim()||void 0,X.trim()||void 0);pe(O.data),N(O.data.length),V("ready")}catch(O){Q((O==null?void 0:O.message)||"Connection failed"),V("error")}}},ae=()=>{if(!l.trim()){u(!0);return}const O=g==="api"?Z:i||b;O&&(n(l.trim(),m.trim(),O),ee())},ee=()=>{d(""),u(!1),f(""),v(null),z(null),C(""),k("json"),a(""),F(""),re(""),V("idle"),Q(""),pe(null),N(0),r()},ne=i||b,oe=c&&!l.trim();return l.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:ee,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:O=>Ne(O),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:O=>se(O,"menu")}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:500,fontSize:"1.125rem",color:"text.primary",letterSpacing:"-0.01em",borderBottom:"1px solid",borderColor:"divider"},children:["Create new report",t.jsx(o.IconButton,{onClick:ee,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(T.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:l,onChange:O=>{d(O.target.value),c&&O.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:oe,helperText:oe?"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:m,onChange:O=>f(O.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:g==="json"?0:1,onChange:(O,te)=>{k(te===0?"json":"api"),V("idle"),Q("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40},children:[t.jsx(o.Tab,{label:"Upload JSON",icon:t.jsx(T.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}}),t.jsx(o.Tab,{label:"Connect API",icon:t.jsx(T.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}})]}),g==="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:O=>D(O.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:O=>D(O.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(T.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),t.jsx(o.IconButton,{size:"small",onClick:()=>y(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(T.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:H,onDragOver:O=>O.preventDefault(),onPaste:O=>O.preventDefault(),onClick:()=>{var O;return(O=E.current)==null?void 0:O.click()},sx:{position:"relative",border:"1.5px",borderStyle:b?"solid":"dashed",borderColor:b?"success.main":w?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:b?O=>D(O.palette.success.main,.04):w?O=>D(O.palette.error.main,.04):O=>D(O.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:b?O=>D(O.palette.success.main,.08):w?O=>D(O.palette.error.main,.08):O=>D(O.palette.primary.main,.08),borderColor:b?"success.dark":w?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:E,type:"file",accept:".json",sx:{display:"none"},onChange:O=>{var te;return((te=O.target.files)==null?void 0:te[0])&&R(O.target.files[0])}}),b?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:O=>D(O.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx(T.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:O=>D(O.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx(T.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:O=>D(O.palette.error.main,.08),border:1,borderColor:O=>D(O.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:w})})]})]})]})}),g==="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:L,onChange:O=>{a(O.target.value),V("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:_,onChange:O=>F(O.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(T.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:X,onChange:O=>re(O.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:!L.trim()||h==="loading",onClick:G,startIcon:h==="loading"?t.jsx(o.CircularProgress,{size:16,color:"inherit"}):t.jsx(T.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:O=>D(O.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:h==="loading"?"Connecting...":"Test Connection & Load Data"}),h==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:O=>D(O.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(T.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:[he.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:L})]})]}),h==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:O=>D(O.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(T.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:W})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:ee,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:O=>`${O.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:O=>D(O.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:ae,disabled:g==="json"&&!ne||g==="api"&&h!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:O=>`${O.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]})]}),t.jsxs(o.Dialog,{open:S,onClose:()=>y(!1),maxWidth:"sm",PaperProps:{sx:{borderRadius:3,width:560,maxHeight:"80vh",boxShadow:8}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em"},children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>y(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(T.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:`[
67
+ export default theme;`}function Li(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const wd=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 kd(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})`:B(r,wd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${Li(n)})`:nn(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${Li(n)})`:on(r,n)}})}function An(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:l={},transitions:d={},typography:c={},shape:u,colorSpace:h,...g}=e;if(e.vars&&e.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":vr(20));const f=Kn({...l,colorSpace:h}),b=ks(e);let v=tt(b,{mixins:ud(b.breakpoints,i),palette:f,shadows:gd.slice(),typography:xd(f,c),transitions:Sd(d),zIndex:{...Cd}});if(v=tt(v,g),v=r.reduce((T,C)=>tt(T,C),v),process.env.NODE_ENV!=="production"){const T=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],C=(m,j)=>{let y;for(y in m){const $=m[y];if(T.includes(y)&&Object.keys($).length>0){if(process.env.NODE_ENV!=="production"){const S=Gc("",y);console.error([`MUI: The \`${j}\` component increases the CSS specificity of the \`${y}\` internal state.`,"You can not override it like this: ",JSON.stringify(m,null,2),"",`Instead, you need to use the '&.${S}' syntax:`,JSON.stringify({root:{[`&.${S}`]:$}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
68
+ `))}m[y]={}}}};Object.keys(v.components).forEach(m=>{const j=v.components[m].styleOverrides;j&&m.startsWith("Mui")&&C(j,m)})}return v.unstable_sxConfig={...en,...g==null?void 0:g.unstable_sxConfig},v.unstable_sx=function(C){return tn({sx:C,theme:this})},v.toRuntimeSource=Es,kd(v),v}function Td(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 Bd=[...Array(25)].map((e,r)=>{if(r===0)return"none";const n=Td(r);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function Ds(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function $s(e){return e==="dark"?Bd:[]}function Id(e){const{palette:r={mode:"light"},opacity:n,overlays:i,colorSpace:s,...l}=e,d=Kn({...r,colorSpace:s});return{palette:d,opacity:{...Ds(d.mode),...n},overlays:i||$s(d.mode),...l}}function zd(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 Ed=e=>[...[...Array(25)].map((r,n)=>`--${e?`${e}-`:""}overlays-${n}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],Dd=e=>(r,n)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let l=s;if(s==="class"&&(l=".%s"),s==="data"&&(l="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(l=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const d={};return Ed(e.cssVarPrefix).forEach(c=>{d[c]=n[c],delete n[c]}),l==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:d}}:l?{[l.replace("%s",r)]:d,[`${i}, ${l.replace("%s",r)}`]:n}:{[i]:{...n,...d}}}if(l&&l!=="media")return`${i}, ${l.replace("%s",String(r))}`}else if(r){if(l==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(l)return l.replace("%s",String(r))}return i};function $d(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function M(e,r,n){!e[r]&&n&&(e[r]=n)}function ao(e){return typeof e!="string"||!e.startsWith("hsl")?e:Ts(e)}function Ft(e,r){`${r}Channel`in e||(e[`${r}Channel`]=so(ao(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().
69
+ 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 Od(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Dt=e=>{try{return e()}catch{}},_d=(e="mui")=>Xc(e);function In(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const l=s==="dark"?"dark":"light";if(!i){r[s]=Id({...n,palette:{mode:l,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:d,...c}=An({...i,palette:{mode:l,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:d,opacity:{...Ds(l),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||$s(l)},c}function Ad(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:l="mui",nativeColor:d=!1,shouldSkipGeneratingVar:c=zd,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:h=":root",...g}=e,f=Object.keys(n)[0],b=i||(n.light&&f!=="light"?"light":f),v=_d(l),{[b]:T,light:C,dark:m,...j}=n,y={...j};let $=T;if((b==="dark"&&!("dark"in n)||b==="light"&&!("light"in n))&&($=!0),!$)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${b}\` option is either missing or invalid.`:vr(21,b));let S;d&&(S="oklch");const I=In(S,y,$,g,b);C&&!y.light&&In(S,y,C,void 0,"light"),m&&!y.dark&&In(S,y,m,void 0,"dark");let N={defaultColorScheme:b,...I,cssVarPrefix:l,colorSchemeSelector:u,rootSelector:h,getCssVar:v,colorSchemes:y,font:{...dd(I.typography),...I.font},spacing:Od(g.spacing)};Object.keys(N.colorSchemes).forEach(ee=>{const x=N.colorSchemes[ee].palette,R=te=>{const ae=te.split("-"),Q=ae[1],re=ae[2];return v(te,x[Q][re])};x.mode==="light"&&(M(x.common,"background","#fff"),M(x.common,"onBackground","#000")),x.mode==="dark"&&(M(x.common,"background","#000"),M(x.common,"onBackground","#fff"));function P(te,ae,Q){if(S){let re;return te===yr&&(re=`transparent ${((1-Q)*100).toFixed(0)}%`),te===je&&(re=`#000 ${(Q*100).toFixed(0)}%`),te===we&&(re=`#fff ${(Q*100).toFixed(0)}%`),`color-mix(in ${S}, ${ae}, ${re})`}return te(ae,Q)}if($d(x,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),x.mode==="light"){M(x.Alert,"errorColor",P(je,x.error.light,.6)),M(x.Alert,"infoColor",P(je,x.info.light,.6)),M(x.Alert,"successColor",P(je,x.success.light,.6)),M(x.Alert,"warningColor",P(je,x.warning.light,.6)),M(x.Alert,"errorFilledBg",R("palette-error-main")),M(x.Alert,"infoFilledBg",R("palette-info-main")),M(x.Alert,"successFilledBg",R("palette-success-main")),M(x.Alert,"warningFilledBg",R("palette-warning-main")),M(x.Alert,"errorFilledColor",Dt(()=>x.getContrastText(x.error.main))),M(x.Alert,"infoFilledColor",Dt(()=>x.getContrastText(x.info.main))),M(x.Alert,"successFilledColor",Dt(()=>x.getContrastText(x.success.main))),M(x.Alert,"warningFilledColor",Dt(()=>x.getContrastText(x.warning.main))),M(x.Alert,"errorStandardBg",P(we,x.error.light,.9)),M(x.Alert,"infoStandardBg",P(we,x.info.light,.9)),M(x.Alert,"successStandardBg",P(we,x.success.light,.9)),M(x.Alert,"warningStandardBg",P(we,x.warning.light,.9)),M(x.Alert,"errorIconColor",R("palette-error-main")),M(x.Alert,"infoIconColor",R("palette-info-main")),M(x.Alert,"successIconColor",R("palette-success-main")),M(x.Alert,"warningIconColor",R("palette-warning-main")),M(x.AppBar,"defaultBg",R("palette-grey-100")),M(x.Avatar,"defaultBg",R("palette-grey-400")),M(x.Button,"inheritContainedBg",R("palette-grey-300")),M(x.Button,"inheritContainedHoverBg",R("palette-grey-A100")),M(x.Chip,"defaultBorder",R("palette-grey-400")),M(x.Chip,"defaultAvatarColor",R("palette-grey-700")),M(x.Chip,"defaultIconColor",R("palette-grey-700")),M(x.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),M(x.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),M(x.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),M(x.LinearProgress,"primaryBg",P(we,x.primary.main,.62)),M(x.LinearProgress,"secondaryBg",P(we,x.secondary.main,.62)),M(x.LinearProgress,"errorBg",P(we,x.error.main,.62)),M(x.LinearProgress,"infoBg",P(we,x.info.main,.62)),M(x.LinearProgress,"successBg",P(we,x.success.main,.62)),M(x.LinearProgress,"warningBg",P(we,x.warning.main,.62)),M(x.Skeleton,"bg",S?P(yr,x.text.primary,.11):`rgba(${R("palette-text-primaryChannel")} / 0.11)`),M(x.Slider,"primaryTrack",P(we,x.primary.main,.62)),M(x.Slider,"secondaryTrack",P(we,x.secondary.main,.62)),M(x.Slider,"errorTrack",P(we,x.error.main,.62)),M(x.Slider,"infoTrack",P(we,x.info.main,.62)),M(x.Slider,"successTrack",P(we,x.success.main,.62)),M(x.Slider,"warningTrack",P(we,x.warning.main,.62));const te=S?P(je,x.background.default,.6825):To(x.background.default,.8);M(x.SnackbarContent,"bg",te),M(x.SnackbarContent,"color",Dt(()=>S?_n.text.primary:x.getContrastText(te))),M(x.SpeedDialAction,"fabHoverBg",To(x.background.paper,.15)),M(x.StepConnector,"border",R("palette-grey-400")),M(x.StepContent,"border",R("palette-grey-400")),M(x.Switch,"defaultColor",R("palette-common-white")),M(x.Switch,"defaultDisabledColor",R("palette-grey-100")),M(x.Switch,"primaryDisabledColor",P(we,x.primary.main,.62)),M(x.Switch,"secondaryDisabledColor",P(we,x.secondary.main,.62)),M(x.Switch,"errorDisabledColor",P(we,x.error.main,.62)),M(x.Switch,"infoDisabledColor",P(we,x.info.main,.62)),M(x.Switch,"successDisabledColor",P(we,x.success.main,.62)),M(x.Switch,"warningDisabledColor",P(we,x.warning.main,.62)),M(x.TableCell,"border",P(we,P(yr,x.divider,1),.88)),M(x.Tooltip,"bg",P(yr,x.grey[700],.92))}if(x.mode==="dark"){M(x.Alert,"errorColor",P(we,x.error.light,.6)),M(x.Alert,"infoColor",P(we,x.info.light,.6)),M(x.Alert,"successColor",P(we,x.success.light,.6)),M(x.Alert,"warningColor",P(we,x.warning.light,.6)),M(x.Alert,"errorFilledBg",R("palette-error-dark")),M(x.Alert,"infoFilledBg",R("palette-info-dark")),M(x.Alert,"successFilledBg",R("palette-success-dark")),M(x.Alert,"warningFilledBg",R("palette-warning-dark")),M(x.Alert,"errorFilledColor",Dt(()=>x.getContrastText(x.error.dark))),M(x.Alert,"infoFilledColor",Dt(()=>x.getContrastText(x.info.dark))),M(x.Alert,"successFilledColor",Dt(()=>x.getContrastText(x.success.dark))),M(x.Alert,"warningFilledColor",Dt(()=>x.getContrastText(x.warning.dark))),M(x.Alert,"errorStandardBg",P(je,x.error.light,.9)),M(x.Alert,"infoStandardBg",P(je,x.info.light,.9)),M(x.Alert,"successStandardBg",P(je,x.success.light,.9)),M(x.Alert,"warningStandardBg",P(je,x.warning.light,.9)),M(x.Alert,"errorIconColor",R("palette-error-main")),M(x.Alert,"infoIconColor",R("palette-info-main")),M(x.Alert,"successIconColor",R("palette-success-main")),M(x.Alert,"warningIconColor",R("palette-warning-main")),M(x.AppBar,"defaultBg",R("palette-grey-900")),M(x.AppBar,"darkBg",R("palette-background-paper")),M(x.AppBar,"darkColor",R("palette-text-primary")),M(x.Avatar,"defaultBg",R("palette-grey-600")),M(x.Button,"inheritContainedBg",R("palette-grey-800")),M(x.Button,"inheritContainedHoverBg",R("palette-grey-700")),M(x.Chip,"defaultBorder",R("palette-grey-700")),M(x.Chip,"defaultAvatarColor",R("palette-grey-300")),M(x.Chip,"defaultIconColor",R("palette-grey-300")),M(x.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),M(x.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),M(x.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),M(x.LinearProgress,"primaryBg",P(je,x.primary.main,.5)),M(x.LinearProgress,"secondaryBg",P(je,x.secondary.main,.5)),M(x.LinearProgress,"errorBg",P(je,x.error.main,.5)),M(x.LinearProgress,"infoBg",P(je,x.info.main,.5)),M(x.LinearProgress,"successBg",P(je,x.success.main,.5)),M(x.LinearProgress,"warningBg",P(je,x.warning.main,.5)),M(x.Skeleton,"bg",S?P(yr,x.text.primary,.13):`rgba(${R("palette-text-primaryChannel")} / 0.13)`),M(x.Slider,"primaryTrack",P(je,x.primary.main,.5)),M(x.Slider,"secondaryTrack",P(je,x.secondary.main,.5)),M(x.Slider,"errorTrack",P(je,x.error.main,.5)),M(x.Slider,"infoTrack",P(je,x.info.main,.5)),M(x.Slider,"successTrack",P(je,x.success.main,.5)),M(x.Slider,"warningTrack",P(je,x.warning.main,.5));const te=S?P(we,x.background.default,.985):To(x.background.default,.98);M(x.SnackbarContent,"bg",te),M(x.SnackbarContent,"color",Dt(()=>S?Is.text.primary:x.getContrastText(te))),M(x.SpeedDialAction,"fabHoverBg",To(x.background.paper,.15)),M(x.StepConnector,"border",R("palette-grey-600")),M(x.StepContent,"border",R("palette-grey-600")),M(x.Switch,"defaultColor",R("palette-grey-300")),M(x.Switch,"defaultDisabledColor",R("palette-grey-600")),M(x.Switch,"primaryDisabledColor",P(je,x.primary.main,.55)),M(x.Switch,"secondaryDisabledColor",P(je,x.secondary.main,.55)),M(x.Switch,"errorDisabledColor",P(je,x.error.main,.55)),M(x.Switch,"infoDisabledColor",P(je,x.info.main,.55)),M(x.Switch,"successDisabledColor",P(je,x.success.main,.55)),M(x.Switch,"warningDisabledColor",P(je,x.warning.main,.55)),M(x.TableCell,"border",P(je,P(yr,x.divider,1),.68)),M(x.Tooltip,"bg",P(yr,x.grey[700],.92))}Ft(x.background,"default"),Ft(x.background,"paper"),Ft(x.common,"background"),Ft(x.common,"onBackground"),Ft(x,"divider"),Object.keys(x).forEach(te=>{const ae=x[te];te!=="tonalOffset"&&ae&&typeof ae=="object"&&(ae.main&&M(x[te],"mainChannel",so(ao(ae.main))),ae.light&&M(x[te],"lightChannel",so(ao(ae.light))),ae.dark&&M(x[te],"darkChannel",so(ao(ae.dark))),ae.contrastText&&M(x[te],"contrastTextChannel",so(ao(ae.contrastText))),te==="text"&&(Ft(x[te],"primary"),Ft(x[te],"secondary")),te==="action"&&(ae.active&&Ft(x[te],"active"),ae.selected&&Ft(x[te],"selected")))})}),N=r.reduce((ee,x)=>tt(ee,x),N);const a={prefix:l,disableCssColorScheme:s,shouldSkipGeneratingVar:c,getSelector:Dd(N),enableContrastVars:d},{vars:A,generateThemeVars:F,generateStyleSheets:J}=ed(N,a);return N.vars=A,Object.entries(N.colorSchemes[N.defaultColorScheme]).forEach(([ee,x])=>{N[ee]=x}),N.generateThemeVars=F,N.generateStyleSheets=J,N.generateSpacing=function(){return ws(g.spacing,Yn(this))},N.getColorSchemeSelector=td(u),N.spacing=N.generateSpacing(),N.shouldSkipGeneratingVar=c,N.unstable_sxConfig={...en,...g==null?void 0:g.unstable_sxConfig},N.unstable_sx=function(x){return tn({sx:x,theme:this})},N.toRuntimeSource=Es,N}function Fi(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:Kn({...n===!0?{}:n.palette,mode:r})})}function Md(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:l=n==null?void 0:n.mode,...d}=e,c=l||"light",u=s==null?void 0:s[c],h={...s,...n?{[c]:{...typeof u!="boolean"&&u,palette:n}}:void 0};if(i===!1){if(!("colorSchemes"in e))return An(e,...r);let g=n;"palette"in e||h[c]&&(h[c]!==!0?g=h[c].palette:c==="dark"&&(g={mode:"dark"}));const f=An({...e,palette:g},...r);return f.defaultColorScheme=c,f.colorSchemes=h,f.palette.mode==="light"&&(f.colorSchemes.light={...h.light!==!0&&h.light,palette:f.palette},Fi(f,"dark",h.dark)),f.palette.mode==="dark"&&(f.colorSchemes.dark={...h.dark!==!0&&h.dark,palette:f.palette},Fi(f,"light",h.light)),f}return!n&&!("light"in h)&&c==="light"&&(h.light=!0),Ad({...d,colorSchemes:h,defaultColorScheme:c,...typeof i!="boolean"&&i},...r)}const Rd=Md();function rt(){const e=Fc(Rd);return process.env.NODE_ENV!=="production"&&Fo.useDebugValue(e),e[Dl]||e}async function Wd(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,l=setTimeout(()=>s.abort(),3e4);let d;try{d=await fetch(e,{headers:i,signal:s.signal})}catch(h){throw clearTimeout(l),(h==null?void 0:h.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(l)}if(d.status===401)throw new Error("Authentication failed (401) — check your API key");if(!d.ok)throw new Error(`API error ${d.status}: ${d.statusText}`);let c;try{c=await d.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(c))u=c;else if(n&&c[n]&&Array.isArray(c[n]))u=c[n];else{const g=["data","results","items","records"].find(f=>c[f]&&Array.isArray(c[f]));if(g)u=c[g];else throw new Error("API response must be a JSON array, or specify the data path key.")}return{data:u,source:e,fetchedAt:new Date().toISOString()}}function Pd(e,r){return r.map(n=>`${n.x}px ${n.y}px ${n.blur}px ${n.spread}px ${B(e.palette.common.black,n.opacity)}`).join(", ")}const Nd={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 ce(e,r){return Pd(e,Nd[r])}function Ue(e){return`${Number(e.shape.borderRadius)*1.5}px`}function fo(e){return`${Number(e.shape.borderRadius)}px`}function Ld({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[l,d]=p.useState(""),[c,u]=p.useState(!1),[h,g]=p.useState(""),[f,b]=p.useState(null),[v,T]=p.useState(null),[C,m]=p.useState(!1),[j,y]=p.useState(""),$=p.useRef(null),[S,I]=p.useState("json"),[N,a]=p.useState(""),[A,F]=p.useState(""),[J,ee]=p.useState(""),[x,R]=p.useState("idle"),[P,te]=p.useState(""),[ae,Q]=p.useState(null),[re,he]=p.useState(0),L=async D=>{if(y(""),!D.name.endsWith(".json")){y("Only .json files are allowed");return}const Z=10*1024*1024;if(D.size>Z){y("File size exceeds 10MB limit");return}try{const de=await D.text();let oe;try{oe=JSON.parse(de)}catch{y("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(oe)){y("JSON must be an array of objects");return}if(oe.length===0){y("No data rows found in JSON file");return}b(D),T(oe)}catch{y("Network error — please try again")}},K=D=>{D.preventDefault();const Z=D.dataTransfer.files[0];Z&&L(Z)},ne=async()=>{if(N.trim()){R("loading"),te("");try{const D=await Wd(N.trim(),A.trim()||void 0,J.trim()||void 0);Q(D.data),he(D.data.length),R("ready")}catch(D){te((D==null?void 0:D.message)||"Connection failed"),R("error")}}},le=()=>{if(!l.trim()){u(!0);return}const D=S==="api"?ae:i||v;D&&(n(l.trim(),h.trim(),D),U())},U=()=>{d(""),u(!1),g(""),b(null),T(null),y(""),I("json"),a(""),F(""),ee(""),R("idle"),te(""),Q(null),he(0),r()},se=i||v,ie=c&&!l.trim();return l.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:U,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:D=>Ue(D),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:D=>ce(D,"menu")}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2.5,fontWeight:500,fontSize:"1.125rem",color:"text.primary",letterSpacing:"-0.01em",borderBottom:"1px solid",borderColor:"divider"},children:["Create new report",t.jsx(o.IconButton,{onClick:U,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(z.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:l,onChange:D=>{d(D.target.value),c&&D.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:h,onChange:D=>g(D.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:S==="json"?0:1,onChange:(D,Z)=>{I(Z===0?"json":"api"),R("idle"),te("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40},children:[t.jsx(o.Tab,{label:"Upload JSON",icon:t.jsx(z.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}}),t.jsx(o.Tab,{label:"Connect API",icon:t.jsx(z.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5}})]}),S==="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:D=>B(D.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:D=>B(D.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(z.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(z.Info,{sx:{fontSize:16}})})]}),t.jsxs(o.Box,{onDrop:K,onDragOver:D=>D.preventDefault(),onPaste:D=>D.preventDefault(),onClick:()=>{var D;return(D=$.current)==null?void 0:D.click()},sx:{position:"relative",border:"1.5px",borderStyle:v?"solid":"dashed",borderColor:v?"success.main":j?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:v?D=>B(D.palette.success.main,.04):j?D=>B(D.palette.error.main,.04):D=>B(D.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:v?D=>B(D.palette.success.main,.08):j?D=>B(D.palette.error.main,.08):D=>B(D.palette.primary.main,.08),borderColor:v?"success.dark":j?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:$,type:"file",accept:".json",sx:{display:"none"},onChange:D=>{var Z;return((Z=D.target.files)==null?void 0:Z[0])&&L(D.target.files[0])}}),v?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:D=>B(D.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx(z.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:D=>B(D.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx(z.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:D=>B(D.palette.error.main,.08),border:1,borderColor:D=>B(D.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:j})})]})]})]})}),S==="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:N,onChange:D=>{a(D.target.value),R("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:A,onChange:D=>F(D.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",children:t.jsx(z.Lock,{sx:{fontSize:16,color:"text.secondary"}})})},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(o.TextField,{label:"Response data path (optional)",fullWidth:!0,size:"small",value:J,onChange:D=>ee(D.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:!N.trim()||x==="loading",onClick:ne,startIcon:x==="loading"?t.jsx(o.CircularProgress,{size:16,color:"inherit"}):t.jsx(z.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:D=>B(D.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:x==="loading"?"Connecting...":"Test Connection & Load Data"}),x==="ready"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:D=>B(D.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(z.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:N})]})]}),x==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:D=>B(D.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(z.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:P})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:U,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:D=>`${D.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:D=>B(D.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:le,disabled:S==="json"&&!se||S==="api"&&x!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:D=>`${D.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:{borderRadius:3,width:560,maxHeight:"80vh",boxShadow:8}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:500,fontSize:"1.25rem",color:"text.primary",letterSpacing:"-0.01em"},children:["JSON format guide",t.jsx(o.IconButton,{onClick:()=>m(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(z.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:`[
70
70
  {
71
71
  "id": 1,
72
72
  "customerName": "John Smith",
@@ -76,7 +76,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
76
76
  "memberSince": "2024-01-15",
77
77
  "status": "active"
78
78
  }
79
- ]`})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:2},children:t.jsx(o.Button,{onClick:()=>y(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:O=>`${O.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Ss({isOpen:e,onClose:r}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:n=>Ne(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:n=>se(n,"menu"),display:"flex",flexDirection:"column"}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["JSON Format Guide",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx(T.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",t.jsx("strong",{children:"array of objects"}),". Each object represents a single row in your report, and the keys of each object become the column names."]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(o.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
79
+ ]`})]}),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:D=>`${D.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function Os({isOpen:e,onClose:r}){return e?t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:n=>Ue(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:n=>ce(n,"menu"),display:"flex",flexDirection:"column"}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["JSON Format Guide",t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary"},children:t.jsx(z.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{dividers:!0,sx:{overflowY:"auto",flex:1},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["The uploaded JSON must be an ",t.jsx("strong",{children:"array of objects"}),". Each object represents a single row in your report, and the keys of each object become the column names."]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(o.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
80
80
  {
81
81
  "Active Sessions": 33,
82
82
  "Active State": true,
@@ -86,10 +86,10 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
86
86
  "Region": "Europe",
87
87
  "Subscription Type": "Basic"
88
88
  }
89
- ]`})})]}),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:500,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:500,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:500,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:500,minWidth:80},children:"Date:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[t.jsx("li",{children:"Each object in the array represents one row in the report."}),t.jsx("li",{children:"The keys of the JSON objects become report columns."}),t.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),t.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:n=>`${n.shape.borderRadius}px`,boxShadow:n=>se(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>se(n,"hoverButton")},"&:active":{boxShadow:n=>se(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function Nd({onFileUpload:e,onError:r,isUploading:n}){const[i,s]=p.useState(!1),[l,d]=p.useState(""),[c,u]=p.useState(!1),m=p.useRef(null),f=async w=>{if(!w.name.endsWith(".json")){r("Only .json files are allowed");return}const C=10*1024*1024;if(w.size>C){r("File size exceeds 10MB limit");return}d(w.name);try{const E=await w.text();let g;try{g=JSON.parse(E)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(g)){r("JSON must be an array of objects");return}if(g.length===0){r("No data rows found in JSON file");return}e(g)}catch{r("Network error — please try again")}finally{d("")}},x=w=>{w.preventDefault(),s(!0)},v=w=>{w.preventDefault(),s(!1)},b=w=>{w.preventDefault(),s(!1);const C=w.dataTransfer.files[0];C&&f(C)},z=()=>{var w;(w=m.current)==null||w.click()},S=w=>{var E;const C=(E=w.target.files)==null?void 0:E[0];C&&f(C)},y=w=>{w.stopPropagation(),u(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:x,onDragLeave:v,onDrop:b,onPaste:w=>w.preventDefault(),onClick:z,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?w=>D(w.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:m,type:"file",accept:".json",onChange:S,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:500,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:w=>D(w.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(T.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[t.jsx(o.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),t.jsx(o.IconButton,{onClick:y,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx(T.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(Ss,{isOpen:c,onClose:()=>u(!1)})]})}function Ld({schema:e,onConfirm:r,hasConflicts:n}){return t.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[t.jsxs(o.Box,{sx:{mb:2},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontWeight:600,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:600},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),t.jsx(o.TableContainer,{sx:{mb:3},children:t.jsxs(o.Table,{children:[t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:"action.hover"},children:[t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),t.jsx(o.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),t.jsx(o.TableBody,{children:e.map(i=>t.jsxs(o.TableRow,{sx:{bgcolor:i.hasConflict?s=>D(s.palette.warning.main,.12):"transparent"},children:[t.jsxs(o.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&t.jsx(o.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),t.jsx(o.TableCell,{children:t.jsx(o.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(T.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 Fd({error:e,onRetry:r}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:n=>D(n.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:n=>D(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(T.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:600,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(T.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function Cs({title:e,description:r,showIcon:n=!0}){return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[n&&t.jsx(o.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>D(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx(T.Description,{sx:{fontSize:36,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:500,mb:1,color:"text.primary",fontSize:"1.125rem"},children:e}),t.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:"0.875rem",lineHeight:1.5},children:r})]})}function Vd({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:l,disabled:d}){const[c,u]=p.useState(!1),[m,f]=p.useState(!1),[x,v]=p.useState(-1),b=p.useRef(null),z=p.useRef(null);p.useEffect(()=>{function _(F){b.current&&!b.current.contains(F.target)&&(u(!1),f(!1))}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[]);const S=p.useCallback(()=>{f(!0),v(-1),n.length>0&&u(!0)},[n.length]),y=p.useCallback(_=>{r(_),v(-1)},[r]),w=p.useCallback(_=>{var F;r(_),i(_),u(!1),(F=z.current)==null||F.blur()},[r,i]),C=p.useCallback(_=>{v(-1),w(_)},[w]),E=p.useCallback(_=>{var F;_.key==="Enter"?x>=0&&x<n.length?(_.preventDefault(),C(n[x].query)):e.trim()&&w(e.trim()):_.key==="Escape"?(u(!1),v(-1),(F=z.current)==null||F.blur()):_.key==="ArrowDown"?(_.preventDefault(),n.length>0&&(c||u(!0),v(X=>X<n.length-1?X+1:X))):_.key==="ArrowUp"&&(_.preventDefault(),v(X=>X>0?X-1:-1))},[x,n,e,c,C,w]),g=p.useCallback(()=>{var _;r(""),(_=z.current)==null||_.focus()},[r]),k=p.useMemo(()=>n.filter(_=>_.isFavourite),[n]),L=p.useMemo(()=>n.filter(_=>!_.isFavourite),[n]),a=c&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:b,children:[t.jsx(o.TextField,{inputRef:z,size:"small",fullWidth:!0,value:e,onChange:_=>y(_.target.value),onFocus:S,onKeyDown:E,placeholder:"Search data...",disabled:d,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:_=>D(_.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:_=>D(_.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(T.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:g,edge:"end",sx:{mr:-.5},children:t.jsx(T.Close,{sx:{fontSize:16}})})}):null}}),a&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[k.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),k.map((_,F)=>t.jsx(Ai,{entry:_,isSelected:x===F,onClick:()=>C(_.query),onToggleFavourite:()=>s(_.query),onDelete:()=>l(_.query)},`fav-${_.query}`))]}),L.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[k.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),L.map((_,F)=>{const X=k.length+F;return t.jsx(Ai,{entry:_,isSelected:x===X,onClick:()=>C(_.query),onToggleFavourite:()=>s(_.query),onDelete:()=>l(_.query)},`recent-${_.query}`)})]})]})]})}const Ai=p.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:l}){const d=p.useCallback(u=>{u.stopPropagation(),s()},[s]),c=p.useCallback(u=>{u.stopPropagation(),l()},[l]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>D(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>D(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(o.IconButton,{size:"small",onClick:d,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?t.jsx(T.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx(T.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(o.IconButton,{size:"small",onClick:c,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(T.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function Hd({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:l,onToggleFavorite:d,onRestoreView:c,onPermanentDelete:u,onEditView:m,onCloneView:f,onCopyLink:x,onDeleteView:v,onPromoteToGlobal:b,isReadOnly:z,isAdmin:S=!1}){const y=Lt(),[w,C]=p.useState(!1),[E,g]=p.useState(!1),[k,L]=p.useState({top:0,left:0}),[a,_]=p.useState(null),[F,X]=p.useState(null),re=p.useRef(null),h=p.useRef(null),V=e.find(O=>O.id===r),W=V==null?void 0:V.isDefault,Q=(O,te)=>O.name.localeCompare(te.name),Z=e.filter(O=>O.scope==="global"&&!O.isDeleted).sort(Q),pe=e.filter(O=>O.scope!=="global"&&!O.isDeleted).sort(Q),he=e.filter(O=>O.isFavorite&&!O.isDeleted).sort(Q),N=e.filter(O=>O.isDeleted);p.useEffect(()=>{if(w&&h.current){const O=h.current.getBoundingClientRect();L({top:O.bottom+window.scrollY+8,left:O.right+window.scrollX-320})}},[w]),p.useEffect(()=>{const O=te=>{re.current&&!re.current.contains(te.target)&&h.current&&!h.current.contains(te.target)&&C(!1)};return w&&document.addEventListener("mousedown",O),()=>{document.removeEventListener("mousedown",O)}},[w]);const R=O=>{if(n&&O!==r){_(O),C(!1);return}i(O),C(!1)},H=()=>{a&&(i(a),_(null))},G=()=>{_(null)},ae=(O,te=!1)=>{const ce=O.scope==="global",ie=!z&&(!ce||S),Ie=S&&!ce;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===O.id?D(y.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===O.id?D(y.palette.primary.main,.12):y.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>R(O.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===O.id&&t.jsx(T.Check,{sx:{fontSize:16,flexShrink:0}}),r!==O.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===O.id?y.palette.primary.dark:y.palette.text.primary,fontWeight:r===O.id?500:400},children:O.name}),te&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:y.palette.text.secondary,backgroundColor:y.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[ie&&d&&t.jsx(o.IconButton,{onClick:q=>{q.stopPropagation(),d(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:O.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(T.Star,{sx:{fontSize:16}})}),ie&&l&&!O.isDefault&&t.jsx(o.IconButton,{onClick:q=>{q.stopPropagation(),l(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Set as default",children:t.jsx(T.RadioButtonUnchecked,{sx:{fontSize:16}})}),(ie||Ie)&&(m||f||x||v||Ie&&b)&&t.jsx(o.IconButton,{onClick:q=>{q.stopPropagation(),X({el:q.currentTarget,view:O})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"More actions",children:t.jsx(T.MoreVert,{sx:{fontSize:16}})})]})]},O.id)},ee=O=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:y.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:y.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:O.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[c&&t.jsx(o.IconButton,{onClick:te=>{te.stopPropagation(),c(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Restore view",children:t.jsx(T.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(o.IconButton,{onClick:te=>{te.stopPropagation(),u(O.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},title:"Delete permanently",children:t.jsx(T.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},O.id),ne=n||!W,oe=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:h,onClick:()=>C(!w),variant:"outlined",size:"small",endIcon:t.jsx(T.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:ne?"warning.main":"text.primary",borderColor:ne?"warning.main":"divider",bgcolor:ne?D(y.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:ne?"warning.dark":"primary.main",bgcolor:ne?D(y.palette.warning.main,.2):D(y.palette.text.primary,.06),color:ne?"warning.dark":"text.primary"}},title:`View: ${(V==null?void 0:V.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(V==null?void 0:V.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"}})]}),w&&Vi.createPortal(t.jsxs(o.Box,{ref:re,sx:{position:"fixed",width:"320px",backgroundColor:y.palette.background.paper,border:`1px solid ${y.palette.divider}`,borderRadius:1,boxShadow:y.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:k.top,left:k.left},children:[Z.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),Z.map(O=>ae(O,O.isDefault))]}),he.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx(T.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),he.map(O=>ae(O))]})]}),pe.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),pe.map(O=>ae(O))]})]}),N.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>g(!E),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:y.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",N.length,")"]}),t.jsx(T.ChevronRight,{sx:{fontSize:16}})]}),E&&t.jsx(o.Box,{sx:{backgroundColor:y.palette.action.hover},children:N.map(O=>ee(O))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${y.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),C(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:y.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:y.palette.action.hover}},children:[t.jsx(T.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!F,anchorEl:(F==null?void 0:F.el)||null,onClose:()=>X(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[m&&t.jsxs(o.MenuItem,{onClick:()=>{F&&m(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(T.Edit,{sx:{fontSize:18}}),"Edit"]}),x&&t.jsxs(o.MenuItem,{onClick:()=>{F&&x(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(T.Link,{sx:{fontSize:18}}),"Copy Link"]}),f&&t.jsxs(o.MenuItem,{onClick:()=>{F&&f(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(T.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),b&&S&&(F==null?void 0:F.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{F&&b(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(T.Language,{sx:{fontSize:18}}),"Promote to Global"]}),v&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{F&&v(F.view.id),X(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx(T.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:a!==null,onClose:G,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:oo(y)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[t.jsx(T.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:G,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:H,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function Ud({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:l=!1,hasModifications:d=!1,position:c,onSortAscending:u,onSortDescending:m,onRemoveSort:f,onFilter:x,onClearFilter:v,onGroupByColumn:b,onHideColumn:z,onManageColumns:S,onResetLayout:y,onClose:w}){var X,re;const C=Lt(),E=C.palette,g=p.useRef(null);p.useEffect(()=>{if(!g.current)return;const h=g.current,V=h.getBoundingClientRect(),W=window.innerWidth,Q=window.innerHeight;V.right>W-8&&(h.style.left=`${W-V.width-8}px`),V.bottom>Q-8&&(h.style.top=`${Q-V.height-8}px`)},[c]),p.useEffect(()=>{const h=W=>{g.current&&!g.current.contains(W.target)&&w()},V=W=>{W.key==="Escape"&&w()};return document.addEventListener("mousedown",h),document.addEventListener("keydown",V),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",V)}},[w]);const k=p.useCallback(h=>()=>{h(),w()},[w]),L=(n==null?void 0:n.direction)==="asc",a=(n==null?void 0:n.direction)==="desc",_=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",F=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return Vi.createPortal(t.jsxs(o.Paper,{ref:g,elevation:0,sx:{position:"fixed",left:`${c.x}px`,top:`${c.y}px`,zIndex:C.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:oo(C),overflow:"hidden",boxShadow:`0 4px 20px ${D(((X=E.common)==null?void 0:X.black)??"#000",.12)}, 0 1px 4px ${D(((re=E.common)==null?void 0:re.black)??"#000",.06)}`},children:[!l&&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:"0.8125rem",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 (${_})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:k(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:L?"primary.main":"text.secondary",bgcolor:L?D(E.primary.main,.1):"transparent","&:hover":{bgcolor:D(E.primary.main,.08),color:"primary.main"}},children:t.jsx(T.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${F})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:k(()=>m(e)),sx:{p:.625,borderRadius:"6px",color:a?"primary.main":"text.secondary",bgcolor:a?D(E.primary.main,.1):"transparent","&:hover":{bgcolor:D(E.primary.main,.08),color:"primary.main"}},children:t.jsx(T.ArrowDownward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:t.jsx("span",{children:t.jsx(o.IconButton,{size:"small",disabled:!s,onClick:k(()=>f(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:D(E.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx(T.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:k(()=>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(T.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&&!l&&t.jsxs(o.MenuItem,{onClick:k(()=>v(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:D(E.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(T.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!l&&b&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.25}}),t.jsx(o.MenuList,{dense:!0,sx:{py:.5},children:t.jsxs(o.MenuItem,{onClick:k(()=>b(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(T.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:[!l&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsxs(o.MenuItem,{onClick:k(()=>z(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(T.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),t.jsx(o.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:k(S),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:D(E.primary.main,.08),color:"primary.main"}},children:t.jsx(T.Settings,{sx:{fontSize:16}})})})]}),l&&t.jsxs(o.MenuItem,{onClick:k(S),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(T.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!l&&d&&y&&t.jsxs(o.MenuItem,{onClick:k(y),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:D(E.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(T.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const Gd=176,_i="COLUMN_HEADER",Yd=p.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:l,isReadOnly:d=!1,hasModifications:c=!1,width:u,onColumnClick:m,onMoveColumn:f,onColumnDragEnd:x,onResizeStart:v,onSortAscending:b,onSortDescending:z,onRemoveSort:S,onOpenFilterForColumn:y,onClearFiltersForColumn:w,onGroupByColumn:C,onHideColumn:E,onManageColumns:g,onResetLayout:k}){const L=p.useRef(null),[a,_]=p.useState(!1),[F,X]=p.useState({x:0,y:0}),[{handlerId:re,isOver:h},V]=Pt.useDrop({accept:_i,collect(G){return{handlerId:G.getHandlerId(),isOver:G.isOver()}},hover(G,ae){var ie;if(!L.current)return;const ee=G.index,ne=n;if(ee===ne)return;const oe=(ie=L.current)==null?void 0:ie.getBoundingClientRect(),O=(oe.right-oe.left)/2,te=ae.getClientOffset(),ce=((te==null?void 0:te.x)??0)-oe.left;ee<ne&&ce<O||ee>ne&&ce>O||(f(ee,ne),G.index=ne)}}),[{isDragging:W},Q]=Pt.useDrag({type:_i,item:()=>({index:n,columnName:r.name}),collect:G=>({isDragging:G.isDragging()}),end:()=>{x==null||x()}});Q(V(L));const Z=p.useCallback(G=>{G.preventDefault(),G.stopPropagation(),X({x:G.clientX,y:G.clientY}),_(!0)},[]),pe=p.useCallback(()=>_(!1),[]),he=p.useCallback(()=>{m(r.name)},[m,r.name]),N=p.useCallback(G=>{G.stopPropagation(),y(r.name)},[y,r.name]),R=p.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx(T.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):t.jsx(T.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]),H=p.useCallback(()=>s?t.jsx(T.FilterList,{onClick:N,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,N]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:L,"data-handler-id":re,"data-column-index":n,onClick:he,onContextMenu:Z,sx:{position:"sticky",top:0,zIndex:5,textAlign:"left",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:W?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:h?G=>D(G.palette.primary.main,.08):"action.hover",boxShadow:G=>`0 1px 0 ${D(G.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:"1px solid",borderColor:"divider",py:0,px:2,height:34,"&:hover":{bgcolor:G=>D(G.palette.primary.main,.1),color:"primary.dark"},width:u?`${u}px`:`${Gd}px`},children:[t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[Qe(r.name),R(),H()]}),t.jsx(o.Box,{draggable:!1,onDragStart:G=>G.preventDefault(),sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center","&:hover > div":{opacity:1}},onMouseDown:G=>{G.preventDefault(),G.stopPropagation(),v(G,r.name)},onClick:G=>G.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"}})}),h&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),a&&t.jsx(Ud,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:l,isReadOnly:d,hasModifications:c,position:F,onSortAscending:b,onSortDescending:z,onRemoveSort:S,onFilter:y,onClearFilter:w,onGroupByColumn:C,onHideColumn:E,onManageColumns:g,onResetLayout:k,onClose:pe})]})}),qd={active:"success",completed:"success",approved:"success",success:"success",done:"success",contract:"info","in progress":"info","in review":"info",review:"info",pending:"info","on leave":"error","on hold":"warning",probation:"warning",cancelled:"error",rejected:"error",blocked:"error",inactive:"neutral","not started":"neutral",paused:"neutral"};function Bo(e,r){const n=qd[r.toLowerCase().trim()];if(!n||n==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.palette[n];return{bg:D(i.main,e.palette.mode==="dark"?.24:.12),color:e.palette.mode==="dark"?i.light:i.dark}}function Jd(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.warning.dark;case"critical":case"urgent":return e.palette.error.main;default:return}}const Kd={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"}};function Xd(e,r){const n=Kd[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function qe(e){return D(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function Qd(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:500,bgcolor:n=>Bo(n,r).bg,color:n=>Bo(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function Zd(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 Qd(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:l=>{const d=Jd(l,s);return d?{color:d,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:n})}return typeof r=="boolean"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:n})}function eu(e){const r=e.find(s=>{const l=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(l)})||e[0]||null,n=e.find(s=>{const l=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(l)&&s!==r})||null,i=e.filter(s=>s!==r&&s!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function tu({row:e,rowIndex:r,visibleColumns:n,isSelected:i,isReadOnly:s,onToggleSelection:l,onView:d,onEdit:c,onDuplicate:u,onDelete:m}){const[f,x]=p.useState(null),[v,b]=p.useState(!1),{primaryCol:z,idCol:S,bodyColumns:y}=p.useMemo(()=>eu(n),[n]),w=z?e[z.name]:null,C=S?e[S.name]:null,E=v||i||!!f;return t.jsxs(o.Box,{onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),onClick:()=>l(r),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":g=>D(g.palette.divider,.8),borderWidth:i?2:1,borderRadius:"12px",cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?g=>`0 0 0 3px ${D(g.palette.primary.main,.15)}, 0 2px 8px ${D(g.palette.common.black,.08)}`:v?g=>se(g,"cardHover"):g=>se(g,"cardRest"),transform:v&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:g=>D(g.palette.primary.main,.03)}},children:[t.jsx(o.Box,{sx:{px:2,pt:2,pb:1.5},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,fontSize:"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:w!=null&&w!==""?String(w):t.jsx(o.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})}),t.jsx(o.Box,{sx:{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:[y.map(g=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:500,fontSize:"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:Qe(g.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[g.name]??""),children:Zd(g,e[g.name])})]},g.name)),y.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:g=>D(g.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:C?.85:0,userSelect:"none"},children:C?String(C):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:E?1:0,transition:"opacity 0.15s ease"},onClick:g=>g.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:g=>{g.stopPropagation(),x(g.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:g=>D(g.palette.text.primary,.08)}},children:t.jsx(T.MoreVert,{sx:{fontSize:17}})})})})]}),t.jsxs(o.Popover,{open:!!f,anchorEl:f,onClose:()=>x(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:g=>se(g,"popover")}},onClick:g=>g.stopPropagation(),children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{d(e),x(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[t.jsx(T.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!s&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{c(e,r),x(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[t.jsx(T.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!s&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{u(r,e),x(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[t.jsx(T.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),!s&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5,mx:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{m(r,e),x(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[t.jsx(T.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function ru({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=>se(s,"flatHover"),"&:hover":{bgcolor:s=>D(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx(T.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx(T.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:Ki(e.groupLevel,((i=r==null?void 0:r.levels[e.groupLevel])==null?void 0:i.column)||"",e.groupValue)}),t.jsxs(o.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>D(s.palette.primary.main,.1),color:"primary.main",borderRadius:"10px"},children:[e.rowCount," ",e.rowCount===1?"row":"rows"]}),Object.keys(e.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(e.aggregates).map(([s,l])=>Ji(l)).filter(Boolean).join(" • ")})]})}function ou({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isReadOnly:s,isGrouped:l,onToggleRowSelection:d,onToggleGroupCollapse:c,onViewRow:u,onEditRow:m,onDuplicateRow:f,onDeleteRow:x}){const v=p.useMemo(()=>{const b=new Set;return i.forEach(z=>{const S=z==null?void 0:z.__urm_row_id__;S!==void 0&&b.add(S)}),b},[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:b=>b.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:1.5,alignContent:"start"},children:e.map((b,z)=>l&&b.isGroupHeader?t.jsx(ru,{row:b,grouping:n,onToggleCollapse:c||(()=>{})},`group-${b.groupKey}`):t.jsx(tu,{row:b,rowIndex:z,visibleColumns:r,isSelected:v.has(b==null?void 0:b.__urm_row_id__),isReadOnly:s,onToggleSelection:()=>d(b),onView:u,onEdit:m,onDuplicate:f,onDelete:x},`card-${z}`))})})}const Mi=[10,15,25,50,100];function nu(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 iu({currentPage:e,pageSize:r,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:l}){var V;const c=Lt().palette,u=Math.ceil(n/r),[m,f]=p.useState(String(e)),[x,v]=p.useState(null),[b,z]=p.useState(!1),S=p.useRef(null);p.useEffect(()=>{b||(f(String(e)),v(null))},[e,b]);const y=p.useCallback(()=>{const W=nu(m,u);if(W){v(W);return}const Q=parseInt(m.trim(),10);v(null),z(!1),Q!==e&&s(Q)},[m,u,e,s]),w=p.useCallback(W=>{var Q;W.key==="Enter"?(W.preventDefault(),y()):W.key==="Escape"&&(f(String(e)),v(null),z(!1),(Q=S.current)==null||Q.blur())},[y,e]),C=p.useCallback(()=>{f(String(e)),v(null),z(!1)},[e]),E=p.useCallback(()=>{z(!0),v(null),setTimeout(()=>{var W;return(W=S.current)==null?void 0:W.select()},0)},[]);if(n<=Math.min(...Mi))return null;const g=()=>{f(String(e)),v(null),z(!1)},k=()=>{g(),s(1)},L=()=>{g(),e>1&&s(e-1)},a=()=>{g(),e<u&&s(e+1)},_=()=>{g(),s(u)},F=(e-1)*r+1,X=Math.min(e*r,n),re=`${Math.max(2,String(u).length+.5)}ch`,h={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:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:W=>l(Number(W.target.value)),size:"small",MenuProps:{PaperProps:{sx:{maxHeight:300}},anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"bottom",horizontal:"left"}},sx:{minWidth:70,fontSize:"0.8125rem",color:"text.primary","& .MuiSelect-select":{py:.5,px:1.5},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},children:Mi.map(W=>t.jsx(o.MenuItem,{value:W,sx:{fontSize:"0.8125rem"},children:W},W))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[F,"–",X," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[x&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:D(c.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${D(((V=c.common)==null?void 0:V.black)??"#000",.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:D(c.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",fontWeight:500,color:"error.main",lineHeight:1.3},children:x})}),t.jsx(o.InputBase,{inputRef:S,value:m,onChange:W=>{f(W.target.value),x&&v(null)},onKeyDown:w,onFocus:E,onBlur:C,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:re,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:x?"error.main":"text.primary",border:"1px solid",borderColor:x?"error.main":b?"primary.main":"divider",borderRadius:"4px",bgcolor:x?D(c.error.main,.04):b?D(c.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:x?"error.main":"text.secondary"},"&:focus-within":{boxShadow:x?`0 0 0 2px ${D(c.error.main,.2)}`:`0 0 0 2px ${D(c.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",u]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:k,disabled:e===1,size:"small",title:"First page",sx:h,children:t.jsx(T.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:L,disabled:e===1,size:"small",title:"Previous page",sx:h,children:t.jsx(T.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:a,disabled:e===u,size:"small",title:"Next page",sx:h,children:t.jsx(T.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:_,disabled:e===u,size:"small",title:"Last page",sx:h,children:t.jsx(T.LastPage,{sx:{fontSize:20}})})]})]})]})}function su(){return t.jsx(o.Chip,{icon:t.jsx(T.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const js="urm_hint_seen_";function au(e){try{return localStorage.getItem(js+e)==="true"}catch{return!1}}function lu(e){try{localStorage.setItem(js+e,"true")}catch{}}const ws={"& .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 In(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 ks({row:e,schema:r}){const i=Lt().palette,s=r.filter(c=>c.name in e),l=s.filter(c=>c.type!=="object"&&c.type!=="array"),d=s.filter(c=>c.type==="object"||c.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[l.map(c=>t.jsx(o.TextField,{label:Qe(c.name),value:In(e[c.name],c.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:ws},c.name)),d.map(c=>{const u=In(e[c.name],c.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:Qe(c.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:D(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color: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"})]},c.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3},children:"No fields to display"})]})}function cu({open:e,onClose:r,row:n,schema:i,reportName:s}){var u,m;const l=Lt(),d=l.palette;if(!n)return null;const c=i.filter(f=>f.name in n).length;return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Ne(l),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${D(((u=d.common)==null?void 0:u.black)??"#000",.14)}, 0 2px 8px ${D(((m=d.common)==null?void 0:m.black)??"#000",.08)}`,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:D(d.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(T.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"View Record"}),s&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",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(T.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:D(d.text.primary,.015)},children:t.jsx(ks,{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:f=>`${f.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function du({open:e,onClose:r,onConfirm:n,row:i,schema:s}){return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:l=>Ne(l),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:l=>se(l,"menu")}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:l=>D(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(T.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsx(o.Typography,{variant:"body2",sx:{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(T.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(ks,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:l=>D(l.palette.error.main,.1),border:l=>`1px solid ${D(l.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"error.main",fontWeight:500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:t.jsx(T.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>se(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>se(l,"hoverButton")},"&:active":{boxShadow:l=>se(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function uu({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:l}){var y,w,C;const d=Lt(),c=d.palette,[u,m]=p.useState({});if(p.useEffect(()=>{e&&i&&m({...i})},[e,i]),!i)return null;const f=s.filter(E=>E.name in i),x=f.filter(E=>E.type!=="object"&&E.type!=="array"),v=f.filter(E=>E.type==="object"||E.type==="array"),b=(E,g)=>{m(k=>({...k,[E]:g}))},z=()=>{const E={...u};f.forEach(g=>{const k=u[g.name];if(g.type==="number"){const L=Number(k);E[g.name]=isNaN(L)?i[g.name]:L}else g.type==="boolean"&&(E[g.name]=!!k)}),n(E),r()},S=f.length;return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Ne(d),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${D(((y=c.common)==null?void 0:y.black)??"#000",.14)}, 0 2px 8px ${D(((w=c.common)==null?void 0:w.black)??"#000",.08)}`,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:D(((C=c.warning)==null?void 0:C.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(T.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),l&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[l," · ",S," ",S===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(T.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:D(c.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[x.map(E=>{const g=u[E.name];return E.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:Qe(E.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!g,onChange:k=>b(E.name,k.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary"},children:g?"Enabled":"Disabled"})]})]},E.name):t.jsx(o.TextField,{label:Qe(E.name),value:g??"",onChange:k=>b(E.name,k.target.value),type:E.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:ws},E.name)}),v.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:v.map(E=>{const g=In(i[E.name],E.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:{fontWeight:500,color:"text.secondary"},children:Qe(E.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:D(c.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(T.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(c.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:g?"text.primary":"text.disabled",fontStyle:g?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:g||"No value"})]},E.name)})}),f.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx(T.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:E=>`${E.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:z,variant:"contained",startIcon:t.jsx(T.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:E=>`${E.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const pu=176,xu=170,mu=40;function Ts(e){return e.type==="date"?180:pu}function fu(e,r){return r!=null&&r!==xu&&r!==Ts(e)}function hu(e,r,n){return p.useMemo(()=>{const i=e.map(x=>({name:x.name,width:r[x.name]??Ts(x),explicit:fu(x,r[x.name])})),s={};i.forEach(x=>{s[x.name]=x.width});const l=i.reduce((x,v)=>x+v.width,0),c=Math.max(0,n-mu)-l;if(c<=0)return{widths:s,fillerWidth:0};const u=i.filter(x=>!x.explicit);if(u.length===0)return{widths:s,fillerWidth:c};const m=u.reduce((x,v)=>x+v.width,0)||1;let f=0;return u.forEach((x,v)=>{const z=v===u.length-1?x.width+c-f:Math.round(x.width+c*x.width/m);s[x.name]=z,f+=z-x.width}),{widths:s,fillerWidth:0}},[e,r,n])}const Ri=176,yn=32,bn=24,gu=St(),yu={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function bu(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:500,bgcolor:n=>Bo(n,r).bg,color:n=>Bo(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function vu(e){const r=e.toLowerCase().trim(),n=yu[r];return n?t.jsx(o.Box,{component:"span",sx:{color:n,fontWeight:500,fontSize:"inherit"},children:e}):e}function Su(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((l,d)=>l.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:l},d):l)}function Cu(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 bu(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return vu(s);if(e.type==="date"){const c=e.dateFormat??"iso",u=ga(r,c,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 c=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:[c,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const c=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:c,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:c.length>40?c.slice(0,40)+"…":c})}return Su(s,i)}function ju({schema:e,data:r,sortStack:n=[],filters:i=gu,views:s=[],activeViewId:l="",isDirty:d=!1,isExporting:c=!1,columnVisibility:u={},columnOrder:m=[],columnWidths:f={},grouping:x=null,onSort:v,onSortAscending:b,onSortDescending:z,onOpenFilters:S,onOpenSort:y,onOpenFilterForColumn:w,onSelectView:C,onCreateView:E,onUpdateCurrentView:g,onSaveAsNewView:k,onDiscardChanges:L,onToggleDefault:a,onToggleFavorite:_,onRestoreView:F,onPermanentDelete:X,onEditView:re,onCloneView:h,onCopyLink:V,onDeleteView:W,onPromoteToGlobal:Q,isAdmin:Z=!1,onExport:pe,onOpenColumns:he,onUpdateColumnWidth:N,onUpdateColumnOrder:R,onUpdateColumnVisibility:H,onClearFiltersForColumn:G,onResetLayout:ae,onOpenGroup:ee,onGroupByColumn:ne,onToggleGroupCollapse:oe,onExpandAllGroups:O,onCollapseAllGroups:te,onOpenAuditHistory:ce,onOpenScheduledReports:ie,searchQuery:Ie,highlightQuery:q="",searchHistory:Me=[],onAddToSearchHistory:et,onToggleSearchFavourite:tt,onDeleteSearchHistory:rr,selectedRowIds:Ft=new Set,onSearchChange:Vt,onToggleRowSelection:rt,onToggleAllRows:pt,onRangeSelection:or,onClearSelection:Ct,onExportSelected:Je,currentPage:jt=1,pageSize:Bt=15,totalRowsBeforePagination:Ht=r.length,onPageChange:nr,onPageSizeChange:ir,isReadOnly:He=!1,userRole:no,reportName:sr,onEditRow:Ut,onDuplicateRow:ot,onDeleteRow:nt,showDevPanel:ar=!1,onOpenDevConfig:lr}){var co;const[wt,wr]=p.useState(null),[xt,Nr]=p.useState(0),[cr,dr]=p.useState(0),[me,kr]=p.useState(null),kt=((co=Sr().dates)==null?void 0:co.displayFormat)??null,[P,mt]=p.useState(null),[fe,Le]=p.useState(null),[Dt,ft]=p.useState(null),[Gt,Tt]=p.useState(!1),[Tr,Yt]=p.useState(!1),[ur,qt]=p.useState(null),[ze,K]=p.useState(!1),[Ot,we]=p.useState(null),[Ir,pr]=p.useState(null),[Se,Fe]=p.useState(null),[xr,it]=p.useState(null),ht=p.useRef(null),Ve=p.useCallback(()=>{ht.current&&(clearTimeout(ht.current),ht.current=null)},[]),mr=p.useCallback(()=>{Ve(),ht.current=setTimeout(()=>it(null),200)},[Ve]);p.useEffect(()=>Ve,[Ve]);const[zr,gt]=p.useState(null),[Ue,Er]=p.useState("list"),[Lr,$t]=p.useState(!1),[Jt,Fr]=p.useState(()=>!au("toolbar_search")),st=p.useRef(null),Kt=p.useRef(null),[Br,At]=p.useState(0);p.useLayoutEffect(()=>{const B=st.current;if(!B)return;At(B.clientWidth);const J=new ResizeObserver(xe=>{At(xe[0].contentRect.width)});return J.observe(B),()=>J.disconnect()},[]);const _t=p.useCallback(()=>{lu("toolbar_search"),Fr(!1)},[]);p.useEffect(()=>{if(!Jt)return;const B=setTimeout(_t,2e3);return()=>clearTimeout(B)},[Jt,_t]);const fr=p.useMemo(()=>{const B=me??m;return B.length>0?B.map(J=>e.find(xe=>xe.name===J)).filter(J=>J!==void 0):e},[me,m,e]),le=p.useMemo(()=>fr.filter(B=>u[B.name]!==!1),[fr,u]),ge=p.useMemo(()=>new Set(((x==null?void 0:x.levels)??[]).map(B=>B.column)),[x]),Ae=p.useMemo(()=>!(x!=null&&x.enabled)||x.levels.length===0||le.length>0&&ge.has(le[0].name)?0:(x.levels.length-1)*yn+bn,[x,le,ge]),{widths:yt,fillerWidth:bt}=hu(le,f,Br),Xt=p.useMemo(()=>e.filter(B=>u[B.name]===!1).length,[e,u]),so=p.useMemo(()=>e.map(B=>B.name),[e]),Dr=p.useMemo(()=>m.length===0?!1:JSON.stringify(m)!==JSON.stringify(so),[m,so]),qo=p.useCallback((B,J)=>{B.preventDefault(),B.stopPropagation(),wr(J),Nr(B.clientX),dr(f[J]||150)},[f]);p.useEffect(()=>{if(!wt)return;const B=xe=>{const Ge=xe.clientX-xt,Ye=Math.max(100,Math.min(600,cr+Ge));N==null||N(wt,Ye)},J=()=>{wr(null)};return document.addEventListener("mousemove",B),document.addEventListener("mouseup",J),()=>{document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",J)}},[wt,xt,cr,N]);const Jo=p.useCallback(B=>B==null?"-":typeof B=="object"?JSON.stringify(B):typeof B=="boolean"?B?"true":"false":String(B),[]);p.useCallback(B=>{const J=n.find(xe=>xe.column===B);return J?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[J.direction==="asc"?t.jsx(T.ArrowUpward,{sx:{fontSize:14}}):t.jsx(T.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:J.priority})]}):null},[n]),p.useCallback(B=>Sn(i,B)?t.jsx(o.IconButton,{size:"small",onClick:xe=>{xe.stopPropagation(),w==null||w(B)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx(T.FilterList,{sx:{fontSize:14}})}):null,[i,w]);const Ko=p.useCallback(B=>{v&&v(B)},[v]),Xo=p.useCallback((B,J)=>{kr(xe=>{const Ye=[...xe??(m.length>0?m:e.map(gr=>gr.name))],[ue]=Ye.splice(B,1);return Ye.splice(J,0,ue),Ye})},[m,e]),Qo=p.useCallback(()=>{me&&R&&R(me),kr(null)},[me,R]),Zo=p.useCallback(B=>{if(!v)return;const J=n.find(xe=>xe.column===B);(!J||J.direction!=="asc")&&v(B)},[v,n]),en=p.useCallback(B=>{if(!v)return;const J=n.find(xe=>xe.column===B);J?J.direction==="asc"&&v(B):(v(B),setTimeout(()=>v(B),0))},[v,n]),tn=p.useCallback(B=>{if(!v)return;const J=n.find(xe=>xe.column===B);J&&(J.direction==="asc"?(v(B),setTimeout(()=>v(B),0)):J.direction==="desc"&&v(B))},[v,n]),rn=p.useCallback(B=>{H&&H(B,!1)},[H]),hr=(x==null?void 0:x.enabled)&&r.length>0&&r[0]&&"isGroupHeader"in r[0],Mt=p.useMemo(()=>dt(i),[i]),on=n.length>0||Mt>0||((x==null?void 0:x.enabled)??!1)||Object.values(u).some(B=>B===!1),nn=(jt-1)*Bt,Pe=r,Rt=p.useMemo(()=>{const B=new Set;return Ft.forEach(J=>{const xe=J==null?void 0:J.__urm_row_id__;xe!==void 0&&B.add(xe)}),B},[Ft]);p.useEffect(()=>{const B=J=>{!pt||!Ct||J.target instanceof HTMLInputElement||J.target instanceof HTMLTextAreaElement||((J.ctrlKey||J.metaKey)&&J.key==="a"&&(J.preventDefault(),pt(!0,Pe)),J.key==="Escape"&&(J.preventDefault(),Ct()))};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[pt,Ct,Pe]);const ao=p.useCallback((B,J)=>{rt&&(J.shiftKey&&P!==null?(J.preventDefault(),or&&or(P,B,Pe)):(rt(Pe[B]),mt(B)))},[rt,P,or,Pe]);!p.useMemo(()=>Pe.length>0&&Rt.size>0&&Pe.every(B=>Rt.has(B==null?void 0:B.__urm_row_id__)),[Pe,Rt])&&Pe.some(B=>Rt.has(B==null?void 0:B.__urm_row_id__));const Vr=rt&&pt,sn=p.useCallback(B=>{var Ge;const J=B.groupLevel,xe=J*yn;return t.jsx(o.TableRow,{onClick:()=>oe==null?void 0:oe(B.groupKey),sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"},cursor:"pointer",borderTop:2,borderColor:"divider"},children:t.jsxs(o.TableCell,{colSpan:le.length+(Vr?1:0),sx:{pl:`${xe+bn}px`,position:"relative"},children:[Array.from({length:J}).map((Ye,ue)=>t.jsx(o.Box,{sx:{position:"absolute",left:`${bn+ue*yn+8}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}},ue)),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[B.isCollapsed?t.jsx(T.ChevronRight,{sx:{fontSize:16}}):t.jsx(T.KeyboardArrowDown,{sx:{fontSize:16}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:Ki(J,((Ge=x==null?void 0:x.levels[J])==null?void 0:Ge.column)||"",B.groupValue)}),t.jsxs(o.Box,{sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:Ye=>D(Ye.palette.primary.main,.12),color:"primary.main",borderRadius:2},children:[B.rowCount," ",B.rowCount===1?"row":"rows"]}),Object.keys(B.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",sx:{ml:1,color:"text.secondary"},children:Object.entries(B.aggregates).map(([Ye,ue])=>Ji(ue)).filter(Boolean).join(" • ")})]})]})},B.groupKey)},[le,Vr,x,oe]),lo=p.useCallback((B,J)=>{const xe=Rt.has(B==null?void 0:B.__urm_row_id__),Ge=fe===J,Ye=Gt&&(B==null?void 0:B.__urm_row_id__)===(Dt==null?void 0:Dt.__urm_row_id__);return t.jsxs(o.TableRow,{"data-row-index":J,onMouseEnter:()=>Le(J),onMouseLeave:()=>Le(null),onClick:ue=>{!rt||ue.target.closest("[data-row-action-btn]")||ao(J,ue)},onContextMenu:ue=>{ue.preventDefault(),ue.stopPropagation(),it(null),Fe({mouseX:ue.clientX,mouseY:ue.clientY,row:B,rowIndex:J})},sx:{height:34,cursor:"pointer",bgcolor:xe?ue=>D(ue.palette.warning.main,.12):Ye?ue=>D(ue.palette.info.main,.12):"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:xe?ue=>D(ue.palette.warning.main,.2):Ye?ue=>D(ue.palette.info.main,.2):"action.hover"},borderBottom:"1px solid",borderColor:"divider"},children:[le.map((ue,gr)=>t.jsx(o.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:"6px",px:2,textAlign:"left",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:"1px solid",borderColor:"divider",minWidth:f[ue.name]?`${f[ue.name]}px`:`${ue.type==="date"?Math.max(Ri,180):Ri}px`,...gr===0&&Ae>0?{pl:`${Ae}px`}:{}},children:hr&&ge.has(ue.name)?null:Cu(ue,B[ue.name],kt,q)},ue.name)),t.jsx(o.TableCell,{sx:{p:0,border:"none",borderBottom:"1px solid",borderColor:"divider"}}),t.jsx(o.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:40,minWidth:40,maxWidth:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",background:Ge?ue=>`linear-gradient(to right, transparent, ${xe?D(ue.palette.warning.main,.12):ue.palette.background.paper} 32px)`:"transparent",opacity:Ge?1:0,transition:"opacity 0.12s ease, background 0.12s ease",zIndex:10,verticalAlign:"middle"},children:t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",height:"100%",px:1,gap:.25},children:t.jsx(o.IconButton,{"data-row-action-btn":"true",size:"small",onClick:ue=>{ue.stopPropagation(),ue.preventDefault(),it(null),Fe({anchorEl:ue.currentTarget,row:B,rowIndex:J})},sx:{color:"text.secondary",opacity:Ge?1:0,transition:"opacity 0.12s ease",pointerEvents:Ge?"auto":"none","&:hover":{bgcolor:ue=>D(ue.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(T.MoreVert,{sx:{fontSize:18}})})})})]},J)},[Ft,nn,fe,ao,le,f,q,Jo,Ut,ot,nt,rt,ft,Tt,Dt,Gt,Fe,hr,ge,Ae]);return t.jsxs(Pt.DndProvider,{backend:zn.HTML5Backend,children:[t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[t.jsxs(o.Box,{sx:{position:"sticky",top:0,zIndex:10,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",px:2,py:0,height:56,display:"flex",alignItems:"center",gap:1},children:[He&&t.jsx(su,{}),Vt&&et&&tt&&rr&&t.jsx(o.Tooltip,{open:Jt,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",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:_t},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(Vd,{value:Ie||"",onChange:B=>{Jt&&_t(),Vt(B)},searchHistory:Me,onAddToHistory:et,onToggleFavourite:tt,onDeleteHistory:rr,disabled:He})})}),t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>$t(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:B=>D(B.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(T.InfoOutlined,{sx:{fontSize:20}})})}),C&&E&&g&&s.length>0&&t.jsx(Hd,{views:s||[],activeViewId:l||"",isDirty:d,onSelectView:C,onCreateView:E,onToggleDefault:a,onToggleFavorite:_,onRestoreView:F,onPermanentDelete:X,onEditView:re,onCloneView:h,onCopyLink:V,onDeleteView:W,onPromoteToGlobal:Q,isAdmin:Z,isReadOnly:He}),d&&!He&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,ml:1},children:[g&&t.jsx(o.Button,{onClick:g,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",px:2,boxShadow:"none"},children:"Save"}),k&&t.jsx(o.Button,{onClick:k,size:"small",variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",minWidth:0,px:1},children:"Save as new view"}),L&&t.jsx(o.Button,{onClick:L,size:"small",variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",minWidth:0,px:1},children:"Discard"})]}),ar&&lr&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:lr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:B=>D(B.palette.text.secondary,.3),"&:hover":{bgcolor:B=>D(B.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx(T.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!He&&y&&t.jsx(o.Tooltip,{title:"Sort",children:t.jsxs(o.IconButton,{onClick:y,size:"small",sx:{position:"relative",color:n.length>0?"primary.main":"text.secondary",bgcolor:n.length>0?B=>qe(B):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?B=>D(B.palette.primary.main,.2):B=>D(B.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[t.jsx(T.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})]})}),!He&&S&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:S,size:"small",sx:{position:"relative",color:Mt>0?"primary.main":"text.secondary",bgcolor:Mt>0?B=>qe(B):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Mt>0?B=>D(B.palette.primary.main,.2):B=>D(B.palette.text.primary,.06),color:Mt>0?"primary.main":"text.primary"}},children:[t.jsx(T.FilterList,{sx:{fontSize:20}}),Mt>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:Mt})]})}),!He&&he&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:he,size:"small",sx:{position:"relative",color:Xt>0||Dr?"primary.main":"text.secondary",bgcolor:Xt>0||Dr?B=>qe(B):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Xt>0||Dr?B=>D(B.palette.primary.main,.2):B=>D(B.palette.text.primary,.06),color:Xt>0||Dr?"primary.main":"text.primary"}},children:[t.jsx(T.ViewColumn,{sx:{fontSize:20}}),Xt>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:Xt})]})}),hr&&(O||te)&&(()=>{var xe;const B=(((xe=x==null?void 0:x.collapsedGroups)==null?void 0:xe.length)??0)>0,J=B?O:te;return J?t.jsx(o.Tooltip,{title:B?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:J,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:Ge=>D(Ge.palette.text.primary,.06),color:"text.primary"}},children:B?t.jsx(T.UnfoldMore,{sx:{fontSize:20}}):t.jsx(T.UnfoldLess,{sx:{fontSize:20}})})}):null})(),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),t.jsx(o.Tooltip,{title:"List view",children:t.jsx(o.IconButton,{size:"small",onClick:()=>Er("list"),sx:{borderRadius:1,color:Ue==="list"?"primary.main":"text.secondary",bgcolor:Ue==="list"?B=>qe(B):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Ue==="list"?B=>D(B.palette.primary.main,.2):B=>D(B.palette.text.primary,.06),color:Ue==="list"?"primary.main":"text.primary"}},children:t.jsx(T.TableRows,{sx:{fontSize:20}})})}),t.jsx(o.Tooltip,{title:"Grid view",children:t.jsx(o.IconButton,{size:"small",onClick:()=>Er("grid"),sx:{borderRadius:1,color:Ue==="grid"?"primary.main":"text.secondary",bgcolor:Ue==="grid"?B=>qe(B):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Ue==="grid"?B=>D(B.palette.primary.main,.2):B=>D(B.palette.text.primary,.06),color:Ue==="grid"?"primary.main":"text.primary"}},children:t.jsx(T.GridView,{sx:{fontSize:20}})})}),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:B=>gt(B.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:B=>D(B.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(T.Settings,{sx:{fontSize:20}})})})]}),t.jsxs(o.Popover,{open:!!zr,anchorEl:zr,onClose:()=>gt(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:[pe&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{pe(),gt(null)},disabled:c,sx:{py:1,px:2,gap:1.5},children:[t.jsx(T.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!He&&ee&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ee(),gt(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(T.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),ce&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ce(),gt(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(T.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),ie&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ie(),gt(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(T.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Scheduled Reports"})]})]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Ue==="grid"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(ou,{data:Pe,visibleColumns:le,grouping:x,selectedRowIds:Ft,isReadOnly:He,isGrouped:!!hr,onToggleRowSelection:rt||(()=>{}),onToggleGroupCollapse:oe,onViewRow:B=>{ft(B),Tt(!0)},onEditRow:(B,J)=>{we(B),pr(J),K(!0)},onDuplicateRow:(B,J)=>ot==null?void 0:ot(B,J),onDeleteRow:(B,J)=>{qt(J),Yt(!0)}})}),Ue==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:st,onScroll:B=>{Kt.current&&(Kt.current.scrollLeft=B.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(yt).reduce((B,J)=>B+J,0)+bt+40}px`},children:[t.jsxs("colgroup",{children:[le.map(B=>t.jsx("col",{style:{width:`${yt[B.name]}px`}},B.name)),t.jsx("col",{style:{width:`${bt}px`}}),t.jsx("col",{style:{width:"40px"}})]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{height:34,bgcolor:"action.hover",borderBottom:"1px solid",borderColor:"divider"},children:[le.map((B,J)=>t.jsx(Yd,{column:B,index:J,sortRule:n.find(xe=>xe.column===B.name),hasFilters:Sn(i,B.name),isInSortStack:n.some(xe=>xe.column===B.name),isReadOnly:He,hasModifications:on,width:f[B.name],onColumnClick:Ko,onMoveColumn:Xo,onColumnDragEnd:Qo,onResizeStart:qo,onSortAscending:b||Zo,onSortDescending:z||en,onRemoveSort:tn,onOpenFilterForColumn:w||(()=>{}),onClearFiltersForColumn:G||(()=>{}),onGroupByColumn:ne,onHideColumn:rn,onManageColumns:he||(()=>{}),onResetLayout:ae},B.name)),t.jsx(o.TableCell,{sx:{p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}}),t.jsx(o.TableCell,{sx:{width:40,minWidth:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",bgcolor:"action.hover"}})]})})]})}),t.jsx(o.Box,{ref:Kt,onScroll:B=>{st.current&&(st.current.scrollLeft=B.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:B=>B.palette.mode==="dark"?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.2)",borderRadius:4,"&:hover":{bgcolor:B=>B.palette.mode==="dark"?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.3)"}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(yt).reduce((B,J)=>B+J,0)+bt+40}px`},children:[t.jsxs("colgroup",{children:[le.map(B=>t.jsx("col",{style:{width:`${yt[B.name]}px`}},B.name)),t.jsx("col",{style:{width:`${bt}px`}}),t.jsx("col",{style:{width:"40px"}})]}),t.jsx(o.TableBody,{children:Pe.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:le.length+(Vr?1:0),align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):hr?Pe.map((B,J)=>B.isGroupHeader?sn(B):lo(B,J)):Pe.map((B,J)=>lo(B,J))})]})})]}),nr&&ir&&t.jsx(iu,{currentPage:jt,pageSize:Bt,totalRows:Ht,totalFields:e.length,onPageChange:nr,onPageSizeChange:ir}),!(nr&&ir)&&t.jsx(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",Pe.length," ",Pe.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!Se,onClose:()=>{Fe(null),it(null)},anchorEl:(Se==null?void 0:Se.anchorEl)||null,anchorReference:Se!=null&&Se.anchorEl?"anchorEl":"anchorPosition",anchorPosition:Se&&!Se.anchorEl?{top:Se.mouseY,left:Se.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:Se!=null&&Se.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Se&&(ft(Se.row),Tt(!0)),Fe(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(T.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Se&&(we(Se.row),pr(Se.rowIndex),K(!0)),Fe(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(T.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Se&&(ot==null||ot(Se.rowIndex,Se.row)),Fe(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(T.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),Rt.size>0&&Je&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:B=>{Ve(),it(B.currentTarget)},onMouseLeave:mr,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(T.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",Rt.size,")"]})]}),t.jsx(T.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!xr,anchorEl:xr,placement:"right-start",transition:!0,sx:{zIndex:B=>B.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:B})=>t.jsx(o.Grow,{...B,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:Ve,onMouseLeave:mr,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:()=>{Je("csv"),it(null),Fe(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(T.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Je("excel"),it(null),Fe(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(T.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(o.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Je("json"),it(null),Fe(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(T.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"JSON"})]})]})})})})]}),t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{Se&&(qt(Se.row),Yt(!0)),Fe(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx(T.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]}),t.jsx(cu,{open:Gt,onClose:()=>{Tt(!1),ft(null)},row:Dt,schema:e,reportName:sr}),t.jsx(uu,{open:ze,onClose:()=>{K(!1),we(null),pr(null)},onSave:B=>{Ir!==null&&(Ut==null||Ut(Ir,B))},row:Ot,schema:e,reportName:sr}),t.jsx(du,{open:Tr,onClose:()=>{Yt(!1),qt(null)},onConfirm:()=>{ur!==null&&(nt==null||nt(ur))},row:ur,schema:e}),t.jsx(Ss,{isOpen:Lr,onClose:()=>$t(!1)})]})}function Cr({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=>D(s.palette.primary.main,.08)}},children:t.jsx(T.InfoOutlined,{sx:{fontSize:15}})}),t.jsxs(o.Popover,{open:!!n,anchorEl:n,onClose:()=>i(null),anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},PaperProps:{sx:{width:280,borderRadius:"10px",boxShadow:4,p:0,overflow:"hidden"}},children:[t.jsx(o.Box,{sx:{px:2,py:1.5,bgcolor:s=>D(s.palette.primary.main,.06)},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,color:"primary.main",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:"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,l)=>t.jsx(o.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},l))}),r&&e.devNote&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>D(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>D(s.palette.warning.main,.2)},children:[t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:500,display:"block",mb:.25},children:"Dev note"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}const jr={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}},vn=40;function wu({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 l=r.find(u=>u.name===e.column),d=p.useMemo(()=>{const u=l?zo(l.type):[],m=i.filter.allowedOperators;return m.length>0?u.filter(f=>m.includes(f.value)):u},[l,i]),c=fl(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 m=r.find(v=>v.name===u.target.value),f=m?zo(m.type):[];s({column:u.target.value,operator:((x=f[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:Qe(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:d.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),c&&(l==null?void 0:l.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"}}}),c&&(l==null?void 0:l.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(l==null?void 0:l.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(l==null?void 0:l.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 Is({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:l,totalConditions:d,onChange:c}){const u=d>=l;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((m,f)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:vn,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[f<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),f>0&&t.jsx(wu,{operator:e.operator,onSelect:x=>c(v=>Dn(v,e.id,x))}),f>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:vn/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:f>0?1:0},children:Re(m)?t.jsx(Tu,{group:m,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:l,totalConditions:d,onChange:c}):t.jsx(ku,{condition:m,schema:n,availableColumns:i,devConfig:s,onUpdate:x=>c(v=>Bn(v,m.id,x))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>c(x=>On(x,m.id)),sx:{mt:f>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx(T.Close,{sx:{fontSize:16}})})]},m.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${vn}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>c(m=>{var f,x,v;return Pr(m,e.id,{id:Wr(),column:((f=i[0])==null?void 0:f.name)??"",operator:((v=zo(((x=i[0])==null?void 0:x.type)??"string")[0])==null?void 0:v.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(o.Button,{size:"small",disabled:u,onClick:()=>c(m=>Pr(m,e.id,St())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Tu(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>D(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>D(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(Is,{...e})})}function Iu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s}){const[l,d]=p.useState(r??St()),c=Sr(),u=p.useMemo(()=>e.filter(y=>y.type!=="mixed"&&y.type!=="null"&&y.type!=="array"&&y.type!=="object"),[e]);p.useEffect(()=>{var w;const y=r??St();if(s&&y.children.length===0){const C=e.find(E=>E.name===s);if(C){d(Pr(y,y.id,{id:Wr(),column:s,operator:((w=zo(C.type)[0])==null?void 0:w.value)??"equals"}));return}}d(y)},[r,s,e]);const m=dt(l),f=c.filter.maxConditions,x=p.useCallback(y=>{d(w=>y(w))},[]),v=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r??St()),[l,r]),b=p.useCallback(()=>{n(l),i()},[l,n,i]),z=p.useCallback(()=>{d(r??St()),i()},[r,i]),S=p.useCallback(()=>{n(St()),i()},[n,i]);return t.jsx(o.Box,{onClick:z,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:y=>D(y.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:y=>y.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:y=>y.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:y=>Ne(y),bgcolor:"background.paper",outline:"none",boxShadow:y=>se(y,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(Cr,{content:jr.filter,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:z,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(T.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:y=>D(y.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:y=>D(y.palette.text.primary,.3)}}},children:[m===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${Qe(s)}"`:"","."]}),t.jsx(Is,{group:l,depth:0,schema:e,availableColumns:u,devConfig:c,maxConditions:f,totalConditions:m,onChange:x}),m>=f&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Filter limit reached — maximum ",f," conditions allowed. Remove one to add another."]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",alignItems:"center",gap:1.5,justifyContent:"space-between",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:S,disabled:m===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:z,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:y=>`${y.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:b,disabled:!v,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:y=>`${y.shape.borderRadius}px`,boxShadow:y=>se(y,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const Wi="SORT_RULE";function zu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const l=p.useRef(null),[{handlerId:d},c]=Pt.useDrop({accept:Wi,collect(f){return{handlerId:f.getHandlerId()}},hover(f,x){var C;if(!l.current)return;const v=f.index,b=r;if(v===b)return;const z=(C=l.current)==null?void 0:C.getBoundingClientRect(),S=(z.bottom-z.top)/2,y=x.getClientOffset(),w=((y==null?void 0:y.y)??0)-z.top;v<b&&w<S||v>b&&w>S||(s(v,b),f.index=b)}}),[{isDragging:u},m]=Pt.useDrag({type:Wi,item:()=>({index:r}),collect:f=>({isDragging:f.isDragging()})});return m(c(l)),t.jsxs(o.Box,{ref:l,"data-handler-id":d,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:f=>se(f,"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:f=>`0 1px 2px 0 ${D(f.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:"0.875rem",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:f=>n(r,f.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:f=>qe(f),"&:hover":{bgcolor:f=>D(f.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:f=>qe(f),"&:hover":{bgcolor:f=>D(f.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:f=>D(f.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx(T.Close,{sx:{fontSize:18}})})]})}function Eu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i}){const[s,l]=p.useState(""),[d,c]=p.useState([]);p.useEffect(()=>{c([...r])},[r]);const u=p.useMemo(()=>JSON.stringify(d)!==JSON.stringify(r),[d,r]),m=Sr(),f=p.useCallback(C=>{if(!C||d.length>=m.sort.maxLevels)return;const E={column:C,direction:"asc",priority:d.length+1};c([...d,E]),l(""),setTimeout(()=>{var g;return(g=document.activeElement)==null?void 0:g.blur()},0)},[d,m.sort.maxLevels]),x=p.useCallback(C=>{const g=d.filter((k,L)=>L!==C).map((k,L)=>({...k,priority:L+1}));c(g)},[d]),v=p.useCallback((C,E)=>{const g=[...d];g[C]={...g[C],direction:E},c(g)},[d]),b=p.useCallback((C,E)=>{const g=[...d],[k]=g.splice(C,1);g.splice(E,0,k);const L=g.map((a,_)=>({...a,priority:_+1}));c(L)},[d]),z=p.useCallback(()=>{n([]),i()},[n,i]),S=p.useCallback(()=>{n(d),i()},[d,n,i]),y=p.useCallback(()=>{c([...r]),l(""),i()},[r,i]),w=e.filter(C=>!d.some(E=>E.column===C.name));return t.jsx(Pt.DndProvider,{backend:zn.HTML5Backend,children:t.jsx(o.Box,{onClick:y,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:C=>D(C.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:C=>C.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:C=>C.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:C=>Ne(C),bgcolor:"background.paper",outline:"none",boxShadow:C=>se(C,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(Cr,{content:jr.sort,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:y,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(T.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=>D(C.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:C=>D(C.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:d.length>=m.sort.maxLevels,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(o.Select,{value:s,onChange: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:w.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:E=>qe(E),"&:hover":{bgcolor:E=>D(E.palette.primary.main,.2)}}},children:Qe(C.name)},C.name))})]}),d.length>=m.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Maximum ",m.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:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",d.length,"/",m.sort.maxLevels,")"]}),t.jsx(o.Button,{onClick:z,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,E)=>t.jsx(zu,{rule:C,index:E,onToggleDirection:v,onRemove:x,onMove:b},`${C.column}-${E}`))})]})]}),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:y,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:S,variant:"contained",disabled:!u||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=>se(C,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:C=>se(C,"hoverButton")},"&:active":{boxShadow:C=>se(C,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const go=50;function Pi({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:l="",initialIsDefault:d=!1,atViewLimit:c=!1,maxViews:u=10}){const[m,f]=p.useState(s),[x,v]=p.useState(!1),[b,z]=p.useState(l),[S,y]=p.useState(d),w=()=>{if(!m.trim()){v(!0);return}if(m.trim().length>go){v(!0);return}r(m.trim(),b.trim(),S),n()},C=g=>{g.key==="Enter"&&!g.shiftKey?w():g.key==="Escape"&&n()},E=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:g=>Ne(g),boxShadow:g=>se(g,"menu")}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[E(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(T.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[c&&!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:m,onChange:g=>{g.target.value.length<=go&&f(g.target.value),x&&g.target.value.trim()&&v(!1)},onKeyDown:C,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:c&&!i,inputProps:{maxLength:go},error:x&&!m.trim(),helperText:x&&!m.trim()?"View name is required":`${m.length} / ${go}`}),t.jsx(o.TextField,{label:"Description (optional)",value:b,onChange:g=>z(g.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: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:[dt(e.filters)," filter",dt(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",Da(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:S,onChange:g=>y(g.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:g=>`${g.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:c&&!i,startIcon:t.jsx(T.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:g=>`${g.shape.borderRadius}px`,boxShadow:g=>se(g,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:g=>se(g,"hoverButton")},"&:active":{boxShadow:g=>se(g,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function Bu({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>Ne(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:i=>se(i,"menu")}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Delete View",t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(T.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(T.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=>se(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>se(i,"hoverButton")},"&:active":{boxShadow:i=>se(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const So=100,Co=600,Ni="COLUMN";function Du({column:e,index:r,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:l,moveColumn:d}){const c=p.useRef(null),[u,m]=p.useState(i.toString());p.useEffect(()=>{m(i.toString())},[i]);const[{handlerId:f},x]=Pt.useDrop({accept:Ni,collect(C){return{handlerId:C.getHandlerId()}},hover(C,E){var X;if(!c.current)return;const g=C.index,k=r;if(g===k)return;const L=(X=c.current)==null?void 0:X.getBoundingClientRect(),a=(L.bottom-L.top)/2,_=E.getClientOffset(),F=((_==null?void 0:_.y)??0)-L.top;g<k&&F<a||g>k&&F>a||(d(g,k),C.index=k)}}),[{isDragging:v},b]=Pt.useDrag({type:Ni,item:()=>({index:r}),collect:C=>({isDragging:C.isDragging()})});b(x(c));const z=()=>{const C=parseInt(u);if(isNaN(C)){m(i.toString()),l(e.name,i);return}const E=Math.max(So,Math.min(Co,C));m(E.toString()),l(e.name,E)},S=C=>{if(C===""||/^\d+$/.test(C)){m(C);const E=parseInt(C);if(!isNaN(E)&&E>=So){const g=Math.min(Co,E);l(e.name,g)}}},y=C=>{C.key==="Enter"&&(C.preventDefault(),z(),C.target.blur())},w=C=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[C]||"text.secondary";return t.jsxs(o.TableRow,{ref:c,"data-handler-id":f,sx:{opacity:v?.4:1,bgcolor:n?"background.paper":"action.hover",transition:"opacity 0.15s ease","&:hover":{bgcolor:n?"action.hover":"action.selected"},cursor:"move",height:56,borderBottom:"1px solid divider"},children:[t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx(T.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:Qe(e.name)})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsx(o.Chip,{label:e.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${w(e.type)}15`,color:w(e.type),border:`1px solid ${w(e.type)}30`,"& .MuiChip-label":{px:1}}})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.TextField,{type:"number",value:u,onChange:C=>S(C.target.value),onBlur:z,onKeyDown:y,placeholder:"150",size:"small",inputProps:{min:So,max:Co,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:"0.75rem",color:"text.secondary"},children:"px"})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.IconButton,{onClick:()=>s(e.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"}},children:n?t.jsx(T.Visibility,{sx:{fontSize:20}}):t.jsx(T.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?C=>D(C.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function Ou({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:l="",onUpdateColumnVisibility:d,onUpdateColumnOrder:c,onUpdateColumnWidth:u,onResetLayout:m,onSaveToCurrentView:f,onSaveToAllViews:x,onSelectView:v,onClose:b}){const[z,S]=p.useState(!1),[y,w]=p.useState(n),[C,E]=p.useState(i),[g,k]=p.useState("all"),[L,a]=p.useState(null);p.useEffect(()=>{w(n)},[n]),p.useEffect(()=>{E(i)},[i]);const _=(N,R)=>{E(H=>({...H,[N]:R})),u==null||u(N,R)},F=(N,R)=>{const H=[...y],[G]=H.splice(N,1);H.splice(R,0,G),w(H),c(H)},X=()=>{m(),S(!1)},h=y.map(N=>e.find(R=>R.name===N)).filter(N=>N!==void 0).filter(N=>{const R=r[N.name]??!0;return g==="active"?R:g==="hidden"?!R:!0}),V=Object.values(r).filter(N=>N).length,W=e.length,Q=s.find(N=>N.id===l),Z=s.filter(N=>!N.isDeleted),pe=Z.length>1,he=p.useMemo(()=>{if(!Q)return!1;const N=Q.snapshot,R=N.columnVisibility??{},H=JSON.stringify(r)!==JSON.stringify(R),G=N.columnOrder??[],ae=n??[],ee=JSON.stringify(ae)!==JSON.stringify(G)&&!(ae.length===0&&G.length===0),ne=N.columnWidths??{},oe=JSON.stringify(C)!==JSON.stringify(ne);return H||ee||oe},[Q,r,n,C]);return t.jsx(Pt.DndProvider,{backend:zn.HTML5Backend,children:t.jsx(o.Box,{onClick:b,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:N=>D(N.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:N=>N.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:N=>N.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:N=>Ne(N),bgcolor:"background.paper",outline:"none",boxShadow:N=>se(N,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2,pb:1.5,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsx(o.Box,{sx:{flex:1},children:t.jsxs(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",t.jsx(Cr,{content:jr.columns,isDev:process.env.NODE_ENV==="development"})]})}),Z.length>0&&v&&t.jsxs(o.Box,{sx:{ml:2},children:[t.jsx(o.Button,{onClick:N=>a(N.currentTarget),variant:"outlined",size:"small",endIcon:t.jsx(T.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{minWidth:180,justifyContent:"space-between",fontSize:"0.875rem",color:"text.primary",borderColor:"divider",py:.75,px:1.5,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(Q==null?void 0:Q.name)||"Select View"})}),t.jsx(o.Menu,{anchorEl:L,open:!!L,onClose:()=>a(null),PaperProps:{sx:{mt:.5,borderRadius:"8px",boxShadow:N=>se(N,"small")}},children:Z.map(N=>t.jsx(o.MenuItem,{onClick:()=>{v(N.id),a(null)},selected:N.id===l,sx:{fontSize:"0.875rem",color:"text.primary",py:1,px:2,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:R=>qe(R),"&:hover":{bgcolor:R=>D(R.palette.primary.main,.2)}}},children:N.name},N.id))})]}),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(T.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:g,onChange:(N,R)=>k(R),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:"primary.main",height:3}},children:[t.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),t.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),t.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:N=>D(N.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:N=>D(N.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: ${So}px, max: ${Co}px)`,arrow:!0,placement:"top",children:t.jsx(T.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:h.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:"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):h.map((N,R)=>t.jsx(Du,{column:N,index:R,isVisible:r[N.name]??!0,width:C[N.name]||170,onToggleVisibility:d,onWidthChange:_,moveColumn:F},N.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:"0.8125rem",color:"text.secondary"},children:[V," of ",W," columns visible • Drag to reorder"]})}),t.jsxs(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:()=>S(!0),disabled:!he,variant:"outlined",startIcon:t.jsx(T.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:N=>`${N.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"}),t.jsxs(o.Stack,{direction:"row",spacing:1.25,children:[f&&t.jsx(o.Button,{onClick:()=>{f(C),b()},disabled:!he,variant:"contained",startIcon:t.jsx(T.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:N=>`${N.shape.borderRadius}px`,boxShadow:N=>se(N,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:N=>se(N,"hoverButton")},"&:active":{boxShadow:N=>se(N,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to current view"}),x&&pe&&t.jsx(o.Button,{onClick:()=>{x(C),b()},disabled:!he||!pe,variant:"contained",startIcon:t.jsx(T.GridView,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"success.main",color:"background.paper",px:2.5,py:.875,minHeight:36,borderRadius:N=>`${N.shape.borderRadius}px`,boxShadow:N=>se(N,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"success.dark",boxShadow:N=>se(N,"hoverButton")},"&:active":{boxShadow:N=>se(N,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:"Save to all views"})]})]}),z&&t.jsx(o.Box,{onClick:()=>S(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:N=>D(N.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:N=>N.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:N=>N.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:N=>oo(N),bgcolor:"background.paper",boxShadow:N=>se(N,"menu")},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:()=>S(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:N=>`${N.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:X,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:N=>`${N.shape.borderRadius}px`,boxShadow:N=>se(N,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:N=>se(N,"hoverButton")},"&:active":{boxShadow:N=>se(N,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function $u({schema:e,grouping:r,onApply:n,onClose:i}){var L;const[s,l]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[d,c]=p.useState(""),[u,m]=p.useState(null),f=p.useMemo(()=>wa(e),[e]),x=p.useMemo(()=>f.filter(a=>!s.levels.some((_,F)=>_.column===a.name&&F!==u)),[f,s.levels,u]),v=Sr(),b=s.levels.length<v.grouping.maxLevels&&x.length>0,z=p.useCallback(a=>{!b||!a||(l({...s,levels:[...s.levels,{column:a}],enabled:!0}),c(""),setTimeout(()=>{var _;return(_=document.activeElement)==null?void 0:_.blur()},0))},[b,s]),S=p.useCallback(a=>{const _=s.levels.filter((F,X)=>X!==a);if(_.length===0){n(null),i();return}l({...s,levels:_,enabled:_.length>0})},[s,n,i]),y=p.useCallback(a=>{m(a),c(s.levels[a].column)},[s.levels]),w=p.useCallback(()=>{if(u===null||!d)return;const a=[...s.levels];a[u]={column:d},l({...s,levels:a}),m(null),c("")},[u,d,s]),C=p.useCallback(()=>{m(null),c("")},[]),E=p.useCallback((a,_)=>{const F=_==="up"?a-1:a+1;if(F<0||F>=s.levels.length)return;const X=[...s.levels],[re]=X.splice(a,1);X.splice(F,0,re),l({...s,levels:X})},[s]),g=p.useCallback(()=>{n(null),i()},[n,i]),k=p.useCallback(()=>{s.levels.length===0?n(null):n({...s,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[s,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:a=>D(a.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:a=>a.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:a=>a.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:a=>Ne(a),bgcolor:"background.paper",outline:"none",boxShadow:a=>se(a,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(Cr,{content:jr.grouping,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(T.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:a=>D(a.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:a=>D(a.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[u===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:d,onChange:a=>z(a.target.value),disabled:!b,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),x.map(a=>t.jsxs(o.MenuItem,{value:a.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:_=>qe(_),"&:hover":{bgcolor:_=>D(_.palette.primary.main,.2)}}},children:[Qe(a.name)," (",a.type.toUpperCase(),")"]},a.name))]})}),s.levels.length>=v.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:"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:"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),u!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:a=>`1px solid ${D(a.palette.warning.main,.5)}`,bgcolor:a=>D(a.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:1.5,fontSize:"0.875rem",color:"text.primary"},children:["Edit Group Level ",u+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:d,onChange:a=>c(a.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:s.levels[u].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:a=>qe(a)}},children:[s.levels[u].column," (",(L=e.find(a=>a.name===s.levels[u].column))==null?void 0:L.type.toUpperCase(),")"]}),x.filter(a=>a.name!==s.levels[u].column).map(a=>t.jsxs(o.MenuItem,{value:a.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:_=>qe(_)}},children:[Qe(a.name)," (",a.type.toUpperCase(),")"]},a.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:w,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:a=>se(a,"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"})]})]}),s.levels.length>0&&u===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:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:g,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:s.levels.map((a,_)=>{const F=e.find(X=>X.name===a.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:X=>se(X,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${_+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:X=>`0 1px 2px 0 ${D(X.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:a.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:F==null?void 0:F.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>E(_,"up"),disabled:_===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(T.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>E(_,"down"),disabled:_===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(T.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>y(_),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx(T.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>S(_),sx:{color:"text.secondary","&:hover":{bgcolor:X=>D(X.palette.error.main,.08),color:"error.main"}},children:t.jsx(T.Delete,{sx:{fontSize:18}})})]})]},_)})})]})]})}),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:a=>`${a.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:k,variant:"contained",disabled:s.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:a=>`${a.shape.borderRadius}px`,boxShadow:a=>se(a,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:a=>se(a,"hoverButton")},"&:active":{boxShadow:a=>se(a,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function Au({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(T.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx(T.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:600,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(T.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx(T.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const Li=[{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 _u(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 Mu(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function Ru({auditHistory:e,onClose:r,onClearAuditHistory:n}){var z,S,y,w;const i=Lt(),s=i.palette,[l,d]=p.useState("1h"),[c,u]=p.useState(!1),m=[...e].sort((C,E)=>new Date(E.timestamp).getTime()-new Date(C.timestamp).getTime()),f=Li.find(C=>C.key===l),x=_u(e,f.ms),v=()=>u(!0),b=()=>{n&&(n(Mu(e,f.ms)),u(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:D(((z=s.common)==null?void 0:z.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:C=>C.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:Ne(i),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${D(((S=s.common)==null?void 0:S.black)??"#000",.14)}, 0 2px 8px ${D(((y=s.common)==null?void 0:y.black)??"#000",.08)}`,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,borderBottom:"1px solid",borderColor:"divider"},children:[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:"0.9375rem",fontWeight:600,color:"text.primary"},children:"Audit History"}),t.jsx(Cr,{content:jr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:[m.length," event",m.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:l,onChange:C=>d(C.target.value),size:"small",variant:"outlined",sx:{fontSize:"0.75rem",height:30,minWidth:120,"& .MuiSelect-select":{py:.375,px:1,fontSize:"0.75rem"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:D(s.text.primary,.3)}},children:Li.map(C=>t.jsx(o.MenuItem,{value:C.key,sx:{fontSize:"0.8125rem"},children:C.label},C.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(T.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:v,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:D(s.error.main,.5),"&:hover":{bgcolor:D(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(T.Close,{sx:{fontSize:17}})})]})]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:D(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:D(s.text.primary,.14),borderRadius:3}},children:m.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx(T.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:"0.9375rem",color:"text.secondary",fontWeight:500},children:"No audit events yet"}),t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:m.map(C=>{const E=Xd(i,C.feature),{summary:g,detail:k}=Ua(C);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transition:"border-color 0.15s","&:hover":{borderColor:D(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:qa(C.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:D(E,.1),color:E,border:`1px solid ${D(E,.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:g}),k&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:k}),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(T.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:Ja(C.timestamp)})]}),C.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(T.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:C.user})]})]})]})]},C.id)})})})]})}),t.jsxs(o.Dialog,{open:c,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:oo(i),boxShadow:`0 8px 32px ${D(((w=s.common)==null?void 0:w.black)??"#000",.14)}`}},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:D(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(T.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{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:[x," audit record",x!==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:b,variant:"contained",color:"error",startIcon:t.jsx(T.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",x," Record",x!==1?"s":""]})]})]})]})}function Wu({onSave:e,onClose:r}){const[n,i]=p.useState(""),[s,l]=p.useState(""),[d,c]=p.useState(""),[u,m]=p.useState([]),[f,x]=p.useState(""),[v,b]=p.useState(""),z=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),S=()=>{const k=d.trim();if(k){if(!z(k)){b("Please enter a valid email address");return}if(u.includes(k)){b("This email is already added");return}m([...u,k]),c(""),b("")}},y=k=>{m(u.filter(L=>L!==k))},w=k=>{k.key==="Enter"&&(k.preventDefault(),S())},C=()=>{if(!n.trim()){x("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},E=k=>{i(k),f&&x("")},g=k=>{c(k),v&&b("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:k=>D(k.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:k=>k.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:k=>k.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:k=>Ne(k),bgcolor:"background.paper",outline:"none",boxShadow:k=>se(k,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,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(T.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:k=>D(k.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:k=>D(k.palette.text.primary,.3)}}},children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsx(o.Alert,{severity:"info",icon:t.jsx(T.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:k=>`1px solid ${D(k.palette.primary.main,.3)}`,bgcolor:k=>qe(k),"& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"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:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),t.jsx(o.TextField,{required:!0,value:n,onChange:k=>E(k.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!f,helperText:f,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:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(o.TextField,{value:s,onChange:k=>l(k.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[t.jsx(o.TextField,{value:d,onChange:k=>g(k.target.value),onKeyPress:w,placeholder:"Enter email address",error:!!v,helperText:v,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx(T.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:S,variant:"outlined",startIcon:t.jsx(T.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:k=>`${k.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(k=>t.jsx(o.Chip,{label:k,onDelete:()=>y(k),deleteIcon:t.jsx(T.Delete,{sx:{fontSize:16}}),sx:{bgcolor:L=>qe(L),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},k))}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",mt:1,display:"block",lineHeight:1.5},children: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:k=>`${k.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:C,variant:"contained",startIcon:t.jsx(T.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:k=>`${k.shape.borderRadius}px`,boxShadow:k=>se(k,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:k=>se(k,"hoverButton")},"&:active":{boxShadow:k=>se(k,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function Pu({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx(T.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(T.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>D(n.palette.primary.main,.12),borderColor:"primary.light",border:1,fontSize:"body2.fontSize",fontWeight:500,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.main"}}}})}function Nu({presets:e,reportId:r,onOpenPreset:n,onDeletePreset:i,onClose:s}){const l=d=>new Date(d).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(o.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:d=>D(d.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:d=>d.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:d=>d.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:d=>Ne(d),bgcolor:"background.paper",outline:"none",boxShadow:d=>se(d,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{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(T.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"divider",borderRadius:4,"&:hover":{bgcolor:d=>D(d.palette.text.primary,.2)}}},children:e.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx(T.Share,{sx:{fontSize:48,color:"divider",mb:2}}),t.jsx(o.Typography,{variant:"body1",sx:{fontSize:"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.disabled",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(d=>t.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:c=>se(c,"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:"0.9375rem",fontWeight:500,color:"text.primary",mb:.5},children:d.name}),d.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:d.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${l(d.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(o.Chip,{label:`By ${d.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),t.jsx(o.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",gap:1},children:t.jsx(o.Button,{onClick:()=>i(d.id,d.name),variant:"outlined",size:"small",startIcon:t.jsx(T.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:c=>`${c.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:c=>D(c.palette.error.main,.04)}},children:"Delete"})})]},d.id))})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:t.jsx(o.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:d=>`${d.shape.borderRadius}px`,boxShadow:d=>se(d,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:d=>se(d,"hoverButton")},"&:active":{boxShadow:d=>se(d,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const zs={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},Lu=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],Fu=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function Vu(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=Fu.some(c=>c.test(i.name));let l=!1;const d=r.slice(0,10).map(c=>c[i.name]).filter(c=>typeof c=="string"&&c.length>0);d.length>0&&(l=d.filter(u=>Lu.some(m=>m.test(u))).length/d.length>.6),(s||l)&&n.push(i.name)}return n}function Fn(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(d=>{const c=n.map(m=>String(m[d]??"")).filter(m=>m.length>0);if(c.length===0)return 5;const u=c.reduce((m,f)=>m+f.length,0);return Math.ceil(u/c.length)+1}).reduce((d,c)=>d+c,0)+1;return r.reduce((d,c)=>d+c.length+1,0)+s*e.length}function Hu(e,r){const n=Fn(e,r);return Math.ceil(n*3.5)}function Uu(e,r){const n=Fn(e,r);return Math.ceil(n*.7)}function Gu(e,r,n){switch(e){case"csv":return Fn(r,n);case"excel":return Uu(r,n);case"json":return Hu(r,n)}}function Fi(e,r){return Math.ceil(e/r)}function Yu(e,r,n,i,s=zs){const l=[],d=Gu(e,r,n),c=r.length;if(c>s.maxRowsHard){const f=Fi(c,s.maxRows);l.push({type:"row_count",severity:"error",message:`Export blocked: ${c.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${f} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:f,value:c,limit:s.maxRowsHard})}else if(c>s.maxRows){const f=Fi(c,s.maxRows);l.push({type:"row_count",severity:"warning",message:`Large export: ${c.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${f} smaller export${f>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:f,value:c,limit:s.maxRows})}if(d>s.maxFileSizeHardBytes?l.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${Xr(d)} exceeds the ${Xr(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:d,limit:s.maxFileSizeHardBytes}):d>s.maxFileSizeBytes&&l.push({type:"file_size",severity:"warning",message:`Large file: estimated ${Xr(d)}`,detail:`This exceeds the recommended ${Xr(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:d,limit:s.maxFileSizeBytes}),e!=="excel"){const f=Vu(i.filter(x=>n.includes(x.name)),r);if(f.length>0){const x=f.length>s.maxImageColumns;l.push({type:"image_columns",severity:x?"error":"warning",message:`Image column${f.length>1?"s":""} detected: ${f.map(v=>`"${v.replace(/_/g," ")}"`).join(", ")}`,detail:x?`Exporting ${f.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:f.length,limit:s.maxImageColumns})}}const u=l.some(f=>f.severity==="error"),m=l.some(f=>f.severity==="warning");return{violations:l,hasBlockingViolation:u,hasWarning:m,estimatedBytes:d}}function Xr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function qu({violation:e}){const n=Lt().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,l=D(i?n.error.main:n.warning.main,.06),d=i?D(n.error.main,.25):D(n.warning.main,.3),c=i?T.ErrorOutline:T.WarningAmberOutlined;return t.jsxs(o.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"8px",bgcolor:l,border:"1px solid",borderColor:d},children:[t.jsx(c,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",fontWeight:600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{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(T.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",fontWeight:500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function Ju({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:l,sampleRows:d=[],allRows:c=[],processedRows:u=[],onExport:m,onClose:f}){var V,W,Q;const x=Lt(),v=x.palette,b=Sr(),[z,S]=p.useState(b.export.allowedFormats[0]||"csv"),[y,w]=p.useState("visible"),[C,E]=p.useState("visible"),g=y==="visible"?r:e,k=C==="visible"?i:s,L=p.useMemo(()=>y==="visible"?u.length>0?u:new Array(r):c.length>0?c:new Array(e),[y,r,e,u,c]),a=p.useMemo(()=>C==="all"?l.map(Z=>Z.name):l.map(Z=>Z.name).slice(0,i),[C,l,i]),_=p.useMemo(()=>Yu(z,L,a,l,zs),[z,L,a,l]),F=()=>{_.hasBlockingViolation||(m({format:z,scope:y,columnScope:C}),f())},X={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"},re={alignItems:"flex-start",px:1.5,py:.875,borderRadius:"8px",mx:0,transition:"background-color 0.15s","&:hover":{bgcolor:"action.hover"}},h={color:"text.secondary","&.Mui-checked":{color:"primary.main"},pt:.125};return t.jsx(o.Box,{onClick:f,sx:{position:"fixed",inset:0,bgcolor:D(((V=v.common)==null?void 0:V.black)??"#000",.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:x.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:Z=>Z.stopPropagation(),elevation:0,sx:{width:480,maxWidth:"calc(100vw - 48px)",maxHeight:"min(680px, calc(100vh - 180px))",display:"flex",flexDirection:"column",borderRadius:Ne(x),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${D(((W=v.common)==null?void 0:W.black)??"#000",.14)}, 0 2px 8px ${D(((Q=v.common)==null?void 0:Q.black)??"#000",.08)}`,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary"},children:"Export Report"}),t.jsx(Cr,{content:jr.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:f,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(T.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.Box,{sx:{flex:1,overflowY:"auto",px:3,py:2.5,display:"flex",flexDirection:"column",gap:2.5,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:D(v.text.primary,.15),borderRadius:3}},children:[_.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:_.violations.map((Z,pe)=>t.jsx(qu,{violation:Z},pe))}),t.jsxs(o.FormControl,{component:"fieldset",children:[t.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Format"}),t.jsxs(o.RadioGroup,{value:z,onChange:Z=>S(Z.target.value),children:[b.export.allowedFormats.includes("csv")&&t.jsx(o.FormControlLabel,{value:"csv",control:t.jsx(o.Radio,{size:"small",sx:h}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(T.TableChart,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"CSV"}),t.jsx(o.Tooltip,{title:"Comma-separated values, compatible with Excel",arrow:!0,children:t.jsx(T.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),sx:{...re,mb:.5}}),b.export.allowedFormats.includes("excel")&&t.jsx(o.FormControlLabel,{value:"excel",control:t.jsx(o.Radio,{size:"small",sx:h}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(T.TableChart,{sx:{fontSize:16,color:"success.main"}}),t.jsx(o.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Excel (.xlsx)"}),t.jsx(o.Tooltip,{title:"Native Excel format with formatting support",arrow:!0,children:t.jsx(T.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),sx:{...re,mb:.5}}),b.export.allowedFormats.includes("json")&&t.jsx(o.FormControlLabel,{value:"json",control:t.jsx(o.Radio,{size:"small",sx:h}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(T.DataObject,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"JSON"}),t.jsx(o.Tooltip,{title:"Structured data with metadata and filters",arrow:!0,children:t.jsx(T.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),sx:re})]})]}),t.jsxs(o.FormControl,{component:"fieldset",children:[t.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Rows"}),t.jsxs(o.RadioGroup,{value:y,onChange:Z=>w(Z.target.value),children:[t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small",sx:h}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible rows"}),t.jsx(o.Tooltip,{title:`Export ${r.toLocaleString()} rows (filtered and searched)`,arrow:!0,children:t.jsx(T.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),sx:{...re,mb:.5}}),t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small",sx:h}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All rows"}),t.jsx(o.Tooltip,{title:`Export ${e.toLocaleString()} rows (complete original dataset)`,arrow:!0,children:t.jsx(T.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),sx:re})]})]}),t.jsxs(o.FormControl,{component:"fieldset",children:[t.jsx(o.FormLabel,{component:"legend",sx:{fontSize:"0.6875rem",fontWeight:700,color:"text.secondary",letterSpacing:"0.08em",mb:1,textTransform:"uppercase"},children:"Columns"}),t.jsxs(o.RadioGroup,{value:C,onChange:Z=>E(Z.target.value),children:[t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small",sx:h}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Visible columns only"}),t.jsx(o.Tooltip,{title:`Export ${i} visible column${i!==1?"s":""}`,arrow:!0,children:t.jsx(T.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),sx:{...re,mb:.5}}),t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small",sx:h}),label:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"All columns"}),t.jsx(o.Tooltip,{title:`Export all ${s} columns (including hidden)`,arrow:!0,children:t.jsx(T.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),sx:re})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Divider,{sx:{mb:2}}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[{label:"Format",value:X[z]},{label:"Rows to export",value:g.toLocaleString()},{label:"Columns to export",value:String(k)},{label:"Estimated file size",value:Xr(_.estimatedBytes),highlight:_.hasBlockingViolation?"error.main":_.hasWarning?"warning.main":void 0}].map(({label:Z,value:pe,highlight:he})=>t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary"},children:Z}),t.jsx(o.Typography,{sx:{fontWeight:500,fontSize:"0.8125rem",color:he??"text.primary"},children:pe})]},Z))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:D(v.text.primary,.015)},children:[_.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx(T.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"error.main",fontWeight:500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:f,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:2.5,borderRadius:"8px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:F,disabled:_.hasBlockingViolation,variant:"contained",startIcon:t.jsx(T.Download,{sx:{fontSize:16}}),sx:{fontSize:"0.875rem",px:2.5,borderRadius:"8px"},children:["Download ",X[z]]})]})]})})}function Ku({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(T.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx(T.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 Xu({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=5e3}){p.useEffect(()=>{if(n){const c=setTimeout(()=>{r()},i);return()=>clearTimeout(c)}},[n,i,r]);const l=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx(T.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx(T.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx(T.InfoOutlined,{sx:{fontSize:20}})}}})(),d=sl(e);return t.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:l.severity,icon:l.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${l.severity}.main`},children:t.jsx(T.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${l.severity}.main`,boxShadow:3},children:[t.jsxs(o.AlertTitle,{sx:{fontWeight:600},children:[e.context.charAt(0).toUpperCase()+e.context.slice(1)," Error"]}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize"},children:d}),e.details&&process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e.details,null,2)})]})})}class Qu extends p.Component{constructor(n){super(n);Kn(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){Et.error("urm:error-boundary","Caught unhandled component error",n,i),this.props.onError&&this.props.onError(n,i)}render(){var n,i;return this.state.hasError?this.props.fallback?this.props.fallback:t.jsx(o.Paper,{sx:{bgcolor:s=>D(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(T.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:600},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((n=this.state.error)==null?void 0:n.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:s=>D(s.palette.error.main,.12),p:1.5,borderRadius:1,overflow:"auto",maxHeight:170},children:(i=this.state.error)==null?void 0:i.stack}),t.jsx(o.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx(T.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function Zu({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(T.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx(T.Close,{sx:{fontSize:16}})}),children:[t.jsxs(o.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function yo({children:e,feature:r,onError:n}){return t.jsx(Qu,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(Zu,{feature:r}),children:e})}const ep=[{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"}];function Yr({children:e,active:r}){return t.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5},children:e})}function rp({open:e,onClose:r,config:n,onApply:i}){const[s,l]=p.useState(0),[d,c]=p.useState(n),u=()=>c(n),m=()=>c(Ke),f=()=>{i(d),r()},x={sort:y=>c(w=>({...w,sort:{...w.sort,...y}})),filter:y=>c(w=>({...w,filter:{...w.filter,...y}})),columns:y=>c(w=>({...w,columns:{...w.columns,...y}})),grouping:y=>c(w=>({...w,grouping:{...w.grouping,...y}})),export:y=>c(w=>({...w,export:{...w.export,...y}}))},v=y=>{const w=d.filter.allowedOperators,C=w.includes(y)?w.filter(E=>E!==y):[...w,y];C.length!==0&&x.filter({allowedOperators:C})},b=y=>{const w=d.export.allowedFormats,C=w.includes(y)?w.filter(E=>E!==y):[...w,y];C.length!==0&&x.export({allowedFormats:C})},z=[{label:"Sort",icon:t.jsx(T.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:t.jsx(T.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:t.jsx(T.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:t.jsx(T.Layers,{sx:{fontSize:17}})},{label:"Export",icon:t.jsx(T.Download,{sx:{fontSize:17}})}],S=y=>JSON.stringify(d[y])===JSON.stringify(Ke[y]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:y=>Ne(y),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:y=>`0 8px 32px ${D(y.palette.common.black,.2)}`}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(o.Box,{sx:{width:32,height:32,borderRadius:"8px",bgcolor:y=>D(y.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem"},children:"⚙️"}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:t.jsx(T.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:t.jsx(o.Tabs,{value:s,onChange:(y,w)=>l(w),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:z.map((y,w)=>t.jsx(o.Tab,{label:y.label,icon:y.icon,iconPosition:"start"},w))})}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:3,py:0},children:[t.jsxs(Yr,{active:s===0,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!S("sort")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),t.jsx(o.Slider,{value:d.sort.maxLevels,onChange:(y,w)=>x.sort({maxLevels:w}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]}),t.jsxs(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:['The "Add sort column" button is hidden once users reach this limit. Default is'," ",t.jsx("strong",{children:"5"}),"."]})]}),t.jsxs(Yr,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!S("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),t.jsx(o.Slider,{value:d.filter.maxConditions,onChange:(y,w)=>x.filter({maxConditions:w}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter type dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(y=>t.jsxs(o.Box,{sx:{mb:1.5},children:[t.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:y}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:ep.filter(w=>w.group===y).map(w=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:d.filter.allowedOperators.includes(w.value),onChange:()=>v(w.value)}),label:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:w.label}),sx:{mr:1.5}},w.value))})]},y))]})]}),t.jsxs(Yr,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!S("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),t.jsx(o.Slider,{value:d.columns.maxVisible,onChange:(y,w)=>x.columns({maxVisible:w}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),t.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(o.Slider,{value:d.columns.minColumnWidth,onChange:(y,w)=>x.columns({minColumnWidth:w}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:y=>`${y}px`})]}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),t.jsx(o.Slider,{value:d.columns.maxColumnWidth,onChange:(y,w)=>x.columns({maxColumnWidth:w}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:y=>`${y}px`})]})]})]})]}),t.jsxs(Yr,{active:s===3,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!S("grouping")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(y=>t.jsxs(o.Box,{onClick:()=>x.grouping({maxLevels:y}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:d.grouping.maxLevels===y?"primary.main":"divider",bgcolor:d.grouping.maxLevels===y?w=>D(w.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:w=>D(w.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:d.grouping.maxLevels===y?"primary.main":"text.secondary"},children:y}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][y-1]})]},y))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:d.grouping.allowNested,onChange:y=>x.grouping({allowNested:y.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:d.grouping.allowCollapse,onChange:y=>x.grouping({allowCollapse:y.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),t.jsx(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),t.jsx(Yr,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!S("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog and the bulk export action. At least one must remain checked."}),t.jsx(o.FormGroup,{sx:{gap:1},children:tp.map(y=>t.jsxs(o.Box,{onClick:()=>b(y.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:d.export.allowedFormats.includes(y.value)?"primary.main":"divider",bgcolor:d.export.allowedFormats.includes(y.value)?w=>D(w.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:d.export.allowedFormats.includes(y.value),onChange:()=>b(y.value),onClick:w=>w.stopPropagation()}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500},children:y.label}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:y.desc})]})]},y.value))})]})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid",borderColor:"divider",bgcolor:y=>D(y.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx(T.RestartAlt,{sx:{fontSize:18}}),onClick:m,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:y=>D(y.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),t.jsx(o.Button,{onClick:f,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const op=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],np={1:"1st",2:"2nd",3:"3rd",4:"4th",5:"5th",6:"6th",7:"7th",8:"8th",9:"9th",10:"10th",11:"11th",12:"12th",13:"13th",14:"14th",15:"15th",16:"16th",17:"17th",18:"18th",19:"19th",20:"20th",21:"21st",22:"22nd",23:"23rd",24:"24th",25:"25th",26:"26th",27:"27th",28:"28th"};function jo(e,r,n,i,s=new Date){const[l,d]=r.split(":").map(Number),c=new Date(s);if(c.setSeconds(0,0),c.setHours(l,d,0,0),e==="daily")return c<=s&&c.setDate(c.getDate()+1),c.toISOString();if(e==="weekly"){const u=n??1,m=c.getDay();let f=u-m;return f<0&&(f+=7),f===0&&c<=s&&(f=7),c.setDate(c.getDate()+f),c.toISOString()}if(e==="monthly"){const u=Math.min(i??1,28);return c.setDate(u),c<=s&&(c.setMonth(c.getMonth()+1),c.setDate(u)),c.toISOString()}return c.toISOString()}function ip(e){const r=Es(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${op[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${np[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function Es(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function sp(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),l=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${l}m`:l>0?`in ${l}m`:"in less than a minute"}function ap(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=Es(`${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 Bs(e){return`urm_schedules_${e}`}function Ds(e){try{const r=localStorage.getItem(Bs(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 Os(e,r){try{localStorage.setItem(Bs(e),JSON.stringify(r))}catch{}}const lp=[{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"}],cp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,$s={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},br={"& .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 dp({initial:e=$s,isEditing:r=!1,onSave:n,onBack:i}){const[s,l]=p.useState(e),[d,c]=p.useState(!1),[u,m]=p.useState(!1),f=(b,z)=>l(S=>({...S,[b]:z})),x=s.email.trim().length>0&&!cp.test(s.email.trim()),v=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!x;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:b=>D(b.palette.text.primary,.06)}},children:t.jsx(T.ArrowBack,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:r?"Edit schedule":"New schedule"})]}),t.jsx(o.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:b=>{f("name",b.target.value),d&&b.target.value.trim()&&c(!1)},onBlur:()=>c(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:d&&!s.name.trim(),helperText:d&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:br}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:br,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:b=>f("frequency",b.target.value),children:[t.jsx(o.MenuItem,{value:"daily",children:"Daily"}),t.jsx(o.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(o.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:br,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:b=>f("dayOfWeek",Number(b.target.value)),children:lp.map(b=>t.jsx(o.MenuItem,{value:b.value,children:b.label},b.value))})]}),s.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:b=>f("dayOfMonth",Number(b.target.value)),inputProps:{min:1,max:28},error:s.dayOfMonth<1||s.dayOfMonth>28,helperText:s.dayOfMonth<1||s.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:br}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:b=>f("time",b.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:br}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:br,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:b=>f("format",b.target.value),children:[t.jsx(o.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),t.jsx(o.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(o.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),t.jsxs(o.RadioGroup,{row:!0,value:s.scope,onChange:b=>f("scope",b.target.value),sx:{gap:2},children:[t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"All rows"})}),t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:b=>f("email",b.target.value),onBlur:()=>m(!0),placeholder:"user@company.com",error:u&&x,helperText:u&&x?"Enter a valid email address":void 0,InputProps:{startAdornment:t.jsx(T.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:br}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[t.jsx(T.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{lineHeight:1.5},children:"Opens your device's email app when the schedule fires. Requires a default mail app (e.g. Outlook, Mail) on this device."})]})]}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(o.Button,{onClick:i,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:b=>D(b.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>v&&n(s),disabled:!v,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function up({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>oo(i),boxShadow:i=>{var s;return`0 8px 32px ${D(((s=i.palette.common)==null?void 0:s.black)??"#000",.14)}`}}},children:[t.jsxs(o.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(o.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>D(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(T.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Delete Schedule"}),t.jsxs(o.Typography,{sx:{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:l}){const d=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:d?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:d?c=>D(c.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:d?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:d?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:d?c=>D(c.palette.success.main,.1):c=>D(c.palette.text.primary,.06),color:d?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:ip(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:c=>D(c.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:c=>D(c.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx(T.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:c=>D(c.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[d&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",sp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",ap(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:c=>D(c.palette.primary.main,.08)}},children:t.jsx(T.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:d?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:d?"warning.main":"success.main","&:hover":{bgcolor:d?c=>D(c.palette.warning.main,.08):c=>D(c.palette.success.main,.08)}},children:d?t.jsx(T.Pause,{sx:{fontSize:15}}):t.jsx(T.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:c=>D(c.palette.primary.main,.08)}},children:t.jsx(T.Download,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Delete",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>l(e.id),sx:{color:"error.main","&:hover":{bgcolor:c=>D(c.palette.error.main,.08)}},children:t.jsx(T.Delete,{sx:{fontSize:15}})})})]})]})]})}function xp({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s}){const[l,d]=p.useState([]),[c,u]=p.useState({type:"list"}),[m,f]=p.useState(0),[x,v]=p.useState(null);p.useEffect(()=>{e&&(d(Ds(n)),u({type:"list"}))},[e,n]),p.useEffect(()=>{if(!e)return;const a=setInterval(()=>f(_=>_+1),3e4);return()=>clearInterval(a)},[e]);const b=p.useCallback(a=>{d(a),Os(n,a)},[n]),z=a=>{const _=jo(a.frequency,a.time,a.dayOfWeek,a.dayOfMonth),F={id:`sched-${Date.now()}`,reportId:n,name:a.name.trim(),frequency:a.frequency,dayOfWeek:a.frequency==="weekly"?a.dayOfWeek:void 0,dayOfMonth:a.frequency==="monthly"?a.dayOfMonth:void 0,time:a.time,format:a.format,scope:a.scope,email:a.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:_,runCount:0};b([...l,F]),u({type:"list"})},S=a=>{if(c.type!=="edit")return;const _=c.schedule,F=jo(a.frequency,a.time,a.dayOfWeek,a.dayOfMonth);b(l.map(X=>X.id===_.id?{..._,name:a.name.trim(),frequency:a.frequency,dayOfWeek:a.frequency==="weekly"?a.dayOfWeek:void 0,dayOfMonth:a.frequency==="monthly"?a.dayOfMonth:void 0,time:a.time,format:a.format,scope:a.scope,email:a.email.trim()||void 0,nextRunAt:F}:X)),u({type:"list"})},y=a=>{b(l.map(_=>{if(_.id!==a)return _;const F=_.isActive?_.nextRunAt:jo(_.frequency,_.time,_.dayOfWeek,_.dayOfMonth);return{..._,isActive:!_.isActive,nextRunAt:F}}))},w=a=>{s(a);const _=new Date().toISOString();b(l.map(F=>F.id===a.id?{...F,lastRunAt:_,runCount:F.runCount+1}:F))},C=a=>{const _=l.find(F=>F.id===a)??null;v(_)},E=()=>{x&&(b(l.filter(a=>a.id!==x.id)),v(null))},g=a=>({name:a.name,frequency:a.frequency,dayOfWeek:a.dayOfWeek??1,dayOfMonth:a.dayOfMonth??1,time:a.time,format:a.format,scope:a.scope,email:a.email??""}),k=c.type!=="list",L=l.filter(a=>a.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:k,PaperProps:{sx:{borderRadius:a=>Ne(a),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:6}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,borderBottom:"1px solid",borderColor:"divider",flexShrink:0,minHeight:0},children:[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:a=>D(a.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(T.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:600,lineHeight:1},children:"Scheduled Reports"}),t.jsx(Cr,{content:jr.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:a=>D(a.palette.text.primary,.06)}},children:t.jsx(T.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[k&&t.jsx(dp,{initial:c.type==="edit"?g(c.schedule):$s,isEditing:c.type==="edit",onSave:c.type==="edit"?S:z,onBack:()=>u({type:"list"})}),c.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:l.length===0?"No schedules yet":`${L} of ${l.length} active`}),t.jsx(o.Button,{startIcon:t.jsx(T.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>u({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),l.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx(T.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,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:l.map(a=>t.jsx(pp,{schedule:a,tick:m,onToggle:y,onRunNow:w,onEdit:_=>u({type:"edit",schedule:_}),onDelete:C},a.id))})]})]}),c.type==="list"&&t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:a=>D(a.palette.warning.main,.06),border:"1px solid",borderColor:a=>D(a.palette.warning.main,.2)},children:[t.jsx(T.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:a=>D(a.palette.text.primary,.06)}},children:"Close"})]})]}),x&&t.jsx(up,{scheduleName:x.name,onConfirm:E,onCancel:()=>v(null)})]})}const mp=6e4;function fp({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:l,columnVisibility:d,columnOrder:c,filters:u,sortStack:m,onFired:f}){const x=p.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:l,columnVisibility:d,columnOrder:c,filters:u,sortStack:m,onFired:f});p.useEffect(()=>{x.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:l,columnVisibility:d,columnOrder:c,filters:u,sortStack:m,onFired:f}});const v=p.useCallback(b=>{var a,_;const{reportName:z,uploadedData:S,processedData:y,schema:w,activeView:C,columnVisibility:E,columnOrder:g,filters:k,sortStack:L}=x.current;try{const F=b.scope==="all"?S:y,X=wo(F,w,k,L,C,E,g),re=`${b.name}_scheduled`;switch(b.format){case"csv":ko(X,re,{scope:b.scope});break;case"excel":To(X,re,{scope:b.scope});break;case"json":Io(X,re,{scope:b.scope});break}if(b.email){const h=encodeURIComponent(`Scheduled Report: ${b.name}`),V=encodeURIComponent(`Your scheduled report "${b.name}" has been generated.
89
+ ]`})})]}),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:500,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:500,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:500,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:500,minWidth:80},children:"Date:"}),t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",t.jsx(o.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),t.jsxs(o.Box,{component:"ul",sx:{m:0,pl:2.5,"& li":{fontSize:"body2.fontSize",color:"text.secondary",mb:.5}},children:[t.jsx("li",{children:"Each object in the array represents one row in the report."}),t.jsx("li",{children:"The keys of the JSON objects become report columns."}),t.jsx("li",{children:"All objects should have consistent keys for proper column detection."}),t.jsx("li",{children:"Column names are case-sensitive and preserve spacing."})]})]})]})}),t.jsx(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:t.jsx(o.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:n=>`${n.shape.borderRadius}px`,boxShadow:n=>ce(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>ce(n,"hoverButton")},"&:active":{boxShadow:n=>ce(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function Fd({onFileUpload:e,onError:r,isUploading:n}){const[i,s]=p.useState(!1),[l,d]=p.useState(""),[c,u]=p.useState(!1),h=p.useRef(null),g=async j=>{if(!j.name.endsWith(".json")){r("Only .json files are allowed");return}const y=10*1024*1024;if(j.size>y){r("File size exceeds 10MB limit");return}d(j.name);try{const $=await j.text();let S;try{S=JSON.parse($)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(S)){r("JSON must be an array of objects");return}if(S.length===0){r("No data rows found in JSON file");return}e(S)}catch{r("Network error — please try again")}finally{d("")}},f=j=>{j.preventDefault(),s(!0)},b=j=>{j.preventDefault(),s(!1)},v=j=>{j.preventDefault(),s(!1);const y=j.dataTransfer.files[0];y&&g(y)},T=()=>{var j;(j=h.current)==null||j.click()},C=j=>{var $;const y=($=j.target.files)==null?void 0:$[0];y&&g(y)},m=j=>{j.stopPropagation(),u(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:f,onDragLeave:b,onDrop:v,onPaste:j=>j.preventDefault(),onClick:T,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?j=>B(j.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:n?.5:1,pointerEvents:n?"none":"auto","&:hover":{borderColor:i?"primary.main":"text.secondary"}},children:[t.jsx(o.Box,{component:"input",ref:h,type:"file",accept:".json",onChange:C,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:500,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:j=>B(j.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(z.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[t.jsx(o.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),t.jsx(o.IconButton,{onClick:m,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx(z.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(Os,{isOpen:c,onClose:()=>u(!1)})]})}function Vd({schema:e,onConfirm:r,hasConflicts:n}){return t.jsxs(o.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[t.jsxs(o.Box,{sx:{mb:2},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontWeight:600,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:600},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=>B(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(z.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 Hd({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=>B(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=>B(n.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(z.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(o.Typography,{variant:"h6",color:"error.main",sx:{fontWeight:600,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(z.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function _s({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=>B(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx(z.Description,{sx:{fontSize:36,color:"primary.main"}})}),t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:500,mb:1,color:"text.primary",fontSize:"1.125rem"},children:e}),t.jsx(o.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:"0.875rem",lineHeight:1.5},children:r})]})}function Ud({value:e,onChange:r,searchHistory:n,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:l,disabled:d}){const[c,u]=p.useState(!1),[h,g]=p.useState(!1),[f,b]=p.useState(-1),v=p.useRef(null),T=p.useRef(null);p.useEffect(()=>{function A(F){v.current&&!v.current.contains(F.target)&&(u(!1),g(!1))}return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[]);const C=p.useCallback(()=>{g(!0),b(-1),n.length>0&&u(!0)},[n.length]),m=p.useCallback(A=>{r(A),b(-1)},[r]),j=p.useCallback(A=>{var F;r(A),i(A),u(!1),(F=T.current)==null||F.blur()},[r,i]),y=p.useCallback(A=>{b(-1),j(A)},[j]),$=p.useCallback(A=>{var F;A.key==="Enter"?f>=0&&f<n.length?(A.preventDefault(),y(n[f].query)):e.trim()&&j(e.trim()):A.key==="Escape"?(u(!1),b(-1),(F=T.current)==null||F.blur()):A.key==="ArrowDown"?(A.preventDefault(),n.length>0&&(c||u(!0),b(J=>J<n.length-1?J+1:J))):A.key==="ArrowUp"&&(A.preventDefault(),b(J=>J>0?J-1:-1))},[f,n,e,c,y,j]),S=p.useCallback(()=>{var A;r(""),(A=T.current)==null||A.focus()},[r]),I=p.useMemo(()=>n.filter(A=>A.isFavourite),[n]),N=p.useMemo(()=>n.filter(A=>!A.isFavourite),[n]),a=c&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:v,children:[t.jsx(o.TextField,{inputRef:T,size:"small",fullWidth:!0,value:e,onChange:A=>m(A.target.value),onFocus:C,onKeyDown:$,placeholder:"Search data...",disabled:d,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:A=>B(A.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:A=>B(A.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(z.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:S,edge:"end",sx:{mr:-.5},children:t.jsx(z.Close,{sx:{fontSize:16}})})}):null}}),a&&t.jsxs(o.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[I.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:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),I.map((A,F)=>t.jsx(Vi,{entry:A,isSelected:f===F,onClick:()=>y(A.query),onToggleFavourite:()=>s(A.query),onDelete:()=>l(A.query)},`fav-${A.query}`))]}),N.length>0&&t.jsxs(o.Box,{sx:{py:1},children:[I.length>0&&t.jsx(o.Divider,{}),t.jsx(o.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:600,textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),N.map((A,F)=>{const J=I.length+F;return t.jsx(Vi,{entry:A,isSelected:f===J,onClick:()=>y(A.query),onToggleFavourite:()=>s(A.query),onDelete:()=>l(A.query)},`recent-${A.query}`)})]})]})]})}const Vi=p.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:l}){const d=p.useCallback(u=>{u.stopPropagation(),s()},[s]),c=p.useCallback(u=>{u.stopPropagation(),l()},[l]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>B(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>B(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(o.IconButton,{size:"small",onClick:d,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?t.jsx(z.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx(z.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(o.IconButton,{size:"small",onClick:c,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(z.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function Gd({views:e,activeViewId:r,isDirty:n,onSelectView:i,onCreateView:s,onToggleDefault:l,onToggleFavorite:d,onRestoreView:c,onPermanentDelete:u,onEditView:h,onCloneView:g,onCopyLink:f,onDeleteView:b,onPromoteToGlobal:v,isReadOnly:T,isAdmin:C=!1}){const m=rt(),[j,y]=p.useState(!1),[$,S]=p.useState(!1),[I,N]=p.useState({top:0,left:0}),[a,A]=p.useState(null),[F,J]=p.useState(null),ee=p.useRef(null),x=p.useRef(null),R=e.find(D=>D.id===r),P=R==null?void 0:R.isDefault,te=(D,Z)=>D.name.localeCompare(Z.name),ae=e.filter(D=>D.scope==="global"&&!D.isDeleted).sort(te),Q=e.filter(D=>D.scope!=="global"&&!D.isDeleted).sort(te),re=e.filter(D=>D.isFavorite&&!D.isDeleted).sort(te),he=e.filter(D=>D.isDeleted);p.useEffect(()=>{if(j&&x.current){const D=x.current.getBoundingClientRect();N({top:D.bottom+window.scrollY+8,left:D.right+window.scrollX-320})}},[j]),p.useEffect(()=>{const D=Z=>{ee.current&&!ee.current.contains(Z.target)&&x.current&&!x.current.contains(Z.target)&&y(!1)};return j&&document.addEventListener("mousedown",D),()=>{document.removeEventListener("mousedown",D)}},[j]);const L=D=>{if(n&&D!==r){A(D),y(!1);return}i(D),y(!1)},K=()=>{a&&(i(a),A(null))},ne=()=>{A(null)},le=(D,Z=!1)=>{const de=D.scope==="global",oe=!T&&(!de||C),ye=C&&!de;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===D.id?B(m.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===D.id?B(m.palette.primary.main,.12):m.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>L(D.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===D.id&&t.jsx(z.Check,{sx:{fontSize:16,flexShrink:0}}),r!==D.id&&t.jsx(o.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(o.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===D.id?m.palette.primary.dark:m.palette.text.primary,fontWeight:r===D.id?500:400},children:D.name}),Z&&t.jsx(o.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:m.palette.text.secondary,backgroundColor:m.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[oe&&d&&t.jsx(o.IconButton,{onClick:G=>{G.stopPropagation(),d(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:D.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(z.Star,{sx:{fontSize:16}})}),oe&&l&&!D.isDefault&&t.jsx(o.IconButton,{onClick:G=>{G.stopPropagation(),l(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"Set as default",children:t.jsx(z.RadioButtonUnchecked,{sx:{fontSize:16}})}),(oe||ye)&&(h||g||f||b||ye&&v)&&t.jsx(o.IconButton,{onClick:G=>{G.stopPropagation(),J({el:G.currentTarget,view:D})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"More actions",children:t.jsx(z.MoreVert,{sx:{fontSize:16}})})]})]},D.id)},U=D=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:m.palette.action.hover},children:[t.jsx(o.Typography,{sx:{color:m.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:D.name}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[c&&t.jsx(o.IconButton,{onClick:Z=>{Z.stopPropagation(),c(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"Restore view",children:t.jsx(z.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(o.IconButton,{onClick:Z=>{Z.stopPropagation(),u(D.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},title:"Delete permanently",children:t.jsx(z.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},D.id),se=n||!P,ie=n;return t.jsxs(o.Box,{sx:{position:"relative"},children:[t.jsxs(o.Button,{ref:x,onClick:()=>y(!j),variant:"outlined",size:"small",endIcon:t.jsx(z.KeyboardArrowDown,{sx:{fontSize:18}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.8125rem",textTransform:"none",color:se?"warning.main":"text.primary",borderColor:se?"warning.main":"divider",bgcolor:se?B(m.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:se?"warning.dark":"primary.main",bgcolor:se?B(m.palette.warning.main,.2):B(m.palette.text.primary,.06),color:se?"warning.dark":"text.primary"}},title:`View: ${(R==null?void 0:R.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(R==null?void 0:R.name)||"Default View"}),ie&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),j&&ts.createPortal(t.jsxs(o.Box,{ref:ee,sx:{position:"fixed",width:"320px",backgroundColor:m.palette.background.paper,border:`1px solid ${m.palette.divider}`,borderRadius:1,boxShadow:m.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:I.top,left:I.left},children:[ae.length>0&&t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),ae.map(D=>le(D,D.isDefault))]}),re.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx(z.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),re.map(D=>le(D))]})]}),Q.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsx(o.Typography,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),Q.map(D=>le(D))]})]}),he.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),t.jsxs(o.Box,{sx:{py:.5},children:[t.jsxs(o.Button,{onClick:()=>S(!$),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:m.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},children:[t.jsxs(o.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",he.length,")"]}),t.jsx(z.ChevronRight,{sx:{fontSize:16}})]}),$&&t.jsx(o.Box,{sx:{backgroundColor:m.palette.action.hover},children:he.map(D=>U(D))})]})]}),t.jsx(o.Box,{sx:{borderTop:`1px solid ${m.palette.divider}`}}),t.jsxs(o.Button,{onClick:()=>{s(),y(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:m.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:m.palette.action.hover}},children:[t.jsx(z.Add,{sx:{fontSize:16}}),t.jsx(o.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(o.Popover,{open:!!F,anchorEl:(F==null?void 0:F.el)||null,onClose:()=>J(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[h&&t.jsxs(o.MenuItem,{onClick:()=>{F&&h(F.view.id),J(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(z.Edit,{sx:{fontSize:18}}),"Edit"]}),f&&t.jsxs(o.MenuItem,{onClick:()=>{F&&f(F.view.id),J(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(z.Link,{sx:{fontSize:18}}),"Copy Link"]}),g&&t.jsxs(o.MenuItem,{onClick:()=>{F&&g(F.view.id),J(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(z.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),v&&C&&(F==null?void 0:F.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{F&&v(F.view.id),J(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(z.Language,{sx:{fontSize:18}}),"Promote to Global"]}),b&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{F&&b(F.view.id),J(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx(z.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(o.Dialog,{open:a!==null,onClose:ne,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:fo(m)}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1},children:[t.jsx(z.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:ne,variant:"text",children:"Stay here"}),t.jsx(o.Button,{onClick:K,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function Yd({columnName:e,columnType:r="string",currentSort:n,hasFilters:i,isInSortStack:s,isReadOnly:l=!1,hasModifications:d=!1,position:c,onSortAscending:u,onSortDescending:h,onRemoveSort:g,onFilter:f,onClearFilter:b,onGroupByColumn:v,onHideColumn:T,onManageColumns:C,onResetLayout:m,onClose:j}){const y=rt(),$=y.palette,S=p.useRef(null);p.useEffect(()=>{if(!S.current)return;const J=S.current,ee=J.getBoundingClientRect(),x=window.innerWidth,R=window.innerHeight;ee.right>x-8&&(J.style.left=`${x-ee.width-8}px`),ee.bottom>R-8&&(J.style.top=`${R-ee.height-8}px`)},[c]),p.useEffect(()=>{const J=x=>{S.current&&!S.current.contains(x.target)&&j()},ee=x=>{x.key==="Escape"&&j()};return document.addEventListener("mousedown",J),document.addEventListener("keydown",ee),()=>{document.removeEventListener("mousedown",J),document.removeEventListener("keydown",ee)}},[j]);const I=p.useCallback(J=>()=>{J(),j()},[j]),N=(n==null?void 0:n.direction)==="asc",a=(n==null?void 0:n.direction)==="desc",A=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",F=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return ts.createPortal(t.jsxs(o.Paper,{ref:S,elevation:0,sx:{position:"fixed",left:`${c.x}px`,top:`${c.y}px`,zIndex:y.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:fo(y),overflow:"hidden",boxShadow:`0 4px 20px ${B($.common.black,.12)}, 0 1px 4px ${B($.common.black,.06)}`},children:[!l&&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:"0.8125rem",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 (${A})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:I(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:N?"primary.main":"text.secondary",bgcolor:N?B($.primary.main,.1):"transparent","&:hover":{bgcolor:B($.primary.main,.08),color:"primary.main"}},children:t.jsx(z.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${F})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:I(()=>h(e)),sx:{p:.625,borderRadius:"6px",color:a?"primary.main":"text.secondary",bgcolor:a?B($.primary.main,.1):"transparent","&:hover":{bgcolor:B($.primary.main,.08),color:"primary.main"}},children:t.jsx(z.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:I(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:B($.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx(z.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(o.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(o.MenuItem,{onClick:I(()=>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(z.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&&!l&&t.jsxs(o.MenuItem,{onClick:I(()=>b(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:B($.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(z.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!l&&v&&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:I(()=>v(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(z.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:[!l&&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:I(()=>T(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(z.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:I(C),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:B($.primary.main,.08),color:"primary.main"}},children:t.jsx(z.Settings,{sx:{fontSize:16}})})})]}),l&&t.jsxs(o.MenuItem,{onClick:I(C),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(z.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!l&&d&&m&&t.jsxs(o.MenuItem,{onClick:I(m),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:B($.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(z.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(o.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const qd=176,Hi="COLUMN_HEADER",Jd=p.memo(function({column:r,index:n,sortRule:i,hasFilters:s,isInSortStack:l,isReadOnly:d=!1,hasModifications:c=!1,width:u,onColumnClick:h,onMoveColumn:g,onColumnDragEnd:f,onResizeStart:b,onSortAscending:v,onSortDescending:T,onRemoveSort:C,onOpenFilterForColumn:m,onClearFiltersForColumn:j,onGroupByColumn:y,onHideColumn:$,onManageColumns:S,onResetLayout:I}){const a=rt().urmTable,A=p.useRef(null),[F,J]=p.useState(!1),[ee,x]=p.useState({x:0,y:0}),[{handlerId:R,isOver:P},te]=Vt.useDrop({accept:Hi,collect(U){return{handlerId:U.getHandlerId(),isOver:U.isOver()}},hover(U,se){var G;if(!A.current)return;const ie=U.index,D=n;if(ie===D)return;const Z=(G=A.current)==null?void 0:G.getBoundingClientRect(),de=(Z.right-Z.left)/2,oe=se.getClientOffset(),ye=((oe==null?void 0:oe.x)??0)-Z.left;ie<D&&ye<de||ie>D&&ye>de||(g(ie,D),U.index=D)}}),[{isDragging:ae},Q]=Vt.useDrag({type:Hi,item:()=>({index:n,columnName:r.name}),collect:U=>({isDragging:U.isDragging()}),end:()=>{f==null||f()}});Q(te(A));const re=p.useCallback(U=>{U.preventDefault(),U.stopPropagation(),x({x:U.clientX,y:U.clientY}),J(!0)},[]),he=p.useCallback(()=>J(!1),[]),L=p.useCallback(()=>{h(r.name)},[h,r.name]),K=p.useCallback(U=>{U.stopPropagation(),m(r.name)},[m,r.name]),ne=p.useCallback(()=>i?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx(z.ArrowUpward,{sx:{fontSize:13,color:"primary.main"}}):t.jsx(z.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(z.FilterList,{onClick:K,titleAccess:"Active filter on this column — click to edit",sx:{ml:.5,fontSize:13,color:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.15)"},transition:"transform 0.12s ease"}}):null,[s,K]);return t.jsxs(t.Fragment,{children:[t.jsxs(o.TableCell,{ref:A,"data-handler-id":R,"data-column-index":n,onClick:L,onContextMenu:re,sx:{position:"sticky",top:0,zIndex:5,textAlign:(a==null?void 0:a.cellAlignH)??"left",verticalAlign:(a==null?void 0:a.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:700,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:"primary.main",opacity:ae?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:P?U=>B(U.palette.primary.main,.08):(a==null?void 0:a.headerBg)??"action.hover",boxShadow:U=>`0 1px 0 ${B(U.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(a==null?void 0:a.rowDivider)??"1px solid",borderRight:a==null?void 0:a.colDivider,borderColor:"divider",py:0,px:(a==null?void 0:a.cellPaddingX)??2,"&:hover":{bgcolor:U=>B(U.palette.primary.main,.1),color:"primary.dark"},width:u?`${u}px`:`${qd}px`},children:[t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[et(r.name),ne(),le()]}),t.jsx(o.Box,{draggable:!1,onDragStart:U=>U.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:U=>{U.preventDefault(),U.stopPropagation(),b(U,r.name)},onClick:U=>U.stopPropagation(),children:t.jsx(o.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),P&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),F&&t.jsx(Yd,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:l,isReadOnly:d,hasModifications:c,position:ee,onSortAscending:v,onSortDescending:T,onRemoveSort:C,onFilter:m,onClearFilter:j,onGroupByColumn:y,onHideColumn:$,onManageColumns:S,onResetLayout:I,onClose:he})]})}),Kd={active:"success",completed:"success",approved:"success",success:"success",done:"success",contract:"info","in progress":"info","in review":"info",review:"info",pending:"info","on leave":"error","on hold":"warning",probation:"warning",cancelled:"error",rejected:"error",blocked:"error",inactive:"neutral","not started":"neutral",paused:"neutral"};function Lo(e,r){const n=Kd[r.toLowerCase().trim()];if(!n||n==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.palette[n];return{bg:B(i.main,e.palette.mode==="dark"?.24:.12),color:e.palette.mode==="dark"?i.light:i.dark}}function Xd(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.warning.dark;case"critical":case"urgent":return e.palette.error.main;default:return}}const Qd={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"}};function Zd(e,r){const n=Qd[r];return n?e.palette[n.hue][n.shade]:e.palette.text.secondary}function Ze(e){return B(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function eu(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:500,bgcolor:n=>Lo(n,r).bg,color:n=>Lo(n,r).color,whiteSpace:"nowrap",lineHeight:1.5},children:e})}function tu(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 eu(n);if(/\b(priority|severity|urgency)\b/.test(i)){const s=n.toLowerCase().trim();return t.jsx(o.Box,{component:"span",sx:l=>{const d=Xd(l,s);return d?{color:d,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:n})}return typeof r=="boolean"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:n})}function ru(e){const r=e.find(s=>{const l=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(l)})||e[0]||null,n=e.find(s=>{const l=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(l)&&s!==r})||null,i=e.filter(s=>s!==r&&s!==n).slice(0,4);return{primaryCol:r,idCol:n,bodyColumns:i}}function ou({row:e,rowIndex:r,visibleColumns:n,isSelected:i,isReadOnly:s,onToggleSelection:l,onView:d,onEdit:c,onDuplicate:u,onDelete:h}){const[g,f]=p.useState(null),[b,v]=p.useState(!1),{primaryCol:T,idCol:C,bodyColumns:m}=p.useMemo(()=>ru(n),[n]),j=T?e[T.name]:null,y=C?e[C.name]:null,$=b||i||!!g;return t.jsxs(o.Box,{onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),onClick:()=>l(r),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:"1px solid",borderColor:i?"primary.main":S=>B(S.palette.divider,.8),borderWidth:i?2:1,borderRadius:"12px",cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?S=>`0 0 0 3px ${B(S.palette.primary.main,.15)}, 0 2px 8px ${B(S.palette.common.black,.08)}`:b?S=>ce(S,"cardHover"):S=>ce(S,"cardRest"),transform:b&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:S=>B(S.palette.primary.main,.03)}},children:[t.jsx(o.Box,{sx:{px:2,pt:2,pb:1.5},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,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:{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:[m.map(S=>t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{color:"text.secondary",fontWeight:500,fontSize:"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:et(S.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[S.name]??""),children:tu(S,e[S.name])})]},S.name)),m.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:S=>B(S.palette.action.hover,.1),minHeight:40},children:[t.jsx(o.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:y?.85:0,userSelect:"none"},children:y?String(y):" "}),t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:$?1:0,transition:"opacity 0.15s ease"},onClick:S=>S.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:S=>{S.stopPropagation(),f(S.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:S=>B(S.palette.text.primary,.08)}},children:t.jsx(z.MoreVert,{sx:{fontSize:17}})})})})]}),t.jsxs(o.Popover,{open:!!g,anchorEl:g,onClose:()=>f(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{minWidth:180,py:.5,borderRadius:"10px",boxShadow:S=>ce(S,"popover")}},onClick:S=>S.stopPropagation(),children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{d(e),f(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[t.jsx(z.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!s&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{c(e,r),f(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[t.jsx(z.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!s&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{u(r,e),f(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5},children:[t.jsx(z.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),!s&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5,mx:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{h(r,e),f(null)},sx:{py:1,px:2,gap:1.5,borderRadius:"6px",mx:.5,color:"error.main"},children:[t.jsx(z.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]})]})}function nu({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=>ce(s,"flatHover"),"&:hover":{bgcolor:s=>B(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx(z.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx(z.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,color:"text.primary"},children:ls(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=>B(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,l])=>as(l)).filter(Boolean).join(" • ")})]})}function iu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isReadOnly:s,isGrouped:l,onToggleRowSelection:d,onToggleGroupCollapse:c,onViewRow:u,onEditRow:h,onDuplicateRow:g,onDeleteRow:f}){const b=p.useMemo(()=>{const v=new Set;return i.forEach(T=>{const C=T==null?void 0:T.__urm_row_id__;C!==void 0&&v.add(C)}),v},[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:v=>v.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:1.5,alignContent:"start"},children:e.map((v,T)=>l&&v.isGroupHeader?t.jsx(nu,{row:v,grouping:n,onToggleCollapse:c||(()=>{})},`group-${v.groupKey}`):t.jsx(ou,{row:v,rowIndex:T,visibleColumns:r,isSelected:b.has(v==null?void 0:v.__urm_row_id__),isReadOnly:s,onToggleSelection:()=>d(v),onView:u,onEdit:h,onDuplicate:g,onDelete:f},`card-${T}`))})})}const Ui=[10,15,25,50,100];function su(e,r){const n=e.trim();if(n==="")return"Page number is required";if(!/^-?\d+$/.test(n))return"Must be a number";const i=parseInt(n,10);return i<1?"Page number must be at least 1":i>r?"Entered page number is out of range":null}function au({currentPage:e,pageSize:r,totalRows:n,totalFields:i,onPageChange:s,onPageSizeChange:l}){const c=rt().palette,u=Math.ceil(n/r),[h,g]=p.useState(String(e)),[f,b]=p.useState(null),[v,T]=p.useState(!1),C=p.useRef(null);p.useEffect(()=>{v||(g(String(e)),b(null))},[e,v]);const m=p.useCallback(()=>{const R=su(h,u);if(R){b(R);return}const P=parseInt(h.trim(),10);b(null),T(!1),P!==e&&s(P)},[h,u,e,s]),j=p.useCallback(R=>{var P;R.key==="Enter"?(R.preventDefault(),m()):R.key==="Escape"&&(g(String(e)),b(null),T(!1),(P=C.current)==null||P.blur())},[m,e]),y=p.useCallback(()=>{g(String(e)),b(null),T(!1)},[e]),$=p.useCallback(()=>{T(!0),b(null),setTimeout(()=>{var R;return(R=C.current)==null?void 0:R.select()},0)},[]);if(n<=Math.min(...Ui))return null;const S=()=>{g(String(e)),b(null),T(!1)},I=()=>{S(),s(1)},N=()=>{S(),e>1&&s(e-1)},a=()=>{S(),e<u&&s(e+1)},A=()=>{S(),s(u)},F=(e-1)*r+1,J=Math.min(e*r,n),ee=`${Math.max(2,String(u).length+.5)}ch`,x={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:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total data:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:n})]}),i!==void 0&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:["Total fields:"," ",t.jsx(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:i})]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:3},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400},children:"Rows per page:"}),t.jsx(o.Select,{value:r,onChange:R=>l(Number(R.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:Ui.map(R=>t.jsx(o.MenuItem,{value:R,sx:{fontSize:"0.8125rem"},children:R},R))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[F,"–",J," of ",n]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75,position:"relative"},children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:"Page"}),t.jsxs(o.Box,{sx:{position:"relative"},children:[f&&t.jsx(o.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:B(c.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${B(c.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:B(c.error.main,.4)}},children:t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",fontWeight:500,color:"error.main",lineHeight:1.3},children:f})}),t.jsx(o.InputBase,{inputRef:C,value:h,onChange:R=>{g(R.target.value),f&&b(null)},onKeyDown:j,onFocus:$,onBlur:y,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:ee,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:f?"error.main":"text.primary",border:"1px solid",borderColor:f?"error.main":v?"primary.main":"divider",borderRadius:"4px",bgcolor:f?B(c.error.main,.04):v?B(c.primary.main,.04):"background.paper",px:.75,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:f?"error.main":"text.secondary"},"&:focus-within":{boxShadow:f?`0 0 0 2px ${B(c.error.main,.2)}`:`0 0 0 2px ${B(c.primary.main,.2)}`}}})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",userSelect:"none"},children:["of ",u]})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.IconButton,{onClick:I,disabled:e===1,size:"small",title:"First page",sx:x,children:t.jsx(z.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:N,disabled:e===1,size:"small",title:"Previous page",sx:x,children:t.jsx(z.ChevronLeft,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:a,disabled:e===u,size:"small",title:"Next page",sx:x,children:t.jsx(z.ChevronRight,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:A,disabled:e===u,size:"small",title:"Last page",sx:x,children:t.jsx(z.LastPage,{sx:{fontSize:20}})})]})]})]})}function lu(){return t.jsx(o.Chip,{icon:t.jsx(z.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:"caption.fontSize",fontWeight:500}})}const As="urm_hint_seen_";function cu(e){try{return localStorage.getItem(As+e)==="true"}catch{return!1}}function du(e){try{localStorage.setItem(As+e,"true")}catch{}}const Ms={"& .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 Mn(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 Rs({row:e,schema:r}){const i=rt().palette,s=r.filter(c=>c.name in e),l=s.filter(c=>c.type!=="object"&&c.type!=="array"),d=s.filter(c=>c.type==="object"||c.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[l.map(c=>t.jsx(o.TextField,{label:et(c.name),value:Mn(e[c.name],c.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:Ms},c.name)),d.map(c=>{const u=Mn(e[c.name],c.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:et(c.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:B(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"})]},c.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3},children:"No fields to display"})]})}function uu({open:e,onClose:r,row:n,schema:i,reportName:s}){const l=rt(),d=l.palette;if(!n)return null;const c=i.filter(u=>u.name in n).length;return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Ue(l),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${B(d.common.black,.14)}, 0 2px 8px ${B(d.common.black,.08)}`,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:B(d.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(z.VisibilityOutlined,{sx:{fontSize:18,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"View Record"}),s&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[s," · ",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(z.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:B(d.text.primary,.015)},children:t.jsx(Rs,{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:u=>`${u.shape.borderRadius}px`,minWidth:80},children:"Close"})})]})}function pu({open:e,onClose:r,onConfirm:n,row:i,schema:s}){return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:l=>Ue(l),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:l=>ce(l,"menu")}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:1.5,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsxs(o.Stack,{direction:"row",spacing:1.5,alignItems:"flex-start",children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:l=>B(l.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(z.WarningAmberRounded,{sx:{fontSize:22,color:"error.main"}})}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5,mb:.5},children:"Delete record?"}),t.jsx(o.Typography,{variant:"body2",sx:{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(z.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(Rs,{row:i,schema:s}),t.jsx(o.Box,{sx:{p:2,borderRadius:"8px",bgcolor:l=>B(l.palette.error.main,.1),border:l=>`1px solid ${B(l.palette.error.main,.5)}`},children:t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"error.main",fontWeight:500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})]}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>{n(),r()},variant:"contained",startIcon:t.jsx(z.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>ce(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:l=>ce(l,"hoverButton")},"&:active":{boxShadow:l=>ce(l,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function xu({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:l}){var m;const d=rt(),c=d.palette,[u,h]=p.useState({});if(p.useEffect(()=>{e&&i&&h({...i})},[e,i]),!i)return null;const g=s.filter(j=>j.name in i),f=g.filter(j=>j.type!=="object"&&j.type!=="array"),b=g.filter(j=>j.type==="object"||j.type==="array"),v=(j,y)=>{h($=>({...$,[j]:y}))},T=()=>{const j={...u};g.forEach(y=>{const $=u[y.name];if(y.type==="number"){const S=Number($);j[y.name]=isNaN(S)?i[y.name]:S}else y.type==="boolean"&&(j[y.name]=!!$)}),n(j),r()},C=g.length;return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:Ue(d),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${B(c.common.black,.14)}, 0 2px 8px ${B(c.common.black,.08)}`,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2.5,pb:2,bgcolor:"background.paper",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,minWidth:0},children:[t.jsx(o.Box,{sx:{width:36,height:36,borderRadius:"10px",bgcolor:B(((m=c.warning)==null?void 0:m.main)??"#ed6c02",.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(z.EditOutlined,{sx:{fontSize:18,color:"warning.main"}})}),t.jsxs(o.Box,{sx:{minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:"1rem",fontWeight:600,color:"text.primary",lineHeight:1.3},children:"Edit Record"}),l&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[l," · ",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(z.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogContent,{sx:{p:2.5,overflowY:"auto",flex:1,bgcolor:B(c.text.primary,.015),display:"flex",flexDirection:"column",gap:2},children:[f.map(j=>{const y=u[j.name];return j.type==="boolean"?t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:et(j.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!y,onChange:$=>v(j.name,$.target.checked),size:"small"}),t.jsx(o.Typography,{variant:"body2",sx:{color:"text.secondary"},children:y?"Enabled":"Disabled"})]})]},j.name):t.jsx(o.TextField,{label:et(j.name),value:y??"",onChange:$=>v(j.name,$.target.value),type:j.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:Ms},j.name)}),b.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:b.map(j=>{const y=Mn(i[j.name],j.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:{fontWeight:500,color:"text.secondary"},children:et(j.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:B(c.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(z.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:B(c.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:y?"text.primary":"text.disabled",fontStyle:y?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:y||"No value"})]},j.name)})}),g.length===0&&t.jsxs(o.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx(z.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:j=>`${j.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:T,variant:"contained",startIcon:t.jsx(z.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:j=>`${j.shape.borderRadius}px`,minWidth:90},children:"Save"})]})]})}const mu=176,fu=170,hu=40;function Ws(e){return e.type==="date"?180:mu}function gu(e,r){return r!=null&&r!==fu&&r!==Ws(e)}function yu(e,r,n){return p.useMemo(()=>{const i=e.map(f=>({name:f.name,width:r[f.name]??Ws(f),explicit:gu(f,r[f.name])})),s={};i.forEach(f=>{s[f.name]=f.width});const l=i.reduce((f,b)=>f+b.width,0),c=Math.max(0,n-hu)-l;if(c<=0)return{widths:s,fillerWidth:0};const u=i.filter(f=>!f.explicit);if(u.length===0)return{widths:s,fillerWidth:c};const h=u.reduce((f,b)=>f+b.width,0)||1;let g=0;return u.forEach((f,b)=>{const T=b===u.length-1?f.width+c-g:Math.round(f.width+c*f.width/h);s[f.name]=T,g+=T-f.width}),{widths:s,fillerWidth:0}},[e,r,n])}const Bo=176,Gi=32,Yi=24,bu=Ct(),vu={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Su(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:500,bgcolor:n=>Lo(n,r).bg,color:n=>Lo(n,r).color,whiteSpace:"nowrap",lineHeight:1.6,letterSpacing:"0.01em"},children:e})}function Cu(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 ju(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((l,d)=>l.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:l},d):l)}function qi(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 Su(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Cu(s);if(e.type==="date"){const c=e.dateFormat??"iso",u=ba(r,c,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 c=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:[c,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const c=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:c,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:c.length>40?c.slice(0,40)+"…":c})}return ju(s,i)}function wu({schema:e,data:r,sortStack:n=[],filters:i=bu,views:s=[],activeViewId:l="",isDirty:d=!1,isExporting:c=!1,columnVisibility:u={},columnOrder:h=[],columnWidths:g={},grouping:f=null,classTokens:b={},onSort:v,onSortAscending:T,onSortDescending:C,onOpenFilters:m,onOpenSort:j,onOpenFilterForColumn:y,onSelectView:$,onCreateView:S,onUpdateCurrentView:I,onSaveAsNewView:N,onDiscardChanges:a,onToggleDefault:A,onToggleFavorite:F,onRestoreView:J,onPermanentDelete:ee,onEditView:x,onCloneView:R,onCopyLink:P,onDeleteView:te,onPromoteToGlobal:ae,isAdmin:Q=!1,onExport:re,onOpenColumns:he,onUpdateColumnWidth:L,onUpdateColumnOrder:K,onUpdateColumnVisibility:ne,onClearFiltersForColumn:le,onResetLayout:U,onOpenGroup:se,onGroupByColumn:ie,onToggleGroupCollapse:D,onExpandAllGroups:Z,onCollapseAllGroups:de,onOpenAuditHistory:oe,onOpenScheduledReports:ye,searchQuery:G,highlightQuery:Me="",searchHistory:ht=[],onAddToSearchHistory:ot,onToggleSearchFavourite:wr,onDeleteSearchHistory:kr,selectedRowIds:gt=new Set,onSearchChange:Tr,onToggleRowSelection:nt,onToggleAllRows:Ut,onRangeSelection:jt,onClearSelection:it,onExportSelected:st,currentPage:_t=1,pageSize:At=15,totalRowsBeforePagination:Jr=r.length,onPageChange:ir,onPageSizeChange:sr,isReadOnly:Ye=!1,userRole:Kr,reportName:Br,onEditRow:Mt,onDuplicateRow:Ve,onDeleteRow:wt,showDevPanel:Xr=!1,onOpenDevConfig:qe,rowActions:ar,hideDefaultRowActions:Re,onRowClick:Gt,onRowRightClick:Rt}){var gr;const H=rt().urmTable,[lr,zr]=p.useState(null),[yt,W]=p.useState(0),[at,ge]=p.useState(0),[Pe,cr]=p.useState(null),Er=((gr=Sr().dates)==null?void 0:gr.displayFormat)??null,[Wt,Dr]=p.useState(null),[Yt,$r]=p.useState(null),[Pt,Be]=p.useState(null),[X,lt]=p.useState(!1),[Ie,qt]=p.useState(!1),[ur,Jt]=p.useState(null),[Qr,kt]=p.useState(!1),[Tt,Kt]=p.useState(null),[Fe,pr]=p.useState(null),[fe,He]=p.useState(null),[Or,ct]=p.useState(null),bt=p.useRef(null),Bt=p.useCallback(()=>{bt.current&&(clearTimeout(bt.current),bt.current=null)},[]),_r=p.useCallback(()=>{Bt(),bt.current=setTimeout(()=>ct(null),200)},[Bt]);p.useEffect(()=>Bt,[Bt]);const[Xt,Je]=p.useState(null),[Ge,xr]=p.useState("list"),[Qt,mr]=p.useState(!1),[xe,Ce]=p.useState(()=>!cu("toolbar_search")),$e=p.useRef(null),It=p.useRef(null),[Zt,ho]=p.useState(0);p.useLayoutEffect(()=>{const k=$e.current;if(!k)return;ho(k.clientWidth);const V=new ResizeObserver(me=>{ho(me[0].contentRect.width)});return V.observe(k),()=>V.disconnect()},[]);const Ar=p.useCallback(()=>{du("toolbar_search"),Ce(!1)},[]);p.useEffect(()=>{if(!xe)return;const k=setTimeout(Ar,2e3);return()=>clearTimeout(k)},[xe,Ar]);const go=p.useMemo(()=>{const k=Pe??h;return k.length>0?k.map(V=>e.find(me=>me.name===V)).filter(V=>V!==void 0):e},[Pe,h,e]),fr=p.useMemo(()=>go.filter(k=>u[k.name]!==!1),[go,u]),Zr=p.useMemo(()=>new Set(((f==null?void 0:f.levels)??[]).map(k=>k.column)),[f]),yo=!!(f!=null&&f.enabled&&(f!=null&&f.levels)&&f.levels.length>0),vt=p.useMemo(()=>{if(!yo)return fr;const k=fr.filter(V=>!Zr.has(V.name));return k.length>0?k:fr},[fr,yo,Zr]),{widths:Mr,fillerWidth:Rr}=yu(vt,g,Zt),er=p.useMemo(()=>e.filter(k=>u[k.name]===!1).length,[e,u]),bo=p.useMemo(()=>e.map(k=>k.name),[e]),Wr=p.useMemo(()=>h.length===0?!1:JSON.stringify(h)!==JSON.stringify(bo),[h,bo]),sn=p.useCallback((k,V)=>{k.preventDefault(),k.stopPropagation(),zr(V),W(k.clientX),ge(g[V]||150)},[g]);p.useEffect(()=>{if(!lr)return;const k=me=>{const Ke=me.clientX-yt,dt=Math.max(100,Math.min(600,at+Ke));L==null||L(lr,dt)},V=()=>{zr(null)};return document.addEventListener("mousemove",k),document.addEventListener("mouseup",V),()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",V)}},[lr,yt,at,L]);const an=p.useCallback(k=>k==null?"-":typeof k=="object"?JSON.stringify(k):typeof k=="boolean"?k?"true":"false":String(k),[]);p.useCallback(k=>{const V=n.find(me=>me.column===k);return V?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[V.direction==="asc"?t.jsx(z.ArrowUpward,{sx:{fontSize:14}}):t.jsx(z.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:V.priority})]}):null},[n]),p.useCallback(k=>En(i,k)?t.jsx(o.IconButton,{size:"small",onClick:me=>{me.stopPropagation(),y==null||y(k)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx(z.FilterList,{sx:{fontSize:14}})}):null,[i,y]);const ln=p.useCallback(k=>{v&&v(k)},[v]),cn=p.useCallback((k,V)=>{cr(me=>{const dt=[...me??(h.length>0?h:e.map(Et=>Et.name))],[zt]=dt.splice(k,1);return dt.splice(V,0,zt),dt})},[h,e]),dn=p.useCallback(()=>{Pe&&K&&K(Pe),cr(null)},[Pe,K]),un=p.useCallback(k=>{if(!v)return;const V=n.find(me=>me.column===k);(!V||V.direction!=="asc")&&v(k)},[v,n]),pn=p.useCallback(k=>{if(!v)return;const V=n.find(me=>me.column===k);V?V.direction==="asc"&&v(k):(v(k),setTimeout(()=>v(k),0))},[v,n]),xn=p.useCallback(k=>{if(!v)return;const V=n.find(me=>me.column===k);V&&(V.direction==="asc"?(v(k),setTimeout(()=>v(k),0)):V.direction==="desc"&&v(k))},[v,n]),mn=p.useCallback(k=>{ne&&ne(k,!1)},[ne]),Pr=(f==null?void 0:f.enabled)&&r.length>0&&r[0]&&"isGroupHeader"in r[0],Nt=p.useMemo(()=>mt(i),[i]),fn=n.length>0||Nt>0||((f==null?void 0:f.enabled)??!1)||Object.values(u).some(k=>k===!1),hn=(_t-1)*At,Ne=r,Lt=p.useMemo(()=>{const k=new Set;return gt.forEach(V=>{const me=V==null?void 0:V.__urm_row_id__;me!==void 0&&k.add(me)}),k},[gt]);p.useEffect(()=>{const k=V=>{!Ut||!it||V.target instanceof HTMLInputElement||V.target instanceof HTMLTextAreaElement||((V.ctrlKey||V.metaKey)&&V.key==="a"&&(V.preventDefault(),Ut(!0,Ne)),V.key==="Escape"&&(V.preventDefault(),it()))};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[Ut,it,Ne]);const vo=p.useCallback((k,V)=>{Gt==null||Gt(Ne[k],k,V),nt&&(V.shiftKey&&Wt!==null?(V.preventDefault(),jt&&jt(Wt,k,Ne)):(nt(Ne[k]),Dr(k)))},[nt,Wt,jt,Ne,Gt]);!p.useMemo(()=>Ne.length>0&&Lt.size>0&&Ne.every(k=>Lt.has(k==null?void 0:k.__urm_row_id__)),[Ne,Lt])&&Ne.some(k=>Lt.has(k==null?void 0:k.__urm_row_id__));const eo=nt&&Ut,hr=p.useCallback(k=>{var zt;const V=k.groupLevel,me=V*Gi,Ke=V===0?b.groupRowLevel0||"urm-group-level-0":V===1?b.groupRowLevel1||"urm-group-level-1":b.groupRowLevel2||"urm-group-level-2",dt=V===0?"action.selected":V===1?"action.hover":"background.paper";return t.jsx(o.TableRow,{onClick:()=>D==null?void 0:D(k.groupKey),className:`urm-group-header-row urm-group-level-${V} ${Ke} ${b.groupRow||""}`,sx:{bgcolor:dt,"&:hover":{bgcolor:Et=>B(Et.palette.text.primary,.08)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider"},children:t.jsx(o.TableCell,{colSpan:vt.length+2+(eo?1:0),className:`urm-group-cell ${b.groupCellFirst||""} ${b.groupCell||""}`,sx:{pl:`${me+Yi}px`,position:"relative",py:1},children:t.jsxs(o.Box,{className:`urm-group-content ${b.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${b.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:k.isCollapsed?t.jsx(z.ChevronRight,{sx:{fontSize:18}}):t.jsx(z.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",className:`urm-group-title ${b.groupTitle||""}`,sx:{fontWeight:V===0?600:500,color:"text.primary"},children:ls(V,((zt=f==null?void 0:f.levels[V])==null?void 0:zt.column)||"",k.groupValue)}),t.jsxs(o.Box,{className:`urm-group-count ${b.groupBadge||""} ${b.groupCount||""}`,sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:Et=>B(Et.palette.text.secondary,.12),color:"text.secondary",borderRadius:2},children:[k.rowCount," ",k.rowCount===1?"row":"rows"]}),Object.keys(k.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",className:`urm-group-aggregates ${b.groupAggregates||""}`,sx:{ml:1,color:"text.secondary"},children:Object.entries(k.aggregates).map(([Et,pe])=>as(pe)).filter(Boolean).join(" • ")})]})})},k.groupKey)},[vt,eo,f,D,b]),So=p.useCallback((k,V)=>{const me=Lt.has(k==null?void 0:k.__urm_row_id__),Ke=Yt===V,dt=X&&(k==null?void 0:k.__urm_row_id__)===(Pt==null?void 0:Pt.__urm_row_id__),zt=!!(k!=null&&k.__urm_is_grouped_data_row__),Et=zt?k.__urm_group_level__??(f==null?void 0:f.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":V,className:zt?`urm-data-row-grouped ${b.dataRowGrouped||""}`:"",onMouseEnter:()=>$r(V),onMouseLeave:()=>$r(null),onClick:pe=>{pe.target.closest("[data-row-action-btn]")||vo(V,pe)},onContextMenu:pe=>{pe.preventDefault(),pe.stopPropagation(),Rt==null||Rt(k,V,pe),ct(null),He({mouseX:pe.clientX,mouseY:pe.clientY,row:k,rowIndex:V})},sx:{cursor:"pointer",bgcolor:me?pe=>B(pe.palette.warning.main,.12):dt?pe=>B(pe.palette.info.main,.12):H!=null&&H.striped&&V%2===1?H.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:me?pe=>B(pe.palette.warning.main,.2):dt?pe=>B(pe.palette.info.main,.2):"action.hover"},borderBottom:(H==null?void 0:H.rowDivider)??"1px solid",borderColor:"divider"},children:[vt.map((pe,Nr)=>{if(zt&&Nr===0){const gn=Et*Gi+Yi;return t.jsx(o.TableCell,{className:`urm-data-cell-grouped ${b.dataCellGrouped||""}`,sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(H==null?void 0:H.rowPaddingY)??"6px",px:(H==null?void 0:H.cellPaddingX)??2,pl:`${gn}px`,position:"relative",textAlign:(H==null?void 0:H.cellAlignH)??"left",verticalAlign:(H==null?void 0:H.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(H==null?void 0:H.rowDivider)??"1px solid",borderRight:H==null?void 0:H.colDivider,borderColor:"divider",minWidth:g[pe.name]?`${g[pe.name]}px`:`${pe.type==="date"?Math.max(Bo,180):Bo}px`},children:t.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx("span",{className:`urm-item-title ${b.itemTitle||""}`,children:qi(pe,k[pe.name],Er,Me)})})},pe.name)}return t.jsx(o.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(H==null?void 0:H.rowPaddingY)??"6px",px:(H==null?void 0:H.cellPaddingX)??2,textAlign:(H==null?void 0:H.cellAlignH)??"left",verticalAlign:(H==null?void 0:H.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(H==null?void 0:H.rowDivider)??"1px solid",borderRight:H==null?void 0:H.colDivider,borderColor:"divider",minWidth:g[pe.name]?`${g[pe.name]}px`:`${pe.type==="date"?Math.max(Bo,180):Bo}px`},children:qi(pe,k[pe.name],Er,Me)},pe.name)}),t.jsx(o.TableCell,{sx:{p:0,border:"none",borderBottom:"1px solid",borderColor:"divider"}}),t.jsx(o.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:40,minWidth:40,maxWidth:40,p:0,border:"none",borderBottom:"1px solid",borderColor:"divider",background:Ke?pe=>`linear-gradient(to right, transparent, ${me?B(pe.palette.warning.main,.12):pe.palette.background.paper} 32px)`:"transparent",opacity:Ke?1:0,transition:"opacity 0.12s ease, background 0.12s ease",zIndex:10,verticalAlign:"middle"},children:t.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",height:"100%",px:1,gap:.25},children:t.jsx(o.IconButton,{"data-row-action-btn":"true",size:"small",onClick:pe=>{pe.stopPropagation(),pe.preventDefault(),ct(null),He({anchorEl:pe.currentTarget,row:k,rowIndex:V})},sx:{color:"text.secondary",opacity:Ke?1:0,transition:"opacity 0.12s ease",pointerEvents:Ke?"auto":"none","&:hover":{bgcolor:pe=>B(pe.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(z.MoreVert,{sx:{fontSize:18}})})})})]},V)},[gt,hn,Yt,vo,vt,g,Me,an,Mt,Ve,wt,nt,Be,lt,Pt,X,He,Pr,Zr,Rt]);return t.jsxs(Vt.DndProvider,{backend:Rn.HTML5Backend,children:[t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[t.jsxs(o.Box,{sx:{position:"sticky",top:0,zIndex:10,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider",px:2,py:0,height:56,display:"flex",alignItems:"center",gap:1},children:[Ye&&t.jsx(lu,{}),Tr&&ot&&wr&&kr&&t.jsx(o.Tooltip,{open:xe,title:t.jsxs(o.Box,{sx:{p:.5},children:[t.jsx(o.Typography,{variant:"caption",sx:{display:"block",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:Ar},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(Ud,{value:G||"",onChange:k=>{xe&&Ar(),Tr(k)},searchHistory:ht,onAddToHistory:ot,onToggleFavourite:wr,onDeleteHistory:kr,disabled:Ye})})}),t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>mr(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:k=>B(k.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(z.InfoOutlined,{sx:{fontSize:20}})})}),$&&S&&I&&s.length>0&&t.jsx(Gd,{views:s||[],activeViewId:l||"",isDirty:d,onSelectView:$,onCreateView:S,onToggleDefault:A,onToggleFavorite:F,onRestoreView:J,onPermanentDelete:ee,onEditView:x,onCloneView:R,onCopyLink:P,onDeleteView:te,onPromoteToGlobal:ae,isAdmin:Q,isReadOnly:Ye}),d&&!Ye&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[I&&t.jsx(o.Button,{onClick:I,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:"var(--urm-btn-save-current-bg, primary.main)",color:"var(--urm-btn-save-current-color, primary.contrastText)",textTransform:"none",boxShadow:"none","&:hover":{bgcolor:"var(--urm-btn-save-current-hover-bg, primary.dark)",boxShadow:k=>`0 2px 6px ${B(k.palette.primary.main,.25)}`}},children:"Save current view"}),N&&t.jsx(o.Button,{onClick:N,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:"var(--urm-btn-save-new-border, primary.main)",color:"var(--urm-btn-save-new-color, primary.main)",bgcolor:"var(--urm-btn-save-new-bg, background.paper)",borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:"var(--urm-btn-save-new-hover-border, primary.dark)",bgcolor:k=>`var(--urm-btn-save-new-hover-bg, ${B(k.palette.primary.main,.08)})`}},children:"Save new view"}),a&&t.jsx(o.Button,{onClick:a,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:k=>`var(--urm-btn-discard-bg, ${B(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, ${B(k.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),Xr&&qe&&t.jsx(o.Tooltip,{title:"Developer configuration",children:t.jsx(o.IconButton,{size:"small",onClick:qe,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:k=>B(k.palette.text.secondary,.3),"&:hover":{bgcolor:k=>B(k.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx(z.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(o.Box,{sx:{flexGrow:1}}),!Ye&&j&&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?k=>Ze(k):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?k=>B(k.palette.primary.main,.2):k=>B(k.palette.text.primary,.06),color:n.length>0?"primary.main":"text.primary"}},children:[t.jsx(z.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})]})}),!Ye&&m&&t.jsx(o.Tooltip,{title:"Filter",children:t.jsxs(o.IconButton,{onClick:m,size:"small",sx:{position:"relative",color:Nt>0?"primary.main":"text.secondary",bgcolor:Nt>0?k=>Ze(k):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Nt>0?k=>B(k.palette.primary.main,.2):k=>B(k.palette.text.primary,.06),color:Nt>0?"primary.main":"text.primary"}},children:[t.jsx(z.FilterList,{sx:{fontSize:20}}),Nt>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:Nt})]})}),!Ye&&he&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:he,size:"small",sx:{position:"relative",color:er>0||Wr?"primary.main":"text.secondary",bgcolor:er>0||Wr?k=>Ze(k):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:er>0||Wr?k=>B(k.palette.primary.main,.2):k=>B(k.palette.text.primary,.06),color:er>0||Wr?"primary.main":"text.primary"}},children:[t.jsx(z.ViewColumn,{sx:{fontSize:20}}),er>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:er})]})}),Pr&&(Z||de)&&(()=>{var me;const k=(((me=f==null?void 0:f.collapsedGroups)==null?void 0:me.length)??0)>0,V=k?Z:de;return V?t.jsx(o.Tooltip,{title:k?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:V,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:Ke=>B(Ke.palette.text.primary,.06),color:"text.primary"}},children:k?t.jsx(z.UnfoldMore,{sx:{fontSize:20}}):t.jsx(z.UnfoldLess,{sx:{fontSize:20}})})}):null})(),t.jsx(o.Divider,{orientation:"vertical",flexItem:!0,sx:{mx:.5,my:1.5}}),t.jsx(o.Tooltip,{title:"List view",children:t.jsx(o.IconButton,{size:"small",onClick:()=>xr("list"),sx:{borderRadius:1,color:Ge==="list"?"primary.main":"text.secondary",bgcolor:Ge==="list"?k=>Ze(k):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Ge==="list"?k=>B(k.palette.primary.main,.2):k=>B(k.palette.text.primary,.06),color:Ge==="list"?"primary.main":"text.primary"}},children:t.jsx(z.TableRows,{sx:{fontSize:20}})})}),t.jsx(o.Tooltip,{title:"Grid view",children:t.jsx(o.IconButton,{size:"small",onClick:()=>xr("grid"),sx:{borderRadius:1,color:Ge==="grid"?"primary.main":"text.secondary",bgcolor:Ge==="grid"?k=>Ze(k):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Ge==="grid"?k=>B(k.palette.primary.main,.2):k=>B(k.palette.text.primary,.06),color:Ge==="grid"?"primary.main":"text.primary"}},children:t.jsx(z.GridView,{sx:{fontSize:20}})})}),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=>Je(k.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:k=>B(k.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(z.Settings,{sx:{fontSize:20}})})})]}),t.jsxs(o.Popover,{open:!!Xt,anchorEl:Xt,onClose:()=>Je(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:200,py:.5,borderRadius:1.5,boxShadow:3}},children:[re&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{re(),Je(null)},disabled:c,sx:{py:1,px:2,gap:1.5},children:[t.jsx(z.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Export"})]}),!Ye&&se&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{se(),Je(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(z.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Grouping"})]}),oe&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{oe(),Je(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(z.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Audit History"})]}),ye&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ye(),Je(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(z.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Scheduled Reports"})]})]}),t.jsxs(o.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Ge==="grid"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(iu,{data:Ne,visibleColumns:fr,grouping:f,selectedRowIds:gt,isReadOnly:Ye,isGrouped:!!Pr,onToggleRowSelection:nt||(()=>{}),onToggleGroupCollapse:D,onViewRow:k=>{Be(k),lt(!0)},onEditRow:(k,V)=>{Kt(k),pr(V),kt(!0)},onDuplicateRow:(k,V)=>Ve==null?void 0:Ve(k,V),onDeleteRow:(k,V)=>{Jt(V),qt(!0)}})}),Ge==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:$e,onScroll:k=>{It.current&&(It.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(Mr).reduce((k,V)=>k+V,0)+Rr+40}px`},children:[t.jsxs("colgroup",{children:[vt.map(k=>t.jsx("col",{style:{width:`${Mr[k.name]}px`}},k.name)),t.jsx("col",{style:{width:`${Rr}px`}}),t.jsx("col",{style:{width:"40px"}})]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(H==null?void 0:H.headerBg)??"action.hover",borderBottom:(H==null?void 0:H.rowDivider)??"1px solid",borderColor:"divider"},children:[vt.map((k,V)=>t.jsx(Jd,{column:k,index:V,sortRule:n.find(me=>me.column===k.name),hasFilters:En(i,k.name),isInSortStack:n.some(me=>me.column===k.name),isReadOnly:Ye,hasModifications:fn,width:g[k.name],onColumnClick:ln,onMoveColumn:cn,onColumnDragEnd:dn,onResizeStart:sn,onSortAscending:T||un,onSortDescending:C||pn,onRemoveSort:xn,onOpenFilterForColumn:y||(()=>{}),onClearFiltersForColumn:le||(()=>{}),onGroupByColumn:ie,onHideColumn:mn,onManageColumns:he||(()=>{}),onResetLayout:U},k.name)),t.jsx(o.TableCell,{sx:{p:0,border:"none",borderBottom:(H==null?void 0:H.rowDivider)??"1px solid",borderColor:"divider",bgcolor:(H==null?void 0:H.headerBg)??"action.hover"}}),t.jsx(o.TableCell,{sx:{width:40,minWidth:40,p:0,border:"none",borderBottom:(H==null?void 0:H.rowDivider)??"1px solid",borderColor:"divider",bgcolor:(H==null?void 0:H.headerBg)??"action.hover"}})]})})]})}),t.jsx(o.Box,{ref:It,onScroll:k=>{$e.current&&($e.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=>B(k.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:k=>B(k.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Mr).reduce((k,V)=>k+V,0)+Rr+40}px`},children:[t.jsxs("colgroup",{children:[vt.map(k=>t.jsx("col",{style:{width:`${Mr[k.name]}px`}},k.name)),t.jsx("col",{style:{width:`${Rr}px`}}),t.jsx("col",{style:{width:"40px"}})]}),t.jsx(o.TableBody,{children:Ne.length===0?t.jsx(o.TableRow,{children:t.jsx(o.TableCell,{colSpan:vt.length+2+(eo?1:0),align:"center",sx:{py:4},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):Pr?Ne.map((k,V)=>k.isGroupHeader?hr(k):So(k,V)):Ne.map((k,V)=>So(k,V))})]})})]}),ir&&sr&&t.jsx(au,{currentPage:_t,pageSize:At,totalRows:Jr,totalFields:e.length,onPageChange:ir,onPageSizeChange:sr}),!(ir&&sr)&&t.jsx(o.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider"},children:t.jsxs(o.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",Ne.length," ",Ne.length===1?"row":"rows"]})})]})]}),t.jsxs(o.Popover,{open:!!fe,onClose:()=>{He(null),ct(null)},anchorEl:(fe==null?void 0:fe.anchorEl)||null,anchorReference:fe!=null&&fe.anchorEl?"anchorEl":"anchorPosition",anchorPosition:fe&&!fe.anchorEl?{top:fe.mouseY,left:fe.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:fe!=null&&fe.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(Re!=null&&Re.includes("view"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{fe&&(Be(fe.row),lt(!0)),He(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(z.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"View"})]}),!(Re!=null&&Re.includes("edit"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{fe&&(Kt(fe.row),pr(fe.rowIndex),kt(!0)),He(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(z.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Edit"})]}),!(Re!=null&&Re.includes("duplicate"))&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{fe&&(Ve==null||Ve(fe.rowIndex,fe.row)),He(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(z.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"Duplicate"})]}),fe&&(ar==null?void 0:ar.map(k=>{var V,me;return(V=k.hidden)!=null&&V.call(k,fe.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(me=k.disabled)==null?void 0:me.call(k,fe.row),onClick:()=>{k.onClick(fe.row,fe.rowIndex),He(null)},sx:{py:1,px:2,gap:1.5},children:[k.icon,t.jsx(o.Typography,{variant:"body2",children:k.label})]},k.key)})),Lt.size>0&&st&&!(Re!=null&&Re.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:k=>{Bt(),ct(k.currentTarget)},onMouseLeave:_r,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(z.Download,{sx:{fontSize:18,color:"text.secondary"}}),t.jsxs(o.Typography,{variant:"body2",children:["Export Selected (",Lt.size,")"]})]}),t.jsx(z.ChevronRight,{sx:{fontSize:18,color:"text.secondary"}})]}),t.jsx(o.Popper,{open:!!Or,anchorEl:Or,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:Bt,onMouseLeave:_r,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:()=>{st("csv"),ct(null),He(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(z.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{st("excel"),ct(null),He(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(z.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(o.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{st("json"),ct(null),He(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(z.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(o.Typography,{variant:"body2",children:"JSON"})]})]})})})})]}),!(Re!=null&&Re.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{fe&&(Jt(fe.row),qt(!0)),He(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx(z.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(o.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(uu,{open:X,onClose:()=>{lt(!1),Be(null)},row:Pt,schema:e,reportName:Br}),t.jsx(xu,{open:Qr,onClose:()=>{kt(!1),Kt(null),pr(null)},onSave:k=>{Fe!==null&&(Mt==null||Mt(Fe,k))},row:Tt,schema:e,reportName:Br}),t.jsx(pu,{open:Ie,onClose:()=>{qt(!1),Jt(null)},onConfirm:()=>{ur!==null&&(wt==null||wt(ur))},row:ur,schema:e}),t.jsx(Os,{isOpen:Qt,onClose:()=>mr(!1)})]})}function Cr({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=>B(s.palette.primary.main,.08)}},children:t.jsx(z.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=>B(s.palette.primary.main,.06)},children:t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,color:"primary.main",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:"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,l)=>t.jsx(o.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},l))}),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=>B(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>B(s.palette.warning.main,.2)},children:[t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:500,display:"block",mb:.25},children:"Dev note"}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}const jr={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}},zn=40;function ku({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 Tu({condition:e,schema:r,availableColumns:n,devConfig:i,onUpdate:s}){const l=r.find(u=>u.name===e.column),d=p.useMemo(()=>{const u=l?Po(l.type):[],h=i.filter.allowedOperators;return h.length>0?u.filter(g=>h.includes(g.value)):u},[l,i]),c=gl(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 h=r.find(b=>b.name===u.target.value),g=h?Po(h.type):[];s({column:u.target.value,operator:((f=g[0])==null?void 0:f.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:n.map(u=>t.jsx(o.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:et(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:d.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),c&&(l==null?void 0:l.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"}}}),c&&(l==null?void 0:l.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(l==null?void 0:l.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(l==null?void 0:l.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 Ps({group:e,depth:r,schema:n,availableColumns:i,devConfig:s,maxConditions:l,totalConditions:d,onChange:c}){const u=d>=l;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((h,g)=>t.jsxs(o.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(o.Box,{sx:{width:zn,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[g<e.children.length-1&&t.jsx(o.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),g>0&&t.jsx(ku,{operator:e.operator,onSelect:f=>c(b=>Nn(b,e.id,f))}),g>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:zn/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(o.Box,{sx:{flex:1,minWidth:0,pt:g>0?1:0},children:We(h)?t.jsx(Bu,{group:h,depth:r+1,schema:n,availableColumns:i,devConfig:s,maxConditions:l,totalConditions:d,onChange:c}):t.jsx(Tu,{condition:h,schema:n,availableColumns:i,devConfig:s,onUpdate:f=>c(b=>Pn(b,h.id,f))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>c(f=>Ln(f,h.id)),sx:{mt:g>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx(z.Close,{sx:{fontSize:16}})})]},h.id)),t.jsxs(o.Box,{sx:{display:"flex",gap:2,pl:`${zn}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>c(h=>{var g,f,b;return qr(h,e.id,{id:Yr(),column:((g=i[0])==null?void 0:g.name)??"",operator:((b=Po(((f=i[0])==null?void 0:f.type)??"string")[0])==null?void 0:b.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:()=>c(h=>qr(h,e.id,Ct())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function Bu(e){return t.jsx(o.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>B(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>B(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(Ps,{...e})})}function Iu({schema:e,filters:r,onReplaceFilters:n,onClose:i,focusColumn:s}){const[l,d]=p.useState(r??Ct()),c=Sr(),u=p.useMemo(()=>e.filter(m=>m.type!=="mixed"&&m.type!=="null"&&m.type!=="array"&&m.type!=="object"),[e]);p.useEffect(()=>{var j;const m=r??Ct();if(s&&m.children.length===0){const y=e.find($=>$.name===s);if(y){d(qr(m,m.id,{id:Yr(),column:s,operator:((j=Po(y.type)[0])==null?void 0:j.value)??"equals"}));return}}d(m)},[r,s,e]);const h=mt(l),g=c.filter.maxConditions,f=p.useCallback(m=>{d(j=>m(j))},[]),b=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r??Ct()),[l,r]),v=p.useCallback(()=>{n(l),i()},[l,n,i]),T=p.useCallback(()=>{d(r??Ct()),i()},[r,i]),C=p.useCallback(()=>{n(Ct()),i()},[n,i]);return t.jsx(o.Box,{onClick:T,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:m=>B(m.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:m=>m.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:m=>m.stopPropagation(),elevation:0,sx:{position:"relative",width:640,maxWidth:"calc(100vw - 120px)",maxHeight:"min(620px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:m=>Ue(m),bgcolor:"background.paper",outline:"none",boxShadow:m=>ce(m,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",lineHeight:1.5},children:"Filter columns"}),t.jsx(Cr,{content:jr.filter,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:T,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(z.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2.5,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:m=>B(m.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:m=>B(m.palette.text.primary,.3)}}},children:[h===0&&t.jsxs(o.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${et(s)}"`:"","."]}),t.jsx(Ps,{group:l,depth:0,schema:e,availableColumns:u,devConfig:c,maxConditions:g,totalConditions:h,onChange:f}),h>=g&&t.jsxs(o.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Filter limit reached — maximum ",g," conditions allowed. Remove one to add another."]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",alignItems:"center",gap:1.5,justifyContent:"space-between",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:C,disabled:h===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:T,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:m=>`${m.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:v,disabled:!b,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:m=>`${m.shape.borderRadius}px`,boxShadow:m=>ce(m,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]})]})]})})}const Ji="SORT_RULE";function zu({rule:e,index:r,onToggleDirection:n,onRemove:i,onMove:s}){const l=p.useRef(null),[{handlerId:d},c]=Vt.useDrop({accept:Ji,collect(g){return{handlerId:g.getHandlerId()}},hover(g,f){var y;if(!l.current)return;const b=g.index,v=r;if(b===v)return;const T=(y=l.current)==null?void 0:y.getBoundingClientRect(),C=(T.bottom-T.top)/2,m=f.getClientOffset(),j=((m==null?void 0:m.y)??0)-T.top;b<v&&j<C||b>v&&j>C||(s(b,v),g.index=v)}}),[{isDragging:u},h]=Vt.useDrag({type:Ji,item:()=>({index:r}),collect:g=>({isDragging:g.isDragging()})});return h(c(l)),t.jsxs(o.Box,{ref:l,"data-handler-id":d,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:g=>ce(g,"restButtonLight"),transform:"translateY(-1px)"}},children:[t.jsx(o.Chip,{label:e.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:g=>`0 1px 2px 0 ${B(g.palette.primary.main,.3)}`,"& .MuiChip-label":{px:0}}}),t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:"3px",cursor:"grab",px:.5,opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:[t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(o.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",fontWeight:400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:e.column}),t.jsx(o.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:t.jsxs(o.Select,{value:e.direction,onChange:g=>n(r,g.target.value),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"& .MuiSelect-select":{py:.875,color:"text.primary",fontWeight:400}},children:[t.jsx(o.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:g=>Ze(g),"&:hover":{bgcolor:g=>B(g.palette.primary.main,.2)}}},children:"Ascending"}),t.jsx(o.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:g=>Ze(g),"&:hover":{bgcolor:g=>B(g.palette.primary.main,.2)}}},children:"Descending"})]})}),t.jsx(o.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:g=>B(g.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx(z.Close,{sx:{fontSize:18}})})]})}function Eu({schema:e,sortStack:r,onUpdateSortStack:n,onClose:i}){const[s,l]=p.useState(""),[d,c]=p.useState([]);p.useEffect(()=>{c([...r])},[r]);const u=p.useMemo(()=>JSON.stringify(d)!==JSON.stringify(r),[d,r]),h=Sr(),g=p.useCallback(y=>{if(!y||d.length>=h.sort.maxLevels)return;const $={column:y,direction:"asc",priority:d.length+1};c([...d,$]),l(""),setTimeout(()=>{var S;return(S=document.activeElement)==null?void 0:S.blur()},0)},[d,h.sort.maxLevels]),f=p.useCallback(y=>{const S=d.filter((I,N)=>N!==y).map((I,N)=>({...I,priority:N+1}));c(S)},[d]),b=p.useCallback((y,$)=>{const S=[...d];S[y]={...S[y],direction:$},c(S)},[d]),v=p.useCallback((y,$)=>{const S=[...d],[I]=S.splice(y,1);S.splice($,0,I);const N=S.map((a,A)=>({...a,priority:A+1}));c(N)},[d]),T=p.useCallback(()=>{n([]),i()},[n,i]),C=p.useCallback(()=>{n(d),i()},[d,n,i]),m=p.useCallback(()=>{c([...r]),l(""),i()},[r,i]),j=e.filter(y=>!d.some($=>$.column===y.name));return t.jsx(Vt.DndProvider,{backend:Rn.HTML5Backend,children:t.jsx(o.Box,{onClick:m,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:y=>B(y.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:y=>y.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:y=>y.stopPropagation(),elevation:0,sx:{position:"relative",width:480,maxWidth:"calc(100vw - 120px)",maxHeight:"min(440px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:y=>Ue(y),bgcolor:"background.paper",outline:"none",boxShadow:y=>ce(y,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Sort columns"}),t.jsx(Cr,{content:jr.sort,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:m,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(z.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:y=>B(y.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:y=>B(y.palette.text.primary,.3)}}},children:[t.jsxs(o.Box,{sx:{mb:2.5},children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,disabled:d.length>=h.sort.maxLevels,children:[t.jsx(o.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(o.Select,{value:s,onChange:y=>g(y.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:j.map(y=>t.jsx(o.MenuItem,{value:y.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:$=>Ze($),"&:hover":{bgcolor:$=>B($.palette.primary.main,.2)}}},children:et(y.name)},y.name))})]}),d.length>=h.sort.maxLevels&&t.jsxs(o.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:"0.75rem",fontWeight:500},children:["Maximum ",h.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:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",d.length,"/",h.sort.maxLevels,")"]}),t.jsx(o.Button,{onClick:T,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((y,$)=>t.jsx(zu,{rule:y,index:$,onToggleDirection:b,onRemove:f,onMove:v},`${y.column}-${$}`))})]})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",flexShrink:0,bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:m,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:y=>`${y.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:C,variant:"contained",disabled:!u||d.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:y=>`${y.shape.borderRadius}px`,boxShadow:y=>ce(y,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:y=>ce(y,"hoverButton")},"&:active":{boxShadow:y=>ce(y,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const Io=50;function Ki({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:l="",initialIsDefault:d=!1,atViewLimit:c=!1,maxViews:u=10}){const[h,g]=p.useState(s),[f,b]=p.useState(!1),[v,T]=p.useState(l),[C,m]=p.useState(d),j=()=>{if(!h.trim()){b(!0);return}if(h.trim().length>Io){b(!0);return}r(h.trim(),v.trim(),C),n()},y=S=>{S.key==="Enter"&&!S.shiftKey?j():S.key==="Escape"&&n()},$=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{mt:8,borderRadius:S=>Ue(S),boxShadow:S=>ce(S,"menu")}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[$(),t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(z.Close,{sx:{fontSize:20}})})]}),t.jsx(o.DialogContent,{children:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[c&&!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:h,onChange:S=>{S.target.value.length<=Io&&g(S.target.value),f&&S.target.value.trim()&&b(!1)},onKeyDown:y,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:c&&!i,inputProps:{maxLength:Io},error:f&&!h.trim(),helperText:f&&!h.trim()?"View name is required":`${h.length} / ${Io}`}),t.jsx(o.TextField,{label:"Description (optional)",value:v,onChange:S=>T(S.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: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:[mt(e.filters)," filter",mt(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",Oa(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:C,onChange:S=>m(S.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:S=>`${S.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:c&&!i,startIcon:t.jsx(z.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:S=>`${S.shape.borderRadius}px`,boxShadow:S=>ce(S,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:S=>ce(S,"hoverButton")},"&:active":{boxShadow:S=>ce(S,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]})]})}function Du({viewName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>Ue(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:i=>ce(i,"menu")}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:["Delete View",t.jsx(o.IconButton,{onClick:n,size:"small",sx:{color:"text.secondary"},children:t.jsx(z.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(z.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=>ce(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ce(i,"hoverButton")},"&:active":{boxShadow:i=>ce(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const $o=100,Oo=600,Xi="COLUMN";function $u({column:e,index:r,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:l,moveColumn:d}){const c=p.useRef(null),[u,h]=p.useState(i.toString());p.useEffect(()=>{h(i.toString())},[i]);const[{handlerId:g},f]=Vt.useDrop({accept:Xi,collect(y){return{handlerId:y.getHandlerId()}},hover(y,$){var J;if(!c.current)return;const S=y.index,I=r;if(S===I)return;const N=(J=c.current)==null?void 0:J.getBoundingClientRect(),a=(N.bottom-N.top)/2,A=$.getClientOffset(),F=((A==null?void 0:A.y)??0)-N.top;S<I&&F<a||S>I&&F>a||(d(S,I),y.index=I)}}),[{isDragging:b},v]=Vt.useDrag({type:Xi,item:()=>({index:r}),collect:y=>({isDragging:y.isDragging()})});v(f(c));const T=()=>{const y=parseInt(u);if(isNaN(y)){h(i.toString()),l(e.name,i);return}const $=Math.max($o,Math.min(Oo,y));h($.toString()),l(e.name,$)},C=y=>{if(y===""||/^\d+$/.test(y)){h(y);const $=parseInt(y);if(!isNaN($)&&$>=$o){const S=Math.min(Oo,$);l(e.name,S)}}},m=y=>{y.key==="Enter"&&(y.preventDefault(),T(),y.target.blur())},j=y=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[y]||"text.secondary";return t.jsxs(o.TableRow,{ref:c,"data-handler-id":g,sx:{opacity:b?.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(z.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:et(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:`${j(e.type)}15`,color:j(e.type),border:`1px solid ${j(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:u,onChange:y=>C(y.target.value),onBlur:T,onKeyDown:m,placeholder:"150",size:"small",inputProps:{min:$o,max:Oo,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:"0.75rem",color:"text.secondary"},children:"px"})]})}),t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.IconButton,{onClick:()=>s(e.name,!n),title:n?"Hide column":"Show column",size:"small",sx:{p:.75,color:n?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:n?"primary.dark":"primary.main"}},children:n?t.jsx(z.Visibility,{sx:{fontSize:20}}):t.jsx(z.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(o.Chip,{label:n?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:n?y=>B(y.palette.success.main,.12):"action.selected",color:n?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function Ou({schema:e,columnVisibility:r,columnOrder:n,columnWidths:i={},views:s=[],activeViewId:l="",onUpdateColumnVisibility:d,onUpdateColumnOrder:c,onUpdateColumnWidth:u,onResetLayout:h,onClose:g}){const[f,b]=p.useState(!1),[v,T]=p.useState(n),[C,m]=p.useState(i),[j,y]=p.useState("all");p.useEffect(()=>{T(n)},[n]),p.useEffect(()=>{m(i)},[i]);const $=(x,R)=>{m(P=>({...P,[x]:R})),u==null||u(x,R)},S=(x,R)=>{const P=[...v],[te]=P.splice(x,1);P.splice(R,0,te),T(P),c(P)},I=()=>{h(),b(!1)},a=v.map(x=>e.find(R=>R.name===x)).filter(x=>x!==void 0).filter(x=>{const R=r[x.name]??!0;return j==="active"?R:j==="hidden"?!R:!0}),A=Object.values(r).filter(x=>x).length,F=e.length,J=s.find(x=>x.id===l),ee=p.useMemo(()=>{if(!J)return!1;const x=J.snapshot,R=x.columnVisibility??{},P=JSON.stringify(r)!==JSON.stringify(R),te=x.columnOrder??[],ae=n??[],Q=JSON.stringify(ae)!==JSON.stringify(te)&&!(ae.length===0&&te.length===0),re=x.columnWidths??{},he=JSON.stringify(C)!==JSON.stringify(re);return P||Q||he},[J,r,n,C]);return t.jsx(Vt.DndProvider,{backend:Rn.HTML5Backend,children:t.jsx(o.Box,{onClick:g,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:x=>B(x.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:x=>x.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:x=>x.stopPropagation(),elevation:0,sx:{position:"relative",width:720,maxWidth:"calc(100vw - 120px)",maxHeight:"min(760px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:x=>Ue(x),bgcolor:"background.paper",outline:"none",boxShadow:x=>ce(x,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:3,pt:2,pb:1.5,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[t.jsx(o.Box,{sx:{flex:1},children:t.jsxs(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:["Manage columns",t.jsx(Cr,{content:jr.columns,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.IconButton,{onClick:g,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(z.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:j,onChange:(x,R)=>y(R),sx:{minHeight:36,mt:.5,"& .MuiTabs-indicator":{bgcolor:"primary.main",height:3}},children:[t.jsx(o.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),t.jsx(o.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}}),t.jsx(o.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary","&.Mui-selected":{color:"primary.main"}}})]})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:x=>B(x.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:x=>B(x.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: ${$o}px, max: ${Oo}px)`,arrow:!0,placement:"top",children:t.jsx(z.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:a.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:"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):a.map((x,R)=>t.jsx($u,{column:x,index:R,isVisible:r[x.name]??!0,width:C[x.name]||170,onToggleVisibility:d,onWidthChange:$,moveColumn:S},x.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:"0.8125rem",color:"text.secondary"},children:[A," of ",F," columns visible • Drag to reorder"]})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:t.jsx(o.Button,{onClick:()=>b(!0),disabled:!ee,variant:"outlined",startIcon:t.jsx(z.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:x=>`${x.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})}),f&&t.jsx(o.Box,{onClick:()=>b(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:x=>B(x.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:x=>x.zIndex.tooltip},children:t.jsxs(o.Paper,{onClick:x=>x.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:x=>fo(x),bgcolor:"background.paper",boxShadow:x=>ce(x,"menu")},children:[t.jsxs(o.Box,{sx:{px:3,py:2.5},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1rem",fontWeight:500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.875rem",color:"text.secondary",lineHeight:1.5},children:"This will restore default visibility, order, and widths for all columns."})]}),t.jsxs(o.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(o.Button,{onClick:()=>b(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:x=>`${x.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:I,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:x=>`${x.shape.borderRadius}px`,boxShadow:x=>ce(x,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:x=>ce(x,"hoverButton")},"&:active":{boxShadow:x=>ce(x,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function _u({schema:e,grouping:r,onApply:n,onClose:i}){var N;const[s,l]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[d,c]=p.useState(""),[u,h]=p.useState(null),g=p.useMemo(()=>Ta(e),[e]),f=p.useMemo(()=>g.filter(a=>!s.levels.some((A,F)=>A.column===a.name&&F!==u)),[g,s.levels,u]),b=Sr(),v=s.levels.length<b.grouping.maxLevels&&f.length>0,T=p.useCallback(a=>{!v||!a||(l({...s,levels:[...s.levels,{column:a}],enabled:!0}),c(""),setTimeout(()=>{var A;return(A=document.activeElement)==null?void 0:A.blur()},0))},[v,s]),C=p.useCallback(a=>{const A=s.levels.filter((F,J)=>J!==a);if(A.length===0){n(null),i();return}l({...s,levels:A,enabled:A.length>0})},[s,n,i]),m=p.useCallback(a=>{h(a),c(s.levels[a].column)},[s.levels]),j=p.useCallback(()=>{if(u===null||!d)return;const a=[...s.levels];a[u]={column:d},l({...s,levels:a}),h(null),c("")},[u,d,s]),y=p.useCallback(()=>{h(null),c("")},[]),$=p.useCallback((a,A)=>{const F=A==="up"?a-1:a+1;if(F<0||F>=s.levels.length)return;const J=[...s.levels],[ee]=J.splice(a,1);J.splice(F,0,ee),l({...s,levels:J})},[s]),S=p.useCallback(()=>{n(null),i()},[n,i]),I=p.useCallback(()=>{s.levels.length===0?n(null):n({...s,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[s,r,n,i]);return t.jsx(o.Box,{onClick:i,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:a=>B(a.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:a=>a.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:a=>a.stopPropagation(),elevation:0,sx:{position:"relative",width:540,maxWidth:"calc(100vw - 120px)",maxHeight:"min(560px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:a=>Ue(a),bgcolor:"background.paper",outline:"none",boxShadow:a=>ce(a,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Group configuration"}),t.jsx(Cr,{content:jr.grouping,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:i,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(z.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:a=>B(a.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:a=>B(a.palette.text.primary,.3)}}},children:t.jsxs(o.Stack,{spacing:2.5,children:[u===null&&t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:d,onChange:a=>T(a.target.value),disabled:!v,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..."}),f.map(a=>t.jsxs(o.MenuItem,{value:a.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:A=>Ze(A),"&:hover":{bgcolor:A=>B(A.palette.primary.main,.2)}}},children:[et(a.name)," (",a.type.toUpperCase(),")"]},a.name))]})}),s.levels.length>=b.grouping.maxLevels&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),g.length===0&&t.jsx(o.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),u!==null&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px",border:a=>`1px solid ${B(a.palette.warning.main,.5)}`,bgcolor:a=>B(a.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(o.Typography,{variant:"body2",sx:{fontWeight:500,mb:1.5,fontSize:"0.875rem",color:"text.primary"},children:["Edit Group Level ",u+1]}),t.jsx(o.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(o.Select,{value:d,onChange:a=>c(a.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(o.MenuItem,{value:s.levels[u].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:a=>Ze(a)}},children:[s.levels[u].column," (",(N=e.find(a=>a.name===s.levels[u].column))==null?void 0:N.type.toUpperCase(),")"]}),f.filter(a=>a.name!==s.levels[u].column).map(a=>t.jsxs(o.MenuItem,{value:a.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:A=>Ze(A)}},children:[et(a.name)," (",a.type.toUpperCase(),")"]},a.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:j,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:a=>ce(a,"pressedButton")}},children:"Save"}),t.jsx(o.Button,{onClick:y,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),s.levels.length>0&&u===null&&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:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(o.Button,{onClick:S,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:s.levels.map((a,A)=>{const F=e.find(J=>J.name===a.column);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,p:2,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:J=>ce(J,"pressedButtonLight")}},children:[t.jsx(o.Chip,{label:`L${A+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:J=>`0 1px 2px 0 ${B(J.palette.primary.main,.3)}`}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:a.column}),t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary"},children:F==null?void 0:F.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>$(A,"up"),disabled:A===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(z.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>$(A,"down"),disabled:A===s.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(z.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>m(A),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx(z.Edit,{sx:{fontSize:18}})}),t.jsx(o.IconButton,{size:"small",onClick:()=>C(A),sx:{color:"text.secondary","&:hover":{bgcolor:J=>B(J.palette.error.main,.08),color:"error.main"}},children:t.jsx(z.Delete,{sx:{fontSize:18}})})]})]},A)})})]})]})}),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:a=>`${a.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:I,variant:"contained",disabled:s.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:a=>`${a.shape.borderRadius}px`,boxShadow:a=>ce(a,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:a=>ce(a,"hoverButton")},"&:active":{boxShadow:a=>ce(a,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function Au({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(z.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:n,sx:{color:"warning.main"},children:t.jsx(z.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:600,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(z.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(o.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx(z.Download,{sx:{fontSize:14}}),size:"small",children:"Export Anyway"})]})]})})}const Qi=[{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 Mu(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 Ru(e,r){if(r===null)return[];const n=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<n)}function Wu({auditHistory:e,onClose:r,onClearAuditHistory:n}){const i=rt(),s=i.palette,[l,d]=p.useState("1h"),[c,u]=p.useState(!1),h=[...e].sort((T,C)=>new Date(C.timestamp).getTime()-new Date(T.timestamp).getTime()),g=Qi.find(T=>T.key===l),f=Mu(e,g.ms),b=()=>u(!0),v=()=>{n&&(n(Ru(e,g.ms)),u(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{onClick:r,sx:{position:"fixed",inset:0,bgcolor:B(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:T=>T.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:Ue(i),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${B(s.common.black,.14)}, 0 2px 8px ${B(s.common.black,.08)}`,animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{px:2.5,py:1.75,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,flexShrink:0,borderBottom:"1px solid",borderColor:"divider"},children:[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:"0.9375rem",fontWeight:600,color:"text.primary"},children:"Audit History"}),t.jsx(Cr,{content:jr.auditHistory,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.125},children:[h.length," event",h.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:l,onChange:T=>d(T.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:B(s.text.primary,.3)}},children:Qi.map(T=>t.jsx(o.MenuItem,{value:T.key,sx:{fontSize:"0.8125rem"},children:T.label},T.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(z.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:b,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:B(s.error.main,.5),"&:hover":{bgcolor:B(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),t.jsx(o.IconButton,{onClick:r,size:"small",sx:{color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(z.Close,{sx:{fontSize:17}})})]})]}),t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",px:2,py:1.5,bgcolor:B(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:B(s.text.primary,.14),borderRadius:3}},children:h.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx(z.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(o.Typography,{sx:{fontSize:"0.9375rem",color:"text.secondary",fontWeight:500},children:"No audit events yet"}),t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",color:"text.disabled"},children:"Changes to this report will appear here"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:h.map(T=>{const C=Zd(i,T.feature),{summary:m,detail:j}=Ya(T);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:B(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:Ka(T.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:B(C,.1),color:C,border:`1px solid ${B(C,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:m}),j&&t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:j}),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(z.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:Xa(T.timestamp)})]}),T.user&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(z.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(o.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:T.user})]})]})]})]},T.id)})})})]})}),t.jsxs(o.Dialog,{open:c,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:fo(i),boxShadow:`0 8px 32px ${B(s.common.black,.14)}`}},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:B(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(z.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(o.Typography,{sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",t.jsxs(o.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[f," audit record",f!==1?"s":""]})," ",g.key==="all"?"from all time":`from the ${g.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(o.Divider,{}),t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(o.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(o.Button,{onClick:v,variant:"contained",color:"error",startIcon:t.jsx(z.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",f," Record",f!==1?"s":""]})]})]})]})}function Pu({onSave:e,onClose:r}){const[n,i]=p.useState(""),[s,l]=p.useState(""),[d,c]=p.useState(""),[u,h]=p.useState([]),[g,f]=p.useState(""),[b,v]=p.useState(""),T=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),C=()=>{const I=d.trim();if(I){if(!T(I)){v("Please enter a valid email address");return}if(u.includes(I)){v("This email is already added");return}h([...u,I]),c(""),v("")}},m=I=>{h(u.filter(N=>N!==I))},j=I=>{I.key==="Enter"&&(I.preventDefault(),C())},y=()=>{if(!n.trim()){f("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},$=I=>{i(I),g&&f("")},S=I=>{c(I),b&&v("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:I=>B(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(480px, calc(100vh - 280px))",display:"flex",flexDirection:"column",borderRadius:I=>Ue(I),bgcolor:"background.paper",outline:"none",boxShadow:I=>ce(I,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,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(z.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:I=>B(I.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:I=>B(I.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(z.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:I=>`1px solid ${B(I.palette.primary.main,.3)}`,bgcolor:I=>Ze(I),"& .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:"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:"0.6875rem",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:I=>$(I.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!g,helperText:g,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(o.TextField,{value:s,onChange:I=>l(I.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:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[t.jsx(o.TextField,{value:d,onChange:I=>S(I.target.value),onKeyPress:j,placeholder:"Enter email address",error:!!b,helperText:b,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx(z.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}}),t.jsx(o.Button,{onClick:C,variant:"outlined",startIcon:t.jsx(z.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:I=>`${I.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(I=>t.jsx(o.Chip,{label:I,onDelete:()=>m(I),deleteIcon:t.jsx(z.Delete,{sx:{fontSize:16}}),sx:{bgcolor:N=>Ze(N),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},I))}),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:I=>`${I.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:y,variant:"contained",startIcon:t.jsx(z.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:I=>`${I.shape.borderRadius}px`,boxShadow:I=>ce(I,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:I=>ce(I,"hoverButton")},"&:active":{boxShadow:I=>ce(I,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]})]})})}function Nu({presetName:e,onClear:r}){return t.jsx(o.Chip,{icon:t.jsx(z.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(z.Close,{sx:{fontSize:14}})}),sx:{bgcolor:n=>B(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 Lu({presets:e,reportId:r,onOpenPreset:n,onDeletePreset:i,onClose:s}){const l=d=>new Date(d).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(o.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:d=>B(d.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:d=>d.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:d=>d.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:d=>Ue(d),bgcolor:"background.paper",outline:"none",boxShadow:d=>ce(d,"menu"),animation:"slideIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.95) translateY(-12px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,borderBottom:"1px solid divider",flexShrink:0},children:[t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"1.125rem",fontWeight:500,color:"text.primary",letterSpacing:"0",lineHeight:1.5},children:"Manage Presets"}),t.jsxs(o.Typography,{variant:"caption",sx:{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(z.Close,{sx:{fontSize:20}})})]}),t.jsx(o.Box,{sx:{flex:1,overflow:"auto",px:3,py:2,"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:"divider",borderRadius:4,"&:hover":{bgcolor:d=>B(d.palette.text.primary,.2)}}},children:e.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx(z.Share,{sx:{fontSize:48,color:"divider",mb:2}}),t.jsx(o.Typography,{variant:"body1",sx:{fontSize:"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.disabled",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(d=>t.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:c=>ce(c,"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:"0.9375rem",fontWeight:500,color:"text.primary",mb:.5},children:d.name}),d.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:d.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${l(d.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(o.Chip,{label:`By ${d.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),t.jsx(o.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",gap:1},children:t.jsx(o.Button,{onClick:()=>i(d.id,d.name),variant:"outlined",size:"small",startIcon:t.jsx(z.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:c=>`${c.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:c=>B(c.palette.error.main,.04)}},children:"Delete"})})]},d.id))})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:t.jsx(o.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:d=>`${d.shape.borderRadius}px`,boxShadow:d=>ce(d,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:d=>ce(d,"hoverButton")},"&:active":{boxShadow:d=>ce(d,"pressedButton"),transform:"translateY(1px)"}},children:"Close"})})]})})}const Ns={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},Fu=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],Vu=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function Hu(e,r){const n=[];for(const i of e){if(i.type!=="string")continue;const s=Vu.some(c=>c.test(i.name));let l=!1;const d=r.slice(0,10).map(c=>c[i.name]).filter(c=>typeof c=="string"&&c.length>0);d.length>0&&(l=d.filter(u=>Fu.some(h=>h.test(u))).length/d.length>.6),(s||l)&&n.push(i.name)}return n}function Xn(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(d=>{const c=n.map(h=>String(h[d]??"")).filter(h=>h.length>0);if(c.length===0)return 5;const u=c.reduce((h,g)=>h+g.length,0);return Math.ceil(u/c.length)+1}).reduce((d,c)=>d+c,0)+1;return r.reduce((d,c)=>d+c.length+1,0)+s*e.length}function Uu(e,r){const n=Xn(e,r);return Math.ceil(n*3.5)}function Gu(e,r){const n=Xn(e,r);return Math.ceil(n*.7)}function Yu(e,r,n){switch(e){case"csv":return Xn(r,n);case"excel":return Gu(r,n);case"json":return Uu(r,n)}}function Zi(e,r){return Math.ceil(e/r)}function qu(e,r,n,i,s=Ns){const l=[],d=Yu(e,r,n),c=r.length;if(c>s.maxRowsHard){const g=Zi(c,s.maxRows);l.push({type:"row_count",severity:"error",message:`Export blocked: ${c.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${g} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:g,value:c,limit:s.maxRowsHard})}else if(c>s.maxRows){const g=Zi(c,s.maxRows);l.push({type:"row_count",severity:"warning",message:`Large export: ${c.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${g} smaller export${g>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:g,value:c,limit:s.maxRows})}if(d>s.maxFileSizeHardBytes?l.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${lo(d)} exceeds the ${lo(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:d,limit:s.maxFileSizeHardBytes}):d>s.maxFileSizeBytes&&l.push({type:"file_size",severity:"warning",message:`Large file: estimated ${lo(d)}`,detail:`This exceeds the recommended ${lo(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:d,limit:s.maxFileSizeBytes}),e!=="excel"){const g=Hu(i.filter(f=>n.includes(f.name)),r);if(g.length>0){const f=g.length>s.maxImageColumns;l.push({type:"image_columns",severity:f?"error":"warning",message:`Image column${g.length>1?"s":""} detected: ${g.map(b=>`"${b.replace(/_/g," ")}"`).join(", ")}`,detail:f?`Exporting ${g.length} image columns may produce a very large file. Consider hiding these columns before exporting.`:"Image URL columns are included in the export as plain text links — not embedded images.",value:g.length,limit:s.maxImageColumns})}}const u=l.some(g=>g.severity==="error"),h=l.some(g=>g.severity==="warning");return{violations:l,hasBlockingViolation:u,hasWarning:h,estimatedBytes:d}}function lo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ju({violation:e}){const n=rt().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,l=B(i?n.error.main:n.warning.main,.06),d=i?B(n.error.main,.25):B(n.warning.main,.3),c=i?z.ErrorOutline:z.WarningAmberOutlined;return t.jsxs(o.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"10px",bgcolor:l,border:"1px solid",borderColor:d},children:[t.jsx(c,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:"0.8125rem",fontWeight:600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(o.Typography,{sx:{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(z.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(o.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",fontWeight:500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function Ku({format:e}){const r=rt(),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"}}[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:B(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=rt();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 Xu({totalRows:e,visibleRows:r,hasGrouping:n,visibleColumnsCount:i,totalColumnsCount:s,schema:l,sampleRows:d=[],allRows:c=[],processedRows:u=[],initialFormat:h,initialScope:g="visible",initialColumnScope:f="visible",classTokens:b={},onExport:v,onClose:T}){const C=rt(),m=C.palette,j=Sr(),y=p.useMemo(()=>({sectionBorder:`var(--urm-export-section-border, ${m.divider})`,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.mode==="dark"?B(m.common.white,.04):B(m.common.black,.02)})`,cardBorder:`var(--urm-export-card-border, ${m.divider})`,cardHoverBg:`var(--urm-export-card-hover-bg, ${m.mode==="dark"?B(m.common.white,.08):B(m.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${B(m.primary.main,.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${m.primary.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${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]),$=h||j.export.allowedFormats[0]||"csv",[S,I]=p.useState($),[N,a]=p.useState(g),[A,F]=p.useState(f),J=N==="visible"?r:e,ee=A==="visible"?i:s,x=p.useMemo(()=>N==="visible"?u.length>0?u:new Array(r):c.length>0?c:new Array(e),[N,r,e,u,c]),R=p.useMemo(()=>A==="all"?l.map(Q=>Q.name):l.map(Q=>Q.name).slice(0,i),[A,l,i]),P=p.useMemo(()=>qu(S,x,R,l,Ns),[S,x,R,l]),te=()=>{P.hasBlockingViolation||(v({format:S,scope:N,columnScope:A}),T())},ae={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"};return t.jsx(o.Box,{onClick:T,className:`urm-export-backdrop ${b.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:B(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:Q=>Q.stopPropagation(),elevation:0,className:`urm-export-paper ${b.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:"16px",bgcolor:y.sectionTitleBg,overflow:"hidden",boxShadow:Q=>`0 20px 40px -10px ${B(Q.palette.common.black,.16)}, 0 0 0 1px ${B(Q.palette.common.black,.05)}`,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 ${b.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{className:`urm-export-title ${b.modalTitle||""}`,sx:{fontSize:"1.125rem",fontWeight:700,color:m.text.primary},children:"Export Report"}),t.jsx(Cr,{content:jr.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:T,size:"small",className:`urm-export-close ${b.modalCloseButton||""}`,sx:{color:m.text.secondary,borderRadius:"50%","&:hover":{bgcolor:m.action.hover,color:m.text.primary}},children:t.jsx(z.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{className:`urm-export-content ${b.modalContent||""}`,sx:{flex:1,overflowY:"auto",px:3,pb:2.5,pt:.5,display:"flex",flexDirection:"column",gap:y.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:B(m.text.primary,.15),borderRadius:3}},children:[P.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:P.violations.map((Q,re)=>t.jsx(Ju,{violation:Q},re))}),t.jsxs(o.Box,{className:`urm-export-section ${b.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${y.sectionBorder}`,borderRadius:"12px",p:y.sectionPadding,pt:2.25,bgcolor:y.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${b.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:y.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:y.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:y.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")}].filter(Q=>Q.allowed).map(Q=>{const re=S===Q.id;return t.jsxs(o.Box,{onClick:()=>I(Q.id),className:`urm-export-format-card ${re?b.formatCardSelected||"":b.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:"12px",border:re?`2px solid ${y.cardSelectedBorder}`:`1px solid ${y.cardBorder}`,bgcolor:re?y.cardSelectedBg:y.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?y.cardSelectedBorder:B(m.text.primary,.25),bgcolor:re?y.cardSelectedBg:y.cardHoverBg}},children:[re&&t.jsx(o.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:y.cardSelectedBorder,color:m.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${B(m.primary.main,.3)}`},children:t.jsx(z.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(Ku,{format:Q.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?y.cardSelectedColor:m.text.primary},children:Q.title}),t.jsx(o.Tooltip,{title:Q.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:he=>he.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(z.InfoOutlined,{sx:{fontSize:13}})})})]})]},Q.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${b.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${y.sectionBorder}`,borderRadius:"12px",p:y.sectionPadding,pt:2.25,bgcolor:y.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${b.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:y.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:y.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:y.optionGap},children:[{value:"visible",label:"Visible rows",icon:t.jsx(z.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx(z.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(Q=>{const re=N===Q.value;return t.jsxs(o.Box,{onClick:()=>a(Q.value),className:`urm-export-row-card ${re?b.rowCardSelected||"":b.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:"10px",border:re?`2px solid ${y.cardSelectedBorder}`:`1px solid ${y.cardBorder}`,bgcolor:re?y.cardSelectedBg:y.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?y.cardSelectedBorder:B(m.text.primary,.25),bgcolor:re?y.cardSelectedBg:y.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?y.cardSelectedColor:m.text.secondary,display:"flex"},children:Q.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?y.cardSelectedColor:m.text.primary},children:Q.label})]}),t.jsx(o.Tooltip,{title:Q.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:he=>he.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(z.InfoOutlined,{sx:{fontSize:16}})})})]},Q.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${b.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${y.sectionBorder}`,borderRadius:"12px",p:y.sectionPadding,pt:2.25,bgcolor:y.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${b.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:y.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:y.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(o.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:y.optionGap},children:[{value:"visible",label:"Visible columns only",icon:t.jsx(z.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx(z.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(Q=>{const re=A===Q.value;return t.jsxs(o.Box,{onClick:()=>F(Q.value),className:`urm-export-column-card ${re?b.columnCardSelected||"":b.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:"10px",border:re?`2px solid ${y.cardSelectedBorder}`:`1px solid ${y.cardBorder}`,bgcolor:re?y.cardSelectedBg:y.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:re?y.cardSelectedBorder:B(m.text.primary,.25),bgcolor:re?y.cardSelectedBg:y.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?y.cardSelectedColor:m.text.secondary,display:"flex"},children:Q.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:re?y.cardSelectedColor:m.text.primary},children:Q.label})]}),t.jsx(o.Tooltip,{title:Q.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:he=>he.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(z.InfoOutlined,{sx:{fontSize:16}})})})]},Q.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${b.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${y.sectionBorder}`,borderRadius:"12px",p:y.sectionPadding,pt:2.25,bgcolor:y.sectionTitleBg,mt:1.5},children:[t.jsx(o.Typography,{className:`urm-export-section-title ${b.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:y.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:y.sectionTitleColor,lineHeight:1,zIndex:1},children:"Export Summary"}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[{icon:t.jsx(z.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Format",value:ae[S]},{icon:t.jsx(z.FormatListNumberedOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Rows to Export",value:J.toLocaleString()},{icon:t.jsx(z.SwapVertOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Columns to Export",value:String(ee)},{icon:t.jsx(z.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Estimated File Size",value:`~${lo(P.estimatedBytes)}`,highlight:P.hasBlockingViolation?"error.main":P.hasWarning?"warning.main":void 0}].map(({icon:Q,label:re,value:he,highlight:L})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${b.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[Q,t.jsx(o.Typography,{className:`urm-export-summary-label ${b.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:m.text.secondary,fontWeight:500},children:re})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${b.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:L??m.text.primary},children:he})]},re))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${b.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,flexShrink:0},children:[P.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx(z.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(o.Typography,{sx:{fontSize:"0.75rem",color:"error.main",fontWeight:500},children:"Reduce rows or columns to enable download"})]}),t.jsx(o.Button,{onClick:T,variant:"outlined",className:`urm-export-cancel-btn ${b.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:m.text.primary,borderColor:y.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:y.cardHoverBg,borderColor:B(m.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:te,disabled:P.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${b.downloadButton||""}`,startIcon:t.jsx(z.Download,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:y.primaryBtnBg,color:y.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${B(m.primary.main,.25)}`,"&:hover":{bgcolor:y.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:B(m.primary.main,.4),color:y.primaryBtnColor}},children:["Download ",ae[S]]})]})]})})}function Qu({warning:e,onDismiss:r}){return t.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:"warning",icon:t.jsx(z.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx(z.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 Zu({error:e,onDismiss:r,autoDismiss:n=!0,autoDismissDelay:i=5e3}){p.useEffect(()=>{if(n){const c=setTimeout(()=>{r()},i);return()=>clearTimeout(c)}},[n,i,r]);const l=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx(z.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx(z.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx(z.InfoOutlined,{sx:{fontSize:20}})}}})(),d=ll(e);return t.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:l.severity,icon:l.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${l.severity}.main`},children:t.jsx(z.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${l.severity}.main`,boxShadow:3},children:[t.jsxs(o.AlertTitle,{sx:{fontWeight:600},children:[e.context.charAt(0).toUpperCase()+e.context.slice(1)," Error"]}),t.jsx(o.Box,{sx:{fontSize:"body2.fontSize"},children:d}),e.details&&process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e.details,null,2)})]})})}class ep extends p.Component{constructor(n){super(n);ii(this,"handleReset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,i){Ot.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=>B(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(z.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"h6",sx:{color:"error.main",fontWeight:600},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=>B(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(z.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function tp({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(z.Warning,{sx:{fontSize:20}}),action:t.jsx(o.IconButton,{size:"small",onClick:()=>n(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx(z.Close,{sx:{fontSize:16}})}),children:[t.jsxs(o.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function zo({children:e,feature:r,onError:n}){return t.jsx(ep,{context:r,onError:i=>{n&&n(i)},fallback:t.jsx(tp,{feature:r}),children:e})}const rp=[{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"}],op=[{value:"csv",label:"CSV",desc:"Comma-separated values"},{value:"excel",label:"Excel (.xlsx)",desc:"Native Excel format"},{value:"json",label:"JSON",desc:"Structured data with metadata"}];function no({children:e,active:r}){return t.jsx(o.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5},children:e})}function np({open:e,onClose:r,config:n,onApply:i}){const[s,l]=p.useState(0),[d,c]=p.useState(n),u=()=>c(n),h=()=>c(Xe),g=()=>{i(d),r()},f={sort:m=>c(j=>({...j,sort:{...j.sort,...m}})),filter:m=>c(j=>({...j,filter:{...j.filter,...m}})),columns:m=>c(j=>({...j,columns:{...j.columns,...m}})),grouping:m=>c(j=>({...j,grouping:{...j.grouping,...m}})),export:m=>c(j=>({...j,export:{...j.export,...m}}))},b=m=>{const j=d.filter.allowedOperators,y=j.includes(m)?j.filter($=>$!==m):[...j,m];y.length!==0&&f.filter({allowedOperators:y})},v=m=>{const j=d.export.allowedFormats,y=j.includes(m)?j.filter($=>$!==m):[...j,m];y.length!==0&&f.export({allowedFormats:y})},T=[{label:"Sort",icon:t.jsx(z.SwapVert,{sx:{fontSize:17}})},{label:"Filter",icon:t.jsx(z.FilterList,{sx:{fontSize:17}})},{label:"Columns",icon:t.jsx(z.ViewColumn,{sx:{fontSize:17}})},{label:"Grouping",icon:t.jsx(z.Layers,{sx:{fontSize:17}})},{label:"Export",icon:t.jsx(z.Download,{sx:{fontSize:17}})}],C=m=>JSON.stringify(d[m])===JSON.stringify(Xe[m]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:m=>Ue(m),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:m=>`0 8px 32px ${B(m.palette.common.black,.2)}`}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1,borderBottom:"1px solid",borderColor:"divider",flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(o.Box,{sx:{width:32,height:32,borderRadius:"8px",bgcolor:m=>B(m.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.1rem"},children:"⚙️"}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"subtitle1",sx:{fontWeight:600,lineHeight:1.2},children:"Developer Configuration"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:"Set runtime constraints · Ctrl+Shift+D"})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary"},children:t.jsx(z.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)=>l(j),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:T.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},children:[t.jsxs(no,{active:s===0,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),!C("sort")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can sort by at most this many columns simultaneously."}),t.jsx(o.Slider,{value:d.sort.maxLevels,onChange:(m,j)=>f.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(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:['The "Add sort column" button is hidden once users reach this limit. Default is'," ",t.jsx("strong",{children:"5"}),"."]})]}),t.jsxs(no,{active:s===1,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),!C("filter")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users can apply at most this many simultaneous filter conditions."}),t.jsx(o.Slider,{value:d.filter.maxConditions,onChange:(m,j)=>f.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.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Allowed filter operators"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked operators appear in the filter type dropdown. At least one must remain checked."}),["Text","Numeric","Boolean","Null checks"].map(m=>t.jsxs(o.Box,{sx:{mb:1.5},children:[t.jsx(o.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:"0.6875rem",display:"block",mb:.5},children:m}),t.jsx(o.FormGroup,{row:!0,sx:{gap:.5},children:rp.filter(j=>j.group===m).map(j=>t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{size:"small",checked:d.filter.allowedOperators.includes(j.value),onChange:()=>b(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(no,{active:s===2,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),!C("columns")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot make more than this many columns visible simultaneously."}),t.jsx(o.Slider,{value:d.columns.maxVisible,onChange:(m,j)=>f.columns({maxVisible:j}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(o.Divider,{}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,mb:.5},children:"Column width range (px)"}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:2},children:"Users cannot resize columns outside this minimum / maximum range."}),t.jsxs(o.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(o.Box,{sx:{flex:1},children:[t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(o.Slider,{value:d.columns.minColumnWidth,onChange:(m,j)=>f.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:d.columns.maxColumnWidth,onChange:(m,j)=>f.columns({maxColumnWidth:j}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}px`})]})]})]})]}),t.jsxs(no,{active:s===3,children:[t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),!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:()=>f.grouping({maxLevels:m}),sx:{flex:1,py:2.5,borderRadius:"10px",border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:d.grouping.maxLevels===m?"primary.main":"divider",bgcolor:d.grouping.maxLevels===m?j=>B(j.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:j=>B(j.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:d.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:d.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:d.grouping.allowCollapse,onChange:m=>f.grouping({allowCollapse:m.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),t.jsx(o.Alert,{severity:"info",sx:{borderRadius:2,fontSize:"0.8125rem"},children:'The "Add group level" button is hidden when users reach the configured limit.'})]}),t.jsx(no,{active:s===4,children:t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),!C("export")&&t.jsx(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.5},children:"Only checked formats appear in the Export dialog and the bulk export action. At least one must remain checked."}),t.jsx(o.FormGroup,{sx:{gap:1},children:op.map(m=>t.jsxs(o.Box,{onClick:()=>v(m.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:d.export.allowedFormats.includes(m.value)?"primary.main":"divider",bgcolor:d.export.allowedFormats.includes(m.value)?j=>B(j.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:d.export.allowedFormats.includes(m.value),onChange:()=>v(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=>B(m.palette.action.hover,.4),justifyContent:"space-between",flexShrink:0},children:[t.jsx(o.Button,{startIcon:t.jsx(z.RestartAlt,{sx:{fontSize:18}}),onClick:h,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary","&:hover":{color:"text.primary",bgcolor:m=>B(m.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsxs(o.Box,{sx:{display:"flex",gap:1},children:[t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px"},children:"Cancel"}),t.jsx(o.Button,{onClick:g,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:"Apply"})]})]})]})}const ip=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],sp={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 _o(e,r,n,i,s=new Date){const[l,d]=r.split(":").map(Number),c=new Date(s);if(c.setSeconds(0,0),c.setHours(l,d,0,0),e==="daily")return c<=s&&c.setDate(c.getDate()+1),c.toISOString();if(e==="weekly"){const u=n??1,h=c.getDay();let g=u-h;return g<0&&(g+=7),g===0&&c<=s&&(g=7),c.setDate(c.getDate()+g),c.toISOString()}if(e==="monthly"){const u=Math.min(i??1,28);return c.setDate(u),c<=s&&(c.setMonth(c.getMonth()+1),c.setDate(u)),c.toISOString()}return c.toISOString()}function ap(e){const r=Ls(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 ${sp[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function Ls(e){const[r,n]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(n).padStart(2,"0")} ${i}`}function lp(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),l=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${l}m`:l>0?`in ${l}m`:"in less than a minute"}function cp(e){const r=new Date(e),n=new Date,i=r.toDateString()===n.toDateString(),s=Ls(`${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 Fs(e){return`urm_schedules_${e}`}function Vs(e){try{const r=localStorage.getItem(Fs(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 Hs(e,r){try{localStorage.setItem(Fs(e),JSON.stringify(r))}catch{}}const dp=[{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"}],up=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Us={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"csv",scope:"all",email:""},br={"& .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 pp({initial:e=Us,isEditing:r=!1,onSave:n,onBack:i}){const[s,l]=p.useState(e),[d,c]=p.useState(!1),[u,h]=p.useState(!1),g=(v,T)=>l(C=>({...C,[v]:T})),f=s.email.trim().length>0&&!up.test(s.email.trim()),b=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!f;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:v=>B(v.palette.text.primary,.06)}},children:t.jsx(z.ArrowBack,{sx:{fontSize:18}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600},children:r?"Edit schedule":"New schedule"})]}),t.jsx(o.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:s.name,onChange:v=>{g("name",v.target.value),d&&v.target.value.trim()&&c(!1)},onBlur:()=>c(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:d&&!s.name.trim(),helperText:d&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:br}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:br,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:v=>g("frequency",v.target.value),children:[t.jsx(o.MenuItem,{value:"daily",children:"Daily"}),t.jsx(o.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(o.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:br,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:v=>g("dayOfWeek",Number(v.target.value)),children:dp.map(v=>t.jsx(o.MenuItem,{value:v.value,children:v.label},v.value))})]}),s.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:v=>g("dayOfMonth",Number(v.target.value)),inputProps:{min:1,max:28},error:s.dayOfMonth<1||s.dayOfMonth>28,helperText:s.dayOfMonth<1||s.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:br}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:v=>g("time",v.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:br}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:br,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:v=>g("format",v.target.value),children:[t.jsx(o.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),t.jsx(o.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(o.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),t.jsxs(o.RadioGroup,{row:!0,value:s.scope,onChange:v=>g("scope",v.target.value),sx:{gap:2},children:[t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"All rows"})}),t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:v=>g("email",v.target.value),onBlur:()=>h(!0),placeholder:"user@company.com",error:u&&f,helperText:u&&f?"Enter a valid email address":void 0,InputProps:{startAdornment:t.jsx(z.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:br}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:.5,mt:.5,px:.5},children:[t.jsx(z.InfoOutlined,{sx:{fontSize:12,color:"text.disabled",mt:.2,flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",color:"text.disabled",sx:{lineHeight:1.5},children:"Opens your device's email app when the schedule fires. Requires a default mail app (e.g. Outlook, Mail) on this device."})]})]}),t.jsxs(o.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(o.Button,{onClick:i,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:v=>B(v.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>b&&n(s),disabled:!b,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function xp({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>fo(i),boxShadow:i=>`0 8px 32px ${B(i.palette.common.black,.14)}`}},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=>B(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(z.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(o.Typography,{sx:{fontSize:"0.9375rem",fontWeight:600,color:"text.primary",mb:1},children:"Delete Schedule"}),t.jsxs(o.Typography,{sx:{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 mp({schedule:e,tick:r,onToggle:n,onRunNow:i,onEdit:s,onDelete:l}){const d=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:d?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:d?c=>B(c.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:d?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:d?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:d?c=>B(c.palette.success.main,.1):c=>B(c.palette.text.primary,.06),color:d?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:ap(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:c=>B(c.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:c=>B(c.palette.text.primary,.06),color:"text.secondary"}}),e.email&&t.jsx(o.Chip,{icon:t.jsx(z.Email,{sx:{fontSize:11}}),label:e.email,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:c=>B(c.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}})]}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:1},children:[t.jsxs(o.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[d&&t.jsxs(o.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",lp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",cp(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:c=>B(c.palette.primary.main,.08)}},children:t.jsx(z.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:d?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:d?"warning.main":"success.main","&:hover":{bgcolor:d?c=>B(c.palette.warning.main,.08):c=>B(c.palette.success.main,.08)}},children:d?t.jsx(z.Pause,{sx:{fontSize:15}}):t.jsx(z.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:c=>B(c.palette.primary.main,.08)}},children:t.jsx(z.Download,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:"Delete",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>l(e.id),sx:{color:"error.main","&:hover":{bgcolor:c=>B(c.palette.error.main,.08)}},children:t.jsx(z.Delete,{sx:{fontSize:15}})})})]})]})]})}function fp({open:e,onClose:r,reportId:n,reportName:i,onRunNow:s}){const[l,d]=p.useState([]),[c,u]=p.useState({type:"list"}),[h,g]=p.useState(0),[f,b]=p.useState(null);p.useEffect(()=>{e&&(d(Vs(n)),u({type:"list"}))},[e,n]),p.useEffect(()=>{if(!e)return;const a=setInterval(()=>g(A=>A+1),3e4);return()=>clearInterval(a)},[e]);const v=p.useCallback(a=>{d(a),Hs(n,a)},[n]),T=a=>{const A=_o(a.frequency,a.time,a.dayOfWeek,a.dayOfMonth),F={id:`sched-${Date.now()}`,reportId:n,name:a.name.trim(),frequency:a.frequency,dayOfWeek:a.frequency==="weekly"?a.dayOfWeek:void 0,dayOfMonth:a.frequency==="monthly"?a.dayOfMonth:void 0,time:a.time,format:a.format,scope:a.scope,email:a.email.trim()||void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:A,runCount:0};v([...l,F]),u({type:"list"})},C=a=>{if(c.type!=="edit")return;const A=c.schedule,F=_o(a.frequency,a.time,a.dayOfWeek,a.dayOfMonth);v(l.map(J=>J.id===A.id?{...A,name:a.name.trim(),frequency:a.frequency,dayOfWeek:a.frequency==="weekly"?a.dayOfWeek:void 0,dayOfMonth:a.frequency==="monthly"?a.dayOfMonth:void 0,time:a.time,format:a.format,scope:a.scope,email:a.email.trim()||void 0,nextRunAt:F}:J)),u({type:"list"})},m=a=>{v(l.map(A=>{if(A.id!==a)return A;const F=A.isActive?A.nextRunAt:_o(A.frequency,A.time,A.dayOfWeek,A.dayOfMonth);return{...A,isActive:!A.isActive,nextRunAt:F}}))},j=a=>{s(a);const A=new Date().toISOString();v(l.map(F=>F.id===a.id?{...F,lastRunAt:A,runCount:F.runCount+1}:F))},y=a=>{const A=l.find(F=>F.id===a)??null;b(A)},$=()=>{f&&(v(l.filter(a=>a.id!==f.id)),b(null))},S=a=>({name:a.name,frequency:a.frequency,dayOfWeek:a.dayOfWeek??1,dayOfMonth:a.dayOfMonth??1,time:a.time,format:a.format,scope:a.scope,email:a.email??""}),I=c.type!=="list",N=l.filter(a=>a.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,disableEscapeKeyDown:I,PaperProps:{sx:{borderRadius:a=>Ue(a),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:6}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",py:1.5,px:2.5,borderBottom:"1px solid",borderColor:"divider",flexShrink:0,minHeight:0},children:[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:a=>B(a.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(z.Schedule,{sx:{fontSize:17,color:"primary.main"}})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(o.Typography,{variant:"subtitle2",sx:{fontWeight:600,lineHeight:1},children:"Scheduled Reports"}),t.jsx(Cr,{content:jr.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:a=>B(a.palette.text.primary,.06)}},children:t.jsx(z.Close,{sx:{fontSize:18}})})]}),t.jsxs(o.DialogContent,{sx:{overflowY:"auto",flex:1,px:2.5,py:2},children:[I&&t.jsx(pp,{initial:c.type==="edit"?S(c.schedule):Us,isEditing:c.type==="edit",onSave:c.type==="edit"?C:T,onBack:()=>u({type:"list"})}),c.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:l.length===0?"No schedules yet":`${N} of ${l.length} active`}),t.jsx(o.Button,{startIcon:t.jsx(z.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>u({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),l.length===0?t.jsxs(o.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx(z.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:500,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:l.map(a=>t.jsx(mp,{schedule:a,tick:h,onToggle:m,onRunNow:j,onEdit:A=>u({type:"edit",schedule:A}),onDelete:y},a.id))})]})]}),c.type==="list"&&t.jsxs(o.DialogActions,{sx:{px:2.5,py:1.25,borderTop:"1px solid",borderColor:"divider",flexShrink:0,display:"flex",alignItems:"center",gap:1},children:[t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75,px:1.25,py:.75,borderRadius:"8px",bgcolor:a=>B(a.palette.warning.main,.06),border:"1px solid",borderColor:a=>B(a.palette.warning.main,.2)},children:[t.jsx(z.Schedule,{sx:{fontSize:13,color:"warning.main",flexShrink:0}}),t.jsx(o.Typography,{variant:"caption",sx:{color:"warning.dark",lineHeight:1.1},children:"Schedules require this browser tab to remain open."})]}),t.jsx(o.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:a=>B(a.palette.text.primary,.06)}},children:"Close"})]})]}),f&&t.jsx(xp,{scheduleName:f.name,onConfirm:$,onCancel:()=>b(null)})]})}const hp=6e4;function gp({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:l,columnVisibility:d,columnOrder:c,filters:u,sortStack:h,onFired:g}){const f=p.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:l,columnVisibility:d,columnOrder:c,filters:u,sortStack:h,onFired:g});p.useEffect(()=>{f.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:l,columnVisibility:d,columnOrder:c,filters:u,sortStack:h,onFired:g}});const b=p.useCallback(v=>{var a,A;const{reportName:T,uploadedData:C,processedData:m,schema:j,activeView:y,columnVisibility:$,columnOrder:S,filters:I,sortStack:N}=f.current;try{const F=v.scope==="all"?C:m,J=Ao(F,j,I,N,y,$,S),ee=`${v.name}_scheduled`;switch(v.format){case"csv":Mo(J,ee,{scope:v.scope});break;case"excel":Ro(J,ee,{scope:v.scope});break;case"json":Wo(J,ee,{scope:v.scope});break}if(v.email){const x=encodeURIComponent(`Scheduled Report: ${v.name}`),R=encodeURIComponent(`Your scheduled report "${v.name}" has been generated.
90
90
 
91
- Report: ${z}
92
- Format: ${b.format.toUpperCase()}
91
+ Report: ${T}
92
+ Format: ${v.format.toUpperCase()}
93
93
  Generated: ${new Date().toLocaleString()}
94
94
 
95
- The file has been downloaded to your device.`);window.open(`mailto:${b.email}?subject=${h}&body=${V}`,"_blank")}(_=(a=x.current).onFired)==null||_.call(a,b)}catch(F){Et.error("urm:scheduler",`Export failed for schedule: ${b.name}`,F)}},[]);p.useEffect(()=>{if(!e)return;const b=()=>{const{reportId:S}=x.current;if(!S)return;const y=Ds(S),w=new Date;let C=!1;const E=y.map(g=>{if(!g.isActive)return g;if(new Date(g.nextRunAt)<=w){v(g);const L=jo(g.frequency,g.time,g.dayOfWeek,g.dayOfMonth,w);return C=!0,{...g,lastRunAt:w.toISOString(),nextRunAt:L,runCount:g.runCount+1}}return g});C&&Os(S,E)};b();const z=setInterval(b,mp);return()=>clearInterval(z)},[e,v])}function As({reportEngine:e}){var Kt,Br,At,_t,fr;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:l,activeView:d,isDirty:c,currentTableState:u,showFilterPanel:m,setShowFilterPanel:f,filterFocusColumn:x,handleReplaceFilters:v,handleOpenFilterForColumn:b,handleCloseFilterPanel:z,handleClearFiltersForColumn:S,showSortPanel:y,setShowSortPanel:w,handleSort:C,handleUpdateSortStack:E,handleSortAscending:g,handleSortDescending:k,showCreateViewModal:L,setShowCreateViewModal:a,showEditViewModal:_,setShowEditViewModal:F,showDeleteConfirmation:X,setShowDeleteConfirmation:re,editingView:h,deletingView:V,handleSelectView:W,handleCreateView:Q,handleUpdateCurrentView:Z,handleSaveColumnConfigToCurrentView:pe,handleSaveColumnConfigToAllViews:he,handleSaveAsNewView:N,handleRevertChanges:R,handleToggleDefault:H,handleToggleFavorite:G,handleSoftDelete:ae,handleRestoreView:ee,handlePermanentDelete:ne,handleEditView:oe,handleCloneView:O,handleCopyViewLink:te,handleSaveEditView:ce,handleConfirmDelete:ie,handlePromoteToGlobal:Ie,showManageColumns:q,setShowManageColumns:Me,handleUpdateColumnVisibility:et,handleUpdateColumnOrder:tt,handleUpdateColumnWidth:rr,handleResetColumnLayout:Ft,showGroupPanel:Vt,setShowGroupPanel:rt,handleGroup:pt,handleToggleGroupCollapse:or,handleExpandAllGroups:Ct,handleCollapseAllGroups:Je,searchQuery:jt,debouncedSearchQuery:Bt,searchHistory:Ht,handleSearchChange:nr,handleAddToSearchHistory:ir,handleToggleSearchFavourite:He,handleDeleteSearchHistory:no,selectedRowIds:sr,handleToggleRowSelection:Ut,handleToggleAllRows:ot,handleRangeSelection:nt,handleClearSelection:ar,handleUpdateSelectionAfterDelete:lr,currentPage:wt,pageSize:wr,paginationEngine:xt,handlePageChange:Nr,handlePageSizeChange:cr,isExporting:dr,showExportModal:me,setShowExportModal:kr,showDirtyExportWarning:io,handleExport:kt,handleExportWithConfig:P,handleExportSelected:mt,handleExportAnyway:fe,handleSaveAndExport:Le,handleCancelExport:Dt,showAuditHistory:ft,setShowAuditHistory:Gt,showCreatePreset:Tt,setShowCreatePreset:Tr,showManagePresets:Yt,setShowManagePresets:ur,activePreset:qt,handleCreatePreset:ze,handleClearActivePreset:K,handleOpenPresetById:Ot,handleDeletePresetById:we,isViewerRole:Ir,userRole:pr,featureLimitWarning:Se,setFeatureLimitWarning:Fe,reportError:xr,setReportError:it,handleError:ht,updateReport:Ve,showSnack:mr}=e,[zr,gt]=p.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:d,columnVisibility:(r==null?void 0:r.columnVisibility)||((Kt=d==null?void 0:d.snapshot)==null?void 0:Kt.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((Br=d==null?void 0:d.snapshot)==null?void 0:Br.columnOrder)||[],filters:Oe(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:le=>{mr(`Scheduled export "${le.name}" completed`,"success")}});const Ue=p.useCallback((le,ge)=>{if(!(r!=null&&r.uploadedData))return;const Ae=[...r.uploadedData];Ae[le]=ge,Ve(r.id,{uploadedData:Ae})},[r,Ve]),Er=p.useCallback(le=>{if(!(r!=null&&r.uploadedData))return;const ge=r.uploadedData.indexOf(le);if(ge===-1)return;const Ae=r.uploadedData.filter((yt,bt)=>bt!==ge);Ve(r.id,{uploadedData:Ae}),lr(le)},[r,Ve,lr]),Lr=p.useCallback((le,ge)=>{if(!(r!=null&&r.uploadedData))return;const Ae=r.uploadedData.indexOf(ge),yt=Ae!==-1?Ae+1:le+1,bt=[...r.uploadedData];bt.splice(yt,0,{...ge}),Ve(r.id,{uploadedData:bt})},[r,Ve]),$t=Sr(),{handleDevConfigChange:Jt}=$o(),[Fr,st]=p.useState(!1);return p.useEffect(()=>{const le=ge=>{ge.ctrlKey&&ge.shiftKey&&ge.key==="D"&&(ge.preventDefault(),st(!0))};return document.addEventListener("keydown",le),()=>document.removeEventListener("keydown",le)},[]),!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:[Se&&t.jsx(Ku,{warning:Se,onDismiss:()=>Fe(null)}),xr&&t.jsx(Xu,{error:xr,onDismiss:()=>it(null)}),io&&t.jsx(Au,{onExportAnyway:fe,onSaveAndExport:Le,onCancel:Dt}),t.jsx(ju,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:c,isExporting:dr,columnVisibility:r.columnVisibility||(d==null?void 0:d.snapshot.columnVisibility),columnOrder:r.columnOrder||(d==null?void 0:d.snapshot.columnOrder),columnWidths:r.columnWidths||(d==null?void 0:d.snapshot.columnWidths),grouping:r.grouping,onSort:C,onSortAscending:g,onSortDescending:k,onOpenFilters:()=>f(!0),onOpenSort:()=>w(!0),onOpenFilterForColumn:b,onSelectView:W,onCreateView:()=>a(!0),onUpdateCurrentView:Z,onSaveAsNewView:N,onDiscardChanges:R,onToggleDefault:H,onToggleFavorite:G,onRestoreView:ee,onPermanentDelete:ne,onEditView:oe,onCloneView:O,onCopyLink:te,onDeleteView:ae,onPromoteToGlobal:Ie,isAdmin:((At=$t.views)==null?void 0:At.isAdmin)??!1,onExport:kt,onOpenColumns:()=>Me(!0),onUpdateColumnWidth:rr,onUpdateColumnOrder:tt,onUpdateColumnVisibility:et,onClearFiltersForColumn:S,onResetLayout:Ft,onOpenGroup:()=>rt(!0),onGroupByColumn:le=>{pt({enabled:!0,levels:[{column:le}],collapsedGroups:[]})},onToggleGroupCollapse:or,onExpandAllGroups:Ct,onCollapseAllGroups:Je,onOpenAuditHistory:()=>Gt(!0),onOpenScheduledReports:()=>gt(!0),searchQuery:jt,highlightQuery:Bt,searchHistory:Ht,onAddToSearchHistory:ir,onToggleSearchFavourite:He,onDeleteSearchHistory:no,selectedRowIds:sr,onSearchChange:nr,onToggleRowSelection:Ut,onToggleAllRows:ot,onRangeSelection:nt,onClearSelection:ar,onExportSelected:mt,currentPage:(xt==null?void 0:xt.currentPage)||wt,pageSize:(xt==null?void 0:xt.pageSize)||wr,onPageChange:Nr,onPageSizeChange:cr,totalRowsBeforePagination:(s==null?void 0:s.searchedRows)||i.length,isReadOnly:Ir,userRole:pr,reportName:r.name,onEditRow:Ue,onDeleteRow:Er,onDuplicateRow:Lr,showDevPanel:$t.display.showDevPanel,onOpenDevConfig:()=>st(!0)})]}),m&&t.jsx(yo,{feature:"Filters",onError:le=>{const ge=Zt("ui","filters",le);ht(ge)},children:t.jsx(Iu,{schema:r.schema,filters:r.filters,onReplaceFilters:v,onClose:z,focusColumn:x})}),y&&t.jsx(yo,{feature:"Sorting",onError:le=>{const ge=Zt("ui","sorting",le);ht(ge)},children:t.jsx(Eu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:E,onClose:()=>w(!1)})}),L&&u&&(()=>{var Ae;const le=(r.views??[]).filter(yt=>!yt.isDeleted).length,ge=((Ae=$t.views)==null?void 0:Ae.maxViews)??10;return t.jsx(Pi,{currentSnapshot:u,onSave:Q,onClose:()=>a(!1),atViewLimit:le>=ge,maxViews:ge})})(),_&&h&&t.jsx(Pi,{currentSnapshot:h.snapshot,onSave:ce,onClose:()=>{F(!1)},isEditMode:!0,initialName:h.name,initialDescription:h.description,initialIsDefault:h.isDefault}),X&&V&&t.jsx(Bu,{viewName:V.name,onConfirm:ie,onCancel:()=>{re(!1)}}),q&&d&&t.jsx(Ou,{schema:r.schema,columnVisibility:r.columnVisibility||d.snapshot.columnVisibility,columnOrder:r.columnOrder||d.snapshot.columnOrder,columnWidths:r.columnWidths||d.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:et,onUpdateColumnOrder:tt,onUpdateColumnWidth:rr,onResetLayout:Ft,onSelectView:le=>{W(le)},onSaveToCurrentView:le=>{pe(le),Me(!1)},onSaveToAllViews:le=>{he(le),Me(!1)},onClose:()=>Me(!1)}),Vt&&t.jsx(yo,{feature:"Grouping",onError:le=>{const ge=Zt("ui","grouping",le);ht(ge)},children:t.jsx($u,{schema:r.schema,grouping:r.grouping||null,onApply:pt,onClose:()=>rt(!1)})}),ft&&t.jsx(Ru,{auditHistory:r.auditHistory||[],onClose:()=>Gt(!1)}),Tt&&t.jsx(Wu,{onSave:ze,onClose:()=>Tr(!1)}),Yt&&t.jsx(Nu,{presets:r.presets||[],reportId:r.id,onOpenPreset:Ot,onDeletePreset:we,onClose:()=>ur(!1)}),qt&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(Pu,{presetName:qt.name,onClear:K})}),me&&t.jsx(yo,{feature:"Export",onError:le=>{const ge=Zt("ui","export",le);ht(ge)},children:t.jsx(Ju,{totalRows:(s==null?void 0:s.totalRows)||((_t=r.uploadedData)==null?void 0:_t.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((fr=l==null?void 0:l.columnEngine)==null?void 0:fr.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:P,onClose:()=>{kr(!1)}})}),r&&t.jsx(xp,{open:zr,onClose:()=>gt(!1),reportId:r.id,reportName:r.name,onRunNow:le=>{const ge=le.scope==="all"?r.uploadedData||[]:i||[],Ae=wo(ge,r.schema||[],Oe(r.filters),r.sortStack||[],d,r.columnVisibility,r.columnOrder);le.format==="csv"&&ko(Ae,le.name),le.format==="excel"&&To(Ae,le.name),le.format==="json"&&Io(Ae,le.name),mr(`"${le.name}" exported successfully`,"success")}}),t.jsx(rp,{open:Fr,onClose:()=>st(!1),config:$t,onApply:Jt})]})}const hp={error:"err",warning:"warn",info:"info",success:"suc"};function _s({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var C,E;const l=o.useTheme(),d=l.tokens,c=(d==null?void 0:d.notifPosition)??"top-right",u=(d==null?void 0:d.notifStyle)??"toast",m=(d==null?void 0:d.notifAccent)??"severity",f=(d==null?void 0:d.notifAutoDismiss)??!0,x=(d==null?void 0:d.toastW)??252,v=c.startsWith("top")?"top":"bottom",b=c.endsWith("center")?"center":c.endsWith("left")?"left":"right",z=hp[n],S=((C=d==null?void 0:d.status)==null?void 0:C[`${z}Soft`])??l.palette[n].light,y=((E=d==null?void 0:d.status)==null?void 0:E[`${z}Txt`])??l.palette[n].dark,w=m==="primary"?l.palette.primary.main:m==="mono"?l.palette.text.secondary:y;return t.jsx(o.Snackbar,{open:e,autoHideDuration:f?s??2e3:void 0,onClose:(g,k)=>{k!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:v,horizontal:b},children:t.jsx(o.Alert,{severity:n,icon:!1,onClose:f?void 0:i,sx:{width:x,alignItems:"flex-start",bgcolor:S,color:y,boxShadow:u==="inline"?"none":(d==null?void 0:d.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(d==null?void 0:d.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${w}`:void 0,borderRadius:`${l.shape.borderRadius}px`},children:r})})}function Ms({hasExternalData:e=!1}){const r=$o(),{reports:n,activeReportId:i,activeReport:s,uploadState:l,hasSchemaConflicts:d,isModalOpen:c,setIsModalOpen:u,setActiveReportId:m,createReport:f,handleFileUpload:x,handleUploadError:v,handleRetry:b,handleConfirm:z,snack:S,handleSnackClose:y,snackDurationMs:w}=r,C=e&&l==="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:m}),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(Cs,{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(As,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:l==="preview"&&s.schema&&s.uploadedData?t.jsx(Ld,{schema:s.schema,onConfirm:z,hasConflicts:d}):s.uploadError?t.jsx(Fd,{error:s.uploadError,onRetry:b}):t.jsx(Nd,{onFileUpload:x,onError:v,isUploading:l==="uploading"})})}):null}),!e&&t.jsx(Pd,{isOpen:c,onClose:()=>u(!1),onCreate:f}),t.jsx(_s,{open:S.open,message:S.message,severity:S.severity,onClose:y,autoHideDurationMs:w})]})}function gp({data:e,dataSource:r,reportName:n,autoLoad:i=!0,config:s}={}){return t.jsx(Mn,{mode:"builder",data:e,dataSource:r,reportName:n,autoLoad:i,config:s,children:t.jsx(Ms,{hasExternalData:!!(e||r)})})}function Rs(){const e=$o(),{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(As,{reportEngine:e}):t.jsx(Cs,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(_s,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function yp({data:e,autoLoad:r=!0,config:n}){return t.jsx(Mn,{data:e,mode:"viewer",autoLoad:r,config:n,children:t.jsx(Rs,{})})}exports.URMBuilder=gp;exports.URMBuilderRaw=Ms;exports.URMProvider=Mn;exports.URMViewer=yp;exports.URMViewerRaw=Rs;exports.useURMContext=$o;
95
+ The file has been downloaded to your device.`);window.open(`mailto:${v.email}?subject=${x}&body=${R}`,"_blank")}(A=(a=f.current).onFired)==null||A.call(a,v)}catch(F){Ot.error("urm:scheduler",`Export failed for schedule: ${v.name}`,F)}},[]);p.useEffect(()=>{if(!e)return;const v=()=>{const{reportId:C}=f.current;if(!C)return;const m=Vs(C),j=new Date;let y=!1;const $=m.map(S=>{if(!S.isActive)return S;if(new Date(S.nextRunAt)<=j){b(S);const N=_o(S.frequency,S.time,S.dayOfWeek,S.dayOfMonth,j);return y=!0,{...S,lastRunAt:j.toISOString(),nextRunAt:N,runCount:S.runCount+1}}return S});y&&Hs(C,$)};v();const T=setInterval(v,hp);return()=>clearInterval(T)},[e,b])}function Gs({reportEngine:e}){var Je,Ge,xr,Qt,mr;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:l,activeView:d,isDirty:c,currentTableState:u,showFilterPanel:h,setShowFilterPanel:g,filterFocusColumn:f,handleReplaceFilters:b,handleOpenFilterForColumn:v,handleCloseFilterPanel:T,handleClearFiltersForColumn:C,showSortPanel:m,setShowSortPanel:j,handleSort:y,handleUpdateSortStack:$,handleSortAscending:S,handleSortDescending:I,showCreateViewModal:N,setShowCreateViewModal:a,showEditViewModal:A,setShowEditViewModal:F,showDeleteConfirmation:J,setShowDeleteConfirmation:ee,editingView:x,deletingView:R,handleSelectView:P,handleCreateView:te,handleUpdateCurrentView:ae,handleSaveAsNewView:Q,handleRevertChanges:re,handleToggleDefault:he,handleToggleFavorite:L,handleSoftDelete:K,handleRestoreView:ne,handlePermanentDelete:le,handleEditView:U,handleCloneView:se,handleCopyViewLink:ie,handleSaveEditView:D,handleConfirmDelete:Z,handlePromoteToGlobal:de,showManageColumns:oe,setShowManageColumns:ye,handleUpdateColumnVisibility:G,handleUpdateColumnOrder:Me,handleUpdateColumnWidth:ht,handleResetColumnLayout:ot,showGroupPanel:wr,setShowGroupPanel:kr,handleGroup:gt,handleToggleGroupCollapse:Tr,handleExpandAllGroups:nt,handleCollapseAllGroups:Ut,searchQuery:jt,debouncedSearchQuery:it,searchHistory:st,handleSearchChange:_t,handleAddToSearchHistory:At,handleToggleSearchFavourite:Jr,handleDeleteSearchHistory:ir,selectedRowIds:sr,handleToggleRowSelection:Ye,handleToggleAllRows:Kr,handleRangeSelection:Br,handleClearSelection:Mt,handleUpdateSelectionAfterDelete:Ve,currentPage:wt,pageSize:Xr,paginationEngine:qe,handlePageChange:ar,handlePageSizeChange:Re,isExporting:Gt,showExportModal:Rt,setShowExportModal:Ir,showDirtyExportWarning:H,handleExport:lr,handleExportWithConfig:zr,handleExportSelected:yt,handleExportAnyway:W,handleSaveAndExport:at,handleCancelExport:ge,showAuditHistory:Pe,setShowAuditHistory:cr,showCreatePreset:dr,setShowCreatePreset:Er,showManagePresets:Wt,setShowManagePresets:Dr,activePreset:Yt,handleCreatePreset:$r,handleClearActivePreset:Pt,handleOpenPresetById:Be,handleDeletePresetById:X,isViewerRole:lt,userRole:Ie,featureLimitWarning:qt,setFeatureLimitWarning:ur,reportError:Jt,setReportError:Qr,handleError:kt,updateReport:Tt,showSnack:Kt,config:Fe}=e,[pr,fe]=p.useState(!1);gp({reportId:r==null?void 0:r.id,reportName:(r==null?void 0:r.name)||"Report",uploadedData:(r==null?void 0:r.uploadedData)||[],processedData:i||[],schema:(r==null?void 0:r.schema)||[],activeView:d,columnVisibility:(r==null?void 0:r.columnVisibility)||((Je=d==null?void 0:d.snapshot)==null?void 0:Je.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((Ge=d==null?void 0:d.snapshot)==null?void 0:Ge.columnOrder)||[],filters:Oe(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:xe=>{Kt(`Scheduled export "${xe.name}" completed`,"success")}});const He=p.useCallback((xe,Ce)=>{if(!(r!=null&&r.uploadedData))return;const $e=[...r.uploadedData];$e[xe]=Ce,Tt(r.id,{uploadedData:$e})},[r,Tt]),Or=p.useCallback(xe=>{if(!(r!=null&&r.uploadedData))return;const Ce=r.uploadedData.indexOf(xe);if(Ce===-1)return;const $e=r.uploadedData.filter((It,Zt)=>Zt!==Ce);Tt(r.id,{uploadedData:$e}),Ve(xe)},[r,Tt,Ve]),ct=p.useCallback((xe,Ce)=>{if(!(r!=null&&r.uploadedData))return;const $e=r.uploadedData.indexOf(Ce),It=$e!==-1?$e+1:xe+1,Zt=[...r.uploadedData];Zt.splice(It,0,{...Ce}),Tt(r.id,{uploadedData:Zt})},[r,Tt]),bt=Sr(),{handleDevConfigChange:Bt}=Ho(),[_r,Xt]=p.useState(!1);return p.useEffect(()=>{const xe=Ce=>{Ce.ctrlKey&&Ce.shiftKey&&Ce.key==="D"&&(Ce.preventDefault(),Xt(!0))};return document.addEventListener("keydown",xe),()=>document.removeEventListener("keydown",xe)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[qt&&t.jsx(Qu,{warning:qt,onDismiss:()=>ur(null)}),Jt&&t.jsx(Zu,{error:Jt,onDismiss:()=>Qr(null)}),H&&t.jsx(Au,{onExportAnyway:W,onSaveAndExport:at,onCancel:ge}),t.jsx(wu,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:c,isExporting:Gt,columnVisibility:r.columnVisibility||(d==null?void 0:d.snapshot.columnVisibility),columnOrder:r.columnOrder||(d==null?void 0:d.snapshot.columnOrder),columnWidths:r.columnWidths||(d==null?void 0:d.snapshot.columnWidths),grouping:r.grouping,onSort:y,onSortAscending:S,onSortDescending:I,onOpenFilters:()=>g(!0),onOpenSort:()=>j(!0),onOpenFilterForColumn:v,onSelectView:P,onCreateView:()=>a(!0),onUpdateCurrentView:ae,onSaveAsNewView:Q,onDiscardChanges:re,onToggleDefault:he,onToggleFavorite:L,onRestoreView:ne,onPermanentDelete:le,onEditView:U,onCloneView:se,onCopyLink:ie,onDeleteView:K,onPromoteToGlobal:de,isAdmin:((xr=bt.views)==null?void 0:xr.isAdmin)??!1,onExport:lr,onOpenColumns:()=>ye(!0),onUpdateColumnWidth:ht,onUpdateColumnOrder:Me,onUpdateColumnVisibility:G,onClearFiltersForColumn:C,onResetLayout:ot,onOpenGroup:()=>kr(!0),onGroupByColumn:xe=>{gt({enabled:!0,levels:[{column:xe}],collapsedGroups:[]})},onToggleGroupCollapse:Tr,onExpandAllGroups:nt,onCollapseAllGroups:Ut,onOpenAuditHistory:()=>cr(!0),onOpenScheduledReports:()=>fe(!0),searchQuery:jt,highlightQuery:it,searchHistory:st,onAddToSearchHistory:At,onToggleSearchFavourite:Jr,onDeleteSearchHistory:ir,selectedRowIds:sr,onSearchChange:_t,onToggleRowSelection:Ye,onToggleAllRows:Kr,onRangeSelection:Br,onClearSelection:Mt,onExportSelected:yt,currentPage:(qe==null?void 0:qe.currentPage)||wt,pageSize:(qe==null?void 0:qe.pageSize)||Xr,onPageChange:ar,onPageSizeChange:Re,totalRowsBeforePagination:(s==null?void 0:s.searchedRows)||i.length,isReadOnly:lt,userRole:Ie,reportName:r.name,onEditRow:He,onDeleteRow:Or,onDuplicateRow:ct,rowActions:Fe==null?void 0:Fe.rowActions,hideDefaultRowActions:Fe==null?void 0:Fe.hideDefaultRowActions,onRowClick:Fe==null?void 0:Fe.onRowClick,onRowRightClick:Fe==null?void 0:Fe.onRowRightClick,showDevPanel:bt.display.showDevPanel,onOpenDevConfig:()=>Xt(!0)})]}),h&&t.jsx(zo,{feature:"Filters",onError:xe=>{const Ce=rr("ui","filters",xe);kt(Ce)},children:t.jsx(Iu,{schema:r.schema,filters:r.filters,onReplaceFilters:b,onClose:T,focusColumn:f})}),m&&t.jsx(zo,{feature:"Sorting",onError:xe=>{const Ce=rr("ui","sorting",xe);kt(Ce)},children:t.jsx(Eu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:$,onClose:()=>j(!1)})}),N&&u&&(()=>{var $e;const xe=(r.views??[]).filter(It=>!It.isDeleted).length,Ce=(($e=bt.views)==null?void 0:$e.maxViews)??10;return t.jsx(Ki,{currentSnapshot:u,onSave:te,onClose:()=>a(!1),atViewLimit:xe>=Ce,maxViews:Ce})})(),A&&x&&t.jsx(Ki,{currentSnapshot:x.snapshot,onSave:D,onClose:()=>{F(!1)},isEditMode:!0,initialName:x.name,initialDescription:x.description,initialIsDefault:x.isDefault}),J&&R&&t.jsx(Du,{viewName:R.name,onConfirm:Z,onCancel:()=>{ee(!1)}}),oe&&d&&t.jsx(Ou,{schema:r.schema,columnVisibility:r.columnVisibility||d.snapshot.columnVisibility,columnOrder:r.columnOrder||d.snapshot.columnOrder,columnWidths:r.columnWidths||d.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:G,onUpdateColumnOrder:Me,onUpdateColumnWidth:ht,onResetLayout:ot,onClose:()=>ye(!1)}),wr&&t.jsx(zo,{feature:"Grouping",onError:xe=>{const Ce=rr("ui","grouping",xe);kt(Ce)},children:t.jsx(_u,{schema:r.schema,grouping:r.grouping||null,onApply:gt,onClose:()=>kr(!1)})}),Pe&&t.jsx(Wu,{auditHistory:r.auditHistory||[],onClose:()=>cr(!1)}),dr&&t.jsx(Pu,{onSave:$r,onClose:()=>Er(!1)}),Wt&&t.jsx(Lu,{presets:r.presets||[],reportId:r.id,onOpenPreset:Be,onDeletePreset:X,onClose:()=>Dr(!1)}),Yt&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(Nu,{presetName:Yt.name,onClear:Pt})}),Rt&&t.jsx(zo,{feature:"Export",onError:xe=>{const Ce=rr("ui","export",xe);kt(Ce)},children:t.jsx(Xu,{totalRows:(s==null?void 0:s.totalRows)||((Qt=r.uploadedData)==null?void 0:Qt.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((mr=l==null?void 0:l.columnEngine)==null?void 0:mr.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:zr,onClose:()=>{Ir(!1)}})}),r&&t.jsx(fp,{open:pr,onClose:()=>fe(!1),reportId:r.id,reportName:r.name,onRunNow:xe=>{const Ce=xe.scope==="all"?r.uploadedData||[]:i||[],$e=Ao(Ce,r.schema||[],Oe(r.filters),r.sortStack||[],d,r.columnVisibility,r.columnOrder);xe.format==="csv"&&Mo($e,xe.name),xe.format==="excel"&&Ro($e,xe.name),xe.format==="json"&&Wo($e,xe.name),Kt(`"${xe.name}" exported successfully`,"success")}}),t.jsx(np,{open:_r,onClose:()=>Xt(!1),config:bt,onApply:Bt})]})}const yp={error:"err",warning:"warn",info:"info",success:"suc"};function Ys({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var y,$;const l=o.useTheme(),d=l.tokens,c=(d==null?void 0:d.notifPosition)??"top-right",u=(d==null?void 0:d.notifStyle)??"toast",h=(d==null?void 0:d.notifAccent)??"severity",g=(d==null?void 0:d.notifAutoDismiss)??!0,f=(d==null?void 0:d.toastW)??252,b=c.startsWith("top")?"top":"bottom",v=c.endsWith("center")?"center":c.endsWith("left")?"left":"right",T=yp[n],C=((y=d==null?void 0:d.status)==null?void 0:y[`${T}Soft`])??l.palette[n].light,m=(($=d==null?void 0:d.status)==null?void 0:$[`${T}Txt`])??l.palette[n].dark,j=h==="primary"?l.palette.primary.main:h==="mono"?l.palette.text.secondary:m;return t.jsx(o.Snackbar,{open:e,autoHideDuration:g?s??2e3:void 0,onClose:(S,I)=>{I!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:b,horizontal:v},children:t.jsx(o.Alert,{severity:n,icon:!1,onClose:g?void 0:i,sx:{width:f,alignItems:"flex-start",bgcolor:C,color:m,boxShadow:u==="inline"?"none":(d==null?void 0:d.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(d==null?void 0:d.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${j}`:void 0,borderRadius:`${l.shape.borderRadius}px`},children:r})})}function qs({hasExternalData:e=!1}){const r=Ho(),{reports:n,activeReportId:i,activeReport:s,uploadState:l,hasSchemaConflicts:d,isModalOpen:c,setIsModalOpen:u,setActiveReportId:h,createReport:g,handleFileUpload:f,handleUploadError:b,handleRetry:v,handleConfirm:T,snack:C,handleSnackClose:m,snackDurationMs:j}=r,y=e&&l==="uploading"&&n.length===0;return t.jsxs(o.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(El,{onCreateReport:()=>u(!0),reports:n,activeReportId:i,onReportClick:h}),t.jsx(o.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:y?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(_s,{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(Gs,{reportEngine:r}):t.jsx(o.Box,{sx:{p:3},children:l==="preview"&&s.schema&&s.uploadedData?t.jsx(Vd,{schema:s.schema,onConfirm:T,hasConflicts:d}):s.uploadError?t.jsx(Hd,{error:s.uploadError,onRetry:v}):t.jsx(Fd,{onFileUpload:f,onError:b,isUploading:l==="uploading"})})}):null}),!e&&t.jsx(Ld,{isOpen:c,onClose:()=>u(!1),onCreate:g}),t.jsx(Ys,{open:C.open,message:C.message,severity:C.severity,onClose:m,autoHideDurationMs:j})]})}function bp({data:e,dataSource:r,reportName:n,autoLoad:i=!0,config:s}={}){return t.jsx(Un,{mode:"builder",data:e,dataSource:r,reportName:n,autoLoad:i,config:s,children:t.jsx(qs,{hasExternalData:!!(e||r)})})}function Js(){const e=Ho(),{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(Gs,{reportEngine:e}):t.jsx(_s,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(Ys,{open:r.open,message:r.message,severity:r.severity,onClose:n,autoHideDurationMs:i})]})}function vp({data:e,autoLoad:r=!0,config:n}){return t.jsx(Un,{data:e,mode:"viewer",autoLoad:r,config:n,children:t.jsx(Js,{})})}exports.URMBuilder=bp;exports.URMBuilderRaw=qs;exports.URMProvider=Un;exports.URMViewer=vp;exports.URMViewerRaw=Js;exports.useURMContext=Ho;