dts-universal-report-module 1.2.0 → 1.2.1

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 +5260 -5130
  2. package/dist/index.js +26 -26
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,25 +1,25 @@
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
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"),Ht=require("react-dnd"),Wn=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 Vo=rs(p),jo=rs(ta),et={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 et;const r=JSON.parse(e),n={sort:{...et.sort,...r.sort},filter:{...et.filter,...r.filter},columns:{...et.columns,...r.columns},grouping:{...et.grouping,...r.grouping},export:{...et.export,...r.export},views:{...et.views,...r.views},dates:{...et.dates,...r.dates},display:{...et.display,...r.display}};return n.sort.maxLevels=Math.min(5,Math.max(1,n.sort.maxLevels)),n}catch{return et}}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(et);function Cr(){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(l=>l[e]).filter(l=>l!=null&&l!=="");if(n.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const l of n){const d=xa(l);i[d]++}const s=n.length,c=.7;for(const l of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[l]/s>=c)return l;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 Me(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),c=Math.floor(s/60),l=Math.floor(c/60),d=Math.floor(l/24),u=Math.floor(d/7),h=Math.floor(d/30),g=Math.floor(d/365);let f;return s<60?f="just now":c<60?f=`${c} minute${c!==1?"s":""}`:l<24?f=`${l} hour${l!==1?"s":""}`:d<7?f=`${d} day${d!==1?"s":""}`:u<5?f=`${u} week${u!==1?"s":""}`: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(),c=e.getHours(),l=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${n}-${Me(i+1)}-${Me(s)}`;case"DD/MM/YYYY":return`${Me(s)}/${Me(i+1)}/${n}`;case"MM/DD/YYYY":return`${Me(i+1)}/${Me(s)}/${n}`;case"MMM DD, YYYY":return`${si[i]} ${Me(s)}, ${n}`;case"DD MMM YYYY":return`${Me(s)} ${si[i]} ${n}`;case"MMMM D, YYYY":return`${ha[i]} ${s}, ${n}`;case"YYYY-MM-DD HH:mm":return`${n}-${Me(i+1)}-${Me(s)} ${Me(c)}:${Me(l)}`;case"DD/MM/YYYY HH:mm":return`${Me(s)}/${Me(i+1)}/${n} ${Me(c)}:${Me(l)}`;case"MM/DD/YYYY HH:mm":return`${Me(i+1)}/${Me(s)}/${n} ${Me(c)}:${Me(l)}`;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 c=r?`${r}.${s}`:s,l=e[s];l!==null&&typeof l=="object"&&!Array.isArray(l)&&n<2?Object.assign(i,is(l,c,n+1)):i[c]=l}return i}function Do(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:is(r))}function ro(e){if(!Array.isArray(e)||e.length===0)return[];const r=Do(e),n=new Set;r.forEach(l=>{typeof l=="object"&&l!==null&&Object.keys(l).forEach(d=>n.add(d))});const i=[];n.forEach(l=>{const d=new Set;let u=0;r.forEach(v=>{typeof v=="object"&&v!==null&&l in v&&(u++,d.add(va(v[l])))});const h=u===r.length,g=d.size>1&&!d.has("null");let f="mixed";if(d.size===1)f=Array.from(d)[0];else if(d.size===2&&d.has("null")){const v=Array.from(d).filter(S=>S!=="null");v.length===1&&(f=v[0])}i.push({name:l,type:f,required:h,hasConflict:g})});const c=r.slice(0,50);for(const l of i){if(l.type!=="string"&&l.type!=="number")continue;const d=ma(l.name,c);d!=="unknown"&&(l.type="date",l.dateFormat=d)}return i}function Sa(e){return e.some(r=>r.hasConflict)}function ot(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),c=ai(n);if(s&&c)return 0;if(s)return 1;if(c)return-1;let l=0;switch(e){case"number":const d=Number(r),u=Number(n);l=d-u;break;case"boolean":l=(r?1:0)-(n?1:0);break;case"string":l=String(r).localeCompare(String(n));break;case"array":case"object":l=JSON.stringify(r).localeCompare(JSON.stringify(n));break;case"mixed":case"null":default:l=String(r).localeCompare(String(n));break}return i==="asc"?l:-l}}function ja(e,r,n){if(!n||n.length===0)return e;const i=[...n].sort((s,c)=>s.priority-c.priority);return[...e].sort((s,c)=>{for(const l of i){const d=r.find(g=>g.name===l.column);if(!d)continue;const h=Ca(d.type)(s[l.column],c[l.column],l.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(c=>c[i.name]).filter(c=>typeof c=="number");s.length>0&&(n[i.name]=s.reduce((c,l)=>c+l,0))}}),n}function Ia(e,r,n){if(!n.enabled||n.levels.length===0)return e;const i=Pn(e,n.levels,r);return ss(i,n.collapsedGroups||[])}function Pn(e,r,n,i="",s=0){if(s>=r.length)return e;const c=r[s].column,l=new Map;e.forEach(h=>{const g=h[c],f=g==null?"(empty)":String(g);l.has(f)||l.set(f,[]),l.get(f).push(h)});const d=[];return Array.from(l.keys()).sort().forEach(h=>{const g=l.get(h),f=`${c}:${h}`,v=i?`${i}|${f}`:f,S=Ba(g,n),B=s<r.length-1?Pn(g,r,n,v,s+1):g,C={key:v,level:s,column:c,value:h,rowCount:g.length,aggregates:S,children:B};d.push(C)}),d}function ss(e,r,n=[],i=0){for(const s of e)if("key"in s&&"level"in s&&"children"in s){const c=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:c}),!c&&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=Pn(e,n.levels,r),s=[],c=l=>{for(const d of l)"key"in d&&"level"in d&&"children"in d&&(s.push(d.key),c(d.children))};return c(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 wt(){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:wt()}function ht(e){return e?We(e)?e.children.reduce((r,n)=>r+ht(n),0):1:0}function $o(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=$o(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 Nn(e,r,n){return{...e,children:e.children.map(i=>i.id===r&&!We(i)?{...i,...n}:We(i)?Nn(i,r,n):i)}}function Ln(e,r,n){return e.id===r?{...e,operator:n}:{...e,children:e.children.map(i=>We(i)?Ln(i,r,n):i)}}function Fn(e,r){const n=e.children.filter(i=>i.id!==r).map(i=>We(i)?Fn(i,r):i).filter(i=>!We(i)||i.children.length>0);return{...e,children:n}}function Dn(e,r){return e?We(e)?e.children.some(n=>Dn(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 po(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(po)}}function so(e,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const n=r.levels.map(s=>s.column),i=e.filter(s=>!n.includes(s));return[...n,...i]}function Vn(e,r,n){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(c=>c.column),s=e.filter(c=>!i.includes(c));if(n){const c=[],l=new Set(i),d=new Set(s);let u=0;for(const h of n)l.has(h)?c.push(h):d.has(h)&&u<s.length?(c.push(s[u]),u++):d.has(h)||c.push(h);for(let h=u;h<s.length;h++)c.includes(s[h])||c.push(s[h]);return c}return[...e]}function vn(e){const r={},n=[],i={};return e.forEach(s=>{r[s.name]=!0,n.push(s.name),i[s.name]=170}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:wt(),sortStack:[],columnVisibility:r,columnOrder:n,columnWidths:i,grouping:null}}}function Da(e,r,n,i,s,c,l,d){const u={},h=[],g={};n.forEach(S=>{u[S.name]=!0,h.push(S.name),g[S.name]=170});const v=Vn(s||h,l||null,d||h);return{filters:Oe(e),sortStack:r||[],columnVisibility:i||u,columnOrder:v,columnWidths:c||g,grouping:l||null}}function $a(e,r){const n=S=>{if(S==null)return S;if(Array.isArray(S))return S.map(B=>n(B));if(typeof S=="object"){const B={};return Object.keys(S).sort().forEach(C=>{B[C]=n(S[C])}),B}return S},i=S=>JSON.stringify(n(S));if(i(po(e.filters))!==i(po(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},c=r.columnVisibility??{};if(i(s)!==i(c))return!0;const l=Vn(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),d=[...l].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(d!==u)return!1;const h=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==h){if(l.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const S=[...l].sort().join(",");if(l.join(",")!==S)return!0}const f=e.columnWidths??{},v=r.columnWidths??{};return i(f)!==i(v)||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(po(e.filters)),s=JSON.stringify(po(r.filters));if(i!==s){const y=ht(e.filters),O=ht(r.filters);y>O?n.push({category:"filters",label:"Filters Added",description:`${y-O} new filter${y-O>1?"s":""} added`}):y<O?n.push({category:"filters",label:"Filters Removed",description:`${O-y} filter${O-y>1?"s":""} removed`}):n.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const c=JSON.stringify(e.sortStack),l=JSON.stringify(r.sortStack);if(c!==l){const y=e.sortStack.length,O=r.sortStack.length;y>O?n.push({category:"sorting",label:"Sorting Added",description:`${y-O} new sort rule${y-O>1?"s":""} added`}):y<O?n.push({category:"sorting",label:"Sorting Removed",description:`${O-y} sort rule${O-y>1?"s":""} removed`}):n.push({category:"sorting",label:"Sorting Modified",description:"Sort rules or order have been changed"})}const d=JSON.stringify(e.columnVisibility),u=JSON.stringify(r.columnVisibility);if(d!==u){const y=Object.values(e.columnVisibility).filter(b=>b).length,O=Object.values(r.columnVisibility).filter(b=>b).length;y>O?n.push({category:"visibility",label:"Columns Shown",description:`${y-O} column${y-O>1?"s":""} made visible`}):y<O?n.push({category:"visibility",label:"Columns Hidden",description:`${O-y} column${O-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),v=JSON.stringify(r.columnWidths);if(f!==v){const y=Object.keys(e.columnWidths).filter(O=>e.columnWidths[O]!==r.columnWidths[O]).length;n.push({category:"widths",label:"Column Widths Adjusted",description:`${y} column width${y>1?"s":""} modified`})}const S=JSON.stringify(e.grouping),B=JSON.stringify(r.grouping);if(S!==B){const y=(C=e.grouping)==null?void 0:C.enabled,O=(m=r.grouping)==null?void 0:m.enabled;if(y&&!O){const b=((j=e.grouping)==null?void 0:j.levels.length)||0;n.push({category:"grouping",label:"Grouping Applied",description:`${b} grouping level${b>1?"s":""} added`})}else!y&&O?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 Ma(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 Aa(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 Ho(e,r,n=0){const i=[];for(const s of e){const c=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:c}),!c&&s.children&&s.children.length>0){const l=s.children[0];if(Ra(l)){const d=s.children,u=Ho(d,r,n+1);i.push(...u)}else{const d=s.children;for(const u of d)i.push({type:"row",parentGroupKey:s.key,level:n+1,data:u})}}}return i}function 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 Hn(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function Un(e,r){const n=new Date,i=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),c=String(n.getDate()).padStart(2,"0"),l=`${i}-${s}-${c}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${l}.${r}`}function Ao(e,r,n,i,s,c,l){let d,u;c?(d={...c},u=l||r.map(g=>g.name)):s?(d={...s.snapshot.columnVisibility},u=l||[...s.snapshot.columnOrder]):(d={},u=[],r.forEach(g=>{d[g.name]=!0,u.push(g.name)}));const h=Object.entries(d).filter(([g,f])=>!f).map(([g,f])=>g);return{data:e,schema:r,appliedFilters:n,appliedSortStack:i,columnVisibility:d,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 Ro(e,r="export",n){const{data:i,columnOrder:s,grouping:c}=e,l=s.filter(f=>e.columnVisibility[f]);let d;if(c&&c.enabled){const f=c.collapsedGroups??[],v=Ho(i,f);d=Hn(v)}else d=i;const u=l.join(","),h=d.map(f=>l.map(v=>{const S=f[v];if(S==null)return"";const B=String(S);return B.includes(",")||B.includes('"')||B.includes(`
2
+ `)?`"${B.replace(/"/g,'""')}"`:B}).join(",")),g=[u,...h].join(`
3
+ `);ps(g,Un(r,"csv"),"text/csv;charset=utf-8;")}function Wo(e,r="export",n){const{data:i,columnOrder:s,grouping:c}=e,l=s.filter(f=>e.columnVisibility[f]);let d;if(c&&c.enabled){const f=c.collapsedGroups??[],v=Ho(i,f);d=Hn(v)}else d=i;const u=[l,...d.map(f=>l.map(v=>f[v]??""))],h=jo.utils.aoa_to_sheet(u),g=jo.utils.book_new();jo.utils.book_append_sheet(g,h,"Data"),jo.writeFile(g,Un(r,"xlsx"))}function Po(e,r="export",n){const{data:i,appliedFilters:s,appliedSortStack:c,viewMeta:l,hiddenColumns:d,columnOrder:u,grouping:h}=e;let g;if(h&&h.enabled){const S=h.collapsedGroups??[],B=Ho(i,S);g=Hn(B)}else g=i;const f={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(l==null?void 0:l.name)||"Default View",filters:ds(s).map(S=>({field:S.column,operator:S.operator,value:S.value})),sortStack:c.map(S=>({field:S.column,direction:S.direction,priority:S.priority})),grouping:h||{},hiddenColumns:d,columnOrder:u,exportConfig:n||{scope:"visible"}},data:g},v=JSON.stringify(f,null,2);ps(v,Un(r,"json"),"application/json;charset=utf-8;")}function ps(e,r,n){const i=new Blob([e],{type:n}),s=URL.createObjectURL(i),c=document.createElement("a");c.href=s,c.download=r,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(s)}const di=10;function Wa(e,r){const n=r.trim();if(!n)return e;const i=e.findIndex(c=>c.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((l,d)=>l.isFavourite&&!d.isFavourite?-1:!l.isFavourite&&d.isFavourite?1:d.lastUsed-l.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 xt(e,r){return Fa[r].includes(e)}function mt(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 $n(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 $n(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 Sn(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,c,l;const{action:r,previousState:n,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${Sn(i)}`};case"filter_removed":return{summary:`Filter removed: ${Sn(n)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const d=n,u=i;return d!=null&&d.column&&(u!=null&&u.column)&&d.column!==u.column?{summary:`Filter changed on "${$t(u.column)}"`,detail:`Previously filtered "${$t(d.column)}"`}:{summary:`Filter updated: ${Sn(u)}`}}case"filter_cleared":{const d=n&&typeof n=="object"&&"count"in n?n.count:0;return{summary:d>0?`All filters cleared (${d} filter${d!==1?"s":""} removed)`:"All filters cleared"}}case"sort_level_added":{const d=i!=null&&i.column?$t(i.column):"",u=(i==null?void 0:i.direction)==="asc"?"ascending":"descending";return{summary:d?`Sort added: "${d}" ${u}`:"Sort level added"}}case"sort_level_removed":{const d=n!=null&&n.column?$t(n.column):"";return{summary:d?`Sort removed: "${d}"`:"Sort level removed"}}case"sort_reordered":return{summary:"Sort order changed"};case"sort_cleared":return{summary:"All sorting cleared"};case"group_level_added":return{summary:`Grouping applied: ${pi(i)}`};case"group_level_removed":{const d=n,u=(c=(s=d==null?void 0:d.levels)==null?void 0:s[0])!=null&&c.column?$t(d.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 d=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:d?`Column hidden: "${$t(d)}"`:"Column hidden"}}case"column_shown":{const d=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:d?`Column shown: "${$t(d)}"`:"Column made visible"}}case"column_reordered":{const d=Array.isArray(n)?n:[],u=Array.isArray(i)?i:[];return d.length>0&&u.length>0?{summary:"Column order changed",detail:`${u.length} column${u.length!==1?"s":""} reordered`}:{summary:"Columns reordered"}}case"column_resized":{const d=(i==null?void 0:i.column)??"",u=(i==null?void 0:i.width)??"";return{summary:d?`Column resized: "${$t(d)}"`:"Column resized",detail:u?`New width: ${u}px`:void 0}}case"view_created":{const d=(i==null?void 0:i.name)??(i==null?void 0:i.viewName)??"";return{summary:d?`View created: "${d}"`:"New view created"}}case"view_updated":{const d=(i==null?void 0:i.name)??(n==null?void 0:n.name)??"";return{summary:d?`View updated: "${d}"`:"View updated"}}case"view_deleted":{const d=(n==null?void 0:n.name)??(n==null?void 0:n.viewName)??"";return{summary:d?`View deleted: "${d}"`:"View deleted"}}case"view_set_default":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Default view set to "${d}"`:"Default view changed"}}case"view_switched":{const d=(n==null?void 0:n.name)??"",u=(i==null?void 0:i.name)??"";return d&&u?{summary:`Switched to view "${u}"`,detail:`From "${d}"`}:u?{summary:`Switched to view "${u}"`}:{summary:"View switched"}}case"export_csv":case"export_excel":case"export_json":{const d=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 ${d}${f}`,detail:g?`${$n(h)} · View: "${g}"`:$n(h)}}case"export_triggered":{const d=((l=i==null?void 0:i.format)==null?void 0:l.toUpperCase())??"";return{summary:d?`Export triggered: ${d}`:"Export triggered"}}case"preset_created":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Preset created: "${d}"`:"New preset created"}}case"preset_applied":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Preset applied: "${d}"`:"Preset applied"}}case"preset_deleted":{const d=(n==null?void 0:n.name)??"";return{summary:d?`Preset deleted: "${d}"`:"Preset deleted"}}case"preset_link_copied":{const d=(i==null?void 0:i.name)??"";return{summary:d?`Preset link copied: "${d}"`:"Preset link copied to clipboard"}}case"theme_changed":{const d=typeof n=="string"?n:(n==null?void 0:n.theme)??"",u=typeof i=="string"?i:(i==null?void 0:i.theme)??"";return d&&u?{summary:`Theme changed from "${d}" to "${u}"`}:u?{summary:`Theme changed to "${u}"`}:{summary:"Theme changed"}}case"error_occurred":{const d=(i==null?void 0:i.message)??(i==null?void 0:i.error)??typeof i=="string"?i:"";return{summary:"An error was recorded",detail:d?`Details: ${String(d).slice(0,120)}`:void 0}}default:return{summary:Ja(r)}}}function qa(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function xs(e,r,n,i,s,c){return{id:qa(),user:r,reportId:e,feature:n,action:i,timestamp:new Date().toISOString(),previousState:s,newState:c}}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),c=Math.floor(i/36e5),l=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:c<24?`${c} hour${c>1?"s":""} ago`:l<7?`${l} day${l>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const xi=100;function Qa(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Za(e){var c;const r=(c=e.views)==null?void 0:c.find(l=>l.id===e.activeViewId),n=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=Vn(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=so(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 or(e,r,n,i){const s=n instanceof Error?n.message:n,c={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}),c}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(c=>c.name));return e.forEach(c=>{s.has(c.column)?n.push(c):i.push(c.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(c=>c.name)),i=[],s=[];return e.levels.forEach(c=>{n.has(c.column)?i.push(c):s.push(c.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(c=>c.name)),s={...e};if(s.filters){const c=l=>{const d=l.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)?c(u):u).filter(u=>!We(u)||u.children.length>0);return{...l,children:d}};s.filters=c(Oe(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:c,invalidColumns:l}=fs(s.sortStack,r);l.length>0&&n.push(`Sort rules for columns ignored: ${l.join(", ")}`),s.sortStack=c.length>0?c:void 0}if(s.grouping){const{validGrouping:c,invalidColumns:l}=hs(s.grouping,r);l.length>0&&n.push(`Grouping for columns ignored: ${l.join(", ")}`),s.grouping=c}if(s.columnVisibility){const c={};Object.entries(s.columnVisibility).forEach(([l,d])=>{i.has(l)?c[l]=d:n.push(`Column visibility for "${l}" ignored (column not found)`)}),s.columnVisibility=Object.keys(c).length>0?c:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const c=s.columnOrder.filter(l=>{const d=i.has(l);return d||n.push(`Column "${l}" in order ignored (column not found)`),d});s.columnOrder=c.length>0?c:void 0}if(s.columnWidths){const c={};Object.entries(s.columnWidths).forEach(([l,d])=>{i.has(l)?c[l]=d:n.push(`Column width for "${l}" ignored (column not found)`)}),s.columnWidths=Object.keys(c).length>0?c:void 0}return{sanitizedConfig:s,warnings:n}}function xl(e,r){return or("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 c=new Date(e).getTime(),l=new Date(s).getTime();switch(i){case"equals":return c===l;case"gt":return c>l;case"lt":return c<l;case"gte":return c>=l;case"lte":return c<=l;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 On(e,r,n){var s;if(We(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(c=>On(e,c,n)):r.children.some(c=>On(e,c,n));const i=((s=n.find(c=>c.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=>On(i,r,n))}function No(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(),c=r.filter(l=>i.includes(l.name));return e.filter(l=>c.some(d=>{const u=l[d.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(d=>r[d]!==!1),[n,r]),s=p.useMemo(()=>Object.entries(r).filter(([d,u])=>!u).map(([d,u])=>d),[r]),c=p.useMemo(()=>n.map(d=>e.find(h=>h.name===d)||{name:d,type:"string"}),[n,e]),l=p.useMemo(()=>i.map(d=>e.find(h=>h.name===d)||{name:d,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:c,visibleColumnSchemas:l,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]),c=p.useMemo(()=>e.find(h=>h.isDefault),[e]),l=p.useMemo(()=>e.filter(h=>!h.isDefault&&!h.isDeleted),[e]),d=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:c,customViews:l,favoriteViews:d,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,c]=p.useState(i),l=e.length,d=Math.ceil(l/n),u=p.useMemo(()=>{if(!r)return e;const S=(s-1)*n,B=S+n;return e.slice(S,B)},[e,r,s,n]),h=p.useCallback(S=>{const B=Math.max(1,Math.min(S,d));c(B)},[d]),g=p.useCallback(()=>{s<d&&c(s+1)},[s,d]),f=p.useCallback(()=>{s>1&&c(s-1)},[s]),v=p.useCallback(()=>{c(1)},[]);return{paginatedData:u,currentPage:s,totalPages:d,pageSize:n,totalRows:l,goToPage:h,nextPage:g,prevPage:f,resetPage:v,hasNextPage:s<d,hasPrevPage:s>1}}function Tl(e){const{rawData:r,schema:n,filters:i,sortStack:s,grouping:c,searchQuery:l,columnVisibility:d,columnOrder:u,columnWidths:h,views:g,activeViewId:f,pagination:v}=e,S=p.useMemo(()=>({filters:i,sortStack:s,grouping:c,columnVisibility:d,columnOrder:u,columnWidths:h}),[i,s,c,d,u,h]),B=wl({views:g,activeViewId:f,currentState:S}),C=jl({schema:n,columnVisibility:d,columnOrder:u}),{filteredData:m}=yl({data:r,filters:i,schema:n}),{sortedData:j}=Sl({data:m,sortStack:s,schema:n}),{groupedData:y,isGrouped:O}=Cl({data:j,grouping:c,schema:n}),{searchedData:b}=vl({data:y,searchQuery:l,schema:n,visibleColumns:C.visibleColumns}),k=kl({data:b,enabled:(v==null?void 0:v.enabled)||!1,pageSize:(v==null?void 0:v.pageSize)||100,initialPage:(v==null?void 0:v.currentPage)||1}),R=v!=null&&v.enabled?k.paginatedData:b,a=p.useMemo(()=>({totalRows:r.length,filteredRows:m.length,sortedRows:j.length,groupedRows:O?y.length:j.length,searchedRows:b.length,visibleRows:R.length,hiddenColumns:C.hiddenCount,activeFilters:ht(i),activeSorts:s.length,isGrouped:O}),[r.length,m.length,j.length,y.length,b.length,R.length,C.hiddenCount,i,s.length,O]);return{data:R,filteredData:m,sortedData:j,groupedData:y,searchedData:b,viewEngine:B,columnEngine:C,paginationEngine:k,metrics:a,isGrouped:O,isPaginated:(v==null?void 0:v.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 jt="user-demo-001";function zl(e={}){var ei,ti,ri,oi,ni;const{mode:r="builder",autoLoad:n=!0,initialData:i,dataSource:s,reportName:c,sharedReportId:l,sharedViewId:d,config:u={}}=e,[h,g]=p.useState([]),f=Cr(),[v,S]=p.useState(""),[B,C]=p.useState(!1),[m,j]=p.useState(!1),[y,O]=p.useState({message:"",severity:"info",open:!1}),b=(T,E="info")=>{O({message:T,severity:E,open:!0})},k=()=>O(T=>({...T,open:!1})),R=u.notifDurationMs??2e3,a=h.find(T=>T.id===v),[$,W]=p.useState("idle"),[J,te]=p.useState(!1),[x,P]=p.useState(!1),[F,re]=p.useState(!1),[ce,X]=p.useState(!1),[ee,fe]=p.useState(!1),[V,K]=p.useState(void 0),[oe,ie]=p.useState(null),[H,ae]=p.useState(null),[se,D]=p.useState(!1),[Z,ue]=p.useState(!1),[ne,ye]=p.useState(null),[G,Ae]=p.useState(!1),[yt,st]=p.useState(!1),[kr,Tr]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[bt,Br]=p.useState(""),[at,Gt]=p.useState(""),[kt,lt]=p.useState(new Set),[ct,_t]=p.useState(1),[Mt,Jr]=p.useState(15),[sr,ar]=p.useState(!1),[Xe,Kr]=p.useState(!1),[Ir,At]=p.useState(!1),[Ue,Tt]=p.useState(null),[Xr,Qe]=p.useState(!1),[lr,Re]=p.useState(null),[Yt,Rt]=p.useState(null),zr=p.useRef(null),U=p.useMemo(()=>a?Va(a.permissions,jt):"owner",[a]),cr=Ha(U),Er=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]),vt=p.useCallback(()=>{a&&(zr.current=cl(a))},[a]),N=p.useCallback((T,E)=>{g(M=>M.map(_=>_.id===T?{..._,...E}:_))},[]),dt=p.useCallback(T=>{if(!a)return;Rt(T);const E=fi(a.id,jt,T,a.auditHistory||[]);N(a.id,{auditHistory:E}),b(T.message,"error"),T.recoverable&&zr.current&&setTimeout(()=>{dl(a,zr.current,N),b("Previous state restored","success")},100)},[a,N]),ge=p.useCallback((T,E,M,_)=>{if(!a)return;const Y=xs(a.id,jt,T,E,M,_),q=a.auditHistory||[],pe=ms(q,Y);setTimeout(()=>{N(a.id,{auditHistory:pe})},0)},[a,N]);p.useEffect(()=>{if(a!=null&&a.schemaLocked&&a.schema&&(!a.views||a.views.length===0)){const T=vn(a.schema);(()=>{try{const E=localStorage.getItem("urm_dev_config");return E?JSON.parse(E):null}catch{return null}})(),N(a.id,{views:[T],activeViewId:T.id,filters:T.snapshot.filters,sortStack:T.snapshot.sortStack,columnVisibility:T.snapshot.columnVisibility,columnOrder:T.snapshot.columnOrder,columnWidths:T.snapshot.columnWidths,grouping:T.snapshot.grouping})}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id,N]),p.useEffect(()=>{if(i&&n&&!m&&h.length===0){const T=Do(i),E={id:`auto-report-${Date.now()}`,name:c||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:T,schema:ro(T),permissions:{owner:jt,editors:[],viewers:[]}};g([E]),S(E.id),j(!0),W("confirmed")}},[i,n,m,h.length,r,c]),p.useEffect(()=>{if(!s||m)return;let T=!1,E=null;const M=async()=>{try{W("uploading");let _;if(s.type==="api"){const q=await fetch(s.url,{headers:s.headers||{}});if(!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);_=await q.json()}else _=await s.fetch();if(T)return;if(!Array.isArray(_))throw new Error("Data source must return an array of objects");const Y=ro(_);if(m)g(q=>q.map(pe=>pe.id===v?{...pe,uploadedData:_}:pe)),W("confirmed");else{const q={id:`auto-report-${Date.now()}`,name:c||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:Do(_),schema:ro(Do(_)),permissions:{owner:jt,editors:[],viewers:[]}};g([q]),S(q.id),j(!0),W("confirmed")}}catch(_){T||(W("error"),a&&N(a.id,{uploadError:(_==null?void 0:_.message)||"Failed to load data from source"}))}};return M(),s.refreshInterval&&s.refreshInterval>0&&(E=setInterval(M,s.refreshInterval)),()=>{T=!0,E&&clearInterval(E)}},[s,c,r]);const Pe=(ei=a==null?void 0:a.views)==null?void 0:ei.find(T=>T.id===a.activeViewId),dr=p.useMemo(()=>a!=null&&a.uploadedData?(a.uploadedData.forEach(Il),a.uploadedData):[],[a==null?void 0:a.uploadedData]),ur=Tl({rawData:dr,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:at||"",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:Mt,currentPage:ct}}),{data:Dr=[],searchedData:Wt=[],groupedData:$r=[],sortedData:qt=[],metrics:Or={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Pt=!1,paginationEngine:Be}=ur||{},Q=((ti=ur.viewEngine)==null?void 0:ti.activeView)||Pe,ut=((ri=ur.viewEngine)==null?void 0:ri.isDirty)||!1;p.useEffect(()=>{if(!(!Q||!a)&&!a.columnOrder){const T=Q.snapshot.columnOrder,E=so(T,Q.snapshot.grouping);N(a.id,{columnOrder:E})}},[a==null?void 0:a.activeViewId]);const Ie=p.useMemo(()=>!(a!=null&&a.schema)||!Q?null:Da(a.filters,a.sortStack||[],a.schema,a.columnVisibility,a.columnOrder,a.columnWidths,a.grouping,Q.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,Q]),Jt=p.useMemo(()=>!Q||!Ie||!ut?[]:_a(Ie,Q.snapshot),[Q,Ie,ut]),pr=p.useCallback((T,E,M)=>{const _={id:`report-${Date.now()}`,name:T,description:E,schemaLocked:!1,permissions:{owner:jt,editors:[],viewers:[]}};if(M&&Array.isArray(M)&&M.length>0){const Y=ro(M),q=vn(Y);_.uploadedData=M,_.schema=Y,_.schemaLocked=!0,_.views=[q],_.activeViewId=q.id,_.sortStack=q.snapshot.sortStack,_.filters=q.snapshot.filters,_.columnVisibility=q.snapshot.columnVisibility,_.columnOrder=q.snapshot.columnOrder,_.columnWidths=q.snapshot.columnWidths,_.grouping=q.snapshot.grouping}g(Y=>[...Y,_]),S(_.id),C(!1),W("confirmed")},[]),Kt=p.useCallback(T=>{a&&(W("uploading"),setTimeout(()=>{const E=ro(T);N(a.id,{uploadedData:T,schema:E,uploadError:void 0}),W("preview")},500))},[a,N]),Qr=p.useCallback(T=>{a&&(N(a.id,{uploadError:T}),W("idle"))},[a,N]),Bt=p.useCallback(()=>{a&&(N(a.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),W("idle"))},[a,N]),It=p.useCallback(()=>{a&&(N(a.id,{schemaLocked:!0}),W("confirmed"))},[a,N]),Xt=p.useCallback(T=>{if(!a)return;if(!xt("edit_sorting",U)){b(mt("edit_sorting"),"error");return}const E=a.sortStack??[],M=E.find(_=>_.column===T);if(M){const _=wa(M.direction);if(_===null){const Y=E.filter(q=>q.column!==T).map((q,pe)=>({...q,priority:pe+1}));N(a.id,{sortStack:Y.length>0?Y:void 0})}else{const Y=_,q=E.map(pe=>pe.column===T?{...pe,direction:Y}:pe);N(a.id,{sortStack:q})}}else{if(E.length>=f.sort.maxLevels){b(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const _={column:T,direction:"asc",priority:E.length+1};N(a.id,{sortStack:[...E,_]})}},[a,U,N]),Ve=p.useCallback(T=>{if(a)if(a.schema){const{validRules:E,invalidColumns:M}=fs(T,a.schema);M.length>0&&b(`Removed invalid sort columns: ${M.join(", ")}`),vt();try{N(a.id,{sortStack:E.length>0?E:void 0})}catch(_){const Y=or("processing","sorting",_);dt(Y)}}else N(a.id,{sortStack:T.length>0?T:void 0})},[a,N,vt,dt]),xr=p.useCallback(T=>{if(!a)return;const E=a.sortStack??[],M=E.find(_=>_.column===T);if(!(M&&M.direction==="asc"))if(M){const _=E.map(Y=>Y.column===T?{...Y,direction:"asc"}:Y);N(a.id,{sortStack:_})}else{if(E.length>=f.sort.maxLevels){b(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const _={column:T,direction:"asc",priority:E.length+1};N(a.id,{sortStack:[...E,_]})}},[a,N]),he=p.useCallback(T=>{if(!a)return;const E=a.sortStack??[],M=E.find(_=>_.column===T);if(!(M&&M.direction==="desc"))if(M){const _=E.map(Y=>Y.column===T?{...Y,direction:"desc"}:Y);N(a.id,{sortStack:_})}else{if(E.length>=f.sort.maxLevels){b(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const _={column:T,direction:"desc",priority:E.length+1};N(a.id,{sortStack:[...E,_]})}},[a,N]),Ge=p.useCallback((T,E)=>{var _;if(!a)return;if(!xt("edit_filters",U)){b(mt("edit_filters"),"error");return}const M=(_=a.schema)==null?void 0:_.find(Y=>Y.name===E.column);if(M&&E.value!==void 0){const Y=ul(M.type,E.operator,E.value);if(!Y.isValid){b(Y.errorMessage||"Invalid filter value","error");return}}vt();try{const Y=Oe(a.filters),q={...E,id:Yr()},pe=qr(Y,T,q);ge("filters","filter_added",null,q),N(a.id,{filters:pe})}catch(Y){const q=or("processing","filters",Y);dt(q)}},[a,U,N,vt,dt,ge]),_r=p.useCallback(T=>{if(!a)return;if(!xt("edit_filters",U)){b(mt("edit_filters"),"error");return}const E=Oe(a.filters),M=qr(E,T,wt());ge("filters","filter_added",null,"a condition group"),N(a.id,{filters:M})},[a,U,N,ge]),pt=p.useCallback((T,E)=>{if(!a)return;if(!xt("edit_filters",U)){b(mt("edit_filters"),"error");return}const M=Oe(a.filters),_=$o(M,T),Y=Nn(M,T,E),q=$o(Y,T);ge("filters","filter_updated",_,q),N(a.id,{filters:Y})},[a,U,N,ge]),St=p.useCallback((T,E)=>{if(!a)return;if(!xt("edit_filters",U)){b(mt("edit_filters"),"error");return}const M=Oe(a.filters),_=Ln(M,T,E);ge("filters","filter_updated",null,`group operator changed to ${E.toUpperCase()}`),N(a.id,{filters:_})},[a,U,N,ge]),zt=p.useCallback(T=>{if(!a)return;if(!xt("edit_filters",U)){b(mt("edit_filters"),"error");return}const E=Oe(a.filters),M=$o(E,T),_=Fn(E,T);ge("filters","filter_removed",M,null),N(a.id,{filters:_})},[a,U,N,ge]),Mr=p.useCallback(()=>{if(!a)return;if(!xt("edit_filters",U)){b(mt("edit_filters"),"error");return}const T=Oe(a.filters);ge("filters","filter_cleared",{count:ht(T)},null),N(a.id,{filters:wt()})},[a,U,N,ge]),Qt=p.useCallback(T=>{if(!a)return;if(!xt("edit_filters",U)){b(mt("edit_filters"),"error");return}const E=Oe(a.filters);ge("filters","filter_cleared",{count:ht(E)},{count:ht(T)}),N(a.id,{filters:T})},[a,U,N,ge]),Ze=p.useCallback(T=>{var Y;if(!a)return;const E=(Y=a.views)==null?void 0:Y.find(q=>q.id===T);if(!E)return;const M=E.snapshot.columnOrder,_=so(M,E.snapshot.grouping);N(a.id,{filters:E.snapshot.filters,sortStack:E.snapshot.sortStack.length>0?[...E.snapshot.sortStack]:void 0,columnVisibility:{...E.snapshot.columnVisibility},columnOrder:_,columnWidths:{...E.snapshot.columnWidths},grouping:E.snapshot.grouping,activeViewId:T}),lt(new Set)},[a,N]),Ke=p.useCallback((T,E,M)=>{var Fe;if(!(a!=null&&a.schema)||!Ie)return;const _=a.views??[],Y=_.filter(bn=>!bn.isDeleted).length,q=((Fe=f.views)==null?void 0:Fe.maxViews)??10;if(Y>=q){b(`View limit reached — you can have at most ${q} saved views. Delete an existing view to create a new one.`,"error");return}const pe={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:T,description:E||void 0,isDefault:M,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:jt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Ie}},be=M?_.map(bn=>({...bn,isDefault:!1})):_;N(a.id,{views:[...be,pe],activeViewId:pe.id}),b(`"${T}" view created`,"success")},[a,Ie,N]),mr=p.useCallback(T=>{var pe;if(!(a!=null&&a.views))return;const E=a.views.find(be=>be.id===T);if(!E)return;const M=a.views,_=M.filter(be=>!be.isDeleted).length,Y=((pe=f.views)==null?void 0:pe.maxViews)??10;if(_>=Y){b(`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:jt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...E.snapshot}};N(a.id,{views:[...M,q]}),b(`"${q.name}" created`,"success")},[a,f,N]),Zt=p.useCallback(()=>{var E;if(!Q||!Ie||!a)return;const T=(E=a.views)==null?void 0:E.map(M=>M.id===Q.id?{...M,snapshot:{...Ie}}:M);N(a.id,{views:T}),b(`"${Q.name}" view updated`,"success")},[Q,Ie,a,N]),fr=p.useCallback(T=>{var _;if(!Q||!Ie||!a)return;const E=T??Ie.columnWidths,M=(_=a.views)==null?void 0:_.map(Y=>Y.id===Q.id?{...Y,snapshot:{...Y.snapshot,columnVisibility:Ie.columnVisibility,columnOrder:Ie.columnOrder,columnWidths:E},updatedAt:Date.now()}:Y);N(a.id,{views:M,columnWidths:E}),b(`Column configuration saved to "${Q.name}"`,"success")},[Q,Ie,a,N]),me=p.useCallback(T=>{var q,pe;if(!Ie||!a||!Q)return;const E=T??Ie.columnWidths,M={...Q,snapshot:{...Q.snapshot,columnVisibility:Ie.columnVisibility,columnOrder:Ie.columnOrder,columnWidths:E},updatedAt:Date.now()},_=(q=a.views)==null?void 0:q.map(be=>be.id===Q.id?M:{...be,snapshot:{...be.snapshot,columnVisibility:Ie.columnVisibility,columnOrder:Ie.columnOrder,columnWidths:E},updatedAt:Date.now()});N(a.id,{views:_,columnWidths:E});const Y=(((pe=a.views)==null?void 0:pe.length)||0)-1;b(`Column configuration saved to current view and ${Y} other view${Y===1?"":"s"}`,"success")},[Ie,a,Q,N]),Ce=p.useCallback(()=>{re(!0)},[]),$e=p.useCallback(()=>{if(!Q||!a)return;const T=Q.snapshot.columnOrder,E=so(T,Q.snapshot.grouping);N(a.id,{filters:Q.snapshot.filters,sortStack:Q.snapshot.sortStack.length>0?[...Q.snapshot.sortStack]:void 0,columnVisibility:{...Q.snapshot.columnVisibility},columnOrder:E,columnWidths:{...Q.snapshot.columnWidths},grouping:Q.snapshot.grouping}),b("Changes reverted to last saved state","success")},[Q,a,N]),Et=p.useCallback(T=>{if(!(a!=null&&a.views))return;const E=a.views.map(_=>({..._,isDefault:_.id===T}));N(a.id,{views:E});const M=a.views.find(_=>_.id===T);M&&b(`"${M.name}" set as default view`,"success")},[a,N]),er=p.useCallback(T=>{if(!(a!=null&&a.views))return;const E=a.views.map(_=>_.id===T?{..._,isFavorite:!_.isFavorite,updatedAt:Date.now()}:_);N(a.id,{views:E});const M=a.views.find(_=>_.id===T);M&&!M.isFavorite?b(`"${M.name}" added to favorites`,"success"):M&&b(`"${M.name}" removed from favorites`,"info")},[a,N]),go=p.useCallback(T=>{if(!(a!=null&&a.views))return;const E=a.views.find(Fe=>Fe.id===T),M=a.views.filter(Fe=>!Fe.isDeleted||Fe.id===T);if((E==null?void 0:E.isDefault)&&M.filter(Fe=>Fe.isDefault).length===1){b("Cannot delete the last default view","error");return}const Y=a.views.map(Fe=>Fe.id===T?{...Fe,isDeleted:!0,updatedAt:Date.now()}:Fe),q=a.activeViewId===T,pe=Y.find(Fe=>Fe.isDefault&&!Fe.isDeleted);N(a.id,{views:Y,activeViewId:q&&pe?pe.id:a.activeViewId,filters:q&&pe?pe.snapshot.filters:a.filters,sortStack:q&&pe?pe.snapshot.sortStack.length>0?pe.snapshot.sortStack:void 0:a.sortStack});const be=a.views.find(Fe=>Fe.id===T);be&&b(`"${be.name}" moved to Recently Deleted`,"info")},[a,N]),Ar=p.useCallback(T=>{if(!(a!=null&&a.views))return;const E=a.views.map(_=>_.id===T?{..._,isDeleted:!1,updatedAt:Date.now()}:_);N(a.id,{views:E});const M=a.views.find(_=>_.id===T);M&&b(`"${M.name}" restored`,"success")},[a,N]),yo=p.useCallback(T=>{if(!(a!=null&&a.views))return;const E=a.views.find(be=>be.id===T),M=a.views.filter(be=>!be.isDeleted||be.id===T);if((E==null?void 0:E.isDefault)&&M.filter(be=>be.isDefault).length===1){b("Cannot delete the last default view","error");return}const Y=a.views.filter(be=>be.id!==T),q=a.activeViewId===T,pe=Y.find(be=>be.isDefault&&!be.isDeleted);N(a.id,{views:Y,activeViewId:q&&pe?pe.id:a.activeViewId,filters:q&&pe?pe.snapshot.filters:a.filters,sortStack:q&&pe?pe.snapshot.sortStack.length>0?pe.snapshot.sortStack:void 0:a.sortStack}),E&&b(`"${E.name}" permanently deleted`,"success")},[a,N]),hr=p.useCallback(T=>{ie(T),X(!0)},[]),Zr=p.useCallback(async T=>{if(!a)return;const E=new URLSearchParams(window.location.search);E.set("reportId",a.id),E.set("view",T);const M=`${window.location.origin}${window.location.pathname}?${E.toString()}`,_=await il(M);b(_?"Link copied to clipboard":"Failed to copy link",_?"success":"error")},[a]),bo=p.useCallback((T,E)=>{if(!oe||!(a!=null&&a.views))return;const M=a.views.map(_=>_.id===oe?{..._,name:T,description:E||void 0}:_);N(a.id,{views:M}),ie(null)},[oe,a,N]),Ct=p.useCallback(T=>{ae(T),fe(!0)},[]),Rr=p.useCallback(()=>{if(!H||!(a!=null&&a.views))return;const T=a.views.filter(_=>_.id!==H),E=a.activeViewId===H,M=T.find(_=>_.isDefault);N(a.id,{views:T,activeViewId:E&&M?M.id:a.activeViewId,filters:E&&M?M.snapshot.filters:a.filters,sortStack:E&&M?M.snapshot.sortStack.length>0?M.snapshot.sortStack:void 0:a.sortStack}),ae(null),fe(!1)},[H,a,N]),Wr=p.useCallback(T=>{var Y;if(!(a!=null&&a.views))return;if(!(((Y=f.views)==null?void 0:Y.isAdmin)??!1)){b("Only administrators can promote views to Global.","error");return}const M=a.views.find(q=>q.id===T);if(!M)return;if(M.scope==="global"){b(`"${M.name}" is already a Global View.`,"info");return}const _=a.views.map(q=>q.id===T?{...q,scope:"global",isDefault:!0,updatedAt:Date.now()}:q.scope==="global"&&q.isDefault?{...q,isDefault:!1}:q);N(a.id,{views:_}),b(`"${M.name}" promoted to Global View and set as default.`,"success")},[a,f,N]);p.useEffect(()=>{Be!=null&&Be.resetPage?Be.resetPage():_t(1)},[a==null?void 0:a.filters,at,a==null?void 0:a.activeViewId]),p.useEffect(()=>{Be&&Be.currentPage!==ct&&_t(Be.currentPage)},[Be==null?void 0:Be.currentPage]);const tr=p.useCallback(T=>{Be!=null&&Be.goToPage&&Be.goToPage(T),_t(T)},[Be]),vo=p.useCallback(T=>{const E=(ct-1)*Mt,M=Math.floor(E/T)+1;Jr(T),_t(M),Be==null||Be.goToPage(M)},[ct,Mt,Be]),Pr=p.useCallback((T,E)=>{if(!a)return;if(!xt("edit_columns",U)){b(mt("edit_columns"),"error");return}const _={...a.columnVisibility||(Q==null?void 0:Q.snapshot.columnVisibility)||{},[T]:E};N(a.id,{columnVisibility:_})},[a,Q,U,N]),an=p.useCallback(T=>{if(a){if(!xt("edit_columns",U)){b(mt("edit_columns"),"error");return}N(a.id,{columnOrder:T})}},[a,U,N]),ln=p.useCallback((T,E)=>{if(!a)return;if(!xt("edit_columns",U)){b(mt("edit_columns"),"error");return}const _={...a.columnWidths||(Q==null?void 0:Q.snapshot.columnWidths)||{},[T]:E};N(a.id,{columnWidths:_})},[a,Q,U,N]),cn=p.useCallback(T=>{if(!a)return;const E=Oe(a.filters),M=cs(E,T);N(a.id,{filters:M})},[a,N]),dn=p.useCallback(()=>{if(!Q||!(a!=null&&a.schema))return;const T={},E=[],M={};a.schema.forEach(_=>{T[_.name]=!0,E.push(_.name),M[_.name]=170}),N(a.id,{columnVisibility:T,columnOrder:E,columnWidths:M,filters:void 0,sortStack:void 0}),b("Reset to default layout - all filters and sorts cleared","success")},[Q,a,N]);p.useEffect(()=>{const T=setTimeout(()=>Gt(bt),300);return()=>clearTimeout(T)},[bt]);const un=p.useCallback(T=>{Br(T)},[]),pn=p.useCallback(T=>{if(!T.trim()||!a)return;const E=a.searchHistory||[],M=Wa(E,T);N(a.id,{searchHistory:M})},[a,N]),xn=p.useCallback(T=>{if(!a)return;const E=a.searchHistory||[],M=Pa(E,T);N(a.id,{searchHistory:M})},[a,N]),mn=p.useCallback(T=>{if(!a)return;const E=a.searchHistory||[],M=Na(E,T);N(a.id,{searchHistory:M})},[a,N]),fn=p.useCallback(T=>{const E=T==null?void 0:T.__urm_row_id__;lt(M=>{const _=new Set(M);if(E!==void 0){const Y=Array.from(_).find(q=>(q==null?void 0:q.__urm_row_id__)===E);Y!==void 0?_.delete(Y):_.add(T)}else{const Y=JSON.stringify(T),q=Array.from(_).find(pe=>JSON.stringify(pe)===Y);q!==void 0?_.delete(q):_.add(T)}return _})},[]),Nr=p.useCallback((T,E)=>{lt(M=>{const _=new Set(M);for(const Y of E)T?_.add(Y):_.delete(Y);return _})},[]),Nt=p.useCallback((T,E,M)=>{lt(_=>{const Y=new Set(_),q=Math.min(T,E),pe=Math.max(T,E);for(let be=q;be<=pe;be++)M[be]!==void 0&&Y.add(M[be]);return Y})},[]),hn=p.useCallback(()=>{lt(new Set)},[]),gn=p.useCallback(T=>{const E=T==null?void 0:T.__urm_row_id__;lt(M=>{const _=new Set(M);if(E!==void 0){const Y=Array.from(_).find(q=>(q==null?void 0:q.__urm_row_id__)===E);Y!==void 0&&_.delete(Y)}else _.delete(T);return _})},[]),Ne=p.useCallback(T=>{if(a){if(!xt("edit_columns",U)){b(mt("edit_columns"),"error");return}if(T&&a.schema){const{validGrouping:E,invalidColumns:M}=hs(T,a.schema);M.length>0&&b(`Removed invalid grouping columns: ${M.join(", ")}`,"warning"),vt();try{const _=a.grouping;E===null?ge("grouping","group_cleared",_,null):_?ge("grouping","group_reordered",_,E):ge("grouping","group_level_added",null,E);const Y=(Q==null?void 0:Q.snapshot.columnOrder)||a.columnOrder||[],q=so(Y,E);N(a.id,{grouping:E,columnOrder:q}),JSON.stringify(q)!==JSON.stringify(a.columnOrder)&&ge("columns","column_reordered",a.columnOrder,q),st(!1)}catch(_){const Y=or("processing","grouping",_);dt(Y)}}else{const E=a.grouping;ge("grouping","group_cleared",E,null);const M=(Q==null?void 0:Q.snapshot.columnOrder)||a.columnOrder||[];N(a.id,{grouping:T,columnOrder:[...M]}),JSON.stringify(M)!==JSON.stringify(a.columnOrder)&&ge("columns","column_reordered",a.columnOrder,M),st(!1)}}},[a,Q,U,N,vt,dt,ge]),Lt=p.useCallback(T=>{if(!a)return;const E=a.grouping;if(!E)return;const M=Ea(E,T);N(a.id,{grouping:M})},[a,N]),So=p.useCallback(()=>{a!=null&&a.grouping&&N(a.id,{grouping:{...a.grouping,collapsedGroups:[]}})},[a,N]),Zn=p.useCallback(()=>{if(!(a!=null&&a.grouping)||!a.schema)return;const T=za(qt,a.schema,a.grouping);N(a.id,{grouping:{...a.grouping,collapsedGroups:T}})},[a,qt,N]),eo=p.useCallback(()=>{Qe(!0)},[]),gr=p.useCallback(T=>{a!=null&&a.schema&&(D(!0),setTimeout(()=>{try{let E;T.scope==="visible"?E=Wt:E=a.uploadedData||[];let M;T.columnScope==="all"?(M={},(a.schema??[]).forEach(be=>{M[be.name]=!0})):M=a.columnVisibility||(Q==null?void 0:Q.snapshot.columnVisibility)||{};const _=a.columnOrder||(Q==null?void 0:Q.snapshot.columnOrder),Y=Ao(E,a.schema,Oe(a.filters),a.sortStack??[],Q,M,_),q=a.name;let pe;switch(T.format){case"csv":Ro(Y,q,T),pe="export_csv";break;case"excel":Wo(Y,q,T),pe="export_excel";break;case"json":Po(Y,q,T),pe="export_json";break}ge("export",pe,null,{format:T.format,scope:T.scope,columnScope:T.columnScope,rowCount:E.length,viewName:(Q==null?void 0:Q.name)||"Default View"}),b(`Export completed successfully (${T.format.toUpperCase()})`,"success")}catch(E){const M=xl(E,{onRetry:()=>gr(T)});b(`Export failed: ${M.message}. Click Export to retry.`,"error");const _=fi(a.id,jt,M,a.auditHistory||[]);N(a.id,{auditHistory:_}),Ot.error("urm:report-engine","Export failed",E)}finally{D(!1)}},500))},[a,Q,Wt,N,ge]),Co=p.useCallback(T=>{if(a!=null&&a.schema){if(ut&&Q&&!Q.isDefault){ye(T.format),ue(!0),Qe(!1);return}gr(T),Qe(!1)}},[a,Q,ut,gr]),yr=p.useCallback(T=>{gr({format:T,scope:"visible",columnScope:"visible"})},[gr]),w=p.useCallback(()=>{ne&&yr(ne),ue(!1),ye(null)},[ne,yr]),L=p.useCallback(()=>{Zt(),ne&&yr(ne),ue(!1),ye(null)},[Zt,ne,yr]),xe=p.useCallback(()=>{ue(!1),ye(null)},[]),Le=p.useCallback(T=>{!(a!=null&&a.schema)||kt.size===0||(D(!0),setTimeout(()=>{try{const E=Array.from(kt),M=Ao(E,a.schema,Oe(a.filters),a.sortStack??[],Q),_=`${a.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(T){case"csv":Ro(M,_);break;case"excel":Wo(M,_);break;case"json":Po(M,_);break}b(`Exported ${E.length} selected rows`,"info")}catch(E){b("Export failed. Please try again.","error"),Ot.error("urm:report-engine","Bulk export failed",E)}finally{D(!1)}},500))},[a,Q,kt,$r]),Ye=p.useCallback((T,E)=>{if(a)try{const M=Za(a),_=el(T,E,jt,M),Y=tl(a.presets,_);N(a.id,{presets:Y}),ge("presets","preset_created",null,{presetId:_.id,name:_.name}),Kr(!1),b(`Preset "${T}" saved successfully`,"success")}catch(M){b(M instanceof Error?M.message:"Failed to create preset","error")}},[a,N,ge]),qe=p.useCallback(()=>{Tt(null),b("Exited preset view","info")},[]),Je=p.useCallback(()=>{At(!0)},[]),de=p.useCallback((T,E)=>{if(!a)return;const M=rl(a.presets,T);N(a.id,{presets:M}),ge("presets","preset_deleted",{presetId:T,name:E},null),Ue===T&&Tt(null),b(`Preset "${E}" deleted`,"success")},[a,Ue,N,ge]);p.useEffect(()=>{if(!l||h.length===0)return;const T=h.find(E=>E.id===l);T&&T.id!==v&&S(T.id)},[l,h,v]);const Ft=p.useRef(!1);p.useEffect(()=>{var E;if(!d||Ft.current||!a||a.id!==l)return;const T=(E=a.views)==null?void 0:E.find(M=>M.id===d&&!M.isDeleted);T&&Ze(T.id),Ft.current=!0},[d,l,a,Ze]),p.useEffect(()=>{if(!a)return;const T=ol();if(T&&a.presets&&a.schemaLocked&&a.schema){const E=mi(a.presets,T);if(E){const{sanitizedConfig:M,warnings:_}=pl(E.config,a.schema);_.length>0&&_.forEach(q=>b(q,"warning"));const Y=nl(M);N(a.id,Y),Tt(T),ge("presets","preset_applied",null,{presetId:E.id,name:E.name}),b(`Loaded preset: ${E.name}`,"info")}else b("Preset not found","info")}},[a==null?void 0:a.schemaLocked]);const to=Ue?mi(a==null?void 0:a.presets,Ue):void 0;p.useEffect(()=>{a!=null&&a.views&&a.views.length>0&&a.activeViewId&&Ma(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 T=Aa(a.id);if(T&&T.views.length>0){const E=T.views.find(M=>M.id===T.activeViewId);if(E)N(a.id,{views:T.views,activeViewId:T.activeViewId,filters:Oe(E.snapshot.filters),sortStack:E.snapshot.sortStack.length>0?E.snapshot.sortStack:void 0});else{const M=T.views.find(_=>_.isDefault)||vn(a.schema);N(a.id,{views:T.views,activeViewId:M.id,filters:Oe(M.snapshot.filters),sortStack:M.snapshot.sortStack.length>0?M.snapshot.sortStack:void 0})}}}},[a==null?void 0:a.schemaLocked,a==null?void 0:a.schema,a==null?void 0:a.id]);const yn=p.useCallback(T=>{var _;const E=Oe(a==null?void 0:a.filters),M=((_=f.filter)==null?void 0:_.maxConditions)??3;if(ht(E)>=M){b(`Filter limit reached — maximum ${M} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}K(T),te(!0)},[a,f,b]),Ks=p.useCallback(()=>{te(!1),K(void 0)},[]),Xs=(oi=a==null?void 0:a.views)==null?void 0:oi.find(T=>T.id===oe),Qs=(ni=a==null?void 0:a.views)==null?void 0:ni.find(T=>T.id===H);return{reports:h,activeReport:a,activeReportId:v,setActiveReportId:S,isModalOpen:B,setIsModalOpen:C,createReport:pr,updateReport:N,uploadState:$,handleFileUpload:Kt,handleUploadError:Qr,handleRetry:Bt,handleConfirm:It,paginatedData:Dr,processedData:Wt,displayData:$r,tableMetrics:Or,isGrouped:Pt,tableEngine:ur,activeView:Q,isDirty:ut,currentTableState:Ie,viewChanges:Jt,filters:a==null?void 0:a.filters,showFilterPanel:J,setShowFilterPanel:te,filterFocusColumn:V,handleAddCondition:Ge,handleAddGroup:_r,handleUpdateCondition:pt,handleSetGroupOperator:St,handleRemoveFilterNode:zt,handleClearAllFilters:Mr,handleReplaceFilters:Qt,handleOpenFilterForColumn:yn,handleCloseFilterPanel:Ks,handleClearFiltersForColumn:cn,sortStack:a==null?void 0:a.sortStack,showSortPanel:x,setShowSortPanel:P,handleSort:Xt,handleUpdateSortStack:Ve,handleSortAscending:xr,handleSortDescending:he,views:a==null?void 0:a.views,showCreateViewModal:F,setShowCreateViewModal:re,showEditViewModal:ce,setShowEditViewModal:X,showDeleteConfirmation:ee,setShowDeleteConfirmation:fe,editingView:Xs,deletingView:Qs,editingViewId:oe,deletingViewId:H,handleSelectView:Ze,handleCreateView:Ke,handleCloneView:mr,handleUpdateCurrentView:Zt,handleSaveColumnConfigToCurrentView:fr,handleSaveColumnConfigToAllViews:me,handleSaveAsNewView:Ce,handleRevertChanges:$e,handleToggleDefault:Et,handleToggleFavorite:er,handleSoftDelete:go,handleRestoreView:Ar,handlePermanentDelete:yo,handleEditView:hr,handleCopyViewLink:Zr,handleSaveEditView:bo,handleDeleteView:Ct,handleConfirmDelete:Rr,handlePromoteToGlobal:Wr,showManageColumns:G,setShowManageColumns:Ae,columnVisibility:a==null?void 0:a.columnVisibility,columnOrder:a==null?void 0:a.columnOrder,columnWidths:a==null?void 0:a.columnWidths,handleUpdateColumnVisibility:Pr,handleUpdateColumnOrder:an,handleUpdateColumnWidth:ln,handleResetColumnLayout:dn,showGroupPanel:yt,setShowGroupPanel:st,grouping:a==null?void 0:a.grouping,groupingState:kr,handleGroup:Ne,handleToggleGroupCollapse:Lt,handleExpandAllGroups:So,handleCollapseAllGroups:Zn,searchQuery:bt,debouncedSearchQuery:at,searchHistory:La((a==null?void 0:a.searchHistory)||[]),handleSearchChange:un,handleAddToSearchHistory:pn,handleToggleSearchFavourite:xn,handleDeleteSearchHistory:mn,selectedRowIds:kt,handleToggleRowSelection:fn,handleToggleAllRows:Nr,handleRangeSelection:Nt,handleClearSelection:hn,handleUpdateSelectionAfterDelete:gn,currentPage:ct,pageSize:Mt,paginationEngine:Be,handlePageChange:tr,handlePageSizeChange:vo,isExporting:se,showExportModal:Xr,setShowExportModal:Qe,showDirtyExportWarning:Z,handleExport:eo,handleExportWithConfig:Co,handleExportSelected:Le,handleExportAnyway:w,handleSaveAndExport:L,handleCancelExport:xe,showAuditHistory:sr,setShowAuditHistory:ar,auditHistory:a==null?void 0:a.auditHistory,showCreatePreset:Xe,setShowCreatePreset:Kr,showManagePresets:Ir,setShowManagePresets:At,activePreset:to,activePresetId:Ue,handleOpenManagePresets:Je,handleCreatePreset:Ye,handleClearActivePreset:qe,handleDeletePresetById:de,userRole:U,isViewerRole:cr,currentUserId:jt,featureLimitWarning:lr,setFeatureLimitWarning:Re,datasetMeta:Er,reportError:Yt,setReportError:Rt,handleError:dt,schema:a==null?void 0:a.schema,hasSchemaConflicts:a!=null&&a.schema?Sa(a.schema):!1,snack:y,handleSnackClose:k,showSnack:b,snackDurationMs:R,config:u}}const gs=p.createContext(void 0);function Gn(e){const{children:r,initialData:n,data:i,reportName:s,dataSource:c,mode:l="builder",autoLoad:d=!0,config:u,devConfig:h,showDevPanel:g=!1,sharedReportId:f,sharedViewId:v}=e,B=zl({mode:l,autoLoad:d,initialData:i||n,dataSource:c,reportName:s,sharedReportId:f,sharedViewId:v,config:u}),[C,m]=p.useState(()=>oa()),j=(()=>{const k=ia(C,h,!!h);return{...k,display:{...k.display,showDevPanel:g||k.display.showDevPanel}}})(),y=p.useCallback(b=>{m(b),na(b)},[]),O={...B,activeDevConfig:j,handleDevConfigChange:y};return t.jsx(ns.Provider,{value:j,children:t.jsx(gs.Provider,{value:O,children:r})})}function Uo(){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(c=>c.id===n);return t.jsx(o.Box,{component:"header",sx:c=>{var g,f,v;const l=((v=(f=(g=c.components)==null?void 0:g.MuiCardHeader)==null?void 0:f.styleOverrides)==null?void 0:v.root)||{},d=l.backgroundColor&&l.backgroundColor!=="transparent"?l.backgroundColor:c.palette.background.paper,u=l.borderBottom&&l.borderBottom!=="none"?l.borderBottom:"1px solid",h=l.boxShadow&&l.boxShadow!=="none"?l.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:u,borderColor:u!=="none"?"divider":void 0,boxShadow:h,bgcolor:d}},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[t.jsxs(o.Breadcrumbs,{separator:t.jsx(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 Sr(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 wo={exports:{}},ko={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 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
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,c=e?Symbol.for("react.profiler"):60114,l=e?Symbol.for("react.provider"):60109,d=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,h=e?Symbol.for("react.concurrent_mode"):60111,g=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,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 O(k){if(typeof k=="object"&&k!==null){var R=k.$$typeof;switch(R){case r:switch(k=k.type,k){case u:case h:case i:case c:case s:case f:return k;default:switch(k=k&&k.$$typeof,k){case d:case g:case B:case S:case l:return k;default:return R}}case n:return R}}}function b(k){return O(k)===h}return ve.AsyncMode=u,ve.ConcurrentMode=h,ve.ContextConsumer=d,ve.ContextProvider=l,ve.Element=r,ve.ForwardRef=g,ve.Fragment=i,ve.Lazy=B,ve.Memo=S,ve.Portal=n,ve.Profiler=c,ve.StrictMode=s,ve.Suspense=f,ve.isAsyncMode=function(k){return b(k)||O(k)===u},ve.isConcurrentMode=b,ve.isContextConsumer=function(k){return O(k)===d},ve.isContextProvider=function(k){return O(k)===l},ve.isElement=function(k){return typeof k=="object"&&k!==null&&k.$$typeof===r},ve.isForwardRef=function(k){return O(k)===g},ve.isFragment=function(k){return O(k)===i},ve.isLazy=function(k){return O(k)===B},ve.isMemo=function(k){return O(k)===S},ve.isPortal=function(k){return O(k)===n},ve.isProfiler=function(k){return O(k)===c},ve.isStrictMode=function(k){return O(k)===s},ve.isSuspense=function(k){return O(k)===f},ve.isValidElementType=function(k){return typeof k=="string"||typeof k=="function"||k===i||k===h||k===c||k===s||k===f||k===v||typeof k=="object"&&k!==null&&(k.$$typeof===B||k.$$typeof===S||k.$$typeof===l||k.$$typeof===d||k.$$typeof===g||k.$$typeof===m||k.$$typeof===j||k.$$typeof===y||k.$$typeof===C)},ve.typeOf=O,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 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}/*
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,c=e?Symbol.for("react.profiler"):60114,l=e?Symbol.for("react.provider"):60109,d=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,h=e?Symbol.for("react.concurrent_mode"):60111,g=e?Symbol.for("react.forward_ref"):60112,f=e?Symbol.for("react.suspense"):60113,v=e?Symbol.for("react.suspense_list"):60120,S=e?Symbol.for("react.memo"):60115,B=e?Symbol.for("react.lazy"):60116,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 O(G){return typeof G=="string"||typeof G=="function"||G===i||G===h||G===c||G===s||G===f||G===v||typeof G=="object"&&G!==null&&(G.$$typeof===B||G.$$typeof===S||G.$$typeof===l||G.$$typeof===d||G.$$typeof===g||G.$$typeof===m||G.$$typeof===j||G.$$typeof===y||G.$$typeof===C)}function b(G){if(typeof G=="object"&&G!==null){var Ae=G.$$typeof;switch(Ae){case r:var yt=G.type;switch(yt){case u:case h:case i:case c:case s:case f:return yt;default:var st=yt&&yt.$$typeof;switch(st){case d:case g:case B:case S:case l:return st;default:return Ae}}case n:return Ae}}}var k=u,R=h,a=d,$=l,W=r,J=g,te=i,x=B,P=S,F=n,re=c,ce=s,X=f,ee=!1;function fe(G){return ee||(ee=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),V(G)||b(G)===u}function V(G){return b(G)===h}function K(G){return b(G)===d}function oe(G){return b(G)===l}function ie(G){return typeof G=="object"&&G!==null&&G.$$typeof===r}function H(G){return b(G)===g}function ae(G){return b(G)===i}function se(G){return b(G)===B}function D(G){return b(G)===S}function Z(G){return b(G)===n}function ue(G){return b(G)===c}function ne(G){return b(G)===s}function ye(G){return b(G)===f}Se.AsyncMode=k,Se.ConcurrentMode=R,Se.ContextConsumer=a,Se.ContextProvider=$,Se.Element=W,Se.ForwardRef=J,Se.Fragment=te,Se.Lazy=x,Se.Memo=P,Se.Portal=F,Se.Profiler=re,Se.StrictMode=ce,Se.Suspense=X,Se.isAsyncMode=fe,Se.isConcurrentMode=V,Se.isContextConsumer=K,Se.isContextProvider=oe,Se.isElement=ie,Se.isForwardRef=H,Se.isFragment=ae,Se.isLazy=se,Se.isMemo=D,Se.isPortal=Z,Se.isProfiler=ue,Se.isStrictMode=ne,Se.isSuspense=ye,Se.isValidElementType=O,Se.typeOf=b})()),Se}var yi;function ys(){return yi||(yi=1,process.env.NODE_ENV==="production"?ko.exports=Ol():ko.exports=_l()),ko.exports}/*
18
18
  object-assign
19
19
  (c) Sindre Sorhus
20
20
  @license MIT
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={};/**
21
+ */var Cn,bi;function Ml(){if(bi)return Cn;bi=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function i(c){if(c==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(c)}function s(){try{if(!Object.assign)return!1;var c=new String("abc");if(c[5]="de",Object.getOwnPropertyNames(c)[0]==="5")return!1;for(var l={},d=0;d<10;d++)l["_"+String.fromCharCode(d)]=d;var u=Object.getOwnPropertyNames(l).map(function(g){return l[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 Cn=s()?Object.assign:function(c,l){for(var d,u=i(c),h,g=1;g<arguments.length;g++){d=Object(arguments[g]);for(var f in d)r.call(d,f)&&(u[f]=d[f]);if(e){h=e(d);for(var v=0;v<h.length;v++)n.call(d,h[v])&&(u[h[v]]=d[h[v]])}}return u},Cn}var jn,vi;function Yn(){if(vi)return jn;vi=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return jn=e,jn}var wn,Si;function bs(){return Si||(Si=1,wn=Function.call.bind(Object.prototype.hasOwnProperty)),wn}var kn,Ci;function Al(){if(Ci)return kn;Ci=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=Yn(),n={},i=bs();e=function(c){var l="Warning: "+c;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}}}function s(c,l,d,u,h){if(process.env.NODE_ENV!=="production"){for(var g in c)if(i(c,g)){var f;try{if(typeof c[g]!="function"){var v=Error((u||"React class")+": "+d+" type `"+g+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof c[g]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw v.name="Invariant Violation",v}f=c[g](l,g,u,d,null,r)}catch(B){f=B}if(f&&!(f instanceof Error)&&e((u||"React class")+": type specification of "+d+" `"+g+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof f+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),f instanceof Error&&!(f.message in n)){n[f.message]=!0;var S=h?h():"";e("Failed "+d+" type: "+f.message+(S??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},kn=s,kn}var Tn,ji;function Rl(){if(ji)return Tn;ji=1;var e=ys(),r=Ml(),n=Yn(),i=bs(),s=Al(),c=function(){};process.env.NODE_ENV!=="production"&&(c=function(d){var u="Warning: "+d;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function l(){return null}return Tn=function(d,u){var h=typeof Symbol=="function"&&Symbol.iterator,g="@@iterator";function f(V){var K=V&&(h&&V[h]||V[g]);if(typeof K=="function")return K}var v="<<anonymous>>",S={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:O,element:b(),elementType:k(),instanceOf:R,node:J(),objectOf:$,oneOf:a,oneOfType:W,shape:x,exact:P};function B(V,K){return V===K?V!==0||1/V===1/K:V!==V&&K!==K}function C(V,K){this.message=V,this.data=K&&typeof K=="object"?K:{},this.stack=""}C.prototype=Error.prototype;function m(V){if(process.env.NODE_ENV!=="production")var K={},oe=0;function ie(ae,se,D,Z,ue,ne,ye){if(Z=Z||v,ne=ne||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 Ae=Z+":"+D;!K[Ae]&&oe<3&&(c("You are manually calling a React.PropTypes validation function for the `"+ne+"` 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[Ae]=!0,oe++)}}return se[D]==null?ae?se[D]===null?new C("The "+ue+" `"+ne+"` is marked as required "+("in `"+Z+"`, but its value is `null`.")):new C("The "+ue+" `"+ne+"` is marked as required in "+("`"+Z+"`, but its value is `undefined`.")):null:V(se,D,Z,ue,ne)}var H=ie.bind(null,!1);return H.isRequired=ie.bind(null,!0),H}function j(V){function K(oe,ie,H,ae,se,D){var Z=oe[ie],ue=ce(Z);if(ue!==V){var ne=X(Z);return new C("Invalid "+ae+" `"+se+"` of type "+("`"+ne+"` supplied to `"+H+"`, expected ")+("`"+V+"`."),{expectedType:V})}return null}return m(K)}function y(){return m(l)}function O(V){function K(oe,ie,H,ae,se){if(typeof V!="function")return new C("Property `"+se+"` of component `"+H+"` has invalid PropType notation inside arrayOf.");var D=oe[ie];if(!Array.isArray(D)){var Z=ce(D);return new C("Invalid "+ae+" `"+se+"` of type "+("`"+Z+"` supplied to `"+H+"`, expected an array."))}for(var ue=0;ue<D.length;ue++){var ne=V(D,ue,H,ae,se+"["+ue+"]",n);if(ne instanceof Error)return ne}return null}return m(K)}function b(){function V(K,oe,ie,H,ae){var se=K[oe];if(!d(se)){var D=ce(se);return new C("Invalid "+H+" `"+ae+"` of type "+("`"+D+"` supplied to `"+ie+"`, expected a single ReactElement."))}return null}return m(V)}function k(){function V(K,oe,ie,H,ae){var se=K[oe];if(!e.isValidElementType(se)){var D=ce(se);return new C("Invalid "+H+" `"+ae+"` of type "+("`"+D+"` supplied to `"+ie+"`, expected a single ReactElement type."))}return null}return m(V)}function R(V){function K(oe,ie,H,ae,se){if(!(oe[ie]instanceof V)){var D=V.name||v,Z=fe(oe[ie]);return new C("Invalid "+ae+" `"+se+"` of type "+("`"+Z+"` supplied to `"+H+"`, expected ")+("instance of `"+D+"`."))}return null}return m(K)}function a(V){if(!Array.isArray(V))return process.env.NODE_ENV!=="production"&&(arguments.length>1?c("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])."):c("Invalid argument supplied to oneOf, expected an array.")),l;function K(oe,ie,H,ae,se){for(var D=oe[ie],Z=0;Z<V.length;Z++)if(B(D,V[Z]))return null;var ue=JSON.stringify(V,function(ye,G){var Ae=X(G);return Ae==="symbol"?String(G):G});return new C("Invalid "+ae+" `"+se+"` of value `"+String(D)+"` "+("supplied to `"+H+"`, expected one of "+ue+"."))}return m(K)}function $(V){function K(oe,ie,H,ae,se){if(typeof V!="function")return new C("Property `"+se+"` of component `"+H+"` has invalid PropType notation inside objectOf.");var D=oe[ie],Z=ce(D);if(Z!=="object")return new C("Invalid "+ae+" `"+se+"` of type "+("`"+Z+"` supplied to `"+H+"`, expected an object."));for(var ue in D)if(i(D,ue)){var ne=V(D,ue,H,ae,se+"."+ue,n);if(ne instanceof Error)return ne}return null}return m(K)}function W(V){if(!Array.isArray(V))return process.env.NODE_ENV!=="production"&&c("Invalid argument supplied to oneOfType, expected an instance of array."),l;for(var K=0;K<V.length;K++){var oe=V[K];if(typeof oe!="function")return c("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ee(oe)+" at index "+K+"."),l}function ie(H,ae,se,D,Z){for(var ue=[],ne=0;ne<V.length;ne++){var ye=V[ne],G=ye(H,ae,se,D,Z,n);if(G==null)return null;G.data&&i(G.data,"expectedType")&&ue.push(G.data.expectedType)}var Ae=ue.length>0?", expected one of type ["+ue.join(", ")+"]":"";return new C("Invalid "+D+" `"+Z+"` supplied to "+("`"+se+"`"+Ae+"."))}return m(ie)}function J(){function V(K,oe,ie,H,ae){return F(K[oe])?null:new C("Invalid "+H+" `"+ae+"` supplied to "+("`"+ie+"`, expected a ReactNode."))}return m(V)}function te(V,K,oe,ie,H){return new C((V||"React class")+": "+K+" type `"+oe+"."+ie+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+H+"`.")}function x(V){function K(oe,ie,H,ae,se){var D=oe[ie],Z=ce(D);if(Z!=="object")return new C("Invalid "+ae+" `"+se+"` of type `"+Z+"` "+("supplied to `"+H+"`, expected `object`."));for(var ue in V){var ne=V[ue];if(typeof ne!="function")return te(H,ae,se,ue,X(ne));var ye=ne(D,ue,H,ae,se+"."+ue,n);if(ye)return ye}return null}return m(K)}function P(V){function K(oe,ie,H,ae,se){var D=oe[ie],Z=ce(D);if(Z!=="object")return new C("Invalid "+ae+" `"+se+"` of type `"+Z+"` "+("supplied to `"+H+"`, expected `object`."));var ue=r({},oe[ie],V);for(var ne in ue){var ye=V[ne];if(i(V,ne)&&typeof ye!="function")return te(H,ae,se,ne,X(ye));if(!ye)return new C("Invalid "+ae+" `"+se+"` key `"+ne+"` supplied to `"+H+"`.\nBad object: "+JSON.stringify(oe[ie],null," ")+`
22
+ Valid keys: `+JSON.stringify(Object.keys(V),null," "));var G=ye(D,ne,H,ae,se+"."+ne,n);if(G)return G}return null}return m(K)}function F(V){switch(typeof V){case"number":case"string":case"undefined":return!0;case"boolean":return!V;case"object":if(Array.isArray(V))return V.every(F);if(V===null||d(V))return!0;var K=f(V);if(K){var oe=K.call(V),ie;if(K!==V.entries){for(;!(ie=oe.next()).done;)if(!F(ie.value))return!1}else for(;!(ie=oe.next()).done;){var H=ie.value;if(H&&!F(H[1]))return!1}}else return!1;return!0;default:return!1}}function re(V,K){return V==="symbol"?!0:K?K["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&K instanceof Symbol:!1}function ce(V){var K=typeof V;return Array.isArray(V)?"array":V instanceof RegExp?"object":re(K,V)?"symbol":K}function X(V){if(typeof V>"u"||V===null)return""+V;var K=ce(V);if(K==="object"){if(V instanceof Date)return"date";if(V instanceof RegExp)return"regexp"}return K}function ee(V){var K=X(V);switch(K){case"array":case"object":return"an "+K;case"boolean":case"date":case"regexp":return"a "+K;default:return K}}function fe(V){return!V.constructor||!V.constructor.name?v:V.constructor.name}return S.checkPropTypes=s,S.resetWarningCache=s.resetWarningCache,S.PropTypes=S,S},Tn}var Bn,wi;function Wl(){if(wi)return Bn;wi=1;var e=Yn();function r(){}function n(){}return n.resetWarningCache=r,Bn=function(){function i(l,d,u,h,g,f){if(f!==e){var v=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw v.name="Invariant Violation",v}}i.isRequired=i;function s(){return i}var c={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 c.PropTypes=c,c},Bn}var ki;function Pl(){if(ki)return wo.exports;if(ki=1,process.env.NODE_ENV!=="production"){var e=ys(),r=!0;wo.exports=Rl()(e.isElement,r)}else wo.exports=Wl()();return wo.exports}var Nl=Pl();const oo=$l(Nl);var To={exports:{}},ke={};/**
23
23
  * @license React
24
24
  * react-is.production.js
25
25
  *
@@ -27,7 +27,7 @@ Valid keys: `+JSON.stringify(Object.keys(L),null," "));var G=ye(D,oe,U,se,ie+".
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 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={};/**
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"),c=Symbol.for("react.consumer"),l=Symbol.for("react.context"),d=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"),v=Symbol.for("react.view_transition"),S=Symbol.for("react.client.reference");function B(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 v:return C;default:switch(C=C&&C.$$typeof,C){case l:case d:case f:case g:return C;case c:return C;default:return m}}case r:return m}}}return ke.ContextConsumer=c,ke.ContextProvider=l,ke.Element=e,ke.ForwardRef=d,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 B(C)===c},ke.isContextProvider=function(C){return B(C)===l},ke.isElement=function(C){return typeof C=="object"&&C!==null&&C.$$typeof===e},ke.isForwardRef=function(C){return B(C)===d},ke.isFragment=function(C){return B(C)===n},ke.isLazy=function(C){return B(C)===f},ke.isMemo=function(C){return B(C)===g},ke.isPortal=function(C){return B(C)===r},ke.isProfiler=function(C){return B(C)===s},ke.isStrictMode=function(C){return B(C)===i},ke.isSuspense=function(C){return B(C)===u},ke.isSuspenseList=function(C){return B(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===l||C.$$typeof===c||C.$$typeof===d||C.$$typeof===S||C.getModuleId!==void 0)},ke.typeOf=B,ke}var Te={};/**
31
31
  * @license React
32
32
  * react-is.development.js
33
33
  *
@@ -35,15 +35,15 @@ Valid keys: `+JSON.stringify(Object.keys(L),null," "));var G=ye(D,oe,U,se,ie+".
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 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(`
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 c:case s:case h:case g:case S:return C;default:switch(C=C&&C.$$typeof,C){case d:case u:case v:case f:return C;case l: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"),c=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),d=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"),v=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),B=Symbol.for("react.client.reference");Te.ContextConsumer=l,Te.ContextProvider=d,Te.Element=r,Te.ForwardRef=u,Te.Fragment=i,Te.Lazy=v,Te.Memo=f,Te.Portal=n,Te.Profiler=c,Te.StrictMode=s,Te.Suspense=h,Te.SuspenseList=g,Te.isContextConsumer=function(C){return e(C)===l},Te.isContextProvider=function(C){return e(C)===d},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)===v},Te.isMemo=function(C){return e(C)===f},Te.isPortal=function(C){return e(C)===n},Te.isProfiler=function(C){return e(C)===c},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===c||C===s||C===h||C===g||typeof C=="object"&&C!==null&&(C.$$typeof===v||C.$$typeof===f||C.$$typeof===d||C.$$typeof===l||C.$$typeof===u||C.$$typeof===B||C.getModuleId!==void 0)},Te.typeOf=e})()),Te}var Ii;function Vl(){return Ii||(Ii=1,process.env.NODE_ENV==="production"?To.exports=Ll():To.exports=Fl()),To.exports}var vs=Vl();function rr(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(Vo.isValidElement(e)||vs.isValidElementType(e)||!rr(e))return e;const r={};return Object.keys(e).forEach(n=>{r[n]=Ss(e[n])}),r}function nt(e,r,n={clone:!0}){const i=n.clone?{...e}:e;return rr(e)&&rr(r)&&Object.keys(r).forEach(s=>{Vo.isValidElement(r[s])||vs.isValidElementType(r[s])?i[s]=r[s]:rr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&rr(e[s])?i[s]=nt(e[s],r[s],n):n.clone?i[s]=rr(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,c=Hl(r),l=Object.keys(c);function d(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 h(v,S){const B=l.indexOf(S);return`@media (min-width:${typeof r[v]=="number"?r[v]:v}${n}) and (max-width:${(B!==-1&&typeof r[l[B]]=="number"?r[l[B]]:S)-i/100}${n})`}function g(v){return l.indexOf(v)+1<l.length?h(v,l[l.indexOf(v)+1]):d(v)}function f(v){const S=l.indexOf(v);return S===0?d(l[1]):S===l.length-1?u(l[S]):h(v,l[l.indexOf(v)+1]).replace("@media","@media not all and")}return{keys:l,values:c,up:d,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 l,d;const c=/min-width:\s*([0-9.]+)/;return+(((l=i.match(c))==null?void 0:l[1])||0)-+(((d=s.match(c))==null?void 0:d[1])||0)});return n.length?n.reduce((i,s)=>{const c=r[s];return delete i[s],i[s]=c,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,c=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(c)}function ql(e){const r=(c,l)=>c.replace("@media",l?`@container ${l}`:"@container");function n(c,l){c.up=(...d)=>r(e.breakpoints.up(...d),l),c.down=(...d)=>r(e.breakpoints.down(...d),l),c.between=(...d)=>r(e.breakpoints.between(...d),l),c.only=(...d)=>r(e.breakpoints.only(...d),l),c.not=(...d)=>{const u=r(e.breakpoints.not(...d),l);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=c=>(n(i,c),i);return n(s),{...e,containerQueries:s}}const Jl={borderRadius:4},ir=process.env.NODE_ENV!=="production"?oo.oneOfType([oo.number,oo.string,oo.object,oo.array]):{};function uo(e,r){return r?nt(e,r,{clone:!1}):e}const Go={xs:0,sm:600,md:900,lg:1200,xl:1536},Ei={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${Go[e]}px)`},Kl={containerQueries:e=>({up:r=>{let n=typeof r=="number"?r:Go[r]||r;return typeof n=="number"&&(n=`${n}px`),e?`@container ${e} (min-width:${n})`:`@container (min-width:${n})`}})};function Ut(e,r,n){const i=e.theme||{};if(Array.isArray(r)){const c=i.breakpoints||Ei;return r.reduce((l,d,u)=>(l[c.up(c.keys[u])]=n(r[u]),l),{})}if(typeof r=="object"){const c=i.breakpoints||Ei;return Object.keys(r).reduce((l,d)=>{if(Gl(c.keys,d)){const u=Yl(i.containerQueries?i:Kl,d);u&&(l[u]=n(r[d],d))}else if(Object.keys(c.values||Go).includes(d)){const u=c.up(d);l[u]=n(r[d],d)}else{const u=d;l[u]=r[u]}return l},{})}return n(r)}function Xl(e={}){var n;return((n=e.keys)==null?void 0:n.reduce((i,s)=>{const c=e.up(s);return i[c]={},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.":Sr(7));return e.charAt(0).toUpperCase()+e.slice(1)}function Yo(e,r,n=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&n){const i=`vars.${r}`.split(".").reduce((s,c)=>s&&s[c]?s[c]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function Lo(e,r,n,i=n){let s;return typeof e=="function"?s=e(n):Array.isArray(e)?s=e[n]||i:s=Yo(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,c=l=>{if(l[r]==null)return null;const d=l[r],u=l.theme,h=Yo(u,i)||{};return Ut(l,d,f=>{let v=Lo(h,s,f);return f===v&&typeof f=="string"&&(v=Lo(h,s,`${r}${f==="default"?"":Cs(f)}`,f)),n===!1?v:{[n]:v}})};return c.propTypes=process.env.NODE_ENV!=="production"?{[r]:ir}:{},c.filterProps=[r],c}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(c=>i+c):[i+s]}),qo=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],Jo=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],rc=[...qo,...Jo];function mo(e,r,n,i){const s=Yo(e,r,!0)??n;return typeof s=="number"||typeof s=="string"?c=>typeof c=="string"?c:(process.env.NODE_ENV!=="production"&&typeof c!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${c}.`),typeof s=="string"?s.startsWith("var(")&&c===0?0:s.startsWith("var(")&&c===1?s:`calc(${c} * ${s})`:s*c):Array.isArray(s)?c=>{if(typeof c=="string")return c;const l=Math.abs(c);process.env.NODE_ENV!=="production"&&(Number.isInteger(l)?l>s.length-1&&console.error([`MUI: The value provided (${l}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${l} > ${s.length-1}, you need to add the missing values.`].join(`
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
- `)));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 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
- 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 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.
41
+ `)));const d=s[l];return c>=0?d:typeof d=="number"?-d:typeof d=="string"&&d.startsWith("var(")?`calc(-1 * ${d})`:`-${d}`}:typeof s=="function"?s:(process.env.NODE_ENV!=="production"&&console.error([`MUI: The \`theme.${r}\` value (${s}) is invalid.`,"It should be a number, an array or a function."].join(`
42
+ `)),()=>{})}function qn(e){return mo(e,"spacing",8,"spacing")}function fo(e,r){return typeof r=="string"||r==null?r:e(r)}function oc(e,r){return n=>e.reduce((i,s)=>(i[s]=fo(r,n),i),{})}function nc(e,r,n,i){if(!r.includes(n))return null;const s=tc(n),c=oc(s,i),l=e[n];return Ut(e,l,c)}function js(e,r){const n=qn(e.theme);return Object.keys(e).map(i=>nc(e,r,i,n)).reduce(uo,{})}function Ee(e){return js(e,qo)}Ee.propTypes=process.env.NODE_ENV!=="production"?qo.reduce((e,r)=>(e[r]=ir,e),{}):{};Ee.filterProps=qo;function De(e){return js(e,Jo)}De.propTypes=process.env.NODE_ENV!=="production"?Jo.reduce((e,r)=>(e[r]=ir,e),{}):{};De.filterProps=Jo;process.env.NODE_ENV!=="production"&&rc.reduce((e,r)=>(e[r]=ir,e),{});function ws(e=8,r=qn({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(c=>{const l=r(c);return typeof l=="number"?`${l}px`:l}).join(" "));return n.mui=!0,n}function Ko(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(c=>{i[c]=s}),i),{}),n=i=>Object.keys(i).reduce((s,c)=>r[c]?uo(s,r[c](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 ft(e){return typeof e!="number"?e:`${e}px solid`}function gt(e,r){return _e({prop:e,themeKey:"borders",transform:r})}const ic=gt("border",ft),sc=gt("borderTop",ft),ac=gt("borderRight",ft),lc=gt("borderBottom",ft),cc=gt("borderLeft",ft),dc=gt("borderColor"),uc=gt("borderTopColor"),pc=gt("borderRightColor"),xc=gt("borderBottomColor"),mc=gt("borderLeftColor"),fc=gt("outline",ft),hc=gt("outlineColor"),Xo=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=mo(e.theme,"shape.borderRadius",4,"borderRadius"),n=i=>({borderRadius:fo(r,i)});return Ut(e,e.borderRadius,n)}return null};Xo.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:ir}:{};Xo.filterProps=["borderRadius"];Ko(ic,sc,ac,lc,cc,dc,uc,pc,xc,mc,Xo,fc,hc);const Qo=e=>{if(e.gap!==void 0&&e.gap!==null){const r=mo(e.theme,"spacing",8,"gap"),n=i=>({gap:fo(r,i)});return Ut(e,e.gap,n)}return null};Qo.propTypes=process.env.NODE_ENV!=="production"?{gap:ir}:{};Qo.filterProps=["gap"];const Zo=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=mo(e.theme,"spacing",8,"columnGap"),n=i=>({columnGap:fo(r,i)});return Ut(e,e.columnGap,n)}return null};Zo.propTypes=process.env.NODE_ENV!=="production"?{columnGap:ir}:{};Zo.filterProps=["columnGap"];const en=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=mo(e.theme,"spacing",8,"rowGap"),n=i=>({rowGap:fo(r,i)});return Ut(e,e.rowGap,n)}return null};en.propTypes=process.env.NODE_ENV!=="production"?{rowGap:ir}:{};en.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"});Ko(Qo,Zo,en,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});Ko(Tc,Bc,Ic);function tt(e){return e<=1&&e!==0?`${e*100}%`:e}const zc=_e({prop:"width",transform:tt}),Jn=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=n=>{var s,c,l,d,u;const i=((l=(c=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:c.values)==null?void 0:l[n])||Go[n];return i?((u=(d=e.theme)==null?void 0:d.breakpoints)==null?void 0:u.unit)!=="px"?{maxWidth:`${i}${e.theme.breakpoints.unit}`}:{maxWidth:i}:{maxWidth:tt(n)}};return Ut(e,e.maxWidth,r)}return null};Jn.filterProps=["maxWidth"];const Ec=_e({prop:"minWidth",transform:tt}),Dc=_e({prop:"height",transform:tt}),$c=_e({prop:"maxHeight",transform:tt}),Oc=_e({prop:"minHeight",transform:tt});_e({prop:"size",cssProperty:"width",transform:tt});_e({prop:"size",cssProperty:"height",transform:tt});const _c=_e({prop:"boxSizing"});Ko(zc,Jn,Ec,Dc,$c,Oc,_c);const tn={border:{themeKey:"borders",transform:ft},borderTop:{themeKey:"borders",transform:ft},borderRight:{themeKey:"borders",transform:ft},borderBottom:{themeKey:"borders",transform:ft},borderLeft:{themeKey:"borders",transform:ft},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:ft},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Xo},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:Qo},rowGap:{style:en},columnGap:{style:Zo},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:tt},maxWidth:{style:Jn},minWidth:{transform:tt},height:{transform:tt},maxHeight:{transform:tt},minHeight:{transform:tt},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 Mc(...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 Rc(){function e(n,i,s,c){const l={[n]:i,theme:s},d=c[n];if(!d)return{[n]:i};const{cssProperty:u=n,themeKey:h,transform:g,style:f}=d;if(i==null)return null;if(h==="typography"&&i==="inherit")return{[n]:i};const v=Yo(s,h)||{};return f?f(l):Ut(l,i,B=>{let C=Lo(v,g,B);return B===C&&typeof B=="string"&&(C=Lo(v,g,`${n}${B==="default"?"":Cs(B)}`,B)),u===!1?C:{[u]:C}})}function r(n){const{sx:i,theme:s={},nested:c}=n||{};if(!i)return null;const l=s.unstable_sxConfig??tn;function d(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 v=g;return Object.keys(h).forEach(S=>{const B=Ac(h[S],s);if(B!=null)if(typeof B=="object")if(l[S])v=uo(v,e(S,B,s,l));else{const C=Ut({theme:s},B,m=>({[S]:m}));Mc(C,B)?v[S]=r({sx:B,theme:s,nested:!0}):v=uo(v,C)}else v=uo(v,e(S,B,s,l))}),!c&&s.modularCssLayers?{"@layer sx":zi(s,Di(f,v))}:zi(s,Di(f,v))}return Array.isArray(i)?i.map(d):d(i)}return r}const rn=Rc();rn.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:c={},...l}=e,d=Ul(n),u=ws(s);let h=nt({breakpoints:d,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...Jl,...c}},l);return h=ql(h),h.applyStyles=Wc,h=r.reduce((g,f)=>nt(g,f),h),h.unstable_sxConfig={...tn,...l==null?void 0:l.unstable_sxConfig},h.unstable_sx=function(f){return rn({sx:f,theme:this})},h}function Pc(e){return Object.keys(e).length===0}function Nc(e=null){const r=Vo.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 Kn(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 nr(e){if(e.type)return e;if(e.charAt(0)==="#")return nr(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
+ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Sr(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.`:Sr(10,s))}else i=i.split(",");return i=i.map(c=>parseFloat(c)),{type:n,values:i,colorSpace:s}}const Jc=e=>{const r=nr(e);return r.values.slice(0,3).map((n,i)=>r.type.includes("hsl")&&i!==0?`${n}%`:n).join(" ")},ao=(e,r)=>{try{return Jc(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function on(e){const{type:r,colorSpace:n}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,c)=>c<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=nr(e);const{values:r}=e,n=r[0],i=r[1]/100,s=r[2]/100,c=i*Math.min(s,1-s),l=(h,g=(h+n/30)%12)=>s-c*Math.max(Math.min(g-3,9-g,1),-1);let d="rgb";const u=[Math.round(l(0)*255),Math.round(l(8)*255),Math.round(l(4)*255)];return e.type==="hsla"&&(d+="a",u.push(r[3])),on({type:d,values:u})}function _n(e){e=nr(e);let r=e.type==="hsl"||e.type==="hsla"?nr(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=_n(e),i=_n(r);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function I(e,r){return e=nr(e),r=Kn(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,on(e)}function br(e,r,n){try{return I(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function nn(e,r){if(e=nr(e),r=Kn(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 on(e)}function je(e,r,n){try{return nn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function sn(e,r){if(e=nr(e),r=Kn(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 on(e)}function we(e,r,n){try{return sn(e,r)}catch{return n&&process.env.NODE_ENV!=="production"&&console.warn(n),e}}function Kc(e,r=.15){return _n(e)>.5?nn(e,r):sn(e,r)}function Bo(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 Mi=(e,r,n,i=[])=>{let s=e;r.forEach((c,l)=>{l===r.length-1?Array.isArray(s)?s[Number(c)]=n:s&&typeof s=="object"&&(s[c]=n):s&&typeof s=="object"&&(s[c]||(s[c]=i.includes(c)?[]:{}),s=s[c])})},Qc=(e,r,n)=>{function i(s,c=[],l=[]){Object.entries(s).forEach(([d,u])=>{(!n||n&&!n([...c,d]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...c,d],Array.isArray(u)?[...l,d]:l):r([...c,d],u,l))})}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 In(e,r){const{prefix:n,shouldSkipGeneratingVar:i}=r||{},s={},c={},l={};return Qc(e,(d,u,h)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(d,u))){const g=`--${n?`${n}-`:""}${d.join("-")}`,f=Zc(d,u);Object.assign(s,{[g]:f}),Mi(c,d,`var(${g})`,h),Mi(l,d,`var(${g}, ${f})`,h)}},d=>d[0]==="vars"),{css:s,vars:c,varsWithDefaults:l}}function ed(e,r={}){const{getSelector:n=j,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:c}=r,{colorSchemes:l={},components:d,defaultColorScheme:u="light",...h}=e,{vars:g,css:f,varsWithDefaults:v}=In(h,r);let S=v;const B={},{[u]:C,...m}=l;if(Object.entries(m||{}).forEach(([b,k])=>{const{vars:R,css:a,varsWithDefaults:$}=In(k,r);S=nt(S,$),B[b]={css:a,vars:R}}),C){const{css:b,vars:k,varsWithDefaults:R}=In(C,r);S=nt(S,R),B[u]={css:b,vars:k}}function j(b,k){var a,$;let R=s;if(s==="class"&&(R=".%s"),s==="data"&&(R="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(R=`[${s}="%s"]`),b){if(R==="media")return e.defaultColorScheme===b?":root":{[`@media (prefers-color-scheme: ${(($=(a=l[b])==null?void 0:a.palette)==null?void 0:$.mode)||b})`]:{":root":k}};if(R)return e.defaultColorScheme===b?`:root, ${R.replace("%s",String(b))}`:R.replace("%s",String(b))}return":root"}return{vars:S,generateThemeVars:()=>{let b={...g};return Object.entries(B).forEach(([,{vars:k}])=>{b=nt(b,k)}),b},generateStyleSheets:()=>{var W,J;const b=[],k=e.defaultColorScheme||"light";function R(te,x){Object.keys(x).length&&b.push(typeof te=="string"?{[te]:{...x}}:te)}R(n(void 0,{...f}),f);const{[k]:a,...$}=B;if(a){const{css:te}=a,x=(J=(W=l[k])==null?void 0:W.palette)==null?void 0:J.mode,P=!i&&x?{colorScheme:x,...te}:{...te};R(n(k,{...P}),P)}return Object.entries($).forEach(([te,{css:x}])=>{var re,ce;const P=(ce=(re=l[te])==null?void 0:re.palette)==null?void 0:ce.mode,F=!i&&P?{colorScheme:P,...x}:{...x};R(n(te,{...F}),F)}),c&&b.push({":root":{"--__l-threshold":"0.7","--__l":"clamp(0, (l / var(--__l-threshold) - 1) * -infinity, 1)","--__a":"clamp(0.87, (l / var(--__l-threshold) - 1) * -infinity, 1)"}}),b}}}function 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 xo={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"},no={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:xo.white,default:xo.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:xo.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:xo.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 Mn=zs();function Ai(e,r,n,i){const s=i.light||i,c=i.dark||i*1.5;e[r]||(e.hasOwnProperty(n)?e[r]=e[n]:r==="light"?e.light=sn(e.main,s):r==="dark"&&(e.dark=nn(e.main,c)))}function Ri(e,r,n,i,s){const c=s.light||s,l=s.dark||s*1.5;r[n]||(r.hasOwnProperty(i)?r[n]=r[i]:n==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(c*100).toFixed(0)}%)`:n==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(l*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:no[400],light:no[300],dark:no[700]}:{main:"#ed6c02",light:no[500],dark:no[900]}}function cd(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function Xn(e){const{mode:r="light",contrastThreshold:n=3,tonalOffset:i=.2,colorSpace:s,...c}=e,l=e.primary||od(r),d=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 v(m){if(s)return cd(m);const j=_i(m,Mn.text.primary)>=n?Mn.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 S=({color:m,name:j,mainShade:y=500,lightShade:O=300,darkShade:b=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.`:Sr(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
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?
@@ -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,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';
59
+ } });`:Sr(12,j?` (${j})`:"",JSON.stringify(m.main)));return s?(Ri(s,m,"light",O,i),Ri(s,m,"dark",b,i)):(Ai(m,"light",O,i),Ai(m,"dark",b,i)),m.contrastText||(m.contrastText=v(m.main)),m};let B;return r==="light"?B=Bs():r==="dark"&&(B=zs()),process.env.NODE_ENV!=="production"&&(B||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),nt({common:{...xo},mode:r,primary:S({color:l,name:"primary"}),secondary:S({color:d,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:S({color:u,name:"error"}),warning:S({color:f,name:"warning"}),info:S({color:h,name:"info"}),success:S({color:g,name:"success"}),grey:rd,contrastThreshold:n,getContrastText:v,augmentColor:S,tonalOffset:i,...B},c)}function dd(e){const r={};return Object.entries(e).forEach(i=>{const[s,c]=i;typeof c=="object"&&(r[s]=`${c.fontStyle?`${c.fontStyle} `:""}${c.fontVariant?`${c.fontVariant} `:""}${c.fontWeight?`${c.fontWeight} `:""}${c.fontStretch?`${c.fontStretch} `:""}${c.fontSize||""}${c.lineHeight?`/${c.lineHeight} `:""}${c.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:c=400,fontWeightMedium:l=500,fontWeightBold:d=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 v=i/14,S=g||(m=>`${m/u*v}rem`),B=(m,j,y,O,b)=>({fontFamily:n,fontWeight:m,fontSize:S(j),lineHeight:y,...n===Pi?{letterSpacing:`${pd(O/j)}em`}:{},...b,...h}),C={h1:B(s,96,1.167,-1.5),h2:B(s,60,1.2,-.5),h3:B(c,48,1.167,0),h4:B(c,34,1.235,.25),h5:B(c,24,1.334,0),h6:B(l,20,1.6,.15),subtitle1:B(c,16,1.75,.15),subtitle2:B(l,14,1.57,.1),body1:B(c,16,1.5,.15),body2:B(c,14,1.43,.15),button:B(l,14,1.75,.4,Wi),caption:B(c,12,1.66,.4),overline:B(c,12,2.66,1,Wi),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return nt({htmlFontSize:u,pxToRem:S,fontFamily:n,fontSize:i,fontWeightLight:s,fontWeightRegular:c,fontWeightMedium:l,fontWeightBold:d,...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"],c={})=>{const{duration:l=n.standard,easing:d=r.easeInOut,delay:u=0,...h}=c;if(process.env.NODE_ENV!=="production"){const g=v=>typeof v=="string",f=v=>!Number.isNaN(parseFloat(v));!g(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!f(l)&&!g(l)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${l}.`),g(d)||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 c!="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 l=="string"?l:Ni(l)} ${d} ${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 rr(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 c=0;c<s.length;c++){const[l,d]=s[c];!jd(d)||l.startsWith("unstable_")?delete i[l]:rr(d)&&(i[l]={...d},n(i[l]))}}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 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:`[
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})`:I(r,wd(n))},lighten(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${Li(n)})`:sn(r,n)},darken(r,n){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${Li(n)})`:nn(r,n)}})}function An(e={},...r){const{breakpoints:n,mixins:i={},spacing:s,palette:c={},transitions:l={},typography:d={},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.":Sr(20));const f=Xn({...c,colorSpace:h}),v=ks(e);let S=nt(v,{mixins:ud(v.breakpoints,i),palette:f,shadows:gd.slice(),typography:xd(f,d),transitions:Sd(l),zIndex:{...Cd}});if(S=nt(S,g),S=r.reduce((B,C)=>nt(B,C),S),process.env.NODE_ENV!=="production"){const B=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],C=(m,j)=>{let y;for(y in m){const O=m[y];if(B.includes(y)&&Object.keys(O).length>0){if(process.env.NODE_ENV!=="production"){const b=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 '&.${b}' syntax:`,JSON.stringify({root:{[`&.${b}`]:O}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
68
+ `))}m[y]={}}}};Object.keys(S.components).forEach(m=>{const j=S.components[m].styleOverrides;j&&m.startsWith("Mui")&&C(j,m)})}return S.unstable_sxConfig={...tn,...g==null?void 0:g.unstable_sxConfig},S.unstable_sx=function(C){return rn({sx:C,theme:this})},S.toRuntimeSource=Es,kd(S),S}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,...c}=e,l=Xn({...r,colorSpace:s});return{palette:l,opacity:{...Ds(l.mode),...n},overlays:i||$s(l.mode),...c}}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 c=s;if(s==="class"&&(c=".%s"),s==="data"&&(c="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(c=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const l={};return Ed(e.cssVarPrefix).forEach(d=>{l[d]=n[d],delete n[d]}),c==="media"?{[i]:n,"@media (prefers-color-scheme: dark)":{[i]:l}}:c?{[c.replace("%s",r)]:l,[`${i}, ${c.replace("%s",r)}`]:n}:{[i]:{...n,...l}}}if(c&&c!=="media")return`${i}, ${c.replace("%s",String(r))}`}else if(r){if(c==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:n}};if(c)return c.replace("%s",String(r))}return i};function $d(e,r){r.forEach(n=>{e[n]||(e[n]={})})}function A(e,r,n){!e[r]&&n&&(e[r]=n)}function lo(e){return typeof e!="string"||!e.startsWith("hsl")?e:Ts(e)}function Vt(e,r){`${r}Channel`in e||(e[`${r}Channel`]=ao(lo(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 zn(e,r,n,i,s){if(!n)return;n=n===!0?{}:n;const c=s==="dark"?"dark":"light";if(!i){r[s]=Id({...n,palette:{mode:c,...n==null?void 0:n.palette},colorSpace:e});return}const{palette:l,...d}=An({...i,palette:{mode:c,...n==null?void 0:n.palette},colorSpace:e});return r[s]={...n,palette:l,opacity:{...Ds(c),...n==null?void 0:n.opacity},overlays:(n==null?void 0:n.overlays)||$s(c)},d}function Md(e={},...r){const{colorSchemes:n={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:c="mui",nativeColor:l=!1,shouldSkipGeneratingVar:d=zd,colorSchemeSelector:u=n.light&&n.dark?"media":void 0,rootSelector:h=":root",...g}=e,f=Object.keys(n)[0],v=i||(n.light&&f!=="light"?"light":f),S=_d(c),{[v]:B,light:C,dark:m,...j}=n,y={...j};let O=B;if((v==="dark"&&!("dark"in n)||v==="light"&&!("light"in n))&&(O=!0),!O)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${v}\` option is either missing or invalid.`:Sr(21,v));let b;l&&(b="oklch");const k=zn(b,y,O,g,v);C&&!y.light&&zn(b,y,C,void 0,"light"),m&&!y.dark&&zn(b,y,m,void 0,"dark");let R={defaultColorScheme:v,...k,cssVarPrefix:c,colorSchemeSelector:u,rootSelector:h,getCssVar:S,colorSchemes:y,font:{...dd(k.typography),...k.font},spacing:Od(g.spacing)};Object.keys(R.colorSchemes).forEach(te=>{const x=R.colorSchemes[te].palette,P=re=>{const ce=re.split("-"),X=ce[1],ee=ce[2];return S(re,x[X][ee])};x.mode==="light"&&(A(x.common,"background","#fff"),A(x.common,"onBackground","#000")),x.mode==="dark"&&(A(x.common,"background","#000"),A(x.common,"onBackground","#fff"));function F(re,ce,X){if(b){let ee;return re===br&&(ee=`transparent ${((1-X)*100).toFixed(0)}%`),re===je&&(ee=`#000 ${(X*100).toFixed(0)}%`),re===we&&(ee=`#fff ${(X*100).toFixed(0)}%`),`color-mix(in ${b}, ${ce}, ${ee})`}return re(ce,X)}if($d(x,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),x.mode==="light"){A(x.Alert,"errorColor",F(je,x.error.light,.6)),A(x.Alert,"infoColor",F(je,x.info.light,.6)),A(x.Alert,"successColor",F(je,x.success.light,.6)),A(x.Alert,"warningColor",F(je,x.warning.light,.6)),A(x.Alert,"errorFilledBg",P("palette-error-main")),A(x.Alert,"infoFilledBg",P("palette-info-main")),A(x.Alert,"successFilledBg",P("palette-success-main")),A(x.Alert,"warningFilledBg",P("palette-warning-main")),A(x.Alert,"errorFilledColor",Dt(()=>x.getContrastText(x.error.main))),A(x.Alert,"infoFilledColor",Dt(()=>x.getContrastText(x.info.main))),A(x.Alert,"successFilledColor",Dt(()=>x.getContrastText(x.success.main))),A(x.Alert,"warningFilledColor",Dt(()=>x.getContrastText(x.warning.main))),A(x.Alert,"errorStandardBg",F(we,x.error.light,.9)),A(x.Alert,"infoStandardBg",F(we,x.info.light,.9)),A(x.Alert,"successStandardBg",F(we,x.success.light,.9)),A(x.Alert,"warningStandardBg",F(we,x.warning.light,.9)),A(x.Alert,"errorIconColor",P("palette-error-main")),A(x.Alert,"infoIconColor",P("palette-info-main")),A(x.Alert,"successIconColor",P("palette-success-main")),A(x.Alert,"warningIconColor",P("palette-warning-main")),A(x.AppBar,"defaultBg",P("palette-grey-100")),A(x.Avatar,"defaultBg",P("palette-grey-400")),A(x.Button,"inheritContainedBg",P("palette-grey-300")),A(x.Button,"inheritContainedHoverBg",P("palette-grey-A100")),A(x.Chip,"defaultBorder",P("palette-grey-400")),A(x.Chip,"defaultAvatarColor",P("palette-grey-700")),A(x.Chip,"defaultIconColor",P("palette-grey-700")),A(x.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),A(x.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),A(x.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),A(x.LinearProgress,"primaryBg",F(we,x.primary.main,.62)),A(x.LinearProgress,"secondaryBg",F(we,x.secondary.main,.62)),A(x.LinearProgress,"errorBg",F(we,x.error.main,.62)),A(x.LinearProgress,"infoBg",F(we,x.info.main,.62)),A(x.LinearProgress,"successBg",F(we,x.success.main,.62)),A(x.LinearProgress,"warningBg",F(we,x.warning.main,.62)),A(x.Skeleton,"bg",b?F(br,x.text.primary,.11):`rgba(${P("palette-text-primaryChannel")} / 0.11)`),A(x.Slider,"primaryTrack",F(we,x.primary.main,.62)),A(x.Slider,"secondaryTrack",F(we,x.secondary.main,.62)),A(x.Slider,"errorTrack",F(we,x.error.main,.62)),A(x.Slider,"infoTrack",F(we,x.info.main,.62)),A(x.Slider,"successTrack",F(we,x.success.main,.62)),A(x.Slider,"warningTrack",F(we,x.warning.main,.62));const re=b?F(je,x.background.default,.6825):Bo(x.background.default,.8);A(x.SnackbarContent,"bg",re),A(x.SnackbarContent,"color",Dt(()=>b?Mn.text.primary:x.getContrastText(re))),A(x.SpeedDialAction,"fabHoverBg",Bo(x.background.paper,.15)),A(x.StepConnector,"border",P("palette-grey-400")),A(x.StepContent,"border",P("palette-grey-400")),A(x.Switch,"defaultColor",P("palette-common-white")),A(x.Switch,"defaultDisabledColor",P("palette-grey-100")),A(x.Switch,"primaryDisabledColor",F(we,x.primary.main,.62)),A(x.Switch,"secondaryDisabledColor",F(we,x.secondary.main,.62)),A(x.Switch,"errorDisabledColor",F(we,x.error.main,.62)),A(x.Switch,"infoDisabledColor",F(we,x.info.main,.62)),A(x.Switch,"successDisabledColor",F(we,x.success.main,.62)),A(x.Switch,"warningDisabledColor",F(we,x.warning.main,.62)),A(x.TableCell,"border",F(we,F(br,x.divider,1),.88)),A(x.Tooltip,"bg",F(br,x.grey[700],.92))}if(x.mode==="dark"){A(x.Alert,"errorColor",F(we,x.error.light,.6)),A(x.Alert,"infoColor",F(we,x.info.light,.6)),A(x.Alert,"successColor",F(we,x.success.light,.6)),A(x.Alert,"warningColor",F(we,x.warning.light,.6)),A(x.Alert,"errorFilledBg",P("palette-error-dark")),A(x.Alert,"infoFilledBg",P("palette-info-dark")),A(x.Alert,"successFilledBg",P("palette-success-dark")),A(x.Alert,"warningFilledBg",P("palette-warning-dark")),A(x.Alert,"errorFilledColor",Dt(()=>x.getContrastText(x.error.dark))),A(x.Alert,"infoFilledColor",Dt(()=>x.getContrastText(x.info.dark))),A(x.Alert,"successFilledColor",Dt(()=>x.getContrastText(x.success.dark))),A(x.Alert,"warningFilledColor",Dt(()=>x.getContrastText(x.warning.dark))),A(x.Alert,"errorStandardBg",F(je,x.error.light,.9)),A(x.Alert,"infoStandardBg",F(je,x.info.light,.9)),A(x.Alert,"successStandardBg",F(je,x.success.light,.9)),A(x.Alert,"warningStandardBg",F(je,x.warning.light,.9)),A(x.Alert,"errorIconColor",P("palette-error-main")),A(x.Alert,"infoIconColor",P("palette-info-main")),A(x.Alert,"successIconColor",P("palette-success-main")),A(x.Alert,"warningIconColor",P("palette-warning-main")),A(x.AppBar,"defaultBg",P("palette-grey-900")),A(x.AppBar,"darkBg",P("palette-background-paper")),A(x.AppBar,"darkColor",P("palette-text-primary")),A(x.Avatar,"defaultBg",P("palette-grey-600")),A(x.Button,"inheritContainedBg",P("palette-grey-800")),A(x.Button,"inheritContainedHoverBg",P("palette-grey-700")),A(x.Chip,"defaultBorder",P("palette-grey-700")),A(x.Chip,"defaultAvatarColor",P("palette-grey-300")),A(x.Chip,"defaultIconColor",P("palette-grey-300")),A(x.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),A(x.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),A(x.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),A(x.LinearProgress,"primaryBg",F(je,x.primary.main,.5)),A(x.LinearProgress,"secondaryBg",F(je,x.secondary.main,.5)),A(x.LinearProgress,"errorBg",F(je,x.error.main,.5)),A(x.LinearProgress,"infoBg",F(je,x.info.main,.5)),A(x.LinearProgress,"successBg",F(je,x.success.main,.5)),A(x.LinearProgress,"warningBg",F(je,x.warning.main,.5)),A(x.Skeleton,"bg",b?F(br,x.text.primary,.13):`rgba(${P("palette-text-primaryChannel")} / 0.13)`),A(x.Slider,"primaryTrack",F(je,x.primary.main,.5)),A(x.Slider,"secondaryTrack",F(je,x.secondary.main,.5)),A(x.Slider,"errorTrack",F(je,x.error.main,.5)),A(x.Slider,"infoTrack",F(je,x.info.main,.5)),A(x.Slider,"successTrack",F(je,x.success.main,.5)),A(x.Slider,"warningTrack",F(je,x.warning.main,.5));const re=b?F(we,x.background.default,.985):Bo(x.background.default,.98);A(x.SnackbarContent,"bg",re),A(x.SnackbarContent,"color",Dt(()=>b?Is.text.primary:x.getContrastText(re))),A(x.SpeedDialAction,"fabHoverBg",Bo(x.background.paper,.15)),A(x.StepConnector,"border",P("palette-grey-600")),A(x.StepContent,"border",P("palette-grey-600")),A(x.Switch,"defaultColor",P("palette-grey-300")),A(x.Switch,"defaultDisabledColor",P("palette-grey-600")),A(x.Switch,"primaryDisabledColor",F(je,x.primary.main,.55)),A(x.Switch,"secondaryDisabledColor",F(je,x.secondary.main,.55)),A(x.Switch,"errorDisabledColor",F(je,x.error.main,.55)),A(x.Switch,"infoDisabledColor",F(je,x.info.main,.55)),A(x.Switch,"successDisabledColor",F(je,x.success.main,.55)),A(x.Switch,"warningDisabledColor",F(je,x.warning.main,.55)),A(x.TableCell,"border",F(je,F(br,x.divider,1),.68)),A(x.Tooltip,"bg",F(br,x.grey[700],.92))}Vt(x.background,"default"),Vt(x.background,"paper"),Vt(x.common,"background"),Vt(x.common,"onBackground"),Vt(x,"divider"),Object.keys(x).forEach(re=>{const ce=x[re];re!=="tonalOffset"&&ce&&typeof ce=="object"&&(ce.main&&A(x[re],"mainChannel",ao(lo(ce.main))),ce.light&&A(x[re],"lightChannel",ao(lo(ce.light))),ce.dark&&A(x[re],"darkChannel",ao(lo(ce.dark))),ce.contrastText&&A(x[re],"contrastTextChannel",ao(lo(ce.contrastText))),re==="text"&&(Vt(x[re],"primary"),Vt(x[re],"secondary")),re==="action"&&(ce.active&&Vt(x[re],"active"),ce.selected&&Vt(x[re],"selected")))})}),R=r.reduce((te,x)=>nt(te,x),R);const a={prefix:c,disableCssColorScheme:s,shouldSkipGeneratingVar:d,getSelector:Dd(R),enableContrastVars:l},{vars:$,generateThemeVars:W,generateStyleSheets:J}=ed(R,a);return R.vars=$,Object.entries(R.colorSchemes[R.defaultColorScheme]).forEach(([te,x])=>{R[te]=x}),R.generateThemeVars=W,R.generateStyleSheets=J,R.generateSpacing=function(){return ws(g.spacing,qn(this))},R.getColorSchemeSelector=td(u),R.spacing=R.generateSpacing(),R.shouldSkipGeneratingVar=d,R.unstable_sxConfig={...tn,...g==null?void 0:g.unstable_sxConfig},R.unstable_sx=function(x){return rn({sx:x,theme:this})},R.toRuntimeSource=Es,R}function Fi(e,r,n){e.colorSchemes&&n&&(e.colorSchemes[r]={...n!==!0&&n,palette:Xn({...n===!0?{}:n.palette,mode:r})})}function Ad(e={},...r){const{palette:n,cssVariables:i=!1,colorSchemes:s=n?void 0:{light:!0},defaultColorScheme:c=n==null?void 0:n.mode,...l}=e,d=c||"light",u=s==null?void 0:s[d],h={...s,...n?{[d]:{...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[d]&&(h[d]!==!0?g=h[d].palette:d==="dark"&&(g={mode:"dark"}));const f=An({...e,palette:g},...r);return f.defaultColorScheme=d,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)&&d==="light"&&(h.light=!0),Md({...l,colorSchemes:h,defaultColorScheme:d,...typeof i!="boolean"&&i},...r)}const Rd=Ad();function it(){const e=Fc(Rd);return process.env.NODE_ENV!=="production"&&Vo.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,c=setTimeout(()=>s.abort(),3e4);let l;try{l=await fetch(e,{headers:i,signal:s.signal})}catch(h){throw clearTimeout(c),(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(c)}if(l.status===401)throw new Error("Authentication failed (401) — check your API key");if(!l.ok)throw new Error(`API error ${l.status}: ${l.statusText}`);let d;try{d=await l.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(d))u=d;else if(n&&d[n]&&Array.isArray(d[n]))u=d[n];else{const g=["data","results","items","records"].find(f=>d[f]&&Array.isArray(d[f]));if(g)u=d[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 ${I(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 le(e,r){return Pd(e,Nd[r])}function He(e){return`${Number(e.shape.borderRadius)*1.5}px`}function ho(e){return`${Number(e.shape.borderRadius)}px`}function Ld({isOpen:e,onClose:r,onCreate:n,preloadedData:i,preloadedDataLabel:s}){const[c,l]=p.useState(""),[d,u]=p.useState(!1),[h,g]=p.useState(""),[f,v]=p.useState(null),[S,B]=p.useState(null),[C,m]=p.useState(!1),[j,y]=p.useState(""),O=p.useRef(null),[b,k]=p.useState("json"),[R,a]=p.useState(""),[$,W]=p.useState(""),[J,te]=p.useState(""),[x,P]=p.useState("idle"),[F,re]=p.useState(""),[ce,X]=p.useState(null),[ee,fe]=p.useState(0),V=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 ue=await D.text();let ne;try{ne=JSON.parse(ue)}catch{y("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(ne)){y("JSON must be an array of objects");return}if(ne.length===0){y("No data rows found in JSON file");return}v(D),B(ne)}catch{y("Network error — please try again")}},K=D=>{D.preventDefault();const Z=D.dataTransfer.files[0];Z&&V(Z)},oe=async()=>{if(R.trim()){P("loading"),re("");try{const D=await Wd(R.trim(),$.trim()||void 0,J.trim()||void 0);X(D.data),fe(D.data.length),P("ready")}catch(D){re((D==null?void 0:D.message)||"Connection failed"),P("error")}}},ie=()=>{if(!c.trim()){u(!0);return}const D=b==="api"?ce:i||S;D&&(n(c.trim(),h.trim(),D),H())},H=()=>{l(""),u(!1),g(""),v(null),B(null),y(""),k("json"),a(""),W(""),te(""),P("idle"),re(""),X(null),fe(0),r()},ae=i||S,se=d&&!c.trim();return c.trim(),t.jsxs(t.Fragment,{children:[t.jsxs(o.Dialog,{open:e,onClose:H,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:D=>He(D),width:480,maxHeight:"min(720px, calc(100vh - 120px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:D=>le(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:H,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:c,onChange:D=>{l(D.target.value),d&&D.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:se,helperText:se?"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:b==="json"?0:1,onChange:(D,Z)=>{k(Z===0?"json":"api"),P("idle"),re("")},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}})]}),b==="json"&&t.jsx(o.Box,{children:i?t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:D=>I(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=>I(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=O.current)==null?void 0:D.click()},sx:{position:"relative",border:"1.5px",borderStyle:S?"solid":"dashed",borderColor:S?"success.main":j?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:S?D=>I(D.palette.success.main,.04):j?D=>I(D.palette.error.main,.04):D=>I(D.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:S?D=>I(D.palette.success.main,.08):j?D=>I(D.palette.error.main,.08):D=>I(D.palette.primary.main,.08),borderColor:S?"success.dark":j?"error.dark":"primary.dark"}},children:[t.jsx(o.Box,{component:"input",ref:O,type:"file",accept:".json",sx:{display:"none"},onChange:D=>{var Z;return((Z=D.target.files)==null?void 0:Z[0])&&V(D.target.files[0])}}),S?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:.75,animation:"fadeIn 0.2s ease-in","@keyframes fadeIn":{from:{opacity:0,transform:"scale(0.98)"},to:{opacity:1,transform:"scale(1)"}}},children:[t.jsx(o.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:D=>I(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=>I(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=>I(D.palette.error.main,.08),border:1,borderColor:D=>I(D.palette.error.main,.2)},children:t.jsx(o.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:j})})]})]})]})}),b==="api"&&t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx(o.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:R,onChange:D=>{a(D.target.value),P("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:D=>W(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=>te(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:!R.trim()||x==="loading",onClick:oe,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=>I(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=>I(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:[ee.toLocaleString()," records loaded — ready to create"]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:R})]})]}),x==="error"&&t.jsxs(o.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:D=>I(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:F})]})]})]})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:2,gap:1,borderTop:"1px solid",borderColor:"divider"},children:[t.jsx(o.Button,{onClick:H,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:D=>`${D.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:D=>I(D.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(o.Button,{onClick:ie,disabled:b==="json"&&!ae||b==="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:()=>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:`[
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=>He(n),maxHeight:"min(640px, calc(100vh - 180px))",my:"auto",boxShadow:n=>le(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=>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.
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=>le(n,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:n=>le(n,"hoverButton")},"&:active":{boxShadow:n=>le(n,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"})})]}):null}function Fd({onFileUpload:e,onError:r,isUploading:n}){const[i,s]=p.useState(!1),[c,l]=p.useState(""),[d,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}l(j.name);try{const O=await j.text();let b;try{b=JSON.parse(O)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(b)){r("JSON must be an array of objects");return}if(b.length===0){r("No data rows found in JSON file");return}e(b)}catch{r("Network error — please try again")}finally{l("")}},f=j=>{j.preventDefault(),s(!0)},v=j=>{j.preventDefault(),s(!1)},S=j=>{j.preventDefault(),s(!1);const y=j.dataTransfer.files[0];y&&g(y)},B=()=>{var j;(j=h.current)==null||j.click()},C=j=>{var O;const y=(O=j.target.files)==null?void 0:O[0];y&&g(y)},m=j=>{j.stopPropagation(),u(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(o.Box,{onDragOver:f,onDragLeave:v,onDrop:S,onPaste:j=>j.preventDefault(),onClick:B,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:i?"primary.main":"divider",bgcolor:i?j=>I(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..."}),c&&t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:c})]}):t.jsxs(t.Fragment,{children:[t.jsx(o.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:j=>I(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:d,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=>I(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=>I(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=>I(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=>I(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:c,disabled:l}){const[d,u]=p.useState(!1),[h,g]=p.useState(!1),[f,v]=p.useState(-1),S=p.useRef(null),B=p.useRef(null);p.useEffect(()=>{function $(W){S.current&&!S.current.contains(W.target)&&(u(!1),g(!1))}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);const C=p.useCallback(()=>{g(!0),v(-1),n.length>0&&u(!0)},[n.length]),m=p.useCallback($=>{r($),v(-1)},[r]),j=p.useCallback($=>{var W;r($),i($),u(!1),(W=B.current)==null||W.blur()},[r,i]),y=p.useCallback($=>{v(-1),j($)},[j]),O=p.useCallback($=>{var W;$.key==="Enter"?f>=0&&f<n.length?($.preventDefault(),y(n[f].query)):e.trim()&&j(e.trim()):$.key==="Escape"?(u(!1),v(-1),(W=B.current)==null||W.blur()):$.key==="ArrowDown"?($.preventDefault(),n.length>0&&(d||u(!0),v(J=>J<n.length-1?J+1:J))):$.key==="ArrowUp"&&($.preventDefault(),v(J=>J>0?J-1:-1))},[f,n,e,d,y,j]),b=p.useCallback(()=>{var $;r(""),($=B.current)==null||$.focus()},[r]),k=p.useMemo(()=>n.filter($=>$.isFavourite),[n]),R=p.useMemo(()=>n.filter($=>!$.isFavourite),[n]),a=d&&n.length>0;return t.jsxs(o.Box,{sx:{position:"relative",width:240},ref:S,children:[t.jsx(o.TextField,{inputRef:B,size:"small",fullWidth:!0,value:e,onChange:$=>m($.target.value),onFocus:C,onKeyDown:O,placeholder:"Search data...",disabled:l,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:$=>I($.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:$=>I($.palette.text.primary,.5)},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px",color:"text.primary"}},InputProps:{startAdornment:t.jsx(o.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx(z.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(o.InputAdornment,{position:"end",children:t.jsx(o.IconButton,{size:"small",onClick:b,edge:"end",sx:{mr:-.5},children:t.jsx(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:[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(($,W)=>t.jsx(Vi,{entry:$,isSelected:f===W,onClick:()=>y($.query),onToggleFavourite:()=>s($.query),onDelete:()=>c($.query)},`fav-${$.query}`))]}),R.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"}),R.map(($,W)=>{const J=k.length+W;return t.jsx(Vi,{entry:$,isSelected:f===J,onClick:()=>y($.query),onToggleFavourite:()=>s($.query),onDelete:()=>c($.query)},`recent-${$.query}`)})]})]})]})}const Vi=p.memo(function({entry:r,isSelected:n,onClick:i,onToggleFavourite:s,onDelete:c}){const l=p.useCallback(u=>{u.stopPropagation(),s()},[s]),d=p.useCallback(u=>{u.stopPropagation(),c()},[c]);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:n?u=>I(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:n?u=>I(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(o.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(o.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(o.IconButton,{size:"small",onClick:l,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?t.jsx(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:d,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:c,onToggleFavorite:l,onRestoreView:d,onPermanentDelete:u,onEditView:h,onCloneView:g,onCopyLink:f,onDeleteView:v,onPromoteToGlobal:S,isReadOnly:B,isAdmin:C=!1}){const m=it(),[j,y]=p.useState(!1),[O,b]=p.useState(!1),[k,R]=p.useState({top:0,left:0}),[a,$]=p.useState(null),[W,J]=p.useState(null),te=p.useRef(null),x=p.useRef(null),P=e.find(D=>D.id===r),F=P==null?void 0:P.isDefault,re=(D,Z)=>D.name.localeCompare(Z.name),ce=e.filter(D=>D.scope==="global"&&!D.isDeleted).sort(re),X=e.filter(D=>D.scope!=="global"&&!D.isDeleted).sort(re),ee=e.filter(D=>D.isFavorite&&!D.isDeleted).sort(re),fe=e.filter(D=>D.isDeleted);p.useEffect(()=>{if(j&&x.current){const D=x.current.getBoundingClientRect();R({top:D.bottom+window.scrollY+8,left:D.right+window.scrollX-320})}},[j]),p.useEffect(()=>{const D=Z=>{te.current&&!te.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 V=D=>{if(n&&D!==r){$(D),y(!1);return}i(D),y(!1)},K=()=>{a&&(i(a),$(null))},oe=()=>{$(null)},ie=(D,Z=!1)=>{const ue=D.scope==="global",ne=!B&&(!ue||C),ye=C&&!ue;return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===D.id?I(m.palette.primary.main,.12):"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===D.id?I(m.palette.primary.main,.12):m.palette.action.hover}},children:[t.jsxs(o.Button,{onClick:()=>V(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:[ne&&l&&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:D.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(z.Star,{sx:{fontSize:16}})}),ne&&c&&!D.isDefault&&t.jsx(o.IconButton,{onClick:G=>{G.stopPropagation(),c(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}})}),(ne||ye)&&(h||g||f||v||ye&&S)&&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)},H=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:[d&&t.jsx(o.IconButton,{onClick:Z=>{Z.stopPropagation(),d(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),ae=n||!F,se=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:ae?"warning.main":"text.primary",borderColor:ae?"warning.main":"divider",bgcolor:ae?I(m.palette.warning.main,.12):"transparent",borderRadius:1,py:.5,px:1.25,transition:"all 0.15s ease","&:hover":{borderColor:ae?"warning.dark":"primary.main",bgcolor:ae?I(m.palette.warning.main,.2):I(m.palette.text.primary,.06),color:ae?"warning.dark":"text.primary"}},title:`View: ${(P==null?void 0:P.name)||"Default View"}`,children:[t.jsx(o.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(P==null?void 0:P.name)||"Default View"}),se&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:8,height:8,borderRadius:"50%",bgcolor:"warning.main",border:"2px solid",borderColor:"background.paper"}})]}),j&&ts.createPortal(t.jsxs(o.Box,{ref:te,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:k.top,left:k.left},children:[ce.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"}),ce.map(D=>ie(D,D.isDefault))]}),ee.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"})]}),ee.map(D=>ie(D))]})]}),X.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"}),X.map(D=>ie(D))]})]}),fe.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:()=>b(!O),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 (",fe.length,")"]}),t.jsx(z.ChevronRight,{sx:{fontSize:16}})]}),O&&t.jsx(o.Box,{sx:{backgroundColor:m.palette.action.hover},children:fe.map(D=>H(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:!!W,anchorEl:(W==null?void 0:W.el)||null,onClose:()=>J(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[h&&t.jsxs(o.MenuItem,{onClick:()=>{W&&h(W.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:()=>{W&&f(W.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:()=>{W&&g(W.view.id),J(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(z.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),S&&C&&(W==null?void 0:W.view.scope)!=="global"&&t.jsxs(o.MenuItem,{onClick:()=>{W&&S(W.view.id),J(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(z.Language,{sx:{fontSize:18}}),"Promote to Global"]}),v&&[t.jsx(o.Divider,{},"delete-divider"),t.jsxs(o.MenuItem,{onClick:()=>{W&&v(W.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:oe,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:ho(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:oe,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:c=!1,hasModifications:l=!1,position:d,onSortAscending:u,onSortDescending:h,onRemoveSort:g,onFilter:f,onClearFilter:v,onGroupByColumn:S,onHideColumn:B,onManageColumns:C,onResetLayout:m,onClose:j}){const y=it(),O=y.palette,b=p.useRef(null);p.useEffect(()=>{if(!b.current)return;const J=b.current,te=J.getBoundingClientRect(),x=window.innerWidth,P=window.innerHeight;te.right>x-8&&(J.style.left=`${x-te.width-8}px`),te.bottom>P-8&&(J.style.top=`${P-te.height-8}px`)},[d]),p.useEffect(()=>{const J=x=>{b.current&&!b.current.contains(x.target)&&j()},te=x=>{x.key==="Escape"&&j()};return document.addEventListener("mousedown",J),document.addEventListener("keydown",te),()=>{document.removeEventListener("mousedown",J),document.removeEventListener("keydown",te)}},[j]);const k=p.useCallback(J=>()=>{J(),j()},[j]),R=(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",W=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return ts.createPortal(t.jsxs(o.Paper,{ref:b,elevation:0,sx:{position:"fixed",left:`${d.x}px`,top:`${d.y}px`,zIndex:y.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:ho(y),overflow:"hidden",boxShadow:`0 4px 20px ${I(O.common.black,.12)}, 0 1px 4px ${I(O.common.black,.06)}`},children:[!c&&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:R?"primary.main":"text.secondary",bgcolor:R?I(O.primary.main,.1):"transparent","&:hover":{bgcolor:I(O.primary.main,.08),color:"primary.main"}},children:t.jsx(z.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(o.Tooltip,{title:`Sort Descending (${W})`,placement:"top",arrow:!0,children:t.jsx(o.IconButton,{size:"small",onClick:k(()=>h(e)),sx:{p:.625,borderRadius:"6px",color:a?"primary.main":"text.secondary",bgcolor:a?I(O.primary.main,.1):"transparent","&:hover":{bgcolor:I(O.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:k(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:I(O.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:k(()=>f(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(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&&!c&&t.jsxs(o.MenuItem,{onClick:k(()=>v(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:I(O.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"}})]})]}),!c&&S&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.25}}),t.jsx(o.MenuList,{dense:!0,sx:{py:.5},children:t.jsxs(o.MenuItem,{onClick:k(()=>S(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(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:[!c&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsxs(o.MenuItem,{onClick:k(()=>B(e)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[t.jsx(o.ListItemIcon,{sx:{minWidth:28},children:t.jsx(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:k(C),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:I(O.primary.main,.08),color:"primary.main"}},children:t.jsx(z.Settings,{sx:{fontSize:16}})})})]}),c&&t.jsxs(o.MenuItem,{onClick:k(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"}})]}),!c&&l&&m&&t.jsxs(o.MenuItem,{onClick:k(m),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:I(O.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:c,isReadOnly:l=!1,hasModifications:d=!1,width:u,onColumnClick:h,onMoveColumn:g,onColumnDragEnd:f,onResizeStart:v,onSortAscending:S,onSortDescending:B,onRemoveSort:C,onOpenFilterForColumn:m,onClearFiltersForColumn:j,onGroupByColumn:y,onHideColumn:O,onManageColumns:b,onResetLayout:k}){const a=it().urmTable,$=p.useRef(null),[W,J]=p.useState(!1),[te,x]=p.useState({x:0,y:0}),[{handlerId:P,isOver:F},re]=Ht.useDrop({accept:Hi,collect(H){return{handlerId:H.getHandlerId(),isOver:H.isOver()}},hover(H,ae){var G;if(!$.current)return;const se=H.index,D=n;if(se===D)return;const Z=(G=$.current)==null?void 0:G.getBoundingClientRect(),ue=(Z.right-Z.left)/2,ne=ae.getClientOffset(),ye=((ne==null?void 0:ne.x)??0)-Z.left;se<D&&ye<ue||se>D&&ye>ue||(g(se,D),H.index=D)}}),[{isDragging:ce},X]=Ht.useDrag({type:Hi,item:()=>({index:n,columnName:r.name}),collect:H=>({isDragging:H.isDragging()}),end:()=>{f==null||f()}});X(re($));const ee=p.useCallback(H=>{H.preventDefault(),H.stopPropagation(),x({x:H.clientX,y:H.clientY}),J(!0)},[]),fe=p.useCallback(()=>J(!1),[]),V=p.useCallback(()=>{h(r.name)},[h,r.name]),K=p.useCallback(H=>{H.stopPropagation(),m(r.name)},[m,r.name]),oe=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]),ie=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:$,"data-handler-id":P,"data-column-index":n,onClick:V,onContextMenu:ee,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:(a==null?void 0:a.headerColor)??"text.primary",opacity:ce?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:F?H=>I(H.palette.primary.main,.08):(a==null?void 0:a.headerBg)??"action.hover",boxShadow:H=>`0 1px 0 ${I(H.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:H=>I(H.palette.primary.main,.1),color:"text.primary"},width:u?`${u}px`:`${qd}px`},children:[t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[ot(r.name),oe(),ie()]}),t.jsx(o.Box,{draggable:!1,onDragStart:H=>H.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:H=>{H.preventDefault(),H.stopPropagation(),v(H,r.name)},onClick:H=>H.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"}})}),F&&t.jsx(o.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),W&&t.jsx(Yd,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:c,isReadOnly:l,hasModifications:d,position:te,onSortAscending:S,onSortDescending:B,onRemoveSort:C,onFilter:m,onClearFilter:j,onGroupByColumn:y,onHideColumn:O,onManageColumns:b,onResetLayout:k,onClose:fe})]})}),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 Fo(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:I(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.mode==="dark"?e.palette.warning.light: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 rt(e){return I(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:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>Fo(n,r).bg,color:n=>Fo(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:c=>{const l=Xd(c,s);return l?{color:l,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:n})}return typeof r=="boolean"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(o.Box,{component:"span",sx:{fontSize:"0.875rem"},children:n})}function ru(e){const r=e.find(s=>{const c=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(c)})||e[0]||null,n=e.find(s=>{const c=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(c)&&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:c,onView:l,onEdit:d,onDuplicate:u,onDelete:h}){const[g,f]=p.useState(null),[v,S]=p.useState(!1),{primaryCol:B,idCol:C,bodyColumns:m}=p.useMemo(()=>ru(n),[n]),j=B?e[B.name]:null,y=C?e[C.name]:null,O=v||i||!!g;return t.jsxs(o.Box,{onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),onClick:()=>c(r),sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:b=>{var R,a,$,W;const k=(W=($=(a=(R=b.components)==null?void 0:R.MuiCard)==null?void 0:a.styleOverrides)==null?void 0:$.root)==null?void 0:W.border;return i?"2px solid":k&&k!=="none"?k:"1px solid"},borderColor:i?"primary.main":b=>{var R,a,$,W;const k=(W=($=(a=(R=b.components)==null?void 0:R.MuiCard)==null?void 0:a.styleOverrides)==null?void 0:$.root)==null?void 0:W.border;return k&&k!=="none"?"inherit":I(b.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:b=>{var R,a,$,W;const k=(W=($=(a=(R=b.components)==null?void 0:R.MuiCard)==null?void 0:a.styleOverrides)==null?void 0:$.root)==null?void 0:W.borderRadius;return k!==void 0?typeof k=="number"?`${k}px`:k:`${b.shape.borderRadius}px`},cursor:"pointer",transition:"box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease",overflow:"hidden",minHeight:180,boxShadow:i?b=>`0 0 0 3px ${I(b.palette.primary.main,.15)}, 0 2px 8px ${I(b.palette.common.black,.08)}`:v?b=>{var R,a,$,W;const k=(W=($=(a=(R=b.components)==null?void 0:R.MuiCard)==null?void 0:a.styleOverrides)==null?void 0:$.root)==null?void 0:W.boxShadow;return k&&k!=="none"?k:le(b,"cardHover")}:b=>{var R,a,$,W;const k=(W=($=(a=(R=b.components)==null?void 0:R.MuiCard)==null?void 0:a.styleOverrides)==null?void 0:$.root)==null?void 0:W.boxShadow;return k&&k!=="none"?k:le(b,"cardRest")},transform:v&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:b=>I(b.palette.primary.main,.03)}},children:[t.jsx(o.Box,{sx:b=>{var W,J,te,x;const k=((te=(J=(W=b.components)==null?void 0:W.MuiCardHeader)==null?void 0:J.styleOverrides)==null?void 0:te.root)||{},R=(k.backgroundColor&&k.backgroundColor!=="transparent"?k.backgroundColor:void 0)??((x=b.tokens)==null?void 0:x.cardHdrHex)??"transparent",a=k.borderBottom&&k.borderBottom!=="none"?k.borderBottom:void 0,$=k.boxShadow&&k.boxShadow!=="none"?k.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:R,borderBottom:a,boxShadow:$}},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:b=>{var a,$,W;const k=((W=($=(a=b.components)==null?void 0:a.MuiCardHeader)==null?void 0:$.styleOverrides)==null?void 0:W.root)||{};return k.borderBottom&&k.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(o.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[m.map(b=>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:ot(b.name)}),t.jsx(o.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[b.name]??""),children:tu(b,e[b.name])})]},b.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:b=>I(b.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:O?1:0,transition:"opacity 0.15s ease"},onClick:b=>b.stopPropagation(),children:t.jsx(o.Tooltip,{title:"More actions",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:b=>{b.stopPropagation(),f(b.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:b=>I(b.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:b=>le(b,"popover")}},onClick:b=>b.stopPropagation(),children:[t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{l(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:()=>{d(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=>le(s,"flatHover"),"&:hover":{bgcolor:s=>I(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=>I(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,c])=>as(c)).filter(Boolean).join(" • ")})]})}function iu({data:e,visibleColumns:r,grouping:n,selectedRowIds:i,isReadOnly:s,isGrouped:c,onToggleRowSelection:l,onToggleGroupCollapse:d,onViewRow:u,onEditRow:h,onDuplicateRow:g,onDeleteRow:f}){const v=p.useMemo(()=>{const S=new Set;return i.forEach(B=>{const C=B==null?void 0:B.__urm_row_id__;C!==void 0&&S.add(C)}),S},[i]);return e.length===0?t.jsx(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:t.jsx(o.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):t.jsx(o.Box,{sx:{fontFamily:S=>S.typography.fontFamily},children:t.jsx(o.Box,{sx:{p:2,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:1.5,alignContent:"start"},children:e.map((S,B)=>c&&S.isGroupHeader?t.jsx(nu,{row:S,grouping:n,onToggleCollapse:d||(()=>{})},`group-${S.groupKey}`):t.jsx(ou,{row:S,rowIndex:B,visibleColumns:r,isSelected:v.has(S==null?void 0:S.__urm_row_id__),isReadOnly:s,onToggleSelection:()=>l(S),onView:u,onEdit:h,onDuplicate:g,onDelete:f},`card-${B}`))})})}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:c}){const d=it().palette,u=Math.ceil(n/r),[h,g]=p.useState(String(e)),[f,v]=p.useState(null),[S,B]=p.useState(!1),C=p.useRef(null);p.useEffect(()=>{S||(g(String(e)),v(null))},[e,S]);const m=p.useCallback(()=>{const P=su(h,u);if(P){v(P);return}const F=parseInt(h.trim(),10);v(null),B(!1),F!==e&&s(F)},[h,u,e,s]),j=p.useCallback(P=>{var F;P.key==="Enter"?(P.preventDefault(),m()):P.key==="Escape"&&(g(String(e)),v(null),B(!1),(F=C.current)==null||F.blur())},[m,e]),y=p.useCallback(()=>{g(String(e)),v(null),B(!1)},[e]),O=p.useCallback(()=>{B(!0),v(null),setTimeout(()=>{var P;return(P=C.current)==null?void 0:P.select()},0)},[]);if(n<=Math.min(...Ui))return null;const b=()=>{g(String(e)),v(null),B(!1)},k=()=>{b(),s(1)},R=()=>{b(),e>1&&s(e-1)},a=()=>{b(),e<u&&s(e+1)},$=()=>{b(),s(u)},W=(e-1)*r+1,J=Math.min(e*r,n),te=`${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:P=>c(Number(P.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(P=>t.jsx(o.MenuItem,{value:P,sx:{fontSize:"0.8125rem"},children:P},P))})]}),t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.8125rem",color:"text.secondary",fontWeight:400,userSelect:"none"},children:[W,"–",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:I(d.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${I(d.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:I(d.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:P=>{g(P.target.value),f&&v(null)},onKeyDown:j,onFocus:O,onBlur:y,inputProps:{"aria-label":`Page number, 1 to ${u}`,style:{textAlign:"center",padding:"2px 0",width:te,fontSize:"0.8125rem",fontWeight:600}},sx:{fontSize:"0.8125rem",fontWeight:600,color:f?"error.main":"text.primary",border:"1px solid",borderColor:f?"error.main":S?"primary.main":"divider",borderRadius:"4px",bgcolor:f?I(d.error.main,.04):S?I(d.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 ${I(d.error.main,.2)}`:`0 0 0 2px ${I(d.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:x,children:t.jsx(z.FirstPage,{sx:{fontSize:20}})}),t.jsx(o.IconButton,{onClick:R,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:$,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 Ms="urm_hint_seen_";function cu(e){try{return localStorage.getItem(Ms+e)==="true"}catch{return!1}}function du(e){try{localStorage.setItem(Ms+e,"true")}catch{}}const As={"& .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 Rn(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=it().palette,s=r.filter(d=>d.name in e),c=s.filter(d=>d.type!=="object"&&d.type!=="array"),l=s.filter(d=>d.type==="object"||d.type==="array");return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[c.map(d=>t.jsx(o.TextField,{label:ot(d.name),value:Rn(e[d.name],d.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:As},d.name)),l.map(d=>{const u=Rn(e[d.name],d.type);return t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:ot(d.name)}),t.jsx(o.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:I(i.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:u?"text.primary":"text.disabled",fontStyle:u?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:u||"No value"})]},d.name)}),s.length===0&&t.jsx(o.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3},children:"No fields to display"})]})}function uu({open:e,onClose:r,row:n,schema:i,reportName:s}){const c=it(),l=c.palette;if(!n)return null;const d=i.filter(u=>u.name in n).length;return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:He(c),maxHeight:"min(720px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${I(l.common.black,.14)}, 0 2px 8px ${I(l.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:I(l.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," · ",d," ",d===1?"field":"fields"]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{mt:.25,color:"text.secondary",borderRadius:"8px","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(z.Close,{sx:{fontSize:18}})})]}),t.jsx(o.Divider,{}),t.jsx(o.DialogContent,{sx:{overflowY:"auto",flex:1,bgcolor:I(l.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:c=>He(c),maxHeight:"min(720px, calc(100vh - 80px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:c=>le(c,"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:c=>I(c.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:c=>I(c.palette.error.main,.1),border:c=>`1px solid ${I(c.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:c=>`${c.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:c=>`${c.shape.borderRadius}px`,boxShadow:c=>le(c,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:c=>le(c,"hoverButton")},"&:active":{boxShadow:c=>le(c,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]})]})}function xu({open:e,onClose:r,onSave:n,row:i,schema:s,reportName:c}){var m;const l=it(),d=l.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"),v=g.filter(j=>j.type==="object"||j.type==="array"),S=(j,y)=>{h(O=>({...O,[j]:y}))},B=()=>{const j={...u};g.forEach(y=>{const O=u[y.name];if(y.type==="number"){const b=Number(O);j[y.name]=isNaN(b)?i[y.name]:b}else y.type==="boolean"&&(j[y.name]=!!O)}),n(j),r()},C=g.length;return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:He(l),maxHeight:"min(760px, calc(100vh - 80px))",display:"flex",flexDirection:"column",boxShadow:`0 8px 32px ${I(d.common.black,.14)}, 0 2px 8px ${I(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:I(((m=d.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"}),c&&t.jsxs(o.Typography,{variant:"caption",sx:{fontSize:"0.75rem",color:"text.secondary",display:"block",mt:.25,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[c," · ",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:I(d.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:ot(j.name)}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Switch,{checked:!!y,onChange:O=>S(j.name,O.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:ot(j.name),value:y??"",onChange:O=>S(j.name,O.target.value),type:j.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:As},j.name)}),v.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:v.map(j=>{const y=Rn(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:ot(j.name)}),t.jsx(o.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:I(d.text.secondary,.07),color:"text.secondary",border:"none"}}),t.jsx(o.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:t.jsx(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:I(d.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:B,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 c=i.reduce((f,v)=>f+v.width,0),d=Math.max(0,n-hu)-c;if(d<=0)return{widths:s,fillerWidth:0};const u=i.filter(f=>!f.explicit);if(u.length===0)return{widths:s,fillerWidth:d};const h=u.reduce((f,v)=>f+v.width,0)||1;let g=0;return u.forEach((f,v)=>{const B=v===u.length-1?f.width+d-g:Math.round(f.width+d*f.width/h);s[f.name]=B,g+=B-f.width}),{widths:s,fillerWidth:0}},[e,r,n])}const Io=176,Gi=32,Yi=24,bu=wt(),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:n=>{var i;return(i=n.tokens)!=null&&i.statusBold?700:500},bgcolor:n=>Fo(n,r).bg,color:n=>Fo(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((c,l)=>c.toLowerCase()===n.toLowerCase()?t.jsx(o.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:c},l):c)}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 d=e.dateFormat??"iso",u=ba(r,d,n??null);return t.jsx(o.Box,{component:"span",sx:{color:"text.primary",whiteSpace:"nowrap"},children:u})}if(e.type==="number"&&typeof r=="number")return r.toLocaleString();if(typeof r=="boolean")return r?"Yes":"No";if(Array.isArray(r)){if(r.length===0)return t.jsx(o.Box,{component:"span",sx:{color:"text.disabled"},children:"[ ]"});const d=r.slice(0,3).map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(", ");return t.jsxs(o.Box,{component:"span",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[d,r.length>3?` +${r.length-3} more`:""]})}if(typeof r=="object"){const d=JSON.stringify(r);return t.jsx(o.Box,{component:"span",title:d,sx:{color:"text.secondary",fontSize:"0.8125rem",fontFamily:"monospace",cursor:"help"},children:d.length>40?d.slice(0,40)+"…":d})}return ju(s,i)}function wu({schema:e,data:r,sortStack:n=[],filters:i=bu,views:s=[],activeViewId:c="",isDirty:l=!1,isExporting:d=!1,columnVisibility:u={},columnOrder:h=[],columnWidths:g={},grouping:f=null,classTokens:v={},onSort:S,onSortAscending:B,onSortDescending:C,onOpenFilters:m,onOpenSort:j,onOpenFilterForColumn:y,onSelectView:O,onCreateView:b,onUpdateCurrentView:k,onSaveAsNewView:R,onDiscardChanges:a,onToggleDefault:$,onToggleFavorite:W,onRestoreView:J,onPermanentDelete:te,onEditView:x,onCloneView:P,onCopyLink:F,onDeleteView:re,onPromoteToGlobal:ce,isAdmin:X=!1,onExport:ee,onOpenColumns:fe,onUpdateColumnWidth:V,onUpdateColumnOrder:K,onUpdateColumnVisibility:oe,onClearFiltersForColumn:ie,onResetLayout:H,onOpenGroup:ae,onGroupByColumn:se,onToggleGroupCollapse:D,onExpandAllGroups:Z,onCollapseAllGroups:ue,onOpenAuditHistory:ne,onOpenScheduledReports:ye,searchQuery:G,highlightQuery:Ae="",searchHistory:yt=[],onAddToSearchHistory:st,onToggleSearchFavourite:kr,onDeleteSearchHistory:Tr,selectedRowIds:bt=new Set,onSearchChange:Br,onToggleRowSelection:at,onToggleAllRows:Gt,onRangeSelection:kt,onClearSelection:lt,onExportSelected:ct,currentPage:_t=1,pageSize:Mt=15,totalRowsBeforePagination:Jr=r.length,onPageChange:sr,onPageSizeChange:ar,isReadOnly:Xe=!1,userRole:Kr,reportName:Ir,onEditRow:At,onDuplicateRow:Ue,onDeleteRow:Tt,showDevPanel:Xr=!1,onOpenDevConfig:Qe,rowActions:lr,hideDefaultRowActions:Re,onRowClick:Yt,onRowRightClick:Rt}){var yr;const U=it().urmTable,[cr,Er]=p.useState(null),[vt,N]=p.useState(0),[dt,ge]=p.useState(0),[Pe,dr]=p.useState(null),Dr=((yr=Cr().dates)==null?void 0:yr.displayFormat)??null,[Wt,$r]=p.useState(null),[qt,Or]=p.useState(null),[Pt,Be]=p.useState(null),[Q,ut]=p.useState(!1),[Ie,Jt]=p.useState(!1),[pr,Kt]=p.useState(null),[Qr,Bt]=p.useState(!1),[It,Xt]=p.useState(null),[Ve,xr]=p.useState(null),[he,Ge]=p.useState(null),[_r,pt]=p.useState(null),St=p.useRef(null),zt=p.useCallback(()=>{St.current&&(clearTimeout(St.current),St.current=null)},[]),Mr=p.useCallback(()=>{zt(),St.current=setTimeout(()=>pt(null),200)},[zt]);p.useEffect(()=>zt,[zt]);const[Qt,Ze]=p.useState(null),[Ke,mr]=p.useState("list"),[Zt,fr]=p.useState(!1),[me,Ce]=p.useState(()=>!cu("toolbar_search")),$e=p.useRef(null),Et=p.useRef(null),[er,go]=p.useState(0);p.useLayoutEffect(()=>{const w=$e.current;if(!w)return;go(w.clientWidth);const L=new ResizeObserver(xe=>{go(xe[0].contentRect.width)});return L.observe(w),()=>L.disconnect()},[]);const Ar=p.useCallback(()=>{du("toolbar_search"),Ce(!1)},[]);p.useEffect(()=>{if(!me)return;const w=setTimeout(Ar,2e3);return()=>clearTimeout(w)},[me,Ar]);const yo=p.useMemo(()=>{const w=Pe??h;return w.length>0?w.map(L=>e.find(xe=>xe.name===L)).filter(L=>L!==void 0):e},[Pe,h,e]),hr=p.useMemo(()=>yo.filter(w=>u[w.name]!==!1),[yo,u]),Zr=p.useMemo(()=>new Set(((f==null?void 0:f.levels)??[]).map(w=>w.column)),[f]),bo=!!(f!=null&&f.enabled&&(f!=null&&f.levels)&&f.levels.length>0),Ct=p.useMemo(()=>{if(!bo)return hr;const w=hr.filter(L=>!Zr.has(L.name));return w.length>0?w:hr},[hr,bo,Zr]),{widths:Rr,fillerWidth:Wr}=yu(Ct,g,er),tr=p.useMemo(()=>e.filter(w=>u[w.name]===!1).length,[e,u]),vo=p.useMemo(()=>e.map(w=>w.name),[e]),Pr=p.useMemo(()=>h.length===0?!1:JSON.stringify(h)!==JSON.stringify(vo),[h,vo]),an=p.useCallback((w,L)=>{w.preventDefault(),w.stopPropagation(),Er(L),N(w.clientX),ge(g[L]||150)},[g]);p.useEffect(()=>{if(!cr)return;const w=xe=>{const Le=xe.clientX-vt,Ye=Math.max(100,Math.min(600,dt+Le));V==null||V(cr,Ye)},L=()=>{Er(null)};return document.addEventListener("mousemove",w),document.addEventListener("mouseup",L),()=>{document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",L)}},[cr,vt,dt,V]);const ln=p.useCallback(w=>w==null?"-":typeof w=="object"?JSON.stringify(w):typeof w=="boolean"?w?"true":"false":String(w),[]);p.useCallback(w=>{const L=n.find(xe=>xe.column===w);return L?t.jsxs(o.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[L.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:L.priority})]}):null},[n]),p.useCallback(w=>Dn(i,w)?t.jsx(o.IconButton,{size:"small",onClick:xe=>{xe.stopPropagation(),y==null||y(w)},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 cn=p.useCallback(w=>{S&&S(w)},[S]),dn=p.useCallback((w,L)=>{dr(xe=>{const Ye=[...xe??(h.length>0?h:e.map(Je=>Je.name))],[qe]=Ye.splice(w,1);return Ye.splice(L,0,qe),Ye})},[h,e]),un=p.useCallback(()=>{Pe&&K&&K(Pe),dr(null)},[Pe,K]),pn=p.useCallback(w=>{if(!S)return;const L=n.find(xe=>xe.column===w);(!L||L.direction!=="asc")&&S(w)},[S,n]),xn=p.useCallback(w=>{if(!S)return;const L=n.find(xe=>xe.column===w);L?L.direction==="asc"&&S(w):(S(w),setTimeout(()=>S(w),0))},[S,n]),mn=p.useCallback(w=>{if(!S)return;const L=n.find(xe=>xe.column===w);L&&(L.direction==="asc"?(S(w),setTimeout(()=>S(w),0)):L.direction==="desc"&&S(w))},[S,n]),fn=p.useCallback(w=>{oe&&oe(w,!1)},[oe]),Nr=(f==null?void 0:f.enabled)&&r.length>0&&r[0]&&"isGroupHeader"in r[0],Nt=p.useMemo(()=>ht(i),[i]),hn=n.length>0||Nt>0||((f==null?void 0:f.enabled)??!1)||Object.values(u).some(w=>w===!1),gn=(_t-1)*Mt,Ne=r,Lt=p.useMemo(()=>{const w=new Set;return bt.forEach(L=>{const xe=L==null?void 0:L.__urm_row_id__;xe!==void 0&&w.add(xe)}),w},[bt]);p.useEffect(()=>{const w=L=>{!Gt||!lt||L.target instanceof HTMLInputElement||L.target instanceof HTMLTextAreaElement||((L.ctrlKey||L.metaKey)&&L.key==="a"&&(L.preventDefault(),Gt(!0,Ne)),L.key==="Escape"&&(L.preventDefault(),lt()))};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[Gt,lt,Ne]);const So=p.useCallback((w,L)=>{Yt==null||Yt(Ne[w],w,L),at&&(L.shiftKey&&Wt!==null?(L.preventDefault(),kt&&kt(Wt,w,Ne)):(at(Ne[w]),$r(w)))},[at,Wt,kt,Ne,Yt]);!p.useMemo(()=>Ne.length>0&&Lt.size>0&&Ne.every(w=>Lt.has(w==null?void 0:w.__urm_row_id__)),[Ne,Lt])&&Ne.some(w=>Lt.has(w==null?void 0:w.__urm_row_id__));const eo=at&&Gt,gr=p.useCallback(w=>{var qe;const L=w.groupLevel,xe=L*Gi,Le=L===0?v.groupRowLevel0||"urm-group-level-0":L===1?v.groupRowLevel1||"urm-group-level-1":v.groupRowLevel2||"urm-group-level-2",Ye=L===0?"action.selected":L===1?"action.hover":"background.paper";return t.jsx(o.TableRow,{onClick:()=>D==null?void 0:D(w.groupKey),className:`urm-group-header-row urm-group-level-${L} ${Le} ${v.groupRow||""}`,sx:{bgcolor:Ye,"&:hover":{bgcolor:Je=>I(Je.palette.text.primary,.08)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider"},children:t.jsx(o.TableCell,{colSpan:Ct.length+2+(eo?1:0),className:`urm-group-cell ${v.groupCellFirst||""} ${v.groupCell||""}`,sx:{pl:`${xe+Yi}px`,position:"relative",py:1},children:t.jsxs(o.Box,{className:`urm-group-content ${v.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Box,{className:`urm-group-caret ${v.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:w.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 ${v.groupTitle||""}`,sx:{fontWeight:L===0?600:500,color:"text.primary"},children:ls(L,((qe=f==null?void 0:f.levels[L])==null?void 0:qe.column)||"",w.groupValue)}),t.jsxs(o.Box,{className:`urm-group-count ${v.groupBadge||""} ${v.groupCount||""}`,sx:{px:1,py:.25,fontSize:"caption.fontSize",fontWeight:500,bgcolor:Je=>I(Je.palette.text.secondary,.12),color:"text.secondary",borderRadius:2},children:[w.rowCount," ",w.rowCount===1?"row":"rows"]}),Object.keys(w.aggregates).length>0&&t.jsx(o.Typography,{variant:"caption",className:`urm-group-aggregates ${v.groupAggregates||""}`,sx:{ml:1,color:"text.secondary"},children:Object.entries(w.aggregates).map(([Je,de])=>as(de)).filter(Boolean).join(" • ")})]})})},w.groupKey)},[Ct,eo,f,D,v]),Co=p.useCallback((w,L)=>{const xe=Lt.has(w==null?void 0:w.__urm_row_id__),Le=qt===L,Ye=Q&&(w==null?void 0:w.__urm_row_id__)===(Pt==null?void 0:Pt.__urm_row_id__),qe=!!(w!=null&&w.__urm_is_grouped_data_row__),Je=qe?w.__urm_group_level__??(f==null?void 0:f.levels.length)??1:0;return t.jsxs(o.TableRow,{"data-row-index":L,className:qe?`urm-data-row-grouped ${v.dataRowGrouped||""}`:"",onMouseEnter:()=>Or(L),onMouseLeave:()=>Or(null),onClick:de=>{de.target.closest("[data-row-action-btn]")||So(L,de)},onContextMenu:de=>{de.preventDefault(),de.stopPropagation(),Rt==null||Rt(w,L,de),pt(null),Ge({mouseX:de.clientX,mouseY:de.clientY,row:w,rowIndex:L})},sx:{cursor:"pointer",bgcolor:xe?de=>I(de.palette.warning.main,.12):Ye?de=>I(de.palette.info.main,.12):U!=null&&U.striped&&L%2===1?U.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:xe?de=>I(de.palette.warning.main,.2):Ye?de=>I(de.palette.info.main,.2):"action.hover"},borderBottom:(U==null?void 0:U.rowDivider)??"1px solid",borderColor:"divider"},children:[Ct.map((de,Ft)=>{if(qe&&Ft===0){const yn=Je*Gi+Yi;return t.jsx(o.TableCell,{className:`urm-data-cell-grouped ${v.dataCellGrouped||""}`,sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(U==null?void 0:U.rowPaddingY)??"6px",px:(U==null?void 0:U.cellPaddingX)??2,pl:`${yn}px`,position:"relative",textAlign:(U==null?void 0:U.cellAlignH)??"left",verticalAlign:(U==null?void 0:U.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(U==null?void 0:U.rowDivider)??"1px solid",borderRight:U==null?void 0:U.colDivider,borderColor:"divider",minWidth:g[de.name]?`${g[de.name]}px`:`${de.type==="date"?Math.max(Io,180):Io}px`},children:t.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:t.jsx("span",{className:`urm-item-title ${v.itemTitle||""}`,children:qi(de,w[de.name],Dr,Ae)})})},de.name)}return t.jsx(o.TableCell,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(U==null?void 0:U.rowPaddingY)??"6px",px:(U==null?void 0:U.cellPaddingX)??2,textAlign:(U==null?void 0:U.cellAlignH)??"left",verticalAlign:(U==null?void 0:U.cellAlignV)??"middle",fontSize:"0.8125rem",fontWeight:400,color:"text.primary",borderBottom:(U==null?void 0:U.rowDivider)??"1px solid",borderRight:U==null?void 0:U.colDivider,borderColor:"divider",minWidth:g[de.name]?`${g[de.name]}px`:`${de.type==="date"?Math.max(Io,180):Io}px`},children:qi(de,w[de.name],Dr,Ae)},de.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:Le?de=>`linear-gradient(to right, transparent, ${xe?I(de.palette.warning.main,.12):de.palette.background.paper} 32px)`:"transparent",opacity:Le?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:de=>{de.stopPropagation(),de.preventDefault(),pt(null),Ge({anchorEl:de.currentTarget,row:w,rowIndex:L})},sx:{color:"text.secondary",opacity:Le?1:0,transition:"opacity 0.12s ease",pointerEvents:Le?"auto":"none","&:hover":{bgcolor:de=>I(de.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(z.MoreVert,{sx:{fontSize:18}})})})})]},L)},[bt,gn,qt,So,Ct,g,Ae,ln,At,Ue,Tt,at,Be,ut,Pt,Q,Ge,Nr,Zr,Rt]);return t.jsxs(Ht.DndProvider,{backend:Wn.HTML5Backend,children:[t.jsxs(o.Box,{sx:w=>{var qe,Je,de;const L=((de=(Je=(qe=w.components)==null?void 0:qe.MuiCard)==null?void 0:Je.styleOverrides)==null?void 0:de.root)||{},xe=L.border&&L.border!=="none"?L.border:"1px solid",Le=L.borderRadius!==void 0?typeof L.borderRadius=="number"?`${L.borderRadius}px`:L.borderRadius:`${w.shape.borderRadius}px`,Ye=L.boxShadow&&L.boxShadow!=="none"?L.boxShadow:le(w,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:xe,borderColor:xe!=="none"?"divider":void 0,borderRadius:Le,boxShadow:Ye,overflow:"hidden"}},children:[t.jsxs(o.Box,{sx:w=>{var qe,Je,de,Ft,to;const L=((de=(Je=(qe=w.components)==null?void 0:qe.MuiCardHeader)==null?void 0:Je.styleOverrides)==null?void 0:de.root)||{},xe=(L.backgroundColor&&L.backgroundColor!=="transparent"?L.backgroundColor:void 0)??((Ft=w.tokens)==null?void 0:Ft.cardHdrHex)??((to=w.urmTable)==null?void 0:to.headerBg)??w.palette.background.paper,Le=L.borderBottom&&L.borderBottom!=="none"?L.borderBottom:"1px solid",Ye=L.boxShadow&&L.boxShadow!=="none"?L.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:xe,borderBottom:Le,borderColor:Le!=="none"?"divider":void 0,boxShadow:Ye,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Xe&&t.jsx(lu,{}),Br&&st&&kr&&Tr&&t.jsx(o.Tooltip,{open:me,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:w=>{me&&Ar(),Br(w)},searchHistory:yt,onAddToHistory:st,onToggleFavourite:kr,onDeleteHistory:Tr,disabled:Xe})})}),t.jsx(o.Tooltip,{title:"JSON format guide",children:t.jsx(o.IconButton,{size:"small",onClick:()=>fr(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:w=>I(w.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(z.InfoOutlined,{sx:{fontSize:20}})})}),O&&b&&k&&s.length>0&&t.jsx(Gd,{views:s||[],activeViewId:c||"",isDirty:l,onSelectView:O,onCreateView:b,onToggleDefault:$,onToggleFavorite:W,onRestoreView:J,onPermanentDelete:te,onEditView:x,onCloneView:P,onCopyLink:F,onDeleteView:re,onPromoteToGlobal:ce,isAdmin:X,isReadOnly:Xe}),l&&!Xe&&t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[k&&t.jsx(o.Button,{onClick:k,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:w=>`var(--urm-btn-save-current-bg, ${w.palette.primary.main})`,color:w=>`var(--urm-btn-save-current-color, ${w.palette.primary.contrastText})`,textTransform:"none",boxShadow:w=>le(w,"restButton"),"&:hover":{bgcolor:w=>`var(--urm-btn-save-current-hover-bg, ${w.palette.primary.dark})`,boxShadow:w=>le(w,"hoverButton")}},children:"Save current view"}),R&&t.jsx(o.Button,{onClick:R,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:w=>`var(--urm-btn-save-new-border, ${w.palette.primary.main})`,color:w=>`var(--urm-btn-save-new-color, ${w.palette.primary.main})`,bgcolor:w=>`var(--urm-btn-save-new-bg, ${w.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:w=>`var(--urm-btn-save-new-hover-border, ${w.palette.primary.dark})`,bgcolor:w=>`var(--urm-btn-save-new-hover-bg, ${I(w.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:w=>`var(--urm-btn-discard-bg, ${I(w.palette.text.primary,.12)})`,color:w=>`var(--urm-btn-discard-color, ${w.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:w=>`var(--urm-btn-discard-hover-bg, ${I(w.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:w=>I(w.palette.text.secondary,.3),"&:hover":{bgcolor:w=>I(w.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}}),!Xe&&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?w=>rt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:n.length>0?w=>I(w.palette.primary.main,.2):w=>I(w.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})]})}),!Xe&&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?w=>rt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:Nt>0?w=>I(w.palette.primary.main,.2):w=>I(w.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})]})}),!Xe&&fe&&t.jsx(o.Tooltip,{title:"Show/Hide Columns",children:t.jsxs(o.IconButton,{onClick:fe,size:"small",sx:{position:"relative",color:tr>0||Pr?"primary.main":"text.secondary",bgcolor:tr>0||Pr?w=>rt(w):"transparent",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:tr>0||Pr?w=>I(w.palette.primary.main,.2):w=>I(w.palette.text.primary,.06),color:tr>0||Pr?"primary.main":"text.primary"}},children:[t.jsx(z.ViewColumn,{sx:{fontSize:20}}),tr>0&&t.jsx(o.Box,{component:"span",sx:{position:"absolute",top:-2,right:-2,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"primary.main",color:"primary.contrastText",borderRadius:"50%",fontSize:"0.625rem",fontWeight:700,border:"2px solid",borderColor:"background.paper"},children:tr})]})}),Nr&&(Z||ue)&&(()=>{var xe;const w=(((xe=f==null?void 0:f.collapsedGroups)==null?void 0:xe.length)??0)>0,L=w?Z:ue;return L?t.jsx(o.Tooltip,{title:w?"Expand all groups":"Collapse all groups",children:t.jsx(o.IconButton,{onClick:L,size:"small",sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:Le=>I(Le.palette.text.primary,.06),color:"text.primary"}},children:w?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:()=>mr("list"),sx:{borderRadius:1,color:Ke==="list"?"primary.main":"text.secondary",bgcolor:Ke==="list"?w=>rt(w):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Ke==="list"?w=>I(w.palette.primary.main,.2):w=>I(w.palette.text.primary,.06),color:Ke==="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:()=>mr("grid"),sx:{borderRadius:1,color:Ke==="grid"?"primary.main":"text.secondary",bgcolor:Ke==="grid"?w=>rt(w):"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:Ke==="grid"?w=>I(w.palette.primary.main,.2):w=>I(w.palette.text.primary,.06),color:Ke==="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:w=>Ze(w.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:w=>I(w.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(z.Settings,{sx:{fontSize:20}})})})]}),t.jsxs(o.Popover,{open:!!Qt,anchorEl:Qt,onClose:()=>Ze(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:[ee&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ee(),Ze(null)},disabled:d,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"})]}),!Xe&&ae&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ae(),Ze(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"})]}),ne&&t.jsxs(o.MenuItem,{dense:!0,onClick:()=>{ne(),Ze(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(),Ze(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:[Ke==="grid"&&t.jsx(o.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(iu,{data:Ne,visibleColumns:hr,grouping:f,selectedRowIds:bt,isReadOnly:Xe,isGrouped:!!Nr,onToggleRowSelection:at||(()=>{}),onToggleGroupCollapse:D,onViewRow:w=>{Be(w),ut(!0)},onEditRow:(w,L)=>{Xt(w),xr(L),Bt(!0)},onDuplicateRow:(w,L)=>Ue==null?void 0:Ue(w,L),onDeleteRow:(w,L)=>{Kt(L),Jt(!0)}})}),Ke==="list"&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(o.Box,{ref:$e,onScroll:w=>{Et.current&&(Et.current.scrollLeft=w.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Rr).reduce((w,L)=>w+L,0)+Wr+40}px`},children:[t.jsxs("colgroup",{children:[Ct.map(w=>t.jsx("col",{style:{width:`${Rr[w.name]}px`}},w.name)),t.jsx("col",{style:{width:`${Wr}px`}}),t.jsx("col",{style:{width:"40px"}})]}),t.jsx(o.TableHead,{children:t.jsxs(o.TableRow,{sx:{bgcolor:(U==null?void 0:U.headerBg)??"action.hover",borderBottom:(U==null?void 0:U.rowDivider)??"1px solid",borderColor:"divider"},children:[Ct.map((w,L)=>t.jsx(Jd,{column:w,index:L,sortRule:n.find(xe=>xe.column===w.name),hasFilters:Dn(i,w.name),isInSortStack:n.some(xe=>xe.column===w.name),isReadOnly:Xe,hasModifications:hn,width:g[w.name],onColumnClick:cn,onMoveColumn:dn,onColumnDragEnd:un,onResizeStart:an,onSortAscending:B||pn,onSortDescending:C||xn,onRemoveSort:mn,onOpenFilterForColumn:y||(()=>{}),onClearFiltersForColumn:ie||(()=>{}),onGroupByColumn:se,onHideColumn:fn,onManageColumns:fe||(()=>{}),onResetLayout:H},w.name)),t.jsx(o.TableCell,{sx:{p:0,border:"none",borderBottom:(U==null?void 0:U.rowDivider)??"1px solid",borderColor:"divider",bgcolor:(U==null?void 0:U.headerBg)??"action.hover"}}),t.jsx(o.TableCell,{sx:{width:40,minWidth:40,p:0,border:"none",borderBottom:(U==null?void 0:U.rowDivider)??"1px solid",borderColor:"divider",bgcolor:(U==null?void 0:U.headerBg)??"action.hover"}})]})})]})}),t.jsx(o.Box,{ref:Et,onScroll:w=>{$e.current&&($e.current.scrollLeft=w.target.scrollLeft)},sx:{flex:1,overflowY:"auto",overflowX:"auto",minHeight:0,bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:w=>I(w.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:w=>I(w.palette.text.primary,.3)}}},children:t.jsxs(o.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(Rr).reduce((w,L)=>w+L,0)+Wr+40}px`},children:[t.jsxs("colgroup",{children:[Ct.map(w=>t.jsx("col",{style:{width:`${Rr[w.name]}px`}},w.name)),t.jsx("col",{style:{width:`${Wr}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:Ct.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"})})}):Nr?Ne.map((w,L)=>w.isGroupHeader?gr(w):Co(w,L)):Ne.map((w,L)=>Co(w,L))})]})})]}),sr&&ar&&t.jsx(au,{currentPage:_t,pageSize:Mt,totalRows:Jr,totalFields:e.length,onPageChange:sr,onPageSizeChange:ar}),!(sr&&ar)&&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:!!he,onClose:()=>{Ge(null),pt(null)},anchorEl:(he==null?void 0:he.anchorEl)||null,anchorReference:he!=null&&he.anchorEl?"anchorEl":"anchorPosition",anchorPosition:he&&!he.anchorEl?{top:he.mouseY,left:he.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:he!=null&&he.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:()=>{he&&(Be(he.row),ut(!0)),Ge(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:()=>{he&&(Xt(he.row),xr(he.rowIndex),Bt(!0)),Ge(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:()=>{he&&(Ue==null||Ue(he.rowIndex,he.row)),Ge(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"})]}),he&&(lr==null?void 0:lr.map(w=>{var L,xe;return(L=w.hidden)!=null&&L.call(w,he.row)?null:t.jsxs(o.MenuItem,{dense:!0,disabled:(xe=w.disabled)==null?void 0:xe.call(w,he.row),onClick:()=>{w.onClick(he.row,he.rowIndex),Ge(null)},sx:{py:1,px:2,gap:1.5},children:[w.icon,t.jsx(o.Typography,{variant:"body2",children:w.label})]},w.key)})),Lt.size>0&&ct&&!(Re!=null&&Re.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(o.Divider,{sx:{my:.5}}),t.jsxs(o.MenuItem,{dense:!0,onMouseEnter:w=>{zt(),pt(w.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(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:!!_r,anchorEl:_r,placement:"right-start",transition:!0,sx:{zIndex:w=>w.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:w})=>t.jsx(o.Grow,{...w,timeout:150,children:t.jsx(o.Paper,{onMouseEnter:zt,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:()=>{ct("csv"),pt(null),Ge(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:()=>{ct("excel"),pt(null),Ge(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:()=>{ct("json"),pt(null),Ge(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:()=>{he&&(Kt(he.row),Jt(!0)),Ge(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:Q,onClose:()=>{ut(!1),Be(null)},row:Pt,schema:e,reportName:Ir}),t.jsx(xu,{open:Qr,onClose:()=>{Bt(!1),Xt(null),xr(null)},onSave:w=>{Ve!==null&&(At==null||At(Ve,w))},row:It,schema:e,reportName:Ir}),t.jsx(pu,{open:Ie,onClose:()=>{Jt(!1),Kt(null)},onConfirm:()=>{pr!==null&&(Tt==null||Tt(pr))},row:pr,schema:e}),t.jsx(Os,{isOpen:Zt,onClose:()=>fr(!1)})]})}function jr({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=>I(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=>I(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,c)=>t.jsx(o.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},c))}),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=>I(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>I(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 wr={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it"],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."}},En=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 c=r.find(u=>u.name===e.column),l=p.useMemo(()=>{const u=c?No(c.type):[],h=i.filter.allowedOperators;return h.length>0?u.filter(g=>h.includes(g.value)):u},[c,i]),d=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(v=>v.name===u.target.value),g=h?No(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:ot(u.name)},u.name))})}),t.jsx(o.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(o.Select,{value:e.operator,onChange:u=>s({operator:u.target.value,value:void 0}),sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:l.map(u=>t.jsx(o.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),d&&(c==null?void 0:c.type)==="date"&&t.jsx(o.TextField,{size:"small",type:"date",value:e.value??"",onChange:u=>s({value:u.target.value}),sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}}),d&&(c==null?void 0:c.type)!=="date"&&t.jsx(o.TextField,{size:"small",type:(c==null?void 0:c.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(c==null?void 0:c.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:c,totalConditions:l,onChange:d}){const u=l>=c;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:En,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=>d(v=>Ln(v,e.id,f))}),g>0&&t.jsx(o.Box,{sx:{position:"absolute",top:13,left:"50%",width:En/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:c,totalConditions:l,onChange:d}):t.jsx(Tu,{condition:h,schema:n,availableColumns:i,devConfig:s,onUpdate:f=>d(v=>Nn(v,h.id,f))})}),t.jsx(o.IconButton,{size:"small",onClick:()=>d(f=>Fn(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:`${En}px`},children:[t.jsx(o.Button,{size:"small",disabled:u||i.length===0,onClick:()=>d(h=>{var g,f,v;return qr(h,e.id,{id:Yr(),column:((g=i[0])==null?void 0:g.name)??"",operator:((v=No(((f=i[0])==null?void 0:f.type)??"string")[0])==null?void 0:v.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(o.Button,{size:"small",disabled:u,onClick:()=>d(h=>qr(h,e.id,wt())),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=>I(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>I(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[c,l]=p.useState(r??wt()),d=Cr(),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??wt();if(s&&m.children.length===0){const y=e.find(O=>O.name===s);if(y){l(qr(m,m.id,{id:Yr(),column:s,operator:((j=No(y.type)[0])==null?void 0:j.value)??"equals"}));return}}l(m)},[r,s,e]);const h=ht(c),g=d.filter.maxConditions,f=p.useCallback(m=>{l(j=>m(j))},[]),v=p.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r??wt()),[c,r]),S=p.useCallback(()=>{n(c),i()},[c,n,i]),B=p.useCallback(()=>{l(r??wt()),i()},[r,i]),C=p.useCallback(()=>{n(wt()),i()},[n,i]);return t.jsx(o.Box,{onClick:B,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:m=>I(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=>He(m),bgcolor:"background.paper",outline:"none",boxShadow:m=>le(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(jr,{content:wr.filter,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:B,size:"small",sx:{p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(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=>I(m.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:m=>I(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 "${ot(s)}"`:"","."]}),t.jsx(Ps,{group:c,depth:0,schema:e,availableColumns:u,devConfig:d,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:B,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:m=>`${m.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:S,disabled:!v,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:m=>`${m.shape.borderRadius}px`,boxShadow:m=>le(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 c=p.useRef(null),[{handlerId:l},d]=Ht.useDrop({accept:Ji,collect(g){return{handlerId:g.getHandlerId()}},hover(g,f){var y;if(!c.current)return;const v=g.index,S=r;if(v===S)return;const B=(y=c.current)==null?void 0:y.getBoundingClientRect(),C=(B.bottom-B.top)/2,m=f.getClientOffset(),j=((m==null?void 0:m.y)??0)-B.top;v<S&&j<C||v>S&&j>C||(s(v,S),g.index=S)}}),[{isDragging:u},h]=Ht.useDrag({type:Ji,item:()=>({index:r}),collect:g=>({isDragging:g.isDragging()})});return h(d(c)),t.jsxs(o.Box,{ref:c,"data-handler-id":l,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:g=>le(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 ${I(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=>rt(g),"&:hover":{bgcolor:g=>I(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=>rt(g),"&:hover":{bgcolor:g=>I(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=>I(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,c]=p.useState(""),[l,d]=p.useState([]);p.useEffect(()=>{d([...r])},[r]);const u=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r),[l,r]),h=Cr(),g=p.useCallback(y=>{if(!y||l.length>=h.sort.maxLevels)return;const O={column:y,direction:"asc",priority:l.length+1};d([...l,O]),c(""),setTimeout(()=>{var b;return(b=document.activeElement)==null?void 0:b.blur()},0)},[l,h.sort.maxLevels]),f=p.useCallback(y=>{const b=l.filter((k,R)=>R!==y).map((k,R)=>({...k,priority:R+1}));d(b)},[l]),v=p.useCallback((y,O)=>{const b=[...l];b[y]={...b[y],direction:O},d(b)},[l]),S=p.useCallback((y,O)=>{const b=[...l],[k]=b.splice(y,1);b.splice(O,0,k);const R=b.map((a,$)=>({...a,priority:$+1}));d(R)},[l]),B=p.useCallback(()=>{n([]),i()},[n,i]),C=p.useCallback(()=>{n(l),i()},[l,n,i]),m=p.useCallback(()=>{d([...r]),c(""),i()},[r,i]),j=e.filter(y=>!l.some(O=>O.column===y.name));return t.jsx(Ht.DndProvider,{backend:Wn.HTML5Backend,children:t.jsx(o.Box,{onClick:m,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:y=>I(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=>He(y),bgcolor:"background.paper",outline:"none",boxShadow:y=>le(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(jr,{content:wr.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=>I(y.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:y=>I(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:l.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:O=>rt(O),"&:hover":{bgcolor:O=>I(O.palette.primary.main,.2)}}},children:ot(y.name)},y.name))})]}),l.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"]})]}),l.length>0&&t.jsxs(o.Box,{children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(o.Typography,{variant:"overline",sx:{fontSize:"0.6875rem",fontWeight:600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",l.length,"/",h.sort.maxLevels,")"]}),t.jsx(o.Button,{onClick:B,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto",minHeight:"auto",transition:"color 0.2s ease","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:l.map((y,O)=>t.jsx(zu,{rule:y,index:O,onToggleDirection:v,onRemove:f,onMove:S},`${y.column}-${O}`))})]})]}),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||l.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=>le(y,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:y=>le(y,"hoverButton")},"&:active":{boxShadow:y=>le(y,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]})]})})})}const zo=50;function Ki({currentSnapshot:e,onSave:r,onClose:n,isEditMode:i=!1,initialName:s="",initialDescription:c="",initialIsDefault:l=!1,atViewLimit:d=!1,maxViews:u=10}){const[h,g]=p.useState(s),[f,v]=p.useState(!1),[S,B]=p.useState(c),[C,m]=p.useState(l),j=()=>{if(!h.trim()){v(!0);return}if(h.trim().length>zo){v(!0);return}r(h.trim(),S.trim(),C),n()},y=b=>{b.key==="Enter"&&!b.shiftKey?j():b.key==="Escape"&&n()},O=()=>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:b=>He(b),boxShadow:b=>le(b,"menu")}},children:[t.jsxs(o.DialogTitle,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pb:1},children:[O(),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:[d&&!i&&t.jsxs(o.Alert,{severity:"warning",sx:{borderRadius:"8px"},children:["You have reached the maximum of ",u," saved views. Delete an existing view before creating a new one."]}),t.jsx(o.TextField,{label:"View Name",required:!0,value:h,onChange:b=>{b.target.value.length<=zo&&g(b.target.value),f&&b.target.value.trim()&&v(!1)},onKeyDown:y,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:d&&!i,inputProps:{maxLength:zo},error:f&&!h.trim(),helperText:f&&!h.trim()?"View name is required":`${h.length} / ${zo}`}),t.jsx(o.TextField,{label:"Description (optional)",value:S,onChange:b=>B(b.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),t.jsxs(o.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight: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:[ht(e.filters)," filter",ht(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:b=>m(b.target.checked),size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Set as default view"})})]})}),t.jsxs(o.DialogActions,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end"},children:[t.jsx(o.Button,{onClick:n,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:b=>`${b.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(o.Button,{onClick:j,variant:"contained",disabled:d&&!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:b=>`${b.shape.borderRadius}px`,boxShadow:b=>le(b,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:b=>le(b,"hoverButton")},"&:active":{boxShadow:b=>le(b,"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=>He(i),maxHeight:"min(480px, calc(100vh - 180px))",my:"auto",boxShadow:i=>le(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=>le(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>le(i,"hoverButton")},"&:active":{boxShadow:i=>le(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]})]})}const Oo=100,_o=600,Xi="COLUMN";function $u({column:e,index:r,isVisible:n,width:i,onToggleVisibility:s,onWidthChange:c,moveColumn:l}){const d=p.useRef(null),[u,h]=p.useState(i.toString());p.useEffect(()=>{h(i.toString())},[i]);const[{handlerId:g},f]=Ht.useDrop({accept:Xi,collect(y){return{handlerId:y.getHandlerId()}},hover(y,O){var J;if(!d.current)return;const b=y.index,k=r;if(b===k)return;const R=(J=d.current)==null?void 0:J.getBoundingClientRect(),a=(R.bottom-R.top)/2,$=O.getClientOffset(),W=(($==null?void 0:$.y)??0)-R.top;b<k&&W<a||b>k&&W>a||(l(b,k),y.index=k)}}),[{isDragging:v},S]=Ht.useDrag({type:Xi,item:()=>({index:r}),collect:y=>({isDragging:y.isDragging()})});S(f(d));const B=()=>{const y=parseInt(u);if(isNaN(y)){h(i.toString()),c(e.name,i);return}const O=Math.max(Oo,Math.min(_o,y));h(O.toString()),c(e.name,O)},C=y=>{if(y===""||/^\d+$/.test(y)){h(y);const O=parseInt(y);if(!isNaN(O)&&O>=Oo){const b=Math.min(_o,O);c(e.name,b)}}},m=y=>{y.key==="Enter"&&(y.preventDefault(),B(),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:d,"data-handler-id":g,sx:{opacity:v?.4:1,bgcolor:n?"background.paper":"action.hover",transition:"opacity 0.15s ease","&:hover":{bgcolor:n?"action.hover":"action.selected"},cursor:"move",height:56,borderBottom:"1px solid divider"},children:[t.jsx(o.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(o.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx(z.DragIndicator,{sx:{fontSize:20}})}),t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:400,fontSize:"0.875rem",color:n?"text.primary":"text.secondary"},children:ot(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:B,onKeyDown:m,placeholder:"150",size:"small",inputProps:{min:Oo,max:_o,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=>I(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:c="",onUpdateColumnVisibility:l,onUpdateColumnOrder:d,onUpdateColumnWidth:u,onResetLayout:h,onClose:g}){const[f,v]=p.useState(!1),[S,B]=p.useState(n),[C,m]=p.useState(i),[j,y]=p.useState("all");p.useEffect(()=>{B(n)},[n]),p.useEffect(()=>{m(i)},[i]);const O=(x,P)=>{m(F=>({...F,[x]:P})),u==null||u(x,P)},b=(x,P)=>{const F=[...S],[re]=F.splice(x,1);F.splice(P,0,re),B(F),d(F)},k=()=>{h(),v(!1)},a=S.map(x=>e.find(P=>P.name===x)).filter(x=>x!==void 0).filter(x=>{const P=r[x.name]??!0;return j==="active"?P:j==="hidden"?!P:!0}),$=Object.values(r).filter(x=>x).length,W=e.length,J=s.find(x=>x.id===c),te=p.useMemo(()=>{if(!J)return!1;const x=J.snapshot,P=x.columnVisibility??{},F=JSON.stringify(r)!==JSON.stringify(P),re=x.columnOrder??[],ce=n??[],X=JSON.stringify(ce)!==JSON.stringify(re)&&!(ce.length===0&&re.length===0),ee=x.columnWidths??{},fe=JSON.stringify(C)!==JSON.stringify(ee);return F||X||fe},[J,r,n,C]);return t.jsx(Ht.DndProvider,{backend:Wn.HTML5Backend,children:t.jsx(o.Box,{onClick:g,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:x=>I(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=>He(x),bgcolor:"background.paper",outline:"none",boxShadow:x=>le(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(jr,{content:wr.columns,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(o.IconButton,{onClick:g,size:"small",sx:{ml:2,p:.75,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(z.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Tabs,{value:j,onChange:(x,P)=>y(P),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=>I(x.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:x=>I(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: ${Oo}px, max: ${_o}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,P)=>t.jsx($u,{column:x,index:P,isVisible:r[x.name]??!0,width:C[x.name]||170,onToggleVisibility:l,onWidthChange:O,moveColumn:b},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:[$," of ",W," columns visible • Drag to reorder"]})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0,bgcolor:"action.hover"},children:t.jsx(o.Button,{onClick:()=>v(!0),disabled:!te,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:()=>v(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:x=>I(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=>ho(x),bgcolor:"background.paper",boxShadow:x=>le(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:()=>v(!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:k,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:x=>`${x.shape.borderRadius}px`,boxShadow:x=>le(x,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:x=>le(x,"hoverButton")},"&:active":{boxShadow:x=>le(x,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})})}function _u({schema:e,grouping:r,onApply:n,onClose:i}){var R;const[s,c]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[l,d]=p.useState(""),[u,h]=p.useState(null),g=p.useMemo(()=>Ta(e),[e]),f=p.useMemo(()=>g.filter(a=>!s.levels.some(($,W)=>$.column===a.name&&W!==u)),[g,s.levels,u]),v=Cr(),S=s.levels.length<v.grouping.maxLevels&&f.length>0,B=p.useCallback(a=>{!S||!a||(c({...s,levels:[...s.levels,{column:a}],enabled:!0}),d(""),setTimeout(()=>{var $;return($=document.activeElement)==null?void 0:$.blur()},0))},[S,s]),C=p.useCallback(a=>{const $=s.levels.filter((W,J)=>J!==a);if($.length===0){n(null),i();return}c({...s,levels:$,enabled:$.length>0})},[s,n,i]),m=p.useCallback(a=>{h(a),d(s.levels[a].column)},[s.levels]),j=p.useCallback(()=>{if(u===null||!l)return;const a=[...s.levels];a[u]={column:l},c({...s,levels:a}),h(null),d("")},[u,l,s]),y=p.useCallback(()=>{h(null),d("")},[]),O=p.useCallback((a,$)=>{const W=$==="up"?a-1:a+1;if(W<0||W>=s.levels.length)return;const J=[...s.levels],[te]=J.splice(a,1);J.splice(W,0,te),c({...s,levels:J})},[s]),b=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=>I(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=>He(a),bgcolor:"background.paper",outline:"none",boxShadow:a=>le(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(jr,{content:wr.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=>I(a.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:a=>I(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:l,onChange:a=>B(a.target.value),disabled:!S,displayEmpty:!0,sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider",transition:"border-color 0.2s ease"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-disabled":{bgcolor:"action.hover"}},children:[t.jsx(o.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),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:$=>rt($),"&:hover":{bgcolor:$=>I($.palette.primary.main,.2)}}},children:[ot(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"}),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 ${I(a.palette.warning.main,.5)}`,bgcolor:a=>I(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:l,onChange:a=>d(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=>rt(a)}},children:[s.levels[u].column," (",(R=e.find(a=>a.name===s.levels[u].column))==null?void 0:R.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:$=>rt($)}},children:[ot(a.name)," (",a.type.toUpperCase(),")"]},a.name))]})}),t.jsxs(o.Stack,{direction:"row",spacing:1.5,children:[t.jsx(o.Button,{onClick:j,disabled:!l,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:a=>le(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:b,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})]}),t.jsx(o.Stack,{spacing:1.5,children:s.levels.map((a,$)=>{const W=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=>le(J,"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:J=>`0 1px 2px 0 ${I(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:W==null?void 0:W.type.toUpperCase()})]}),t.jsxs(o.Stack,{direction:"row",spacing:.5,children:[t.jsx(o.IconButton,{size:"small",onClick:()=>O($,"up"),disabled:$===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:()=>O($,"down"),disabled:$===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($),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($),sx:{color:"text.secondary","&:hover":{bgcolor:J=>I(J.palette.error.main,.08),color:"error.main"}},children:t.jsx(z.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=>le(a,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:a=>le(a,"hoverButton")},"&:active":{boxShadow:a=>le(a,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]})]})})}function Mu({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 Au(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=it(),s=i.palette,[c,l]=p.useState("1h"),[d,u]=p.useState(!1),h=[...e].sort((B,C)=>new Date(C.timestamp).getTime()-new Date(B.timestamp).getTime()),g=Qi.find(B=>B.key===c),f=Au(e,g.ms),v=()=>u(!0),S=()=>{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:I(s.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:i.zIndex.modal,animation:"fadeIn 0.2s ease","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:B=>B.stopPropagation(),elevation:0,sx:{width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"min(700px, calc(100vh - 80px))",display:"flex",flexDirection:"column",borderRadius:He(i),bgcolor:"background.paper",overflow:"hidden",boxShadow:`0 8px 32px ${I(s.common.black,.14)}, 0 2px 8px ${I(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(jr,{content:wr.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:c,onChange:B=>l(B.target.value),size:"small",variant:"outlined",sx:{fontSize:"0.75rem",height:30,minWidth:120,"& .MuiSelect-select":{py:.375,px:1,fontSize:"0.75rem"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:I(s.text.primary,.3)}},children:Qi.map(B=>t.jsx(o.MenuItem,{value:B.key,sx:{fontSize:"0.8125rem"},children:B.label},B.key))}),t.jsx(o.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(z.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:v,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:I(s.error.main,.5),"&:hover":{bgcolor:I(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:I(s.text.primary,.012),"&::-webkit-scrollbar":{width:5},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:I(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(B=>{const C=Zd(i,B.feature),{summary:m,detail:j}=Ya(B);return t.jsxs(o.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.25,px:1.5,py:1.25,borderRadius:"10px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transition:"border-color 0.15s","&:hover":{borderColor:I(s.text.primary,.18)}},children:[t.jsx(o.Chip,{label:Ka(B.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:I(C,.1),color:C,border:`1px solid ${I(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(B.timestamp)})]}),B.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:B.user})]})]})]})]},B.id)})})})]})}),t.jsxs(o.Dialog,{open:d,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:ho(i),boxShadow:`0 8px 32px ${I(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:I(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:S,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,c]=p.useState(""),[l,d]=p.useState(""),[u,h]=p.useState([]),[g,f]=p.useState(""),[v,S]=p.useState(""),B=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),C=()=>{const k=l.trim();if(k){if(!B(k)){S("Please enter a valid email address");return}if(u.includes(k)){S("This email is already added");return}h([...u,k]),d(""),S("")}},m=k=>{h(u.filter(R=>R!==k))},j=k=>{k.key==="Enter"&&(k.preventDefault(),C())},y=()=>{if(!n.trim()){f("Preset name is required");return}e(n.trim(),s.trim(),u.length>0?u:void 0)},O=k=>{i(k),g&&f("")},b=k=>{d(k),v&&S("")};return t.jsx(o.Box,{onClick:r,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:k=>I(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=>He(k),bgcolor:"background.paper",outline:"none",boxShadow:k=>le(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(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:k=>I(k.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:k=>I(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(z.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:k=>`1px solid ${I(k.palette.primary.main,.3)}`,bgcolor:k=>rt(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=>O(k.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!g,helperText:g,autoFocus:!0,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontSize:"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=>c(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:l,onChange:k=>b(k.target.value),onKeyPress:j,placeholder:"Enter email address",error:!!v,helperText:v,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: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:()=>m(k),deleteIcon:t.jsx(z.Delete,{sx:{fontSize:16}}),sx:{bgcolor:R=>rt(R),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: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:k=>`${k.shape.borderRadius}px`,boxShadow:k=>le(k,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:k=>le(k,"hoverButton")},"&:active":{boxShadow:k=>le(k,"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=>I(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 c=l=>new Date(l).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(o.Box,{onClick:s,sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:l=>I(l.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:l=>l.zIndex.modal,animation:"fadeIn 0.225s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes fadeIn":{from:{opacity:0},to:{opacity:1}}},children:t.jsxs(o.Paper,{onClick:l=>l.stopPropagation(),elevation:0,sx:{position:"relative",width:680,maxWidth:"calc(100vw - 120px)",maxHeight:"min(720px, calc(100vh - 200px))",display:"flex",flexDirection:"column",borderRadius:l=>He(l),bgcolor:"background.paper",outline:"none",boxShadow:l=>le(l,"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:l=>I(l.palette.text.primary,.2)}}},children:e.length===0?t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx(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(l=>t.jsxs(o.Paper,{elevation:0,sx:{p:2.5,border:"1px solid divider",borderRadius:"8px",bgcolor:"background.paper",transition:"all 0.2s ease","&:hover":{borderColor:"divider",boxShadow:d=>le(d,"restButtonLight")}},children:[t.jsx(o.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:t.jsxs(o.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(o.Typography,{variant:"h6",sx:{fontSize:"0.9375rem",fontWeight:500,color:"text.primary",mb:.5},children:l.name}),l.description&&t.jsx(o.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:l.description})]})}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(o.Chip,{label:`Created ${c(l.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(o.Chip,{label:`By ${l.createdBy}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}})]}),t.jsx(o.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(o.Box,{sx:{display:"flex",gap:1},children:t.jsx(o.Button,{onClick:()=>i(l.id,l.name),variant:"outlined",size:"small",startIcon:t.jsx(z.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:d=>`${d.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:d=>I(d.palette.error.main,.04)}},children:"Delete"})})]},l.id))})}),t.jsx(o.Box,{sx:{px:3,py:1.75,borderTop:"1px solid divider",bgcolor:"action.hover",gap:1.25,justifyContent:"flex-end",display:"flex"},children:t.jsx(o.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>le(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:l=>le(l,"hoverButton")},"&:active":{boxShadow:l=>le(l,"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(d=>d.test(i.name));let c=!1;const l=r.slice(0,10).map(d=>d[i.name]).filter(d=>typeof d=="string"&&d.length>0);l.length>0&&(c=l.filter(u=>Fu.some(h=>h.test(u))).length/l.length>.6),(s||c)&&n.push(i.name)}return n}function Qn(e,r){if(e.length===0||r.length===0)return 0;const n=e.slice(0,Math.min(50,e.length)),s=r.map(l=>{const d=n.map(h=>String(h[l]??"")).filter(h=>h.length>0);if(d.length===0)return 5;const u=d.reduce((h,g)=>h+g.length,0);return Math.ceil(u/d.length)+1}).reduce((l,d)=>l+d,0)+1;return r.reduce((l,d)=>l+d.length+1,0)+s*e.length}function Uu(e,r){const n=Qn(e,r);return Math.ceil(n*3.5)}function Gu(e,r){const n=Qn(e,r);return Math.ceil(n*.7)}function Yu(e,r,n){switch(e){case"csv":return Qn(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 c=[],l=Yu(e,r,n),d=r.length;if(d>s.maxRowsHard){const g=Zi(d,s.maxRows);c.push({type:"row_count",severity:"error",message:`Export blocked: ${d.toLocaleString()} rows exceeds the maximum of ${s.maxRowsHard.toLocaleString()}`,detail:`Consider using filters to reduce the dataset before exporting, or split into ${g} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:g,value:d,limit:s.maxRowsHard})}else if(d>s.maxRows){const g=Zi(d,s.maxRows);c.push({type:"row_count",severity:"warning",message:`Large export: ${d.toLocaleString()} rows`,detail:`This is a large export that may take a moment to complete. For faster results, consider splitting into ${g} smaller export${g>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:g,value:d,limit:s.maxRows})}if(l>s.maxFileSizeHardBytes?c.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${co(l)} exceeds the ${co(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:l,limit:s.maxFileSizeHardBytes}):l>s.maxFileSizeBytes&&c.push({type:"file_size",severity:"warning",message:`Large file: estimated ${co(l)}`,detail:`This exceeds the recommended ${co(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:l,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;c.push({type:"image_columns",severity:f?"error":"warning",message:`Image column${g.length>1?"s":""} detected: ${g.map(v=>`"${v.replace(/_/g," ")}"`).join(", ")}`,detail:f?`Exporting ${g.length} image columns may produce a very large file. Consider hiding these columns before exporting.`:"Image URL columns are included in the export as plain text links — not embedded images.",value:g.length,limit:s.maxImageColumns})}}const u=c.some(g=>g.severity==="error"),h=c.some(g=>g.severity==="warning");return{violations:c,hasBlockingViolation:u,hasWarning:h,estimatedBytes:l}}function co(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=it().palette,i=e.severity==="error",s=i?n.error.main:n.warning.main,c=I(i?n.error.main:n.warning.main,.06),l=i?I(n.error.main,.25):I(n.warning.main,.3),d=i?z.ErrorOutline:z.WarningAmberOutlined;return t.jsxs(o.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"10px",bgcolor:c,border:"1px solid",borderColor:l},children:[t.jsx(d,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{sx:{fontSize:"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=it(),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:I(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=it();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:c,sampleRows:l=[],allRows:d=[],processedRows:u=[],initialFormat:h,initialScope:g="visible",initialColumnScope:f="visible",classTokens:v={},onExport:S,onClose:B}){const C=it(),m=C.palette,j=Cr(),y=p.useMemo(()=>{var K,oe,ie,H;const X=((ie=(oe=(K=C.components)==null?void 0:K.MuiCard)==null?void 0:oe.styleOverrides)==null?void 0:ie.root)||{},ee=X.border&&X.border!=="none"?X.border:((H=C.tokens)==null?void 0:H.cardBorder)||m.divider,fe=X.borderRadius!==void 0?typeof X.borderRadius=="number"?`${X.borderRadius}px`:X.borderRadius:`${C.shape.borderRadius}px`,V=X.boxShadow&&X.boxShadow!=="none"?X.boxShadow:void 0;return{sectionBorder:`var(--urm-export-section-border, ${ee})`,sectionTitleColor:`var(--urm-export-section-title-color, ${m.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${m.background.paper})`,cardBg:`var(--urm-export-card-bg, ${m.background.paper})`,cardBorder:`var(--urm-export-card-border, ${ee})`,cardRadius:fe,cardShadow:V,cardHoverBg:`var(--urm-export-card-hover-bg, ${m.mode==="dark"?I(m.common.white,.08):I(m.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${I(m.primary.main,m.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${m.primary.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${m.mode==="dark"?m.primary.light:m.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${m.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${m.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${m.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${C.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${C.spacing(1.5)})`}},[m,C]),O=h||j.export.allowedFormats[0]||"csv",[b,k]=p.useState(O),[R,a]=p.useState(g),[$,W]=p.useState(f),J=R==="visible"?r:e,te=$==="visible"?i:s,x=p.useMemo(()=>R==="visible"?u.length>0?u:new Array(r):d.length>0?d:new Array(e),[R,r,e,u,d]),P=p.useMemo(()=>$==="all"?c.map(X=>X.name):c.map(X=>X.name).slice(0,i),[$,c,i]),F=p.useMemo(()=>qu(b,x,P,c,Ns),[b,x,P,c]),re=()=>{F.hasBlockingViolation||(S({format:b,scope:R,columnScope:$}),B())},ce={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON"};return t.jsx(o.Box,{onClick:B,className:`urm-export-backdrop ${v.modalBackdrop||""}`,sx:{position:"fixed",inset:0,bgcolor:I(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:X=>X.stopPropagation(),elevation:0,className:`urm-export-paper ${v.modalPaper||""}`,sx:{width:540,maxWidth:"calc(100vw - 32px)",maxHeight:"min(760px, calc(100vh - 48px))",display:"flex",flexDirection:"column",borderRadius:He(C),bgcolor:y.sectionTitleBg,overflow:"hidden",boxShadow:y.cardShadow??le(C,"menu"),animation:"slideIn 0.2s cubic-bezier(0.4, 0, 0.2, 1)","@keyframes slideIn":{from:{opacity:0,transform:"scale(0.96) translateY(-8px)"},to:{opacity:1,transform:"scale(1) translateY(0)"}}},children:[t.jsxs(o.Box,{className:`urm-export-header ${v.modalHeader||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,pt:2.5,pb:1.5,flexShrink:0},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(o.Typography,{className:`urm-export-title ${v.modalTitle||""}`,sx:{fontSize:"1.125rem",fontWeight:700,color:m.text.primary},children:"Export Report"}),t.jsx(jr,{content:wr.export,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(o.IconButton,{onClick:B,size:"small",className:`urm-export-close ${v.modalCloseButton||""}`,sx:{color:m.text.secondary,borderRadius:"50%","&:hover":{bgcolor:m.action.hover,color:m.text.primary}},children:t.jsx(z.Close,{sx:{fontSize:20}})})]}),t.jsxs(o.Box,{className:`urm-export-content ${v.modalContent||""}`,sx:{flex:1,overflowY:"auto",px:3,pb:2.5,pt:.5,display:"flex",flexDirection:"column",gap:y.optionGap,"&::-webkit-scrollbar":{width:6},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:I(m.text.primary,.15),borderRadius:3}},children:[F.violations.length>0&&t.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:F.violations.map((X,ee)=>t.jsx(Ju,{violation:X},ee))}),t.jsxs(o.Box,{className:`urm-export-section ${v.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 ${v.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(X=>X.allowed).map(X=>{const ee=b===X.id;return t.jsxs(o.Box,{onClick:()=>k(X.id),className:`urm-export-format-card ${ee?v.formatCardSelected||"":v.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:y.cardRadius,border:ee?`2px solid ${y.cardSelectedBorder}`:`1px solid ${y.cardBorder}`,boxShadow:ee?void 0:y.cardShadow,bgcolor:ee?y.cardSelectedBg:y.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?y.cardSelectedBorder:I(m.text.primary,.25),bgcolor:ee?y.cardSelectedBg:y.cardHoverBg}},children:[ee&&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 ${I(m.primary.main,.3)}`},children:t.jsx(z.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(Ku,{format:X.id}),t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:ee?y.cardSelectedColor:m.text.primary},children:X.title}),t.jsx(o.Tooltip,{title:X.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:fe=>fe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(z.InfoOutlined,{sx:{fontSize:13}})})})]})]},X.id)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.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 ${v.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(X=>{const ee=R===X.value;return t.jsxs(o.Box,{onClick:()=>a(X.value),className:`urm-export-row-card ${ee?v.rowCardSelected||"":v.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:y.cardRadius,border:ee?`2px solid ${y.cardSelectedBorder}`:`1px solid ${y.cardBorder}`,boxShadow:ee?void 0:y.cardShadow,bgcolor:ee?y.cardSelectedBg:y.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?y.cardSelectedBorder:I(m.text.primary,.25),bgcolor:ee?y.cardSelectedBg:y.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(es,{checked:ee}),t.jsx(o.Box,{sx:{color:ee?y.cardSelectedColor:m.text.secondary,display:"flex"},children:X.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:ee?y.cardSelectedColor:m.text.primary},children:X.label})]}),t.jsx(o.Tooltip,{title:X.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:fe=>fe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(z.InfoOutlined,{sx:{fontSize:16}})})})]},X.value)})})]}),t.jsxs(o.Box,{className:`urm-export-section ${v.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 ${v.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",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(X=>{const ee=$===X.value;return t.jsxs(o.Box,{onClick:()=>W(X.value),className:`urm-export-column-card ${ee?v.columnCardSelected||"":v.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:y.cardRadius,border:ee?`2px solid ${y.cardSelectedBorder}`:`1px solid ${y.cardBorder}`,boxShadow:ee?void 0:y.cardShadow,bgcolor:ee?y.cardSelectedBg:y.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?y.cardSelectedBorder:I(m.text.primary,.25),bgcolor:ee?y.cardSelectedBg:y.cardHoverBg}},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(es,{checked:ee}),t.jsx(o.Box,{sx:{color:ee?y.cardSelectedColor:m.text.secondary,display:"flex"},children:X.icon}),t.jsx(o.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:ee?y.cardSelectedColor:m.text.primary},children:X.label})]}),t.jsx(o.Tooltip,{title:X.info,arrow:!0,placement:"top",children:t.jsx(o.Box,{component:"span",onClick:fe=>fe.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(z.InfoOutlined,{sx:{fontSize:16}})})})]},X.value)})})]}),t.jsxs(o.Box,{className:`urm-export-summary ${v.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 ${v.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:ce[b]},{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(te)},{icon:t.jsx(z.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Estimated File Size",value:`~${co(F.estimatedBytes)}`,highlight:F.hasBlockingViolation?"error.main":F.hasWarning?"warning.main":void 0}].map(({icon:X,label:ee,value:fe,highlight:V})=>t.jsxs(o.Box,{className:`urm-export-summary-row ${v.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[X,t.jsx(o.Typography,{className:`urm-export-summary-label ${v.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:m.text.secondary,fontWeight:500},children:ee})]}),t.jsx(o.Typography,{className:`urm-export-summary-value ${v.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:V??m.text.primary},children:fe})]},ee))})]})]}),t.jsxs(o.Box,{className:`urm-export-footer ${v.footer||""}`,sx:{px:3,py:2,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,flexShrink:0},children:[F.hasBlockingViolation&&t.jsxs(o.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx(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:B,variant:"outlined",className:`urm-export-cancel-btn ${v.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:I(m.text.primary,.3)}},children:"Cancel"}),t.jsxs(o.Button,{onClick:re,disabled:F.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${v.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 ${I(m.primary.main,.25)}`,"&:hover":{bgcolor:y.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:I(m.primary.main,.4),color:y.primaryBtnColor}},children:["Download ",ce[b]]})]})]})})}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 d=setTimeout(()=>{r()},i);return()=>clearTimeout(d)}},[n,i,r]);const c=(()=>{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}})}}})(),l=ll(e);return t.jsx(o.Box,{sx:{position:"fixed",top:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(o.Alert,{severity:c.severity,icon:c.icon,action:t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:`${c.severity}.main`},children:t.jsx(z.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${c.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:l}),e.details&&process.env.NODE_ENV==="development"&&t.jsx(o.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e.details,null,2)})]})})}class 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=>I(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=>I(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 Eo({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 io({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,c]=p.useState(0),[l,d]=p.useState(n),u=()=>d(n),h=()=>d(et),g=()=>{i(l),r()},f={sort:m=>d(j=>({...j,sort:{...j.sort,...m}})),filter:m=>d(j=>({...j,filter:{...j.filter,...m}})),columns:m=>d(j=>({...j,columns:{...j.columns,...m}})),grouping:m=>d(j=>({...j,grouping:{...j.grouping,...m}})),export:m=>d(j=>({...j,export:{...j.export,...m}}))},v=m=>{const j=l.filter.allowedOperators,y=j.includes(m)?j.filter(O=>O!==m):[...j,m];y.length!==0&&f.filter({allowedOperators:y})},S=m=>{const j=l.export.allowedFormats,y=j.includes(m)?j.filter(O=>O!==m):[...j,m];y.length!==0&&f.export({allowedFormats:y})},B=[{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(l[m])===JSON.stringify(et[m]);return t.jsxs(o.Dialog,{open:e,onClose:r,maxWidth:"sm",fullWidth:!0,TransitionProps:{onEnter:u},PaperProps:{sx:{borderRadius:m=>He(m),maxHeight:"min(680px, calc(100vh - 180px))",my:"auto",display:"flex",flexDirection:"column",boxShadow:m=>`0 8px 32px ${I(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=>I(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)=>c(j),variant:"fullWidth",sx:{minHeight:44,"& .MuiTab-root":{minHeight:44,fontSize:"0.8125rem",textTransform:"none",fontWeight:500,gap:.5}},children:B.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(io,{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:l.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(io,{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:l.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:l.filter.allowedOperators.includes(j.value),onChange:()=>v(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(io,{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:l.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:l.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:l.columns.maxColumnWidth,onChange:(m,j)=>f.columns({maxColumnWidth:j}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}px`})]})]})]})]}),t.jsxs(io,{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:l.grouping.maxLevels===m?"primary.main":"divider",bgcolor:l.grouping.maxLevels===m?j=>I(j.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:j=>I(j.palette.primary.main,.04)}},children:[t.jsx(o.Typography,{variant:"h5",sx:{fontWeight:700,color:l.grouping.maxLevels===m?"primary.main":"text.secondary"},children:m}),t.jsx(o.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][m-1]})]},m))}),t.jsxs(o.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:l.grouping.allowNested,onChange:m=>f.grouping({allowNested:m.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(o.FormControlLabel,{control:t.jsx(o.Checkbox,{checked:l.grouping.allowCollapse,onChange:m=>f.grouping({allowCollapse:m.target.checked})}),label:t.jsx(o.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]}),t.jsx(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(io,{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:()=>S(m.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:"8px",border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:l.export.allowedFormats.includes(m.value)?"primary.main":"divider",bgcolor:l.export.allowedFormats.includes(m.value)?j=>I(j.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(o.Checkbox,{size:"small",checked:l.export.allowedFormats.includes(m.value),onChange:()=>S(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=>I(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=>I(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 Mo(e,r,n,i,s=new Date){const[c,l]=r.split(":").map(Number),d=new Date(s);if(d.setSeconds(0,0),d.setHours(c,l,0,0),e==="daily")return d<=s&&d.setDate(d.getDate()+1),d.toISOString();if(e==="weekly"){const u=n??1,h=d.getDay();let g=u-h;return g<0&&(g+=7),g===0&&d<=s&&(g=7),d.setDate(d.getDate()+g),d.toISOString()}if(e==="monthly"){const u=Math.min(i??1,28);return d.setDate(u),d<=s&&(d.setMonth(d.getMonth()+1),d.setDate(u)),d.toISOString()}return d.toISOString()}function 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),c=Math.floor(n%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${c}m`:c>0?`in ${c}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:""},vr={"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:"8px"},"& .MuiInputLabel-root":{fontSize:"0.875rem"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",mx:.5},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}};function pp({initial:e=Us,isEditing:r=!1,onSave:n,onBack:i}){const[s,c]=p.useState(e),[l,d]=p.useState(!1),[u,h]=p.useState(!1),g=(S,B)=>c(C=>({...C,[S]:B})),f=s.email.trim().length>0&&!up.test(s.email.trim()),v=s.name.trim().length>0&&/^\d{2}:\d{2}$/.test(s.time)&&(s.frequency!=="monthly"||s.dayOfMonth>=1&&s.dayOfMonth<=28)&&!f;return t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:S=>I(S.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:S=>{g("name",S.target.value),l&&S.target.value.trim()&&d(!1)},onBlur:()=>d(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:l&&!s.name.trim(),helperText:l&&!s.name.trim()?"Schedule name is required":`${s.name.length}/50`,sx:vr}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:vr,children:[t.jsx(o.InputLabel,{children:"Frequency"}),t.jsxs(o.Select,{value:s.frequency,label:"Frequency",onChange:S=>g("frequency",S.target.value),children:[t.jsx(o.MenuItem,{value:"daily",children:"Daily"}),t.jsx(o.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(o.MenuItem,{value:"monthly",children:"Monthly"})]})]}),s.frequency==="weekly"&&t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:vr,children:[t.jsx(o.InputLabel,{children:"Day of week"}),t.jsx(o.Select,{value:s.dayOfWeek,label:"Day of week",onChange:S=>g("dayOfWeek",Number(S.target.value)),children:dp.map(S=>t.jsx(o.MenuItem,{value:S.value,children:S.label},S.value))})]}),s.frequency==="monthly"&&t.jsx(o.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:s.dayOfMonth,onChange:S=>g("dayOfMonth",Number(S.target.value)),inputProps:{min:1,max:28},error:s.dayOfMonth<1||s.dayOfMonth>28,helperText:s.dayOfMonth<1||s.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:vr}),t.jsx(o.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:s.time,onChange:S=>g("time",S.target.value),InputLabelProps:{shrink:!0},helperText:"24-hour format · Tab must be open for the schedule to fire",sx:vr}),t.jsxs(o.FormControl,{size:"small",fullWidth:!0,sx:vr,children:[t.jsx(o.InputLabel,{children:"Export format"}),t.jsxs(o.Select,{value:s.format,label:"Export format",onChange:S=>g("format",S.target.value),children:[t.jsx(o.MenuItem,{value:"csv",children:"CSV — Comma-separated values"}),t.jsx(o.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(o.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Data scope"}),t.jsxs(o.RadioGroup,{row:!0,value:s.scope,onChange:S=>g("scope",S.target.value),sx:{gap:2},children:[t.jsx(o.FormControlLabel,{value:"all",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"All rows"})}),t.jsx(o.FormControlLabel,{value:"visible",control:t.jsx(o.Radio,{size:"small"}),label:t.jsx(o.Typography,{variant:"body2",children:"Filtered rows only"})})]})]}),t.jsxs(o.Box,{children:[t.jsx(o.TextField,{label:"Email reminder (optional)",size:"small",fullWidth:!0,type:"email",value:s.email,onChange:S=>g("email",S.target.value),onBlur:()=>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:vr}),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:S=>I(S.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(o.Button,{onClick:()=>v&&n(s),disabled:!v,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function xp({scheduleName:e,onConfirm:r,onCancel:n}){return t.jsxs(o.Dialog,{open:!0,onClose:n,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:i=>ho(i),boxShadow:i=>`0 8px 32px ${I(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=>I(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:c}){const l=e.isActive;return t.jsxs(o.Box,{sx:{border:"1px solid",borderColor:l?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:l?d=>I(d.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(o.Typography,{variant:"body2",sx:{fontWeight:600,flex:1,minWidth:0,color:l?"text.primary":"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),t.jsx(o.Chip,{label:l?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:l?d=>I(d.palette.success.main,.1):d=>I(d.palette.text.primary,.06),color:l?"success.dark":"text.secondary"}})]}),t.jsx(o.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children: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:d=>I(d.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:d=>I(d.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:d=>I(d.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:[l&&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:d=>I(d.palette.primary.main,.08)}},children:t.jsx(z.Edit,{sx:{fontSize:15}})})}),t.jsx(o.Tooltip,{title:l?"Pause":"Resume",placement:"top",children:t.jsx(o.IconButton,{size:"small",onClick:()=>n(e.id),sx:{color:l?"warning.main":"success.main","&:hover":{bgcolor:l?d=>I(d.palette.warning.main,.08):d=>I(d.palette.success.main,.08)}},children:l?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:d=>I(d.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:()=>c(e.id),sx:{color:"error.main","&:hover":{bgcolor:d=>I(d.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[c,l]=p.useState([]),[d,u]=p.useState({type:"list"}),[h,g]=p.useState(0),[f,v]=p.useState(null);p.useEffect(()=>{e&&(l(Vs(n)),u({type:"list"}))},[e,n]),p.useEffect(()=>{if(!e)return;const a=setInterval(()=>g($=>$+1),3e4);return()=>clearInterval(a)},[e]);const S=p.useCallback(a=>{l(a),Hs(n,a)},[n]),B=a=>{const $=Mo(a.frequency,a.time,a.dayOfWeek,a.dayOfMonth),W={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};S([...c,W]),u({type:"list"})},C=a=>{if(d.type!=="edit")return;const $=d.schedule,W=Mo(a.frequency,a.time,a.dayOfWeek,a.dayOfMonth);S(c.map(J=>J.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:W}:J)),u({type:"list"})},m=a=>{S(c.map($=>{if($.id!==a)return $;const W=$.isActive?$.nextRunAt:Mo($.frequency,$.time,$.dayOfWeek,$.dayOfMonth);return{...$,isActive:!$.isActive,nextRunAt:W}}))},j=a=>{s(a);const $=new Date().toISOString();S(c.map(W=>W.id===a.id?{...W,lastRunAt:$,runCount:W.runCount+1}:W))},y=a=>{const $=c.find(W=>W.id===a)??null;v($)},O=()=>{f&&(S(c.filter(a=>a.id!==f.id)),v(null))},b=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=d.type!=="list",R=c.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=>He(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=>I(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(jr,{content:wr.schedule,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(o.Typography,{variant:"caption",color:"text.secondary",sx:{lineHeight:1},children:["· ",i]})]})]}),t.jsx(o.IconButton,{size:"small",onClick:r,sx:{color:"text.secondary","&:hover":{bgcolor:a=>I(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:[k&&t.jsx(pp,{initial:d.type==="edit"?b(d.schedule):Us,isEditing:d.type==="edit",onSave:d.type==="edit"?C:B,onBack:()=>u({type:"list"})}),d.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:c.length===0?"No schedules yet":`${R} of ${c.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"})]}),c.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:c.map(a=>t.jsx(mp,{schedule:a,tick:h,onToggle:m,onRunNow:j,onEdit:$=>u({type:"edit",schedule:$}),onDelete:y},a.id))})]})]}),d.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=>I(a.palette.warning.main,.06),border:"1px solid",borderColor:a=>I(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=>I(a.palette.text.primary,.06)}},children:"Close"})]})]}),f&&t.jsx(xp,{scheduleName:f.name,onConfirm:O,onCancel:()=>v(null)})]})}const hp=6e4;function gp({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:c,columnVisibility:l,columnOrder:d,filters:u,sortStack:h,onFired:g}){const f=p.useRef({reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:c,columnVisibility:l,columnOrder:d,filters:u,sortStack:h,onFired:g});p.useEffect(()=>{f.current={reportId:e,reportName:r,uploadedData:n,processedData:i,schema:s,activeView:c,columnVisibility:l,columnOrder:d,filters:u,sortStack:h,onFired:g}});const v=p.useCallback(S=>{var a,$;const{reportName:B,uploadedData:C,processedData:m,schema:j,activeView:y,columnVisibility:O,columnOrder:b,filters:k,sortStack:R}=f.current;try{const W=S.scope==="all"?C:m,J=Ao(W,j,k,R,y,O,b),te=`${S.name}_scheduled`;switch(S.format){case"csv":Ro(J,te,{scope:S.scope});break;case"excel":Wo(J,te,{scope:S.scope});break;case"json":Po(J,te,{scope:S.scope});break}if(S.email){const x=encodeURIComponent(`Scheduled Report: ${S.name}`),P=encodeURIComponent(`Your scheduled report "${S.name}" has been generated.
90
90
 
91
- Report: ${T}
92
- Format: ${v.format.toUpperCase()}
91
+ Report: ${B}
92
+ Format: ${S.format.toUpperCase()}
93
93
  Generated: ${new Date().toLocaleString()}
94
94
 
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;
95
+ The file has been downloaded to your device.`);window.open(`mailto:${S.email}?subject=${x}&body=${P}`,"_blank")}($=(a=f.current).onFired)==null||$.call(a,S)}catch(W){Ot.error("urm:scheduler",`Export failed for schedule: ${S.name}`,W)}},[]);p.useEffect(()=>{if(!e)return;const S=()=>{const{reportId:C}=f.current;if(!C)return;const m=Vs(C),j=new Date;let y=!1;const O=m.map(b=>{if(!b.isActive)return b;if(new Date(b.nextRunAt)<=j){v(b);const R=Mo(b.frequency,b.time,b.dayOfWeek,b.dayOfMonth,j);return y=!0,{...b,lastRunAt:j.toISOString(),nextRunAt:R,runCount:b.runCount+1}}return b});y&&Hs(C,O)};S();const B=setInterval(S,hp);return()=>clearInterval(B)},[e,v])}function Gs({reportEngine:e}){var Ze,Ke,mr,Zt,fr;const{activeReport:r,paginatedData:n,processedData:i,tableMetrics:s,tableEngine:c,activeView:l,isDirty:d,currentTableState:u,showFilterPanel:h,setShowFilterPanel:g,filterFocusColumn:f,handleReplaceFilters:v,handleOpenFilterForColumn:S,handleCloseFilterPanel:B,handleClearFiltersForColumn:C,showSortPanel:m,setShowSortPanel:j,handleSort:y,handleUpdateSortStack:O,handleSortAscending:b,handleSortDescending:k,showCreateViewModal:R,setShowCreateViewModal:a,showEditViewModal:$,setShowEditViewModal:W,showDeleteConfirmation:J,setShowDeleteConfirmation:te,editingView:x,deletingView:P,handleSelectView:F,handleCreateView:re,handleUpdateCurrentView:ce,handleSaveAsNewView:X,handleRevertChanges:ee,handleToggleDefault:fe,handleToggleFavorite:V,handleSoftDelete:K,handleRestoreView:oe,handlePermanentDelete:ie,handleEditView:H,handleCloneView:ae,handleCopyViewLink:se,handleSaveEditView:D,handleConfirmDelete:Z,handlePromoteToGlobal:ue,showManageColumns:ne,setShowManageColumns:ye,handleUpdateColumnVisibility:G,handleUpdateColumnOrder:Ae,handleUpdateColumnWidth:yt,handleResetColumnLayout:st,showGroupPanel:kr,setShowGroupPanel:Tr,handleGroup:bt,handleToggleGroupCollapse:Br,handleExpandAllGroups:at,handleCollapseAllGroups:Gt,searchQuery:kt,debouncedSearchQuery:lt,searchHistory:ct,handleSearchChange:_t,handleAddToSearchHistory:Mt,handleToggleSearchFavourite:Jr,handleDeleteSearchHistory:sr,selectedRowIds:ar,handleToggleRowSelection:Xe,handleToggleAllRows:Kr,handleRangeSelection:Ir,handleClearSelection:At,handleUpdateSelectionAfterDelete:Ue,currentPage:Tt,pageSize:Xr,paginationEngine:Qe,handlePageChange:lr,handlePageSizeChange:Re,isExporting:Yt,showExportModal:Rt,setShowExportModal:zr,showDirtyExportWarning:U,handleExport:cr,handleExportWithConfig:Er,handleExportSelected:vt,handleExportAnyway:N,handleSaveAndExport:dt,handleCancelExport:ge,showAuditHistory:Pe,setShowAuditHistory:dr,showCreatePreset:ur,setShowCreatePreset:Dr,showManagePresets:Wt,setShowManagePresets:$r,activePreset:qt,handleCreatePreset:Or,handleClearActivePreset:Pt,handleOpenPresetById:Be,handleDeletePresetById:Q,isViewerRole:ut,userRole:Ie,featureLimitWarning:Jt,setFeatureLimitWarning:pr,reportError:Kt,setReportError:Qr,handleError:Bt,updateReport:It,showSnack:Xt,config:Ve}=e,[xr,he]=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:l,columnVisibility:(r==null?void 0:r.columnVisibility)||((Ze=l==null?void 0:l.snapshot)==null?void 0:Ze.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((Ke=l==null?void 0:l.snapshot)==null?void 0:Ke.columnOrder)||[],filters:Oe(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:me=>{Xt(`Scheduled export "${me.name}" completed`,"success")}});const Ge=p.useCallback((me,Ce)=>{if(!(r!=null&&r.uploadedData))return;const $e=[...r.uploadedData];$e[me]=Ce,It(r.id,{uploadedData:$e})},[r,It]),_r=p.useCallback(me=>{if(!(r!=null&&r.uploadedData))return;const Ce=r.uploadedData.indexOf(me);if(Ce===-1)return;const $e=r.uploadedData.filter((Et,er)=>er!==Ce);It(r.id,{uploadedData:$e}),Ue(me)},[r,It,Ue]),pt=p.useCallback((me,Ce)=>{if(!(r!=null&&r.uploadedData))return;const $e=r.uploadedData.indexOf(Ce),Et=$e!==-1?$e+1:me+1,er=[...r.uploadedData];er.splice(Et,0,{...Ce}),It(r.id,{uploadedData:er})},[r,It]),St=Cr(),{handleDevConfigChange:zt}=Uo(),[Mr,Qt]=p.useState(!1);return p.useEffect(()=>{const me=Ce=>{Ce.ctrlKey&&Ce.shiftKey&&Ce.key==="D"&&(Ce.preventDefault(),Qt(!0))};return document.addEventListener("keydown",me),()=>document.removeEventListener("keydown",me)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(o.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[Jt&&t.jsx(Qu,{warning:Jt,onDismiss:()=>pr(null)}),Kt&&t.jsx(Zu,{error:Kt,onDismiss:()=>Qr(null)}),U&&t.jsx(Mu,{onExportAnyway:N,onSaveAndExport:dt,onCancel:ge}),t.jsx(wu,{schema:r.schema,data:n,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:d,isExporting:Yt,columnVisibility:r.columnVisibility||(l==null?void 0:l.snapshot.columnVisibility),columnOrder:r.columnOrder||(l==null?void 0:l.snapshot.columnOrder),columnWidths:r.columnWidths||(l==null?void 0:l.snapshot.columnWidths),grouping:r.grouping,onSort:y,onSortAscending:b,onSortDescending:k,onOpenFilters:()=>g(!0),onOpenSort:()=>j(!0),onOpenFilterForColumn:S,onSelectView:F,onCreateView:()=>a(!0),onUpdateCurrentView:ce,onSaveAsNewView:X,onDiscardChanges:ee,onToggleDefault:fe,onToggleFavorite:V,onRestoreView:oe,onPermanentDelete:ie,onEditView:H,onCloneView:ae,onCopyLink:se,onDeleteView:K,onPromoteToGlobal:ue,isAdmin:((mr=St.views)==null?void 0:mr.isAdmin)??!1,onExport:cr,onOpenColumns:()=>ye(!0),onUpdateColumnWidth:yt,onUpdateColumnOrder:Ae,onUpdateColumnVisibility:G,onClearFiltersForColumn:C,onResetLayout:st,onOpenGroup:()=>Tr(!0),onGroupByColumn:me=>{bt({enabled:!0,levels:[{column:me}],collapsedGroups:[]})},onToggleGroupCollapse:Br,onExpandAllGroups:at,onCollapseAllGroups:Gt,onOpenAuditHistory:()=>dr(!0),onOpenScheduledReports:()=>he(!0),searchQuery:kt,highlightQuery:lt,searchHistory:ct,onAddToSearchHistory:Mt,onToggleSearchFavourite:Jr,onDeleteSearchHistory:sr,selectedRowIds:ar,onSearchChange:_t,onToggleRowSelection:Xe,onToggleAllRows:Kr,onRangeSelection:Ir,onClearSelection:At,onExportSelected:vt,currentPage:(Qe==null?void 0:Qe.currentPage)||Tt,pageSize:(Qe==null?void 0:Qe.pageSize)||Xr,onPageChange:lr,onPageSizeChange:Re,totalRowsBeforePagination:(s==null?void 0:s.searchedRows)||i.length,isReadOnly:ut,userRole:Ie,reportName:r.name,onEditRow:Ge,onDeleteRow:_r,onDuplicateRow:pt,rowActions:Ve==null?void 0:Ve.rowActions,hideDefaultRowActions:Ve==null?void 0:Ve.hideDefaultRowActions,onRowClick:Ve==null?void 0:Ve.onRowClick,onRowRightClick:Ve==null?void 0:Ve.onRowRightClick,showDevPanel:St.display.showDevPanel,onOpenDevConfig:()=>Qt(!0)})]}),h&&t.jsx(Eo,{feature:"Filters",onError:me=>{const Ce=or("ui","filters",me);Bt(Ce)},children:t.jsx(Iu,{schema:r.schema,filters:r.filters,onReplaceFilters:v,onClose:B,focusColumn:f})}),m&&t.jsx(Eo,{feature:"Sorting",onError:me=>{const Ce=or("ui","sorting",me);Bt(Ce)},children:t.jsx(Eu,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:O,onClose:()=>j(!1)})}),R&&u&&(()=>{var $e;const me=(r.views??[]).filter(Et=>!Et.isDeleted).length,Ce=(($e=St.views)==null?void 0:$e.maxViews)??10;return t.jsx(Ki,{currentSnapshot:u,onSave:re,onClose:()=>a(!1),atViewLimit:me>=Ce,maxViews:Ce})})(),$&&x&&t.jsx(Ki,{currentSnapshot:x.snapshot,onSave:D,onClose:()=>{W(!1)},isEditMode:!0,initialName:x.name,initialDescription:x.description,initialIsDefault:x.isDefault}),J&&P&&t.jsx(Du,{viewName:P.name,onConfirm:Z,onCancel:()=>{te(!1)}}),ne&&l&&t.jsx(Ou,{schema:r.schema,columnVisibility:r.columnVisibility||l.snapshot.columnVisibility,columnOrder:r.columnOrder||l.snapshot.columnOrder,columnWidths:r.columnWidths||l.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:G,onUpdateColumnOrder:Ae,onUpdateColumnWidth:yt,onResetLayout:st,onClose:()=>ye(!1)}),kr&&t.jsx(Eo,{feature:"Grouping",onError:me=>{const Ce=or("ui","grouping",me);Bt(Ce)},children:t.jsx(_u,{schema:r.schema,grouping:r.grouping||null,onApply:bt,onClose:()=>Tr(!1)})}),Pe&&t.jsx(Wu,{auditHistory:r.auditHistory||[],onClose:()=>dr(!1)}),ur&&t.jsx(Pu,{onSave:Or,onClose:()=>Dr(!1)}),Wt&&t.jsx(Lu,{presets:r.presets||[],reportId:r.id,onOpenPreset:Be,onDeletePreset:Q,onClose:()=>$r(!1)}),qt&&t.jsx(o.Box,{sx:{mt:2},children:t.jsx(Nu,{presetName:qt.name,onClear:Pt})}),Rt&&t.jsx(Eo,{feature:"Export",onError:me=>{const Ce=or("ui","export",me);Bt(Ce)},children:t.jsx(Xu,{totalRows:(s==null?void 0:s.totalRows)||((Zt=r.uploadedData)==null?void 0:Zt.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((fr=c==null?void 0:c.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:Er,onClose:()=>{zr(!1)}})}),r&&t.jsx(fp,{open:xr,onClose:()=>he(!1),reportId:r.id,reportName:r.name,onRunNow:me=>{const Ce=me.scope==="all"?r.uploadedData||[]:i||[],$e=Ao(Ce,r.schema||[],Oe(r.filters),r.sortStack||[],l,r.columnVisibility,r.columnOrder);me.format==="csv"&&Ro($e,me.name),me.format==="excel"&&Wo($e,me.name),me.format==="json"&&Po($e,me.name),Xt(`"${me.name}" exported successfully`,"success")}}),t.jsx(np,{open:Mr,onClose:()=>Qt(!1),config:St,onApply:zt})]})}const yp={error:"err",warning:"warn",info:"info",success:"suc"};function Ys({open:e,message:r,severity:n,onClose:i,autoHideDurationMs:s}){var O,b,k,R;const c=o.useTheme(),l=c.tokens,d=(l==null?void 0:l.notifPosition)??"top-right",u=(l==null?void 0:l.notifStyle)??"toast",h=(l==null?void 0:l.notifAccent)??"severity",g=(l==null?void 0:l.notifAutoDismiss)??!0,f=(l==null?void 0:l.toastW)??252,v=d.startsWith("top")?"top":"bottom",S=d.endsWith("center")?"center":d.endsWith("left")?"left":"right",B=yp[n],C=((O=l==null?void 0:l.status)==null?void 0:O[`${B}Soft`])??c.palette[n].light,m=((b=l==null?void 0:l.status)==null?void 0:b[`${B}Txt`])??c.palette[n].dark,j=h==="primary"?c.palette.primary.main:h==="mono"?c.palette.text.secondary:m,y=u==="toast"?(l==null?void 0:l.toastBg)??c.palette.background.paper:C;return t.jsx(o.Snackbar,{open:e,autoHideDuration:g?s??(l!=null&&l.autoDismissSec?l.autoDismissSec*1e3:2e3):void 0,onClose:(a,$)=>{$!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:v,horizontal:S},children:t.jsx(o.Alert,{severity:n,icon:u==="toast"?t.jsx(o.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(c.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((k=l==null?void 0:l.status)==null?void 0:k[`${B}Soft`])??c.palette[n].light,color:((R=l==null?void 0:l.status)==null?void 0:R[`${B}Txt`])??c.palette[n].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:n==="error"||n==="warning"?"!":n==="success"?"✓":"i"}):void 0,action:t.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[g&&(l==null?void 0:l.autoDismissSec)&&t.jsx(o.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:I(j,.14),color:j,fontSize:"0.7rem",fontWeight:800,fontVariantNumeric:"tabular-nums"},children:`${l.autoDismissSec}s`}),t.jsx(o.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",p:.25},children:t.jsx(z.Close,{sx:{fontSize:16}})})]}),sx:{width:f,alignItems:"flex-start",bgcolor:y,color:m,boxShadow:u==="inline"?"none":(l==null?void 0:l.cardShadow)??3,border:u==="inline"?"1px solid":u==="toast"?(l==null?void 0:l.cardBorder)??"1px solid":"none",borderColor:"divider",borderLeft:u==="banner"?`4px solid ${j}`:void 0,borderRadius:`${c.shape.borderRadius}px`,"& .MuiAlert-icon":{color:j}},children:t.jsxs(o.Box,{children:[u==="toast"&&t.jsx(o.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:c.palette.text.primary},children:n==="error"?"Error":n==="warning"?"Warning":n==="success"?"Success":"Info"}),t.jsx(o.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function qs({hasExternalData:e=!1}){const r=Uo(),{reports:n,activeReportId:i,activeReport:s,uploadState:c,hasSchemaConflicts:l,isModalOpen:d,setIsModalOpen:u,setActiveReportId:h,createReport:g,handleFileUpload:f,handleUploadError:v,handleRetry:S,handleConfirm:B,snack:C,handleSnackClose:m,snackDurationMs:j}=r,y=e&&c==="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:c==="preview"&&s.schema&&s.uploadedData?t.jsx(Vd,{schema:s.schema,onConfirm:B,hasConflicts:l}):s.uploadError?t.jsx(Hd,{error:s.uploadError,onRetry:S}):t.jsx(Fd,{onFileUpload:f,onError:v,isUploading:c==="uploading"})})}):null}),!e&&t.jsx(Ld,{isOpen:d,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(Gn,{mode:"builder",data:e,dataSource:r,reportName:n,autoLoad:i,config:s,children:t.jsx(qs,{hasExternalData:!!(e||r)})})}function Js(){const e=Uo(),{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(Gn,{data:e,mode:"viewer",autoLoad:r,config:n,children:t.jsx(Js,{})})}exports.URMBuilder=bp;exports.URMBuilderRaw=qs;exports.URMProvider=Gn;exports.URMViewer=vp;exports.URMViewerRaw=Js;exports.useURMContext=Uo;