@alaarab/ogrid-core 2.5.9 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
function me(t){if(t)return {id:t.id,displayName:t.displayName,email:"email"in t&&t.email?t.email:t.mail||t.userPrincipalName||"",photo:t.photo}}function F(t,e,n){let r=Math.min(t.startRow,t.endRow),o=Math.max(t.startRow,t.endRow),l=Math.min(t.startCol,t.endCol),i=Math.max(t.startCol,t.endCol);return e>=r&&e<=o&&n>=l&&n<=i}function R(t){return {startRow:Math.min(t.startRow,t.endRow),endRow:Math.max(t.startRow,t.endRow),startCol:Math.min(t.startCol,t.endCol),endCol:Math.max(t.startCol,t.endCol)}}function k(t){if(t==null)return "";let e=String(t);return e.includes(",")||e.includes('"')||e.includes(`
|
|
2
|
-
`)?`"${e.replace(/"/g,'""')}"`:e}function
|
|
3
|
-
`);K(a,r??`export_${new Date().toISOString().slice(0,10)}.csv`);}function K(t,e){let n=new Blob([t],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(n),o=document.createElement("a");try{o.setAttribute("href",r),o.setAttribute("download",e),o.style.visibility="hidden",document.body.appendChild(o),o.click();}finally{try{document.body.removeChild(o);}catch{}URL.revokeObjectURL(r);}}function x(t,e){return e.valueGetter?e.valueGetter(t):t[e.columnId]}function h(t,e){return t.editable===true||typeof t.editable=="function"&&t.editable(e)}function pe(t,e){return {getCellValue:(n,r)=>r<0||r>=t.length||n<0||n>=e.length?null:x(t[r],e[n]),getRowCount:()=>t.length,getColumnCount:()=>e.length}}function L(t){return "children"in t&&Array.isArray(t.children)}function Z(t){let e=[];for(let n of t)L(n)?e.push(...Z(n.children)):e.push(n);return e}function ge(t,e){function n(m,c){let d=c;for(let s of m)L(s)&&(d=Math.max(d,n(s.children,c+1)));return d}let r=n(t,0);if(r===0){let m=[];for(let c of t)if(!L(c)){if(e&&!e.has(c.columnId))continue;m.push({label:c.name,colSpan:1,isGroup:false,columnDef:c,depth:0});}return [m]}let o=r+1,l=Array.from({length:o},()=>[]),i=new Map;function a(m){let c=i.get(m);if(c!==void 0)return c;let d=0;for(let s of m)L(s)?d+=a(s.children):(!e||e.has(s.columnId))&&d++;return i.set(m,d),d}function u(m,c){for(let d of m)if(L(d)){let s=a(d.children);if(s===0)continue;l[c].push({label:d.headerName,colSpan:s,isGroup:true,depth:c}),u(d.children,c+1);}else {if(e&&!e.has(d.columnId))continue;l[c].push({label:d.name,colSpan:1,isGroup:false,columnDef:d,depth:c});}}return u(t,0),l.filter(m=>m.length>0)}function v(t){return t!=null&&typeof t=="object"&&"type"in t}function w(t){return (v(t.filterable)?t.filterable:null)?.filterField??t.columnId}function Ce(t,e,n){if(n===void 0||n.type==="text"&&n.value.trim()===""||n.type==="multiSelect"&&n.value.length===0||n.type==="date"&&!n.value.from&&!n.value.to||n.type==="people"&&!n.value){let{[e]:o,...l}=t;return l}return {...t,[e]:n}}function Ie(t,e){let n=[];for(let l=0;l<e.length;l++){let i=e[l];(v(i.filterable)?i.filterable:null)?.type==="multiSelect"&&n.push({col:i,field:w(i)});}if(n.length===0)return {};let r=new Map;for(let l=0;l<n.length;l++)r.set(n[l].field,new Set);for(let l=0;l<t.length;l++){let i=t[l];for(let a=0;a<n.length;a++){let u=x(i,n[a].col),m=r.get(n[a].field);u!=null&&u!==""&&m&&m.add(String(u));}}let o={};for(let l=0;l<n.length;l++){let i=r.get(n[l].field);o[n[l].field]=i?Array.from(i).sort():[];}return o}function be(t){let e=[];for(let n of t)(v(n.filterable)?n.filterable:null)?.type==="multiSelect"&&e.push(w(n));return e}function xe(t){let{totalCount:e,filteredCount:n,selectedCount:r,selectedCellCount:o,aggregation:l,suppressRowCount:i}=t,a=[];return i||a.push({key:"total",label:"Rows:",value:e}),n!==void 0&&n!==e&&a.push({key:"filtered",label:"Filtered:",value:n}),r!==void 0&&r>0&&a.push({key:"selected",label:"Selected:",value:r}),o!==void 0&&o>1&&a.push({key:"cells",label:"Cells:",value:o}),l&&(a.push({key:"sum",label:"Sum:",value:l.sum}),a.push({key:"avg",label:"Avg:",value:Math.round(l.avg*100)/100}),a.push({key:"min",label:"Min:",value:l.min}),a.push({key:"max",label:"Max:",value:l.max}),a.push({key:"count",label:"Count:",value:l.count})),a}function he(t,e,n,r){return t?typeof t=="object"?t:{totalCount:e,selectedCount:n>0?n:void 0,filteredCount:r!==void 0&&r!==e?r:void 0}:null}var Q=[10,25,50,100];function Lt(t,e){return e.includes(t)?e:[...e,t].sort((n,r)=>n-r)}var J=5;function Re(t,e,n,r){if(n<=0)return null;let o=r?.maxPageButtons??J,l=Math.ceil(n/e),i,a,u;if(l<=o){i=[];for(let d=1;d<=l;d++)i.push(d);a=false,u=false;}else {let d=Math.max(1,t-2),s=Math.min(l,t+2);s-d+1<o&&(d===1?s=Math.min(l,d+o-1):s===l&&(d=Math.max(1,s-o+1))),i=[];for(let f=d;f<=s;f++)i.push(f);a=d>1,u=s<l;}let m=Math.max(1,(t-1)*e+1),c=Math.min(t*e,n);return {totalPages:l,pageNumbers:i,showStartEllipsis:a,showEndEllipsis:u,startItem:m,endItem:c,pageSizeOptions:Lt(e,r?.pageSizeOptions??Q)}}var ye=[{id:"undo",label:"Undo",shortcut:"Ctrl+Z"},{id:"redo",label:"Redo",shortcut:"Ctrl+Y"},{id:"copy",label:"Copy",shortcut:"Ctrl+C",disabledWhenNoSelection:true,dividerBefore:true},{id:"cut",label:"Cut",shortcut:"Ctrl+X",disabledWhenNoSelection:true},{id:"paste",label:"Paste",shortcut:"Ctrl+V"},{id:"selectAll",label:"Select all",shortcut:"Ctrl+A",dividerBefore:true}];function Te(t){return typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)?t.replace("Ctrl","\u2318"):t}function Se(t){let{onCopy:e,onCut:n,onPaste:r,onSelectAll:o,onUndo:l,onRedo:i,onClose:a}=t;return {undo:()=>{l(),a();},redo:()=>{i(),a();},copy:()=>{e(),a();},cut:()=>{n(),a();},paste:()=>{r(),a();},selectAll:()=>{o(),a();}}}var we=[{id:"pinLeft",label:"Pin left"},{id:"pinRight",label:"Pin right"},{id:"unpin",label:"Unpin"}];function De(t){let{canPinLeft:e,canPinRight:n,canUnpin:r,currentSort:o,isSortable:l=true,isResizable:i=true}=t,a=[];if(a.push({id:"pinLeft",label:"Pin left",disabled:!e},{id:"pinRight",label:"Pin right",disabled:!n},{id:"unpin",label:"Unpin",disabled:!r,divider:l||i}),l)if(!o)a.push({id:"sortAsc",label:"Sort ascending"},{id:"sortDesc",label:"Sort descending",divider:i});else {let u=o==="asc"?"desc":"asc",m=o==="asc"?"Sort descending":"Sort ascending";a.push({id:`sort${u==="asc"?"Asc":"Desc"}`,label:m},{id:"clearSort",label:"Clear sort",divider:i});}return i&&a.push({id:"autosizeThis",label:"Autosize this column"},{id:"autosizeAll",label:"Autosize all columns"}),a}function T(t,e,n,r){if(r.valueParser){let l={newValue:t,oldValue:e,data:n,column:r},i=r.valueParser(l);return i===void 0?{valid:false,value:void 0}:{valid:true,value:i}}if(r.cellEditor==="select"&&r.cellEditorParams?.values!=null&&Array.isArray(r.cellEditorParams.values)){let l=r.cellEditorParams.values,i=typeof t=="string"?t:String(t??"");if(i==="")return {valid:true,value:""};let a=l.find(u=>String(u).toLowerCase()===i.toLowerCase());return a!==void 0?{valid:true,value:a}:{valid:false,value:void 0}}let o=r.type;if(o==="date"){let l=te({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}if(o==="boolean"){let l=ne({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}if(o==="numeric"){let l=ee({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}return {valid:true,value:t}}function ee(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).replace(/[\s,]/g,""),r=Number(n);return Number.isNaN(r)?void 0:r}function ve(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).replace(/[$\u20AC\u00A3\u00A5]/g,"").replace(/[\s,]/g,""),r=Number(n);return Number.isNaN(r)?void 0:r}function te(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim(),r=new Date(n);if(!Number.isNaN(r.getTime()))return r.toISOString()}function Ee(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim();return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?n:void 0}function ne(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim().toLowerCase();if(["true","yes","1"].includes(n))return true;if(["false","no","0"].includes(n))return false}function Fe(t,e,n){if(!n)return null;let r=R(n),o=0,l=0,i=1/0,a=-1/0,u=0;for(let m=r.startRow;m<=r.endRow;m++)for(let c=r.startCol;c<=r.endCol;c++){if(m>=t.length||c>=e.length)continue;o++;let d=t[m],s=e[c],f=x(d,s),g=typeof f=="number"?f:Number(f);!isNaN(g)&&isFinite(g)&&(l+=g,g<i&&(i=g),g>a&&(a=g),u++);}return o<2||u===0?null:{sum:l,avg:l/u,min:i,max:a,count:u}}var Me=new WeakMap;function M(t,e,n,r,o){let l=Me.get(e);if(!l){l=new Map;for(let m=0;m<e.length;m++)l.set(e[m].columnId,e[m]);Me.set(e,l);}let i=[];for(let m=0;m<e.length;m++){let c=e[m],d=w(c),s=n[d];if(s)switch(s.type){case "multiSelect":if(s.value.length>0){let f=new Set(s.value);i.push(g=>f.has(String(x(g,c))));}break;case "text":{let f=s.value.trim();if(f){let g=f.toLowerCase(),p=new Map;for(let I=0;I<t.length;I++)p.set(t[I],String(x(t[I],c)??"").toLowerCase());i.push(I=>(p.get(I)??"").includes(g));}break}case "people":{let f=s.value.email.toLowerCase(),g=new Map;for(let p=0;p<t.length;p++)g.set(t[p],String(x(t[p],c)??"").toLowerCase());i.push(p=>(g.get(p)??"")===f);break}case "date":{let f=s.value,g=f.from?new Date(f.from+"T00:00:00").getTime():NaN,p=f.to?new Date(f.to+"T23:59:59.999").getTime():NaN,I=new Map;for(let C=0;C<t.length;C++){let b=x(t[C],c);if(b==null)I.set(t[C],NaN);else {let y=new Date(String(b)).getTime();I.set(t[C],Number.isNaN(y)?NaN:y);}}i.push(C=>{let b=I.get(C)??NaN;return !(Number.isNaN(b)||!Number.isNaN(g)&&b<g||!Number.isNaN(p)&&b>p)});break}}}let a=i.length>0,u=a?t.filter(m=>{for(let c=0;c<i.length;c++)if(!i[c](m))return false;return true}):t;if(r){let m=a?u:u.slice(),c=l.get(r),d=c?.compare,s=o==="asc"?1:-1;if(c?.type==="date"&&!d){let g=new Map;for(let p=0;p<m.length;p++){let I=m[p],C=c?x(I,c):I[r];if(C==null)g.set(I,NaN);else {let b=new Date(String(C)).getTime();g.set(I,Number.isNaN(b)?0:b);}}m.sort((p,I)=>{let C=g.get(p)??NaN,b=g.get(I)??NaN;return Number.isNaN(C)&&Number.isNaN(b)?0:Number.isNaN(C)?-1*s:Number.isNaN(b)?1*s:C===b?0:C>b?s:-s});}else if(d)m.sort((g,p)=>d(g,p)*s);else {let g=new Map;for(let p=0;p<m.length;p++){let I=m[p],C=c?x(I,c):I[r];C==null?g.set(I,void 0):typeof C=="number"?g.set(I,C):g.set(I,String(C).toLowerCase());}m.sort((p,I)=>{let C=g.get(p),b=g.get(I);return C===void 0&&b===void 0?0:C===void 0?-1*s:b===void 0?1*s:C===b?0:C>b?s:-s});}return m}return u}function D(t,e){if(!t)return false;let n=Math.min(t.startRow,t.endRow),r=Math.max(t.startRow,t.endRow);return e>=n&&e<=r}function Pe(t,e){if(t.item!==e.item||t.isSelected!==e.isSelected||t.hasCheckboxCol!==e.hasCheckboxCol||t.visibleCols!==e.visibleCols||t.columnMeta!==e.columnMeta||t.cellClassMap!==e.cellClassMap||t.columnLayouts!==e.columnLayouts)return false;let n=t.rowIndex;if(t.editingRowId!==e.editingRowId&&(t.editingRowId===t.rowId||e.editingRowId===e.rowId))return false;let r=t.activeCell?.rowIndex===n,o=e.activeCell?.rowIndex===n;if(r!==o||r&&o&&t.activeCell?.columnIndex!==e.activeCell?.columnIndex)return false;let l=D(t.selectionRange,n),i=D(e.selectionRange,n);if(l!==i||l&&i&&(t.selectionRange?.startCol!==e.selectionRange?.startCol||t.selectionRange?.endCol!==e.selectionRange?.endCol))return false;let a=t.selectionRange?.endRow===n,u=e.selectionRange?.endRow===n;return !(a!==u||(a||u)&&t.isDragging!==e.isDragging||t.cutRange!==e.cutRange&&(D(t.cutRange,n)||D(e.cutRange,n))||t.copyRange!==e.copyRange&&(D(t.copyRange,n)||D(e.copyRange,n)))}function re(t,e){return e?e.left?.includes(t)?"left":e.right?.includes(t)?"right":"unpinned":"unpinned"}function Ne(t,e,n){let r=t.filter(i=>i!==e),o=Math.max(0,Math.min(n,r.length)),l=[...r];return l.splice(o,0,e),l}function Ae(t){let{mouseX:e,columnOrder:n,draggedColumnId:r,draggedPinState:o,tableElement:l,pinnedColumns:i}=t,a=l.querySelectorAll("[data-column-id]");if(a.length===0)return null;let u=[];if(a.forEach(s=>{let f=s.getAttribute("data-column-id");if(!f||re(f,i)!==o)return;let p=s.getBoundingClientRect(),I=n.indexOf(f);I!==-1&&u.push({columnId:f,left:p.left,right:p.right,midX:p.left+p.width/2,orderIndex:I});}),u.length===0)return null;u.sort((s,f)=>s.left-f.left);let m,c;if(e<=u[0].midX)m=u[0].orderIndex,c=u[0].left;else if(e>=u[u.length-1].midX){let s=u[u.length-1];m=s.orderIndex+1,c=s.right;}else {let s=-1;for(let f=0;f<u.length-1;f++)if(e>=u[f].midX&&e<u[f+1].midX){s=f;break}if(s===-1)return null;m=u[s].orderIndex+1,c=u[s].right;}let d=n.indexOf(r);return d===m||d+1===m?{targetIndex:m,indicatorX:null}:{targetIndex:m,indicatorX:c}}function _e(t,e,n,r=2){if(e.length===0||n<=0)return {startIndex:0,endIndex:-1,leftOffset:0,rightOffset:0};let o=0,l=e.length,i=-1;for(let d=0;d<e.length;d++){let s=o;o+=e[d],o>t&&l===e.length&&(l=d),s<t+n&&(i=d);}if(l>i)return {startIndex:0,endIndex:-1,leftOffset:0,rightOffset:0};let a=Math.max(0,l-r),u=Math.min(e.length-1,i+r),m=0;for(let d=0;d<a;d++)m+=e[d];let c=0;for(let d=u+1;d<e.length;d++)c+=e[d];return {startIndex:a,endIndex:u,leftOffset:m,rightOffset:c}}function Oe(t,e,n){let r=[],o=[],l=[];for(let a of t){let u=n?.[a.columnId];u==="left"?r.push(a):u==="right"?o.push(a):l.push(a);}if(!e||e.endIndex<0)return {pinnedLeft:r,virtualizedUnpinned:l,pinnedRight:o,leftSpacerWidth:0,rightSpacerWidth:0};let i=l.slice(e.startIndex,e.endIndex+1);return {pinnedLeft:r,virtualizedUnpinned:i,pinnedRight:o,leftSpacerWidth:e.leftOffset,rightSpacerWidth:e.rightOffset}}function ke(t,e,n,r,o=5){if(r<=0||e<=0||n<=0)return {startIndex:0,endIndex:0,offsetTop:0,offsetBottom:0};let l=Math.max(0,Math.floor(t/e)-o),i=Math.min(r-1,Math.ceil((t+n)/e)+o),a=l*e,u=Math.max(0,(r-i-1)*e);return {startIndex:l,endIndex:i,offsetTop:a,offsetBottom:u}}function Le(t,e){return t*e}function Ve(t,e,n,r="start"){let o=t*e;switch(r){case "start":return o;case "center":return Math.max(0,o-(n-e)/2);case "end":return Math.max(0,o-n+e)}}function Ue(){let t=self;t.onmessage=e=>{let n=e.data;if(n.type!=="sort-filter")return;let{requestId:r,values:o,filters:l,sort:i}=n,a=o.length,u=[],m=Object.entries(l);if(m.length===0){u=new Array(a);for(let d=0;d<a;d++)u[d]=d;}else for(let d=0;d<a;d++){let s=true;for(let f=0;f<m.length;f++){let g=Number(m[f][0]),p=m[f][1],I=o[d][g];switch(p.type){case "text":{let C=p.value.trim().toLowerCase();C&&!String(I??"").toLowerCase().includes(C)&&(s=false);break}case "multiSelect":{p.value.length>0&&(new Set(p.value).has(String(I??""))||(s=false));break}case "date":{if(I==null){s=false;break}let C=new Date(String(I)).getTime();if(isNaN(C)){s=false;break}if(p.value.from){let b=new Date(p.value.from+"T00:00:00").getTime();if(C<b){s=false;break}}if(p.value.to){let b=new Date(p.value.to+"T23:59:59.999").getTime();if(C>b){s=false;break}}break}}if(!s)break}s&&u.push(d);}if(i){let{columnIndex:d,direction:s}=i,f=s==="asc"?1:-1;u.sort((g,p)=>{let I=o[g][d],C=o[p][d];if(I==null&&C==null)return 0;if(I==null)return -1*f;if(C==null)return 1*f;if(typeof I=="number"&&typeof C=="number")return I===C?0:I>C?f:-f;let b=String(I).toLowerCase(),y=String(C).toLowerCase();return b===y?0:b>y?f:-f});}let c={type:"sort-filter-result",requestId:r,indices:u};t.postMessage(c);};}var S=null,Vt=0,E=new Map;function oe(){if(S)return S;if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u")return null;try{let t=Ue.toString(),e=new Blob([`(${t})()`],{type:"application/javascript"}),n=URL.createObjectURL(e);return S=new Worker(n),URL.revokeObjectURL(n),S.onmessage=r=>{let{requestId:o,indices:l}=r.data,i=E.get(o);i&&(E.delete(o),i.resolve(l));},S.onerror=r=>{for(let[o,l]of E)l.reject(new Error(r.message||"Worker error")),E.delete(o);},S}catch{return null}}function He(){S&&(S.terminate(),S=null);for(let[t,e]of E)e.reject(new Error("Worker terminated")),E.delete(t);}function le(t,e){let n=new Array(t.length);for(let r=0;r<t.length;r++){let o=new Array(e.length);for(let l=0;l<e.length;l++){let i=x(t[r],e[l]);i==null?o[l]=null:typeof i=="string"||typeof i=="number"||typeof i=="boolean"?o[l]=i:o[l]=String(i);}n[r]=o;}return n}function Be(t,e,n,r,o){if(r&&e.find(f=>f.columnId===r)?.compare)return Promise.resolve(M(t,e,n,r,o));let l=oe();if(!l)return Promise.resolve(M(t,e,n,r,o));let i=new Map;for(let s=0;s<e.length;s++)i.set(e[s].columnId,s);let a=le(t,e),u=e.map((s,f)=>({type:s.type??"text",index:f})),m={};for(let s of e){let f=w(s),g=n[f];if(!g)continue;let p=i.get(s.columnId);if(p!==void 0)switch(g.type){case "text":m[p]={type:"text",value:g.value};break;case "multiSelect":m[p]={type:"multiSelect",value:g.value};break;case "date":m[p]={type:"date",value:{from:g.value.from,to:g.value.to}};break;case "people":return Promise.resolve(M(t,e,n,r,o))}}let c;if(r){let s=i.get(r);s!==void 0&&(c={columnIndex:s,direction:o??"asc"});}let d=++Vt;return new Promise((s,f)=>{E.set(d,{resolve:p=>{let I=new Array(p.length);for(let C=0;C<p.length;C++)I[C]=t[p[C]];s(I);},reject:f});let g={type:"sort-filter",requestId:d,values:a,columnMeta:u,filters:m,sort:c};l.postMessage(g);})}var B="YYYY-MM-DD";function G(t,e,n="UTC"){if(t==null)return null;let r=t instanceof Date?t:new Date(String(t));if(Number.isNaN(r.getTime()))return null;let o,l,i;if(n==="UTC")o=r.getUTCFullYear(),l=r.getUTCMonth()+1,i=r.getUTCDate();else {let d=new Intl.DateTimeFormat("en-CA",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(r);o=parseInt(d.find(s=>s.type==="year")?.value??"0",10),l=parseInt(d.find(s=>s.type==="month")?.value??"0",10),i=parseInt(d.find(s=>s.type==="day")?.value??"0",10);}let a=String(o).padStart(4,"0"),u=String(l).padStart(2,"0"),m=String(i).padStart(2,"0");return e.replace("YYYY",a).replace("MM",u).replace("DD",m)}function Ge(t,e){if(!t||!t.trim())return null;let r=t.trim().split(/[/\-.\s]+/).filter(Boolean);if(r.length===0)return null;let o=new Date().getUTCFullYear(),l=Ut(e),i,a,u;if(r.length===3){let[c,d,s]=r.map(Number);l==="YMD"?(i=c,a=d,u=s):l==="DMY"?(u=c,a=d,i=s):(a=c,u=d,i=s),i!==void 0&&i<100&&(i=i<50?2e3+i:1900+i);}else if(r.length===2){let[c,d]=r.map(Number);l==="DMY"?(u=c,a=d):(a=c,u=d),i=o;}else if(r.length===1){let c=r[0];if(/^\d+$/.test(c))if(c.length===8)i=parseInt(c.slice(0,4),10),a=parseInt(c.slice(4,6),10),u=parseInt(c.slice(6,8),10);else if(c.length===4)a=parseInt(c.slice(0,2),10),u=parseInt(c.slice(2,4),10),i=o;else return null;else return null}else return null;if(!Ht(i,a,u))return null;let m=new Date(Date.UTC(i,a-1,u));return m.getUTCFullYear()!==i||m.getUTCMonth()+1!==a||m.getUTCDate()!==u?null:m}function We(t){return t}function Ut(t){let e=t.indexOf("Y"),n=t.indexOf("M"),r=t.indexOf("D");return e===-1||n===-1||r===-1?"MDY":e<n&&n<r?"YMD":r<n&&n<e?"DMY":"MDY"}function Ht(t,e,n){return !(t==null||e==null||n==null||!Number.isFinite(t)||!Number.isFinite(e)||!Number.isFinite(n)||e<1||e>12||n<1||n>31)}var V=class{constructor(e,n){this.type=e;this.message=n;}toString(){return this.type}};function Xe(t,e){let n=v(t.filterable)?t.filterable:null,r=n?.type??"none",o=n?.filterField??t.columnId,l=t.sortable!==false,i=e.filters[o],a={columnKey:t.columnId,columnName:t.name,filterType:r,isSorted:e.sortBy===t.columnId,isSortedDescending:e.sortBy===t.columnId&&e.sortDirection==="desc",onSort:l?()=>e.onColumnSort(t.columnId):void 0};return r==="text"?{...a,textValue:i?.type==="text"?i.value:"",onTextChange:u=>e.onFilterChange(o,u.trim()?{type:"text",value:u}:void 0)}:r==="people"?{...a,selectedUser:i?.type==="people"?i.value:void 0,onUserChange:u=>e.onFilterChange(o,u?{type:"people",value:u}:void 0),peopleSearch:e.peopleSearch}:r==="multiSelect"?{...a,options:e.filterOptions[o]??[],isLoadingOptions:e.loadingFilterOptions[o]??false,selectedValues:i?.type==="multiSelect"?i.value:[],onFilterChange:u=>e.onFilterChange(o,u.length?{type:"multiSelect",value:u}:void 0)}:r==="date"?{...a,dateValue:i?.type==="date"?i.value:void 0,onDateChange:u=>e.onFilterChange(o,u?{type:"date",value:u}:void 0)}:a}var $=class ${constructor(){this.cache=new Map;this.lastVersion="";}static computeVersion(e){let n=e.editingCell,r=e.activeCell,o=e.selectionRange,l=e.cutRange,i=e.copyRange;return (n?`${String(n.rowId)}\0${n.columnId}`:"")+""+(r?`${r.rowIndex}\0${r.columnIndex}`:"")+""+(o?`${o.startRow}\0${o.startCol}\0${o.endRow}\0${o.endCol}`:"")+""+(l?`${l.startRow}\0${l.startCol}\0${l.endRow}\0${l.endCol}`:"")+""+(i?`${i.startRow}\0${i.startCol}\0${i.endRow}\0${i.endCol}`:"")+""+(e.isDragging?"1":"0")+""+(e.editable!==false?"1":"0")+""+(e.onCellValueChanged?"1":"0")+""+(e.formulaVersion??0)}get(e,n,r,o){let l=e*$.MAX_COL_STRIDE+n,i=this.cache.get(l);if(i!==void 0&&i.version===r)return i.descriptor;let a=o();return this.cache.set(l,{version:r,descriptor:a}),a}updateVersion(e){this.lastVersion=e;}get currentVersion(){return this.lastVersion}clear(){this.cache.clear();}};$.MAX_COL_STRIDE=1024;var W=$;function qe(t,e,n,r,o,l){return l!==void 0?l.get(n,r,l.currentVersion,()=>$e(t,e,n,r,o)):$e(t,e,n,r,o)}function $e(t,e,n,r,o){let l=o.getRowId(t),i=r+o.colOffset,a=h(e,t),u=o.editable!==false&&a&&!!o.onCellValueChanged&&typeof e.cellEditor!="function",m=o.editable!==false&&a&&!!o.onCellValueChanged&&typeof e.cellEditor=="function"&&e.cellEditorPopup!==false,c=u||m,d=o.editingCell?.rowId===l&&o.editingCell?.columnId===e.columnId,s=!o.isDragging&&o.activeCell?.rowIndex===n&&o.activeCell?.columnIndex===i,f=o.selectionRange!=null&&o.selectionRange.startRow===o.selectionRange.endRow&&o.selectionRange.startCol===o.selectionRange.endCol,g=o.selectionRange!=null&&!f&&F(o.selectionRange,n,r),p=o.cutRange!=null&&F(o.cutRange,n,r),I=o.copyRange!=null&&F(o.copyRange,n,r),C=!o.isDragging&&o.copyRange==null&&o.cutRange==null&&o.selectionRange!=null&&n===o.selectionRange.endRow&&r===o.selectionRange.endCol,b=e.pinned!=null,y=e.pinned??void 0,N=x(t,e),H=o.hasFormula?.(r,n)??false,A=H?o.getFormulaValue?.(r,n):void 0,_="display",O;d&&u?(_="editing-inline",e.cellEditor==="text"||e.cellEditor==="select"||e.cellEditor==="checkbox"||e.cellEditor==="richSelect"||e.cellEditor==="date"?O=e.cellEditor:e.type==="date"?O="date":e.type==="boolean"?O="checkbox":O="text"):d&&m&&typeof e.cellEditor=="function"&&(_="editing-popover");let kt=d&&H?o.getFormula?.(r,n)??N:N;return {mode:_,editorType:O,value:kt,isActive:s,isInRange:g,isInCutRange:p,isInCopyRange:I,isSelectionEndCell:C,canEditAny:c,isPinned:b,pinnedSide:y,globalColIndex:i,rowId:l,rowIndex:n,displayValue:A!==void 0?A:N,columnType:e.type}}function ze(t,e,n){if(n instanceof V)return n.toString();let r=t;if(r.renderCell&&typeof r.renderCell=="function")return r.renderCell(e);if(t.valueFormatter)return t.valueFormatter(n,e);if(n==null)return null;if(t.type==="date"){let o=t.dateFormat??B,l=G(n,o);if(l!==null)return l}return t.type==="boolean"?n?"True":"False":String(n)}function Ye(t,e,n){let r=t,o=n instanceof V,l=r.cellStyle?typeof r.cellStyle=="function"?r.cellStyle(e):r.cellStyle:void 0;return o?{...l,color:"var(--ogrid-formula-error-color, #d32f2f)"}:l}function je(t,e,n,r){let o=n.editorType??"text";return {value:n.value,item:t,column:e,rowIndex:n.rowIndex,editorType:o,onCommit:l=>r.commitCellEdit(t,e.columnId,n.value,l,n.rowIndex,n.globalColIndex,o==="checkbox"?{skipAdvance:true}:void 0),onCancel:()=>r.setEditingCell(null)}}function Ke(t,e,n,r,o){let l=n.value,i=r!==void 0?r:l,a=r;return {value:i,onValueChange:u=>{a=u,o.setPendingEditorValue(u);},onCommit:()=>{let u=a!==void 0?a:l;o.commitCellEdit(t,e.columnId,l,u,n.rowIndex,n.globalColIndex);},onCancel:o.cancelPopoverEdit,item:t,column:e,cellEditorParams:e.cellEditorParams}}function Ze(t,e){let n=null,r=((...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{t(...o),n=null;},e);});return r.cancel=()=>{n!==null&&(clearTimeout(n),n=null);},r}function Qe(t,e,n){let r=e.startCol+n,o=e.endCol+n,l=t.querySelector(`[data-row-index="${e.startRow}"][data-col-index="${r}"]`),i=t.querySelector(`[data-row-index="${e.endRow}"][data-col-index="${o}"]`);if(!l||!i)return null;let a=t.getBoundingClientRect(),u=l.getBoundingClientRect(),m=i.getBoundingClientRect();return {top:u.top-a.top,left:u.left-a.left,width:m.right-u.left,height:m.bottom-u.top}}function Je(t){let e=new Map;if(!t)return e;let n=t.querySelectorAll("[data-row-index][data-col-index]");for(let r=0;r<n.length;r++){let o=n[r],l=o.getAttribute("data-row-index")??"",i=o.getAttribute("data-col-index")??"";e.set(`${l},${i}`,o);}return e}function et(t,e){if(typeof document>"u"||document.getElementById(t))return;let n=document.createElement("style");n.id=t,n.textContent=e,document.head.appendChild(n);}function tt(t,e,n){return n===null?{field:"",direction:"asc"}:n?{field:e,direction:n}:{field:e,direction:t.field===e&&t.direction==="asc"?"desc":"asc"}}var nt=48,rt=50,X=80,ot=16,lt=30,it="__row_number__",at=6;var ie=16,ae=520,Bt=44,Gt=8;function st(t){return Math.max(80,Math.ceil(t.length*Gt+Bt))}function Wt(t){let e=getComputedStyle(t),n=(parseFloat(e.paddingLeft)||0)+(parseFloat(e.paddingRight)||0),r=(parseFloat(e.borderLeftWidth)||0)+(parseFloat(e.borderRightWidth)||0),o=0;for(let d=0;d<t.children.length;d++){let s=t.children[d],f=s.className||"";if(f.includes("resizeHandle")||f.includes("resize-handle")||f.includes("ogrid-resize-handle")){o=s.offsetWidth;break}}let l=t.firstElementChild;if(!l)return t.offsetWidth;let i=[],a=d=>{for(let s=0;s<d.children.length;s++){let f=d.children[s],g=getComputedStyle(f);(g.overflow==="hidden"||g.flexShrink!=="0")&&(i.push({el:f,overflow:f.style.overflow,flexShrink:f.style.flexShrink,width:f.style.width,minWidth:f.style.minWidth,maxWidth:f.style.maxWidth}),f.style.overflow="visible",f.style.flexShrink="0",f.style.width="max-content",f.style.minWidth="max-content",f.style.maxWidth="none"),a(f);}},u=l.style.position,m=l.style.width;l.style.position="absolute",l.style.width="max-content",a(l);let c=l.offsetWidth;l.style.position=u,l.style.width=m;for(let d of i)d.el.style.overflow=d.overflow,d.el.style.flexShrink=d.flexShrink,d.el.style.width=d.width,d.el.style.minWidth=d.minWidth,d.el.style.maxWidth=d.maxWidth;return c+o+n+r}function ut(t,e,n){let r=e??80,l=(n??document).querySelectorAll(`[data-column-id="${t}"]`);if(l.length===0)return r;let i=r,a=[],u=[],m=[];if(l.forEach(c=>{let d=c;if(!!d.querySelector?.("[data-header-label]"))i=Math.max(i,Wt(d));else {let f=d.firstElementChild??d;a.push(f);}}),a.length>0){for(let c=0;c<a.length;c++){let d=a[c];u.push(d.style.position),m.push(d.style.width),d.style.position="absolute",d.style.width="max-content";}for(let c=0;c<a.length;c++)i=Math.max(i,a[c].offsetWidth+ie);for(let c=0;c<a.length;c++)a[c].style.position=u[c],a[c].style.width=m[c];}return Math.min(ae,Math.max(r,Math.ceil(i)))}function P(t,e,n,r){if(t===e)return t;let o=t+n;if(!r(t)&&!r(o)){let i=o;for(;i!==e;){if(r(i+n))return i;i+=n;}return e}let l=o;for(;l!==e;){if(!r(l))return l;l+=n;}return e}function dt(t,e,n,r,o,l){let i=t,a=e;return l?e>o?a=e-1:t>0&&(i=t-1,a=r):e<r?a=e+1:t<n&&(i=t+1,a=o),{rowIndex:i,columnIndex:a}}function ct(t){let{direction:e,rowIndex:n,columnIndex:r,dataColIndex:o,colOffset:l,maxRowIndex:i,maxColIndex:a,visibleColCount:u,isCtrl:m,isShift:c,selectionRange:d,isEmptyAt:s}=t,f=n,g=r;e==="ArrowDown"?f=m?P(n,i,1,b=>s(b,Math.max(0,o))):Math.min(n+1,i):e==="ArrowUp"?f=m?P(n,0,-1,b=>s(b,Math.max(0,o))):Math.max(n-1,0):e==="ArrowRight"?m&&o>=0?g=P(o,u-1,1,b=>s(n,b))+l:g=Math.min(r+1,a):m&&o>=0?g=P(o,0,-1,b=>s(n,b))+l:g=Math.max(r-1,l);let p=g-l,I=e==="ArrowDown"||e==="ArrowUp",C;return c?I?C=R({startRow:d?.startRow??n,startCol:d?.startCol??o,endRow:f,endCol:d?.endCol??o}):C=R({startRow:d?.startRow??n,startCol:d?.startCol??o,endRow:d?.endRow??n,endCol:p}):C={startRow:f,startCol:p,endRow:f,endCol:p},{newRowIndex:f,newColumnIndex:g,newDataColIndex:p,newRange:C}}function mt(t,e,n){let r=R(t),o=[];for(let l=r.startRow;l<=r.endRow;l++)for(let i=r.startCol;i<=r.endCol;i++){if(l>=e.length||i>=n.length)continue;let a=e[l],u=n[i];if(!h(u,a))continue;let m=x(a,u),c=T("",m,a,u);c.valid&&o.push({item:a,columnId:u.columnId,oldValue:m,newValue:c.value,rowIndex:l});}return o}function ft(t,e){return t===e?true:!t||!e?false:t.startRow===e.startRow&&t.endRow===e.endRow&&t.startCol===e.startCol&&t.endCol===e.endCol}function pt(t,e,n){return e<0||n<0?null:{startRow:Math.max(0,Math.min(t.startRow,e)),endRow:Math.max(0,Math.min(t.endRow,e)),startCol:Math.max(0,Math.min(t.startCol,n)),endCol:Math.max(0,Math.min(t.endCol,n))}}function gt(t,e=40,n=2,r=20){let o=Math.min(t/e,1);return n+o*(r-n)}function Ct(t,e,n,r,o,l){let i=new Set(l),a=Math.min(t,e),u=Math.max(t,e);for(let m=a;m<=u;m++)if(m<r.length){let c=o(r[m]);n?i.add(c):i.delete(c);}return i}function It(t,e,n){if(t.size===0||e.length===0)return {allSelected:false,someSelected:false};let r=t.size>=e.length&&e.every(l=>t.has(n(l))),o=!r&&t.size>0;return {allSelected:r,someSelected:o}}function se(t,e){let n=e!=null&&e!==""?e:t;if(n==null||n==="")return "";try{return String(n).replace(/[\t\n]/g," ")}catch{return "[Object]"}}function bt(t,e,n,r){let o=R(n),l=[];for(let i=o.startRow;i<=o.endRow;i++){let a=[];for(let u=o.startCol;u<=o.endCol&&!(i>=t.length||u>=e.length);u++){let m=t[i],c=e[u];if(r?.hasFormula&&r?.getFormula){let g=r.flatColumns.findIndex(p=>p.columnId===c.columnId);if(g>=0&&r.hasFormula(g,i)){let p=r.getFormula(g,i);if(p){a.push(p);continue}}}let d=x(m,c),f=(c.clipboardFormatter?c.clipboardFormatter(d,m):null)??(c.valueFormatter?c.valueFormatter(d,m):d);a.push(se(d,f));}l.push(a.join(" "));}return l.join(`\r
|
|
4
|
-
`)}function
|
|
2
|
+
`)?`"${e.replace(/"/g,'""')}"`:e}function j(t){return t.map(e=>k(e.name)).join(",")}function K(t,e,n,r){return t.map((o,l)=>e.map(i=>{if(r?.exportMode==="formulas"&&r.hasFormula&&r.getFormula&&r.columnIdToIndex){let a=r.columnIdToIndex.get(i.columnId);if(a!==void 0&&r.hasFormula(a,l)){let u=r.getFormula(a,l);if(u)return k(u)}}return k(n(o,i.columnId))}).join(","))}function fe(t,e,n,r,o){let l=j(e),i=K(t,e,n,o),a=[l,...i].join(`
|
|
3
|
+
`);Y(a,r??`export_${new Date().toISOString().slice(0,10)}.csv`);}function Y(t,e){let n=new Blob([t],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(n),o=document.createElement("a");try{o.setAttribute("href",r),o.setAttribute("download",e),o.style.visibility="hidden",document.body.appendChild(o),o.click();}finally{try{document.body.removeChild(o);}catch{}URL.revokeObjectURL(r);}}function x(t,e){return e.valueGetter?e.valueGetter(t):t[e.columnId]}function h(t,e){return t.editable===true||typeof t.editable=="function"&&t.editable(e)}function pe(t,e){return {getCellValue:(n,r)=>r<0||r>=t.length||n<0||n>=e.length?null:x(t[r],e[n]),getRowCount:()=>t.length,getColumnCount:()=>e.length}}function L(t){return "children"in t&&Array.isArray(t.children)}function Z(t){let e=[];for(let n of t)L(n)?e.push(...Z(n.children)):e.push(n);return e}function ge(t,e){function n(m,c){let d=c;for(let s of m)L(s)&&(d=Math.max(d,n(s.children,c+1)));return d}let r=n(t,0);if(r===0){let m=[];for(let c of t)if(!L(c)){if(e&&!e.has(c.columnId))continue;m.push({label:c.name,colSpan:1,isGroup:false,columnDef:c,depth:0});}return [m]}let o=r+1,l=Array.from({length:o},()=>[]),i=new Map;function a(m){let c=i.get(m);if(c!==void 0)return c;let d=0;for(let s of m)L(s)?d+=a(s.children):(!e||e.has(s.columnId))&&d++;return i.set(m,d),d}function u(m,c){for(let d of m)if(L(d)){let s=a(d.children);if(s===0)continue;l[c].push({label:d.headerName,colSpan:s,isGroup:true,depth:c}),u(d.children,c+1);}else {if(e&&!e.has(d.columnId))continue;l[c].push({label:d.name,colSpan:1,isGroup:false,columnDef:d,depth:c});}}return u(t,0),l.filter(m=>m.length>0)}function v(t){return t!=null&&typeof t=="object"&&"type"in t}function w(t){return (v(t.filterable)?t.filterable:null)?.filterField??t.columnId}function Ce(t,e,n){if(n===void 0||n.type==="text"&&n.value.trim()===""||n.type==="multiSelect"&&n.value.length===0||n.type==="date"&&!n.value.from&&!n.value.to||n.type==="people"&&!n.value){let{[e]:o,...l}=t;return l}return {...t,[e]:n}}function Ie(t,e){let n=[];for(let l=0;l<e.length;l++){let i=e[l];(v(i.filterable)?i.filterable:null)?.type==="multiSelect"&&n.push({col:i,field:w(i)});}if(n.length===0)return {};let r=new Map;for(let l=0;l<n.length;l++)r.set(n[l].field,new Set);for(let l=0;l<t.length;l++){let i=t[l];for(let a=0;a<n.length;a++){let u=x(i,n[a].col),m=r.get(n[a].field);u!=null&&u!==""&&m&&m.add(String(u));}}let o={};for(let l=0;l<n.length;l++){let i=r.get(n[l].field);o[n[l].field]=i?Array.from(i).sort():[];}return o}function be(t){let e=[];for(let n of t)(v(n.filterable)?n.filterable:null)?.type==="multiSelect"&&e.push(w(n));return e}function xe(t){let{totalCount:e,filteredCount:n,selectedCount:r,selectedCellCount:o,aggregation:l,suppressRowCount:i}=t,a=[];return i||a.push({key:"total",label:"Rows:",value:e}),n!==void 0&&n!==e&&a.push({key:"filtered",label:"Filtered:",value:n}),r!==void 0&&r>0&&a.push({key:"selected",label:"Selected:",value:r}),o!==void 0&&o>1&&a.push({key:"cells",label:"Cells:",value:o}),l&&(a.push({key:"sum",label:"Sum:",value:l.sum}),a.push({key:"avg",label:"Avg:",value:Math.round(l.avg*100)/100}),a.push({key:"min",label:"Min:",value:l.min}),a.push({key:"max",label:"Max:",value:l.max}),a.push({key:"count",label:"Count:",value:l.count})),a}function he(t,e,n,r){return t?typeof t=="object"?t:{totalCount:e,selectedCount:n>0?n:void 0,filteredCount:r!==void 0&&r!==e?r:void 0}:null}var Q=[10,25,50,100];function Ut(t,e){return e.includes(t)?e:[...e,t].sort((n,r)=>n-r)}var J=5;function Re(t,e,n,r){if(n<=0)return null;let o=r?.maxPageButtons??J,l=Math.ceil(n/e),i,a,u;if(l<=o){i=[];for(let d=1;d<=l;d++)i.push(d);a=false,u=false;}else {let d=Math.max(1,t-2),s=Math.min(l,t+2);s-d+1<o&&(d===1?s=Math.min(l,d+o-1):s===l&&(d=Math.max(1,s-o+1))),i=[];for(let f=d;f<=s;f++)i.push(f);a=d>1,u=s<l;}let m=Math.max(1,(t-1)*e+1),c=Math.min(t*e,n);return {totalPages:l,pageNumbers:i,showStartEllipsis:a,showEndEllipsis:u,startItem:m,endItem:c,pageSizeOptions:Ut(e,r?.pageSizeOptions??Q)}}var ye=[{id:"undo",label:"Undo",shortcut:"Ctrl+Z"},{id:"redo",label:"Redo",shortcut:"Ctrl+Y"},{id:"copy",label:"Copy",shortcut:"Ctrl+C",disabledWhenNoSelection:true,dividerBefore:true},{id:"cut",label:"Cut",shortcut:"Ctrl+X",disabledWhenNoSelection:true},{id:"paste",label:"Paste",shortcut:"Ctrl+V"},{id:"selectAll",label:"Select all",shortcut:"Ctrl+A",dividerBefore:true}];function Te(t){return typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)?t.replace("Ctrl","\u2318"):t}function Se(t){let{onCopy:e,onCut:n,onPaste:r,onSelectAll:o,onUndo:l,onRedo:i,onClose:a}=t;return {undo:()=>{l(),a();},redo:()=>{i(),a();},copy:()=>{e(),a();},cut:()=>{n(),a();},paste:()=>{r(),a();},selectAll:()=>{o(),a();}}}var we=[{id:"pinLeft",label:"Pin left"},{id:"pinRight",label:"Pin right"},{id:"unpin",label:"Unpin"}];function De(t){let{canPinLeft:e,canPinRight:n,canUnpin:r,currentSort:o,isSortable:l=true,isResizable:i=true}=t,a=[];if(a.push({id:"pinLeft",label:"Pin left",disabled:!e},{id:"pinRight",label:"Pin right",disabled:!n},{id:"unpin",label:"Unpin",disabled:!r,divider:l||i}),l)if(!o)a.push({id:"sortAsc",label:"Sort ascending"},{id:"sortDesc",label:"Sort descending",divider:i});else {let u=o==="asc"?"desc":"asc",m=o==="asc"?"Sort descending":"Sort ascending";a.push({id:`sort${u==="asc"?"Asc":"Desc"}`,label:m},{id:"clearSort",label:"Clear sort",divider:i});}return i&&a.push({id:"autosizeThis",label:"Autosize this column"},{id:"autosizeAll",label:"Autosize all columns"}),a}function T(t,e,n,r){if(r.valueParser){let l={newValue:t,oldValue:e,data:n,column:r},i=r.valueParser(l);return i===void 0?{valid:false,value:void 0}:{valid:true,value:i}}if(r.cellEditor==="select"&&r.cellEditorParams?.values!=null&&Array.isArray(r.cellEditorParams.values)){let l=r.cellEditorParams.values,i=typeof t=="string"?t:String(t??"");if(i==="")return {valid:true,value:""};let a=l.find(u=>String(u).toLowerCase()===i.toLowerCase());return a!==void 0?{valid:true,value:a}:{valid:false,value:void 0}}let o=r.type;if(o==="date"){let l=te({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}if(o==="boolean"){let l=ne({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}if(o==="numeric"){let l=ee({newValue:t});return l===void 0?{valid:false,value:void 0}:{valid:true,value:l}}return {valid:true,value:t}}function ee(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).replace(/[\s,]/g,""),r=Number(n);return Number.isNaN(r)?void 0:r}function ve(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).replace(/[$\u20AC\u00A3\u00A5]/g,"").replace(/[\s,]/g,""),r=Number(n);return Number.isNaN(r)?void 0:r}function te(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim(),r=new Date(n);if(!Number.isNaN(r.getTime()))return r.toISOString()}function Ee(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim();return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)?n:void 0}function ne(t){let{newValue:e}=t;if(e===""||e==null)return null;let n=String(e).trim().toLowerCase();if(["true","yes","1"].includes(n))return true;if(["false","no","0"].includes(n))return false}function Fe(t,e,n){if(!n)return null;let r=R(n),o=0,l=0,i=1/0,a=-1/0,u=0;for(let m=r.startRow;m<=r.endRow;m++)for(let c=r.startCol;c<=r.endCol;c++){if(m>=t.length||c>=e.length)continue;o++;let d=t[m],s=e[c],f=x(d,s),g=typeof f=="number"?f:Number(f);!isNaN(g)&&isFinite(g)&&(l+=g,g<i&&(i=g),g>a&&(a=g),u++);}return o<2||u===0?null:{sum:l,avg:l/u,min:i,max:a,count:u}}var Me=new WeakMap;function M(t,e,n,r,o){let l=Me.get(e);if(!l){l=new Map;for(let m=0;m<e.length;m++)l.set(e[m].columnId,e[m]);Me.set(e,l);}let i=[];for(let m=0;m<e.length;m++){let c=e[m],d=w(c),s=n[d];if(s)switch(s.type){case "multiSelect":if(s.value.length>0){let f=new Set(s.value);i.push(g=>f.has(String(x(g,c))));}break;case "text":{let f=s.value.trim();if(f){let g=f.toLowerCase(),p=new Map;for(let I=0;I<t.length;I++)p.set(t[I],String(x(t[I],c)??"").toLowerCase());i.push(I=>(p.get(I)??"").includes(g));}break}case "people":{let f=s.value.email.toLowerCase(),g=new Map;for(let p=0;p<t.length;p++)g.set(t[p],String(x(t[p],c)??"").toLowerCase());i.push(p=>(g.get(p)??"")===f);break}case "date":{let f=s.value,g=f.from?new Date(f.from+"T00:00:00").getTime():NaN,p=f.to?new Date(f.to+"T23:59:59.999").getTime():NaN,I=new Map;for(let C=0;C<t.length;C++){let b=x(t[C],c);if(b==null)I.set(t[C],NaN);else {let y=new Date(String(b)).getTime();I.set(t[C],Number.isNaN(y)?NaN:y);}}i.push(C=>{let b=I.get(C)??NaN;return !(Number.isNaN(b)||!Number.isNaN(g)&&b<g||!Number.isNaN(p)&&b>p)});break}}}let a=i.length>0,u=a?t.filter(m=>{for(let c=0;c<i.length;c++)if(!i[c](m))return false;return true}):t;if(r){let m=a?u:u.slice(),c=l.get(r),d=c?.compare,s=o==="asc"?1:-1;if(c?.type==="date"&&!d){let g=new Map;for(let p=0;p<m.length;p++){let I=m[p],C=c?x(I,c):I[r];if(C==null)g.set(I,NaN);else {let b=new Date(String(C)).getTime();g.set(I,Number.isNaN(b)?0:b);}}m.sort((p,I)=>{let C=g.get(p)??NaN,b=g.get(I)??NaN;return Number.isNaN(C)&&Number.isNaN(b)?0:Number.isNaN(C)?-1*s:Number.isNaN(b)?1*s:C===b?0:C>b?s:-s});}else if(d)m.sort((g,p)=>d(g,p)*s);else {let g=new Map;for(let p=0;p<m.length;p++){let I=m[p],C=c?x(I,c):I[r];C==null?g.set(I,void 0):typeof C=="number"?g.set(I,C):g.set(I,String(C).toLowerCase());}m.sort((p,I)=>{let C=g.get(p),b=g.get(I);return C===void 0&&b===void 0?0:C===void 0?-1*s:b===void 0?1*s:C===b?0:C>b?s:-s});}return m}return u}function D(t,e){if(!t)return false;let n=Math.min(t.startRow,t.endRow),r=Math.max(t.startRow,t.endRow);return e>=n&&e<=r}function Ae(t,e){if(t.item!==e.item||t.isSelected!==e.isSelected||t.hasCheckboxCol!==e.hasCheckboxCol||t.visibleCols!==e.visibleCols||t.columnMeta!==e.columnMeta||t.cellClassMap!==e.cellClassMap||t.columnLayouts!==e.columnLayouts)return false;let n=t.rowIndex;if(t.editingRowId!==e.editingRowId&&(t.editingRowId===t.rowId||e.editingRowId===e.rowId))return false;let r=t.activeCell?.rowIndex===n,o=e.activeCell?.rowIndex===n;if(r!==o||r&&o&&t.activeCell?.columnIndex!==e.activeCell?.columnIndex)return false;let l=D(t.selectionRange,n),i=D(e.selectionRange,n);if(l!==i||l&&i&&(t.selectionRange?.startCol!==e.selectionRange?.startCol||t.selectionRange?.endCol!==e.selectionRange?.endCol))return false;let a=t.selectionRange?.endRow===n,u=e.selectionRange?.endRow===n;return !(a!==u||(a||u)&&t.isDragging!==e.isDragging||t.cutRange!==e.cutRange&&(D(t.cutRange,n)||D(e.cutRange,n))||t.copyRange!==e.copyRange&&(D(t.copyRange,n)||D(e.copyRange,n)))}function re(t,e){return e?e.left?.includes(t)?"left":e.right?.includes(t)?"right":"unpinned":"unpinned"}function Pe(t,e,n){let r=t.filter(i=>i!==e),o=Math.max(0,Math.min(n,r.length)),l=[...r];return l.splice(o,0,e),l}function Ne(t){let{mouseX:e,columnOrder:n,draggedColumnId:r,draggedPinState:o,tableElement:l,pinnedColumns:i}=t,a=l.querySelectorAll("[data-column-id]");if(a.length===0)return null;let u=[];if(a.forEach(s=>{let f=s.getAttribute("data-column-id");if(!f||re(f,i)!==o)return;let p=s.getBoundingClientRect(),I=n.indexOf(f);I!==-1&&u.push({columnId:f,left:p.left,right:p.right,midX:p.left+p.width/2,orderIndex:I});}),u.length===0)return null;u.sort((s,f)=>s.left-f.left);let m,c;if(e<=u[0].midX)m=u[0].orderIndex,c=u[0].left;else if(e>=u[u.length-1].midX){let s=u[u.length-1];m=s.orderIndex+1,c=s.right;}else {let s=-1;for(let f=0;f<u.length-1;f++)if(e>=u[f].midX&&e<u[f+1].midX){s=f;break}if(s===-1)return null;m=u[s].orderIndex+1,c=u[s].right;}let d=n.indexOf(r);return d===m||d+1===m?{targetIndex:m,indicatorX:null}:{targetIndex:m,indicatorX:c}}function Oe(t,e,n,r=2){if(e.length===0||n<=0)return {startIndex:0,endIndex:-1,leftOffset:0,rightOffset:0};let o=0,l=e.length,i=-1;for(let d=0;d<e.length;d++){let s=o;o+=e[d],o>t&&l===e.length&&(l=d),s<t+n&&(i=d);}if(l>i)return {startIndex:0,endIndex:-1,leftOffset:0,rightOffset:0};let a=Math.max(0,l-r),u=Math.min(e.length-1,i+r),m=0;for(let d=0;d<a;d++)m+=e[d];let c=0;for(let d=u+1;d<e.length;d++)c+=e[d];return {startIndex:a,endIndex:u,leftOffset:m,rightOffset:c}}function _e(t,e,n){let r=[],o=[],l=[];for(let a of t){let u=n?.[a.columnId];u==="left"?r.push(a):u==="right"?o.push(a):l.push(a);}if(!e||e.endIndex<0)return {pinnedLeft:r,virtualizedUnpinned:l,pinnedRight:o,leftSpacerWidth:0,rightSpacerWidth:0};let i=l.slice(e.startIndex,e.endIndex+1);return {pinnedLeft:r,virtualizedUnpinned:i,pinnedRight:o,leftSpacerWidth:e.leftOffset,rightSpacerWidth:e.rightOffset}}function ke(t,e,n,r,o=5){if(r<=0||e<=0||n<=0)return {startIndex:0,endIndex:0,offsetTop:0,offsetBottom:0};let l=Math.max(0,Math.floor(t/e)-o),i=Math.min(r-1,Math.ceil((t+n)/e)+o),a=l*e,u=Math.max(0,(r-i-1)*e);return {startIndex:l,endIndex:i,offsetTop:a,offsetBottom:u}}function Le(t,e){return t*e}function Ve(t,e,n,r="start"){let o=t*e;switch(r){case "start":return o;case "center":return Math.max(0,o-(n-e)/2);case "end":return Math.max(0,o-n+e)}}function Ue(){let t=self;t.onmessage=e=>{let n=e.data;if(n.type!=="sort-filter")return;let{requestId:r,values:o,filters:l,sort:i}=n,a=o.length,u=[],m=Object.entries(l);if(m.length===0){u=new Array(a);for(let d=0;d<a;d++)u[d]=d;}else for(let d=0;d<a;d++){let s=true;for(let f=0;f<m.length;f++){let g=Number(m[f][0]),p=m[f][1],I=o[d][g];switch(p.type){case "text":{let C=p.value.trim().toLowerCase();C&&!String(I??"").toLowerCase().includes(C)&&(s=false);break}case "multiSelect":{p.value.length>0&&(new Set(p.value).has(String(I??""))||(s=false));break}case "date":{if(I==null){s=false;break}let C=new Date(String(I)).getTime();if(isNaN(C)){s=false;break}if(p.value.from){let b=new Date(p.value.from+"T00:00:00").getTime();if(C<b){s=false;break}}if(p.value.to){let b=new Date(p.value.to+"T23:59:59.999").getTime();if(C>b){s=false;break}}break}}if(!s)break}s&&u.push(d);}if(i){let{columnIndex:d,direction:s}=i,f=s==="asc"?1:-1;u.sort((g,p)=>{let I=o[g][d],C=o[p][d];if(I==null&&C==null)return 0;if(I==null)return -1*f;if(C==null)return 1*f;if(typeof I=="number"&&typeof C=="number")return I===C?0:I>C?f:-f;let b=String(I).toLowerCase(),y=String(C).toLowerCase();return b===y?0:b>y?f:-f});}let c={type:"sort-filter-result",requestId:r,indices:u};t.postMessage(c);};}var S=null,Ht=0,E=new Map;function oe(){if(S)return S;if(typeof Worker>"u"||typeof Blob>"u"||typeof URL>"u")return null;try{let t=Ue.toString(),e=new Blob([`(${t})()`],{type:"application/javascript"}),n=URL.createObjectURL(e);return S=new Worker(n),URL.revokeObjectURL(n),S.onmessage=r=>{let{requestId:o,indices:l}=r.data,i=E.get(o);i&&(E.delete(o),i.resolve(l));},S.onerror=r=>{for(let[o,l]of E)l.reject(new Error(r.message||"Worker error")),E.delete(o);},S}catch{return null}}function He(){S&&(S.terminate(),S=null);for(let[t,e]of E)e.reject(new Error("Worker terminated")),E.delete(t);}function le(t,e){let n=new Array(t.length);for(let r=0;r<t.length;r++){let o=new Array(e.length);for(let l=0;l<e.length;l++){let i=x(t[r],e[l]);i==null?o[l]=null:typeof i=="string"||typeof i=="number"||typeof i=="boolean"?o[l]=i:o[l]=String(i);}n[r]=o;}return n}function Be(t,e,n,r,o){if(r&&e.find(f=>f.columnId===r)?.compare)return Promise.resolve(M(t,e,n,r,o));let l=oe();if(!l)return Promise.resolve(M(t,e,n,r,o));let i=new Map;for(let s=0;s<e.length;s++)i.set(e[s].columnId,s);let a=le(t,e),u=e.map((s,f)=>({type:s.type??"text",index:f})),m={};for(let s of e){let f=w(s),g=n[f];if(!g)continue;let p=i.get(s.columnId);if(p!==void 0)switch(g.type){case "text":m[p]={type:"text",value:g.value};break;case "multiSelect":m[p]={type:"multiSelect",value:g.value};break;case "date":m[p]={type:"date",value:{from:g.value.from,to:g.value.to}};break;case "people":return Promise.resolve(M(t,e,n,r,o))}}let c;if(r){let s=i.get(r);s!==void 0&&(c={columnIndex:s,direction:o??"asc"});}let d=++Ht;return new Promise((s,f)=>{E.set(d,{resolve:p=>{let I=new Array(p.length);for(let C=0;C<p.length;C++)I[C]=t[p[C]];s(I);},reject:f});let g={type:"sort-filter",requestId:d,values:a,columnMeta:u,filters:m,sort:c};l.postMessage(g);})}var We=5e3;function Ge(t,e,n){return !(!(t===true||t==="auto"&&e>5e3)||n?.filters&&Object.values(n.filters).some(o=>o?.type==="people")||n?.sortBy&&n.columns&&n.columns.find(l=>l.columnId===n.sortBy)?.compare)}var B="YYYY-MM-DD";function W(t,e,n="UTC"){if(t==null)return null;let r=t instanceof Date?t:new Date(String(t));if(Number.isNaN(r.getTime()))return null;let o,l,i;if(n==="UTC")o=r.getUTCFullYear(),l=r.getUTCMonth()+1,i=r.getUTCDate();else {let d=new Intl.DateTimeFormat("en-CA",{timeZone:n,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(r);o=parseInt(d.find(s=>s.type==="year")?.value??"0",10),l=parseInt(d.find(s=>s.type==="month")?.value??"0",10),i=parseInt(d.find(s=>s.type==="day")?.value??"0",10);}let a=String(o).padStart(4,"0"),u=String(l).padStart(2,"0"),m=String(i).padStart(2,"0");return e.replace("YYYY",a).replace("MM",u).replace("DD",m)}function $e(t,e){if(!t||!t.trim())return null;let r=t.trim().split(/[/\-.\s]+/).filter(Boolean);if(r.length===0)return null;let o=new Date().getUTCFullYear(),l=Bt(e),i,a,u;if(r.length===3){let[c,d,s]=r.map(Number);l==="YMD"?(i=c,a=d,u=s):l==="DMY"?(u=c,a=d,i=s):(a=c,u=d,i=s),i!==void 0&&i<100&&(i=i<50?2e3+i:1900+i);}else if(r.length===2){let[c,d]=r.map(Number);l==="DMY"?(u=c,a=d):(a=c,u=d),i=o;}else if(r.length===1){let c=r[0];if(/^\d+$/.test(c))if(c.length===8)i=parseInt(c.slice(0,4),10),a=parseInt(c.slice(4,6),10),u=parseInt(c.slice(6,8),10);else if(c.length===4)a=parseInt(c.slice(0,2),10),u=parseInt(c.slice(2,4),10),i=o;else return null;else return null}else return null;if(!Wt(i,a,u))return null;let m=new Date(Date.UTC(i,a-1,u));return m.getUTCFullYear()!==i||m.getUTCMonth()+1!==a||m.getUTCDate()!==u?null:m}function Xe(t){return t}function Bt(t){let e=t.indexOf("Y"),n=t.indexOf("M"),r=t.indexOf("D");return e===-1||n===-1||r===-1?"MDY":e<n&&n<r?"YMD":r<n&&n<e?"DMY":"MDY"}function Wt(t,e,n){return !(t==null||e==null||n==null||!Number.isFinite(t)||!Number.isFinite(e)||!Number.isFinite(n)||e<1||e>12||n<1||n>31)}var V=class{constructor(e,n){this.type=e;this.message=n;}toString(){return this.type}};function ze(t,e){let n=v(t.filterable)?t.filterable:null,r=n?.type??"none",o=n?.filterField??t.columnId,l=t.sortable!==false,i=e.filters[o],a={columnKey:t.columnId,columnName:t.name,filterType:r,isSorted:e.sortBy===t.columnId,isSortedDescending:e.sortBy===t.columnId&&e.sortDirection==="desc",onSort:l?()=>e.onColumnSort(t.columnId):void 0};return r==="text"?{...a,textValue:i?.type==="text"?i.value:"",onTextChange:u=>e.onFilterChange(o,u.trim()?{type:"text",value:u}:void 0)}:r==="people"?{...a,selectedUser:i?.type==="people"?i.value:void 0,onUserChange:u=>e.onFilterChange(o,u?{type:"people",value:u}:void 0),peopleSearch:e.peopleSearch}:r==="multiSelect"?{...a,options:e.filterOptions[o]??[],isLoadingOptions:e.loadingFilterOptions[o]??false,selectedValues:i?.type==="multiSelect"?i.value:[],onFilterChange:u=>e.onFilterChange(o,u.length?{type:"multiSelect",value:u}:void 0)}:r==="date"?{...a,dateValue:i?.type==="date"?i.value:void 0,onDateChange:u=>e.onFilterChange(o,u?{type:"date",value:u}:void 0)}:a}var $=class ${constructor(){this.cache=new Map;this.lastVersion="";}static computeVersion(e){let n=e.editingCell,r=e.activeCell,o=e.selectionRange,l=e.cutRange,i=e.copyRange;return (n?`${String(n.rowId)}\0${n.columnId}`:"")+""+(r?`${r.rowIndex}\0${r.columnIndex}`:"")+""+(o?`${o.startRow}\0${o.startCol}\0${o.endRow}\0${o.endCol}`:"")+""+(l?`${l.startRow}\0${l.startCol}\0${l.endRow}\0${l.endCol}`:"")+""+(i?`${i.startRow}\0${i.startCol}\0${i.endRow}\0${i.endCol}`:"")+""+(e.isDragging?"1":"0")+""+(e.editable!==false?"1":"0")+""+(e.onCellValueChanged?"1":"0")+""+(e.formulaVersion??0)}get(e,n,r,o){let l=e*$.MAX_COL_STRIDE+n,i=this.cache.get(l);if(i!==void 0&&i.version===r)return i.descriptor;let a=o();return this.cache.set(l,{version:r,descriptor:a}),a}updateVersion(e){this.lastVersion=e;}get currentVersion(){return this.lastVersion}clear(){this.cache.clear();}};$.MAX_COL_STRIDE=1024;var G=$;function je(t,e,n,r,o,l){return l!==void 0?l.get(n,r,l.currentVersion,()=>qe(t,e,n,r,o)):qe(t,e,n,r,o)}function qe(t,e,n,r,o){let l=o.getRowId(t),i=r+o.colOffset,a=h(e,t),u=o.editable!==false&&a&&!!o.onCellValueChanged&&typeof e.cellEditor!="function",m=o.editable!==false&&a&&!!o.onCellValueChanged&&typeof e.cellEditor=="function"&&e.cellEditorPopup!==false,c=u||m,d=o.editingCell?.rowId===l&&o.editingCell?.columnId===e.columnId,s=!o.isDragging&&o.activeCell?.rowIndex===n&&o.activeCell?.columnIndex===i,f=o.selectionRange!=null&&o.selectionRange.startRow===o.selectionRange.endRow&&o.selectionRange.startCol===o.selectionRange.endCol,g=o.selectionRange!=null&&!f&&F(o.selectionRange,n,r),p=o.cutRange!=null&&F(o.cutRange,n,r),I=o.copyRange!=null&&F(o.copyRange,n,r),C=!o.isDragging&&o.copyRange==null&&o.cutRange==null&&o.selectionRange!=null&&n===o.selectionRange.endRow&&r===o.selectionRange.endCol,b=e.pinned!=null,y=e.pinned??void 0,P=x(t,e),H=o.hasFormula?.(r,n)??false,N=H?o.getFormulaValue?.(r,n):void 0,O="display",_;d&&u?(O="editing-inline",e.cellEditor==="text"||e.cellEditor==="select"||e.cellEditor==="checkbox"||e.cellEditor==="richSelect"||e.cellEditor==="date"?_=e.cellEditor:e.type==="date"?_="date":e.type==="boolean"?_="checkbox":_="text"):d&&m&&typeof e.cellEditor=="function"&&(O="editing-popover");let Vt=d&&H?o.getFormula?.(r,n)??P:P;return {mode:O,editorType:_,value:Vt,isActive:s,isInRange:g,isInCutRange:p,isInCopyRange:I,isSelectionEndCell:C,canEditAny:c,isPinned:b,pinnedSide:y,globalColIndex:i,rowId:l,rowIndex:n,displayValue:N!==void 0?N:P,columnType:e.type}}function Ke(t,e,n){if(n instanceof V)return n.toString();let r=t;if(r.renderCell&&typeof r.renderCell=="function")return r.renderCell(e);if(t.valueFormatter)return t.valueFormatter(n,e);if(n==null)return null;if(t.type==="date"){let o=t.dateFormat??B,l=W(n,o);if(l!==null)return l}return t.type==="boolean"?n?"True":"False":String(n)}function Ye(t,e,n){let r=t,o=n instanceof V,l=r.cellStyle?typeof r.cellStyle=="function"?r.cellStyle(e):r.cellStyle:void 0;return o?{...l,color:"var(--ogrid-formula-error-color, #d32f2f)"}:l}function Ze(t,e,n,r){let o=n.editorType??"text";return {value:n.value,item:t,column:e,rowIndex:n.rowIndex,editorType:o,onCommit:l=>r.commitCellEdit(t,e.columnId,n.value,l,n.rowIndex,n.globalColIndex,o==="checkbox"?{skipAdvance:true}:void 0),onCancel:()=>r.setEditingCell(null)}}function Qe(t,e,n,r,o){let l=n.value,i=r!==void 0?r:l,a=r;return {value:i,onValueChange:u=>{a=u,o.setPendingEditorValue(u);},onCommit:()=>{let u=a!==void 0?a:l;o.commitCellEdit(t,e.columnId,l,u,n.rowIndex,n.globalColIndex);},onCancel:o.cancelPopoverEdit,item:t,column:e,cellEditorParams:e.cellEditorParams}}function Je(t,e){let n=null,r=((...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{t(...o),n=null;},e);});return r.cancel=()=>{n!==null&&(clearTimeout(n),n=null);},r}function et(t,e,n){let r=e.startCol+n,o=e.endCol+n,l=t.querySelector(`[data-row-index="${e.startRow}"][data-col-index="${r}"]`),i=t.querySelector(`[data-row-index="${e.endRow}"][data-col-index="${o}"]`);if(!l||!i)return null;let a=t.getBoundingClientRect(),u=l.getBoundingClientRect(),m=i.getBoundingClientRect();return {top:u.top-a.top,left:u.left-a.left,width:m.right-u.left,height:m.bottom-u.top}}function tt(t){let e=new Map;if(!t)return e;let n=t.querySelectorAll("[data-row-index][data-col-index]");for(let r=0;r<n.length;r++){let o=n[r],l=o.getAttribute("data-row-index")??"",i=o.getAttribute("data-col-index")??"";e.set(`${l},${i}`,o);}return e}function nt(t,e){if(typeof document>"u"||document.getElementById(t))return;let n=document.createElement("style");n.id=t,n.textContent=e,document.head.appendChild(n);}function rt(t,e,n){return n===null?{field:"",direction:"asc"}:n?{field:e,direction:n}:{field:e,direction:t.field===e&&t.direction==="asc"?"desc":"asc"}}var ot=48,lt=50,X=80,it=16,at=30,st="__row_number__",ut=6;var ie=16,ae=520,Gt=44,$t=8;function dt(t){return Math.max(80,Math.ceil(t.length*$t+Gt))}function Xt(t){let e=getComputedStyle(t),n=(parseFloat(e.paddingLeft)||0)+(parseFloat(e.paddingRight)||0),r=(parseFloat(e.borderLeftWidth)||0)+(parseFloat(e.borderRightWidth)||0),o=0;for(let d=0;d<t.children.length;d++){let s=t.children[d],f=s.className||"";if(f.includes("resizeHandle")||f.includes("resize-handle")||f.includes("ogrid-resize-handle")){o=s.offsetWidth;break}}let l=t.firstElementChild;if(!l)return t.offsetWidth;let i=[],a=d=>{for(let s=0;s<d.children.length;s++){let f=d.children[s],g=getComputedStyle(f);(g.overflow==="hidden"||g.flexShrink!=="0")&&(i.push({el:f,overflow:f.style.overflow,flexShrink:f.style.flexShrink,width:f.style.width,minWidth:f.style.minWidth,maxWidth:f.style.maxWidth}),f.style.overflow="visible",f.style.flexShrink="0",f.style.width="max-content",f.style.minWidth="max-content",f.style.maxWidth="none"),a(f);}},u=l.style.position,m=l.style.width;l.style.position="absolute",l.style.width="max-content",a(l);let c=l.offsetWidth;l.style.position=u,l.style.width=m;for(let d of i)d.el.style.overflow=d.overflow,d.el.style.flexShrink=d.flexShrink,d.el.style.width=d.width,d.el.style.minWidth=d.minWidth,d.el.style.maxWidth=d.maxWidth;return c+o+n+r}function ct(t,e,n){let r=e??80,l=(n??document).querySelectorAll(`[data-column-id="${t}"]`);if(l.length===0)return r;let i=r,a=[],u=[],m=[];if(l.forEach(c=>{let d=c;if(!!d.querySelector?.("[data-header-label]"))i=Math.max(i,Xt(d));else {let f=d.firstElementChild??d;a.push(f);}}),a.length>0){for(let c=0;c<a.length;c++){let d=a[c];u.push(d.style.position),m.push(d.style.width),d.style.position="absolute",d.style.width="max-content";}for(let c=0;c<a.length;c++)i=Math.max(i,a[c].offsetWidth+ie);for(let c=0;c<a.length;c++)a[c].style.position=u[c],a[c].style.width=m[c];}return Math.min(ae,Math.max(r,Math.ceil(i)))}function A(t,e,n,r){if(t===e)return t;let o=t+n;if(!r(t)&&!r(o)){let i=o;for(;i!==e;){if(r(i+n))return i;i+=n;}return e}let l=o;for(;l!==e;){if(!r(l))return l;l+=n;}return e}function mt(t,e,n,r,o,l){let i=t,a=e;return l?e>o?a=e-1:t>0&&(i=t-1,a=r):e<r?a=e+1:t<n&&(i=t+1,a=o),{rowIndex:i,columnIndex:a}}function ft(t){let{direction:e,rowIndex:n,columnIndex:r,dataColIndex:o,colOffset:l,maxRowIndex:i,maxColIndex:a,visibleColCount:u,isCtrl:m,isShift:c,selectionRange:d,isEmptyAt:s}=t,f=n,g=r;e==="ArrowDown"?f=m?A(n,i,1,b=>s(b,Math.max(0,o))):Math.min(n+1,i):e==="ArrowUp"?f=m?A(n,0,-1,b=>s(b,Math.max(0,o))):Math.max(n-1,0):e==="ArrowRight"?m&&o>=0?g=A(o,u-1,1,b=>s(n,b))+l:g=Math.min(r+1,a):m&&o>=0?g=A(o,0,-1,b=>s(n,b))+l:g=Math.max(r-1,l);let p=g-l,I=e==="ArrowDown"||e==="ArrowUp",C;return c?I?C=R({startRow:d?.startRow??n,startCol:d?.startCol??o,endRow:f,endCol:d?.endCol??o}):C=R({startRow:d?.startRow??n,startCol:d?.startCol??o,endRow:d?.endRow??n,endCol:p}):C={startRow:f,startCol:p,endRow:f,endCol:p},{newRowIndex:f,newColumnIndex:g,newDataColIndex:p,newRange:C}}function pt(t,e,n){let r=R(t),o=[];for(let l=r.startRow;l<=r.endRow;l++)for(let i=r.startCol;i<=r.endCol;i++){if(l>=e.length||i>=n.length)continue;let a=e[l],u=n[i];if(!h(u,a))continue;let m=x(a,u),c=T("",m,a,u);c.valid&&o.push({item:a,columnId:u.columnId,oldValue:m,newValue:c.value,rowIndex:l});}return o}function gt(t,e){return t===e?true:!t||!e?false:t.startRow===e.startRow&&t.endRow===e.endRow&&t.startCol===e.startCol&&t.endCol===e.endCol}function Ct(t,e,n){return e<0||n<0?null:{startRow:Math.max(0,Math.min(t.startRow,e)),endRow:Math.max(0,Math.min(t.endRow,e)),startCol:Math.max(0,Math.min(t.startCol,n)),endCol:Math.max(0,Math.min(t.endCol,n))}}function It(t,e=40,n=2,r=20){let o=Math.min(t/e,1);return n+o*(r-n)}function bt(t,e,n,r,o,l){let i=new Set(l),a=Math.min(t,e),u=Math.max(t,e);for(let m=a;m<=u;m++)if(m<r.length){let c=o(r[m]);n?i.add(c):i.delete(c);}return i}function xt(t,e,n){if(t.size===0||e.length===0)return {allSelected:false,someSelected:false};let r=t.size>=e.length&&e.every(l=>t.has(n(l))),o=!r&&t.size>0;return {allSelected:r,someSelected:o}}function se(t,e){let n=e!=null&&e!==""?e:t;if(n==null||n==="")return "";try{return String(n).replace(/[\t\n]/g," ")}catch{return "[Object]"}}function ht(t,e,n,r){let o=R(n),l=[];for(let i=o.startRow;i<=o.endRow;i++){let a=[];for(let u=o.startCol;u<=o.endCol&&!(i>=t.length||u>=e.length);u++){let m=t[i],c=e[u];if(r?.hasFormula&&r?.getFormula){let g=r.flatColumns.findIndex(p=>p.columnId===c.columnId);if(g>=0&&r.hasFormula(g,i)){let p=r.getFormula(g,i);if(p){a.push(p);continue}}}let d=x(m,c),f=(c.clipboardFormatter?c.clipboardFormatter(d,m):null)??(c.valueFormatter?c.valueFormatter(d,m):d);a.push(se(d,f));}l.push(a.join(" "));}return l.join(`\r
|
|
4
|
+
`)}function Rt(t){return t.trim()?t.split(/\r?\n/).filter(n=>n.length>0).map(n=>n.split(" ")):[]}function yt(t,e,n,r,o,l){let i=[];for(let a=0;a<t.length;a++){let u=t[a];for(let m=0;m<u.length;m++){let c=e+a,d=n+m;if(c>=r.length||d>=o.length)continue;let s=r[c],f=o[d];if(!h(f,s))continue;let g=u[m]??"";if(g.startsWith("=")&&l?.setFormula){let C=l.flatColumns.findIndex(b=>b.columnId===f.columnId);if(C>=0){l.setFormula(C,c,g);continue}}let p=x(s,f),I=T(g,p,s,f);I.valid&&i.push({item:s,columnId:f.columnId,oldValue:p,newValue:I.value,rowIndex:c});}}return i}function Tt(t,e,n){let r=[];for(let o=t.startRow;o<=t.endRow;o++)for(let l=t.startCol;l<=t.endCol;l++){if(o>=e.length||l>=n.length)continue;let i=e[o],a=n[l];if(!h(a,i))continue;let u=x(i,a),m=T("",u,i,a);m.valid&&r.push({item:i,columnId:a.columnId,oldValue:u,newValue:m.value,rowIndex:o});}return r}function U(t){let e="",n=t;for(;n>=0;)e=String.fromCharCode(n%26+65)+e,n=Math.floor(n/26)-1;return e}function q(t){let e=0,n=t.toUpperCase();for(let r=0;r<n.length;r++)e=e*26+(n.charCodeAt(r)-64);return e-1}function St(t,e){return `${U(t)}${e}`}var wt=/(?:'[^']*'!|[A-Za-z_]\w*!)?(\$?)([A-Z]+)(\$?)(\d+)/g;function Dt(t,e,n){return wt.lastIndex=0,t.replace(wt,(r,o,l,i,a)=>{let u=r.indexOf(o+l),m=u>0?r.substring(0,u):"",c=l,d=a;if(o!=="$"){let s=q(l)+e;if(s<0)return "#REF!";c=U(s);}if(i!=="$"){let s=parseInt(a,10)+n;if(s<1)return "#REF!";d=String(s);}return `${m}${o}${c}${i}${d}`})}function ue(t,e){if(t.columnId===e.columnId)return true;let n=t.type??"text",r=e.type??"text";return !(n!==r||t.cellEditor!==e.cellEditor)}function vt(t,e,n,r,o,l){let i=[],a=r[t.startRow],u=o[t.startCol];if(!a||!u)return i;let m=x(a,u),c=l?l.flatColumns.findIndex(s=>s.columnId===u.columnId):-1,d=new Set;for(let s=t.startCol;s<=t.endCol;s++)s<o.length&&ue(u,o[s])&&d.add(s);for(let s=t.startRow;s<=t.endRow;s++)for(let f=t.startCol;f<=t.endCol;f++){if(s===e&&f===n||s>=r.length||!d.has(f))continue;let g=r[s],p=o[f];if(!h(p,g))continue;if(l&&l.hasFormula&&l.getFormula&&l.setFormula&&c>=0&&l.hasFormula(c,e)){let b=l.getFormula(c,e);if(b){let y=s-e,P=f-n,H=Dt(b,P,y),N=l.flatColumns.findIndex(O=>O.columnId===p.columnId);if(N>=0){l.setFormula(N,s,H);continue}}}let I=x(g,p),C=T(m,I,g,p);C.valid&&i.push({item:g,columnId:p.columnId,oldValue:I,newValue:C.value,rowIndex:s});}return i}var z=class{constructor(e=100){this.history=[];this.redoStack=[];this.batch=null;this.maxDepth=e;}get canUndo(){return this.history.length>0}get canRedo(){return this.redoStack.length>0}get historyLength(){return this.history.length}get redoLength(){return this.redoStack.length}get isBatching(){return this.batch!==null}push(e){e.length!==0&&(this.batch!==null?this.batch.push(...e):(this.history.push(e),this.history.length>this.maxDepth&&this.history.splice(0,this.history.length-this.maxDepth),this.redoStack.length=0));}record(e){this.push([e]);}beginBatch(){this.batch===null&&(this.batch=[]);}endBatch(){let e=this.batch;this.batch=null,!(!e||e.length===0)&&(this.history.push(e),this.history.length>this.maxDepth&&this.history.splice(0,this.history.length-this.maxDepth),this.redoStack.length=0);}undo(){let e=this.history.pop();return e?(this.redoStack.push(e),e):null}redo(){let e=this.redoStack.pop();return e?(this.history.push(e),e):null}clear(){this.history=[],this.redoStack=[];}};function Et(t){if(!Array.isArray(t)||t.length===0){console.warn("[OGrid] columns prop is empty or not an array");return}let e=typeof process<"u"&&process.env?.NODE_ENV!=="production",n=new Set;for(let r of t)r.columnId||console.warn("[OGrid] Column missing columnId:",r),n.has(r.columnId)&&console.warn(`[OGrid] Duplicate columnId: "${r.columnId}"`),n.add(r.columnId),e&&r.editable===true&&r.cellEditor==null&&console.warn(`[OGrid] Column "${r.columnId}" has editable=true but no cellEditor defined. Cells will not open an editor on double-click. Set cellEditor to 'text', 'select', 'checkbox', 'date', or a custom component.`);}function Ft(t){typeof process<"u"&&process.env?.NODE_ENV==="production"||t.enabled===true&&(!t.rowHeight||t.rowHeight<=0)&&console.warn("[OGrid] virtualScroll.enabled is true but rowHeight is missing or <= 0. Set a positive rowHeight (e.g. virtualScroll: { enabled: true, rowHeight: 36 }) for correct virtual scrolling behavior.");}function Mt(t,e){if(typeof process<"u"&&process.env.NODE_ENV==="production"||!e)return;let n=new Set,r=Math.min(t.length,100);for(let o=0;o<r;o++){let l=e(t[o]);if(l==null){console.warn(`[OGrid] getRowId returned null/undefined for row ${o}`);return}if(n.has(l)){console.warn(`[OGrid] Duplicate row ID "${l}" at index ${o}. getRowId must return unique values.`);return}n.add(l);}}var de=[{minWidth:0,maxPriority:0},{minWidth:576,maxPriority:1},{minWidth:768,maxPriority:2},{minWidth:992,maxPriority:3},{minWidth:1200,maxPriority:1/0}];function ce(t,e,n){let r=n?.breakpoints??de,o=new Set;if(t<=0||e.length===0)return o;let l=1/0;for(let i=r.length-1;i>=0;i--)if(t>=r[i].minWidth){l=r[i].maxPriority;break}if(l===1/0)return o;for(let i of e)i.responsivePriority!=null&&(i.required||i.responsivePriority>l&&o.add(i.columnId));return o}function At(t){return t===true?{}:t||void 0}function Pt(t,e,n){if(!n||e<=0)return t;let r=ce(e,t,n);return r.size===0?t:t.filter(o=>!r.has(o.columnId))}function Nt(t,e,n,r,o){t.stopPropagation();let l=n-r;o.setActiveCell({rowIndex:e,columnIndex:n}),o.setSelectionRange({startRow:e,startCol:l,endRow:e,endCol:l});}var Ot=300,_t=300,kt=300;var Lt={RESIZE_HANDLE:1,ACTIVE_CELL:2,FILL_HANDLE:3,SELECTION_OVERLAY:4,ROW_NUMBER:5,CLIPBOARD_OVERLAY:5,PINNED:6,SELECTION_CELL:7,THEAD:8,PINNED_HEADER:10,HEADER_FOCUS:11,SELECTION_HEADER_PINNED:12,LOADING:2,DROP_INDICATOR:100,DROPDOWN:1e3,FILTER_POPOVER:1e3,MODAL:2e3,FULLSCREEN:9999,CONTEXT_MENU:1e4};export{ie as AUTOSIZE_EXTRA_PX,ae as AUTOSIZE_MAX_PX,it as CELL_PADDING,ot as CHECKBOX_COLUMN_WIDTH,we as COLUMN_HEADER_MENU_ITEMS,G as CellDescriptorCache,B as DEFAULT_DATE_FORMAT,Ot as DEFAULT_DEBOUNCE_MS,X as DEFAULT_MIN_COLUMN_WIDTH,We as DEFAULT_WORKER_SORT_AUTO_THRESHOLD,ut as GRID_BORDER_RADIUS,ye as GRID_CONTEXT_MENU_ITEMS,J as MAX_PAGE_BUTTONS,Q as PAGE_SIZE_OPTIONS,_t as PEOPLE_SEARCH_DEBOUNCE_MS,de as RESPONSIVE_BREAKPOINTS,st as ROW_NUMBER_COLUMN_ID,at as ROW_NUMBER_COLUMN_MIN_WIDTH,lt as ROW_NUMBER_COLUMN_WIDTH,kt as SIDEBAR_TRANSITION_MS,z as UndoRedoStack,Lt as Z_INDEX,pt as applyCellDeletion,Tt as applyCutClear,vt as applyFillValues,yt as applyPastedValues,bt as applyRangeRowSelection,Pt as applyResponsiveHiding,ue as areFillCompatible,Ae as areGridRowPropsEqual,ne as booleanParser,tt as buildCellIndex,j as buildCsvHeader,K as buildCsvRows,ge as buildHeaderRows,Ze as buildInlineEditorProps,Qe as buildPopoverEditorProps,Ne as calculateDropTarget,Ct as clampSelectionToBounds,q as columnLetterToIndex,Fe as computeAggregations,ft as computeArrowNavigation,It as computeAutoScrollSpeed,rt as computeNextSortState,xt as computeRowSelectionState,mt as computeTabNavigation,Le as computeTotalHeight,Oe as computeVisibleColumnRange,ke as computeVisibleRange,pe as createGridDataAccessor,oe as createSortFilterWorker,ve as currencyParser,te as dateParser,Je as debounce,Ie as deriveFilterOptionsFromData,Ee as emailParser,k as escapeCsvValue,dt as estimateHeaderMinWidth,fe as exportToCsv,le as extractValueMatrix,A as findCtrlArrowTarget,Z as flattenColumns,St as formatCellReference,se as formatCellValueForTsv,W as formatDateForDisplay,ht as formatSelectionAsTsv,Te as formatShortcut,je as getCellRenderDescriptor,x as getCellValue,De as getColumnHeaderMenuItems,Se as getContextMenuHandlers,he as getDataGridStatusBarConfig,Xe as getDateInputPlaceholder,w as getFilterField,ze as getHeaderFilterConfig,be as getMultiSelectFilterFields,Re as getPaginationViewModel,re as getPinStateForColumn,ce as getResponsiveHiddenColumns,Ve as getScrollTopForRow,xe as getStatusBarParts,Nt as handleBooleanCellPointerDown,U as indexToColumnLetter,nt as injectGlobalStyles,h as isColumnEditable,v as isFilterConfig,F as isInSelectionRange,D as isRowInRange,ct as measureColumnContentWidth,et as measureRange,Ce as mergeFilter,R as normalizeSelectionRange,ee as numberParser,Rt as parseTsvClipboard,$e as parseUserInputDate,T as parseValue,_e as partitionColumnsForVirtualization,M as processClientSideData,Be as processClientSideDataAsync,gt as rangesEqual,Pe as reorderColumnArray,Ke as resolveCellDisplayContent,Ye as resolveCellStyle,At as resolveResponsiveConfig,Ge as shouldUseWorkerSort,He as terminateSortFilterWorker,me as toUserLike,Y as triggerCsvDownload,Et as validateColumns,Mt as validateRowIds,Ft as validateVirtualScrollConfig};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export { getPinStateForColumn, reorderColumnArray, calculateDropTarget, } from '
|
|
|
26
26
|
export type { ColumnPinState, IDropTarget, ICalculateDropTargetParams } from './utils';
|
|
27
27
|
export { computeVisibleRange, computeTotalHeight, getScrollTopForRow, computeVisibleColumnRange, partitionColumnsForVirtualization, } from './utils';
|
|
28
28
|
export type { IVisibleRange, IVisibleColumnRange } from './utils';
|
|
29
|
-
export { createSortFilterWorker, terminateSortFilterWorker, extractValueMatrix, processClientSideDataAsync, } from './utils';
|
|
29
|
+
export { createSortFilterWorker, terminateSortFilterWorker, extractValueMatrix, processClientSideDataAsync, DEFAULT_WORKER_SORT_AUTO_THRESHOLD, shouldUseWorkerSort, } from './utils';
|
|
30
30
|
export type { SortFilterRequest, SortFilterResponse } from './utils';
|
|
31
31
|
export { getHeaderFilterConfig, getCellRenderDescriptor, CellDescriptorCache, resolveCellDisplayContent, resolveCellStyle, buildInlineEditorProps, buildPopoverEditorProps, } from './utils';
|
|
32
32
|
export type { HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, } from './utils';
|
|
@@ -43,6 +43,8 @@ export interface IFetchParams {
|
|
|
43
43
|
direction: 'asc' | 'desc';
|
|
44
44
|
};
|
|
45
45
|
filters: IFilters;
|
|
46
|
+
/** Optional abort signal for cancelling stale requests when the grid state changes. */
|
|
47
|
+
signal?: AbortSignal;
|
|
46
48
|
}
|
|
47
49
|
export interface IPageResult<T> {
|
|
48
50
|
items: T[];
|
|
@@ -88,6 +90,8 @@ export interface IStatusBarProps {
|
|
|
88
90
|
filteredCount?: number;
|
|
89
91
|
/** Number of selected rows. Omit or 0 to hide. */
|
|
90
92
|
selectedCount?: number;
|
|
93
|
+
/** Number of selected cells in the current cell range. Omit or 0/1 to hide. */
|
|
94
|
+
selectedCellCount?: number;
|
|
91
95
|
/** Panels to show (default: all applicable). */
|
|
92
96
|
panels?: StatusBarPanel[];
|
|
93
97
|
/** Aggregation values for selected numeric cells. */
|
|
@@ -22,6 +22,7 @@ export type { ColumnPinState, IDropTarget, ICalculateDropTargetParams } from './
|
|
|
22
22
|
export { computeVisibleRange, computeTotalHeight, getScrollTopForRow, computeVisibleColumnRange, partitionColumnsForVirtualization, } from './virtualScroll';
|
|
23
23
|
export type { IVisibleRange, IVisibleColumnRange } from './virtualScroll';
|
|
24
24
|
export { createSortFilterWorker, terminateSortFilterWorker, extractValueMatrix, processClientSideDataAsync, } from './workerSortFilter';
|
|
25
|
+
export { DEFAULT_WORKER_SORT_AUTO_THRESHOLD, shouldUseWorkerSort } from './workerSortMode';
|
|
25
26
|
export type { SortFilterRequest, SortFilterResponse } from '../workers/sortFilterWorker';
|
|
26
27
|
export { getHeaderFilterConfig, getCellRenderDescriptor, CellDescriptorCache, resolveCellDisplayContent, resolveCellStyle, buildInlineEditorProps, buildPopoverEditorProps, } from './dataGridViewModel';
|
|
27
28
|
export type { HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, } from './dataGridViewModel';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IColumnDef, IFilters } from '../types';
|
|
2
|
+
/** Shared row-count threshold used by workerSort='auto'. */
|
|
3
|
+
export declare const DEFAULT_WORKER_SORT_AUTO_THRESHOLD = 5000;
|
|
4
|
+
export interface WorkerSortModeOptions<T> {
|
|
5
|
+
columns?: IColumnDef<T>[];
|
|
6
|
+
filters?: IFilters;
|
|
7
|
+
sortBy?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Resolves whether client-side worker sort should be enabled for the current dataset. */
|
|
10
|
+
export declare function shouldUseWorkerSort<T>(workerSort: boolean | 'auto' | undefined, rowCount: number, options?: WorkerSortModeOptions<T>): boolean;
|
package/package.json
CHANGED