dts-universal-report-module 1.3.17 → 1.3.18

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 +6513 -6234
  2. package/dist/index.js +31 -31
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var za=Object.defineProperty;var Ba=(e,r,o)=>r in e?za(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o;var Oi=(e,r,o)=>Ba(e,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),Ea=require("xlsx"),D=require("@mui/icons-material"),n=require("@mui/material"),_a=require("@emotion/react"),Is=require("react-dom"),cr=require("react-dnd"),gi=require("react-dnd-html5-backend");function Os(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,i.get?i:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const gn=Os(p),Qo=Os(Ea),mt={sort:{maxLevels:5},filter:{maxConditions:3,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0},export:{allowedFormats:["csv","excel","json","pdf"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},Ms="urm_dev_config";function $a(){try{const e=localStorage.getItem(Ms);if(!e)return mt;const r=JSON.parse(e),o={sort:{...mt.sort,...r.sort},filter:{...mt.filter,...r.filter},columns:{...mt.columns,...r.columns},grouping:{...mt.grouping,...r.grouping},export:{...mt.export,...r.export},views:{...mt.views,...r.views},dates:{...mt.dates,...r.dates},display:{...mt.display,...r.display}};return o.sort.maxLevels=Math.min(5,Math.max(1,o.sort.maxLevels)),o}catch{return mt}}function Da(e){try{localStorage.setItem(Ms,JSON.stringify(e))}catch{}}function Ia(e,r,o){if(!o||!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 Oa=/^\d{4}-\d{2}-\d{2}$/,Ma=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/,Aa=/^(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{2,4})$|^([A-Za-z]+)\s+\d{1,2},?\s+\d{4}$/,Ra=9783072e5,Wa=41024448e5,Pa=978307200,La=4102444800;function Fa(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=Ra&&e<=Wa?"timestamp_ms":Number.isInteger(e)&&e>=Pa&&e<=La?"timestamp_s":"unknown":typeof e!="string"?"unknown":Ma.test(e)||Oa.test(e)?"iso":Aa.test(e.trim())?"locale_string":"unknown"}function Na(e,r){const o=r.map(l=>l[e]).filter(l=>l!=null&&l!=="");if(o.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const l of o){const c=Fa(l);i[c]++}const s=o.length,a=.7;for(const l of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[l]/s>=a)return l;return"unknown"}function Va(e,r){if(e==null||e==="")return null;try{switch(r){case"timestamp_ms":{const o=new Date(Number(e));return isNaN(o.getTime())?null:o}case"timestamp_s":{const o=new Date(Number(e)*1e3);return isNaN(o.getTime())?null:o}case"iso":{const o=new Date(String(e));return isNaN(o.getTime())?null:o}case"locale_string":{const o=new Date(String(e));return isNaN(o.getTime())?null:o}default:return null}}catch{return null}}const Mi=["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 Je(e){return String(e).padStart(2,"0")}function Ga(e){const r=Date.now()-e.getTime(),o=Math.abs(r),i=r>0,s=Math.floor(o/1e3),a=Math.floor(s/60),l=Math.floor(a/60),c=Math.floor(l/24),u=Math.floor(c/7),g=Math.floor(c/30),x=Math.floor(c/365);let y;return s<60?y="just now":a<60?y=`${a} minute${a!==1?"s":""}`:l<24?y=`${l} hour${l!==1?"s":""}`:c<7?y=`${c} day${c!==1?"s":""}`:u<5?y=`${u} week${u!==1?"s":""}`:g<12?y=`${g} month${g!==1?"s":""}`:y=`${x} year${x!==1?"s":""}`,s<60?y:i?`${y} ago`:`in ${y}`}function Ua(e,r){const o=e.getFullYear(),i=e.getMonth(),s=e.getDate(),a=e.getHours(),l=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${o}-${Je(i+1)}-${Je(s)}`;case"DD/MM/YYYY":return`${Je(s)}/${Je(i+1)}/${o}`;case"MM/DD/YYYY":return`${Je(i+1)}/${Je(s)}/${o}`;case"MMM DD, YYYY":return`${Mi[i]} ${Je(s)}, ${o}`;case"DD MMM YYYY":return`${Je(s)} ${Mi[i]} ${o}`;case"MMMM D, YYYY":return`${Ha[i]} ${s}, ${o}`;case"YYYY-MM-DD HH:mm":return`${o}-${Je(i+1)}-${Je(s)} ${Je(a)}:${Je(l)}`;case"DD/MM/YYYY HH:mm":return`${Je(s)}/${Je(i+1)}/${o} ${Je(a)}:${Je(l)}`;case"MM/DD/YYYY HH:mm":return`${Je(i+1)}/${Je(s)}/${o} ${Je(a)}:${Je(l)}`;case"relative":return Ga(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function Ya(e,r,o){if(!o||r==="unknown")return String(e);const i=Va(e,r);return!i||isNaN(i.getTime())?String(e):Ua(i,o)}function qa(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 As(e,r="",o=0){if(o>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const a=r?`${r}.${s}`:s,l=e[s];l!==null&&typeof l=="object"&&!Array.isArray(l)&&o<2?Object.assign(i,As(l,a,o+1)):i[a]=l}return i}function lo(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:As(r))}function ko(e){if(!Array.isArray(e)||e.length===0)return[];const r=lo(e),o=new Set;r.forEach(l=>{typeof l=="object"&&l!==null&&Object.keys(l).forEach(c=>o.add(c))});const i=[];o.forEach(l=>{const c=new Set;let u=0;r.forEach(w=>{typeof w=="object"&&w!==null&&l in w&&(u++,c.add(qa(w[l])))});const g=u===r.length,x=c.size>1&&!c.has("null");let y="mixed";if(c.size===1)y=Array.from(c)[0];else if(c.size===2&&c.has("null")){const w=Array.from(c).filter(b=>b!=="null");w.length===1&&(y=w[0])}i.push({name:l,type:y,required:g,hasConflict:x})});const a=r.slice(0,50);for(const l of i){if(l.type!=="string"&&l.type!=="number")continue;const c=Na(l.name,a);c!=="unknown"&&(l.type="date",l.dateFormat=c)}return i}function Ai(e,r){return!r||r.length===0?e:e.filter(o=>!r.includes(o.name))}function Ja(e){return e.some(r=>r.hasConflict)}function ut(e){if(!e)return"";const o=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return o.charAt(0).toUpperCase()+o.slice(1)}function Ri(e){return e==null}function Ka(e){return(r,o,i)=>{const s=Ri(r),a=Ri(o);if(s&&a)return 0;if(s)return 1;if(a)return-1;let l=0;switch(e){case"number":const c=Number(r),u=Number(o);l=c-u;break;case"boolean":l=(r?1:0)-(o?1:0);break;case"string":l=String(r).localeCompare(String(o));break;case"array":case"object":l=JSON.stringify(r).localeCompare(JSON.stringify(o));break;case"mixed":case"null":default:l=String(r).localeCompare(String(o));break}return i==="asc"?l:-l}}function yi(e,r,o){if(!o||o.length===0)return e;const i=[...o].sort((s,a)=>s.priority-a.priority);return[...e].sort((s,a)=>{for(const l of i){const c=r.find(x=>x.name===l.column);if(!c)continue;const g=Ka(c.type)(s[l.column],a[l.column],l.direction);if(g!==0)return g}return 0})}function Xa(e){return e===null?"asc":e==="asc"?"desc":null}function Qa(e){return e==="string"||e==="boolean"||e==="number"||e==="date"||e==="mixed"}function Za(e){return e.filter(r=>Qa(r.type))}function el(e,r){const o={};return r.forEach(i=>{if(i.type==="number"){const s=e.map(a=>a[i.name]).filter(a=>typeof a=="number");s.length>0&&(o[i.name]=s.reduce((a,l)=>a+l,0))}}),o}function tl(e,r,o){if(!o.enabled||o.levels.length===0)return e;const i=bi(e,o.levels,r);return Rs(i,o.collapsedGroups||[])}function bi(e,r,o,i="",s=0){if(s>=r.length)return e;const a=r[s].column,l=new Map;e.forEach(g=>{const x=g[a],y=x==null?"(empty)":String(x);l.has(y)||l.set(y,[]),l.get(y).push(g)});const c=[];return Array.from(l.keys()).sort().forEach(g=>{const x=l.get(g),y=`${a}:${g}`,w=i?`${i}|${y}`:y,b=el(x,o),z=s<r.length-1?bi(x,r,o,w,s+1):x,h={key:w,level:s,column:a,value:g,rowCount:x.length,aggregates:b,children:z};c.push(h)}),c}function Rs(e,r,o=[],i=0){for(const s of e)if("key"in s&&"level"in s&&"children"in s){const a=r.includes(s.key);o.push({isGroupHeader:!0,groupKey:s.key,groupLevel:s.level,groupColumn:s.column,groupValue:s.value,rowCount:s.rowCount,aggregates:s.aggregates,isCollapsed:a}),!a&&s.children&&Rs(s.children,r,o,i+1)}else o.push({...s,__urm_row_id__:s.__urm_row_id__,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return o}function Wi(e,r,o){if(!o.enabled||o.levels.length===0)return[];const i=bi(e,o.levels,r),s=[],a=l=>{for(const c of l)"key"in c&&"level"in c&&"children"in c&&(s.push(c.key),a(c.children))};return a(i),s}function rl(e,r){const o=e.collapsedGroups||[],i=o.includes(r)?o.filter(s=>s!==r):[...o,r];return{...e,collapsedGroups:i}}function Ws(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function ol(e,r,o){const i=r?ut(r):"",s=String(o??"");return i?`${i}: ${s}`:s}function uo(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Qe(e){return"children"in e}function At(){return{id:uo(),operator:"and",children:[]}}function Ue(e){return e?Array.isArray(e)?{id:uo(),operator:"and",children:e.map(r=>({...r,id:r.id??uo()}))}:e:At()}function Tt(e){return e?Qe(e)?e.children.reduce((r,o)=>r+Tt(o),0):1:0}function cn(e,r){if(e.id===r)return e;for(const o of e.children){if(o.id===r)return o;if(Qe(o)){const i=cn(o,r);if(i)return i}}}function po(e,r,o){return e.id===r?{...e,children:[...e.children,o]}:{...e,children:e.children.map(i=>Qe(i)?po(i,r,o):i)}}function vi(e,r,o){return{...e,children:e.children.map(i=>i.id===r&&!Qe(i)?{...i,...o}:Qe(i)?vi(i,r,o):i)}}function Si(e,r,o){return e.id===r?{...e,operator:o}:{...e,children:e.children.map(i=>Qe(i)?Si(i,r,o):i)}}function wi(e,r){const o=e.children.filter(i=>i.id!==r).map(i=>Qe(i)?wi(i,r):i).filter(i=>!Qe(i)||i.children.length>0);return{...e,children:o}}function di(e,r){return e?Qe(e)?e.children.some(o=>di(o,r)):e.column===r:!1}function Ps(e,r){const o=e.children.filter(i=>Qe(i)||i.column!==r).map(i=>Qe(i)?Ps(i,r):i).filter(i=>!Qe(i)||i.children.length>0);return{...e,children:o}}function Ls(e){return e?Qe(e)?e.children.flatMap(Ls):[e]:[]}function Ao(e){if(!e)return null;if(!Qe(e)){const{id:i,...s}=e;return s}const{id:r,...o}=e;return{...o,children:e.children.map(Ao)}}function Eo(e,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const o=r.levels.map(s=>s.column),i=e.filter(s=>!o.includes(s));return[...o,...i]}function Ci(e,r,o){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(a=>a.column),s=e.filter(a=>!i.includes(a));if(o){const a=[],l=new Set(i),c=new Set(s);let u=0;for(const g of o)l.has(g)?a.push(g):c.has(g)&&u<s.length?(a.push(s[u]),u++):c.has(g)||a.push(g);for(let g=u;g<s.length;g++)a.includes(s[g])||a.push(s[g]);return a}return[...e]}function Qn(e){const r={},o=[],i={};return e.forEach(s=>{r[s.name]=!0,o.push(s.name),i[s.name]=170}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:At(),sortStack:[],columnVisibility:r,columnOrder:o,columnWidths:i,grouping:null}}}function nl(e,r,o,i,s,a,l,c){const u={},g=[],x={};o.forEach(b=>{u[b.name]=!0,g.push(b.name),x[b.name]=170});const w=Ci(s||g,l||null,c||g);return{filters:Ue(e),sortStack:r||[],columnVisibility:i||u,columnOrder:w,columnWidths:a||x,grouping:l||null}}function il(e,r){const o=b=>{if(b==null)return b;if(Array.isArray(b))return b.map(z=>o(z));if(typeof b=="object"){const z={};return Object.keys(b).sort().forEach(h=>{z[h]=o(b[h])}),z}return b},i=b=>JSON.stringify(o(b));if(i(Ao(e.filters))!==i(Ao(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},a=r.columnVisibility??{};if(i(s)!==i(a))return!0;const l=Ci(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),c=[...l].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(c!==u)return!1;const g=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==g){if(l.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const b=[...l].sort().join(",");if(l.join(",")!==b)return!0}const y=e.columnWidths??{},w=r.columnWidths??{};return i(y)!==i(w)||i(e.grouping)!==i(r.grouping)}function sl(e){return!e||e.length===0?"None":e.sort((r,o)=>r.priority-o.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function al(e,r){var h,m,E;const o=[],i=JSON.stringify(Ao(e.filters)),s=JSON.stringify(Ao(r.filters));if(i!==s){const v=Tt(e.filters),T=Tt(r.filters);v>T?o.push({category:"filters",label:"Filters Added",description:`${v-T} new filter${v-T>1?"s":""} added`}):v<T?o.push({category:"filters",label:"Filters Removed",description:`${T-v} filter${T-v>1?"s":""} removed`}):o.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const a=JSON.stringify(e.sortStack),l=JSON.stringify(r.sortStack);if(a!==l){const v=e.sortStack.length,T=r.sortStack.length;v>T?o.push({category:"sorting",label:"Sorting Added",description:`${v-T} new sort rule${v-T>1?"s":""} added`}):v<T?o.push({category:"sorting",label:"Sorting Removed",description:`${T-v} sort rule${T-v>1?"s":""} removed`}):o.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 v=Object.values(e.columnVisibility).filter(B=>B).length,T=Object.values(r.columnVisibility).filter(B=>B).length;v>T?o.push({category:"visibility",label:"Columns Shown",description:`${v-T} column${v-T>1?"s":""} made visible`}):v<T?o.push({category:"visibility",label:"Columns Hidden",description:`${T-v} column${T-v>1?"s":""} hidden`}):o.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const g=JSON.stringify(e.columnOrder),x=JSON.stringify(r.columnOrder);g!==x&&o.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const y=JSON.stringify(e.columnWidths),w=JSON.stringify(r.columnWidths);if(y!==w){const v=Object.keys(e.columnWidths).filter(T=>e.columnWidths[T]!==r.columnWidths[T]).length;o.push({category:"widths",label:"Column Widths Adjusted",description:`${v} column width${v>1?"s":""} modified`})}const b=JSON.stringify(e.grouping),z=JSON.stringify(r.grouping);if(b!==z){const v=(h=e.grouping)==null?void 0:h.enabled,T=(m=r.grouping)==null?void 0:m.enabled;if(v&&!T){const B=((E=e.grouping)==null?void 0:E.levels.length)||0;o.push({category:"grouping",label:"Grouping Applied",description:`${B} grouping level${B>1?"s":""} added`})}else!v&&T?o.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):o.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return o}function Pi(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Li(e){return`[${e}]`}const Kt={warn(e,r,...o){Pi()&&console.warn(Li(e),r,...o)},error(e,r,...o){Pi()&&console.error(Li(e),r,...o)}},Fs="urm_report_";function ll(e,r){try{const o=`${Fs}${e}`;localStorage.setItem(o,JSON.stringify(r))}catch(o){Kt.error("urm:persistence","Failed to save report state",o)}}function cl(e){try{const r=`${Fs}${e}`,o=localStorage.getItem(r);return o?JSON.parse(o):null}catch(r){return Kt.error("urm:persistence","Failed to load report state",r),null}}function Wo(e,r,o=0){const i=[];for(const s of e){const a=r.includes(s.key);if(i.push({type:"group",key:s.key,level:o,column:s.column,value:s.value,rowCount:s.rowCount,aggregates:s.aggregates,collapsed:a}),!a&&s.children&&s.children.length>0){const l=s.children[0];if(dl(l)){const c=s.children,u=Wo(c,r,o+1);i.push(...u)}else{const c=s.children;for(const u of c)i.push({type:"row",parentGroupKey:s.key,level:o+1,data:u})}}}return i}function dl(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 yn(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function bn(e,r){const o=new Date,i=o.getFullYear(),s=String(o.getMonth()+1).padStart(2,"0"),a=String(o.getDate()).padStart(2,"0"),l=`${i}-${s}-${a}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${l}.${r}`}function un(e,r,o,i,s,a,l){let c,u;a?(c={...a},u=l||r.map(x=>x.name)):s?(c={...s.snapshot.columnVisibility},u=l||[...s.snapshot.columnOrder]):(c={},u=[],r.forEach(x=>{c[x.name]=!0,u.push(x.name)}));const g=Object.entries(c).filter(([x,y])=>!y).map(([x,y])=>x);return{data:e,schema:r,appliedFilters:o,appliedSortStack:i,columnVisibility:c,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:g,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function pn(e,r="export",o){const{data:i,columnOrder:s,grouping:a}=e,l=s.filter(y=>e.columnVisibility[y]);let c;if(a&&a.enabled){const y=a.collapsedGroups??[],w=Wo(i,y);c=yn(w)}else c=i;const u=l.join(","),g=c.map(y=>l.map(w=>{const b=y[w];if(b==null)return"";const z=String(b);return z.includes(",")||z.includes('"')||z.includes(`
2
- `)?`"${z.replace(/"/g,'""')}"`:z}).join(",")),x=[u,...g].join(`
3
- `);ji(x,bn(r,"csv"),"text/csv;charset=utf-8;")}function fn(e,r="export",o){const{data:i,columnOrder:s,grouping:a}=e,l=s.filter(y=>e.columnVisibility[y]);let c;if(a&&a.enabled){const y=a.collapsedGroups??[],w=Wo(i,y);c=yn(w)}else c=i;const u=[l,...c.map(y=>l.map(w=>y[w]??""))],g=Qo.utils.aoa_to_sheet(u),x=Qo.utils.book_new();Qo.utils.book_append_sheet(x,g,"Data"),Qo.writeFile(x,bn(r,"xlsx"))}function mn(e,r="export",o){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:l,hiddenColumns:c,columnOrder:u,grouping:g}=e,x=u.filter(z=>e.columnVisibility[z]);let y;if(g&&g.enabled){const z=g.collapsedGroups??[],h=Wo(i,z);y=yn(h)}else y=i;y=y.map(z=>{const h={};return x.forEach(m=>{h[m]=z[m]}),h});const w={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(l==null?void 0:l.name)||"Default View",filters:Ls(s).map(z=>({field:z.column,operator:z.operator,value:z.value})),sortStack:a.map(z=>({field:z.column,direction:z.direction,priority:z.priority})),grouping:g||{},hiddenColumns:c,columnOrder:u,exportConfig:o||{scope:"visible"}},data:y},b=JSON.stringify(w,null,2);ji(b,bn(r,"json"),"application/json;charset=utf-8;")}function ji(e,r,o){const i=new Blob([e],{type:o}),s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}function ki(e,r="export",o){var h;const{data:i,columnOrder:s,grouping:a}=e,l=s.filter(m=>e.columnVisibility[m]);let c;if(a&&a.enabled){const m=a.collapsedGroups??[],E=Wo(i,m);c=yn(E)}else c=i;const u=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),g=l.map(m=>`<th>${Zo(m)}</th>`).join(""),x=c.map((m,E)=>{const v=l.map(T=>{const B=m[T],f=B==null?"":String(B);return`<td>${Zo(f)}</td>`}).join("");return`<tr class="${E%2===0?"even":"odd"}">${v}</tr>`}).join(""),y=`<!DOCTYPE html>
1
+ "use strict";var $a=Object.defineProperty;var Ia=(e,r,o)=>r in e?$a(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o;var Ri=(e,r,o)=>Ia(e,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),Da=require("xlsx"),_=require("@mui/icons-material"),n=require("@mui/material"),Oa=require("@emotion/react"),Ws=require("react-dom"),ar=require("react-dnd"),bi=require("react-dnd-html5-backend");function Ps(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,i.get?i:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const mn=Ps(p),Ko=Ps(Da),ft={sort:{maxLevels:5},filter:{maxConditions:3,allowedOperators:["equals","contains","startsWith","endsWith","gt","lt","gte","lte","isTrue","isFalse","NULL","NOT_NULL"]},columns:{maxVisible:20,minColumnWidth:60,maxColumnWidth:800},grouping:{maxLevels:3,allowNested:!0,allowCollapse:!0},export:{allowedFormats:["csv","excel","json","pdf"]},views:{maxViews:10,isAdmin:!1},dates:{displayFormat:null},display:{showDevPanel:!1}},Ls="urm_dev_config";function Ma(){try{const e=localStorage.getItem(Ls);if(!e)return ft;const r=JSON.parse(e),o={sort:{...ft.sort,...r.sort},filter:{...ft.filter,...r.filter},columns:{...ft.columns,...r.columns},grouping:{...ft.grouping,...r.grouping},export:{...ft.export,...r.export},views:{...ft.views,...r.views},dates:{...ft.dates,...r.dates},display:{...ft.display,...r.display}};return o.sort.maxLevels=Math.min(5,Math.max(1,o.sort.maxLevels)),o}catch{return ft}}function Aa(e){try{localStorage.setItem(Ls,JSON.stringify(e))}catch{}}function Ra(e,r,o){if(!o||!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 Wa=/^\d{4}-\d{2}-\d{2}$/,Pa=/^\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}$/,Fa=9783072e5,Na=41024448e5,Va=978307200,Ha=4102444800;function Ga(e){return e==null||e===""?"unknown":typeof e=="number"?Number.isInteger(e)&&e>=Fa&&e<=Na?"timestamp_ms":Number.isInteger(e)&&e>=Va&&e<=Ha?"timestamp_s":"unknown":typeof e!="string"?"unknown":Pa.test(e)||Wa.test(e)?"iso":La.test(e.trim())?"locale_string":"unknown"}function Ua(e,r){const o=r.map(l=>l[e]).filter(l=>l!=null&&l!=="");if(o.length===0)return"unknown";const i={iso:0,timestamp_ms:0,timestamp_s:0,locale_string:0,unknown:0};for(const l of o){const c=Ga(l);i[c]++}const s=o.length,a=.7;for(const l of["iso","timestamp_ms","timestamp_s","locale_string"])if(i[l]/s>=a)return l;return"unknown"}function Ya(e,r){if(e==null||e==="")return null;try{switch(r){case"timestamp_ms":{const o=new Date(Number(e));return isNaN(o.getTime())?null:o}case"timestamp_s":{const o=new Date(Number(e)*1e3);return isNaN(o.getTime())?null:o}case"iso":{const o=new Date(String(e));return isNaN(o.getTime())?null:o}case"locale_string":{const o=new Date(String(e));return isNaN(o.getTime())?null:o}default:return null}}catch{return null}}const Wi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],qa=["January","February","March","April","May","June","July","August","September","October","November","December"];function Xe(e){return String(e).padStart(2,"0")}function Ja(e){const r=Date.now()-e.getTime(),o=Math.abs(r),i=r>0,s=Math.floor(o/1e3),a=Math.floor(s/60),l=Math.floor(a/60),c=Math.floor(l/24),u=Math.floor(c/7),x=Math.floor(c/30),g=Math.floor(c/365);let y;return s<60?y="just now":a<60?y=`${a} minute${a!==1?"s":""}`:l<24?y=`${l} hour${l!==1?"s":""}`:c<7?y=`${c} day${c!==1?"s":""}`:u<5?y=`${u} week${u!==1?"s":""}`:x<12?y=`${x} month${x!==1?"s":""}`:y=`${g} year${g!==1?"s":""}`,s<60?y:i?`${y} ago`:`in ${y}`}function Ka(e,r){const o=e.getFullYear(),i=e.getMonth(),s=e.getDate(),a=e.getHours(),l=e.getMinutes();switch(r){case"YYYY-MM-DD":return`${o}-${Xe(i+1)}-${Xe(s)}`;case"DD/MM/YYYY":return`${Xe(s)}/${Xe(i+1)}/${o}`;case"MM/DD/YYYY":return`${Xe(i+1)}/${Xe(s)}/${o}`;case"MMM DD, YYYY":return`${Wi[i]} ${Xe(s)}, ${o}`;case"DD MMM YYYY":return`${Xe(s)} ${Wi[i]} ${o}`;case"MMMM D, YYYY":return`${qa[i]} ${s}, ${o}`;case"YYYY-MM-DD HH:mm":return`${o}-${Xe(i+1)}-${Xe(s)} ${Xe(a)}:${Xe(l)}`;case"DD/MM/YYYY HH:mm":return`${Xe(s)}/${Xe(i+1)}/${o} ${Xe(a)}:${Xe(l)}`;case"MM/DD/YYYY HH:mm":return`${Xe(i+1)}/${Xe(s)}/${o} ${Xe(a)}:${Xe(l)}`;case"relative":return Ja(e);case"locale":return e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});default:return e.toLocaleDateString()}}function Xa(e,r,o){if(!o||r==="unknown")return String(e);const i=Ya(e,r);return!i||isNaN(i.getTime())?String(e):Ka(i,o)}function Qa(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 Fs(e,r="",o=0){if(o>2)return{[r]:e};const i={};for(const s of Object.keys(e)){const a=r?`${r}.${s}`:s,l=e[s];l!==null&&typeof l=="object"&&!Array.isArray(l)&&o<2?Object.assign(i,Fs(l,a,o+1)):i[a]=l}return i}function lo(e){return e.map(r=>typeof r!="object"||r===null||Array.isArray(r)?r:Fs(r))}function Co(e){if(!Array.isArray(e)||e.length===0)return[];const r=lo(e),o=new Set;r.forEach(l=>{typeof l=="object"&&l!==null&&Object.keys(l).forEach(c=>o.add(c))});const i=[];o.forEach(l=>{const c=new Set;let u=0;r.forEach(S=>{typeof S=="object"&&S!==null&&l in S&&(u++,c.add(Qa(S[l])))});const x=u===r.length,g=c.size>1&&!c.has("null");let y="mixed";if(c.size===1)y=Array.from(c)[0];else if(c.size===2&&c.has("null")){const S=Array.from(c).filter(b=>b!=="null");S.length===1&&(y=S[0])}i.push({name:l,type:y,required:x,hasConflict:g})});const a=r.slice(0,50);for(const l of i){if(l.type!=="string"&&l.type!=="number")continue;const c=Ua(l.name,a);c!=="unknown"&&(l.type="date",l.dateFormat=c)}return i}function Pi(e,r){return!r||r.length===0?e:e.filter(o=>!r.includes(o.name))}function Za(e){return e.some(r=>r.hasConflict)}function pt(e){if(!e)return"";const o=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return o.charAt(0).toUpperCase()+o.slice(1)}function Li(e){return e==null}function el(e){return(r,o,i)=>{const s=Li(r),a=Li(o);if(s&&a)return 0;if(s)return 1;if(a)return-1;let l=0;switch(e){case"number":const c=Number(r),u=Number(o);l=c-u;break;case"boolean":l=(r?1:0)-(o?1:0);break;case"string":l=String(r).localeCompare(String(o));break;case"array":case"object":l=JSON.stringify(r).localeCompare(JSON.stringify(o));break;case"mixed":case"null":default:l=String(r).localeCompare(String(o));break}return i==="asc"?l:-l}}function vi(e,r,o){if(!o||o.length===0)return e;const i=[...o].sort((s,a)=>s.priority-a.priority);return[...e].sort((s,a)=>{for(const l of i){const c=r.find(g=>g.name===l.column);if(!c)continue;const x=el(c.type)(s[l.column],a[l.column],l.direction);if(x!==0)return x}return 0})}function tl(e){return e===null?"asc":e==="asc"?"desc":null}function rl(e){return e==="string"||e==="boolean"||e==="number"||e==="date"||e==="mixed"}function ol(e){return e.filter(r=>rl(r.type))}function nl(e,r){const o={};return r.forEach(i=>{if(i.type==="number"){const s=e.map(a=>a[i.name]).filter(a=>typeof a=="number");s.length>0&&(o[i.name]=s.reduce((a,l)=>a+l,0))}}),o}function il(e,r,o){if(!o.enabled||o.levels.length===0)return e;const i=Si(e,o.levels,r);return Ns(i,o.collapsedGroups||[])}function Si(e,r,o,i="",s=0){if(s>=r.length)return e;const a=r[s].column,l=new Map;e.forEach(x=>{const g=x[a],y=g==null?"(empty)":String(g);l.has(y)||l.set(y,[]),l.get(y).push(x)});const c=[];return Array.from(l.keys()).sort().forEach(x=>{const g=l.get(x),y=`${a}:${x}`,S=i?`${i}|${y}`:y,b=nl(g,o),T=s<r.length-1?Si(g,r,o,S,s+1):g,m={key:S,level:s,column:a,value:x,rowCount:g.length,aggregates:b,children:T};c.push(m)}),c}function Ns(e,r,o=[],i=0){for(const s of e)if("key"in s&&"level"in s&&"children"in s){const a=r.includes(s.key);o.push({isGroupHeader:!0,groupKey:s.key,groupLevel:s.level,groupColumn:s.column,groupValue:s.value,rowCount:s.rowCount,aggregates:s.aggregates,isCollapsed:a}),!a&&s.children&&Ns(s.children,r,o,i+1)}else o.push({...s,__urm_row_id__:s.__urm_row_id__,__urm_is_grouped_data_row__:!0,__urm_group_level__:i});return o}function Fi(e,r,o){if(!o.enabled||o.levels.length===0)return[];const i=Si(e,o.levels,r),s=[],a=l=>{for(const c of l)"key"in c&&"level"in c&&"children"in c&&(s.push(c.key),a(c.children))};return a(i),s}function sl(e,r){const o=e.collapsedGroups||[],i=o.includes(r)?o.filter(s=>s!==r):[...o,r];return{...e,collapsedGroups:i}}function Vs(e,r){return e==null?"":typeof e=="number"?`Σ ${e.toLocaleString()}`:String(e)}function al(e,r,o){const i=r?pt(r):"",s=String(o??"");return i?`${i}: ${s}`:s}function uo(){return`flt_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function et(e){return"children"in e}function At(){return{id:uo(),operator:"and",children:[]}}function qe(e){return e?Array.isArray(e)?{id:uo(),operator:"and",children:e.map(r=>({...r,id:r.id??uo()}))}:e:At()}function Tt(e){return e?et(e)?e.children.reduce((r,o)=>r+Tt(o),0):1:0}function an(e,r){if(e.id===r)return e;for(const o of e.children){if(o.id===r)return o;if(et(o)){const i=an(o,r);if(i)return i}}}function po(e,r,o){return e.id===r?{...e,children:[...e.children,o]}:{...e,children:e.children.map(i=>et(i)?po(i,r,o):i)}}function wi(e,r,o){return{...e,children:e.children.map(i=>i.id===r&&!et(i)?{...i,...o}:et(i)?wi(i,r,o):i)}}function Ci(e,r,o){return e.id===r?{...e,operator:o}:{...e,children:e.children.map(i=>et(i)?Ci(i,r,o):i)}}function ji(e,r){const o=e.children.filter(i=>i.id!==r).map(i=>et(i)?ji(i,r):i).filter(i=>!et(i)||i.children.length>0);return{...e,children:o}}function pi(e,r){return e?et(e)?e.children.some(o=>pi(o,r)):e.column===r:!1}function Hs(e,r){const o=e.children.filter(i=>et(i)||i.column!==r).map(i=>et(i)?Hs(i,r):i).filter(i=>!et(i)||i.children.length>0);return{...e,children:o}}function Gs(e){return e?et(e)?e.children.flatMap(Gs):[e]:[]}function Oo(e){if(!e)return null;if(!et(e)){const{id:i,...s}=e;return s}const{id:r,...o}=e;return{...o,children:e.children.map(Oo)}}function zo(e,r){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const o=r.levels.map(s=>s.column),i=e.filter(s=>!o.includes(s));return[...o,...i]}function ki(e,r,o){if(!r||!r.enabled||!r.levels||r.levels.length===0)return[...e];const i=r.levels.map(a=>a.column),s=e.filter(a=>!i.includes(a));if(o){const a=[],l=new Set(i),c=new Set(s);let u=0;for(const x of o)l.has(x)?a.push(x):c.has(x)&&u<s.length?(a.push(s[u]),u++):c.has(x)||a.push(x);for(let x=u;x<s.length;x++)a.includes(s[x])||a.push(s[x]);return a}return[...e]}function Zn(e){const r={},o=[],i={};return e.forEach(s=>{r[s.name]=!0,o.push(s.name),i[s.name]=170}),{id:"default-view",name:"Default View",description:"Unfiltered, unsorted baseline view",isDefault:!0,snapshot:{filters:At(),sortStack:[],columnVisibility:r,columnOrder:o,columnWidths:i,grouping:null}}}function ll(e,r,o,i,s,a,l,c){const u={},x=[],g={};o.forEach(b=>{u[b.name]=!0,x.push(b.name),g[b.name]=170});const S=ki(s||x,l||null,c||x);return{filters:qe(e),sortStack:r||[],columnVisibility:i||u,columnOrder:S,columnWidths:a||g,grouping:l||null}}function cl(e,r){const o=b=>{if(b==null)return b;if(Array.isArray(b))return b.map(T=>o(T));if(typeof b=="object"){const T={};return Object.keys(b).sort().forEach(m=>{T[m]=o(b[m])}),T}return b},i=b=>JSON.stringify(o(b));if(i(Oo(e.filters))!==i(Oo(r.filters))||i(e.sortStack)!==i(r.sortStack))return!0;const s=e.columnVisibility??{},a=r.columnVisibility??{};if(i(s)!==i(a))return!0;const l=ki(e.columnOrder||[],e.grouping||null,r.columnOrder||[]),c=[...l].sort().join(","),u=[...r.columnOrder||[]].sort().join(",");if(c!==u)return!1;const x=[...r.columnOrder||[]].sort().join(",");if((r.columnOrder||[]).join(",")!==x){if(l.join(",")!==(r.columnOrder||[]).join(","))return!0}else{const b=[...l].sort().join(",");if(l.join(",")!==b)return!0}const y=e.columnWidths??{},S=r.columnWidths??{};return i(y)!==i(S)||i(e.grouping)!==i(r.grouping)}function dl(e){return!e||e.length===0?"None":e.sort((r,o)=>r.priority-o.priority).map(r=>`${r.column} ${r.direction==="asc"?"↑":"↓"}`).join(", ")}function ul(e,r){var m,f,B;const o=[],i=JSON.stringify(Oo(e.filters)),s=JSON.stringify(Oo(r.filters));if(i!==s){const j=Tt(e.filters),D=Tt(r.filters);j>D?o.push({category:"filters",label:"Filters Added",description:`${j-D} new filter${j-D>1?"s":""} added`}):j<D?o.push({category:"filters",label:"Filters Removed",description:`${D-j} filter${D-j>1?"s":""} removed`}):o.push({category:"filters",label:"Filters Modified",description:"Filter conditions have been changed"})}const a=JSON.stringify(e.sortStack),l=JSON.stringify(r.sortStack);if(a!==l){const j=e.sortStack.length,D=r.sortStack.length;j>D?o.push({category:"sorting",label:"Sorting Added",description:`${j-D} new sort rule${j-D>1?"s":""} added`}):j<D?o.push({category:"sorting",label:"Sorting Removed",description:`${D-j} sort rule${D-j>1?"s":""} removed`}):o.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 j=Object.values(e.columnVisibility).filter(z=>z).length,D=Object.values(r.columnVisibility).filter(z=>z).length;j>D?o.push({category:"visibility",label:"Columns Shown",description:`${j-D} column${j-D>1?"s":""} made visible`}):j<D?o.push({category:"visibility",label:"Columns Hidden",description:`${D-j} column${D-j>1?"s":""} hidden`}):o.push({category:"visibility",label:"Column Visibility Changed",description:"Column visibility settings have been modified"})}const x=JSON.stringify(e.columnOrder),g=JSON.stringify(r.columnOrder);x!==g&&o.push({category:"order",label:"Column Order Changed",description:"Columns have been reordered"});const y=JSON.stringify(e.columnWidths),S=JSON.stringify(r.columnWidths);if(y!==S){const j=Object.keys(e.columnWidths).filter(D=>e.columnWidths[D]!==r.columnWidths[D]).length;o.push({category:"widths",label:"Column Widths Adjusted",description:`${j} column width${j>1?"s":""} modified`})}const b=JSON.stringify(e.grouping),T=JSON.stringify(r.grouping);if(b!==T){const j=(m=e.grouping)==null?void 0:m.enabled,D=(f=r.grouping)==null?void 0:f.enabled;if(j&&!D){const z=((B=e.grouping)==null?void 0:B.levels.length)||0;o.push({category:"grouping",label:"Grouping Applied",description:`${z} grouping level${z>1?"s":""} added`})}else!j&&D?o.push({category:"grouping",label:"Grouping Removed",description:"All grouping has been cleared"}):o.push({category:"grouping",label:"Grouping Modified",description:"Grouping configuration has been changed"})}return o}function Ni(){try{return localStorage.getItem("urm:debug")==="true"}catch{return!1}}function Vi(e){return`[${e}]`}const qt={warn(e,r,...o){Ni()&&console.warn(Vi(e),r,...o)},error(e,r,...o){Ni()&&console.error(Vi(e),r,...o)}},Us="urm_report_";function pl(e,r){try{const o=`${Us}${e}`;localStorage.setItem(o,JSON.stringify(r))}catch(o){qt.error("urm:persistence","Failed to save report state",o)}}function fl(e){try{const r=`${Us}${e}`,o=localStorage.getItem(r);return o?JSON.parse(o):null}catch(r){return qt.error("urm:persistence","Failed to load report state",r),null}}function Ao(e,r,o=0){const i=[];for(const s of e){const a=r.includes(s.key);if(i.push({type:"group",key:s.key,level:o,column:s.column,value:s.value,rowCount:s.rowCount,aggregates:s.aggregates,collapsed:a}),!a&&s.children&&s.children.length>0){const l=s.children[0];if(hl(l)){const c=s.children,u=Ao(c,r,o+1);i.push(...u)}else{const c=s.children;for(const u of c)i.push({type:"row",parentGroupKey:s.key,level:o+1,data:u})}}}return i}function hl(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 xn(e){return e.filter(r=>r.type==="row").map(r=>r.type==="row"?r.data:null).filter(r=>r!==null)}function gn(e,r){const o=new Date,i=o.getFullYear(),s=String(o.getMonth()+1).padStart(2,"0"),a=String(o.getDate()).padStart(2,"0"),l=`${i}-${s}-${a}`;return`${e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}_${l}.${r}`}function cn(e,r,o,i,s,a,l){let c,u;a?(c={...a},u=l||r.map(g=>g.name)):s?(c={...s.snapshot.columnVisibility},u=l||[...s.snapshot.columnOrder]):(c={},u=[],r.forEach(g=>{c[g.name]=!0,u.push(g.name)}));const x=Object.entries(c).filter(([g,y])=>!y).map(([g,y])=>g);return{data:e,schema:r,appliedFilters:o,appliedSortStack:i,columnVisibility:c,columnOrder:u,grouping:(s==null?void 0:s.snapshot.grouping)??null,hiddenColumns:x,viewMeta:s?{id:s.id,name:s.name,isDefault:s.isDefault}:void 0}}function dn(e,r="export",o){const{data:i,columnOrder:s,grouping:a}=e,l=s.filter(y=>e.columnVisibility[y]);let c;if(a&&a.enabled){const y=a.collapsedGroups??[],S=Ao(i,y);c=xn(S)}else c=i;const u=l.join(","),x=c.map(y=>l.map(S=>{const b=y[S];if(b==null)return"";const T=String(b);return T.includes(",")||T.includes('"')||T.includes(`
2
+ `)?`"${T.replace(/"/g,'""')}"`:T}).join(",")),g=[u,...x].join(`
3
+ `);Ti(g,gn(r,"csv"),"text/csv;charset=utf-8;")}function un(e,r="export",o){const{data:i,columnOrder:s,grouping:a}=e,l=s.filter(y=>e.columnVisibility[y]);let c;if(a&&a.enabled){const y=a.collapsedGroups??[],S=Ao(i,y);c=xn(S)}else c=i;const u=[l,...c.map(y=>l.map(S=>y[S]??""))],x=Ko.utils.aoa_to_sheet(u),g=Ko.utils.book_new();Ko.utils.book_append_sheet(g,x,"Data"),Ko.writeFile(g,gn(r,"xlsx"))}function pn(e,r="export",o){const{data:i,appliedFilters:s,appliedSortStack:a,viewMeta:l,hiddenColumns:c,columnOrder:u,grouping:x}=e,g=u.filter(T=>e.columnVisibility[T]);let y;if(x&&x.enabled){const T=x.collapsedGroups??[],m=Ao(i,T);y=xn(m)}else y=i;y=y.map(T=>{const m={};return g.forEach(f=>{m[f]=T[f]}),m});const S={meta:{exportedAt:new Date().toISOString(),reportName:r,view:(l==null?void 0:l.name)||"Default View",filters:Gs(s).map(T=>({field:T.column,operator:T.operator,value:T.value})),sortStack:a.map(T=>({field:T.column,direction:T.direction,priority:T.priority})),grouping:x||{},hiddenColumns:c,columnOrder:u,exportConfig:o||{scope:"visible"}},data:y},b=JSON.stringify(S,null,2);Ti(b,gn(r,"json"),"application/json;charset=utf-8;")}function Ti(e,r,o){const i=new Blob([e],{type:o}),s=URL.createObjectURL(i),a=document.createElement("a");a.href=s,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(s)}function zi(e,r="export",o){var m;const{data:i,columnOrder:s,grouping:a}=e,l=s.filter(f=>e.columnVisibility[f]);let c;if(a&&a.enabled){const f=a.collapsedGroups??[],B=Ao(i,f);c=xn(B)}else c=i;const u=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),x=l.map(f=>`<th>${Xo(f)}</th>`).join(""),g=c.map((f,B)=>{const j=l.map(D=>{const z=f[D],h=z==null?"":String(z);return`<td>${Xo(h)}</td>`}).join("");return`<tr class="${B%2===0?"even":"odd"}">${j}</tr>`}).join(""),y=`<!DOCTYPE html>
4
4
  <html lang="en">
5
5
  <head>
6
6
  <meta charset="UTF-8" />
7
- <title>${Zo(r)}</title>
7
+ <title>${Xo(r)}</title>
8
8
  <style>
9
9
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
10
10
  body {
@@ -82,15 +82,15 @@
82
82
  </head>
83
83
  <body>
84
84
  <div class="report-header">
85
- <div class="report-title">${Zo(r)}</div>
85
+ <div class="report-title">${Xo(r)}</div>
86
86
  <div class="report-meta">
87
87
  ${c.length.toLocaleString()} row${c.length!==1?"s":""}<br/>
88
88
  Generated ${u}
89
89
  </div>
90
90
  </div>
91
91
  <table>
92
- <thead><tr>${g}</tr></thead>
93
- <tbody>${x}</tbody>
92
+ <thead><tr>${x}</tr></thead>
93
+ <tbody>${g}</tbody>
94
94
  </table>
95
95
  <div class="report-footer">Universal Report Module &mdash; PDF Export</div>
96
96
  <script>
@@ -102,26 +102,26 @@
102
102
  };
103
103
  <\/script>
104
104
  </body>
105
- </html>`;try{const m=document.createElement("iframe");m.style.position="fixed",m.style.right="0",m.style.bottom="0",m.style.width="0",m.style.height="0",m.style.border="0",document.body.appendChild(m);const E=((h=m.contentWindow)==null?void 0:h.document)||m.contentDocument;if(E){E.open(),E.write(y),E.close(),setTimeout(()=>{var v,T;try{(v=m.contentWindow)==null||v.focus(),(T=m.contentWindow)==null||T.print()}catch{}setTimeout(()=>{document.body.removeChild(m)},3e3)},300);return}}catch{}const w=new Blob([y],{type:"text/html;charset=utf-8;"}),b=URL.createObjectURL(w);window.open(b,"_blank")||ji(y,bn(r,"html"),"text/html;charset=utf-8;")}function Zo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Fi=10;function ul(e,r){const o=r.trim();if(!o)return e;const i=e.findIndex(a=>a.query.toLowerCase()===o.toLowerCase());let s;return i!==-1?s=[{...e[i],lastUsed:Date.now()},...e.slice(0,i),...e.slice(i+1)]:s=[{query:o,isFavourite:!1,lastUsed:Date.now()},...e],s.length>Fi&&(s=[...s].sort((l,c)=>l.isFavourite&&!c.isFavourite?-1:!l.isFavourite&&c.isFavourite?1:c.lastUsed-l.lastUsed).slice(0,Fi)),s}function pl(e,r){return e.map(o=>o.query===r?{...o,isFavourite:!o.isFavourite}:o)}function fl(e,r){return e.filter(o=>o.query!==r)}function ml(e){const r=e.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),o=e.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...r,...o]}const hl={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 xl(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function Ct(e,r){return hl[r].includes(e)}function jt(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 gl(e){return e==="viewer"}const Ni=1e3;function ui(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Jt(e){if(!e)return"";const o=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return ui(o)}const yl={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 bl(e){if(!e||!e.column)return"a filter";const r=Jt(e.column),o=yl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${o}`:`"${r}" ${o} "${e.value}"`}function Zn(e){return e?typeof e=="string"?e:"children"in e?"a condition group":bl(e):"a filter"}function Vi(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(o=>`"${Jt(o.column)}"`).join(", ")}`}function vl(e){var s,a,l;const{action:r,previousState:o,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${Zn(i)}`};case"filter_removed":return{summary:`Filter removed: ${Zn(o)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const c=o,u=i;return c!=null&&c.column&&(u!=null&&u.column)&&c.column!==u.column?{summary:`Filter changed on "${Jt(u.column)}"`,detail:`Previously filtered "${Jt(c.column)}"`}:{summary:`Filter updated: ${Zn(u)}`}}case"filter_cleared":{const c=o&&typeof o=="object"&&"count"in o?o.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?Jt(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=o!=null&&o.column?Jt(o.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: ${Vi(i)}`};case"group_level_removed":{const c=o,u=(a=(s=c==null?void 0:c.levels)==null?void 0:s[0])!=null&&a.column?Jt(c.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Vi(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: "${Jt(c)}"`:"Column hidden"}}case"column_shown":{const c=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:c?`Column shown: "${Jt(c)}"`:"Column made visible"}}case"column_reordered":{const c=Array.isArray(o)?o:[],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: "${Jt(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)??(o==null?void 0:o.name)??"";return{summary:c?`View updated: "${c}"`:"View updated"}}case"view_deleted":{const c=(o==null?void 0:o.name)??(o==null?void 0:o.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=(o==null?void 0:o.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":case"export_pdf":{const c=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",u=i==null?void 0:i.rowCount,g=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",x=(i==null?void 0:i.viewName)??"",y=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${c}${y}`,detail:x?`${ui(g)} · View: "${x}"`:ui(g)}}case"export_triggered":{const c=((l=i==null?void 0:i.format)==null?void 0:l.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=(o==null?void 0:o.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"row_edited":{const c=(i==null?void 0:i.id)??(o==null?void 0:o.id)??"",u=(i==null?void 0:i.label)??(o==null?void 0:o.label)??(c?`#${c}`:"");return{summary:u?`Row edited: "${u}"`:"Row edited"}}case"row_deleted":{const c=(o==null?void 0:o.id)??"",u=(o==null?void 0:o.label)??(c?`#${c}`:"");return{summary:u?`Row deleted: "${u}"`:"Row deleted"}}case"row_duplicated":{const c=(o==null?void 0:o.id)??"",u=(o==null?void 0:o.label)??(c?`#${c}`:"");return{summary:u?`Row duplicated: "${u}"`:"Row duplicated"}}case"theme_changed":{const c=typeof o=="string"?o:(o==null?void 0:o.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:wl(r)}}}function Sl(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function Io(e,r,o,i,s,a){return{id:Sl(),user:r,reportId:e,feature:o,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function Oo(e,r){const o=[r,...e];return o.length>Ni?o.slice(0,Ni):o}function wl(e){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",export_pdf:"Exported as PDF",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",error_occurred:"Error Occurred"}[e]||e}function ei(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",rows:"Rows",system:"System"}[e]||e}function Cl(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),a=Math.floor(i/36e5),l=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:l<7?`${l} day${l>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Hi=100;function jl(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function kl(e){var a;const r=(a=e.views)==null?void 0:a.find(l=>l.id===e.activeViewId),o=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=Ci(i,e.grouping||null,o);return{filters:Ue(e.filters),sortStack:e.sortStack?[...e.sortStack]:[],columnVisibility:e.columnVisibility?{...e.columnVisibility}:{},columnOrder:s,columnWidths:e.columnWidths?{...e.columnWidths}:{},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}function Tl(e,r,o,i){return{id:jl(),name:e,description:r,createdBy:o,createdAt:Date.now(),config:i}}function zl(e,r){const o=e||[];if(o.length>=Hi)throw new Error(`Maximum of ${Hi} presets reached. Please delete old presets first.`);return[...o,r]}function Bl(e,r){return(e||[]).filter(i=>i.id!==r)}function Gi(e,r){if(e)return e.find(o=>o.id===r)}function El(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function _l(e){const r=e.columnOrder,o=Eo(r,e.grouping);return{filters:Ue(e.filters),sortStack:e.sortStack.length>0?[...e.sortStack]:void 0,columnVisibility:{...e.columnVisibility},columnOrder:o,columnWidths:{...e.columnWidths},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}async function $l(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){Kt.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 o=!1;try{o=document.execCommand("copy")}catch(i){Kt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),o}catch(r){return Kt.error("urm:presets","Fallback copy method failed",r),!1}}function Dl(e,r){return{totalRows:e.length,totalColumns:r.length}}function vr(e,r,o,i){const s=o instanceof Error?o.message:o,a={type:e,context:r,message:s,details:i,timestamp:Date.now(),recoverable:Il(e,r)};return process.env.NODE_ENV==="development"&&Kt.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function Il(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function Ol(e){const o={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?`${o}. Your previous state has been restored.`:`${o}. Please refresh the page.`}function Ml(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 Al(e,r,o){o(e.id,{filters:Ue(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function Rl(e,r,o){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(r)&&(o==null||o==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:e==="number"&&["gt","gte","lt","lte","equals"].includes(r)&&isNaN(Number(o))?{isValid:!1,errorMessage:"Value must be a valid number"}:e==="date"&&o&&isNaN(Date.parse(o))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function Ns(e,r){const o=[],i=[],s=new Set(r.map(a=>a.name));return e.forEach(a=>{s.has(a.column)?o.push(a):i.push(a.column)}),{validRules:o,invalidColumns:i}}function Vs(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const o=new Set(r.map(a=>a.name)),i=[],s=[];return e.levels.forEach(a=>{o.has(a.column)?i.push(a):s.push(a.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...e,levels:i},invalidColumns:s}}function Wl(e,r){const o=[],i=new Set(r.map(a=>a.name)),s={...e};if(s.filters){const a=l=>{const c=l.children.filter(u=>{if(Qe(u))return!0;const g=i.has(u.column);return g||o.push(`Filter for column "${u.column}" ignored (column not found)`),g}).map(u=>Qe(u)?a(u):u).filter(u=>!Qe(u)||u.children.length>0);return{...l,children:c}};s.filters=a(Ue(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:l}=Ns(s.sortStack,r);l.length>0&&o.push(`Sort rules for columns ignored: ${l.join(", ")}`),s.sortStack=a.length>0?a:void 0}if(s.grouping){const{validGrouping:a,invalidColumns:l}=Vs(s.grouping,r);l.length>0&&o.push(`Grouping for columns ignored: ${l.join(", ")}`),s.grouping=a}if(s.columnVisibility){const a={};Object.entries(s.columnVisibility).forEach(([l,c])=>{i.has(l)?a[l]=c:o.push(`Column visibility for "${l}" ignored (column not found)`)}),s.columnVisibility=Object.keys(a).length>0?a:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const a=s.columnOrder.filter(l=>{const c=i.has(l);return c||o.push(`Column "${l}" in order ignored (column not found)`),c});s.columnOrder=a.length>0?a:void 0}if(s.columnWidths){const a={};Object.entries(s.columnWidths).forEach(([l,c])=>{i.has(l)?a[l]=c:o.push(`Column width for "${l}" ignored (column not found)`)}),s.columnWidths=Object.keys(a).length>0?a:void 0}return{sanitizedConfig:s,warnings:o}}function Pl(e,r){return vr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Ui(e,r,o,i){const s=Io(e,r,"system","error_occurred",null,{errorType:o.type,errorContext:o.context,errorMessage:o.message,recoverable:o.recoverable,timestamp:o.timestamp});return Oo(i||[],s)}function Ll(e){return e==null}function Fl(e,r,o){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(Ll(e))return!1;if(o==="date"){const a=new Date(e).getTime(),l=new Date(s).getTime();switch(i){case"equals":return a===l;case"gt":return a>l;case"lt":return a<l;case"gte":return a>=l;case"lte":return a<=l;default:return!0}}switch(i){case"equals":return String(e).toLowerCase()===String(s).toLowerCase();case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function pi(e,r,o){var s;if(Qe(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>pi(e,a,o)):r.children.some(a=>pi(e,a,o));const i=((s=o.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return Fl(e[r.column],r,i)}function Ti(e,r,o){return!r||r.children.length===0?e:e.filter(i=>pi(i,r,o))}function hn(e){switch(e){case"string":return[{value:"equals",label:"Equals"},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"endsWith",label:"Ends with"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"number":return[{value:"equals",label:"="},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:"≥"},{value:"lte",label:"≤"}];case"boolean":return[{value:"isTrue",label:"Is true"},{value:"isFalse",label:"Is false"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"date":return[{value:"equals",label:"Is"},{value:"gt",label:"After"},{value:"lt",label:"Before"},{value:"gte",label:"On or after"},{value:"lte",label:"On or before"},{value:"NULL",label:"Is NULL"},{value:"NOT_NULL",label:"Is NOT NULL"}];case"mixed":case"null":case"array":case"object":default:return[]}}function Nl(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Vl({data:e,filters:r,schema:o}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:Ti(e,r,o),[e,r,o])}}function Hl(e,r){const o=e.length+1,i=r.length+1,s=Array.from({length:o},()=>new Array(i).fill(0));for(let a=0;a<o;a+=1)s[a][0]=a;for(let a=0;a<i;a+=1)s[0][a]=a;for(let a=1;a<o;a+=1)for(let l=1;l<i;l+=1){const c=e[a-1]===r[l-1]?0:1;s[a][l]=Math.min(s[a-1][l]+1,s[a][l-1]+1,s[a-1][l-1]+c)}return s[o-1][i-1]}function Gl(e,r){const o=e.split(/\s+/).filter(Boolean);return r.some(i=>{const s=i.length<=5?1:2;return o.some(a=>Hl(i,a)<=s)})}function Ul(e,r,o,i){if(!o||o.trim()==="")return e;const s=o.toLowerCase().trim(),a=s.split(/\s+/).filter(Boolean),l=r.filter(c=>i.includes(c.name));return e.filter(c=>l.some(u=>{const g=c[u.name];if(g==null)return!1;const x=String(g).toLowerCase();return x.includes(s)?!0:Gl(x,a)}))}function Yl({data:e,searchQuery:r,schema:o,visibleColumns:i,mode:s="client"}){return{searchedData:p.useMemo(()=>s==="server"||!r||r.trim()===""?e:Ul(e,o,r,i),[e,r,o,i,s])}}function ql({data:e,sortStack:r,schema:o}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:yi(e,o,r),[e,r,o])}}function Jl({data:e,grouping:r,schema:o}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:tl(e,o,r),[e,r,o]),s=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function Kl({schema:e,columnVisibility:r,columnOrder:o}){const i=p.useMemo(()=>o.filter(c=>r[c]!==!1),[o,r]),s=p.useMemo(()=>Object.entries(r).filter(([c,u])=>!u).map(([c,u])=>c),[r]),a=p.useMemo(()=>o.map(c=>e.find(g=>g.name===c)||{name:c,type:"string"}),[o,e]),l=p.useMemo(()=>i.map(c=>e.find(g=>g.name===c)||{name:c,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:l,hiddenCount:s.length}}function Xl({views:e,activeViewId:r,currentState:o}){const i=p.useMemo(()=>e.find(g=>g.id===r),[e,r]),s=p.useMemo(()=>i?il(o,i.snapshot):!1,[i,o]),a=p.useMemo(()=>e.find(g=>g.isDefault),[e]),l=p.useMemo(()=>e.filter(g=>!g.isDefault&&!g.isDeleted),[e]),c=p.useMemo(()=>e.filter(g=>g.isFavorite&&!g.isDeleted),[e]),u=p.useMemo(()=>e.filter(g=>g.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:l,favoriteViews:c,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function Ql(e,r,o){if(!e||e.length===0)return[];if(r<=0)return e.slice(0,o);const i=e.slice(r,o);if(i.length===0)return[];const s=i[0],a=!!(s.__isGroupHeader||s.isGroupHeader),l=a?s.groupLevel??0:s.__urm_group_level__??0;if(l===0&&a)return i;const c=l-1;if(c<0)return i;const u={};let g=c+1;for(let z=r-1;z>=0;z--){const h=e[z];if(h.__isGroupHeader||h.isGroupHeader){const m=h.groupLevel??0;if(m<=c&&u[m]===void 0&&(u[m]=h,g--,g<=0))break}}const x=[];for(let z=0;z<=c;z++)u[z]&&x.push({...u[z],__urm_is_continuation_header__:!0});const y=Math.max(0,o-r-x.length),w=r+y,b=e.slice(r,w);return[...x,...b]}function Zl({data:e,enabled:r=!1,pageSize:o=100,initialPage:i=1}){const[s,a]=p.useState(i),l=e.length,c=Math.max(1,Math.ceil(l/o));p.useEffect(()=>{s>c&&a(c)},[s,c]);const u=p.useMemo(()=>{if(!r)return e;const b=(s-1)*o,z=b+o;return Ql(e,b,z)},[e,r,s,o]),g=p.useCallback(b=>{const z=Math.max(1,Math.min(b,c));a(z)},[c]),x=p.useCallback(()=>{s<c&&a(b=>Math.min(b+1,c))},[c]),y=p.useCallback(()=>{s>1&&a(b=>Math.max(b-1,1))},[]),w=p.useCallback(()=>{a(1)},[]);return{paginatedData:u,currentPage:s,totalPages:c,pageSize:o,totalRows:l,goToPage:g,nextPage:x,prevPage:y,resetPage:w,hasNextPage:s<c,hasPrevPage:s>1}}function ec(e){const{rawData:r,schema:o,filters:i,sortStack:s,grouping:a,searchQuery:l,searchMode:c,columnVisibility:u,columnOrder:g,columnWidths:x,views:y,activeViewId:w,pagination:b}=e,z=p.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:u,columnOrder:g,columnWidths:x}),[i,s,a,u,g,x]),h=Xl({views:y,activeViewId:w,currentState:z}),m=Kl({schema:o,columnVisibility:u,columnOrder:g}),{filteredData:E}=Vl({data:r,filters:i,schema:o}),{sortedData:v}=ql({data:E,sortStack:s,schema:o}),{groupedData:T,isGrouped:B}=Jl({data:v,grouping:a,schema:o}),{searchedData:f}=Yl({data:T,searchQuery:l,schema:o,visibleColumns:m.visibleColumns,mode:c}),$=Zl({data:f,enabled:(b==null?void 0:b.enabled)||!1,pageSize:(b==null?void 0:b.pageSize)||100,initialPage:(b==null?void 0:b.currentPage)||1}),F=b!=null&&b.enabled?$.paginatedData:f,O=p.useMemo(()=>({totalRows:r.length,filteredRows:E.length,sortedRows:v.length,groupedRows:B?T.length:v.length,searchedRows:f.length,visibleRows:F.length,hiddenColumns:m.hiddenCount,activeFilters:Tt(i),activeSorts:s.length,isGrouped:B}),[r.length,E.length,v.length,T.length,f.length,F.length,m.hiddenCount,i,s.length,B]);return{data:F,filteredData:E,sortedData:v,groupedData:T,searchedData:f,viewEngine:h,columnEngine:m,paginationEngine:$,metrics:O,isGrouped:B,isPaginated:(b==null?void 0:b.enabled)||!1}}let tc=0;function rc(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):tc++,writable:!1,enumerable:!1,configurable:!1})}const Mt="user-demo-001";function oc(e={}){var It,Ot,_e,sr,Xo;const{mode:r="builder",autoLoad:o=!0,initialData:i,dataSource:s,pagination:a,search:l,scheduler:c,reportName:u,reportId:g,sharedReportId:x,sharedViewId:y,viewPersistence:w,permissions:b,config:z={},devConfig:h}=e,m=(w==null?void 0:w.mode)??"local",E=(a==null?void 0:a.mode)??"client",v=(l==null?void 0:l.mode)??"client",[T,B]=p.useState([]),f=h??mt,[$,F]=p.useState(""),[O,J]=p.useState(!1),[te,L]=p.useState(!1),[S,A]=p.useState({message:"",severity:"info",open:!1}),k=(C,_="info")=>{A({message:C,severity:_,open:!0})},Y=()=>A(C=>({...C,open:!1})),oe=z.notifDurationMs,d=T.find(C=>C.id===$),[Q,ee]=p.useState("idle"),[N,re]=p.useState(!1),[ue,le]=p.useState(!1),[Z,de]=p.useState(!1),[se,W]=p.useState(!1),[ie,fe]=p.useState(!1),[pe,Me]=p.useState(void 0),[P,be]=p.useState(null),[ke,Pe]=p.useState(null),[Ae,st]=p.useState(!1),[Ze,Wt]=p.useState(!1),[Bt,Xt]=p.useState(null),[Wr,Qt]=p.useState(!1),[Pr,qe]=p.useState(!1),[Et,Lr]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[lt,Zt]=p.useState(""),[Pt,Fr]=p.useState(""),[Lt,_t]=p.useState(new Set),[Ft,ct]=p.useState(1),[Le,Nr]=p.useState(15),[Vr,ur]=p.useState(!1),[pr,er]=p.useState(!1),[fo,Cr]=p.useState(!1),[$t,Ve]=p.useState(null),[Se,Nt]=p.useState(!1),[mo,ho]=p.useState(null),[Hr,Gr]=p.useState(null),tr=p.useRef(null),je=p.useMemo(()=>d?xl(d.permissions,Mt):"owner",[d]),fr=gl(je),ot=p.useMemo(()=>!(d!=null&&d.uploadedData)||!(d!=null&&d.schema)?{totalRows:0,totalColumns:0}:Dl(d.uploadedData,d.schema),[d==null?void 0:d.uploadedData,d==null?void 0:d.schema]),ht=p.useCallback(()=>{d&&(tr.current=Ml(d))},[d]),G=p.useCallback((C,_)=>{B(R=>R.map(I=>I.id===C?{...I,..._}:I))},[]),Dt=p.useCallback(C=>{if(!d)return;Gr(C);const _=Ui(d.id,Mt,C,d.auditHistory||[]);G(d.id,{auditHistory:_}),k(C.message,"error"),C.recoverable&&tr.current&&setTimeout(()=>{Al(d,tr.current,G),k("Previous state restored","success")},100)},[d,G]),K=p.useCallback((C,_,R,I)=>{if(!d)return;const X=Io(d.id,Mt,C,_,R,I),q=d.auditHistory||[],ce=Oo(q,X);setTimeout(()=>{G(d.id,{auditHistory:ce})},0)},[d,G]);p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const C=Qn(d.schema);(()=>{try{const _=localStorage.getItem("urm_dev_config");return _?JSON.parse(_):null}catch{return null}})(),G(d.id,{views:[C],activeViewId:C.id,filters:C.snapshot.filters,sortStack:C.snapshot.sortStack,columnVisibility:C.snapshot.columnVisibility,columnOrder:C.snapshot.columnOrder,columnWidths:C.snapshot.columnWidths,grouping:C.snapshot.grouping})}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,G]),p.useEffect(()=>{if(i&&o&&!te&&T.length===0){const C=lo(i),_={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:C,schema:Ai(ko(C),z.hiddenColumns),permissions:b??{owner:Mt,editors:[],viewers:[]}};B([_]),F(_.id),L(!0),ee("confirmed")}},[i,o,te,T.length,r,u,g]),p.useEffect(()=>{E!=="server"||!te||!$||G($,{uploadedData:lo(i||[])})},[i,E,te,$]),p.useEffect(()=>{E==="server"&&((a==null?void 0:a.page)!==void 0&&ct(a.page),(a==null?void 0:a.pageSize)!==void 0&&Nr(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,E]),p.useEffect(()=>{if(!s||te)return;let C=!1,_=null;const R=async()=>{try{ee("uploading");let I;if(s.type==="api"){const q=await fetch(s.url,{headers:s.headers||{}});if(!q.ok)throw new Error(`HTTP ${q.status}: ${q.statusText}`);I=await q.json()}else I=await s.fetch();if(C)return;if(!Array.isArray(I))throw new Error("Data source must return an array of objects");const X=ko(I);if(te)B(q=>q.map(ce=>ce.id===$?{...ce,uploadedData:lo(I)}:ce)),ee("confirmed");else{const q={id:g||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:lo(I),schema:Ai(ko(lo(I)),z.hiddenColumns),permissions:b??{owner:Mt,editors:[],viewers:[]}};B([q]),F(q.id),L(!0),ee("confirmed")}}catch(I){C||(ee("error"),d&&G(d.id,{uploadError:(I==null?void 0:I.message)||"Failed to load data from source"}))}};return R(),s.refreshInterval&&s.refreshInterval>0&&(_=setInterval(R,s.refreshInterval)),()=>{C=!0,_&&clearInterval(_)}},[s,u,r,g]);const at=(It=d==null?void 0:d.views)==null?void 0:It.find(C=>C.id===d.activeViewId),mr=p.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(C=>rc(C,z.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);p.useEffect(()=>{_t(C=>{if(C.size===0)return C;const _=new Set(mr.map(I=>I==null?void 0:I.__urm_row_id__)),R=new Set(Array.from(C).filter(I=>_.has(I==null?void 0:I.__urm_row_id__)));return R.size===C.size?C:R})},[mr]);const rr=ec({rawData:mr,schema:(d==null?void 0:d.schema)||[],filters:Ue(d==null?void 0:d.filters),sortStack:(d==null?void 0:d.sortStack)||[],grouping:(d==null?void 0:d.grouping)||null,searchQuery:Pt||"",searchMode:v,columnVisibility:(d==null?void 0:d.columnVisibility)||(at==null?void 0:at.snapshot.columnVisibility)||{},columnOrder:(d==null?void 0:d.columnOrder)||(at==null?void 0:at.snapshot.columnOrder)||[],columnWidths:(d==null?void 0:d.columnWidths)||(at==null?void 0:at.snapshot.columnWidths)||{},views:(d==null?void 0:d.views)||[],activeViewId:(d==null?void 0:d.activeViewId)||"",pagination:{enabled:E==="client",pageSize:Le,currentPage:Ft}}),{data:xo=[],searchedData:hr=[],groupedData:jr=[],sortedData:vt=[],metrics:or={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:kr=!1,paginationEngine:ve}=rr||{},St=E==="server"?(a==null?void 0:a.totalRows)??0:kr?or.totalRows:or.searchedRows,Ur=E==="server"?Math.max(1,Math.ceil(((a==null?void 0:a.totalRows)??0)/Le)):(ve==null?void 0:ve.totalPages)??1,U=((Ot=rr.viewEngine)==null?void 0:Ot.activeView)||at,Ke=((_e=rr.viewEngine)==null?void 0:_e.isDirty)||!1;p.useEffect(()=>{if(!(!U||!d)&&!d.columnOrder){const C=U.snapshot.columnOrder,_=Eo(C,U.snapshot.grouping);G(d.id,{columnOrder:_})}},[d==null?void 0:d.activeViewId]);const Te=p.useMemo(()=>!(d!=null&&d.schema)||!U?null:nl(d.filters,d.sortStack||[],d.schema,d.columnVisibility,d.columnOrder,d.columnWidths,d.grouping,U.snapshot.columnOrder),[d==null?void 0:d.filters,d==null?void 0:d.sortStack,d==null?void 0:d.schema,d==null?void 0:d.columnVisibility,d==null?void 0:d.columnOrder,d==null?void 0:d.columnWidths,d==null?void 0:d.grouping,U]),pt=p.useMemo(()=>!U||!Te||!Ke?[]:al(Te,U.snapshot),[U,Te,Ke]),Tr=p.useCallback((C,_,R)=>{const I={id:`report-${Date.now()}`,name:C,description:_,schemaLocked:!1,permissions:{owner:Mt,editors:[],viewers:[]}};if(R&&Array.isArray(R)&&R.length>0){const X=ko(R),q=Qn(X);I.uploadedData=R,I.schema=X,I.schemaLocked=!0,I.views=[q],I.activeViewId=q.id,I.sortStack=q.snapshot.sortStack,I.filters=q.snapshot.filters,I.columnVisibility=q.snapshot.columnVisibility,I.columnOrder=q.snapshot.columnOrder,I.columnWidths=q.snapshot.columnWidths,I.grouping=q.snapshot.grouping}B(X=>[...X,I]),F(I.id),J(!1),ee("confirmed")},[]),xt=p.useCallback(C=>{d&&(ee("uploading"),setTimeout(()=>{const _=ko(C);G(d.id,{uploadedData:C,schema:_,uploadError:void 0}),ee("preview")},500))},[d,G]),go=p.useCallback(C=>{d&&(G(d.id,{uploadError:C}),ee("idle"))},[d,G]),Vt=p.useCallback(()=>{d&&(G(d.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),ee("idle"))},[d,G]),zr=p.useCallback(()=>{d&&(G(d.id,{schemaLocked:!0}),ee("confirmed"))},[d,G]),Yr=p.useCallback(C=>{if(!d)return;if(!Ct("edit_sorting",je)){k(jt("edit_sorting"),"error");return}const _=d.sortStack??[],R=_.find(I=>I.column===C);if(R){const I=Xa(R.direction);if(I===null){const X=_.filter(q=>q.column!==C).map((q,ce)=>({...q,priority:ce+1}));K("sorting","sort_level_removed",R,null),G(d.id,{sortStack:X.length>0?X:void 0})}else{const X=I,q=_.map(ce=>ce.column===C?{...ce,direction:X}:ce);K("sorting","sort_reordered",{column:C,direction:R.direction},{column:C,direction:X}),G(d.id,{sortStack:q})}}else{if(_.length>=f.sort.maxLevels){k(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const I={column:C,direction:"asc",priority:_.length+1};K("sorting","sort_level_added",null,I),G(d.id,{sortStack:[..._,I]})}},[d,je,G,K]),Ht=p.useCallback(C=>{if(!d)return;const _=d.sortStack??[],R=C.length===0?"sort_cleared":"sort_reordered";if(d.schema){const{validRules:I,invalidColumns:X}=Ns(C,d.schema);X.length>0&&k(`Removed invalid sort columns: ${X.join(", ")}`),ht();try{K("sorting",R,_,I.length>0?I:null),G(d.id,{sortStack:I.length>0?I:void 0})}catch(q){const ce=vr("processing","sorting",q);Dt(ce)}}else K("sorting",R,_,C.length>0?C:null),G(d.id,{sortStack:C.length>0?C:void 0})},[d,G,ht,Dt,K]),Br=p.useCallback(C=>{if(!d)return;const _=d.sortStack??[],R=_.find(I=>I.column===C);if(!(R&&R.direction==="asc"))if(R){const I=_.map(X=>X.column===C?{...X,direction:"asc"}:X);K("sorting","sort_reordered",{column:C,direction:R.direction},{column:C,direction:"asc"}),G(d.id,{sortStack:I})}else{if(_.length>=f.sort.maxLevels){k(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const I={column:C,direction:"asc",priority:_.length+1};K("sorting","sort_level_added",null,I),G(d.id,{sortStack:[..._,I]})}},[d,G,K]),qr=p.useCallback(C=>{if(!d)return;const _=d.sortStack??[],R=_.find(I=>I.column===C);if(!(R&&R.direction==="desc"))if(R){const I=_.map(X=>X.column===C?{...X,direction:"desc"}:X);K("sorting","sort_reordered",{column:C,direction:R.direction},{column:C,direction:"desc"}),G(d.id,{sortStack:I})}else{if(_.length>=f.sort.maxLevels){k(`Sort limit reached — maximum ${f.sort.maxLevels} sort levels allowed. Remove an existing sort to add a new one.`,"warning");return}const I={column:C,direction:"desc",priority:_.length+1};K("sorting","sort_level_added",null,I),G(d.id,{sortStack:[..._,I]})}},[d,G,K]),Er=p.useCallback((C,_)=>{var I;if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const R=(I=d.schema)==null?void 0:I.find(X=>X.name===_.column);if(R&&_.value!==void 0){const X=Rl(R.type,_.operator,_.value);if(!X.isValid){k(X.errorMessage||"Invalid filter value","error");return}}ht();try{const X=Ue(d.filters),q={..._,id:uo()},ce=po(X,C,q);K("filters","filter_added",null,q),G(d.id,{filters:ce})}catch(X){const q=vr("processing","filters",X);Dt(q)}},[d,je,G,ht,Dt,K]),_r=p.useCallback(C=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const _=Ue(d.filters),R=po(_,C,At());K("filters","filter_added",null,"a condition group"),G(d.id,{filters:R})},[d,je,G,K]),$r=p.useCallback((C,_)=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const R=Ue(d.filters),I=cn(R,C),X=vi(R,C,_),q=cn(X,C);K("filters","filter_updated",I,q),G(d.id,{filters:X})},[d,je,G,K]),we=p.useCallback((C,_)=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const R=Ue(d.filters),I=Si(R,C,_);K("filters","filter_updated",null,`group operator changed to ${_.toUpperCase()}`),G(d.id,{filters:I})},[d,je,G,K]),ae=p.useCallback(C=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const _=Ue(d.filters),R=cn(_,C),I=wi(_,C);K("filters","filter_removed",R,null),G(d.id,{filters:I})},[d,je,G,K]),me=p.useCallback(()=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const C=Ue(d.filters);K("filters","filter_cleared",{count:Tt(C)},null),G(d.id,{filters:At()})},[d,je,G,K]),Ce=p.useCallback(C=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const _=Ue(d.filters);K("filters","filter_cleared",{count:Tt(_)},{count:Tt(C)}),G(d.id,{filters:C})},[d,je,G,K]),We=p.useCallback(C=>{var X;if(!d)return;const _=(X=d.views)==null?void 0:X.find(q=>q.id===C);if(!_)return;const R=_.snapshot.columnOrder,I=Eo(R,_.snapshot.grouping);K("views","view_switched",{previousViewId:d.activeViewId},{viewId:C,name:_.name}),G(d.id,{filters:_.snapshot.filters,sortStack:_.snapshot.sortStack.length>0?[..._.snapshot.sortStack]:void 0,columnVisibility:{..._.snapshot.columnVisibility},columnOrder:I,columnWidths:{..._.snapshot.columnWidths},grouping:_.snapshot.grouping,activeViewId:C}),_t(new Set)},[d,G,K]),Xe=p.useCallback((C,_,R)=>{var ye;if(!(d!=null&&d.schema)||!Te)return;const I=d.views??[],X=I.filter(Yt=>!Yt.isDeleted).length,q=((ye=f.views)==null?void 0:ye.maxViews)??10;if(X>=q){k(`View limit reached — you can have at most ${q} saved views. Delete an existing view to create a new one.`,"error");return}const ce={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:C,description:_||void 0,isDefault:R,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:Mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Te}},xe=R?I.map(Yt=>({...Yt,isDefault:!1})):I;K("views","view_created",null,{viewId:ce.id,name:C,isDefault:R}),G(d.id,{views:[...xe,ce],activeViewId:ce.id}),k(`"${C}" view created`,"success")},[d,Te,G,K]),ft=p.useCallback(C=>{var ce;if(!(d!=null&&d.views))return;const _=d.views.find(xe=>xe.id===C);if(!_)return;const R=d.views,I=R.filter(xe=>!xe.isDeleted).length,X=((ce=f.views)==null?void 0:ce.maxViews)??10;if(I>=X){k(`View limit reached — you can have at most ${X} saved views. Delete an existing view to create a new one.`,"error");return}const q={..._,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${_.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:Mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{..._.snapshot}};G(d.id,{views:[...R,q]}),k(`"${q.name}" created`,"success")},[d,f,G]),dt=p.useCallback(()=>{var _;if(!U||!Te||!d)return;const C=(_=d.views)==null?void 0:_.map(R=>R.id===U.id?{...R,snapshot:{...Te}}:R);G(d.id,{views:C}),k(`"${U.name}" view updated`,"success")},[U,Te,d,G]),wt=p.useCallback(C=>{var I;if(!U||!Te||!d)return;const _=C??Te.columnWidths,R=(I=d.views)==null?void 0:I.map(X=>X.id===U.id?{...X,snapshot:{...X.snapshot,columnVisibility:Te.columnVisibility,columnOrder:Te.columnOrder,columnWidths:_},updatedAt:Date.now()}:X);G(d.id,{views:R,columnWidths:_}),k(`Column configuration saved to "${U.name}"`,"success")},[U,Te,d,G]),Gt=p.useCallback(C=>{var q,ce;if(!Te||!d||!U)return;const _=C??Te.columnWidths,R={...U,snapshot:{...U.snapshot,columnVisibility:Te.columnVisibility,columnOrder:Te.columnOrder,columnWidths:_},updatedAt:Date.now()},I=(q=d.views)==null?void 0:q.map(xe=>xe.id===U.id?R:{...xe,snapshot:{...xe.snapshot,columnVisibility:Te.columnVisibility,columnOrder:Te.columnOrder,columnWidths:_},updatedAt:Date.now()});G(d.id,{views:I,columnWidths:_});const X=(((ce=d.views)==null?void 0:ce.length)||0)-1;k(`Column configuration saved to current view and ${X} other view${X===1?"":"s"}`,"success")},[Te,d,U,G]),xr=p.useCallback(()=>{de(!0)},[]),Dr=p.useCallback(()=>{if(!U||!d)return;const C=U.snapshot.columnOrder,_=Eo(C,U.snapshot.grouping);G(d.id,{filters:U.snapshot.filters,sortStack:U.snapshot.sortStack.length>0?[...U.snapshot.sortStack]:void 0,columnVisibility:{...U.snapshot.columnVisibility},columnOrder:_,columnWidths:{...U.snapshot.columnWidths},grouping:U.snapshot.grouping}),k("Changes reverted to last saved state","success")},[U,d,G]),yo=p.useCallback(C=>{if(!(d!=null&&d.views))return;const _=d.views.map(I=>({...I,isDefault:I.id===C}));G(d.id,{views:_});const R=d.views.find(I=>I.id===C);R&&k(`"${R.name}" set as default view`,"success")},[d,G]),No=p.useCallback(C=>{if(!(d!=null&&d.views))return;const _=d.views.map(I=>I.id===C?{...I,isFavorite:!I.isFavorite,updatedAt:Date.now()}:I);G(d.id,{views:_});const R=d.views.find(I=>I.id===C);R&&!R.isFavorite?k(`"${R.name}" added to favorites`,"success"):R&&k(`"${R.name}" removed from favorites`,"info")},[d,G]),Jr=p.useCallback(C=>{if(!(d!=null&&d.views))return;const _=d.views.find(ye=>ye.id===C),R=d.views.filter(ye=>!ye.isDeleted||ye.id===C);if((_==null?void 0:_.isDefault)&&R.filter(ye=>ye.isDefault).length===1){k("Cannot delete the last default view","error");return}const X=d.views.map(ye=>ye.id===C?{...ye,isDeleted:!0,updatedAt:Date.now()}:ye),q=d.activeViewId===C,ce=X.find(ye=>ye.isDefault&&!ye.isDeleted);G(d.id,{views:X,activeViewId:q&&ce?ce.id:d.activeViewId,filters:q&&ce?ce.snapshot.filters:d.filters,sortStack:q&&ce?ce.snapshot.sortStack.length>0?ce.snapshot.sortStack:void 0:d.sortStack});const xe=d.views.find(ye=>ye.id===C);xe&&k(`"${xe.name}" moved to Recently Deleted`,"info")},[d,G]),An=p.useCallback(C=>{if(!(d!=null&&d.views))return;const _=d.views.map(I=>I.id===C?{...I,isDeleted:!1,updatedAt:Date.now()}:I);G(d.id,{views:_});const R=d.views.find(I=>I.id===C);R&&k(`"${R.name}" restored`,"success")},[d,G]),Kr=p.useCallback(C=>{if(!(d!=null&&d.views))return;const _=d.views.find(xe=>xe.id===C),R=d.views.filter(xe=>!xe.isDeleted||xe.id===C);if((_==null?void 0:_.isDefault)&&R.filter(xe=>xe.isDefault).length===1){k("Cannot delete the last default view","error");return}const X=d.views.filter(xe=>xe.id!==C),q=d.activeViewId===C,ce=X.find(xe=>xe.isDefault&&!xe.isDeleted);G(d.id,{views:X,activeViewId:q&&ce?ce.id:d.activeViewId,filters:q&&ce?ce.snapshot.filters:d.filters,sortStack:q&&ce?ce.snapshot.sortStack.length>0?ce.snapshot.sortStack:void 0:d.sortStack}),_&&k(`"${_.name}" permanently deleted`,"success")},[d,G]),bo=p.useCallback(C=>{be(C),W(!0)},[]),Rn=p.useCallback(async C=>{if(!d)return;const _=new URLSearchParams(window.location.search);_.set("reportId",d.id),_.set("view",C);const R=`${window.location.origin}${window.location.pathname}?${_.toString()}`,I=await $l(R);k(I?"Link copied to clipboard":"Failed to copy link",I?"success":"error")},[d]),Vo=p.useCallback((C,_)=>{if(!P||!(d!=null&&d.views))return;const R=d.views.map(I=>I.id===P?{...I,name:C,description:_||void 0}:I);G(d.id,{views:R}),be(null)},[P,d,G]),Xr=p.useCallback(C=>{Pe(C),fe(!0)},[]),Ho=p.useCallback(()=>{if(!ke||!(d!=null&&d.views))return;const C=d.views.find(X=>X.id===ke),_=d.views.filter(X=>X.id!==ke),R=d.activeViewId===ke,I=_.find(X=>X.isDefault);K("views","view_deleted",{viewId:ke,name:C==null?void 0:C.name},null),G(d.id,{views:_,activeViewId:R&&I?I.id:d.activeViewId,filters:R&&I?I.snapshot.filters:d.filters,sortStack:R&&I?I.snapshot.sortStack.length>0?I.snapshot.sortStack:void 0:d.sortStack}),Pe(null),fe(!1)},[ke,d,G,K]),Qr=p.useCallback(C=>{var X;if(!(d!=null&&d.views))return;if(!(((X=f.views)==null?void 0:X.isAdmin)??!1)){k("Only administrators can promote views to Global.","error");return}const R=d.views.find(q=>q.id===C);if(!R)return;if(R.scope==="global"){k(`"${R.name}" is already a Global View.`,"info");return}const I=d.views.map(q=>q.id===C?{...q,scope:"global",isDefault:!0,updatedAt:Date.now()}:q.scope==="global"&&q.isDefault?{...q,isDefault:!1}:q);G(d.id,{views:I}),k(`"${R.name}" promoted to Global View and set as default.`,"success")},[d,f,G]),vo=p.useCallback((C,_)=>{if(!(d!=null&&d.views))return;const R=d.views.find(q=>q.id===C);if(!R)return;const I=d.views.map(q=>q.id===C?{...q,isDefaultForAllUsers:_,updatedAt:Date.now()}:_&&q.isDefaultForAllUsers?{...q,isDefaultForAllUsers:!1}:q);K("views",_?"view_set_default":"view_updated",{viewId:C,isDefaultForAllUsers:!_},{viewId:C,isDefaultForAllUsers:_}),G(d.id,{views:I}),k(`"${R.name}" ${_?"set as":"removed from"} default for all users.`,"success")},[d,G,K]),So=p.useRef(!0);p.useEffect(()=>{var C;if(So.current){So.current=!1;return}if(E==="server"){ct(1),(C=a==null?void 0:a.onPaginationChange)==null||C.call(a,1,Le);return}ve!=null&&ve.resetPage?ve.resetPage():ct(1)},[d==null?void 0:d.filters,Pt,d==null?void 0:d.activeViewId]);const Zr=p.useCallback(C=>{var _;if(E==="server"){ct(C),(_=a==null?void 0:a.onPaginationChange)==null||_.call(a,C,Le);return}ve!=null&&ve.goToPage&&ve.goToPage(C)},[E,a,Le,ve]),eo=p.useCallback(C=>{var X;const R=((E==="server"?Ft:(ve==null?void 0:ve.currentPage)||1)-1)*Le,I=Math.floor(R/C)+1;if(E==="server"){Nr(C),ct(I),(X=a==null?void 0:a.onPaginationChange)==null||X.call(a,I,C);return}Nr(C),ve==null||ve.goToPage(I)},[Ft,Le,E,a,ve]),Go=p.useCallback((C,_)=>{if(!d)return;if(!Ct("edit_columns",je)){k(jt("edit_columns"),"error");return}const I={...d.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{},[C]:_};K("columns",_?"column_shown":"column_hidden",{columnName:C,visible:!_},{columnName:C,visible:_}),G(d.id,{columnVisibility:I})},[d,U,je,G,K]),Uo=p.useCallback(C=>{if(d){if(!Ct("edit_columns",je)){k(jt("edit_columns"),"error");return}K("columns","column_reordered",d.columnOrder,C),G(d.id,{columnOrder:C})}},[d,je,G,K]),Wn=p.useCallback((C,_)=>{if(!d)return;if(!Ct("edit_columns",je)){k(jt("edit_columns"),"error");return}const R=d.columnWidths||(U==null?void 0:U.snapshot.columnWidths)||{},I={...R,[C]:_};K("columns","column_resized",{columnName:C,width:R[C]},{columnName:C,width:_}),G(d.id,{columnWidths:I})},[d,U,je,G,K]),Pn=p.useCallback(C=>{if(!d)return;const _=Ue(d.filters),R=Ps(_,C);G(d.id,{filters:R})},[d,G]),Ln=p.useCallback(()=>{if(!U||!(d!=null&&d.schema))return;const C={},_=[],R={};d.schema.forEach(I=>{C[I.name]=!0,_.push(I.name),R[I.name]=170}),G(d.id,{columnVisibility:C,columnOrder:_,columnWidths:R,filters:void 0,sortStack:void 0}),k("Reset to default layout - all filters and sorts cleared","success")},[U,d,G]);p.useEffect(()=>{const C=setTimeout(()=>Fr(lt),300);return()=>clearTimeout(C)},[lt]),p.useEffect(()=>{var C;v==="server"&&((C=l==null?void 0:l.onSearchChange)==null||C.call(l,Pt))},[Pt,v,l]);const Fn=p.useCallback(C=>{Zt(C),ct(1)},[]),Nn=p.useCallback(C=>{if(!C.trim()||!d)return;const _=d.searchHistory||[],R=ul(_,C);G(d.id,{searchHistory:R})},[d,G]),Vn=p.useCallback(C=>{if(!d)return;const _=d.searchHistory||[],R=pl(_,C);G(d.id,{searchHistory:R})},[d,G]),Hn=p.useCallback(C=>{if(!d)return;const _=d.searchHistory||[],R=fl(_,C);G(d.id,{searchHistory:R})},[d,G]);p.useEffect(()=>{if(!z.onSelectionChange)return;const C=Array.from(Lt);z.onSelectionChange(C,C.map(_=>_==null?void 0:_.__urm_row_id__))},[Lt,z.onSelectionChange]);const Gn=p.useCallback(C=>{const _=C==null?void 0:C.__urm_row_id__;_t(R=>{const I=new Set(R);let X;return _!==void 0?X=Array.from(I).find(q=>(q==null?void 0:q.__urm_row_id__)===_):X=Array.from(I).find(q=>q===C),X!==void 0?I.delete(X):I.add(C),I})},[]),Un=p.useCallback((C,_)=>{_t(R=>{const I=new Set(R),X=_.filter(q=>!q.isGroupHeader);for(const q of X){const ce=q==null?void 0:q.__urm_row_id__;if(C){let xe;ce!==void 0?xe=Array.from(I).find(ye=>(ye==null?void 0:ye.__urm_row_id__)===ce):xe=Array.from(I).find(ye=>ye===q),xe===void 0&&I.add(q)}else{let xe;ce!==void 0?xe=Array.from(I).find(ye=>(ye==null?void 0:ye.__urm_row_id__)===ce):xe=Array.from(I).find(ye=>ye===q),xe!==void 0&&I.delete(xe)}}return I})},[]),Yn=p.useCallback((C,_,R)=>{_t(I=>{const X=new Set(I),q=R.filter(ye=>!ye.isGroupHeader),ce=Math.min(C,_),xe=Math.max(C,_);for(let ye=ce;ye<=xe;ye++){const Yt=q[ye];if(!Yt)continue;const Ii=Yt==null?void 0:Yt.__urm_row_id__;let Xn;Ii!==void 0?Xn=Array.from(X).find(jo=>(jo==null?void 0:jo.__urm_row_id__)===Ii):Xn=Array.from(X).find(jo=>jo===Yt),Xn===void 0&&X.add(Yt)}return X})},[]),to=p.useCallback(()=>{_t(new Set)},[]),wo=p.useCallback(C=>{const _=C==null?void 0:C.__urm_row_id__;_t(R=>{const I=new Set(R);if(_!==void 0){const X=Array.from(I).find(q=>(q==null?void 0:q.__urm_row_id__)===_);X!==void 0&&I.delete(X)}else I.delete(C);return I})},[]),qn=p.useCallback(C=>{var _,R;if(d){if(!Ct("edit_columns",je)){k(jt("edit_columns"),"error");return}if(C&&d.schema){const{validGrouping:I,invalidColumns:X}=Vs(C,d.schema);X.length>0&&k(`Removed invalid grouping columns: ${X.join(", ")}`,"warning"),ht();try{const q=d.grouping;I===null?K("grouping","group_cleared",q,null):q?K("grouping","group_reordered",q,I):K("grouping","group_level_added",null,I);const ce=(U==null?void 0:U.snapshot.columnOrder)||d.columnOrder||[],xe=Eo(ce,I),ye=I.levels.length>0?{...I,collapsedGroups:Wi(vt,d.schema,I)}:I;G(d.id,{grouping:ye,columnOrder:xe}),E==="server"?(ct(1),(_=a==null?void 0:a.onPaginationChange)==null||_.call(a,1,Le)):ve==null||ve.resetPage(),JSON.stringify(xe)!==JSON.stringify(d.columnOrder)&&K("columns","column_reordered",d.columnOrder,xe),qe(!1)}catch(q){const ce=vr("processing","grouping",q);Dt(ce)}}else{const I=d.grouping;K("grouping","group_cleared",I,null);const X=(U==null?void 0:U.snapshot.columnOrder)||d.columnOrder||[];G(d.id,{grouping:C,columnOrder:X}),E==="server"?(ct(1),(R=a==null?void 0:a.onPaginationChange)==null||R.call(a,1,Le)):ve==null||ve.resetPage(),JSON.stringify(X)!==JSON.stringify(d.columnOrder)&&K("columns","column_reordered",d.columnOrder,X),qe(!1)}}},[d,U,je,G,ht,Dt,K,vt]),Jn=p.useCallback(C=>{if(!d||!f.grouping.allowCollapse)return;const _=d.grouping;if(!_)return;const R=rl(_,C);G(d.id,{grouping:R})},[d,f,G]),He=p.useCallback(()=>{!(d!=null&&d.grouping)||!f.grouping.allowCollapse||G(d.id,{grouping:{...d.grouping,collapsedGroups:[]}})},[d,f,G]),et=p.useCallback(()=>{if(!(d!=null&&d.grouping)||!d.schema||!f.grouping.allowCollapse)return;const C=Wi(vt,d.schema,d.grouping);G(d.id,{grouping:{...d.grouping,collapsedGroups:C}})},[d,vt,f,G]),Co=p.useCallback(()=>{Nt(!0)},[]),Ut=p.useCallback(C=>{d!=null&&d.schema&&(st(!0),setTimeout(()=>{try{let _;C.scope==="visible"?_=hr:_=d.uploadedData||[];let R;C.columnScope==="all"?(R={},(d.schema??[]).forEach(xe=>{R[xe.name]=!0})):R=d.columnVisibility||(U==null?void 0:U.snapshot.columnVisibility)||{};const I=d.columnOrder||(U==null?void 0:U.snapshot.columnOrder),X=un(_,d.schema,Ue(d.filters),d.sortStack??[],U,R,I),q=d.name;let ce;switch(C.format){case"csv":pn(X,q,C),ce="export_csv";break;case"excel":fn(X,q,C),ce="export_excel";break;case"json":mn(X,q,C),ce="export_json";break;case"pdf":ki(X,q,C),ce="export_pdf";break}K("export",ce,null,{format:C.format,scope:C.scope,columnScope:C.columnScope,rowCount:_.length,viewName:(U==null?void 0:U.name)||"Default View"}),k(`Export completed successfully (${C.format.toUpperCase()})`,"success")}catch(_){const R=Pl(_,{onRetry:()=>Ut(C)});k(`Export failed: ${R.message}. Click Export to retry.`,"error");const I=Ui(d.id,Mt,R,d.auditHistory||[]);G(d.id,{auditHistory:I}),Kt.error("urm:report-engine","Export failed",_)}finally{st(!1)}},500))},[d,U,hr,G,K]),Yo=p.useCallback(C=>{if(d!=null&&d.schema){if(Ke&&U&&!U.isDefault){Xt(C.format),Wt(!0),Nt(!1);return}Ut(C),Nt(!1)}},[d,U,Ke,Ut]),ro=p.useCallback(C=>{Ut({format:C,scope:"visible",columnScope:"visible"})},[Ut]),nr=p.useCallback(()=>{Bt&&ro(Bt),Wt(!1),Xt(null)},[Bt,ro]),ir=p.useCallback(()=>{dt(),Bt&&ro(Bt),Wt(!1),Xt(null)},[dt,Bt,ro]),qo=p.useCallback(()=>{Wt(!1),Xt(null)},[]),Kn=p.useCallback(C=>{!(d!=null&&d.schema)||Lt.size===0||(st(!0),setTimeout(()=>{try{const _=Array.from(Lt),R=un(_,d.schema,Ue(d.filters),d.sortStack??[],U),I=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(C){case"csv":pn(R,I);break;case"excel":fn(R,I);break;case"json":mn(R,I);break}k(`Exported ${_.length} selected rows`,"info")}catch(_){k("Export failed. Please try again.","error"),Kt.error("urm:report-engine","Bulk export failed",_)}finally{st(!1)}},500))},[d,U,Lt,jr]),Jo=p.useCallback((C,_)=>{if(d)try{const R=kl(d),I=Tl(C,_,Mt,R),X=zl(d.presets,I);G(d.id,{presets:X}),K("presets","preset_created",null,{presetId:I.id,name:I.name}),er(!1),k(`Preset "${C}" saved successfully`,"success")}catch(R){k(R instanceof Error?R.message:"Failed to create preset","error")}},[d,G,K]),Ko=p.useCallback(()=>{Ve(null),k("Exited preset view","info")},[]),j=p.useCallback(()=>{Cr(!0)},[]),H=p.useCallback((C,_)=>{if(!d)return;const R=Bl(d.presets,C);G(d.id,{presets:R}),K("presets","preset_deleted",{presetId:C,name:_},null),$t===C&&Ve(null),k(`Preset "${_}" deleted`,"success")},[d,$t,G,K]);p.useEffect(()=>{if(!x||T.length===0)return;const C=T.find(_=>_.id===x);C&&C.id!==$&&F(C.id)},[x,T,$]);const ne=p.useRef(!1);p.useEffect(()=>{var _;if(!y||ne.current||!d||d.id!==x)return;const C=(_=d.views)==null?void 0:_.find(R=>R.id===y&&!R.isDeleted);C&&We(C.id),ne.current=!0},[y,x,d,We]),p.useEffect(()=>{if(!d)return;const C=El();if(C&&d.presets&&d.schemaLocked&&d.schema){const _=Gi(d.presets,C);if(_){const{sanitizedConfig:R,warnings:I}=Wl(_.config,d.schema);I.length>0&&I.forEach(q=>k(q,"warning"));const X=_l(R);G(d.id,X),Ve(C),K("presets","preset_applied",null,{presetId:_.id,name:_.name}),k(`Loaded preset: ${_.name}`,"info")}else k("Preset not found","info")}},[d==null?void 0:d.schemaLocked]);const Ee=$t?Gi(d==null?void 0:d.presets,$t):void 0;p.useEffect(()=>{var C;d!=null&&d.views&&d.views.length>0&&d.activeViewId&&((C=w==null?void 0:w.onViewsChange)==null||C.call(w,d.views,d.activeViewId),m!=="api"&&ll(d.id,{views:d.views,activeViewId:d.activeViewId}))},[d==null?void 0:d.views,d==null?void 0:d.activeViewId,d==null?void 0:d.id,m,w]),p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const C=m==="api"?w!=null&&w.views&&w.views.length>0?{views:w.views,activeViewId:w.activeViewId??w.views[0].id}:null:cl(d.id);if(C&&C.views.length>0){const _=C.views.find(R=>R.id===C.activeViewId);if(_)G(d.id,{views:C.views,activeViewId:C.activeViewId,filters:Ue(_.snapshot.filters),sortStack:_.snapshot.sortStack.length>0?_.snapshot.sortStack:void 0});else{const R=C.views.find(I=>I.isDefault)||Qn(d.schema);G(d.id,{views:C.views,activeViewId:R.id,filters:Ue(R.snapshot.filters),sortStack:R.snapshot.sortStack.length>0?R.snapshot.sortStack:void 0})}}}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,m,w]);const tt=p.useCallback(C=>{var I;const _=Ue(d==null?void 0:d.filters),R=((I=f.filter)==null?void 0:I.maxConditions)??3;if(Tt(_)>=R){k(`Filter limit reached — maximum ${R} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}Me(C),re(!0)},[d,f,k]),Ge=p.useCallback(()=>{re(!1),Me(void 0)},[]),rt=(sr=d==null?void 0:d.views)==null?void 0:sr.find(C=>C.id===P),he=(Xo=d==null?void 0:d.views)==null?void 0:Xo.find(C=>C.id===ke);return{reports:T,activeReport:d,activeReportId:$,setActiveReportId:F,isModalOpen:O,setIsModalOpen:J,createReport:Tr,updateReport:G,uploadState:Q,handleFileUpload:xt,handleUploadError:go,handleRetry:Vt,handleConfirm:zr,paginatedData:xo,processedData:hr,displayData:jr,tableMetrics:or,isGrouped:kr,tableEngine:rr,activeView:U,isDirty:Ke,currentTableState:Te,viewChanges:pt,filters:d==null?void 0:d.filters,showFilterPanel:N,setShowFilterPanel:re,filterFocusColumn:pe,handleAddCondition:Er,handleAddGroup:_r,handleUpdateCondition:$r,handleSetGroupOperator:we,handleRemoveFilterNode:ae,handleClearAllFilters:me,handleReplaceFilters:Ce,handleOpenFilterForColumn:tt,handleCloseFilterPanel:Ge,handleClearFiltersForColumn:Pn,sortStack:d==null?void 0:d.sortStack,showSortPanel:ue,setShowSortPanel:le,handleSort:Yr,handleUpdateSortStack:Ht,handleSortAscending:Br,handleSortDescending:qr,views:d==null?void 0:d.views,showCreateViewModal:Z,setShowCreateViewModal:de,showEditViewModal:se,setShowEditViewModal:W,showDeleteConfirmation:ie,setShowDeleteConfirmation:fe,editingView:rt,deletingView:he,editingViewId:P,deletingViewId:ke,handleSelectView:We,handleCreateView:Xe,handleCloneView:ft,handleUpdateCurrentView:dt,handleSaveColumnConfigToCurrentView:wt,handleSaveColumnConfigToAllViews:Gt,handleSaveAsNewView:xr,handleRevertChanges:Dr,handleToggleDefault:yo,handleToggleFavorite:No,handleSoftDelete:Jr,handleRestoreView:An,handlePermanentDelete:Kr,handleEditView:bo,handleCopyViewLink:Rn,handleSaveEditView:Vo,handleDeleteView:Xr,handleConfirmDelete:Ho,handlePromoteToGlobal:Qr,handleSetDefaultForAllUsers:vo,showManageColumns:Wr,setShowManageColumns:Qt,columnVisibility:d==null?void 0:d.columnVisibility,columnOrder:d==null?void 0:d.columnOrder,columnWidths:d==null?void 0:d.columnWidths,handleUpdateColumnVisibility:Go,handleUpdateColumnOrder:Uo,handleUpdateColumnWidth:Wn,handleResetColumnLayout:Ln,showGroupPanel:Pr,setShowGroupPanel:qe,grouping:d==null?void 0:d.grouping,groupingState:Et,handleGroup:qn,handleToggleGroupCollapse:Jn,handleExpandAllGroups:He,handleCollapseAllGroups:et,searchQuery:lt,debouncedSearchQuery:Pt,searchHistory:ml((d==null?void 0:d.searchHistory)||[]),handleSearchChange:Fn,handleAddToSearchHistory:Nn,handleToggleSearchFavourite:Vn,handleDeleteSearchHistory:Hn,selectedRowIds:Lt,handleToggleRowSelection:Gn,handleToggleAllRows:Un,handleRangeSelection:Yn,handleClearSelection:to,handleUpdateSelectionAfterDelete:wo,currentPage:E==="server"?Ft:(ve==null?void 0:ve.currentPage)||1,pageSize:Le,paginationEngine:ve,paginationMode:E,paginationTotalRows:St,paginationTotalPages:Ur,handlePageChange:Zr,handlePageSizeChange:eo,isExporting:Ae,showExportModal:Se,setShowExportModal:Nt,showDirtyExportWarning:Ze,handleExport:Co,handleExportWithConfig:Yo,handleExportSelected:Kn,handleExportAnyway:nr,handleSaveAndExport:ir,handleCancelExport:qo,showAuditHistory:Vr,setShowAuditHistory:ur,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:pr,setShowCreatePreset:er,showManagePresets:fo,setShowManagePresets:Cr,activePreset:Ee,activePresetId:$t,handleOpenManagePresets:j,handleCreatePreset:Jo,handleClearActivePreset:Ko,handleDeletePresetById:H,userRole:je,isViewerRole:fr,currentUserId:Mt,permissions:d==null?void 0:d.permissions,featureLimitWarning:mo,setFeatureLimitWarning:ho,datasetMeta:ot,reportError:Hr,setReportError:Gr,handleError:Dt,schema:d==null?void 0:d.schema,hasSchemaConflicts:d!=null&&d.schema?Ja(d.schema):!1,snack:S,handleSnackClose:Y,showSnack:k,snackDurationMs:oe,config:z,scheduler:c}}const Hs=p.createContext(mt);function Ar(){return p.useContext(Hs)}const Gs=p.createContext(void 0);function zi(e){const{children:r,initialData:o,data:i,reportName:s,reportId:a,dataSource:l,pagination:c,search:u,scheduler:g,mode:x="builder",autoLoad:y=!0,config:w,devConfig:b,showDevPanel:z=!1,sharedReportId:h,sharedViewId:m,viewPersistence:E,permissions:v}=e,T=i||o,[B,f]=p.useState(()=>$a()),$=(()=>{const L=Ia(B,b,!!b);return{...L,display:{...L.display,showDevPanel:z||L.display.showDevPanel}}})(),F=oc({mode:x,autoLoad:y,initialData:T,dataSource:l,pagination:c,search:u,scheduler:g,reportName:s,reportId:a,sharedReportId:h,sharedViewId:m,viewPersistence:E,permissions:v,config:w,devConfig:$}),O=p.useCallback(te=>{f(te),Da(te)},[]),J={...F,activeDevConfig:$,handleDevConfigChange:O};return t.jsx(Hs.Provider,{value:$,children:t.jsx(Gs.Provider,{value:J,children:r})})}function vn(){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 Mr(e,...r){const o=new URL(`https://mui.com/production-error/?code=${e}`);return r.forEach(i=>o.searchParams.append("args[]",i)),`Minified MUI error #${e}; visit ${o} for the full message.`}const nc="$$material";function ic(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var en={exports:{}},tn={exports:{}},ze={};/** @license React v16.13.1
105
+ </html>`;try{const f=document.createElement("iframe");f.style.position="fixed",f.style.right="0",f.style.bottom="0",f.style.width="0",f.style.height="0",f.style.border="0",document.body.appendChild(f);const B=((m=f.contentWindow)==null?void 0:m.document)||f.contentDocument;if(B){B.open(),B.write(y),B.close(),setTimeout(()=>{var j,D;try{(j=f.contentWindow)==null||j.focus(),(D=f.contentWindow)==null||D.print()}catch{}setTimeout(()=>{document.body.removeChild(f)},3e3)},300);return}}catch{}const S=new Blob([y],{type:"text/html;charset=utf-8;"}),b=URL.createObjectURL(S);window.open(b,"_blank")||Ti(y,gn(r,"html"),"text/html;charset=utf-8;")}function Xo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Hi=10;function ml(e,r){const o=r.trim();if(!o)return e;const i=e.findIndex(a=>a.query.toLowerCase()===o.toLowerCase());let s;return i!==-1?s=[{...e[i],lastUsed:Date.now()},...e.slice(0,i),...e.slice(i+1)]:s=[{query:o,isFavourite:!1,lastUsed:Date.now()},...e],s.length>Hi&&(s=[...s].sort((l,c)=>l.isFavourite&&!c.isFavourite?-1:!l.isFavourite&&c.isFavourite?1:c.lastUsed-l.lastUsed).slice(0,Hi)),s}function xl(e,r){return e.map(o=>o.query===r?{...o,isFavourite:!o.isFavourite}:o)}function gl(e,r){return e.filter(o=>o.query!==r)}function yl(e){const r=e.filter(i=>i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed),o=e.filter(i=>!i.isFavourite).sort((i,s)=>s.lastUsed-i.lastUsed);return[...r,...o]}const bl={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 vl(e,r){return!e||e.owner===r?"owner":e.editors.includes(r)?"editor":(e.viewers.includes(r),"viewer")}function Ct(e,r){return bl[r].includes(e)}function jt(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 Sl(e){return e==="viewer"}const Gi=1e3;function fi(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function Yt(e){if(!e)return"";const o=e.replace(/[_-]/g," ").replace(/([a-z])([A-Z])/g,"$1 $2");return fi(o)}const wl={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 Cl(e){if(!e||!e.column)return"a filter";const r=Yt(e.column),o=wl[e.operator]??e.operator;return["isTrue","isFalse","NULL","NOT_NULL"].includes(e.operator)?`"${r}" ${o}`:`"${r}" ${o} "${e.value}"`}function ei(e){return e?typeof e=="string"?e:"children"in e?"a condition group":Cl(e):"a filter"}function Ui(e){return!e||!e.enabled||e.levels.length===0?"grouping removed":`grouped by ${e.levels.map(o=>`"${Yt(o.column)}"`).join(", ")}`}function jl(e){var s,a,l;const{action:r,previousState:o,newState:i}=e;switch(r){case"filter_added":return{summary:`Filter added: ${ei(i)}`};case"filter_removed":return{summary:`Filter removed: ${ei(o)}`};case"filter_updated":{if(typeof i=="string")return{summary:`Filter updated: ${i}`};const c=o,u=i;return c!=null&&c.column&&(u!=null&&u.column)&&c.column!==u.column?{summary:`Filter changed on "${Yt(u.column)}"`,detail:`Previously filtered "${Yt(c.column)}"`}:{summary:`Filter updated: ${ei(u)}`}}case"filter_cleared":{const c=o&&typeof o=="object"&&"count"in o?o.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?Yt(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=o!=null&&o.column?Yt(o.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: ${Ui(i)}`};case"group_level_removed":{const c=o,u=(a=(s=c==null?void 0:c.levels)==null?void 0:s[0])!=null&&a.column?Yt(c.levels[0].column):"";return{summary:u?`Group level removed: "${u}"`:"Group level removed"}}case"group_reordered":return{summary:`Grouping updated: ${Ui(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: "${Yt(c)}"`:"Column hidden"}}case"column_shown":{const c=(i==null?void 0:i.column)??(typeof i=="string"?i:"");return{summary:c?`Column shown: "${Yt(c)}"`:"Column made visible"}}case"column_reordered":{const c=Array.isArray(o)?o:[],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: "${Yt(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)??(o==null?void 0:o.name)??"";return{summary:c?`View updated: "${c}"`:"View updated"}}case"view_deleted":{const c=(o==null?void 0:o.name)??(o==null?void 0:o.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=(o==null?void 0:o.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":case"export_pdf":{const c=r==="export_csv"?"CSV":r==="export_excel"?"Excel":r==="export_json"?"JSON":"PDF",u=i==null?void 0:i.rowCount,x=(i==null?void 0:i.scope)==="all"?"all rows":"filtered rows",g=(i==null?void 0:i.viewName)??"",y=typeof u=="number"?` (${u.toLocaleString()} rows)`:"";return{summary:`Exported as ${c}${y}`,detail:g?`${fi(x)} · View: "${g}"`:fi(x)}}case"export_triggered":{const c=((l=i==null?void 0:i.format)==null?void 0:l.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=(o==null?void 0:o.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"row_edited":{const c=(i==null?void 0:i.id)??(o==null?void 0:o.id)??"",u=(i==null?void 0:i.label)??(o==null?void 0:o.label)??(c?`#${c}`:"");return{summary:u?`Row edited: "${u}"`:"Row edited"}}case"row_deleted":{const c=(o==null?void 0:o.id)??"",u=(o==null?void 0:o.label)??(c?`#${c}`:"");return{summary:u?`Row deleted: "${u}"`:"Row deleted"}}case"row_duplicated":{const c=(o==null?void 0:o.id)??"",u=(o==null?void 0:o.label)??(c?`#${c}`:"");return{summary:u?`Row duplicated: "${u}"`:"Row duplicated"}}case"theme_changed":{const c=typeof o=="string"?o:(o==null?void 0:o.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:Tl(r)}}}function kl(){return`EVT_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function $o(e,r,o,i,s,a){return{id:kl(),user:r,reportId:e,feature:o,action:i,timestamp:new Date().toISOString(),previousState:s,newState:a}}function Io(e,r){const o=[r,...e];return o.length>Gi?o.slice(0,Gi):o}function Tl(e){return{filter_added:"Filter Added",filter_removed:"Filter Removed",filter_updated:"Filter Updated",filter_cleared:"All Filters Cleared",sort_level_added:"Sort Level Added",sort_level_removed:"Sort Level Removed",sort_reordered:"Sort Reordered",sort_cleared:"All Sorting Cleared",group_level_added:"Group Level Added",group_level_removed:"Group Level Removed",group_reordered:"Group Reordered",group_cleared:"All Grouping Cleared",column_hidden:"Column Hidden",column_shown:"Column Shown",column_reordered:"Columns Reordered",column_resized:"Column Resized",view_created:"View Created",view_updated:"View Updated",view_deleted:"View Deleted",view_set_default:"View Set as Default",view_switched:"View Switched",theme_changed:"Theme Changed",export_triggered:"Export Triggered",export_csv:"Exported as CSV",export_excel:"Exported as Excel",export_json:"Exported as JSON",export_pdf:"Exported as PDF",preset_created:"Preset Created",preset_applied:"Preset Applied",preset_deleted:"Preset Deleted",preset_link_copied:"Preset Link Copied",row_edited:"Row Edited",row_deleted:"Row Deleted",row_duplicated:"Row Duplicated",error_occurred:"Error Occurred"}[e]||e}function ti(e){return{filters:"Filters",sorting:"Sorting",grouping:"Grouping",columns:"Columns",views:"Views",theme:"Theme",export:"Export",presets:"Presets",rows:"Rows",system:"System"}[e]||e}function zl(e){const r=new Date(e),i=new Date().getTime()-r.getTime(),s=Math.floor(i/6e4),a=Math.floor(i/36e5),l=Math.floor(i/864e5);return s<1?"Just now":s<60?`${s} minute${s>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:l<7?`${l} day${l>1?"s":""} ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const Yi=100;function Bl(){return`preset_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}function El(e){var a;const r=(a=e.views)==null?void 0:a.find(l=>l.id===e.activeViewId),o=r==null?void 0:r.snapshot.columnOrder,i=e.columnOrder||[],s=ki(i,e.grouping||null,o);return{filters:qe(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 _l(e,r,o,i){return{id:Bl(),name:e,description:r,createdBy:o,createdAt:Date.now(),config:i}}function $l(e,r){const o=e||[];if(o.length>=Yi)throw new Error(`Maximum of ${Yi} presets reached. Please delete old presets first.`);return[...o,r]}function Il(e,r){return(e||[]).filter(i=>i.id!==r)}function qi(e,r){if(e)return e.find(o=>o.id===r)}function Dl(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("preset")}function Ol(e){const r=e.columnOrder,o=zo(r,e.grouping);return{filters:qe(e.filters),sortStack:e.sortStack.length>0?[...e.sortStack]:void 0,columnVisibility:{...e.columnVisibility},columnOrder:o,columnWidths:{...e.columnWidths},grouping:e.grouping?{...e.grouping}:null,activeViewId:e.activeViewId}}async function Ml(e){try{if(navigator.clipboard&&navigator.clipboard.writeText)return await navigator.clipboard.writeText(e),!0}catch(r){qt.warn("urm:presets","Clipboard API blocked, using fallback method",r)}try{const r=document.createElement("textarea");r.value=e,r.style.position="fixed",r.style.top="0",r.style.left="0",r.style.width="2em",r.style.height="2em",r.style.padding="0",r.style.border="none",r.style.outline="none",r.style.boxShadow="none",r.style.background="transparent",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();let o=!1;try{o=document.execCommand("copy")}catch(i){qt.error("urm:presets","execCommand copy failed",i)}return document.body.removeChild(r),o}catch(r){return qt.error("urm:presets","Fallback copy method failed",r),!1}}function Al(e,r){return{totalRows:e.length,totalColumns:r.length}}function gr(e,r,o,i){const s=o instanceof Error?o.message:o,a={type:e,context:r,message:s,details:i,timestamp:Date.now(),recoverable:Rl(e,r)};return process.env.NODE_ENV==="development"&&qt.error("urm:error-handling","[Report Error]",{type:e,context:r,message:s,details:i}),a}function Rl(e,r){return e==="ui"?!0:r==="export"?!1:e==="processing"&&["filters","sorting","grouping","columns"].includes(r)?!0:e!=="system"}function Wl(e){const o={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?`${o}. Your previous state has been restored.`:`${o}. Please refresh the page.`}function Pl(e){return{filters:e.filters,sortStack:e.sortStack?[...e.sortStack]:void 0,grouping:e.grouping?{...e.grouping}:void 0,columnVisibility:e.columnVisibility?{...e.columnVisibility}:void 0,columnOrder:e.columnOrder?[...e.columnOrder]:void 0,columnWidths:e.columnWidths?{...e.columnWidths}:void 0,activeViewId:e.activeViewId}}function Ll(e,r,o){o(e.id,{filters:qe(r.filters),sortStack:r.sortStack,grouping:r.grouping,columnVisibility:r.columnVisibility,columnOrder:r.columnOrder,columnWidths:r.columnWidths,activeViewId:r.activeViewId})}function Fl(e,r,o){return["equals","contains","starts_with","ends_with","gt","gte","lt","lte"].includes(r)&&(o==null||o==="")?{isValid:!1,errorMessage:"Value is required for this operator"}:e==="number"&&["gt","gte","lt","lte","equals"].includes(r)&&isNaN(Number(o))?{isValid:!1,errorMessage:"Value must be a valid number"}:e==="date"&&o&&isNaN(Date.parse(o))?{isValid:!1,errorMessage:"Value must be a valid date"}:{isValid:!0}}function Ys(e,r){const o=[],i=[],s=new Set(r.map(a=>a.name));return e.forEach(a=>{s.has(a.column)?o.push(a):i.push(a.column)}),{validRules:o,invalidColumns:i}}function qs(e,r){if(!e||!e.levels||e.levels.length===0)return{validGrouping:null,invalidColumns:[]};const o=new Set(r.map(a=>a.name)),i=[],s=[];return e.levels.forEach(a=>{o.has(a.column)?i.push(a):s.push(a.column)}),i.length===0?{validGrouping:null,invalidColumns:s}:{validGrouping:{...e,levels:i},invalidColumns:s}}function Nl(e,r){const o=[],i=new Set(r.map(a=>a.name)),s={...e};if(s.filters){const a=l=>{const c=l.children.filter(u=>{if(et(u))return!0;const x=i.has(u.column);return x||o.push(`Filter for column "${u.column}" ignored (column not found)`),x}).map(u=>et(u)?a(u):u).filter(u=>!et(u)||u.children.length>0);return{...l,children:c}};s.filters=a(qe(s.filters))}if(s.sortStack&&Array.isArray(s.sortStack)){const{validRules:a,invalidColumns:l}=Ys(s.sortStack,r);l.length>0&&o.push(`Sort rules for columns ignored: ${l.join(", ")}`),s.sortStack=a.length>0?a:void 0}if(s.grouping){const{validGrouping:a,invalidColumns:l}=qs(s.grouping,r);l.length>0&&o.push(`Grouping for columns ignored: ${l.join(", ")}`),s.grouping=a}if(s.columnVisibility){const a={};Object.entries(s.columnVisibility).forEach(([l,c])=>{i.has(l)?a[l]=c:o.push(`Column visibility for "${l}" ignored (column not found)`)}),s.columnVisibility=Object.keys(a).length>0?a:void 0}if(s.columnOrder&&Array.isArray(s.columnOrder)){const a=s.columnOrder.filter(l=>{const c=i.has(l);return c||o.push(`Column "${l}" in order ignored (column not found)`),c});s.columnOrder=a.length>0?a:void 0}if(s.columnWidths){const a={};Object.entries(s.columnWidths).forEach(([l,c])=>{i.has(l)?a[l]=c:o.push(`Column width for "${l}" ignored (column not found)`)}),s.columnWidths=Object.keys(a).length>0?a:void 0}return{sanitizedConfig:s,warnings:o}}function Vl(e,r){return gr("processing","export",e,{retryAvailable:!!(r!=null&&r.onRetry)})}function Ji(e,r,o,i){const s=$o(e,r,"system","error_occurred",null,{errorType:o.type,errorContext:o.context,errorMessage:o.message,recoverable:o.recoverable,timestamp:o.timestamp});return Io(i||[],s)}function Hl(e){return e==null}function Gl(e,r,o){const{operator:i,value:s}=r;if(i==="NULL")return e==null;if(i==="NOT_NULL")return e!=null;if(Hl(e))return!1;if(o==="date"){const a=new Date(e).getTime(),l=new Date(s).getTime();switch(i){case"equals":return a===l;case"gt":return a>l;case"lt":return a<l;case"gte":return a>=l;case"lte":return a<=l;default:return!0}}switch(i){case"equals":return String(e).toLowerCase()===String(s).toLowerCase();case"contains":return String(e).toLowerCase().includes(String(s).toLowerCase());case"startsWith":return String(e).toLowerCase().startsWith(String(s).toLowerCase());case"endsWith":return String(e).toLowerCase().endsWith(String(s).toLowerCase());case"gt":return Number(e)>Number(s);case"lt":return Number(e)<Number(s);case"gte":return Number(e)>=Number(s);case"lte":return Number(e)<=Number(s);case"isTrue":return e===!0;case"isFalse":return e===!1;default:return!0}}function hi(e,r,o){var s;if(et(r))return r.children.length===0?!0:r.operator==="and"?r.children.every(a=>hi(e,a,o)):r.children.some(a=>hi(e,a,o));const i=((s=o.find(a=>a.name===r.column))==null?void 0:s.type)??"string";return Gl(e[r.column],r,i)}function Bi(e,r,o){return!r||r.children.length===0?e:e.filter(i=>hi(i,r,o))}function fn(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 Ul(e){return e!=="isTrue"&&e!=="isFalse"&&e!=="NULL"&&e!=="NOT_NULL"}function Yl({data:e,filters:r,schema:o}){return{filteredData:p.useMemo(()=>!r||r.children.length===0?e:Bi(e,r,o),[e,r,o])}}function ql(e,r){const o=e.length+1,i=r.length+1,s=Array.from({length:o},()=>new Array(i).fill(0));for(let a=0;a<o;a+=1)s[a][0]=a;for(let a=0;a<i;a+=1)s[0][a]=a;for(let a=1;a<o;a+=1)for(let l=1;l<i;l+=1){const c=e[a-1]===r[l-1]?0:1;s[a][l]=Math.min(s[a-1][l]+1,s[a][l-1]+1,s[a-1][l-1]+c)}return s[o-1][i-1]}function Jl(e,r){const o=e.split(/\s+/).filter(Boolean);return r.some(i=>{const s=i.length<=5?1:2;return o.some(a=>ql(i,a)<=s)})}function Kl(e,r,o,i){if(!o||o.trim()==="")return e;const s=o.toLowerCase().trim(),a=s.split(/\s+/).filter(Boolean),l=r.filter(c=>i.includes(c.name));return e.filter(c=>l.some(u=>{const x=c[u.name];if(x==null)return!1;const g=String(x).toLowerCase();return g.includes(s)?!0:Jl(g,a)}))}function Xl({data:e,searchQuery:r,schema:o,visibleColumns:i,mode:s="client"}){return{searchedData:p.useMemo(()=>s==="server"||!r||r.trim()===""?e:Kl(e,o,r,i),[e,r,o,i,s])}}function Ql({data:e,sortStack:r,schema:o}){return{sortedData:p.useMemo(()=>!r||r.length===0?e:vi(e,o,r),[e,r,o])}}function Zl({data:e,grouping:r,schema:o}){const i=p.useMemo(()=>!r||!r.enabled||r.levels.length===0?e:il(e,o,r),[e,r,o]),s=(r==null?void 0:r.enabled)&&((r==null?void 0:r.levels.length)||0)>0;return{groupedData:i,isGrouped:s}}function ec({schema:e,columnVisibility:r,columnOrder:o}){const i=p.useMemo(()=>o.filter(c=>r[c]!==!1),[o,r]),s=p.useMemo(()=>Object.entries(r).filter(([c,u])=>!u).map(([c,u])=>c),[r]),a=p.useMemo(()=>o.map(c=>e.find(x=>x.name===c)||{name:c,type:"string"}),[o,e]),l=p.useMemo(()=>i.map(c=>e.find(x=>x.name===c)||{name:c,type:"string"}),[i,e]);return{visibleColumns:i,hiddenColumns:s,allColumns:a,visibleColumnSchemas:l,hiddenCount:s.length}}function tc({views:e,activeViewId:r,currentState:o}){const i=p.useMemo(()=>e.find(x=>x.id===r),[e,r]),s=p.useMemo(()=>i?cl(o,i.snapshot):!1,[i,o]),a=p.useMemo(()=>e.find(x=>x.isDefault),[e]),l=p.useMemo(()=>e.filter(x=>!x.isDefault&&!x.isDeleted),[e]),c=p.useMemo(()=>e.filter(x=>x.isFavorite&&!x.isDeleted),[e]),u=p.useMemo(()=>e.filter(x=>x.isDeleted),[e]);return{activeView:i,isDirty:s,defaultView:a,customViews:l,favoriteViews:c,deletedViews:u,isDefaultView:(i==null?void 0:i.isDefault)||!1}}function rc(e,r,o){if(!e||e.length===0)return[];if(r<=0)return e.slice(0,o);const i=e.slice(r,o);if(i.length===0)return[];const s=i[0],a=!!(s.__isGroupHeader||s.isGroupHeader),l=a?s.groupLevel??0:s.__urm_group_level__??0;if(l===0&&a)return i;const c=l-1;if(c<0)return i;const u={};let x=c+1;for(let T=r-1;T>=0;T--){const m=e[T];if(m.__isGroupHeader||m.isGroupHeader){const f=m.groupLevel??0;if(f<=c&&u[f]===void 0&&(u[f]=m,x--,x<=0))break}}const g=[];for(let T=0;T<=c;T++)u[T]&&g.push({...u[T],__urm_is_continuation_header__:!0});const y=Math.max(0,o-r-g.length),S=r+y,b=e.slice(r,S);return[...g,...b]}function oc({data:e,enabled:r=!1,pageSize:o=100,initialPage:i=1}){const[s,a]=p.useState(i),l=e.length,c=Math.max(1,Math.ceil(l/o));p.useEffect(()=>{s>c&&a(c)},[s,c]);const u=p.useMemo(()=>{if(!r)return e;const b=(s-1)*o,T=b+o;return rc(e,b,T)},[e,r,s,o]),x=p.useCallback(b=>{const T=Math.max(1,Math.min(b,c));a(T)},[c]),g=p.useCallback(()=>{s<c&&a(b=>Math.min(b+1,c))},[c]),y=p.useCallback(()=>{s>1&&a(b=>Math.max(b-1,1))},[]),S=p.useCallback(()=>{a(1)},[]);return{paginatedData:u,currentPage:s,totalPages:c,pageSize:o,totalRows:l,goToPage:x,nextPage:g,prevPage:y,resetPage:S,hasNextPage:s<c,hasPrevPage:s>1}}function nc(e){const{rawData:r,schema:o,filters:i,sortStack:s,grouping:a,searchQuery:l,searchMode:c,columnVisibility:u,columnOrder:x,columnWidths:g,views:y,activeViewId:S,pagination:b}=e,T=p.useMemo(()=>({filters:i,sortStack:s,grouping:a,columnVisibility:u,columnOrder:x,columnWidths:g}),[i,s,a,u,x,g]),m=tc({views:y,activeViewId:S,currentState:T}),f=ec({schema:o,columnVisibility:u,columnOrder:x}),{filteredData:B}=Yl({data:r,filters:i,schema:o}),{sortedData:j}=Ql({data:B,sortStack:s,schema:o}),{groupedData:D,isGrouped:z}=Zl({data:j,grouping:a,schema:o}),{searchedData:h}=Xl({data:D,searchQuery:l,schema:o,visibleColumns:f.visibleColumns,mode:c}),I=oc({data:h,enabled:(b==null?void 0:b.enabled)||!1,pageSize:(b==null?void 0:b.pageSize)||100,initialPage:(b==null?void 0:b.currentPage)||1}),A=b!=null&&b.enabled?I.paginatedData:h,$=p.useMemo(()=>({totalRows:r.length,filteredRows:B.length,sortedRows:j.length,groupedRows:z?D.length:j.length,searchedRows:h.length,visibleRows:A.length,hiddenColumns:f.hiddenCount,activeFilters:Tt(i),activeSorts:s.length,isGrouped:z}),[r.length,B.length,j.length,D.length,h.length,A.length,f.hiddenCount,i,s.length,z]);return{data:A,filteredData:B,sortedData:j,groupedData:D,searchedData:h,viewEngine:m,columnEngine:f,paginationEngine:I,metrics:$,isGrouped:z,isPaginated:(b==null?void 0:b.enabled)||!1}}let ic=0;function sc(e,r){e!==null&&e.__urm_row_id__===void 0&&Object.defineProperty(e,"__urm_row_id__",{value:r?r(e):ic++,writable:!1,enumerable:!1,configurable:!1})}const Mt="user-demo-001";function ac(e={}){var Ze,xe,Dt,Ot,Ee;const{mode:r="builder",autoLoad:o=!0,initialData:i,dataSource:s,pagination:a,search:l,scheduler:c,reportName:u,reportId:x,sharedReportId:g,sharedViewId:y,viewPersistence:S,permissions:b,config:T={},devConfig:m}=e,f=(S==null?void 0:S.mode)??"local",B=(a==null?void 0:a.mode)??"client",j=(l==null?void 0:l.mode)??"client",[D,z]=p.useState([]),h=m??ft,[I,A]=p.useState(""),[$,Y]=p.useState(!1),[X,R]=p.useState(!1),[v,W]=p.useState({message:"",severity:"info",open:!1}),k=(w,E="info")=>{W({message:w,severity:E,open:!0})},q=()=>W(w=>({...w,open:!1})),re=T.notifDurationMs,d=D.find(w=>w.id===I),[Q,ee]=p.useState("idle"),[H,te]=p.useState(!1),[ue,le]=p.useState(!1),[Z,de]=p.useState(!1),[ae,F]=p.useState(!1),[ie,he]=p.useState(!1),[pe,Me]=p.useState(void 0),[L,Se]=p.useState(null),[ke,We]=p.useState(null),[Ae,at]=p.useState(!1),[tt,Wt]=p.useState(!1),[Bt,Jt]=p.useState(null),[Pr,Kt]=p.useState(!1),[Lr,Ke]=p.useState(!1),[Et,Fr]=p.useState({enabled:!1,levels:[],collapsedGroups:[]}),[ct,cr]=p.useState(""),[Pt,Nr]=p.useState(""),[Lt,_t]=p.useState(new Set),[Ft,dt]=p.useState(1),[Pe,Vr]=p.useState(15),[Hr,dr]=p.useState(!1),[ur,Xt]=p.useState(!1),[fo,vr]=p.useState(!1),[$t,He]=p.useState(null),[Ce,Nt]=p.useState(!1),[ho,mo]=p.useState(null),[xo,Sr]=p.useState(null),wr=p.useRef(null),je=p.useMemo(()=>d?vl(d.permissions,Mt):"owner",[d]),Cr=Sl(je),Gr=p.useMemo(()=>!(d!=null&&d.uploadedData)||!(d!=null&&d.schema)?{totalRows:0,totalColumns:0}:Al(d.uploadedData,d.schema),[d==null?void 0:d.uploadedData,d==null?void 0:d.schema]),mt=p.useCallback(()=>{d&&(wr.current=Pl(d))},[d]),N=p.useCallback((w,E)=>{z(P=>P.map(O=>O.id===w?{...O,...E}:O))},[]),ut=p.useCallback(w=>{if(!d)return;Sr(w);const E=Ji(d.id,Mt,w,d.auditHistory||[]);N(d.id,{auditHistory:E}),k(w.message,"error"),w.recoverable&&wr.current&&setTimeout(()=>{Ll(d,wr.current,N),k("Previous state restored","success")},100)},[d,N]),se=p.useCallback((w,E,P,O)=>{if(!d)return;const K=$o(d.id,Mt,w,E,P,O),J=d.auditHistory||[],ce=Io(J,K);setTimeout(()=>{N(d.id,{auditHistory:ce})},0)},[d,N]);p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const w=Zn(d.schema);(()=>{try{const E=localStorage.getItem("urm_dev_config");return E?JSON.parse(E):null}catch{return null}})(),N(d.id,{views:[w],activeViewId:w.id,filters:w.snapshot.filters,sortStack:w.snapshot.sortStack,columnVisibility:w.snapshot.columnVisibility,columnOrder:w.snapshot.columnOrder,columnWidths:w.snapshot.columnWidths,grouping:w.snapshot.grouping})}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,N]),p.useEffect(()=>{if(i&&o&&!X&&D.length===0){const w=lo(i),E={id:x||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:"Auto-generated from external data",schemaLocked:!0,uploadedData:w,schema:Pi(Co(w),T.hiddenColumns),permissions:b??{owner:Mt,editors:[],viewers:[]}};z([E]),A(E.id),R(!0),ee("confirmed")}},[i,o,X,D.length,r,u,x]),p.useEffect(()=>{B!=="server"||!X||!I||N(I,{uploadedData:lo(i||[])})},[i,B,X,I]),p.useEffect(()=>{B==="server"&&((a==null?void 0:a.page)!==void 0&&dt(a.page),(a==null?void 0:a.pageSize)!==void 0&&Vr(a.pageSize))},[a==null?void 0:a.page,a==null?void 0:a.pageSize,B]),p.useEffect(()=>{if(!s||X)return;let w=!1,E=null;const P=async()=>{try{ee("uploading");let O;if(s.type==="api"){const J=await fetch(s.url,{headers:s.headers||{}});if(!J.ok)throw new Error(`HTTP ${J.status}: ${J.statusText}`);O=await J.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 K=Co(O);if(X)z(J=>J.map(ce=>ce.id===I?{...ce,uploadedData:lo(O)}:ce)),ee("confirmed");else{const J={id:x||`auto-report-${Date.now()}`,name:u||(r==="viewer"?"Data View":"Imported Data"),description:`Loaded from ${s.type==="api"?s.url:"callback"}`,schemaLocked:!0,uploadedData:lo(O),schema:Pi(Co(lo(O)),T.hiddenColumns),permissions:b??{owner:Mt,editors:[],viewers:[]}};z([J]),A(J.id),R(!0),ee("confirmed")}}catch(O){w||(ee("error"),d&&N(d.id,{uploadError:(O==null?void 0:O.message)||"Failed to load data from source"}))}};return P(),s.refreshInterval&&s.refreshInterval>0&&(E=setInterval(P,s.refreshInterval)),()=>{w=!0,E&&clearInterval(E)}},[s,u,r,x]);const xt=(Ze=d==null?void 0:d.views)==null?void 0:Ze.find(w=>w.id===d.activeViewId),fe=p.useMemo(()=>d!=null&&d.uploadedData?(d.uploadedData.forEach(w=>sc(w,T.getRowId)),d.uploadedData):[],[d==null?void 0:d.uploadedData]);p.useEffect(()=>{_t(w=>{if(w.size===0)return w;const E=new Set(fe.map(O=>O==null?void 0:O.__urm_row_id__)),P=new Set(Array.from(w).filter(O=>E.has(O==null?void 0:O.__urm_row_id__)));return P.size===w.size?w:P})},[fe]);const Vt=nc({rawData:fe,schema:(d==null?void 0:d.schema)||[],filters:qe(d==null?void 0:d.filters),sortStack:(d==null?void 0:d.sortStack)||[],grouping:(d==null?void 0:d.grouping)||null,searchQuery:Pt||"",searchMode:j,columnVisibility:(d==null?void 0:d.columnVisibility)||(xt==null?void 0:xt.snapshot.columnVisibility)||{},columnOrder:(d==null?void 0:d.columnOrder)||(xt==null?void 0:xt.snapshot.columnOrder)||[],columnWidths:(d==null?void 0:d.columnWidths)||(xt==null?void 0:xt.snapshot.columnWidths)||{},views:(d==null?void 0:d.views)||[],activeViewId:(d==null?void 0:d.activeViewId)||"",pagination:{enabled:B==="client",pageSize:Pe,currentPage:Ft}}),{data:Ur=[],searchedData:pr=[],groupedData:jr=[],sortedData:Qt=[],metrics:fr={totalRows:0,searchedRows:0,isGrouped:!1},isGrouped:Ht=!1,paginationEngine:we}=Vt||{},It=B==="server"?(a==null?void 0:a.totalRows)??0:Ht?fr.totalRows:fr.searchedRows,Yr=B==="server"?Math.max(1,Math.ceil(((a==null?void 0:a.totalRows)??0)/Pe)):(we==null?void 0:we.totalPages)??1,V=((xe=Vt.viewEngine)==null?void 0:xe.activeView)||xt,rt=((Dt=Vt.viewEngine)==null?void 0:Dt.isDirty)||!1;p.useEffect(()=>{if(!(!V||!d)&&!d.columnOrder){const w=V.snapshot.columnOrder,E=zo(w,V.snapshot.grouping);N(d.id,{columnOrder:E})}},[d==null?void 0:d.activeViewId]);const Oe=p.useMemo(()=>!(d!=null&&d.schema)||!V?null:ll(d.filters,d.sortStack||[],d.schema,d.columnVisibility,d.columnOrder,d.columnWidths,d.grouping,V.snapshot.columnOrder),[d==null?void 0:d.filters,d==null?void 0:d.sortStack,d==null?void 0:d.schema,d==null?void 0:d.columnVisibility,d==null?void 0:d.columnOrder,d==null?void 0:d.columnWidths,d==null?void 0:d.grouping,V]),kr=p.useMemo(()=>!V||!Oe||!rt?[]:ul(Oe,V.snapshot),[V,Oe,rt]),Zt=p.useCallback((w,E,P)=>{const O={id:`report-${Date.now()}`,name:w,description:E,schemaLocked:!1,permissions:{owner:Mt,editors:[],viewers:[]}};if(P&&Array.isArray(P)&&P.length>0){const K=Co(P),J=Zn(K);O.uploadedData=P,O.schema=K,O.schemaLocked=!0,O.views=[J],O.activeViewId=J.id,O.sortStack=J.snapshot.sortStack,O.filters=J.snapshot.filters,O.columnVisibility=J.snapshot.columnVisibility,O.columnOrder=J.snapshot.columnOrder,O.columnWidths=J.snapshot.columnWidths,O.grouping=J.snapshot.grouping}z(K=>[...K,O]),A(O.id),Y(!1),ee("confirmed")},[]),gt=p.useCallback(w=>{d&&(ee("uploading"),setTimeout(()=>{const E=Co(w);N(d.id,{uploadedData:w,schema:E,uploadError:void 0}),ee("preview")},500))},[d,N]),Tr=p.useCallback(w=>{d&&(N(d.id,{uploadError:w}),ee("idle"))},[d,N]),nt=p.useCallback(()=>{d&&(N(d.id,{uploadError:void 0,uploadedData:void 0,schema:void 0}),ee("idle"))},[d,N]),go=p.useCallback(()=>{d&&(N(d.id,{schemaLocked:!0}),ee("confirmed"))},[d,N]),qr=p.useCallback(w=>{if(!d)return;if(!Ct("edit_sorting",je)){k(jt("edit_sorting"),"error");return}const E=d.sortStack??[],P=E.find(O=>O.column===w);if(P){const O=tl(P.direction);if(O===null){const K=E.filter(J=>J.column!==w).map((J,ce)=>({...J,priority:ce+1}));se("sorting","sort_level_removed",P,null),N(d.id,{sortStack:K.length>0?K:void 0})}else{const K=O,J=E.map(ce=>ce.column===w?{...ce,direction:K}:ce);se("sorting","sort_reordered",{column:w,direction:P.direction},{column:w,direction:K}),N(d.id,{sortStack:J})}}else{if(E.length>=h.sort.maxLevels){k(`Sort limit reached — maximum ${h.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};se("sorting","sort_level_added",null,O),N(d.id,{sortStack:[...E,O]})}},[d,je,N,se]),St=p.useCallback(w=>{if(!d)return;const E=d.sortStack??[],P=w.length===0?"sort_cleared":"sort_reordered";if(d.schema){const{validRules:O,invalidColumns:K}=Ys(w,d.schema);K.length>0&&k(`Removed invalid sort columns: ${K.join(", ")}`),mt();try{se("sorting",P,E,O.length>0?O:null),N(d.id,{sortStack:O.length>0?O:void 0})}catch(J){const ce=gr("processing","sorting",J);ut(ce)}}else se("sorting",P,E,w.length>0?w:null),N(d.id,{sortStack:w.length>0?w:void 0})},[d,N,mt,ut,se]),zr=p.useCallback(w=>{if(!d)return;const E=d.sortStack??[],P=E.find(O=>O.column===w);if(!(P&&P.direction==="asc"))if(P){const O=E.map(K=>K.column===w?{...K,direction:"asc"}:K);se("sorting","sort_reordered",{column:w,direction:P.direction},{column:w,direction:"asc"}),N(d.id,{sortStack:O})}else{if(E.length>=h.sort.maxLevels){k(`Sort limit reached — maximum ${h.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};se("sorting","sort_level_added",null,O),N(d.id,{sortStack:[...E,O]})}},[d,N,se]),Jr=p.useCallback(w=>{if(!d)return;const E=d.sortStack??[],P=E.find(O=>O.column===w);if(!(P&&P.direction==="desc"))if(P){const O=E.map(K=>K.column===w?{...K,direction:"desc"}:K);se("sorting","sort_reordered",{column:w,direction:P.direction},{column:w,direction:"desc"}),N(d.id,{sortStack:O})}else{if(E.length>=h.sort.maxLevels){k(`Sort limit reached — maximum ${h.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};se("sorting","sort_level_added",null,O),N(d.id,{sortStack:[...E,O]})}},[d,N,se]),Br=p.useCallback((w,E)=>{var O;if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const P=(O=d.schema)==null?void 0:O.find(K=>K.name===E.column);if(P&&E.value!==void 0){const K=Fl(P.type,E.operator,E.value);if(!K.isValid){k(K.errorMessage||"Invalid filter value","error");return}}mt();try{const K=qe(d.filters),J={...E,id:uo()},ce=po(K,w,J);se("filters","filter_added",null,J),N(d.id,{filters:ce})}catch(K){const J=gr("processing","filters",K);ut(J)}},[d,je,N,mt,ut,se]),Kr=p.useCallback(w=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const E=qe(d.filters),P=po(E,w,At());se("filters","filter_added",null,"a condition group"),N(d.id,{filters:P})},[d,je,N,se]),Er=p.useCallback((w,E)=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const P=qe(d.filters),O=an(P,w),K=wi(P,w,E),J=an(K,w);se("filters","filter_updated",O,J),N(d.id,{filters:K})},[d,je,N,se]),_r=p.useCallback((w,E)=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const P=qe(d.filters),O=Ci(P,w,E);se("filters","filter_updated",null,`group operator changed to ${E.toUpperCase()}`),N(d.id,{filters:O})},[d,je,N,se]),me=p.useCallback(w=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const E=qe(d.filters),P=an(E,w),O=ji(E,w);se("filters","filter_removed",P,null),N(d.id,{filters:O})},[d,je,N,se]),oe=p.useCallback(()=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const w=qe(d.filters);se("filters","filter_cleared",{count:Tt(w)},null),N(d.id,{filters:At()})},[d,je,N,se]),be=p.useCallback(w=>{if(!d)return;if(!Ct("edit_filters",je)){k(jt("edit_filters"),"error");return}const E=qe(d.filters);se("filters","filter_cleared",{count:Tt(E)},{count:Tt(w)}),N(d.id,{filters:w})},[d,je,N,se]),Ge=p.useCallback(w=>{var K;if(!d)return;const E=(K=d.views)==null?void 0:K.find(J=>J.id===w);if(!E)return;const P=E.snapshot.columnOrder,O=zo(P,E.snapshot.grouping);se("views","view_switched",{previousViewId:d.activeViewId},{viewId:w,name:E.name}),N(d.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}),_t(new Set)},[d,N,se]),Le=p.useCallback((w,E,P)=>{var ve;if(!(d!=null&&d.schema)||!Oe)return;const O=d.views??[],K=O.filter(Gt=>!Gt.isDeleted).length,J=((ve=h.views)==null?void 0:ve.maxViews)??10;if(K>=J){k(`View limit reached — you can have at most ${J} saved views. Delete an existing view to create a new one.`,"error");return}const ce={id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:w,description:E||void 0,isDefault:P,isFavorite:!1,isDeleted:!1,scope:"personal",createdBy:Mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...Oe}},ge=P?O.map(Gt=>({...Gt,isDefault:!1})):O;se("views","view_created",null,{viewId:ce.id,name:w,isDefault:P}),N(d.id,{views:[...ge,ce],activeViewId:ce.id}),k(`"${w}" view created`,"success")},[d,Oe,N,se]),lt=p.useCallback(w=>{var ce;if(!(d!=null&&d.views))return;const E=d.views.find(ge=>ge.id===w);if(!E)return;const P=d.views,O=P.filter(ge=>!ge.isDeleted).length,K=((ce=h.views)==null?void 0:ce.maxViews)??10;if(O>=K){k(`View limit reached — you can have at most ${K} saved views. Delete an existing view to create a new one.`,"error");return}const J={...E,id:`view-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:`${E.name} (copy)`,scope:"personal",isDefault:!1,isFavorite:!1,isDeleted:!1,createdBy:Mt,createdAt:Date.now(),updatedAt:Date.now(),snapshot:{...E.snapshot}};N(d.id,{views:[...P,J]}),k(`"${J.name}" created`,"success")},[d,h,N]),Qe=p.useCallback(()=>{var E;if(!V||!Oe||!d)return;const w=(E=d.views)==null?void 0:E.map(P=>P.id===V.id?{...P,snapshot:{...Oe}}:P);N(d.id,{views:w}),k(`"${V.name}" view updated`,"success")},[V,Oe,d,N]),$r=p.useCallback(w=>{var O;if(!V||!Oe||!d)return;const E=w??Oe.columnWidths,P=(O=d.views)==null?void 0:O.map(K=>K.id===V.id?{...K,snapshot:{...K.snapshot,columnVisibility:Oe.columnVisibility,columnOrder:Oe.columnOrder,columnWidths:E},updatedAt:Date.now()}:K);N(d.id,{views:P,columnWidths:E}),k(`Column configuration saved to "${V.name}"`,"success")},[V,Oe,d,N]),er=p.useCallback(w=>{var J,ce;if(!Oe||!d||!V)return;const E=w??Oe.columnWidths,P={...V,snapshot:{...V.snapshot,columnVisibility:Oe.columnVisibility,columnOrder:Oe.columnOrder,columnWidths:E},updatedAt:Date.now()},O=(J=d.views)==null?void 0:J.map(ge=>ge.id===V.id?P:{...ge,snapshot:{...ge.snapshot,columnVisibility:Oe.columnVisibility,columnOrder:Oe.columnOrder,columnWidths:E},updatedAt:Date.now()});N(d.id,{views:O,columnWidths:E});const K=(((ce=d.views)==null?void 0:ce.length)||0)-1;k(`Column configuration saved to current view and ${K} other view${K===1?"":"s"}`,"success")},[Oe,d,V,N]),wt=p.useCallback(()=>{de(!0)},[]),tr=p.useCallback(()=>{if(!V||!d)return;const w=V.snapshot.columnOrder,E=zo(w,V.snapshot.grouping);N(d.id,{filters:V.snapshot.filters,sortStack:V.snapshot.sortStack.length>0?[...V.snapshot.sortStack]:void 0,columnVisibility:{...V.snapshot.columnVisibility},columnOrder:E,columnWidths:{...V.snapshot.columnWidths},grouping:V.snapshot.grouping}),k("Changes reverted to last saved state","success")},[V,d,N]),Ir=p.useCallback(w=>{if(!(d!=null&&d.views))return;const E=d.views.map(O=>({...O,isDefault:O.id===w}));N(d.id,{views:E});const P=d.views.find(O=>O.id===w);P&&k(`"${P.name}" set as default view`,"success")},[d,N]),On=p.useCallback(w=>{if(!(d!=null&&d.views))return;const E=d.views.map(O=>O.id===w?{...O,isFavorite:!O.isFavorite,updatedAt:Date.now()}:O);N(d.id,{views:E});const P=d.views.find(O=>O.id===w);P&&!P.isFavorite?k(`"${P.name}" added to favorites`,"success"):P&&k(`"${P.name}" removed from favorites`,"info")},[d,N]),Mn=p.useCallback(w=>{if(!(d!=null&&d.views))return;const E=d.views.find(ve=>ve.id===w),P=d.views.filter(ve=>!ve.isDeleted||ve.id===w);if((E==null?void 0:E.isDefault)&&P.filter(ve=>ve.isDefault).length===1){k("Cannot delete the last default view","error");return}const K=d.views.map(ve=>ve.id===w?{...ve,isDeleted:!0,updatedAt:Date.now()}:ve),J=d.activeViewId===w,ce=K.find(ve=>ve.isDefault&&!ve.isDeleted);N(d.id,{views:K,activeViewId:J&&ce?ce.id:d.activeViewId,filters:J&&ce?ce.snapshot.filters:d.filters,sortStack:J&&ce?ce.snapshot.sortStack.length>0?ce.snapshot.sortStack:void 0:d.sortStack});const ge=d.views.find(ve=>ve.id===w);ge&&k(`"${ge.name}" moved to Recently Deleted`,"info")},[d,N]),Lo=p.useCallback(w=>{if(!(d!=null&&d.views))return;const E=d.views.map(O=>O.id===w?{...O,isDeleted:!1,updatedAt:Date.now()}:O);N(d.id,{views:E});const P=d.views.find(O=>O.id===w);P&&k(`"${P.name}" restored`,"success")},[d,N]),Xr=p.useCallback(w=>{if(!(d!=null&&d.views))return;const E=d.views.find(ge=>ge.id===w),P=d.views.filter(ge=>!ge.isDeleted||ge.id===w);if((E==null?void 0:E.isDefault)&&P.filter(ge=>ge.isDefault).length===1){k("Cannot delete the last default view","error");return}const K=d.views.filter(ge=>ge.id!==w),J=d.activeViewId===w,ce=K.find(ge=>ge.isDefault&&!ge.isDeleted);N(d.id,{views:K,activeViewId:J&&ce?ce.id:d.activeViewId,filters:J&&ce?ce.snapshot.filters:d.filters,sortStack:J&&ce?ce.snapshot.sortStack.length>0?ce.snapshot.sortStack:void 0:d.sortStack}),E&&k(`"${E.name}" permanently deleted`,"success")},[d,N]),An=p.useCallback(w=>{Se(w),F(!0)},[]),Qr=p.useCallback(async w=>{if(!d)return;const E=new URLSearchParams(window.location.search);E.set("reportId",d.id),E.set("view",w);const P=`${window.location.origin}${window.location.pathname}?${E.toString()}`,O=await Ml(P);k(O?"Link copied to clipboard":"Failed to copy link",O?"success":"error")},[d]),yo=p.useCallback((w,E)=>{if(!L||!(d!=null&&d.views))return;const P=d.views.map(O=>O.id===L?{...O,name:w,description:E||void 0}:O);N(d.id,{views:P}),Se(null)},[L,d,N]),Rn=p.useCallback(w=>{We(w),he(!0)},[]),Fo=p.useCallback(()=>{if(!ke||!(d!=null&&d.views))return;const w=d.views.find(K=>K.id===ke),E=d.views.filter(K=>K.id!==ke),P=d.activeViewId===ke,O=E.find(K=>K.isDefault);se("views","view_deleted",{viewId:ke,name:w==null?void 0:w.name},null),N(d.id,{views:E,activeViewId:P&&O?O.id:d.activeViewId,filters:P&&O?O.snapshot.filters:d.filters,sortStack:P&&O?O.snapshot.sortStack.length>0?O.snapshot.sortStack:void 0:d.sortStack}),We(null),he(!1)},[ke,d,N,se]),Zr=p.useCallback(w=>{var K;if(!(d!=null&&d.views))return;if(!(((K=h.views)==null?void 0:K.isAdmin)??!1)){k("Only administrators can promote views to Global.","error");return}const P=d.views.find(J=>J.id===w);if(!P)return;if(P.scope==="global"){k(`"${P.name}" is already a Global View.`,"info");return}const O=d.views.map(J=>J.id===w?{...J,scope:"global",isDefault:!0,updatedAt:Date.now()}:J.scope==="global"&&J.isDefault?{...J,isDefault:!1}:J);N(d.id,{views:O}),k(`"${P.name}" promoted to Global View and set as default.`,"success")},[d,h,N]),No=p.useCallback((w,E)=>{if(!(d!=null&&d.views))return;const P=d.views.find(J=>J.id===w);if(!P)return;const O=d.views.map(J=>J.id===w?{...J,isDefaultForAllUsers:E,updatedAt:Date.now()}:E&&J.isDefaultForAllUsers?{...J,isDefaultForAllUsers:!1}:J);se("views",E?"view_set_default":"view_updated",{viewId:w,isDefaultForAllUsers:!E},{viewId:w,isDefaultForAllUsers:E}),N(d.id,{views:O}),k(`"${P.name}" ${E?"set as":"removed from"} default for all users.`,"success")},[d,N,se]),Dr=p.useRef(!0);p.useEffect(()=>{var w;if(Dr.current){Dr.current=!1;return}if(B==="server"){dt(1),(w=a==null?void 0:a.onPaginationChange)==null||w.call(a,1,Pe);return}we!=null&&we.resetPage?we.resetPage():dt(1)},[d==null?void 0:d.filters,Pt,d==null?void 0:d.activeViewId]);const bo=p.useCallback(w=>{var E;if(B==="server"){dt(w),(E=a==null?void 0:a.onPaginationChange)==null||E.call(a,w,Pe);return}we!=null&&we.goToPage&&we.goToPage(w)},[B,a,Pe,we]),Vo=p.useCallback(w=>{var K;const P=((B==="server"?Ft:(we==null?void 0:we.currentPage)||1)-1)*Pe,O=Math.floor(P/w)+1;if(B==="server"){Vr(w),dt(O),(K=a==null?void 0:a.onPaginationChange)==null||K.call(a,O,w);return}Vr(w),we==null||we.goToPage(O)},[Ft,Pe,B,a,we]),eo=p.useCallback((w,E)=>{if(!d)return;if(!Ct("edit_columns",je)){k(jt("edit_columns"),"error");return}const O={...d.columnVisibility||(V==null?void 0:V.snapshot.columnVisibility)||{},[w]:E};se("columns",E?"column_shown":"column_hidden",{columnName:w,visible:!E},{columnName:w,visible:E}),N(d.id,{columnVisibility:O})},[d,V,je,N,se]),to=p.useCallback(w=>{if(d){if(!Ct("edit_columns",je)){k(jt("edit_columns"),"error");return}se("columns","column_reordered",d.columnOrder,w),N(d.id,{columnOrder:w})}},[d,je,N,se]),Ho=p.useCallback((w,E)=>{if(!d)return;if(!Ct("edit_columns",je)){k(jt("edit_columns"),"error");return}const P=d.columnWidths||(V==null?void 0:V.snapshot.columnWidths)||{},O={...P,[w]:E};se("columns","column_resized",{columnName:w,width:P[w]},{columnName:w,width:E}),N(d.id,{columnWidths:O})},[d,V,je,N,se]),Go=p.useCallback(w=>{if(!d)return;const E=qe(d.filters),P=Hs(E,w);N(d.id,{filters:P})},[d,N]),Wn=p.useCallback(()=>{if(!V||!(d!=null&&d.schema))return;const w={},E=[],P={};d.schema.forEach(O=>{w[O.name]=!0,E.push(O.name),P[O.name]=170}),N(d.id,{columnVisibility:w,columnOrder:E,columnWidths:P,filters:void 0,sortStack:void 0}),k("Reset to default layout - all filters and sorts cleared","success")},[V,d,N]);p.useEffect(()=>{const w=setTimeout(()=>Nr(ct),300);return()=>clearTimeout(w)},[ct]),p.useEffect(()=>{var w;j==="server"&&((w=l==null?void 0:l.onSearchChange)==null||w.call(l,Pt))},[Pt,j,l]);const Pn=p.useCallback(w=>{cr(w),dt(1)},[]),Ln=p.useCallback(w=>{if(!w.trim()||!d)return;const E=d.searchHistory||[],P=ml(E,w);N(d.id,{searchHistory:P})},[d,N]),Fn=p.useCallback(w=>{if(!d)return;const E=d.searchHistory||[],P=xl(E,w);N(d.id,{searchHistory:P})},[d,N]),Nn=p.useCallback(w=>{if(!d)return;const E=d.searchHistory||[],P=gl(E,w);N(d.id,{searchHistory:P})},[d,N]);p.useEffect(()=>{if(!T.onSelectionChange)return;const w=Array.from(Lt);T.onSelectionChange(w,w.map(E=>E==null?void 0:E.__urm_row_id__))},[Lt,T.onSelectionChange]);const Vn=p.useCallback(w=>{const E=w==null?void 0:w.__urm_row_id__;_t(P=>{const O=new Set(P);let K;return E!==void 0?K=Array.from(O).find(J=>(J==null?void 0:J.__urm_row_id__)===E):K=Array.from(O).find(J=>J===w),K!==void 0?O.delete(K):O.add(w),O})},[]),Hn=p.useCallback((w,E)=>{_t(P=>{const O=new Set(P),K=E.filter(J=>!J.isGroupHeader);for(const J of K){const ce=J==null?void 0:J.__urm_row_id__;if(w){let ge;ce!==void 0?ge=Array.from(O).find(ve=>(ve==null?void 0:ve.__urm_row_id__)===ce):ge=Array.from(O).find(ve=>ve===J),ge===void 0&&O.add(J)}else{let ge;ce!==void 0?ge=Array.from(O).find(ve=>(ve==null?void 0:ve.__urm_row_id__)===ce):ge=Array.from(O).find(ve=>ve===J),ge!==void 0&&O.delete(ge)}}return O})},[]),Gn=p.useCallback((w,E,P)=>{_t(O=>{const K=new Set(O),J=P.filter(ve=>!ve.isGroupHeader),ce=Math.min(w,E),ge=Math.max(w,E);for(let ve=ce;ve<=ge;ve++){const Gt=J[ve];if(!Gt)continue;const Ai=Gt==null?void 0:Gt.__urm_row_id__;let Qn;Ai!==void 0?Qn=Array.from(K).find(wo=>(wo==null?void 0:wo.__urm_row_id__)===Ai):Qn=Array.from(K).find(wo=>wo===Gt),Qn===void 0&&K.add(Gt)}return K})},[]),Un=p.useCallback(()=>{_t(new Set)},[]),Yn=p.useCallback(w=>{const E=w==null?void 0:w.__urm_row_id__;_t(P=>{const O=new Set(P);if(E!==void 0){const K=Array.from(O).find(J=>(J==null?void 0:J.__urm_row_id__)===E);K!==void 0&&O.delete(K)}else O.delete(w);return O})},[]),ro=p.useCallback(w=>{var E,P;if(d){if(!Ct("edit_columns",je)){k(jt("edit_columns"),"error");return}if(w&&d.schema){const{validGrouping:O,invalidColumns:K}=qs(w,d.schema);K.length>0&&k(`Removed invalid grouping columns: ${K.join(", ")}`,"warning"),mt();try{const J=d.grouping;O===null?se("grouping","group_cleared",J,null):J?se("grouping","group_reordered",J,O):se("grouping","group_level_added",null,O);const ce=(V==null?void 0:V.snapshot.columnOrder)||d.columnOrder||[],ge=zo(ce,O),ve=O.levels.length>0?{...O,collapsedGroups:Fi(Qt,d.schema,O)}:O;N(d.id,{grouping:ve,columnOrder:ge}),B==="server"?(dt(1),(E=a==null?void 0:a.onPaginationChange)==null||E.call(a,1,Pe)):we==null||we.resetPage(),JSON.stringify(ge)!==JSON.stringify(d.columnOrder)&&se("columns","column_reordered",d.columnOrder,ge),Ke(!1)}catch(J){const ce=gr("processing","grouping",J);ut(ce)}}else{const O=d.grouping;se("grouping","group_cleared",O,null);const K=(V==null?void 0:V.snapshot.columnOrder)||d.columnOrder||[];N(d.id,{grouping:w,columnOrder:K}),B==="server"?(dt(1),(P=a==null?void 0:a.onPaginationChange)==null||P.call(a,1,Pe)):we==null||we.resetPage(),JSON.stringify(K)!==JSON.stringify(d.columnOrder)&&se("columns","column_reordered",d.columnOrder,K),Ke(!1)}}},[d,V,je,N,mt,ut,se,Qt]),vo=p.useCallback(w=>{if(!d||!h.grouping.allowCollapse)return;const E=d.grouping;if(!E)return;const P=sl(E,w);N(d.id,{grouping:P})},[d,h,N]),qn=p.useCallback(()=>{!(d!=null&&d.grouping)||!h.grouping.allowCollapse||N(d.id,{grouping:{...d.grouping,collapsedGroups:[]}})},[d,h,N]),Jn=p.useCallback(()=>{if(!(d!=null&&d.grouping)||!d.schema||!h.grouping.allowCollapse)return;const w=Fi(Qt,d.schema,d.grouping);N(d.id,{grouping:{...d.grouping,collapsedGroups:w}})},[d,Qt,h,N]),Ue=p.useCallback(()=>{Nt(!0)},[]),Fe=p.useCallback(w=>{d!=null&&d.schema&&(at(!0),setTimeout(()=>{try{let E;w.scope==="visible"?E=pr:E=d.uploadedData||[];let P;w.columnScope==="all"?(P={},(d.schema??[]).forEach(ge=>{P[ge.name]=!0})):P=d.columnVisibility||(V==null?void 0:V.snapshot.columnVisibility)||{};const O=d.columnOrder||(V==null?void 0:V.snapshot.columnOrder),K=cn(E,d.schema,qe(d.filters),d.sortStack??[],V,P,O),J=d.name;let ce;switch(w.format){case"csv":dn(K,J,w),ce="export_csv";break;case"excel":un(K,J,w),ce="export_excel";break;case"json":pn(K,J,w),ce="export_json";break;case"pdf":zi(K,J,w),ce="export_pdf";break}se("export",ce,null,{format:w.format,scope:w.scope,columnScope:w.columnScope,rowCount:E.length,viewName:(V==null?void 0:V.name)||"Default View"}),k(`Export completed successfully (${w.format.toUpperCase()})`,"success")}catch(E){const P=Vl(E,{onRetry:()=>Fe(w)});k(`Export failed: ${P.message}. Click Export to retry.`,"error");const O=Ji(d.id,Mt,P,d.auditHistory||[]);N(d.id,{auditHistory:O}),qt.error("urm:report-engine","Export failed",E)}finally{at(!1)}},500))},[d,V,pr,N,se]),So=p.useCallback(w=>{if(d!=null&&d.schema){if(rt&&V&&!V.isDefault){Jt(w.format),Wt(!0),Nt(!1);return}Fe(w),Nt(!1)}},[d,V,rt,Fe]),rr=p.useCallback(w=>{Fe({format:w,scope:"visible",columnScope:"visible"})},[Fe]),Uo=p.useCallback(()=>{Bt&&rr(Bt),Wt(!1),Jt(null)},[Bt,rr]),Kn=p.useCallback(()=>{Qe(),Bt&&rr(Bt),Wt(!1),Jt(null)},[Qe,Bt,rr]),or=p.useCallback(()=>{Wt(!1),Jt(null)},[]),nr=p.useCallback(w=>{!(d!=null&&d.schema)||Lt.size===0||(at(!0),setTimeout(()=>{try{const E=Array.from(Lt),P=cn(E,d.schema,qe(d.filters),d.sortStack??[],V),O=`${d.name.toLowerCase().replace(/\s+/g,"_")}_selected_export`;switch(w){case"csv":dn(P,O);break;case"excel":un(P,O);break;case"json":pn(P,O);break}k(`Exported ${E.length} selected rows`,"info")}catch(E){k("Export failed. Please try again.","error"),qt.error("urm:report-engine","Bulk export failed",E)}finally{at(!1)}},500))},[d,V,Lt,jr]),Yo=p.useCallback((w,E)=>{if(d)try{const P=El(d),O=_l(w,E,Mt,P),K=$l(d.presets,O);N(d.id,{presets:K}),se("presets","preset_created",null,{presetId:O.id,name:O.name}),Xt(!1),k(`Preset "${w}" saved successfully`,"success")}catch(P){k(P instanceof Error?P.message:"Failed to create preset","error")}},[d,N,se]),Xn=p.useCallback(()=>{He(null),k("Exited preset view","info")},[]),qo=p.useCallback(()=>{vr(!0)},[]),Jo=p.useCallback((w,E)=>{if(!d)return;const P=Il(d.presets,w);N(d.id,{presets:P}),se("presets","preset_deleted",{presetId:w,name:E},null),$t===w&&He(null),k(`Preset "${E}" deleted`,"success")},[d,$t,N,se]);p.useEffect(()=>{if(!g||D.length===0)return;const w=D.find(E=>E.id===g);w&&w.id!==I&&A(w.id)},[g,D,I]);const C=p.useRef(!1);p.useEffect(()=>{var E;if(!y||C.current||!d||d.id!==g)return;const w=(E=d.views)==null?void 0:E.find(P=>P.id===y&&!P.isDeleted);w&&Ge(w.id),C.current=!0},[y,g,d,Ge]),p.useEffect(()=>{if(!d)return;const w=Dl();if(w&&d.presets&&d.schemaLocked&&d.schema){const E=qi(d.presets,w);if(E){const{sanitizedConfig:P,warnings:O}=Nl(E.config,d.schema);O.length>0&&O.forEach(J=>k(J,"warning"));const K=Ol(P);N(d.id,K),He(w),se("presets","preset_applied",null,{presetId:E.id,name:E.name}),k(`Loaded preset: ${E.name}`,"info")}else k("Preset not found","info")}},[d==null?void 0:d.schemaLocked]);const U=$t?qi(d==null?void 0:d.presets,$t):void 0;p.useEffect(()=>{var w;d!=null&&d.views&&d.views.length>0&&d.activeViewId&&((w=S==null?void 0:S.onViewsChange)==null||w.call(S,d.views,d.activeViewId),f!=="api"&&pl(d.id,{views:d.views,activeViewId:d.activeViewId}))},[d==null?void 0:d.views,d==null?void 0:d.activeViewId,d==null?void 0:d.id,f,S]),p.useEffect(()=>{if(d!=null&&d.schemaLocked&&d.schema&&(!d.views||d.views.length===0)){const w=f==="api"?S!=null&&S.views&&S.views.length>0?{views:S.views,activeViewId:S.activeViewId??S.views[0].id}:null:fl(d.id);if(w&&w.views.length>0){const E=w.views.find(P=>P.id===w.activeViewId);if(E)N(d.id,{views:w.views,activeViewId:w.activeViewId,filters:qe(E.snapshot.filters),sortStack:E.snapshot.sortStack.length>0?E.snapshot.sortStack:void 0});else{const P=w.views.find(O=>O.isDefault)||Zn(d.schema);N(d.id,{views:w.views,activeViewId:P.id,filters:qe(P.snapshot.filters),sortStack:P.snapshot.sortStack.length>0?P.snapshot.sortStack:void 0})}}}},[d==null?void 0:d.schemaLocked,d==null?void 0:d.schema,d==null?void 0:d.id,f,S]);const ne=p.useCallback(w=>{var O;const E=qe(d==null?void 0:d.filters),P=((O=h.filter)==null?void 0:O.maxConditions)??3;if(Tt(E)>=P){k(`Filter limit reached — maximum ${P} filters allowed. Remove an existing filter before adding a new one.`,"warning");return}Me(w),te(!0)},[d,h,k]),Be=p.useCallback(()=>{te(!1),Me(void 0)},[]),ot=(Ot=d==null?void 0:d.views)==null?void 0:Ot.find(w=>w.id===L),Ye=(Ee=d==null?void 0:d.views)==null?void 0:Ee.find(w=>w.id===ke);return{reports:D,activeReport:d,activeReportId:I,setActiveReportId:A,isModalOpen:$,setIsModalOpen:Y,createReport:Zt,updateReport:N,uploadState:Q,handleFileUpload:gt,handleUploadError:Tr,handleRetry:nt,handleConfirm:go,paginatedData:Ur,processedData:pr,displayData:jr,tableMetrics:fr,isGrouped:Ht,tableEngine:Vt,activeView:V,isDirty:rt,currentTableState:Oe,viewChanges:kr,filters:d==null?void 0:d.filters,showFilterPanel:H,setShowFilterPanel:te,filterFocusColumn:pe,handleAddCondition:Br,handleAddGroup:Kr,handleUpdateCondition:Er,handleSetGroupOperator:_r,handleRemoveFilterNode:me,handleClearAllFilters:oe,handleReplaceFilters:be,handleOpenFilterForColumn:ne,handleCloseFilterPanel:Be,handleClearFiltersForColumn:Go,sortStack:d==null?void 0:d.sortStack,showSortPanel:ue,setShowSortPanel:le,handleSort:qr,handleUpdateSortStack:St,handleSortAscending:zr,handleSortDescending:Jr,views:d==null?void 0:d.views,showCreateViewModal:Z,setShowCreateViewModal:de,showEditViewModal:ae,setShowEditViewModal:F,showDeleteConfirmation:ie,setShowDeleteConfirmation:he,editingView:ot,deletingView:Ye,editingViewId:L,deletingViewId:ke,handleSelectView:Ge,handleCreateView:Le,handleCloneView:lt,handleUpdateCurrentView:Qe,handleSaveColumnConfigToCurrentView:$r,handleSaveColumnConfigToAllViews:er,handleSaveAsNewView:wt,handleRevertChanges:tr,handleToggleDefault:Ir,handleToggleFavorite:On,handleSoftDelete:Mn,handleRestoreView:Lo,handlePermanentDelete:Xr,handleEditView:An,handleCopyViewLink:Qr,handleSaveEditView:yo,handleDeleteView:Rn,handleConfirmDelete:Fo,handlePromoteToGlobal:Zr,handleSetDefaultForAllUsers:No,showManageColumns:Pr,setShowManageColumns:Kt,columnVisibility:d==null?void 0:d.columnVisibility,columnOrder:d==null?void 0:d.columnOrder,columnWidths:d==null?void 0:d.columnWidths,handleUpdateColumnVisibility:eo,handleUpdateColumnOrder:to,handleUpdateColumnWidth:Ho,handleResetColumnLayout:Wn,showGroupPanel:Lr,setShowGroupPanel:Ke,grouping:d==null?void 0:d.grouping,groupingState:Et,handleGroup:ro,handleToggleGroupCollapse:vo,handleExpandAllGroups:qn,handleCollapseAllGroups:Jn,searchQuery:ct,debouncedSearchQuery:Pt,searchHistory:yl((d==null?void 0:d.searchHistory)||[]),handleSearchChange:Pn,handleAddToSearchHistory:Ln,handleToggleSearchFavourite:Fn,handleDeleteSearchHistory:Nn,selectedRowIds:Lt,handleToggleRowSelection:Vn,handleToggleAllRows:Hn,handleRangeSelection:Gn,handleClearSelection:Un,handleUpdateSelectionAfterDelete:Yn,currentPage:B==="server"?Ft:(we==null?void 0:we.currentPage)||1,pageSize:Pe,paginationEngine:we,paginationMode:B,paginationTotalRows:It,paginationTotalPages:Yr,handlePageChange:bo,handlePageSizeChange:Vo,isExporting:Ae,showExportModal:Ce,setShowExportModal:Nt,showDirtyExportWarning:tt,handleExport:Ue,handleExportWithConfig:So,handleExportSelected:nr,handleExportAnyway:Uo,handleSaveAndExport:Kn,handleCancelExport:or,showAuditHistory:Hr,setShowAuditHistory:dr,auditHistory:d==null?void 0:d.auditHistory,showCreatePreset:ur,setShowCreatePreset:Xt,showManagePresets:fo,setShowManagePresets:vr,activePreset:U,activePresetId:$t,handleOpenManagePresets:qo,handleCreatePreset:Yo,handleClearActivePreset:Xn,handleDeletePresetById:Jo,userRole:je,isViewerRole:Cr,currentUserId:Mt,permissions:d==null?void 0:d.permissions,featureLimitWarning:ho,setFeatureLimitWarning:mo,datasetMeta:Gr,reportError:xo,setReportError:Sr,handleError:ut,schema:d==null?void 0:d.schema,hasSchemaConflicts:d!=null&&d.schema?Za(d.schema):!1,snack:v,handleSnackClose:q,showSnack:k,snackDurationMs:re,config:T,scheduler:c}}const Js=p.createContext(ft);function Rr(){return p.useContext(Js)}const Ks=p.createContext(void 0);function Ei(e){const{children:r,initialData:o,data:i,reportName:s,reportId:a,dataSource:l,pagination:c,search:u,scheduler:x,mode:g="builder",autoLoad:y=!0,config:S,devConfig:b,showDevPanel:T=!1,sharedReportId:m,sharedViewId:f,viewPersistence:B,permissions:j}=e,D=i||o,[z,h]=p.useState(()=>Ma()),I=(()=>{const R=Ra(z,b,!!b);return{...R,display:{...R.display,showDevPanel:T||R.display.showDevPanel}}})(),A=ac({mode:g,autoLoad:y,initialData:D,dataSource:l,pagination:c,search:u,scheduler:x,reportName:s,reportId:a,sharedReportId:m,sharedViewId:f,viewPersistence:B,permissions:j,config:S,devConfig:I}),$=p.useCallback(X=>{h(X),Aa(X)},[]),Y={...A,activeDevConfig:I,handleDevConfigChange:$};return t.jsx(Js.Provider,{value:I,children:t.jsx(Ks.Provider,{value:Y,children:r})})}function yn(){const e=p.useContext(Ks);if(e===void 0)throw new Error("useReportContext must be used within a ReportProvider. Wrap your component tree with <ReportProvider>...</ReportProvider>");return e}function Ar(e,...r){const o=new URL(`https://mui.com/production-error/?code=${e}`);return r.forEach(i=>o.searchParams.append("args[]",i)),`Minified MUI error #${e}; visit ${o} for the full message.`}const lc="$$material";function cc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qo={exports:{}},Zo={exports:{}},Te={};/** @license React v16.13.1
106
106
  * react-is.production.min.js
107
107
  *
108
108
  * Copyright (c) Facebook, Inc. and its affiliates.
109
109
  *
110
110
  * This source code is licensed under the MIT license found in the
111
111
  * LICENSE file in the root directory of this source tree.
112
- */var Yi;function sc(){if(Yi)return ze;Yi=1;var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,o=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,l=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,g=e?Symbol.for("react.concurrent_mode"):60111,x=e?Symbol.for("react.forward_ref"):60112,y=e?Symbol.for("react.suspense"):60113,w=e?Symbol.for("react.suspense_list"):60120,b=e?Symbol.for("react.memo"):60115,z=e?Symbol.for("react.lazy"):60116,h=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,E=e?Symbol.for("react.responder"):60118,v=e?Symbol.for("react.scope"):60119;function T(f){if(typeof f=="object"&&f!==null){var $=f.$$typeof;switch($){case r:switch(f=f.type,f){case u:case g:case i:case a:case s:case y:return f;default:switch(f=f&&f.$$typeof,f){case c:case x:case z:case b:case l:return f;default:return $}}case o:return $}}}function B(f){return T(f)===g}return ze.AsyncMode=u,ze.ConcurrentMode=g,ze.ContextConsumer=c,ze.ContextProvider=l,ze.Element=r,ze.ForwardRef=x,ze.Fragment=i,ze.Lazy=z,ze.Memo=b,ze.Portal=o,ze.Profiler=a,ze.StrictMode=s,ze.Suspense=y,ze.isAsyncMode=function(f){return B(f)||T(f)===u},ze.isConcurrentMode=B,ze.isContextConsumer=function(f){return T(f)===c},ze.isContextProvider=function(f){return T(f)===l},ze.isElement=function(f){return typeof f=="object"&&f!==null&&f.$$typeof===r},ze.isForwardRef=function(f){return T(f)===x},ze.isFragment=function(f){return T(f)===i},ze.isLazy=function(f){return T(f)===z},ze.isMemo=function(f){return T(f)===b},ze.isPortal=function(f){return T(f)===o},ze.isProfiler=function(f){return T(f)===a},ze.isStrictMode=function(f){return T(f)===s},ze.isSuspense=function(f){return T(f)===y},ze.isValidElementType=function(f){return typeof f=="string"||typeof f=="function"||f===i||f===g||f===a||f===s||f===y||f===w||typeof f=="object"&&f!==null&&(f.$$typeof===z||f.$$typeof===b||f.$$typeof===l||f.$$typeof===c||f.$$typeof===x||f.$$typeof===m||f.$$typeof===E||f.$$typeof===v||f.$$typeof===h)},ze.typeOf=T,ze}var Be={};/** @license React v16.13.1
112
+ */var Ki;function dc(){if(Ki)return Te;Ki=1;var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,o=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,l=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,x=e?Symbol.for("react.concurrent_mode"):60111,g=e?Symbol.for("react.forward_ref"):60112,y=e?Symbol.for("react.suspense"):60113,S=e?Symbol.for("react.suspense_list"):60120,b=e?Symbol.for("react.memo"):60115,T=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,f=e?Symbol.for("react.fundamental"):60117,B=e?Symbol.for("react.responder"):60118,j=e?Symbol.for("react.scope"):60119;function D(h){if(typeof h=="object"&&h!==null){var I=h.$$typeof;switch(I){case r:switch(h=h.type,h){case u:case x:case i:case a:case s:case y:return h;default:switch(h=h&&h.$$typeof,h){case c:case g:case T:case b:case l:return h;default:return I}}case o:return I}}}function z(h){return D(h)===x}return Te.AsyncMode=u,Te.ConcurrentMode=x,Te.ContextConsumer=c,Te.ContextProvider=l,Te.Element=r,Te.ForwardRef=g,Te.Fragment=i,Te.Lazy=T,Te.Memo=b,Te.Portal=o,Te.Profiler=a,Te.StrictMode=s,Te.Suspense=y,Te.isAsyncMode=function(h){return z(h)||D(h)===u},Te.isConcurrentMode=z,Te.isContextConsumer=function(h){return D(h)===c},Te.isContextProvider=function(h){return D(h)===l},Te.isElement=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===r},Te.isForwardRef=function(h){return D(h)===g},Te.isFragment=function(h){return D(h)===i},Te.isLazy=function(h){return D(h)===T},Te.isMemo=function(h){return D(h)===b},Te.isPortal=function(h){return D(h)===o},Te.isProfiler=function(h){return D(h)===a},Te.isStrictMode=function(h){return D(h)===s},Te.isSuspense=function(h){return D(h)===y},Te.isValidElementType=function(h){return typeof h=="string"||typeof h=="function"||h===i||h===x||h===a||h===s||h===y||h===S||typeof h=="object"&&h!==null&&(h.$$typeof===T||h.$$typeof===b||h.$$typeof===l||h.$$typeof===c||h.$$typeof===g||h.$$typeof===f||h.$$typeof===B||h.$$typeof===j||h.$$typeof===m)},Te.typeOf=D,Te}var ze={};/** @license React v16.13.1
113
113
  * react-is.development.js
114
114
  *
115
115
  * Copyright (c) Facebook, Inc. and its affiliates.
116
116
  *
117
117
  * This source code is licensed under the MIT license found in the
118
118
  * LICENSE file in the root directory of this source tree.
119
- */var qi;function ac(){return qi||(qi=1,process.env.NODE_ENV!=="production"&&(function(){var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,o=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,l=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,g=e?Symbol.for("react.concurrent_mode"):60111,x=e?Symbol.for("react.forward_ref"):60112,y=e?Symbol.for("react.suspense"):60113,w=e?Symbol.for("react.suspense_list"):60120,b=e?Symbol.for("react.memo"):60115,z=e?Symbol.for("react.lazy"):60116,h=e?Symbol.for("react.block"):60121,m=e?Symbol.for("react.fundamental"):60117,E=e?Symbol.for("react.responder"):60118,v=e?Symbol.for("react.scope"):60119;function T(P){return typeof P=="string"||typeof P=="function"||P===i||P===g||P===a||P===s||P===y||P===w||typeof P=="object"&&P!==null&&(P.$$typeof===z||P.$$typeof===b||P.$$typeof===l||P.$$typeof===c||P.$$typeof===x||P.$$typeof===m||P.$$typeof===E||P.$$typeof===v||P.$$typeof===h)}function B(P){if(typeof P=="object"&&P!==null){var be=P.$$typeof;switch(be){case r:var ke=P.type;switch(ke){case u:case g:case i:case a:case s:case y:return ke;default:var Pe=ke&&ke.$$typeof;switch(Pe){case c:case x:case z:case b:case l:return Pe;default:return be}}case o:return be}}}var f=u,$=g,F=c,O=l,J=r,te=x,L=i,S=z,A=b,k=o,Y=a,oe=s,d=y,Q=!1;function ee(P){return Q||(Q=!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.")),N(P)||B(P)===u}function N(P){return B(P)===g}function re(P){return B(P)===c}function ue(P){return B(P)===l}function le(P){return typeof P=="object"&&P!==null&&P.$$typeof===r}function Z(P){return B(P)===x}function de(P){return B(P)===i}function se(P){return B(P)===z}function W(P){return B(P)===b}function ie(P){return B(P)===o}function fe(P){return B(P)===a}function pe(P){return B(P)===s}function Me(P){return B(P)===y}Be.AsyncMode=f,Be.ConcurrentMode=$,Be.ContextConsumer=F,Be.ContextProvider=O,Be.Element=J,Be.ForwardRef=te,Be.Fragment=L,Be.Lazy=S,Be.Memo=A,Be.Portal=k,Be.Profiler=Y,Be.StrictMode=oe,Be.Suspense=d,Be.isAsyncMode=ee,Be.isConcurrentMode=N,Be.isContextConsumer=re,Be.isContextProvider=ue,Be.isElement=le,Be.isForwardRef=Z,Be.isFragment=de,Be.isLazy=se,Be.isMemo=W,Be.isPortal=ie,Be.isProfiler=fe,Be.isStrictMode=pe,Be.isSuspense=Me,Be.isValidElementType=T,Be.typeOf=B})()),Be}var Ji;function Us(){return Ji||(Ji=1,process.env.NODE_ENV==="production"?tn.exports=sc():tn.exports=ac()),tn.exports}/*
119
+ */var Xi;function uc(){return Xi||(Xi=1,process.env.NODE_ENV!=="production"&&(function(){var e=typeof Symbol=="function"&&Symbol.for,r=e?Symbol.for("react.element"):60103,o=e?Symbol.for("react.portal"):60106,i=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,l=e?Symbol.for("react.provider"):60109,c=e?Symbol.for("react.context"):60110,u=e?Symbol.for("react.async_mode"):60111,x=e?Symbol.for("react.concurrent_mode"):60111,g=e?Symbol.for("react.forward_ref"):60112,y=e?Symbol.for("react.suspense"):60113,S=e?Symbol.for("react.suspense_list"):60120,b=e?Symbol.for("react.memo"):60115,T=e?Symbol.for("react.lazy"):60116,m=e?Symbol.for("react.block"):60121,f=e?Symbol.for("react.fundamental"):60117,B=e?Symbol.for("react.responder"):60118,j=e?Symbol.for("react.scope"):60119;function D(L){return typeof L=="string"||typeof L=="function"||L===i||L===x||L===a||L===s||L===y||L===S||typeof L=="object"&&L!==null&&(L.$$typeof===T||L.$$typeof===b||L.$$typeof===l||L.$$typeof===c||L.$$typeof===g||L.$$typeof===f||L.$$typeof===B||L.$$typeof===j||L.$$typeof===m)}function z(L){if(typeof L=="object"&&L!==null){var Se=L.$$typeof;switch(Se){case r:var ke=L.type;switch(ke){case u:case x:case i:case a:case s:case y:return ke;default:var We=ke&&ke.$$typeof;switch(We){case c:case g:case T:case b:case l:return We;default:return Se}}case o:return Se}}}var h=u,I=x,A=c,$=l,Y=r,X=g,R=i,v=T,W=b,k=o,q=a,re=s,d=y,Q=!1;function ee(L){return Q||(Q=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),H(L)||z(L)===u}function H(L){return z(L)===x}function te(L){return z(L)===c}function ue(L){return z(L)===l}function le(L){return typeof L=="object"&&L!==null&&L.$$typeof===r}function Z(L){return z(L)===g}function de(L){return z(L)===i}function ae(L){return z(L)===T}function F(L){return z(L)===b}function ie(L){return z(L)===o}function he(L){return z(L)===a}function pe(L){return z(L)===s}function Me(L){return z(L)===y}ze.AsyncMode=h,ze.ConcurrentMode=I,ze.ContextConsumer=A,ze.ContextProvider=$,ze.Element=Y,ze.ForwardRef=X,ze.Fragment=R,ze.Lazy=v,ze.Memo=W,ze.Portal=k,ze.Profiler=q,ze.StrictMode=re,ze.Suspense=d,ze.isAsyncMode=ee,ze.isConcurrentMode=H,ze.isContextConsumer=te,ze.isContextProvider=ue,ze.isElement=le,ze.isForwardRef=Z,ze.isFragment=de,ze.isLazy=ae,ze.isMemo=F,ze.isPortal=ie,ze.isProfiler=he,ze.isStrictMode=pe,ze.isSuspense=Me,ze.isValidElementType=D,ze.typeOf=z})()),ze}var Qi;function Xs(){return Qi||(Qi=1,process.env.NODE_ENV==="production"?Zo.exports=dc():Zo.exports=uc()),Zo.exports}/*
120
120
  object-assign
121
121
  (c) Sindre Sorhus
122
122
  @license MIT
123
- */var ti,Ki;function lc(){if(Ki)return ti;Ki=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function i(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function s(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var l={},c=0;c<10;c++)l["_"+String.fromCharCode(c)]=c;var u=Object.getOwnPropertyNames(l).map(function(x){return l[x]});if(u.join("")!=="0123456789")return!1;var g={};return"abcdefghijklmnopqrst".split("").forEach(function(x){g[x]=x}),Object.keys(Object.assign({},g)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return ti=s()?Object.assign:function(a,l){for(var c,u=i(a),g,x=1;x<arguments.length;x++){c=Object(arguments[x]);for(var y in c)r.call(c,y)&&(u[y]=c[y]);if(e){g=e(c);for(var w=0;w<g.length;w++)o.call(c,g[w])&&(u[g[w]]=c[g[w]])}}return u},ti}var ri,Xi;function Bi(){if(Xi)return ri;Xi=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ri=e,ri}var oi,Qi;function Ys(){return Qi||(Qi=1,oi=Function.call.bind(Object.prototype.hasOwnProperty)),oi}var ni,Zi;function cc(){if(Zi)return ni;Zi=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=Bi(),o={},i=Ys();e=function(a){var l="Warning: "+a;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}}}function s(a,l,c,u,g){if(process.env.NODE_ENV!=="production"){for(var x in a)if(i(a,x)){var y;try{if(typeof a[x]!="function"){var w=Error((u||"React class")+": "+c+" type `"+x+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[x]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw w.name="Invariant Violation",w}y=a[x](l,x,u,c,null,r)}catch(z){y=z}if(y&&!(y instanceof Error)&&e((u||"React class")+": type specification of "+c+" `"+x+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof y+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),y instanceof Error&&!(y.message in o)){o[y.message]=!0;var b=g?g():"";e("Failed "+c+" type: "+y.message+(b??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(o={})},ni=s,ni}var ii,es;function dc(){if(es)return ii;es=1;var e=Us(),r=lc(),o=Bi(),i=Ys(),s=cc(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(c){var u="Warning: "+c;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function l(){return null}return ii=function(c,u){var g=typeof Symbol=="function"&&Symbol.iterator,x="@@iterator";function y(N){var re=N&&(g&&N[g]||N[x]);if(typeof re=="function")return re}var w="<<anonymous>>",b={array:E("array"),bigint:E("bigint"),bool:E("boolean"),func:E("function"),number:E("number"),object:E("object"),string:E("string"),symbol:E("symbol"),any:v(),arrayOf:T,element:B(),elementType:f(),instanceOf:$,node:te(),objectOf:O,oneOf:F,oneOfType:J,shape:S,exact:A};function z(N,re){return N===re?N!==0||1/N===1/re:N!==N&&re!==re}function h(N,re){this.message=N,this.data=re&&typeof re=="object"?re:{},this.stack=""}h.prototype=Error.prototype;function m(N){if(process.env.NODE_ENV!=="production")var re={},ue=0;function le(de,se,W,ie,fe,pe,Me){if(ie=ie||w,pe=pe||W,Me!==o){if(u){var P=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 P.name="Invariant Violation",P}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var be=ie+":"+W;!re[be]&&ue<3&&(a("You are manually calling a React.PropTypes validation function for the `"+pe+"` prop on `"+ie+"`. 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."),re[be]=!0,ue++)}}return se[W]==null?de?se[W]===null?new h("The "+fe+" `"+pe+"` is marked as required "+("in `"+ie+"`, but its value is `null`.")):new h("The "+fe+" `"+pe+"` is marked as required in "+("`"+ie+"`, but its value is `undefined`.")):null:N(se,W,ie,fe,pe)}var Z=le.bind(null,!1);return Z.isRequired=le.bind(null,!0),Z}function E(N){function re(ue,le,Z,de,se,W){var ie=ue[le],fe=oe(ie);if(fe!==N){var pe=d(ie);return new h("Invalid "+de+" `"+se+"` of type "+("`"+pe+"` supplied to `"+Z+"`, expected ")+("`"+N+"`."),{expectedType:N})}return null}return m(re)}function v(){return m(l)}function T(N){function re(ue,le,Z,de,se){if(typeof N!="function")return new h("Property `"+se+"` of component `"+Z+"` has invalid PropType notation inside arrayOf.");var W=ue[le];if(!Array.isArray(W)){var ie=oe(W);return new h("Invalid "+de+" `"+se+"` of type "+("`"+ie+"` supplied to `"+Z+"`, expected an array."))}for(var fe=0;fe<W.length;fe++){var pe=N(W,fe,Z,de,se+"["+fe+"]",o);if(pe instanceof Error)return pe}return null}return m(re)}function B(){function N(re,ue,le,Z,de){var se=re[ue];if(!c(se)){var W=oe(se);return new h("Invalid "+Z+" `"+de+"` of type "+("`"+W+"` supplied to `"+le+"`, expected a single ReactElement."))}return null}return m(N)}function f(){function N(re,ue,le,Z,de){var se=re[ue];if(!e.isValidElementType(se)){var W=oe(se);return new h("Invalid "+Z+" `"+de+"` of type "+("`"+W+"` supplied to `"+le+"`, expected a single ReactElement type."))}return null}return m(N)}function $(N){function re(ue,le,Z,de,se){if(!(ue[le]instanceof N)){var W=N.name||w,ie=ee(ue[le]);return new h("Invalid "+de+" `"+se+"` of type "+("`"+ie+"` supplied to `"+Z+"`, expected ")+("instance of `"+W+"`."))}return null}return m(re)}function F(N){if(!Array.isArray(N))return process.env.NODE_ENV!=="production"&&(arguments.length>1?a("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):a("Invalid argument supplied to oneOf, expected an array.")),l;function re(ue,le,Z,de,se){for(var W=ue[le],ie=0;ie<N.length;ie++)if(z(W,N[ie]))return null;var fe=JSON.stringify(N,function(Me,P){var be=d(P);return be==="symbol"?String(P):P});return new h("Invalid "+de+" `"+se+"` of value `"+String(W)+"` "+("supplied to `"+Z+"`, expected one of "+fe+"."))}return m(re)}function O(N){function re(ue,le,Z,de,se){if(typeof N!="function")return new h("Property `"+se+"` of component `"+Z+"` has invalid PropType notation inside objectOf.");var W=ue[le],ie=oe(W);if(ie!=="object")return new h("Invalid "+de+" `"+se+"` of type "+("`"+ie+"` supplied to `"+Z+"`, expected an object."));for(var fe in W)if(i(W,fe)){var pe=N(W,fe,Z,de,se+"."+fe,o);if(pe instanceof Error)return pe}return null}return m(re)}function J(N){if(!Array.isArray(N))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),l;for(var re=0;re<N.length;re++){var ue=N[re];if(typeof ue!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Q(ue)+" at index "+re+"."),l}function le(Z,de,se,W,ie){for(var fe=[],pe=0;pe<N.length;pe++){var Me=N[pe],P=Me(Z,de,se,W,ie,o);if(P==null)return null;P.data&&i(P.data,"expectedType")&&fe.push(P.data.expectedType)}var be=fe.length>0?", expected one of type ["+fe.join(", ")+"]":"";return new h("Invalid "+W+" `"+ie+"` supplied to "+("`"+se+"`"+be+"."))}return m(le)}function te(){function N(re,ue,le,Z,de){return k(re[ue])?null:new h("Invalid "+Z+" `"+de+"` supplied to "+("`"+le+"`, expected a ReactNode."))}return m(N)}function L(N,re,ue,le,Z){return new h((N||"React class")+": "+re+" type `"+ue+"."+le+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+Z+"`.")}function S(N){function re(ue,le,Z,de,se){var W=ue[le],ie=oe(W);if(ie!=="object")return new h("Invalid "+de+" `"+se+"` of type `"+ie+"` "+("supplied to `"+Z+"`, expected `object`."));for(var fe in N){var pe=N[fe];if(typeof pe!="function")return L(Z,de,se,fe,d(pe));var Me=pe(W,fe,Z,de,se+"."+fe,o);if(Me)return Me}return null}return m(re)}function A(N){function re(ue,le,Z,de,se){var W=ue[le],ie=oe(W);if(ie!=="object")return new h("Invalid "+de+" `"+se+"` of type `"+ie+"` "+("supplied to `"+Z+"`, expected `object`."));var fe=r({},ue[le],N);for(var pe in fe){var Me=N[pe];if(i(N,pe)&&typeof Me!="function")return L(Z,de,se,pe,d(Me));if(!Me)return new h("Invalid "+de+" `"+se+"` key `"+pe+"` supplied to `"+Z+"`.\nBad object: "+JSON.stringify(ue[le],null," ")+`
124
- Valid keys: `+JSON.stringify(Object.keys(N),null," "));var P=Me(W,pe,Z,de,se+"."+pe,o);if(P)return P}return null}return m(re)}function k(N){switch(typeof N){case"number":case"string":case"undefined":return!0;case"boolean":return!N;case"object":if(Array.isArray(N))return N.every(k);if(N===null||c(N))return!0;var re=y(N);if(re){var ue=re.call(N),le;if(re!==N.entries){for(;!(le=ue.next()).done;)if(!k(le.value))return!1}else for(;!(le=ue.next()).done;){var Z=le.value;if(Z&&!k(Z[1]))return!1}}else return!1;return!0;default:return!1}}function Y(N,re){return N==="symbol"?!0:re?re["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&re instanceof Symbol:!1}function oe(N){var re=typeof N;return Array.isArray(N)?"array":N instanceof RegExp?"object":Y(re,N)?"symbol":re}function d(N){if(typeof N>"u"||N===null)return""+N;var re=oe(N);if(re==="object"){if(N instanceof Date)return"date";if(N instanceof RegExp)return"regexp"}return re}function Q(N){var re=d(N);switch(re){case"array":case"object":return"an "+re;case"boolean":case"date":case"regexp":return"a "+re;default:return re}}function ee(N){return!N.constructor||!N.constructor.name?w:N.constructor.name}return b.checkPropTypes=s,b.resetWarningCache=s.resetWarningCache,b.PropTypes=b,b},ii}var si,ts;function uc(){if(ts)return si;ts=1;var e=Bi();function r(){}function o(){}return o.resetWarningCache=r,si=function(){function i(l,c,u,g,x,y){if(y!==e){var w=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 w.name="Invariant Violation",w}}i.isRequired=i;function s(){return i}var a={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:o,resetWarningCache:r};return a.PropTypes=a,a},si}var rs;function pc(){if(rs)return en.exports;if(rs=1,process.env.NODE_ENV!=="production"){var e=Us(),r=!0;en.exports=dc()(e.isElement,r)}else en.exports=uc()();return en.exports}var fc=pc();const To=ic(fc);var rn={exports:{}},Ie={};/**
123
+ */var ri,Zi;function pc(){if(Zi)return ri;Zi=1;var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;function i(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function s(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var l={},c=0;c<10;c++)l["_"+String.fromCharCode(c)]=c;var u=Object.getOwnPropertyNames(l).map(function(g){return l[g]});if(u.join("")!=="0123456789")return!1;var x={};return"abcdefghijklmnopqrst".split("").forEach(function(g){x[g]=g}),Object.keys(Object.assign({},x)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return ri=s()?Object.assign:function(a,l){for(var c,u=i(a),x,g=1;g<arguments.length;g++){c=Object(arguments[g]);for(var y in c)r.call(c,y)&&(u[y]=c[y]);if(e){x=e(c);for(var S=0;S<x.length;S++)o.call(c,x[S])&&(u[x[S]]=c[x[S]])}}return u},ri}var oi,es;function _i(){if(es)return oi;es=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return oi=e,oi}var ni,ts;function Qs(){return ts||(ts=1,ni=Function.call.bind(Object.prototype.hasOwnProperty)),ni}var ii,rs;function fc(){if(rs)return ii;rs=1;var e=function(){};if(process.env.NODE_ENV!=="production"){var r=_i(),o={},i=Qs();e=function(a){var l="Warning: "+a;typeof console<"u"&&console.error(l);try{throw new Error(l)}catch{}}}function s(a,l,c,u,x){if(process.env.NODE_ENV!=="production"){for(var g in a)if(i(a,g)){var y;try{if(typeof a[g]!="function"){var S=Error((u||"React class")+": "+c+" type `"+g+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof a[g]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw S.name="Invariant Violation",S}y=a[g](l,g,u,c,null,r)}catch(T){y=T}if(y&&!(y 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 y+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),y instanceof Error&&!(y.message in o)){o[y.message]=!0;var b=x?x():"";e("Failed "+c+" type: "+y.message+(b??""))}}}}return s.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(o={})},ii=s,ii}var si,os;function hc(){if(os)return si;os=1;var e=Xs(),r=pc(),o=_i(),i=Qs(),s=fc(),a=function(){};process.env.NODE_ENV!=="production"&&(a=function(c){var u="Warning: "+c;typeof console<"u"&&console.error(u);try{throw new Error(u)}catch{}});function l(){return null}return si=function(c,u){var x=typeof Symbol=="function"&&Symbol.iterator,g="@@iterator";function y(H){var te=H&&(x&&H[x]||H[g]);if(typeof te=="function")return te}var S="<<anonymous>>",b={array:B("array"),bigint:B("bigint"),bool:B("boolean"),func:B("function"),number:B("number"),object:B("object"),string:B("string"),symbol:B("symbol"),any:j(),arrayOf:D,element:z(),elementType:h(),instanceOf:I,node:X(),objectOf:$,oneOf:A,oneOfType:Y,shape:v,exact:W};function T(H,te){return H===te?H!==0||1/H===1/te:H!==H&&te!==te}function m(H,te){this.message=H,this.data=te&&typeof te=="object"?te:{},this.stack=""}m.prototype=Error.prototype;function f(H){if(process.env.NODE_ENV!=="production")var te={},ue=0;function le(de,ae,F,ie,he,pe,Me){if(ie=ie||S,pe=pe||F,Me!==o){if(u){var L=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 L.name="Invariant Violation",L}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var Se=ie+":"+F;!te[Se]&&ue<3&&(a("You are manually calling a React.PropTypes validation function for the `"+pe+"` prop on `"+ie+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),te[Se]=!0,ue++)}}return ae[F]==null?de?ae[F]===null?new m("The "+he+" `"+pe+"` is marked as required "+("in `"+ie+"`, but its value is `null`.")):new m("The "+he+" `"+pe+"` is marked as required in "+("`"+ie+"`, but its value is `undefined`.")):null:H(ae,F,ie,he,pe)}var Z=le.bind(null,!1);return Z.isRequired=le.bind(null,!0),Z}function B(H){function te(ue,le,Z,de,ae,F){var ie=ue[le],he=re(ie);if(he!==H){var pe=d(ie);return new m("Invalid "+de+" `"+ae+"` of type "+("`"+pe+"` supplied to `"+Z+"`, expected ")+("`"+H+"`."),{expectedType:H})}return null}return f(te)}function j(){return f(l)}function D(H){function te(ue,le,Z,de,ae){if(typeof H!="function")return new m("Property `"+ae+"` of component `"+Z+"` has invalid PropType notation inside arrayOf.");var F=ue[le];if(!Array.isArray(F)){var ie=re(F);return new m("Invalid "+de+" `"+ae+"` of type "+("`"+ie+"` supplied to `"+Z+"`, expected an array."))}for(var he=0;he<F.length;he++){var pe=H(F,he,Z,de,ae+"["+he+"]",o);if(pe instanceof Error)return pe}return null}return f(te)}function z(){function H(te,ue,le,Z,de){var ae=te[ue];if(!c(ae)){var F=re(ae);return new m("Invalid "+Z+" `"+de+"` of type "+("`"+F+"` supplied to `"+le+"`, expected a single ReactElement."))}return null}return f(H)}function h(){function H(te,ue,le,Z,de){var ae=te[ue];if(!e.isValidElementType(ae)){var F=re(ae);return new m("Invalid "+Z+" `"+de+"` of type "+("`"+F+"` supplied to `"+le+"`, expected a single ReactElement type."))}return null}return f(H)}function I(H){function te(ue,le,Z,de,ae){if(!(ue[le]instanceof H)){var F=H.name||S,ie=ee(ue[le]);return new m("Invalid "+de+" `"+ae+"` of type "+("`"+ie+"` supplied to `"+Z+"`, expected ")+("instance of `"+F+"`."))}return null}return f(te)}function A(H){if(!Array.isArray(H))return process.env.NODE_ENV!=="production"&&(arguments.length>1?a("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):a("Invalid argument supplied to oneOf, expected an array.")),l;function te(ue,le,Z,de,ae){for(var F=ue[le],ie=0;ie<H.length;ie++)if(T(F,H[ie]))return null;var he=JSON.stringify(H,function(Me,L){var Se=d(L);return Se==="symbol"?String(L):L});return new m("Invalid "+de+" `"+ae+"` of value `"+String(F)+"` "+("supplied to `"+Z+"`, expected one of "+he+"."))}return f(te)}function $(H){function te(ue,le,Z,de,ae){if(typeof H!="function")return new m("Property `"+ae+"` of component `"+Z+"` has invalid PropType notation inside objectOf.");var F=ue[le],ie=re(F);if(ie!=="object")return new m("Invalid "+de+" `"+ae+"` of type "+("`"+ie+"` supplied to `"+Z+"`, expected an object."));for(var he in F)if(i(F,he)){var pe=H(F,he,Z,de,ae+"."+he,o);if(pe instanceof Error)return pe}return null}return f(te)}function Y(H){if(!Array.isArray(H))return process.env.NODE_ENV!=="production"&&a("Invalid argument supplied to oneOfType, expected an instance of array."),l;for(var te=0;te<H.length;te++){var ue=H[te];if(typeof ue!="function")return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+Q(ue)+" at index "+te+"."),l}function le(Z,de,ae,F,ie){for(var he=[],pe=0;pe<H.length;pe++){var Me=H[pe],L=Me(Z,de,ae,F,ie,o);if(L==null)return null;L.data&&i(L.data,"expectedType")&&he.push(L.data.expectedType)}var Se=he.length>0?", expected one of type ["+he.join(", ")+"]":"";return new m("Invalid "+F+" `"+ie+"` supplied to "+("`"+ae+"`"+Se+"."))}return f(le)}function X(){function H(te,ue,le,Z,de){return k(te[ue])?null:new m("Invalid "+Z+" `"+de+"` supplied to "+("`"+le+"`, expected a ReactNode."))}return f(H)}function R(H,te,ue,le,Z){return new m((H||"React class")+": "+te+" type `"+ue+"."+le+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+Z+"`.")}function v(H){function te(ue,le,Z,de,ae){var F=ue[le],ie=re(F);if(ie!=="object")return new m("Invalid "+de+" `"+ae+"` of type `"+ie+"` "+("supplied to `"+Z+"`, expected `object`."));for(var he in H){var pe=H[he];if(typeof pe!="function")return R(Z,de,ae,he,d(pe));var Me=pe(F,he,Z,de,ae+"."+he,o);if(Me)return Me}return null}return f(te)}function W(H){function te(ue,le,Z,de,ae){var F=ue[le],ie=re(F);if(ie!=="object")return new m("Invalid "+de+" `"+ae+"` of type `"+ie+"` "+("supplied to `"+Z+"`, expected `object`."));var he=r({},ue[le],H);for(var pe in he){var Me=H[pe];if(i(H,pe)&&typeof Me!="function")return R(Z,de,ae,pe,d(Me));if(!Me)return new m("Invalid "+de+" `"+ae+"` key `"+pe+"` supplied to `"+Z+"`.\nBad object: "+JSON.stringify(ue[le],null," ")+`
124
+ Valid keys: `+JSON.stringify(Object.keys(H),null," "));var L=Me(F,pe,Z,de,ae+"."+pe,o);if(L)return L}return null}return f(te)}function k(H){switch(typeof H){case"number":case"string":case"undefined":return!0;case"boolean":return!H;case"object":if(Array.isArray(H))return H.every(k);if(H===null||c(H))return!0;var te=y(H);if(te){var ue=te.call(H),le;if(te!==H.entries){for(;!(le=ue.next()).done;)if(!k(le.value))return!1}else for(;!(le=ue.next()).done;){var Z=le.value;if(Z&&!k(Z[1]))return!1}}else return!1;return!0;default:return!1}}function q(H,te){return H==="symbol"?!0:te?te["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&te instanceof Symbol:!1}function re(H){var te=typeof H;return Array.isArray(H)?"array":H instanceof RegExp?"object":q(te,H)?"symbol":te}function d(H){if(typeof H>"u"||H===null)return""+H;var te=re(H);if(te==="object"){if(H instanceof Date)return"date";if(H instanceof RegExp)return"regexp"}return te}function Q(H){var te=d(H);switch(te){case"array":case"object":return"an "+te;case"boolean":case"date":case"regexp":return"a "+te;default:return te}}function ee(H){return!H.constructor||!H.constructor.name?S:H.constructor.name}return b.checkPropTypes=s,b.resetWarningCache=s.resetWarningCache,b.PropTypes=b,b},si}var ai,ns;function mc(){if(ns)return ai;ns=1;var e=_i();function r(){}function o(){}return o.resetWarningCache=r,ai=function(){function i(l,c,u,x,g,y){if(y!==e){var S=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw S.name="Invariant Violation",S}}i.isRequired=i;function s(){return i}var a={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:o,resetWarningCache:r};return a.PropTypes=a,a},ai}var is;function xc(){if(is)return Qo.exports;if(is=1,process.env.NODE_ENV!=="production"){var e=Xs(),r=!0;Qo.exports=hc()(e.isElement,r)}else Qo.exports=mc()();return Qo.exports}var gc=xc();const jo=cc(gc);var en={exports:{}},Ie={};/**
125
125
  * @license React
126
126
  * react-is.production.js
127
127
  *
@@ -129,7 +129,7 @@ Valid keys: `+JSON.stringify(Object.keys(N),null," "));var P=Me(W,pe,Z,de,se+".
129
129
  *
130
130
  * This source code is licensed under the MIT license found in the
131
131
  * LICENSE file in the root directory of this source tree.
132
- */var os;function mc(){if(os)return Ie;os=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),w=Symbol.for("react.view_transition"),b=Symbol.for("react.client.reference");function z(h){if(typeof h=="object"&&h!==null){var m=h.$$typeof;switch(m){case e:switch(h=h.type,h){case o:case s:case i:case u:case g:case w:return h;default:switch(h=h&&h.$$typeof,h){case l:case c:case y:case x:return h;case a:return h;default:return m}}case r:return m}}}return Ie.ContextConsumer=a,Ie.ContextProvider=l,Ie.Element=e,Ie.ForwardRef=c,Ie.Fragment=o,Ie.Lazy=y,Ie.Memo=x,Ie.Portal=r,Ie.Profiler=s,Ie.StrictMode=i,Ie.Suspense=u,Ie.SuspenseList=g,Ie.isContextConsumer=function(h){return z(h)===a},Ie.isContextProvider=function(h){return z(h)===l},Ie.isElement=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===e},Ie.isForwardRef=function(h){return z(h)===c},Ie.isFragment=function(h){return z(h)===o},Ie.isLazy=function(h){return z(h)===y},Ie.isMemo=function(h){return z(h)===x},Ie.isPortal=function(h){return z(h)===r},Ie.isProfiler=function(h){return z(h)===s},Ie.isStrictMode=function(h){return z(h)===i},Ie.isSuspense=function(h){return z(h)===u},Ie.isSuspenseList=function(h){return z(h)===g},Ie.isValidElementType=function(h){return typeof h=="string"||typeof h=="function"||h===o||h===s||h===i||h===u||h===g||typeof h=="object"&&h!==null&&(h.$$typeof===y||h.$$typeof===x||h.$$typeof===l||h.$$typeof===a||h.$$typeof===c||h.$$typeof===b||h.getModuleId!==void 0)},Ie.typeOf=z,Ie}var Oe={};/**
132
+ */var ss;function yc(){if(ss)return Ie;ss=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),S=Symbol.for("react.view_transition"),b=Symbol.for("react.client.reference");function T(m){if(typeof m=="object"&&m!==null){var f=m.$$typeof;switch(f){case e:switch(m=m.type,m){case o:case s:case i:case u:case x:case S:return m;default:switch(m=m&&m.$$typeof,m){case l:case c:case y:case g:return m;case a:return m;default:return f}}case r:return f}}}return Ie.ContextConsumer=a,Ie.ContextProvider=l,Ie.Element=e,Ie.ForwardRef=c,Ie.Fragment=o,Ie.Lazy=y,Ie.Memo=g,Ie.Portal=r,Ie.Profiler=s,Ie.StrictMode=i,Ie.Suspense=u,Ie.SuspenseList=x,Ie.isContextConsumer=function(m){return T(m)===a},Ie.isContextProvider=function(m){return T(m)===l},Ie.isElement=function(m){return typeof m=="object"&&m!==null&&m.$$typeof===e},Ie.isForwardRef=function(m){return T(m)===c},Ie.isFragment=function(m){return T(m)===o},Ie.isLazy=function(m){return T(m)===y},Ie.isMemo=function(m){return T(m)===g},Ie.isPortal=function(m){return T(m)===r},Ie.isProfiler=function(m){return T(m)===s},Ie.isStrictMode=function(m){return T(m)===i},Ie.isSuspense=function(m){return T(m)===u},Ie.isSuspenseList=function(m){return T(m)===x},Ie.isValidElementType=function(m){return typeof m=="string"||typeof m=="function"||m===o||m===s||m===i||m===u||m===x||typeof m=="object"&&m!==null&&(m.$$typeof===y||m.$$typeof===g||m.$$typeof===l||m.$$typeof===a||m.$$typeof===c||m.$$typeof===b||m.getModuleId!==void 0)},Ie.typeOf=T,Ie}var De={};/**
133
133
  * @license React
134
134
  * react-is.development.js
135
135
  *
@@ -137,16 +137,16 @@ Valid keys: `+JSON.stringify(Object.keys(N),null," "));var P=Me(W,pe,Z,de,se+".
137
137
  *
138
138
  * This source code is licensed under the MIT license found in the
139
139
  * LICENSE file in the root directory of this source tree.
140
- */var ns;function hc(){return ns||(ns=1,process.env.NODE_ENV!=="production"&&(function(){function e(h){if(typeof h=="object"&&h!==null){var m=h.$$typeof;switch(m){case r:switch(h=h.type,h){case i:case a:case s:case g:case x:case b:return h;default:switch(h=h&&h.$$typeof,h){case c:case u:case w:case y:return h;case l:return h;default:return m}}case o:return m}}}var r=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),b=Symbol.for("react.view_transition"),z=Symbol.for("react.client.reference");Oe.ContextConsumer=l,Oe.ContextProvider=c,Oe.Element=r,Oe.ForwardRef=u,Oe.Fragment=i,Oe.Lazy=w,Oe.Memo=y,Oe.Portal=o,Oe.Profiler=a,Oe.StrictMode=s,Oe.Suspense=g,Oe.SuspenseList=x,Oe.isContextConsumer=function(h){return e(h)===l},Oe.isContextProvider=function(h){return e(h)===c},Oe.isElement=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===r},Oe.isForwardRef=function(h){return e(h)===u},Oe.isFragment=function(h){return e(h)===i},Oe.isLazy=function(h){return e(h)===w},Oe.isMemo=function(h){return e(h)===y},Oe.isPortal=function(h){return e(h)===o},Oe.isProfiler=function(h){return e(h)===a},Oe.isStrictMode=function(h){return e(h)===s},Oe.isSuspense=function(h){return e(h)===g},Oe.isSuspenseList=function(h){return e(h)===x},Oe.isValidElementType=function(h){return typeof h=="string"||typeof h=="function"||h===i||h===a||h===s||h===g||h===x||typeof h=="object"&&h!==null&&(h.$$typeof===w||h.$$typeof===y||h.$$typeof===c||h.$$typeof===l||h.$$typeof===u||h.$$typeof===z||h.getModuleId!==void 0)},Oe.typeOf=e})()),Oe}var is;function xc(){return is||(is=1,process.env.NODE_ENV==="production"?rn.exports=mc():rn.exports=hc()),rn.exports}var qs=xc();function br(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 Js(e){if(gn.isValidElement(e)||qs.isValidElementType(e)||!br(e))return e;const r={};return Object.keys(e).forEach(o=>{r[o]=Js(e[o])}),r}function yt(e,r,o={clone:!0}){const i=o.clone?{...e}:e;return br(e)&&br(r)&&Object.keys(r).forEach(s=>{gn.isValidElement(r[s])||qs.isValidElementType(r[s])?i[s]=r[s]:br(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&br(e[s])?i[s]=yt(e[s],r[s],o):o.clone?i[s]=br(r[s])?Js(r[s]):r[s]:i[s]=r[s]}),i}const gc=e=>{const r=Object.keys(e).map(o=>({key:o,val:e[o]}))||[];return r.sort((o,i)=>o.val-i.val),r.reduce((o,i)=>({...o,[i.key]:i.val}),{})};function yc(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:o="px",step:i=5,...s}=e,a=gc(r),l=Object.keys(a);function c(w){return`@media (min-width:${typeof r[w]=="number"?r[w]:w}${o})`}function u(w){return`@media (max-width:${(typeof r[w]=="number"?r[w]:w)-i/100}${o})`}function g(w,b){const z=l.indexOf(b);return`@media (min-width:${typeof r[w]=="number"?r[w]:w}${o}) and (max-width:${(z!==-1&&typeof r[l[z]]=="number"?r[l[z]]:b)-i/100}${o})`}function x(w){return l.indexOf(w)+1<l.length?g(w,l[l.indexOf(w)+1]):c(w)}function y(w){const b=l.indexOf(w);return b===0?c(l[1]):b===l.length-1?u(l[b]):g(w,l[l.indexOf(w)+1]).replace("@media","@media not all and")}return{keys:l,values:a,up:c,down:u,between:g,only:x,not:y,unit:o,...s}}function ss(e,r){if(!e.containerQueries)return r;const o=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var l,c;const a=/min-width:\s*([0-9.]+)/;return+(((l=i.match(a))==null?void 0:l[1])||0)-+(((c=s.match(a))==null?void 0:c[1])||0)});return o.length?o.reduce((i,s)=>{const a=r[s];return delete i[s],i[s]=a,i},{...r}):r}function bc(e,r){return r==="@"||r.startsWith("@")&&(e.some(o=>r.startsWith(`@${o}`))||!!r.match(/^@\d/))}function vc(e,r){const o=r.match(/^@([^/]+)?\/?(.+)?$/);if(!o){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${r})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
141
- For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=o,a=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(a)}function Sc(e){const r=(a,l)=>a.replace("@media",l?`@container ${l}`:"@container");function o(a,l){a.up=(...c)=>r(e.breakpoints.up(...c),l),a.down=(...c)=>r(e.breakpoints.down(...c),l),a.between=(...c)=>r(e.breakpoints.between(...c),l),a.only=(...c)=>r(e.breakpoints.only(...c),l),a.not=(...c)=>{const u=r(e.breakpoints.not(...c),l);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=a=>(o(i,a),i);return o(s),{...e,containerQueries:s}}const wc={borderRadius:4},wr=process.env.NODE_ENV!=="production"?To.oneOfType([To.number,To.string,To.object,To.array]):{};function Mo(e,r){return r?yt(e,r,{clone:!1}):e}const Sn={xs:0,sm:600,md:900,lg:1200,xl:1536},as={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${Sn[e]}px)`},Cc={containerQueries:e=>({up:r=>{let o=typeof r=="number"?r:Sn[r]||r;return typeof o=="number"&&(o=`${o}px`),e?`@container ${e} (min-width:${o})`:`@container (min-width:${o})`}})};function dr(e,r,o){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||as;return r.reduce((l,c,u)=>(l[a.up(a.keys[u])]=o(r[u]),l),{})}if(typeof r=="object"){const a=i.breakpoints||as;return Object.keys(r).reduce((l,c)=>{if(bc(a.keys,c)){const u=vc(i.containerQueries?i:Cc,c);u&&(l[u]=o(r[c],c))}else if(Object.keys(a.values||Sn).includes(c)){const u=a.up(c);l[u]=o(r[c],c)}else{const u=c;l[u]=r[u]}return l},{})}return o(r)}function jc(e={}){var o;return((o=e.keys)==null?void 0:o.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function ls(e,r){return e.reduce((o,i)=>{const s=o[i];return(!s||Object.keys(s).length===0)&&delete o[i],o},r)}function Ks(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Mr(7));return e.charAt(0).toUpperCase()+e.slice(1)}function wn(e,r,o=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&o){const i=`vars.${r}`.split(".").reduce((s,a)=>s&&s[a]?s[a]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function xn(e,r,o,i=o){let s;return typeof e=="function"?s=e(o):Array.isArray(e)?s=e[o]||i:s=wn(e,o)||i,r&&(s=r(s,i,e)),s}function Ye(e){const{prop:r,cssProperty:o=e.prop,themeKey:i,transform:s}=e,a=l=>{if(l[r]==null)return null;const c=l[r],u=l.theme,g=wn(u,i)||{};return dr(l,c,y=>{let w=xn(g,s,y);return y===w&&typeof y=="string"&&(w=xn(g,s,`${r}${y==="default"?"":Ks(y)}`,y)),o===!1?w:{[o]:w}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:wr}:{},a.filterProps=[r],a}function kc(e){const r={};return o=>(r[o]===void 0&&(r[o]=e(o)),r[o])}const Tc={m:"margin",p:"padding"},zc={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},cs={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Bc=kc(e=>{if(e.length>2)if(cs[e])e=cs[e];else return[e];const[r,o]=e.split(""),i=Tc[r],s=zc[o]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),Cn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],jn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],Ec=[...Cn,...jn];function Po(e,r,o,i){const s=wn(e,r,!0)??o;return typeof s=="number"||typeof s=="string"?a=>typeof a=="string"?a:(process.env.NODE_ENV!=="production"&&typeof a!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${a}.`),typeof s=="string"?s.startsWith("var(")&&a===0?0:s.startsWith("var(")&&a===1?s:`calc(${a} * ${s})`:s*a):Array.isArray(s)?a=>{if(typeof a=="string")return a;const l=Math.abs(a);process.env.NODE_ENV!=="production"&&(Number.isInteger(l)?l>s.length-1&&console.error([`MUI: The value provided (${l}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${l} > ${s.length-1}, you need to add the missing values.`].join(`
140
+ */var as;function bc(){return as||(as=1,process.env.NODE_ENV!=="production"&&(function(){function e(m){if(typeof m=="object"&&m!==null){var f=m.$$typeof;switch(f){case r:switch(m=m.type,m){case i:case a:case s:case x:case g:case b:return m;default:switch(m=m&&m.$$typeof,m){case c:case u:case S:case y:return m;case l:return m;default:return f}}case o:return f}}}var r=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),b=Symbol.for("react.view_transition"),T=Symbol.for("react.client.reference");De.ContextConsumer=l,De.ContextProvider=c,De.Element=r,De.ForwardRef=u,De.Fragment=i,De.Lazy=S,De.Memo=y,De.Portal=o,De.Profiler=a,De.StrictMode=s,De.Suspense=x,De.SuspenseList=g,De.isContextConsumer=function(m){return e(m)===l},De.isContextProvider=function(m){return e(m)===c},De.isElement=function(m){return typeof m=="object"&&m!==null&&m.$$typeof===r},De.isForwardRef=function(m){return e(m)===u},De.isFragment=function(m){return e(m)===i},De.isLazy=function(m){return e(m)===S},De.isMemo=function(m){return e(m)===y},De.isPortal=function(m){return e(m)===o},De.isProfiler=function(m){return e(m)===a},De.isStrictMode=function(m){return e(m)===s},De.isSuspense=function(m){return e(m)===x},De.isSuspenseList=function(m){return e(m)===g},De.isValidElementType=function(m){return typeof m=="string"||typeof m=="function"||m===i||m===a||m===s||m===x||m===g||typeof m=="object"&&m!==null&&(m.$$typeof===S||m.$$typeof===y||m.$$typeof===c||m.$$typeof===l||m.$$typeof===u||m.$$typeof===T||m.getModuleId!==void 0)},De.typeOf=e})()),De}var ls;function vc(){return ls||(ls=1,process.env.NODE_ENV==="production"?en.exports=yc():en.exports=bc()),en.exports}var Zs=vc();function xr(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 ea(e){if(mn.isValidElement(e)||Zs.isValidElementType(e)||!xr(e))return e;const r={};return Object.keys(e).forEach(o=>{r[o]=ea(e[o])}),r}function bt(e,r,o={clone:!0}){const i=o.clone?{...e}:e;return xr(e)&&xr(r)&&Object.keys(r).forEach(s=>{mn.isValidElement(r[s])||Zs.isValidElementType(r[s])?i[s]=r[s]:xr(r[s])&&Object.prototype.hasOwnProperty.call(e,s)&&xr(e[s])?i[s]=bt(e[s],r[s],o):o.clone?i[s]=xr(r[s])?ea(r[s]):r[s]:i[s]=r[s]}),i}const Sc=e=>{const r=Object.keys(e).map(o=>({key:o,val:e[o]}))||[];return r.sort((o,i)=>o.val-i.val),r.reduce((o,i)=>({...o,[i.key]:i.val}),{})};function wc(e){const{values:r={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:o="px",step:i=5,...s}=e,a=Sc(r),l=Object.keys(a);function c(S){return`@media (min-width:${typeof r[S]=="number"?r[S]:S}${o})`}function u(S){return`@media (max-width:${(typeof r[S]=="number"?r[S]:S)-i/100}${o})`}function x(S,b){const T=l.indexOf(b);return`@media (min-width:${typeof r[S]=="number"?r[S]:S}${o}) and (max-width:${(T!==-1&&typeof r[l[T]]=="number"?r[l[T]]:b)-i/100}${o})`}function g(S){return l.indexOf(S)+1<l.length?x(S,l[l.indexOf(S)+1]):c(S)}function y(S){const b=l.indexOf(S);return b===0?c(l[1]):b===l.length-1?u(l[b]):x(S,l[l.indexOf(S)+1]).replace("@media","@media not all and")}return{keys:l,values:a,up:c,down:u,between:x,only:g,not:y,unit:o,...s}}function cs(e,r){if(!e.containerQueries)return r;const o=Object.keys(r).filter(i=>i.startsWith("@container")).sort((i,s)=>{var l,c;const a=/min-width:\s*([0-9.]+)/;return+(((l=i.match(a))==null?void 0:l[1])||0)-+(((c=s.match(a))==null?void 0:c[1])||0)});return o.length?o.reduce((i,s)=>{const a=r[s];return delete i[s],i[s]=a,i},{...r}):r}function Cc(e,r){return r==="@"||r.startsWith("@")&&(e.some(o=>r.startsWith(`@${o}`))||!!r.match(/^@\d/))}function jc(e,r){const o=r.match(/^@([^/]+)?\/?(.+)?$/);if(!o){if(process.env.NODE_ENV!=="production")throw new Error(`MUI: The provided shorthand ${`(${r})`} is invalid. The format should be \`@<breakpoint | number>\` or \`@<breakpoint | number>/<container>\`.
141
+ For example, \`@sm\` or \`@600\` or \`@40rem/sidebar\`.`);return null}const[,i,s]=o,a=Number.isNaN(+i)?i||0:+i;return e.containerQueries(s).up(a)}function kc(e){const r=(a,l)=>a.replace("@media",l?`@container ${l}`:"@container");function o(a,l){a.up=(...c)=>r(e.breakpoints.up(...c),l),a.down=(...c)=>r(e.breakpoints.down(...c),l),a.between=(...c)=>r(e.breakpoints.between(...c),l),a.only=(...c)=>r(e.breakpoints.only(...c),l),a.not=(...c)=>{const u=r(e.breakpoints.not(...c),l);return u.includes("not all and")?u.replace("not all and ","").replace("min-width:","width<").replace("max-width:","width>").replace("and","or"):u}}const i={},s=a=>(o(i,a),i);return o(s),{...e,containerQueries:s}}const Tc={borderRadius:4},br=process.env.NODE_ENV!=="production"?jo.oneOfType([jo.number,jo.string,jo.object,jo.array]):{};function Do(e,r){return r?bt(e,r,{clone:!1}):e}const bn={xs:0,sm:600,md:900,lg:1200,xl:1536},ds={keys:["xs","sm","md","lg","xl"],up:e=>`@media (min-width:${bn[e]}px)`},zc={containerQueries:e=>({up:r=>{let o=typeof r=="number"?r:bn[r]||r;return typeof o=="number"&&(o=`${o}px`),e?`@container ${e} (min-width:${o})`:`@container (min-width:${o})`}})};function lr(e,r,o){const i=e.theme||{};if(Array.isArray(r)){const a=i.breakpoints||ds;return r.reduce((l,c,u)=>(l[a.up(a.keys[u])]=o(r[u]),l),{})}if(typeof r=="object"){const a=i.breakpoints||ds;return Object.keys(r).reduce((l,c)=>{if(Cc(a.keys,c)){const u=jc(i.containerQueries?i:zc,c);u&&(l[u]=o(r[c],c))}else if(Object.keys(a.values||bn).includes(c)){const u=a.up(c);l[u]=o(r[c],c)}else{const u=c;l[u]=r[u]}return l},{})}return o(r)}function Bc(e={}){var o;return((o=e.keys)==null?void 0:o.reduce((i,s)=>{const a=e.up(s);return i[a]={},i},{}))||{}}function us(e,r){return e.reduce((o,i)=>{const s=o[i];return(!s||Object.keys(s).length===0)&&delete o[i],o},r)}function ta(e){if(typeof e!="string")throw new Error(process.env.NODE_ENV!=="production"?"MUI: `capitalize(string)` expects a string argument.":Ar(7));return e.charAt(0).toUpperCase()+e.slice(1)}function vn(e,r,o=!0){if(!r||typeof r!="string")return null;if(e&&e.vars&&o){const i=`vars.${r}`.split(".").reduce((s,a)=>s&&s[a]?s[a]:null,e);if(i!=null)return i}return r.split(".").reduce((i,s)=>i&&i[s]!=null?i[s]:null,e)}function hn(e,r,o,i=o){let s;return typeof e=="function"?s=e(o):Array.isArray(e)?s=e[o]||i:s=vn(e,o)||i,r&&(s=r(s,i,e)),s}function Je(e){const{prop:r,cssProperty:o=e.prop,themeKey:i,transform:s}=e,a=l=>{if(l[r]==null)return null;const c=l[r],u=l.theme,x=vn(u,i)||{};return lr(l,c,y=>{let S=hn(x,s,y);return y===S&&typeof y=="string"&&(S=hn(x,s,`${r}${y==="default"?"":ta(y)}`,y)),o===!1?S:{[o]:S}})};return a.propTypes=process.env.NODE_ENV!=="production"?{[r]:br}:{},a.filterProps=[r],a}function Ec(e){const r={};return o=>(r[o]===void 0&&(r[o]=e(o)),r[o])}const _c={m:"margin",p:"padding"},$c={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},ps={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Ic=Ec(e=>{if(e.length>2)if(ps[e])e=ps[e];else return[e];const[r,o]=e.split(""),i=_c[r],s=$c[o]||"";return Array.isArray(s)?s.map(a=>i+a):[i+s]}),Sn=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],wn=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],Dc=[...Sn,...wn];function Ro(e,r,o,i){const s=vn(e,r,!0)??o;return typeof s=="number"||typeof s=="string"?a=>typeof a=="string"?a:(process.env.NODE_ENV!=="production"&&typeof a!="number"&&console.error(`MUI: Expected ${i} argument to be a number or a string, got ${a}.`),typeof s=="string"?s.startsWith("var(")&&a===0?0:s.startsWith("var(")&&a===1?s:`calc(${a} * ${s})`:s*a):Array.isArray(s)?a=>{if(typeof a=="string")return a;const l=Math.abs(a);process.env.NODE_ENV!=="production"&&(Number.isInteger(l)?l>s.length-1&&console.error([`MUI: The value provided (${l}) overflows.`,`The supported values are: ${JSON.stringify(s)}.`,`${l} > ${s.length-1}, you need to add the missing values.`].join(`
142
142
  `)):console.error([`MUI: The \`theme.${r}\` array type cannot be combined with non integer values.You should either use an integer value that can be used as index, or define the \`theme.${r}\` as a number.`].join(`
143
143
  `)));const c=s[l];return a>=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(`
144
- `)),()=>{})}function Ei(e){return Po(e,"spacing",8,"spacing")}function Lo(e,r){return typeof r=="string"||r==null?r:e(r)}function _c(e,r){return o=>e.reduce((i,s)=>(i[s]=Lo(r,o),i),{})}function $c(e,r,o,i){if(!r.includes(o))return null;const s=Bc(o),a=_c(s,i),l=e[o];return dr(e,l,a)}function Xs(e,r){const o=Ei(e.theme);return Object.keys(e).map(i=>$c(e,r,i,o)).reduce(Mo,{})}function Fe(e){return Xs(e,Cn)}Fe.propTypes=process.env.NODE_ENV!=="production"?Cn.reduce((e,r)=>(e[r]=wr,e),{}):{};Fe.filterProps=Cn;function Ne(e){return Xs(e,jn)}Ne.propTypes=process.env.NODE_ENV!=="production"?jn.reduce((e,r)=>(e[r]=wr,e),{}):{};Ne.filterProps=jn;process.env.NODE_ENV!=="production"&&Ec.reduce((e,r)=>(e[r]=wr,e),{});function Qs(e=8,r=Ei({spacing:e})){if(e.mui)return e;const o=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(a=>{const l=r(a);return typeof l=="number"?`${l}px`:l}).join(" "));return o.mui=!0,o}function kn(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(a=>{i[a]=s}),i),{}),o=i=>Object.keys(i).reduce((s,a)=>r[a]?Mo(s,r[a](i)):s,{});return o.propTypes=process.env.NODE_ENV!=="production"?e.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},o.filterProps=e.reduce((i,s)=>i.concat(s.filterProps),[]),o}function kt(e){return typeof e!="number"?e:`${e}px solid`}function zt(e,r){return Ye({prop:e,themeKey:"borders",transform:r})}const Dc=zt("border",kt),Ic=zt("borderTop",kt),Oc=zt("borderRight",kt),Mc=zt("borderBottom",kt),Ac=zt("borderLeft",kt),Rc=zt("borderColor"),Wc=zt("borderTopColor"),Pc=zt("borderRightColor"),Lc=zt("borderBottomColor"),Fc=zt("borderLeftColor"),Nc=zt("outline",kt),Vc=zt("outlineColor"),Tn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=Po(e.theme,"shape.borderRadius",4,"borderRadius"),o=i=>({borderRadius:Lo(r,i)});return dr(e,e.borderRadius,o)}return null};Tn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:wr}:{};Tn.filterProps=["borderRadius"];kn(Dc,Ic,Oc,Mc,Ac,Rc,Wc,Pc,Lc,Fc,Tn,Nc,Vc);const zn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=Po(e.theme,"spacing",8,"gap"),o=i=>({gap:Lo(r,i)});return dr(e,e.gap,o)}return null};zn.propTypes=process.env.NODE_ENV!=="production"?{gap:wr}:{};zn.filterProps=["gap"];const Bn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=Po(e.theme,"spacing",8,"columnGap"),o=i=>({columnGap:Lo(r,i)});return dr(e,e.columnGap,o)}return null};Bn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:wr}:{};Bn.filterProps=["columnGap"];const En=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=Po(e.theme,"spacing",8,"rowGap"),o=i=>({rowGap:Lo(r,i)});return dr(e,e.rowGap,o)}return null};En.propTypes=process.env.NODE_ENV!=="production"?{rowGap:wr}:{};En.filterProps=["rowGap"];const Hc=Ye({prop:"gridColumn"}),Gc=Ye({prop:"gridRow"}),Uc=Ye({prop:"gridAutoFlow"}),Yc=Ye({prop:"gridAutoColumns"}),qc=Ye({prop:"gridAutoRows"}),Jc=Ye({prop:"gridTemplateColumns"}),Kc=Ye({prop:"gridTemplateRows"}),Xc=Ye({prop:"gridTemplateAreas"}),Qc=Ye({prop:"gridArea"});kn(zn,Bn,En,Hc,Gc,Uc,Yc,qc,Jc,Kc,Xc,Qc);function co(e,r){return r==="grey"?r:e}const Zc=Ye({prop:"color",themeKey:"palette",transform:co}),ed=Ye({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:co}),td=Ye({prop:"backgroundColor",themeKey:"palette",transform:co});kn(Zc,ed,td);function gt(e){return e<=1&&e!==0?`${e*100}%`:e}const rd=Ye({prop:"width",transform:gt}),_i=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=o=>{var s,a,l,c,u;const i=((l=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:l[o])||Sn[o];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:gt(o)}};return dr(e,e.maxWidth,r)}return null};_i.filterProps=["maxWidth"];const od=Ye({prop:"minWidth",transform:gt}),nd=Ye({prop:"height",transform:gt}),id=Ye({prop:"maxHeight",transform:gt}),sd=Ye({prop:"minHeight",transform:gt});Ye({prop:"size",cssProperty:"width",transform:gt});Ye({prop:"size",cssProperty:"height",transform:gt});const ad=Ye({prop:"boxSizing"});kn(rd,_i,od,nd,id,sd,ad);const _n={border:{themeKey:"borders",transform:kt},borderTop:{themeKey:"borders",transform:kt},borderRight:{themeKey:"borders",transform:kt},borderBottom:{themeKey:"borders",transform:kt},borderLeft:{themeKey:"borders",transform:kt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:kt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:Tn},color:{themeKey:"palette",transform:co},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:co},backgroundColor:{themeKey:"palette",transform:co},p:{style:Ne},pt:{style:Ne},pr:{style:Ne},pb:{style:Ne},pl:{style:Ne},px:{style:Ne},py:{style:Ne},padding:{style:Ne},paddingTop:{style:Ne},paddingRight:{style:Ne},paddingBottom:{style:Ne},paddingLeft:{style:Ne},paddingX:{style:Ne},paddingY:{style:Ne},paddingInline:{style:Ne},paddingInlineStart:{style:Ne},paddingInlineEnd:{style:Ne},paddingBlock:{style:Ne},paddingBlockStart:{style:Ne},paddingBlockEnd:{style:Ne},m:{style:Fe},mt:{style:Fe},mr:{style:Fe},mb:{style:Fe},ml:{style:Fe},mx:{style:Fe},my:{style:Fe},margin:{style:Fe},marginTop:{style:Fe},marginRight:{style:Fe},marginBottom:{style:Fe},marginLeft:{style:Fe},marginX:{style:Fe},marginY:{style:Fe},marginInline:{style:Fe},marginInlineStart:{style:Fe},marginInlineEnd:{style:Fe},marginBlock:{style:Fe},marginBlockStart:{style:Fe},marginBlockEnd:{style:Fe},displayPrint:{cssProperty:!1,transform:e=>({"@media print":{display:e}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:zn},rowGap:{style:En},columnGap:{style:Bn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:gt},maxWidth:{style:_i},minWidth:{transform:gt},height:{transform:gt},maxHeight:{transform:gt},minHeight:{transform:gt},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 ld(...e){const r=e.reduce((i,s)=>i.concat(Object.keys(s)),[]),o=new Set(r);return e.every(i=>o.size===Object.keys(i).length)}function cd(e,r){return typeof e=="function"?e(r):e}function dd(){function e(o,i,s,a){const l={[o]:i,theme:s},c=a[o];if(!c)return{[o]:i};const{cssProperty:u=o,themeKey:g,transform:x,style:y}=c;if(i==null)return null;if(g==="typography"&&i==="inherit")return{[o]:i};const w=wn(s,g)||{};return y?y(l):dr(l,i,z=>{let h=xn(w,x,z);return z===h&&typeof z=="string"&&(h=xn(w,x,`${o}${z==="default"?"":Ks(z)}`,z)),u===!1?h:{[u]:h}})}function r(o){const{sx:i,theme:s={},nested:a}=o||{};if(!i)return null;const l=s.unstable_sxConfig??_n;function c(u){let g=u;if(typeof u=="function")g=u(s);else if(typeof u!="object")return u;if(!g)return null;const x=jc(s.breakpoints),y=Object.keys(x);let w=x;return Object.keys(g).forEach(b=>{const z=cd(g[b],s);if(z!=null)if(typeof z=="object")if(l[b])w=Mo(w,e(b,z,s,l));else{const h=dr({theme:s},z,m=>({[b]:m}));ld(h,z)?w[b]=r({sx:z,theme:s,nested:!0}):w=Mo(w,h)}else w=Mo(w,e(b,z,s,l))}),!a&&s.modularCssLayers?{"@layer sx":ss(s,ls(y,w))}:ss(s,ls(y,w))}return Array.isArray(i)?i.map(c):c(i)}return r}const $n=dd();$n.filterProps=["sx"];function ud(e,r){var i;const o=this;if(o.vars){if(!((i=o.colorSchemes)!=null&&i[e])||typeof o.getColorSchemeSelector!="function")return{};let s=o.getColorSchemeSelector(e);return s==="&"?r:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:r})}return o.palette.mode===e?r:{}}function Zs(e={},...r){const{breakpoints:o={},palette:i={},spacing:s,shape:a={},...l}=e,c=yc(o),u=Qs(s);let g=yt({breakpoints:c,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...wc,...a}},l);return g=Sc(g),g.applyStyles=ud,g=r.reduce((x,y)=>yt(x,y),g),g.unstable_sxConfig={..._n,...l==null?void 0:l.unstable_sxConfig},g.unstable_sx=function(y){return $n({sx:y,theme:this})},g}function pd(e){return Object.keys(e).length===0}function fd(e=null){const r=gn.useContext(_a.ThemeContext);return!r||pd(r)?e:r}const md=Zs();function hd(e=md){return fd(e)}const ds=e=>e,xd=()=>{let e=ds;return{configure(r){e=r},generate(r){return e(r)},reset(){e=ds}}},gd=xd(),yd={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 bd(e,r,o="Mui"){const i=yd[r];return i?`${o}-${i}`:`${gd.generate(e)}-${r}`}function vd(e,r=Number.MIN_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,o))}function $i(e,r=0,o=1){return process.env.NODE_ENV!=="production"&&(e<r||e>o)&&console.error(`MUI: The value provided ${e} is out of range [${r}, ${o}].`),vd(e,r,o)}function Sd(e){e=e.slice(1);const r=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let o=e.match(r);return o&&o[0].length===1&&(o=o.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.`),o?`rgb${o.length===4?"a":""}(${o.map((i,s)=>s<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function Sr(e){if(e.type)return e;if(e.charAt(0)==="#")return Sr(Sd(e));const r=e.indexOf("("),o=e.substring(0,r);if(!["rgb","rgba","hsl","hsla","color"].includes(o))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${e}\` color.
145
- The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Mr(9,e));let i=e.substring(r+1,e.length-1),s;if(o==="color"){if(i=i.split(" "),s=i.shift(),i.length===4&&i[3].charAt(0)==="/"&&(i[3]=i[3].slice(1)),!["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].includes(s))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${s}\` color space.
146
- The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:Mr(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:o,values:i,colorSpace:s}}const wd=e=>{const r=Sr(e);return r.values.slice(0,3).map((o,i)=>r.type.includes("hsl")&&i!==0?`${o}%`:o).join(" ")},_o=(e,r)=>{try{return wd(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function Dn(e){const{type:r,colorSpace:o}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,a)=>a<3?parseInt(s,10):s):r.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),r.includes("color")?i=`${o} ${i.join(" ")}`:i=`${i.join(", ")}`,`${r}(${i})`}function ea(e){e=Sr(e);const{values:r}=e,o=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),l=(g,x=(g+o/30)%12)=>s-a*Math.max(Math.min(x-3,9-x,1),-1);let c="rgb";const u=[Math.round(l(0)*255),Math.round(l(8)*255),Math.round(l(4)*255)];return e.type==="hsla"&&(c+="a",u.push(r[3])),Dn({type:c,values:u})}function fi(e){e=Sr(e);let r=e.type==="hsl"||e.type==="hsla"?Sr(ea(e)).values:e.values;return r=r.map(o=>(e.type!=="color"&&(o/=255),o<=.03928?o/12.92:((o+.055)/1.055)**2.4)),Number((.2126*r[0]+.7152*r[1]+.0722*r[2]).toFixed(3))}function us(e,r){const o=fi(e),i=fi(r);return(Math.max(o,i)+.05)/(Math.min(o,i)+.05)}function M(e,r){return e=Sr(e),r=$i(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,Dn(e)}function Ir(e,r,o){try{return M(e,r)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),e}}function In(e,r){if(e=Sr(e),r=$i(r),e.type.includes("hsl"))e.values[2]*=1-r;else if(e.type.includes("rgb")||e.type.includes("color"))for(let o=0;o<3;o+=1)e.values[o]*=1-r;return Dn(e)}function $e(e,r,o){try{return In(e,r)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),e}}function On(e,r){if(e=Sr(e),r=$i(r),e.type.includes("hsl"))e.values[2]+=(100-e.values[2])*r;else if(e.type.includes("rgb"))for(let o=0;o<3;o+=1)e.values[o]+=(255-e.values[o])*r;else if(e.type.includes("color"))for(let o=0;o<3;o+=1)e.values[o]+=(1-e.values[o])*r;return Dn(e)}function De(e,r,o){try{return On(e,r)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),e}}function Cd(e,r=.15){return fi(e)>.5?In(e,r):On(e,r)}function on(e,r,o){try{return Cd(e,r)}catch{return e}}function jd(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 ps=(e,r,o,i=[])=>{let s=e;r.forEach((a,l)=>{l===r.length-1?Array.isArray(s)?s[Number(a)]=o:s&&typeof s=="object"&&(s[a]=o):s&&typeof s=="object"&&(s[a]||(s[a]=i.includes(a)?[]:{}),s=s[a])})},kd=(e,r,o)=>{function i(s,a=[],l=[]){Object.entries(s).forEach(([c,u])=>{(!o||o&&!o([...a,c]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...a,c],Array.isArray(u)?[...l,c]:l):r([...a,c],u,l))})}i(e)},Td=(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 ai(e,r){const{prefix:o,shouldSkipGeneratingVar:i}=r||{},s={},a={},l={};return kd(e,(c,u,g)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(c,u))){const x=`--${o?`${o}-`:""}${c.join("-")}`,y=Td(c,u);Object.assign(s,{[x]:y}),ps(a,c,`var(${x})`,g),ps(l,c,`var(${x}, ${y})`,g)}},c=>c[0]==="vars"),{css:s,vars:a,varsWithDefaults:l}}function zd(e,r={}){const{getSelector:o=E,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:l={},components:c,defaultColorScheme:u="light",...g}=e,{vars:x,css:y,varsWithDefaults:w}=ai(g,r);let b=w;const z={},{[u]:h,...m}=l;if(Object.entries(m||{}).forEach(([B,f])=>{const{vars:$,css:F,varsWithDefaults:O}=ai(f,r);b=yt(b,O),z[B]={css:F,vars:$}}),h){const{css:B,vars:f,varsWithDefaults:$}=ai(h,r);b=yt(b,$),z[u]={css:B,vars:f}}function E(B,f){var F,O;let $=s;if(s==="class"&&($=".%s"),s==="data"&&($="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&($=`[${s}="%s"]`),B){if($==="media")return e.defaultColorScheme===B?":root":{[`@media (prefers-color-scheme: ${((O=(F=l[B])==null?void 0:F.palette)==null?void 0:O.mode)||B})`]:{":root":f}};if($)return e.defaultColorScheme===B?`:root, ${$.replace("%s",String(B))}`:$.replace("%s",String(B))}return":root"}return{vars:b,generateThemeVars:()=>{let B={...x};return Object.entries(z).forEach(([,{vars:f}])=>{B=yt(B,f)}),B},generateStyleSheets:()=>{var J,te;const B=[],f=e.defaultColorScheme||"light";function $(L,S){Object.keys(S).length&&B.push(typeof L=="string"?{[L]:{...S}}:L)}$(o(void 0,{...y}),y);const{[f]:F,...O}=z;if(F){const{css:L}=F,S=(te=(J=l[f])==null?void 0:J.palette)==null?void 0:te.mode,A=!i&&S?{colorScheme:S,...L}:{...L};$(o(f,{...A}),A)}return Object.entries(O).forEach(([L,{css:S}])=>{var Y,oe;const A=(oe=(Y=l[L])==null?void 0:Y.palette)==null?void 0:oe.mode,k=!i&&A?{colorScheme:A,...S}:{...S};$(o(L,{...k}),k)}),a&&B.push({":root":{"--__l-threshold":"0.7","--__l":"clamp(0, (l / var(--__l-threshold) - 1) * -infinity, 1)","--__a":"clamp(0.87, (l / var(--__l-threshold) - 1) * -infinity, 1)"}}),B}}}function Bd(e){return function(o){return e==="media"?(process.env.NODE_ENV!=="production"&&o!=="light"&&o!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${o}'.`),`@media (prefers-color-scheme: ${o})`):e?e.startsWith("data-")&&!e.includes("%s")?`[${e}="${o}"] &`:e==="class"?`.${o} &`:e==="data"?`[data-${o}] &`:`${e.replace("%s",o)} &`:"&"}}const Ro={black:"#000",white:"#fff"},Ed={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},oo={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},no={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},zo={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},io={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},so={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},ao={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function ta(){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:Ro.white,default:Ro.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 ra=ta();function oa(){return{text:{primary:Ro.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:Ro.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 mi=oa();function fs(e,r,o,i){const s=i.light||i,a=i.dark||i*1.5;e[r]||(e.hasOwnProperty(o)?e[r]=e[o]:r==="light"?e.light=On(e.main,s):r==="dark"&&(e.dark=In(e.main,a)))}function ms(e,r,o,i,s){const a=s.light||s,l=s.dark||s*1.5;r[o]||(r.hasOwnProperty(i)?r[o]=r[i]:o==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(a*100).toFixed(0)}%)`:o==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(l*100).toFixed(0)}%)`))}function _d(e="light"){return e==="dark"?{main:io[200],light:io[50],dark:io[400]}:{main:io[700],light:io[400],dark:io[800]}}function $d(e="light"){return e==="dark"?{main:oo[200],light:oo[50],dark:oo[400]}:{main:oo[500],light:oo[300],dark:oo[700]}}function Dd(e="light"){return e==="dark"?{main:no[500],light:no[300],dark:no[700]}:{main:no[700],light:no[400],dark:no[800]}}function Id(e="light"){return e==="dark"?{main:so[400],light:so[300],dark:so[700]}:{main:so[700],light:so[500],dark:so[900]}}function Od(e="light"){return e==="dark"?{main:ao[400],light:ao[300],dark:ao[700]}:{main:ao[800],light:ao[500],dark:ao[900]}}function Md(e="light"){return e==="dark"?{main:zo[400],light:zo[300],dark:zo[700]}:{main:"#ed6c02",light:zo[500],dark:zo[900]}}function Ad(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function Di(e){const{mode:r="light",contrastThreshold:o=3,tonalOffset:i=.2,colorSpace:s,...a}=e,l=e.primary||_d(r),c=e.secondary||$d(r),u=e.error||Dd(r),g=e.info||Id(r),x=e.success||Od(r),y=e.warning||Md(r);function w(m){if(s)return Ad(m);const E=us(m,mi.text.primary)>=o?mi.text.primary:ra.text.primary;if(process.env.NODE_ENV!=="production"){const v=us(m,E);v<3&&console.error([`MUI: The contrast ratio of ${v}:1 for ${E} on ${m}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
147
- `))}return E}const b=({color:m,name:E,mainShade:v=500,lightShade:T=300,darkShade:B=700})=>{if(m={...m},!m.main&&m[v]&&(m.main=m[v]),!m.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${E?` (${E})`:""} provided to augmentColor(color) is invalid.
148
- The color object needs to have a \`main\` property or a \`${v}\` property.`:Mr(11,E?` (${E})`:"",v));if(typeof m.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${E?` (${E})`:""} provided to augmentColor(color) is invalid.
149
- \`color.main\` should be a string, but \`${JSON.stringify(m.main)}\` was provided instead.
144
+ `)),()=>{})}function $i(e){return Ro(e,"spacing",8,"spacing")}function Wo(e,r){return typeof r=="string"||r==null?r:e(r)}function Oc(e,r){return o=>e.reduce((i,s)=>(i[s]=Wo(r,o),i),{})}function Mc(e,r,o,i){if(!r.includes(o))return null;const s=Ic(o),a=Oc(s,i),l=e[o];return lr(e,l,a)}function ra(e,r){const o=$i(e.theme);return Object.keys(e).map(i=>Mc(e,r,i,o)).reduce(Do,{})}function Ne(e){return ra(e,Sn)}Ne.propTypes=process.env.NODE_ENV!=="production"?Sn.reduce((e,r)=>(e[r]=br,e),{}):{};Ne.filterProps=Sn;function Ve(e){return ra(e,wn)}Ve.propTypes=process.env.NODE_ENV!=="production"?wn.reduce((e,r)=>(e[r]=br,e),{}):{};Ve.filterProps=wn;process.env.NODE_ENV!=="production"&&Dc.reduce((e,r)=>(e[r]=br,e),{});function oa(e=8,r=$i({spacing:e})){if(e.mui)return e;const o=(...i)=>(process.env.NODE_ENV!=="production"&&(i.length<=4||console.error(`MUI: Too many arguments provided, expected between 0 and 4, got ${i.length}`)),(i.length===0?[1]:i).map(a=>{const l=r(a);return typeof l=="number"?`${l}px`:l}).join(" "));return o.mui=!0,o}function Cn(...e){const r=e.reduce((i,s)=>(s.filterProps.forEach(a=>{i[a]=s}),i),{}),o=i=>Object.keys(i).reduce((s,a)=>r[a]?Do(s,r[a](i)):s,{});return o.propTypes=process.env.NODE_ENV!=="production"?e.reduce((i,s)=>Object.assign(i,s.propTypes),{}):{},o.filterProps=e.reduce((i,s)=>i.concat(s.filterProps),[]),o}function kt(e){return typeof e!="number"?e:`${e}px solid`}function zt(e,r){return Je({prop:e,themeKey:"borders",transform:r})}const Ac=zt("border",kt),Rc=zt("borderTop",kt),Wc=zt("borderRight",kt),Pc=zt("borderBottom",kt),Lc=zt("borderLeft",kt),Fc=zt("borderColor"),Nc=zt("borderTopColor"),Vc=zt("borderRightColor"),Hc=zt("borderBottomColor"),Gc=zt("borderLeftColor"),Uc=zt("outline",kt),Yc=zt("outlineColor"),jn=e=>{if(e.borderRadius!==void 0&&e.borderRadius!==null){const r=Ro(e.theme,"shape.borderRadius",4,"borderRadius"),o=i=>({borderRadius:Wo(r,i)});return lr(e,e.borderRadius,o)}return null};jn.propTypes=process.env.NODE_ENV!=="production"?{borderRadius:br}:{};jn.filterProps=["borderRadius"];Cn(Ac,Rc,Wc,Pc,Lc,Fc,Nc,Vc,Hc,Gc,jn,Uc,Yc);const kn=e=>{if(e.gap!==void 0&&e.gap!==null){const r=Ro(e.theme,"spacing",8,"gap"),o=i=>({gap:Wo(r,i)});return lr(e,e.gap,o)}return null};kn.propTypes=process.env.NODE_ENV!=="production"?{gap:br}:{};kn.filterProps=["gap"];const Tn=e=>{if(e.columnGap!==void 0&&e.columnGap!==null){const r=Ro(e.theme,"spacing",8,"columnGap"),o=i=>({columnGap:Wo(r,i)});return lr(e,e.columnGap,o)}return null};Tn.propTypes=process.env.NODE_ENV!=="production"?{columnGap:br}:{};Tn.filterProps=["columnGap"];const zn=e=>{if(e.rowGap!==void 0&&e.rowGap!==null){const r=Ro(e.theme,"spacing",8,"rowGap"),o=i=>({rowGap:Wo(r,i)});return lr(e,e.rowGap,o)}return null};zn.propTypes=process.env.NODE_ENV!=="production"?{rowGap:br}:{};zn.filterProps=["rowGap"];const qc=Je({prop:"gridColumn"}),Jc=Je({prop:"gridRow"}),Kc=Je({prop:"gridAutoFlow"}),Xc=Je({prop:"gridAutoColumns"}),Qc=Je({prop:"gridAutoRows"}),Zc=Je({prop:"gridTemplateColumns"}),ed=Je({prop:"gridTemplateRows"}),td=Je({prop:"gridTemplateAreas"}),rd=Je({prop:"gridArea"});Cn(kn,Tn,zn,qc,Jc,Kc,Xc,Qc,Zc,ed,td,rd);function co(e,r){return r==="grey"?r:e}const od=Je({prop:"color",themeKey:"palette",transform:co}),nd=Je({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:co}),id=Je({prop:"backgroundColor",themeKey:"palette",transform:co});Cn(od,nd,id);function yt(e){return e<=1&&e!==0?`${e*100}%`:e}const sd=Je({prop:"width",transform:yt}),Ii=e=>{if(e.maxWidth!==void 0&&e.maxWidth!==null){const r=o=>{var s,a,l,c,u;const i=((l=(a=(s=e.theme)==null?void 0:s.breakpoints)==null?void 0:a.values)==null?void 0:l[o])||bn[o];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:yt(o)}};return lr(e,e.maxWidth,r)}return null};Ii.filterProps=["maxWidth"];const ad=Je({prop:"minWidth",transform:yt}),ld=Je({prop:"height",transform:yt}),cd=Je({prop:"maxHeight",transform:yt}),dd=Je({prop:"minHeight",transform:yt});Je({prop:"size",cssProperty:"width",transform:yt});Je({prop:"size",cssProperty:"height",transform:yt});const ud=Je({prop:"boxSizing"});Cn(sd,Ii,ad,ld,cd,dd,ud);const Bn={border:{themeKey:"borders",transform:kt},borderTop:{themeKey:"borders",transform:kt},borderRight:{themeKey:"borders",transform:kt},borderBottom:{themeKey:"borders",transform:kt},borderLeft:{themeKey:"borders",transform:kt},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:kt},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:jn},color:{themeKey:"palette",transform:co},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:co},backgroundColor:{themeKey:"palette",transform:co},p:{style:Ve},pt:{style:Ve},pr:{style:Ve},pb:{style:Ve},pl:{style:Ve},px:{style:Ve},py:{style:Ve},padding:{style:Ve},paddingTop:{style:Ve},paddingRight:{style:Ve},paddingBottom:{style:Ve},paddingLeft:{style:Ve},paddingX:{style:Ve},paddingY:{style:Ve},paddingInline:{style:Ve},paddingInlineStart:{style:Ve},paddingInlineEnd:{style:Ve},paddingBlock:{style:Ve},paddingBlockStart:{style:Ve},paddingBlockEnd:{style:Ve},m:{style:Ne},mt:{style:Ne},mr:{style:Ne},mb:{style:Ne},ml:{style:Ne},mx:{style:Ne},my:{style:Ne},margin:{style:Ne},marginTop:{style:Ne},marginRight:{style:Ne},marginBottom:{style:Ne},marginLeft:{style:Ne},marginX:{style:Ne},marginY:{style:Ne},marginInline:{style:Ne},marginInlineStart:{style:Ne},marginInlineEnd:{style:Ne},marginBlock:{style:Ne},marginBlockStart:{style:Ne},marginBlockEnd:{style:Ne},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:kn},rowGap:{style:zn},columnGap:{style:Tn},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:yt},maxWidth:{style:Ii},minWidth:{transform:yt},height:{transform:yt},maxHeight:{transform:yt},minHeight:{transform:yt},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 pd(...e){const r=e.reduce((i,s)=>i.concat(Object.keys(s)),[]),o=new Set(r);return e.every(i=>o.size===Object.keys(i).length)}function fd(e,r){return typeof e=="function"?e(r):e}function hd(){function e(o,i,s,a){const l={[o]:i,theme:s},c=a[o];if(!c)return{[o]:i};const{cssProperty:u=o,themeKey:x,transform:g,style:y}=c;if(i==null)return null;if(x==="typography"&&i==="inherit")return{[o]:i};const S=vn(s,x)||{};return y?y(l):lr(l,i,T=>{let m=hn(S,g,T);return T===m&&typeof T=="string"&&(m=hn(S,g,`${o}${T==="default"?"":ta(T)}`,T)),u===!1?m:{[u]:m}})}function r(o){const{sx:i,theme:s={},nested:a}=o||{};if(!i)return null;const l=s.unstable_sxConfig??Bn;function c(u){let x=u;if(typeof u=="function")x=u(s);else if(typeof u!="object")return u;if(!x)return null;const g=Bc(s.breakpoints),y=Object.keys(g);let S=g;return Object.keys(x).forEach(b=>{const T=fd(x[b],s);if(T!=null)if(typeof T=="object")if(l[b])S=Do(S,e(b,T,s,l));else{const m=lr({theme:s},T,f=>({[b]:f}));pd(m,T)?S[b]=r({sx:T,theme:s,nested:!0}):S=Do(S,m)}else S=Do(S,e(b,T,s,l))}),!a&&s.modularCssLayers?{"@layer sx":cs(s,us(y,S))}:cs(s,us(y,S))}return Array.isArray(i)?i.map(c):c(i)}return r}const En=hd();En.filterProps=["sx"];function md(e,r){var i;const o=this;if(o.vars){if(!((i=o.colorSchemes)!=null&&i[e])||typeof o.getColorSchemeSelector!="function")return{};let s=o.getColorSchemeSelector(e);return s==="&"?r:((s.includes("data-")||s.includes("."))&&(s=`*:where(${s.replace(/\s*&$/,"")}) &`),{[s]:r})}return o.palette.mode===e?r:{}}function na(e={},...r){const{breakpoints:o={},palette:i={},spacing:s,shape:a={},...l}=e,c=wc(o),u=oa(s);let x=bt({breakpoints:c,direction:"ltr",components:{},palette:{mode:"light",...i},spacing:u,shape:{...Tc,...a}},l);return x=kc(x),x.applyStyles=md,x=r.reduce((g,y)=>bt(g,y),x),x.unstable_sxConfig={...Bn,...l==null?void 0:l.unstable_sxConfig},x.unstable_sx=function(y){return En({sx:y,theme:this})},x}function xd(e){return Object.keys(e).length===0}function gd(e=null){const r=mn.useContext(Oa.ThemeContext);return!r||xd(r)?e:r}const yd=na();function bd(e=yd){return gd(e)}const fs=e=>e,vd=()=>{let e=fs;return{configure(r){e=r},generate(r){return e(r)},reset(){e=fs}}},Sd=vd(),wd={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 Cd(e,r,o="Mui"){const i=wd[r];return i?`${o}-${i}`:`${Sd.generate(e)}-${r}`}function jd(e,r=Number.MIN_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER){return Math.max(r,Math.min(e,o))}function Di(e,r=0,o=1){return process.env.NODE_ENV!=="production"&&(e<r||e>o)&&console.error(`MUI: The value provided ${e} is out of range [${r}, ${o}].`),jd(e,r,o)}function kd(e){e=e.slice(1);const r=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let o=e.match(r);return o&&o[0].length===1&&(o=o.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.`),o?`rgb${o.length===4?"a":""}(${o.map((i,s)=>s<3?parseInt(i,16):Math.round(parseInt(i,16)/255*1e3)/1e3).join(", ")})`:""}function yr(e){if(e.type)return e;if(e.charAt(0)==="#")return yr(kd(e));const r=e.indexOf("("),o=e.substring(0,r);if(!["rgb","rgba","hsl","hsla","color"].includes(o))throw new Error(process.env.NODE_ENV!=="production"?`MUI: Unsupported \`${e}\` color.
145
+ The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().`:Ar(9,e));let i=e.substring(r+1,e.length-1),s;if(o==="color"){if(i=i.split(" "),s=i.shift(),i.length===4&&i[3].charAt(0)==="/"&&(i[3]=i[3].slice(1)),!["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].includes(s))throw new Error(process.env.NODE_ENV!=="production"?`MUI: unsupported \`${s}\` color space.
146
+ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.`:Ar(10,s))}else i=i.split(",");return i=i.map(a=>parseFloat(a)),{type:o,values:i,colorSpace:s}}const Td=e=>{const r=yr(e);return r.values.slice(0,3).map((o,i)=>r.type.includes("hsl")&&i!==0?`${o}%`:o).join(" ")},Bo=(e,r)=>{try{return Td(e)}catch{return r&&process.env.NODE_ENV!=="production"&&console.warn(r),e}};function _n(e){const{type:r,colorSpace:o}=e;let{values:i}=e;return r.includes("rgb")?i=i.map((s,a)=>a<3?parseInt(s,10):s):r.includes("hsl")&&(i[1]=`${i[1]}%`,i[2]=`${i[2]}%`),r.includes("color")?i=`${o} ${i.join(" ")}`:i=`${i.join(", ")}`,`${r}(${i})`}function ia(e){e=yr(e);const{values:r}=e,o=r[0],i=r[1]/100,s=r[2]/100,a=i*Math.min(s,1-s),l=(x,g=(x+o/30)%12)=>s-a*Math.max(Math.min(g-3,9-g,1),-1);let c="rgb";const u=[Math.round(l(0)*255),Math.round(l(8)*255),Math.round(l(4)*255)];return e.type==="hsla"&&(c+="a",u.push(r[3])),_n({type:c,values:u})}function mi(e){e=yr(e);let r=e.type==="hsl"||e.type==="hsla"?yr(ia(e)).values:e.values;return r=r.map(o=>(e.type!=="color"&&(o/=255),o<=.03928?o/12.92:((o+.055)/1.055)**2.4)),Number((.2126*r[0]+.7152*r[1]+.0722*r[2]).toFixed(3))}function hs(e,r){const o=mi(e),i=mi(r);return(Math.max(o,i)+.05)/(Math.min(o,i)+.05)}function M(e,r){return e=yr(e),r=Di(r),(e.type==="rgb"||e.type==="hsl")&&(e.type+="a"),e.type==="color"?e.values[3]=`/${r}`:e.values[3]=r,_n(e)}function Or(e,r,o){try{return M(e,r)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),e}}function $n(e,r){if(e=yr(e),r=Di(r),e.type.includes("hsl"))e.values[2]*=1-r;else if(e.type.includes("rgb")||e.type.includes("color"))for(let o=0;o<3;o+=1)e.values[o]*=1-r;return _n(e)}function _e(e,r,o){try{return $n(e,r)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),e}}function In(e,r){if(e=yr(e),r=Di(r),e.type.includes("hsl"))e.values[2]+=(100-e.values[2])*r;else if(e.type.includes("rgb"))for(let o=0;o<3;o+=1)e.values[o]+=(255-e.values[o])*r;else if(e.type.includes("color"))for(let o=0;o<3;o+=1)e.values[o]+=(1-e.values[o])*r;return _n(e)}function $e(e,r,o){try{return In(e,r)}catch{return o&&process.env.NODE_ENV!=="production"&&console.warn(o),e}}function zd(e,r=.15){return mi(e)>.5?$n(e,r):In(e,r)}function tn(e,r,o){try{return zd(e,r)}catch{return e}}function Bd(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 ms=(e,r,o,i=[])=>{let s=e;r.forEach((a,l)=>{l===r.length-1?Array.isArray(s)?s[Number(a)]=o:s&&typeof s=="object"&&(s[a]=o):s&&typeof s=="object"&&(s[a]||(s[a]=i.includes(a)?[]:{}),s=s[a])})},Ed=(e,r,o)=>{function i(s,a=[],l=[]){Object.entries(s).forEach(([c,u])=>{(!o||o&&!o([...a,c]))&&u!=null&&(typeof u=="object"&&Object.keys(u).length>0?i(u,[...a,c],Array.isArray(u)?[...l,c]:l):r([...a,c],u,l))})}i(e)},_d=(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 li(e,r){const{prefix:o,shouldSkipGeneratingVar:i}=r||{},s={},a={},l={};return Ed(e,(c,u,x)=>{if((typeof u=="string"||typeof u=="number")&&(!i||!i(c,u))){const g=`--${o?`${o}-`:""}${c.join("-")}`,y=_d(c,u);Object.assign(s,{[g]:y}),ms(a,c,`var(${g})`,x),ms(l,c,`var(${g}, ${y})`,x)}},c=>c[0]==="vars"),{css:s,vars:a,varsWithDefaults:l}}function $d(e,r={}){const{getSelector:o=B,disableCssColorScheme:i,colorSchemeSelector:s,enableContrastVars:a}=r,{colorSchemes:l={},components:c,defaultColorScheme:u="light",...x}=e,{vars:g,css:y,varsWithDefaults:S}=li(x,r);let b=S;const T={},{[u]:m,...f}=l;if(Object.entries(f||{}).forEach(([z,h])=>{const{vars:I,css:A,varsWithDefaults:$}=li(h,r);b=bt(b,$),T[z]={css:A,vars:I}}),m){const{css:z,vars:h,varsWithDefaults:I}=li(m,r);b=bt(b,I),T[u]={css:z,vars:h}}function B(z,h){var A,$;let I=s;if(s==="class"&&(I=".%s"),s==="data"&&(I="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(I=`[${s}="%s"]`),z){if(I==="media")return e.defaultColorScheme===z?":root":{[`@media (prefers-color-scheme: ${(($=(A=l[z])==null?void 0:A.palette)==null?void 0:$.mode)||z})`]:{":root":h}};if(I)return e.defaultColorScheme===z?`:root, ${I.replace("%s",String(z))}`:I.replace("%s",String(z))}return":root"}return{vars:b,generateThemeVars:()=>{let z={...g};return Object.entries(T).forEach(([,{vars:h}])=>{z=bt(z,h)}),z},generateStyleSheets:()=>{var Y,X;const z=[],h=e.defaultColorScheme||"light";function I(R,v){Object.keys(v).length&&z.push(typeof R=="string"?{[R]:{...v}}:R)}I(o(void 0,{...y}),y);const{[h]:A,...$}=T;if(A){const{css:R}=A,v=(X=(Y=l[h])==null?void 0:Y.palette)==null?void 0:X.mode,W=!i&&v?{colorScheme:v,...R}:{...R};I(o(h,{...W}),W)}return Object.entries($).forEach(([R,{css:v}])=>{var q,re;const W=(re=(q=l[R])==null?void 0:q.palette)==null?void 0:re.mode,k=!i&&W?{colorScheme:W,...v}:{...v};I(o(R,{...k}),k)}),a&&z.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)"}}),z}}}function Id(e){return function(o){return e==="media"?(process.env.NODE_ENV!=="production"&&o!=="light"&&o!=="dark"&&console.error(`MUI: @media (prefers-color-scheme) supports only 'light' or 'dark', but receive '${o}'.`),`@media (prefers-color-scheme: ${o})`):e?e.startsWith("data-")&&!e.includes("%s")?`[${e}="${o}"] &`:e==="class"?`.${o} &`:e==="data"?`[data-${o}] &`:`${e.replace("%s",o)} &`:"&"}}const Mo={black:"#000",white:"#fff"},Dd={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"},oo={50:"#f3e5f5",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",700:"#7b1fa2"},no={300:"#e57373",400:"#ef5350",500:"#f44336",700:"#d32f2f",800:"#c62828"},ko={300:"#ffb74d",400:"#ffa726",500:"#ff9800",700:"#f57c00",900:"#e65100"},io={50:"#e3f2fd",200:"#90caf9",400:"#42a5f5",700:"#1976d2",800:"#1565c0"},so={300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",700:"#0288d1",900:"#01579b"},ao={300:"#81c784",400:"#66bb6a",500:"#4caf50",700:"#388e3c",800:"#2e7d32",900:"#1b5e20"};function sa(){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:Mo.white,default:Mo.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 aa=sa();function la(){return{text:{primary:Mo.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:Mo.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 xi=la();function xs(e,r,o,i){const s=i.light||i,a=i.dark||i*1.5;e[r]||(e.hasOwnProperty(o)?e[r]=e[o]:r==="light"?e.light=In(e.main,s):r==="dark"&&(e.dark=$n(e.main,a)))}function gs(e,r,o,i,s){const a=s.light||s,l=s.dark||s*1.5;r[o]||(r.hasOwnProperty(i)?r[o]=r[i]:o==="light"?r.light=`color-mix(in ${e}, ${r.main}, #fff ${(a*100).toFixed(0)}%)`:o==="dark"&&(r.dark=`color-mix(in ${e}, ${r.main}, #000 ${(l*100).toFixed(0)}%)`))}function Od(e="light"){return e==="dark"?{main:io[200],light:io[50],dark:io[400]}:{main:io[700],light:io[400],dark:io[800]}}function Md(e="light"){return e==="dark"?{main:oo[200],light:oo[50],dark:oo[400]}:{main:oo[500],light:oo[300],dark:oo[700]}}function Ad(e="light"){return e==="dark"?{main:no[500],light:no[300],dark:no[700]}:{main:no[700],light:no[400],dark:no[800]}}function Rd(e="light"){return e==="dark"?{main:so[400],light:so[300],dark:so[700]}:{main:so[700],light:so[500],dark:so[900]}}function Wd(e="light"){return e==="dark"?{main:ao[400],light:ao[300],dark:ao[700]}:{main:ao[800],light:ao[500],dark:ao[900]}}function Pd(e="light"){return e==="dark"?{main:ko[400],light:ko[300],dark:ko[700]}:{main:"#ed6c02",light:ko[500],dark:ko[900]}}function Ld(e){return`oklch(from ${e} var(--__l) 0 h / var(--__a))`}function Oi(e){const{mode:r="light",contrastThreshold:o=3,tonalOffset:i=.2,colorSpace:s,...a}=e,l=e.primary||Od(r),c=e.secondary||Md(r),u=e.error||Ad(r),x=e.info||Rd(r),g=e.success||Wd(r),y=e.warning||Pd(r);function S(f){if(s)return Ld(f);const B=hs(f,xi.text.primary)>=o?xi.text.primary:aa.text.primary;if(process.env.NODE_ENV!=="production"){const j=hs(f,B);j<3&&console.error([`MUI: The contrast ratio of ${j}:1 for ${B} on ${f}`,"falls below the WCAG recommended absolute minimum contrast ratio of 3:1.","https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast"].join(`
147
+ `))}return B}const b=({color:f,name:B,mainShade:j=500,lightShade:D=300,darkShade:z=700})=>{if(f={...f},!f.main&&f[j]&&(f.main=f[j]),!f.hasOwnProperty("main"))throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${B?` (${B})`:""} provided to augmentColor(color) is invalid.
148
+ The color object needs to have a \`main\` property or a \`${j}\` property.`:Ar(11,B?` (${B})`:"",j));if(typeof f.main!="string")throw new Error(process.env.NODE_ENV!=="production"?`MUI: The color${B?` (${B})`:""} provided to augmentColor(color) is invalid.
149
+ \`color.main\` should be a string, but \`${JSON.stringify(f.main)}\` was provided instead.
150
150
 
151
151
  Did you intend to use one of the following approaches?
152
152
 
@@ -158,17 +158,17 @@ const theme1 = createTheme({ palette: {
158
158
 
159
159
  const theme2 = createTheme({ palette: {
160
160
  primary: { main: green[500] },
161
- } });`:Mr(12,E?` (${E})`:"",JSON.stringify(m.main)));return s?(ms(s,m,"light",T,i),ms(s,m,"dark",B,i)):(fs(m,"light",T,i),fs(m,"dark",B,i)),m.contrastText||(m.contrastText=w(m.main)),m};let z;return r==="light"?z=ta():r==="dark"&&(z=oa()),process.env.NODE_ENV!=="production"&&(z||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),yt({common:{...Ro},mode:r,primary:b({color:l,name:"primary"}),secondary:b({color:c,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:b({color:u,name:"error"}),warning:b({color:y,name:"warning"}),info:b({color:g,name:"info"}),success:b({color:x,name:"success"}),grey:Ed,contrastThreshold:o,getContrastText:w,augmentColor:b,tonalOffset:i,...z},a)}function Rd(e){const r={};return Object.entries(e).forEach(i=>{const[s,a]=i;typeof a=="object"&&(r[s]=`${a.fontStyle?`${a.fontStyle} `:""}${a.fontVariant?`${a.fontVariant} `:""}${a.fontWeight?`${a.fontWeight} `:""}${a.fontStretch?`${a.fontStretch} `:""}${a.fontSize||""}${a.lineHeight?`/${a.lineHeight} `:""}${a.fontFamily||""}`)}),r}function Wd(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 hs={textTransform:"uppercase"},xs='"Roboto", "Helvetica", "Arial", sans-serif';function Ld(e,r){const{fontFamily:o=xs,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:l=500,fontWeightBold:c=700,htmlFontSize:u=16,allVariants:g,pxToRem:x,...y}=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 w=i/14,b=x||(m=>`${m/u*w}rem`),z=(m,E,v,T,B)=>({fontFamily:o,fontWeight:m,fontSize:b(E),lineHeight:v,...o===xs?{letterSpacing:`${Pd(T/E)}em`}:{},...B,...g}),h={h1:z(s,96,1.167,-1.5),h2:z(s,60,1.2,-.5),h3:z(a,48,1.167,0),h4:z(a,34,1.235,.25),h5:z(a,24,1.334,0),h6:z(l,20,1.6,.15),subtitle1:z(a,16,1.75,.15),subtitle2:z(l,14,1.57,.1),body1:z(a,16,1.5,.15),body2:z(a,14,1.43,.15),button:z(l,14,1.75,.4,hs),caption:z(a,12,1.66,.4),overline:z(a,12,2.66,1,hs),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return yt({htmlFontSize:u,pxToRem:b,fontFamily:o,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:l,fontWeightBold:c,...h},y,{clone:!1})}const Fd=.2,Nd=.14,Vd=.12;function Re(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${Fd})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Nd})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Vd})`].join(",")}const Hd=["none",Re(0,2,1,-1,0,1,1,0,0,1,3,0),Re(0,3,1,-2,0,2,2,0,0,1,5,0),Re(0,3,3,-2,0,3,4,0,0,1,8,0),Re(0,2,4,-1,0,4,5,0,0,1,10,0),Re(0,3,5,-1,0,5,8,0,0,1,14,0),Re(0,3,5,-1,0,6,10,0,0,1,18,0),Re(0,4,5,-2,0,7,10,1,0,2,16,1),Re(0,5,5,-3,0,8,10,1,0,3,14,2),Re(0,5,6,-3,0,9,12,1,0,3,16,2),Re(0,6,6,-3,0,10,14,1,0,4,18,3),Re(0,6,7,-4,0,11,15,1,0,4,20,3),Re(0,7,8,-4,0,12,17,2,0,5,22,4),Re(0,7,8,-4,0,13,19,2,0,5,24,4),Re(0,7,9,-4,0,14,21,2,0,5,26,4),Re(0,8,9,-5,0,15,22,2,0,6,28,5),Re(0,8,10,-5,0,16,24,2,0,6,30,5),Re(0,8,11,-5,0,17,26,2,0,6,32,5),Re(0,9,11,-5,0,18,28,2,0,7,34,6),Re(0,9,12,-6,0,19,29,2,0,7,36,6),Re(0,10,13,-6,0,20,31,3,0,8,38,7),Re(0,10,13,-6,0,21,33,3,0,8,40,7),Re(0,10,14,-6,0,22,35,3,0,8,42,7),Re(0,11,14,-7,0,23,36,3,0,9,44,8),Re(0,11,15,-7,0,24,38,3,0,9,46,8)],Gd={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)"},Ud={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function gs(e){return`${Math.round(e)}ms`}function Yd(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function qd(e){const r={...Gd,...e.easing},o={...Ud,...e.duration};return{getAutoHeightDuration:Yd,create:(s=["all"],a={})=>{const{duration:l=o.standard,easing:c=r.easeInOut,delay:u=0,...g}=a;if(process.env.NODE_ENV!=="production"){const x=w=>typeof w=="string",y=w=>!Number.isNaN(parseFloat(w));!x(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!y(l)&&!x(l)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${l}.`),x(c)||console.error('MUI: Argument "easing" must be a string.'),!y(u)&&!x(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof a!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
162
- `)),Object.keys(g).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(g).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(x=>`${x} ${typeof l=="string"?l:gs(l)} ${c} ${typeof u=="string"?u:gs(u)}`).join(",")},...e,easing:r,duration:o}}const Jd={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function Kd(e){return br(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function na(e={}){const r={...e};function o(i){const s=Object.entries(i);for(let a=0;a<s.length;a++){const[l,c]=s[a];!Kd(c)||l.startsWith("unstable_")?delete i[l]:br(c)&&(i[l]={...c},o(i[l]))}}return o(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
161
+ } });`:Ar(12,B?` (${B})`:"",JSON.stringify(f.main)));return s?(gs(s,f,"light",D,i),gs(s,f,"dark",z,i)):(xs(f,"light",D,i),xs(f,"dark",z,i)),f.contrastText||(f.contrastText=S(f.main)),f};let T;return r==="light"?T=sa():r==="dark"&&(T=la()),process.env.NODE_ENV!=="production"&&(T||console.error(`MUI: The palette mode \`${r}\` is not supported.`)),bt({common:{...Mo},mode:r,primary:b({color:l,name:"primary"}),secondary:b({color:c,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:b({color:u,name:"error"}),warning:b({color:y,name:"warning"}),info:b({color:x,name:"info"}),success:b({color:g,name:"success"}),grey:Dd,contrastThreshold:o,getContrastText:S,augmentColor:b,tonalOffset:i,...T},a)}function Fd(e){const r={};return Object.entries(e).forEach(i=>{const[s,a]=i;typeof a=="object"&&(r[s]=`${a.fontStyle?`${a.fontStyle} `:""}${a.fontVariant?`${a.fontVariant} `:""}${a.fontWeight?`${a.fontWeight} `:""}${a.fontStretch?`${a.fontStretch} `:""}${a.fontSize||""}${a.lineHeight?`/${a.lineHeight} `:""}${a.fontFamily||""}`)}),r}function Nd(e,r){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...r}}function Vd(e){return Math.round(e*1e5)/1e5}const ys={textTransform:"uppercase"},bs='"Roboto", "Helvetica", "Arial", sans-serif';function Hd(e,r){const{fontFamily:o=bs,fontSize:i=14,fontWeightLight:s=300,fontWeightRegular:a=400,fontWeightMedium:l=500,fontWeightBold:c=700,htmlFontSize:u=16,allVariants:x,pxToRem:g,...y}=typeof r=="function"?r(e):r;process.env.NODE_ENV!=="production"&&(typeof i!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof u!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const S=i/14,b=g||(f=>`${f/u*S}rem`),T=(f,B,j,D,z)=>({fontFamily:o,fontWeight:f,fontSize:b(B),lineHeight:j,...o===bs?{letterSpacing:`${Vd(D/B)}em`}:{},...z,...x}),m={h1:T(s,96,1.167,-1.5),h2:T(s,60,1.2,-.5),h3:T(a,48,1.167,0),h4:T(a,34,1.235,.25),h5:T(a,24,1.334,0),h6:T(l,20,1.6,.15),subtitle1:T(a,16,1.75,.15),subtitle2:T(l,14,1.57,.1),body1:T(a,16,1.5,.15),body2:T(a,14,1.43,.15),button:T(l,14,1.75,.4,ys),caption:T(a,12,1.66,.4),overline:T(a,12,2.66,1,ys),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return bt({htmlFontSize:u,pxToRem:b,fontFamily:o,fontSize:i,fontWeightLight:s,fontWeightRegular:a,fontWeightMedium:l,fontWeightBold:c,...m},y,{clone:!1})}const Gd=.2,Ud=.14,Yd=.12;function Re(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${Gd})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${Ud})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${Yd})`].join(",")}const qd=["none",Re(0,2,1,-1,0,1,1,0,0,1,3,0),Re(0,3,1,-2,0,2,2,0,0,1,5,0),Re(0,3,3,-2,0,3,4,0,0,1,8,0),Re(0,2,4,-1,0,4,5,0,0,1,10,0),Re(0,3,5,-1,0,5,8,0,0,1,14,0),Re(0,3,5,-1,0,6,10,0,0,1,18,0),Re(0,4,5,-2,0,7,10,1,0,2,16,1),Re(0,5,5,-3,0,8,10,1,0,3,14,2),Re(0,5,6,-3,0,9,12,1,0,3,16,2),Re(0,6,6,-3,0,10,14,1,0,4,18,3),Re(0,6,7,-4,0,11,15,1,0,4,20,3),Re(0,7,8,-4,0,12,17,2,0,5,22,4),Re(0,7,8,-4,0,13,19,2,0,5,24,4),Re(0,7,9,-4,0,14,21,2,0,5,26,4),Re(0,8,9,-5,0,15,22,2,0,6,28,5),Re(0,8,10,-5,0,16,24,2,0,6,30,5),Re(0,8,11,-5,0,17,26,2,0,6,32,5),Re(0,9,11,-5,0,18,28,2,0,7,34,6),Re(0,9,12,-6,0,19,29,2,0,7,36,6),Re(0,10,13,-6,0,20,31,3,0,8,38,7),Re(0,10,13,-6,0,21,33,3,0,8,40,7),Re(0,10,14,-6,0,22,35,3,0,8,42,7),Re(0,11,14,-7,0,23,36,3,0,9,44,8),Re(0,11,15,-7,0,24,38,3,0,9,46,8)],Jd={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)"},Kd={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function vs(e){return`${Math.round(e)}ms`}function Xd(e){if(!e)return 0;const r=e/36;return Math.min(Math.round((4+15*r**.25+r/5)*10),3e3)}function Qd(e){const r={...Jd,...e.easing},o={...Kd,...e.duration};return{getAutoHeightDuration:Xd,create:(s=["all"],a={})=>{const{duration:l=o.standard,easing:c=r.easeInOut,delay:u=0,...x}=a;if(process.env.NODE_ENV!=="production"){const g=S=>typeof S=="string",y=S=>!Number.isNaN(parseFloat(S));!g(s)&&!Array.isArray(s)&&console.error('MUI: Argument "props" must be a string or Array.'),!y(l)&&!g(l)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${l}.`),g(c)||console.error('MUI: Argument "easing" must be a string.'),!y(u)&&!g(u)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof a!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
162
+ `)),Object.keys(x).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(x).join(",")}].`)}return(Array.isArray(s)?s:[s]).map(g=>`${g} ${typeof l=="string"?l:vs(l)} ${c} ${typeof u=="string"?u:vs(u)}`).join(",")},...e,easing:r,duration:o}}const Zd={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function eu(e){return xr(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function ca(e={}){const r={...e};function o(i){const s=Object.entries(i);for(let a=0;a<s.length;a++){const[l,c]=s[a];!eu(c)||l.startsWith("unstable_")?delete i[l]:xr(c)&&(i[l]={...c},o(i[l]))}}return o(r),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
163
163
 
164
164
  const theme = ${JSON.stringify(r,null,2)};
165
165
 
166
166
  theme.breakpoints = createBreakpoints(theme.breakpoints || {});
167
167
  theme.transitions = createTransitions(theme.transitions || {});
168
168
 
169
- export default theme;`}function ys(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const Xd=e=>{if(!Number.isNaN(+e))return+e;const r=e.match(/\d*\.?\d+/g);if(!r)return 0;let o=0;for(let i=0;i<r.length;i+=1)o+=+r[i];return o};function Qd(e){Object.assign(e,{alpha(r,o){const i=this||e;return i.colorSpace?`oklch(from ${r} l c h / ${typeof o=="string"?`calc(${o})`:o})`:i.vars?`rgba(${r.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof o=="string"?`calc(${o})`:o})`:M(r,Xd(o))},lighten(r,o){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${ys(o)})`:On(r,o)},darken(r,o){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${ys(o)})`:In(r,o)}})}function hi(e={},...r){const{breakpoints:o,mixins:i={},spacing:s,palette:a={},transitions:l={},typography:c={},shape:u,colorSpace:g,...x}=e;if(e.vars&&e.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://v7.mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":Mr(20));const y=Di({...a,colorSpace:g}),w=Zs(e);let b=yt(w,{mixins:Wd(w.breakpoints,i),palette:y,shadows:Hd.slice(),typography:Ld(y,c),transitions:qd(l),zIndex:{...Jd}});if(b=yt(b,x),b=r.reduce((z,h)=>yt(z,h),b),process.env.NODE_ENV!=="production"){const z=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],h=(m,E)=>{let v;for(v in m){const T=m[v];if(z.includes(v)&&Object.keys(T).length>0){if(process.env.NODE_ENV!=="production"){const B=bd("",v);console.error([`MUI: The \`${E}\` component increases the CSS specificity of the \`${v}\` 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}`]:T}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
170
- `))}m[v]={}}}};Object.keys(b.components).forEach(m=>{const E=b.components[m].styleOverrides;E&&m.startsWith("Mui")&&h(E,m)})}return b.unstable_sxConfig={..._n,...x==null?void 0:x.unstable_sxConfig},b.unstable_sx=function(h){return $n({sx:h,theme:this})},b.toRuntimeSource=na,Qd(b),b}function Zd(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 eu=[...Array(25)].map((e,r)=>{if(r===0)return"none";const o=Zd(r);return`linear-gradient(rgba(255 255 255 / ${o}), rgba(255 255 255 / ${o}))`});function ia(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function sa(e){return e==="dark"?eu:[]}function tu(e){const{palette:r={mode:"light"},opacity:o,overlays:i,colorSpace:s,...a}=e,l=Di({...r,colorSpace:s});return{palette:l,opacity:{...ia(l.mode),...o},overlays:i||sa(l.mode),...a}}function ru(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 ou=e=>[...[...Array(25)].map((r,o)=>`--${e?`${e}-`:""}overlays-${o}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],nu=e=>(r,o)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const l={};return ou(e.cssVarPrefix).forEach(c=>{l[c]=o[c],delete o[c]}),a==="media"?{[i]:o,"@media (prefers-color-scheme: dark)":{[i]:l}}:a?{[a.replace("%s",r)]:l,[`${i}, ${a.replace("%s",r)}`]:o}:{[i]:{...o,...l}}}if(a&&a!=="media")return`${i}, ${a.replace("%s",String(r))}`}else if(r){if(a==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:o}};if(a)return a.replace("%s",String(r))}return i};function iu(e,r){r.forEach(o=>{e[o]||(e[o]={})})}function V(e,r,o){!e[r]&&o&&(e[r]=o)}function $o(e){return typeof e!="string"||!e.startsWith("hsl")?e:ea(e)}function ar(e,r){`${r}Channel`in e||(e[`${r}Channel`]=_o($o(e[r]),`MUI: Can't create \`palette.${r}Channel\` because \`palette.${r}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
171
- To suppress this warning, you need to explicitly provide the \`palette.${r}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function su(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const qt=e=>{try{return e()}catch{}},au=(e="mui")=>jd(e);function li(e,r,o,i,s){if(!o)return;o=o===!0?{}:o;const a=s==="dark"?"dark":"light";if(!i){r[s]=tu({...o,palette:{mode:a,...o==null?void 0:o.palette},colorSpace:e});return}const{palette:l,...c}=hi({...i,palette:{mode:a,...o==null?void 0:o.palette},colorSpace:e});return r[s]={...o,palette:l,opacity:{...ia(a),...o==null?void 0:o.opacity},overlays:(o==null?void 0:o.overlays)||sa(a)},c}function lu(e={},...r){const{colorSchemes:o={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:l=!1,shouldSkipGeneratingVar:c=ru,colorSchemeSelector:u=o.light&&o.dark?"media":void 0,rootSelector:g=":root",...x}=e,y=Object.keys(o)[0],w=i||(o.light&&y!=="light"?"light":y),b=au(a),{[w]:z,light:h,dark:m,...E}=o,v={...E};let T=z;if((w==="dark"&&!("dark"in o)||w==="light"&&!("light"in o))&&(T=!0),!T)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${w}\` option is either missing or invalid.`:Mr(21,w));let B;l&&(B="oklch");const f=li(B,v,T,x,w);h&&!v.light&&li(B,v,h,void 0,"light"),m&&!v.dark&&li(B,v,m,void 0,"dark");let $={defaultColorScheme:w,...f,cssVarPrefix:a,colorSchemeSelector:u,rootSelector:g,getCssVar:b,colorSchemes:v,font:{...Rd(f.typography),...f.font},spacing:su(x.spacing)};Object.keys($.colorSchemes).forEach(L=>{const S=$.colorSchemes[L].palette,A=Y=>{const oe=Y.split("-"),d=oe[1],Q=oe[2];return b(Y,S[d][Q])};S.mode==="light"&&(V(S.common,"background","#fff"),V(S.common,"onBackground","#000")),S.mode==="dark"&&(V(S.common,"background","#000"),V(S.common,"onBackground","#fff"));function k(Y,oe,d){if(B){let Q;return Y===Ir&&(Q=`transparent ${((1-d)*100).toFixed(0)}%`),Y===$e&&(Q=`#000 ${(d*100).toFixed(0)}%`),Y===De&&(Q=`#fff ${(d*100).toFixed(0)}%`),`color-mix(in ${B}, ${oe}, ${Q})`}return Y(oe,d)}if(iu(S,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),S.mode==="light"){V(S.Alert,"errorColor",k($e,l?b("palette-error-light"):S.error.light,.6)),V(S.Alert,"infoColor",k($e,l?b("palette-info-light"):S.info.light,.6)),V(S.Alert,"successColor",k($e,l?b("palette-success-light"):S.success.light,.6)),V(S.Alert,"warningColor",k($e,l?b("palette-warning-light"):S.warning.light,.6)),V(S.Alert,"errorFilledBg",A("palette-error-main")),V(S.Alert,"infoFilledBg",A("palette-info-main")),V(S.Alert,"successFilledBg",A("palette-success-main")),V(S.Alert,"warningFilledBg",A("palette-warning-main")),V(S.Alert,"errorFilledColor",qt(()=>S.getContrastText(S.error.main))),V(S.Alert,"infoFilledColor",qt(()=>S.getContrastText(S.info.main))),V(S.Alert,"successFilledColor",qt(()=>S.getContrastText(S.success.main))),V(S.Alert,"warningFilledColor",qt(()=>S.getContrastText(S.warning.main))),V(S.Alert,"errorStandardBg",k(De,l?b("palette-error-light"):S.error.light,.9)),V(S.Alert,"infoStandardBg",k(De,l?b("palette-info-light"):S.info.light,.9)),V(S.Alert,"successStandardBg",k(De,l?b("palette-success-light"):S.success.light,.9)),V(S.Alert,"warningStandardBg",k(De,l?b("palette-warning-light"):S.warning.light,.9)),V(S.Alert,"errorIconColor",A("palette-error-main")),V(S.Alert,"infoIconColor",A("palette-info-main")),V(S.Alert,"successIconColor",A("palette-success-main")),V(S.Alert,"warningIconColor",A("palette-warning-main")),V(S.AppBar,"defaultBg",A("palette-grey-100")),V(S.Avatar,"defaultBg",A("palette-grey-400")),V(S.Button,"inheritContainedBg",A("palette-grey-300")),V(S.Button,"inheritContainedHoverBg",A("palette-grey-A100")),V(S.Chip,"defaultBorder",A("palette-grey-400")),V(S.Chip,"defaultAvatarColor",A("palette-grey-700")),V(S.Chip,"defaultIconColor",A("palette-grey-700")),V(S.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),V(S.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),V(S.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),V(S.LinearProgress,"primaryBg",k(De,l?b("palette-primary-main"):S.primary.main,.62)),V(S.LinearProgress,"secondaryBg",k(De,l?b("palette-secondary-main"):S.secondary.main,.62)),V(S.LinearProgress,"errorBg",k(De,l?b("palette-error-main"):S.error.main,.62)),V(S.LinearProgress,"infoBg",k(De,l?b("palette-info-main"):S.info.main,.62)),V(S.LinearProgress,"successBg",k(De,l?b("palette-success-main"):S.success.main,.62)),V(S.LinearProgress,"warningBg",k(De,l?b("palette-warning-light"):S.warning.main,.62)),V(S.Skeleton,"bg",B?k(Ir,l?b("palette-text-primary"):S.text.primary,.11):`rgba(${A("palette-text-primaryChannel")} / 0.11)`),V(S.Slider,"primaryTrack",k(De,l?b("palette-primary-main"):S.primary.main,.62)),V(S.Slider,"secondaryTrack",k(De,l?b("palette-secondary-main"):S.secondary.main,.62)),V(S.Slider,"errorTrack",k(De,l?b("palette-error-main"):S.error.main,.62)),V(S.Slider,"infoTrack",k(De,l?b("palette-info-main"):S.info.main,.62)),V(S.Slider,"successTrack",k(De,l?b("palette-success-main"):S.success.main,.62)),V(S.Slider,"warningTrack",k(De,l?b("palette-warning-main"):S.warning.main,.62));const Y=B?k($e,l?b("palette-background-default"):S.background.default,.6825):on(S.background.default,.8);V(S.SnackbarContent,"bg",Y),V(S.SnackbarContent,"color",qt(()=>B?mi.text.primary:S.getContrastText(Y))),V(S.SpeedDialAction,"fabHoverBg",on(S.background.paper,.15)),V(S.StepConnector,"border",A("palette-grey-400")),V(S.StepContent,"border",A("palette-grey-400")),V(S.Switch,"defaultColor",A("palette-common-white")),V(S.Switch,"defaultDisabledColor",A("palette-grey-100")),V(S.Switch,"primaryDisabledColor",k(De,l?b("palette-primary-main"):S.primary.main,.62)),V(S.Switch,"secondaryDisabledColor",k(De,l?b("palette-secondary-main"):S.secondary.main,.62)),V(S.Switch,"errorDisabledColor",k(De,l?b("palette-error-main"):S.error.main,.62)),V(S.Switch,"infoDisabledColor",k(De,l?b("palette-info-main"):S.info.main,.62)),V(S.Switch,"successDisabledColor",k(De,l?b("palette-success-main"):S.success.main,.62)),V(S.Switch,"warningDisabledColor",k(De,l?b("palette-warning-main"):S.warning.main,.62)),V(S.TableCell,"border",k(De,Ir(l?b("palette-divider"):S.divider,1),.88)),V(S.Tooltip,"bg",k(Ir,l?b("palette-grey-700"):S.grey[700],.92))}if(S.mode==="dark"){V(S.Alert,"errorColor",k(De,l?b("palette-error-light"):S.error.light,.6)),V(S.Alert,"infoColor",k(De,l?b("palette-info-light"):S.info.light,.6)),V(S.Alert,"successColor",k(De,l?b("palette-success-light"):S.success.light,.6)),V(S.Alert,"warningColor",k(De,l?b("palette-warning-light"):S.warning.light,.6)),V(S.Alert,"errorFilledBg",A("palette-error-dark")),V(S.Alert,"infoFilledBg",A("palette-info-dark")),V(S.Alert,"successFilledBg",A("palette-success-dark")),V(S.Alert,"warningFilledBg",A("palette-warning-dark")),V(S.Alert,"errorFilledColor",qt(()=>S.getContrastText(S.error.dark))),V(S.Alert,"infoFilledColor",qt(()=>S.getContrastText(S.info.dark))),V(S.Alert,"successFilledColor",qt(()=>S.getContrastText(S.success.dark))),V(S.Alert,"warningFilledColor",qt(()=>S.getContrastText(S.warning.dark))),V(S.Alert,"errorStandardBg",k($e,l?b("palette-error-light"):S.error.light,.9)),V(S.Alert,"infoStandardBg",k($e,l?b("palette-info-light"):S.info.light,.9)),V(S.Alert,"successStandardBg",k($e,l?b("palette-success-light"):S.success.light,.9)),V(S.Alert,"warningStandardBg",k($e,l?b("palette-warning-light"):S.warning.light,.9)),V(S.Alert,"errorIconColor",A("palette-error-main")),V(S.Alert,"infoIconColor",A("palette-info-main")),V(S.Alert,"successIconColor",A("palette-success-main")),V(S.Alert,"warningIconColor",A("palette-warning-main")),V(S.AppBar,"defaultBg",A("palette-grey-900")),V(S.AppBar,"darkBg",A("palette-background-paper")),V(S.AppBar,"darkColor",A("palette-text-primary")),V(S.Avatar,"defaultBg",A("palette-grey-600")),V(S.Button,"inheritContainedBg",A("palette-grey-800")),V(S.Button,"inheritContainedHoverBg",A("palette-grey-700")),V(S.Chip,"defaultBorder",A("palette-grey-700")),V(S.Chip,"defaultAvatarColor",A("palette-grey-300")),V(S.Chip,"defaultIconColor",A("palette-grey-300")),V(S.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),V(S.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),V(S.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),V(S.LinearProgress,"primaryBg",k($e,l?b("palette-primary-main"):S.primary.main,.5)),V(S.LinearProgress,"secondaryBg",k($e,l?b("palette-secondary-main"):S.secondary.main,.5)),V(S.LinearProgress,"errorBg",k($e,l?b("palette-error-main"):S.error.main,.5)),V(S.LinearProgress,"infoBg",k($e,l?b("palette-info-main"):S.info.main,.5)),V(S.LinearProgress,"successBg",k($e,l?b("palette-success-main"):S.success.main,.5)),V(S.LinearProgress,"warningBg",k($e,l?b("palette-warning-main"):S.warning.main,.5)),V(S.Skeleton,"bg",B?k(Ir,l?b("palette-text-primary"):S.text.primary,.13):`rgba(${A("palette-text-primaryChannel")} / 0.13)`),V(S.Slider,"primaryTrack",k($e,l?b("palette-primary-main"):S.primary.main,.5)),V(S.Slider,"secondaryTrack",k($e,l?b("palette-secondary-main"):S.secondary.main,.5)),V(S.Slider,"errorTrack",k($e,l?b("palette-error-main"):S.error.main,.5)),V(S.Slider,"infoTrack",k($e,l?b("palette-info-main"):S.info.main,.5)),V(S.Slider,"successTrack",k($e,l?b("palette-success-main"):S.success.main,.5)),V(S.Slider,"warningTrack",k($e,l?b("palette-warning-light"):S.warning.main,.5));const Y=B?k(De,l?b("palette-background-default"):S.background.default,.985):on(S.background.default,.98);V(S.SnackbarContent,"bg",Y),V(S.SnackbarContent,"color",qt(()=>B?ra.text.primary:S.getContrastText(Y))),V(S.SpeedDialAction,"fabHoverBg",on(S.background.paper,.15)),V(S.StepConnector,"border",A("palette-grey-600")),V(S.StepContent,"border",A("palette-grey-600")),V(S.Switch,"defaultColor",A("palette-grey-300")),V(S.Switch,"defaultDisabledColor",A("palette-grey-600")),V(S.Switch,"primaryDisabledColor",k($e,l?b("palette-primary-main"):S.primary.main,.55)),V(S.Switch,"secondaryDisabledColor",k($e,l?b("palette-secondary-main"):S.secondary.main,.55)),V(S.Switch,"errorDisabledColor",k($e,l?b("palette-error-main"):S.error.main,.55)),V(S.Switch,"infoDisabledColor",k($e,l?b("palette-info-main"):S.info.main,.55)),V(S.Switch,"successDisabledColor",k($e,l?b("palette-success-main"):S.success.main,.55)),V(S.Switch,"warningDisabledColor",k($e,l?b("palette-warning-light"):S.warning.main,.55)),V(S.TableCell,"border",k($e,Ir(l?b("palette-divider"):S.divider,1),.68)),V(S.Tooltip,"bg",k(Ir,l?b("palette-grey-700"):S.grey[700],.92))}l||(ar(S.background,"default"),ar(S.background,"paper"),ar(S.common,"background"),ar(S.common,"onBackground"),ar(S,"divider")),Object.keys(S).forEach(Y=>{const oe=S[Y];Y!=="tonalOffset"&&!l&&oe&&typeof oe=="object"&&(oe.main&&V(S[Y],"mainChannel",_o($o(oe.main))),oe.light&&V(S[Y],"lightChannel",_o($o(oe.light))),oe.dark&&V(S[Y],"darkChannel",_o($o(oe.dark))),oe.contrastText&&V(S[Y],"contrastTextChannel",_o($o(oe.contrastText))),Y==="text"&&(ar(S[Y],"primary"),ar(S[Y],"secondary")),Y==="action"&&(oe.active&&ar(S[Y],"active"),oe.selected&&ar(S[Y],"selected")))})}),$=r.reduce((L,S)=>yt(L,S),$);const F={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:c,getSelector:nu($),enableContrastVars:l},{vars:O,generateThemeVars:J,generateStyleSheets:te}=zd($,F);return $.vars=O,Object.entries($.colorSchemes[$.defaultColorScheme]).forEach(([L,S])=>{$[L]=S}),$.generateThemeVars=J,$.generateStyleSheets=te,$.generateSpacing=function(){return Qs(x.spacing,Ei(this))},$.getColorSchemeSelector=Bd(u),$.spacing=$.generateSpacing(),$.shouldSkipGeneratingVar=c,$.unstable_sxConfig={..._n,...x==null?void 0:x.unstable_sxConfig},$.unstable_sx=function(S){return $n({sx:S,theme:this})},$.toRuntimeSource=na,$}function bs(e,r,o){e.colorSchemes&&o&&(e.colorSchemes[r]={...o!==!0&&o,palette:Di({...o===!0?{}:o.palette,mode:r})})}function cu(e={},...r){const{palette:o,cssVariables:i=!1,colorSchemes:s=o?void 0:{light:!0},defaultColorScheme:a=o==null?void 0:o.mode,...l}=e,c=a||"light",u=s==null?void 0:s[c],g={...s,...o?{[c]:{...typeof u!="boolean"&&u,palette:o}}:void 0};if(i===!1){if(!("colorSchemes"in e))return hi(e,...r);let x=o;"palette"in e||g[c]&&(g[c]!==!0?x=g[c].palette:c==="dark"&&(x={mode:"dark"}));const y=hi({...e,palette:x},...r);return y.defaultColorScheme=c,y.colorSchemes=g,y.palette.mode==="light"&&(y.colorSchemes.light={...g.light!==!0&&g.light,palette:y.palette},bs(y,"dark",g.dark)),y.palette.mode==="dark"&&(y.colorSchemes.dark={...g.dark!==!0&&g.dark,palette:y.palette},bs(y,"light",g.light)),y}return!o&&!("light"in g)&&c==="light"&&(g.light=!0),lu({...l,colorSchemes:g,defaultColorScheme:c,...typeof i!="boolean"&&i},...r)}const du=cu();function bt(){const e=hd(du);return process.env.NODE_ENV!=="production"&&gn.useDebugValue(e),e[nc]||e}function uu({onCreateReport:e,reports:r=[],activeReportId:o,onReportClick:i}){const s=r.find(a=>a.id===o);return t.jsx(n.Box,{component:"header",sx:a=>{var x,y,w;const l=((w=(y=(x=a.components)==null?void 0:x.MuiCardHeader)==null?void 0:y.styleOverrides)==null?void 0:w.root)||{},c=l.backgroundColor&&l.backgroundColor!=="transparent"?l.backgroundColor:a.palette.background.paper,u=l.borderBottom&&l.borderBottom!=="none"?l.borderBottom:"1px solid",g=l.boxShadow&&l.boxShadow!=="none"?l.boxShadow:void 0;return{position:"sticky",top:0,zIndex:50,borderBottom:u,borderColor:u!=="none"?"divider":void 0,boxShadow:g,bgcolor:c}},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[t.jsxs(n.Breadcrumbs,{separator:t.jsx(D.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[t.jsx(n.Typography,{variant:"h2",component:"h1",sx:{fontWeight:300,fontSize:a=>a.typography.h2.fontSize,color:"text.secondary",cursor:r.length>0&&s?"pointer":"default","&:hover":r.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{r.length>0},children:"Reports"}),s&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(D.Description,{sx:{fontSize:22,color:"primary.main"}}),t.jsx(n.Typography,{sx:{fontWeight:500,fontSize:a=>a.typography.h2.fontSize,color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),t.jsx(n.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:t.jsx(D.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),t.jsx(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(n.Tooltip,{title:"New Report",children:t.jsx(n.IconButton,{onClick:e,"aria-label":"New Report",sx:{width:38,height:38,borderRadius:"11px",color:"primary.contrastText",backgroundImage:a=>`linear-gradient(146.94deg, ${a.palette.primary.dark} 0%, ${a.palette.primary.main} 45%, ${a.palette.primary.light} 100%)`,boxShadow:a=>`0 6px 10px ${M(a.palette.primary.dark,.35)}, 0 2px 4px ${M(a.palette.primary.dark,.3)}`,"&:hover":{filter:"brightness(1.05)"}},children:t.jsx(D.Add,{sx:{fontSize:20}})})})})]})})}async function pu(e,r,o){try{new URL(e)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};r&&(i.Authorization=`Bearer ${r}`);const s=new AbortController,a=setTimeout(()=>s.abort(),3e4);let l;try{l=await fetch(e,{headers:i,signal:s.signal})}catch(g){throw clearTimeout(a),(g==null?void 0:g.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(a)}if(l.status===401)throw new Error("Authentication failed (401) — check your API key");if(l.status===429){const g=l.headers.get("Retry-After"),x=g&&/^\d+$/.test(g)?` — retry after ${g}s`:"";throw new Error(`Rate limit exceeded (429 Too Many Requests)${x}`)}if(!l.ok){const g=l.statusText?`: ${l.statusText}`:"";throw new Error(`API error ${l.status}${g}`)}let c;try{c=await l.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(c))u=c;else if(o&&c[o]&&Array.isArray(c[o]))u=c[o];else{const x=["data","results","items","records"].find(y=>c[y]&&Array.isArray(c[y]));if(x)u=c[x];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 aa(e,r){return r.map(o=>`${o.x}px ${o.y}px ${o.blur}px ${o.spread}px ${M(e.palette.common.black,o.opacity)}`).join(", ")}const la={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}],accentModal:[{x:0,y:40,blur:120,spread:0,opacity:.75}]};function ge(e,r){return aa(e,la[r])}function fu(e){return`${Number(e.shape.borderRadius)*1.5}px`}function Fo(e){return`${Number(e.shape.borderRadius)}px`}function vs(e){const r=e.tokens;return{containerPad:`${(r==null?void 0:r.containerPad)??16}px`,cardGap:`${(r==null?void 0:r.cardGap)??12}px`}}function nt(e){const r=e.tokens,o=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:o,bg:`var(--highlight-bg, ${M(o,.08)})`,hoverBg:`var(--highlight-hover, ${M(o,.12)})`}}function nn(e){const r=e.tokens;return{iconTileBg:(r==null?void 0:r.reportsAccentTileGradient)||e.palette.primary.main,surfaceBg:(r==null?void 0:r.gsModalBgDark)||e.palette.background.paper,innerHighlight:(r==null?void 0:r.reportsModalInnerHighlight)||"none",border:`1px solid ${M(e.palette.common.white,.2)}`,shadow:aa(e,la.accentModal)}}function Rt(e,r="menu"){const o=e.tokens;return{paper:{boxShadow:(o==null?void 0:o.cardBodyShadow)||ge(e,r),border:o!=null&&o.cardBodyBorder&&o.cardBodyBorder!=="none"?o.cardBodyBorder:"none"},header:{backgroundColor:(o==null?void 0:o.cardHdrBg)||"transparent",borderBottom:(o==null?void 0:o.cardHdrBorder)||"none",boxShadow:(o==null?void 0:o.cardHdrAccent)||"none"}}}function yr({content:e,isDev:r=!1}){const[o,i]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(n.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=>M(s.palette.primary.main,.08)}},children:t.jsx(D.InfoOutlined,{sx:{fontSize:15}})}),t.jsxs(n.Popover,{open:!!o,anchorEl:o,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(n.Box,{sx:{px:2,py:1.5,bgcolor:s=>M(s.palette.primary.main,.06)},children:t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||600,color:"primary.main",fontSize:s=>s.typography.body2.fontSize||"0.875rem"},children:e.title})}),t.jsx(n.Divider,{}),t.jsxs(n.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:s=>s.typography.body2.fontSize||"0.8125rem",lineHeight:1.6},children:e.description}),e.tips&&e.tips.length>0&&t.jsx(n.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:e.tips.map((s,a)=>t.jsx(n.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},a))}),r&&e.devNote&&t.jsxs(t.Fragment,{children:[t.jsx(n.Divider,{sx:{my:.5}}),t.jsxs(n.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>M(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>M(s.palette.warning.main,.2)},children:[t.jsx(n.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:s=>s.typography.caption.fontWeight||500,fontSize:s=>s.typography.caption.fontSize||"0.75rem",display:"block",mb:.25},children:"Dev note"}),t.jsx(n.Typography,{variant:"caption",sx:{color:"warning.dark",fontSize:s=>s.typography.caption.fontSize||"0.75rem",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}function it({open:e,onClose:r,icon:o,title:i,iconColor:s="primary",accentSurface:a,subtitle:l,helpContent:c,headerActions:u,headerExtra:g,width:x=520,maxHeight:y="90vh",children:w,footer:b,disableBackdropClose:z=!1,disableEscapeKeyDown:h=!1,classNames:m}){const E=bt(),v=a??E.palette.mode==="dark",T=s==="accent"||s==="primary"&&v,B=p.useRef(r);if(B.current=r,p.useEffect(()=>{if(!e||h)return;const $=F=>{F.key==="Escape"&&B.current()};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[e,h]),!e)return null;const f=$=>{$.target===$.currentTarget&&!z&&r()};return t.jsx(n.Box,{onMouseDown:f,className:m==null?void 0:m.backdrop,sx:{position:"fixed",inset:0,bgcolor:$=>M($.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:$=>$.zIndex.modal},children:t.jsxs(n.Paper,{className:m==null?void 0:m.paper,sx:{width:x,maxWidth:"calc(100vw - 48px)",maxHeight:y,display:"flex",flexDirection:"column",overflow:"hidden",borderRadius:$=>fu($),background:$=>v?nn($).surfaceBg:void 0,boxShadow:$=>{if(v){const F=nn($);return F.innerHighlight!=="none"?`${F.innerHighlight}, ${F.shadow}`:F.shadow}return Rt($).paper.boxShadow},border:$=>v?nn($).border:Rt($).paper.border},children:[!v&&t.jsx(n.Box,{sx:{height:3,flexShrink:0,bgcolor:"primary.main"}}),t.jsxs(n.Box,{className:m==null?void 0:m.header,sx:{flexShrink:0},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,px:3,pt:2.5,pb:g?1.5:2,bgcolor:$=>v?"transparent":Rt($).header.backgroundColor,borderBottom:$=>v?"none":Rt($).header.borderBottom,boxShadow:$=>v?"none":Rt($).header.boxShadow},children:[t.jsx(n.Box,{sx:{width:40,height:40,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"10px",...T?{background:$=>nn($).iconTileBg,color:"common.white"}:{bgcolor:`${s}.main`,color:`${s}.contrastText`}},children:o}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75,minWidth:0},children:[t.jsx(n.Typography,{variant:"h4",className:m==null?void 0:m.title,sx:{fontWeight:600,color:v?"common.white":void 0},noWrap:!0,children:i}),l&&t.jsx(n.Typography,{variant:"caption",color:v?void 0:"text.secondary",sx:{color:v?$=>M($.palette.common.white,.6):void 0},noWrap:!0,children:l}),c&&t.jsx(yr,{content:c,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(n.Box,{sx:{flex:1}}),u,t.jsx(n.IconButton,{onClick:r,size:"small","aria-label":"Close",className:m==null?void 0:m.closeButton,sx:{color:v?$=>M($.palette.common.white,.7):"text.secondary",flexShrink:0},children:t.jsx(D.Close,{sx:{fontSize:20}})})]}),g&&t.jsx(n.Box,{sx:{px:3},children:g})]}),t.jsx(n.Box,{className:m==null?void 0:m.body,sx:{flex:1,overflowY:"auto",px:3,pb:2},children:w}),b&&t.jsx(n.Box,{className:m==null?void 0:m.footer,sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,px:3,py:2,borderTop:1,borderColor:$=>v?M($.palette.common.white,.2):"divider",flexShrink:0},children:b})]})})}function mu({isOpen:e,onClose:r,onCreate:o,preloadedData:i,preloadedDataLabel:s}){const[a,l]=p.useState(""),[c,u]=p.useState(!1),[g,x]=p.useState(""),[y,w]=p.useState(null),[b,z]=p.useState(null),[h,m]=p.useState(!1),[E,v]=p.useState(""),T=p.useRef(null),[B,f]=p.useState("json"),[$,F]=p.useState(""),[O,J]=p.useState(""),[te,L]=p.useState(""),[S,A]=p.useState("idle"),[k,Y]=p.useState(""),[oe,d]=p.useState(null),[Q,ee]=p.useState(0),N=async W=>{if(v(""),!W.name.endsWith(".json")){v("Only .json files are allowed");return}const ie=10*1024*1024;if(W.size>ie){v("File size exceeds 10MB limit");return}try{const fe=await W.text();let pe;try{pe=JSON.parse(fe)}catch{v("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(pe)){v("JSON must be an array of objects");return}if(pe.length===0){v("No data rows found in JSON file");return}w(W),z(pe)}catch{v("Network error — please try again")}},re=W=>{W.preventDefault();const ie=W.dataTransfer.files[0];ie&&N(ie)},ue=async()=>{if($.trim()){A("loading"),Y("");try{const W=await pu($.trim(),O.trim()||void 0,te.trim()||void 0);d(W.data),ee(W.data.length),A("ready")}catch(W){Y((W==null?void 0:W.message)||"Connection failed"),A("error")}}},le=()=>{if(!a.trim()){u(!0);return}const W=B==="api"?oe:i||b;W&&(o(a.trim(),g.trim(),W),Z())},Z=()=>{l(""),u(!1),x(""),w(null),z(null),v(""),f("json"),F(""),J(""),L(""),A("idle"),Y(""),d(null),ee(0),r()},de=i||b,se=c&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsx(it,{open:e,onClose:Z,icon:t.jsx(D.Description,{sx:{fontSize:20}}),title:"Create new report",width:480,maxHeight:"min(720px, calc(100vh - 120px))",footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:Z,variant:"text",sx:{color:"primary.main",fontSize:"0.875rem",borderRadius:W=>`${W.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:W=>M(W.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(n.Button,{onClick:le,disabled:B==="json"&&!de||B==="api"&&S!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:W=>`${W.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,"&:disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Create"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[t.jsx(n.TextField,{label:"Report name",required:!0,fullWidth:!0,value:a,onChange:W=>{l(W.target.value),c&&W.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(n.TextField,{label:"Description (optional)",fullWidth:!0,multiline:!0,rows:2,value:g,onChange:W=>x(W.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(n.Tabs,{value:B==="json"?0:1,onChange:(W,ie)=>{f(ie===0?"json":"api"),A("idle"),Y("")},variant:"fullWidth",sx:{borderBottom:1,borderColor:"divider",minHeight:40,"& .MuiTabs-indicator":{height:3,bgcolor:"primary.main"}},children:[t.jsx(n.Tab,{label:"Upload JSON",icon:t.jsx(D.Description,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:W=>`var(--highlight-hover, ${M(W.palette.primary.main,.15)})`},"&:hover":{bgcolor:W=>`var(--highlight-hover, ${M(W.palette.primary.main,.08)})`}}}),t.jsx(n.Tab,{label:"Connect API",icon:t.jsx(D.Api,{fontSize:"small"}),iconPosition:"start",sx:{textTransform:"none",fontSize:"0.875rem",fontWeight:500,minHeight:40,py:.5,borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:W=>`var(--highlight-hover, ${M(W.palette.primary.main,.15)})`},"&:hover":{bgcolor:W=>`var(--highlight-hover, ${M(W.palette.primary.main,.08)})`}}})]}),B==="json"&&t.jsx(n.Box,{children:i?t.jsxs(n.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:W=>M(W.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(n.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:W=>M(W.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(D.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),t.jsx(n.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),t.jsx(n.IconButton,{size:"small",onClick:()=>m(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(D.Info,{sx:{fontSize:16}})})]}),t.jsxs(n.Box,{onDrop:re,onDragOver:W=>W.preventDefault(),onPaste:W=>W.preventDefault(),onClick:()=>{var W;return(W=T.current)==null?void 0:W.click()},sx:{position:"relative",border:"1.5px",borderStyle:b?"solid":"dashed",borderColor:b?"success.main":E?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:b?W=>M(W.palette.success.main,.04):E?W=>M(W.palette.error.main,.04):W=>M(W.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:b?W=>M(W.palette.success.main,.08):E?W=>M(W.palette.error.main,.08):W=>M(W.palette.primary.main,.08),borderColor:b?"success.dark":E?"error.dark":"primary.dark"}},children:[t.jsx(n.Box,{component:"input",ref:T,type:"file",accept:".json",sx:{display:"none"},onChange:W=>{var ie;return((ie=W.target.files)==null?void 0:ie[0])&&N(W.target.files[0])}}),b?t.jsxs(n.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(n.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:W=>M(W.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx(D.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:y==null?void 0:y.name}),t.jsx(n.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):t.jsxs(n.Box,{children:[t.jsx(n.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:W=>M(W.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx(D.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),t.jsx(n.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),t.jsx(n.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),E&&t.jsx(n.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:W=>M(W.palette.error.main,.08),border:1,borderColor:W=>M(W.palette.error.main,.2)},children:t.jsx(n.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:E})})]})]})]})}),B==="api"&&t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx(n.TextField,{label:"API Endpoint URL",required:!0,fullWidth:!0,size:"small",value:$,onChange:W=>{F(W.target.value),A("idle")},placeholder:"http://localhost:8000/api/reports/sales-pipeline/data/flat",sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(n.TextField,{label:"API Key (optional)",fullWidth:!0,size:"small",value:O,onChange:W=>J(W.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(n.InputAdornment,{position:"start",children:t.jsx(D.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(n.TextField,{label:"Response data path (optional)",fullWidth:!0,size:"small",value:te,onChange:W=>L(W.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(n.Button,{variant:"outlined",fullWidth:!0,disabled:!$.trim()||S==="loading",onClick:ue,startIcon:S==="loading"?t.jsx(n.CircularProgress,{size:16,color:"inherit"}):t.jsx(D.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:W=>M(W.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:S==="loading"?"Connecting...":"Test Connection & Load Data"}),S==="ready"&&t.jsxs(n.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:W=>M(W.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(D.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),t.jsxs(n.Box,{children:[t.jsxs(n.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[Q.toLocaleString()," records loaded — ready to create"]}),t.jsx(n.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:$})]})]}),S==="error"&&t.jsxs(n.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:W=>M(W.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(D.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),t.jsx(n.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:k})]})]})]})]})}),t.jsxs(n.Dialog,{open:h,onClose:()=>m(!1),maxWidth:"sm",PaperProps:{sx:W=>({borderRadius:3,width:560,maxHeight:"80vh",...Rt(W).paper})},children:[t.jsxs(n.DialogTitle,{sx:W=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:ie=>ie.typography.h4.fontWeight||500,fontSize:ie=>ie.typography.h4.fontSize||"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...Rt(W).header}),children:["JSON format guide",t.jsx(n.IconButton,{onClick:()=>m(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(D.Close,{sx:{fontSize:20}})})]}),t.jsx(n.DialogContent,{sx:{px:3,py:2},children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),t.jsx(n.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(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),t.jsx(n.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
169
+ export default theme;`}function Ss(e){return typeof e=="number"?`${(e*100).toFixed(0)}%`:`calc((${e}) * 100%)`}const tu=e=>{if(!Number.isNaN(+e))return+e;const r=e.match(/\d*\.?\d+/g);if(!r)return 0;let o=0;for(let i=0;i<r.length;i+=1)o+=+r[i];return o};function ru(e){Object.assign(e,{alpha(r,o){const i=this||e;return i.colorSpace?`oklch(from ${r} l c h / ${typeof o=="string"?`calc(${o})`:o})`:i.vars?`rgba(${r.replace(/var\(--([^,\s)]+)(?:,[^)]+)?\)+/g,"var(--$1Channel)")} / ${typeof o=="string"?`calc(${o})`:o})`:M(r,tu(o))},lighten(r,o){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #fff ${Ss(o)})`:In(r,o)},darken(r,o){const i=this||e;return i.colorSpace?`color-mix(in ${i.colorSpace}, ${r}, #000 ${Ss(o)})`:$n(r,o)}})}function gi(e={},...r){const{breakpoints:o,mixins:i={},spacing:s,palette:a={},transitions:l={},typography:c={},shape:u,colorSpace:x,...g}=e;if(e.vars&&e.generateThemeVars===void 0)throw new Error(process.env.NODE_ENV!=="production"?"MUI: `vars` is a private field used for CSS variables support.\nPlease use another name or follow the [docs](https://v7.mui.com/material-ui/customization/css-theme-variables/usage/) to enable the feature.":Ar(20));const y=Oi({...a,colorSpace:x}),S=na(e);let b=bt(S,{mixins:Nd(S.breakpoints,i),palette:y,shadows:qd.slice(),typography:Hd(y,c),transitions:Qd(l),zIndex:{...Zd}});if(b=bt(b,g),b=r.reduce((T,m)=>bt(T,m),b),process.env.NODE_ENV!=="production"){const T=["active","checked","completed","disabled","error","expanded","focused","focusVisible","required","selected"],m=(f,B)=>{let j;for(j in f){const D=f[j];if(T.includes(j)&&Object.keys(D).length>0){if(process.env.NODE_ENV!=="production"){const z=Cd("",j);console.error([`MUI: The \`${B}\` component increases the CSS specificity of the \`${j}\` internal state.`,"You can not override it like this: ",JSON.stringify(f,null,2),"",`Instead, you need to use the '&.${z}' syntax:`,JSON.stringify({root:{[`&.${z}`]:D}},null,2),"","https://mui.com/r/state-classes-guide"].join(`
170
+ `))}f[j]={}}}};Object.keys(b.components).forEach(f=>{const B=b.components[f].styleOverrides;B&&f.startsWith("Mui")&&m(B,f)})}return b.unstable_sxConfig={...Bn,...g==null?void 0:g.unstable_sxConfig},b.unstable_sx=function(m){return En({sx:m,theme:this})},b.toRuntimeSource=ca,ru(b),b}function ou(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 nu=[...Array(25)].map((e,r)=>{if(r===0)return"none";const o=ou(r);return`linear-gradient(rgba(255 255 255 / ${o}), rgba(255 255 255 / ${o}))`});function da(e){return{inputPlaceholder:e==="dark"?.5:.42,inputUnderline:e==="dark"?.7:.42,switchTrackDisabled:e==="dark"?.2:.12,switchTrack:e==="dark"?.3:.38}}function ua(e){return e==="dark"?nu:[]}function iu(e){const{palette:r={mode:"light"},opacity:o,overlays:i,colorSpace:s,...a}=e,l=Oi({...r,colorSpace:s});return{palette:l,opacity:{...da(l.mode),...o},overlays:i||ua(l.mode),...a}}function su(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 au=e=>[...[...Array(25)].map((r,o)=>`--${e?`${e}-`:""}overlays-${o}`),`--${e?`${e}-`:""}palette-AppBar-darkBg`,`--${e?`${e}-`:""}palette-AppBar-darkColor`],lu=e=>(r,o)=>{const i=e.rootSelector||":root",s=e.colorSchemeSelector;let a=s;if(s==="class"&&(a=".%s"),s==="data"&&(a="[data-%s]"),s!=null&&s.startsWith("data-")&&!s.includes("%s")&&(a=`[${s}="%s"]`),e.defaultColorScheme===r){if(r==="dark"){const l={};return au(e.cssVarPrefix).forEach(c=>{l[c]=o[c],delete o[c]}),a==="media"?{[i]:o,"@media (prefers-color-scheme: dark)":{[i]:l}}:a?{[a.replace("%s",r)]:l,[`${i}, ${a.replace("%s",r)}`]:o}:{[i]:{...o,...l}}}if(a&&a!=="media")return`${i}, ${a.replace("%s",String(r))}`}else if(r){if(a==="media")return{[`@media (prefers-color-scheme: ${String(r)})`]:{[i]:o}};if(a)return a.replace("%s",String(r))}return i};function cu(e,r){r.forEach(o=>{e[o]||(e[o]={})})}function G(e,r,o){!e[r]&&o&&(e[r]=o)}function Eo(e){return typeof e!="string"||!e.startsWith("hsl")?e:ia(e)}function ir(e,r){`${r}Channel`in e||(e[`${r}Channel`]=Bo(Eo(e[r]),`MUI: Can't create \`palette.${r}Channel\` because \`palette.${r}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
171
+ To suppress this warning, you need to explicitly provide the \`palette.${r}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function du(e){return typeof e=="number"?`${e}px`:typeof e=="string"||typeof e=="function"||Array.isArray(e)?e:"8px"}const Ut=e=>{try{return e()}catch{}},uu=(e="mui")=>Bd(e);function ci(e,r,o,i,s){if(!o)return;o=o===!0?{}:o;const a=s==="dark"?"dark":"light";if(!i){r[s]=iu({...o,palette:{mode:a,...o==null?void 0:o.palette},colorSpace:e});return}const{palette:l,...c}=gi({...i,palette:{mode:a,...o==null?void 0:o.palette},colorSpace:e});return r[s]={...o,palette:l,opacity:{...da(a),...o==null?void 0:o.opacity},overlays:(o==null?void 0:o.overlays)||ua(a)},c}function pu(e={},...r){const{colorSchemes:o={light:!0},defaultColorScheme:i,disableCssColorScheme:s=!1,cssVarPrefix:a="mui",nativeColor:l=!1,shouldSkipGeneratingVar:c=su,colorSchemeSelector:u=o.light&&o.dark?"media":void 0,rootSelector:x=":root",...g}=e,y=Object.keys(o)[0],S=i||(o.light&&y!=="light"?"light":y),b=uu(a),{[S]:T,light:m,dark:f,...B}=o,j={...B};let D=T;if((S==="dark"&&!("dark"in o)||S==="light"&&!("light"in o))&&(D=!0),!D)throw new Error(process.env.NODE_ENV!=="production"?`MUI: The \`colorSchemes.${S}\` option is either missing or invalid.`:Ar(21,S));let z;l&&(z="oklch");const h=ci(z,j,D,g,S);m&&!j.light&&ci(z,j,m,void 0,"light"),f&&!j.dark&&ci(z,j,f,void 0,"dark");let I={defaultColorScheme:S,...h,cssVarPrefix:a,colorSchemeSelector:u,rootSelector:x,getCssVar:b,colorSchemes:j,font:{...Fd(h.typography),...h.font},spacing:du(g.spacing)};Object.keys(I.colorSchemes).forEach(R=>{const v=I.colorSchemes[R].palette,W=q=>{const re=q.split("-"),d=re[1],Q=re[2];return b(q,v[d][Q])};v.mode==="light"&&(G(v.common,"background","#fff"),G(v.common,"onBackground","#000")),v.mode==="dark"&&(G(v.common,"background","#000"),G(v.common,"onBackground","#fff"));function k(q,re,d){if(z){let Q;return q===Or&&(Q=`transparent ${((1-d)*100).toFixed(0)}%`),q===_e&&(Q=`#000 ${(d*100).toFixed(0)}%`),q===$e&&(Q=`#fff ${(d*100).toFixed(0)}%`),`color-mix(in ${z}, ${re}, ${Q})`}return q(re,d)}if(cu(v,["Alert","AppBar","Avatar","Button","Chip","FilledInput","LinearProgress","Skeleton","Slider","SnackbarContent","SpeedDialAction","StepConnector","StepContent","Switch","TableCell","Tooltip"]),v.mode==="light"){G(v.Alert,"errorColor",k(_e,l?b("palette-error-light"):v.error.light,.6)),G(v.Alert,"infoColor",k(_e,l?b("palette-info-light"):v.info.light,.6)),G(v.Alert,"successColor",k(_e,l?b("palette-success-light"):v.success.light,.6)),G(v.Alert,"warningColor",k(_e,l?b("palette-warning-light"):v.warning.light,.6)),G(v.Alert,"errorFilledBg",W("palette-error-main")),G(v.Alert,"infoFilledBg",W("palette-info-main")),G(v.Alert,"successFilledBg",W("palette-success-main")),G(v.Alert,"warningFilledBg",W("palette-warning-main")),G(v.Alert,"errorFilledColor",Ut(()=>v.getContrastText(v.error.main))),G(v.Alert,"infoFilledColor",Ut(()=>v.getContrastText(v.info.main))),G(v.Alert,"successFilledColor",Ut(()=>v.getContrastText(v.success.main))),G(v.Alert,"warningFilledColor",Ut(()=>v.getContrastText(v.warning.main))),G(v.Alert,"errorStandardBg",k($e,l?b("palette-error-light"):v.error.light,.9)),G(v.Alert,"infoStandardBg",k($e,l?b("palette-info-light"):v.info.light,.9)),G(v.Alert,"successStandardBg",k($e,l?b("palette-success-light"):v.success.light,.9)),G(v.Alert,"warningStandardBg",k($e,l?b("palette-warning-light"):v.warning.light,.9)),G(v.Alert,"errorIconColor",W("palette-error-main")),G(v.Alert,"infoIconColor",W("palette-info-main")),G(v.Alert,"successIconColor",W("palette-success-main")),G(v.Alert,"warningIconColor",W("palette-warning-main")),G(v.AppBar,"defaultBg",W("palette-grey-100")),G(v.Avatar,"defaultBg",W("palette-grey-400")),G(v.Button,"inheritContainedBg",W("palette-grey-300")),G(v.Button,"inheritContainedHoverBg",W("palette-grey-A100")),G(v.Chip,"defaultBorder",W("palette-grey-400")),G(v.Chip,"defaultAvatarColor",W("palette-grey-700")),G(v.Chip,"defaultIconColor",W("palette-grey-700")),G(v.FilledInput,"bg","rgba(0, 0, 0, 0.06)"),G(v.FilledInput,"hoverBg","rgba(0, 0, 0, 0.09)"),G(v.FilledInput,"disabledBg","rgba(0, 0, 0, 0.12)"),G(v.LinearProgress,"primaryBg",k($e,l?b("palette-primary-main"):v.primary.main,.62)),G(v.LinearProgress,"secondaryBg",k($e,l?b("palette-secondary-main"):v.secondary.main,.62)),G(v.LinearProgress,"errorBg",k($e,l?b("palette-error-main"):v.error.main,.62)),G(v.LinearProgress,"infoBg",k($e,l?b("palette-info-main"):v.info.main,.62)),G(v.LinearProgress,"successBg",k($e,l?b("palette-success-main"):v.success.main,.62)),G(v.LinearProgress,"warningBg",k($e,l?b("palette-warning-light"):v.warning.main,.62)),G(v.Skeleton,"bg",z?k(Or,l?b("palette-text-primary"):v.text.primary,.11):`rgba(${W("palette-text-primaryChannel")} / 0.11)`),G(v.Slider,"primaryTrack",k($e,l?b("palette-primary-main"):v.primary.main,.62)),G(v.Slider,"secondaryTrack",k($e,l?b("palette-secondary-main"):v.secondary.main,.62)),G(v.Slider,"errorTrack",k($e,l?b("palette-error-main"):v.error.main,.62)),G(v.Slider,"infoTrack",k($e,l?b("palette-info-main"):v.info.main,.62)),G(v.Slider,"successTrack",k($e,l?b("palette-success-main"):v.success.main,.62)),G(v.Slider,"warningTrack",k($e,l?b("palette-warning-main"):v.warning.main,.62));const q=z?k(_e,l?b("palette-background-default"):v.background.default,.6825):tn(v.background.default,.8);G(v.SnackbarContent,"bg",q),G(v.SnackbarContent,"color",Ut(()=>z?xi.text.primary:v.getContrastText(q))),G(v.SpeedDialAction,"fabHoverBg",tn(v.background.paper,.15)),G(v.StepConnector,"border",W("palette-grey-400")),G(v.StepContent,"border",W("palette-grey-400")),G(v.Switch,"defaultColor",W("palette-common-white")),G(v.Switch,"defaultDisabledColor",W("palette-grey-100")),G(v.Switch,"primaryDisabledColor",k($e,l?b("palette-primary-main"):v.primary.main,.62)),G(v.Switch,"secondaryDisabledColor",k($e,l?b("palette-secondary-main"):v.secondary.main,.62)),G(v.Switch,"errorDisabledColor",k($e,l?b("palette-error-main"):v.error.main,.62)),G(v.Switch,"infoDisabledColor",k($e,l?b("palette-info-main"):v.info.main,.62)),G(v.Switch,"successDisabledColor",k($e,l?b("palette-success-main"):v.success.main,.62)),G(v.Switch,"warningDisabledColor",k($e,l?b("palette-warning-main"):v.warning.main,.62)),G(v.TableCell,"border",k($e,Or(l?b("palette-divider"):v.divider,1),.88)),G(v.Tooltip,"bg",k(Or,l?b("palette-grey-700"):v.grey[700],.92))}if(v.mode==="dark"){G(v.Alert,"errorColor",k($e,l?b("palette-error-light"):v.error.light,.6)),G(v.Alert,"infoColor",k($e,l?b("palette-info-light"):v.info.light,.6)),G(v.Alert,"successColor",k($e,l?b("palette-success-light"):v.success.light,.6)),G(v.Alert,"warningColor",k($e,l?b("palette-warning-light"):v.warning.light,.6)),G(v.Alert,"errorFilledBg",W("palette-error-dark")),G(v.Alert,"infoFilledBg",W("palette-info-dark")),G(v.Alert,"successFilledBg",W("palette-success-dark")),G(v.Alert,"warningFilledBg",W("palette-warning-dark")),G(v.Alert,"errorFilledColor",Ut(()=>v.getContrastText(v.error.dark))),G(v.Alert,"infoFilledColor",Ut(()=>v.getContrastText(v.info.dark))),G(v.Alert,"successFilledColor",Ut(()=>v.getContrastText(v.success.dark))),G(v.Alert,"warningFilledColor",Ut(()=>v.getContrastText(v.warning.dark))),G(v.Alert,"errorStandardBg",k(_e,l?b("palette-error-light"):v.error.light,.9)),G(v.Alert,"infoStandardBg",k(_e,l?b("palette-info-light"):v.info.light,.9)),G(v.Alert,"successStandardBg",k(_e,l?b("palette-success-light"):v.success.light,.9)),G(v.Alert,"warningStandardBg",k(_e,l?b("palette-warning-light"):v.warning.light,.9)),G(v.Alert,"errorIconColor",W("palette-error-main")),G(v.Alert,"infoIconColor",W("palette-info-main")),G(v.Alert,"successIconColor",W("palette-success-main")),G(v.Alert,"warningIconColor",W("palette-warning-main")),G(v.AppBar,"defaultBg",W("palette-grey-900")),G(v.AppBar,"darkBg",W("palette-background-paper")),G(v.AppBar,"darkColor",W("palette-text-primary")),G(v.Avatar,"defaultBg",W("palette-grey-600")),G(v.Button,"inheritContainedBg",W("palette-grey-800")),G(v.Button,"inheritContainedHoverBg",W("palette-grey-700")),G(v.Chip,"defaultBorder",W("palette-grey-700")),G(v.Chip,"defaultAvatarColor",W("palette-grey-300")),G(v.Chip,"defaultIconColor",W("palette-grey-300")),G(v.FilledInput,"bg","rgba(255, 255, 255, 0.09)"),G(v.FilledInput,"hoverBg","rgba(255, 255, 255, 0.13)"),G(v.FilledInput,"disabledBg","rgba(255, 255, 255, 0.12)"),G(v.LinearProgress,"primaryBg",k(_e,l?b("palette-primary-main"):v.primary.main,.5)),G(v.LinearProgress,"secondaryBg",k(_e,l?b("palette-secondary-main"):v.secondary.main,.5)),G(v.LinearProgress,"errorBg",k(_e,l?b("palette-error-main"):v.error.main,.5)),G(v.LinearProgress,"infoBg",k(_e,l?b("palette-info-main"):v.info.main,.5)),G(v.LinearProgress,"successBg",k(_e,l?b("palette-success-main"):v.success.main,.5)),G(v.LinearProgress,"warningBg",k(_e,l?b("palette-warning-main"):v.warning.main,.5)),G(v.Skeleton,"bg",z?k(Or,l?b("palette-text-primary"):v.text.primary,.13):`rgba(${W("palette-text-primaryChannel")} / 0.13)`),G(v.Slider,"primaryTrack",k(_e,l?b("palette-primary-main"):v.primary.main,.5)),G(v.Slider,"secondaryTrack",k(_e,l?b("palette-secondary-main"):v.secondary.main,.5)),G(v.Slider,"errorTrack",k(_e,l?b("palette-error-main"):v.error.main,.5)),G(v.Slider,"infoTrack",k(_e,l?b("palette-info-main"):v.info.main,.5)),G(v.Slider,"successTrack",k(_e,l?b("palette-success-main"):v.success.main,.5)),G(v.Slider,"warningTrack",k(_e,l?b("palette-warning-light"):v.warning.main,.5));const q=z?k($e,l?b("palette-background-default"):v.background.default,.985):tn(v.background.default,.98);G(v.SnackbarContent,"bg",q),G(v.SnackbarContent,"color",Ut(()=>z?aa.text.primary:v.getContrastText(q))),G(v.SpeedDialAction,"fabHoverBg",tn(v.background.paper,.15)),G(v.StepConnector,"border",W("palette-grey-600")),G(v.StepContent,"border",W("palette-grey-600")),G(v.Switch,"defaultColor",W("palette-grey-300")),G(v.Switch,"defaultDisabledColor",W("palette-grey-600")),G(v.Switch,"primaryDisabledColor",k(_e,l?b("palette-primary-main"):v.primary.main,.55)),G(v.Switch,"secondaryDisabledColor",k(_e,l?b("palette-secondary-main"):v.secondary.main,.55)),G(v.Switch,"errorDisabledColor",k(_e,l?b("palette-error-main"):v.error.main,.55)),G(v.Switch,"infoDisabledColor",k(_e,l?b("palette-info-main"):v.info.main,.55)),G(v.Switch,"successDisabledColor",k(_e,l?b("palette-success-main"):v.success.main,.55)),G(v.Switch,"warningDisabledColor",k(_e,l?b("palette-warning-light"):v.warning.main,.55)),G(v.TableCell,"border",k(_e,Or(l?b("palette-divider"):v.divider,1),.68)),G(v.Tooltip,"bg",k(Or,l?b("palette-grey-700"):v.grey[700],.92))}l||(ir(v.background,"default"),ir(v.background,"paper"),ir(v.common,"background"),ir(v.common,"onBackground"),ir(v,"divider")),Object.keys(v).forEach(q=>{const re=v[q];q!=="tonalOffset"&&!l&&re&&typeof re=="object"&&(re.main&&G(v[q],"mainChannel",Bo(Eo(re.main))),re.light&&G(v[q],"lightChannel",Bo(Eo(re.light))),re.dark&&G(v[q],"darkChannel",Bo(Eo(re.dark))),re.contrastText&&G(v[q],"contrastTextChannel",Bo(Eo(re.contrastText))),q==="text"&&(ir(v[q],"primary"),ir(v[q],"secondary")),q==="action"&&(re.active&&ir(v[q],"active"),re.selected&&ir(v[q],"selected")))})}),I=r.reduce((R,v)=>bt(R,v),I);const A={prefix:a,disableCssColorScheme:s,shouldSkipGeneratingVar:c,getSelector:lu(I),enableContrastVars:l},{vars:$,generateThemeVars:Y,generateStyleSheets:X}=$d(I,A);return I.vars=$,Object.entries(I.colorSchemes[I.defaultColorScheme]).forEach(([R,v])=>{I[R]=v}),I.generateThemeVars=Y,I.generateStyleSheets=X,I.generateSpacing=function(){return oa(g.spacing,$i(this))},I.getColorSchemeSelector=Id(u),I.spacing=I.generateSpacing(),I.shouldSkipGeneratingVar=c,I.unstable_sxConfig={...Bn,...g==null?void 0:g.unstable_sxConfig},I.unstable_sx=function(v){return En({sx:v,theme:this})},I.toRuntimeSource=ca,I}function ws(e,r,o){e.colorSchemes&&o&&(e.colorSchemes[r]={...o!==!0&&o,palette:Oi({...o===!0?{}:o.palette,mode:r})})}function fu(e={},...r){const{palette:o,cssVariables:i=!1,colorSchemes:s=o?void 0:{light:!0},defaultColorScheme:a=o==null?void 0:o.mode,...l}=e,c=a||"light",u=s==null?void 0:s[c],x={...s,...o?{[c]:{...typeof u!="boolean"&&u,palette:o}}:void 0};if(i===!1){if(!("colorSchemes"in e))return gi(e,...r);let g=o;"palette"in e||x[c]&&(x[c]!==!0?g=x[c].palette:c==="dark"&&(g={mode:"dark"}));const y=gi({...e,palette:g},...r);return y.defaultColorScheme=c,y.colorSchemes=x,y.palette.mode==="light"&&(y.colorSchemes.light={...x.light!==!0&&x.light,palette:y.palette},ws(y,"dark",x.dark)),y.palette.mode==="dark"&&(y.colorSchemes.dark={...x.dark!==!0&&x.dark,palette:y.palette},ws(y,"light",x.light)),y}return!o&&!("light"in x)&&c==="light"&&(x.light=!0),pu({...l,colorSchemes:x,defaultColorScheme:c,...typeof i!="boolean"&&i},...r)}const hu=fu();function vt(){const e=bd(hu);return process.env.NODE_ENV!=="production"&&mn.useDebugValue(e),e[lc]||e}function mu({onCreateReport:e,reports:r=[],activeReportId:o,onReportClick:i}){const s=r.find(a=>a.id===o);return t.jsx(n.Box,{component:"header",sx:a=>{var g,y,S;const l=((S=(y=(g=a.components)==null?void 0:g.MuiCardHeader)==null?void 0:y.styleOverrides)==null?void 0:S.root)||{},c=l.backgroundColor&&l.backgroundColor!=="transparent"?l.backgroundColor:a.palette.background.paper,u=l.borderBottom&&l.borderBottom!=="none"?l.borderBottom:"1px solid",x=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:x,bgcolor:c}},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,height:64},children:[t.jsxs(n.Breadcrumbs,{separator:t.jsx(_.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}),sx:{display:"flex",alignItems:"center"},children:[t.jsx(n.Typography,{variant:"h2",component:"h1",sx:{fontWeight:300,fontSize:a=>a.typography.h2.fontSize,color:"text.secondary",cursor:r.length>0&&s?"pointer":"default","&:hover":r.length>0&&s?{color:"primary.main"}:{}},onClick:()=>{r.length>0},children:"Reports"}),s&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(_.Description,{sx:{fontSize:22,color:"primary.main"}}),t.jsx(n.Typography,{sx:{fontWeight:500,fontSize:a=>a.typography.h2.fontSize,color:"primary.main",cursor:"pointer","&:hover":{textDecoration:"underline"}},onClick:()=>i==null?void 0:i(s.id),children:s.name}),t.jsx(n.Tooltip,{title:s.description||"No description",arrow:!0,placement:"bottom",children:t.jsx(_.InfoOutlined,{sx:{fontSize:18,color:"text.secondary",opacity:.7,cursor:"help","&:hover":{opacity:1}}})})]})]}),t.jsx(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(n.Tooltip,{title:"New Report",children:t.jsx(n.IconButton,{onClick:e,"aria-label":"New Report",sx:{width:38,height:38,borderRadius:"11px",color:"primary.contrastText",backgroundImage:a=>`linear-gradient(146.94deg, ${a.palette.primary.dark} 0%, ${a.palette.primary.main} 45%, ${a.palette.primary.light} 100%)`,boxShadow:a=>`0 6px 10px ${M(a.palette.primary.dark,.35)}, 0 2px 4px ${M(a.palette.primary.dark,.3)}`,"&:hover":{filter:"brightness(1.05)"}},children:t.jsx(_.Add,{sx:{fontSize:20}})})})})]})})}async function xu(e,r,o){try{new URL(e)}catch{throw new Error("Please enter a valid URL")}const i={"Content-Type":"application/json"};r&&(i.Authorization=`Bearer ${r}`);const s=new AbortController,a=setTimeout(()=>s.abort(),3e4);let l;try{l=await fetch(e,{headers:i,signal:s.signal})}catch(x){throw clearTimeout(a),(x==null?void 0:x.name)==="AbortError"?new Error("Request timed out after 30 seconds"):new Error("Failed to fetch — check the URL and your network connection")}finally{clearTimeout(a)}if(l.status===401)throw new Error("Authentication failed (401) — check your API key");if(l.status===429){const x=l.headers.get("Retry-After"),g=x&&/^\d+$/.test(x)?` — retry after ${x}s`:"";throw new Error(`Rate limit exceeded (429 Too Many Requests)${g}`)}if(!l.ok){const x=l.statusText?`: ${l.statusText}`:"";throw new Error(`API error ${l.status}${x}`)}let c;try{c=await l.json()}catch{throw new Error("Response is not valid JSON")}let u;if(Array.isArray(c))u=c;else if(o&&c[o]&&Array.isArray(c[o]))u=c[o];else{const g=["data","results","items","records"].find(y=>c[y]&&Array.isArray(c[y]));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 pa(e,r){return r.map(o=>`${o.x}px ${o.y}px ${o.blur}px ${o.spread}px ${M(e.palette.common.black,o.opacity)}`).join(", ")}const fa={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}],accentModal:[{x:0,y:40,blur:120,spread:0,opacity:.75}]};function ye(e,r){return pa(e,fa[r])}function gu(e){return`${Number(e.shape.borderRadius)*1.5}px`}function Po(e){return`${Number(e.shape.borderRadius)}px`}function Cs(e){const r=e.tokens;return{containerPad:`${(r==null?void 0:r.containerPad)??16}px`,cardGap:`${(r==null?void 0:r.cardGap)??12}px`}}function it(e){const r=e.tokens,o=(r==null?void 0:r.highlight)||e.palette.primary.main;return{main:o,bg:`var(--highlight-bg, ${M(o,.08)})`,hoverBg:`var(--highlight-hover, ${M(o,.12)})`}}function yu(e){const r=e.tokens,o=(r==null?void 0:r.highlight)||e.palette.primary.main;return{color:o,bg:(r==null?void 0:r.highlightSoft)||M(o,.14),border:(r==null?void 0:r.highlightBd)||M(o,.32)}}function ht(e){const r=e.tokens;return{iconTileBg:(r==null?void 0:r.reportsAccentTileGradient)||e.palette.primary.main,surfaceBg:(r==null?void 0:r.gsModalBgDark)||e.palette.background.paper,ctaBg:(r==null?void 0:r.reportsAccentCtaGradient)||e.palette.primary.main,tileShadow:`drop-shadow(0 7.8px 5.9px ${M(e.palette.primary.main,.25)}) drop-shadow(0 3.1px 2.3px ${M(e.palette.primary.main,.25)})`,ctaShadow:`drop-shadow(0 10px 7.5px ${M(e.palette.primary.main,.3)}) drop-shadow(0 4px 3px ${M(e.palette.primary.main,.3)})`,cornerGlow:M(e.palette.primary.main,.1),innerHighlight:(r==null?void 0:r.reportsModalInnerHighlight)||"none",border:`1px solid ${M(e.palette.common.white,.2)}`,shadow:pa(e,fa.accentModal)}}function Rt(e,r="menu"){const o=e.tokens;return{paper:{boxShadow:(o==null?void 0:o.cardBodyShadow)||ye(e,r),border:o!=null&&o.cardBodyBorder&&o.cardBodyBorder!=="none"?o.cardBodyBorder:"none"},header:{backgroundColor:(o==null?void 0:o.cardHdrBg)||"transparent",borderBottom:(o==null?void 0:o.cardHdrBorder)||"none",boxShadow:(o==null?void 0:o.cardHdrAccent)||"none"}}}function mr({content:e,isDev:r=!1}){const[o,i]=p.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(n.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=>M(s.palette.primary.main,.08)}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:15}})}),t.jsxs(n.Popover,{open:!!o,anchorEl:o,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(n.Box,{sx:{px:2,py:1.5,bgcolor:s=>M(s.palette.primary.main,.06)},children:t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||600,color:"primary.main",fontSize:s=>s.typography.body2.fontSize||"0.875rem"},children:e.title})}),t.jsx(n.Divider,{}),t.jsxs(n.Box,{sx:{px:2,py:1.5,display:"flex",flexDirection:"column",gap:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{color:"text.secondary",fontSize:s=>s.typography.body2.fontSize||"0.8125rem",lineHeight:1.6},children:e.description}),e.tips&&e.tips.length>0&&t.jsx(n.Box,{component:"ul",sx:{m:0,pl:2,display:"flex",flexDirection:"column",gap:.5},children:e.tips.map((s,a)=>t.jsx(n.Box,{component:"li",sx:{fontSize:"0.8125rem",color:"text.secondary",lineHeight:1.5},children:s},a))}),r&&e.devNote&&t.jsxs(t.Fragment,{children:[t.jsx(n.Divider,{sx:{my:.5}}),t.jsxs(n.Box,{sx:{px:1.25,py:.75,borderRadius:"6px",bgcolor:s=>M(s.palette.warning.main,.08),border:"1px solid",borderColor:s=>M(s.palette.warning.main,.2)},children:[t.jsx(n.Typography,{variant:"caption",sx:{color:"warning.dark",fontWeight:s=>s.typography.caption.fontWeight||500,fontSize:s=>s.typography.caption.fontSize||"0.75rem",display:"block",mb:.25},children:"Dev note"}),t.jsx(n.Typography,{variant:"caption",sx:{color:"warning.dark",fontSize:s=>s.typography.caption.fontSize||"0.75rem",lineHeight:1.5},children:e.devNote})]})]})]})]})]})}function st({open:e,onClose:r,icon:o,title:i,iconColor:s="primary",accentSurface:a,subtitle:l,helpContent:c,headerActions:u,headerExtra:x,width:g=520,maxHeight:y="90vh",children:S,footer:b,disableBackdropClose:T=!1,disableEscapeKeyDown:m=!1,classNames:f}){const B=vt(),j=a??B.palette.mode==="dark",D=s!=="error",z=Math.min(56,Math.max(44,Math.round(g*.11))),h=p.useRef(r);if(h.current=r,p.useEffect(()=>{if(!e||m)return;const A=$=>{$.key==="Escape"&&h.current()};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[e,m]),!e)return null;const I=A=>{A.target===A.currentTarget&&!T&&r()};return t.jsx(n.Box,{onMouseDown:I,className:f==null?void 0:f.backdrop,sx:{position:"fixed",inset:0,bgcolor:A=>M(A.palette.common.black,.4),display:"flex",alignItems:"center",justifyContent:"center",zIndex:A=>A.zIndex.modal},children:t.jsxs(n.Paper,{className:f==null?void 0:f.paper,sx:{width:g,maxWidth:"calc(100vw - 48px)",maxHeight:y,display:"flex",flexDirection:"column",overflow:"hidden",position:"relative",isolation:"isolate",borderRadius:A=>gu(A),background:A=>j?ht(A).surfaceBg:void 0,boxShadow:A=>{if(j){const $=ht(A);return $.innerHighlight!=="none"?`${$.innerHighlight}, ${$.shadow}`:$.shadow}return Rt(A).paper.boxShadow},border:A=>j?ht(A).border:Rt(A).paper.border},children:[!j&&t.jsx(n.Box,{"aria-hidden":!0,sx:{position:"absolute",top:-50,right:-50,width:125,height:125,borderRadius:"50%",pointerEvents:"none",zIndex:-1,filter:"blur(50px)",bgcolor:A=>ht(A).cornerGlow}}),!j&&t.jsx(n.Box,{sx:{height:3,flexShrink:0,background:A=>ht(A).iconTileBg}}),t.jsxs(n.Box,{className:f==null?void 0:f.header,sx:{flexShrink:0},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,px:3,pt:2.5,pb:x?1.5:2,bgcolor:A=>j?"transparent":Rt(A).header.backgroundColor,borderBottom:A=>j?"none":Rt(A).header.borderBottom,boxShadow:A=>j?"none":Rt(A).header.boxShadow},children:[t.jsx(n.Box,{sx:{width:z,height:Math.round(z*.94),flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:`${Math.round(z*.18)}px`,"& > svg":{fontSize:Math.round(z*.55)},...D?{background:A=>ht(A).iconTileBg,color:"common.white",filter:A=>j?void 0:ht(A).tileShadow}:{bgcolor:`${s}.main`,color:`${s}.contrastText`}},children:o}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"baseline",gap:.75,minWidth:0},children:[t.jsx(n.Typography,{variant:"h4",className:f==null?void 0:f.title,sx:{fontWeight:600,color:j?"common.white":void 0},noWrap:!0,children:i}),l&&t.jsx(n.Typography,{variant:"caption",color:j?void 0:"text.secondary",sx:{color:j?A=>M(A.palette.common.white,.6):void 0},noWrap:!0,children:l}),c&&t.jsx(mr,{content:c,isDev:process.env.NODE_ENV==="development"})]}),t.jsx(n.Box,{sx:{flex:1}}),u,t.jsx(n.IconButton,{onClick:r,size:"small","aria-label":"Close",className:f==null?void 0:f.closeButton,sx:{color:j?A=>M(A.palette.common.white,.7):"text.secondary",flexShrink:0},children:t.jsx(_.Close,{sx:{fontSize:20}})})]}),x&&t.jsx(n.Box,{sx:{px:3},children:x})]}),t.jsx(n.Box,{className:f==null?void 0:f.body,sx:{flex:1,overflowY:"auto",px:3,pb:2},children:S}),b&&t.jsx(n.Box,{className:f==null?void 0:f.footer,sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1.5,px:3,py:2,borderTop:1,borderColor:A=>j?M(A.palette.common.white,.2):"divider",flexShrink:0},children:b})]})})}const bu=e=>({minHeight:0,p:.4,borderRadius:"10px",bgcolor:e.palette.action.hover,"& .MuiTabs-indicator":{display:"none"},"& .MuiTabs-flexContainer":{gap:.4}}),js=e=>({textTransform:"none",fontSize:"0.8125rem",fontWeight:500,minHeight:32,py:.25,borderRadius:"7px",color:e.palette.text.secondary,"&.Mui-selected":{color:e.palette.common.white,background:ht(e).ctaBg,boxShadow:`0 3px 2.4px ${M(e.palette.primary.main,.25)}`}});function vu({isOpen:e,onClose:r,onCreate:o,preloadedData:i,preloadedDataLabel:s}){const[a,l]=p.useState(""),[c,u]=p.useState(!1),[x,g]=p.useState(""),[y,S]=p.useState(null),[b,T]=p.useState(null),[m,f]=p.useState(!1),[B,j]=p.useState(""),D=p.useRef(null),[z,h]=p.useState(i?"json":"api"),[I,A]=p.useState(""),[$,Y]=p.useState(""),[X,R]=p.useState(""),[v,W]=p.useState("idle"),[k,q]=p.useState(""),[re,d]=p.useState(null),[Q,ee]=p.useState(0);p.useEffect(()=>{i&&h("json")},[i]);const H=async F=>{if(j(""),!F.name.endsWith(".json")){j("Only .json files are allowed");return}const ie=10*1024*1024;if(F.size>ie){j("File size exceeds 10MB limit");return}try{const he=await F.text();let pe;try{pe=JSON.parse(he)}catch{j("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(pe)){j("JSON must be an array of objects");return}if(pe.length===0){j("No data rows found in JSON file");return}S(F),T(pe)}catch{j("Network error — please try again")}},te=F=>{F.preventDefault();const ie=F.dataTransfer.files[0];ie&&H(ie)},ue=async()=>{if(I.trim()){W("loading"),q("");try{const F=await xu(I.trim(),$.trim()||void 0,X.trim()||void 0);d(F.data),ee(F.data.length),W("ready")}catch(F){q((F==null?void 0:F.message)||"Connection failed"),W("error")}}},le=()=>{if(!a.trim()){u(!0);return}const F=z==="api"?re:i||b;F&&(o(a.trim(),x.trim(),F),Z())},Z=()=>{l(""),u(!1),g(""),S(null),T(null),j(""),h(i?"json":"api"),A(""),Y(""),R(""),W("idle"),q(""),d(null),ee(0),r()},de=i||b,ae=c&&!a.trim();return a.trim(),t.jsxs(t.Fragment,{children:[t.jsx(st,{open:e,onClose:Z,icon:t.jsx(_.Description,{sx:{fontSize:20}}),title:"Create new report",width:480,maxHeight:"min(720px, calc(100vh - 120px))",footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:Z,variant:"text",sx:{color:"text.secondary",fontWeight:600,fontSize:"0.875rem",borderRadius:F=>`${F.shape.borderRadius}px`,px:2,py:.625,minWidth:64,"&:hover":{bgcolor:F=>M(F.palette.primary.main,.04)}},children:"Cancel"}),t.jsx(n.Button,{onClick:le,disabled:z==="json"&&!de||z==="api"&&v!=="ready",variant:"contained",sx:{fontSize:"0.875rem",borderRadius:F=>`${F.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64,fontWeight:600,color:"common.white",background:F=>ht(F).ctaBg,"&.Mui-disabled":{background:F=>ht(F).ctaBg,color:"common.white",opacity:.45}},children:"Create report"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:2},children:[t.jsx(n.TextField,{label:"Report Name",required:!0,fullWidth:!0,value:a,onChange:F=>{l(F.target.value),c&&F.target.value.trim()&&u(!1)},placeholder:"Enter report name",autoFocus:!0,error:ae,helperText:ae?"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(n.TextField,{label:"Short Description",fullWidth:!0,multiline:!0,rows:2,value:x,onChange:F=>g(F.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(n.Tabs,{value:z==="api"?0:1,onChange:(F,ie)=>{h(ie===0?"api":"json"),W("idle"),q("")},variant:"fullWidth",sx:bu,children:[t.jsx(n.Tab,{label:"Connect API",icon:t.jsx(_.Api,{fontSize:"small"}),iconPosition:"start",sx:js}),t.jsx(n.Tab,{label:"Upload JSON",icon:t.jsx(_.Description,{fontSize:"small"}),iconPosition:"start",sx:js})]}),z==="json"&&t.jsx(n.Box,{children:i?t.jsxs(n.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2.5,bgcolor:F=>M(F.palette.success.main,.04),display:"flex",alignItems:"center",gap:2},children:[t.jsx(n.Box,{sx:{width:36,height:36,borderRadius:"50%",bgcolor:F=>M(F.palette.success.main,.12),display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(_.CheckCircle,{sx:{fontSize:20,color:"success.main"}})}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:s||`${i.length.toLocaleString()} records loaded`}),t.jsx(n.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Data source is connected — ready to create"})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.25},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:500,fontSize:"0.875rem",color:"text.primary"},children:"Data source"}),t.jsx(n.IconButton,{size:"small",onClick:()=>f(!0),sx:{p:.25,color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(_.Info,{sx:{fontSize:16}})})]}),t.jsxs(n.Box,{onDrop:te,onDragOver:F=>F.preventDefault(),onPaste:F=>F.preventDefault(),onClick:()=>{var F;return(F=D.current)==null?void 0:F.click()},sx:{position:"relative",border:"1.5px",borderStyle:b?"solid":"dashed",borderColor:b?"success.main":B?"error.main":"primary.main",borderRadius:2,p:3,textAlign:"center",cursor:"pointer",bgcolor:b?F=>M(F.palette.success.main,.04):B?F=>M(F.palette.error.main,.04):F=>M(F.palette.primary.main,.04),transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:b?F=>M(F.palette.success.main,.08):B?F=>M(F.palette.error.main,.08):F=>M(F.palette.primary.main,.08),borderColor:b?"success.dark":B?"error.dark":"primary.dark"}},children:[t.jsx(n.Box,{component:"input",ref:D,type:"file",accept:".json",sx:{display:"none"},onChange:F=>{var ie;return((ie=F.target.files)==null?void 0:ie[0])&&H(F.target.files[0])}}),b?t.jsxs(n.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(n.Box,{sx:{width:40,height:40,borderRadius:"50%",bgcolor:F=>M(F.palette.success.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:.5},children:t.jsx(_.CheckCircle,{sx:{fontSize:24,color:"success.main"}})}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.main",fontSize:"0.875rem"},children:y==null?void 0:y.name}),t.jsx(n.Typography,{variant:"caption",sx:{color:"success.dark",fontSize:"0.75rem"},children:"Ready to create"})]}):t.jsxs(n.Box,{children:[t.jsx(n.Box,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:F=>M(F.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mx:"auto",mb:1.5},children:t.jsx(_.CloudUpload,{sx:{fontSize:28,color:"primary.main"}})}),t.jsx(n.Typography,{variant:"body2",sx:{color:"text.primary",fontSize:"0.875rem",fontWeight:500,mb:.25},children:"Upload JSON file"}),t.jsx(n.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block"},children:"Click to browse or drag and drop"}),B&&t.jsx(n.Box,{sx:{mt:1.25,p:.75,borderRadius:1,bgcolor:F=>M(F.palette.error.main,.08),border:1,borderColor:F=>M(F.palette.error.main,.2)},children:t.jsx(n.Typography,{variant:"caption",sx:{color:"error.main",fontSize:"0.6875rem",fontWeight:500},children:B})})]})]})]})}),z==="api"&&t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx(n.TextField,{label:"API End URL",required:!0,fullWidth:!0,size:"small",value:I,onChange:F=>{A(F.target.value),W("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(n.TextField,{label:"API Key",fullWidth:!0,size:"small",value:$,onChange:F=>Y(F.target.value),placeholder:"Leave blank if no auth required",InputProps:{startAdornment:t.jsx(n.InputAdornment,{position:"start",children:t.jsx(_.Lock,{sx:{fontSize:16,color:"text.secondary"}})})},sx:{"& .MuiInputBase-root":{fontSize:"0.875rem",borderRadius:1,color:"text.primary"},"& .MuiInputLabel-root":{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},"& .MuiOutlinedInput-root":{"& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"text.secondary"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}}}}),t.jsx(n.TextField,{label:"Response Data Path",fullWidth:!0,size:"small",value:X,onChange:F=>R(F.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(n.Button,{variant:"outlined",fullWidth:!0,disabled:!I.trim()||v==="loading",onClick:ue,startIcon:v==="loading"?t.jsx(n.CircularProgress,{size:16,color:"inherit"}):t.jsx(_.Api,{}),sx:{fontSize:"0.875rem",borderRadius:1,py:.875,borderColor:"primary.main",color:"primary.main","&:hover":{bgcolor:F=>M(F.palette.primary.main,.04),borderColor:"primary.dark"},"&:disabled":{borderColor:"action.disabledBackground",color:"action.disabled"}},children:v==="loading"?"Connecting...":"Test Connection and Load Data"}),v==="ready"&&t.jsxs(n.Box,{sx:{border:"1.5px solid",borderColor:"success.main",borderRadius:2,p:2,bgcolor:F=>M(F.palette.success.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(_.CheckCircle,{sx:{fontSize:20,color:"success.main",flexShrink:0,mt:.1}}),t.jsxs(n.Box,{children:[t.jsxs(n.Typography,{variant:"body2",sx:{fontWeight:500,color:"success.dark",fontSize:"0.875rem"},children:[Q.toLocaleString()," records loaded — ready to create"]}),t.jsx(n.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",wordBreak:"break-all",display:"block",mt:.25},children:I})]})]}),v==="error"&&t.jsxs(n.Box,{sx:{border:"1.5px solid",borderColor:"error.main",borderRadius:2,p:2,bgcolor:F=>M(F.palette.error.main,.04),display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(_.ErrorOutline,{sx:{fontSize:20,color:"error.main",flexShrink:0,mt:.1}}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:500,color:"error.main",fontSize:"0.875rem"},children:"Connection failed"}),t.jsx(n.Typography,{variant:"caption",sx:{color:"text.secondary",fontSize:"0.75rem",display:"block",mt:.25},children:k})]})]})]})]})}),t.jsxs(n.Dialog,{open:m,onClose:()=>f(!1),maxWidth:"sm",PaperProps:{sx:F=>({borderRadius:3,width:560,maxHeight:"80vh",...Rt(F).paper})},children:[t.jsxs(n.DialogTitle,{sx:F=>({display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,fontWeight:ie=>ie.typography.h4.fontWeight||500,fontSize:ie=>ie.typography.h4.fontSize||"1.25rem",color:"text.primary",letterSpacing:"-0.01em",...Rt(F).header}),children:["JSON format guide",t.jsx(n.IconButton,{onClick:()=>f(!1),size:"small",sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"}},children:t.jsx(_.Close,{sx:{fontSize:20}})})]}),t.jsx(n.DialogContent,{sx:{px:3,py:2},children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Required format"}),t.jsx(n.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(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Example structure"}),t.jsx(n.Box,{component:"pre",sx:{bgcolor:"action.hover",border:1,borderColor:"divider",p:2,borderRadius:1,overflow:"auto",maxHeight:200,fontSize:"0.75rem",fontFamily:"monospace",lineHeight:1.5,color:"text.primary"},children:`[
172
172
  {
173
173
  "id": 1,
174
174
  "customerName": "John Smith",
@@ -178,7 +178,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
178
178
  "memberSince": "2024-01-15",
179
179
  "status": "active"
180
180
  }
181
- ]`})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(n.DialogActions,{sx:{px:3,py:2},children:t.jsx(n.Button,{onClick:()=>m(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:W=>`${W.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function ca({isOpen:e,onClose:r,content:o,title:i="JSON Format Guide"}){return e?t.jsx(it,{open:e,onClose:r,icon:t.jsx(D.DataObject,{sx:{fontSize:20}}),title:i,width:700,maxHeight:"min(640px, calc(100vh - 180px))",footer:t.jsx(n.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:s=>`${s.shape.borderRadius}px`,boxShadow:s=>ge(s,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:s=>ge(s,"hoverButton")},"&:active":{boxShadow:s=>ge(s,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"}),children:o?typeof o=="string"?t.jsx(n.Typography,{variant:"body2",sx:{whiteSpace:"pre-wrap"},children:o}):o:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(n.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(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(n.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(n.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
181
+ ]`})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Supported data types"}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"Text, numbers, booleans, dates, and null values"})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",sx:{fontWeight:500,mb:.75,color:"text.primary",fontSize:"0.875rem"},children:"Guidelines"}),t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:.5},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• Must be valid JSON with array format"}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:"• All objects should have consistent field names"}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:"0.8125rem",color:"text.secondary"},children:'• Field names auto-format (e.g., "customerName" → "Customer Name")'})]})]})]})}),t.jsx(n.DialogActions,{sx:{px:3,py:2},children:t.jsx(n.Button,{onClick:()=>f(!1),variant:"contained",sx:{fontSize:"0.875rem",borderRadius:F=>`${F.shape.borderRadius}px`,px:2.5,py:.625,minWidth:64},children:"Got it"})})]})]})}function ha({isOpen:e,onClose:r,content:o,title:i="JSON Format Guide"}){return e?t.jsx(st,{open:e,onClose:r,icon:t.jsx(_.DataObject,{sx:{fontSize:20}}),title:i,width:700,maxHeight:"min(640px, calc(100vh - 180px))",footer:t.jsx(n.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:s=>`${s.shape.borderRadius}px`,boxShadow:s=>ye(s,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:s=>ye(s,"hoverButton")},"&:active":{boxShadow:s=>ye(s,"pressedButton"),transform:"translateY(1px)"}},children:"Got it"}),children:o?typeof o=="string"?t.jsx(n.Typography,{variant:"body2",sx:{whiteSpace:"pre-wrap"},children:o}):o:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:3,py:1},children:[t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Expected JSON Structure"}),t.jsxs(n.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(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Example JSON"}),t.jsx(n.Paper,{elevation:0,sx:{p:2,bgcolor:"action.hover",border:1,borderColor:"divider",borderRadius:1,overflowX:"auto"},children:t.jsx(n.Box,{component:"pre",sx:{fontSize:"caption.fontSize",fontFamily:"monospace",m:0},children:`[
182
182
  {
183
183
  "Active Sessions": 33,
184
184
  "Active State": true,
@@ -188,10 +188,10 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
188
188
  "Region": "Europe",
189
189
  "Subscription Type": "Basic"
190
190
  }
191
- ]`})})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Number:"}),t.jsxs(n.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g.,"," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),","," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Boolean:"}),t.jsxs(n.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g.,"," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),","," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.typography.body2.fontSize||"0.875rem",minWidth:80},children:"String:"}),t.jsxs(n.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g.,"," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),","," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Date:"}),t.jsxs(n.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),t.jsxs(n.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."})]})]})]})}):null}function hu({onFileUpload:e,onError:r,isUploading:o,jsonGuideContent:i,jsonGuideTitle:s}){const[a,l]=p.useState(!1),[c,u]=p.useState(""),[g,x]=p.useState(!1),y=p.useRef(null),w=async T=>{if(!T.name.endsWith(".json")){r("Only .json files are allowed");return}const B=10*1024*1024;if(T.size>B){r("File size exceeds 10MB limit");return}u(T.name);try{const f=await T.text();let $;try{$=JSON.parse(f)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray($)){r("JSON must be an array of objects");return}if($.length===0){r("No data rows found in JSON file");return}e($)}catch{r("Network error — please try again")}finally{u("")}},b=T=>{T.preventDefault(),l(!0)},z=T=>{T.preventDefault(),l(!1)},h=T=>{T.preventDefault(),l(!1);const B=T.dataTransfer.files[0];B&&w(B)},m=()=>{var T;(T=y.current)==null||T.click()},E=T=>{var f;const B=(f=T.target.files)==null?void 0:f[0];B&&w(B)},v=T=>{T.stopPropagation(),x(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(n.Box,{onDragOver:b,onDragLeave:z,onDrop:h,onPaste:T=>T.preventDefault(),onClick:m,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:a?"primary.main":"divider",bgcolor:a?T=>M(T.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:o?.5:1,pointerEvents:o?"none":"auto","&:hover":{borderColor:a?"primary.main":"text.secondary"}},children:[t.jsx(n.Box,{component:"input",ref:y,type:"file",accept:".json",onChange:E,sx:{display:"none"}}),o?t.jsxs(t.Fragment,{children:[t.jsx(n.CircularProgress,{size:32,sx:{mb:2}}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:T=>T.typography.body2.fontWeight||500,fontSize:T=>T.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),c&&t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:c})]}):t.jsxs(t.Fragment,{children:[t.jsx(n.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:T=>M(T.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(D.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[t.jsx(n.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),t.jsx(n.IconButton,{onClick:v,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:"View JSON format guide",children:t.jsx(D.InfoOutlined,{sx:{fontSize:16}})})]}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),t.jsx(n.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),t.jsx(ca,{isOpen:g,onClose:()=>x(!1),content:i,title:s})]})}function xu({schema:e,onConfirm:r,hasConflicts:o}){return t.jsxs(n.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[t.jsxs(n.Box,{sx:{mb:2},children:[t.jsx(n.Typography,{variant:"h4",sx:{fontWeight:i=>i.typography.h4.fontWeight||600,fontSize:i=>i.typography.h4.fontSize||"1.25rem",mb:.5},children:"Schema Preview"}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),o&&t.jsxs(n.Alert,{severity:"warning",sx:{mb:2},children:[t.jsx(n.AlertTitle,{sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.subtitle2.fontSize||"0.875rem"},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),t.jsx(n.TableContainer,{sx:{mb:3},children:t.jsxs(n.Table,{children:[t.jsx(n.TableHead,{children:t.jsxs(n.TableRow,{sx:{bgcolor:"action.hover"},children:[t.jsx(n.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),t.jsx(n.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),t.jsx(n.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),t.jsx(n.TableBody,{children:e.map(i=>t.jsxs(n.TableRow,{sx:{bgcolor:i.hasConflict?s=>M(s.palette.warning.main,.12):"transparent"},children:[t.jsxs(n.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&t.jsx(n.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),t.jsx(n.TableCell,{children:t.jsx(n.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),t.jsx(n.TableCell,{children:t.jsx(n.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(D.Lock,{sx:{fontSize:16}}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),t.jsx(n.Button,{variant:"contained",onClick:r,disabled:o,sx:{fontWeight:500},children:"Generate Table"})]})]})}function gu({error:e,onRetry:r}){return t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:o=>M(o.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[t.jsx(n.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:o=>M(o.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(D.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(n.Typography,{variant:"h4",color:"error.main",sx:{fontWeight:o=>o.typography.h4.fontWeight||600,fontSize:o=>o.typography.h4.fontSize||"1.25rem",mb:1},children:"Upload Failed"}),t.jsx(n.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:e}),t.jsx(n.Button,{variant:"contained",color:"error",startIcon:t.jsx(D.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function da({title:e,description:r,showIcon:o=!0}){return t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8},children:[o&&t.jsx(n.Box,{sx:{width:80,height:80,borderRadius:"50%",bgcolor:i=>M(i.palette.primary.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:3},children:t.jsx(D.Description,{sx:{fontSize:36,color:"primary.main"}})}),t.jsx(n.Typography,{variant:"h5",sx:{fontWeight:i=>i.typography.h5.fontWeight||500,mb:1,color:i=>i.typography.h5.color||"text.primary",fontSize:i=>i.typography.h5.fontSize||"1.125rem"},children:e}),t.jsx(n.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,color:"text.secondary",fontSize:i=>i.typography.body2.fontSize||"0.875rem",lineHeight:1.5},children:r})]})}function yu({value:e,onChange:r,searchHistory:o,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:l}){const[c,u]=p.useState(!1),[g,x]=p.useState(!1),[y,w]=p.useState(-1),b=p.useRef(null),z=p.useRef(null);p.useEffect(()=>{function O(J){b.current&&!b.current.contains(J.target)&&(u(!1),x(!1))}return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]);const h=p.useCallback(()=>{x(!0),w(-1),o.length>0&&u(!0)},[o.length]),m=p.useCallback(O=>{r(O),w(-1)},[r]),E=p.useCallback(O=>{var J;r(O),i(O),u(!1),(J=z.current)==null||J.blur()},[r,i]),v=p.useCallback(O=>{w(-1),E(O)},[E]),T=p.useCallback(O=>{var J;O.key==="Enter"?y>=0&&y<o.length?(O.preventDefault(),v(o[y].query)):e.trim()&&E(e.trim()):O.key==="Escape"?(u(!1),w(-1),(J=z.current)==null||J.blur()):O.key==="ArrowDown"?(O.preventDefault(),o.length>0&&(c||u(!0),w(te=>te<o.length-1?te+1:te))):O.key==="ArrowUp"&&(O.preventDefault(),w(te=>te>0?te-1:-1))},[y,o,e,c,v,E]),B=p.useCallback(()=>{var O;r(""),(O=z.current)==null||O.focus()},[r]),f=p.useMemo(()=>o.filter(O=>O.isFavourite),[o]),$=p.useMemo(()=>o.filter(O=>!O.isFavourite),[o]),F=c&&o.length>0;return t.jsxs(n.Box,{sx:{position:"relative",width:240},ref:b,children:[t.jsx(n.TextField,{inputRef:z,size:"small",fullWidth:!0,value:e,onChange:O=>m(O.target.value),onFocus:h,onKeyDown:T,placeholder:"Search data...",disabled:l,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:O=>M(O.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:O=>M(O.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(n.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx(D.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(n.InputAdornment,{position:"end",children:t.jsx(n.IconButton,{size:"small",onClick:B,edge:"end",sx:{mr:-.5},children:t.jsx(D.Close,{sx:{fontSize:16}})})}):null}}),F&&t.jsxs(n.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[f.length>0&&t.jsxs(n.Box,{sx:{py:1},children:[t.jsx(n.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:O=>O.typography.caption.fontWeight||600,fontSize:O=>O.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),f.map((O,J)=>t.jsx(Ss,{entry:O,isSelected:y===J,onClick:()=>v(O.query),onToggleFavourite:()=>s(O.query),onDelete:()=>a(O.query)},`fav-${O.query}`))]}),$.length>0&&t.jsxs(n.Box,{sx:{py:1},children:[f.length>0&&t.jsx(n.Divider,{}),t.jsx(n.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:O=>O.typography.caption.fontWeight||600,fontSize:O=>O.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),$.map((O,J)=>{const te=f.length+J;return t.jsx(Ss,{entry:O,isSelected:y===te,onClick:()=>v(O.query),onToggleFavourite:()=>s(O.query),onDelete:()=>a(O.query)},`recent-${O.query}`)})]})]})]})}const Ss=p.memo(function({entry:r,isSelected:o,onClick:i,onToggleFavourite:s,onDelete:a}){const l=p.useCallback(u=>{u.stopPropagation(),s()},[s]),c=p.useCallback(u=>{u.stopPropagation(),a()},[a]);return t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:o?u=>M(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:o?u=>M(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(n.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(n.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(n.IconButton,{size:"small",onClick:l,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?t.jsx(D.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx(D.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(n.IconButton,{size:"small",onClick:c,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(D.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function bu(e){const{value:r,disabled:o}=e,[i,s]=p.useState(!1),a=p.useRef(null),l=r.trim().length>0,c=i||l;return p.useEffect(()=>{var u,g;i&&((g=(u=a.current)==null?void 0:u.querySelector("input"))==null||g.focus())},[i]),p.useEffect(()=>{if(!i)return;const u=g=>{var x;!((x=a.current)!=null&&x.contains(g.target))&&!l&&s(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[i,l]),c?t.jsx(n.Box,{ref:a,onKeyDown:u=>{u.key==="Escape"&&!l&&s(!1)},children:t.jsx(yu,{...e})}):t.jsx(n.Tooltip,{title:"Search",children:t.jsx("span",{children:t.jsx(n.IconButton,{onClick:()=>s(!0),disabled:o,"aria-label":"Search",sx:{width:40,height:40,color:"text.primary",bgcolor:u=>M(u.palette.primary.main,.1),"&:hover":{bgcolor:u=>M(u.palette.primary.main,.18)}},children:t.jsx(D.Search,{sx:{fontSize:20}})})})})}const vu={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"},Su={error:"err",warning:"warn",info:"info",success:"suc"};function ws(e,r){var l,c;const o=vu[r.toLowerCase().trim()];if(!o||o==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.tokens,s=Su[o],a=e.palette[o];return{bg:((l=i==null?void 0:i.status)==null?void 0:l[`${s}Soft`])??M(a.main,e.palette.mode==="dark"?.24:.12),color:((c=i==null?void 0:i.status)==null?void 0:c[`${s}Txt`])??(e.palette.mode==="dark"?a.light:a.dark)}}function wu(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 Cu={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"},rows:{hue:"primary",shade:"main"}};function Cs(e,r){const o=Cu[r];return o?e.palette[o.hue][o.shade]:e.palette.text.secondary}function lr(e){return M(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function sn({title:e,onClick:r,active:o=!1,badge:i,children:s}){return t.jsx(n.Tooltip,{title:e,children:t.jsxs(n.IconButton,{onClick:r,size:"small",sx:{position:"relative",width:34,height:32,border:"1px solid",borderColor:"primary.light",borderRadius:"8px",color:"primary.main",bgcolor:o?a=>lr(a):"background.paper",transition:"all 0.15s ease","&:hover":{bgcolor:a=>M(a.palette.primary.main,o?.2:.08)}},children:[s,i!==void 0&&i>0&&t.jsx(n.Box,{component:"span",sx:{position:"absolute",top:-6,right:-6,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:i})]})})}function ju({views:e,activeViewId:r,isDirty:o,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:l,onRestoreView:c,onPermanentDelete:u,onEditView:g,onCloneView:x,onCopyLink:y,onDeleteView:w,onPromoteToGlobal:b,onSetDefaultForAllUsers:z,isReadOnly:h,isAdmin:m=!1,hideViewMenuActions:E,customViewMenuActions:v,viewMenuActionData:T,viewMenuActionTableState:B}){const f=bt(),[$,F]=p.useState(!1),[O,J]=p.useState(!1),[te,L]=p.useState({top:0,left:0}),[S,A]=p.useState(null),[k,Y]=p.useState(null),oe=p.useRef(null),d=p.useRef(null),Q=e.find(P=>P.id===r),ee=Q==null?void 0:Q.isDefault,N=(P,be)=>P.name.localeCompare(be.name),re=e.filter(P=>P.scope==="global"&&!P.isDeleted).sort(N),ue=e.filter(P=>P.scope!=="global"&&!P.isDeleted).sort(N),le=e.filter(P=>P.isFavorite&&!P.isDeleted).sort(N),Z=e.filter(P=>P.isDeleted);p.useEffect(()=>{if($&&d.current){const P=d.current.getBoundingClientRect(),be=320,ke=8;let Pe=P.left+window.scrollX;Pe+be>window.innerWidth-ke&&(Pe=window.innerWidth-be-ke),Pe<ke&&(Pe=ke),L({top:P.bottom+window.scrollY+8,left:Pe})}},[$]),p.useEffect(()=>{const P=be=>{oe.current&&!oe.current.contains(be.target)&&d.current&&!d.current.contains(be.target)&&F(!1)};return $&&document.addEventListener("mousedown",P),()=>{document.removeEventListener("mousedown",P)}},[$]);const de=P=>{if(o&&P!==r){A(P),F(!1);return}i(P),F(!1)},se=()=>{S&&(i(S),A(null))},W=()=>{A(null)},ie=(P,be=!1)=>{const ke=P.scope==="global",Pe=!h&&(!ke||m),Ae=m&&!ke,st=((v==null?void 0:v.length)??0)>0;return t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===P.id?nt(f).bg:"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===P.id?nt(f).hoverBg:f.palette.action.hover}},children:[t.jsxs(n.Button,{onClick:()=>de(P.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===P.id&&t.jsx(D.Check,{sx:{fontSize:16,flexShrink:0}}),r!==P.id&&t.jsx(n.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(n.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===P.id?f.palette.primary.dark:f.palette.text.primary,fontWeight:r===P.id?Ze=>Ze.typography.body2.fontWeight||500:400,fontSize:Ze=>Ze.typography.body2.fontSize||"0.875rem"},children:P.name}),be&&t.jsx(n.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:f.palette.text.secondary,backgroundColor:f.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[Pe&&l&&t.jsx(n.IconButton,{onClick:Ze=>{Ze.stopPropagation(),l(P.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.action.hover}},title:P.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(D.Star,{sx:{fontSize:16}})}),Pe&&a&&!P.isDefault&&t.jsx(n.IconButton,{onClick:Ze=>{Ze.stopPropagation(),a(P.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.action.hover}},title:"Set as default",children:t.jsx(D.RadioButtonUnchecked,{sx:{fontSize:16}})}),(st||(Pe||Ae)&&(g||x||y||w||Ae&&b))&&t.jsx(n.IconButton,{onClick:Ze=>{Ze.stopPropagation(),Y({el:Ze.currentTarget,view:P})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.action.hover}},title:"More actions",children:t.jsx(D.MoreVert,{sx:{fontSize:16}})})]})]},P.id)},fe=P=>t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:f.palette.action.hover},children:[t.jsx(n.Typography,{sx:{color:f.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:P.name}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[c&&t.jsx(n.IconButton,{onClick:be=>{be.stopPropagation(),c(P.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.action.hover}},title:"Restore view",children:t.jsx(D.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(n.IconButton,{onClick:be=>{be.stopPropagation(),u(P.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.action.hover}},title:"Delete permanently",children:t.jsx(D.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},P.id),pe=o||!ee,Me=o;return t.jsxs(n.Box,{sx:{position:"relative"},children:[t.jsxs(n.Button,{ref:d,onClick:()=>F(!$),variant:"outlined",size:"small",endIcon:t.jsx(D.KeyboardArrowDown,{sx:{fontSize:16}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.875rem",textTransform:"none",color:pe?"warning.main":"text.primary",borderColor:pe?"warning.main":M(f.palette.text.primary,.2),bgcolor:pe?M(f.palette.warning.main,.12):"background.paper",borderRadius:"999px",py:.5,px:1.5,transition:"all 0.15s ease","&:hover":{borderColor:pe?"warning.dark":"primary.main",bgcolor:pe?M(f.palette.warning.main,.2):M(f.palette.text.primary,.06),color:pe?"warning.dark":"text.primary"}},title:`View: ${(Q==null?void 0:Q.name)||"Default View"}`,children:[t.jsx(n.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(Q==null?void 0:Q.name)||"Default View"}),Me&&t.jsx(n.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"}})]}),$&&Is.createPortal(t.jsxs(n.Box,{ref:oe,sx:{position:"fixed",width:"320px",backgroundColor:f.palette.background.paper,border:`1px solid ${f.palette.divider}`,borderRadius:1,boxShadow:f.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:te.top,left:te.left},children:[re.length>0&&t.jsxs(n.Box,{sx:{py:.5},children:[t.jsx(n.Typography,{sx:{px:2,py:1,fontSize:P=>P.typography.caption.fontSize||"caption.fontSize",fontWeight:P=>P.typography.caption.fontWeight||600,color:f.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),re.map(P=>ie(P,P.isDefault))]}),le.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(n.Box,{sx:{borderTop:`1px solid ${f.palette.divider}`}}),t.jsxs(n.Box,{sx:{py:.5},children:[t.jsxs(n.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:f.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx(D.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(n.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),le.map(P=>ie(P))]})]}),ue.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(n.Box,{sx:{borderTop:`1px solid ${f.palette.divider}`}}),t.jsxs(n.Box,{sx:{py:.5},children:[t.jsx(n.Typography,{sx:{px:2,py:1,fontSize:P=>P.typography.caption.fontSize||"caption.fontSize",fontWeight:P=>P.typography.caption.fontWeight||600,color:f.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),ue.map(P=>ie(P))]})]}),Z.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(n.Box,{sx:{borderTop:`1px solid ${f.palette.divider}`}}),t.jsxs(n.Box,{sx:{py:.5},children:[t.jsxs(n.Button,{onClick:()=>J(!O),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:f.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.action.hover}},children:[t.jsxs(n.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",Z.length,")"]}),t.jsx(D.ChevronRight,{sx:{fontSize:16}})]}),O&&t.jsx(n.Box,{sx:{backgroundColor:f.palette.action.hover},children:Z.map(P=>fe(P))})]})]}),t.jsx(n.Box,{sx:{borderTop:`1px solid ${f.palette.divider}`}}),t.jsxs(n.Button,{onClick:()=>{s(),F(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:f.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:f.palette.action.hover}},children:[t.jsx(D.Add,{sx:{fontSize:16}}),t.jsx(n.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(n.Popover,{open:!!k,anchorEl:(k==null?void 0:k.el)||null,onClose:()=>Y(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[g&&t.jsxs(n.MenuItem,{onClick:()=>{k&&g(k.view.id),Y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(D.Edit,{sx:{fontSize:18}}),"Edit"]}),y&&t.jsxs(n.MenuItem,{onClick:()=>{k&&y(k.view.id),Y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(D.Link,{sx:{fontSize:18}}),"Copy Link"]}),x&&t.jsxs(n.MenuItem,{onClick:()=>{k&&x(k.view.id),Y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(D.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),b&&m&&(k==null?void 0:k.view.scope)!=="global"&&t.jsxs(n.MenuItem,{onClick:()=>{k&&b(k.view.id),Y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(D.Language,{sx:{fontSize:18}}),"Promote to Global"]}),z&&k&&!(E!=null&&E.includes("setDefaultForAllUsers"))?t.jsxs(n.MenuItem,{onClick:()=>{k&&z(k.view.id,!k.view.isDefaultForAllUsers),Y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(D.Star,{sx:{fontSize:18,color:k.view.isDefaultForAllUsers?"warning.main":"inherit"}}),k.view.isDefaultForAllUsers?"Remove from":"Set as"," Default for All Users"]}):null,v&&v.length>0&&k&&(()=>{const P=k.view,be={allViews:e,activeView:e.find(Ae=>Ae.id===r),currentTableState:B??null,data:T??[],closeMenu:()=>Y(null)},ke=v.filter(Ae=>{var st;return!((st=Ae.hidden)!=null&&st.call(Ae,P,be))});return ke.length===0?null:[!!(g||y||x||b&&m&&P.scope!=="global"||z&&!(E!=null&&E.includes("setDefaultForAllUsers")))?t.jsx(n.Divider,{},"custom-view-actions-divider"):null,...ke.map(Ae=>{var st;return t.jsxs(n.MenuItem,{disabled:(st=Ae.disabled)==null?void 0:st.call(Ae,P,be),onClick:()=>{Ae.onClick(P,be),Y(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[Ae.icon,Ae.label]},Ae.key)})]})(),w&&[t.jsx(n.Divider,{},"delete-divider"),t.jsxs(n.MenuItem,{onClick:()=>{k&&w(k.view.id),Y(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx(D.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(n.Dialog,{open:S!==null,onClose:W,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Fo(f)}},children:[t.jsxs(n.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1,fontSize:f.typography.h4.fontSize||"1.125rem",fontWeight:f.typography.h4.fontWeight||500},children:[t.jsx(D.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),t.jsx(n.DialogContent,{children:t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),t.jsxs(n.DialogActions,{sx:{px:3,pb:2,gap:1},children:[t.jsx(n.Button,{onClick:W,variant:"text",children:"Stay here"}),t.jsx(n.Button,{onClick:se,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function ku({columnName:e,columnType:r="string",currentSort:o,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:l=!1,position:c,onSortAscending:u,onSortDescending:g,onRemoveSort:x,onFilter:y,onClearFilter:w,onGroupByColumn:b,onHideColumn:z,onManageColumns:h,onResetLayout:m,onClose:E}){const v=bt(),T=v.palette,B=p.useRef(null);p.useEffect(()=>{if(!B.current)return;const te=B.current,L=te.getBoundingClientRect(),S=window.innerWidth,A=window.innerHeight;L.right>S-8&&(te.style.left=`${S-L.width-8}px`),L.bottom>A-8&&(te.style.top=`${A-L.height-8}px`)},[c]),p.useEffect(()=>{const te=S=>{B.current&&!B.current.contains(S.target)&&E()},L=S=>{S.key==="Escape"&&E()};return document.addEventListener("mousedown",te),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",te),document.removeEventListener("keydown",L)}},[E]);const f=p.useCallback(te=>()=>{te(),E()},[E]),$=(o==null?void 0:o.direction)==="asc",F=(o==null?void 0:o.direction)==="desc",O=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",J=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return Is.createPortal(t.jsxs(n.Paper,{ref:B,elevation:0,sx:{position:"fixed",left:`${c.x}px`,top:`${c.y}px`,zIndex:v.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:Fo(v),overflow:"hidden",boxShadow:`0 4px 20px ${M(T.common.black,.12)}, 0 1px 4px ${M(T.common.black,.06)}`},children:[!a&&t.jsxs(n.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsx(n.Typography,{sx:{fontSize:te=>te.typography.body2.fontSize||"0.8125rem",fontWeight:te=>te.typography.body2.fontWeight||500,color:"text.primary"},children:"Sorting"}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[t.jsx(n.Tooltip,{title:`Sort Ascending (${O})`,placement:"top",arrow:!0,children:t.jsx(n.IconButton,{size:"small",onClick:f(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:$?"primary.main":"text.secondary",bgcolor:$?M(T.primary.main,.1):"transparent","&:hover":{bgcolor:M(T.primary.main,.08),color:"primary.main"}},children:t.jsx(D.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(n.Tooltip,{title:`Sort Descending (${J})`,placement:"top",arrow:!0,children:t.jsx(n.IconButton,{size:"small",onClick:f(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:F?"primary.main":"text.secondary",bgcolor:F?M(T.primary.main,.1):"transparent","&:hover":{bgcolor:M(T.primary.main,.08),color:"primary.main"}},children:t.jsx(D.ArrowDownward,{sx:{fontSize:16}})})}),t.jsx(n.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:t.jsx("span",{children:t.jsx(n.IconButton,{size:"small",disabled:!s,onClick:f(()=>x(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:M(T.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx(D.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(n.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(n.MenuItem,{onClick:f(()=>y(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(D.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!a&&t.jsxs(n.MenuItem,{onClick:f(()=>w(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:M(T.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(D.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!a&&b&&t.jsxs(t.Fragment,{children:[t.jsx(n.Divider,{sx:{my:.25}}),t.jsx(n.MenuList,{dense:!0,sx:{py:.5},children:t.jsxs(n.MenuItem,{onClick:f(()=>b(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(D.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),t.jsx(n.Divider,{sx:{my:.25}}),t.jsxs(n.MenuList,{dense:!0,sx:{py:.5},children:[!a&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsxs(n.MenuItem,{onClick:f(()=>z(e)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(D.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),t.jsx(n.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:t.jsx(n.IconButton,{size:"small",onClick:f(h),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:M(T.primary.main,.08),color:"primary.main"}},children:t.jsx(D.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(n.MenuItem,{onClick:f(h),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(D.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!a&&l&&m&&t.jsxs(n.MenuItem,{onClick:f(m),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:M(T.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(D.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const Tu=176,js="COLUMN_HEADER",zu=p.memo(function({column:r,index:o,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:l=!1,hasModifications:c=!1,width:u,onColumnClick:g,onMoveColumn:x,onColumnDragEnd:y,onResizeStart:w,onSortAscending:b,onSortDescending:z,onRemoveSort:h,onOpenFilterForColumn:m,onClearFiltersForColumn:E,onGroupByColumn:v,onHideColumn:T,onManageColumns:B,onResetLayout:f}){const F=bt().urmTable,O=p.useRef(null),[J,te]=p.useState(!1),[L,S]=p.useState({x:0,y:0}),[{handlerId:A,isOver:k},Y]=cr.useDrop({accept:js,collect(Z){return{handlerId:Z.getHandlerId(),isOver:Z.isOver()}},hover(Z,de){var P;if(!O.current)return;const se=Z.index,W=o;if(se===W)return;const ie=(P=O.current)==null?void 0:P.getBoundingClientRect(),fe=(ie.right-ie.left)/2,pe=de.getClientOffset(),Me=((pe==null?void 0:pe.x)??0)-ie.left;se<W&&Me<fe||se>W&&Me>fe||(x(se,W),Z.index=W)}}),[{isDragging:oe},d]=cr.useDrag({type:js,item:()=>({index:o,columnName:r.name}),collect:Z=>({isDragging:Z.isDragging()}),end:()=>{y==null||y()}});d(Y(O));const Q=p.useCallback(Z=>{Z.preventDefault(),Z.stopPropagation(),S({x:Z.clientX,y:Z.clientY}),te(!0)},[]),ee=p.useCallback(()=>te(!1),[]),N=p.useCallback(()=>{g(r.name)},[g,r.name]),re=p.useCallback(Z=>{Z.stopPropagation(),m(r.name)},[m,r.name]),ue=p.useCallback(()=>i?t.jsxs(n.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx(D.ArrowUpward,{sx:{fontSize:15,color:"primary.main"}}):t.jsx(D.ArrowDownward,{sx:{fontSize:15,color:"primary.main"}}),t.jsx(n.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(D.FilterList,{onClick:re,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,re]);return t.jsxs(t.Fragment,{children:[t.jsxs(n.TableCell,{ref:O,"data-handler-id":A,"data-column-index":o,onClick:N,onContextMenu:Q,sx:{position:"sticky",top:0,zIndex:5,textAlign:(F==null?void 0:F.cellAlignH)??"left",verticalAlign:(F==null?void 0:F.cellAlignV)??"middle",fontSize:"0.875rem",fontWeight:500,height:33,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(F==null?void 0:F.headerColor)??"text.secondary",opacity:oe?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:k?Z=>M(Z.palette.primary.main,.08):(F==null?void 0:F.headerBg)??"action.hover",boxShadow:Z=>`0 1px 0 ${M(Z.palette.common.black,.08)}`,backgroundImage:"none",borderBottom:(F==null?void 0:F.rowDivider)??"1px solid",borderRight:F==null?void 0:F.colDivider,borderColor:"divider",py:0,px:(F==null?void 0:F.cellPaddingX)??2,"&:hover":{bgcolor:Z=>M(Z.palette.primary.main,.1),color:"text.primary"},width:u?`${u}px`:`${Tu}px`},children:[t.jsxs(n.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[ut(r.name),ue(),le()]}),t.jsx(n.Box,{draggable:!1,onDragStart:Z=>Z.preventDefault(),sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center","&:hover > div":{opacity:1}},onMouseDown:Z=>{Z.preventDefault(),Z.stopPropagation(),w(Z,r.name)},onClick:Z=>Z.stopPropagation(),children:t.jsx(n.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),k&&t.jsx(n.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),J&&t.jsx(ku,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:l,hasModifications:c,position:L,onSortAscending:b,onSortDescending:z,onRemoveSort:h,onFilter:m,onClearFilter:E,onGroupByColumn:v,onHideColumn:T,onManageColumns:B,onResetLayout:f,onClose:ee})]})});function ua({value:e}){const r=e.toLowerCase().trim();return t.jsxs(n.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:"7px",whiteSpace:"nowrap"},children:[t.jsx(n.Box,{component:"span",sx:{width:7,height:7,borderRadius:"50%",flexShrink:0,bgcolor:o=>ws(o,r).color}}),t.jsx(n.Box,{component:"span",sx:{fontSize:"0.75rem",fontWeight:o=>{var i;return(i=o.tokens)!=null&&i.statusBold?700:500},color:o=>ws(o,r).color,lineHeight:1.5,letterSpacing:"0.01em"},children:e})]})}function Bu(e){return t.jsx(ua,{value:e})}function Eu(e,r){if(r==null||r==="")return t.jsx(n.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.875rem"},children:"—"});const o=String(r),i=e.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return Bu(o);if(/\b(priority|severity|urgency)\b/.test(i)){const s=o.toLowerCase().trim();return t.jsx(n.Box,{component:"span",sx:a=>{const l=wu(a,s);return l?{color:l,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:o})}return typeof r=="boolean"?t.jsx(n.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(n.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(n.Box,{component:"span",sx:{fontSize:"0.875rem"},children:o})}function _u(e){const r=e.find(s=>{const a=s.name.toLowerCase();return/\b(name|title|label|subject|task_?name|taskname)\b/.test(a)})||e[0]||null,o=e.find(s=>{const a=s.name.toLowerCase().replace(/[\s_-]/g,"");return/(^id$|id$|_id$|taskid|code$|ref$)/.test(a)&&s!==r})||null,i=e.filter(s=>s!==r&&s!==o).slice(0,4);return{primaryCol:r,idCol:o,bodyColumns:i}}function $u({row:e,rowIndex:r,visibleColumns:o,isSelected:i,onCardClick:s,onCardDoubleClick:a,onCardContextMenu:l,onOpenRowMenu:c,onToggleSelection:u,hideCheckbox:g}){const[x,y]=p.useState(!1),{primaryCol:w,idCol:b,bodyColumns:z}=p.useMemo(()=>_u(o),[o]),h=w?e[w.name]:null,m=b?e[b.name]:null,E=x||i;return t.jsxs(n.Box,{onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),onClick:v=>s(r,v),onDoubleClick:v=>a(e,r,v),onContextMenu:v=>{v.preventDefault(),v.stopPropagation(),l(e,r,v)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:v=>{var B,f,$,F;const T=(F=($=(f=(B=v.components)==null?void 0:B.MuiCard)==null?void 0:f.styleOverrides)==null?void 0:$.root)==null?void 0:F.border;return i?"2px solid":T&&T!=="none"?T:"1px solid"},borderColor:i?v=>nt(v).main:v=>{var B,f,$,F;const T=(F=($=(f=(B=v.components)==null?void 0:B.MuiCard)==null?void 0:f.styleOverrides)==null?void 0:$.root)==null?void 0:F.border;return T&&T!=="none"?"inherit":M(v.palette.divider,.8)},borderWidth:i?2:void 0,borderRadius:v=>{var B,f,$,F;const T=(F=($=(f=(B=v.components)==null?void 0:B.MuiCard)==null?void 0:f.styleOverrides)==null?void 0:$.root)==null?void 0:F.borderRadius;return T!==void 0?typeof T=="number"?`${T}px`:T:`${v.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?v=>`0 0 0 3px ${M(nt(v).main,.15)}, 0 2px 8px ${M(v.palette.common.black,.08)}`:x?v=>{var B,f,$,F;const T=(F=($=(f=(B=v.components)==null?void 0:B.MuiCard)==null?void 0:f.styleOverrides)==null?void 0:$.root)==null?void 0:F.boxShadow;return T&&T!=="none"?T:ge(v,"cardHover")}:v=>{var B,f,$,F;const T=(F=($=(f=(B=v.components)==null?void 0:B.MuiCard)==null?void 0:f.styleOverrides)==null?void 0:$.root)==null?void 0:F.boxShadow;return T&&T!=="none"?T:ge(v,"cardRest")},transform:x&&!i?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...i&&{bgcolor:v=>M(nt(v).main,.03)}},children:[t.jsxs(n.Box,{sx:v=>{var F,O,J,te;const T=((J=(O=(F=v.components)==null?void 0:F.MuiCardHeader)==null?void 0:O.styleOverrides)==null?void 0:J.root)||{},B=(T.backgroundColor&&T.backgroundColor!=="transparent"?T.backgroundColor:void 0)??((te=v.tokens)==null?void 0:te.cardHdrHex)??"transparent",f=T.borderBottom&&T.borderBottom!=="none"?T.borderBottom:void 0,$=T.boxShadow&&T.boxShadow!=="none"?T.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:B,borderBottom:f,boxShadow:$,display:"flex",alignItems:"center",gap:.5}},children:[!g&&E&&t.jsx(n.Checkbox,{size:"small",checked:i,onClick:v=>v.stopPropagation(),onChange:()=>u(e),sx:{p:.25}}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:v=>v.typography.body2.fontWeight||600,fontSize:v=>v.typography.body1.fontSize||"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:h!=null&&h!==""?String(h):t.jsx(n.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})})]}),t.jsx(n.Box,{sx:v=>{var f,$,F;const T=((F=($=(f=v.components)==null?void 0:f.MuiCardHeader)==null?void 0:$.styleOverrides)==null?void 0:F.root)||{};return T.borderBottom&&T.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(n.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[z.map(v=>t.jsxs(n.Box,{sx:{minWidth:0},children:[t.jsx(n.Typography,{sx:{color:"text.secondary",fontWeight:T=>T.typography.body2.fontWeight||500,fontSize:T=>T.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:ut(v.name)}),t.jsx(n.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[v.name]??""),children:Eu(v,e[v.name])})]},v.name)),z.length===0&&t.jsx(n.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic",gridColumn:"1 / -1"},children:"No additional fields visible"})]}),t.jsxs(n.Box,{sx:{px:2,py:1,display:"flex",alignItems:"center",justifyContent:"space-between",borderTop:"1px solid",borderColor:"divider",bgcolor:v=>M(v.palette.action.hover,.1),minHeight:40},children:[t.jsx(n.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.75rem",fontWeight:400,letterSpacing:"0.04em",opacity:m?.85:0,userSelect:"none"},children:m?String(m):" "}),t.jsx(n.Box,{sx:{display:"flex",alignItems:"center",gap:.25,opacity:E?1:0,transition:"opacity 0.15s ease"},onClick:v=>v.stopPropagation(),children:t.jsx(n.Tooltip,{title:"More actions",placement:"top",children:t.jsx(n.IconButton,{size:"small",onClick:v=>{v.stopPropagation(),c(e,r,v.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:v=>M(v.palette.text.primary,.08)}},children:t.jsx(D.MoreVert,{sx:{fontSize:17}})})})})]})]})}function Du({row:e,grouping:r,onToggleCollapse:o}){var i;return t.jsxs(n.Box,{onClick:()=>o(e.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:s=>ge(s,"flatHover"),"&:hover":{bgcolor:s=>M(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx(D.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx(D.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"h5",sx:{fontWeight:s=>s.typography.h5.fontWeight||600,color:s=>s.typography.h5.color||"text.primary"},children:ol(e.groupLevel,((i=r==null?void 0:r.levels[e.groupLevel])==null?void 0:i.column)||"",e.groupValue)}),t.jsxs(n.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>M(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(n.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(e.aggregates).map(([s,a])=>Ws(a)).filter(Boolean).join(" • ")})]})}function Iu({data:e,visibleColumns:r,grouping:o,selectedRowIds:i,isGrouped:s,onToggleGroupCollapse:a,onCardClick:l,onCardDoubleClick:c,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:x,hideSelectionCheckboxes:y}){const w=p.useMemo(()=>{const b=new Set;return i.forEach(z=>{const h=z==null?void 0:z.__urm_row_id__;h!==void 0&&b.add(h)}),b},[i]);return e.length===0?t.jsx(n.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):t.jsx(n.Box,{sx:{fontFamily:b=>b.typography.fontFamily},children:t.jsx(n.Box,{sx:{p:b=>vs(b).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:b=>vs(b).cardGap,alignContent:"start"},children:e.map((b,z)=>s&&b.isGroupHeader?t.jsx(Du,{row:b,grouping:o,onToggleCollapse:a||(()=>{})},`group-${b.groupKey}`):t.jsx($u,{row:b,rowIndex:z,visibleColumns:r,isSelected:w.has(b==null?void 0:b.__urm_row_id__),onCardClick:l,onCardDoubleClick:c,onCardContextMenu:u,onOpenRowMenu:g,onToggleSelection:x,hideCheckbox:y},`card-${z}`))})})}const ks=[10,15,25,50,100];function Ou(e,r){const o=e.trim();if(o==="")return"Page number is required";if(!/^-?\d+$/.test(o))return"Must be a number";const i=parseInt(o,10);return i<1?"Page number must be at least 1":i>r?"Entered page number is out of range":null}function Mu({currentPage:e,pageSize:r,totalRows:o,totalPages:i,selectedCount:s,onClearSelection:a,onPageChange:l,onPageSizeChange:c}){const g=bt().palette,x=i??Math.max(1,Math.ceil(o/r)),[y,w]=p.useState(String(e)),[b,z]=p.useState(null),[h,m]=p.useState(!1),E=p.useRef(null);p.useEffect(()=>{h||(w(String(e)),z(null))},[e,h]);const v=p.useCallback(()=>{const d=Ou(y,x);if(d){z(d);return}const Q=parseInt(y.trim(),10);z(null),m(!1),Q!==e&&l(Q)},[y,x,e,l]),T=p.useCallback(d=>{var Q;d.key==="Enter"?(d.preventDefault(),v()):d.key==="Escape"&&(w(String(e)),z(null),m(!1),(Q=E.current)==null||Q.blur())},[v,e]),B=p.useCallback(()=>{w(String(e)),z(null),m(!1)},[e]),f=p.useCallback(()=>{m(!0),z(null),setTimeout(()=>{var d;return(d=E.current)==null?void 0:d.select()},0)},[]);if(o<=Math.min(...ks))return null;const $=()=>{w(String(e)),z(null),m(!1)},F=()=>{$(),l(1)},O=()=>{$(),e>1&&l(e-1)},J=()=>{$(),e<x&&l(e+1)},te=()=>{$(),l(x)},L=(e-1)*r+1,S=Math.min(e*r,o),A=`${Math.max(2,String(x).length+.5)}ch`,k={width:24,height:24,color:"text.secondary",border:"1px solid",borderColor:"divider",borderRadius:"6px","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"text.disabled",opacity:.4}},Y={width:36,height:36,color:"primary.main",border:"1.5px solid",borderColor:"primary.main",borderRadius:"9px","&:hover":{bgcolor:d=>M(d.palette.primary.main,.08)},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},oe={fontSize:d=>d.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400};return t.jsxs(n.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(n.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[!!s&&s>0&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsxs(n.Typography,{variant:"caption",sx:{fontSize:oe.fontSize,color:"primary.main",fontWeight:600},children:[s," selected"]}),a&&t.jsx(n.Button,{size:"small",onClick:a,sx:{fontSize:"0.75rem",p:0,minWidth:"auto",color:"text.secondary"},children:"Clear"})]}),t.jsxs(n.Typography,{variant:"caption",sx:{...oe,userSelect:"none"},children:[L,"–",S," of ",o]})]}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(n.IconButton,{onClick:F,disabled:e===1,size:"small",title:"First page",sx:k,children:t.jsx(D.FirstPage,{sx:{fontSize:15}})}),t.jsx(n.IconButton,{onClick:O,disabled:e===1,size:"small",title:"Previous page",sx:Y,children:t.jsx(D.ChevronLeft,{sx:{fontSize:18}})}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"baseline",gap:.5,position:"relative"},children:[t.jsx(n.Typography,{variant:"caption",sx:{...oe,userSelect:"none"},children:"Page"}),t.jsxs(n.Box,{sx:{position:"relative"},children:[b&&t.jsx(n.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:M(g.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${M(g.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:M(g.error.main,.4)}},children:t.jsx(n.Typography,{sx:{fontSize:d=>d.typography.caption.fontSize||"0.6875rem",fontWeight:d=>d.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:b})}),t.jsx(n.InputBase,{inputRef:E,value:y,onChange:d=>{w(d.target.value),b&&z(null)},onKeyDown:T,onFocus:f,onBlur:B,inputProps:{"aria-label":`Page number, 1 to ${x}`,style:{textAlign:"center",padding:"2px 0",width:A,fontSize:"1rem",fontWeight:700}},sx:{fontSize:"1rem",fontWeight:700,color:b?"error.main":"primary.main",border:"1px solid",borderColor:b?"error.main":h?"primary.main":"transparent",borderRadius:"4px",bgcolor:b?M(g.error.main,.04):"transparent",px:.5,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:b?"error.main":M(g.primary.main,.4)},"&:focus-within":{boxShadow:b?`0 0 0 2px ${M(g.error.main,.2)}`:`0 0 0 2px ${M(g.primary.main,.2)}`}}})]}),t.jsxs(n.Typography,{variant:"caption",sx:{...oe,userSelect:"none"},children:["of ",x]})]}),t.jsx(n.IconButton,{onClick:J,disabled:e===x,size:"small",title:"Next page",sx:Y,children:t.jsx(D.ChevronRight,{sx:{fontSize:18}})}),t.jsx(n.IconButton,{onClick:te,disabled:e===x,size:"small",title:"Last page",sx:k,children:t.jsx(D.LastPage,{sx:{fontSize:15}})})]}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(n.Typography,{variant:"caption",sx:oe,children:"Rows per page:"}),t.jsx(n.Select,{value:r,onChange:d=>c(Number(d.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:ks.map(d=>t.jsx(n.MenuItem,{value:d,sx:{fontSize:"0.8125rem"},children:d},d))})]})]})}function Au(){return t.jsx(n.Chip,{icon:t.jsx(D.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:e=>e.typography.caption.fontSize||"caption.fontSize",fontWeight:e=>e.typography.caption.fontWeight||500}})}const pa="urm_hint_seen_";function Ru(e){try{return localStorage.getItem(pa+e)==="true"}catch{return!1}}function Wu(e){try{localStorage.setItem(pa+e,"true")}catch{}}const fa={"& .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 xi(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 ma({row:e,schema:r}){const i=bt().palette,s=r.filter(c=>c.name in e),a=s.filter(c=>c.type!=="object"&&c.type!=="array"),l=s.filter(c=>c.type==="object"||c.type==="array");return t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[a.map(c=>t.jsx(n.TextField,{label:ut(c.name),value:xi(e[c.name],c.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:fa},c.name)),l.map(c=>{const u=xi(e[c.name],c.type);return t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontWeight:g=>g.typography.caption.fontWeight||500,fontSize:g=>g.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:ut(c.name)}),t.jsx(n.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:M(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(n.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3,fontSize:c=>c.typography.body2.fontSize||"0.875rem"},children:"No fields to display"})]})}function Pu({open:e,onClose:r,row:o,schema:i,reportName:s}){if(!o)return null;const a=i.filter(l=>l.name in o).length;return t.jsx(it,{open:e,onClose:r,icon:t.jsx(D.VisibilityOutlined,{sx:{fontSize:20}}),title:"View Record",subtitle:s?`· ${s} · ${a} ${a===1?"field":"fields"}`:void 0,width:600,maxHeight:"min(720px, calc(100vh - 80px))",footer:t.jsx(n.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:l=>`${l.shape.borderRadius}px`,minWidth:80},children:"Close"}),children:t.jsx(ma,{row:o,schema:i})})}function Lu({open:e,onClose:r,onConfirm:o,row:i,schema:s}){return t.jsx(it,{open:e,onClose:r,icon:t.jsx(D.WarningAmberRounded,{sx:{fontSize:20}}),iconColor:"error",title:"Delete record?",subtitle:"· This record will be permanently removed.",width:600,maxHeight:"min(720px, calc(100vh - 80px))",footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:a=>`${a.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:()=>{o(),r()},variant:"contained",startIcon:t.jsx(D.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:a=>`${a.shape.borderRadius}px`,boxShadow:a=>ge(a,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:a=>ge(a,"hoverButton")},"&:active":{boxShadow:a=>ge(a,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[i&&s&&t.jsx(ma,{row:i,schema:s}),t.jsx(n.Box,{sx:{p:2,borderRadius:"8px",bgcolor:a=>M(a.palette.error.main,.1),border:a=>`1px solid ${M(a.palette.error.main,.5)}`},children:t.jsx(n.Typography,{variant:"body2",sx:{fontSize:a=>a.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:a=>a.typography.body2.fontWeight||500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})]})})}function Fu({open:e,onClose:r,onSave:o,row:i,schema:s,reportName:a}){const c=bt().palette,[u,g]=p.useState({});if(p.useEffect(()=>{e&&i&&g({...i})},[e,i]),!i)return null;const x=s.filter(m=>m.name in i),y=x.filter(m=>m.type!=="object"&&m.type!=="array"),w=x.filter(m=>m.type==="object"||m.type==="array"),b=(m,E)=>{g(v=>({...v,[m]:E}))},z=()=>{const m={...u};x.forEach(E=>{const v=u[E.name];if(E.type==="number"){const T=Number(v);m[E.name]=isNaN(T)?i[E.name]:T}else E.type==="boolean"&&(m[E.name]=!!v)}),o(m),r()},h=x.length;return t.jsx(it,{open:e,onClose:r,icon:t.jsx(D.EditOutlined,{sx:{fontSize:20}}),title:"Edit Record",subtitle:a?`· ${a} · ${h} ${h===1?"field":"fields"}`:void 0,width:600,maxHeight:"min(760px, calc(100vh - 80px))",footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:r,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:m=>`${m.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:z,variant:"contained",startIcon:t.jsx(D.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:m=>`${m.shape.borderRadius}px`,minWidth:90},children:"Save"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[y.map(m=>{const E=u[m.name];return m.type==="boolean"?t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontWeight:v=>v.typography.caption.fontWeight||500,fontSize:v=>v.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:ut(m.name)}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(n.Switch,{checked:!!E,onChange:v=>b(m.name,v.target.checked),size:"small"}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:v=>v.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:E?"Enabled":"Disabled"})]})]},m.name):t.jsx(n.TextField,{label:ut(m.name),value:E??"",onChange:v=>b(m.name,v.target.value),type:m.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:fa},m.name)}),w.length>0&&t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:w.map(m=>{const E=xi(i[m.name],m.type);return t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75},children:[t.jsx(n.Typography,{variant:"caption",sx:{fontSize:v=>v.typography.caption.fontSize||"0.75rem",fontWeight:v=>v.typography.caption.fontWeight||500,color:"text.secondary"},children:ut(m.name)}),t.jsx(n.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:M(c.text.secondary,.07),color:"text.secondary",border:"none"}}),t.jsx(n.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:t.jsx(D.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),t.jsx(n.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:M(c.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:E?"text.primary":"text.disabled",fontStyle:E?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:E||"No value"})]},m.name)})}),x.length===0&&t.jsxs(n.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx(D.EditOutlined,{sx:{fontSize:40,opacity:.4}}),t.jsx(n.Typography,{variant:"body2",children:"No editable fields"})]})]})})}const Nu=176,Vu=170,Hu=40;function ha(e){return e.type==="date"?180:Nu}function Gu(e,r){return r!=null&&r!==Vu&&r!==ha(e)}function Uu(e,r,o){return p.useMemo(()=>{const i=e.map(y=>({name:y.name,width:r[y.name]??ha(y),explicit:Gu(y,r[y.name])})),s={};i.forEach(y=>{s[y.name]=y.width});const a=i.reduce((y,w)=>y+w.width,0),c=Math.max(0,o-Hu)-a;if(c<=0)return{widths:s,fillerWidth:0};const u=i.filter(y=>!y.explicit);if(u.length===0)return{widths:s,fillerWidth:c};const g=u.reduce((y,w)=>y+w.width,0)||1;let x=0;return u.forEach((y,w)=>{const z=w===u.length-1?y.width+c-x:Math.round(y.width+c*y.width/g);s[y.name]=z,x+=z-y.width}),{widths:s,fillerWidth:0}},[e,r,o])}const Ts=176,Yu=At(),qu={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function Ju(e){return t.jsx(ua,{value:e})}function Ku(e){const r=e.toLowerCase().trim(),o=qu[r];return o?t.jsx(n.Box,{component:"span",sx:{color:o,fontWeight:500,fontSize:"inherit"},children:e}):e}function Xu(e,r){const o=r.trim();if(!o)return e;const i=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.split(new RegExp(`(${i})`,"gi"));return s.length===1?e:s.map((a,l)=>a.toLowerCase()===o.toLowerCase()?t.jsx(n.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:a},l):a)}function Qu(e,r,o,i=""){if(r==null||r==="")return t.jsx(n.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 Ju(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return Ku(s);if(e.type==="date"){const c=e.dateFormat??"iso",u=Ya(r,c,o??null);return t.jsx(n.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(n.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(n.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(n.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 Xu(s,i)}function Zu({schema:e,data:r,sortStack:o=[],filters:i=Yu,views:s=[],activeViewId:a="",isDirty:l=!1,isExporting:c=!1,columnVisibility:u={},columnOrder:g=[],columnWidths:x={},grouping:y=null,classTokens:w={},onSort:b,onSortAscending:z,onSortDescending:h,onOpenFilters:m,onOpenSort:E,onOpenFilterForColumn:v,onSelectView:T,onCreateView:B,onUpdateCurrentView:f,onSaveAsNewView:$,onDiscardChanges:F,onToggleDefault:O,onToggleFavorite:J,onRestoreView:te,onPermanentDelete:L,onEditView:S,onCloneView:A,onCopyLink:k,onDeleteView:Y,onPromoteToGlobal:oe,onSetDefaultForAllUsers:d,isAdmin:Q=!1,hideViewMenuActions:ee,customViewMenuActions:N,viewMenuActionData:re,viewMenuActionTableState:ue,onExport:le,onOpenColumns:Z,onUpdateColumnWidth:de,onUpdateColumnOrder:se,onUpdateColumnVisibility:W,onClearFiltersForColumn:ie,onResetLayout:fe,onOpenGroup:pe,onGroupByColumn:Me,onToggleGroupCollapse:P,onExpandAllGroups:be,onCollapseAllGroups:ke,onOpenAuditHistory:Pe,onOpenScheduledReports:Ae,searchQuery:st,highlightQuery:Ze="",searchHistory:Wt=[],onAddToSearchHistory:Bt,onToggleSearchFavourite:Xt,onDeleteSearchHistory:Wr,selectedRowIds:Qt=new Set,onSearchChange:Pr,onToggleRowSelection:qe,onToggleAllRows:Et,onRangeSelection:Lr,onClearSelection:lt,onExportSelected:Zt,currentPage:Pt=1,pageSize:Fr=15,totalRowsBeforePagination:Lt=r.length,totalPagesOverride:_t,onPageChange:Ft,onPageSizeChange:ct,isReadOnly:Le=!1,userRole:Nr,reportName:Vr,onEditRow:ur,onDuplicateRow:pr,onDeleteRow:er,showDevPanel:fo=!1,onOpenDevConfig:Cr,rowActions:$t,hideDefaultRowActions:Ve,hideToolbarActions:Se,customSettingsActions:Nt,jsonGuideContent:mo,jsonGuideTitle:ho,viewOptions:Hr,defaultViewMode:Gr,bulkActions:tr,hideSelectionCheckboxes:je,rowClickBehavior:fr="select",openModalOn:ot,onRowClick:ht,onRowRightClick:G}){var Ko;const K=bt().urmTable,[at,mr]=p.useState(null),[rr,xo]=p.useState(0),[hr,jr]=p.useState(0),[vt,or]=p.useState(null),kr=Ar(),ve=((Ko=kr.dates)==null?void 0:Ko.displayFormat)??null,[St,Ur]=p.useState(null),[U,Ke]=p.useState(null),[Te,pt]=p.useState(null),[Tr,xt]=p.useState(!1),[go,Vt]=p.useState(!1),[zr,Yr]=p.useState(null),[Ht,Br]=p.useState(!1),[qr,Er]=p.useState(null),[_r,$r]=p.useState(null),[we,ae]=p.useState(null),[me,Ce]=p.useState(null),We=p.useRef(null),Xe=p.useCallback(()=>{We.current&&(clearTimeout(We.current),We.current=null)},[]),ft=p.useCallback(()=>{Xe(),We.current=setTimeout(()=>Ce(null),200)},[Xe]);p.useEffect(()=>Xe,[Xe]);const[dt,wt]=p.useState(null),Gt=p.useMemo(()=>Hr??["list","grid"],[Hr]),[xr,Dr]=p.useState(()=>Gr??Gt[0]??"list"),[yo,No]=p.useState(!1),[Jr,An]=p.useState(()=>!Ru("toolbar_search")),Kr=p.useRef(null),bo=p.useRef(null),[Rn,Vo]=p.useState(0);p.useLayoutEffect(()=>{const j=Kr.current;if(!j)return;Vo(j.clientWidth);const H=new ResizeObserver(ne=>{Vo(ne[0].contentRect.width)});return H.observe(j),()=>H.disconnect()},[]);const Xr=p.useCallback(()=>{Wu("toolbar_search"),An(!1)},[]);p.useEffect(()=>{if(!Jr)return;const j=setTimeout(Xr,2e3);return()=>clearTimeout(j)},[Jr,Xr]);const Ho=p.useMemo(()=>{const j=vt??g;return j.length>0?j.map(H=>e.find(ne=>ne.name===H)).filter(H=>H!==void 0):e},[vt,g,e]),Qr=p.useMemo(()=>Ho.filter(j=>u[j.name]!==!1),[Ho,u]),vo=p.useMemo(()=>new Set(((y==null?void 0:y.levels)??[]).map(j=>j.column)),[y]),So=!!(y!=null&&y.enabled&&(y!=null&&y.levels)&&y.levels.length>0),Zr=p.useMemo(()=>{if(!So)return Qr;const j=((y==null?void 0:y.levels)??[]).map(ne=>e.find(Ee=>Ee.name===ne.column)).filter(ne=>ne!==void 0),H=Qr.filter(ne=>!vo.has(ne.name));return[...j,...H]},[Qr,So,vo,y,e]),{widths:eo}=Uu(Zr,x,Rn),Go=p.useMemo(()=>e.filter(j=>u[j.name]===!1).length,[e,u]),Uo=p.useMemo(()=>e.map(j=>j.name),[e]),Wn=p.useMemo(()=>g.length===0?!1:JSON.stringify(g)!==JSON.stringify(Uo),[g,Uo]),Pn=p.useCallback((j,H)=>{j.preventDefault(),j.stopPropagation(),mr(H),xo(j.clientX),jr(x[H]||150)},[x]);p.useEffect(()=>{if(!at)return;const j=ne=>{const Ee=ne.clientX-rr,tt=Math.max(100,Math.min(600,hr+Ee));de==null||de(at,tt)},H=()=>{mr(null)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",H),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",H)}},[at,rr,hr,de]);const Ln=p.useCallback(j=>j==null?"-":typeof j=="object"?JSON.stringify(j):typeof j=="boolean"?j?"true":"false":String(j),[]);p.useCallback(j=>{const H=o.find(ne=>ne.column===j);return H?t.jsxs(n.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[H.direction==="asc"?t.jsx(D.ArrowUpward,{sx:{fontSize:14}}):t.jsx(D.ArrowDownward,{sx:{fontSize:14}}),t.jsx(n.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:H.priority})]}):null},[o]),p.useCallback(j=>di(i,j)?t.jsx(n.IconButton,{size:"small",onClick:ne=>{ne.stopPropagation(),v==null||v(j)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx(D.FilterList,{sx:{fontSize:14}})}):null,[i,v]);const Fn=p.useCallback(j=>{b&&b(j)},[b]),Nn=p.useCallback((j,H)=>{or(ne=>{const tt=[...ne??(g.length>0?g:e.map(rt=>rt.name))],[Ge]=tt.splice(j,1);return tt.splice(H,0,Ge),tt})},[g,e]),Vn=p.useCallback(()=>{vt&&se&&se(vt),or(null)},[vt,se]),Hn=p.useCallback(j=>{if(!b)return;const H=o.find(ne=>ne.column===j);(!H||H.direction!=="asc")&&b(j)},[b,o]),Gn=p.useCallback(j=>{if(!b)return;const H=o.find(ne=>ne.column===j);H?H.direction==="asc"&&b(j):(b(j),setTimeout(()=>b(j),0))},[b,o]),Un=p.useCallback(j=>{if(!b)return;const H=o.find(ne=>ne.column===j);H&&(H.direction==="asc"?(b(j),setTimeout(()=>b(j),0)):H.direction==="desc"&&b(j))},[b,o]),Yn=p.useCallback(j=>{W&&W(j,!1)},[W]),to=!!(y!=null&&y.enabled&&(y!=null&&y.levels)&&y.levels.length>0),wo=p.useMemo(()=>Tt(i),[i]),qn=o.length>0||wo>0||((y==null?void 0:y.enabled)??!1)||Object.values(u).some(j=>j===!1),Jn=(Pt-1)*Fr,He=r,et=p.useMemo(()=>{const j=new Set;return Qt.forEach(H=>{const ne=H==null?void 0:H.__urm_row_id__;ne!==void 0&&j.add(ne)}),j},[Qt]);p.useEffect(()=>{const j=H=>{!Et||!lt||H.target instanceof HTMLInputElement||H.target instanceof HTMLTextAreaElement||((H.ctrlKey||H.metaKey)&&H.key==="a"&&(H.preventDefault(),Et(!0,He)),H.key==="Escape"&&(H.preventDefault(),lt()))};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[Et,lt,He]);const Co=p.useCallback((j,H)=>{ht==null||ht(He[j],j,H),(fr==="activate"||fr==="both")&&(pt(He[j]),xt(!0)),fr!=="activate"&&qe&&(H.shiftKey&&St!==null?(H.preventDefault(),Lr&&Lr(St,j,He)):(qe(He[j]),Ur(j)))},[qe,St,Lr,He,ht,fr,pt,xt]),Ut=p.useMemo(()=>He.filter(j=>!j.isGroupHeader),[He]),Yo=p.useMemo(()=>Ut.length>0&&et.size>0&&Ut.every(j=>et.has(j==null?void 0:j.__urm_row_id__)),[Ut,et]),ro=!Yo&&Ut.some(j=>et.has(j==null?void 0:j.__urm_row_id__)),nr=!!(qe&&Et&&!je),ir=p.useMemo(()=>Zr,[Zr]),qo=p.useMemo(()=>{const j=new Map;if(!(y!=null&&y.enabled)||!He)return j;let H=[];for(const ne of He)if(ne.__isGroupHeader||ne.isGroupHeader){const Ee=ne.groupLevel??0;H[Ee]=ne.groupKey,H=H.slice(0,Ee+1),j.has(ne.groupKey)||j.set(ne.groupKey,[])}else if(ne.__urm_is_grouped_data_row__)for(const Ee of H)Ee&&j.has(Ee)&&j.get(Ee).push(ne);return j},[y,He]),Kn=p.useCallback(j=>{const H=j.groupLevel,ne=H===0?w.groupRowLevel0||"urm-group-level-0":H===1?w.groupRowLevel1||"urm-group-level-1":w.groupRowLevel2||"urm-group-level-2",Ee=H===0?_e=>_e.palette.mode==="dark"?M(_e.palette.action.hover,.12):_e.palette.action.hover:_e=>_e.palette.mode==="dark"?M(_e.palette.action.hover,.06):M(_e.palette.action.hover,.5),tt=String(j.groupValue??"(empty)"),Ge=`${j.rowCount} ${j.rowCount===1?"item":"items"}`,rt=qo.get(j.groupKey)||[],he=rt.filter(_e=>et.has(_e==null?void 0:_e.__urm_row_id__)).length,It=rt.length>0&&he===rt.length,Ot=he>0&&he<rt.length;return t.jsxs(n.TableRow,{onClick:()=>P==null?void 0:P(j.groupKey),className:`urm-group-header-row urm-group-level-${H} ${ne} ${w.groupRow||""}`,sx:{bgcolor:Ee,"&:hover":{bgcolor:_e=>M(_e.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[nr&&t.jsx(n.TableCell,{padding:"checkbox",onClick:_e=>_e.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(n.Checkbox,{size:"small",checked:It,indeterminate:Ot,onChange:()=>{if(!qe)return;const _e=!It;rt.forEach(sr=>{const Xo=et.has(sr==null?void 0:sr.__urm_row_id__);_e!==Xo&&qe(sr)})}})}),t.jsxs(n.TableCell,{colSpan:ir.length,className:`urm-group-cell ${w.groupCellFirst||""} ${w.groupCell||""}`,sx:{pl:`${H*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[H>0&&t.jsx(n.Box,{sx:{position:"absolute",left:`${H*24+4}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsxs(n.Box,{className:`urm-group-content ${w.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(n.Box,{className:`urm-group-caret ${w.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:j.isCollapsed?t.jsx(D.ChevronRight,{sx:{fontSize:18}}):t.jsx(D.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(n.Typography,{variant:"h5",className:`urm-group-title ${w.groupTitle||""}`,sx:{fontWeight:H===0?600:500,fontSize:H===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:tt}),!j.isCollapsed&&t.jsx(n.Box,{className:"urm-group-column-heading-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:_e=>M(_e.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:_e=>M(_e.palette.primary.main,.2),ml:.5},children:ut(j.groupColumn||"")}),!!j.__urm_is_continuation_header__&&t.jsx(n.Box,{className:"urm-group-continuation-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:_e=>M(_e.palette.text.secondary,.05),color:"text.secondary",borderRadius:"10px",border:"1px dashed",borderColor:"divider",ml:.5},children:"Continued"}),t.jsx(n.Box,{className:`urm-group-count ${w.groupBadge||""} ${w.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:_e=>M(_e.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:Ge}),Object.keys(j.aggregates||{}).length>0&&t.jsxs(n.Typography,{variant:"caption",className:`urm-group-aggregates ${w.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(j.aggregates).map(([_e,sr])=>Ws(sr)).filter(Boolean).join(" • "),")"]})]})]})]},j.groupKey)},[ir,nr,y,e,P,w,K,qo,et,qe]),Jo=p.useCallback((j,H)=>{const ne=et.has(j==null?void 0:j.__urm_row_id__),Ee=U===H,tt=Tr&&(j==null?void 0:j.__urm_row_id__)===(Te==null?void 0:Te.__urm_row_id__),Ge=!!(j!=null&&j.__urm_is_grouped_data_row__),rt=Ge?j.__urm_group_level__??(y==null?void 0:y.levels.length)??1:0;return t.jsxs(n.TableRow,{"data-row-index":H,className:Ge?`urm-data-row-grouped ${w.dataRowGrouped||""}`:"",onMouseEnter:()=>Ke(H),onMouseLeave:()=>Ke(null),onClick:he=>{he.target.closest("[data-row-action-btn]")||Co(H,he)},onDoubleClick:()=>{ot!=null&&ot.includes("doubleClick")&&(pt(j),xt(!0))},onContextMenu:he=>{he.preventDefault(),he.stopPropagation(),G==null||G(j,H,he),Ce(null),ae({mouseX:he.clientX,mouseY:he.clientY,row:j,rowIndex:H}),ot!=null&&ot.includes("rightClick")&&(pt(j),xt(!0))},sx:{cursor:"pointer",bgcolor:ne?he=>nt(he).bg:tt?he=>M(he.palette.info.main,.12):K!=null&&K.striped&&H%2===1?K.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:ne?he=>nt(he).hoverBg:tt?he=>M(he.palette.info.main,.2):he=>`var(--highlight-hover-row, ${M(nt(he).main,.04)})`},borderBottom:(K==null?void 0:K.rowDivider)??"1px solid",borderColor:"divider"},children:[nr&&t.jsx(n.TableCell,{padding:"checkbox",onClick:he=>he.stopPropagation(),sx:{borderBottom:(K==null?void 0:K.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(K==null?void 0:K.cellAlignV)??"middle"},children:t.jsx(n.Checkbox,{size:"small",checked:ne,onChange:()=>qe==null?void 0:qe(j)})}),ir.map((he,It)=>{const Ot=It===0;return t.jsxs(n.TableCell,{className:Ge&&Ot?`urm-data-cell-grouped ${w.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(K==null?void 0:K.rowPaddingY)??"6px",px:(K==null?void 0:K.cellPaddingX)??2,pl:Ge&&Ot?`${rt*24}px`:void 0,position:"relative",textAlign:(K==null?void 0:K.cellAlignH)??"left",verticalAlign:(K==null?void 0:K.cellAlignV)??"middle",fontSize:"0.875rem",fontWeight:400,color:"text.primary",borderBottom:(K==null?void 0:K.rowDivider)??"1px solid",borderRight:K==null?void 0:K.colDivider,borderColor:"divider",minWidth:x[he.name]?`${x[he.name]}px`:`${he.type==="date"?Math.max(Ts,180):Ts}px`},children:[Ge&&Ot&&rt>0&&t.jsx(n.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsx(n.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%"},children:t.jsx("span",{className:`urm-item-title ${w.itemTitle||""}`,children:Qu(he,j[he.name],ve,Ze)})})]},he.name)}),t.jsx(n.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:0,minWidth:0,maxWidth:0,p:0,border:"none",background:"transparent",opacity:Ee?1:0,transition:"opacity 0.12s ease",zIndex:10},children:t.jsx(n.Box,{sx:{position:"absolute",right:8,top:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"flex-end",zIndex:10},children:t.jsx(n.IconButton,{"data-row-action-btn":"true",size:"small",onClick:he=>{he.stopPropagation(),he.preventDefault(),Ce(null),ae({anchorEl:he.currentTarget,row:j,rowIndex:H})},sx:{color:"text.secondary",opacity:Ee?1:0,transition:"opacity 0.12s ease",pointerEvents:Ee?"auto":"none","&:hover":{bgcolor:he=>M(he.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(D.MoreVert,{sx:{fontSize:18}})})})})]},H)},[Qt,Jn,U,Co,Zr,x,Ze,Ln,ur,pr,er,qe,nr,pt,xt,Te,Tr,ae,to,vo,G,ot,et,K,w]);return t.jsxs(cr.DndProvider,{backend:gi.HTML5Backend,children:[t.jsxs(n.Box,{sx:j=>{var Ge,rt,he;const H=((he=(rt=(Ge=j.components)==null?void 0:Ge.MuiCard)==null?void 0:rt.styleOverrides)==null?void 0:he.root)||{},ne=H.border&&H.border!=="none"?H.border:"1px solid",Ee=H.borderRadius!==void 0?typeof H.borderRadius=="number"?`${H.borderRadius}px`:H.borderRadius:`${j.shape.borderRadius}px`,tt=H.boxShadow&&H.boxShadow!=="none"?H.boxShadow:ge(j,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:ne,borderColor:ne!=="none"?"divider":void 0,borderRadius:Ee,boxShadow:tt,overflow:"hidden"}},children:[t.jsxs(n.Box,{sx:j=>{var Ge,rt,he,It,Ot;const H=((he=(rt=(Ge=j.components)==null?void 0:Ge.MuiCardHeader)==null?void 0:rt.styleOverrides)==null?void 0:he.root)||{},ne=(H.backgroundColor&&H.backgroundColor!=="transparent"?H.backgroundColor:void 0)??((It=j.tokens)==null?void 0:It.cardHdrHex)??((Ot=j.urmTable)==null?void 0:Ot.headerBg)??j.palette.background.paper,Ee=H.borderBottom&&H.borderBottom!=="none"?H.borderBottom:"1px solid",tt=H.boxShadow&&H.boxShadow!=="none"?H.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:ne,borderBottom:Ee,borderColor:Ee!=="none"?"divider":void 0,boxShadow:tt,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Le&&t.jsx(Au,{}),T&&B&&f&&s.length>0&&t.jsx(ju,{views:s||[],activeViewId:a||"",isDirty:l,onSelectView:T,onCreateView:B,onToggleDefault:O,onToggleFavorite:J,onRestoreView:te,onPermanentDelete:L,onEditView:S,onCloneView:A,onCopyLink:k,onDeleteView:Y,onPromoteToGlobal:oe,onSetDefaultForAllUsers:d,isAdmin:Q,hideViewMenuActions:ee,customViewMenuActions:N,viewMenuActionData:re,viewMenuActionTableState:ue,isReadOnly:Le}),l&&!Le&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[f&&t.jsx(n.Button,{onClick:f,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:j=>`var(--urm-btn-save-current-bg, ${j.palette.primary.main})`,color:j=>`var(--urm-btn-save-current-color, ${j.palette.primary.contrastText})`,textTransform:"none",boxShadow:j=>ge(j,"restButton"),"&:hover":{bgcolor:j=>`var(--urm-btn-save-current-hover-bg, ${j.palette.primary.dark})`,boxShadow:j=>ge(j,"hoverButton")}},children:"Save current view"}),$&&t.jsx(n.Button,{onClick:$,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:j=>`var(--urm-btn-save-new-border, ${j.palette.primary.main})`,color:j=>`var(--urm-btn-save-new-color, ${j.palette.primary.main})`,bgcolor:j=>`var(--urm-btn-save-new-bg, ${j.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:j=>`var(--urm-btn-save-new-hover-border, ${j.palette.primary.dark})`,bgcolor:j=>`var(--urm-btn-save-new-hover-bg, ${M(j.palette.primary.main,.08)})`}},children:"Save new view"}),F&&t.jsx(n.Button,{onClick:F,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:j=>`var(--urm-btn-discard-bg, ${M(j.palette.text.primary,.12)})`,color:j=>`var(--urm-btn-discard-color, ${j.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:j=>`var(--urm-btn-discard-hover-bg, ${M(j.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),Pr&&Bt&&Xt&&Wr&&!(Se!=null&&Se.includes("search"))&&t.jsx(n.Tooltip,{open:Jr,title:t.jsxs(n.Box,{sx:{p:.5},children:[t.jsx(n.Typography,{variant:"caption",sx:{display:"block",fontWeight:j=>j.typography.caption.fontWeight||500,mb:.25},children:"💡 Search tip"}),t.jsx(n.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:Xr},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:t.jsx(n.Box,{component:"span",children:t.jsx(bu,{value:st||"",onChange:j=>{Jr&&Xr(),Pr(j)},searchHistory:Wt,onAddToHistory:Bt,onToggleFavourite:Xt,onDeleteHistory:Wr,disabled:Le})})}),!Le&&E&&!(Se!=null&&Se.includes("sort"))&&t.jsx(sn,{title:"Sort",onClick:E,active:o.length>0,badge:o.length,children:t.jsx(D.SwapVert,{sx:{fontSize:20}})}),!Le&&m&&!(Se!=null&&Se.includes("filter"))&&t.jsx(sn,{title:"Filter",onClick:m,active:wo>0,badge:wo,children:t.jsx(D.FilterList,{sx:{fontSize:20}})}),!Le&&Z&&!(Se!=null&&Se.includes("columns"))&&t.jsx(sn,{title:"Show/Hide Columns",onClick:Z,active:Go>0||Wn,badge:Go,children:t.jsx(D.ViewColumn,{sx:{fontSize:20}})}),to&&(be||ke)&&(()=>{var ne;const j=(((ne=y==null?void 0:y.collapsedGroups)==null?void 0:ne.length)??0)>0,H=j?be:ke;return H?t.jsx(sn,{title:j?"Expand all groups":"Collapse all groups",onClick:H,children:j?t.jsx(D.UnfoldMore,{sx:{fontSize:20}}):t.jsx(D.UnfoldLess,{sx:{fontSize:20}})}):null})(),!(Se!=null&&Se.includes("jsonGuide"))&&t.jsx(n.Tooltip,{title:"JSON format guide",children:t.jsx(n.IconButton,{size:"small",onClick:()=>No(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:j=>M(j.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(D.InfoOutlined,{sx:{fontSize:20}})})}),fo&&Cr&&t.jsx(n.Tooltip,{title:"Developer configuration",children:t.jsx(n.IconButton,{size:"small",onClick:Cr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:j=>M(j.palette.text.secondary,.3),"&:hover":{bgcolor:j=>M(j.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx(D.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(n.Box,{sx:{flexGrow:1}}),Gt.length>1&&t.jsx(n.Box,{sx:{display:"flex",alignItems:"stretch",height:30,border:"1px solid",borderColor:j=>M(j.palette.text.primary,.2),borderRadius:"8px",overflow:"hidden",ml:.5},children:Gt.map((j,H)=>{const ne=xr===j,Ee=j==="list"?t.jsx(D.TableRows,{sx:{fontSize:18}}):t.jsx(D.GridView,{sx:{fontSize:18}}),tt=j==="list"?"List view":"Grid view";return t.jsx(n.Tooltip,{title:tt,children:t.jsx(n.IconButton,{size:"small",onClick:()=>Dr(j),"aria-pressed":ne,sx:{width:36,borderRadius:0,borderLeft:H>0?"1px solid":"none",borderColor:Ge=>M(Ge.palette.text.primary,.2),color:ne?"primary.contrastText":"text.secondary",bgcolor:ne?"primary.main":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:ne?"primary.dark":Ge=>M(Ge.palette.text.primary,.06)}},children:Ee})},j)})}),!(Se!=null&&Se.includes("settings"))&&t.jsx(n.Tooltip,{title:"More actions",children:t.jsx(n.IconButton,{onClick:j=>wt(j.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:j=>M(j.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(D.MoreVert,{sx:{fontSize:20}})})})]}),t.jsxs(n.Popover,{open:!!dt,anchorEl:dt,onClose:()=>wt(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:200,py:.5,borderRadius:1.5,boxShadow:3}},children:[le&&!(Se!=null&&Se.includes("export"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{le(),wt(null)},disabled:c,sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.Download,{sx:{fontSize:j=>j.typography.body1.fontSize,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Export"})]}),!Le&&pe&&!(Se!=null&&Se.includes("grouping"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{pe(),wt(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Grouping"})]}),Pe&&!(Se!=null&&Se.includes("auditHistory"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{Pe(),wt(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Audit History"})]}),Ae&&!(Se!=null&&Se.includes("scheduledReports"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{Ae(),wt(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Scheduled Reports"})]}),Nt==null?void 0:Nt.map(j=>t.jsxs(n.MenuItem,{dense:!0,disabled:j.disabled,onClick:()=>{j.onClick(),wt(null)},sx:{py:1,px:2,gap:1.5},children:[j.icon,t.jsx(n.Typography,{variant:"body2",children:j.label})]},j.key))]}),t.jsxs(n.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[tr&&tr.length>0&&et.size>0&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:j=>nt(j).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(n.Typography,{variant:"body2",sx:{fontWeight:j=>j.typography.body2.fontWeight||600,mr:1},children:[et.size," selected"]}),t.jsx(n.Button,{size:"small",onClick:()=>lt==null?void 0:lt(),children:"Clear"}),tr.map(j=>{var ne,Ee;const H=Array.from(Qt);return(ne=j.hidden)!=null&&ne.call(j,H)?null:t.jsx(n.Button,{size:"small",variant:"outlined",startIcon:j.icon,disabled:(Ee=j.disabled)==null?void 0:Ee.call(j,H),onClick:()=>j.onClick(H),children:j.label},j.key)})]}),xr!=="list"&&t.jsx(n.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(Iu,{data:He,visibleColumns:Qr,grouping:y,selectedRowIds:Qt,isGrouped:!!to,onToggleGroupCollapse:P,onCardClick:(j,H)=>Co(j,H),onCardDoubleClick:j=>{ot!=null&&ot.includes("doubleClick")&&(pt(j),xt(!0))},onCardContextMenu:(j,H,ne)=>{G==null||G(j,H,ne),Ce(null),ae({mouseX:ne.clientX,mouseY:ne.clientY,row:j,rowIndex:H}),ot!=null&&ot.includes("rightClick")&&(pt(j),xt(!0))},onOpenRowMenu:(j,H,ne)=>ae({anchorEl:ne,row:j,rowIndex:H}),onToggleSelection:j=>qe==null?void 0:qe(j),hideSelectionCheckboxes:je})}),xr==="list"&&t.jsxs(n.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(n.Box,{ref:Kr,onScroll:j=>{bo.current&&(bo.current.scrollLeft=j.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:t.jsxs(n.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(eo).reduce((j,H)=>j+H,0)}px`},children:[t.jsxs("colgroup",{children:[nr&&t.jsx("col",{style:{width:"40px"}}),ir.map(j=>t.jsx("col",{style:{width:`${eo[j.name]}px`}},j.name))]}),t.jsx(n.TableHead,{children:t.jsxs(n.TableRow,{sx:{bgcolor:(K==null?void 0:K.headerBg)??"action.hover",borderBottom:(K==null?void 0:K.rowDivider)??"1px solid",borderColor:"divider"},children:[nr&&t.jsx(n.TableCell,{padding:"checkbox",sx:{borderBottom:(K==null?void 0:K.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(K==null?void 0:K.cellAlignV)??"middle"},children:t.jsx(n.Checkbox,{size:"small",checked:Yo,indeterminate:ro,onChange:j=>Et==null?void 0:Et(j.target.checked,He)})}),ir.map((j,H)=>t.jsx(zu,{column:j,index:H,sortRule:o.find(ne=>ne.column===j.name),hasFilters:di(i,j.name),isInSortStack:o.some(ne=>ne.column===j.name),isReadOnly:Le,hasModifications:qn,width:x[j.name],onColumnClick:Fn,onMoveColumn:Nn,onColumnDragEnd:Vn,onResizeStart:Pn,onSortAscending:z||Hn,onSortDescending:h||Gn,onRemoveSort:Un,onOpenFilterForColumn:v||(()=>{}),onClearFiltersForColumn:ie||(()=>{}),onGroupByColumn:Me,onHideColumn:Yn,onManageColumns:Z||(()=>{}),onResetLayout:fe},j.name))]})})]})}),t.jsx(n.Box,{ref:bo,onScroll:j=>{Kr.current&&(Kr.current.scrollLeft=j.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:j=>M(j.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:j=>M(j.palette.text.primary,.3)}}},children:t.jsxs(n.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(eo).reduce((j,H)=>j+H,0)}px`},children:[t.jsxs("colgroup",{children:[nr&&t.jsx("col",{style:{width:"40px"}}),ir.map(j=>t.jsx("col",{style:{width:`${eo[j.name]}px`}},j.name))]}),t.jsx(n.TableBody,{children:He.length===0?t.jsx(n.TableRow,{children:t.jsx(n.TableCell,{colSpan:ir.length,align:"center",sx:{py:4},children:t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):to?He.map((j,H)=>j.isGroupHeader?Kn(j):Jo(j,H)):He.map((j,H)=>Jo(j,H))})]})})]}),Ft&&ct&&t.jsx(Mu,{currentPage:Pt,pageSize:Fr,totalRows:Lt,totalPages:_t,totalFields:e.length,selectedCount:et.size,onClearSelection:lt,onPageChange:Ft,onPageSizeChange:ct}),!(Ft&&ct)&&t.jsxs(n.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider",display:"flex",alignItems:"center",gap:1.5},children:[t.jsxs(n.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",He.length," ",He.length===1?"row":"rows"]}),et.size>0&&t.jsxs(t.Fragment,{children:[t.jsxs(n.Typography,{variant:"body2",sx:{color:"primary.main",fontWeight:600},children:["· ",et.size," selected"]}),lt&&t.jsx(n.Button,{size:"small",onClick:lt,sx:{fontSize:"0.75rem",p:0,minWidth:"auto",color:"text.secondary"},children:"Clear"})]})]})]})]}),t.jsxs(n.Popover,{open:!!we,onClose:()=>{ae(null),Ce(null)},anchorEl:(we==null?void 0:we.anchorEl)||null,anchorReference:we!=null&&we.anchorEl?"anchorEl":"anchorPosition",anchorPosition:we&&!we.anchorEl?{top:we.mouseY,left:we.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:we!=null&&we.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(Ve!=null&&Ve.includes("view"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{we&&(pt(we.row),xt(!0)),ae(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"View"})]}),!(Ve!=null&&Ve.includes("edit"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{we&&(Er(we.row),$r(we.rowIndex),Br(!0)),ae(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Edit"})]}),!(Ve!=null&&Ve.includes("duplicate"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{we&&(pr==null||pr(we.rowIndex,we.row)),ae(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Duplicate"})]}),we&&($t==null?void 0:$t.map(j=>{var H,ne;return(H=j.hidden)!=null&&H.call(j,we.row)?null:t.jsxs(n.MenuItem,{dense:!0,disabled:(ne=j.disabled)==null?void 0:ne.call(j,we.row),onClick:()=>{j.onClick(we.row,we.rowIndex),ae(null)},sx:{py:1,px:2,gap:1.5},children:[j.icon,t.jsx(n.Typography,{variant:"body2",children:j.label})]},j.key)})),et.size>0&&Zt&&!(Ve!=null&&Ve.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(n.Divider,{sx:{my:.5}}),t.jsxs(n.MenuItem,{dense:!0,onMouseEnter:j=>{Xe(),Ce(j.currentTarget)},onMouseLeave:ft,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between",flexWrap:"wrap"},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(D.Download,{sx:{fontSize:j=>j.typography.body1.fontSize,color:"text.secondary"}}),t.jsxs(n.Typography,{variant:"body2",children:["Export Selected (",et.size,")"]})]}),t.jsx(D.ChevronRight,{sx:{fontSize:j=>j.typography.body1.fontSize,color:"text.secondary"}})]}),t.jsx(n.Popper,{open:!!me,anchorEl:me,placement:"right-start",transition:!0,sx:{zIndex:j=>j.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:j})=>t.jsx(n.Grow,{...j,timeout:150,children:t.jsx(n.Paper,{onMouseEnter:Xe,onMouseLeave:ft,sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3},children:t.jsxs(n.MenuList,{dense:!0,autoFocusItem:!1,children:[t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{Zt("csv"),Ce(null),ae(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.TableChart,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"CSV"})]}),t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{Zt("excel"),Ce(null),ae(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(n.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{Zt("json"),Ce(null),ae(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"JSON"})]}),kr.export.allowedFormats.includes("pdf")&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{Zt("pdf"),Ce(null),ae(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(D.PictureAsPdf,{sx:{fontSize:18,color:"error.main"}}),t.jsx(n.Typography,{variant:"body2",children:"PDF"})]})]})})})})]}),!(Ve!=null&&Ve.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(n.Divider,{sx:{my:.5}}),t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{we&&(Yr(we.row),Vt(!0)),ae(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx(D.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(n.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(Pu,{open:Tr,onClose:()=>{xt(!1),pt(null)},row:Te,schema:e,reportName:Vr}),t.jsx(Fu,{open:Ht,onClose:()=>{Br(!1),Er(null),$r(null)},onSave:j=>{_r!==null&&(ur==null||ur(_r,j))},row:qr,schema:e,reportName:Vr}),t.jsx(Lu,{open:go,onClose:()=>{Vt(!1),Yr(null)},onConfirm:()=>{zr!==null&&(er==null||er(zr))},row:zr,schema:e}),t.jsx(ca,{isOpen:yo,onClose:()=>No(!1),content:mo,title:ho})]})}const Rr={filter:{title:"Filter columns",description:"Narrow down rows by setting conditions on any column. Only rows matching all active filters are shown.",tips:["Add multiple conditions to combine filters (AND logic)",'Use "Contains" for partial text matches','Use "Is empty" to find missing values',"Clear all filters to return to the full dataset"],devNote:"Max filter conditions controlled by DevConfig → Filter → maxConditions. Allowed operators also configurable."},sort:{title:"Sort columns",description:"Order rows by one or more columns. Drag levels to set sort priority — the first level is applied first.",tips:["Add multiple sort levels for multi-column sorting","Drag the ⋮⋮ handle to reorder sort priority","Each level can be ascending (A→Z, 0→9) or descending"],devNote:"Max sort levels controlled by DevConfig → Sort → maxLevels."},grouping:{title:"Group data",description:"Organize rows into collapsible groups by one or more column values. Each unique value becomes a group header.",tips:["Add up to 3 nesting levels for hierarchical grouping","Click a group header to collapse or expand it","Aggregates (count) are shown on each group header","Combine grouping with filters and sort for focused views"],devNote:"Max group levels controlled by DevConfig → Grouping → maxLevels. allowNested and allowCollapse also configurable."},columns:{title:"Manage columns",description:"Control which columns are visible, their display order, and their widths.",tips:["Drag rows to reorder columns","Toggle the eye icon to show or hide a column","Drag the resize handle in the table header to resize","Reset to restore default visibility and order"],devNote:"Max visible columns and width range controlled by DevConfig → Columns."},export:{title:"Export data",description:"Download the report data as a file. Choose between CSV, Excel, or JSON format.",tips:["CSV: universal format, opens in any spreadsheet app","Excel: formatted .xlsx file with native Excel support","JSON: structured data including metadata","Export visible rows only (after filters) or all rows"],devNote:"Allowed export formats controlled by DevConfig → Export → allowedFormats."},schedule:{title:"Scheduled reports",description:"Set up automatic exports that run at a specified time — daily, weekly, or monthly.",tips:["The browser tab must remain open for the schedule to fire","Each schedule triggers a file download automatically","Add an email address to open a notification in your mail app","Pause a schedule without deleting it","24-hour format · Tab must be open for the schedule to fire","Opens your device's email app when the schedule fires. If you added email.","The data columns visible on the selected view will be send as a report"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}},ci=40;function ep({operator:e,onSelect:r}){return t.jsxs(n.Select,{value:e,onChange:o=>r(o.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(n.MenuItem,{value:"and",sx:{fontSize:"0.75rem",fontWeight:600},children:"AND"}),t.jsx(n.MenuItem,{value:"or",sx:{fontSize:"0.75rem",fontWeight:600},children:"OR"})]})}function tp({condition:e,schema:r,availableColumns:o,devConfig:i,onUpdate:s}){const a=r.find(u=>u.name===e.column),l=p.useMemo(()=>{const u=a?hn(a.type):[],g=i.filter.allowedOperators;return g.length>0?u.filter(x=>g.includes(x.value)):u},[a,i]),c=Nl(e.operator);return t.jsxs(n.Box,{sx:{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},children:[t.jsx(n.FormControl,{size:"small",sx:{minWidth:150,flex:"1 1 150px"},children:t.jsx(n.Select,{value:e.column,onChange:u=>{var y;const g=r.find(w=>w.name===u.target.value),x=g?hn(g.type):[];s({column:u.target.value,operator:((y=x[0])==null?void 0:y.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:o.map(u=>t.jsx(n.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:ut(u.name)},u.name))})}),t.jsx(n.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(n.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(n.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),c&&(a==null?void 0:a.type)==="date"&&t.jsx(n.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&&(a==null?void 0:a.type)!=="date"&&t.jsx(n.TextField,{size:"small",type:(a==null?void 0:a.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(a==null?void 0:a.type)==="number"?Number(u.target.value):u.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function xa({group:e,depth:r,schema:o,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:l,onChange:c}){const u=l>=a;return t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((g,x)=>t.jsxs(n.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(n.Box,{sx:{width:ci,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[x<e.children.length-1&&t.jsx(n.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),x>0&&t.jsx(ep,{operator:e.operator,onSelect:y=>c(w=>Si(w,e.id,y))}),x>0&&t.jsx(n.Box,{sx:{position:"absolute",top:13,left:"50%",width:ci/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(n.Box,{sx:{flex:1,minWidth:0,pt:x>0?1:0},children:Qe(g)?t.jsx(rp,{group:g,depth:r+1,schema:o,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:l,onChange:c}):t.jsx(tp,{condition:g,schema:o,availableColumns:i,devConfig:s,onUpdate:y=>c(w=>vi(w,g.id,y))})}),t.jsx(n.IconButton,{size:"small",onClick:()=>c(y=>wi(y,g.id)),sx:{mt:x>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx(D.Close,{sx:{fontSize:16}})})]},g.id)),t.jsxs(n.Box,{sx:{display:"flex",gap:2,pl:`${ci}px`},children:[t.jsx(n.Button,{size:"small",disabled:u||i.length===0,onClick:()=>c(g=>{var x,y,w;return po(g,e.id,{id:uo(),column:((x=i[0])==null?void 0:x.name)??"",operator:((w=hn(((y=i[0])==null?void 0:y.type)??"string")[0])==null?void 0:w.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(n.Button,{size:"small",disabled:u,onClick:()=>c(g=>po(g,e.id,At())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function rp(e){return t.jsx(n.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>M(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>M(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(xa,{...e})})}function op({schema:e,filters:r,onReplaceFilters:o,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[l,c]=p.useState(r??At()),u=Ar(),g=p.useMemo(()=>e.filter(E=>E.type!=="mixed"&&E.type!=="null"&&E.type!=="array"&&E.type!=="object"),[e]);p.useEffect(()=>{var v;const E=r??At();if(s&&E.children.length===0){const T=e.find(B=>B.name===s);if(T){c(po(E,E.id,{id:uo(),column:s,operator:((v=hn(T.type)[0])==null?void 0:v.value)??"equals"}));return}}c(E)},[r,s,e]);const x=Tt(l),y=u.filter.maxConditions,w=p.useCallback(E=>{c(v=>E(v))},[]),b=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r??At()),[l,r]),z=p.useCallback(()=>{o(l),i()},[l,o,i]),h=p.useCallback(()=>{c(r??At()),i()},[r,i]),m=p.useCallback(()=>{o(At()),i()},[o,i]);return t.jsxs(it,{open:!0,onClose:h,icon:t.jsx(D.FilterAlt,{sx:{fontSize:20}}),title:"Filter columns",helpContent:Rr.filter,width:640,maxHeight:"min(620px, calc(100vh - 200px))",headerActions:a?t.jsx(n.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(D.Settings,{sx:{fontSize:18}})}):void 0,footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Tooltip,{title:"Removes all applied filters and closes this panel",arrow:!0,children:t.jsx(n.Box,{component:"span",sx:{mr:"auto"},children:t.jsx(n.Button,{onClick:m,disabled:x===0,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"Clear all"})})}),t.jsx(n.Button,{onClick:h,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:z,disabled:!b,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:E=>`${E.shape.borderRadius}px`,boxShadow:E=>ge(E,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]}),children:[x===0&&t.jsxs(n.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:E=>E.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${ut(s)}"`:"","."]}),t.jsx(xa,{group:l,depth:0,schema:e,availableColumns:g,devConfig:u,maxConditions:y,totalConditions:x,onChange:w}),x>=y&&t.jsxs(n.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:E=>E.typography.caption.fontSize||"0.75rem",fontWeight:E=>E.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",y," conditions allowed. Remove one to add another."]})]})}const zs="SORT_RULE";function np({rule:e,index:r,onToggleDirection:o,onRemove:i,onMove:s}){const a=p.useRef(null),[{handlerId:l},c]=cr.useDrop({accept:zs,collect(x){return{handlerId:x.getHandlerId()}},hover(x,y){var v;if(!a.current)return;const w=x.index,b=r;if(w===b)return;const z=(v=a.current)==null?void 0:v.getBoundingClientRect(),h=(z.bottom-z.top)/2,m=y.getClientOffset(),E=((m==null?void 0:m.y)??0)-z.top;w<b&&E<h||w>b&&E>h||(s(w,b),x.index=b)}}),[{isDragging:u},g]=cr.useDrag({type:zs,item:()=>({index:r}),collect:x=>({isDragging:x.isDragging()})});return g(c(a)),t.jsxs(n.Box,{ref:a,"data-handler-id":l,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:x=>ge(x,"restButtonLight"),transform:"translateY(-1px)"}},children:[t.jsx(n.Chip,{label:e.priority,size:"small",sx:{width:26,height:26,fontSize:"0.75rem",fontWeight:600,bgcolor:"primary.main",color:"background.paper",boxShadow:x=>`0 1px 2px 0 ${M(x.palette.primary.main,.3)}`,"& .MuiChip-label":{px:0}}}),t.jsxs(n.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(n.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(n.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(n.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:x=>x.typography.body2.fontSize||"0.875rem",fontWeight:x=>x.typography.body2.fontWeight||400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:e.column}),t.jsx(n.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:t.jsxs(n.Select,{value:e.direction,onChange:x=>o(r,x.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(n.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:x=>lr(x),"&:hover":{bgcolor:x=>M(x.palette.primary.main,.2)}}},children:"Ascending"}),t.jsx(n.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:x=>lr(x),"&:hover":{bgcolor:x=>M(x.palette.primary.main,.2)}}},children:"Descending"})]})}),t.jsx(n.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:x=>M(x.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx(D.Close,{sx:{fontSize:18}})})]})}function ip({schema:e,sortStack:r,onUpdateSortStack:o,onClose:i,onOpenDevConfig:s}){const[a,l]=p.useState(""),[c,u]=p.useState([]);p.useEffect(()=>{u([...r])},[r]);const g=p.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r),[c,r]),x=Ar(),y=p.useCallback(T=>{if(!T||c.length>=x.sort.maxLevels)return;const B={column:T,direction:"asc",priority:c.length+1};u([...c,B]),l(""),setTimeout(()=>{var f;return(f=document.activeElement)==null?void 0:f.blur()},0)},[c,x.sort.maxLevels]),w=p.useCallback(T=>{const f=c.filter(($,F)=>F!==T).map(($,F)=>({...$,priority:F+1}));u(f)},[c]),b=p.useCallback((T,B)=>{const f=[...c];f[T]={...f[T],direction:B},u(f)},[c]),z=p.useCallback((T,B)=>{const f=[...c],[$]=f.splice(T,1);f.splice(B,0,$);const F=f.map((O,J)=>({...O,priority:J+1}));u(F)},[c]),h=p.useCallback(()=>{o([]),i()},[o,i]),m=p.useCallback(()=>{o(c),i()},[c,o,i]),E=p.useCallback(()=>{u([...r]),l(""),i()},[r,i]),v=e.filter(T=>!c.some(B=>B.column===T.name));return t.jsx(cr.DndProvider,{backend:gi.HTML5Backend,children:t.jsxs(it,{open:!0,onClose:E,icon:t.jsx(D.SwapVert,{sx:{fontSize:20}}),title:"Sort columns",helpContent:Rr.sort,width:480,maxHeight:"min(440px, calc(100vh - 280px))",headerActions:s?t.jsx(n.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(D.Settings,{sx:{fontSize:18}})}):void 0,footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:E,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:m,variant:"contained",disabled:!g||c.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:T=>`${T.shape.borderRadius}px`,boxShadow:T=>ge(T,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:T=>ge(T,"hoverButton")},"&:active":{boxShadow:T=>ge(T,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]}),children:[t.jsxs(n.Box,{sx:{mb:2.5},children:[t.jsx(n.Typography,{variant:"overline",sx:{fontSize:T=>T.typography.caption.fontSize||"0.6875rem",fontWeight:T=>T.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(n.FormControl,{size:"small",fullWidth:!0,disabled:c.length>=x.sort.maxLevels,children:[t.jsx(n.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(n.Select,{value:a,onChange:T=>y(T.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:v.map(T=>t.jsx(n.MenuItem,{value:T.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:B=>lr(B),"&:hover":{bgcolor:B=>M(B.palette.primary.main,.2)}}},children:ut(T.name)},T.name))})]}),c.length>=x.sort.maxLevels&&t.jsxs(n.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:T=>T.typography.caption.fontSize||"0.75rem",fontWeight:T=>T.typography.caption.fontWeight||500},children:["Maximum ",x.sort.maxLevels," sort levels allowed"]})]}),c.length>0&&t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(n.Typography,{variant:"overline",sx:{fontSize:T=>T.typography.caption.fontSize||"0.6875rem",fontWeight:T=>T.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",c.length,"/",x.sort.maxLevels,")"]}),t.jsx(n.Tooltip,{title:"Removes all applied sorting and closes this panel",arrow:!0,children:t.jsx(n.Button,{onClick:h,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(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:c.map((T,B)=>t.jsx(np,{rule:T,index:B,onToggleDirection:b,onRemove:w,onMove:z},`${T.column}-${B}`))})]})]})})}const an=50;function Bs({currentSnapshot:e,onSave:r,onClose:o,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:l=!1,atViewLimit:c=!1,maxViews:u=10}){const[g,x]=p.useState(s),[y,w]=p.useState(!1),[b,z]=p.useState(a),[h,m]=p.useState(l),E=()=>{if(!g.trim()){w(!0);return}if(g.trim().length>an){w(!0);return}r(g.trim(),b.trim(),h),o()},v=B=>{B.key==="Enter"&&!B.shiftKey&&E()},T=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsx(it,{open:!0,onClose:o,icon:t.jsx(D.Save,{sx:{fontSize:20}}),title:T(),width:600,footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:o,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(n.Button,{onClick:E,variant:"contained",disabled:c&&!i,startIcon:t.jsx(D.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=>ge(B,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:B=>ge(B,"hoverButton")},"&:active":{boxShadow:B=>ge(B,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[c&&!i&&t.jsxs(n.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(n.TextField,{label:"View Name",required:!0,value:g,onChange:B=>{B.target.value.length<=an&&x(B.target.value),y&&B.target.value.trim()&&w(!1)},onKeyDown:v,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:c&&!i,inputProps:{maxLength:an},error:y&&!g.trim(),helperText:y&&!g.trim()?"View name is required":`${g.length} / ${an}`}),t.jsx(n.TextField,{label:"Description (optional)",value:b,onChange:B=>z(B.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),t.jsxs(n.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:B=>B.typography.body2.fontWeight||500,mb:1},children:"This view will capture:"}),t.jsxs(n.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[t.jsxs("li",{children:[Tt(e.filters)," filter",Tt(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",sl(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(n.FormControlLabel,{control:t.jsx(n.Checkbox,{checked:h,onChange:B=>m(B.target.checked),size:"small"}),label:t.jsx(n.Typography,{variant:"body2",children:"Set as default view"})})]})})}function sp({viewName:e,onConfirm:r,onCancel:o}){return t.jsx(it,{open:!0,onClose:o,icon:t.jsx(D.Warning,{sx:{fontSize:20}}),iconColor:"error",title:"Delete View",width:600,maxHeight:"min(480px, calc(100vh - 180px))",footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:o,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(n.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>ge(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ge(i,"hoverButton")},"&:active":{boxShadow:i=>ge(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[t.jsx(D.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),t.jsxs(n.Box,{children:[t.jsxs(n.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",t.jsxs("strong",{children:['"',e,'"']}),"?"]}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})})}const Es="COLUMN";function ap({column:e,index:r,isVisible:o,width:i,minColumnWidth:s,maxColumnWidth:a,canToggleOn:l,onToggleVisibility:c,onWidthChange:u,moveColumn:g}){const x=p.useRef(null),[y,w]=p.useState(i.toString());p.useEffect(()=>{w(i.toString())},[i]);const[{handlerId:b},z]=cr.useDrop({accept:Es,collect(f){return{handlerId:f.getHandlerId()}},hover(f,$){var A;if(!x.current)return;const F=f.index,O=r;if(F===O)return;const J=(A=x.current)==null?void 0:A.getBoundingClientRect(),te=(J.bottom-J.top)/2,L=$.getClientOffset(),S=((L==null?void 0:L.y)??0)-J.top;F<O&&S<te||F>O&&S>te||(g(F,O),f.index=O)}}),[{isDragging:h},m]=cr.useDrag({type:Es,item:()=>({index:r}),collect:f=>({isDragging:f.isDragging()})});m(z(x));const E=()=>{const f=parseInt(y);if(isNaN(f)){w(i.toString()),u(e.name,i);return}const $=Math.max(s,Math.min(a,f));w($.toString()),u(e.name,$)},v=f=>{if(f===""||/^\d+$/.test(f)){w(f);const $=parseInt(f);if(!isNaN($)&&$>=s){const F=Math.min(a,$);u(e.name,F)}}},T=f=>{f.key==="Enter"&&(f.preventDefault(),E(),f.target.blur())},B=f=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[f]||"text.secondary";return t.jsxs(n.TableRow,{ref:x,"data-handler-id":b,sx:{opacity:h?.4:1,bgcolor:o?"background.paper":"action.hover",transition:"opacity 0.15s ease","&:hover":{bgcolor:o?"action.hover":"action.selected"},cursor:"move",height:56,borderBottom:f=>`1px solid ${f.palette.divider}`},children:[t.jsx(n.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(n.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx(D.DragIndicator,{sx:{fontSize:20}})}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:f=>f.typography.body2.fontWeight||400,fontSize:f=>f.typography.body2.fontSize||"0.875rem",color:o?"text.primary":"text.secondary"},children:ut(e.name)})]})}),t.jsx(n.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsx(n.Chip,{label:e.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${B(e.type)}15`,color:B(e.type),border:`1px solid ${B(e.type)}30`,"& .MuiChip-label":{px:1}}})}),t.jsx(n.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(n.TextField,{type:"number",value:y,onChange:f=>v(f.target.value),onBlur:E,onKeyDown:T,placeholder:"150",size:"small",inputProps:{min:s,max:a,step:10},sx:{width:90,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"},"& input[type=number]::-webkit-inner-spin-button":{opacity:1},"& input[type=number]::-webkit-outer-spin-button":{opacity:1}}}),t.jsx(n.Typography,{variant:"caption",sx:{fontSize:f=>f.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"px"})]})}),t.jsx(n.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(n.IconButton,{onClick:()=>c(e.name,!o),disabled:!o&&!l,title:o?"Hide column":l?"Show column":"Max visible columns reached",size:"small",sx:{p:.75,color:o?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover:not(:disabled)":{bgcolor:"action.hover",color:o?"primary.dark":"primary.main"},"&:disabled":{opacity:.5,cursor:"not-allowed"}},children:o?t.jsx(D.Visibility,{sx:{fontSize:20}}):t.jsx(D.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(n.Chip,{label:o?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:o?f=>M(f.palette.success.main,.12):"action.selected",color:o?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function lp({schema:e,columnVisibility:r,columnOrder:o,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:l,onUpdateColumnOrder:c,onUpdateColumnWidth:u,onResetLayout:g,onClose:x}){const y=Ar(),[w,b]=p.useState(!1),[z,h]=p.useState(o),[m,E]=p.useState(i),[v,T]=p.useState("all");p.useEffect(()=>{h(o)},[o]),p.useEffect(()=>{E(i)},[i]);const B=(A,k)=>{E(Y=>({...Y,[A]:k})),u==null||u(A,k)},f=(A,k)=>{const Y=[...z],[oe]=Y.splice(A,1);Y.splice(k,0,oe),h(Y),c(Y)},$=()=>{g(),b(!1)},O=z.map(A=>e.find(k=>k.name===A)).filter(A=>A!==void 0).filter(A=>{const k=r[A.name]??!0;return v==="active"?k:v==="hidden"?!k:!0}),J=Object.values(r).filter(A=>A).length,te=e.length,L=s.find(A=>A.id===a),S=p.useMemo(()=>{if(!L)return!1;const A=L.snapshot,k=A.columnVisibility??{},Y=JSON.stringify(r)!==JSON.stringify(k),oe=A.columnOrder??[],d=o??[],Q=JSON.stringify(d)!==JSON.stringify(oe)&&!(d.length===0&&oe.length===0),ee=A.columnWidths??{},N=JSON.stringify(m)!==JSON.stringify(ee);return Y||Q||N},[L,r,o,m]);return t.jsx(cr.DndProvider,{backend:gi.HTML5Backend,children:t.jsxs(it,{open:!0,onClose:x,icon:t.jsx(D.ViewColumn,{sx:{fontSize:20}}),title:"Manage columns",helpContent:Rr.columns,width:720,maxHeight:"min(760px, calc(100vh - 200px))",headerExtra:t.jsxs(n.Tabs,{value:v,onChange:(A,k)=>T(k),sx:{minHeight:36,"& .MuiTabs-indicator":{bgcolor:A=>nt(A).main,height:3}},children:[t.jsx(n.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:A=>nt(A).hoverBg},"&:hover":{color:"text.primary",bgcolor:A=>nt(A).bg}}}),t.jsx(n.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:A=>nt(A).hoverBg},"&:hover":{color:"text.primary",bgcolor:A=>nt(A).bg}}}),t.jsx(n.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:A=>nt(A).hoverBg},"&:hover":{color:"text.primary",bgcolor:A=>nt(A).bg}}})]}),footer:t.jsxs(t.Fragment,{children:[t.jsxs(n.Typography,{variant:"body2",sx:{fontSize:A=>A.typography.body2.fontSize||"0.8125rem",color:"text.secondary",mr:"auto"},children:[J," of ",te," columns visible • Drag to reorder"]}),t.jsx(n.Button,{onClick:()=>b(!0),disabled:!S,variant:"outlined",startIcon:t.jsx(D.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:A=>`${A.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})]}),children:[t.jsxs(n.Table,{stickyHeader:!0,sx:{minWidth:650},children:[t.jsx(n.TableHead,{children:t.jsxs(n.TableRow,{children:[t.jsx(n.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(n.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(n.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(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",t.jsx(n.Tooltip,{title:`Column width in pixels (min: ${y.columns.minColumnWidth}px, max: ${y.columns.maxColumnWidth}px)`,arrow:!0,placement:"top",children:t.jsx(D.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),t.jsx(n.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(n.TableBody,{children:O.length===0?t.jsx(n.TableRow,{children:t.jsx(n.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:t.jsx(n.Typography,{variant:"body2",sx:{fontSize:A=>A.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):O.map((A,k)=>{const Y=r[A.name]??!0,oe=Y||J<y.columns.maxVisible;return t.jsx(ap,{column:A,index:k,isVisible:Y,width:m[A.name]||170,minColumnWidth:y.columns.minColumnWidth,maxColumnWidth:y.columns.maxColumnWidth,canToggleOn:oe,onToggleVisibility:l,onWidthChange:B,moveColumn:f},A.name)})})]}),w&&t.jsx(n.Box,{onClick:()=>b(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:A=>M(A.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:A=>A.zIndex.tooltip},children:t.jsxs(n.Paper,{onClick:A=>A.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:A=>Fo(A),bgcolor:"background.paper",boxShadow:A=>Rt(A).paper.boxShadow,border:A=>Rt(A).paper.border},children:[t.jsxs(n.Box,{sx:{px:3,py:2.5},children:[t.jsx(n.Typography,{variant:"h4",sx:{fontSize:A=>A.typography.h4.fontSize||"1rem",fontWeight:A=>A.typography.h4.fontWeight||500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),t.jsx(n.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(n.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(n.Button,{onClick:()=>b(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:A=>`${A.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:$,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:A=>`${A.shape.borderRadius}px`,boxShadow:A=>ge(A,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:A=>ge(A,"hoverButton")},"&:active":{boxShadow:A=>ge(A,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})}function cp({schema:e,grouping:r,onApply:o,onClose:i,onOpenDevConfig:s}){var F;const[a,l]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[c,u]=p.useState(""),[g,x]=p.useState(null),y=p.useMemo(()=>Za(e),[e]),w=p.useMemo(()=>y.filter(O=>!a.levels.some((J,te)=>J.column===O.name&&te!==g)),[y,a.levels,g]),b=Ar(),z=a.levels.length<b.grouping.maxLevels&&w.length>0&&(b.grouping.allowNested||a.levels.length===0),h=p.useCallback(O=>{!z||!O||(l({...a,levels:[...a.levels,{column:O}],enabled:!0}),u(""),setTimeout(()=>{var J;return(J=document.activeElement)==null?void 0:J.blur()},0))},[z,a]),m=p.useCallback(O=>{const J=a.levels.filter((te,L)=>L!==O);if(J.length===0){o(null),i();return}l({...a,levels:J,enabled:J.length>0})},[a,o,i]),E=p.useCallback(O=>{x(O),u(a.levels[O].column)},[a.levels]),v=p.useCallback(()=>{if(g===null||!c)return;const O=[...a.levels];O[g]={column:c},l({...a,levels:O}),x(null),u("")},[g,c,a]),T=p.useCallback(()=>{x(null),u("")},[]),B=p.useCallback((O,J)=>{const te=J==="up"?O-1:O+1;if(te<0||te>=a.levels.length)return;const L=[...a.levels],[S]=L.splice(O,1);L.splice(te,0,S),l({...a,levels:L})},[a]),f=p.useCallback(()=>{o(null),i()},[o,i]),$=p.useCallback(()=>{a.levels.length===0?o(null):o({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,o,i]);return t.jsx(it,{open:!0,onClose:i,icon:t.jsx(D.Layers,{sx:{fontSize:20}}),title:"Group configuration",helpContent:Rr.grouping,width:540,maxHeight:"min(560px, calc(100vh - 280px))",headerActions:s?t.jsx(n.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(D.Settings,{sx:{fontSize:18}})}):void 0,footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:O=>`${O.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:$,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:O=>`${O.shape.borderRadius}px`,boxShadow:O=>ge(O,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:O=>ge(O,"hoverButton")},"&:active":{boxShadow:O=>ge(O,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]}),children:t.jsxs(n.Stack,{spacing:2.5,children:[g===null&&t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"overline",sx:{fontSize:O=>O.typography.caption.fontSize||"0.6875rem",fontWeight:O=>O.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(n.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(n.Select,{value:c,onChange:O=>h(O.target.value),disabled:!z,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(n.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),w.map(O=>t.jsxs(n.MenuItem,{value:O.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:J=>lr(J),"&:hover":{bgcolor:J=>M(J.palette.primary.main,.2)}}},children:[ut(O.name)," (",O.type.toUpperCase(),")"]},O.name))]})}),a.levels.length>=b.grouping.maxLevels&&t.jsx(n.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:O=>O.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),y.length===0&&t.jsx(n.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:O=>O.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),g!==null&&t.jsxs(n.Alert,{severity:"warning",sx:{borderRadius:"8px",border:O=>`1px solid ${M(O.palette.warning.main,.5)}`,bgcolor:O=>M(O.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(n.Typography,{variant:"body2",sx:{fontWeight:O=>O.typography.body2.fontWeight||500,mb:1.5,fontSize:O=>O.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",g+1]}),t.jsx(n.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(n.Select,{value:c,onChange:O=>u(O.target.value),sx:{fontSize:"0.875rem",height:40,borderRadius:"4px",bgcolor:"background.paper","& .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:"2px"}},children:[t.jsx(n.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(n.MenuItem,{value:a.levels[g].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:O=>lr(O)}},children:[a.levels[g].column," (",(F=e.find(O=>O.name===a.levels[g].column))==null?void 0:F.type.toUpperCase(),")"]}),w.filter(O=>O.name!==a.levels[g].column).map(O=>t.jsxs(n.MenuItem,{value:O.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:J=>lr(J)}},children:[ut(O.name)," (",O.type.toUpperCase(),")"]},O.name))]})}),t.jsxs(n.Stack,{direction:"row",spacing:1.5,children:[t.jsx(n.Button,{onClick:v,disabled:!c,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:O=>ge(O,"pressedButton")}},children:"Save"}),t.jsx(n.Button,{onClick:T,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),a.levels.length>0&&g===null&&t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[t.jsx(n.Typography,{variant:"overline",sx:{fontSize:O=>O.typography.caption.fontSize||"0.6875rem",fontWeight:O=>O.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(n.Tooltip,{title:"Removes all applied grouping and closes this panel",arrow:!0,children:t.jsx(n.Button,{onClick:f,size:"small",sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"}},children:"Clear all"})})]}),t.jsx(n.Stack,{spacing:1.5,children:a.levels.map((O,J)=>{const te=e.find(L=>L.name===O.column);return t.jsxs(n.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:L=>ge(L,"pressedButtonLight")}},children:[t.jsx(n.Chip,{label:`L${J+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:L=>`0 1px 2px 0 ${M(L.palette.primary.main,.3)}`}}),t.jsxs(n.Box,{sx:{flex:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:L=>L.typography.body2.fontWeight||500,fontSize:L=>L.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:O.column}),t.jsx(n.Typography,{variant:"caption",sx:{fontSize:L=>L.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:te==null?void 0:te.type.toUpperCase()})]}),t.jsxs(n.Stack,{direction:"row",spacing:.5,children:[t.jsx(n.IconButton,{size:"small",onClick:()=>B(J,"up"),disabled:J===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(D.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(n.IconButton,{size:"small",onClick:()=>B(J,"down"),disabled:J===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(D.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(n.IconButton,{size:"small",onClick:()=>E(J),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx(D.Edit,{sx:{fontSize:18}})}),t.jsx(n.IconButton,{size:"small",onClick:()=>m(J),sx:{color:"text.secondary","&:hover":{bgcolor:L=>M(L.palette.error.main,.08),color:"error.main"}},children:t.jsx(D.Delete,{sx:{fontSize:18}})})]})]},J)})})]})]})})}function dp({onExportAnyway:e,onSaveAndExport:r,onCancel:o}){return t.jsx(n.Box,{sx:{mb:2,mx:3,mt:2},children:t.jsxs(n.Alert,{severity:"warning",icon:t.jsx(D.Warning,{sx:{fontSize:20}}),action:t.jsx(n.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:t.jsx(D.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(n.Typography,{variant:"subtitle2",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1rem",mb:.5},children:"You are exporting with unsaved view changes"}),t.jsx(n.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.Button,{onClick:r,variant:"contained",color:"primary",startIcon:t.jsx(D.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(n.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx(D.Download,{sx:{fontSize:i=>i.typography.body1.fontSize}}),size:"small",children:"Export Anyway"})]})]})})}const _s=[{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 up(e,r){if(r===null)return e.length;const o=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()>=o).length}function pp(e,r){if(r===null)return[];const o=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<o)}function fp({auditHistory:e,onClose:r,onClearAuditHistory:o}){const i=bt(),s=i.palette,[a,l]=p.useState("1h"),[c,u]=p.useState(!1),[g,x]=p.useState("all"),[y,w]=p.useState(!0),[b,z]=p.useState(!1),[h,m]=p.useState(!1),E=[...e].sort((L,S)=>{const A=new Date(L.timestamp).getTime()-new Date(S.timestamp).getTime();return b?A:-A}),v=E.reduce((L,S)=>(L[S.feature]=(L[S.feature]??0)+1,L),{}),T=Object.keys(v).sort((L,S)=>(v[S]??0)-(v[L]??0)),B=g==="all"?E:E.filter(L=>L.feature===g),f=_s.find(L=>L.key===a),$=up(e,f.ms),F=()=>u(!0),O=()=>{o&&(o(pp(e,f.ms)),u(!1))},J=L=>{const S=Cs(i,L.feature),{summary:A,detail:k}=vl(L);return t.jsxs(n.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:M(s.text.primary,.18)}},children:[t.jsx(n.Chip,{label:ei(L.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:M(S,.1),color:S,border:`1px solid ${M(S,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),t.jsxs(n.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(n.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:A}),k&&t.jsx(n.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:k}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(D.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(n.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:Cl(L.timestamp)})]}),L.user&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(D.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(n.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:L.user})]})]})]})]},L.id)},te=h?T.map(L=>({feature:L,events:B.filter(S=>S.feature===L)})).filter(L=>L.events.length>0):[];return t.jsxs(t.Fragment,{children:[t.jsx(it,{open:!0,onClose:r,icon:t.jsx(D.AccessTime,{sx:{fontSize:20}}),title:"Audit History",subtitle:`· ${B.length} event${B.length!==1?"s":""} recorded`,helpContent:Rr.auditHistory,width:520,maxHeight:"min(700px, calc(100vh - 80px))",headerActions:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[o&&e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(n.Select,{value:a,onChange:L=>l(L.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:M(s.text.primary,.3)}},children:_s.map(L=>t.jsx(n.MenuItem,{value:L.key,sx:{fontSize:"0.8125rem"},children:L.label},L.key))}),t.jsx(n.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(D.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:F,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:M(s.error.main,.5),"&:hover":{bgcolor:M(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),T.length>1&&t.jsx(n.IconButton,{onClick:()=>w(L=>!L),size:"small",title:y?"Hide category filter":"Show category filter",sx:{color:y?"primary.main":"text.secondary",bgcolor:y?M(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:y?M(s.primary.main,.16):"action.hover"}},children:t.jsx(D.FilterAltOutlined,{sx:{fontSize:17}})}),t.jsx(n.IconButton,{onClick:()=>z(L=>!L),size:"small",title:b?"Sorted oldest first":"Sorted newest first",sx:{color:b?"primary.main":"text.secondary",bgcolor:b?M(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:b?M(s.primary.main,.16):"action.hover"}},children:t.jsx(D.SortOutlined,{sx:{fontSize:17,transform:b?"scaleY(-1)":"none"}})}),t.jsx(n.IconButton,{onClick:()=>m(L=>!L),size:"small",title:h?"Ungroup events":"Group by category",sx:{color:h?"primary.main":"text.secondary",bgcolor:h?M(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:h?M(s.primary.main,.16):"action.hover"}},children:t.jsx(D.WorkspacesOutlined,{sx:{fontSize:17}})})]}),headerExtra:T.length>1&&y&&t.jsxs(n.Tabs,{value:g,onChange:(L,S)=>x(S),variant:"scrollable",scrollButtons:"auto",sx:{minHeight:36,borderBottom:"1px solid",borderColor:"divider","& .MuiTabs-indicator":{height:2}},children:[t.jsx(n.Tab,{value:"all",label:`All (${E.length})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}}),T.map(L=>t.jsx(n.Tab,{value:L,label:`${ei(L)} (${v[L]})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}},L))]}),children:B.length===0?t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx(D.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(n.Typography,{sx:{fontSize:L=>L.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:L=>L.typography.body2.fontWeight||500},children:E.length===0?"No audit events yet":"No events in this category"}),t.jsx(n.Typography,{sx:{fontSize:L=>L.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:E.length===0?"Changes to this report will appear here":"Try a different category tab"})]}):h?t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:te.map(({feature:L,events:S})=>t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75,px:.25},children:[t.jsx(n.Box,{sx:{width:6,height:6,borderRadius:"50%",bgcolor:Cs(i,L)}}),t.jsxs(n.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"text.secondary"},children:[ei(L)," (",S.length,")"]})]}),t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:S.map(J)})]},L))}):t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:B.map(J)})}),t.jsxs(n.Dialog,{open:c,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Fo(i),...Rt(i).paper}},children:[t.jsxs(n.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(n.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:M(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(D.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(n.Typography,{sx:{fontSize:L=>L.typography.body1.fontSize||"0.9375rem",fontWeight:L=>L.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(n.Typography,{sx:{fontSize:L=>L.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",t.jsxs(n.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[$," audit record",$!==1?"s":""]})," ",f.key==="all"?"from all time":`from the ${f.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(n.Divider,{}),t.jsxs(n.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(n.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(n.Button,{onClick:O,variant:"contained",color:"error",startIcon:t.jsx(D.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",$," Record",$!==1?"s":""]})]})]})]})}function mp({onSave:e,onClose:r}){const[o,i]=p.useState(""),[s,a]=p.useState(""),[l,c]=p.useState(""),[u,g]=p.useState([]),[x,y]=p.useState(""),[w,b]=p.useState(""),z=f=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f),h=()=>{const f=l.trim();if(f){if(!z(f)){b("Please enter a valid email address");return}if(u.includes(f)){b("This email is already added");return}g([...u,f]),c(""),b("")}},m=f=>{g(u.filter($=>$!==f))},E=f=>{f.key==="Enter"&&(f.preventDefault(),h())},v=()=>{if(!o.trim()){y("Preset name is required");return}e(o.trim(),s.trim(),u.length>0?u:void 0)},T=f=>{i(f),x&&y("")},B=f=>{c(f),w&&b("")};return t.jsx(it,{open:!0,onClose:r,icon:t.jsx(D.Share,{sx:{fontSize:20}}),title:"Create shareable preset",width:540,maxHeight:"min(480px, calc(100vh - 280px))",footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:f=>`${f.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:v,variant:"contained",startIcon:t.jsx(D.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:f=>`${f.shape.borderRadius}px`,boxShadow:f=>ge(f,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:f=>ge(f,"hoverButton")},"&:active":{boxShadow:f=>ge(f,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsx(n.Alert,{severity:"info",icon:t.jsx(D.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:f=>`1px solid ${M(f.palette.primary.main,.3)}`,bgcolor:f=>lr(f),"& .MuiAlert-icon":{color:"primary.main"},"& .MuiAlert-message":{fontSize:"0.8125rem",color:"text.primary",lineHeight:1.5}},children:"This preset will capture filters, sorting, grouping, column configuration, and the active view. The actual data is not saved or shared."}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:f=>f.typography.body2.fontSize||"0.875rem",color:"text.secondary",lineHeight:1.6},children:"Save the current report configuration and generate a shareable link that others can use to view the same filters, sorting, and column layout."}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontSize:f=>f.typography.caption.fontSize||"0.6875rem",fontWeight:f=>f.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),t.jsx(n.TextField,{required:!0,value:o,onChange:f=>T(f.target.value),placeholder:"e.g., Q4 Active Users Report",error:!!x,helperText:x,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(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontSize:f=>f.typography.caption.fontSize||"0.6875rem",fontWeight:f=>f.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(n.TextField,{value:s,onChange:f=>a(f.target.value),placeholder:"Briefly describe what this preset shows...",multiline:!0,rows:3,fullWidth:!0,size:"small",sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary",lineHeight:1.6}}})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontSize:f=>f.typography.caption.fontSize||"0.6875rem",fontWeight:f=>f.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),t.jsxs(n.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[t.jsx(n.TextField,{value:l,onChange:f=>B(f.target.value),onKeyPress:E,placeholder:"Enter email address",error:!!w,helperText:w,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx(D.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(n.Button,{onClick:h,variant:"outlined",startIcon:t.jsx(D.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:f=>`${f.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(n.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(f=>t.jsx(n.Chip,{label:f,onDelete:()=>m(f),deleteIcon:t.jsx(D.Delete,{sx:{fontSize:16}}),sx:{bgcolor:$=>lr($),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},f))}),t.jsx(n.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"})]})]})})}function hp({presetName:e,onClear:r}){return t.jsx(n.Chip,{icon:t.jsx(D.Link,{sx:{fontSize:14}}),label:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset:"," ",t.jsx(n.Box,{component:"span",sx:{fontWeight:600},children:e})]}),onDelete:r,deleteIcon:t.jsx(n.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:t.jsx(D.Close,{sx:{fontSize:14}})}),sx:{bgcolor:o=>M(o.palette.primary.main,.12),borderColor:"primary.light",border:1,fontSize:"body2.fontSize",fontWeight:500,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.main"}}}})}function xp({presets:e,reportId:r,onOpenPreset:o,onDeletePreset:i,onClose:s}){const a=l=>new Date(l).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(it,{open:!0,onClose:s,icon:t.jsx(D.Share,{sx:{fontSize:20}}),title:"Manage Presets",subtitle:`· ${e.length} saved ${e.length===1?"preset":"presets"}`,width:680,maxHeight:"min(720px, calc(100vh - 200px))",footer:t.jsx(n.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=>ge(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:l=>ge(l,"hoverButton")},"&:active":{boxShadow:l=>ge(l,"pressedButton"),transform:"translateY(1px)"}},children:"Close"}),children:e.length===0?t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx(D.Share,{sx:{fontSize:48,color:"divider",mb:2}}),t.jsx(n.Typography,{variant:"body1",sx:{fontSize:l=>l.typography.body2.fontSize||"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"text.disabled",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(l=>t.jsxs(n.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=>ge(c,"restButtonLight")}},children:[t.jsx(n.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:t.jsxs(n.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(n.Typography,{variant:"h6",sx:{fontSize:c=>c.typography.body1.fontSize||"0.9375rem",fontWeight:c=>c.typography.h6.fontWeight||500,color:"text.primary",mb:.5},children:l.name}),l.description&&t.jsx(n.Typography,{variant:"body2",sx:{fontSize:c=>c.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.5},children:l.description})]})}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(n.Chip,{label:`Created ${a(l.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(n.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(n.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(n.Box,{sx:{display:"flex",gap:1},children:t.jsx(n.Button,{onClick:()=>i(l.id,l.name),variant:"outlined",size:"small",startIcon:t.jsx(D.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=>M(c.palette.error.main,.04)}},children:"Delete"})})]},l.id))})})}const ga={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},gp=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],yp=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function bp(e,r){const o=[];for(const i of e){if(i.type!=="string")continue;const s=yp.some(c=>c.test(i.name));let a=!1;const l=r.slice(0,10).map(c=>c[i.name]).filter(c=>typeof c=="string"&&c.length>0);l.length>0&&(a=l.filter(u=>gp.some(g=>g.test(u))).length/l.length>.6),(s||a)&&o.push(i.name)}return o}function Mn(e,r){if(e.length===0||r.length===0)return 0;const o=e.slice(0,Math.min(50,e.length)),s=r.map(l=>{const c=o.map(g=>String(g[l]??"")).filter(g=>g.length>0);if(c.length===0)return 5;const u=c.reduce((g,x)=>g+x.length,0);return Math.ceil(u/c.length)+1}).reduce((l,c)=>l+c,0)+1;return r.reduce((l,c)=>l+c.length+1,0)+s*e.length}function vp(e,r){const o=Mn(e,r);return Math.ceil(o*3.5)}function Sp(e,r){const o=Mn(e,r);return Math.ceil(o*.7)}function wp(e,r){const o=Mn(e,r);return Math.ceil(o*2)}function Cp(e,r,o){switch(e){case"csv":return Mn(r,o);case"excel":return Sp(r,o);case"json":return vp(r,o);case"pdf":return wp(r,o)}}function $s(e,r){return Math.ceil(e/r)}function jp(e,r,o,i,s=ga){const a=[],l=Cp(e,r,o),c=r.length;if(c>s.maxRowsHard){const x=$s(c,s.maxRows);a.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 ${x} smaller exports of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:x,value:c,limit:s.maxRowsHard})}else if(c>s.maxRows){const x=$s(c,s.maxRows);a.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 ${x} smaller export${x>1?"s":""} of ~${s.maxRows.toLocaleString()} rows each.`,suggestedBatches:x,value:c,limit:s.maxRows})}if(l>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${Do(l)} exceeds the ${Do(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:l,limit:s.maxFileSizeHardBytes}):l>s.maxFileSizeBytes&&a.push({type:"file_size",severity:"warning",message:`Large file: estimated ${Do(l)}`,detail:`This exceeds the recommended ${Do(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:l,limit:s.maxFileSizeBytes}),e!=="excel"){const x=bp(i.filter(y=>o.includes(y.name)),r);if(x.length>0){const y=x.length>s.maxImageColumns;a.push({type:"image_columns",severity:y?"error":"warning",message:`Image column${x.length>1?"s":""} detected: ${x.map(w=>`"${w.replace(/_/g," ")}"`).join(", ")}`,detail:y?`Exporting ${x.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:x.length,limit:s.maxImageColumns})}}const u=a.some(x=>x.severity==="error"),g=a.some(x=>x.severity==="warning");return{violations:a,hasBlockingViolation:u,hasWarning:g,estimatedBytes:l}}function Do(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function kp({violation:e}){const o=bt().palette,i=e.severity==="error",s=i?o.error.main:o.warning.main,a=M(i?o.error.main:o.warning.main,.06),l=i?M(o.error.main,.25):M(o.warning.main,.3),c=i?D.ErrorOutline:D.WarningAmberOutlined;return t.jsxs(n.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"10px",bgcolor:a,border:"1px solid",borderColor:l},children:[t.jsx(c,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{sx:{fontSize:u=>u.typography.body2.fontSize||"0.8125rem",fontWeight:u=>u.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(n.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:e.detail}),e.suggestedBatches&&e.suggestedBatches>1&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[t.jsx(D.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(n.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:u=>u.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function Tp({format:e}){const r=bt(),o={csv:{color:r.palette.primary.main,bg:r.palette.primary.main,label:"CSV"},excel:{color:r.palette.success.main,bg:r.palette.success.main,label:"XLSX"},json:{color:r.palette.text.secondary,bg:r.palette.text.secondary,label:"JSON"},pdf:{color:r.palette.error.main,bg:r.palette.error.main,label:"PDF"}}[e];return t.jsxs(n.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:o.color,strokeWidth:"2.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M24 2V13H36",fill:M(r.palette.text.primary,.05),stroke:o.color,strokeWidth:"2.5",strokeLinejoin:"round"})]}),t.jsx(n.Box,{sx:{position:"absolute",bottom:8,left:3,right:3,bgcolor:o.bg,color:r.palette.primary.contrastText,fontSize:"0.625rem",fontWeight:800,py:.25,borderRadius:"3px",textAlign:"center",letterSpacing:"0.05em"},children:o.label})]})}function Ds({checked:e}){const r=bt();return t.jsx(n.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(n.Box,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:`var(--urm-export-card-selected-border, ${r.palette.primary.main})`}})})}function zp({totalRows:e,visibleRows:r,hasGrouping:o,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:l=[],allRows:c=[],processedRows:u=[],initialFormat:g,initialScope:x="visible",initialColumnScope:y="visible",classTokens:w={},onExport:b,onClose:z}){const h=bt(),m=h.palette,E=Ar(),v=p.useMemo(()=>{var le,Z,de,se,W;const Q=((de=(Z=(le=h.components)==null?void 0:le.MuiCard)==null?void 0:Z.styleOverrides)==null?void 0:de.root)||{},ee=Q.border&&Q.border!=="none"?Q.border:(se=h.tokens)!=null&&se.cardBodyBorder&&h.tokens.cardBodyBorder!=="none"?h.tokens.cardBodyBorder:m.divider,N=Q.borderRadius!==void 0?typeof Q.borderRadius=="number"?`${Q.borderRadius}px`:Q.borderRadius:`${h.shape.borderRadius}px`,re=Q.boxShadow&&Q.boxShadow!=="none"?Q.boxShadow:((W=h.tokens)==null?void 0:W.cardBodyShadow)||ge(h,"menu"),ue=nt(h);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:N,cardShadow:re,cardHoverBg:`var(--urm-export-card-hover-bg, ${m.mode==="dark"?M(m.common.white,.08):M(m.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${M(ue.main,m.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${ue.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, ${h.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${h.spacing(1.5)})`}},[m,h]),T=E.export.allowedFormats.filter(Q=>Q!=="csv"),B=g||(T.includes("pdf")?"pdf":T[0]||"excel"),[f,$]=p.useState(B),[F,O]=p.useState(x),[J,te]=p.useState(y),L=F==="visible"?r:e,S=J==="visible"?i:s,A=p.useMemo(()=>F==="visible"?u.length>0?u:new Array(r):c.length>0?c:new Array(e),[F,r,e,u,c]),k=p.useMemo(()=>J==="all"?a.map(Q=>Q.name):a.map(Q=>Q.name).slice(0,i),[J,a,i]),Y=p.useMemo(()=>jp(f,A,k,a,ga),[f,A,k,a]),oe=()=>{Y.hasBlockingViolation||(b({format:f,scope:F,columnScope:J}),z())},d={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(it,{open:!0,onClose:z,icon:t.jsx(D.Download,{sx:{fontSize:20}}),title:"Export Report",helpContent:Rr.export,width:540,maxHeight:"min(760px, calc(100vh - 48px))",classNames:{backdrop:`urm-export-backdrop ${w.modalBackdrop||""}`,paper:`urm-export-paper ${w.modalPaper||""}`,header:`urm-export-header ${w.modalHeader||""}`,title:`urm-export-title ${w.modalTitle||""}`,closeButton:`urm-export-close ${w.modalCloseButton||""}`,body:`urm-export-content ${w.modalContent||""}`,footer:`urm-export-footer ${w.footer||""}`},footer:t.jsxs(t.Fragment,{children:[Y.hasBlockingViolation&&t.jsxs(n.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx(D.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(n.Typography,{sx:{fontSize:Q=>Q.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:Q=>Q.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(n.Button,{onClick:z,variant:"outlined",className:`urm-export-cancel-btn ${w.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:m.text.primary,borderColor:v.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:v.cardHoverBg,borderColor:M(m.text.primary,.3)}},children:"Cancel"}),t.jsxs(n.Button,{onClick:oe,disabled:Y.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${w.downloadButton||""}`,startIcon:t.jsx(D.Download,{sx:{fontSize:Q=>Q.typography.body1.fontSize}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:v.primaryBtnBg,color:v.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${M(m.primary.main,.25)}`,"&:hover":{bgcolor:v.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:M(m.primary.main,.4),color:v.primaryBtnColor}},children:["Download ",d[f]]})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:v.optionGap},children:[Y.violations.length>0&&t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:Y.violations.map((Q,ee)=>t.jsx(kp,{violation:Q},ee))}),t.jsxs(n.Box,{className:`urm-export-section ${w.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${v.sectionBorder}`,borderRadius:"12px",p:v.sectionPadding,pt:2.25,bgcolor:v.sectionTitleBg,mt:1.5},children:[t.jsx(n.Typography,{className:`urm-export-section-title ${w.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:v.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:v.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(n.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:v.optionGap},children:[{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:E.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:E.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:E.export.allowedFormats.includes("pdf")}].filter(Q=>Q.allowed).map(Q=>{const ee=f===Q.id;return t.jsxs(n.Box,{onClick:()=>$(Q.id),className:`urm-export-format-card ${ee?w.formatCardSelected||"":w.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:v.cardRadius,border:ee?`2px solid ${v.cardSelectedBorder}`:`1px solid ${v.cardBorder}`,boxShadow:ee?void 0:v.cardShadow,bgcolor:ee?v.cardSelectedBg:v.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?v.cardSelectedBorder:M(m.text.primary,.25),bgcolor:ee?v.cardSelectedBg:v.cardHoverBg}},children:[ee&&t.jsx(n.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:v.cardSelectedBorder,color:m.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${M(m.primary.main,.3)}`},children:t.jsx(D.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(Tp,{format:Q.id}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(n.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:ee?v.cardSelectedColor:m.text.primary},children:Q.title}),t.jsx(n.Tooltip,{title:Q.info,arrow:!0,placement:"top",children:t.jsx(n.Box,{component:"span",onClick:N=>N.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(D.InfoOutlined,{sx:{fontSize:13}})})})]})]},Q.id)})})]}),t.jsxs(n.Box,{className:`urm-export-section ${w.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${v.sectionBorder}`,borderRadius:"12px",p:v.sectionPadding,pt:2.25,bgcolor:v.sectionTitleBg,mt:1.5},children:[t.jsx(n.Typography,{className:`urm-export-section-title ${w.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:v.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:v.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(n.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:v.optionGap},children:[{value:"visible",label:"Visible rows",icon:t.jsx(D.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx(D.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(Q=>{const ee=F===Q.value;return t.jsxs(n.Box,{onClick:()=>O(Q.value),className:`urm-export-row-card ${ee?w.rowCardSelected||"":w.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:v.cardRadius,border:ee?`2px solid ${v.cardSelectedBorder}`:`1px solid ${v.cardBorder}`,boxShadow:ee?void 0:v.cardShadow,bgcolor:ee?v.cardSelectedBg:v.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?v.cardSelectedBorder:M(m.text.primary,.25),bgcolor:ee?v.cardSelectedBg:v.cardHoverBg}},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(Ds,{checked:ee}),t.jsx(n.Box,{sx:{color:ee?v.cardSelectedColor:m.text.secondary,display:"flex"},children:Q.icon}),t.jsx(n.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:ee?v.cardSelectedColor:m.text.primary},children:Q.label})]}),t.jsx(n.Tooltip,{title:Q.info,arrow:!0,placement:"top",children:t.jsx(n.Box,{component:"span",onClick:N=>N.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(D.InfoOutlined,{sx:{fontSize:16}})})})]},Q.value)})})]}),t.jsxs(n.Box,{className:`urm-export-section ${w.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${v.sectionBorder}`,borderRadius:"12px",p:v.sectionPadding,pt:2.25,bgcolor:v.sectionTitleBg,mt:1.5},children:[t.jsx(n.Typography,{className:`urm-export-section-title ${w.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:v.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:v.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(n.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:v.optionGap},children:[{value:"visible",label:"Visible columns",icon:t.jsx(D.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx(D.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(Q=>{const ee=J===Q.value;return t.jsxs(n.Box,{onClick:()=>te(Q.value),className:`urm-export-column-card ${ee?w.columnCardSelected||"":w.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:v.cardRadius,border:ee?`2px solid ${v.cardSelectedBorder}`:`1px solid ${v.cardBorder}`,boxShadow:ee?void 0:v.cardShadow,bgcolor:ee?v.cardSelectedBg:v.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?v.cardSelectedBorder:M(m.text.primary,.25),bgcolor:ee?v.cardSelectedBg:v.cardHoverBg}},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(Ds,{checked:ee}),t.jsx(n.Box,{sx:{color:ee?v.cardSelectedColor:m.text.secondary,display:"flex"},children:Q.icon}),t.jsx(n.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:ee?v.cardSelectedColor:m.text.primary},children:Q.label})]}),t.jsx(n.Tooltip,{title:Q.info,arrow:!0,placement:"top",children:t.jsx(n.Box,{component:"span",onClick:N=>N.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:m.text.secondary,"&:hover":{color:m.text.primary}},children:t.jsx(D.InfoOutlined,{sx:{fontSize:16}})})})]},Q.value)})})]}),t.jsxs(n.Box,{className:`urm-export-summary ${w.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${v.sectionBorder}`,borderRadius:"12px",p:v.sectionPadding,pt:2.25,bgcolor:v.sectionTitleBg,mt:1.5},children:[t.jsx(n.Typography,{className:`urm-export-section-title ${w.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:v.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:v.sectionTitleColor,lineHeight:1,zIndex:1},children:"Export Summary"}),t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[{icon:t.jsx(D.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Format",value:d[f]},{icon:t.jsx(D.FormatListNumberedOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Rows to Export",value:L.toLocaleString()},{icon:t.jsx(D.SwapVertOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Columns to Export",value:String(S)},{icon:t.jsx(D.InsertDriveFileOutlined,{sx:{fontSize:18,color:m.text.secondary}}),label:"Estimated File Size",value:`~${Do(Y.estimatedBytes)}`,highlight:Y.hasBlockingViolation?"error.main":Y.hasWarning?"warning.main":void 0}].map(({icon:Q,label:ee,value:N,highlight:re})=>t.jsxs(n.Box,{className:`urm-export-summary-row ${w.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[Q,t.jsx(n.Typography,{className:`urm-export-summary-label ${w.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:m.text.secondary,fontWeight:500},children:ee})]}),t.jsx(n.Typography,{className:`urm-export-summary-value ${w.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:re??m.text.primary},children:N})]},ee))})]})]})})}function Bp({warning:e,onDismiss:r}){return t.jsx(n.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(n.Alert,{severity:"warning",icon:t.jsx(D.Warning,{sx:{fontSize:20}}),action:t.jsx(n.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx(D.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[t.jsx(n.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),t.jsx(n.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:e.message}),t.jsxs(n.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 Ep({error:e,onDismiss:r,autoDismiss:o=!0,autoDismissDelay:i=3e4}){p.useEffect(()=>{if(o){const c=setTimeout(()=>{r()},i);return()=>clearTimeout(c)}},[o,i,r]);const a=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx(D.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx(D.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx(D.InfoOutlined,{sx:{fontSize:20}})}}})(),l=Ol(e);return t.jsx(n.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(n.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(n.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx(D.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${a.severity}.main`,boxShadow:3},children:[t.jsxs(n.AlertTitle,{sx:{fontWeight:c=>c.typography.h6.fontWeight||600,fontSize:c=>c.typography.subtitle2.fontSize||"0.875rem"},children:[e.context.charAt(0).toUpperCase()+e.context.slice(1)," Error"]}),t.jsx(n.Box,{sx:{fontSize:"body2.fontSize"},children:l}),e.details&&process.env.NODE_ENV==="development"&&t.jsx(n.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 _p extends p.Component{constructor(o){super(o);Oi(this,"handleReset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(o){return{hasError:!0,error:o}}componentDidCatch(o,i){Kt.error("urm:error-boundary","Caught unhandled component error",o,i),this.props.onError&&this.props.onError(o,i)}render(){var o,i;return this.state.hasError?this.props.fallback?this.props.fallback:t.jsx(n.Paper,{sx:{bgcolor:s=>M(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(D.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(n.Box,{sx:{flex:1},children:[t.jsx(n.Typography,{variant:"h4",sx:{color:"error.main",fontWeight:s=>s.typography.h4.fontWeight||600,fontSize:s=>s.typography.h4.fontSize||"1.25rem"},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(n.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((o=this.state.error)==null?void 0:o.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&t.jsx(n.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:s=>M(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(n.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx(D.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function $p({feature:e}){const[r,o]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>o(!1),5e3);return()=>clearTimeout(i)},[]),t.jsx(n.Collapse,{in:r,unmountOnExit:!0,children:t.jsxs(n.Alert,{severity:"warning",sx:{m:1},icon:t.jsx(D.Warning,{sx:{fontSize:20}}),action:t.jsx(n.IconButton,{size:"small",onClick:()=>o(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx(D.Close,{sx:{fontSize:16}})}),children:[t.jsxs(n.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function ln({children:e,feature:r,onError:o}){return t.jsx(_p,{context:r,onError:i=>{o&&o(i)},fallback:t.jsx($p,{feature:r}),children:e})}const Dp=[{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"}],Ip=[{value:"csv",label:"CSV",desc:"Comma-separated values"},{value:"excel",label:"Excel (.xlsx)",desc:"Native Excel format"},{value:"json",label:"JSON",desc:"Structured data with metadata"},{value:"pdf",label:"PDF",desc:"Print-ready PDF document"}],Or={sortMaxLevels:{title:"Maximum Sort Levels",description:"Limits the number of columns users can sort by simultaneously. Restricts multi-level sort depth.",tips:['"Add sort column" button is disabled at this limit',"Prevents adding more sort levels to the active sort stack","Default: 5 levels (range: 1–10)"]},filterMaxConditions:{title:"Maximum Filter Conditions",description:"Limits the total number of active filter conditions users can apply at once.",tips:['"Add condition" button is disabled at this limit',"Prevents performance degradation on large datasets","Default: 3 conditions (range: 1–20)"]},filterAllowedOperators:{title:"Allowed Filter Operators",description:"Controls which comparison operators appear in the filter UI. Unchecked operators are hidden from all dropdowns.",tips:["Simplifies the UI by hiding advanced operators your users don't need","At least one operator per data type must remain checked","Operators grouped by type: Text, Numeric, Boolean, Null checks"]},columnsMaxVisible:{title:"Maximum Visible Columns",description:"Limits the number of columns users can display at once in the data table.",tips:["Column visibility toggle is disabled when this limit is reached","Forces users to be selective about which columns to show","Default: 20 columns (range: 1–50)"]},columnsWidthRange:{title:"Column Width Constraints",description:"Sets minimum and maximum pixel widths for column resizing. Prevents columns from becoming too narrow or too wide.",tips:["Users cannot drag column borders outside this range","Min default: 60px, Max default: 800px","Ensures readable content and consistent layout"]},exportAllowedFormats:{title:"Allowed Export Formats",description:"Determines which export formats appear in the Export dialog and row-level export menus. At least one must be enabled.",tips:["Disabled formats don't appear in any export UI","PDF is now available as a print-ready export option","Unchecked formats are completely hidden from end users"]},groupingMaxLevels:{title:"Maximum Group Levels",description:"Limits how deeply users can nest grouped data. Enforced when adding new group levels.",tips:['"Add group level" button is hidden at this limit',"Range: 1 (single group only) to 3 (triple nested groups)","Prevents overly complex grouping hierarchies"]}};function Bo({children:e,active:r}){return t.jsx(n.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5,height:"200px",width:"100%"},children:e})}function Op({open:e,onClose:r,config:o,onApply:i}){const[s,a]=p.useState(0),[l,c]=p.useState(o);p.useEffect(()=>{e&&c(o)},[e,o]);const u=()=>c(mt),g=()=>{i(l),r()},x={sort:h=>c(m=>({...m,sort:{...m.sort,...h}})),filter:h=>c(m=>({...m,filter:{...m.filter,...h}})),columns:h=>c(m=>({...m,columns:{...m.columns,...h}})),grouping:h=>c(m=>({...m,grouping:{...m.grouping,...h}})),export:h=>c(m=>({...m,export:{...m.export,...h}}))},y=h=>{const m=l.filter.allowedOperators,E=m.includes(h)?m.filter(v=>v!==h):[...m,h];E.length!==0&&x.filter({allowedOperators:E})},w=h=>{const m=l.export.allowedFormats,E=m.includes(h)?m.filter(v=>v!==h):[...m,h];E.length!==0&&x.export({allowedFormats:E})},b=[{label:"Sort",icon:t.jsx(D.SwapVert,{sx:{fontSize:h=>h.typography.body1.fontSize}})},{label:"Filter",icon:t.jsx(D.FilterList,{sx:{fontSize:h=>h.typography.body1.fontSize}})},{label:"Columns",icon:t.jsx(D.ViewColumn,{sx:{fontSize:h=>h.typography.body1.fontSize}})},{label:"Grouping",icon:t.jsx(D.Layers,{sx:{fontSize:h=>h.typography.body1.fontSize}})},{label:"Export",icon:t.jsx(D.Download,{sx:{fontSize:h=>h.typography.body1.fontSize}})}],z=h=>JSON.stringify(l[h])===JSON.stringify(mt[h]);return t.jsxs(it,{open:e,onClose:r,icon:"⚙️",title:"Developer Configuration",subtitle:"· Set runtime constraints · Ctrl+Shift+D",width:600,maxHeight:"min(680px, calc(100vh - 180px))",headerExtra:t.jsx(n.Tabs,{value:s,onChange:(h,m)=>a(m),variant:"fullWidth",sx:{minHeight:44,borderBottom:"1px solid",borderColor:"divider","& .MuiTab-root":{minHeight:44,fontSize:h=>h.typography.caption.fontSize,textTransform:"none",fontWeight:h=>h.typography.button.fontWeight,gap:.5}},children:b.map((h,m)=>t.jsx(n.Tab,{label:h.label,icon:h.icon,iconPosition:"start"},m))}),footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{startIcon:t.jsx(D.RestartAlt,{sx:{fontSize:18}}),onClick:u,size:"small",sx:{mr:"auto",fontSize:h=>h.typography.body2.fontSize,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:h=>M(h.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsx(n.Button,{onClick:r,size:"small",sx:{fontSize:h=>h.typography.body2.fontSize,color:"text.secondary",px:2,borderRadius:h=>Number(h.shape.borderRadius)*2.25},children:"Cancel"}),t.jsx(n.Button,{onClick:g,size:"small",variant:"contained",sx:{fontSize:h=>h.typography.body2.fontSize,px:2.5,borderRadius:h=>Number(h.shape.borderRadius)*2.25},children:"Apply"})]}),children:[t.jsx(Bo,{active:s===0,children:t.jsxs(n.Box,{children:[t.jsx(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),t.jsx(yr,{content:Or.sortMaxLevels,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(n.Slider,{value:l.sort.maxLevels,onChange:(h,m)=>x.sort({maxLevels:m}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(n.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]})}),t.jsxs(Bo,{active:s===1,children:[t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),t.jsx(yr,{content:Or.filterMaxConditions,isDev:process.env.NODE_ENV==="development"})]}),!z("filter")&&t.jsx(n.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(n.Slider,{value:l.filter.maxConditions,onChange:(h,m)=>x.filter({maxConditions:m}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(n.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),t.jsx(n.Divider,{}),t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.5},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed filter operators"}),t.jsx(yr,{content:Or.filterAllowedOperators,isDev:process.env.NODE_ENV==="development"})]}),["Text","Numeric","Boolean","Null checks"].map(h=>t.jsxs(n.Box,{sx:{mb:1.5},children:[t.jsx(n.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:m=>m.typography.overline.fontSize,display:"block",mb:.5},children:h}),t.jsx(n.FormGroup,{row:!0,sx:{gap:.5},children:Dp.filter(m=>m.group===h).map(m=>t.jsx(n.FormControlLabel,{control:t.jsx(n.Checkbox,{size:"small",checked:l.filter.allowedOperators.includes(m.value),onChange:()=>y(m.value)}),label:t.jsx(n.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:m.label}),sx:{mr:1.5}},m.value))})]},h))]})]}),t.jsxs(Bo,{active:s===2,children:[t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),t.jsx(yr,{content:Or.columnsMaxVisible,isDev:process.env.NODE_ENV==="development"})]}),!z("columns")&&t.jsx(n.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(n.Slider,{value:l.columns.maxVisible,onChange:(h,m)=>x.columns({maxVisible:m}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(n.Divider,{}),t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:2},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Column width range (px)"}),t.jsx(yr,{content:Or.columnsWidthRange,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(n.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(n.Box,{sx:{flex:1},children:[t.jsx(n.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(n.Slider,{value:l.columns.minColumnWidth,onChange:(h,m)=>x.columns({minColumnWidth:m}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:h=>`${h}px`})]}),t.jsxs(n.Box,{sx:{flex:1},children:[t.jsx(n.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),t.jsx(n.Slider,{value:l.columns.maxColumnWidth,onChange:(h,m)=>x.columns({maxColumnWidth:m}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:h=>`${h}px`})]})]})]})]}),t.jsx(Bo,{active:s===3,children:t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),t.jsx(yr,{content:Or.groupingMaxLevels,isDev:process.env.NODE_ENV==="development"})]}),!z("grouping")&&t.jsx(n.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(n.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(h=>t.jsxs(n.Box,{onClick:()=>x.grouping({maxLevels:h}),sx:{flex:1,py:2.5,borderRadius:m=>Number(m.shape.borderRadius||0)*1.25,border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:l.grouping.maxLevels===h?"primary.main":"divider",bgcolor:l.grouping.maxLevels===h?m=>M(m.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:m=>M(m.palette.primary.main,.04)}},children:[t.jsx(n.Typography,{variant:"h5",sx:{fontWeight:700,color:l.grouping.maxLevels===h?"primary.main":"text.secondary"},children:h}),t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][h-1]})]},h))}),t.jsxs(n.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(n.FormControlLabel,{control:t.jsx(n.Checkbox,{checked:l.grouping.allowNested,onChange:h=>x.grouping({allowNested:h.target.checked})}),label:t.jsx(n.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(n.FormControlLabel,{control:t.jsx(n.Checkbox,{checked:l.grouping.allowCollapse,onChange:h=>x.grouping({allowCollapse:h.target.checked})}),label:t.jsx(n.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]})}),t.jsx(Bo,{active:s===4,children:t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),t.jsx(yr,{content:Or.exportAllowedFormats,isDev:process.env.NODE_ENV==="development"})]}),!z("export")&&t.jsx(n.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(n.FormGroup,{sx:{gap:1},children:Ip.map(h=>t.jsxs(n.Box,{onClick:()=>w(h.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:m=>m.shape.borderRadius,border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:l.export.allowedFormats.includes(h.value)?"primary.main":"divider",bgcolor:l.export.allowedFormats.includes(h.value)?m=>M(m.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(n.Checkbox,{size:"small",checked:l.export.allowedFormats.includes(h.value),onChange:()=>w(h.value),onClick:m=>m.stopPropagation()}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:500},children:h.label}),t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:h.desc})]})]},h.value))})]})})]})}const Mp=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ap={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 dn(e,r,o,i,s=new Date){const[a,l]=r.split(":").map(Number),c=new Date(s);if(c.setSeconds(0,0),c.setHours(a,l,0,0),e==="daily")return c<=s&&c.setDate(c.getDate()+1),c.toISOString();if(e==="weekly"){const u=o??1,g=c.getDay();let x=u-g;return x<0&&(x+=7),x===0&&c<=s&&(x=7),c.setDate(c.getDate()+x),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 Rp(e){const r=ya(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${Mp[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${Ap[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function ya(e){const[r,o]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(o).padStart(2,"0")} ${i}`}function Wp(e){const r=new Date(e).getTime()-Date.now();if(r<=0)return"now";const o=Math.floor(r/1e3),i=Math.floor(o/86400),s=Math.floor(o%86400/3600),a=Math.floor(o%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${a}m`:a>0?`in ${a}m`:"in less than a minute"}function Pp(e){const r=new Date(e),o=new Date,i=r.toDateString()===o.toDateString(),s=ya(`${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 ba(e){return`urm_schedules_${e}`}function va(e){try{const r=localStorage.getItem(ba(e));return r?JSON.parse(r).map(i=>({...i,runCount:typeof i.runCount=="number"?i.runCount:0,isActive:typeof i.isActive=="boolean"?i.isActive:!0,createdAt:i.createdAt||new Date().toISOString()})):[]}catch{return[]}}function Sa(e,r){try{localStorage.setItem(ba(e),JSON.stringify(r))}catch{}}const Lp=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:2,label:"Tuesday"},{value:3,label:"Wednesday"},{value:4,label:"Thursday"},{value:5,label:"Friday"},{value:6,label:"Saturday"}],Fp=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,wa={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",emails:[],viewId:""},gr={"& .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 Np(e){const r=(o,i)=>o.name.localeCompare(i.name);return{globalViews:e.filter(o=>o.scope==="global"&&!o.isDeleted).sort(r),favoriteViews:e.filter(o=>o.isFavorite&&!o.isDeleted).sort(r),personalViews:e.filter(o=>o.scope!=="global"&&!o.isDeleted).sort(r)}}function Vp({initial:e=wa,isEditing:r=!1,views:o,onSave:i,onBack:s}){const[a,l]=p.useState(e),[c,u]=p.useState(!1),[g,x]=p.useState(""),[y,w]=p.useState(""),{globalViews:b,favoriteViews:z,personalViews:h}=Np(o),m=(f,$)=>l(F=>({...F,[f]:$})),E=()=>{const f=g.trim();if(f){if(!Fp.test(f)){w("Please enter a valid email address");return}if(a.emails.includes(f)){w("This email is already added");return}m("emails",[...a.emails,f]),x(""),w("")}},v=f=>{m("emails",a.emails.filter($=>$!==f))},T=f=>{f.key==="Enter"&&(f.preventDefault(),E())},B=a.name.trim().length>0&&/^\d{2}:\d{2}$/.test(a.time)&&(a.frequency!=="monthly"||a.dayOfMonth>=1&&a.dayOfMonth<=28);return t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(n.IconButton,{size:"small",onClick:s,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:f=>M(f.palette.text.primary,.06)}},children:t.jsx(D.ArrowBack,{sx:{fontSize:18}})}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:f=>f.typography.body2.fontWeight||600,fontSize:f=>f.typography.body2.fontSize||"0.875rem"},children:r?"Edit schedule":"New schedule"})]}),t.jsx(n.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:a.name,onChange:f=>{m("name",f.target.value),c&&f.target.value.trim()&&u(!1)},onBlur:()=>u(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:c&&!a.name.trim(),helperText:c&&!a.name.trim()?"Schedule name is required":`${a.name.length}/50`,sx:gr}),t.jsxs(n.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2},children:[t.jsxs(n.FormControl,{size:"small",fullWidth:!0,sx:gr,children:[t.jsx(n.InputLabel,{children:"Frequency"}),t.jsxs(n.Select,{value:a.frequency,label:"Frequency",onChange:f=>m("frequency",f.target.value),children:[t.jsx(n.MenuItem,{value:"daily",children:"Daily"}),t.jsx(n.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(n.MenuItem,{value:"monthly",children:"Monthly"})]})]}),t.jsx(n.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:a.time,onChange:f=>m("time",f.target.value),InputLabelProps:{shrink:!0},sx:gr})]}),a.frequency==="weekly"&&t.jsxs(n.FormControl,{size:"small",fullWidth:!0,sx:gr,children:[t.jsx(n.InputLabel,{children:"Day of week"}),t.jsx(n.Select,{value:a.dayOfWeek,label:"Day of week",onChange:f=>m("dayOfWeek",Number(f.target.value)),children:Lp.map(f=>t.jsx(n.MenuItem,{value:f.value,children:f.label},f.value))})]}),a.frequency==="monthly"&&t.jsx(n.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:a.dayOfMonth,onChange:f=>m("dayOfMonth",Number(f.target.value)),inputProps:{min:1,max:28},error:a.dayOfMonth<1||a.dayOfMonth>28,helperText:a.dayOfMonth<1||a.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:gr}),t.jsxs(n.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2},children:[t.jsxs(n.FormControl,{size:"small",fullWidth:!0,sx:gr,children:[t.jsx(n.InputLabel,{children:"Export format"}),t.jsxs(n.Select,{value:a.format,label:"Export format",onChange:f=>m("format",f.target.value),children:[t.jsx(n.MenuItem,{value:"pdf",children:"PDF — Print-ready document"}),t.jsx(n.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(n.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(n.FormControl,{size:"small",fullWidth:!0,sx:gr,children:[t.jsx(n.InputLabel,{children:"Report view"}),t.jsx(n.Select,{value:a.viewId,label:"Report view",onChange:f=>m("viewId",f.target.value),startAdornment:t.jsx(D.Visibility,{sx:{fontSize:15,color:"text.disabled",ml:.5,mr:.5}}),MenuProps:{PaperProps:{sx:{maxHeight:280}}},renderValue:f=>{var $;return(($=o.find(F=>F.id===f))==null?void 0:$.name)||"Select view"},children:[["Global Views",b],["Favorite Views",z],["Personal Views",h]].flatMap(([f,$])=>$.length===0?[]:[t.jsx(n.ListSubheader,{sx:{fontSize:"caption.fontSize",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.05em",lineHeight:"32px"},children:f},`${f}-header`),...$.map(F=>t.jsxs(n.MenuItem,{value:F.id,sx:{fontSize:"0.8125rem",gap:1},children:[a.viewId===F.id?t.jsx(D.Check,{sx:{fontSize:16,flexShrink:0}}):t.jsx(n.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(n.Box,{component:"span",sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:F.name}),F.isDefault&&t.jsx(n.Box,{component:"span",sx:{fontSize:"caption.fontSize",color:"text.secondary",bgcolor:"action.selected",px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]},F.id))])})]})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Email recipients (optional)"}),t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.TextField,{size:"small",fullWidth:!0,type:"email",value:g,onChange:f=>{x(f.target.value),y&&w("")},onKeyPress:T,placeholder:"user@company.com",error:!!y,helperText:y||void 0,InputProps:{startAdornment:t.jsx(D.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:gr}),t.jsx(n.Button,{onClick:E,variant:"outlined",size:"small",startIcon:t.jsx(D.Add,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",borderRadius:"8px",px:1.5,flexShrink:0,height:40},children:"Add"})]}),a.emails.length>0&&t.jsx(n.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.75,mt:1},children:a.emails.map(f=>t.jsx(n.Chip,{label:f,size:"small",onDelete:()=>v(f),sx:{fontSize:"0.75rem",bgcolor:$=>M($.palette.primary.main,.08),color:"primary.main"}},f))})]}),t.jsxs(n.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(n.Button,{onClick:s,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:f=>M(f.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(n.Button,{onClick:()=>B&&i(a),disabled:!B,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function Hp({scheduleName:e,onConfirm:r,onCancel:o}){return t.jsxs(n.Dialog,{open:!0,onClose:o,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:Fo(i),...Rt(i).paper})},children:[t.jsxs(n.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(n.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>M(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(D.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(n.Typography,{sx:{fontSize:i=>i.typography.body1.fontSize||"0.9375rem",fontWeight:i=>i.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Delete Schedule"}),t.jsxs(n.Typography,{sx:{fontSize:i=>i.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",t.jsxs(n.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',e,'"']}),"? This action cannot be undone."]})]}),t.jsx(n.Divider,{}),t.jsxs(n.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(n.Button,{onClick:o,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsx(n.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function Gp({schedule:e,tick:r,onToggle:o,onRunNow:i,onEdit:s,onDelete:a}){var c;const l=e.isActive;return t.jsxs(n.Box,{sx:{border:"1px solid",borderColor:l?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:l?u=>M(u.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(n.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(n.Chip,{label:l?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:l?u=>M(u.palette.success.main,.1):u=>M(u.palette.text.primary,.06),color:l?"success.dark":"text.secondary"}})]}),t.jsx(n.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:Rp(e)}),t.jsxs(n.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[t.jsx(n.Chip,{label:e.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:u=>M(u.palette.primary.main,.08),color:"primary.main"}}),t.jsx(n.Chip,{label:e.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:u=>M(u.palette.text.primary,.06),color:"text.secondary"}}),e.viewName&&t.jsx(n.Chip,{icon:t.jsx(D.Visibility,{sx:{fontSize:11}}),label:e.viewName,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:160,bgcolor:u=>M(u.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}}),(c=e.emails)==null?void 0:c.map(u=>t.jsx(n.Chip,{icon:t.jsx(D.Email,{sx:{fontSize:11}}),label:u,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:g=>M(g.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}},u))]}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1},children:[t.jsxs(n.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[l&&t.jsxs(n.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",Wp(e.nextRunAt)]}),e.lastRunAt?t.jsxs(n.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",Pp(e.lastRunAt)," · ",e.runCount," run",e.runCount!==1?"s":""]}):t.jsx(n.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[t.jsx(n.Tooltip,{title:"Edit",placement:"top",children:t.jsx(n.IconButton,{size:"small",onClick:()=>s(e),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:u=>M(u.palette.primary.main,.08)}},children:t.jsx(D.Edit,{sx:{fontSize:15}})})}),t.jsx(n.Tooltip,{title:l?"Pause":"Resume",placement:"top",children:t.jsx(n.IconButton,{size:"small",onClick:()=>o(e.id),sx:{color:l?"warning.main":"success.main","&:hover":{bgcolor:l?u=>M(u.palette.warning.main,.08):u=>M(u.palette.success.main,.08)}},children:l?t.jsx(D.Pause,{sx:{fontSize:15}}):t.jsx(D.PlayArrow,{sx:{fontSize:15}})})}),t.jsx(n.Tooltip,{title:"Export now",placement:"top",children:t.jsx(n.IconButton,{size:"small",onClick:()=>i(e),sx:{color:"primary.main","&:hover":{bgcolor:u=>M(u.palette.primary.main,.08)}},children:t.jsx(D.Download,{sx:{fontSize:u=>u.typography.body1.fontSize}})})}),t.jsx(n.Tooltip,{title:"Delete",placement:"top",children:t.jsx(n.IconButton,{size:"small",onClick:()=>a(e.id),sx:{color:"error.main","&:hover":{bgcolor:u=>M(u.palette.error.main,.08)}},children:t.jsx(D.Delete,{sx:{fontSize:15}})})})]})]})]})}function Up({open:e,onClose:r,reportId:o,reportName:i,onRunNow:s,views:a,schedulerConfig:l}){var S,A;const u=((l==null?void 0:l.mode)??"local")==="api",[g,x]=p.useState([]),y=u?(l==null?void 0:l.schedules)??[]:g,[w,b]=p.useState({type:"list"}),[z,h]=p.useState(0),[m,E]=p.useState(null);p.useEffect(()=>{e&&(u||x(va(o)),b({type:"list"}))},[e,o,u]),p.useEffect(()=>{if(!e)return;const k=setInterval(()=>h(Y=>Y+1),3e4);return()=>clearInterval(k)},[e]);const v=p.useCallback(k=>{x(k),Sa(o,k)},[o]),T=k=>{var d,Q;const Y=dn(k.frequency,k.time,k.dayOfWeek,k.dayOfMonth),oe={id:`sched-${Date.now()}`,reportId:o,name:k.name.trim(),frequency:k.frequency,dayOfWeek:k.frequency==="weekly"?k.dayOfWeek:void 0,dayOfMonth:k.frequency==="monthly"?k.dayOfMonth:void 0,time:k.time,format:k.format,scope:k.scope,emails:k.emails.length>0?k.emails:void 0,viewId:k.viewId||void 0,viewName:k.viewId?(d=a.find(ee=>ee.id===k.viewId))==null?void 0:d.name:void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:Y,runCount:0};u?(Q=l==null?void 0:l.onScheduleCreate)==null||Q.call(l,oe):v([...y,oe]),b({type:"list"})},B=k=>{var Q,ee;if(w.type!=="edit")return;const Y=w.schedule,oe=dn(k.frequency,k.time,k.dayOfWeek,k.dayOfMonth),d={...Y,name:k.name.trim(),frequency:k.frequency,dayOfWeek:k.frequency==="weekly"?k.dayOfWeek:void 0,dayOfMonth:k.frequency==="monthly"?k.dayOfMonth:void 0,time:k.time,format:k.format,scope:k.scope,emails:k.emails.length>0?k.emails:void 0,viewId:k.viewId||void 0,viewName:k.viewId?(Q=a.find(N=>N.id===k.viewId))==null?void 0:Q.name:void 0,nextRunAt:oe};u?(ee=l==null?void 0:l.onScheduleUpdate)==null||ee.call(l,d):v(y.map(N=>N.id===Y.id?d:N)),b({type:"list"})},f=k=>{var ee;const Y=y.find(N=>N.id===k);if(!Y)return;const oe=!Y.isActive,d=oe?dn(Y.frequency,Y.time,Y.dayOfWeek,Y.dayOfMonth):Y.nextRunAt,Q={...Y,isActive:oe,nextRunAt:d};u?(ee=l==null?void 0:l.onScheduleToggle)==null||ee.call(l,k,oe):v(y.map(N=>N.id===k?Q:N))},$=k=>{if(s(k),!u){const Y=new Date().toISOString();v(y.map(oe=>oe.id===k.id?{...oe,lastRunAt:Y,runCount:oe.runCount+1}:oe))}},F=k=>{const Y=y.find(oe=>oe.id===k)??null;E(Y)},O=()=>{var k;m&&(u?(k=l==null?void 0:l.onScheduleDelete)==null||k.call(l,m.id):v(y.filter(Y=>Y.id!==m.id)),E(null))},J=k=>{var Y,oe;return{name:k.name,frequency:k.frequency,dayOfWeek:k.dayOfWeek??1,dayOfMonth:k.dayOfMonth??1,time:k.time,format:k.format,scope:k.scope,emails:k.emails??[],viewId:k.viewId||((Y=a.find(d=>d.isDefault))==null?void 0:Y.id)||((oe=a[0])==null?void 0:oe.id)||""}},te=w.type!=="list",L=y.filter(k=>k.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(it,{open:e,onClose:r,icon:t.jsx(D.Schedule,{sx:{fontSize:20}}),title:"Scheduled Reports",subtitle:`· ${i}`,helpContent:Rr.schedule,width:600,maxHeight:"min(680px, calc(100vh - 180px))",disableEscapeKeyDown:te,footer:w.type==="list"?t.jsx(n.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:k=>M(k.palette.text.primary,.06)}},children:"Close"}):void 0,children:[te&&t.jsx(Vp,{initial:w.type==="edit"?J(w.schedule):{...wa,viewId:((S=a.find(k=>k.isDefault))==null?void 0:S.id)||((A=a[0])==null?void 0:A.id)||""},isEditing:w.type==="edit",views:a,onSave:w.type==="edit"?B:T,onBack:()=>b({type:"list"})}),w.type==="list"&&t.jsxs(t.Fragment,{children:[t.jsxs(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:y.length===0?"No schedules yet":`${L} of ${y.length} active`}),t.jsx(n.Button,{startIcon:t.jsx(D.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>b({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),y.length===0?t.jsxs(n.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx(D.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:k=>k.typography.body2.fontWeight||500,fontSize:k=>k.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No scheduled reports yet"}),t.jsx(n.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:y.map(k=>t.jsx(Gp,{schedule:k,tick:z,onToggle:f,onRunNow:$,onEdit:Y=>b({type:"edit",schedule:Y}),onDelete:F},k.id))})]})]}),m&&t.jsx(Hp,{scheduleName:m.name,onConfirm:O,onCancel:()=>E(null)})]})}const Yp=6e4;function qp({reportId:e,reportName:r,uploadedData:o,processedData:i,schema:s,activeView:a,views:l,columnVisibility:c,columnOrder:u,filters:g,sortStack:x,onFired:y,schedulerConfig:w}){const b=(w==null?void 0:w.mode)??"local",z=p.useRef({reportId:e,reportName:r,uploadedData:o,processedData:i,schema:s,activeView:a,views:l,columnVisibility:c,columnOrder:u,filters:g,sortStack:x,onFired:y,schedulerConfig:w,schedulerMode:b});p.useEffect(()=>{z.current={reportId:e,reportName:r,uploadedData:o,processedData:i,schema:s,activeView:a,views:l,columnVisibility:c,columnOrder:u,filters:g,sortStack:x,onFired:y,schedulerConfig:w,schedulerMode:b}});const h=p.useCallback(m=>{var A,k,Y,oe,d,Q;const{reportName:E,uploadedData:v,processedData:T,schema:B,activeView:f,views:$,columnVisibility:F,columnOrder:O,filters:J,sortStack:te,schedulerConfig:L,schedulerMode:S}=z.current;try{const ee=m.viewId?$.find(W=>W.id===m.viewId):void 0,N=ee?ee.snapshot.filters:J,re=ee?ee.snapshot.sortStack:te,ue=ee?ee.snapshot.columnVisibility:F,le=ee?ee.snapshot.columnOrder:O,Z=m.scope==="all"?v:ee?yi(Ti(v,N,B),B,re):T;if(S==="api"){const W=(le.length>0?le:B.map(fe=>fe.name)).filter(fe=>ue[fe]!==!1),ie={schedule:m,triggeredAt:new Date().toISOString(),rows:Z,columns:W,format:m.format,reportName:E};(A=L==null?void 0:L.onScheduleFire)==null||A.call(L,ie),(Y=(k=z.current).onFired)==null||Y.call(k,m);return}const de=un(Z,B,N,re,ee||f,ue,le),se=`${m.name}_scheduled`;switch(m.format){case"csv":pn(de,se,{scope:m.scope});break;case"excel":fn(de,se,{scope:m.scope});break;case"json":mn(de,se,{scope:m.scope});break;case"pdf":ki(de,se,{scope:m.scope});break}if(L!=null&&L.onScheduleFire){const W=(le.length>0?le:B.map(ie=>ie.name)).filter(ie=>ue[ie]!==!1);L.onScheduleFire({schedule:m,triggeredAt:new Date().toISOString(),rows:Z,columns:W,format:m.format,reportName:E})}if((oe=m.emails)!=null&&oe.length){const W=encodeURIComponent(`Scheduled Report: ${m.name}`),ie=encodeURIComponent(`Your scheduled report "${m.name}" has been generated.
191
+ ]`})})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Supported Column Types"}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"The system automatically detects column types from your data:"}),t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:[t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Number:"}),t.jsxs(n.Typography,{variant:"body2",color:"text.secondary",children:["Numeric values (e.g.,"," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"33"}),","," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"42.5"}),")"]})]}),t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Boolean:"}),t.jsxs(n.Typography,{variant:"body2",color:"text.secondary",children:["True/false values (e.g.,"," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"true"}),","," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:"false"}),")"]})]}),t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.typography.body2.fontSize||"0.875rem",minWidth:80},children:"String:"}),t.jsxs(n.Typography,{variant:"body2",color:"text.secondary",children:["Text values (e.g.,"," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Europe"'}),","," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"Analytics Pro"'}),")"]})]}),t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:s=>s.typography.body2.fontWeight||500,fontSize:s=>s.typography.body2.fontSize||"0.875rem",minWidth:80},children:"Date:"}),t.jsxs(n.Typography,{variant:"body2",color:"text.secondary",children:["ISO date strings (e.g.,"," ",t.jsx(n.Box,{component:"code",sx:{bgcolor:"action.hover",px:.5,borderRadius:.5,fontFamily:"monospace",fontSize:"caption.fontSize"},children:'"2024-08-22"'}),")"]})]})]})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"subtitle2",gutterBottom:!0,children:"Notes"}),t.jsxs(n.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."})]})]})]})}):null}function Su({onFileUpload:e,onError:r,isUploading:o,jsonGuideContent:i,jsonGuideTitle:s,jsonGuideTooltip:a}){const[l,c]=p.useState(!1),[u,x]=p.useState(""),[g,y]=p.useState(!1),S=p.useRef(null),b=async z=>{if(!z.name.endsWith(".json")){r("Only .json files are allowed");return}const h=10*1024*1024;if(z.size>h){r("File size exceeds 10MB limit");return}x(z.name);try{const I=await z.text();let A;try{A=JSON.parse(I)}catch{r("Invalid JSON syntax — please check your file and try again");return}if(!Array.isArray(A)){r("JSON must be an array of objects");return}if(A.length===0){r("No data rows found in JSON file");return}e(A)}catch{r("Network error — please try again")}finally{x("")}},T=z=>{z.preventDefault(),c(!0)},m=z=>{z.preventDefault(),c(!1)},f=z=>{z.preventDefault(),c(!1);const h=z.dataTransfer.files[0];h&&b(h)},B=()=>{var z;(z=S.current)==null||z.click()},j=z=>{var I;const h=(I=z.target.files)==null?void 0:I[0];h&&b(h)},D=z=>{z.stopPropagation(),y(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs(n.Box,{onDragOver:T,onDragLeave:m,onDrop:f,onPaste:z=>z.preventDefault(),onClick:B,sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderStyle:"dashed",borderColor:l?"primary.main":"divider",bgcolor:l?z=>M(z.palette.primary.main,.12):"transparent",borderRadius:1,px:2,py:6,cursor:"pointer",transition:"all 0.2s",opacity:o?.5:1,pointerEvents:o?"none":"auto","&:hover":{borderColor:l?"primary.main":"text.secondary"}},children:[t.jsx(n.Box,{component:"input",ref:S,type:"file",accept:".json",onChange:j,sx:{display:"none"}}),o?t.jsxs(t.Fragment,{children:[t.jsx(n.CircularProgress,{size:32,sx:{mb:2}}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:z=>z.typography.body2.fontWeight||500,fontSize:z=>z.typography.body2.fontSize||"0.875rem",mb:.5},children:"Uploading..."}),u&&t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:u})]}):t.jsxs(t.Fragment,{children:[t.jsx(n.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:z=>M(z.palette.primary.main,.12),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(_.UploadFile,{sx:{fontSize:32,color:"primary.main"}})}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:1.5},children:[t.jsx(n.Button,{variant:"contained",sx:{fontWeight:500},children:"Upload Data (JSON)"}),t.jsx(n.IconButton,{onClick:D,size:"small",sx:{border:1,borderColor:"divider","&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},title:a??"View JSON format guide",children:t.jsx(_.InfoOutlined,{sx:{fontSize:16}})})]}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",maxWidth:500},children:"Upload structured JSON data to generate your report."}),t.jsx(n.Typography,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Click to browse or drag and drop a JSON file here"})]})]}),t.jsx(ha,{isOpen:g,onClose:()=>y(!1),content:i,title:s})]})}function wu({schema:e,onConfirm:r,hasConflicts:o}){return t.jsxs(n.Paper,{sx:{border:2,borderColor:"divider",p:3},children:[t.jsxs(n.Box,{sx:{mb:2},children:[t.jsx(n.Typography,{variant:"h4",sx:{fontWeight:i=>i.typography.h4.fontWeight||600,fontSize:i=>i.typography.h4.fontSize||"1.25rem",mb:.5},children:"Schema Preview"}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"Review the detected schema before generating your table"})]}),o&&t.jsxs(n.Alert,{severity:"warning",sx:{mb:2},children:[t.jsx(n.AlertTitle,{sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.subtitle2.fontSize||"0.875rem"},children:"Schema Conflict Detected"}),"Some columns have inconsistent data types across rows. Please resolve these conflicts before proceeding."]}),t.jsx(n.TableContainer,{sx:{mb:3},children:t.jsxs(n.Table,{children:[t.jsx(n.TableHead,{children:t.jsxs(n.TableRow,{sx:{bgcolor:"action.hover"},children:[t.jsx(n.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Column Name"}),t.jsx(n.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Detected Type"}),t.jsx(n.TableCell,{sx:{fontWeight:600,textTransform:"uppercase",fontSize:"caption.fontSize"},children:"Status"})]})}),t.jsx(n.TableBody,{children:e.map(i=>t.jsxs(n.TableRow,{sx:{bgcolor:i.hasConflict?s=>M(s.palette.warning.main,.12):"transparent"},children:[t.jsxs(n.TableCell,{sx:{fontWeight:500},children:[i.name,i.hasConflict&&t.jsx(n.Box,{component:"span",sx:{ml:1,color:"warning.main"},children:"⚠"})]}),t.jsx(n.TableCell,{children:t.jsx(n.Chip,{label:i.type,size:"small",sx:{bgcolor:"action.hover"}})}),t.jsx(n.TableCell,{children:t.jsx(n.Chip,{label:i.required?"Required":"Optional",size:"small",color:i.required?"success":"default"})})]},i.name))})]})}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",pt:2,borderTop:1,borderColor:"divider"},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(_.Lock,{sx:{fontSize:16}}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"Schema will be locked for this report"})]}),t.jsx(n.Button,{variant:"contained",onClick:r,disabled:o,sx:{fontWeight:500},children:"Generate Table"})]})]})}function Cu({error:e,onRetry:r}){return t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,border:2,borderColor:"error.light",bgcolor:o=>M(o.palette.error.main,.12),borderRadius:1,px:2,py:6},children:[t.jsx(n.Box,{sx:{width:64,height:64,borderRadius:"50%",bgcolor:o=>M(o.palette.error.main,.3),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(_.ErrorOutline,{color:"error",sx:{fontSize:32}})}),t.jsx(n.Typography,{variant:"h4",color:"error.main",sx:{fontWeight:o=>o.typography.h4.fontWeight||600,fontSize:o=>o.typography.h4.fontSize||"1.25rem",mb:1},children:"Upload Failed"}),t.jsx(n.Typography,{variant:"body2",color:"error.main",sx:{textAlign:"center",maxWidth:500,mb:3},children:e}),t.jsx(n.Button,{variant:"contained",color:"error",startIcon:t.jsx(_.Upload,{sx:{fontSize:16}}),onClick:r,sx:{fontWeight:500},children:"Try Again"})]})}function ks({angle:e}){return t.jsx(n.Box,{"aria-hidden":!0,sx:{position:"absolute",inset:0,m:"auto",width:80,height:96,borderRadius:"16px",bgcolor:"background.paper",border:"1px solid",borderColor:"divider",transform:`rotate(${e}deg)`,boxShadow:r=>`0 12px 30px ${M(r.palette.primary.dark,.25)}`}})}function ma({title:e,description:r,showIcon:o=!0,action:i}){return t.jsxs(n.Box,{sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"60vh",px:3,py:8,isolation:"isolate"},children:[t.jsx(n.Box,{"aria-hidden":!0,sx:{position:"absolute",top:"50%",left:"50%",width:226,height:226,transform:"translate(-50%, -62%)",borderRadius:"50%",filter:"blur(64px)",opacity:.76,zIndex:-1,pointerEvents:"none",background:s=>s.palette.mode==="dark"?"none":`linear-gradient(45deg, ${M(s.palette.primary.main,.25)} 0%, ${M(s.palette.primary.main,.2)} 50%, transparent 100%)`}}),o&&t.jsxs(n.Box,{sx:{position:"relative",width:128,height:128,mb:1},children:[t.jsx(ks,{angle:-8}),t.jsx(ks,{angle:7}),t.jsx(n.Box,{sx:{position:"absolute",inset:0,m:"auto",width:80,height:80,borderRadius:"16px",display:"flex",alignItems:"center",justifyContent:"center",color:"common.white",background:s=>ht(s).iconTileBg,filter:s=>`drop-shadow(0 18px 20px ${M(s.palette.primary.main,.6)})`},children:t.jsx(_.Description,{sx:{fontSize:34}})})]}),t.jsx(n.Typography,{variant:"h5",sx:{fontWeight:400,mb:r?1:3,color:"text.primary",fontSize:"1.375rem",letterSpacing:"-0.025em"},children:e}),r&&t.jsx(n.Typography,{variant:"body1",sx:{textAlign:"center",maxWidth:520,mb:i?3:0,color:"text.secondary",fontSize:s=>s.typography.body2.fontSize||"0.875rem",lineHeight:1.5},children:r}),i&&t.jsx(n.Button,{onClick:i.onClick,startIcon:t.jsx(_.Add,{sx:{fontSize:18}}),sx:{height:41,px:2.5,borderRadius:"12px",textTransform:"none",fontSize:"0.875rem",fontWeight:400,color:"common.white",background:s=>ht(s).ctaBg,filter:s=>ht(s).ctaShadow,"&:hover":{filter:s=>ht(s).ctaShadow,opacity:.92}},children:i.label})]})}function ju({value:e,onChange:r,searchHistory:o,onAddToHistory:i,onToggleFavourite:s,onDeleteHistory:a,disabled:l}){const[c,u]=p.useState(!1),[x,g]=p.useState(!1),[y,S]=p.useState(-1),b=p.useRef(null),T=p.useRef(null);p.useEffect(()=>{function $(Y){b.current&&!b.current.contains(Y.target)&&(u(!1),g(!1))}return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[]);const m=p.useCallback(()=>{g(!0),S(-1),o.length>0&&u(!0)},[o.length]),f=p.useCallback($=>{r($),S(-1)},[r]),B=p.useCallback($=>{var Y;r($),i($),u(!1),(Y=T.current)==null||Y.blur()},[r,i]),j=p.useCallback($=>{S(-1),B($)},[B]),D=p.useCallback($=>{var Y;$.key==="Enter"?y>=0&&y<o.length?($.preventDefault(),j(o[y].query)):e.trim()&&B(e.trim()):$.key==="Escape"?(u(!1),S(-1),(Y=T.current)==null||Y.blur()):$.key==="ArrowDown"?($.preventDefault(),o.length>0&&(c||u(!0),S(X=>X<o.length-1?X+1:X))):$.key==="ArrowUp"&&($.preventDefault(),S(X=>X>0?X-1:-1))},[y,o,e,c,j,B]),z=p.useCallback(()=>{var $;r(""),($=T.current)==null||$.focus()},[r]),h=p.useMemo(()=>o.filter($=>$.isFavourite),[o]),I=p.useMemo(()=>o.filter($=>!$.isFavourite),[o]),A=c&&o.length>0;return t.jsxs(n.Box,{sx:{position:"relative",width:240},ref:b,children:[t.jsx(n.TextField,{inputRef:T,size:"small",fullWidth:!0,value:e,onChange:$=>f($.target.value),onFocus:m,onKeyDown:D,placeholder:"Search data...",disabled:l,sx:{"& .MuiOutlinedInput-root":{borderRadius:"20px",fontSize:"0.875rem",bgcolor:"background.paper",height:"36px","& fieldset":{borderColor:$=>M($.palette.text.primary,.3),transition:"all 0.15s ease"},"&:hover":{bgcolor:"action.hover"},"&:hover fieldset":{borderColor:$=>M($.palette.text.primary,.5)},"&.Mui-focused":{bgcolor:"background.paper"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:2}},"& .MuiOutlinedInput-input":{py:"6px",px:"8px",color:"text.primary"}},InputProps:{startAdornment:t.jsx(n.InputAdornment,{position:"start",sx:{ml:.5},children:t.jsx(_.Search,{sx:{fontSize:18,color:"text.secondary"}})}),endAdornment:e?t.jsx(n.InputAdornment,{position:"end",children:t.jsx(n.IconButton,{size:"small",onClick:z,edge:"end",sx:{mr:-.5},children:t.jsx(_.Close,{sx:{fontSize:16}})})}):null}}),A&&t.jsxs(n.Paper,{sx:{position:"absolute",zIndex:50,mt:.5,width:"100%",maxHeight:384,overflowY:"auto"},elevation:3,children:[h.length>0&&t.jsxs(n.Box,{sx:{py:1},children:[t.jsx(n.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:$=>$.typography.caption.fontWeight||600,fontSize:$=>$.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Favourite Searches"}),h.map(($,Y)=>t.jsx(Ts,{entry:$,isSelected:y===Y,onClick:()=>j($.query),onToggleFavourite:()=>s($.query),onDelete:()=>a($.query)},`fav-${$.query}`))]}),I.length>0&&t.jsxs(n.Box,{sx:{py:1},children:[h.length>0&&t.jsx(n.Divider,{}),t.jsx(n.Typography,{variant:"caption",sx:{px:1.5,py:.75,display:"block",fontWeight:$=>$.typography.caption.fontWeight||600,fontSize:$=>$.typography.caption.fontSize||"0.75rem",textTransform:"uppercase",color:"text.secondary",letterSpacing:"0.05em"},children:"Recent Searches"}),I.map(($,Y)=>{const X=h.length+Y;return t.jsx(Ts,{entry:$,isSelected:y===X,onClick:()=>j($.query),onToggleFavourite:()=>s($.query),onDelete:()=>a($.query)},`recent-${$.query}`)})]})]})]})}const Ts=p.memo(function({entry:r,isSelected:o,onClick:i,onToggleFavourite:s,onDelete:a}){const l=p.useCallback(u=>{u.stopPropagation(),s()},[s]),c=p.useCallback(u=>{u.stopPropagation(),a()},[a]);return t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:1.5,py:1,cursor:"pointer",bgcolor:o?u=>M(u.palette.primary.main,.12):"transparent","&:hover":{bgcolor:o?u=>M(u.palette.primary.main,.12):"action.hover"}},children:[t.jsx(n.Box,{sx:{flex:1,minWidth:0},onClick:i,children:t.jsx(n.Typography,{variant:"body2",noWrap:!0,children:r.query})}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5,ml:1},children:[t.jsx(n.IconButton,{size:"small",onClick:l,title:r.isFavourite?"Remove from favourites":"Add to favourites",sx:{p:.5},children:r.isFavourite?t.jsx(_.Star,{sx:{fontSize:14,color:"warning.light"}}):t.jsx(_.StarBorder,{sx:{fontSize:14,color:"action.disabled"}})}),t.jsx(n.IconButton,{size:"small",onClick:c,title:"Delete from history",sx:{p:.5,"&:hover":{color:"error.main"}},children:t.jsx(_.Delete,{sx:{fontSize:14,opacity:.5}})})]})]})});function ku(e){const{value:r,disabled:o}=e,[i,s]=p.useState(!1),a=p.useRef(null),l=r.trim().length>0,c=i||l;return p.useEffect(()=>{var u,x;i&&((x=(u=a.current)==null?void 0:u.querySelector("input"))==null||x.focus())},[i]),p.useEffect(()=>{if(!i)return;const u=x=>{var g;!((g=a.current)!=null&&g.contains(x.target))&&!l&&s(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[i,l]),c?t.jsx(n.Box,{ref:a,onKeyDown:u=>{u.key==="Escape"&&!l&&s(!1)},children:t.jsx(ju,{...e})}):t.jsx(n.Tooltip,{title:"Search",children:t.jsx("span",{children:t.jsx(n.IconButton,{onClick:()=>s(!0),disabled:o,"aria-label":"Search",sx:{width:40,height:40,color:"text.primary",bgcolor:u=>M(u.palette.primary.main,.1),"&:hover":{bgcolor:u=>M(u.palette.primary.main,.18)}},children:t.jsx(_.Search,{sx:{fontSize:20}})})})})}const Tu={active:"success",completed:"success",approved:"success",success:"success",done:"success","full time":"success","part time":"info",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"},zu={error:"err",warning:"warn",info:"info",success:"suc"};function rn(e,r){var l,c;const o=Tu[r.toLowerCase().trim()];if(!o||o==="neutral")return{bg:e.palette.action.selected,color:e.palette.text.secondary};const i=e.tokens,s=zu[o],a=e.palette[o];return{bg:((l=i==null?void 0:i.status)==null?void 0:l[`${s}Soft`])??M(a.main,e.palette.mode==="dark"?.24:.12),color:((c=i==null?void 0:i.status)==null?void 0:c[`${s}Txt`])??(e.palette.mode==="dark"?a.light:a.dark)}}function Bu(e,r){switch(r.toLowerCase().trim()){case"low":return e.palette.text.secondary;case"medium":return e.palette.warning.main;case"high":return e.palette.mode==="dark"?e.palette.warning.light:e.palette.warning.dark;case"critical":case"urgent":return e.palette.error.main;default:return}}const Eu={filters:{hue:"primary",shade:"main"},sorting:{hue:"secondary",shade:"main"},grouping:{hue:"success",shade:"main"},columns:{hue:"warning",shade:"main"},views:{hue:"error",shade:"main"},theme:{hue:"info",shade:"main"},export:{hue:"primary",shade:"dark"},presets:{hue:"secondary",shade:"dark"},system:{hue:"error",shade:"dark"},rows:{hue:"primary",shade:"main"}};function zs(e,r){const o=Eu[r];return o?e.palette[o.hue][o.shade]:e.palette.text.secondary}function sr(e){return M(e.palette.primary.main,e.palette.mode==="dark"?.24:.12)}function on({title:e,onClick:r,active:o=!1,badge:i,children:s}){return t.jsx(n.Tooltip,{title:e,children:t.jsxs(n.IconButton,{onClick:r,size:"small",sx:{position:"relative",width:34,height:32,border:"1px solid",borderColor:"primary.light",borderRadius:"8px",color:"primary.main",bgcolor:o?a=>sr(a):"background.paper",transition:"all 0.15s ease","&:hover":{bgcolor:a=>M(a.palette.primary.main,o?.2:.08)}},children:[s,i!==void 0&&i>0&&t.jsx(n.Box,{component:"span",sx:{position:"absolute",top:-6,right:-6,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:i})]})})}function _u({views:e,activeViewId:r,isDirty:o,onSelectView:i,onCreateView:s,onToggleDefault:a,onToggleFavorite:l,onRestoreView:c,onPermanentDelete:u,onEditView:x,onCloneView:g,onCopyLink:y,onDeleteView:S,onPromoteToGlobal:b,onSetDefaultForAllUsers:T,isReadOnly:m,isAdmin:f=!1,hideViewMenuActions:B,customViewMenuActions:j,viewMenuActionData:D,viewMenuActionTableState:z}){const h=vt(),[I,A]=p.useState(!1),[$,Y]=p.useState(!1),[X,R]=p.useState({top:0,left:0}),[v,W]=p.useState(null),[k,q]=p.useState(null),re=p.useRef(null),d=p.useRef(null),Q=e.find(L=>L.id===r),ee=Q==null?void 0:Q.isDefault,H=(L,Se)=>L.name.localeCompare(Se.name),te=e.filter(L=>L.scope==="global"&&!L.isDeleted).sort(H),ue=e.filter(L=>L.scope!=="global"&&!L.isDeleted).sort(H),le=e.filter(L=>L.isFavorite&&!L.isDeleted).sort(H),Z=e.filter(L=>L.isDeleted);p.useEffect(()=>{if(I&&d.current){const L=d.current.getBoundingClientRect(),Se=320,ke=8;let We=L.left+window.scrollX;We+Se>window.innerWidth-ke&&(We=window.innerWidth-Se-ke),We<ke&&(We=ke),R({top:L.bottom+window.scrollY+8,left:We})}},[I]),p.useEffect(()=>{const L=Se=>{re.current&&!re.current.contains(Se.target)&&d.current&&!d.current.contains(Se.target)&&A(!1)};return I&&document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L)}},[I]);const de=L=>{if(o&&L!==r){W(L),A(!1);return}i(L),A(!1)},ae=()=>{v&&(i(v),W(null))},F=()=>{W(null)},ie=(L,Se=!1)=>{const ke=L.scope==="global",We=!m&&(!ke||f),Ae=f&&!ke,at=((j==null?void 0:j.length)??0)>0;return t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:r===L.id?it(h).bg:"transparent",transition:"background-color 0.2s","&:hover":{backgroundColor:r===L.id?it(h).hoverBg:h.palette.action.hover}},children:[t.jsxs(n.Button,{onClick:()=>de(L.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===L.id&&t.jsx(_.Check,{sx:{fontSize:16,flexShrink:0}}),r!==L.id&&t.jsx(n.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(n.Typography,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:r===L.id?h.palette.primary.dark:h.palette.text.primary,fontWeight:r===L.id?tt=>tt.typography.body2.fontWeight||500:400,fontSize:tt=>tt.typography.body2.fontSize||"0.875rem"},children:L.name}),Se&&t.jsx(n.Typography,{component:"span",sx:{fontSize:"caption.fontSize",color:h.palette.text.secondary,backgroundColor:h.palette.action.selected,px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[We&&l&&t.jsx(n.IconButton,{onClick:tt=>{tt.stopPropagation(),l(L.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:L.isFavorite?"Remove from favorites":"Add to favorites",children:t.jsx(_.Star,{sx:{fontSize:16}})}),We&&a&&!L.isDefault&&t.jsx(n.IconButton,{onClick:tt=>{tt.stopPropagation(),a(L.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Set as default",children:t.jsx(_.RadioButtonUnchecked,{sx:{fontSize:16}})}),(at||(We||Ae)&&(x||g||y||S||Ae&&b))&&t.jsx(n.IconButton,{onClick:tt=>{tt.stopPropagation(),q({el:tt.currentTarget,view:L})},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"More actions",children:t.jsx(_.MoreVert,{sx:{fontSize:16}})})]})]},L.id)},he=L=>t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",px:2,py:1,fontSize:"body2.fontSize",backgroundColor:h.palette.action.hover},children:[t.jsx(n.Typography,{sx:{color:h.palette.text.secondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:L.name}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5,flexShrink:0},children:[c&&t.jsx(n.IconButton,{onClick:Se=>{Se.stopPropagation(),c(L.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Restore view",children:t.jsx(_.Undo,{sx:{fontSize:16,color:"success.main"}})}),u&&t.jsx(n.IconButton,{onClick:Se=>{Se.stopPropagation(),u(L.id)},size:"small",sx:{p:.5,transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},title:"Delete permanently",children:t.jsx(_.Delete,{sx:{fontSize:16,color:"error.main"}})})]})]},L.id),pe=o||!ee,Me=o;return t.jsxs(n.Box,{sx:{position:"relative"},children:[t.jsxs(n.Button,{ref:d,onClick:()=>A(!I),variant:"outlined",size:"small",endIcon:t.jsx(_.KeyboardArrowDown,{sx:{fontSize:16}}),sx:{position:"relative",minWidth:140,maxWidth:220,justifyContent:"space-between",fontSize:"0.875rem",textTransform:"none",color:pe?"warning.main":"text.primary",borderColor:pe?"warning.main":M(h.palette.text.primary,.2),bgcolor:pe?M(h.palette.warning.main,.12):"background.paper",borderRadius:"999px",py:.5,px:1.5,transition:"all 0.15s ease","&:hover":{borderColor:pe?"warning.dark":"primary.main",bgcolor:pe?M(h.palette.warning.main,.2):M(h.palette.text.primary,.06),color:pe?"warning.dark":"text.primary"}},title:`View: ${(Q==null?void 0:Q.name)||"Default View"}`,children:[t.jsx(n.Box,{component:"span",sx:{overflow:"hidden",textOverflow:"ellipsis"},children:(Q==null?void 0:Q.name)||"Default View"}),Me&&t.jsx(n.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"}})]}),I&&Ws.createPortal(t.jsxs(n.Box,{ref:re,sx:{position:"fixed",width:"320px",backgroundColor:h.palette.background.paper,border:`1px solid ${h.palette.divider}`,borderRadius:1,boxShadow:h.shadows[8],zIndex:50,maxHeight:"500px",overflowY:"auto",top:X.top,left:X.left},children:[te.length>0&&t.jsxs(n.Box,{sx:{py:.5},children:[t.jsx(n.Typography,{sx:{px:2,py:1,fontSize:L=>L.typography.caption.fontSize||"caption.fontSize",fontWeight:L=>L.typography.caption.fontWeight||600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Global Views"}),te.map(L=>ie(L,L.isDefault))]}),le.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(n.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(n.Box,{sx:{py:.5},children:[t.jsxs(n.Box,{sx:{px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:.5},children:[t.jsx(_.Star,{sx:{fontSize:12,color:"warning.light"}}),t.jsx(n.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:"Favorite Views"})]}),le.map(L=>ie(L))]})]}),ue.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(n.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(n.Box,{sx:{py:.5},children:[t.jsx(n.Typography,{sx:{px:2,py:1,fontSize:L=>L.typography.caption.fontSize||"caption.fontSize",fontWeight:L=>L.typography.caption.fontWeight||600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Personal Views"}),ue.map(L=>ie(L))]})]}),Z.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(n.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(n.Box,{sx:{py:.5},children:[t.jsxs(n.Button,{onClick:()=>Y(!$),sx:{width:"100%",px:2,py:1,fontSize:"caption.fontSize",fontWeight:600,color:h.palette.text.secondary,textTransform:"uppercase",letterSpacing:"0.05em",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},children:[t.jsxs(n.Typography,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit"},children:["Recently Deleted (",Z.length,")"]}),t.jsx(_.ChevronRight,{sx:{fontSize:16}})]}),$&&t.jsx(n.Box,{sx:{backgroundColor:h.palette.action.hover},children:Z.map(L=>he(L))})]})]}),t.jsx(n.Box,{sx:{borderTop:`1px solid ${h.palette.divider}`}}),t.jsxs(n.Button,{onClick:()=>{s(),A(!1)},sx:{width:"100%",display:"flex",alignItems:"center",gap:1,px:2,py:1,fontSize:"body2.fontSize",color:h.palette.text.primary,justifyContent:"flex-start",transition:"background-color 0.2s","&:hover":{backgroundColor:h.palette.action.hover}},children:[t.jsx(_.Add,{sx:{fontSize:16}}),t.jsx(n.Typography,{component:"span",sx:{fontSize:"inherit"},children:"Create New Report View"})]}),t.jsxs(n.Popover,{open:!!k,anchorEl:(k==null?void 0:k.el)||null,onClose:()=>q(null),disablePortal:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:[x&&t.jsxs(n.MenuItem,{onClick:()=>{k&&x(k.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Edit,{sx:{fontSize:18}}),"Edit"]}),y&&t.jsxs(n.MenuItem,{onClick:()=>{k&&y(k.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Link,{sx:{fontSize:18}}),"Copy Link"]}),g&&t.jsxs(n.MenuItem,{onClick:()=>{k&&g(k.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.ContentCopy,{sx:{fontSize:18}}),"Clone"]}),b&&f&&(k==null?void 0:k.view.scope)!=="global"&&t.jsxs(n.MenuItem,{onClick:()=>{k&&b(k.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Language,{sx:{fontSize:18}}),"Promote to Global"]}),T&&k&&!(B!=null&&B.includes("setDefaultForAllUsers"))?t.jsxs(n.MenuItem,{onClick:()=>{k&&T(k.view.id,!k.view.isDefaultForAllUsers),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[t.jsx(_.Star,{sx:{fontSize:18,color:k.view.isDefaultForAllUsers?"warning.main":"inherit"}}),k.view.isDefaultForAllUsers?"Remove from":"Set as"," Default for All Users"]}):null,j&&j.length>0&&k&&(()=>{const L=k.view,Se={allViews:e,activeView:e.find(Ae=>Ae.id===r),currentTableState:z??null,data:D??[],closeMenu:()=>q(null)},ke=j.filter(Ae=>{var at;return!((at=Ae.hidden)!=null&&at.call(Ae,L,Se))});return ke.length===0?null:[!!(x||y||g||b&&f&&L.scope!=="global"||T&&!(B!=null&&B.includes("setDefaultForAllUsers")))?t.jsx(n.Divider,{},"custom-view-actions-divider"):null,...ke.map(Ae=>{var at;return t.jsxs(n.MenuItem,{disabled:(at=Ae.disabled)==null?void 0:at.call(Ae,L,Se),onClick:()=>{Ae.onClick(L,Se),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize"},children:[Ae.icon,Ae.label]},Ae.key)})]})(),S&&[t.jsx(n.Divider,{},"delete-divider"),t.jsxs(n.MenuItem,{onClick:()=>{k&&S(k.view.id),q(null)},sx:{gap:1.5,fontSize:"body2.fontSize",color:"error.main"},children:[t.jsx(_.Delete,{sx:{fontSize:18}}),"Delete"]},"delete-item")]]})]}),document.body),t.jsxs(n.Dialog,{open:v!==null,onClose:F,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Po(h)}},children:[t.jsxs(n.DialogTitle,{sx:{display:"flex",alignItems:"center",gap:1,pb:1,fontSize:h.typography.h4.fontSize||"1.125rem",fontWeight:h.typography.h4.fontWeight||500},children:[t.jsx(_.Warning,{sx:{fontSize:20,color:"warning.main"}}),"Unsaved changes"]}),t.jsx(n.DialogContent,{children:t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"You have unsaved changes to the current view. Switching views will discard them."})}),t.jsxs(n.DialogActions,{sx:{px:3,pb:2,gap:1},children:[t.jsx(n.Button,{onClick:F,variant:"text",children:"Stay here"}),t.jsx(n.Button,{onClick:ae,variant:"contained",color:"warning",children:"Discard & switch"})]})]})]})}function $u({columnName:e,columnType:r="string",currentSort:o,hasFilters:i,isInSortStack:s,isReadOnly:a=!1,hasModifications:l=!1,position:c,onSortAscending:u,onSortDescending:x,onRemoveSort:g,onFilter:y,onClearFilter:S,onGroupByColumn:b,onHideColumn:T,onManageColumns:m,onResetLayout:f,onClose:B}){const j=vt(),D=j.palette,z=p.useRef(null);p.useEffect(()=>{if(!z.current)return;const X=z.current,R=X.getBoundingClientRect(),v=window.innerWidth,W=window.innerHeight;R.right>v-8&&(X.style.left=`${v-R.width-8}px`),R.bottom>W-8&&(X.style.top=`${W-R.height-8}px`)},[c]),p.useEffect(()=>{const X=v=>{z.current&&!z.current.contains(v.target)&&B()},R=v=>{v.key==="Escape"&&B()};return document.addEventListener("mousedown",X),document.addEventListener("keydown",R),()=>{document.removeEventListener("mousedown",X),document.removeEventListener("keydown",R)}},[B]);const h=p.useCallback(X=>()=>{X(),B()},[B]),I=(o==null?void 0:o.direction)==="asc",A=(o==null?void 0:o.direction)==="desc",$=r==="number"?"0→9":r==="boolean"?"F→T":"A→Z",Y=r==="number"?"9→0":r==="boolean"?"T→F":"Z→A";return Ws.createPortal(t.jsxs(n.Paper,{ref:z,elevation:0,sx:{position:"fixed",left:`${c.x}px`,top:`${c.y}px`,zIndex:j.zIndex.tooltip,minWidth:210,maxWidth:264,border:"1px solid",borderColor:"divider",borderRadius:Po(j),overflow:"hidden",boxShadow:`0 4px 20px ${M(D.common.black,.12)}, 0 1px 4px ${M(D.common.black,.06)}`},children:[!a&&t.jsxs(n.Box,{sx:{px:2,py:.75,display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid",borderColor:"divider"},children:[t.jsx(n.Typography,{sx:{fontSize:X=>X.typography.body2.fontSize||"0.8125rem",fontWeight:X=>X.typography.body2.fontWeight||500,color:"text.primary"},children:"Sorting"}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.25},children:[t.jsx(n.Tooltip,{title:`Sort Ascending (${$})`,placement:"top",arrow:!0,children:t.jsx(n.IconButton,{size:"small",onClick:h(()=>u(e)),sx:{p:.625,borderRadius:"6px",color:I?"primary.main":"text.secondary",bgcolor:I?M(D.primary.main,.1):"transparent","&:hover":{bgcolor:M(D.primary.main,.08),color:"primary.main"}},children:t.jsx(_.ArrowUpward,{sx:{fontSize:16}})})}),t.jsx(n.Tooltip,{title:`Sort Descending (${Y})`,placement:"top",arrow:!0,children:t.jsx(n.IconButton,{size:"small",onClick:h(()=>x(e)),sx:{p:.625,borderRadius:"6px",color:A?"primary.main":"text.secondary",bgcolor:A?M(D.primary.main,.1):"transparent","&:hover":{bgcolor:M(D.primary.main,.08),color:"primary.main"}},children:t.jsx(_.ArrowDownward,{sx:{fontSize:16}})})}),t.jsx(n.Tooltip,{title:"Clear Sort",placement:"top",arrow:!0,children:t.jsx("span",{children:t.jsx(n.IconButton,{size:"small",disabled:!s,onClick:h(()=>g(e)),sx:{p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:M(D.error.main,.08),color:"error.main"},"&.Mui-disabled":{opacity:.3}},children:t.jsx(_.Close,{sx:{fontSize:16}})})})})]})]}),t.jsxs(n.MenuList,{dense:!0,sx:{py:.5},children:[t.jsxs(n.MenuItem,{onClick:h(()=>y(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(_.FilterList,{sx:{fontSize:16,color:i?"primary.main":"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Filter by Column",primaryTypographyProps:{fontSize:"0.8125rem",fontWeight:i?600:400,color:i?"primary.main":"text.primary"}})]}),i&&!a&&t.jsxs(n.MenuItem,{onClick:h(()=>S(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:M(D.warning.main,.06),"& .MuiListItemText-primary":{color:"warning.main"},"& .MuiListItemIcon-root svg":{color:"warning.main"}}},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(_.FilterListOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Clear Filter",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]}),!a&&b&&t.jsxs(t.Fragment,{children:[t.jsx(n.Divider,{sx:{my:.25}}),t.jsx(n.MenuList,{dense:!0,sx:{py:.5},children:t.jsxs(n.MenuItem,{onClick:h(()=>b(e)),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(_.GroupWorkOutlined,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Group By Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]})})]}),t.jsx(n.Divider,{sx:{my:.25}}),t.jsxs(n.MenuList,{dense:!0,sx:{py:.5},children:[!a&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",mx:.5,borderRadius:"6px",overflow:"hidden","&:hover":{bgcolor:"action.hover"}},children:[t.jsxs(n.MenuItem,{onClick:h(()=>T(e)),sx:{flex:1,py:.75,px:1.5,minHeight:34,borderRadius:"6px 0 0 6px","&:hover":{bgcolor:"transparent"}},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(_.VisibilityOff,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Hide Column",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),t.jsx(n.Tooltip,{title:"Manage Columns",placement:"top",arrow:!0,children:t.jsx(n.IconButton,{size:"small",onClick:h(m),sx:{mr:.75,p:.625,borderRadius:"6px",color:"text.secondary","&:hover":{bgcolor:M(D.primary.main,.08),color:"primary.main"}},children:t.jsx(_.Settings,{sx:{fontSize:16}})})})]}),a&&t.jsxs(n.MenuItem,{onClick:h(m),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(_.Settings,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Manage Columns",primaryTypographyProps:{fontSize:"0.8125rem"}})]}),!a&&l&&f&&t.jsxs(n.MenuItem,{onClick:h(f),sx:{py:.75,px:1.5,borderRadius:"6px",mx:.5,minHeight:34,"&:hover":{bgcolor:M(D.error.main,.05),"& .MuiListItemText-primary":{color:"error.main"},"& .MuiListItemIcon-root svg":{color:"error.main"}}},children:[t.jsx(n.ListItemIcon,{sx:{minWidth:28},children:t.jsx(_.RestartAlt,{sx:{fontSize:16,color:"text.secondary"}})}),t.jsx(n.ListItemText,{primary:"Reset to Default Layout",primaryTypographyProps:{fontSize:"0.8125rem"}})]})]})]}),document.body)}const Iu=176,Bs="COLUMN_HEADER",Du=p.memo(function({column:r,index:o,sortRule:i,hasFilters:s,isInSortStack:a,isReadOnly:l=!1,hasModifications:c=!1,width:u,onColumnClick:x,onMoveColumn:g,onColumnDragEnd:y,onResizeStart:S,onSortAscending:b,onSortDescending:T,onRemoveSort:m,onOpenFilterForColumn:f,onClearFiltersForColumn:B,onGroupByColumn:j,onHideColumn:D,onManageColumns:z,onResetLayout:h}){const A=vt().urmTable,$=p.useRef(null),[Y,X]=p.useState(!1),[R,v]=p.useState({x:0,y:0}),[{handlerId:W,isOver:k},q]=ar.useDrop({accept:Bs,collect(Z){return{handlerId:Z.getHandlerId(),isOver:Z.isOver()}},hover(Z,de){var L;if(!$.current)return;const ae=Z.index,F=o;if(ae===F)return;const ie=(L=$.current)==null?void 0:L.getBoundingClientRect(),he=(ie.right-ie.left)/2,pe=de.getClientOffset(),Me=((pe==null?void 0:pe.x)??0)-ie.left;ae<F&&Me<he||ae>F&&Me>he||(g(ae,F),Z.index=F)}}),[{isDragging:re},d]=ar.useDrag({type:Bs,item:()=>({index:o,columnName:r.name}),collect:Z=>({isDragging:Z.isDragging()}),end:()=>{y==null||y()}});d(q($));const Q=p.useCallback(Z=>{Z.preventDefault(),Z.stopPropagation(),v({x:Z.clientX,y:Z.clientY}),X(!0)},[]),ee=p.useCallback(()=>X(!1),[]),H=p.useCallback(()=>{x(r.name)},[x,r.name]),te=p.useCallback(Z=>{Z.stopPropagation(),f(r.name)},[f,r.name]),ue=p.useCallback(()=>i?t.jsxs(n.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[i.direction==="asc"?t.jsx(_.ArrowUpward,{sx:{fontSize:15,color:"primary.main"}}):t.jsx(_.ArrowDownward,{sx:{fontSize:15,color:"primary.main"}}),t.jsx(n.Box,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,bgcolor:"primary.main",color:"primary.contrastText",fontSize:"0.6rem",fontWeight:700,borderRadius:"50%",lineHeight:1},children:i.priority})]}):null,[i]),le=p.useCallback(()=>s?t.jsx(_.FilterList,{onClick:te,titleAccess:"Active filter on this column — click to edit",sx:{ml:.5,fontSize:13,color:"primary.main",cursor:"pointer",flexShrink:0,"&:hover":{transform:"scale(1.15)"},transition:"transform 0.12s ease"}}):null,[s,te]);return t.jsxs(t.Fragment,{children:[t.jsxs(n.TableCell,{ref:$,"data-handler-id":W,"data-column-index":o,onClick:H,onContextMenu:Q,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.875rem",fontWeight:500,height:33,textTransform:"none",letterSpacing:0,whiteSpace:"nowrap",overflow:"visible",cursor:"pointer",userSelect:"none",color:(A==null?void 0:A.headerColor)??"text.secondary",opacity:re?.25:1,transition:"background-color 0.12s ease, opacity 0.15s ease",bgcolor:k?Z=>M(Z.palette.primary.main,.08):(A==null?void 0:A.headerBg)??"action.hover",boxShadow:Z=>`0 1px 0 ${M(Z.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:Z=>M(Z.palette.primary.main,.1),color:"text.primary"},width:u?`${u}px`:`${Iu}px`},children:[t.jsxs(n.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%",pr:"12px"},children:[pt(r.name),ue(),le()]}),t.jsx(n.Box,{draggable:!1,onDragStart:Z=>Z.preventDefault(),sx:{position:"absolute",right:0,top:0,height:"100%",width:8,cursor:"col-resize",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center","&:hover > div":{opacity:1}},onMouseDown:Z=>{Z.preventDefault(),Z.stopPropagation(),S(Z,r.name)},onClick:Z=>Z.stopPropagation(),children:t.jsx(n.Box,{draggable:!1,sx:{width:2,height:"50%",borderRadius:1,opacity:0,bgcolor:"primary.main",transition:"opacity 0.15s ease",pointerEvents:"none"}})}),k&&t.jsx(n.Box,{sx:{position:"absolute",left:0,top:0,bottom:0,width:4,bgcolor:"primary.main"}})]}),Y&&t.jsx($u,{columnName:r.name,columnType:r.type,currentSort:i,hasFilters:s,isInSortStack:a,isReadOnly:l,hasModifications:c,position:R,onSortAscending:b,onSortDescending:T,onRemoveSort:m,onFilter:f,onClearFilter:B,onGroupByColumn:j,onHideColumn:D,onManageColumns:z,onResetLayout:h,onClose:ee})]})}),Ou=["title","id","status","email","phone","handle","dept","region","role"],Mu={title:e=>/\b(name|title|label|subject|task_?name|taskname)\b/.test(e),id:e=>/(^id$|id$|_id$|taskid|code$|ref$)/.test(e.replace(/[\s_-]/g,"")),status:e=>/\b(status|state|stage)\b/.test(e),email:e=>/mail/.test(e),phone:e=>/phone|mobile|\btel\b/.test(e),handle:e=>/handle|username|slack/.test(e),dept:e=>/dept|department|team/.test(e),region:e=>/region|location|city|country/.test(e),role:e=>/role|designation|position/.test(e)};function Au(e,r){const o=r.toLowerCase();return e.find(i=>i.name.toLowerCase()===o)}function Ru(e,r,o,i){if(typeof i!="function")return typeof i=="string"?Au(r,i):r.find(s=>!o.has(s)&&Mu[e](s.name.toLowerCase().replace(/[_-]+/g," "),s))}function Wu(e,r){const o=new Set,i={};if(Ou.forEach(c=>{const u=Ru(c,e,o,r==null?void 0:r[c]);u&&(i[c]=u,o.add(u))}),!i.title&&(r==null?void 0:r.title)===void 0){const c=e.find(u=>!o.has(u));c&&(i.title=c,o.add(c))}const s=(c,u)=>{const x=r==null?void 0:r[c];if(typeof x=="function")return x(u);if(typeof x=="string")return u==null?void 0:u[x];const g=i[c];return g?u==null?void 0:u[g.name]:void 0},a=new Set(Object.values(i)),l=e.filter(c=>!a.has(c)).slice(0,4);return{slotColumns:i,getSlotValue:s,bodyColumns:l}}const Pu=["status","handle","email","phone","dept","region","role"];function Lu(e,r){const o={};return Pu.forEach(i=>{const s=e(i,r);s!=null&&s!==""&&(o[i]=String(s))}),o}function Mi({value:e,variant:r="plain"}){const o=e.toLowerCase().trim(),i=r==="pill";return t.jsxs(n.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:"7px",whiteSpace:"nowrap",...i&&{height:22,px:1.25,borderRadius:999,border:1,borderColor:s=>M(rn(s,o).color,.3),bgcolor:s=>rn(s,o).bg}},children:[t.jsx(n.Box,{component:"span",sx:{width:i?6:7,height:i?6:7,borderRadius:"50%",flexShrink:0,bgcolor:s=>rn(s,o).color}}),t.jsx(n.Box,{component:"span",sx:{fontSize:"0.75rem",fontWeight:s=>{var a;return(a=s.tokens)!=null&&a.statusBold?700:500},color:s=>rn(s,o).color,lineHeight:1.5,letterSpacing:"0.01em"},children:e})]})}const Es=["error","primary","warning","success","info"];function Fu(e){let r=0;for(let o=0;o<e.length;o+=1)r=r*31+e.charCodeAt(o)|0;return Es[Math.abs(r)%Es.length]}function Nu(e){const r=e.trim().split(/\s+/).filter(Boolean);return r.length===0?"?":(r.length===1?r[0].slice(0,2):r[0][0]+r[1][0]).toUpperCase()}function Vu(e,r){const o=e.palette.mode==="dark"?.38:.31;return`linear-gradient(to right, transparent, ${M(e.palette[r].main,o)}, transparent)`}function Hu({label:e,tone:r}){return t.jsx(n.Box,{"aria-hidden":!0,sx:{width:38,height:38,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"11px",color:"common.white",fontSize:"0.8125rem",fontWeight:700,userSelect:"none",background:o=>`linear-gradient(135deg, ${o.palette[r].main}, ${o.palette[r].light})`,filter:o=>`drop-shadow(0 3.8px 5.7px ${M(o.palette[r].main,.25)})`},children:Nu(e)})}function Gu({title:e,idValue:r,tone:o,hideCheckbox:i,showActions:s,isSelected:a,onToggleSelection:l,onOpenMenu:c}){return t.jsxs(n.Box,{sx:u=>{var b,T,m,f;const x=((m=(T=(b=u.components)==null?void 0:b.MuiCardHeader)==null?void 0:T.styleOverrides)==null?void 0:m.root)||{},g=(x.backgroundColor&&x.backgroundColor!=="transparent"?x.backgroundColor:void 0)??((f=u.tokens)==null?void 0:f.cardHdrHex)??"transparent",y=x.borderBottom&&x.borderBottom!=="none"?x.borderBottom:void 0,S=x.boxShadow&&x.boxShadow!=="none"?x.boxShadow:void 0;return{px:2,pt:1.75,pb:1.5,bgcolor:g,borderBottom:y,boxShadow:S,display:"flex",alignItems:"center",gap:1.25}},children:[e&&t.jsx(Hu,{label:e,tone:o}),t.jsxs(n.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:u=>u.typography.body2.fontWeight||600,fontSize:u=>u.typography.body1.fontSize||"0.9375rem",color:"text.primary",lineHeight:1.35,wordBreak:"break-word",letterSpacing:"-0.01em"},children:e||t.jsx(n.Box,{component:"span",sx:{color:"text.disabled",fontStyle:"italic",fontWeight:400},children:"Untitled"})}),r&&t.jsx(n.Typography,{sx:{color:"primary.main",fontFamily:'"Roboto Mono", "Courier New", monospace',fontSize:"0.6875rem",letterSpacing:"0.04em",opacity:.85,userSelect:"none",wordBreak:"break-all"},children:r})]}),!i&&t.jsx(n.Box,{sx:{width:24,flexShrink:0},children:s&&t.jsx(n.Checkbox,{size:"small",checked:a,onClick:u=>u.stopPropagation(),onChange:l,sx:{p:.25}})}),t.jsx(n.Box,{sx:{width:28,flexShrink:0},onClick:u=>u.stopPropagation(),children:s&&t.jsx(n.Tooltip,{title:"More actions",placement:"top",children:t.jsx(n.IconButton,{size:"small",onClick:u=>{u.stopPropagation(),c(u.currentTarget)},sx:{width:28,height:28,color:"action.active","&:hover":{bgcolor:u=>M(u.palette.text.primary,.08)}},children:t.jsx(_.MoreVert,{sx:{fontSize:17}})})})})]})}const Uu='"Roboto Mono", "Courier New", monospace';function di({icon:e,text:r,mono:o}){return t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,minWidth:0},children:[t.jsx(e,{sx:{fontSize:13,color:"text.disabled",flexShrink:0}}),t.jsx(n.Typography,{title:r,noWrap:!0,sx:{color:"text.secondary",fontSize:i=>i.typography.body2.fontSize||"0.8125rem",fontFamily:o?Uu:void 0,lineHeight:1.4},children:r})]})}function Yu({dept:e,region:r,role:o}){return!e&&!r&&!o?null:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:.75,pt:1,borderTop:"1px solid",borderColor:"divider"},children:[e&&t.jsx(n.Box,{component:"span",sx:i=>{const s=yu(i);return{px:1,py:.25,borderRadius:"6px",border:`1px solid ${s.border}`,bgcolor:s.bg,color:s.color,fontSize:i.typography.caption.fontSize||"0.6875rem",fontWeight:500,lineHeight:1.4}},children:e}),[r,o].filter(Boolean).map(i=>t.jsx(n.Typography,{variant:"caption",color:"text.disabled",children:i},i))]})}function qu({texts:e}){const{status:r,handle:o,email:i,phone:s,dept:a,region:l,role:c}=e;return t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:.75,minWidth:0},children:[r&&t.jsx(n.Box,{sx:{mb:.25},children:t.jsx(Mi,{value:r,variant:"pill"})}),o&&t.jsx(di,{icon:_.AlternateEmail,text:o,mono:!0}),i&&t.jsx(di,{icon:_.MailOutline,text:i}),s&&t.jsx(di,{icon:_.PhoneOutlined,text:s,mono:!0}),t.jsx(Yu,{dept:a,region:l,role:c})]})}function Ju(e){return t.jsx(Mi,{value:e})}function Ku(e,r){if(r==null||r==="")return t.jsx(n.Box,{component:"span",sx:{color:"text.disabled",fontSize:"0.875rem"},children:"—"});const o=String(r),i=e.name.toLowerCase();if(/\b(status|state|stage)\b/.test(i))return Ju(o);if(/\b(priority|severity|urgency)\b/.test(i)){const s=o.toLowerCase().trim();return t.jsx(n.Box,{component:"span",sx:a=>{const l=Bu(a,s);return l?{color:l,fontWeight:600,fontSize:"0.875rem"}:{fontSize:"0.875rem"}},children:o})}return typeof r=="boolean"?t.jsx(n.Box,{component:"span",sx:{fontSize:"0.875rem"},children:r?"Yes":"No"}):typeof r=="object"?t.jsx(n.Box,{component:"span",sx:{fontSize:"0.875rem"},children:JSON.stringify(r)}):t.jsx(n.Box,{component:"span",sx:{fontSize:"0.875rem"},children:o})}function Xu({row:e,rowIndex:r,visibleColumns:o,cardSlots:i,isSelected:s,onCardClick:a,onCardDoubleClick:l,onCardContextMenu:c,onOpenRowMenu:u,onToggleSelection:x,hideCheckbox:g}){const[y,S]=p.useState(!1),{getSlotValue:b,bodyColumns:T}=p.useMemo(()=>Wu(o,i),[o,i]),m=b("title",e),f=m!=null&&m!==""?String(m):null,B=b("id",e)??null,j=Fu(f??""),D=p.useMemo(()=>Lu(b,e),[b,e]),z=Object.keys(D).length>0,h=y||s;return t.jsxs(n.Box,{onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1),onClick:I=>a(r,I),onDoubleClick:I=>l(e,r,I),onContextMenu:I=>{I.preventDefault(),I.stopPropagation(),c(e,r,I)},sx:{position:"relative",display:"flex",flexDirection:"column",bgcolor:"background.paper",border:I=>{var $,Y,X,R;const A=(R=(X=(Y=($=I.components)==null?void 0:$.MuiCard)==null?void 0:Y.styleOverrides)==null?void 0:X.root)==null?void 0:R.border;return s?"2px solid":A&&A!=="none"?A:"1px solid"},borderColor:s?I=>it(I).main:I=>{var $,Y,X,R;const A=(R=(X=(Y=($=I.components)==null?void 0:$.MuiCard)==null?void 0:Y.styleOverrides)==null?void 0:X.root)==null?void 0:R.border;return A&&A!=="none"?"inherit":M(I.palette.divider,.8)},borderWidth:s?2:void 0,borderRadius:I=>{var $,Y,X,R;const A=(R=(X=(Y=($=I.components)==null?void 0:$.MuiCard)==null?void 0:Y.styleOverrides)==null?void 0:X.root)==null?void 0:R.borderRadius;return A!==void 0?typeof A=="number"?`${A}px`:A:`${I.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:s?I=>`0 0 0 3px ${M(it(I).main,.15)}, 0 2px 8px ${M(I.palette.common.black,.08)}`:y?I=>{var $,Y,X,R;const A=(R=(X=(Y=($=I.components)==null?void 0:$.MuiCard)==null?void 0:Y.styleOverrides)==null?void 0:X.root)==null?void 0:R.boxShadow;return A&&A!=="none"?A:ye(I,"cardHover")}:I=>{var $,Y,X,R;const A=(R=(X=(Y=($=I.components)==null?void 0:$.MuiCard)==null?void 0:Y.styleOverrides)==null?void 0:X.root)==null?void 0:R.boxShadow;return A&&A!=="none"?A:ye(I,"cardRest")},transform:y&&!s?"translateY(-2px)":"none","&:active":{transform:"translateY(0)"},...s&&{bgcolor:I=>M(it(I).main,.03)}},children:[f&&t.jsx(n.Box,{"aria-hidden":!0,sx:{position:"absolute",top:0,left:0,right:0,height:1.5,pointerEvents:"none",background:I=>Vu(I,j)}}),t.jsx(Gu,{title:f,idValue:B!==null&&B!==""?String(B):null,tone:j,hideCheckbox:g,showActions:h,isSelected:s,onToggleSelection:()=>x(e),onOpenMenu:I=>u(e,r,I)}),t.jsx(n.Box,{sx:I=>{var Y,X,R;const A=((R=(X=(Y=I.components)==null?void 0:Y.MuiCardHeader)==null?void 0:X.styleOverrides)==null?void 0:R.root)||{};return A.borderBottom&&A.borderBottom!=="none"?{display:"none"}:{mx:2,height:"1px",bgcolor:"divider",flexShrink:0}}}),t.jsxs(n.Box,{sx:{flex:1,display:"flex",flexDirection:"column"},children:[z&&t.jsx(n.Box,{sx:{px:2,pt:1.5,pb:T.length>0?0:1.5},children:t.jsx(qu,{texts:D})}),(T.length>0||!z)&&t.jsxs(n.Box,{sx:{px:2,py:1.5,flex:1,display:"grid",gridTemplateColumns:"repeat(2, 1fr)",columnGap:1.5,rowGap:1,alignContent:"start"},children:[T.map(I=>t.jsxs(n.Box,{sx:{minWidth:0},children:[t.jsx(n.Typography,{sx:{color:"text.secondary",fontWeight:A=>A.typography.body2.fontWeight||500,fontSize:A=>A.typography.caption.fontSize||"0.6875rem",textTransform:"uppercase",letterSpacing:"0.06em",lineHeight:1.2,mb:.25},children:pt(I.name)}),t.jsx(n.Box,{sx:{lineHeight:1.3,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},title:String(e[I.name]??""),children:Ku(I,e[I.name])})]},I.name)),T.length===0&&t.jsx(n.Typography,{variant:"caption",color:"text.disabled",sx:{fontStyle:"italic",gridColumn:"1 / -1"},children:"No additional fields visible"})]})]})]})}function Qu({row:e,grouping:r,onToggleCollapse:o}){var i;return t.jsxs(n.Box,{onClick:()=>o(e.groupKey),sx:{gridColumn:"1 / -1",display:"flex",alignItems:"center",gap:1,px:2,py:1,mt:1,mb:.5,bgcolor:"background.paper",border:"1px solid",borderColor:"divider",borderRadius:"8px",cursor:"pointer",boxShadow:s=>ye(s,"flatHover"),"&:hover":{bgcolor:s=>M(s.palette.primary.main,.04),borderColor:"primary.light"},transition:"all 0.15s ease"},children:[e.isCollapsed?t.jsx(_.ChevronRight,{sx:{fontSize:16,color:"text.secondary"}}):t.jsx(_.KeyboardArrowDown,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"h5",sx:{fontWeight:s=>s.typography.h5.fontWeight||600,color:s=>s.typography.h5.color||"text.primary"},children:al(e.groupLevel,((i=r==null?void 0:r.levels[e.groupLevel])==null?void 0:i.column)||"",e.groupValue)}),t.jsxs(n.Box,{sx:{px:1,py:.125,fontSize:"0.6875rem",fontWeight:600,bgcolor:s=>M(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(n.Typography,{variant:"caption",sx:{ml:.5,color:"text.secondary"},children:Object.entries(e.aggregates).map(([s,a])=>Vs(a)).filter(Boolean).join(" • ")})]})}function Zu({data:e,visibleColumns:r,cardSlots:o,grouping:i,selectedRowIds:s,isGrouped:a,onToggleGroupCollapse:l,onCardClick:c,onCardDoubleClick:u,onCardContextMenu:x,onOpenRowMenu:g,onToggleSelection:y,hideSelectionCheckboxes:S}){const b=p.useMemo(()=>{const T=new Set;return s.forEach(m=>{const f=m==null?void 0:m.__urm_row_id__;f!==void 0&&T.add(f)}),T},[s]);return e.length===0?t.jsx(n.Box,{sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",py:10},children:t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})}):t.jsx(n.Box,{sx:{fontFamily:T=>T.typography.fontFamily},children:t.jsx(n.Box,{sx:{p:T=>Cs(T).containerPad,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:T=>Cs(T).cardGap,alignContent:"start"},children:e.map((T,m)=>a&&T.isGroupHeader?t.jsx(Qu,{row:T,grouping:i,onToggleCollapse:l||(()=>{})},`group-${T.groupKey}`):t.jsx(Xu,{row:T,rowIndex:m,visibleColumns:r,cardSlots:o,isSelected:b.has(T==null?void 0:T.__urm_row_id__),onCardClick:c,onCardDoubleClick:u,onCardContextMenu:x,onOpenRowMenu:g,onToggleSelection:y,hideCheckbox:S},`card-${m}`))})})}const _s=[10,15,25,50,100];function ep(e,r){const o=e.trim();if(o==="")return"Page number is required";if(!/^-?\d+$/.test(o))return"Must be a number";const i=parseInt(o,10);return i<1?"Page number must be at least 1":i>r?"Entered page number is out of range":null}function tp({currentPage:e,pageSize:r,totalRows:o,totalPages:i,selectedCount:s,onClearSelection:a,onPageChange:l,onPageSizeChange:c}){const x=vt().palette,g=i??Math.max(1,Math.ceil(o/r)),[y,S]=p.useState(String(e)),[b,T]=p.useState(null),[m,f]=p.useState(!1),B=p.useRef(null);p.useEffect(()=>{m||(S(String(e)),T(null))},[e,m]);const j=p.useCallback(()=>{const d=ep(y,g);if(d){T(d);return}const Q=parseInt(y.trim(),10);T(null),f(!1),Q!==e&&l(Q)},[y,g,e,l]),D=p.useCallback(d=>{var Q;d.key==="Enter"?(d.preventDefault(),j()):d.key==="Escape"&&(S(String(e)),T(null),f(!1),(Q=B.current)==null||Q.blur())},[j,e]),z=p.useCallback(()=>{S(String(e)),T(null),f(!1)},[e]),h=p.useCallback(()=>{f(!0),T(null),setTimeout(()=>{var d;return(d=B.current)==null?void 0:d.select()},0)},[]);if(o<=Math.min(..._s))return null;const I=()=>{S(String(e)),T(null),f(!1)},A=()=>{I(),l(1)},$=()=>{I(),e>1&&l(e-1)},Y=()=>{I(),e<g&&l(e+1)},X=()=>{I(),l(g)},R=(e-1)*r+1,v=Math.min(e*r,o),W=`${Math.max(2,String(g).length+.5)}ch`,k={width:24,height:24,color:"text.secondary",border:"1px solid",borderColor:"divider",borderRadius:"6px","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"text.disabled",opacity:.4}},q={width:36,height:36,color:"primary.main",border:"1.5px solid",borderColor:"primary.main",borderRadius:"9px","&:hover":{bgcolor:d=>M(d.palette.primary.main,.08)},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},re={fontSize:d=>d.typography.body2.fontSize||"0.8125rem",color:"text.secondary",fontWeight:400};return t.jsxs(n.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(n.Box,{sx:{display:"flex",alignItems:"center",gap:2},children:[!!s&&s>0&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsxs(n.Typography,{variant:"caption",sx:{fontSize:re.fontSize,color:"primary.main",fontWeight:600},children:[s," selected"]}),a&&t.jsx(n.Button,{size:"small",onClick:a,sx:{fontSize:"0.75rem",p:0,minWidth:"auto",color:"text.secondary"},children:"Clear"})]}),t.jsxs(n.Typography,{variant:"caption",sx:{...re,userSelect:"none"},children:[R,"–",v," of ",o]})]}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(n.IconButton,{onClick:A,disabled:e===1,size:"small",title:"First page",sx:k,children:t.jsx(_.FirstPage,{sx:{fontSize:15}})}),t.jsx(n.IconButton,{onClick:$,disabled:e===1,size:"small",title:"Previous page",sx:q,children:t.jsx(_.ChevronLeft,{sx:{fontSize:18}})}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"baseline",gap:.5,position:"relative"},children:[t.jsx(n.Typography,{variant:"caption",sx:{...re,userSelect:"none"},children:"Page"}),t.jsxs(n.Box,{sx:{position:"relative"},children:[b&&t.jsx(n.Box,{sx:{position:"absolute",bottom:"calc(100% + 6px)",left:"50%",transform:"translateX(-50%)",bgcolor:"background.paper",border:"1px solid",borderColor:M(x.error.main,.4),borderRadius:"6px",px:1,py:.5,boxShadow:`0 2px 8px ${M(x.common.black,.12)}`,zIndex:20,whiteSpace:"nowrap","&::after":{content:'""',position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)",border:"5px solid transparent",borderTopColor:M(x.error.main,.4)}},children:t.jsx(n.Typography,{sx:{fontSize:d=>d.typography.caption.fontSize||"0.6875rem",fontWeight:d=>d.typography.caption.fontWeight||500,color:"error.main",lineHeight:1.3},children:b})}),t.jsx(n.InputBase,{inputRef:B,value:y,onChange:d=>{S(d.target.value),b&&T(null)},onKeyDown:D,onFocus:h,onBlur:z,inputProps:{"aria-label":`Page number, 1 to ${g}`,style:{textAlign:"center",padding:"2px 0",width:W,fontSize:"1rem",fontWeight:700}},sx:{fontSize:"1rem",fontWeight:700,color:b?"error.main":"primary.main",border:"1px solid",borderColor:b?"error.main":m?"primary.main":"transparent",borderRadius:"4px",bgcolor:b?M(x.error.main,.04):"transparent",px:.5,transition:"border-color 0.15s ease, background-color 0.15s ease","&:hover":{borderColor:b?"error.main":M(x.primary.main,.4)},"&:focus-within":{boxShadow:b?`0 0 0 2px ${M(x.error.main,.2)}`:`0 0 0 2px ${M(x.primary.main,.2)}`}}})]}),t.jsxs(n.Typography,{variant:"caption",sx:{...re,userSelect:"none"},children:["of ",g]})]}),t.jsx(n.IconButton,{onClick:Y,disabled:e===g,size:"small",title:"Next page",sx:q,children:t.jsx(_.ChevronRight,{sx:{fontSize:18}})}),t.jsx(n.IconButton,{onClick:X,disabled:e===g,size:"small",title:"Last page",sx:k,children:t.jsx(_.LastPage,{sx:{fontSize:15}})})]}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(n.Typography,{variant:"caption",sx:re,children:"Rows per page:"}),t.jsx(n.Select,{value:r,onChange:d=>c(Number(d.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:_s.map(d=>t.jsx(n.MenuItem,{value:d,sx:{fontSize:"0.8125rem"},children:d},d))})]})]})}function rp(){return t.jsx(n.Chip,{icon:t.jsx(_.Visibility,{sx:{fontSize:14}}),label:"View Only",size:"small",variant:"outlined",sx:{bgcolor:"action.hover",borderColor:"divider",fontSize:e=>e.typography.caption.fontSize||"caption.fontSize",fontWeight:e=>e.typography.caption.fontWeight||500}})}const xa="urm_hint_seen_";function op(e){try{return localStorage.getItem(xa+e)==="true"}catch{return!1}}function np(e){try{localStorage.setItem(xa+e,"true")}catch{}}const ga={"& .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 yi(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 ya({row:e,schema:r}){const i=vt().palette,s=r.filter(c=>c.name in e),a=s.filter(c=>c.type!=="object"&&c.type!=="array"),l=s.filter(c=>c.type==="object"||c.type==="array");return t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[a.map(c=>t.jsx(n.TextField,{label:pt(c.name),value:yi(e[c.name],c.type)||"No value",size:"small",fullWidth:!0,InputProps:{readOnly:!0},sx:ga},c.name)),l.map(c=>{const u=yi(e[c.name],c.type);return t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontWeight:x=>x.typography.caption.fontWeight||500,fontSize:x=>x.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:pt(c.name)}),t.jsx(n.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:M(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(n.Typography,{variant:"body2",sx:{color:"text.disabled",textAlign:"center",py:3,fontSize:c=>c.typography.body2.fontSize||"0.875rem"},children:"No fields to display"})]})}function ip({open:e,onClose:r,row:o,schema:i,reportName:s}){if(!o)return null;const a=i.filter(l=>l.name in o).length;return t.jsx(st,{open:e,onClose:r,icon:t.jsx(_.VisibilityOutlined,{sx:{fontSize:20}}),title:"View Record",subtitle:s?`· ${s} · ${a} ${a===1?"field":"fields"}`:void 0,width:600,maxHeight:"min(720px, calc(100vh - 80px))",footer:t.jsx(n.Button,{onClick:r,variant:"contained",sx:{fontSize:"0.8125rem",px:3,py:.75,borderRadius:l=>`${l.shape.borderRadius}px`,minWidth:80},children:"Close"}),children:t.jsx(ya,{row:o,schema:i})})}function sp({open:e,onClose:r,onConfirm:o,row:i,schema:s}){return t.jsx(st,{open:e,onClose:r,icon:t.jsx(_.WarningAmberRounded,{sx:{fontSize:20}}),iconColor:"error",title:"Delete record?",subtitle:"· This record will be permanently removed.",width:600,maxHeight:"min(720px, calc(100vh - 80px))",footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:a=>`${a.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:()=>{o(),r()},variant:"contained",startIcon:t.jsx(_.DeleteForever,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"error.contrastText",px:3,py:.875,minHeight:36,borderRadius:a=>`${a.shape.borderRadius}px`,boxShadow:a=>ye(a,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"error.dark",boxShadow:a=>ye(a,"hoverButton")},"&:active":{boxShadow:a=>ye(a,"pressedButton"),transform:"translateY(1px)"}},children:"Delete record"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[i&&s&&t.jsx(ya,{row:i,schema:s}),t.jsx(n.Box,{sx:{p:2,borderRadius:"8px",bgcolor:a=>M(a.palette.error.main,.1),border:a=>`1px solid ${M(a.palette.error.main,.5)}`},children:t.jsx(n.Typography,{variant:"body2",sx:{fontSize:a=>a.typography.body2.fontSize||"0.8125rem",color:"error.main",fontWeight:a=>a.typography.body2.fontWeight||500},children:"This action cannot be undone. The record will be deleted from this report immediately."})})]})})}function ap({open:e,onClose:r,onSave:o,row:i,schema:s,reportName:a}){const c=vt().palette,[u,x]=p.useState({});if(p.useEffect(()=>{e&&i&&x({...i})},[e,i]),!i)return null;const g=s.filter(f=>f.name in i),y=g.filter(f=>f.type!=="object"&&f.type!=="array"),S=g.filter(f=>f.type==="object"||f.type==="array"),b=(f,B)=>{x(j=>({...j,[f]:B}))},T=()=>{const f={...u};g.forEach(B=>{const j=u[B.name];if(B.type==="number"){const D=Number(j);f[B.name]=isNaN(D)?i[B.name]:D}else B.type==="boolean"&&(f[B.name]=!!j)}),o(f),r()},m=g.length;return t.jsx(st,{open:e,onClose:r,icon:t.jsx(_.EditOutlined,{sx:{fontSize:20}}),title:"Edit Record",subtitle:a?`· ${a} · ${m} ${m===1?"field":"fields"}`:void 0,width:600,maxHeight:"min(760px, calc(100vh - 80px))",footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:r,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",px:2,borderRadius:f=>`${f.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:T,variant:"contained",startIcon:t.jsx(_.SaveOutlined,{sx:{fontSize:15}}),sx:{fontSize:"0.8125rem",px:2.5,borderRadius:f=>`${f.shape.borderRadius}px`,minWidth:90},children:"Save"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[y.map(f=>{const B=u[f.name];return f.type==="boolean"?t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontWeight:j=>j.typography.caption.fontWeight||500,fontSize:j=>j.typography.caption.fontSize||"0.75rem",color:"text.secondary",display:"block",mb:.75},children:pt(f.name)}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(n.Switch,{checked:!!B,onChange:j=>b(f.name,j.target.checked),size:"small"}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:j=>j.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:B?"Enabled":"Disabled"})]})]},f.name):t.jsx(n.TextField,{label:pt(f.name),value:B??"",onChange:j=>b(f.name,j.target.value),type:f.type==="number"?"number":"text",size:"small",fullWidth:!0,sx:ga},f.name)}),S.length>0&&t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:S.map(f=>{const B=yi(i[f.name],f.type);return t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75},children:[t.jsx(n.Typography,{variant:"caption",sx:{fontSize:j=>j.typography.caption.fontSize||"0.75rem",fontWeight:j=>j.typography.caption.fontWeight||500,color:"text.secondary"},children:pt(f.name)}),t.jsx(n.Chip,{label:"read only",size:"small",sx:{height:16,fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.04em",bgcolor:M(c.text.secondary,.07),color:"text.secondary",border:"none"}}),t.jsx(n.Tooltip,{title:"Object and array fields cannot be edited directly",arrow:!0,children:t.jsx(_.InfoOutlined,{sx:{fontSize:13,color:"text.disabled",cursor:"help"}})})]}),t.jsx(n.Box,{component:"pre",sx:{m:0,px:1.5,py:1.25,borderRadius:"8px",border:"1px solid",borderColor:"divider",bgcolor:M(c.text.primary,.02),fontSize:"0.75rem",fontFamily:'"Roboto Mono", "Fira Code", monospace',color:B?"text.primary":"text.disabled",fontStyle:B?"normal":"italic",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.6,maxHeight:160,overflowY:"auto"},children:B||"No value"})]},f.name)})}),g.length===0&&t.jsxs(n.Box,{sx:{py:6,display:"flex",flexDirection:"column",alignItems:"center",gap:1,color:"text.disabled"},children:[t.jsx(_.EditOutlined,{sx:{fontSize:40,opacity:.4}}),t.jsx(n.Typography,{variant:"body2",children:"No editable fields"})]})]})})}const lp=176,cp=170,dp=40;function ba(e){return e.type==="date"?180:lp}function up(e,r){return r!=null&&r!==cp&&r!==ba(e)}function pp(e,r,o){return p.useMemo(()=>{const i=e.map(y=>({name:y.name,width:r[y.name]??ba(y),explicit:up(y,r[y.name])})),s={};i.forEach(y=>{s[y.name]=y.width});const a=i.reduce((y,S)=>y+S.width,0),c=Math.max(0,o-dp)-a;if(c<=0)return{widths:s,fillerWidth:0};const u=i.filter(y=>!y.explicit);if(u.length===0)return{widths:s,fillerWidth:c};const x=u.reduce((y,S)=>y+S.width,0)||1;let g=0;return u.forEach((y,S)=>{const T=S===u.length-1?y.width+c-g:Math.round(y.width+c*y.width/x);s[y.name]=T,g+=T-y.width}),{widths:s,fillerWidth:0}},[e,r,o])}const $s=176,fp=At(),hp={low:"text.secondary",medium:"warning.dark",high:"warning.main",critical:"error.main",urgent:"error.main"};function mp(e){return t.jsx(Mi,{value:e})}function xp(e){const r=e.toLowerCase().trim(),o=hp[r];return o?t.jsx(n.Box,{component:"span",sx:{color:o,fontWeight:500,fontSize:"inherit"},children:e}):e}function gp(e,r){const o=r.trim();if(!o)return e;const i=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=e.split(new RegExp(`(${i})`,"gi"));return s.length===1?e:s.map((a,l)=>a.toLowerCase()===o.toLowerCase()?t.jsx(n.Box,{component:"mark",sx:{bgcolor:"warning.light",color:"inherit",px:"1px",borderRadius:"2px"},children:a},l):a)}function yp(e,r,o,i=""){if(r==null||r==="")return t.jsx(n.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 mp(s);if(/\b(priority|severity|urgency|importance|criticality)\b/.test(e.name.toLowerCase()))return xp(s);if(e.type==="date"){const c=e.dateFormat??"iso",u=Xa(r,c,o??null);return t.jsx(n.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(n.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(n.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(n.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 gp(s,i)}function bp({schema:e,data:r,sortStack:o=[],filters:i=fp,views:s=[],activeViewId:a="",isDirty:l=!1,isExporting:c=!1,columnVisibility:u={},columnOrder:x=[],columnWidths:g={},grouping:y=null,classTokens:S={},onSort:b,onSortAscending:T,onSortDescending:m,onOpenFilters:f,onOpenSort:B,onOpenFilterForColumn:j,onSelectView:D,onCreateView:z,onUpdateCurrentView:h,onSaveAsNewView:I,onDiscardChanges:A,onToggleDefault:$,onToggleFavorite:Y,onRestoreView:X,onPermanentDelete:R,onEditView:v,onCloneView:W,onCopyLink:k,onDeleteView:q,onPromoteToGlobal:re,onSetDefaultForAllUsers:d,isAdmin:Q=!1,hideViewMenuActions:ee,customViewMenuActions:H,viewMenuActionData:te,viewMenuActionTableState:ue,onExport:le,onOpenColumns:Z,onUpdateColumnWidth:de,onUpdateColumnOrder:ae,onUpdateColumnVisibility:F,onClearFiltersForColumn:ie,onResetLayout:he,onOpenGroup:pe,onGroupByColumn:Me,onToggleGroupCollapse:L,onExpandAllGroups:Se,onCollapseAllGroups:ke,onOpenAuditHistory:We,onOpenScheduledReports:Ae,searchQuery:at,highlightQuery:tt="",searchHistory:Wt=[],onAddToSearchHistory:Bt,onToggleSearchFavourite:Jt,onDeleteSearchHistory:Pr,selectedRowIds:Kt=new Set,onSearchChange:Lr,onToggleRowSelection:Ke,onToggleAllRows:Et,onRangeSelection:Fr,onClearSelection:ct,onExportSelected:cr,currentPage:Pt=1,pageSize:Nr=15,totalRowsBeforePagination:Lt=r.length,totalPagesOverride:_t,onPageChange:Ft,onPageSizeChange:dt,isReadOnly:Pe=!1,userRole:Vr,reportName:Hr,onEditRow:dr,onDuplicateRow:ur,onDeleteRow:Xt,showDevPanel:fo=!1,onOpenDevConfig:vr,rowActions:$t,hideDefaultRowActions:He,hideToolbarActions:Ce,customSettingsActions:Nt,jsonGuideContent:ho,jsonGuideTitle:mo,jsonGuideTooltip:xo,viewOptions:Sr,cardSlots:wr,defaultViewMode:je,bulkActions:Cr,hideSelectionCheckboxes:Gr,rowClickBehavior:mt="select",openModalOn:N,onRowClick:ut,onRowRightClick:se}){var Jo;const fe=vt().urmTable,[Vt,Ur]=p.useState(null),[pr,jr]=p.useState(0),[Qt,fr]=p.useState(0),[Ht,we]=p.useState(null),It=Rr(),Yr=((Jo=It.dates)==null?void 0:Jo.displayFormat)??null,[V,rt]=p.useState(null),[Oe,kr]=p.useState(null),[Zt,gt]=p.useState(null),[Tr,nt]=p.useState(!1),[go,qr]=p.useState(!1),[St,zr]=p.useState(null),[Jr,Br]=p.useState(!1),[Kr,Er]=p.useState(null),[_r,me]=p.useState(null),[oe,be]=p.useState(null),[Ge,Le]=p.useState(null),lt=p.useRef(null),Qe=p.useCallback(()=>{lt.current&&(clearTimeout(lt.current),lt.current=null)},[]),$r=p.useCallback(()=>{Qe(),lt.current=setTimeout(()=>Le(null),200)},[Qe]);p.useEffect(()=>Qe,[Qe]);const[er,wt]=p.useState(null),tr=p.useMemo(()=>Sr??["list","grid"],[Sr]),[Ir,On]=p.useState(()=>je??tr[0]??"list"),[Mn,Lo]=p.useState(!1),[Xr,An]=p.useState(()=>!op("toolbar_search")),Qr=p.useRef(null),yo=p.useRef(null),[Rn,Fo]=p.useState(0);p.useLayoutEffect(()=>{const C=Qr.current;if(!C)return;Fo(C.clientWidth);const U=new ResizeObserver(ne=>{Fo(ne[0].contentRect.width)});return U.observe(C),()=>U.disconnect()},[]);const Zr=p.useCallback(()=>{np("toolbar_search"),An(!1)},[]);p.useEffect(()=>{if(!Xr)return;const C=setTimeout(Zr,2e3);return()=>clearTimeout(C)},[Xr,Zr]);const No=p.useMemo(()=>{const C=Ht??x;return C.length>0?C.map(U=>e.find(ne=>ne.name===U)).filter(U=>U!==void 0):e},[Ht,x,e]),Dr=p.useMemo(()=>No.filter(C=>u[C.name]!==!1),[No,u]),bo=p.useMemo(()=>new Set(((y==null?void 0:y.levels)??[]).map(C=>C.column)),[y]),Vo=!!(y!=null&&y.enabled&&(y!=null&&y.levels)&&y.levels.length>0),eo=p.useMemo(()=>{if(!Vo)return Dr;const C=((y==null?void 0:y.levels)??[]).map(ne=>e.find(Be=>Be.name===ne.column)).filter(ne=>ne!==void 0),U=Dr.filter(ne=>!bo.has(ne.name));return[...C,...U]},[Dr,Vo,bo,y,e]),{widths:to}=pp(eo,g,Rn),Ho=p.useMemo(()=>e.filter(C=>u[C.name]===!1).length,[e,u]),Go=p.useMemo(()=>e.map(C=>C.name),[e]),Wn=p.useMemo(()=>x.length===0?!1:JSON.stringify(x)!==JSON.stringify(Go),[x,Go]),Pn=p.useCallback((C,U)=>{C.preventDefault(),C.stopPropagation(),Ur(U),jr(C.clientX),fr(g[U]||150)},[g]);p.useEffect(()=>{if(!Vt)return;const C=ne=>{const Be=ne.clientX-pr,ot=Math.max(100,Math.min(600,Qt+Be));de==null||de(Vt,ot)},U=()=>{Ur(null)};return document.addEventListener("mousemove",C),document.addEventListener("mouseup",U),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",U)}},[Vt,pr,Qt,de]);const Ln=p.useCallback(C=>C==null?"-":typeof C=="object"?JSON.stringify(C):typeof C=="boolean"?C?"true":"false":String(C),[]);p.useCallback(C=>{const U=o.find(ne=>ne.column===C);return U?t.jsxs(n.Box,{sx:{display:"inline-flex",alignItems:"center",ml:.5,gap:.25},children:[U.direction==="asc"?t.jsx(_.ArrowUpward,{sx:{fontSize:14}}):t.jsx(_.ArrowDownward,{sx:{fontSize:14}}),t.jsx(n.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:U.priority})]}):null},[o]),p.useCallback(C=>pi(i,C)?t.jsx(n.IconButton,{size:"small",onClick:ne=>{ne.stopPropagation(),j==null||j(C)},sx:{ml:.5,p:.25,color:"primary.main","&:hover":{color:"primary.main"}},title:"Active filters on this column",children:t.jsx(_.FilterList,{sx:{fontSize:14}})}):null,[i,j]);const Fn=p.useCallback(C=>{b&&b(C)},[b]),Nn=p.useCallback((C,U)=>{we(ne=>{const ot=[...ne??(x.length>0?x:e.map(Ze=>Ze.name))],[Ye]=ot.splice(C,1);return ot.splice(U,0,Ye),ot})},[x,e]),Vn=p.useCallback(()=>{Ht&&ae&&ae(Ht),we(null)},[Ht,ae]),Hn=p.useCallback(C=>{if(!b)return;const U=o.find(ne=>ne.column===C);(!U||U.direction!=="asc")&&b(C)},[b,o]),Gn=p.useCallback(C=>{if(!b)return;const U=o.find(ne=>ne.column===C);U?U.direction==="asc"&&b(C):(b(C),setTimeout(()=>b(C),0))},[b,o]),Un=p.useCallback(C=>{if(!b)return;const U=o.find(ne=>ne.column===C);U&&(U.direction==="asc"?(b(C),setTimeout(()=>b(C),0)):U.direction==="desc"&&b(C))},[b,o]),Yn=p.useCallback(C=>{F&&F(C,!1)},[F]),ro=!!(y!=null&&y.enabled&&(y!=null&&y.levels)&&y.levels.length>0),vo=p.useMemo(()=>Tt(i),[i]),qn=o.length>0||vo>0||((y==null?void 0:y.enabled)??!1)||Object.values(u).some(C=>C===!1),Jn=(Pt-1)*Nr,Ue=r,Fe=p.useMemo(()=>{const C=new Set;return Kt.forEach(U=>{const ne=U==null?void 0:U.__urm_row_id__;ne!==void 0&&C.add(ne)}),C},[Kt]);p.useEffect(()=>{const C=U=>{!Et||!ct||U.target instanceof HTMLInputElement||U.target instanceof HTMLTextAreaElement||((U.ctrlKey||U.metaKey)&&U.key==="a"&&(U.preventDefault(),Et(!0,Ue)),U.key==="Escape"&&(U.preventDefault(),ct()))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[Et,ct,Ue]);const So=p.useCallback((C,U)=>{ut==null||ut(Ue[C],C,U),(mt==="activate"||mt==="both")&&(gt(Ue[C]),nt(!0)),mt!=="activate"&&Ke&&(U.shiftKey&&V!==null?(U.preventDefault(),Fr&&Fr(V,C,Ue)):(Ke(Ue[C]),rt(C)))},[Ke,V,Fr,Ue,ut,mt,gt,nt]),rr=p.useMemo(()=>Ue.filter(C=>!C.isGroupHeader),[Ue]),Uo=p.useMemo(()=>rr.length>0&&Fe.size>0&&rr.every(C=>Fe.has(C==null?void 0:C.__urm_row_id__)),[rr,Fe]),Kn=!Uo&&rr.some(C=>Fe.has(C==null?void 0:C.__urm_row_id__)),or=!!(Ke&&Et&&!Gr),nr=p.useMemo(()=>eo,[eo]),Yo=p.useMemo(()=>{const C=new Map;if(!(y!=null&&y.enabled)||!Ue)return C;let U=[];for(const ne of Ue)if(ne.__isGroupHeader||ne.isGroupHeader){const Be=ne.groupLevel??0;U[Be]=ne.groupKey,U=U.slice(0,Be+1),C.has(ne.groupKey)||C.set(ne.groupKey,[])}else if(ne.__urm_is_grouped_data_row__)for(const Be of U)Be&&C.has(Be)&&C.get(Be).push(ne);return C},[y,Ue]),Xn=p.useCallback(C=>{const U=C.groupLevel,ne=U===0?S.groupRowLevel0||"urm-group-level-0":U===1?S.groupRowLevel1||"urm-group-level-1":S.groupRowLevel2||"urm-group-level-2",Be=U===0?Ee=>Ee.palette.mode==="dark"?M(Ee.palette.action.hover,.12):Ee.palette.action.hover:Ee=>Ee.palette.mode==="dark"?M(Ee.palette.action.hover,.06):M(Ee.palette.action.hover,.5),ot=String(C.groupValue??"(empty)"),Ye=`${C.rowCount} ${C.rowCount===1?"item":"items"}`,Ze=Yo.get(C.groupKey)||[],xe=Ze.filter(Ee=>Fe.has(Ee==null?void 0:Ee.__urm_row_id__)).length,Dt=Ze.length>0&&xe===Ze.length,Ot=xe>0&&xe<Ze.length;return t.jsxs(n.TableRow,{onClick:()=>L==null?void 0:L(C.groupKey),className:`urm-group-header-row urm-group-level-${U} ${ne} ${S.groupRow||""}`,sx:{bgcolor:Be,"&:hover":{bgcolor:Ee=>M(Ee.palette.text.primary,.07)},cursor:"pointer",borderTop:"1px solid",borderBottom:"1px solid",borderColor:"divider",position:"relative"},children:[or&&t.jsx(n.TableCell,{padding:"checkbox",onClick:Ee=>Ee.stopPropagation(),sx:{borderBottom:"1px solid",borderColor:"divider",verticalAlign:"middle",bgcolor:"inherit"},children:t.jsx(n.Checkbox,{size:"small",checked:Dt,indeterminate:Ot,onChange:()=>{if(!Ke)return;const Ee=!Dt;Ze.forEach(w=>{const E=Fe.has(w==null?void 0:w.__urm_row_id__);Ee!==E&&Ke(w)})}})}),t.jsxs(n.TableCell,{colSpan:nr.length,className:`urm-group-cell ${S.groupCellFirst||""} ${S.groupCell||""}`,sx:{pl:`${U*24+16}px`,position:"relative",py:1.25,borderBottom:"1px solid",borderColor:"divider"},children:[U>0&&t.jsx(n.Box,{sx:{position:"absolute",left:`${U*24+4}px`,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsxs(n.Box,{className:`urm-group-content ${S.groupContent||""}`,sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(n.Box,{className:`urm-group-caret ${S.groupCaret||""}`,sx:{color:"text.secondary",display:"inline-flex",alignItems:"center"},children:C.isCollapsed?t.jsx(_.ChevronRight,{sx:{fontSize:18}}):t.jsx(_.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(n.Typography,{variant:"h5",className:`urm-group-title ${S.groupTitle||""}`,sx:{fontWeight:U===0?600:500,fontSize:U===0?"0.9375rem":"0.875rem",color:"text.primary",whiteSpace:"nowrap"},children:ot}),!C.isCollapsed&&t.jsx(n.Box,{className:"urm-group-column-heading-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Ee=>M(Ee.palette.primary.main,.1),color:"primary.main",borderRadius:"10px",border:"1px solid",borderColor:Ee=>M(Ee.palette.primary.main,.2),ml:.5},children:pt(C.groupColumn||"")}),!!C.__urm_is_continuation_header__&&t.jsx(n.Box,{className:"urm-group-continuation-badge",sx:{px:1,py:.25,fontSize:"0.7rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Ee=>M(Ee.palette.text.secondary,.05),color:"text.secondary",borderRadius:"10px",border:"1px dashed",borderColor:"divider",ml:.5},children:"Continued"}),t.jsx(n.Box,{className:`urm-group-count ${S.groupBadge||""} ${S.groupCount||""}`,sx:{px:1.25,py:.25,fontSize:"0.75rem",fontWeight:500,lineHeight:1,whiteSpace:"nowrap",display:"inline-flex",alignItems:"center",bgcolor:Ee=>M(Ee.palette.text.secondary,.08),color:"text.secondary",borderRadius:"12px",ml:.5},children:Ye}),Object.keys(C.aggregates||{}).length>0&&t.jsxs(n.Typography,{variant:"caption",className:`urm-group-aggregates ${S.groupAggregates||""}`,sx:{ml:1.5,color:"text.secondary",fontWeight:500},children:["(",Object.entries(C.aggregates).map(([Ee,w])=>Vs(w)).filter(Boolean).join(" • "),")"]})]})]})]},C.groupKey)},[nr,or,y,e,L,S,fe,Yo,Fe,Ke]),qo=p.useCallback((C,U)=>{const ne=Fe.has(C==null?void 0:C.__urm_row_id__),Be=Oe===U,ot=Tr&&(C==null?void 0:C.__urm_row_id__)===(Zt==null?void 0:Zt.__urm_row_id__),Ye=!!(C!=null&&C.__urm_is_grouped_data_row__),Ze=Ye?C.__urm_group_level__??(y==null?void 0:y.levels.length)??1:0;return t.jsxs(n.TableRow,{"data-row-index":U,className:Ye?`urm-data-row-grouped ${S.dataRowGrouped||""}`:"",onMouseEnter:()=>kr(U),onMouseLeave:()=>kr(null),onClick:xe=>{xe.target.closest("[data-row-action-btn]")||So(U,xe)},onDoubleClick:()=>{N!=null&&N.includes("doubleClick")&&(gt(C),nt(!0))},onContextMenu:xe=>{xe.preventDefault(),xe.stopPropagation(),se==null||se(C,U,xe),Le(null),be({mouseX:xe.clientX,mouseY:xe.clientY,row:C,rowIndex:U}),N!=null&&N.includes("rightClick")&&(gt(C),nt(!0))},sx:{cursor:"pointer",bgcolor:ne?xe=>it(xe).bg:ot?xe=>M(xe.palette.info.main,.12):fe!=null&&fe.striped&&U%2===1?fe.stripeBg:"background.paper",transition:"background-color 0.12s ease","&:hover":{bgcolor:ne?xe=>it(xe).hoverBg:ot?xe=>M(xe.palette.info.main,.2):xe=>`var(--highlight-hover-row, ${M(it(xe).main,.04)})`},borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider"},children:[or&&t.jsx(n.TableCell,{padding:"checkbox",onClick:xe=>xe.stopPropagation(),sx:{borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(fe==null?void 0:fe.cellAlignV)??"middle"},children:t.jsx(n.Checkbox,{size:"small",checked:ne,onChange:()=>Ke==null?void 0:Ke(C)})}),nr.map((xe,Dt)=>{const Ot=Dt===0;return t.jsxs(n.TableCell,{className:Ye&&Ot?`urm-data-cell-grouped ${S.dataCellGrouped||""}`:"",sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",py:(fe==null?void 0:fe.rowPaddingY)??"6px",px:(fe==null?void 0:fe.cellPaddingX)??2,pl:Ye&&Ot?`${Ze*24}px`:void 0,position:"relative",textAlign:(fe==null?void 0:fe.cellAlignH)??"left",verticalAlign:(fe==null?void 0:fe.cellAlignV)??"middle",fontSize:"0.875rem",fontWeight:400,color:"text.primary",borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderRight:fe==null?void 0:fe.colDivider,borderColor:"divider",minWidth:g[xe.name]?`${g[xe.name]}px`:`${xe.type==="date"?Math.max($s,180):$s}px`},children:[Ye&&Ot&&Ze>0&&t.jsx(n.Box,{sx:{position:"absolute",left:4,top:0,bottom:0,width:"1px",bgcolor:"divider"}}),t.jsx(n.Box,{sx:{display:"inline-flex",alignItems:"center",overflow:"hidden",maxWidth:"100%"},children:t.jsx("span",{className:`urm-item-title ${S.itemTitle||""}`,children:yp(xe,C[xe.name],Yr,tt)})})]},xe.name)}),t.jsx(n.TableCell,{"data-row-action":"true",sx:{position:"sticky",right:0,width:0,minWidth:0,maxWidth:0,p:0,border:"none",background:"transparent",opacity:Be?1:0,transition:"opacity 0.12s ease",zIndex:10},children:t.jsx(n.Box,{sx:{position:"absolute",right:8,top:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"flex-end",zIndex:10},children:t.jsx(n.IconButton,{"data-row-action-btn":"true",size:"small",onClick:xe=>{xe.stopPropagation(),xe.preventDefault(),Le(null),be({anchorEl:xe.currentTarget,row:C,rowIndex:U})},sx:{color:"text.secondary",opacity:Be?1:0,transition:"opacity 0.12s ease",pointerEvents:Be?"auto":"none","&:hover":{bgcolor:xe=>M(xe.palette.text.primary,.08),color:"text.primary"}},children:t.jsx(_.MoreVert,{sx:{fontSize:18}})})})})]},U)},[Kt,Jn,Oe,So,eo,g,tt,Ln,dr,ur,Xt,Ke,or,gt,nt,Zt,Tr,be,ro,bo,se,N,Fe,fe,S]);return t.jsxs(ar.DndProvider,{backend:bi.HTML5Backend,children:[t.jsxs(n.Box,{sx:C=>{var Ye,Ze,xe;const U=((xe=(Ze=(Ye=C.components)==null?void 0:Ye.MuiCard)==null?void 0:Ze.styleOverrides)==null?void 0:xe.root)||{},ne=U.border&&U.border!=="none"?U.border:"1px solid",Be=U.borderRadius!==void 0?typeof U.borderRadius=="number"?`${U.borderRadius}px`:U.borderRadius:`${C.shape.borderRadius}px`,ot=U.boxShadow&&U.boxShadow!=="none"?U.boxShadow:ye(C,"cardRest");return{display:"flex",flexDirection:"column",height:"100%",bgcolor:"background.paper",border:ne,borderColor:ne!=="none"?"divider":void 0,borderRadius:Be,boxShadow:ot,overflow:"hidden"}},children:[t.jsxs(n.Box,{sx:C=>{var Ye,Ze,xe,Dt,Ot;const U=((xe=(Ze=(Ye=C.components)==null?void 0:Ye.MuiCardHeader)==null?void 0:Ze.styleOverrides)==null?void 0:xe.root)||{},ne=(U.backgroundColor&&U.backgroundColor!=="transparent"?U.backgroundColor:void 0)??((Dt=C.tokens)==null?void 0:Dt.cardHdrHex)??((Ot=C.urmTable)==null?void 0:Ot.headerBg)??C.palette.background.paper,Be=U.borderBottom&&U.borderBottom!=="none"?U.borderBottom:"1px solid",ot=U.boxShadow&&U.boxShadow!=="none"?U.boxShadow:void 0;return{position:"sticky",top:0,zIndex:10,bgcolor:ne,borderBottom:Be,borderColor:Be!=="none"?"divider":void 0,boxShadow:ot,px:2,py:0,minHeight:56,display:"flex",alignItems:"center",gap:1}},children:[Pe&&t.jsx(rp,{}),D&&z&&h&&s.length>0&&t.jsx(_u,{views:s||[],activeViewId:a||"",isDirty:l,onSelectView:D,onCreateView:z,onToggleDefault:$,onToggleFavorite:Y,onRestoreView:X,onPermanentDelete:R,onEditView:v,onCloneView:W,onCopyLink:k,onDeleteView:q,onPromoteToGlobal:re,onSetDefaultForAllUsers:d,isAdmin:Q,hideViewMenuActions:ee,customViewMenuActions:H,viewMenuActionData:te,viewMenuActionTableState:ue,isReadOnly:Pe}),l&&!Pe&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.25,ml:1},children:[h&&t.jsx(n.Button,{onClick:h,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:C=>`var(--urm-btn-save-current-bg, ${C.palette.primary.main})`,color:C=>`var(--urm-btn-save-current-color, ${C.palette.primary.contrastText})`,textTransform:"none",boxShadow:C=>ye(C,"restButton"),"&:hover":{bgcolor:C=>`var(--urm-btn-save-current-hover-bg, ${C.palette.primary.dark})`,boxShadow:C=>ye(C,"hoverButton")}},children:"Save current view"}),I&&t.jsx(n.Button,{onClick:I,size:"small",variant:"outlined",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",borderColor:C=>`var(--urm-btn-save-new-border, ${C.palette.primary.main})`,color:C=>`var(--urm-btn-save-new-color, ${C.palette.primary.main})`,bgcolor:C=>`var(--urm-btn-save-new-bg, ${C.palette.background.paper})`,borderWidth:"1.5px",textTransform:"none","&:hover":{borderWidth:"1.5px",borderColor:C=>`var(--urm-btn-save-new-hover-border, ${C.palette.primary.dark})`,bgcolor:C=>`var(--urm-btn-save-new-hover-bg, ${M(C.palette.primary.main,.08)})`}},children:"Save new view"}),A&&t.jsx(n.Button,{onClick:A,size:"small",variant:"contained",sx:{fontSize:"0.8125rem",fontWeight:500,px:2.25,py:.75,borderRadius:"10px",bgcolor:C=>`var(--urm-btn-discard-bg, ${M(C.palette.text.primary,.12)})`,color:C=>`var(--urm-btn-discard-color, ${C.palette.text.primary})`,textTransform:"none",boxShadow:"none","&:hover":{bgcolor:C=>`var(--urm-btn-discard-hover-bg, ${M(C.palette.text.primary,.18)})`,boxShadow:"none"}},children:"Discard"})]}),Lr&&Bt&&Jt&&Pr&&!(Ce!=null&&Ce.includes("search"))&&t.jsx(n.Tooltip,{open:Xr,title:t.jsxs(n.Box,{sx:{p:.5},children:[t.jsx(n.Typography,{variant:"caption",sx:{display:"block",fontWeight:C=>C.typography.caption.fontWeight||500,mb:.25},children:"💡 Search tip"}),t.jsx(n.Typography,{variant:"caption",children:"Type to search across all columns instantly"})]}),placement:"bottom-start",arrow:!0,PopperProps:{onClick:Zr},componentsProps:{tooltip:{sx:{bgcolor:"primary.main","& .MuiTooltip-arrow":{color:"primary.main"},maxWidth:220,cursor:"pointer",userSelect:"none"}}},children:t.jsx(n.Box,{component:"span",children:t.jsx(ku,{value:at||"",onChange:C=>{Xr&&Zr(),Lr(C)},searchHistory:Wt,onAddToHistory:Bt,onToggleFavourite:Jt,onDeleteHistory:Pr,disabled:Pe})})}),!Pe&&B&&!(Ce!=null&&Ce.includes("sort"))&&t.jsx(on,{title:"Sort",onClick:B,active:o.length>0,badge:o.length,children:t.jsx(_.SwapVert,{sx:{fontSize:20}})}),!Pe&&f&&!(Ce!=null&&Ce.includes("filter"))&&t.jsx(on,{title:"Filter",onClick:f,active:vo>0,badge:vo,children:t.jsx(_.FilterList,{sx:{fontSize:20}})}),!Pe&&Z&&!(Ce!=null&&Ce.includes("columns"))&&t.jsx(on,{title:"Show/Hide Columns",onClick:Z,active:Ho>0||Wn,badge:Ho,children:t.jsx(_.ViewColumn,{sx:{fontSize:20}})}),ro&&(Se||ke)&&(()=>{var ne;const C=(((ne=y==null?void 0:y.collapsedGroups)==null?void 0:ne.length)??0)>0,U=C?Se:ke;return U?t.jsx(on,{title:C?"Expand all groups":"Collapse all groups",onClick:U,children:C?t.jsx(_.UnfoldMore,{sx:{fontSize:20}}):t.jsx(_.UnfoldLess,{sx:{fontSize:20}})}):null})(),!(Ce!=null&&Ce.includes("jsonGuide"))&&t.jsx(n.Tooltip,{title:xo??"JSON format guide",children:t.jsx(n.IconButton,{size:"small",onClick:()=>Lo(!0),sx:{color:"text.secondary",borderRadius:1,"&:hover":{bgcolor:C=>M(C.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:20}})})}),fo&&vr&&t.jsx(n.Tooltip,{title:"Developer configuration",children:t.jsx(n.IconButton,{size:"small",onClick:vr,sx:{color:"text.secondary",borderRadius:1,border:"1px dashed",borderColor:C=>M(C.palette.text.secondary,.3),"&:hover":{bgcolor:C=>M(C.palette.warning.main,.08),borderColor:"warning.main",color:"warning.dark"}},children:t.jsx(_.DisplaySettings,{sx:{fontSize:20}})})}),t.jsx(n.Box,{sx:{flexGrow:1}}),tr.length>1&&t.jsx(n.Box,{sx:{display:"flex",alignItems:"stretch",height:30,border:"1px solid",borderColor:C=>M(C.palette.text.primary,.2),borderRadius:"8px",overflow:"hidden",ml:.5},children:tr.map((C,U)=>{const ne=Ir===C,Be=C==="list"?t.jsx(_.TableRows,{sx:{fontSize:18}}):t.jsx(_.GridView,{sx:{fontSize:18}}),ot=C==="list"?"List view":"Grid view";return t.jsx(n.Tooltip,{title:ot,children:t.jsx(n.IconButton,{size:"small",onClick:()=>On(C),"aria-pressed":ne,sx:{width:36,borderRadius:0,borderLeft:U>0?"1px solid":"none",borderColor:Ye=>M(Ye.palette.text.primary,.2),color:ne?"primary.contrastText":"text.secondary",bgcolor:ne?"primary.main":"transparent",transition:"all 0.15s ease","&:hover":{bgcolor:ne?"primary.dark":Ye=>M(Ye.palette.text.primary,.06)}},children:Be})},C)})}),!(Ce!=null&&Ce.includes("settings"))&&t.jsx(n.Tooltip,{title:"More actions",children:t.jsx(n.IconButton,{onClick:C=>wt(C.currentTarget),size:"small",sx:{color:"text.secondary",borderRadius:1,transition:"all 0.15s ease","&:hover":{bgcolor:C=>M(C.palette.text.primary,.06),color:"text.primary"}},children:t.jsx(_.MoreVert,{sx:{fontSize:20}})})})]}),t.jsxs(n.Popover,{open:!!er,anchorEl:er,onClose:()=>wt(null),anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:.5,minWidth:200,py:.5,borderRadius:1.5,boxShadow:3}},children:[le&&!(Ce!=null&&Ce.includes("export"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{le(),wt(null)},disabled:c,sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.Download,{sx:{fontSize:C=>C.typography.body1.fontSize,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Export"})]}),!Pe&&pe&&!(Ce!=null&&Ce.includes("grouping"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{pe(),wt(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.Layers,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Grouping"})]}),We&&!(Ce!=null&&Ce.includes("auditHistory"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{We(),wt(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.History,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Audit History"})]}),Ae&&!(Ce!=null&&Ce.includes("scheduledReports"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{Ae(),wt(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.Schedule,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Scheduled Reports"})]}),Nt==null?void 0:Nt.map(C=>t.jsxs(n.MenuItem,{dense:!0,disabled:C.disabled,onClick:()=>{C.onClick(),wt(null)},sx:{py:1,px:2,gap:1.5},children:[C.icon,t.jsx(n.Typography,{variant:"body2",children:C.label})]},C.key))]}),t.jsxs(n.Box,{sx:{position:"relative",flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[Cr&&Cr.length>0&&Fe.size>0&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1,px:2,py:1,bgcolor:C=>it(C).bg,borderBottom:"1px solid",borderColor:"divider"},children:[t.jsxs(n.Typography,{variant:"body2",sx:{fontWeight:C=>C.typography.body2.fontWeight||600,mr:1},children:[Fe.size," selected"]}),t.jsx(n.Button,{size:"small",onClick:()=>ct==null?void 0:ct(),children:"Clear"}),Cr.map(C=>{var ne,Be;const U=Array.from(Kt);return(ne=C.hidden)!=null&&ne.call(C,U)?null:t.jsx(n.Button,{size:"small",variant:"outlined",startIcon:C.icon,disabled:(Be=C.disabled)==null?void 0:Be.call(C,U),onClick:()=>C.onClick(U),children:C.label},C.key)})]}),Ir!=="list"&&t.jsx(n.Box,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",bgcolor:"action.hover"},children:t.jsx(Zu,{data:Ue,visibleColumns:Dr,cardSlots:wr,grouping:y,selectedRowIds:Kt,isGrouped:!!ro,onToggleGroupCollapse:L,onCardClick:(C,U)=>So(C,U),onCardDoubleClick:C=>{N!=null&&N.includes("doubleClick")&&(gt(C),nt(!0))},onCardContextMenu:(C,U,ne)=>{se==null||se(C,U,ne),Le(null),be({mouseX:ne.clientX,mouseY:ne.clientY,row:C,rowIndex:U}),N!=null&&N.includes("rightClick")&&(gt(C),nt(!0))},onOpenRowMenu:(C,U,ne)=>be({anchorEl:ne,row:C,rowIndex:U}),onToggleSelection:C=>Ke==null?void 0:Ke(C),hideSelectionCheckboxes:Gr})}),Ir==="list"&&t.jsxs(n.Box,{sx:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.jsx(n.Box,{ref:Qr,onScroll:C=>{yo.current&&(yo.current.scrollLeft=C.target.scrollLeft)},sx:{overflowX:"auto",overflowY:"hidden",flexShrink:0,scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:t.jsxs(n.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(to).reduce((C,U)=>C+U,0)}px`},children:[t.jsxs("colgroup",{children:[or&&t.jsx("col",{style:{width:"40px"}}),nr.map(C=>t.jsx("col",{style:{width:`${to[C.name]}px`}},C.name))]}),t.jsx(n.TableHead,{children:t.jsxs(n.TableRow,{sx:{bgcolor:(fe==null?void 0:fe.headerBg)??"action.hover",borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider"},children:[or&&t.jsx(n.TableCell,{padding:"checkbox",sx:{borderBottom:(fe==null?void 0:fe.rowDivider)??"1px solid",borderColor:"divider",verticalAlign:(fe==null?void 0:fe.cellAlignV)??"middle"},children:t.jsx(n.Checkbox,{size:"small",checked:Uo,indeterminate:Kn,onChange:C=>Et==null?void 0:Et(C.target.checked,Ue)})}),nr.map((C,U)=>t.jsx(Du,{column:C,index:U,sortRule:o.find(ne=>ne.column===C.name),hasFilters:pi(i,C.name),isInSortStack:o.some(ne=>ne.column===C.name),isReadOnly:Pe,hasModifications:qn,width:g[C.name],onColumnClick:Fn,onMoveColumn:Nn,onColumnDragEnd:Vn,onResizeStart:Pn,onSortAscending:T||Hn,onSortDescending:m||Gn,onRemoveSort:Un,onOpenFilterForColumn:j||(()=>{}),onClearFiltersForColumn:ie||(()=>{}),onGroupByColumn:Me,onHideColumn:Yn,onManageColumns:Z||(()=>{}),onResetLayout:he},C.name))]})})]})}),t.jsx(n.Box,{ref:yo,onScroll:C=>{Qr.current&&(Qr.current.scrollLeft=C.target.scrollLeft)},sx:{flex:1,overflowY:"auto",overflowX:"auto",minHeight:0,bgcolor:"background.paper","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-track":{bgcolor:"transparent"},"&::-webkit-scrollbar-thumb":{bgcolor:C=>M(C.palette.text.primary,.2),borderRadius:4,"&:hover":{bgcolor:C=>M(C.palette.text.primary,.3)}}},children:t.jsxs(n.Table,{sx:{tableLayout:"fixed",borderCollapse:"collapse",borderSpacing:0,width:"100%",minWidth:`${Object.values(to).reduce((C,U)=>C+U,0)}px`},children:[t.jsxs("colgroup",{children:[or&&t.jsx("col",{style:{width:"40px"}}),nr.map(C=>t.jsx("col",{style:{width:`${to[C.name]}px`}},C.name))]}),t.jsx(n.TableBody,{children:Ue.length===0?t.jsx(n.TableRow,{children:t.jsx(n.TableCell,{colSpan:nr.length,align:"center",sx:{py:4},children:t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"No data matches the current filters"})})}):ro?Ue.map((C,U)=>C.isGroupHeader?Xn(C):qo(C,U)):Ue.map((C,U)=>qo(C,U))})]})})]}),Ft&&dt&&t.jsx(tp,{currentPage:Pt,pageSize:Nr,totalRows:Lt,totalPages:_t,totalFields:e.length,selectedCount:Fe.size,onClearSelection:ct,onPageChange:Ft,onPageSizeChange:dt}),!(Ft&&dt)&&t.jsxs(n.Box,{sx:{px:3,py:1.5,bgcolor:"action.hover",borderTop:1,borderColor:"divider",display:"flex",alignItems:"center",gap:1.5},children:[t.jsxs(n.Typography,{variant:"body2",color:"text.secondary",children:["Showing ",Ue.length," ",Ue.length===1?"row":"rows"]}),Fe.size>0&&t.jsxs(t.Fragment,{children:[t.jsxs(n.Typography,{variant:"body2",sx:{color:"primary.main",fontWeight:600},children:["· ",Fe.size," selected"]}),ct&&t.jsx(n.Button,{size:"small",onClick:ct,sx:{fontSize:"0.75rem",p:0,minWidth:"auto",color:"text.secondary"},children:"Clear"})]})]})]})]}),t.jsxs(n.Popover,{open:!!oe,onClose:()=>{be(null),Le(null)},anchorEl:(oe==null?void 0:oe.anchorEl)||null,anchorReference:oe!=null&&oe.anchorEl?"anchorEl":"anchorPosition",anchorPosition:oe&&!oe.anchorEl?{top:oe.mouseY,left:oe.mouseX}:void 0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:oe!=null&&oe.anchorEl?{vertical:"top",horizontal:"right"}:{vertical:"top",horizontal:"left"},PaperProps:{sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3}},children:[!(He!=null&&He.includes("view"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{oe&&(gt(oe.row),nt(!0)),be(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.Visibility,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"View"})]}),!(He!=null&&He.includes("edit"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{oe&&(Er(oe.row),me(oe.rowIndex),Br(!0)),be(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.Edit,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Edit"})]}),!(He!=null&&He.includes("duplicate"))&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{oe&&(ur==null||ur(oe.rowIndex,oe.row)),be(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.ContentCopy,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"Duplicate"})]}),oe&&($t==null?void 0:$t.map(C=>{var U,ne;return(U=C.hidden)!=null&&U.call(C,oe.row)?null:t.jsxs(n.MenuItem,{dense:!0,disabled:(ne=C.disabled)==null?void 0:ne.call(C,oe.row),onClick:()=>{C.onClick(oe.row,oe.rowIndex),be(null)},sx:{py:1,px:2,gap:1.5},children:[C.icon,t.jsx(n.Typography,{variant:"body2",children:C.label})]},C.key)})),Fe.size>0&&cr&&!(He!=null&&He.includes("export"))&&t.jsxs(t.Fragment,{children:[t.jsx(n.Divider,{sx:{my:.5}}),t.jsxs(n.MenuItem,{dense:!0,onMouseEnter:C=>{Qe(),Le(C.currentTarget)},onMouseLeave:$r,sx:{py:1,px:2,gap:1.5,justifyContent:"space-between",flexWrap:"wrap"},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(_.Download,{sx:{fontSize:C=>C.typography.body1.fontSize,color:"text.secondary"}}),t.jsxs(n.Typography,{variant:"body2",children:["Export Selected (",Fe.size,")"]})]}),t.jsx(_.ChevronRight,{sx:{fontSize:C=>C.typography.body1.fontSize,color:"text.secondary"}})]}),t.jsx(n.Popper,{open:!!Ge,anchorEl:Ge,placement:"right-start",transition:!0,sx:{zIndex:C=>C.zIndex.modal+1},modifiers:[{name:"offset",options:{offset:[0,0]}}],children:({TransitionProps:C})=>t.jsx(n.Grow,{...C,timeout:150,children:t.jsx(n.Paper,{onMouseEnter:Qe,onMouseLeave:$r,sx:{minWidth:176,py:.5,borderRadius:1.5,boxShadow:3},children:t.jsxs(n.MenuList,{dense:!0,autoFocusItem:!1,children:[t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{cr("excel"),Le(null),be(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.TableChart,{sx:{fontSize:18,color:"success.main"}}),t.jsx(n.Typography,{variant:"body2",children:"Excel"})]}),t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{cr("json"),Le(null),be(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.DataObject,{sx:{fontSize:18,color:"text.secondary"}}),t.jsx(n.Typography,{variant:"body2",children:"JSON"})]}),It.export.allowedFormats.includes("pdf")&&t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{cr("pdf"),Le(null),be(null)},sx:{py:1,px:2,gap:1.5},children:[t.jsx(_.PictureAsPdf,{sx:{fontSize:18,color:"error.main"}}),t.jsx(n.Typography,{variant:"body2",children:"PDF"})]})]})})})})]}),!(He!=null&&He.includes("delete"))&&t.jsxs(t.Fragment,{children:[t.jsx(n.Divider,{sx:{my:.5}}),t.jsxs(n.MenuItem,{dense:!0,onClick:()=>{oe&&(zr(oe.row),qr(!0)),be(null)},sx:{py:1,px:2,gap:1.5,color:"error.main"},children:[t.jsx(_.Delete,{sx:{fontSize:18,color:"error.main"}}),t.jsx(n.Typography,{variant:"body2",color:"error.main",children:"Delete"})]})]})]}),t.jsx(ip,{open:Tr,onClose:()=>{nt(!1),gt(null)},row:Zt,schema:e,reportName:Hr}),t.jsx(ap,{open:Jr,onClose:()=>{Br(!1),Er(null),me(null)},onSave:C=>{_r!==null&&(dr==null||dr(_r,C))},row:Kr,schema:e,reportName:Hr}),t.jsx(sp,{open:go,onClose:()=>{qr(!1),zr(null)},onConfirm:()=>{St!==null&&(Xt==null||Xt(St))},row:St,schema:e}),t.jsx(ha,{isOpen:Mn,onClose:()=>Lo(!1),content:ho,title:mo})]})}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","24-hour format · Tab must be open for the schedule to fire","Opens your device's email app when the schedule fires. If you added email.","The data columns visible on the selected view will be send as a report"],devNote:"Schedules are stored in localStorage per-report. Key: urm_schedules_{reportId}."},auditHistory:{title:"Audit history",description:"A full log of all changes made to this report — filters applied, sorts changed, views saved, exports triggered, and more.",tips:["Each entry shows the action, timestamp, and who performed it","Use audit history to trace back unexpected changes"],devNote:"Audit entries are stored per-report in IndexedDB via the persistence layer."}},ui=40;function vp({operator:e,onSelect:r}){return t.jsxs(n.Select,{value:e,onChange:o=>r(o.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(n.MenuItem,{value:"and",sx:{fontSize:"0.75rem",fontWeight:600},children:"AND"}),t.jsx(n.MenuItem,{value:"or",sx:{fontSize:"0.75rem",fontWeight:600},children:"OR"})]})}function Sp({condition:e,schema:r,availableColumns:o,devConfig:i,onUpdate:s}){const a=r.find(u=>u.name===e.column),l=p.useMemo(()=>{const u=a?fn(a.type):[],x=i.filter.allowedOperators;return x.length>0?u.filter(g=>x.includes(g.value)):u},[a,i]),c=Ul(e.operator);return t.jsxs(n.Box,{sx:{display:"flex",gap:1,alignItems:"center",flexWrap:"wrap"},children:[t.jsx(n.FormControl,{size:"small",sx:{minWidth:150,flex:"1 1 150px"},children:t.jsx(n.Select,{value:e.column,onChange:u=>{var y;const x=r.find(S=>S.name===u.target.value),g=x?fn(x.type):[];s({column:u.target.value,operator:((y=g[0])==null?void 0:y.value)??e.operator,value:void 0})},displayEmpty:!0,sx:{fontSize:"0.875rem",height:36,borderRadius:"4px",bgcolor:"background.paper"},children:o.map(u=>t.jsx(n.MenuItem,{value:u.name,sx:{fontSize:"0.875rem"},children:pt(u.name)},u.name))})}),t.jsx(n.FormControl,{size:"small",sx:{minWidth:130,flex:"1 1 130px"},children:t.jsx(n.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(n.MenuItem,{value:u.value,sx:{fontSize:"0.875rem"},children:u.label},u.value))})}),c&&(a==null?void 0:a.type)==="date"&&t.jsx(n.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&&(a==null?void 0:a.type)!=="date"&&t.jsx(n.TextField,{size:"small",type:(a==null?void 0:a.type)==="number"?"number":"text",value:e.value??"",onChange:u=>s({value:(a==null?void 0:a.type)==="number"?Number(u.target.value):u.target.value}),placeholder:"Value…",sx:{minWidth:160,flex:"1 1 160px","& .MuiInputBase-root":{height:36,fontSize:"0.875rem"}}})]})}function va({group:e,depth:r,schema:o,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:l,onChange:c}){const u=l>=a;return t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[e.children.map((x,g)=>t.jsxs(n.Box,{sx:{display:"flex",alignItems:"stretch",gap:1},children:[t.jsxs(n.Box,{sx:{width:ui,flexShrink:0,position:"relative",display:"flex",justifyContent:"center"},children:[g<e.children.length-1&&t.jsx(n.Box,{sx:{position:"absolute",top:0,bottom:0,left:"50%",width:"1px",bgcolor:"divider"}}),g>0&&t.jsx(vp,{operator:e.operator,onSelect:y=>c(S=>Ci(S,e.id,y))}),g>0&&t.jsx(n.Box,{sx:{position:"absolute",top:13,left:"50%",width:ui/2,height:"1px",bgcolor:"divider"}})]}),t.jsx(n.Box,{sx:{flex:1,minWidth:0,pt:g>0?1:0},children:et(x)?t.jsx(wp,{group:x,depth:r+1,schema:o,availableColumns:i,devConfig:s,maxConditions:a,totalConditions:l,onChange:c}):t.jsx(Sp,{condition:x,schema:o,availableColumns:i,devConfig:s,onUpdate:y=>c(S=>wi(S,x.id,y))})}),t.jsx(n.IconButton,{size:"small",onClick:()=>c(y=>ji(y,x.id)),sx:{mt:g>0?1:.25,color:"text.secondary",flexShrink:0},children:t.jsx(_.Close,{sx:{fontSize:16}})})]},x.id)),t.jsxs(n.Box,{sx:{display:"flex",gap:2,pl:`${ui}px`},children:[t.jsx(n.Button,{size:"small",disabled:u||i.length===0,onClick:()=>c(x=>{var g,y,S;return po(x,e.id,{id:uo(),column:((g=i[0])==null?void 0:g.name)??"",operator:((S=fn(((y=i[0])==null?void 0:y.type)??"string")[0])==null?void 0:S.value)??"equals"})}),sx:{fontSize:"0.8125rem",color:"primary.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add condition"}),t.jsx(n.Button,{size:"small",disabled:u,onClick:()=>c(x=>po(x,e.id,At())),sx:{fontSize:"0.8125rem",color:"text.secondary",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",textDecoration:"underline"}},children:"+ Add group"})]})]})}function wp(e){return t.jsx(n.Box,{sx:{position:"relative",border:"1px solid",borderColor:r=>M(r.palette.primary.main,.2),borderLeft:"3px solid",borderLeftColor:"primary.main",bgcolor:r=>M(r.palette.primary.main,r.palette.mode==="dark"?.06:.03),borderRadius:"8px",p:1.25},children:t.jsx(va,{...e})})}function Cp({schema:e,filters:r,onReplaceFilters:o,onClose:i,focusColumn:s,onOpenDevConfig:a}){const[l,c]=p.useState(r??At()),u=Rr(),x=p.useMemo(()=>e.filter(B=>B.type!=="mixed"&&B.type!=="null"&&B.type!=="array"&&B.type!=="object"),[e]);p.useEffect(()=>{var j;const B=r??At();if(s&&B.children.length===0){const D=e.find(z=>z.name===s);if(D){c(po(B,B.id,{id:uo(),column:s,operator:((j=fn(D.type)[0])==null?void 0:j.value)??"equals"}));return}}c(B)},[r,s,e]);const g=Tt(l),y=u.filter.maxConditions,S=p.useCallback(B=>{c(j=>B(j))},[]),b=p.useMemo(()=>JSON.stringify(l)!==JSON.stringify(r??At()),[l,r]),T=p.useCallback(()=>{o(l),i()},[l,o,i]),m=p.useCallback(()=>{c(r??At()),i()},[r,i]),f=p.useCallback(()=>{o(At()),i()},[o,i]);return t.jsxs(st,{open:!0,onClose:m,icon:t.jsx(_.FilterAlt,{sx:{fontSize:20}}),title:"Filter columns",helpContent:Wr.filter,width:640,maxHeight:"min(620px, calc(100vh - 200px))",headerActions:a?t.jsx(n.IconButton,{onClick:a,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.Settings,{sx:{fontSize:18}})}):void 0,footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Tooltip,{title:"Removes all applied filters and closes this panel",arrow:!0,children:t.jsx(n.Box,{component:"span",sx:{mr:"auto"},children:t.jsx(n.Button,{onClick:f,disabled:g===0,sx:{fontSize:"0.875rem",color:"error.main",p:0,minWidth:"auto","&:hover":{bgcolor:"transparent",color:"error.dark",textDecoration:"underline"},"&.Mui-disabled":{color:"text.disabled"}},children:"Clear all"})})}),t.jsx(n.Button,{onClick:m,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:B=>`${B.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:T,disabled:!b,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:B=>`${B.shape.borderRadius}px`,boxShadow:B=>ye(B,"restButton"),"&:hover":{bgcolor:"primary.dark"},"&.Mui-disabled":{bgcolor:"action.disabledBackground",color:"action.disabled"}},children:"Apply filter"})]}),children:[g===0&&t.jsxs(n.Typography,{variant:"body2",sx:{color:"text.disabled",fontSize:B=>B.typography.body2.fontSize||"0.875rem",mb:2},children:["No conditions yet — add one below to start filtering",s?` on "${pt(s)}"`:"","."]}),t.jsx(va,{group:l,depth:0,schema:e,availableColumns:x,devConfig:u,maxConditions:y,totalConditions:g,onChange:S}),g>=y&&t.jsxs(n.Typography,{variant:"caption",sx:{display:"block",mt:1.5,color:"warning.dark",fontSize:B=>B.typography.caption.fontSize||"0.75rem",fontWeight:B=>B.typography.caption.fontWeight||500},children:["Filter limit reached — maximum ",y," conditions allowed. Remove one to add another."]})]})}const Is="SORT_RULE";function jp({rule:e,index:r,onToggleDirection:o,onRemove:i,onMove:s}){const a=p.useRef(null),[{handlerId:l},c]=ar.useDrop({accept:Is,collect(g){return{handlerId:g.getHandlerId()}},hover(g,y){var j;if(!a.current)return;const S=g.index,b=r;if(S===b)return;const T=(j=a.current)==null?void 0:j.getBoundingClientRect(),m=(T.bottom-T.top)/2,f=y.getClientOffset(),B=((f==null?void 0:f.y)??0)-T.top;S<b&&B<m||S>b&&B>m||(s(S,b),g.index=b)}}),[{isDragging:u},x]=ar.useDrag({type:Is,item:()=>({index:r}),collect:g=>({isDragging:g.isDragging()})});return x(c(a)),t.jsxs(n.Box,{ref:a,"data-handler-id":l,sx:{display:"flex",alignItems:"center",gap:1.25,px:2,py:1.25,borderRadius:"8px",bgcolor:"background.paper",border:"1px solid divider",opacity:u?.4:1,cursor:"move",transition:"all 0.2s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{bgcolor:"action.hover",borderColor:"divider",boxShadow:g=>ye(g,"restButtonLight"),transform:"translateY(-1px)"}},children:[t.jsx(n.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 ${M(g.palette.primary.main,.3)}`,"& .MuiChip-label":{px:0}}}),t.jsxs(n.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(n.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(n.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}}),t.jsx(n.Box,{sx:{width:"4px",height:"4px",borderRadius:"50%",bgcolor:"text.secondary"}})]}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:g=>g.typography.body2.fontSize||"0.875rem",fontWeight:g=>g.typography.body2.fontWeight||400,color:"text.primary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 0 100px",lineHeight:1.5},children:e.column}),t.jsx(n.FormControl,{size:"small",sx:{flex:1,minWidth:100},children:t.jsxs(n.Select,{value:e.direction,onChange:g=>o(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(n.MenuItem,{value:"asc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:g=>sr(g),"&:hover":{bgcolor:g=>M(g.palette.primary.main,.2)}}},children:"Ascending"}),t.jsx(n.MenuItem,{value:"desc",sx:{fontSize:"0.875rem",color:"text.primary","&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:g=>sr(g),"&:hover":{bgcolor:g=>M(g.palette.primary.main,.2)}}},children:"Descending"})]})}),t.jsx(n.IconButton,{onClick:()=>i(r),size:"small",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{color:"error.main",bgcolor:g=>M(g.palette.error.main,.08),transform:"scale(1.1)"}},children:t.jsx(_.Close,{sx:{fontSize:18}})})]})}function kp({schema:e,sortStack:r,onUpdateSortStack:o,onClose:i,onOpenDevConfig:s}){const[a,l]=p.useState(""),[c,u]=p.useState([]);p.useEffect(()=>{u([...r])},[r]);const x=p.useMemo(()=>JSON.stringify(c)!==JSON.stringify(r),[c,r]),g=Rr(),y=p.useCallback(D=>{if(!D||c.length>=g.sort.maxLevels)return;const z={column:D,direction:"asc",priority:c.length+1};u([...c,z]),l(""),setTimeout(()=>{var h;return(h=document.activeElement)==null?void 0:h.blur()},0)},[c,g.sort.maxLevels]),S=p.useCallback(D=>{const h=c.filter((I,A)=>A!==D).map((I,A)=>({...I,priority:A+1}));u(h)},[c]),b=p.useCallback((D,z)=>{const h=[...c];h[D]={...h[D],direction:z},u(h)},[c]),T=p.useCallback((D,z)=>{const h=[...c],[I]=h.splice(D,1);h.splice(z,0,I);const A=h.map(($,Y)=>({...$,priority:Y+1}));u(A)},[c]),m=p.useCallback(()=>{o([]),i()},[o,i]),f=p.useCallback(()=>{o(c),i()},[c,o,i]),B=p.useCallback(()=>{u([...r]),l(""),i()},[r,i]),j=e.filter(D=>!c.some(z=>z.column===D.name));return t.jsx(ar.DndProvider,{backend:bi.HTML5Backend,children:t.jsxs(st,{open:!0,onClose:B,icon:t.jsx(_.SwapVert,{sx:{fontSize:20}}),title:"Sort columns",helpContent:Wr.sort,width:480,maxHeight:"min(440px, calc(100vh - 280px))",headerActions:s?t.jsx(n.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.Settings,{sx:{fontSize:18}})}):void 0,footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:B,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:D=>`${D.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:f,variant:"contained",disabled:!x||c.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:D=>`${D.shape.borderRadius}px`,boxShadow:D=>ye(D,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:D=>ye(D,"hoverButton")},"&:active":{boxShadow:D=>ye(D,"pressedButton"),transform:"translateY(1px)"}},children:"Apply sort"})]}),children:[t.jsxs(n.Box,{sx:{mb:2.5},children:[t.jsx(n.Typography,{variant:"overline",sx:{fontSize:D=>D.typography.caption.fontSize||"0.6875rem",fontWeight:D=>D.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add sort level"}),t.jsxs(n.FormControl,{size:"small",fullWidth:!0,disabled:c.length>=g.sort.maxLevels,children:[t.jsx(n.InputLabel,{sx:{fontSize:"0.875rem",color:"text.secondary","&.Mui-focused":{color:"primary.main"}},children:"Select column..."}),t.jsx(n.Select,{value:a,onChange:D=>y(D.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(D=>t.jsx(n.MenuItem,{value:D.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:z=>sr(z),"&:hover":{bgcolor:z=>M(z.palette.primary.main,.2)}}},children:pt(D.name)},D.name))})]}),c.length>=g.sort.maxLevels&&t.jsxs(n.Typography,{variant:"caption",sx:{mt:.75,display:"block",color:"warning.dark",fontSize:D=>D.typography.caption.fontSize||"0.75rem",fontWeight:D=>D.typography.caption.fontWeight||500},children:["Maximum ",g.sort.maxLevels," sort levels allowed"]})]}),c.length>0&&t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(n.Typography,{variant:"overline",sx:{fontSize:D=>D.typography.caption.fontSize||"0.6875rem",fontWeight:D=>D.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:["Sorted sequence (",c.length,"/",g.sort.maxLevels,")"]}),t.jsx(n.Tooltip,{title:"Removes all applied sorting and closes this panel",arrow:!0,children:t.jsx(n.Button,{onClick:m,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(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:c.map((D,z)=>t.jsx(jp,{rule:D,index:z,onToggleDirection:b,onRemove:S,onMove:T},`${D.column}-${z}`))})]})]})})}const nn=50;function Ds({currentSnapshot:e,onSave:r,onClose:o,isEditMode:i=!1,initialName:s="",initialDescription:a="",initialIsDefault:l=!1,atViewLimit:c=!1,maxViews:u=10}){const[x,g]=p.useState(s),[y,S]=p.useState(!1),[b,T]=p.useState(a),[m,f]=p.useState(l),B=()=>{if(!x.trim()){S(!0);return}if(x.trim().length>nn){S(!0);return}r(x.trim(),b.trim(),m),o()},j=z=>{z.key==="Enter"&&!z.shiftKey&&B()},D=()=>i&&s?`Update ${s} view`:"Create New Report View";return t.jsx(st,{open:!0,onClose:o,icon:t.jsx(_.Save,{sx:{fontSize:20}}),title:D(),width:600,footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:o,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:.875,minHeight:36,borderRadius:z=>`${z.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:B,variant:"contained",disabled:c&&!i,startIcon:t.jsx(_.Save,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:.875,minHeight:36,borderRadius:z=>`${z.shape.borderRadius}px`,boxShadow:z=>ye(z,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:z=>ye(z,"hoverButton")},"&:active":{boxShadow:z=>ye(z,"pressedButton"),transform:"translateY(1px)"},"&.Mui-disabled":{bgcolor:"divider",color:"text.disabled"}},children:i?"Save Changes":"Create Report View"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2,pt:1},children:[c&&!i&&t.jsxs(n.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(n.TextField,{label:"View Name",required:!0,value:x,onChange:z=>{z.target.value.length<=nn&&g(z.target.value),y&&z.target.value.trim()&&S(!1)},onKeyDown:j,placeholder:"e.g., Active Users",autoFocus:!0,fullWidth:!0,size:"small",disabled:c&&!i,inputProps:{maxLength:nn},error:y&&!x.trim(),helperText:y&&!x.trim()?"View name is required":`${x.length} / ${nn}`}),t.jsx(n.TextField,{label:"Description (optional)",value:b,onChange:z=>T(z.target.value),placeholder:"Brief description of this view",multiline:!0,rows:2,fullWidth:!0,size:"small"}),t.jsxs(n.Paper,{sx:{p:2,bgcolor:"action.hover"},variant:"outlined",children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:z=>z.typography.body2.fontWeight||500,mb:1},children:"This view will capture:"}),t.jsxs(n.Box,{component:"ul",sx:{m:0,pl:2,"& li":{fontSize:"body2.fontSize",color:"text.secondary"}},children:[t.jsxs("li",{children:[Tt(e.filters)," filter",Tt(e.filters)!==1?"s":""]}),t.jsxs("li",{children:["Sorting: ",dl(e.sortStack)]}),t.jsx("li",{children:"Column order & visibility"})]})]}),!i&&t.jsx(n.FormControlLabel,{control:t.jsx(n.Checkbox,{checked:m,onChange:z=>f(z.target.checked),size:"small"}),label:t.jsx(n.Typography,{variant:"body2",children:"Set as default view"})})]})})}function Tp({viewName:e,onConfirm:r,onCancel:o}){return t.jsx(st,{open:!0,onClose:o,icon:t.jsx(_.Warning,{sx:{fontSize:20}}),iconColor:"error",title:"Delete View",width:600,maxHeight:"min(480px, calc(100vh - 180px))",footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:o,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(n.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.875rem",px:3,py:.875,minHeight:36,borderRadius:i=>`${i.shape.borderRadius}px`,boxShadow:i=>ye(i,"restButton"),transition:"all 0.2s ease","&:hover":{boxShadow:i=>ye(i,"hoverButton")},"&:active":{boxShadow:i=>ye(i,"pressedButton"),transform:"translateY(1px)"}},children:"Delete View"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5,mt:1},children:[t.jsx(_.Warning,{color:"error",sx:{fontSize:20,flexShrink:0}}),t.jsxs(n.Box,{children:[t.jsxs(n.Typography,{variant:"body2",sx:{mb:1},children:["Are you sure you want to delete the view ",t.jsxs("strong",{children:['"',e,'"']}),"?"]}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:"This action cannot be undone."})]})]})})}const Os="COLUMN";function zp({column:e,index:r,isVisible:o,width:i,minColumnWidth:s,maxColumnWidth:a,canToggleOn:l,onToggleVisibility:c,onWidthChange:u,moveColumn:x}){const g=p.useRef(null),[y,S]=p.useState(i.toString());p.useEffect(()=>{S(i.toString())},[i]);const[{handlerId:b},T]=ar.useDrop({accept:Os,collect(h){return{handlerId:h.getHandlerId()}},hover(h,I){var W;if(!g.current)return;const A=h.index,$=r;if(A===$)return;const Y=(W=g.current)==null?void 0:W.getBoundingClientRect(),X=(Y.bottom-Y.top)/2,R=I.getClientOffset(),v=((R==null?void 0:R.y)??0)-Y.top;A<$&&v<X||A>$&&v>X||(x(A,$),h.index=$)}}),[{isDragging:m},f]=ar.useDrag({type:Os,item:()=>({index:r}),collect:h=>({isDragging:h.isDragging()})});f(T(g));const B=()=>{const h=parseInt(y);if(isNaN(h)){S(i.toString()),u(e.name,i);return}const I=Math.max(s,Math.min(a,h));S(I.toString()),u(e.name,I)},j=h=>{if(h===""||/^\d+$/.test(h)){S(h);const I=parseInt(h);if(!isNaN(I)&&I>=s){const A=Math.min(a,I);u(e.name,A)}}},D=h=>{h.key==="Enter"&&(h.preventDefault(),B(),h.target.blur())},z=h=>({string:"primary.main",number:"success.main",boolean:"secondary.main",array:"info.main",object:"error.main",null:"text.secondary",mixed:"text.secondary"})[h]||"text.secondary";return t.jsxs(n.TableRow,{ref:g,"data-handler-id":b,sx:{opacity:m?.4:1,bgcolor:o?"background.paper":"action.hover",transition:"opacity 0.15s ease","&:hover":{bgcolor:o?"action.hover":"action.selected"},cursor:"move",height:56,borderBottom:h=>`1px solid ${h.palette.divider}`},children:[t.jsx(n.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(n.Box,{sx:{color:"text.secondary",cursor:"grab",opacity:.6,transition:"opacity 0.2s ease","&:hover":{opacity:1},"&:active":{cursor:"grabbing"}},children:t.jsx(_.DragIndicator,{sx:{fontSize:20}})}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||400,fontSize:h=>h.typography.body2.fontSize||"0.875rem",color:o?"text.primary":"text.secondary"},children:pt(e.name)})]})}),t.jsx(n.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsx(n.Chip,{label:e.type.toUpperCase(),size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:600,bgcolor:`${z(e.type)}15`,color:z(e.type),border:`1px solid ${z(e.type)}30`,"& .MuiChip-label":{px:1}}})}),t.jsx(n.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[t.jsx(n.TextField,{type:"number",value:y,onChange:h=>j(h.target.value),onBlur:B,onKeyDown:D,placeholder:"150",size:"small",inputProps:{min:s,max:a,step:10},sx:{width:90,"& .MuiOutlinedInput-root":{height:32,fontSize:"0.8125rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"}},"& .MuiInputBase-input":{py:.5,px:1.25,color:"text.primary"},"& input[type=number]::-webkit-inner-spin-button":{opacity:1},"& input[type=number]::-webkit-outer-spin-button":{opacity:1}}}),t.jsx(n.Typography,{variant:"caption",sx:{fontSize:h=>h.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"px"})]})}),t.jsx(n.TableCell,{sx:{py:1.5,px:2.5,borderBottom:"none"},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[t.jsx(n.IconButton,{onClick:()=>c(e.name,!o),disabled:!o&&!l,title:o?"Hide column":l?"Show column":"Max visible columns reached",size:"small",sx:{p:.75,color:o?"primary.main":"text.secondary",transition:"all 0.2s ease","&:hover:not(:disabled)":{bgcolor:"action.hover",color:o?"primary.dark":"primary.main"},"&:disabled":{opacity:.5,cursor:"not-allowed"}},children:o?t.jsx(_.Visibility,{sx:{fontSize:20}}):t.jsx(_.VisibilityOff,{sx:{fontSize:20}})}),t.jsx(n.Chip,{label:o?"Visible":"Hidden",size:"small",sx:{height:22,fontSize:"0.6875rem",fontWeight:500,bgcolor:o?h=>M(h.palette.success.main,.12):"action.selected",color:o?"success.main":"text.secondary","& .MuiChip-label":{px:1}}})]})})]})}function Bp({schema:e,columnVisibility:r,columnOrder:o,columnWidths:i={},views:s=[],activeViewId:a="",onUpdateColumnVisibility:l,onUpdateColumnOrder:c,onUpdateColumnWidth:u,onResetLayout:x,onClose:g}){const y=Rr(),[S,b]=p.useState(!1),[T,m]=p.useState(o),[f,B]=p.useState(i),[j,D]=p.useState("all");p.useEffect(()=>{m(o)},[o]),p.useEffect(()=>{B(i)},[i]);const z=(W,k)=>{B(q=>({...q,[W]:k})),u==null||u(W,k)},h=(W,k)=>{const q=[...T],[re]=q.splice(W,1);q.splice(k,0,re),m(q),c(q)},I=()=>{x(),b(!1)},$=T.map(W=>e.find(k=>k.name===W)).filter(W=>W!==void 0).filter(W=>{const k=r[W.name]??!0;return j==="active"?k:j==="hidden"?!k:!0}),Y=Object.values(r).filter(W=>W).length,X=e.length,R=s.find(W=>W.id===a),v=p.useMemo(()=>{if(!R)return!1;const W=R.snapshot,k=W.columnVisibility??{},q=JSON.stringify(r)!==JSON.stringify(k),re=W.columnOrder??[],d=o??[],Q=JSON.stringify(d)!==JSON.stringify(re)&&!(d.length===0&&re.length===0),ee=W.columnWidths??{},H=JSON.stringify(f)!==JSON.stringify(ee);return q||Q||H},[R,r,o,f]);return t.jsx(ar.DndProvider,{backend:bi.HTML5Backend,children:t.jsxs(st,{open:!0,onClose:g,icon:t.jsx(_.ViewColumn,{sx:{fontSize:20}}),title:"Manage columns",helpContent:Wr.columns,width:720,maxHeight:"min(760px, calc(100vh - 200px))",headerExtra:t.jsxs(n.Tabs,{value:j,onChange:(W,k)=>D(k),sx:{minHeight:36,"& .MuiTabs-indicator":{bgcolor:W=>it(W).main,height:3}},children:[t.jsx(n.Tab,{label:"All",value:"all",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:W=>it(W).hoverBg},"&:hover":{color:"text.primary",bgcolor:W=>it(W).bg}}}),t.jsx(n.Tab,{label:"Visible",value:"active",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:W=>it(W).hoverBg},"&:hover":{color:"text.primary",bgcolor:W=>it(W).bg}}}),t.jsx(n.Tab,{label:"Hidden",value:"hidden",sx:{minHeight:36,py:.75,px:2,fontSize:"0.875rem",fontWeight:500,textTransform:"none",color:"text.secondary",borderRadius:"8px 8px 0 0","&.Mui-selected":{color:"text.primary",fontWeight:600,bgcolor:W=>it(W).hoverBg},"&:hover":{color:"text.primary",bgcolor:W=>it(W).bg}}})]}),footer:t.jsxs(t.Fragment,{children:[t.jsxs(n.Typography,{variant:"body2",sx:{fontSize:W=>W.typography.body2.fontSize||"0.8125rem",color:"text.secondary",mr:"auto"},children:[Y," of ",X," columns visible • Drag to reorder"]}),t.jsx(n.Button,{onClick:()=>b(!0),disabled:!v,variant:"outlined",startIcon:t.jsx(_.Undo,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",px:2.5,py:.875,minHeight:36,borderRadius:W=>`${W.shape.borderRadius}px`,"&:hover":{borderColor:"primary.main",bgcolor:"background.paper",color:"primary.main"},"&.Mui-disabled":{color:"text.disabled",borderColor:"divider"}},children:"Reset"})]}),children:[t.jsxs(n.Table,{stickyHeader:!0,sx:{minWidth:650},children:[t.jsx(n.TableHead,{children:t.jsxs(n.TableRow,{children:[t.jsx(n.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(n.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(n.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(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Width",t.jsx(n.Tooltip,{title:`Column width in pixels (min: ${y.columns.minColumnWidth}px, max: ${y.columns.maxColumnWidth}px)`,arrow:!0,placement:"top",children:t.jsx(_.InfoOutlined,{sx:{fontSize:14,color:"text.secondary",cursor:"help"}})})]})}),t.jsx(n.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(n.TableBody,{children:$.length===0?t.jsx(n.TableRow,{children:t.jsx(n.TableCell,{colSpan:4,align:"center",sx:{py:6,borderBottom:"none"},children:t.jsx(n.Typography,{variant:"body2",sx:{fontSize:W=>W.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No columns in this category"})})}):$.map((W,k)=>{const q=r[W.name]??!0,re=q||Y<y.columns.maxVisible;return t.jsx(zp,{column:W,index:k,isVisible:q,width:f[W.name]||170,minColumnWidth:y.columns.minColumnWidth,maxColumnWidth:y.columns.maxColumnWidth,canToggleOn:re,onToggleVisibility:l,onWidthChange:z,moveColumn:h},W.name)})})]}),S&&t.jsx(n.Box,{onClick:()=>b(!1),sx:{position:"fixed",top:0,left:0,right:0,bottom:0,bgcolor:W=>M(W.palette.common.black,.5),display:"flex",alignItems:"center",justifyContent:"center",zIndex:W=>W.zIndex.tooltip},children:t.jsxs(n.Paper,{onClick:W=>W.stopPropagation(),elevation:0,sx:{width:400,maxWidth:"90vw",borderRadius:W=>Po(W),bgcolor:"background.paper",boxShadow:W=>Rt(W).paper.boxShadow,border:W=>Rt(W).paper.border},children:[t.jsxs(n.Box,{sx:{px:3,py:2.5},children:[t.jsx(n.Typography,{variant:"h4",sx:{fontSize:W=>W.typography.h4.fontSize||"1rem",fontWeight:W=>W.typography.h4.fontWeight||500,color:"text.primary",mb:1.5},children:"Reset column layout?"}),t.jsx(n.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(n.Box,{sx:{px:3,py:2,borderTop:"1px solid divider",display:"flex",gap:1.5,justifyContent:"flex-end",bgcolor:"action.hover"},children:[t.jsx(n.Button,{onClick:()=>b(!1),variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,borderRadius:W=>`${W.shape.borderRadius}px`,"&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:I,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"error.main",color:"background.paper",px:3,py:1,borderRadius:W=>`${W.shape.borderRadius}px`,boxShadow:W=>ye(W,"pressedButton"),"&:hover":{bgcolor:"error.dark",boxShadow:W=>ye(W,"hoverButton")},"&:active":{boxShadow:W=>ye(W,"pressedButton"),transform:"translateY(1px)"}},children:"Reset layout"})]})]})})]})})}function Ep({schema:e,grouping:r,onApply:o,onClose:i,onOpenDevConfig:s}){var A;const[a,l]=p.useState(r||{enabled:!1,levels:[],collapsedGroups:[]}),[c,u]=p.useState(""),[x,g]=p.useState(null),y=p.useMemo(()=>ol(e),[e]),S=p.useMemo(()=>y.filter($=>!a.levels.some((Y,X)=>Y.column===$.name&&X!==x)),[y,a.levels,x]),b=Rr(),T=a.levels.length<b.grouping.maxLevels&&S.length>0&&(b.grouping.allowNested||a.levels.length===0),m=p.useCallback($=>{!T||!$||(l({...a,levels:[...a.levels,{column:$}],enabled:!0}),u(""),setTimeout(()=>{var Y;return(Y=document.activeElement)==null?void 0:Y.blur()},0))},[T,a]),f=p.useCallback($=>{const Y=a.levels.filter((X,R)=>R!==$);if(Y.length===0){o(null),i();return}l({...a,levels:Y,enabled:Y.length>0})},[a,o,i]),B=p.useCallback($=>{g($),u(a.levels[$].column)},[a.levels]),j=p.useCallback(()=>{if(x===null||!c)return;const $=[...a.levels];$[x]={column:c},l({...a,levels:$}),g(null),u("")},[x,c,a]),D=p.useCallback(()=>{g(null),u("")},[]),z=p.useCallback(($,Y)=>{const X=Y==="up"?$-1:$+1;if(X<0||X>=a.levels.length)return;const R=[...a.levels],[v]=R.splice($,1);R.splice(X,0,v),l({...a,levels:R})},[a]),h=p.useCallback(()=>{o(null),i()},[o,i]),I=p.useCallback(()=>{a.levels.length===0?o(null):o({...a,enabled:!0,collapsedGroups:(r==null?void 0:r.collapsedGroups)||[]}),i()},[a,r,o,i]);return t.jsx(st,{open:!0,onClose:i,icon:t.jsx(_.Layers,{sx:{fontSize:20}}),title:"Group configuration",helpContent:Wr.grouping,width:540,maxHeight:"min(560px, calc(100vh - 280px))",headerActions:s?t.jsx(n.IconButton,{onClick:s,size:"small",title:"Dev config",sx:{p:.5,color:"text.secondary",transition:"all 0.2s ease","&:hover":{bgcolor:"action.hover",color:"text.primary"}},children:t.jsx(_.Settings,{sx:{fontSize:18}})}):void 0,footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:i,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:$=>`${$.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:I,variant:"contained",disabled:a.levels.length===0,sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:$=>`${$.shape.borderRadius}px`,boxShadow:$=>ye($,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:$=>ye($,"hoverButton")},"&:active":{boxShadow:$=>ye($,"pressedButton"),transform:"translateY(1px)"}},children:"Apply grouping"})]}),children:t.jsxs(n.Stack,{spacing:2.5,children:[x===null&&t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"overline",sx:{fontSize:$=>$.typography.caption.fontSize||"0.6875rem",fontWeight:$=>$.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1.5,display:"block",textTransform:"uppercase"},children:"Add group level"}),t.jsx(n.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(n.Select,{value:c,onChange:$=>m($.target.value),disabled:!T,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(n.MenuItem,{value:"",sx:{fontSize:"0.875rem",color:"text.secondary"},children:"Select a column..."}),S.map($=>t.jsxs(n.MenuItem,{value:$.name,sx:{fontSize:"0.875rem",color:"text.primary",py:1,"&:hover":{bgcolor:"action.hover"},"&.Mui-selected":{bgcolor:Y=>sr(Y),"&:hover":{bgcolor:Y=>M(Y.palette.primary.main,.2)}}},children:[pt($.name)," (",$.type.toUpperCase(),")"]},$.name))]})}),a.levels.length>=b.grouping.maxLevels&&t.jsx(n.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",textAlign:"center",mt:1.5,fontSize:$=>$.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:"Maximum group levels (3) reached"}),y.length===0&&t.jsx(n.Typography,{variant:"body2",color:"text.secondary",sx:{textAlign:"center",py:2,fontSize:$=>$.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No groupable columns available. Only STRING and BOOLEAN columns can be grouped."})]}),x!==null&&t.jsxs(n.Alert,{severity:"warning",sx:{borderRadius:"8px",border:$=>`1px solid ${M($.palette.warning.main,.5)}`,bgcolor:$=>M($.palette.warning.main,.12),"& .MuiAlert-icon":{color:"warning.main"}},children:[t.jsxs(n.Typography,{variant:"body2",sx:{fontWeight:$=>$.typography.body2.fontWeight||500,mb:1.5,fontSize:$=>$.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:["Edit Group Level ",x+1]}),t.jsx(n.FormControl,{fullWidth:!0,size:"small",sx:{mb:1.5},children:t.jsxs(n.Select,{value:c,onChange:$=>u($.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(n.MenuItem,{value:"",sx:{fontSize:"0.875rem"},children:"Select a column..."}),t.jsxs(n.MenuItem,{value:a.levels[x].column,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:$=>sr($)}},children:[a.levels[x].column," (",(A=e.find($=>$.name===a.levels[x].column))==null?void 0:A.type.toUpperCase(),")"]}),S.filter($=>$.name!==a.levels[x].column).map($=>t.jsxs(n.MenuItem,{value:$.name,sx:{fontSize:"0.875rem","&.Mui-selected":{bgcolor:Y=>sr(Y)}},children:[pt($.name)," (",$.type.toUpperCase(),")"]},$.name))]})}),t.jsxs(n.Stack,{direction:"row",spacing:1.5,children:[t.jsx(n.Button,{onClick:j,disabled:!c,variant:"contained",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",bgcolor:"warning.main",color:"background.paper",py:.875,boxShadow:"none","&:hover":{bgcolor:"warning.dark",boxShadow:$=>ye($,"pressedButton")}},children:"Save"}),t.jsx(n.Button,{onClick:D,variant:"outlined",fullWidth:!0,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",borderColor:"divider",py:.875,"&:hover":{borderColor:"text.secondary",bgcolor:"action.hover"}},children:"Cancel"})]})]}),a.levels.length>0&&x===null&&t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5},children:[t.jsx(n.Typography,{variant:"overline",sx:{fontSize:$=>$.typography.caption.fontSize||"0.6875rem",fontWeight:$=>$.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",textTransform:"uppercase"},children:"Active group levels"}),t.jsx(n.Tooltip,{title:"Removes all applied grouping and closes this panel",arrow:!0,children:t.jsx(n.Button,{onClick:h,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(n.Stack,{spacing:1.5,children:a.levels.map(($,Y)=>{const X=e.find(R=>R.name===$.column);return t.jsxs(n.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:R=>ye(R,"pressedButtonLight")}},children:[t.jsx(n.Chip,{label:`L${Y+1}`,size:"small",sx:{width:40,height:28,fontWeight:600,fontSize:"0.75rem",bgcolor:"primary.main",color:"background.paper",boxShadow:R=>`0 1px 2px 0 ${M(R.palette.primary.main,.3)}`}}),t.jsxs(n.Box,{sx:{flex:1},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:R=>R.typography.body2.fontWeight||500,fontSize:R=>R.typography.body2.fontSize||"0.875rem",color:"text.primary"},children:$.column}),t.jsx(n.Typography,{variant:"caption",sx:{fontSize:R=>R.typography.caption.fontSize||"0.75rem",color:"text.secondary"},children:X==null?void 0:X.type.toUpperCase()})]}),t.jsxs(n.Stack,{direction:"row",spacing:.5,children:[t.jsx(n.IconButton,{size:"small",onClick:()=>z(Y,"up"),disabled:Y===0,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(_.KeyboardArrowUp,{sx:{fontSize:18}})}),t.jsx(n.IconButton,{size:"small",onClick:()=>z(Y,"down"),disabled:Y===a.levels.length-1,sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover"},"&.Mui-disabled":{color:"divider"}},children:t.jsx(_.KeyboardArrowDown,{sx:{fontSize:18}})}),t.jsx(n.IconButton,{size:"small",onClick:()=>B(Y),sx:{color:"text.secondary","&:hover":{bgcolor:"action.hover",color:"primary.main"}},children:t.jsx(_.Edit,{sx:{fontSize:18}})}),t.jsx(n.IconButton,{size:"small",onClick:()=>f(Y),sx:{color:"text.secondary","&:hover":{bgcolor:R=>M(R.palette.error.main,.08),color:"error.main"}},children:t.jsx(_.Delete,{sx:{fontSize:18}})})]})]},Y)})})]})]})})}function _p({onExportAnyway:e,onSaveAndExport:r,onCancel:o}){return t.jsx(n.Box,{sx:{mb:2,mx:3,mt:2},children:t.jsxs(n.Alert,{severity:"warning",icon:t.jsx(_.Warning,{sx:{fontSize:20}}),action:t.jsx(n.IconButton,{size:"small",onClick:o,sx:{color:"warning.main"},children:t.jsx(_.Close,{sx:{fontSize:20}})}),sx:{alignItems:"flex-start"},children:[t.jsx(n.Typography,{variant:"subtitle2",sx:{fontWeight:i=>i.typography.h6.fontWeight||600,fontSize:i=>i.typography.h6.fontSize||"1rem",mb:.5},children:"You are exporting with unsaved view changes"}),t.jsx(n.Typography,{variant:"body2",sx:{mb:1.5},children:"Your current view has unsaved changes. Choose how to proceed:"}),t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.Button,{onClick:r,variant:"contained",color:"primary",startIcon:t.jsx(_.Save,{sx:{fontSize:14}}),size:"small",children:"Save View & Export"}),t.jsx(n.Button,{onClick:e,variant:"contained",color:"warning",startIcon:t.jsx(_.Download,{sx:{fontSize:i=>i.typography.body1.fontSize}}),size:"small",children:"Export Anyway"})]})]})})}const Ms=[{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 $p(e,r){if(r===null)return e.length;const o=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()>=o).length}function Ip(e,r){if(r===null)return[];const o=Date.now()-r;return e.filter(i=>new Date(i.timestamp).getTime()<o)}function Dp({auditHistory:e,onClose:r,onClearAuditHistory:o}){const i=vt(),s=i.palette,[a,l]=p.useState("1h"),[c,u]=p.useState(!1),[x,g]=p.useState("all"),[y,S]=p.useState(!0),[b,T]=p.useState(!1),[m,f]=p.useState(!1),B=[...e].sort((R,v)=>{const W=new Date(R.timestamp).getTime()-new Date(v.timestamp).getTime();return b?W:-W}),j=B.reduce((R,v)=>(R[v.feature]=(R[v.feature]??0)+1,R),{}),D=Object.keys(j).sort((R,v)=>(j[v]??0)-(j[R]??0)),z=x==="all"?B:B.filter(R=>R.feature===x),h=Ms.find(R=>R.key===a),I=$p(e,h.ms),A=()=>u(!0),$=()=>{o&&(o(Ip(e,h.ms)),u(!1))},Y=R=>{const v=zs(i,R.feature),{summary:W,detail:k}=jl(R);return t.jsxs(n.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:M(s.text.primary,.18)}},children:[t.jsx(n.Chip,{label:ti(R.feature),size:"small",sx:{height:20,fontSize:"0.5625rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",bgcolor:M(v,.1),color:v,border:`1px solid ${M(v,.22)}`,flexShrink:0,mt:.125,"& .MuiChip-label":{px:.75}}}),t.jsxs(n.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(n.Typography,{sx:{fontSize:"0.8125rem",fontWeight:500,color:"text.primary",lineHeight:1.45,wordBreak:"break-word"},children:W}),k&&t.jsx(n.Typography,{sx:{fontSize:"0.75rem",color:"text.secondary",mt:.25,lineHeight:1.4},children:k}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:.5,flexWrap:"wrap"},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(_.AccessTime,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(n.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:zl(R.timestamp)})]}),R.user&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.375},children:[t.jsx(_.Person,{sx:{fontSize:11,color:"text.disabled"}}),t.jsx(n.Typography,{sx:{fontSize:"0.6875rem",color:"text.disabled"},children:R.user})]})]})]})]},R.id)},X=m?D.map(R=>({feature:R,events:z.filter(v=>v.feature===R)})).filter(R=>R.events.length>0):[];return t.jsxs(t.Fragment,{children:[t.jsx(st,{open:!0,onClose:r,icon:t.jsx(_.AccessTime,{sx:{fontSize:20}}),title:"Audit History",subtitle:`· ${z.length} event${z.length!==1?"s":""} recorded`,helpContent:Wr.auditHistory,width:520,maxHeight:"min(700px, calc(100vh - 80px))",headerActions:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1,flexShrink:0},children:[o&&e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(n.Select,{value:a,onChange:R=>l(R.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:M(s.text.primary,.3)}},children:Ms.map(R=>t.jsx(n.MenuItem,{value:R.key,sx:{fontSize:"0.8125rem"},children:R.label},R.key))}),t.jsx(n.Button,{size:"small",variant:"outlined",color:"error",startIcon:t.jsx(_.DeleteSweepOutlined,{sx:{fontSize:14}}),onClick:A,sx:{fontSize:"0.75rem",borderRadius:"7px",px:1.25,height:30,whiteSpace:"nowrap",borderColor:M(s.error.main,.5),"&:hover":{bgcolor:M(s.error.main,.06),borderColor:"error.main"}},children:"Clear Logs"})]}),D.length>1&&t.jsx(n.IconButton,{onClick:()=>S(R=>!R),size:"small",title:y?"Hide category filter":"Show category filter",sx:{color:y?"primary.main":"text.secondary",bgcolor:y?M(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:y?M(s.primary.main,.16):"action.hover"}},children:t.jsx(_.FilterAltOutlined,{sx:{fontSize:17}})}),t.jsx(n.IconButton,{onClick:()=>T(R=>!R),size:"small",title:b?"Sorted oldest first":"Sorted newest first",sx:{color:b?"primary.main":"text.secondary",bgcolor:b?M(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:b?M(s.primary.main,.16):"action.hover"}},children:t.jsx(_.SortOutlined,{sx:{fontSize:17,transform:b?"scaleY(-1)":"none"}})}),t.jsx(n.IconButton,{onClick:()=>f(R=>!R),size:"small",title:m?"Ungroup events":"Group by category",sx:{color:m?"primary.main":"text.secondary",bgcolor:m?M(s.primary.main,.1):"transparent",borderRadius:"7px","&:hover":{bgcolor:m?M(s.primary.main,.16):"action.hover"}},children:t.jsx(_.WorkspacesOutlined,{sx:{fontSize:17}})})]}),headerExtra:D.length>1&&y&&t.jsxs(n.Tabs,{value:x,onChange:(R,v)=>g(v),variant:"scrollable",scrollButtons:"auto",sx:{minHeight:36,borderBottom:"1px solid",borderColor:"divider","& .MuiTabs-indicator":{height:2}},children:[t.jsx(n.Tab,{value:"all",label:`All (${B.length})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}}),D.map(R=>t.jsx(n.Tab,{value:R,label:`${ti(R)} (${j[R]})`,sx:{minHeight:36,py:.5,fontSize:"0.75rem",textTransform:"none",minWidth:"auto",px:1.25}},R))]}),children:z.length===0?t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8,gap:1,textAlign:"center"},children:[t.jsx(_.AccessTime,{sx:{fontSize:44,color:"text.disabled",opacity:.5}}),t.jsx(n.Typography,{sx:{fontSize:R=>R.typography.body1.fontSize||"0.9375rem",color:"text.secondary",fontWeight:R=>R.typography.body2.fontWeight||500},children:B.length===0?"No audit events yet":"No events in this category"}),t.jsx(n.Typography,{sx:{fontSize:R=>R.typography.body2.fontSize||"0.8125rem",color:"text.disabled"},children:B.length===0?"Changes to this report will appear here":"Try a different category tab"})]}):m?t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1.5},children:X.map(({feature:R,events:v})=>t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.75,px:.25},children:[t.jsx(n.Box,{sx:{width:6,height:6,borderRadius:"50%",bgcolor:zs(i,R)}}),t.jsxs(n.Typography,{sx:{fontSize:"0.6875rem",fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"text.secondary"},children:[ti(R)," (",v.length,")"]})]}),t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:v.map(Y)})]},R))}):t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:.75},children:z.map(Y)})}),t.jsxs(n.Dialog,{open:c,onClose:()=>u(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:Po(i),...Rt(i).paper}},children:[t.jsxs(n.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(n.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:M(s.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(_.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(n.Typography,{sx:{fontSize:R=>R.typography.body1.fontSize||"0.9375rem",fontWeight:R=>R.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Clear Audit Logs"}),t.jsxs(n.Typography,{sx:{fontSize:R=>R.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["You are about to permanently remove"," ",t.jsxs(n.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:[I," audit record",I!==1?"s":""]})," ",h.key==="all"?"from all time":`from the ${h.label.toLowerCase()}`,". This action cannot be undone."]})]}),t.jsx(n.Divider,{}),t.jsxs(n.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(n.Button,{onClick:()=>u(!1),variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:"7px","&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsxs(n.Button,{onClick:$,variant:"contained",color:"error",startIcon:t.jsx(_.DeleteSweepOutlined,{sx:{fontSize:14}}),sx:{fontSize:"0.8125rem",borderRadius:"7px",px:2},children:["Clear ",I," Record",I!==1?"s":""]})]})]})]})}function Op({onSave:e,onClose:r}){const[o,i]=p.useState(""),[s,a]=p.useState(""),[l,c]=p.useState(""),[u,x]=p.useState([]),[g,y]=p.useState(""),[S,b]=p.useState(""),T=h=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h),m=()=>{const h=l.trim();if(h){if(!T(h)){b("Please enter a valid email address");return}if(u.includes(h)){b("This email is already added");return}x([...u,h]),c(""),b("")}},f=h=>{x(u.filter(I=>I!==h))},B=h=>{h.key==="Enter"&&(h.preventDefault(),m())},j=()=>{if(!o.trim()){y("Preset name is required");return}e(o.trim(),s.trim(),u.length>0?u:void 0)},D=h=>{i(h),g&&y("")},z=h=>{c(h),S&&b("")};return t.jsx(st,{open:!0,onClose:r,icon:t.jsx(_.Share,{sx:{fontSize:20}}),title:"Create shareable preset",width:540,maxHeight:"min(480px, calc(100vh - 280px))",footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{onClick:r,variant:"text",sx:{fontSize:"0.875rem",color:"text.secondary",px:3,py:1,minHeight:36,borderRadius:h=>`${h.shape.borderRadius}px`,transition:"all 0.2s ease","&:hover":{bgcolor:"divider",color:"text.primary"}},children:"Cancel"}),t.jsx(n.Button,{onClick:j,variant:"contained",startIcon:t.jsx(_.Share,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"background.paper",px:3,py:1,minHeight:36,borderRadius:h=>`${h.shape.borderRadius}px`,boxShadow:h=>ye(h,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:h=>ye(h,"hoverButton")},"&:active":{boxShadow:h=>ye(h,"pressedButton"),transform:"translateY(1px)"}},children:"Create & share"})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[t.jsx(n.Alert,{severity:"info",icon:t.jsx(_.Info,{sx:{fontSize:20}}),sx:{borderRadius:"8px",border:h=>`1px solid ${M(h.palette.primary.main,.3)}`,bgcolor:h=>sr(h),"& .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(n.Typography,{variant:"body2",sx:{fontSize:h=>h.typography.body2.fontSize||"0.875rem",color:"text.secondary",lineHeight:1.6},children:"Save the current report configuration and generate a shareable link that others can use to view the same filters, sorting, and column layout."}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontSize:h=>h.typography.caption.fontSize||"0.6875rem",fontWeight:h=>h.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Preset name *"}),t.jsx(n.TextField,{required:!0,value:o,onChange:h=>D(h.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(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontSize:h=>h.typography.caption.fontSize||"0.6875rem",fontWeight:h=>h.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Description (optional)"}),t.jsx(n.TextField,{value:s,onChange:h=>a(h.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(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontSize:h=>h.typography.caption.fontSize||"0.6875rem",fontWeight:h=>h.typography.caption.fontWeight||600,color:"text.secondary",letterSpacing:"0.1em",mb:1,display:"block",textTransform:"uppercase"},children:"Share with (optional)"}),t.jsxs(n.Box,{sx:{display:"flex",gap:1,alignItems:"flex-start"},children:[t.jsx(n.TextField,{value:l,onChange:h=>z(h.target.value),onKeyPress:B,placeholder:"Enter email address",error:!!S,helperText:S,fullWidth:!0,size:"small",InputProps:{startAdornment:t.jsx(_.Email,{sx:{fontSize:18,color:"text.secondary",mr:1}})},sx:{"& .MuiOutlinedInput-root":{fontSize:"0.875rem",borderRadius:"4px",bgcolor:"background.paper","& fieldset":{borderColor:"divider"},"&:hover fieldset":{borderColor:"primary.main"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"2px"},"&.Mui-error fieldset":{borderColor:"error.main"}},"& .MuiInputBase-input":{py:1.25,color:"text.primary"},"& .MuiFormHelperText-root":{fontSize:"0.75rem",color:"error.main",mt:.75}}}),t.jsx(n.Button,{onClick:m,variant:"outlined",startIcon:t.jsx(_.Add,{sx:{fontSize:18}}),sx:{fontSize:"0.875rem",color:"primary.main",borderColor:"divider",px:2,py:1.25,minHeight:40,borderRadius:h=>`${h.shape.borderRadius}px`,flexShrink:0,"&:hover":{borderColor:"primary.main",bgcolor:"action.hover"}},children:"Add"})]}),u.length>0&&t.jsx(n.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:1.5},children:u.map(h=>t.jsx(n.Chip,{label:h,onDelete:()=>f(h),deleteIcon:t.jsx(_.Delete,{sx:{fontSize:16}}),sx:{bgcolor:I=>sr(I),color:"primary.main",fontSize:"0.8125rem",height:28,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.dark"}}}},h))}),t.jsx(n.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"})]})]})})}function Mp({presetName:e,onClear:r}){return t.jsx(n.Chip,{icon:t.jsx(_.Link,{sx:{fontSize:14}}),label:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:["Preset:"," ",t.jsx(n.Box,{component:"span",sx:{fontWeight:600},children:e})]}),onDelete:r,deleteIcon:t.jsx(n.IconButton,{size:"small",title:"Exit preset view",sx:{p:0},children:t.jsx(_.Close,{sx:{fontSize:14}})}),sx:{bgcolor:o=>M(o.palette.primary.main,.12),borderColor:"primary.light",border:1,fontSize:"body2.fontSize",fontWeight:500,"& .MuiChip-deleteIcon":{color:"primary.main","&:hover":{color:"primary.main"}}}})}function Ap({presets:e,reportId:r,onOpenPreset:o,onDeletePreset:i,onClose:s}){const a=l=>new Date(l).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});return t.jsx(st,{open:!0,onClose:s,icon:t.jsx(_.Share,{sx:{fontSize:20}}),title:"Manage Presets",subtitle:`· ${e.length} saved ${e.length===1?"preset":"presets"}`,width:680,maxHeight:"min(720px, calc(100vh - 200px))",footer:t.jsx(n.Button,{onClick:s,variant:"contained",sx:{fontSize:"0.875rem",bgcolor:"primary.main",color:"primary.contrastText",px:3,py:.875,minHeight:36,borderRadius:l=>`${l.shape.borderRadius}px`,boxShadow:l=>ye(l,"restButton"),transition:"all 0.2s ease","&:hover":{bgcolor:"primary.dark",boxShadow:l=>ye(l,"hoverButton")},"&:active":{boxShadow:l=>ye(l,"pressedButton"),transform:"translateY(1px)"}},children:"Close"}),children:e.length===0?t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",py:8},children:[t.jsx(_.Share,{sx:{fontSize:48,color:"divider",mb:2}}),t.jsx(n.Typography,{variant:"body1",sx:{fontSize:l=>l.typography.body2.fontSize||"0.875rem",color:"text.secondary",textAlign:"center"},children:"No presets created yet"}),t.jsx(n.Typography,{variant:"body2",sx:{fontSize:l=>l.typography.body2.fontSize||"0.8125rem",color:"text.disabled",textAlign:"center",mt:.5},children:"Create a preset to share report configurations"})]}):t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:e.map(l=>t.jsxs(n.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=>ye(c,"restButtonLight")}},children:[t.jsx(n.Box,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",mb:1.5},children:t.jsxs(n.Box,{sx:{flex:1,minWidth:0},children:[t.jsx(n.Typography,{variant:"h6",sx:{fontSize:c=>c.typography.body1.fontSize||"0.9375rem",fontWeight:c=>c.typography.h6.fontWeight||500,color:"text.primary",mb:.5},children:l.name}),l.description&&t.jsx(n.Typography,{variant:"body2",sx:{fontSize:c=>c.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.5},children:l.description})]})}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:2},children:[t.jsx(n.Chip,{label:`Created ${a(l.createdAt)}`,size:"small",sx:{height:22,fontSize:"0.75rem",bgcolor:"action.hover",color:"text.secondary","& .MuiChip-label":{px:1}}}),t.jsx(n.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(n.Divider,{sx:{my:1.5,borderColor:"divider"}}),t.jsx(n.Box,{sx:{display:"flex",gap:1},children:t.jsx(n.Button,{onClick:()=>i(l.id,l.name),variant:"outlined",size:"small",startIcon:t.jsx(_.Delete,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",color:"error.main",borderColor:"divider",px:1.5,py:.75,borderRadius:c=>`${c.shape.borderRadius}px`,"&:hover":{borderColor:"error.main",bgcolor:c=>M(c.palette.error.main,.04)}},children:"Delete"})})]},l.id))})})}const Sa={maxFileSizeBytes:2*1024*1024,maxFileSizeHardBytes:3*1024*1024,maxRows:1e4,maxRowsHard:5e4,maxImageColumns:5},Rp=[/^https?:\/\/.*\.(jpg|jpeg|png|gif|webp|svg|avif|bmp)/i,/^data:image\//i,/^\/.*\.(jpg|jpeg|png|gif|webp|svg)/i],Wp=[/image/i,/photo/i,/avatar/i,/thumbnail/i,/picture/i,/logo/i,/icon/i,/banner/i];function Pp(e,r){const o=[];for(const i of e){if(i.type!=="string")continue;const s=Wp.some(c=>c.test(i.name));let a=!1;const l=r.slice(0,10).map(c=>c[i.name]).filter(c=>typeof c=="string"&&c.length>0);l.length>0&&(a=l.filter(u=>Rp.some(x=>x.test(u))).length/l.length>.6),(s||a)&&o.push(i.name)}return o}function Dn(e,r){if(e.length===0||r.length===0)return 0;const o=e.slice(0,Math.min(50,e.length)),s=r.map(l=>{const c=o.map(x=>String(x[l]??"")).filter(x=>x.length>0);if(c.length===0)return 5;const u=c.reduce((x,g)=>x+g.length,0);return Math.ceil(u/c.length)+1}).reduce((l,c)=>l+c,0)+1;return r.reduce((l,c)=>l+c.length+1,0)+s*e.length}function Lp(e,r){const o=Dn(e,r);return Math.ceil(o*3.5)}function Fp(e,r){const o=Dn(e,r);return Math.ceil(o*.7)}function Np(e,r){const o=Dn(e,r);return Math.ceil(o*2)}function Vp(e,r,o){switch(e){case"csv":return Dn(r,o);case"excel":return Fp(r,o);case"json":return Lp(r,o);case"pdf":return Np(r,o)}}function As(e,r){return Math.ceil(e/r)}function Hp(e,r,o,i,s=Sa){const a=[],l=Vp(e,r,o),c=r.length;if(c>s.maxRowsHard){const g=As(c,s.maxRows);a.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=As(c,s.maxRows);a.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(l>s.maxFileSizeHardBytes?a.push({type:"file_size",severity:"error",message:`File size blocked: estimated ${_o(l)} exceeds the ${_o(s.maxFileSizeHardBytes)} limit`,detail:"Reduce the number of rows or columns and try again. Applying filters before exporting is the most effective way to reduce file size.",value:l,limit:s.maxFileSizeHardBytes}):l>s.maxFileSizeBytes&&a.push({type:"file_size",severity:"warning",message:`Large file: estimated ${_o(l)}`,detail:`This exceeds the recommended ${_o(s.maxFileSizeBytes)} size. The download will still proceed but may be slow on some connections.`,value:l,limit:s.maxFileSizeBytes}),e!=="excel"){const g=Pp(i.filter(y=>o.includes(y.name)),r);if(g.length>0){const y=g.length>s.maxImageColumns;a.push({type:"image_columns",severity:y?"error":"warning",message:`Image column${g.length>1?"s":""} detected: ${g.map(S=>`"${S.replace(/_/g," ")}"`).join(", ")}`,detail:y?`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=a.some(g=>g.severity==="error"),x=a.some(g=>g.severity==="warning");return{violations:a,hasBlockingViolation:u,hasWarning:x,estimatedBytes:l}}function _o(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Gp({violation:e}){const o=vt().palette,i=e.severity==="error",s=i?o.error.main:o.warning.main,a=M(i?o.error.main:o.warning.main,.06),l=i?M(o.error.main,.25):M(o.warning.main,.3),c=i?_.ErrorOutline:_.WarningAmberOutlined;return t.jsxs(n.Box,{sx:{display:"flex",gap:1.25,p:1.5,borderRadius:"10px",bgcolor:a,border:"1px solid",borderColor:l},children:[t.jsx(c,{sx:{fontSize:17,color:s,flexShrink:0,mt:.125}}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{sx:{fontSize:u=>u.typography.body2.fontSize||"0.8125rem",fontWeight:u=>u.typography.body2.fontWeight||600,color:i?"error.main":"warning.dark",lineHeight:1.4},children:e.message}),e.detail&&t.jsx(n.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",mt:.375,lineHeight:1.5},children:e.detail}),e.suggestedBatches&&e.suggestedBatches>1&&t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mt:.75},children:[t.jsx(_.SplitscreenOutlined,{sx:{fontSize:14,color:"text.secondary"}}),t.jsxs(n.Typography,{sx:{fontSize:u=>u.typography.caption.fontSize||"0.75rem",color:"text.secondary",fontWeight:u=>u.typography.body2.fontWeight||500},children:["Suggestion: split into ",e.suggestedBatches," exports"]})]})]})]})}function Up({format:e}){const r=vt(),o={csv:{color:r.palette.primary.main,bg:r.palette.primary.main,label:"CSV"},excel:{color:r.palette.success.main,bg:r.palette.success.main,label:"XLSX"},json:{color:r.palette.text.secondary,bg:r.palette.text.secondary,label:"JSON"},pdf:{color:r.palette.error.main,bg:r.palette.error.main,label:"PDF"}}[e];return t.jsxs(n.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:o.color,strokeWidth:"2.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M24 2V13H36",fill:M(r.palette.text.primary,.05),stroke:o.color,strokeWidth:"2.5",strokeLinejoin:"round"})]}),t.jsx(n.Box,{sx:{position:"absolute",bottom:8,left:3,right:3,bgcolor:o.bg,color:r.palette.primary.contrastText,fontSize:"0.625rem",fontWeight:800,py:.25,borderRadius:"3px",textAlign:"center",letterSpacing:"0.05em"},children:o.label})]})}function Rs({checked:e}){const r=vt();return t.jsx(n.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(n.Box,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:`var(--urm-export-card-selected-border, ${r.palette.primary.main})`}})})}function Yp({totalRows:e,visibleRows:r,hasGrouping:o,visibleColumnsCount:i,totalColumnsCount:s,schema:a,sampleRows:l=[],allRows:c=[],processedRows:u=[],initialFormat:x,initialScope:g="visible",initialColumnScope:y="visible",classTokens:S={},onExport:b,onClose:T}){const m=vt(),f=m.palette,B=Rr(),j=p.useMemo(()=>{var le,Z,de,ae,F;const Q=((de=(Z=(le=m.components)==null?void 0:le.MuiCard)==null?void 0:Z.styleOverrides)==null?void 0:de.root)||{},ee=Q.border&&Q.border!=="none"?Q.border:(ae=m.tokens)!=null&&ae.cardBodyBorder&&m.tokens.cardBodyBorder!=="none"?m.tokens.cardBodyBorder:f.divider,H=Q.borderRadius!==void 0?typeof Q.borderRadius=="number"?`${Q.borderRadius}px`:Q.borderRadius:`${m.shape.borderRadius}px`,te=Q.boxShadow&&Q.boxShadow!=="none"?Q.boxShadow:((F=m.tokens)==null?void 0:F.cardBodyShadow)||ye(m,"menu"),ue=it(m);return{sectionBorder:`var(--urm-export-section-border, ${ee})`,sectionTitleColor:`var(--urm-export-section-title-color, ${f.text.primary})`,sectionTitleBg:`var(--urm-export-section-title-bg, ${f.background.paper})`,cardBg:`var(--urm-export-card-bg, ${f.background.paper})`,cardBorder:`var(--urm-export-card-border, ${ee})`,cardRadius:H,cardShadow:te,cardHoverBg:`var(--urm-export-card-hover-bg, ${f.mode==="dark"?M(f.common.white,.08):M(f.common.black,.04)})`,cardSelectedBg:`var(--urm-export-card-selected-bg, ${M(ue.main,f.mode==="dark"?.16:.08)})`,cardSelectedBorder:`var(--urm-export-card-selected-border, ${ue.main})`,cardSelectedColor:`var(--urm-export-card-selected-color, ${f.mode==="dark"?f.primary.light:f.primary.main})`,primaryBtnBg:`var(--urm-export-primary-btn-bg, ${f.primary.main})`,primaryBtnHoverBg:`var(--urm-export-primary-btn-hover-bg, ${f.primary.dark})`,primaryBtnColor:`var(--urm-export-primary-btn-color, ${f.primary.contrastText})`,sectionPadding:`var(--urm-export-section-padding, ${m.spacing(2)})`,optionGap:`var(--urm-export-option-gap, ${m.spacing(1.5)})`}},[f,m]),D=B.export.allowedFormats.filter(Q=>Q!=="csv"),z=x||(D.includes("pdf")?"pdf":D[0]||"excel"),[h,I]=p.useState(z),[A,$]=p.useState(g),[Y,X]=p.useState(y),R=A==="visible"?r:e,v=Y==="visible"?i:s,W=p.useMemo(()=>A==="visible"?u.length>0?u:new Array(r):c.length>0?c:new Array(e),[A,r,e,u,c]),k=p.useMemo(()=>Y==="all"?a.map(Q=>Q.name):a.map(Q=>Q.name).slice(0,i),[Y,a,i]),q=p.useMemo(()=>Hp(h,W,k,a,Sa),[h,W,k,a]),re=()=>{q.hasBlockingViolation||(b({format:h,scope:A,columnScope:Y}),T())},d={csv:"CSV",excel:"Excel (.xlsx)",json:"JSON",pdf:"PDF"};return t.jsx(st,{open:!0,onClose:T,icon:t.jsx(_.Download,{sx:{fontSize:20}}),title:"Export Report",helpContent:Wr.export,width:540,maxHeight:"min(760px, calc(100vh - 48px))",classNames:{backdrop:`urm-export-backdrop ${S.modalBackdrop||""}`,paper:`urm-export-paper ${S.modalPaper||""}`,header:`urm-export-header ${S.modalHeader||""}`,title:`urm-export-title ${S.modalTitle||""}`,closeButton:`urm-export-close ${S.modalCloseButton||""}`,body:`urm-export-content ${S.modalContent||""}`,footer:`urm-export-footer ${S.footer||""}`},footer:t.jsxs(t.Fragment,{children:[q.hasBlockingViolation&&t.jsxs(n.Box,{sx:{flex:1,display:"flex",alignItems:"center",gap:.75},children:[t.jsx(_.ErrorOutline,{sx:{fontSize:15,color:"error.main"}}),t.jsx(n.Typography,{sx:{fontSize:Q=>Q.typography.caption.fontSize||"0.75rem",color:"error.main",fontWeight:Q=>Q.typography.body2.fontWeight||500},children:"Reduce rows or columns to enable download"})]}),t.jsx(n.Button,{onClick:T,variant:"outlined",className:`urm-export-cancel-btn ${S.cancelButton||""}`,sx:{fontSize:"0.875rem",fontWeight:600,color:f.text.primary,borderColor:j.cardBorder,px:3,py:1,borderRadius:"8px",textTransform:"none","&:hover":{bgcolor:j.cardHoverBg,borderColor:M(f.text.primary,.3)}},children:"Cancel"}),t.jsxs(n.Button,{onClick:re,disabled:q.hasBlockingViolation,variant:"contained",className:`urm-export-download-btn ${S.downloadButton||""}`,startIcon:t.jsx(_.Download,{sx:{fontSize:Q=>Q.typography.body1.fontSize}}),sx:{fontSize:"0.875rem",fontWeight:600,bgcolor:j.primaryBtnBg,color:j.primaryBtnColor,px:3,py:1,borderRadius:"8px",textTransform:"none",boxShadow:`0 2px 6px ${M(f.primary.main,.25)}`,"&:hover":{bgcolor:j.primaryBtnHoverBg},"&.Mui-disabled":{bgcolor:M(f.primary.main,.4),color:j.primaryBtnColor}},children:["Download ",d[h]]})]}),children:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:j.optionGap},children:[q.violations.length>0&&t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1},children:q.violations.map((Q,ee)=>t.jsx(Gp,{violation:Q},ee))}),t.jsxs(n.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${j.sectionBorder}`,borderRadius:"12px",p:j.sectionPadding,pt:2.25,bgcolor:j.sectionTitleBg,mt:1.5},children:[t.jsx(n.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:j.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:j.sectionTitleColor,lineHeight:1,zIndex:1},children:"Choose File Format"}),t.jsx(n.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:j.optionGap},children:[{id:"excel",title:"Excel (.xlsx)",info:"Native Excel format with formatting support",allowed:B.export.allowedFormats.includes("excel")},{id:"json",title:"JSON",info:"Structured data with metadata and filters",allowed:B.export.allowedFormats.includes("json")},{id:"pdf",title:"PDF",info:"Print-ready PDF document",allowed:B.export.allowedFormats.includes("pdf")}].filter(Q=>Q.allowed).map(Q=>{const ee=h===Q.id;return t.jsxs(n.Box,{onClick:()=>I(Q.id),className:`urm-export-format-card ${ee?S.formatCardSelected||"":S.formatCard||""}`,sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",p:1.75,borderRadius:j.cardRadius,border:ee?`2px solid ${j.cardSelectedBorder}`:`1px solid ${j.cardBorder}`,boxShadow:ee?void 0:j.cardShadow,bgcolor:ee?j.cardSelectedBg:j.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?j.cardSelectedBorder:M(f.text.primary,.25),bgcolor:ee?j.cardSelectedBg:j.cardHoverBg}},children:[ee&&t.jsx(n.Box,{sx:{position:"absolute",top:8,right:8,width:20,height:20,borderRadius:"50%",bgcolor:j.cardSelectedBorder,color:f.primary.contrastText,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:`0 2px 4px ${M(f.primary.main,.3)}`},children:t.jsx(_.Check,{sx:{fontSize:13,strokeWidth:2}})}),t.jsx(Up,{format:Q.id}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5},children:[t.jsx(n.Typography,{sx:{fontSize:"0.875rem",fontWeight:700,color:ee?j.cardSelectedColor:f.text.primary},children:Q.title}),t.jsx(n.Tooltip,{title:Q.info,arrow:!0,placement:"top",children:t.jsx(n.Box,{component:"span",onClick:H=>H.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:f.text.secondary,"&:hover":{color:f.text.primary}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:13}})})})]})]},Q.id)})})]}),t.jsxs(n.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${j.sectionBorder}`,borderRadius:"12px",p:j.sectionPadding,pt:2.25,bgcolor:j.sectionTitleBg,mt:1.5},children:[t.jsx(n.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:j.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:j.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Rows Range"}),t.jsx(n.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:j.optionGap},children:[{value:"visible",label:"Visible rows",icon:t.jsx(_.VisibilityOutlined,{sx:{fontSize:20}}),info:`Export ${r.toLocaleString()} rows (filtered and searched)`},{value:"all",label:"All rows",icon:t.jsx(_.TableChartOutlined,{sx:{fontSize:20}}),info:`Export ${e.toLocaleString()} rows (complete original dataset)`}].map(Q=>{const ee=A===Q.value;return t.jsxs(n.Box,{onClick:()=>$(Q.value),className:`urm-export-row-card ${ee?S.rowCardSelected||"":S.rowCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:j.cardRadius,border:ee?`2px solid ${j.cardSelectedBorder}`:`1px solid ${j.cardBorder}`,boxShadow:ee?void 0:j.cardShadow,bgcolor:ee?j.cardSelectedBg:j.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?j.cardSelectedBorder:M(f.text.primary,.25),bgcolor:ee?j.cardSelectedBg:j.cardHoverBg}},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(Rs,{checked:ee}),t.jsx(n.Box,{sx:{color:ee?j.cardSelectedColor:f.text.secondary,display:"flex"},children:Q.icon}),t.jsx(n.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:ee?j.cardSelectedColor:f.text.primary},children:Q.label})]}),t.jsx(n.Tooltip,{title:Q.info,arrow:!0,placement:"top",children:t.jsx(n.Box,{component:"span",onClick:H=>H.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:f.text.secondary,"&:hover":{color:f.text.primary}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:16}})})})]},Q.value)})})]}),t.jsxs(n.Box,{className:`urm-export-section ${S.sectionContainer||""}`,sx:{position:"relative",border:`1.5px solid ${j.sectionBorder}`,borderRadius:"12px",p:j.sectionPadding,pt:2.25,bgcolor:j.sectionTitleBg,mt:1.5},children:[t.jsx(n.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:j.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:j.sectionTitleColor,lineHeight:1,zIndex:1},children:"Select Columns Range"}),t.jsx(n.Box,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:j.optionGap},children:[{value:"visible",label:"Visible columns",icon:t.jsx(_.SwapVertOutlined,{sx:{fontSize:20}}),info:`Export ${i} visible column${i!==1?"s":""}`},{value:"all",label:"All columns",icon:t.jsx(_.TableChartOutlined,{sx:{fontSize:20}}),info:`Export all ${s} columns (including hidden)`}].map(Q=>{const ee=Y===Q.value;return t.jsxs(n.Box,{onClick:()=>X(Q.value),className:`urm-export-column-card ${ee?S.columnCardSelected||"":S.columnCard||""}`,sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:1.5,borderRadius:j.cardRadius,border:ee?`2px solid ${j.cardSelectedBorder}`:`1px solid ${j.cardBorder}`,boxShadow:ee?void 0:j.cardShadow,bgcolor:ee?j.cardSelectedBg:j.cardBg,cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:ee?j.cardSelectedBorder:M(f.text.primary,.25),bgcolor:ee?j.cardSelectedBg:j.cardHoverBg}},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[t.jsx(Rs,{checked:ee}),t.jsx(n.Box,{sx:{color:ee?j.cardSelectedColor:f.text.secondary,display:"flex"},children:Q.icon}),t.jsx(n.Typography,{sx:{fontSize:"0.875rem",fontWeight:600,color:ee?j.cardSelectedColor:f.text.primary},children:Q.label})]}),t.jsx(n.Tooltip,{title:Q.info,arrow:!0,placement:"top",children:t.jsx(n.Box,{component:"span",onClick:H=>H.stopPropagation(),sx:{display:"inline-flex",cursor:"help",color:f.text.secondary,"&:hover":{color:f.text.primary}},children:t.jsx(_.InfoOutlined,{sx:{fontSize:16}})})})]},Q.value)})})]}),t.jsxs(n.Box,{className:`urm-export-summary ${S.summaryContainer||""}`,sx:{position:"relative",border:`1.5px solid ${j.sectionBorder}`,borderRadius:"12px",p:j.sectionPadding,pt:2.25,bgcolor:j.sectionTitleBg,mt:1.5},children:[t.jsx(n.Typography,{className:`urm-export-section-title ${S.sectionTitle||""}`,sx:{position:"absolute",top:-11,left:14,bgcolor:j.sectionTitleBg,px:.75,fontSize:"0.8125rem",fontWeight:600,color:j.sectionTitleColor,lineHeight:1,zIndex:1},children:"Export Summary"}),t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:[{icon:t.jsx(_.InsertDriveFileOutlined,{sx:{fontSize:18,color:f.text.secondary}}),label:"Format",value:d[h]},{icon:t.jsx(_.FormatListNumberedOutlined,{sx:{fontSize:18,color:f.text.secondary}}),label:"Rows to Export",value:R.toLocaleString()},{icon:t.jsx(_.SwapVertOutlined,{sx:{fontSize:18,color:f.text.secondary}}),label:"Columns to Export",value:String(v)},{icon:t.jsx(_.InsertDriveFileOutlined,{sx:{fontSize:18,color:f.text.secondary}}),label:"Estimated File Size",value:`~${_o(q.estimatedBytes)}`,highlight:q.hasBlockingViolation?"error.main":q.hasWarning?"warning.main":void 0}].map(({icon:Q,label:ee,value:H,highlight:te})=>t.jsxs(n.Box,{className:`urm-export-summary-row ${S.summaryRow||""}`,sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[Q,t.jsx(n.Typography,{className:`urm-export-summary-label ${S.summaryLabel||""}`,sx:{fontSize:"0.8125rem",color:f.text.secondary,fontWeight:500},children:ee})]}),t.jsx(n.Typography,{className:`urm-export-summary-value ${S.summaryValue||""}`,sx:{fontWeight:700,fontSize:"0.8125rem",color:te??f.text.primary},children:H})]},ee))})]})]})})}function qp({warning:e,onDismiss:r}){return t.jsx(n.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(n.Alert,{severity:"warning",icon:t.jsx(_.Warning,{sx:{fontSize:20}}),action:t.jsx(n.IconButton,{size:"small",onClick:r,sx:{color:"warning.main"},children:t.jsx(_.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:"warning.main",boxShadow:3},children:[t.jsx(n.AlertTitle,{sx:{fontWeight:600},children:"Feature Limit Reached"}),t.jsx(n.Box,{sx:{fontSize:"body2.fontSize",mb:1},children:e.message}),t.jsxs(n.Box,{sx:{fontSize:"caption.fontSize",opacity:.9},children:["Please remove some"," ",e.type==="filter"?"filters":e.type==="sort"?"sort levels":"grouping levels"," ","before adding more."]})]})})}function Jp({error:e,onDismiss:r,autoDismiss:o=!0,autoDismissDelay:i=3e4}){p.useEffect(()=>{if(o){const c=setTimeout(()=>{r()},i);return()=>clearTimeout(c)}},[o,i,r]);const a=(()=>{switch(e.type){case"system":return{severity:"error",icon:t.jsx(_.Cancel,{sx:{fontSize:20}})};case"processing":return{severity:"warning",icon:t.jsx(_.Warning,{sx:{fontSize:20}})};case"ui":default:return{severity:"info",icon:t.jsx(_.InfoOutlined,{sx:{fontSize:20}})}}})(),l=Wl(e);return t.jsx(n.Box,{sx:{position:"fixed",bottom:16,right:16,zIndex:50,maxWidth:448},children:t.jsxs(n.Alert,{severity:a.severity,icon:a.icon,action:t.jsx(n.IconButton,{size:"small",onClick:r,sx:{color:`${a.severity}.main`},children:t.jsx(_.Close,{sx:{fontSize:16}})}),sx:{borderLeft:4,borderColor:`${a.severity}.main`,boxShadow:3},children:[t.jsxs(n.AlertTitle,{sx:{fontWeight:c=>c.typography.h6.fontWeight||600,fontSize:c=>c.typography.subtitle2.fontSize||"0.875rem"},children:[e.context.charAt(0).toUpperCase()+e.context.slice(1)," Error"]}),t.jsx(n.Box,{sx:{fontSize:"body2.fontSize"},children:l}),e.details&&process.env.NODE_ENV==="development"&&t.jsx(n.Box,{component:"pre",sx:{fontSize:"caption.fontSize",mt:1,fontFamily:"monospace",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:JSON.stringify(e.details,null,2)})]})})}class Kp extends p.Component{constructor(o){super(o);Ri(this,"handleReset",()=>{this.setState({hasError:!1,error:null})});this.state={hasError:!1,error:null}}static getDerivedStateFromError(o){return{hasError:!0,error:o}}componentDidCatch(o,i){qt.error("urm:error-boundary","Caught unhandled component error",o,i),this.props.onError&&this.props.onError(o,i)}render(){var o,i;return this.state.hasError?this.props.fallback?this.props.fallback:t.jsx(n.Paper,{sx:{bgcolor:s=>M(s.palette.error.main,.12),border:1,borderColor:"error.light",borderRadius:2,p:3,m:2},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t.jsx(_.Warning,{color:"error",sx:{fontSize:24,flexShrink:0}}),t.jsxs(n.Box,{sx:{flex:1},children:[t.jsx(n.Typography,{variant:"h4",sx:{color:"error.main",fontWeight:s=>s.typography.h4.fontWeight||600,fontSize:s=>s.typography.h4.fontSize||"1.25rem"},children:this.props.context?`${this.props.context} Error`:"Something went wrong"}),t.jsx(n.Typography,{variant:"body2",sx:{color:"error.main",mt:1},children:((o=this.state.error)==null?void 0:o.message)||"An unexpected error occurred"}),process.env.NODE_ENV==="development"&&t.jsx(n.Box,{component:"pre",sx:{mt:1.5,fontSize:"caption.fontSize",color:"error.main",bgcolor:s=>M(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(n.Button,{onClick:this.handleReset,variant:"contained",color:"error",startIcon:t.jsx(_.Refresh,{sx:{fontSize:16}}),sx:{mt:2},children:"Try Again"})]})]})}):this.props.children}}function Xp({feature:e}){const[r,o]=p.useState(!0);return p.useEffect(()=>{const i=setTimeout(()=>o(!1),5e3);return()=>clearTimeout(i)},[]),t.jsx(n.Collapse,{in:r,unmountOnExit:!0,children:t.jsxs(n.Alert,{severity:"warning",sx:{m:1},icon:t.jsx(_.Warning,{sx:{fontSize:20}}),action:t.jsx(n.IconButton,{size:"small",onClick:()=>o(!1),"aria-label":"dismiss",sx:{color:"warning.dark"},children:t.jsx(_.Close,{sx:{fontSize:16}})}),children:[t.jsxs(n.AlertTitle,{children:[e," temporarily unavailable"]}),"Other features continue to work normally"]})})}function sn({children:e,feature:r,onError:o}){return t.jsx(Kp,{context:r,onError:i=>{o&&o(i)},fallback:t.jsx(Xp,{feature:r}),children:e})}const Qp=[{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"}],Zp=[{value:"csv",label:"CSV",desc:"Comma-separated values"},{value:"excel",label:"Excel (.xlsx)",desc:"Native Excel format"},{value:"json",label:"JSON",desc:"Structured data with metadata"},{value:"pdf",label:"PDF",desc:"Print-ready PDF document"}],Mr={sortMaxLevels:{title:"Maximum Sort Levels",description:"Limits the number of columns users can sort by simultaneously. Restricts multi-level sort depth.",tips:['"Add sort column" button is disabled at this limit',"Prevents adding more sort levels to the active sort stack","Default: 5 levels (range: 1–10)"]},filterMaxConditions:{title:"Maximum Filter Conditions",description:"Limits the total number of active filter conditions users can apply at once.",tips:['"Add condition" button is disabled at this limit',"Prevents performance degradation on large datasets","Default: 3 conditions (range: 1–20)"]},filterAllowedOperators:{title:"Allowed Filter Operators",description:"Controls which comparison operators appear in the filter UI. Unchecked operators are hidden from all dropdowns.",tips:["Simplifies the UI by hiding advanced operators your users don't need","At least one operator per data type must remain checked","Operators grouped by type: Text, Numeric, Boolean, Null checks"]},columnsMaxVisible:{title:"Maximum Visible Columns",description:"Limits the number of columns users can display at once in the data table.",tips:["Column visibility toggle is disabled when this limit is reached","Forces users to be selective about which columns to show","Default: 20 columns (range: 1–50)"]},columnsWidthRange:{title:"Column Width Constraints",description:"Sets minimum and maximum pixel widths for column resizing. Prevents columns from becoming too narrow or too wide.",tips:["Users cannot drag column borders outside this range","Min default: 60px, Max default: 800px","Ensures readable content and consistent layout"]},exportAllowedFormats:{title:"Allowed Export Formats",description:"Determines which export formats appear in the Export dialog and row-level export menus. At least one must be enabled.",tips:["Disabled formats don't appear in any export UI","PDF is now available as a print-ready export option","Unchecked formats are completely hidden from end users"]},groupingMaxLevels:{title:"Maximum Group Levels",description:"Limits how deeply users can nest grouped data. Enforced when adding new group levels.",tips:['"Add group level" button is hidden at this limit',"Range: 1 (single group only) to 3 (triple nested groups)","Prevents overly complex grouping hierarchies"]}};function To({children:e,active:r}){return t.jsx(n.Box,{hidden:!r,sx:{pt:2.5,pb:1,display:r?"flex":"none",flexDirection:"column",gap:2.5,height:"200px",width:"100%"},children:e})}function ef({open:e,onClose:r,config:o,onApply:i}){const[s,a]=p.useState(0),[l,c]=p.useState(o);p.useEffect(()=>{e&&c(o)},[e,o]);const u=()=>c(ft),x=()=>{i(l),r()},g={sort:m=>c(f=>({...f,sort:{...f.sort,...m}})),filter:m=>c(f=>({...f,filter:{...f.filter,...m}})),columns:m=>c(f=>({...f,columns:{...f.columns,...m}})),grouping:m=>c(f=>({...f,grouping:{...f.grouping,...m}})),export:m=>c(f=>({...f,export:{...f.export,...m}}))},y=m=>{const f=l.filter.allowedOperators,B=f.includes(m)?f.filter(j=>j!==m):[...f,m];B.length!==0&&g.filter({allowedOperators:B})},S=m=>{const f=l.export.allowedFormats,B=f.includes(m)?f.filter(j=>j!==m):[...f,m];B.length!==0&&g.export({allowedFormats:B})},b=[{label:"Sort",icon:t.jsx(_.SwapVert,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Filter",icon:t.jsx(_.FilterList,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Columns",icon:t.jsx(_.ViewColumn,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Grouping",icon:t.jsx(_.Layers,{sx:{fontSize:m=>m.typography.body1.fontSize}})},{label:"Export",icon:t.jsx(_.Download,{sx:{fontSize:m=>m.typography.body1.fontSize}})}],T=m=>JSON.stringify(l[m])===JSON.stringify(ft[m]);return t.jsxs(st,{open:e,onClose:r,icon:"⚙️",title:"Developer Configuration",subtitle:"· Set runtime constraints · Ctrl+Shift+D",width:600,maxHeight:"min(680px, calc(100vh - 180px))",headerExtra:t.jsx(n.Tabs,{value:s,onChange:(m,f)=>a(f),variant:"fullWidth",sx:{minHeight:44,borderBottom:"1px solid",borderColor:"divider","& .MuiTab-root":{minHeight:44,fontSize:m=>m.typography.caption.fontSize,textTransform:"none",fontWeight:m=>m.typography.button.fontWeight,gap:.5}},children:b.map((m,f)=>t.jsx(n.Tab,{label:m.label,icon:m.icon,iconPosition:"start"},f))}),footer:t.jsxs(t.Fragment,{children:[t.jsx(n.Button,{startIcon:t.jsx(_.RestartAlt,{sx:{fontSize:18}}),onClick:u,size:"small",sx:{mr:"auto",fontSize:m=>m.typography.body2.fontSize,color:"text.secondary","&:hover":{color:"text.primary",bgcolor:m=>M(m.palette.text.primary,.06)}},children:"Reset to defaults"}),t.jsx(n.Button,{onClick:r,size:"small",sx:{fontSize:m=>m.typography.body2.fontSize,color:"text.secondary",px:2,borderRadius:m=>Number(m.shape.borderRadius)*2.25},children:"Cancel"}),t.jsx(n.Button,{onClick:x,size:"small",variant:"contained",sx:{fontSize:m=>m.typography.body2.fontSize,px:2.5,borderRadius:m=>Number(m.shape.borderRadius)*2.25},children:"Apply"})]}),children:[t.jsx(To,{active:s===0,children:t.jsxs(n.Box,{children:[t.jsx(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum sort levels"}),t.jsx(mr,{content:Mr.sortMaxLevels,isDev:process.env.NODE_ENV==="development"})]})}),t.jsx(n.Slider,{value:l.sort.maxLevels,onChange:(m,f)=>g.sort({maxLevels:f}),min:1,max:10,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(n.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:"1 level (single)"}),t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:"10 levels (maximum)"})]})]})}),t.jsxs(To,{active:s===1,children:[t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum filter conditions"}),t.jsx(mr,{content:Mr.filterMaxConditions,isDev:process.env.NODE_ENV==="development"})]}),!T("filter")&&t.jsx(n.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(n.Slider,{value:l.filter.maxConditions,onChange:(m,f)=>g.filter({maxConditions:f}),min:1,max:20,step:1,marks:!0,valueLabelDisplay:"on"}),t.jsxs(n.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:"1 condition"}),t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:"20 conditions"})]})]}),t.jsx(n.Divider,{}),t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:1.5},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed filter operators"}),t.jsx(mr,{content:Mr.filterAllowedOperators,isDev:process.env.NODE_ENV==="development"})]}),["Text","Numeric","Boolean","Null checks"].map(m=>t.jsxs(n.Box,{sx:{mb:1.5},children:[t.jsx(n.Typography,{sx:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"text.secondary",fontSize:f=>f.typography.overline.fontSize,display:"block",mb:.5},children:m}),t.jsx(n.FormGroup,{row:!0,sx:{gap:.5},children:Qp.filter(f=>f.group===m).map(f=>t.jsx(n.FormControlLabel,{control:t.jsx(n.Checkbox,{size:"small",checked:l.filter.allowedOperators.includes(f.value),onChange:()=>y(f.value)}),label:t.jsx(n.Typography,{variant:"body2",sx:{fontSize:"0.8125rem"},children:f.label}),sx:{mr:1.5}},f.value))})]},m))]})]}),t.jsxs(To,{active:s===2,children:[t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum visible columns"}),t.jsx(mr,{content:Mr.columnsMaxVisible,isDev:process.env.NODE_ENV==="development"})]}),!T("columns")&&t.jsx(n.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(n.Slider,{value:l.columns.maxVisible,onChange:(m,f)=>g.columns({maxVisible:f}),min:1,max:50,step:1,valueLabelDisplay:"on"})]}),t.jsx(n.Divider,{}),t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75,mb:2},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Column width range (px)"}),t.jsx(mr,{content:Mr.columnsWidthRange,isDev:process.env.NODE_ENV==="development"})]}),t.jsxs(n.Box,{sx:{display:"flex",gap:2},children:[t.jsxs(n.Box,{sx:{flex:1},children:[t.jsx(n.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Minimum width"}),t.jsx(n.Slider,{value:l.columns.minColumnWidth,onChange:(m,f)=>g.columns({minColumnWidth:f}),min:40,max:400,step:10,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}px`})]}),t.jsxs(n.Box,{sx:{flex:1},children:[t.jsx(n.Typography,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:"Maximum width"}),t.jsx(n.Slider,{value:l.columns.maxColumnWidth,onChange:(m,f)=>g.columns({maxColumnWidth:f}),min:100,max:2e3,step:50,valueLabelDisplay:"on",valueLabelFormat:m=>`${m}px`})]})]})]})]}),t.jsx(To,{active:s===3,children:t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Maximum group levels"}),t.jsx(mr,{content:Mr.groupingMaxLevels,isDev:process.env.NODE_ENV==="development"})]}),!T("grouping")&&t.jsx(n.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(n.Box,{sx:{display:"flex",gap:1.5,mb:2},children:[1,2,3].map(m=>t.jsxs(n.Box,{onClick:()=>g.grouping({maxLevels:m}),sx:{flex:1,py:2.5,borderRadius:f=>Number(f.shape.borderRadius||0)*1.25,border:"2px solid",cursor:"pointer",textAlign:"center",transition:"all 0.15s ease",borderColor:l.grouping.maxLevels===m?"primary.main":"divider",bgcolor:l.grouping.maxLevels===m?f=>M(f.palette.primary.main,.06):"transparent","&:hover":{borderColor:"primary.light",bgcolor:f=>M(f.palette.primary.main,.04)}},children:[t.jsx(n.Typography,{variant:"h5",sx:{fontWeight:700,color:l.grouping.maxLevels===m?"primary.main":"text.secondary"},children:m}),t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:["Single","Double","Triple"][m-1]})]},m))}),t.jsxs(n.FormGroup,{row:!0,sx:{gap:2},children:[t.jsx(n.FormControlLabel,{control:t.jsx(n.Checkbox,{checked:l.grouping.allowNested,onChange:m=>g.grouping({allowNested:m.target.checked})}),label:t.jsx(n.Typography,{variant:"body2",children:"Allow nested groups"})}),t.jsx(n.FormControlLabel,{control:t.jsx(n.Checkbox,{checked:l.grouping.allowCollapse,onChange:m=>g.grouping({allowCollapse:m.target.checked})}),label:t.jsx(n.Typography,{variant:"body2",children:"Allow collapse / expand"})})]})]})}),t.jsx(To,{active:s===4,children:t.jsxs(n.Box,{children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1.5},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.75},children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:600},children:"Allowed export formats"}),t.jsx(mr,{content:Mr.exportAllowedFormats,isDev:process.env.NODE_ENV==="development"})]}),!T("export")&&t.jsx(n.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:600},children:"Modified"})]}),t.jsx(n.FormGroup,{sx:{gap:1},children:Zp.map(m=>t.jsxs(n.Box,{onClick:()=>S(m.value),sx:{display:"flex",alignItems:"center",gap:1.5,p:1.5,borderRadius:f=>f.shape.borderRadius,border:"1px solid",cursor:"pointer",transition:"all 0.15s ease",borderColor:l.export.allowedFormats.includes(m.value)?"primary.main":"divider",bgcolor:l.export.allowedFormats.includes(m.value)?f=>M(f.palette.primary.main,.04):"transparent","&:hover":{borderColor:"primary.light"}},children:[t.jsx(n.Checkbox,{size:"small",checked:l.export.allowedFormats.includes(m.value),onChange:()=>S(m.value),onClick:f=>f.stopPropagation()}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:500},children:m.label}),t.jsx(n.Typography,{variant:"caption",color:"text.secondary",children:m.desc})]})]},m.value))})]})})]})}const tf=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],rf={1:"1st",2:"2nd",3:"3rd",4:"4th",5:"5th",6:"6th",7:"7th",8:"8th",9:"9th",10:"10th",11:"11th",12:"12th",13:"13th",14:"14th",15:"15th",16:"16th",17:"17th",18:"18th",19:"19th",20:"20th",21:"21st",22:"22nd",23:"23rd",24:"24th",25:"25th",26:"26th",27:"27th",28:"28th"};function ln(e,r,o,i,s=new Date){const[a,l]=r.split(":").map(Number),c=new Date(s);if(c.setSeconds(0,0),c.setHours(a,l,0,0),e==="daily")return c<=s&&c.setDate(c.getDate()+1),c.toISOString();if(e==="weekly"){const u=o??1,x=c.getDay();let g=u-x;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 of(e){const r=wa(e.time);return e.frequency==="daily"?`Daily at ${r}`:e.frequency==="weekly"?`Every ${tf[e.dayOfWeek??1]} at ${r}`:e.frequency==="monthly"?`Monthly on the ${rf[e.dayOfMonth??1]??`${e.dayOfMonth}th`} at ${r}`:r}function wa(e){const[r,o]=e.split(":").map(Number),i=r>=12?"PM":"AM";return`${r%12||12}:${String(o).padStart(2,"0")} ${i}`}function nf(e){const r=new Date(e).getTime()-Date.now();if(r<=0)return"now";const o=Math.floor(r/1e3),i=Math.floor(o/86400),s=Math.floor(o%86400/3600),a=Math.floor(o%3600/60);return i>0?`in ${i}d ${s}h`:s>0?`in ${s}h ${a}m`:a>0?`in ${a}m`:"in less than a minute"}function sf(e){const r=new Date(e),o=new Date,i=r.toDateString()===o.toDateString(),s=wa(`${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 Ca(e){return`urm_schedules_${e}`}function ja(e){try{const r=localStorage.getItem(Ca(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 ka(e,r){try{localStorage.setItem(Ca(e),JSON.stringify(r))}catch{}}const af=[{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"}],lf=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ta={name:"",frequency:"daily",dayOfWeek:1,dayOfMonth:1,time:"09:00",format:"pdf",scope:"all",emails:[],viewId:""},hr={"& .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 cf(e){const r=(o,i)=>o.name.localeCompare(i.name);return{globalViews:e.filter(o=>o.scope==="global"&&!o.isDeleted).sort(r),favoriteViews:e.filter(o=>o.isFavorite&&!o.isDeleted).sort(r),personalViews:e.filter(o=>o.scope!=="global"&&!o.isDeleted).sort(r)}}function df({initial:e=Ta,isEditing:r=!1,views:o,onSave:i,onBack:s}){const[a,l]=p.useState(e),[c,u]=p.useState(!1),[x,g]=p.useState(""),[y,S]=p.useState(""),{globalViews:b,favoriteViews:T,personalViews:m}=cf(o),f=(h,I)=>l(A=>({...A,[h]:I})),B=()=>{const h=x.trim();if(h){if(!lf.test(h)){S("Please enter a valid email address");return}if(a.emails.includes(h)){S("This email is already added");return}f("emails",[...a.emails,h]),g(""),S("")}},j=h=>{f("emails",a.emails.filter(I=>I!==h))},D=h=>{h.key==="Enter"&&(h.preventDefault(),B())},z=a.name.trim().length>0&&/^\d{2}:\d{2}$/.test(a.time)&&(a.frequency!=="monthly"||a.dayOfMonth>=1&&a.dayOfMonth<=28);return t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.5,mb:.5},children:[t.jsx(n.IconButton,{size:"small",onClick:s,sx:{color:"text.secondary",ml:-.75,"&:hover":{bgcolor:h=>M(h.palette.text.primary,.06)}},children:t.jsx(_.ArrowBack,{sx:{fontSize:18}})}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:h=>h.typography.body2.fontWeight||600,fontSize:h=>h.typography.body2.fontSize||"0.875rem"},children:r?"Edit schedule":"New schedule"})]}),t.jsx(n.TextField,{label:"Schedule name *",size:"small",fullWidth:!0,value:a.name,onChange:h=>{f("name",h.target.value),c&&h.target.value.trim()&&u(!1)},onBlur:()=>u(!0),placeholder:"e.g. Weekly Sales Report",autoFocus:!0,inputProps:{maxLength:50},error:c&&!a.name.trim(),helperText:c&&!a.name.trim()?"Schedule name is required":`${a.name.length}/50`,sx:hr}),t.jsxs(n.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2},children:[t.jsxs(n.FormControl,{size:"small",fullWidth:!0,sx:hr,children:[t.jsx(n.InputLabel,{children:"Frequency"}),t.jsxs(n.Select,{value:a.frequency,label:"Frequency",onChange:h=>f("frequency",h.target.value),children:[t.jsx(n.MenuItem,{value:"daily",children:"Daily"}),t.jsx(n.MenuItem,{value:"weekly",children:"Weekly"}),t.jsx(n.MenuItem,{value:"monthly",children:"Monthly"})]})]}),t.jsx(n.TextField,{label:"Time",size:"small",type:"time",fullWidth:!0,value:a.time,onChange:h=>f("time",h.target.value),InputLabelProps:{shrink:!0},sx:hr})]}),a.frequency==="weekly"&&t.jsxs(n.FormControl,{size:"small",fullWidth:!0,sx:hr,children:[t.jsx(n.InputLabel,{children:"Day of week"}),t.jsx(n.Select,{value:a.dayOfWeek,label:"Day of week",onChange:h=>f("dayOfWeek",Number(h.target.value)),children:af.map(h=>t.jsx(n.MenuItem,{value:h.value,children:h.label},h.value))})]}),a.frequency==="monthly"&&t.jsx(n.TextField,{label:"Day of month (1–28)",size:"small",type:"number",fullWidth:!0,value:a.dayOfMonth,onChange:h=>f("dayOfMonth",Number(h.target.value)),inputProps:{min:1,max:28},error:a.dayOfMonth<1||a.dayOfMonth>28,helperText:a.dayOfMonth<1||a.dayOfMonth>28?"Day must be between 1 and 28":"Max 28 — works safely across all months including February",sx:hr}),t.jsxs(n.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:2},children:[t.jsxs(n.FormControl,{size:"small",fullWidth:!0,sx:hr,children:[t.jsx(n.InputLabel,{children:"Export format"}),t.jsxs(n.Select,{value:a.format,label:"Export format",onChange:h=>f("format",h.target.value),children:[t.jsx(n.MenuItem,{value:"pdf",children:"PDF — Print-ready document"}),t.jsx(n.MenuItem,{value:"excel",children:"Excel (.xlsx) — Native format"}),t.jsx(n.MenuItem,{value:"json",children:"JSON — Structured data"})]})]}),t.jsxs(n.FormControl,{size:"small",fullWidth:!0,sx:hr,children:[t.jsx(n.InputLabel,{children:"Report view"}),t.jsx(n.Select,{value:a.viewId,label:"Report view",onChange:h=>f("viewId",h.target.value),startAdornment:t.jsx(_.Visibility,{sx:{fontSize:15,color:"text.disabled",ml:.5,mr:.5}}),MenuProps:{PaperProps:{sx:{maxHeight:280}}},renderValue:h=>{var I;return((I=o.find(A=>A.id===h))==null?void 0:I.name)||"Select view"},children:[["Global Views",b],["Favorite Views",T],["Personal Views",m]].flatMap(([h,I])=>I.length===0?[]:[t.jsx(n.ListSubheader,{sx:{fontSize:"caption.fontSize",fontWeight:600,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.05em",lineHeight:"32px"},children:h},`${h}-header`),...I.map(A=>t.jsxs(n.MenuItem,{value:A.id,sx:{fontSize:"0.8125rem",gap:1},children:[a.viewId===A.id?t.jsx(_.Check,{sx:{fontSize:16,flexShrink:0}}):t.jsx(n.Box,{sx:{width:"16px",flexShrink:0}}),t.jsx(n.Box,{component:"span",sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:A.name}),A.isDefault&&t.jsx(n.Box,{component:"span",sx:{fontSize:"caption.fontSize",color:"text.secondary",bgcolor:"action.selected",px:1,py:.25,borderRadius:1,flexShrink:0},children:"Default"})]},A.id))])})]})]}),t.jsxs(n.Box,{children:[t.jsx(n.Typography,{variant:"caption",sx:{fontWeight:500,color:"text.secondary",display:"block",mb:.75},children:"Email recipients (optional)"}),t.jsxs(n.Box,{sx:{display:"flex",gap:1},children:[t.jsx(n.TextField,{size:"small",fullWidth:!0,type:"email",value:x,onChange:h=>{g(h.target.value),y&&S("")},onKeyPress:D,placeholder:"user@company.com",error:!!y,helperText:y||void 0,InputProps:{startAdornment:t.jsx(_.Email,{sx:{fontSize:15,color:"text.disabled",mr:1}})},sx:hr}),t.jsx(n.Button,{onClick:B,variant:"outlined",size:"small",startIcon:t.jsx(_.Add,{sx:{fontSize:16}}),sx:{fontSize:"0.8125rem",borderRadius:"8px",px:1.5,flexShrink:0,height:40},children:"Add"})]}),a.emails.length>0&&t.jsx(n.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.75,mt:1},children:a.emails.map(h=>t.jsx(n.Chip,{label:h,size:"small",onDelete:()=>j(h),sx:{fontSize:"0.75rem",bgcolor:I=>M(I.palette.primary.main,.08),color:"primary.main"}},h))})]}),t.jsxs(n.Box,{sx:{display:"flex",justifyContent:"flex-end",gap:1,pt:.5},children:[t.jsx(n.Button,{onClick:s,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px","&:hover":{bgcolor:h=>M(h.palette.text.primary,.06)}},children:"Cancel"}),t.jsx(n.Button,{onClick:()=>z&&i(a),disabled:!z,size:"small",variant:"contained",sx:{fontSize:"0.875rem",px:2.5,borderRadius:"18px"},children:r?"Save changes":"Create schedule"})]})]})}function uf({scheduleName:e,onConfirm:r,onCancel:o}){return t.jsxs(n.Dialog,{open:!0,onClose:o,maxWidth:"xs",fullWidth:!0,PaperProps:{sx:i=>({borderRadius:Po(i),...Rt(i).paper})},children:[t.jsxs(n.DialogContent,{sx:{pt:3,pb:2,px:3},children:[t.jsx(n.Box,{sx:{width:44,height:44,borderRadius:"12px",bgcolor:i=>M(i.palette.error.main,.1),display:"flex",alignItems:"center",justifyContent:"center",mb:2},children:t.jsx(_.WarningAmberOutlined,{sx:{fontSize:22,color:"error.main"}})}),t.jsx(n.Typography,{sx:{fontSize:i=>i.typography.body1.fontSize||"0.9375rem",fontWeight:i=>i.typography.h6.fontWeight||600,color:"text.primary",mb:1},children:"Delete Schedule"}),t.jsxs(n.Typography,{sx:{fontSize:i=>i.typography.body2.fontSize||"0.8125rem",color:"text.secondary",lineHeight:1.65},children:["Are you sure you want to delete"," ",t.jsxs(n.Box,{component:"span",sx:{fontWeight:600,color:"text.primary"},children:['"',e,'"']}),"? This action cannot be undone."]})]}),t.jsx(n.Divider,{}),t.jsxs(n.DialogActions,{sx:{px:2.5,py:1.5,gap:1},children:[t.jsx(n.Button,{onClick:o,variant:"text",sx:{fontSize:"0.8125rem",color:"text.secondary",borderRadius:i=>`${i.shape.borderRadius}px`,"&:hover":{bgcolor:"action.hover"}},children:"Cancel"}),t.jsx(n.Button,{onClick:r,variant:"contained",color:"error",sx:{fontSize:"0.8125rem",borderRadius:i=>`${i.shape.borderRadius}px`,px:2},children:"Delete"})]})]})}function pf({schedule:e,tick:r,onToggle:o,onRunNow:i,onEdit:s,onDelete:a}){var c;const l=e.isActive;return t.jsxs(n.Box,{sx:{border:"1px solid",borderColor:l?"primary.main":"divider",borderRadius:"10px",p:1.75,bgcolor:l?u=>M(u.palette.primary.main,.025):"background.paper",transition:"border-color 0.15s ease, background-color 0.15s ease"},children:[t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[t.jsx(n.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(n.Chip,{label:l?"Active":"Paused",size:"small",sx:{height:18,fontSize:"0.6875rem",fontWeight:600,flexShrink:0,bgcolor:l?u=>M(u.palette.success.main,.1):u=>M(u.palette.text.primary,.06),color:l?"success.dark":"text.secondary"}})]}),t.jsx(n.Typography,{variant:"caption",sx:{color:"text.secondary",display:"block",mb:1},children:of(e)}),t.jsxs(n.Box,{sx:{display:"flex",flexWrap:"wrap",gap:.5,mb:1},children:[t.jsx(n.Chip,{label:e.format.toUpperCase(),size:"small",sx:{height:20,fontSize:"0.6875rem",fontWeight:500,bgcolor:u=>M(u.palette.primary.main,.08),color:"primary.main"}}),t.jsx(n.Chip,{label:e.scope==="all"?"All rows":"Filtered rows",size:"small",sx:{height:20,fontSize:"0.6875rem",bgcolor:u=>M(u.palette.text.primary,.06),color:"text.secondary"}}),e.viewName&&t.jsx(n.Chip,{icon:t.jsx(_.Visibility,{sx:{fontSize:11}}),label:e.viewName,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:160,bgcolor:u=>M(u.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}}),(c=e.emails)==null?void 0:c.map(u=>t.jsx(n.Chip,{icon:t.jsx(_.Email,{sx:{fontSize:11}}),label:u,size:"small",sx:{height:20,fontSize:"0.6875rem",maxWidth:220,bgcolor:x=>M(x.palette.text.primary,.06),color:"text.secondary","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}},u))]}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1},children:[t.jsxs(n.Box,{sx:{display:"flex",flexWrap:"wrap",gap:1.5,alignItems:"center"},children:[l&&t.jsxs(n.Typography,{variant:"caption",sx:{color:"primary.main",fontWeight:500},children:["Next: ",nf(e.nextRunAt)]}),e.lastRunAt?t.jsxs(n.Typography,{variant:"caption",color:"text.secondary",children:["Last: ",sf(e.lastRunAt)," · ",e.runCount," run",e.runCount!==1?"s":""]}):t.jsx(n.Typography,{variant:"caption",color:"text.disabled",children:"Never run"})]}),t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:.25,flexShrink:0},children:[t.jsx(n.Tooltip,{title:"Edit",placement:"top",children:t.jsx(n.IconButton,{size:"small",onClick:()=>s(e),sx:{color:"text.secondary","&:hover":{color:"primary.main",bgcolor:u=>M(u.palette.primary.main,.08)}},children:t.jsx(_.Edit,{sx:{fontSize:15}})})}),t.jsx(n.Tooltip,{title:l?"Pause":"Resume",placement:"top",children:t.jsx(n.IconButton,{size:"small",onClick:()=>o(e.id),sx:{color:l?"warning.main":"success.main","&:hover":{bgcolor:l?u=>M(u.palette.warning.main,.08):u=>M(u.palette.success.main,.08)}},children:l?t.jsx(_.Pause,{sx:{fontSize:15}}):t.jsx(_.PlayArrow,{sx:{fontSize:15}})})}),t.jsx(n.Tooltip,{title:"Export now",placement:"top",children:t.jsx(n.IconButton,{size:"small",onClick:()=>i(e),sx:{color:"primary.main","&:hover":{bgcolor:u=>M(u.palette.primary.main,.08)}},children:t.jsx(_.Download,{sx:{fontSize:u=>u.typography.body1.fontSize}})})}),t.jsx(n.Tooltip,{title:"Delete",placement:"top",children:t.jsx(n.IconButton,{size:"small",onClick:()=>a(e.id),sx:{color:"error.main","&:hover":{bgcolor:u=>M(u.palette.error.main,.08)}},children:t.jsx(_.Delete,{sx:{fontSize:15}})})})]})]})]})}function ff({open:e,onClose:r,reportId:o,reportName:i,onRunNow:s,views:a,schedulerConfig:l}){var v,W;const u=((l==null?void 0:l.mode)??"local")==="api",[x,g]=p.useState([]),y=u?(l==null?void 0:l.schedules)??[]:x,[S,b]=p.useState({type:"list"}),[T,m]=p.useState(0),[f,B]=p.useState(null);p.useEffect(()=>{e&&(u||g(ja(o)),b({type:"list"}))},[e,o,u]),p.useEffect(()=>{if(!e)return;const k=setInterval(()=>m(q=>q+1),3e4);return()=>clearInterval(k)},[e]);const j=p.useCallback(k=>{g(k),ka(o,k)},[o]),D=k=>{var d,Q;const q=ln(k.frequency,k.time,k.dayOfWeek,k.dayOfMonth),re={id:`sched-${Date.now()}`,reportId:o,name:k.name.trim(),frequency:k.frequency,dayOfWeek:k.frequency==="weekly"?k.dayOfWeek:void 0,dayOfMonth:k.frequency==="monthly"?k.dayOfMonth:void 0,time:k.time,format:k.format,scope:k.scope,emails:k.emails.length>0?k.emails:void 0,viewId:k.viewId||void 0,viewName:k.viewId?(d=a.find(ee=>ee.id===k.viewId))==null?void 0:d.name:void 0,isActive:!0,createdAt:new Date().toISOString(),nextRunAt:q,runCount:0};u?(Q=l==null?void 0:l.onScheduleCreate)==null||Q.call(l,re):j([...y,re]),b({type:"list"})},z=k=>{var Q,ee;if(S.type!=="edit")return;const q=S.schedule,re=ln(k.frequency,k.time,k.dayOfWeek,k.dayOfMonth),d={...q,name:k.name.trim(),frequency:k.frequency,dayOfWeek:k.frequency==="weekly"?k.dayOfWeek:void 0,dayOfMonth:k.frequency==="monthly"?k.dayOfMonth:void 0,time:k.time,format:k.format,scope:k.scope,emails:k.emails.length>0?k.emails:void 0,viewId:k.viewId||void 0,viewName:k.viewId?(Q=a.find(H=>H.id===k.viewId))==null?void 0:Q.name:void 0,nextRunAt:re};u?(ee=l==null?void 0:l.onScheduleUpdate)==null||ee.call(l,d):j(y.map(H=>H.id===q.id?d:H)),b({type:"list"})},h=k=>{var ee;const q=y.find(H=>H.id===k);if(!q)return;const re=!q.isActive,d=re?ln(q.frequency,q.time,q.dayOfWeek,q.dayOfMonth):q.nextRunAt,Q={...q,isActive:re,nextRunAt:d};u?(ee=l==null?void 0:l.onScheduleToggle)==null||ee.call(l,k,re):j(y.map(H=>H.id===k?Q:H))},I=k=>{if(s(k),!u){const q=new Date().toISOString();j(y.map(re=>re.id===k.id?{...re,lastRunAt:q,runCount:re.runCount+1}:re))}},A=k=>{const q=y.find(re=>re.id===k)??null;B(q)},$=()=>{var k;f&&(u?(k=l==null?void 0:l.onScheduleDelete)==null||k.call(l,f.id):j(y.filter(q=>q.id!==f.id)),B(null))},Y=k=>{var q,re;return{name:k.name,frequency:k.frequency,dayOfWeek:k.dayOfWeek??1,dayOfMonth:k.dayOfMonth??1,time:k.time,format:k.format,scope:k.scope,emails:k.emails??[],viewId:k.viewId||((q=a.find(d=>d.isDefault))==null?void 0:q.id)||((re=a[0])==null?void 0:re.id)||""}},X=S.type!=="list",R=y.filter(k=>k.isActive).length;return t.jsxs(t.Fragment,{children:[t.jsxs(st,{open:e,onClose:r,icon:t.jsx(_.Schedule,{sx:{fontSize:20}}),title:"Scheduled Reports",subtitle:`· ${i}`,helpContent:Wr.schedule,width:600,maxHeight:"min(680px, calc(100vh - 180px))",disableEscapeKeyDown:X,footer:S.type==="list"?t.jsx(n.Button,{onClick:r,size:"small",sx:{fontSize:"0.875rem",color:"text.secondary",px:2,borderRadius:"18px",flexShrink:0,"&:hover":{bgcolor:k=>M(k.palette.text.primary,.06)}},children:"Close"}):void 0,children:[X&&t.jsx(df,{initial:S.type==="edit"?Y(S.schedule):{...Ta,viewId:((v=a.find(k=>k.isDefault))==null?void 0:v.id)||((W=a[0])==null?void 0:W.id)||""},isEditing:S.type==="edit",views:a,onSave:S.type==="edit"?z:D,onBack:()=>b({type:"list"})}),S.type==="list"&&t.jsxs(t.Fragment,{children:[t.jsxs(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.75,pt:1.5},children:[t.jsx(n.Typography,{variant:"body2",color:"text.secondary",children:y.length===0?"No schedules yet":`${R} of ${y.length} active`}),t.jsx(n.Button,{startIcon:t.jsx(_.Add,{sx:{fontSize:15}}),size:"small",variant:"contained",onClick:()=>b({type:"create"}),sx:{fontSize:"0.8125rem",borderRadius:"18px",px:1.75,py:.625},children:"New schedule"})]}),y.length===0?t.jsxs(n.Box,{sx:{border:"1.5px dashed",borderColor:"divider",borderRadius:"10px",py:5,px:2,textAlign:"center"},children:[t.jsx(_.NotificationsActive,{sx:{fontSize:30,color:"text.disabled",mb:1.25,display:"block",mx:"auto"}}),t.jsx(n.Typography,{variant:"body2",sx:{fontWeight:k=>k.typography.body2.fontWeight||500,fontSize:k=>k.typography.body2.fontSize||"0.875rem",color:"text.secondary"},children:"No scheduled reports yet"}),t.jsx(n.Typography,{variant:"caption",color:"text.disabled",sx:{display:"block",mt:.5},children:'Use "New schedule" above to set up automatic exports'})]}):t.jsx(n.Box,{sx:{display:"flex",flexDirection:"column",gap:1.25},children:y.map(k=>t.jsx(pf,{schedule:k,tick:T,onToggle:h,onRunNow:I,onEdit:q=>b({type:"edit",schedule:q}),onDelete:A},k.id))})]})]}),f&&t.jsx(uf,{scheduleName:f.name,onConfirm:$,onCancel:()=>B(null)})]})}const hf=6e4;function mf({reportId:e,reportName:r,uploadedData:o,processedData:i,schema:s,activeView:a,views:l,columnVisibility:c,columnOrder:u,filters:x,sortStack:g,onFired:y,schedulerConfig:S}){const b=(S==null?void 0:S.mode)??"local",T=p.useRef({reportId:e,reportName:r,uploadedData:o,processedData:i,schema:s,activeView:a,views:l,columnVisibility:c,columnOrder:u,filters:x,sortStack:g,onFired:y,schedulerConfig:S,schedulerMode:b});p.useEffect(()=>{T.current={reportId:e,reportName:r,uploadedData:o,processedData:i,schema:s,activeView:a,views:l,columnVisibility:c,columnOrder:u,filters:x,sortStack:g,onFired:y,schedulerConfig:S,schedulerMode:b}});const m=p.useCallback(f=>{var W,k,q,re,d,Q;const{reportName:B,uploadedData:j,processedData:D,schema:z,activeView:h,views:I,columnVisibility:A,columnOrder:$,filters:Y,sortStack:X,schedulerConfig:R,schedulerMode:v}=T.current;try{const ee=f.viewId?I.find(F=>F.id===f.viewId):void 0,H=ee?ee.snapshot.filters:Y,te=ee?ee.snapshot.sortStack:X,ue=ee?ee.snapshot.columnVisibility:A,le=ee?ee.snapshot.columnOrder:$,Z=f.scope==="all"?j:ee?vi(Bi(j,H,z),z,te):D;if(v==="api"){const F=(le.length>0?le:z.map(he=>he.name)).filter(he=>ue[he]!==!1),ie={schedule:f,triggeredAt:new Date().toISOString(),rows:Z,columns:F,format:f.format,reportName:B};(W=R==null?void 0:R.onScheduleFire)==null||W.call(R,ie),(q=(k=T.current).onFired)==null||q.call(k,f);return}const de=cn(Z,z,H,te,ee||h,ue,le),ae=`${f.name}_scheduled`;switch(f.format){case"csv":dn(de,ae,{scope:f.scope});break;case"excel":un(de,ae,{scope:f.scope});break;case"json":pn(de,ae,{scope:f.scope});break;case"pdf":zi(de,ae,{scope:f.scope});break}if(R!=null&&R.onScheduleFire){const F=(le.length>0?le:z.map(ie=>ie.name)).filter(ie=>ue[ie]!==!1);R.onScheduleFire({schedule:f,triggeredAt:new Date().toISOString(),rows:Z,columns:F,format:f.format,reportName:B})}if((re=f.emails)!=null&&re.length){const F=encodeURIComponent(`Scheduled Report: ${f.name}`),ie=encodeURIComponent(`Your scheduled report "${f.name}" has been generated.
192
192
 
193
- Report: ${E}
194
- Format: ${m.format.toUpperCase()}
193
+ Report: ${B}
194
+ Format: ${f.format.toUpperCase()}
195
195
  Generated: ${new Date().toLocaleString()}
196
196
 
197
- The file has been downloaded to your device.`);window.open(`mailto:${m.emails.join(",")}?subject=${W}&body=${ie}`,"_blank")}(Q=(d=z.current).onFired)==null||Q.call(d,m)}catch(ee){Kt.error("urm:scheduler",`Export failed for schedule: ${m.name}`,ee)}},[]);p.useEffect(()=>{if(!e)return;const m=()=>{const{reportId:v,schedulerMode:T,schedulerConfig:B}=z.current;if(!v)return;const f=T==="api"?(B==null?void 0:B.schedules)??[]:va(v),$=new Date;let F=!1;const O=f.map(J=>{if(!J.isActive)return J;if(new Date(J.nextRunAt)<=$){h(J);const L=dn(J.frequency,J.time,J.dayOfWeek,J.dayOfMonth,$);return F=!0,{...J,lastRunAt:$.toISOString(),nextRunAt:L,runCount:J.runCount+1}}return J});F&&T==="local"&&Sa(v,O)};m();const E=setInterval(m,Yp);return()=>clearInterval(E)},[e,h])}function Ca({reportEngine:e}){var Br,qr,Er,_r,$r,we;const{activeReport:r,paginatedData:o,processedData:i,tableMetrics:s,tableEngine:a,activeView:l,isDirty:c,currentTableState:u,showFilterPanel:g,setShowFilterPanel:x,filterFocusColumn:y,handleReplaceFilters:w,handleOpenFilterForColumn:b,handleCloseFilterPanel:z,handleClearFiltersForColumn:h,showSortPanel:m,setShowSortPanel:E,handleSort:v,handleUpdateSortStack:T,handleSortAscending:B,handleSortDescending:f,showCreateViewModal:$,setShowCreateViewModal:F,showEditViewModal:O,setShowEditViewModal:J,showDeleteConfirmation:te,setShowDeleteConfirmation:L,editingView:S,deletingView:A,handleSelectView:k,handleCreateView:Y,handleUpdateCurrentView:oe,handleSaveAsNewView:d,handleRevertChanges:Q,handleToggleDefault:ee,handleToggleFavorite:N,handleSoftDelete:re,handleRestoreView:ue,handlePermanentDelete:le,handleEditView:Z,handleCloneView:de,handleCopyViewLink:se,handleSaveEditView:W,handleConfirmDelete:ie,handlePromoteToGlobal:fe,handleSetDefaultForAllUsers:pe,showManageColumns:Me,setShowManageColumns:P,handleUpdateColumnVisibility:be,handleUpdateColumnOrder:ke,handleUpdateColumnWidth:Pe,handleResetColumnLayout:Ae,showGroupPanel:st,setShowGroupPanel:Ze,handleGroup:Wt,handleToggleGroupCollapse:Bt,handleExpandAllGroups:Xt,handleCollapseAllGroups:Wr,searchQuery:Qt,debouncedSearchQuery:Pr,searchHistory:qe,handleSearchChange:Et,handleAddToSearchHistory:Lr,handleToggleSearchFavourite:lt,handleDeleteSearchHistory:Zt,selectedRowIds:Pt,handleToggleRowSelection:Fr,handleToggleAllRows:Lt,handleRangeSelection:_t,handleClearSelection:Ft,handleUpdateSelectionAfterDelete:ct,currentPage:Le,pageSize:Nr,paginationTotalRows:Vr,paginationTotalPages:ur,handlePageChange:pr,handlePageSizeChange:er,isExporting:fo,showExportModal:Cr,setShowExportModal:$t,showDirtyExportWarning:Ve,handleExport:Se,handleExportWithConfig:Nt,handleExportSelected:mo,handleExportAnyway:ho,handleSaveAndExport:Hr,handleCancelExport:Gr,showAuditHistory:tr,setShowAuditHistory:je,showCreatePreset:fr,setShowCreatePreset:ot,showManagePresets:ht,setShowManagePresets:G,activePreset:Dt,handleCreatePreset:K,handleClearActivePreset:at,handleOpenPresetById:mr,handleDeletePresetById:rr,isViewerRole:xo,userRole:hr,featureLimitWarning:jr,setFeatureLimitWarning:vt,reportError:or,setReportError:kr,handleError:ve,updateReport:St,showSnack:Ur,config:U,scheduler:Ke}=e,[Te,pt]=p.useState(!1);qp({reportId:r==null?void 0:r.id,reportName:(r==null?void 0:r.name)||"Report",uploadedData:(r==null?void 0:r.uploadedData)||[],processedData:i||[],schema:(r==null?void 0:r.schema)||[],activeView:l,views:(r==null?void 0:r.views)||[],columnVisibility:(r==null?void 0:r.columnVisibility)||((Br=l==null?void 0:l.snapshot)==null?void 0:Br.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((qr=l==null?void 0:l.snapshot)==null?void 0:qr.columnOrder)||[],filters:Ue(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:ae=>{Ur(`Scheduled export "${ae.name}" completed`,"success")},schedulerConfig:Ke});const Tr=p.useCallback((ae,me)=>{if(!(r!=null&&r.uploadedData))return;const Ce=r.uploadedData[ae],We=[...r.uploadedData];We[ae]=me;const Xe=Io(r.id,"user","rows","row_edited",Ce,me),ft=Oo(r.auditHistory||[],Xe);St(r.id,{uploadedData:We,auditHistory:ft})},[r,St]),xt=p.useCallback(ae=>{if(!(r!=null&&r.uploadedData))return;const me=r.uploadedData.indexOf(ae);if(me===-1)return;const Ce=r.uploadedData.filter((ft,dt)=>dt!==me),We=Io(r.id,"user","rows","row_deleted",ae,null),Xe=Oo(r.auditHistory||[],We);St(r.id,{uploadedData:Ce,auditHistory:Xe}),ct(ae)},[r,St,ct]),go=p.useCallback((ae,me)=>{if(!(r!=null&&r.uploadedData))return;const Ce=r.uploadedData.indexOf(me),We=Ce!==-1?Ce+1:ae+1,Xe=[...r.uploadedData];Xe.splice(We,0,{...me});const ft=Io(r.id,"user","rows","row_duplicated",me,{...me}),dt=Oo(r.auditHistory||[],ft);St(r.id,{uploadedData:Xe,auditHistory:dt})},[r,St]),Vt=Ar(),{handleDevConfigChange:zr}=vn(),[Yr,Ht]=p.useState(!1);return p.useEffect(()=>{const ae=me=>{me.ctrlKey&&me.shiftKey&&me.key==="D"&&(me.preventDefault(),Ht(!0))};return document.addEventListener("keydown",ae),()=>document.removeEventListener("keydown",ae)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(n.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[jr&&t.jsx(Bp,{warning:jr,onDismiss:()=>vt(null)}),or&&t.jsx(Ep,{error:or,onDismiss:()=>kr(null)}),Ve&&t.jsx(dp,{onExportAnyway:ho,onSaveAndExport:Hr,onCancel:Gr}),t.jsx(Zu,{schema:r.schema,data:o,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:c,isExporting:fo,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:v,onSortAscending:B,onSortDescending:f,onOpenFilters:()=>x(!0),onOpenSort:()=>E(!0),onOpenFilterForColumn:b,onSelectView:k,onCreateView:()=>F(!0),onUpdateCurrentView:oe,onSaveAsNewView:d,onDiscardChanges:Q,onToggleDefault:ee,onToggleFavorite:N,onRestoreView:ue,onPermanentDelete:le,onEditView:Z,onCloneView:de,onCopyLink:se,onDeleteView:re,onPromoteToGlobal:fe,onSetDefaultForAllUsers:pe,isAdmin:((Er=Vt.views)==null?void 0:Er.isAdmin)??!1,hideViewMenuActions:U==null?void 0:U.hideViewMenuActions,customViewMenuActions:U==null?void 0:U.customViewMenuActions,viewMenuActionData:i,viewMenuActionTableState:u??null,onExport:Se,onOpenColumns:()=>P(!0),onUpdateColumnWidth:Pe,onUpdateColumnOrder:ke,onUpdateColumnVisibility:be,onClearFiltersForColumn:h,onResetLayout:Ae,onOpenGroup:()=>Ze(!0),onGroupByColumn:(_r=U==null?void 0:U.hideToolbarActions)!=null&&_r.includes("grouping")?void 0:ae=>{var We;const me=r==null?void 0:r.grouping;if(!((me==null?void 0:me.enabled)&&(me==null?void 0:me.levels)&&me.levels.length>0))Wt({enabled:!0,levels:[{column:ae}],collapsedGroups:[]});else{if(me.levels.some(dt=>dt.column===ae))return;const ft=((We=Vt.grouping)==null?void 0:We.maxLevels)??3;if(me.levels.length>=ft)return;Wt({enabled:!0,levels:[...me.levels,{column:ae}],collapsedGroups:me.collapsedGroups})}},onToggleGroupCollapse:Bt,onExpandAllGroups:Xt,onCollapseAllGroups:Wr,onOpenAuditHistory:()=>je(!0),onOpenScheduledReports:()=>pt(!0),searchQuery:Qt,highlightQuery:Pr,searchHistory:qe,onAddToSearchHistory:Lr,onToggleSearchFavourite:lt,onDeleteSearchHistory:Zt,selectedRowIds:Pt,onSearchChange:Et,onToggleRowSelection:Fr,onToggleAllRows:Lt,onRangeSelection:_t,onClearSelection:Ft,onExportSelected:mo,currentPage:Le,pageSize:Nr,onPageChange:pr,onPageSizeChange:er,totalRowsBeforePagination:Vr,totalPagesOverride:ur,isReadOnly:xo,userRole:hr,reportName:r.name,onEditRow:Tr,onDeleteRow:xt,onDuplicateRow:go,rowActions:U==null?void 0:U.rowActions,hideDefaultRowActions:U==null?void 0:U.hideDefaultRowActions,hideToolbarActions:U==null?void 0:U.hideToolbarActions,customSettingsActions:U==null?void 0:U.customSettingsActions,jsonGuideContent:U==null?void 0:U.jsonGuideContent,jsonGuideTitle:U==null?void 0:U.jsonGuideTitle,viewOptions:U==null?void 0:U.viewOptions,defaultViewMode:U==null?void 0:U.defaultViewMode,bulkActions:U==null?void 0:U.bulkActions,hideSelectionCheckboxes:U==null?void 0:U.hideSelectionCheckboxes,rowClickBehavior:U==null?void 0:U.rowClickBehavior,openModalOn:U==null?void 0:U.openModalOn,onRowClick:U==null?void 0:U.onRowClick,onRowRightClick:U==null?void 0:U.onRowRightClick,showDevPanel:Vt.display.showDevPanel,onOpenDevConfig:()=>Ht(!0)})]}),g&&t.jsx(ln,{feature:"Filters",onError:ae=>{const me=vr("ui","filters",ae);ve(me)},children:t.jsx(op,{schema:r.schema,filters:r.filters,onReplaceFilters:w,onClose:z,focusColumn:y,onOpenDevConfig:()=>Ht(!0)})}),m&&t.jsx(ln,{feature:"Sorting",onError:ae=>{const me=vr("ui","sorting",ae);ve(me)},children:t.jsx(ip,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:T,onClose:()=>E(!1),onOpenDevConfig:()=>Ht(!0)})}),$&&u&&(()=>{var Ce;const ae=(r.views??[]).filter(We=>!We.isDeleted).length,me=((Ce=Vt.views)==null?void 0:Ce.maxViews)??10;return t.jsx(Bs,{currentSnapshot:u,onSave:Y,onClose:()=>F(!1),atViewLimit:ae>=me,maxViews:me})})(),O&&S&&t.jsx(Bs,{currentSnapshot:S.snapshot,onSave:W,onClose:()=>{J(!1)},isEditMode:!0,initialName:S.name,initialDescription:S.description,initialIsDefault:S.isDefault}),te&&A&&t.jsx(sp,{viewName:A.name,onConfirm:ie,onCancel:()=>{L(!1)}}),Me&&l&&t.jsx(lp,{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:be,onUpdateColumnOrder:ke,onUpdateColumnWidth:Pe,onResetLayout:Ae,onClose:()=>P(!1)}),st&&t.jsx(ln,{feature:"Grouping",onError:ae=>{const me=vr("ui","grouping",ae);ve(me)},children:t.jsx(cp,{schema:r.schema,grouping:r.grouping||null,onApply:Wt,onClose:()=>Ze(!1),onOpenDevConfig:()=>Ht(!0)})}),tr&&t.jsx(fp,{auditHistory:r.auditHistory||[],onClose:()=>je(!1)}),fr&&t.jsx(mp,{onSave:K,onClose:()=>ot(!1)}),ht&&t.jsx(xp,{presets:r.presets||[],reportId:r.id,onOpenPreset:mr,onDeletePreset:rr,onClose:()=>G(!1)}),Dt&&t.jsx(n.Box,{sx:{mt:2},children:t.jsx(hp,{presetName:Dt.name,onClear:at})}),Cr&&t.jsx(ln,{feature:"Export",onError:ae=>{const me=vr("ui","export",ae);ve(me)},children:t.jsx(zp,{totalRows:(s==null?void 0:s.totalRows)||(($r=r.uploadedData)==null?void 0:$r.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((we=a==null?void 0:a.columnEngine)==null?void 0:we.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:Nt,onClose:()=>{$t(!1)}})}),r&&t.jsx(Up,{open:Te,onClose:()=>pt(!1),reportId:r.id,reportName:r.name,views:r.views||[],schedulerConfig:Ke,onRunNow:ae=>{var xr;const me=(Ke==null?void 0:Ke.mode)??"local",Ce=ae.viewId?(r.views||[]).find(Dr=>Dr.id===ae.viewId):void 0,We=Ce?Ce.snapshot.filters:Ue(r.filters),Xe=Ce?Ce.snapshot.sortStack:r.sortStack||[],ft=Ce?Ce.snapshot.columnVisibility:r.columnVisibility,dt=Ce?Ce.snapshot.columnOrder:r.columnOrder,wt=ae.scope==="all"?r.uploadedData||[]:Ce?yi(Ti(r.uploadedData||[],We,r.schema||[]),r.schema||[],Xe):i||[],Gt=un(wt,r.schema||[],We,Xe,Ce||l,ft,dt);if(me==="api"){const Dr=(dt||[]).filter(yo=>(ft??{})[yo]!==!1);(xr=Ke==null?void 0:Ke.onScheduleFire)==null||xr.call(Ke,{schedule:ae,triggeredAt:new Date().toISOString(),rows:wt,columns:Dr,format:ae.format,reportName:r.name})}else ae.format==="csv"&&pn(Gt,ae.name),ae.format==="excel"&&fn(Gt,ae.name),ae.format==="json"&&mn(Gt,ae.name),ae.format==="pdf"&&ki(Gt,ae.name);Ur(`"${ae.name}" exported successfully`,"success")}}),t.jsx(Op,{open:Yr,onClose:()=>Ht(!1),config:Vt,onApply:zr})]})}const Jp={error:"err",warning:"warn",info:"info",success:"suc"};function ja({open:e,message:r,severity:o,onClose:i,autoHideDurationMs:s}){var T,B,f,$;const a=n.useTheme(),l=a.tokens,c=(l==null?void 0:l.notifPosition)??"bottom-right",u=(l==null?void 0:l.notifStyle)??"toast",g=(l==null?void 0:l.notifAccent)??"severity",x=(l==null?void 0:l.notifAutoDismiss)??!0,y=(l==null?void 0:l.toastW)??252,w=c.startsWith("top")?"top":"bottom",b=c.endsWith("center")?"center":c.endsWith("left")?"left":"right",z=Jp[o],h=((T=l==null?void 0:l.status)==null?void 0:T[`${z}Soft`])??a.palette[o].light,m=((B=l==null?void 0:l.status)==null?void 0:B[`${z}Txt`])??a.palette[o].dark,E=g==="primary"?a.palette.primary.main:g==="mono"?a.palette.text.secondary:m,v=u==="toast"?(l==null?void 0:l.toastBg)??a.palette.background.paper:h;return t.jsx(n.Snackbar,{open:e,autoHideDuration:x?s??(l!=null&&l.autoDismissSec?l.autoDismissSec*1e3:3e4):void 0,onClose:(F,O)=>{O!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:w,horizontal:b},children:t.jsx(n.Alert,{severity:o,icon:u==="toast"?t.jsx(n.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((f=l==null?void 0:l.status)==null?void 0:f[`${z}Soft`])??a.palette[o].light,color:(($=l==null?void 0:l.status)==null?void 0:$[`${z}Txt`])??a.palette[o].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:o==="error"||o==="warning"?"!":o==="success"?"✓":"i"}):void 0,action:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[x&&(l==null?void 0:l.autoDismissSec)&&t.jsx(n.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:M(E,.14),color:E,fontSize:"0.7rem",fontWeight:800,fontVariantNumeric:"tabular-nums"},children:`${l.autoDismissSec}s`}),t.jsx(n.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",p:.25},children:t.jsx(D.Close,{sx:{fontSize:16}})})]}),sx:{width:y,alignItems:"flex-start",bgcolor:v,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 ${E}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:E}},children:t.jsxs(n.Box,{children:[u==="toast"&&t.jsx(n.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:a.palette.text.primary},children:o==="error"?"Error":o==="warning"?"Warning":o==="success"?"Success":"Info"}),t.jsx(n.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function ka({hasExternalData:e=!1}){const r=vn(),{reports:o,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:l,isModalOpen:c,setIsModalOpen:u,setActiveReportId:g,createReport:x,handleFileUpload:y,handleUploadError:w,handleRetry:b,handleConfirm:z,snack:h,handleSnackClose:m,snackDurationMs:E,config:v}=r,T=e&&a==="uploading"&&o.length===0;return t.jsxs(n.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(uu,{onCreateReport:()=>u(!0),reports:o,activeReportId:i,onReportClick:g}),t.jsx(n.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:T?t.jsxs(n.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[t.jsx(n.CircularProgress,{size:40,thickness:3}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):o.length===0?t.jsx(da,{title:"No reports yet",description:"Create your first report to start analyzing your data."}):s?t.jsx(t.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?t.jsx(Ca,{reportEngine:r}):t.jsx(n.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(xu,{schema:s.schema,onConfirm:z,hasConflicts:l}):s.uploadError?t.jsx(gu,{error:s.uploadError,onRetry:b}):t.jsx(hu,{onFileUpload:y,onError:w,isUploading:a==="uploading",jsonGuideContent:v==null?void 0:v.jsonGuideContent,jsonGuideTitle:v==null?void 0:v.jsonGuideTitle})})}):null}),!e&&t.jsx(mu,{isOpen:c,onClose:()=>u(!1),onCreate:x}),t.jsx(ja,{open:h.open,message:h.message,severity:h.severity,onClose:m,autoHideDurationMs:E})]})}function Kp({data:e,dataSource:r,pagination:o,search:i,reportName:s,reportId:a,autoLoad:l=!0,config:c}={}){return t.jsx(zi,{mode:"builder",data:e,dataSource:r,pagination:o,search:i,reportName:s,reportId:a,autoLoad:l,config:c,children:t.jsx(ka,{hasExternalData:!!(e||r)})})}function Ta(){const e=vn(),{snack:r,handleSnackClose:o,snackDurationMs:i}=e;return t.jsxs(n.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsx(n.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:e.activeReport?t.jsx(Ca,{reportEngine:e}):t.jsx(da,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(ja,{open:r.open,message:r.message,severity:r.severity,onClose:o,autoHideDurationMs:i})]})}function Xp({data:e,reportId:r,pagination:o,search:i,autoLoad:s=!0,config:a}){return t.jsx(zi,{data:e,reportId:r,pagination:o,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(Ta,{})})}exports.URMBuilder=Kp;exports.URMBuilderRaw=ka;exports.URMProvider=zi;exports.URMViewer=Xp;exports.URMViewerRaw=Ta;exports.useURMContext=vn;
197
+ The file has been downloaded to your device.`);window.open(`mailto:${f.emails.join(",")}?subject=${F}&body=${ie}`,"_blank")}(Q=(d=T.current).onFired)==null||Q.call(d,f)}catch(ee){qt.error("urm:scheduler",`Export failed for schedule: ${f.name}`,ee)}},[]);p.useEffect(()=>{if(!e)return;const f=()=>{const{reportId:j,schedulerMode:D,schedulerConfig:z}=T.current;if(!j)return;const h=D==="api"?(z==null?void 0:z.schedules)??[]:ja(j),I=new Date;let A=!1;const $=h.map(Y=>{if(!Y.isActive)return Y;if(new Date(Y.nextRunAt)<=I){m(Y);const R=ln(Y.frequency,Y.time,Y.dayOfWeek,Y.dayOfMonth,I);return A=!0,{...Y,lastRunAt:I.toISOString(),nextRunAt:R,runCount:Y.runCount+1}}return Y});A&&D==="local"&&ka(j,$)};f();const B=setInterval(f,hf);return()=>clearInterval(B)},[e,m])}function za({reportEngine:e}){var zr,Jr,Br,Kr,Er,_r;const{activeReport:r,paginatedData:o,processedData:i,tableMetrics:s,tableEngine:a,activeView:l,isDirty:c,currentTableState:u,showFilterPanel:x,setShowFilterPanel:g,filterFocusColumn:y,handleReplaceFilters:S,handleOpenFilterForColumn:b,handleCloseFilterPanel:T,handleClearFiltersForColumn:m,showSortPanel:f,setShowSortPanel:B,handleSort:j,handleUpdateSortStack:D,handleSortAscending:z,handleSortDescending:h,showCreateViewModal:I,setShowCreateViewModal:A,showEditViewModal:$,setShowEditViewModal:Y,showDeleteConfirmation:X,setShowDeleteConfirmation:R,editingView:v,deletingView:W,handleSelectView:k,handleCreateView:q,handleUpdateCurrentView:re,handleSaveAsNewView:d,handleRevertChanges:Q,handleToggleDefault:ee,handleToggleFavorite:H,handleSoftDelete:te,handleRestoreView:ue,handlePermanentDelete:le,handleEditView:Z,handleCloneView:de,handleCopyViewLink:ae,handleSaveEditView:F,handleConfirmDelete:ie,handlePromoteToGlobal:he,handleSetDefaultForAllUsers:pe,showManageColumns:Me,setShowManageColumns:L,handleUpdateColumnVisibility:Se,handleUpdateColumnOrder:ke,handleUpdateColumnWidth:We,handleResetColumnLayout:Ae,showGroupPanel:at,setShowGroupPanel:tt,handleGroup:Wt,handleToggleGroupCollapse:Bt,handleExpandAllGroups:Jt,handleCollapseAllGroups:Pr,searchQuery:Kt,debouncedSearchQuery:Lr,searchHistory:Ke,handleSearchChange:Et,handleAddToSearchHistory:Fr,handleToggleSearchFavourite:ct,handleDeleteSearchHistory:cr,selectedRowIds:Pt,handleToggleRowSelection:Nr,handleToggleAllRows:Lt,handleRangeSelection:_t,handleClearSelection:Ft,handleUpdateSelectionAfterDelete:dt,currentPage:Pe,pageSize:Vr,paginationTotalRows:Hr,paginationTotalPages:dr,handlePageChange:ur,handlePageSizeChange:Xt,isExporting:fo,showExportModal:vr,setShowExportModal:$t,showDirtyExportWarning:He,handleExport:Ce,handleExportWithConfig:Nt,handleExportSelected:ho,handleExportAnyway:mo,handleSaveAndExport:xo,handleCancelExport:Sr,showAuditHistory:wr,setShowAuditHistory:je,showCreatePreset:Cr,setShowCreatePreset:Gr,showManagePresets:mt,setShowManagePresets:N,activePreset:ut,handleCreatePreset:se,handleClearActivePreset:xt,handleOpenPresetById:fe,handleDeletePresetById:Vt,isViewerRole:Ur,userRole:pr,featureLimitWarning:jr,setFeatureLimitWarning:Qt,reportError:fr,setReportError:Ht,handleError:we,updateReport:It,showSnack:Yr,config:V,scheduler:rt}=e,[Oe,kr]=p.useState(!1);mf({reportId:r==null?void 0:r.id,reportName:(r==null?void 0:r.name)||"Report",uploadedData:(r==null?void 0:r.uploadedData)||[],processedData:i||[],schema:(r==null?void 0:r.schema)||[],activeView:l,views:(r==null?void 0:r.views)||[],columnVisibility:(r==null?void 0:r.columnVisibility)||((zr=l==null?void 0:l.snapshot)==null?void 0:zr.columnVisibility)||{},columnOrder:(r==null?void 0:r.columnOrder)||((Jr=l==null?void 0:l.snapshot)==null?void 0:Jr.columnOrder)||[],filters:qe(r==null?void 0:r.filters),sortStack:(r==null?void 0:r.sortStack)||[],onFired:me=>{Yr(`Scheduled export "${me.name}" completed`,"success")},schedulerConfig:rt});const Zt=p.useCallback((me,oe)=>{if(!(r!=null&&r.uploadedData))return;const be=r.uploadedData[me],Ge=[...r.uploadedData];Ge[me]=oe;const Le=$o(r.id,"user","rows","row_edited",be,oe),lt=Io(r.auditHistory||[],Le);It(r.id,{uploadedData:Ge,auditHistory:lt})},[r,It]),gt=p.useCallback(me=>{if(!(r!=null&&r.uploadedData))return;const oe=r.uploadedData.indexOf(me);if(oe===-1)return;const be=r.uploadedData.filter((lt,Qe)=>Qe!==oe),Ge=$o(r.id,"user","rows","row_deleted",me,null),Le=Io(r.auditHistory||[],Ge);It(r.id,{uploadedData:be,auditHistory:Le}),dt(me)},[r,It,dt]),Tr=p.useCallback((me,oe)=>{if(!(r!=null&&r.uploadedData))return;const be=r.uploadedData.indexOf(oe),Ge=be!==-1?be+1:me+1,Le=[...r.uploadedData];Le.splice(Ge,0,{...oe});const lt=$o(r.id,"user","rows","row_duplicated",oe,{...oe}),Qe=Io(r.auditHistory||[],lt);It(r.id,{uploadedData:Le,auditHistory:Qe})},[r,It]),nt=Rr(),{handleDevConfigChange:go}=yn(),[qr,St]=p.useState(!1);return p.useEffect(()=>{const me=oe=>{oe.ctrlKey&&oe.shiftKey&&oe.key==="D"&&(oe.preventDefault(),St(!0))};return document.addEventListener("keydown",me),()=>document.removeEventListener("keydown",me)},[]),!r||!r.schemaLocked||!r.schema||!r.uploadedData||!r.views?null:t.jsxs(n.Box,{sx:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,position:"relative"},children:[t.jsxs(n.Box,{id:"table-content-area",sx:{flex:1,minHeight:0,display:"flex",flexDirection:"column",position:"relative"},children:[jr&&t.jsx(qp,{warning:jr,onDismiss:()=>Qt(null)}),fr&&t.jsx(Jp,{error:fr,onDismiss:()=>Ht(null)}),He&&t.jsx(_p,{onExportAnyway:mo,onSaveAndExport:xo,onCancel:Sr}),t.jsx(bp,{schema:r.schema,data:o,sortStack:r.sortStack,filters:r.filters,views:r.views,activeViewId:r.activeViewId,isDirty:c,isExporting:fo,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:j,onSortAscending:z,onSortDescending:h,onOpenFilters:()=>g(!0),onOpenSort:()=>B(!0),onOpenFilterForColumn:b,onSelectView:k,onCreateView:()=>A(!0),onUpdateCurrentView:re,onSaveAsNewView:d,onDiscardChanges:Q,onToggleDefault:ee,onToggleFavorite:H,onRestoreView:ue,onPermanentDelete:le,onEditView:Z,onCloneView:de,onCopyLink:ae,onDeleteView:te,onPromoteToGlobal:he,onSetDefaultForAllUsers:pe,isAdmin:((Br=nt.views)==null?void 0:Br.isAdmin)??!1,hideViewMenuActions:V==null?void 0:V.hideViewMenuActions,customViewMenuActions:V==null?void 0:V.customViewMenuActions,viewMenuActionData:i,viewMenuActionTableState:u??null,onExport:Ce,onOpenColumns:()=>L(!0),onUpdateColumnWidth:We,onUpdateColumnOrder:ke,onUpdateColumnVisibility:Se,onClearFiltersForColumn:m,onResetLayout:Ae,onOpenGroup:()=>tt(!0),onGroupByColumn:(Kr=V==null?void 0:V.hideToolbarActions)!=null&&Kr.includes("grouping")?void 0:me=>{var Ge;const oe=r==null?void 0:r.grouping;if(!((oe==null?void 0:oe.enabled)&&(oe==null?void 0:oe.levels)&&oe.levels.length>0))Wt({enabled:!0,levels:[{column:me}],collapsedGroups:[]});else{if(oe.levels.some(Qe=>Qe.column===me))return;const lt=((Ge=nt.grouping)==null?void 0:Ge.maxLevels)??3;if(oe.levels.length>=lt)return;Wt({enabled:!0,levels:[...oe.levels,{column:me}],collapsedGroups:oe.collapsedGroups})}},onToggleGroupCollapse:Bt,onExpandAllGroups:Jt,onCollapseAllGroups:Pr,onOpenAuditHistory:()=>je(!0),onOpenScheduledReports:()=>kr(!0),searchQuery:Kt,highlightQuery:Lr,searchHistory:Ke,onAddToSearchHistory:Fr,onToggleSearchFavourite:ct,onDeleteSearchHistory:cr,selectedRowIds:Pt,onSearchChange:Et,onToggleRowSelection:Nr,onToggleAllRows:Lt,onRangeSelection:_t,onClearSelection:Ft,onExportSelected:ho,currentPage:Pe,pageSize:Vr,onPageChange:ur,onPageSizeChange:Xt,totalRowsBeforePagination:Hr,totalPagesOverride:dr,isReadOnly:Ur,userRole:pr,reportName:r.name,onEditRow:Zt,onDeleteRow:gt,onDuplicateRow:Tr,rowActions:V==null?void 0:V.rowActions,hideDefaultRowActions:V==null?void 0:V.hideDefaultRowActions,hideToolbarActions:V==null?void 0:V.hideToolbarActions,customSettingsActions:V==null?void 0:V.customSettingsActions,jsonGuideContent:V==null?void 0:V.jsonGuideContent,jsonGuideTitle:V==null?void 0:V.jsonGuideTitle,jsonGuideTooltip:V==null?void 0:V.jsonGuideTooltip,viewOptions:V==null?void 0:V.viewOptions,cardSlots:V==null?void 0:V.cardSlots,defaultViewMode:V==null?void 0:V.defaultViewMode,bulkActions:V==null?void 0:V.bulkActions,hideSelectionCheckboxes:V==null?void 0:V.hideSelectionCheckboxes,rowClickBehavior:V==null?void 0:V.rowClickBehavior,openModalOn:V==null?void 0:V.openModalOn,onRowClick:V==null?void 0:V.onRowClick,onRowRightClick:V==null?void 0:V.onRowRightClick,showDevPanel:nt.display.showDevPanel,onOpenDevConfig:()=>St(!0)})]}),x&&t.jsx(sn,{feature:"Filters",onError:me=>{const oe=gr("ui","filters",me);we(oe)},children:t.jsx(Cp,{schema:r.schema,filters:r.filters,onReplaceFilters:S,onClose:T,focusColumn:y,onOpenDevConfig:()=>St(!0)})}),f&&t.jsx(sn,{feature:"Sorting",onError:me=>{const oe=gr("ui","sorting",me);we(oe)},children:t.jsx(kp,{schema:r.schema,sortStack:r.sortStack??[],onUpdateSortStack:D,onClose:()=>B(!1),onOpenDevConfig:()=>St(!0)})}),I&&u&&(()=>{var be;const me=(r.views??[]).filter(Ge=>!Ge.isDeleted).length,oe=((be=nt.views)==null?void 0:be.maxViews)??10;return t.jsx(Ds,{currentSnapshot:u,onSave:q,onClose:()=>A(!1),atViewLimit:me>=oe,maxViews:oe})})(),$&&v&&t.jsx(Ds,{currentSnapshot:v.snapshot,onSave:F,onClose:()=>{Y(!1)},isEditMode:!0,initialName:v.name,initialDescription:v.description,initialIsDefault:v.isDefault}),X&&W&&t.jsx(Tp,{viewName:W.name,onConfirm:ie,onCancel:()=>{R(!1)}}),Me&&l&&t.jsx(Bp,{schema:r.schema,columnVisibility:r.columnVisibility||l.snapshot.columnVisibility,columnOrder:r.columnOrder||l.snapshot.columnOrder,columnWidths:r.columnWidths||l.snapshot.columnWidths,views:r.views,activeViewId:r.activeViewId,onUpdateColumnVisibility:Se,onUpdateColumnOrder:ke,onUpdateColumnWidth:We,onResetLayout:Ae,onClose:()=>L(!1)}),at&&t.jsx(sn,{feature:"Grouping",onError:me=>{const oe=gr("ui","grouping",me);we(oe)},children:t.jsx(Ep,{schema:r.schema,grouping:r.grouping||null,onApply:Wt,onClose:()=>tt(!1),onOpenDevConfig:()=>St(!0)})}),wr&&t.jsx(Dp,{auditHistory:r.auditHistory||[],onClose:()=>je(!1)}),Cr&&t.jsx(Op,{onSave:se,onClose:()=>Gr(!1)}),mt&&t.jsx(Ap,{presets:r.presets||[],reportId:r.id,onOpenPreset:fe,onDeletePreset:Vt,onClose:()=>N(!1)}),ut&&t.jsx(n.Box,{sx:{mt:2},children:t.jsx(Mp,{presetName:ut.name,onClear:xt})}),vr&&t.jsx(sn,{feature:"Export",onError:me=>{const oe=gr("ui","export",me);we(oe)},children:t.jsx(Yp,{totalRows:(s==null?void 0:s.totalRows)||((Er=r.uploadedData)==null?void 0:Er.length)||0,visibleRows:(s==null?void 0:s.searchedRows)||i.length,visibleColumnsCount:((_r=a==null?void 0:a.columnEngine)==null?void 0:_r.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:Nt,onClose:()=>{$t(!1)}})}),r&&t.jsx(ff,{open:Oe,onClose:()=>kr(!1),reportId:r.id,reportName:r.name,views:r.views||[],schedulerConfig:rt,onRunNow:me=>{var wt;const oe=(rt==null?void 0:rt.mode)??"local",be=me.viewId?(r.views||[]).find(tr=>tr.id===me.viewId):void 0,Ge=be?be.snapshot.filters:qe(r.filters),Le=be?be.snapshot.sortStack:r.sortStack||[],lt=be?be.snapshot.columnVisibility:r.columnVisibility,Qe=be?be.snapshot.columnOrder:r.columnOrder,$r=me.scope==="all"?r.uploadedData||[]:be?vi(Bi(r.uploadedData||[],Ge,r.schema||[]),r.schema||[],Le):i||[],er=cn($r,r.schema||[],Ge,Le,be||l,lt,Qe);if(oe==="api"){const tr=(Qe||[]).filter(Ir=>(lt??{})[Ir]!==!1);(wt=rt==null?void 0:rt.onScheduleFire)==null||wt.call(rt,{schedule:me,triggeredAt:new Date().toISOString(),rows:$r,columns:tr,format:me.format,reportName:r.name})}else me.format==="csv"&&dn(er,me.name),me.format==="excel"&&un(er,me.name),me.format==="json"&&pn(er,me.name),me.format==="pdf"&&zi(er,me.name);Yr(`"${me.name}" exported successfully`,"success")}}),t.jsx(ef,{open:qr,onClose:()=>St(!1),config:nt,onApply:go})]})}const xf={error:"err",warning:"warn",info:"info",success:"suc"};function Ba({open:e,message:r,severity:o,onClose:i,autoHideDurationMs:s}){var D,z,h,I;const a=n.useTheme(),l=a.tokens,c=(l==null?void 0:l.notifPosition)??"bottom-right",u=(l==null?void 0:l.notifStyle)??"toast",x=(l==null?void 0:l.notifAccent)??"severity",g=(l==null?void 0:l.notifAutoDismiss)??!0,y=(l==null?void 0:l.toastW)??252,S=c.startsWith("top")?"top":"bottom",b=c.endsWith("center")?"center":c.endsWith("left")?"left":"right",T=xf[o],m=((D=l==null?void 0:l.status)==null?void 0:D[`${T}Soft`])??a.palette[o].light,f=((z=l==null?void 0:l.status)==null?void 0:z[`${T}Txt`])??a.palette[o].dark,B=x==="primary"?a.palette.primary.main:x==="mono"?a.palette.text.secondary:f,j=u==="toast"?(l==null?void 0:l.toastBg)??a.palette.background.paper:m;return t.jsx(n.Snackbar,{open:e,autoHideDuration:g?s??(l!=null&&l.autoDismissSec?l.autoDismissSec*1e3:3e4):void 0,onClose:(A,$)=>{$!=="escapeKeyDown"&&i()},anchorOrigin:{vertical:S,horizontal:b},children:t.jsx(n.Alert,{severity:o,icon:u==="toast"?t.jsx(n.Box,{sx:{width:30,height:30,borderRadius:`${Math.max(Math.round((Number(a.shape.borderRadius)||4)*.6),2)}px`,bgcolor:((h=l==null?void 0:l.status)==null?void 0:h[`${T}Soft`])??a.palette[o].light,color:((I=l==null?void 0:l.status)==null?void 0:I[`${T}Txt`])??a.palette[o].dark,display:"grid",placeItems:"center",flexShrink:0,fontSize:"15px",fontWeight:800,mt:-.5,ml:-.5},children:o==="error"||o==="warning"?"!":o==="success"?"✓":"i"}):void 0,action:t.jsxs(n.Box,{sx:{display:"flex",alignItems:"center",gap:1},children:[g&&(l==null?void 0:l.autoDismissSec)&&t.jsx(n.Box,{sx:{px:1,py:.25,borderRadius:"999px",bgcolor:M(B,.14),color:B,fontSize:"0.7rem",fontWeight:800,fontVariantNumeric:"tabular-nums"},children:`${l.autoDismissSec}s`}),t.jsx(n.IconButton,{size:"small",onClick:i,sx:{color:"text.secondary",p:.25},children:t.jsx(_.Close,{sx:{fontSize:16}})})]}),sx:{width:y,alignItems:"flex-start",bgcolor:j,color:f,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 ${B}`:void 0,borderRadius:`${a.shape.borderRadius}px`,"& .MuiAlert-icon":{color:B}},children:t.jsxs(n.Box,{children:[u==="toast"&&t.jsx(n.Box,{sx:{fontWeight:700,mb:"2px",fontSize:"0.875rem",color:a.palette.text.primary},children:o==="error"?"Error":o==="warning"?"Warning":o==="success"?"Success":"Info"}),t.jsx(n.Box,{sx:{fontSize:"0.8125rem",lineHeight:1.4},children:r})]})})})}function Ea({hasExternalData:e=!1}){const r=yn(),{reports:o,activeReportId:i,activeReport:s,uploadState:a,hasSchemaConflicts:l,isModalOpen:c,setIsModalOpen:u,setActiveReportId:x,createReport:g,handleFileUpload:y,handleUploadError:S,handleRetry:b,handleConfirm:T,snack:m,handleSnackClose:f,snackDurationMs:B,config:j}=r,D=e&&a==="uploading"&&o.length===0;return t.jsxs(n.Box,{sx:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:[t.jsx(mu,{onCreateReport:()=>u(!0),reports:o,activeReportId:i,onReportClick:x}),t.jsx(n.Box,{component:"main",sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",m:0,p:0},children:D?t.jsxs(n.Box,{sx:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:[t.jsx(n.CircularProgress,{size:40,thickness:3}),t.jsx(n.Typography,{variant:"body2",color:"text.secondary",sx:{minWidth:260,textAlign:"center"},children:"Fetching API data — please wait..."})]}):o.length===0?t.jsx(ma,{title:"No reports yet",action:{label:"New Report",onClick:()=>u(!0)}}):s?t.jsx(t.Fragment,{children:s.schemaLocked&&s.schema&&s.uploadedData&&s.views?t.jsx(za,{reportEngine:r}):t.jsx(n.Box,{sx:{p:3},children:a==="preview"&&s.schema&&s.uploadedData?t.jsx(wu,{schema:s.schema,onConfirm:T,hasConflicts:l}):s.uploadError?t.jsx(Cu,{error:s.uploadError,onRetry:b}):t.jsx(Su,{onFileUpload:y,onError:S,isUploading:a==="uploading",jsonGuideContent:j==null?void 0:j.jsonGuideContent,jsonGuideTitle:j==null?void 0:j.jsonGuideTitle,jsonGuideTooltip:j==null?void 0:j.jsonGuideTooltip})})}):null}),!e&&t.jsx(vu,{isOpen:c,onClose:()=>u(!1),onCreate:g}),t.jsx(Ba,{open:m.open,message:m.message,severity:m.severity,onClose:f,autoHideDurationMs:B})]})}function gf({data:e,dataSource:r,pagination:o,search:i,reportName:s,reportId:a,autoLoad:l=!0,config:c}={}){return t.jsx(Ei,{mode:"builder",data:e,dataSource:r,pagination:o,search:i,reportName:s,reportId:a,autoLoad:l,config:c,children:t.jsx(Ea,{hasExternalData:!!(e||r)})})}function _a(){const e=yn(),{snack:r,handleSnackClose:o,snackDurationMs:i}=e;return t.jsxs(n.Box,{sx:{height:"100%",overflow:"hidden",display:"flex",flexDirection:"column"},children:[t.jsx(n.Box,{component:"main",sx:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:e.activeReport?t.jsx(za,{reportEngine:e}):t.jsx(ma,{title:"No report data",description:"This viewer requires report data to be loaded."})}),t.jsx(Ba,{open:r.open,message:r.message,severity:r.severity,onClose:o,autoHideDurationMs:i})]})}function yf({data:e,reportId:r,pagination:o,search:i,autoLoad:s=!0,config:a}){return t.jsx(Ei,{data:e,reportId:r,pagination:o,search:i,mode:"viewer",autoLoad:s,config:a,children:t.jsx(_a,{})})}exports.URMBuilder=gf;exports.URMBuilderRaw=Ea;exports.URMProvider=Ei;exports.URMViewer=yf;exports.URMViewerRaw=_a;exports.useURMContext=yn;