@gp-grid/core 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.d.ts +109 -32
- package/dist/index.js +1 -1315
- package/dist/styles.css +1 -1115
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -3,1318 +3,4 @@ const e=(e,t,n,r,i)=>{let a=0,o=0;return e<40+i?o=-10:e>n-40&&(o=10),t<40?a=-10:
|
|
|
3
3
|
`).replaceAll(`\r`,`
|
|
4
4
|
`),ze=e=>{let t=I(e).split(`
|
|
5
5
|
`);return t.length>1&&t.at(-1)===``&&t.pop(),t.map(e=>e.split(` `).map(e=>({value:e,text:e})))},Be=(e,t)=>{if(e.value===null)return{ok:!0,value:null};let n=e.text,r=n.trim();if(r.length===0)return Ve(t);switch(t.cellDataType){case`text`:return{ok:!0,value:n};case`number`:return He(e.value,r);case`boolean`:return Ue(e.value,r);case`date`:case`dateTime`:return We(e.value,r);case`dateString`:case`dateTimeString`:return Ge(r,n);case`object`:return Ke(e.value,r)}},Ve=e=>e.cellDataType===`text`?{ok:!0,value:``}:{ok:!0,value:null},He=(e,t)=>{if(typeof e==`number`&&Number.isFinite(e))return{ok:!0,value:e};let n=Number(t);return Number.isFinite(n)?{ok:!0,value:n}:{ok:!1}},Ue=(e,t)=>{if(typeof e==`boolean`)return{ok:!0,value:e};let n=t.toLowerCase();return n===`true`?{ok:!0,value:!0}:n===`false`?{ok:!0,value:!1}:{ok:!1}},We=(e,t)=>{if(e instanceof Date&&L(e))return{ok:!0,value:e};let n=new Date(t);return L(n)?{ok:!0,value:n}:{ok:!1}},Ge=(e,t)=>{let n=new Date(e);return L(n)?{ok:!0,value:t}:{ok:!1}},Ke=(e,t)=>{if(typeof e==`object`&&e&&!(e instanceof Date))return{ok:!0,value:e};try{let e=JSON.parse(t);if(typeof e==`object`&&e)return{ok:!0,value:e}}catch{return{ok:!1}}return{ok:!1}},L=e=>Number.isFinite(e.getTime());var R=class{state={activeCell:null,range:null,anchor:null,selectionMode:!1};options;emitter=v();clipboardSnapshot=null;onInstruction=this.emitter.onInstruction;emit=this.emitter.emit;constructor(e){this.options=e}getState(){return{...this.state}}getActiveCell(){return this.state.activeCell}getSelectionRange(){return this.state.range}isSelected(e,t){let{range:n}=this.state;if(!n)return!1;let{minRow:r,maxRow:i,minCol:a,maxCol:s}=o(n);return e>=r&&e<=i&&t>=a&&t<=s}isActiveCell(e,t){let{activeCell:n}=this.state;return n?.row===e&&n?.col===t}startSelection(e,t={}){let{shift:n=!1,ctrl:r=!1}=t,{row:i,col:a}=this.clampPosition(e);n&&this.state.anchor?(this.state.range={startRow:this.state.anchor.row,startCol:this.state.anchor.col,endRow:i,endCol:a},this.state.activeCell={row:i,col:a}):(this.state.activeCell={row:i,col:a},this.state.anchor={row:i,col:a},this.state.range=null),this.state.selectionMode=r,this.emit({type:`SET_ACTIVE_CELL`,position:this.state.activeCell}),this.emit({type:`SET_SELECTION_RANGE`,range:this.state.range})}moveFocus(e,t=!1){if(!this.state.activeCell){this.startSelection({row:0,col:0});return}let{row:n,col:r}=this.state.activeCell,i=n,a=r;switch(e){case`up`:i=Math.max(0,n-1);break;case`down`:i=Math.min(this.options.getRowCount()-1,n+1);break;case`left`:a=Math.max(0,r-1);break;case`right`:a=Math.min(this.options.getColumnCount()-1,r+1);break}t?(this.state.anchor??={row:n,col:r},this.state.range={startRow:this.state.anchor.row,startCol:this.state.anchor.col,endRow:i,endCol:a},this.state.activeCell={row:i,col:a},this.emit({type:`SET_ACTIVE_CELL`,position:this.state.activeCell}),this.emit({type:`SET_SELECTION_RANGE`,range:this.state.range})):(this.state.activeCell={row:i,col:a},this.state.anchor={row:i,col:a},this.state.range=null,this.emit({type:`SET_ACTIVE_CELL`,position:this.state.activeCell}),this.emit({type:`SET_SELECTION_RANGE`,range:null}))}selectAll(){let e=this.options.getRowCount(),t=this.options.getColumnCount();e!==0&&t!==0&&(this.state.range={startRow:0,startCol:0,endRow:e-1,endCol:t-1},this.state.activeCell||(this.state.activeCell={row:0,col:0},this.emit({type:`SET_ACTIVE_CELL`,position:this.state.activeCell})),this.emit({type:`SET_SELECTION_RANGE`,range:this.state.range}))}clearSelection(){this.state.activeCell=null,this.state.range=null,this.state.anchor=null,this.state.selectionMode=!1,this.emit({type:`SET_ACTIVE_CELL`,position:null}),this.emit({type:`SET_SELECTION_RANGE`,range:null})}setActiveCell(e,t){let n=this.clampPosition({row:e,col:t});this.state.activeCell=n,this.state.anchor=n,this.state.range=null,this.emit({type:`SET_ACTIVE_CELL`,position:this.state.activeCell}),this.emit({type:`SET_SELECTION_RANGE`,range:null})}setSelectionRange(e){this.state.range=e,this.emit({type:`SET_SELECTION_RANGE`,range:this.state.range})}getSelectedData(){let e=this.getEffectiveRange();if(e===null)return[];let{minRow:t,maxRow:n,minCol:r,maxCol:i}=o(e),a=[];for(let e=t;e<=n;e++){let t=[];for(let n=r;n<=i;n++)t.push(this.options.getCellValue(e,n));a.push(t)}return a}async copySelectionToClipboard(){let e=this.getEffectiveRange();if(e===null)return;let t=this.createClipboardSnapshot(e);t.cells.length!==0&&(this.clipboardSnapshot=t,!(typeof navigator>`u`||typeof document>`u`)&&await navigator.clipboard.writeText(t.text))}pasteClipboardText(e){let t=this.getEffectiveRange();if(t===null)return{handled:!1,changedCells:[]};let n=this.getPasteSourceCells(e);return n.length===0?{handled:!1,changedCells:[]}:{handled:!0,changedCells:this.applyPasteSource(n,t,this.state.range!==null)}}destroy(){this.emitter.clearListeners(),this.state={activeCell:null,range:null,anchor:null,selectionMode:!1},this.clipboardSnapshot=null}clampPosition(e){let t=this.options.getRowCount(),n=this.options.getColumnCount();return{row:Math.max(0,Math.min(e.row,t-1)),col:Math.max(0,Math.min(e.col,n-1))}}getEffectiveRange(){let{range:e,activeCell:t}=this.state;return e||(t?{startRow:t.row,startCol:t.col,endRow:t.row,endCol:t.col}:null)}createClipboardSnapshot(e){let{minRow:t,maxRow:n,minCol:r,maxCol:i}=o(e),a=[];for(let e=t;e<=n;e++){let t=[];for(let n=r;n<=i;n++){let r=this.options.getCellValue(e,n),i=y(r,this.options.getColumn(n)?.valueFormatter);t.push({value:r,text:i})}a.push(t)}return{cells:a,text:a.map(e=>e.map(e=>e.text).join(` `)).join(`
|
|
6
|
-
`)}}getPasteSourceCells(e){let t=this.clipboardSnapshot;return t&&I(t.text)===I(e)?t.cells:ze(e)}applyPasteSource(e,t,n){let r=[],{minRow:i,maxRow:a,minCol:s,maxCol:c}=o(t),l=this.isSingleSourceCell(e),u=l?a:i+e.length-1,d=l?c:s+this.getMaxSourceColumnCount(e)-1,f=n?Math.min(u,a):u,p=n?Math.min(d,c):d,m=this.options.getRowCount(),h=this.options.getColumnCount(),g=Math.min(f,m-1),_=Math.min(p,h-1);for(let t=i;t<=g;t++)for(let n=s;n<=_;n++){let a=this.getSourceCellForTarget(e,t-i,n-s,l);a&&this.applyPasteCell(t,n,a,r)}return r}applyPasteCell(e,t,n,r){let i=this.options.getColumn(t);if(i===void 0||i.hidden===!0||i.editable!==!0)return;let a=Be(n,i);a.ok!==!1&&(this.options.setCellValue(e,t,a.value),r.push({row:e,col:t,value:a.value}))}getSourceCellForTarget(e,t,n,r){return r?e[0]?.[0]??null:e[t]?.[n]??null}isSingleSourceCell(e){return e.length===1&&e[0]?.length===1}getMaxSourceColumnCount(e){return e.reduce((e,t)=>Math.max(e,t.length),0)}},z=class{state=null;options;emitter=v();onInstruction=this.emitter.onInstruction;emit=this.emitter.emit;constructor(e){this.options=e}getState(){return this.state?{...this.state}:null}isActive(){return this.state!==null}startFillDrag(e){this.state={sourceRange:e,targetRow:e.endRow,targetCol:e.endCol},this.emit({type:`START_FILL`,sourceRange:e})}updateFillDrag(e,t){if(!this.state)return;let n=this.options.getRowCount(),r=this.options.getColumnCount();e=Math.max(0,Math.min(e,n-1)),t=Math.max(0,Math.min(t,r-1)),this.state.targetRow=e,this.state.targetCol=t,this.emit({type:`UPDATE_FILL`,targetRow:e,targetCol:t})}commitFillDrag(){if(!this.state)return;let{sourceRange:e,targetRow:t}=this.state,n=this.calculateFilledCells(e,t);for(let{row:e,col:t,value:r}of n)this.options.setCellValue(e,t,r);this.emit({type:`COMMIT_FILL`,filledCells:n}),this.state=null}cancelFillDrag(){this.state&&(this.state=null,this.emit({type:`CANCEL_FILL`}))}destroy(){this.emitter.clearListeners(),this.state=null}calculateFilledCells(e,t){let n=[],{minRow:r,maxRow:i,minCol:a,maxCol:s}=o(e),c=t>i,l=t<r;if(c||l)for(let e=a;e<=s;e++){let a=this.getSourceColumnValues(r,i,e),o=this.detectPattern(a);if(c)for(let r=i+1;r<=t;r++){let t=r-i-1,s=this.applyPattern(o,a,t);n.push({row:r,col:e,value:s})}else if(l)for(let i=r-1;i>=t;i--){let t=r-i-1,s=this.applyPattern(o,a,t,!0);n.push({row:i,col:e,value:s})}}return n}getSourceColumnValues(e,t,n){let r=[];for(let i=e;i<=t;i++)r.push(this.options.getCellValue(i,n));return r}detectPattern(e){if(e.length===0)return{type:`constant`,value:null};if(e.length===1)return{type:`constant`,value:e[0]??null};let t=e.map(e=>typeof e==`number`?e:Number(e));if(t.every(e=>!Number.isNaN(e))){let e=[];for(let n=1;n<t.length;n++)e.push(t[n]-t[n-1]);if(e.every(t=>t===e[0])&&e[0]!==void 0)return{type:`arithmetic`,start:t[0],step:e[0]}}return{type:`repeat`,values:e}}applyPattern(e,t,n,r=!1){switch(e.type){case`constant`:return e.value;case`arithmetic`:{let i=r?-(n+1):n+1;return(r?e.start:e.start+e.step*(t.length-1))+e.step*i}case`repeat`:{let t=e.values.length;if(t===0)return null;if(r){let r=(t-1-n%t+t)%t;return e.values[r]??null}return e.values[n%t]??null}}}},B=class{state={slots:new Map,rowToSlot:new Map,nextSlotId:0};options;emitter=ee();isDestroyed=!1;onInstruction=this.emitter.onInstruction;onBatchInstruction=this.emitter.onBatchInstruction;emit=this.emitter.emit;emitBatch=this.emitter.emitBatch;constructor(e){this.options=e}getSlotForRow(e){return this.state.rowToSlot.get(e)}getSlots(){return this.state.slots}syncSlots(){let e=this.options.getScrollTop(),t=this.options.getRowHeight(),n=this.options.getViewportHeight(),r=this.options.getTotalRows(),i=this.options.getOverscan(),a=n,o=Math.max(0,Math.floor(e/t)-i),s=Math.min(r-1,Math.ceil((e+a)/t)+i);if(r===0||s<o){this.destroyAllSlots();return}let c=new Set;for(let e=o;e<=s;e++)c.add(e);let l=[],u=this.partitionSlots(c),d=0;for(let e of c){let t=this.options.getRowData(e);if(t===void 0)continue;let n=d<u.length?u[d++]:void 0;this.assignSlotToRow(e,t,n,l)}for(let e=d;e<u.length;e++){let t=u[e];this.state.slots.delete(t),l.push({type:`DESTROY_SLOT`,slotId:t})}this.updateSlotPositions(l),this.emitBatch(l)}partitionSlots(e){let t=[];for(let[n,r]of this.state.slots)e.has(r.rowIndex)?e.delete(r.rowIndex):(t.push(n),this.state.rowToSlot.delete(r.rowIndex));return t}assignSlotToRow(e,t,n,r){let i;if(n===void 0)i=`slot-${this.state.nextSlotId++}`,this.state.slots.set(i,{slotId:i,rowIndex:e,rowData:t,translateY:this.getRowTranslateY(e)}),r.push({type:`CREATE_SLOT`,slotId:i});else{i=n;let r=this.state.slots.get(i);r.rowIndex=e,r.rowData=t,r.translateY=this.getRowTranslateY(e)}this.state.rowToSlot.set(e,i),r.push({type:`ASSIGN_SLOT`,slotId:i,rowIndex:e,rowData:t},{type:`MOVE_SLOT`,slotId:i,translateY:this.getRowTranslateY(e)})}updateSlotPositions(e){for(let[t,n]of this.state.slots){let r=this.getRowTranslateY(n.rowIndex);n.translateY!==r&&(n.translateY=r,e.push({type:`MOVE_SLOT`,slotId:t,translateY:r}))}}destroyAllSlots(){let e=[];for(let t of this.state.slots.keys())e.push({type:`DESTROY_SLOT`,slotId:t});this.state.slots.clear(),this.state.rowToSlot.clear(),this.emitBatch(e)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.state.slots.clear(),this.state.rowToSlot.clear(),this.emitter.clearListeners())}refreshAllSlots(){let e=[],t=this.options.getTotalRows();for(let[n,r]of this.state.slots)if(r.rowIndex>=0&&r.rowIndex<t){let t=this.options.getRowData(r.rowIndex);if(t===void 0)continue;let i=this.getRowTranslateY(r.rowIndex);r.rowData=t,r.translateY=i,e.push({type:`ASSIGN_SLOT`,slotId:n,rowIndex:r.rowIndex,rowData:t},{type:`MOVE_SLOT`,slotId:n,translateY:i})}this.emitBatch(e),this.syncSlots()}updateSlot(e){let t=this.state.rowToSlot.get(e);if(t){let n=this.options.getRowData(e);n&&this.emit({type:`ASSIGN_SLOT`,slotId:t,rowIndex:e,rowData:n})}}getRowTranslateY(e){let t=this.options.getRowHeight(),n=this.options.getScrollRatio(),r=this.options.getScrollTop(),i=e*t;return n>=1?i:i-Math.floor(r/t)*t}getRowTranslateYForIndex(e){return this.getRowTranslateY(e)}getRowsWrapperOffset(){let e=this.options.getScrollRatio(),t=this.options.getScrollTop(),n=this.options.getRowHeight();if(e>=1)return 0;let r=t%n;return t*e-r}},V=class{editState=null;peekState=null;options;emitter=v();onInstruction=this.emitter.onInstruction;emit=this.emitter.emit;constructor(e){this.options=e}getState(){return this.editState?{...this.editState}:null}isEditing(){return this.editState!==null}isEditingCell(e,t){return this.editState!==null&&this.editState.row===e&&this.editState.col===t}startEdit(e,t){if(!this.options.getColumn(t)?.editable)return!1;this.peekState!==null&&this.stopPeek();let n=this.options.getCellValue(e,t);return this.editState={row:e,col:t,initialValue:n,currentValue:n},this.emit({type:`START_EDIT`,row:e,col:t,initialValue:n}),!0}getPeekState(){return this.peekState?{...this.peekState}:null}startPeek(e,t){return this.editState===null?(this.peekState={row:e,col:t},this.emit({type:`START_PEEK`,row:e,col:t}),!0):!1}stopPeek(){this.peekState!==null&&(this.peekState=null,this.emit({type:`STOP_PEEK`}))}updateValue(e){this.editState&&(this.editState.currentValue=e)}commit(){if(!this.editState)return;let{row:e,col:t,currentValue:n}=this.editState;this.options.setCellValue(e,t,n),this.emit({type:`COMMIT_EDIT`,row:e,col:t,value:n}),this.editState=null,this.emit({type:`STOP_EDIT`}),this.options.onCommit?.(e,t,n)}cancel(){this.editState=null,this.emit({type:`STOP_EDIT`})}destroy(){this.emitter.clearListeners(),this.editState=null,this.peekState=null}};const qe=e=>{let{batcher:t}=e,n,r=new A({getRowHeight:e.getRowHeight,getHeaderHeight:e.getHeaderHeight,getTotalRows:e.getTotalRows,getScrollTop:()=>n.getScrollTop(),getViewportHeight:()=>n.getViewportHeight()});n=new Re(()=>r.getScrollRatio());let i=null,a=new R({getRowCount:e.getTotalRows,getColumnCount:()=>e.getColumns().length,getCellValue:e.getCellValue,getRowData:t=>e.getCachedRows().get(t),getColumn:t=>e.getColumns()[t],setCellValue:e.setCellValue});a.onInstruction(e=>{t.emit(e),i?.onSelectionChange()}),e.highlighting&&(i=new C({getActiveCell:()=>a.getActiveCell(),getSelectionRange:()=>a.getSelectionRange(),getColumn:t=>e.getColumns()[t]},e.highlighting),i.onInstruction(e=>t.emit(e)));let o=new z({getRowCount:e.getTotalRows,getColumnCount:()=>e.getColumns().length,getCellValue:e.getCellValue,getColumn:t=>e.getColumns()[t],setCellValue:e.setCellValue});o.onInstruction(e=>t.emit(e));let s=new B({getRowHeight:e.getRowHeight,getHeaderHeight:e.getHeaderHeight,getOverscan:e.getOverscan,getScrollTop:()=>n.getScrollTop(),getViewportHeight:()=>n.getViewportHeight(),getTotalRows:e.getTotalRows,getScrollRatio:()=>r.getScrollRatio(),getVirtualContentHeight:()=>r.getVirtualContentHeight(),getRowData:t=>e.getCachedRows().get(t)});s.onBatchInstruction(e=>t.emitBatch(e));let c=new V({getColumn:t=>e.getColumns()[t],getCellValue:e.getCellValue,setCellValue:e.setCellValue,onCommit:e=>s.updateSlot(e)});c.onInstruction(e=>t.emit(e));let l=new P({getColumns:e.getColumns,isSortingEnabled:e.getSortingEnabled,getCachedRows:e.getCachedRows,onSortFilterChange:async()=>{await e.fetchData(),i?.clearAllCaches(),n.resetScrollTop(),t.start();try{t.emit({type:`SCROLL_TO`,scrollTop:0}),e.emitContentSize(),e.emitHeaders(),s.refreshAllSlots()}finally{t.flush()}},onDataRefreshed:()=>{}});l.onInstruction(e=>t.emit(e));let u=new w({getCachedRows:e.getCachedRows,setCachedRows:e.setCachedRows,getTotalRows:e.getTotalRows,setTotalRows:e.setTotalRows,updateSlot:e=>s.updateSlot(e),refreshAllSlots:()=>s.refreshAllSlots(),emitContentSize:e.emitContentSize,clearSelectionIfInvalid:e.clearSelectionIfInvalid});return u.onInstruction(e=>t.emit(e)),{selection:a,highlight:i,fill:o,scrollVirtualization:r,viewport:n,slotPool:s,editManager:c,sortFilter:l,rowMutation:u}},Je=e=>{let t=e.columnPositions.at(-1)??0;e.scrollVirtualization.updateContentSize(),e.batcher.emit({type:`SET_CONTENT_SIZE`,width:t,height:e.scrollVirtualization.getVirtualHeight(),viewportWidth:e.viewport.getViewportWidth(),viewportHeight:e.viewport.getViewportHeight(),rowsWrapperOffset:e.slotPool.getRowsWrapperOffset()})},Ye=e=>{let t=e.sortFilter.getSortInfoMap();for(let n=0;n<e.columns.length;n++){let r=e.columns[n],i=r.colId??r.field,a=t.get(i);e.batcher.emit({type:`UPDATE_HEADER`,colIndex:n,column:r,sortDirection:a?.direction,sortIndex:a?.index,hasFilter:e.sortFilter.hasActiveFilter(i)})}},Xe=e=>{let t=e.scrollVirtualization.getVisibleRowRange();e.batcher.emit({type:`UPDATE_VISIBLE_RANGE`,start:t.start,end:t.end,rowsWrapperOffset:e.slotPool.getRowsWrapperOffset()})};var Ze=class{columns;rowHeight;headerHeight;overscan;maxFlingVelocity;sortingEnabled;getRowId;onCellValueChanged;rowDragEntireRow;onRowDragEnd;onColumnResized;onColumnMoved;viewport;scrollTopOverride=null;rowData;selection;fill;input;highlight;sortFilter;rowMutation;slotPool;editManager;columnPositions=[];batcher=new Le;scrollVirtualization;isDestroyed=!1;hasWarnedAboutScaledOverscan=!1;constructor(e){if(this.columns=e.columns,this.rowHeight=e.rowHeight,this.headerHeight=e.headerHeight??e.rowHeight,this.overscan=e.overscan??3,this.maxFlingVelocity=e.maxFlingVelocity??2e4*this.rowHeight/1e3,this.sortingEnabled=e.sortingEnabled??!0,this.getRowId=e.getRowId,this.onCellValueChanged=e.onCellValueChanged,this.rowDragEntireRow=e.rowDragEntireRow??!1,this.onRowDragEnd=e.onRowDragEnd,this.onColumnResized=e.onColumnResized,this.onColumnMoved=e.onColumnMoved,this.onCellValueChanged&&!this.getRowId)throw Error(`getRowId is required when onCellValueChanged is provided`);this.computeColumnPositions();let t,n,r;this.rowData=new O({dataSource:e.dataSource,rowLoading:e.rowLoading,batcher:this.batcher,getColumns:()=>this.columns,getSortModel:()=>r.getSortModel(),getFilterModel:()=>r.getFilterModel(),getRowHeight:()=>this.rowHeight,getOverscan:()=>this.overscan,getScrollTop:()=>t.getScrollTop(),getViewportHeight:()=>t.getViewportHeight(),onCellValueChanged:this.onCellValueChanged,getRowId:this.getRowId,syncSlots:()=>n.syncSlots(),emitVisibleRange:()=>this.emitVisibleRange(),emitContentSize:()=>this.emitContentSize()});let i=qe({batcher:this.batcher,highlighting:e.highlighting,getColumns:()=>this.columns,getCachedRows:()=>this.rowData.getCachedRows(),setCachedRows:e=>this.rowData.setCachedRows(e),getTotalRows:()=>this.rowData.getTotalRows(),setTotalRows:e=>this.rowData.setTotalRows(e),getRowHeight:()=>this.rowHeight,getHeaderHeight:()=>this.headerHeight,getOverscan:()=>this.overscan,getSortingEnabled:()=>this.sortingEnabled,getCellValue:(e,t)=>this.getCellValue(e,t),setCellValue:(e,t,n)=>this.setCellValue(e,t,n),emitContentSize:()=>this.emitContentSize(),emitHeaders:()=>this.emitHeaders(),fetchData:()=>this.rowData.loadInitial(),clearSelectionIfInvalid:e=>this.clearSelectionIfInvalid(e)});this.selection=i.selection,this.highlight=i.highlight,this.fill=i.fill,this.scrollVirtualization=i.scrollVirtualization,this.viewport=i.viewport,this.slotPool=i.slotPool,this.editManager=i.editManager,this.sortFilter=i.sortFilter,this.rowMutation=i.rowMutation,t=this.viewport,n=this.slotPool,r=this.sortFilter,this.input=new S(this,{getHeaderHeight:()=>this.headerHeight,getRowHeight:()=>this.rowHeight,getColumnPositions:()=>this.columnPositions,getColumnCount:()=>this.columns.length})}onBatchInstruction(e){return this.batcher.subscribe(e)}async initialize(){await this.rowData.loadInitial(),this.slotPool.syncSlots(),this.emitContentSize(),this.emitHeaders()}setViewport(e,t,n,r){let{changed:i,viewportSizeChanged:a}=this.viewport.update(this.scrollTopOverride??e,t,n,r);i&&(this.rowData.requestVisibleRows(),this.slotPool.syncSlots(),this.emitVisibleRange(),a&&this.emitContentSize())}async setSort(e,t,n=!1){if(!this.rowData.isLoading())return this.sortFilter.setSort(e,t,n)}async setFilter(e,t){if(!this.rowData.isLoading())return this.sortFilter.setFilter(e,t)}hasActiveFilter(e){return this.sortFilter.hasActiveFilter(e)}getDistinctValuesForColumn(e,t=500){return this.sortFilter.getDistinctValuesForColumn(e,t)}openFilterPopup(e,t,n=!0){this.rowData.isLoading()||this.sortFilter.openFilterPopup(e,t,n)}closeFilterPopup(){this.sortFilter.closeFilterPopup()}getSortModel(){return this.sortFilter.getSortModel()}getFilterModel(){return this.sortFilter.getFilterModel()}startEdit(e,t){this.editManager.startEdit(e,t)}startPeek(e,t){let n=this.columns[t];return!n||n.peekable===!1?!1:this.editManager.startPeek(e,t)}stopPeek(){this.editManager.stopPeek()}getPeekState(){return this.editManager.getPeekState()}updateEditValue(e){this.editManager.updateValue(e)}commitEdit(){this.editManager.commit()}cancelEdit(){this.editManager.cancel()}pasteClipboardText(e){if(this.editManager.getState())return!1;let t=this.selection.pasteClipboardText(e);return t.changedCells.length>0&&this.refreshSlotData(),t.handled}getEditState(){return this.editManager.getState()}getCellValue(e,t){return this.rowData.getCellValue(e,t)}setCellValue(e,t,n){this.rowData.setCellValue(e,t,n)}clearSelectionIfInvalid(e){let t=this.selection.getActiveCell();t&&t.row>=e&&this.selection.clearSelection()}computeColumnPositions(){this.columnPositions=ue(this.columns)}emitContentSize(){Je({batcher:this.batcher,scrollVirtualization:this.scrollVirtualization,slotPool:this.slotPool,viewport:this.viewport,columnPositions:this.columnPositions}),this.warnIfOverscanTooLowForScaling()}warnIfOverscanTooLowForScaling(){this.hasWarnedAboutScaledOverscan||this.scrollVirtualization.isScalingActive()!==!1&&(this.hasWarnedAboutScaledOverscan=!0,!(this.overscan>=10)&&console.warn(`[gp-grid] Scroll virtualization is active (${this.rowData.getTotalRows().toLocaleString()} rows) but overscan is ${this.overscan}. Fast momentum scrolling can outrun rendering and show blank rows at this scale — set the overscan option to 10–12.`))}emitHeaders(){Ye({batcher:this.batcher,sortFilter:this.sortFilter,columns:this.columns})}emitVisibleRange(){Xe({batcher:this.batcher,scrollVirtualization:this.scrollVirtualization,slotPool:this.slotPool})}setColumnWidth(e,t){ke(e,t,this.viewport.getViewportWidth(),{batcher:this.batcher,slotPool:this.slotPool,refreshSlots:`sync`,computeColumnPositions:()=>this.computeColumnPositions(),emitContentSize:()=>this.emitContentSize(),emitHeaders:()=>this.emitHeaders(),columns:this.columns,onComplete:()=>this.onColumnResized?.(e,t)})}moveColumn(e,t){let n=Ae(e,t,{batcher:this.batcher,slotPool:this.slotPool,refreshSlots:`all`,computeColumnPositions:()=>this.computeColumnPositions(),emitContentSize:()=>this.emitContentSize(),emitHeaders:()=>this.emitHeaders(),columns:this.columns,onComplete:()=>{}});n!==null&&this.onColumnMoved?.(e,n)}commitRowDrag(e,t){je(e,t,{dataSource:this.rowData.getDataSource(),cachedRows:this.rowData.getCachedRows(),slotPool:this.slotPool,highlight:this.highlight}),this.onRowDragEnd?.(e,t)}isRowDragEntireRow(){return this.rowDragEntireRow}getColumns(){return this.columns}getColumnPositions(){return[...this.columnPositions]}getRowCount(){return this.rowData.getTotalRows()}getRowHeight(){return this.rowHeight}getHeaderHeight(){return this.headerHeight}getTotalWidth(){return this.columnPositions.at(-1)??0}getTotalHeight(){return this.scrollVirtualization.getVirtualHeight()}isScalingActive(){return this.scrollVirtualization.isScalingActive()}getMaxFlingVelocity(){return this.maxFlingVelocity}setScrollTopOverride(e){this.scrollTopOverride=e}getNaturalHeight(){return this.scrollVirtualization.getNaturalHeight()}getScrollRatio(){return this.scrollVirtualization.getScrollRatio()}getVisibleRowRange(){return this.scrollVirtualization.getVisibleRowRange()}getScrollTopForRow(e){return this.scrollVirtualization.getScrollTopForRow(e)}getRowIndexAtDisplayY(e,t){return this.scrollVirtualization.getRowIndexAtDisplayY(e,t)}getRowTranslateY(e){return this.slotPool.getRowTranslateYForIndex(e)}getRowData(e){return this.rowData.getRowData(e)}async refresh(){await this.rowData.loadInitial(),this.highlight?.clearAllCaches(),this.slotPool.refreshAllSlots(),this.emitContentSize(),this.emitVisibleRange()}async refreshFromTransaction(){await this.rowData.refreshFromTransaction(),this.highlight?.clearAllCaches(),this.slotPool.refreshAllSlots(),this.emitContentSize(),this.emitVisibleRange()}refreshSlotData(){this.slotPool.refreshAllSlots()}addRows(e,t){this.rowMutation.addRows(e,t)}updateRows(e){this.rowMutation.updateRows(e)}deleteRows(e){this.rowMutation.deleteRows(e)}getRow(e){return this.rowMutation.getRow(e)}setRow(e,t){this.rowMutation.setRow(e,t)}async setDataSource(e){this.editManager.getState()&&this.editManager.cancel(),this.rowData.setDataSource(e),await this.refresh(),this.clearSelectionIfInvalid(this.rowData.getTotalRows())}setColumns(e){this.columns=e,this.computeColumnPositions(),this.emitContentSize(),this.emitHeaders(),this.slotPool.syncSlots()}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.slotPool.destroy(),this.highlight?.destroy(),this.sortFilter.destroy(),this.rowMutation.destroy(),this.rowData.destroy(),this.batcher.clearListeners())}},Qe=class{workerCode;maxWorkers;workers=[];workerUrl=null;nextRequestId=0;isTerminated=!1;constructor(e,t={}){this.workerCode=e;let n=typeof navigator>`u`?4:navigator.hardwareConcurrency;this.maxWorkers=Math.max(1,t.maxWorkers??n??4),t.preWarm&&this.preWarmWorkers()}getPoolSize(){return this.workers.length}getMaxWorkers(){return this.maxWorkers}isAvailable(){return!this.isTerminated&&typeof Worker<`u`}async execute(e,t){if(this.isTerminated)throw Error(`WorkerPool has been terminated`);if(typeof Worker>`u`)throw TypeError(`Web Workers are not available in this environment`);let n=this.getAvailableWorker(),r=this.nextRequestId++,i={...e,id:r};return new Promise((e,a)=>{n.pendingRequests.set(r,{resolve:e,reject:a}),n.busy=!0,t&&t.length>0?n.worker.postMessage(i,t):n.worker.postMessage(i)})}async executeParallel(e){if(this.isTerminated)throw Error(`WorkerPool has been terminated`);if(e.length===0)return[];let t=Math.min(e.length,this.maxWorkers);this.ensureWorkers(t);let n=e.map((e,t)=>{let n=t%this.workers.length,r=this.workers[n],i=this.nextRequestId++,a={...e.request,id:i};return new Promise((t,n)=>{r.pendingRequests.set(i,{resolve:t,reject:n}),r.busy=!0,e.transferables&&e.transferables.length>0?r.worker.postMessage(a,e.transferables):r.worker.postMessage(a)})});return Promise.all(n)}terminate(){for(let e of this.workers){e.worker.terminate();for(let[,t]of e.pendingRequests)t.reject(Error(`Worker pool terminated`));e.pendingRequests.clear()}this.workers=[],this.workerUrl&&=(URL.revokeObjectURL(this.workerUrl),null),this.isTerminated=!0}preWarmWorkers(){this.ensureWorkers(this.maxWorkers)}ensureWorkers(e){let t=Math.min(e,this.maxWorkers)-this.workers.length;for(let e=0;e<t;e++)this.createWorker()}getAvailableWorker(){return this.workers.find(e=>!e.busy)||(this.workers.length<this.maxWorkers?this.createWorker():this.workers.reduce((e,t)=>t.pendingRequests.size<e.pendingRequests.size?t:e,this.workers[0]))}createWorker(){if(!this.workerUrl){let e=new Blob([this.workerCode],{type:`application/javascript`});this.workerUrl=URL.createObjectURL(e)}let e=new Worker(this.workerUrl),t={worker:e,busy:!1,pendingRequests:new Map};return e.onmessage=e=>{let{id:n}=e.data,r=t.pendingRequests.get(n);r&&(t.pendingRequests.delete(n),t.pendingRequests.size===0&&(t.busy=!1),e.data.type===`error`?r.reject(Error(e.data.error)):r.resolve(e.data))},e.onerror=e=>{for(let[,n]of t.pendingRequests)n.reject(Error(`Worker error: ${e.message}`));t.pendingRequests.clear(),t.busy=!1,this.respawnWorker(t)},this.workers.push(t),t}respawnWorker(e){let t=this.workers.indexOf(e);if(t!==-1){try{e.worker.terminate()}catch{}this.workers.splice(t,1),this.workers.length<this.maxWorkers&&!this.isTerminated&&this.createWorker()}}};function $e(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r}const H=e=>e==null?``:Array.isArray(e)?e.join(`, `):typeof e==`object`&&!(e instanceof Date)?JSON.stringify(e):String(e);function et(e,t){if(e==null&&t==null)return 0;if(e==null)return 1;if(t==null)return-1;let n=Number(e),r=Number(t);return!Number.isNaN(n)&&!Number.isNaN(r)?n-r:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():H(e).localeCompare(H(t))}function tt(e,t){return[...e].sort((e,n)=>{for(let{colId:r,direction:i}of t){let t=et($e(e,r),$e(n,r));if(t!==0)return i===`asc`?t:-t}return 0})}const U=globalThis;U.onmessage!==void 0&&(U.onmessage=e=>{let{type:t,id:n,data:r,sortModel:i}=e.data;if(t===`sort`)try{let e=tt(r,i);U.postMessage?.({type:`sorted`,id:n,data:e})}catch(e){U.postMessage?.({type:`error`,id:n,error:String(e)})}});var nt=class{heap=[];compare;constructor(e){this.compare=e}push(e){this.heap.push(e),this.bubbleUp(this.heap.length-1)}pop(){if(this.heap.length===0)return;let e=this.heap[0],t=this.heap.pop();return this.heap.length>0&&t&&(this.heap[0]=t,this.bubbleDown(0)),e}size(){return this.heap.length}bubbleUp(e){for(;e>0;){let t=Math.floor((e-1)/2);if(this.compare(this.heap[e],this.heap[t])>=0)break;this.swap(e,t),e=t}}bubbleDown(e){let t=this.heap.length;for(;;){let n=2*e+1,r=2*e+2,i=e;if(n<t&&this.compare(this.heap[n],this.heap[i])<0&&(i=n),r<t&&this.compare(this.heap[r],this.heap[i])<0&&(i=r),i===e)break;this.swap(e,i),e=i}}swap(e,t){let n=this.heap[e];this.heap[e]=this.heap[t],this.heap[t]=n}};const rt=(e,t,n)=>{let r=[];for(let i=0;i<n;i++)r.push(e.columns[i][t]);return r};function W(e,t){if(e.length===0)return new Uint32Array;if(e.length===1){let t=e[0],n=new Uint32Array(t.indices.length);for(let e=0;e<t.indices.length;e++)n[e]=t.indices[e]+t.offset;return n}let n=0;for(let t of e)n+=t.indices.length;let r=new Uint32Array(n),i=t===`asc`?1:-1,a=new nt((e,t)=>{let n=(e.value-t.value)*i;return n===0?e.globalIndex-t.globalIndex:n});for(let t=0;t<e.length;t++){let n=e[t];if(n.indices.length>0){let e=n.indices[0];a.push({chunkIndex:t,positionInChunk:0,value:n.values[0],globalIndex:e+n.offset})}}let o=0;for(;a.size()>0;){let t=a.pop();r[o++]=t.globalIndex;let n=e[t.chunkIndex],i=t.positionInChunk+1;if(i<n.indices.length){let e=n.indices[i];a.push({chunkIndex:t.chunkIndex,positionInChunk:i,value:n.values[i],globalIndex:e+n.offset})}}return r}function it(e){if(e.length===0)return new Uint32Array;if(e.length===1){let t=e[0],n=new Uint32Array(t.indices.length);for(let e=0;e<t.indices.length;e++)n[e]=t.indices[e]+t.offset;return n}let t=e[0].directions,n=t.length,r=0;for(let t of e)r+=t.indices.length;let i=new Uint32Array(r),a=new nt((e,n)=>{for(let r=0;r<t.length;r++){let i=(e.values[r]-n.values[r])*t[r];if(i!==0)return i}return e.globalIndex-n.globalIndex});for(let t=0;t<e.length;t++){let r=e[t];if(r.indices.length>0){let e=r.indices[0];a.push({chunkIndex:t,positionInChunk:0,values:rt(r,0,n),globalIndex:e+r.offset})}}let o=0;for(;a.size()>0;){let t=a.pop();i[o++]=t.globalIndex;let r=e[t.chunkIndex],s=t.positionInChunk+1;if(s<r.indices.length){let e=r.indices[s];a.push({chunkIndex:t.chunkIndex,positionInChunk:s,values:rt(r,s,n),globalIndex:e+r.offset})}}return i}function at(e,t){if(e.length<=1)return new Uint32Array;let n=[],r=0;for(let t=0;t<e.length-1;t++){let i=e[t],a=e[t+1];if(i.indices.length===0||a.indices.length===0){r+=i.indices.length;continue}let o=i.indices.length-1,s=i.values[o],c=a.values[0];if(s===c){let e=o;for(;e>0&&i.values[e-1]===s;)e--;let t=0;for(;t<a.indices.length-1&&a.values[t+1]===c;)t++;let l=r+e,u=r+i.indices.length+t+1;n.push(l,u)}r+=i.indices.length}return new Uint32Array(n)}const ot=(e,t,n)=>{let r=Math.max(n,Math.ceil(e/t)),i=[];for(let t=0;t<e;t+=r)i.push({offset:t,length:Math.min(r,e-t)});return i},st=e=>{if(e.length<=1)return[];let t=[],n=0;for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1];if(i.indices.length===0||a.indices.length===0){n+=i.indices.length;continue}let o=i.values[i.indices.length-1],s=a.values[0];if(o===s){let e=i.indices.length-1;for(;e>0&&i.values[e-1]===o;)e--;let r=0;for(;r<a.indices.length-1&&a.values[r+1]===s;)r++;t.push(n+e,n+i.indices.length+r+1)}n+=i.indices.length}return t},ct=(e,t,n,r)=>{let i=r===`asc`?1:-1;for(let r=0;r<t.length;r+=2){let a=t[r],o=t[r+1];o<=a||o>e.length||lt(e,a,o,n,i)}},lt=(e,t,n,r,i)=>{let a=Array.from(e.slice(t,n));if(!ut(a,r)){a.sort((e,t)=>i*r[e].localeCompare(r[t]));for(let n=0;n<a.length;n++)e[t+n]=a[n]}},ut=(e,t)=>{let n=t[e[0]];for(let r=1;r<e.length;r++)if(t[e[r]]!==n)return!1;return!0};var G=class{pool;parallelThreshold;minChunkSize;isTerminated=!1;constructor(e={}){let t=e.maxWorkers??(navigator===void 0?4:navigator.hardwareConcurrency)??4;this.pool=new Qe(`
|
|
7
|
-
// ---- Shared helpers (inlined for worker isolation) ----------------------
|
|
8
|
-
function getFieldValue(row, field) {
|
|
9
|
-
const parts = field.split(".");
|
|
10
|
-
let value = row;
|
|
11
|
-
for (const part of parts) {
|
|
12
|
-
if (value == null || typeof value !== "object") return null;
|
|
13
|
-
value = value[part];
|
|
14
|
-
}
|
|
15
|
-
return value ?? null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function toDisplayString(v) {
|
|
19
|
-
if (v == null) return "";
|
|
20
|
-
if (Array.isArray(v)) return v.join(", ");
|
|
21
|
-
if (typeof v === "object" && !(v instanceof Date)) return JSON.stringify(v);
|
|
22
|
-
return String(v);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function compareValues(a, b) {
|
|
26
|
-
if (a == null && b == null) return 0;
|
|
27
|
-
if (a == null) return 1;
|
|
28
|
-
if (b == null) return -1;
|
|
29
|
-
const aNum = Number(a);
|
|
30
|
-
const bNum = Number(b);
|
|
31
|
-
if (!isNaN(aNum) && !isNaN(bNum)) return aNum - bNum;
|
|
32
|
-
if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();
|
|
33
|
-
return toDisplayString(a).localeCompare(toDisplayString(b));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function sortData(data, sortModel) {
|
|
37
|
-
return [...data].sort((a, b) => {
|
|
38
|
-
for (const { colId, direction } of sortModel) {
|
|
39
|
-
const cmp = compareValues(getFieldValue(a, colId), getFieldValue(b, colId));
|
|
40
|
-
if (cmp !== 0) return direction === "asc" ? cmp : -cmp;
|
|
41
|
-
}
|
|
42
|
-
return 0;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function initIndices(len) {
|
|
47
|
-
const indices = new Uint32Array(len);
|
|
48
|
-
for (let i = 0; i < len; i++) indices[i] = i;
|
|
49
|
-
return indices;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function reorderFloat64(values, indices) {
|
|
53
|
-
const out = new Float64Array(indices.length);
|
|
54
|
-
for (let i = 0; i < indices.length; i++) out[i] = values[indices[i]];
|
|
55
|
-
return out;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Find runs of consecutive sorted indices whose hash tuples are identical.
|
|
59
|
-
// Emits flat pairs: [start1, end1, start2, end2, ...].
|
|
60
|
-
function detectCollisionRuns(indices, hashChunks) {
|
|
61
|
-
const len = indices.length;
|
|
62
|
-
const numChunks = hashChunks.length;
|
|
63
|
-
const runs = [];
|
|
64
|
-
let runStart = 0;
|
|
65
|
-
for (let i = 1; i <= len; i++) {
|
|
66
|
-
let diff = i === len;
|
|
67
|
-
if (!diff) {
|
|
68
|
-
const p = indices[i - 1];
|
|
69
|
-
const c = indices[i];
|
|
70
|
-
for (let k = 0; k < numChunks; k++) {
|
|
71
|
-
if (hashChunks[k][p] !== hashChunks[k][c]) { diff = true; break; }
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (diff) {
|
|
75
|
-
if (i - runStart > 1) runs.push(runStart, i);
|
|
76
|
-
runStart = i;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return new Uint32Array(runs);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// ---- Base sort primitives ----------------------------------------------
|
|
83
|
-
function sortIndices(values, direction) {
|
|
84
|
-
const indices = initIndices(values.length);
|
|
85
|
-
const mult = direction === "asc" ? 1 : -1;
|
|
86
|
-
indices.sort((a, b) => {
|
|
87
|
-
const va = values[a], vb = values[b];
|
|
88
|
-
if (va < vb) return -1 * mult;
|
|
89
|
-
if (va > vb) return 1 * mult;
|
|
90
|
-
// Stable tie-break: preserve original (local) index order.
|
|
91
|
-
return a - b;
|
|
92
|
-
});
|
|
93
|
-
return indices;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function sortMultiColumn(columns, directions) {
|
|
97
|
-
const numCols = columns.length;
|
|
98
|
-
const indices = initIndices(columns[0].length);
|
|
99
|
-
indices.sort((a, b) => {
|
|
100
|
-
for (let c = 0; c < numCols; c++) {
|
|
101
|
-
const va = columns[c][a], vb = columns[c][b];
|
|
102
|
-
if (va < vb) return -1 * directions[c];
|
|
103
|
-
if (va > vb) return 1 * directions[c];
|
|
104
|
-
}
|
|
105
|
-
// Stable tie-break: preserve original (local) index order.
|
|
106
|
-
return a - b;
|
|
107
|
-
});
|
|
108
|
-
return indices;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function sortStringHashes(hashChunks, direction) {
|
|
112
|
-
const numChunks = hashChunks.length;
|
|
113
|
-
const indices = initIndices(hashChunks[0].length);
|
|
114
|
-
const mult = direction === "asc" ? 1 : -1;
|
|
115
|
-
indices.sort((a, b) => {
|
|
116
|
-
for (let c = 0; c < numChunks; c++) {
|
|
117
|
-
const va = hashChunks[c][a], vb = hashChunks[c][b];
|
|
118
|
-
if (va < vb) return -1 * mult;
|
|
119
|
-
if (va > vb) return 1 * mult;
|
|
120
|
-
}
|
|
121
|
-
// Stable tie-break: preserve original (local) index order.
|
|
122
|
-
return a - b;
|
|
123
|
-
});
|
|
124
|
-
return { indices, collisionRuns: detectCollisionRuns(indices, hashChunks) };
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// ---- Chunk variants (base sort + reorder for merge) --------------------
|
|
128
|
-
function sortChunk(values, direction) {
|
|
129
|
-
const indices = sortIndices(values, direction);
|
|
130
|
-
return { indices, sortedValues: reorderFloat64(values, indices) };
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function sortStringChunk(hashChunks, direction) {
|
|
134
|
-
const result = sortStringHashes(hashChunks, direction);
|
|
135
|
-
return {
|
|
136
|
-
indices: result.indices,
|
|
137
|
-
sortedHashes: reorderFloat64(hashChunks[0], result.indices),
|
|
138
|
-
collisionRuns: result.collisionRuns,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function sortMultiColumnChunk(columns, directions) {
|
|
143
|
-
const indices = sortMultiColumn(columns, directions);
|
|
144
|
-
return { indices, sortedColumns: columns.map(col => reorderFloat64(col, indices)) };
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// ---- Dispatch table: type → handler(data) → { type, payload, transfer }
|
|
148
|
-
const HANDLERS = {
|
|
149
|
-
sort: (d) => ({
|
|
150
|
-
type: "sorted",
|
|
151
|
-
payload: { data: sortData(d.data, d.sortModel) },
|
|
152
|
-
}),
|
|
153
|
-
sortIndices: (d) => {
|
|
154
|
-
const indices = sortIndices(d.values, d.direction);
|
|
155
|
-
return { type: "sortedIndices", payload: { indices }, transfer: [indices.buffer] };
|
|
156
|
-
},
|
|
157
|
-
sortMultiColumn: (d) => {
|
|
158
|
-
const indices = sortMultiColumn(d.columns, d.directions);
|
|
159
|
-
return { type: "sortedMultiColumn", payload: { indices }, transfer: [indices.buffer] };
|
|
160
|
-
},
|
|
161
|
-
sortStringHashes: (d) => {
|
|
162
|
-
const r = sortStringHashes(d.hashChunks, d.direction);
|
|
163
|
-
return {
|
|
164
|
-
type: "sortedStringHashes",
|
|
165
|
-
payload: { indices: r.indices, collisionRuns: r.collisionRuns },
|
|
166
|
-
transfer: [r.indices.buffer, r.collisionRuns.buffer],
|
|
167
|
-
};
|
|
168
|
-
},
|
|
169
|
-
sortChunk: (d) => {
|
|
170
|
-
const r = sortChunk(d.values, d.direction);
|
|
171
|
-
return {
|
|
172
|
-
type: "sortedChunk",
|
|
173
|
-
payload: { indices: r.indices, sortedValues: r.sortedValues, chunkOffset: d.chunkOffset },
|
|
174
|
-
transfer: [r.indices.buffer, r.sortedValues.buffer],
|
|
175
|
-
};
|
|
176
|
-
},
|
|
177
|
-
sortStringChunk: (d) => {
|
|
178
|
-
const r = sortStringChunk(d.hashChunks, d.direction);
|
|
179
|
-
return {
|
|
180
|
-
type: "sortedStringChunk",
|
|
181
|
-
payload: {
|
|
182
|
-
indices: r.indices,
|
|
183
|
-
sortedHashes: r.sortedHashes,
|
|
184
|
-
collisionRuns: r.collisionRuns,
|
|
185
|
-
chunkOffset: d.chunkOffset,
|
|
186
|
-
},
|
|
187
|
-
transfer: [r.indices.buffer, r.sortedHashes.buffer, r.collisionRuns.buffer],
|
|
188
|
-
};
|
|
189
|
-
},
|
|
190
|
-
sortMultiColumnChunk: (d) => {
|
|
191
|
-
const r = sortMultiColumnChunk(d.columns, d.directions);
|
|
192
|
-
return {
|
|
193
|
-
type: "sortedMultiColumnChunk",
|
|
194
|
-
payload: { indices: r.indices, sortedColumns: r.sortedColumns, chunkOffset: d.chunkOffset },
|
|
195
|
-
transfer: [r.indices.buffer, ...r.sortedColumns.map(c => c.buffer)],
|
|
196
|
-
};
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
self.onmessage = function(e) {
|
|
201
|
-
const { type, id } = e.data;
|
|
202
|
-
const handler = HANDLERS[type];
|
|
203
|
-
if (!handler) return;
|
|
204
|
-
try {
|
|
205
|
-
const result = handler(e.data);
|
|
206
|
-
self.postMessage({ type: result.type, id, ...result.payload }, result.transfer || []);
|
|
207
|
-
} catch (error) {
|
|
208
|
-
self.postMessage({ type: "error", id, error: String(error) });
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
`,{maxWorkers:t}),this.parallelThreshold=e.parallelThreshold??4e5,this.minChunkSize=e.minChunkSize??5e4}isAvailable(){return!this.isTerminated&&this.pool.isAvailable()}terminate(){this.pool.terminate(),this.isTerminated=!0}async sortIndices(e,t){return this.assertNotTerminated(),e.length<this.parallelThreshold?this.sortIndicesSingle(e,t):this.sortIndicesParallel(e,t)}async sortStringHashes(e,t,n){return this.assertNotTerminated(),(e[0]?.length??0)<this.parallelThreshold?this.sortStringHashesSingle(e,t,n):this.sortStringHashesParallel(e,t,n)}async sortMultiColumn(e,t){return this.assertNotTerminated(),(e[0]?.length??0)<this.parallelThreshold?this.sortMultiColumnSingle(e,t):this.sortMultiColumnParallel(e,t)}assertNotTerminated(){if(this.isTerminated)throw Error(`ParallelSortManager has been terminated`)}async sortIndicesSingle(e,t){let n=new Float64Array(e),r={type:`sortIndices`,id:0,values:n,direction:t};return(await this.pool.execute(r,[n.buffer])).indices}async sortStringHashesSingle(e,t,n){let r={type:`sortStringHashes`,id:0,hashChunks:e,direction:t},i=e.map(e=>e.buffer),a=await this.pool.execute(r,i);return a.collisionRuns.length>0&&ct(a.indices,a.collisionRuns,n,t),a.indices}async sortMultiColumnSingle(e,t){let n=e.map(e=>new Float64Array(e)),r=new Int8Array(t.map(e=>e===`asc`?1:-1)),i={type:`sortMultiColumn`,id:0,columns:n,directions:r},a=[...n.map(e=>e.buffer),r.buffer];return(await this.pool.execute(i,a)).indices}boundariesFor(e){return ot(e,this.pool.getMaxWorkers(),this.minChunkSize)}async runChunks(e){let t=await this.pool.executeParallel(e);return t.sort((e,t)=>e.chunkOffset-t.chunkOffset),t}async sortIndicesParallel(e,t){let n=this.boundariesFor(e.length).map(n=>{let r=new Float64Array(e.slice(n.offset,n.offset+n.length));return{request:{type:`sortChunk`,id:0,values:r,direction:t,chunkOffset:n.offset},transferables:[r.buffer]}});return W((await this.runChunks(n)).map(e=>({indices:e.indices,values:e.sortedValues,offset:e.chunkOffset})),t)}async sortStringHashesParallel(e,t,n){let r=this.boundariesFor(e[0].length).map(n=>{let r=e.map(e=>{let t=new Float64Array(n.length);return t.set(new Float64Array(e.buffer,n.offset*8,n.length)),t});return{request:{type:`sortStringChunk`,id:0,hashChunks:r,direction:t,chunkOffset:n.offset},transferables:r.map(e=>e.buffer)}}),i=await this.runChunks(r),a=i.map(e=>({indices:e.indices,values:e.sortedHashes,offset:e.chunkOffset})),o=dt(i),s=W(a,t),c=st(a),l=new Uint32Array([...o,...c]);return l.length>0&&ct(s,l,n,t),s}async sortMultiColumnParallel(e,t){let n=this.boundariesFor(e[0].length),r=new Int8Array(t.map(e=>e===`asc`?1:-1)),i=n.map(t=>{let n=e.map(e=>{let n=new Float64Array(t.length);for(let r=0;r<t.length;r++)n[r]=e[t.offset+r];return n}),i=new Int8Array(r);return{request:{type:`sortMultiColumnChunk`,id:0,columns:n,directions:i,chunkOffset:t.offset},transferables:[...n.map(e=>e.buffer),i.buffer]}});return it((await this.runChunks(i)).map(e=>({indices:e.indices,columns:e.sortedColumns,directions:r,offset:e.chunkOffset})))}};const dt=e=>{let t=[];for(let n of e)for(let e=0;e<n.collisionRuns.length;e+=2)t.push(n.collisionRuns[e]+n.chunkOffset,n.collisionRuns[e+1]+n.chunkOffset);return t};function K(e){let t=e.toLowerCase(),n=Math.min(t.length,10),r=0;for(let e=0;e<n;e++){let n=t.codePointAt(e)??200,i;i=n>=97&&n<=122?n-97:n>=48&&n<=57?n-48+26:0,r=r*36+i}for(let e=n;e<10;e++)r*=36;return r}function q(e,t){let n=e==null||Array.isArray(e)&&e.length===0,r=t==null||Array.isArray(t)&&t.length===0;if(n&&r)return 0;if(n)return 1;if(r)return-1;if(Array.isArray(e)||Array.isArray(t)){let n=Array.isArray(e)?e.join(`, `):y(e),r=Array.isArray(t)?t.join(`, `):y(t);return n.localeCompare(r)}let i=Number(e),a=Number(t);return!Number.isNaN(i)&&!Number.isNaN(a)?i-a:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():y(e).localeCompare(y(t))}function ft(e){if(e==null)return Number.MAX_VALUE;if(typeof e==`number`)return e;if(e instanceof Date)return e.getTime();if(typeof e==`string`)return K(e);if(Array.isArray(e))return e.length===0?Number.MAX_VALUE:K(e.join(`, `));if(typeof e==`object`)return K(JSON.stringify(e));let t=Number(e);return Number.isNaN(t)?0:t}function pt(e,t){let n=[];for(let r of t.sortModel){let i=ft(t.getFieldValue(e,r.colId));n.push(i)}return n}function mt(e,t,n){if(!e||!t)return null;for(let r=0;r<n.length;r++){let i=e[r]-t[r];if(i!==0)return n[r].direction===`asc`?i:-i}return 0}function ht(e,t,n,r){for(let{colId:i,direction:a}of n){let n=q(r(e,i),r(t,i));if(n!==0)return a===`asc`?n:-n}return 0}function gt(e){let t=e.toLowerCase(),n=[];for(let e=0;e<3;e++){let r=e*10,i=0;for(let e=0;e<10;e++){let n=r+e,a=n<t.length?t.codePointAt(n)??200:0,o;o=a>=97&&a<=122?a-97:a>=48&&a<=57?a-48+26:0,i=i*36+o}n.push(i)}return n}function _t(e){if(e==null)return Number.MAX_VALUE;if(Array.isArray(e))return e.length===0?Number.MAX_VALUE:K(e.join(`, `));if(typeof e==`number`)return e;if(e instanceof Date)return e.getTime();if(typeof e==`string`)return K(e);if(typeof e==`object`)return K(JSON.stringify(e));let t=Number(e);return Number.isNaN(t)?0:t}function vt(e,t,n){return[...e].sort((e,r)=>{for(let{colId:i,direction:a}of t){let t=q(n(e,i),n(r,i));if(t!==0)return a===`asc`?t:-t}return 0})}const yt=(e,t,n)=>{for(let r of e){let e=n(r,t);if(e!=null)return typeof e==`string`||Array.isArray(e)||typeof e==`object`&&!(e instanceof Date)?`string`:`numeric`}return`numeric`},bt=(e,t,n)=>{let r=[],i=Array.from({length:3},()=>[]);for(let a of e){let e=y(n(a,t));r.push(e);let o=gt(e);for(let e=0;e<3;e++)i[e].push(o[e])}return{originalStrings:r,hashChunkArrays:i.map(e=>new Float64Array(e))}},xt=(e,t,n)=>e.map(e=>_t(n(e,t))),St=(e,t,n)=>{let r=[],i=[];for(let{colId:a,direction:o}of t)r.push(e.map(e=>_t(n(e,a)))),i.push(o??`asc`);return{columnValues:r,directions:i}},Ct=(e,t)=>{let n=Array(e.length);for(let r=0;r<t.length;r++)n[r]=e[t[r]];return n},wt=async(e,t,n,r)=>{let{colId:i,direction:a}=t,o=a??`asc`;if(yt(e,i,r)===`string`){let{originalStrings:t,hashChunkArrays:a}=bt(e,i,r);return n.sortStringHashes(a,o,t)}let s=xt(e,i,r);return n.sortIndices(s,o)},Tt=async(e,t,n,r)=>{let{columnValues:i,directions:a}=St(e,t,r);return n.sortMultiColumn(i,a)},Et=async(e,t,n,r)=>{let i=t.length===1?await wt(e,t[0],n,r):await Tt(e,t,n,r);return Ct(e,i)};function J(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}const Dt={contains:(e,t)=>e.includes(t),notContains:(e,t)=>!e.includes(t),equals:(e,t)=>e===t,notEquals:(e,t)=>e!==t,startsWith:(e,t)=>e.startsWith(t),endsWith:(e,t)=>e.endsWith(t),blank:(e,t,n)=>n,notBlank:(e,t,n)=>!n},Ot=new WeakMap,kt=e=>{let t=Ot.get(e);if(t?.size===e.size)return t.keys;let n=new Set;for(let t of e)n.add(M(t));return Ot.set(e,{size:e.size,keys:n}),n};function At(e,t,n){let r=N(e);if(t.selectedValues!==void 0)return r?t.includeBlank===!0:kt(t.selectedValues).has(M(e));let i=y(e,n).toLowerCase(),a=String(t.value??``).toLowerCase();return Dt[t.operator](i,a,r)}const jt={"=":(e,t)=>e===t,"!=":(e,t)=>e!==t,">":(e,t)=>e>t,"<":(e,t)=>e<t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t,between:(e,t,n)=>e>=t&&e<=n};function Mt(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=typeof e==`number`?e:Number(e);if(Number.isNaN(r))return!1;let i=t.value??0,a=t.valueTo??0;return jt[t.operator](r,i,a)}const Nt={"=":(e,t)=>J(e,t),"!=":(e,t)=>!J(e,t),">":(e,t)=>e.getTime()>t.getTime(),"<":(e,t)=>e.getTime()<t.getTime(),between:(e,t,n)=>{let r=e.getTime();return r>=t.getTime()&&r<=n.getTime()}};function Pt(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=e instanceof Date?e:new Date(y(e));if(Number.isNaN(r.getTime()))return!1;let i=t.value instanceof Date?t.value:new Date(String(t.value??``)),a=t.valueTo instanceof Date?t.valueTo:new Date(String(t.valueTo??``));return Nt[t.operator](r,i,a)}function Ft(e,t,n){switch(t.type){case`text`:return At(e,t,n);case`number`:return Mt(e,t);case`date`:return Pt(e,t);default:return!0}}function Y(e,t,n){if(!t.conditions||t.conditions.length===0)return!0;let r=t.conditions[0];if(!r)return!0;let i=Ft(e,r,n);for(let r=1;r<t.conditions.length;r++){let a=t.conditions[r-1],o=t.conditions[r],s=a.nextOperator??t.combination,c=Ft(e,o,n);s===`and`?i&&=c:i||=c}return i}function It(e,t,n,r){let i=Object.entries(t).filter(([,e])=>e!=null);if(i.length===0)return!0;for(let[t,a]of i){let i=n(e,t),o=r?.(t);if(!Y(i,a,o))return!1}return!0}function Lt(e,t,n,r){let i=Object.entries(t).filter(([,e])=>typeof e==`string`?e.trim()!==``:e.conditions&&e.conditions.length>0);return i.length===0?e:e.filter(e=>{for(let[t,a]of i){let i=n(e,t),o=r?.(t);if(typeof a==`string`){if(!y(i,o).toLowerCase().includes(a.toLowerCase()))return!1;continue}if(!Y(i,a,o))return!1}return!0})}function X(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r}function Rt(e,t={}){let{getFieldValue:n=X,getValueFormatter:r,useWorker:i=!0,parallelSort:a}=t,o=e,s=!1,c=i?new G(a===!1?{maxWorkers:1}:a):null;return{loadMode:`all`,async query(e){let t=o?[...o]:[];if(e.filter&&Object.keys(e.filter).length>0){let i=e.valueFormatters===null?r:t=>e.valueFormatters?.[t];t=Lt(t,e.filter,n,i)}e.sort&&e.sort.length>0&&(t=c&&c.isAvailable()&&t.length>=2e5?await Et(t,e.sort,c,n):vt(t,e.sort,n));let i=t.length;return{rows:t.slice(e.range.startRow,e.range.endRow),totalRows:i}},destroy(){s||(s=!0,o=null,c&&c.terminate())},moveRow(e,t){if(!o||e===t||e<0||e>=o.length||t<0||t>=o.length)return;let[n]=o.splice(e,1),r=t>e?t-1:t;o.splice(r,0,n)}}}function Z(e){return Rt(e)}function zt(e,t={}){return{loadMode:t.loadMode??`paginated`,async query(t){return e(t)}}}var Bt=class{rows=[];rowById=new Map;sortedIndices=[];sortModel=[];sortModelHash=``;filterModel={};filteredIndices=new Set;distinctValues=new Map;rowSortCache=new Map;options;constructor(e,t=[]){this.options={getRowId:e.getRowId,getFieldValue:e.getFieldValue??g,getValueFormatter:e.getValueFormatter??(()=>void 0)},this.setData(t)}clear(){this.rows=[],this.rowById.clear(),this.sortedIndices=[],this.filterModel={},this.filteredIndices.clear(),this.rowSortCache.clear(),this.distinctValues.clear(),this.sortModel=[],this.sortModelHash=``}setData(e){this.rows=[...e],this.rowById.clear(),this.rowSortCache.clear(),this.distinctValues.clear();for(let e=0;e<this.rows.length;e++){let t=this.rows[e],n=this.options.getRowId(t);this.rowById.set(n,e)}this.rebuildSortedIndices(),this.rebuildFilteredIndices(),this.rebuildDistinctValues()}query(e){this.setSortModel(e.sort??[]),this.setFilterModel(e.filter??{});let t=this.getVisibleIndices(),n=t.length,r=e.range.startRow,i=Math.min(e.range.endRow,n),a=[];for(let e=r;e<i;e++){let n=t[e];n!==void 0&&a.push(this.rows[n])}return{rows:a,totalRows:n}}getRowById(e){let t=this.rowById.get(e);return t===void 0?void 0:this.rows[t]}getRowByIndex(e){return this.rows[e]}getTotalRowCount(){return this.rows.length}getAllRows(){return[...this.rows]}moveRow(e,t){if(e===t||e<0||e>=this.rows.length||t<0||t>=this.rows.length)return;let[n]=this.rows.splice(e,1),r=t>e?t-1:t;this.rows.splice(r,0,n),this.rowById.clear();for(let e=0;e<this.rows.length;e++)this.rowById.set(this.options.getRowId(this.rows[e]),e);this.sortedIndices=Array.from({length:this.rows.length},(e,t)=>t),this.rowSortCache.clear()}getVisibleRowCount(){return Object.keys(this.filterModel).length===0?this.rows.length:this.filteredIndices.size}getDistinctValues(e){let t=this.distinctValues.get(e);return t?Array.from(t.keys()):[]}addRows(e){for(let t of e)this.addRow(t)}addRow(e){let t=this.options.getRowId(e);if(this.rowById.has(t)){console.warn(`Row with ID ${t} already exists. Skipping.`);return}let n=this.rows.length;if(this.rows.push(e),this.rowById.set(t,n),this.updateDistinctValuesForRow(e,`add`),this.sortModel.length>0&&this.computeRowHashes(n,e),this.sortModel.length>0){let e=this.binarySearchInsertPosition(n);this.sortedIndices.splice(e,0,n)}else this.sortedIndices.push(n);this.rowPassesFilter(e)&&this.filteredIndices.add(n)}removeRows(e){let t=[];for(let n of e){let e=this.rowById.get(n);e!==void 0&&t.push(e)}if(t.length===0)return 0;t.sort((e,t)=>t-e);for(let e of t)this.removeRowByIndex(e);return t.length}removeRowByIndex(e){let t=this.rows[e];if(!t)return;let n=this.options.getRowId(t);this.updateDistinctValuesForRow(t,`remove`);let r=this.sortedIndices.indexOf(e);r!==-1&&this.sortedIndices.splice(r,1),this.filteredIndices.delete(e),this.rowSortCache.delete(e),this.rowById.delete(n),this.rows.splice(e,1),this.reindexAfterRemoval(e)}reindexAfterRemoval(e){for(let[t,n]of this.rowById.entries())n>e&&this.rowById.set(t,n-1);for(let t=0;t<this.sortedIndices.length;t++)this.sortedIndices[t]>e&&this.sortedIndices[t]--;let t=new Set;for(let n of this.filteredIndices)n>e?t.add(n-1):t.add(n);this.filteredIndices=t;let n=new Map;for(let[t,r]of this.rowSortCache)t>e?n.set(t-1,r):n.set(t,r);this.rowSortCache=n}updateCell(e,t,n){let r=this.rowById.get(e);if(r===void 0){console.warn(`Row with ID ${e} not found.`);return}let i=this.rows[r],a=this.options.getFieldValue(i,t);if(_(i,t,n),this.updateDistinctValueForField(t,a,n),this.sortModel.some(e=>e.colId===t)&&this.sortModel.length>0){this.computeRowHashes(r,i);let e=this.sortedIndices.indexOf(r);e!==-1&&this.sortedIndices.splice(e,1);let t=this.binarySearchInsertPosition(r);this.sortedIndices.splice(t,0,r)}t in this.filterModel&&(this.rowPassesFilter(i)?this.filteredIndices.add(r):this.filteredIndices.delete(r))}updateRow(e,t){for(let[n,r]of Object.entries(t))this.updateCell(e,n,r)}setSortModel(e){let t=JSON.stringify(e);t!==this.sortModelHash&&(this.sortModelHash=t,this.sortModel=[...e],this.rebuildHashCache(),this.rebuildSortedIndices())}getSortModel(){return[...this.sortModel]}setFilterModel(e){JSON.stringify(e)!==JSON.stringify(this.filterModel)&&(this.filterModel={...e},this.rebuildFilteredIndices())}getFilterModel(){return{...this.filterModel}}rebuildSortedIndices(){this.sortedIndices=Array.from({length:this.rows.length},(e,t)=>t),this.sortModel.length!==0&&this.sortedIndices.sort((e,t)=>this.compareRows(e,t))}rebuildHashCache(){if(this.rowSortCache.clear(),this.sortModel.length!==0)for(let e=0;e<this.rows.length;e++)this.computeRowHashes(e,this.rows[e])}computeRowHashes(e,t){if(this.sortModel.length===0)return;let n=pt(t,{sortModel:this.sortModel,sortModelHash:this.sortModelHash,getFieldValue:this.options.getFieldValue}),r=this.rowSortCache.get(e);r||(r={hashes:new Map},this.rowSortCache.set(e,r)),r.hashes.set(this.sortModelHash,n)}compareRows(e,t){let n=this.rowSortCache.get(e),r=this.rowSortCache.get(t),i=n?.hashes.get(this.sortModelHash),a=r?.hashes.get(this.sortModelHash),o=mt(i,a,this.sortModel);return o===null?ht(this.rows[e],this.rows[t],this.sortModel,this.options.getFieldValue):o}binarySearchInsertPosition(e){let t=0,n=this.sortedIndices.length;for(;t<n;){let r=t+n>>>1,i=this.sortedIndices[r];this.compareRows(e,i)>0?t=r+1:n=r}return t}rebuildFilteredIndices(){if(this.filteredIndices.clear(),Object.entries(this.filterModel).some(([,e])=>e!=null))for(let e=0;e<this.rows.length;e++)this.rowPassesFilter(this.rows[e])&&this.filteredIndices.add(e)}rowPassesFilter(e){return It(e,this.filterModel,this.options.getFieldValue,this.options.getValueFormatter)}getVisibleIndices(){return Object.entries(this.filterModel).some(([,e])=>e!=null)?this.sortedIndices.filter(e=>this.filteredIndices.has(e)):this.sortedIndices}rebuildDistinctValues(){this.distinctValues.clear();for(let e of this.rows)this.updateDistinctValuesForRow(e,`add`)}updateDistinctValuesForRow(e,t){if(!(typeof e!=`object`||!e))for(let[n,r]of Object.entries(e))r!=null&&(t===`add`?this.addToDistinctValues(n,r):this.decrementDistinctValues(n,r))}updateDistinctValueForField(e,t,n){t!=null&&this.decrementDistinctValues(e,t),n!=null&&this.addToDistinctValues(e,n)}addToDistinctValues(e,t){let n=this.distinctValues.get(e);if(n||(n=new Map,this.distinctValues.set(e,n)),Array.isArray(t)){for(let e of t)e!=null&&Vt(n,e);return}Vt(n,t)}decrementDistinctValues(e,t){let n=this.distinctValues.get(e);if(n!==void 0){if(Array.isArray(t)){for(let e of t)e!=null&&Ht(n,e);return}Ht(n,t)}}};const Vt=(e,t)=>{e.set(t,(e.get(t)??0)+1)},Ht=(e,t)=>{let n=e.get(t);if(n!==void 0){if(n<=1){e.delete(t);return}e.set(t,n-1)}};function Ut(e,t){let{getRowId:n,getFieldValue:r,getValueFormatter:i,debounceMs:a=50,onTransactionProcessed:o,useWorker:s=!0,parallelSort:c}=t,l=new Bt({getRowId:n,getFieldValue:r??X,getValueFormatter:i},e),u=new Set,d=v().emit,f=s&&c!==!1?new G(c):null,p=new F({debounceMs:a,store:l,onProcessed:e=>{o?.(e);for(let t of u)t(e)}});return{loadMode:`all`,async query(e){if(p.hasPending()){d({type:`DATA_LOADING`});try{await p.flush()}finally{d({type:`DATA_LOADED`,totalRows:l.getTotalRowCount()})}}let t=l.getAllRows(),n=r??X;if(e.filter&&Object.keys(e.filter).length>0){let r=e.valueFormatters===null?i:t=>e.valueFormatters?.[t];t=Lt(t,e.filter,n,r)}if(e.sort&&e.sort.length>0)if(f&&f.isAvailable()&&t.length>=2e5){d({type:`DATA_LOADING`});try{t=await Et(t,e.sort,f,n)}finally{d({type:`DATA_LOADED`,totalRows:t.length})}}else t=vt(t,e.sort,n);let a=t.length;return{rows:t.slice(e.range.startRow,e.range.endRow),totalRows:a}},addRows(e){p.add(e)},removeRows(e){p.remove(e)},updateCell(e,t,n){p.updateCell(e,t,n)},updateRow(e,t){p.updateRow(e,t)},async flushTransactions(){await p.flush()},hasPendingTransactions(){return p.hasPending()},getDistinctValues(e){return l.getDistinctValues(e)},getRowById(e){return l.getRowById(e)},getTotalRowCount(){return l.getTotalRowCount()},subscribe(e){return u.add(e),()=>{u.delete(e)}},clear(){let e=l.getTotalRowCount();l.clear();let t={added:0,removed:e,updated:0};o?.(t);for(let e of u)e(t)},moveRow(e,t){l.moveRow(e,t)}}}const Wt=`
|
|
212
|
-
/* =============================================================================
|
|
213
|
-
GP Grid - CSS Variables for Theming
|
|
214
|
-
============================================================================= */
|
|
215
|
-
|
|
216
|
-
.gp-grid-container {
|
|
217
|
-
/* Colors - Light Mode (default) */
|
|
218
|
-
--gp-grid-bg: #ffffff;
|
|
219
|
-
--gp-grid-bg-alt: #f8f9fa;
|
|
220
|
-
--gp-grid-text: #212529;
|
|
221
|
-
--gp-grid-text-secondary: #6c757d;
|
|
222
|
-
--gp-grid-text-muted: #adb5bd;
|
|
223
|
-
--gp-grid-border: #dee2e6;
|
|
224
|
-
--gp-grid-border-light: #e9ecef;
|
|
225
|
-
|
|
226
|
-
/* Header */
|
|
227
|
-
--gp-grid-header-bg: #f1f3f5;
|
|
228
|
-
--gp-grid-header-text: #212529;
|
|
229
|
-
--gp-grid-header-z-index: 10;
|
|
230
|
-
|
|
231
|
-
/* Selection */
|
|
232
|
-
--gp-grid-primary: #228be6;
|
|
233
|
-
--gp-grid-primary-light: #e7f5ff;
|
|
234
|
-
--gp-grid-primary-border: #74c0fc;
|
|
235
|
-
--gp-grid-hover: #f1f3f5;
|
|
236
|
-
|
|
237
|
-
/* Filter */
|
|
238
|
-
--gp-grid-filter-bg: #f8f9fa;
|
|
239
|
-
--gp-grid-input-bg: #ffffff;
|
|
240
|
-
--gp-grid-input-border: #ced4da;
|
|
241
|
-
|
|
242
|
-
/* Error */
|
|
243
|
-
--gp-grid-error-bg: #fff5f5;
|
|
244
|
-
--gp-grid-error-text: #c92a2a;
|
|
245
|
-
|
|
246
|
-
/* Loading */
|
|
247
|
-
--gp-grid-loading-bg: rgba(255, 255, 255, 0.95);
|
|
248
|
-
--gp-grid-loading-text: #495057;
|
|
249
|
-
|
|
250
|
-
/* Scrollbar */
|
|
251
|
-
--gp-grid-scrollbar-track: #f1f3f5;
|
|
252
|
-
--gp-grid-scrollbar-thumb: #ced4da;
|
|
253
|
-
--gp-grid-scrollbar-thumb-hover: #adb5bd;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/* Dark Mode */
|
|
257
|
-
.gp-grid-container--dark {
|
|
258
|
-
--gp-grid-bg: #1a1b1e;
|
|
259
|
-
--gp-grid-bg-alt: #25262b;
|
|
260
|
-
--gp-grid-text: #c1c2c5;
|
|
261
|
-
--gp-grid-text-secondary: #909296;
|
|
262
|
-
--gp-grid-text-muted: #5c5f66;
|
|
263
|
-
--gp-grid-border: #373a40;
|
|
264
|
-
--gp-grid-border-light: #2c2e33;
|
|
265
|
-
|
|
266
|
-
/* Header */
|
|
267
|
-
--gp-grid-header-bg: #25262b;
|
|
268
|
-
--gp-grid-header-text: #c1c2c5;
|
|
269
|
-
--gp-grid-header-z-index: 10;
|
|
270
|
-
|
|
271
|
-
/* Selection */
|
|
272
|
-
--gp-grid-primary: #339af0;
|
|
273
|
-
--gp-grid-primary-light: #1c3d5a;
|
|
274
|
-
--gp-grid-primary-border: #1c7ed6;
|
|
275
|
-
--gp-grid-hover: #2c2e33;
|
|
276
|
-
|
|
277
|
-
/* Filter */
|
|
278
|
-
--gp-grid-filter-bg: #25262b;
|
|
279
|
-
--gp-grid-input-bg: #1a1b1e;
|
|
280
|
-
--gp-grid-input-border: #373a40;
|
|
281
|
-
|
|
282
|
-
/* Error */
|
|
283
|
-
--gp-grid-error-bg: #2c1a1a;
|
|
284
|
-
--gp-grid-error-text: #ff6b6b;
|
|
285
|
-
|
|
286
|
-
/* Loading */
|
|
287
|
-
--gp-grid-loading-bg: rgba(26, 27, 30, 0.95);
|
|
288
|
-
--gp-grid-loading-text: #c1c2c5;
|
|
289
|
-
|
|
290
|
-
/* Scrollbar */
|
|
291
|
-
--gp-grid-scrollbar-track: #25262b;
|
|
292
|
-
--gp-grid-scrollbar-thumb: #373a40;
|
|
293
|
-
--gp-grid-scrollbar-thumb-hover: #4a4d52;
|
|
294
|
-
}
|
|
295
|
-
`,Gt=`
|
|
296
|
-
/* =============================================================================
|
|
297
|
-
GP Grid - Clean Flat Design
|
|
298
|
-
============================================================================= */
|
|
299
|
-
|
|
300
|
-
/* Grid Container - structural */
|
|
301
|
-
.gp-grid-container {
|
|
302
|
-
outline: none;
|
|
303
|
-
user-select: none;
|
|
304
|
-
-webkit-user-select: none;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
/* Visual properties - :where() for zero specificity, consumers can override with a single class */
|
|
308
|
-
:where(.gp-grid-container) {
|
|
309
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
310
|
-
font-size: 13px;
|
|
311
|
-
line-height: 1.5;
|
|
312
|
-
color: var(--gp-grid-text);
|
|
313
|
-
background-color: var(--gp-grid-bg);
|
|
314
|
-
border: 1px solid var(--gp-grid-border);
|
|
315
|
-
border-radius: 6px;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
.gp-grid-container:focus {
|
|
319
|
-
outline: none;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
:where(.gp-grid-container:focus) {
|
|
323
|
-
border-color: var(--gp-grid-primary);
|
|
324
|
-
}
|
|
325
|
-
`,Kt=`
|
|
326
|
-
/* =============================================================================
|
|
327
|
-
Header
|
|
328
|
-
============================================================================= */
|
|
329
|
-
|
|
330
|
-
.gp-grid-header {
|
|
331
|
-
position: sticky;
|
|
332
|
-
top: 0;
|
|
333
|
-
left: 0;
|
|
334
|
-
flex-shrink: 0;
|
|
335
|
-
z-index: 11;
|
|
336
|
-
overflow: hidden;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
:where(.gp-grid-header) {
|
|
340
|
-
background-color: var(--gp-grid-header-bg);
|
|
341
|
-
border-bottom: 1px solid var(--gp-grid-border);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
.gp-grid-container .gp-grid-header-cell {
|
|
345
|
-
position: absolute;
|
|
346
|
-
box-sizing: border-box;
|
|
347
|
-
user-select: none;
|
|
348
|
-
display: flex;
|
|
349
|
-
top: 0;
|
|
350
|
-
touch-action: none;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
:where(.gp-grid-header-cell) {
|
|
354
|
-
align-items: center;
|
|
355
|
-
padding: 0 12px;
|
|
356
|
-
border-right: 1px solid var(--gp-grid-border);
|
|
357
|
-
font-weight: 600;
|
|
358
|
-
font-size: 12px;
|
|
359
|
-
letter-spacing: 0.5px;
|
|
360
|
-
color: var(--gp-grid-header-text);
|
|
361
|
-
cursor: pointer;
|
|
362
|
-
background-color: transparent;
|
|
363
|
-
transition: background-color 0.1s ease;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
:where(.gp-grid-header-cell:hover) {
|
|
367
|
-
background-color: var(--gp-grid-hover);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
:where(.gp-grid-header-cell:active) {
|
|
371
|
-
background-color: var(--gp-grid-border-light);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
.gp-grid-container .gp-grid-header-text {
|
|
375
|
-
flex: 1;
|
|
376
|
-
overflow: hidden;
|
|
377
|
-
text-overflow: ellipsis;
|
|
378
|
-
white-space: nowrap;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
:where(.gp-grid-header-text) {
|
|
382
|
-
color: var(--gp-grid-header-text);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/* Header icons container */
|
|
386
|
-
.gp-grid-header-icons {
|
|
387
|
-
display: flex;
|
|
388
|
-
align-items: center;
|
|
389
|
-
gap: 4px;
|
|
390
|
-
margin-left: auto;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/* Stacked sort arrows */
|
|
394
|
-
.gp-grid-sort-arrows {
|
|
395
|
-
display: flex;
|
|
396
|
-
flex-direction: row;
|
|
397
|
-
align-items: center;
|
|
398
|
-
gap: 2px;
|
|
399
|
-
margin-left: 6px;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
.gp-grid-sort-arrows-stack {
|
|
403
|
-
display: flex;
|
|
404
|
-
flex-direction: column;
|
|
405
|
-
align-items: center;
|
|
406
|
-
gap: 2px;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
:where(.gp-grid-sort-arrow-up),
|
|
410
|
-
:where(.gp-grid-sort-arrow-down) {
|
|
411
|
-
opacity: 0.35;
|
|
412
|
-
transition: opacity 0.15s ease, color 0.15s ease;
|
|
413
|
-
color: var(--gp-grid-text);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
:where(.gp-grid-sort-arrow-up.active),
|
|
417
|
-
:where(.gp-grid-sort-arrow-down.active) {
|
|
418
|
-
opacity: 1;
|
|
419
|
-
color: var(--gp-grid-primary);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
:where(.gp-grid-sort-index) {
|
|
423
|
-
font-size: 9px;
|
|
424
|
-
color: var(--gp-grid-primary);
|
|
425
|
-
font-weight: 600;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/* Filter icon */
|
|
429
|
-
.gp-grid-filter-icon {
|
|
430
|
-
display: flex;
|
|
431
|
-
align-items: center;
|
|
432
|
-
justify-content: center;
|
|
433
|
-
width: 20px;
|
|
434
|
-
height: 20px;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
:where(.gp-grid-filter-icon) {
|
|
438
|
-
border-radius: 4px;
|
|
439
|
-
cursor: pointer;
|
|
440
|
-
color: var(--gp-grid-text-secondary);
|
|
441
|
-
transition: background-color 0.15s ease, color 0.15s ease;
|
|
442
|
-
margin-left: 2px;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
:where(.gp-grid-filter-icon:hover) {
|
|
446
|
-
background-color: var(--gp-grid-hover);
|
|
447
|
-
color: var(--gp-grid-primary);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
:where(.gp-grid-filter-icon.active) {
|
|
451
|
-
color: var(--gp-grid-primary);
|
|
452
|
-
background-color: var(--gp-grid-primary-light);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
/* Touch device: larger tap target for filter icon */
|
|
456
|
-
@media (pointer: coarse) and (hover: none) and (max-width: 768px) {
|
|
457
|
-
.gp-grid-filter-icon {
|
|
458
|
-
min-width: 44px;
|
|
459
|
-
min-height: 44px;
|
|
460
|
-
width: 44px;
|
|
461
|
-
height: 44px;
|
|
462
|
-
}
|
|
463
|
-
:where(.gp-grid-filter-icon) {
|
|
464
|
-
margin-left: 0;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
.gp-grid-filter-icon svg {
|
|
468
|
-
width: 20px;
|
|
469
|
-
height: 20px;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/* Disabled header state during data loading */
|
|
474
|
-
.gp-grid-header--loading .gp-grid-header-cell {
|
|
475
|
-
pointer-events: none;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
:where(.gp-grid-header--loading .gp-grid-header-cell) {
|
|
479
|
-
opacity: 0.6;
|
|
480
|
-
cursor: default;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
/* =============================================================================
|
|
484
|
-
Column Resize
|
|
485
|
-
============================================================================= */
|
|
486
|
-
|
|
487
|
-
.gp-grid-header-resize-handle {
|
|
488
|
-
position: absolute;
|
|
489
|
-
right: -3px;
|
|
490
|
-
top: 0;
|
|
491
|
-
width: 6px;
|
|
492
|
-
height: 100%;
|
|
493
|
-
cursor: col-resize;
|
|
494
|
-
z-index: 10;
|
|
495
|
-
touch-action: none;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
:where(.gp-grid-header-resize-handle:hover),
|
|
499
|
-
:where(.gp-grid-header-resize-handle--active) {
|
|
500
|
-
background-color: var(--gp-grid-primary);
|
|
501
|
-
opacity: 0.4;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/* Touch device: wider resize handle hit area */
|
|
505
|
-
@media (pointer: coarse) and (hover: none) and (max-width: 768px) {
|
|
506
|
-
.gp-grid-header-resize-handle {
|
|
507
|
-
width: 24px;
|
|
508
|
-
right: -12px;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
.gp-grid-column-resize-line {
|
|
513
|
-
position: absolute;
|
|
514
|
-
top: 0;
|
|
515
|
-
width: 2px;
|
|
516
|
-
height: 100%;
|
|
517
|
-
z-index: 1000;
|
|
518
|
-
pointer-events: none;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
:where(.gp-grid-column-resize-line) {
|
|
522
|
-
background-color: var(--gp-grid-primary);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
/* =============================================================================
|
|
526
|
-
Column Move
|
|
527
|
-
============================================================================= */
|
|
528
|
-
|
|
529
|
-
.gp-grid-column-move-ghost {
|
|
530
|
-
position: fixed;
|
|
531
|
-
pointer-events: none;
|
|
532
|
-
z-index: 2000;
|
|
533
|
-
display: flex;
|
|
534
|
-
align-items: center;
|
|
535
|
-
box-sizing: border-box;
|
|
536
|
-
overflow: hidden;
|
|
537
|
-
white-space: nowrap;
|
|
538
|
-
text-overflow: ellipsis;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
:where(.gp-grid-column-move-ghost) {
|
|
542
|
-
opacity: 0.7;
|
|
543
|
-
background-color: var(--gp-grid-header-bg);
|
|
544
|
-
border: 2px solid var(--gp-grid-primary);
|
|
545
|
-
border-radius: 4px;
|
|
546
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
547
|
-
padding: 0 12px;
|
|
548
|
-
font-weight: 600;
|
|
549
|
-
font-size: 12px;
|
|
550
|
-
letter-spacing: 0.5px;
|
|
551
|
-
color: var(--gp-grid-header-text);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
.gp-grid-column-drop-indicator {
|
|
555
|
-
position: absolute;
|
|
556
|
-
top: 0;
|
|
557
|
-
left: 0;
|
|
558
|
-
width: 3px;
|
|
559
|
-
height: 100%;
|
|
560
|
-
z-index: 1000;
|
|
561
|
-
pointer-events: none;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
:where(.gp-grid-column-drop-indicator) {
|
|
565
|
-
background-color: var(--gp-grid-primary);
|
|
566
|
-
border-radius: 2px;
|
|
567
|
-
}
|
|
568
|
-
`,qt=`
|
|
569
|
-
/* =============================================================================
|
|
570
|
-
Data Cells
|
|
571
|
-
============================================================================= */
|
|
572
|
-
|
|
573
|
-
/* Rows wrapper - positions rows with small translateY values for large datasets */
|
|
574
|
-
.gp-grid-rows-wrapper {
|
|
575
|
-
position: absolute;
|
|
576
|
-
top: 0;
|
|
577
|
-
left: 0;
|
|
578
|
-
/* Keep wrapper below the sticky header (z-index: 10) */
|
|
579
|
-
z-index: 1;
|
|
580
|
-
will-change: transform;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
.gp-grid-row {
|
|
584
|
-
position: absolute;
|
|
585
|
-
top: 0;
|
|
586
|
-
left: 0;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
/* Row background - :where() for zero specificity, so user highlight classes always win */
|
|
590
|
-
:where(.gp-grid-row) {
|
|
591
|
-
background-color: var(--gp-grid-bg);
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
/* Structural properties - required for grid layout */
|
|
595
|
-
.gp-grid-cell {
|
|
596
|
-
position: absolute;
|
|
597
|
-
top: 0;
|
|
598
|
-
box-sizing: border-box;
|
|
599
|
-
display: flex;
|
|
600
|
-
overflow: hidden;
|
|
601
|
-
text-overflow: ellipsis;
|
|
602
|
-
white-space: nowrap;
|
|
603
|
-
user-select: none;
|
|
604
|
-
-webkit-user-select: none;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/* Visual properties - :where() for zero specificity, so user highlight classes always win */
|
|
608
|
-
:where(.gp-grid-cell) {
|
|
609
|
-
align-items: center;
|
|
610
|
-
padding: 0 12px;
|
|
611
|
-
cursor: cell;
|
|
612
|
-
color: var(--gp-grid-text);
|
|
613
|
-
border-right: 1px solid var(--gp-grid-border-light);
|
|
614
|
-
border-bottom: 1px solid var(--gp-grid-border-light);
|
|
615
|
-
background-color: transparent;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
/* Active cell (focused) - structural properties stay, visual use :where() */
|
|
619
|
-
.gp-grid-cell--active {
|
|
620
|
-
outline: none;
|
|
621
|
-
z-index: 5;
|
|
622
|
-
}
|
|
623
|
-
:where(.gp-grid-cell--active) {
|
|
624
|
-
background-color: var(--gp-grid-primary-light);
|
|
625
|
-
border: 2px solid var(--gp-grid-primary);
|
|
626
|
-
padding: 0 11px;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
/* Selected cells (range selection) */
|
|
630
|
-
:where(.gp-grid-cell--selected) {
|
|
631
|
-
background-color: var(--gp-grid-primary-light);
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/* Editing cell - structural properties stay, visual use :where() */
|
|
635
|
-
.gp-grid-cell--editing {
|
|
636
|
-
z-index: 10;
|
|
637
|
-
}
|
|
638
|
-
:where(.gp-grid-cell--editing) {
|
|
639
|
-
background-color: var(--gp-grid-bg);
|
|
640
|
-
border: 2px solid var(--gp-grid-primary);
|
|
641
|
-
padding: 0;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
/* =============================================================================
|
|
645
|
-
Fill Handle (drag to fill)
|
|
646
|
-
============================================================================= */
|
|
647
|
-
|
|
648
|
-
.gp-grid-fill-handle {
|
|
649
|
-
position: absolute;
|
|
650
|
-
width: 8px;
|
|
651
|
-
height: 8px;
|
|
652
|
-
z-index: 11;
|
|
653
|
-
pointer-events: auto;
|
|
654
|
-
box-sizing: border-box;
|
|
655
|
-
touch-action: none;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
:where(.gp-grid-fill-handle) {
|
|
659
|
-
background-color: var(--gp-grid-primary);
|
|
660
|
-
border: 2px solid var(--gp-grid-bg);
|
|
661
|
-
cursor: crosshair;
|
|
662
|
-
border-radius: 1px;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
:where(.gp-grid-fill-handle:hover) {
|
|
666
|
-
transform: scale(1.2);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
@media (pointer: coarse) and (hover: none) and (max-width: 768px) {
|
|
670
|
-
.gp-grid-fill-handle {
|
|
671
|
-
width: 24px;
|
|
672
|
-
height: 24px;
|
|
673
|
-
}
|
|
674
|
-
:where(.gp-grid-fill-handle) {
|
|
675
|
-
border-width: 3px;
|
|
676
|
-
border-radius: 3px;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
/* Fill preview (cells being filled) */
|
|
681
|
-
:where(.gp-grid-cell.gp-grid-cell--fill-preview) {
|
|
682
|
-
background-color: var(--gp-grid-primary-light);
|
|
683
|
-
border: 1px dashed var(--gp-grid-primary);
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
/* =============================================================================
|
|
687
|
-
Edit Input
|
|
688
|
-
============================================================================= */
|
|
689
|
-
|
|
690
|
-
.gp-grid-edit-input {
|
|
691
|
-
width: 100%;
|
|
692
|
-
height: 100%;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
:where(.gp-grid-edit-input) {
|
|
696
|
-
padding: 0 11px;
|
|
697
|
-
font-family: inherit;
|
|
698
|
-
font-size: inherit;
|
|
699
|
-
color: var(--gp-grid-text);
|
|
700
|
-
border: none;
|
|
701
|
-
background-color: transparent;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
.gp-grid-edit-input:focus {
|
|
705
|
-
outline: none;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
/* =============================================================================
|
|
709
|
-
Cell Peek (read-only multi-line overlay on dblclick of non-editable cell)
|
|
710
|
-
============================================================================= */
|
|
711
|
-
|
|
712
|
-
/* Structural: positioned absolutely by the framework wrapper; must sit above
|
|
713
|
-
selection (z:5), editing (z:10), fill handle (z:11). */
|
|
714
|
-
.gp-grid-cell-peek {
|
|
715
|
-
position: absolute;
|
|
716
|
-
z-index: 20;
|
|
717
|
-
box-sizing: border-box;
|
|
718
|
-
overflow: auto;
|
|
719
|
-
max-height: 320px;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
:where(.gp-grid-cell-peek) {
|
|
723
|
-
padding: 8px 11px;
|
|
724
|
-
background-color: var(--gp-grid-bg);
|
|
725
|
-
color: var(--gp-grid-text);
|
|
726
|
-
border: 2px solid var(--gp-grid-primary);
|
|
727
|
-
border-radius: 3px;
|
|
728
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
729
|
-
font-family: inherit;
|
|
730
|
-
font-size: inherit;
|
|
731
|
-
line-height: 1.4;
|
|
732
|
-
white-space: pre-wrap;
|
|
733
|
-
overflow-wrap: anywhere;
|
|
734
|
-
cursor: text;
|
|
735
|
-
user-select: text;
|
|
736
|
-
-webkit-user-select: text;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
`,Jt=`
|
|
740
|
-
/* =============================================================================
|
|
741
|
-
Loading & Error States
|
|
742
|
-
============================================================================= */
|
|
743
|
-
|
|
744
|
-
/* Sticky wrapper: stays pinned at viewport top, takes no layout space */
|
|
745
|
-
.gp-grid-loading-anchor {
|
|
746
|
-
position: sticky;
|
|
747
|
-
top: 0;
|
|
748
|
-
left: 0;
|
|
749
|
-
height: 0;
|
|
750
|
-
z-index: 900;
|
|
751
|
-
overflow: visible;
|
|
752
|
-
pointer-events: none;
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
/* Semi-transparent overlay covering the visible viewport area */
|
|
756
|
-
.gp-grid-loading-overlay {
|
|
757
|
-
position: absolute;
|
|
758
|
-
top: 0;
|
|
759
|
-
left: 0;
|
|
760
|
-
width: 100%;
|
|
761
|
-
height: 100%;
|
|
762
|
-
pointer-events: none;
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
:where(.gp-grid-loading-overlay) {
|
|
766
|
-
background-color: var(--gp-grid-loading-overlay-bg, rgba(255, 255, 255, 0.4));
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
:where(.gp-grid-container--dark .gp-grid-loading-overlay) {
|
|
770
|
-
background-color: var(--gp-grid-loading-overlay-bg, rgba(0, 0, 0, 0.3));
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
/* Loading indicator centered in the visible viewport */
|
|
774
|
-
.gp-grid-loading {
|
|
775
|
-
position: absolute;
|
|
776
|
-
top: 50%;
|
|
777
|
-
left: 50%;
|
|
778
|
-
transform: translate(-50%, -50%);
|
|
779
|
-
z-index: 1000;
|
|
780
|
-
display: flex;
|
|
781
|
-
pointer-events: auto;
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
:where(.gp-grid-loading) {
|
|
785
|
-
align-items: center;
|
|
786
|
-
padding: 12px 20px;
|
|
787
|
-
background-color: var(--gp-grid-loading-bg);
|
|
788
|
-
color: var(--gp-grid-loading-text);
|
|
789
|
-
border-radius: 6px;
|
|
790
|
-
border: 1px solid var(--gp-grid-border);
|
|
791
|
-
font-weight: 500;
|
|
792
|
-
font-size: 13px;
|
|
793
|
-
gap: 10px;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
.gp-grid-loading-spinner {
|
|
797
|
-
width: 16px;
|
|
798
|
-
height: 16px;
|
|
799
|
-
animation: gp-grid-spin 0.7s linear infinite;
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
:where(.gp-grid-loading-spinner) {
|
|
803
|
-
border: 2px solid var(--gp-grid-border);
|
|
804
|
-
border-top-color: var(--gp-grid-primary);
|
|
805
|
-
border-radius: 50%;
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
@keyframes gp-grid-spin {
|
|
809
|
-
to {
|
|
810
|
-
transform: rotate(360deg);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
.gp-grid-error {
|
|
815
|
-
position: absolute;
|
|
816
|
-
top: 50%;
|
|
817
|
-
left: 50%;
|
|
818
|
-
transform: translate(-50%, -50%);
|
|
819
|
-
z-index: 1000;
|
|
820
|
-
user-select: text;
|
|
821
|
-
-webkit-user-select: text;
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
:where(.gp-grid-error) {
|
|
825
|
-
padding: 12px 20px;
|
|
826
|
-
background-color: var(--gp-grid-error-bg);
|
|
827
|
-
color: var(--gp-grid-error-text);
|
|
828
|
-
border-radius: 6px;
|
|
829
|
-
border: 1px solid var(--gp-grid-error-text);
|
|
830
|
-
font-weight: 500;
|
|
831
|
-
font-size: 13px;
|
|
832
|
-
max-width: 80%;
|
|
833
|
-
text-align: center;
|
|
834
|
-
cursor: text;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
/* =============================================================================
|
|
838
|
-
Empty State
|
|
839
|
-
============================================================================= */
|
|
840
|
-
|
|
841
|
-
.gp-grid-empty {
|
|
842
|
-
position: absolute;
|
|
843
|
-
top: 50%;
|
|
844
|
-
left: 50%;
|
|
845
|
-
transform: translate(-50%, -50%);
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
:where(.gp-grid-empty) {
|
|
849
|
-
color: var(--gp-grid-text-muted);
|
|
850
|
-
font-size: 14px;
|
|
851
|
-
text-align: center;
|
|
852
|
-
}
|
|
853
|
-
`,Yt=`
|
|
854
|
-
/* =============================================================================
|
|
855
|
-
Scrollbar Styling
|
|
856
|
-
============================================================================= */
|
|
857
|
-
|
|
858
|
-
.gp-grid-container::-webkit-scrollbar {
|
|
859
|
-
width: 8px;
|
|
860
|
-
height: 8px;
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
:where(.gp-grid-container)::-webkit-scrollbar-track {
|
|
864
|
-
background-color: var(--gp-grid-scrollbar-track);
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
:where(.gp-grid-container)::-webkit-scrollbar-thumb {
|
|
868
|
-
background-color: var(--gp-grid-scrollbar-thumb);
|
|
869
|
-
border-radius: 4px;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
:where(.gp-grid-container)::-webkit-scrollbar-thumb:hover {
|
|
873
|
-
background-color: var(--gp-grid-scrollbar-thumb-hover);
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
:where(.gp-grid-container)::-webkit-scrollbar-corner {
|
|
877
|
-
background-color: var(--gp-grid-scrollbar-track);
|
|
878
|
-
}
|
|
879
|
-
`,Xt=`
|
|
880
|
-
/* =============================================================================
|
|
881
|
-
Filter Popup
|
|
882
|
-
============================================================================= */
|
|
883
|
-
|
|
884
|
-
.gp-grid-filter-popup {
|
|
885
|
-
max-height: 400px;
|
|
886
|
-
max-width: min(360px, calc(100vw - 16px));
|
|
887
|
-
display: flex;
|
|
888
|
-
flex-direction: column;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
:where(.gp-grid-filter-popup) {
|
|
892
|
-
background-color: var(--gp-grid-bg);
|
|
893
|
-
border: 1px solid var(--gp-grid-border);
|
|
894
|
-
border-radius: 6px;
|
|
895
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
896
|
-
font-size: 13px;
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
:where(.gp-grid-filter-header) {
|
|
900
|
-
padding: 10px 12px;
|
|
901
|
-
font-weight: 600;
|
|
902
|
-
border-bottom: 1px solid var(--gp-grid-border-light);
|
|
903
|
-
color: var(--gp-grid-header-text);
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
.gp-grid-filter-content {
|
|
907
|
-
display: flex;
|
|
908
|
-
flex-direction: column;
|
|
909
|
-
overflow-y: auto;
|
|
910
|
-
min-height: 0;
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
:where(.gp-grid-filter-content) {
|
|
914
|
-
padding: 10px 12px;
|
|
915
|
-
gap: 10px;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
/* Mode toggle (Values / Condition) */
|
|
919
|
-
.gp-grid-filter-mode-toggle {
|
|
920
|
-
display: flex;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
:where(.gp-grid-filter-mode-toggle) {
|
|
924
|
-
gap: 4px;
|
|
925
|
-
background-color: var(--gp-grid-bg-alt);
|
|
926
|
-
border-radius: 4px;
|
|
927
|
-
padding: 2px;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
.gp-grid-filter-mode-toggle button {
|
|
931
|
-
flex: 1;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
:where(.gp-grid-filter-mode-toggle button) {
|
|
935
|
-
padding: 6px 10px;
|
|
936
|
-
font-size: 11px;
|
|
937
|
-
font-family: inherit;
|
|
938
|
-
border: none;
|
|
939
|
-
border-radius: 3px;
|
|
940
|
-
background-color: transparent;
|
|
941
|
-
color: var(--gp-grid-text-secondary);
|
|
942
|
-
cursor: pointer;
|
|
943
|
-
transition: background-color 0.15s ease, color 0.15s ease;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
:where(.gp-grid-filter-mode-toggle button:hover) {
|
|
947
|
-
color: var(--gp-grid-text);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
:where(.gp-grid-filter-mode-toggle button.active) {
|
|
951
|
-
background-color: var(--gp-grid-bg);
|
|
952
|
-
color: var(--gp-grid-text);
|
|
953
|
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
/* Info message for too many values */
|
|
957
|
-
:where(.gp-grid-filter-info) {
|
|
958
|
-
font-size: 11px;
|
|
959
|
-
color: var(--gp-grid-text-secondary);
|
|
960
|
-
padding: 6px 8px;
|
|
961
|
-
background-color: var(--gp-grid-bg-alt);
|
|
962
|
-
border-radius: 4px;
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
/* Search input in filter */
|
|
966
|
-
.gp-grid-filter-search {
|
|
967
|
-
width: 100%;
|
|
968
|
-
height: 30px;
|
|
969
|
-
box-sizing: border-box;
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
:where(.gp-grid-filter-search) {
|
|
973
|
-
padding: 0 10px;
|
|
974
|
-
font-family: inherit;
|
|
975
|
-
font-size: 12px;
|
|
976
|
-
border: 1px solid var(--gp-grid-input-border);
|
|
977
|
-
border-radius: 4px;
|
|
978
|
-
background-color: var(--gp-grid-input-bg);
|
|
979
|
-
color: var(--gp-grid-text);
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
:where(.gp-grid-filter-search:focus) {
|
|
983
|
-
outline: none;
|
|
984
|
-
border-color: var(--gp-grid-primary);
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
/* Select All / Deselect All actions */
|
|
988
|
-
.gp-grid-filter-actions {
|
|
989
|
-
display: flex;
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
:where(.gp-grid-filter-actions) {
|
|
993
|
-
gap: 8px;
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
.gp-grid-filter-actions button {
|
|
997
|
-
flex: 1;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
:where(.gp-grid-filter-actions button) {
|
|
1001
|
-
padding: 4px 8px;
|
|
1002
|
-
font-size: 11px;
|
|
1003
|
-
font-family: inherit;
|
|
1004
|
-
border: 1px solid var(--gp-grid-input-border);
|
|
1005
|
-
border-radius: 3px;
|
|
1006
|
-
background-color: var(--gp-grid-bg);
|
|
1007
|
-
color: var(--gp-grid-text);
|
|
1008
|
-
cursor: pointer;
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
:where(.gp-grid-filter-actions button:hover:not(:disabled)) {
|
|
1012
|
-
background-color: var(--gp-grid-hover);
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
:where(.gp-grid-filter-actions button:disabled) {
|
|
1016
|
-
opacity: 0.5;
|
|
1017
|
-
cursor: not-allowed;
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
/* Checkbox list */
|
|
1021
|
-
.gp-grid-filter-list {
|
|
1022
|
-
max-height: 200px;
|
|
1023
|
-
overflow-y: auto;
|
|
1024
|
-
display: flex;
|
|
1025
|
-
flex-direction: column;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
:where(.gp-grid-filter-list) {
|
|
1029
|
-
gap: 4px;
|
|
1030
|
-
border: 1px solid var(--gp-grid-border-light);
|
|
1031
|
-
border-radius: 4px;
|
|
1032
|
-
padding: 6px;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
.gp-grid-filter-option {
|
|
1036
|
-
display: flex;
|
|
1037
|
-
align-items: center;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
:where(.gp-grid-filter-option) {
|
|
1041
|
-
gap: 8px;
|
|
1042
|
-
padding: 4px 6px;
|
|
1043
|
-
border-radius: 3px;
|
|
1044
|
-
cursor: pointer;
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
:where(.gp-grid-filter-option:hover) {
|
|
1048
|
-
background-color: var(--gp-grid-hover);
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
.gp-grid-filter-option input[type="checkbox"] {
|
|
1052
|
-
margin: 0;
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
:where(.gp-grid-filter-option input[type="checkbox"]) {
|
|
1056
|
-
cursor: pointer;
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
.gp-grid-filter-option span {
|
|
1060
|
-
flex: 1;
|
|
1061
|
-
overflow: hidden;
|
|
1062
|
-
text-overflow: ellipsis;
|
|
1063
|
-
white-space: nowrap;
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
:where(.gp-grid-filter-blank) {
|
|
1067
|
-
font-style: italic;
|
|
1068
|
-
color: var(--gp-grid-text-muted);
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
/* Filter condition row (for number/date filters) */
|
|
1072
|
-
.gp-grid-filter-condition {
|
|
1073
|
-
display: flex;
|
|
1074
|
-
flex-direction: column;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
:where(.gp-grid-filter-condition) {
|
|
1078
|
-
gap: 6px;
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
.gp-grid-filter-row {
|
|
1082
|
-
display: flex;
|
|
1083
|
-
align-items: center;
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
:where(.gp-grid-filter-row) {
|
|
1087
|
-
gap: 6px;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
.gp-grid-filter-row select {
|
|
1091
|
-
height: 30px;
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
:where(.gp-grid-filter-row select) {
|
|
1095
|
-
padding: 0 6px;
|
|
1096
|
-
font-family: inherit;
|
|
1097
|
-
font-size: 12px;
|
|
1098
|
-
border: 1px solid var(--gp-grid-input-border);
|
|
1099
|
-
border-radius: 4px;
|
|
1100
|
-
background-color: var(--gp-grid-input-bg);
|
|
1101
|
-
color: var(--gp-grid-text);
|
|
1102
|
-
cursor: pointer;
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
.gp-grid-filter-row input[type="number"],
|
|
1106
|
-
.gp-grid-filter-row input[type="date"],
|
|
1107
|
-
.gp-grid-filter-row input[type="text"],
|
|
1108
|
-
.gp-grid-filter-text-input {
|
|
1109
|
-
flex: 1;
|
|
1110
|
-
height: 30px;
|
|
1111
|
-
min-width: 0;
|
|
1112
|
-
box-sizing: border-box;
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
:where(.gp-grid-filter-row input[type="number"]),
|
|
1116
|
-
:where(.gp-grid-filter-row input[type="date"]),
|
|
1117
|
-
:where(.gp-grid-filter-row input[type="text"]),
|
|
1118
|
-
:where(.gp-grid-filter-text-input) {
|
|
1119
|
-
padding: 0 8px;
|
|
1120
|
-
font-family: inherit;
|
|
1121
|
-
font-size: 12px;
|
|
1122
|
-
border: 1px solid var(--gp-grid-input-border);
|
|
1123
|
-
border-radius: 4px;
|
|
1124
|
-
background-color: var(--gp-grid-input-bg);
|
|
1125
|
-
color: var(--gp-grid-text);
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
:where(.gp-grid-filter-row input:focus) {
|
|
1129
|
-
outline: none;
|
|
1130
|
-
border-color: var(--gp-grid-primary);
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
:where(.gp-grid-filter-to) {
|
|
1134
|
-
font-size: 11px;
|
|
1135
|
-
color: var(--gp-grid-text-secondary);
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
.gp-grid-filter-remove {
|
|
1139
|
-
width: 24px;
|
|
1140
|
-
height: 24px;
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
:where(.gp-grid-filter-remove) {
|
|
1144
|
-
padding: 0;
|
|
1145
|
-
font-size: 16px;
|
|
1146
|
-
line-height: 1;
|
|
1147
|
-
border: none;
|
|
1148
|
-
border-radius: 3px;
|
|
1149
|
-
background-color: transparent;
|
|
1150
|
-
color: var(--gp-grid-text-muted);
|
|
1151
|
-
cursor: pointer;
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
:where(.gp-grid-filter-remove:hover) {
|
|
1155
|
-
background-color: var(--gp-grid-error-bg);
|
|
1156
|
-
color: var(--gp-grid-error-text);
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
/* AND/OR combination toggle */
|
|
1160
|
-
.gp-grid-filter-combination {
|
|
1161
|
-
display: flex;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
:where(.gp-grid-filter-combination) {
|
|
1165
|
-
gap: 4px;
|
|
1166
|
-
margin-bottom: 4px;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
.gp-grid-filter-combination button {
|
|
1170
|
-
flex: 1;
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
:where(.gp-grid-filter-combination button) {
|
|
1174
|
-
padding: 4px 8px;
|
|
1175
|
-
font-size: 10px;
|
|
1176
|
-
font-family: inherit;
|
|
1177
|
-
border: 1px solid var(--gp-grid-input-border);
|
|
1178
|
-
border-radius: 3px;
|
|
1179
|
-
background-color: var(--gp-grid-bg);
|
|
1180
|
-
color: var(--gp-grid-text-secondary);
|
|
1181
|
-
cursor: pointer;
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
:where(.gp-grid-filter-combination button.active) {
|
|
1185
|
-
background-color: var(--gp-grid-primary);
|
|
1186
|
-
border-color: var(--gp-grid-primary);
|
|
1187
|
-
color: #fff;
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
/* Add condition button */
|
|
1191
|
-
.gp-grid-filter-add {
|
|
1192
|
-
width: 100%;
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
:where(.gp-grid-filter-add) {
|
|
1196
|
-
padding: 6px;
|
|
1197
|
-
font-size: 11px;
|
|
1198
|
-
font-family: inherit;
|
|
1199
|
-
border: 1px dashed var(--gp-grid-border);
|
|
1200
|
-
border-radius: 4px;
|
|
1201
|
-
background-color: transparent;
|
|
1202
|
-
color: var(--gp-grid-text-secondary);
|
|
1203
|
-
cursor: pointer;
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
:where(.gp-grid-filter-add:hover) {
|
|
1207
|
-
background-color: var(--gp-grid-hover);
|
|
1208
|
-
border-color: var(--gp-grid-primary);
|
|
1209
|
-
color: var(--gp-grid-primary);
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
/* Apply / Clear buttons */
|
|
1213
|
-
.gp-grid-filter-buttons {
|
|
1214
|
-
display: flex;
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
:where(.gp-grid-filter-buttons) {
|
|
1218
|
-
gap: 8px;
|
|
1219
|
-
padding-top: 8px;
|
|
1220
|
-
border-top: 1px solid var(--gp-grid-border-light);
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
.gp-grid-filter-btn-clear,
|
|
1224
|
-
.gp-grid-filter-btn-apply {
|
|
1225
|
-
flex: 1;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
:where(.gp-grid-filter-btn-clear),
|
|
1229
|
-
:where(.gp-grid-filter-btn-apply) {
|
|
1230
|
-
padding: 8px 12px;
|
|
1231
|
-
font-size: 12px;
|
|
1232
|
-
font-family: inherit;
|
|
1233
|
-
border-radius: 4px;
|
|
1234
|
-
cursor: pointer;
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
:where(.gp-grid-filter-btn-clear) {
|
|
1238
|
-
border: 1px solid var(--gp-grid-input-border);
|
|
1239
|
-
background-color: var(--gp-grid-bg);
|
|
1240
|
-
color: var(--gp-grid-text);
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
:where(.gp-grid-filter-btn-clear:hover) {
|
|
1244
|
-
background-color: var(--gp-grid-hover);
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
:where(.gp-grid-filter-btn-apply) {
|
|
1248
|
-
border: 1px solid var(--gp-grid-primary);
|
|
1249
|
-
background-color: var(--gp-grid-primary);
|
|
1250
|
-
color: #fff;
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
:where(.gp-grid-filter-btn-apply:hover) {
|
|
1254
|
-
opacity: 0.9;
|
|
1255
|
-
}
|
|
1256
|
-
`,Zt=`
|
|
1257
|
-
/* =============================================================================
|
|
1258
|
-
Row Drag
|
|
1259
|
-
============================================================================= */
|
|
1260
|
-
|
|
1261
|
-
.gp-grid-cell--row-drag-handle {
|
|
1262
|
-
touch-action: none;
|
|
1263
|
-
}
|
|
1264
|
-
|
|
1265
|
-
:where(.gp-grid-cell--row-drag-handle) {
|
|
1266
|
-
cursor: grab;
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
:where(.gp-grid-cell--row-drag-handle:active) {
|
|
1270
|
-
cursor: grabbing;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
.gp-grid-row-drag-icon {
|
|
1274
|
-
display: flex;
|
|
1275
|
-
align-items: center;
|
|
1276
|
-
justify-content: center;
|
|
1277
|
-
width: 100%;
|
|
1278
|
-
height: 100%;
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
:where(.gp-grid-row-drag-icon) {
|
|
1282
|
-
color: var(--gp-grid-text-secondary);
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
.gp-grid-row-drag-icon svg {
|
|
1286
|
-
width: 16px;
|
|
1287
|
-
height: 16px;
|
|
1288
|
-
}
|
|
1289
|
-
|
|
1290
|
-
.gp-grid-row-drag-ghost {
|
|
1291
|
-
position: fixed;
|
|
1292
|
-
pointer-events: none;
|
|
1293
|
-
z-index: 2000;
|
|
1294
|
-
overflow: hidden;
|
|
1295
|
-
box-sizing: border-box;
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
:where(.gp-grid-row-drag-ghost) {
|
|
1299
|
-
opacity: 0.8;
|
|
1300
|
-
background-color: var(--gp-grid-bg, #fff);
|
|
1301
|
-
border: 2px solid var(--gp-grid-primary);
|
|
1302
|
-
border-radius: 4px;
|
|
1303
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
.gp-grid-row-drop-indicator {
|
|
1307
|
-
position: absolute;
|
|
1308
|
-
left: 0;
|
|
1309
|
-
width: 100%;
|
|
1310
|
-
height: 3px;
|
|
1311
|
-
z-index: 1000;
|
|
1312
|
-
pointer-events: none;
|
|
1313
|
-
}
|
|
1314
|
-
|
|
1315
|
-
:where(.gp-grid-row-drop-indicator) {
|
|
1316
|
-
background-color: var(--gp-grid-primary);
|
|
1317
|
-
border-radius: 2px;
|
|
1318
|
-
}
|
|
1319
|
-
`,Qt=[Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt].join(`
|
|
1320
|
-
`),$t=e=>({slots:new Map,activeCell:null,selectionRange:null,editingCell:null,peekCell:null,contentWidth:0,contentHeight:e?.initialHeight??0,viewportWidth:e?.initialWidth??0,viewportHeight:e?.initialHeight??0,rowsWrapperOffset:0,headers:new Map,filterPopup:null,isLoading:!1,error:null,totalRows:0,visibleRowRange:null,hoverPosition:null,columns:null,pendingScrollTop:null}),en=(e,t,n)=>{switch(e.type){case`CREATE_SLOT`:return t.set(e.slotId,{slotId:e.slotId,rowIndex:-1,rowData:{},translateY:0}),null;case`DESTROY_SLOT`:return t.delete(e.slotId),null;case`ASSIGN_SLOT`:{let n=t.get(e.slotId);return n&&t.set(e.slotId,{...n,rowIndex:e.rowIndex,rowData:e.rowData}),null}case`MOVE_SLOT`:{let n=t.get(e.slotId);return n&&t.set(e.slotId,{...n,translateY:e.translateY}),null}case`SCROLL_TO`:return{pendingScrollTop:e.scrollTop};case`SET_ACTIVE_CELL`:return{activeCell:e.position};case`SET_SELECTION_RANGE`:return{selectionRange:e.range};case`UPDATE_VISIBLE_RANGE`:return{visibleRowRange:{start:e.start,end:e.end},rowsWrapperOffset:e.rowsWrapperOffset};case`SET_HOVER_POSITION`:return{hoverPosition:e.position};case`START_EDIT`:return{editingCell:{row:e.row,col:e.col,initialValue:e.initialValue}};case`STOP_EDIT`:return{editingCell:null};case`START_PEEK`:return{peekCell:{row:e.row,col:e.col}};case`STOP_PEEK`:return{peekCell:null};case`SET_CONTENT_SIZE`:return{contentWidth:e.width,contentHeight:e.height,viewportWidth:e.viewportWidth,viewportHeight:e.viewportHeight,rowsWrapperOffset:e.rowsWrapperOffset};case`UPDATE_HEADER`:return n.set(e.colIndex,{column:e.column,sortDirection:e.sortDirection,sortIndex:e.sortIndex,hasFilter:e.hasFilter}),null;case`OPEN_FILTER_POPUP`:return{filterPopup:{isOpen:!0,colIndex:e.colIndex,column:e.column,anchorRect:e.anchorRect,distinctValues:e.distinctValues,currentFilter:e.currentFilter}};case`CLOSE_FILTER_POPUP`:return{filterPopup:null};case`DATA_LOADING`:return{isLoading:!0,error:null};case`DATA_LOADED`:return{isLoading:!1,totalRows:e.totalRows};case`DATA_ERROR`:return{isLoading:!1,error:e.error};case`ROWS_ADDED`:case`ROWS_REMOVED`:return{totalRows:e.totalRows};case`ROWS_UPDATED`:case`TRANSACTION_PROCESSED`:return null;case`COLUMNS_CHANGED`:return{columns:e.columns};default:return null}},Q=e=>({clientX:e.clientX,clientY:e.clientY,button:e.button,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,pointerId:e.pointerId,pointerType:e.pointerType});var tn=class{intervalId=null;lastPointerEvent=null;getBodyEl;onTick;constructor(e,t){this.getBodyEl=e,this.onTick=t}recordPointer(e){this.lastPointerEvent=e}clearPointer(){this.lastPointerEvent=null}start(e,t){this.stop(),this.intervalId=setInterval(()=>{let n=this.getBodyEl();if(!n)return;n.scrollTop+=t,n.scrollLeft+=e;let r=this.lastPointerEvent;r&&this.onTick(r)},16)}stop(){this.intervalId!==null&&(clearInterval(this.intervalId),this.intervalId=null)}},nn=class{timer=null;capture=null;savedContainerOverflow=null;blockTouchMove=e=>e.preventDefault();deps;constructor(e){this.deps=e}start(e){this.reset(),this.capture={pointerId:e.pointerId,target:e.currentTarget};let t=e.clientX,n=e.clientY,r=e=>{let r=e.clientX-t,i=e.clientY-n;(Math.abs(r)>10||Math.abs(i)>10)&&(this.cancel(),a())},i=()=>{this.cancel(),a()},a=()=>{document.removeEventListener(`pointermove`,r),document.removeEventListener(`pointerup`,i),document.removeEventListener(`pointercancel`,i)};document.addEventListener(`pointermove`,r),document.addEventListener(`pointerup`,i,{once:!0}),document.addEventListener(`pointercancel`,i,{once:!0}),this.timer=setTimeout(()=>{this.timer=null,a(),this.confirm()},300)}cancel(){this.reset(),this.deps.getCore()?.input.cancelPendingRowDrag()}reset(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.capture=null}releaseLocks(){if(!this.deps.isBrowser)return;let e=this.deps.getContainer();this.savedContainerOverflow!==null&&e&&(e.style.overflow=this.savedContainerOverflow),this.savedContainerOverflow=null,document.removeEventListener(`touchmove`,this.blockTouchMove)}confirm(){let e=this.deps.getCore(),t=this.capture;this.capture=null,e!==null&&e.input.confirmPendingRowDrag()&&(this.lockContainer(),document.addEventListener(`touchmove`,this.blockTouchMove,{passive:!1}),this.applyPointerCapture(t),this.deps.onDragConfirmed(e.input.getDragState()))}lockContainer(){let e=this.deps.getContainer();e&&(this.savedContainerOverflow=e.style.overflow,e.style.overflow=`hidden`)}applyPointerCapture(e){e&&rn(e.target,e.pointerId)}};const rn=(e,t)=>{try{return e.setPointerCapture(t),!0}catch{return!1}};var an=class{cleanup=null;deps;constructor(e){this.deps=e}start(e){if(!this.deps.isBrowser)return;this.detachListeners();let t=e.clientX,n=e.clientY,r=e=>{let r=e.clientX-t,i=e.clientY-n;(Math.abs(r)>10||Math.abs(i)>10)&&this.cancel()},i=()=>{this.cancel()},a=()=>{this.detachListeners(),this.deps.getCore()?.input.confirmPendingCellTap()&&this.deps.onTapConfirmed()};document.addEventListener(`pointermove`,r),document.addEventListener(`pointerup`,a,{once:!0}),document.addEventListener(`pointercancel`,i,{once:!0}),this.cleanup=()=>{document.removeEventListener(`pointermove`,r),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,i)}}cancel(){this.detachListeners(),this.deps.getCore()?.input.cancelPendingCellTap()}detachListeners(){this.cleanup!==null&&(this.cleanup(),this.cleanup=null)}};const on=e=>150*e/1e3,sn=(e,t)=>e.filter(e=>t-e.time<=100),cn=(e,t=640)=>{let n=e[0],r=e.at(-1);if(n===void 0||r===void 0||n===r)return 0;let i=r.time-n.time;if(i<=0)return 0;let a=(r.position-n.position)/i,o=Math.min(2.4,t);return Math.max(-o,Math.min(o,a))},ln=(e,t,n=640)=>{let r=e*t>0?e+t*4:e;return Math.max(-n,Math.min(n,r))},un=(e,t)=>{if(t>1500)return e;if(e===null)return t;let n=t>e?.5:.15;return e+(t-e)*n},dn=(e,t=640)=>{if(e===null||e<=0)return t;let n=Math.max(250,t*17)/e;return Math.max(.25,Math.min(t,n))},fn=(e,t)=>({position:e.position+e.velocity*Math.min(t,64),velocity:e.velocity*Math.exp(-t/1200)}),pn=e=>Math.abs(e)<.01,$=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));var mn=class{deps;attachedEl=null;gesture=null;gestureCleanup=null;flingFrame=null;flingVelocity=0;dragFrame=null;pendingDragTarget=null;savedOverscrollBehavior=null;savedTouchAction=null;overrideActive=!1;subscribedCore=null;contentSizeUnsubscribe=null;lastPipelineRunMs=null;pipelineIntervalEmaMs=null;frameIntervalEmaMs=null;flingThrottled=!1;constructor(e){this.deps=e}attach(){if(!this.deps.isBrowser||this.attachedEl!==null)return;let e=this.deps.getScrollEl();e!==null&&(this.attachedEl=e,this.savedOverscrollBehavior=e.style.overscrollBehavior,this.savedTouchAction=e.style.touchAction,this.syncCore(),e.addEventListener(`touchstart`,this.onTouchStart,{passive:!0}),e.addEventListener(`wheel`,this.onWheel,{passive:!0}))}detach(){this.stop(),this.clearGesture(),this.contentSizeUnsubscribe?.(),this.contentSizeUnsubscribe=null,this.subscribedCore=null;let e=this.attachedEl;e!==null&&(this.attachedEl=null,e.removeEventListener(`touchstart`,this.onTouchStart),e.removeEventListener(`wheel`,this.onWheel),this.savedOverscrollBehavior!==null&&(e.style.overscrollBehavior=this.savedOverscrollBehavior,this.savedOverscrollBehavior=null),this.savedTouchAction!==null&&(e.style.touchAction=this.savedTouchAction,this.savedTouchAction=null))}syncCore(){this.syncPolicySubscription(),this.syncTouchPolicy()}syncPolicySubscription(){let e=this.deps.getCore();e!==this.subscribedCore&&(this.contentSizeUnsubscribe?.(),this.contentSizeUnsubscribe=null,this.subscribedCore=e,e!==null&&(this.contentSizeUnsubscribe=e.onBatchInstruction(e=>{e.some(e=>e.type===`SET_CONTENT_SIZE`)&&this.syncTouchPolicy()})))}syncTouchPolicy(){let e=this.attachedEl;if(e===null)return;let t=this.deps.getCore()?.isScalingActive()===!0,n=t?`none`:this.savedTouchAction??``,r=t?`contain`:this.savedOverscrollBehavior??``;e.style.touchAction!==n&&(e.style.touchAction=n),e.style.overscrollBehavior!==r&&(e.style.overscrollBehavior=r)}stop(){this.flingFrame!==null&&(globalThis.cancelAnimationFrame?.(this.flingFrame),this.flingFrame=null),this.releaseScrollOverride()}applySyntheticScrollTop(e,t,n,r){r!==null&&this.lastPipelineRunMs!==null&&(this.pipelineIntervalEmaMs=un(this.pipelineIntervalEmaMs,r-this.lastPipelineRunMs)),this.lastPipelineRunMs=r,this.overrideActive=!0,e.setScrollTopOverride(n),t.scrollTop=n,e.setViewport(n,t.scrollLeft,t.clientWidth,t.clientHeight)}updateFlingThrottle(e,t){if(Math.abs(e)<=t){this.flingThrottled=!1;return}let n=this.frameIntervalEmaMs;n!==null&&n>28&&(this.flingThrottled=!0)}isFlingPipelineDue(e){return!this.flingThrottled||this.lastPipelineRunMs===null||e-this.lastPipelineRunMs>=100}releaseScrollOverride(){if(!this.overrideActive)return;this.overrideActive=!1;let e=this.deps.getCore();if(e===null)return;e.setScrollTopOverride(null);let t=this.attachedEl;t!==null&&e.setViewport(t.scrollTop,t.scrollLeft,t.clientWidth,t.clientHeight)}onWheel=()=>{this.stop(),this.syncCore()};onTouchStart=e=>{this.syncCore(),this.gesture===null&&this.startTouchGesture(e)};startTouchGesture=e=>{let t=this.flingFrame===null?0:this.flingVelocity;this.stop();let n=this.deps.getCore(),r=this.attachedEl;if(n!==null&&r!==null&&n.isScalingActive()){if(e.target?.closest(`.gp-grid-fill-handle, .gp-grid-cell--row-drag-handle`))return;let n=e.changedTouches[0];if(n===void 0)return;this.gesture={touchId:n.identifier,startClientX:n.clientX,startClientY:n.clientY,baseScrollTop:r.scrollTop,baseScrollLeft:r.scrollLeft,engaged:!1,slopOffsetX:0,slopOffsetY:0,samples:[{time:e.timeStamp,position:0}],carriedVelocity:t,expectedScrollTop:r.scrollTop,expectedScrollLeft:r.scrollLeft},this.attachGestureListeners(r)}};attachGestureListeners(e){e.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),e.addEventListener(`touchend`,this.onTouchEnd,{passive:!0}),e.addEventListener(`touchcancel`,this.onTouchCancel,{passive:!0}),this.gestureCleanup=()=>{e.removeEventListener(`touchmove`,this.onTouchMove),e.removeEventListener(`touchend`,this.onTouchEnd),e.removeEventListener(`touchcancel`,this.onTouchCancel)}}clearGesture(){this.gesture=null,this.gestureCleanup?.(),this.gestureCleanup=null,this.dragFrame!==null&&(globalThis.cancelAnimationFrame?.(this.dragFrame),this.dragFrame=null),this.pendingDragTarget=null}findTrackedTouch(e){let t=this.gesture;if(t===null)return null;let n=e.changedTouches;for(let e of Array.from(n))if(e?.identifier===t.touchId)return e;return null}onTouchMove=e=>{let t=this.gesture,n=this.findTrackedTouch(e),r=this.deps.getCore(),i=this.attachedEl;if(t===null||n===null||r===null||i===null)return;if(r.input.getDragState().isDragging){this.clearGesture(),this.releaseScrollOverride();return}if(this.hasNativeScrollTakenOver(t,i)){this.clearGesture(),this.releaseScrollOverride();return}e.cancelable&&e.preventDefault();let a=t.startClientX-n.clientX,o=t.startClientY-n.clientY;if(t.samples.push({time:e.timeStamp,position:o}),t.samples=sn(t.samples,e.timeStamp),!t.engaged){if(Math.abs(a)<=10&&Math.abs(o)<=10)return;t.engaged=!0,t.slopOffsetX=a,t.slopOffsetY=o}let s=r.getScrollRatio();this.pendingDragTarget={top:$(t.baseScrollTop+(o-t.slopOffsetY)*s,0,i.scrollHeight-i.clientHeight),left:$(t.baseScrollLeft+(a-t.slopOffsetX),0,i.scrollWidth-i.clientWidth)},this.scheduleDragApply(r,i)};hasNativeScrollTakenOver(e,t){let n=Math.abs(t.scrollTop-e.expectedScrollTop),r=Math.abs(t.scrollLeft-e.expectedScrollLeft);return n>4||r>4}scheduleDragApply(e,t){if(this.dragFrame!==null)return;let n=globalThis.requestAnimationFrame;if(n===void 0){this.flushPendingDrag(e,t,null);return}this.dragFrame=n(n=>{this.dragFrame=null,this.flushPendingDrag(e,t,n)})}flushPendingDrag(e,t,n){let r=this.pendingDragTarget;r!==null&&(this.pendingDragTarget=null,t.scrollLeft=r.left,this.gesture!==null&&(this.gesture.expectedScrollTop=r.top,this.gesture.expectedScrollLeft=r.left),this.applySyntheticScrollTop(e,t,r.top,n))}onTouchEnd=e=>{let t=this.gesture;if(t===null||this.findTrackedTouch(e)===null)return;let n=t.engaged,r=t.carriedVelocity,i=sn(t.samples,e.timeStamp),a=this.pendingDragTarget;this.clearGesture();let o=this.deps.getCore(),s=this.attachedEl;if(a!==null&&o!==null&&s!==null&&(s.scrollLeft=a.left,this.applySyntheticScrollTop(o,s,a.top,e.timeStamp)),!n)return;let c=o?.getMaxFlingVelocity()??640,l=cn(i,c);if(Math.abs(l)<.25){this.releaseScrollOverride();return}this.startFling(ln(l,r,c))};onTouchCancel=e=>{this.findTrackedTouch(e)!==null&&(this.clearGesture(),this.releaseScrollOverride())};startFling(e){let t=globalThis.requestAnimationFrame,n=this.deps.getCore(),r=this.attachedEl;if(t===void 0||n===null||r===null)return;let i=n.getMaxFlingVelocity(),a=on(n.getRowHeight()),o=dn(this.pipelineIntervalEmaMs,i),s=n.getScrollRatio(),c={position:r.scrollTop/s,velocity:$(e,-o,o)},l=null;this.flingVelocity=c.velocity,this.flingThrottled=!1;let u=e=>{this.flingFrame=null;let o=l===null?16:e-l;l!==null&&(this.frameIntervalEmaMs=un(this.frameIntervalEmaMs,o)),l=e,c=fn(c,o);let d=dn(this.pipelineIntervalEmaMs,i);c={...c,velocity:$(c.velocity,-d,d)},this.flingVelocity=c.velocity,this.updateFlingThrottle(c.velocity,a);let f=c.position*s,p=r.scrollHeight-r.clientHeight,m=$(f,0,p),h=m!==f,g=pn(c.velocity)||h;if(g||this.isFlingPipelineDue(e)?this.applySyntheticScrollTop(n,r,m,e):r.scrollTop=m,g){this.releaseScrollOverride();return}this.flingFrame=t(u)};this.flingFrame=t(u)}};const hn=(e,t,n,r)=>{let i={slots:new Map(t),headers:new Map(n)};for(let t of e){let e=en(t,i.slots,i.headers);e!==null&&gn(e,i,r)}return i},gn=(e,t,n)=>{e.slots!==void 0&&vn(t.slots,e.slots),e.headers!==void 0&&vn(t.headers,e.headers),_n(e,n),e.columns!==void 0&&e.columns!==null&&n.setColumnsOverride(e.columns),e.filterPopup!==void 0&&n.onFilterPopupChange(e.filterPopup)},_n=(e,t)=>{e.contentWidth!==void 0&&t.setContentWidth(e.contentWidth),e.contentHeight!==void 0&&t.setContentHeight(e.contentHeight),e.rowsWrapperOffset!==void 0&&t.setRowsWrapperOffset(e.rowsWrapperOffset),e.isLoading!==void 0&&t.setIsLoading(e.isLoading),e.error!==void 0&&t.setErrorMessage(e.error),e.totalRows!==void 0&&t.setTotalRows(e.totalRows),e.pendingScrollTop!==void 0&&t.setPendingScrollTop(e.pendingScrollTop),e.activeCell!==void 0&&t.setActiveCell(e.activeCell),e.selectionRange!==void 0&&t.setSelectionRange(e.selectionRange),e.editingCell!==void 0&&t.setEditingCell(e.editingCell),e.hoverPosition!==void 0&&t.setHoverPosition(e.hoverPosition),e.peekCell!==void 0&&t.setPeekCell(e.peekCell)},vn=(e,t)=>{e.clear(),t.forEach((t,n)=>e.set(n,t))};var yn=class{owned=null;lastAppliedRows=null;lastAppliedColumns=null;initialize(e,t){return e===null?(this.owned=Z(t),this.lastAppliedRows=t,this.owned):e}syncRows(e,t){return t!==null||this.lastAppliedRows===e?null:(this.lastAppliedRows=e,e.length>1e4&&console.warn(`[gp-grid] rows input changed with ${e.length} rows — this triggers a full rebuild. Use createGridData() for efficient updates.`),this.owned?.destroy?.(),this.owned=Z(e),this.owned)}syncColumns(e){return e.length===0||this.lastAppliedColumns===e?!1:(this.lastAppliedColumns=e,!0)}destroy(){this.owned?.destroy?.(),this.owned=null}},bn=class{deps;constructor(e){this.deps=e}headerPointerDown(e,t,n,r){let i=this.deps.getCore();return i!==null&&i.input.handleHeaderMouseDown(e,t,n,Q(r)).preventDefault}resizePointerDown(e,t,n){let r=this.deps.getCore();return r!==null&&r.input.handleHeaderResizeMouseDown(e,t,Q(n)).preventDefault}cellPointerDown(e,t,n){let r=this.deps.getCore();if(r===null)return{preventDefault:!1,focusContainer:!1};let i=r.input.handleCellMouseDown(e,t,Q(n));return this.dispatchCellDragStart(i,n),{preventDefault:i.preventDefault,focusContainer:i.focusContainer??!1}}cellPointerEnter(e,t){this.deps.getCore()?.input.handleCellMouseEnter(e,t)}cellPointerLeave(){this.deps.getCore()?.input.handleCellMouseLeave()}fillHandlePointerDown(e,t,n){let r=this.deps.getCore();if(r===null)return{preventDefault:!1,stopPropagation:!1};let i=r.input.handleFillHandleMouseDown(e,t,Q(n));return i.startDrag===`fill`&&(xn(n),this.deps.onDragStateChange(r.input.getDragState())),{preventDefault:i.preventDefault,stopPropagation:i.stopPropagation}}dragMove(e){let t=this.deps.getCore(),n=this.deps.getBodyEl();if(t===null||n===null)return;let r=n.getBoundingClientRect(),i=t.input.handleDragMove(Q(e),{top:r.top,left:r.left,width:r.width,height:r.height,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft});this.deps.onDragStateChange(t.input.getDragState()),i?.autoScroll?this.deps.autoScroll.start(i.autoScroll.dx,i.autoScroll.dy):this.deps.autoScroll.stop()}documentPointerMove(e){let t=this.deps.getCore();if(t===null)return!1;let n=t.input.getDragState().isDragging;return this.deps.autoScroll.recordPointer(e),this.dragMove(e),n}documentPointerUp(){let e=this.deps.getCore();if(e===null)return{wasRowDrag:!1};let t=e.input.getDragState().dragType===`row-drag`;return this.deps.autoScroll.stop(),this.deps.autoScroll.clearPointer(),e.input.handleDragEnd(),this.deps.onDragStateChange(e.input.getDragState()),{wasRowDrag:t}}wheel(e,t,n){let r=this.deps.getCore();return r===null?null:r.input.handleWheel(e,t,n)}keyDown(e,t,n,r){let i=this.deps.getCore();return i===null?{preventDefault:!1}:i.input.handleKeyDown({key:e.key,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey},t,n,r)}pasteText(e,t,n){let r=this.deps.getCore();return r===null||t!==null||n?!1:r.pasteClipboardText(e)}dispatchCellDragStart(e,t){let n=this.deps.getCore();if(n!==null){if(e.startTap===!0&&this.deps.pendingCellTap.start(t),e.startDrag===`selection`){n.input.startSelectionDrag(),this.deps.onDragStateChange(n.input.getDragState());return}if(e.startDrag===`row-drag`){this.deps.onDragStateChange(n.input.getDragState());return}e.startDrag===`row-drag-pending`&&this.deps.pendingRowDrag.start(t)}}};const xn=e=>{e.target.setPointerCapture(e.pointerId)};export{tn as AutoScrollDriver,yn as DataSourceOwner,V as EditManager,z as FillManager,Ze as GridCore,C as HighlightManager,Bt as IndexedDataStore,bn as InputEventAdapter,S as InputHandler,G as ParallelSortManager,an as PendingCellTapController,nn as PendingRowDragController,be as ROW_DRAG_HOLD_MS,O as RowDataManager,w as RowMutationManager,A as ScrollVirtualizationManager,R as SelectionManager,B as SlotPoolManager,P as SortFilterManager,ye as TAP_SLOP_PX,mn as TouchScrollController,F as TransactionManager,Qe as WorkerPool,hn as applyBatchInstructions,en as applyInstruction,se as bindPeekSelectAll,p as buildCellClasses,n as calculateColumnPositions,ae as calculateFillHandlePosition,oe as calculateFilterPopupPosition,i as calculateScaledColumnPositions,qt as cellStyles,q as compareValues,ft as computeValueHash,Gt as containerStyles,Rt as createClientDataSource,Z as createDataSourceFromArray,$t as createInitialState,Ut as createMutableClientDataSource,zt as createServerDataSource,at as detectBoundaryCollisions,Y as evaluateColumnFilter,Pt as evaluateDateCondition,Mt as evaluateNumberCondition,At as evaluateTextCondition,Xt as filtersStyles,a as findColumnAtX,te as findSlotForRow,y as formatCellValue,g as getFieldValue,r as getTotalWidth,Qt as gridStyles,Pe as groupDistinctValues,Kt as headerStyles,N as isBlankCellValue,l as isCellActive,d as isCellEditing,f as isCellInFillPreview,c as isCellSelected,h as isColumnInSelectionRange,m as isRowInSelectionRange,u as isRowVisible,J as isSameDay,W as kWayMerge,it as kWayMergeMultiColumn,Fe as labelsForSelectedValues,M as rawValueKey,Ie as rawValuesForLabels,Zt as rowDragStyles,It as rowPassesFilter,ie as scrollCellIntoView,Yt as scrollbarStyles,_ as setFieldValue,Jt as statesStyles,K as stringToSortableNumber,Q as toPointerEventData,Wt as variablesStyles};
|
|
6
|
+
`)}}getPasteSourceCells(e){let t=this.clipboardSnapshot;return t&&I(t.text)===I(e)?t.cells:ze(e)}applyPasteSource(e,t,n){let r=[],{minRow:i,maxRow:a,minCol:s,maxCol:c}=o(t),l=this.isSingleSourceCell(e),u=l?a:i+e.length-1,d=l?c:s+this.getMaxSourceColumnCount(e)-1,f=n?Math.min(u,a):u,p=n?Math.min(d,c):d,m=this.options.getRowCount(),h=this.options.getColumnCount(),g=Math.min(f,m-1),_=Math.min(p,h-1);for(let t=i;t<=g;t++)for(let n=s;n<=_;n++){let a=this.getSourceCellForTarget(e,t-i,n-s,l);a&&this.applyPasteCell(t,n,a,r)}return r}applyPasteCell(e,t,n,r){let i=this.options.getColumn(t);if(i===void 0||i.hidden===!0||i.editable!==!0)return;let a=Be(n,i);a.ok!==!1&&(this.options.setCellValue(e,t,a.value),r.push({row:e,col:t,value:a.value}))}getSourceCellForTarget(e,t,n,r){return r?e[0]?.[0]??null:e[t]?.[n]??null}isSingleSourceCell(e){return e.length===1&&e[0]?.length===1}getMaxSourceColumnCount(e){return e.reduce((e,t)=>Math.max(e,t.length),0)}},z=class{state=null;options;emitter=v();onInstruction=this.emitter.onInstruction;emit=this.emitter.emit;constructor(e){this.options=e}getState(){return this.state?{...this.state}:null}isActive(){return this.state!==null}startFillDrag(e){this.state={sourceRange:e,targetRow:e.endRow,targetCol:e.endCol},this.emit({type:`START_FILL`,sourceRange:e})}updateFillDrag(e,t){if(!this.state)return;let n=this.options.getRowCount(),r=this.options.getColumnCount();e=Math.max(0,Math.min(e,n-1)),t=Math.max(0,Math.min(t,r-1)),this.state.targetRow=e,this.state.targetCol=t,this.emit({type:`UPDATE_FILL`,targetRow:e,targetCol:t})}commitFillDrag(){if(!this.state)return;let{sourceRange:e,targetRow:t}=this.state,n=this.calculateFilledCells(e,t);for(let{row:e,col:t,value:r}of n)this.options.setCellValue(e,t,r);this.emit({type:`COMMIT_FILL`,filledCells:n}),this.state=null}cancelFillDrag(){this.state&&(this.state=null,this.emit({type:`CANCEL_FILL`}))}destroy(){this.emitter.clearListeners(),this.state=null}calculateFilledCells(e,t){let n=[],{minRow:r,maxRow:i,minCol:a,maxCol:s}=o(e),c=t>i,l=t<r;if(c||l)for(let e=a;e<=s;e++){let a=this.getSourceColumnValues(r,i,e),o=this.detectPattern(a);if(c)for(let r=i+1;r<=t;r++){let t=r-i-1,s=this.applyPattern(o,a,t);n.push({row:r,col:e,value:s})}else if(l)for(let i=r-1;i>=t;i--){let t=r-i-1,s=this.applyPattern(o,a,t,!0);n.push({row:i,col:e,value:s})}}return n}getSourceColumnValues(e,t,n){let r=[];for(let i=e;i<=t;i++)r.push(this.options.getCellValue(i,n));return r}detectPattern(e){if(e.length===0)return{type:`constant`,value:null};if(e.length===1)return{type:`constant`,value:e[0]??null};let t=e.map(e=>typeof e==`number`?e:Number(e));if(t.every(e=>!Number.isNaN(e))){let e=[];for(let n=1;n<t.length;n++)e.push(t[n]-t[n-1]);if(e.every(t=>t===e[0])&&e[0]!==void 0)return{type:`arithmetic`,start:t[0],step:e[0]}}return{type:`repeat`,values:e}}applyPattern(e,t,n,r=!1){switch(e.type){case`constant`:return e.value;case`arithmetic`:{let i=r?-(n+1):n+1;return(r?e.start:e.start+e.step*(t.length-1))+e.step*i}case`repeat`:{let t=e.values.length;if(t===0)return null;if(r){let r=(t-1-n%t+t)%t;return e.values[r]??null}return e.values[n%t]??null}}}},B=class{state={slots:new Map,rowToSlot:new Map,nextSlotId:0};options;emitter=ee();isDestroyed=!1;onInstruction=this.emitter.onInstruction;onBatchInstruction=this.emitter.onBatchInstruction;emit=this.emitter.emit;emitBatch=this.emitter.emitBatch;constructor(e){this.options=e}getSlotForRow(e){return this.state.rowToSlot.get(e)}getSlots(){return this.state.slots}syncSlots(){let e=this.options.getScrollTop(),t=this.options.getRowHeight(),n=this.options.getViewportHeight(),r=this.options.getTotalRows(),i=this.options.getOverscan(),a=n,o=Math.max(0,Math.floor(e/t)-i),s=Math.min(r-1,Math.ceil((e+a)/t)+i);if(r===0||s<o){this.destroyAllSlots();return}let c=new Set;for(let e=o;e<=s;e++)c.add(e);let l=[],u=this.partitionSlots(c),d=0;for(let e of c){let t=this.options.getRowData(e);if(t===void 0)continue;let n=d<u.length?u[d++]:void 0;this.assignSlotToRow(e,t,n,l)}for(let e=d;e<u.length;e++){let t=u[e];this.state.slots.delete(t),l.push({type:`DESTROY_SLOT`,slotId:t})}this.updateSlotPositions(l),this.emitBatch(l)}partitionSlots(e){let t=[];for(let[n,r]of this.state.slots)e.has(r.rowIndex)?e.delete(r.rowIndex):(t.push(n),this.state.rowToSlot.delete(r.rowIndex));return t}assignSlotToRow(e,t,n,r){let i;if(n===void 0)i=`slot-${this.state.nextSlotId++}`,this.state.slots.set(i,{slotId:i,rowIndex:e,rowData:t,translateY:this.getRowTranslateY(e)}),r.push({type:`CREATE_SLOT`,slotId:i});else{i=n;let r=this.state.slots.get(i);r.rowIndex=e,r.rowData=t,r.translateY=this.getRowTranslateY(e)}this.state.rowToSlot.set(e,i),r.push({type:`ASSIGN_SLOT`,slotId:i,rowIndex:e,rowData:t},{type:`MOVE_SLOT`,slotId:i,translateY:this.getRowTranslateY(e)})}updateSlotPositions(e){for(let[t,n]of this.state.slots){let r=this.getRowTranslateY(n.rowIndex);n.translateY!==r&&(n.translateY=r,e.push({type:`MOVE_SLOT`,slotId:t,translateY:r}))}}destroyAllSlots(){let e=[];for(let t of this.state.slots.keys())e.push({type:`DESTROY_SLOT`,slotId:t});this.state.slots.clear(),this.state.rowToSlot.clear(),this.emitBatch(e)}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.state.slots.clear(),this.state.rowToSlot.clear(),this.emitter.clearListeners())}refreshAllSlots(){let e=[],t=this.options.getTotalRows();for(let[n,r]of this.state.slots)if(r.rowIndex>=0&&r.rowIndex<t){let t=this.options.getRowData(r.rowIndex);if(t===void 0)continue;let i=this.getRowTranslateY(r.rowIndex);r.rowData=t,r.translateY=i,e.push({type:`ASSIGN_SLOT`,slotId:n,rowIndex:r.rowIndex,rowData:t},{type:`MOVE_SLOT`,slotId:n,translateY:i})}this.emitBatch(e),this.syncSlots()}updateSlot(e){let t=this.state.rowToSlot.get(e);if(t){let n=this.options.getRowData(e);n&&this.emit({type:`ASSIGN_SLOT`,slotId:t,rowIndex:e,rowData:n})}}getRowTranslateY(e){let t=this.options.getRowHeight(),n=this.options.getScrollRatio(),r=this.options.getScrollTop(),i=e*t;return n>=1?i:i-Math.floor(r/t)*t}getRowTranslateYForIndex(e){return this.getRowTranslateY(e)}getRowsWrapperOffset(){let e=this.options.getScrollRatio(),t=this.options.getScrollTop(),n=this.options.getRowHeight();if(e>=1)return 0;let r=t%n;return t*e-r}},V=class{editState=null;peekState=null;options;emitter=v();onInstruction=this.emitter.onInstruction;emit=this.emitter.emit;constructor(e){this.options=e}getState(){return this.editState?{...this.editState}:null}isEditing(){return this.editState!==null}isEditingCell(e,t){return this.editState!==null&&this.editState.row===e&&this.editState.col===t}startEdit(e,t){if(!this.options.getColumn(t)?.editable)return!1;this.peekState!==null&&this.stopPeek();let n=this.options.getCellValue(e,t);return this.editState={row:e,col:t,initialValue:n,currentValue:n},this.emit({type:`START_EDIT`,row:e,col:t,initialValue:n}),!0}getPeekState(){return this.peekState?{...this.peekState}:null}startPeek(e,t){return this.editState===null?(this.peekState={row:e,col:t},this.emit({type:`START_PEEK`,row:e,col:t}),!0):!1}stopPeek(){this.peekState!==null&&(this.peekState=null,this.emit({type:`STOP_PEEK`}))}updateValue(e){this.editState&&(this.editState.currentValue=e)}commit(){if(!this.editState)return;let{row:e,col:t,currentValue:n}=this.editState;this.options.setCellValue(e,t,n),this.emit({type:`COMMIT_EDIT`,row:e,col:t,value:n}),this.editState=null,this.emit({type:`STOP_EDIT`}),this.options.onCommit?.(e,t,n)}cancel(){this.editState=null,this.emit({type:`STOP_EDIT`})}destroy(){this.emitter.clearListeners(),this.editState=null,this.peekState=null}};const qe=e=>{let{batcher:t}=e,n,r=new A({getRowHeight:e.getRowHeight,getHeaderHeight:e.getHeaderHeight,getTotalRows:e.getTotalRows,getScrollTop:()=>n.getScrollTop(),getViewportHeight:()=>n.getViewportHeight()});n=new Re(()=>r.getScrollRatio());let i=null,a=new R({getRowCount:e.getTotalRows,getColumnCount:()=>e.getColumns().length,getCellValue:e.getCellValue,getRowData:t=>e.getCachedRows().get(t),getColumn:t=>e.getColumns()[t],setCellValue:e.setCellValue});a.onInstruction(e=>{t.emit(e),i?.onSelectionChange()}),e.highlighting&&(i=new C({getActiveCell:()=>a.getActiveCell(),getSelectionRange:()=>a.getSelectionRange(),getColumn:t=>e.getColumns()[t]},e.highlighting),i.onInstruction(e=>t.emit(e)));let o=new z({getRowCount:e.getTotalRows,getColumnCount:()=>e.getColumns().length,getCellValue:e.getCellValue,getColumn:t=>e.getColumns()[t],setCellValue:e.setCellValue});o.onInstruction(e=>t.emit(e));let s=new B({getRowHeight:e.getRowHeight,getHeaderHeight:e.getHeaderHeight,getOverscan:e.getOverscan,getScrollTop:()=>n.getScrollTop(),getViewportHeight:()=>n.getViewportHeight(),getTotalRows:e.getTotalRows,getScrollRatio:()=>r.getScrollRatio(),getVirtualContentHeight:()=>r.getVirtualContentHeight(),getRowData:t=>e.getCachedRows().get(t)});s.onBatchInstruction(e=>t.emitBatch(e));let c=new V({getColumn:t=>e.getColumns()[t],getCellValue:e.getCellValue,setCellValue:e.setCellValue,onCommit:e=>s.updateSlot(e)});c.onInstruction(e=>t.emit(e));let l=new P({getColumns:e.getColumns,isSortingEnabled:e.getSortingEnabled,getCachedRows:e.getCachedRows,onSortFilterChange:async()=>{await e.fetchData(),i?.clearAllCaches(),n.resetScrollTop(),t.start();try{t.emit({type:`SCROLL_TO`,scrollTop:0}),e.emitContentSize(),e.emitHeaders(),s.refreshAllSlots()}finally{t.flush()}},onDataRefreshed:()=>{}});l.onInstruction(e=>t.emit(e));let u=new w({getCachedRows:e.getCachedRows,setCachedRows:e.setCachedRows,getTotalRows:e.getTotalRows,setTotalRows:e.setTotalRows,updateSlot:e=>s.updateSlot(e),refreshAllSlots:()=>s.refreshAllSlots(),emitContentSize:e.emitContentSize,clearSelectionIfInvalid:e.clearSelectionIfInvalid});return u.onInstruction(e=>t.emit(e)),{selection:a,highlight:i,fill:o,scrollVirtualization:r,viewport:n,slotPool:s,editManager:c,sortFilter:l,rowMutation:u}},Je=e=>{let t=e.columnPositions.at(-1)??0;e.scrollVirtualization.updateContentSize(),e.batcher.emit({type:`SET_CONTENT_SIZE`,width:t,height:e.scrollVirtualization.getVirtualHeight(),viewportWidth:e.viewport.getViewportWidth(),viewportHeight:e.viewport.getViewportHeight(),rowsWrapperOffset:e.slotPool.getRowsWrapperOffset()})},Ye=e=>{let t=e.sortFilter.getSortInfoMap();for(let n=0;n<e.columns.length;n++){let r=e.columns[n],i=r.colId??r.field,a=t.get(i);e.batcher.emit({type:`UPDATE_HEADER`,colIndex:n,column:r,sortDirection:a?.direction,sortIndex:a?.index,hasFilter:e.sortFilter.hasActiveFilter(i)})}},Xe=e=>{let t=e.scrollVirtualization.getVisibleRowRange();e.batcher.emit({type:`UPDATE_VISIBLE_RANGE`,start:t.start,end:t.end,rowsWrapperOffset:e.slotPool.getRowsWrapperOffset()})};var Ze=class{columns;rowHeight;headerHeight;overscan;maxFlingVelocity;sortingEnabled;getRowId;onCellValueChanged;rowDragEntireRow;onRowDragEnd;onColumnResized;onColumnMoved;viewport;scrollTopOverride=null;rowData;selection;fill;input;highlight;sortFilter;rowMutation;slotPool;editManager;columnPositions=[];batcher=new Le;scrollVirtualization;isDestroyed=!1;hasWarnedAboutScaledOverscan=!1;constructor(e){if(this.columns=e.columns,this.rowHeight=e.rowHeight,this.headerHeight=e.headerHeight??e.rowHeight,this.overscan=e.overscan??3,this.maxFlingVelocity=e.maxFlingVelocity??2e4*this.rowHeight/1e3,this.sortingEnabled=e.sortingEnabled??!0,this.getRowId=e.getRowId,this.onCellValueChanged=e.onCellValueChanged,this.rowDragEntireRow=e.rowDragEntireRow??!1,this.onRowDragEnd=e.onRowDragEnd,this.onColumnResized=e.onColumnResized,this.onColumnMoved=e.onColumnMoved,this.onCellValueChanged&&!this.getRowId)throw Error(`getRowId is required when onCellValueChanged is provided`);this.computeColumnPositions();let t,n,r;this.rowData=new O({dataSource:e.dataSource,rowLoading:e.rowLoading,batcher:this.batcher,getColumns:()=>this.columns,getSortModel:()=>r.getSortModel(),getFilterModel:()=>r.getFilterModel(),getRowHeight:()=>this.rowHeight,getOverscan:()=>this.overscan,getScrollTop:()=>t.getScrollTop(),getViewportHeight:()=>t.getViewportHeight(),onCellValueChanged:this.onCellValueChanged,getRowId:this.getRowId,syncSlots:()=>n.syncSlots(),emitVisibleRange:()=>this.emitVisibleRange(),emitContentSize:()=>this.emitContentSize()});let i=qe({batcher:this.batcher,highlighting:e.highlighting,getColumns:()=>this.columns,getCachedRows:()=>this.rowData.getCachedRows(),setCachedRows:e=>this.rowData.setCachedRows(e),getTotalRows:()=>this.rowData.getTotalRows(),setTotalRows:e=>this.rowData.setTotalRows(e),getRowHeight:()=>this.rowHeight,getHeaderHeight:()=>this.headerHeight,getOverscan:()=>this.overscan,getSortingEnabled:()=>this.sortingEnabled,getCellValue:(e,t)=>this.getCellValue(e,t),setCellValue:(e,t,n)=>this.setCellValue(e,t,n),emitContentSize:()=>this.emitContentSize(),emitHeaders:()=>this.emitHeaders(),fetchData:()=>this.rowData.loadInitial(),clearSelectionIfInvalid:e=>this.clearSelectionIfInvalid(e)});this.selection=i.selection,this.highlight=i.highlight,this.fill=i.fill,this.scrollVirtualization=i.scrollVirtualization,this.viewport=i.viewport,this.slotPool=i.slotPool,this.editManager=i.editManager,this.sortFilter=i.sortFilter,this.rowMutation=i.rowMutation,t=this.viewport,n=this.slotPool,r=this.sortFilter,this.input=new S(this,{getHeaderHeight:()=>this.headerHeight,getRowHeight:()=>this.rowHeight,getColumnPositions:()=>this.columnPositions,getColumnCount:()=>this.columns.length})}onBatchInstruction(e){return this.batcher.subscribe(e)}async initialize(){await this.rowData.loadInitial(),this.slotPool.syncSlots(),this.emitContentSize(),this.emitHeaders()}setViewport(e,t,n,r){let{changed:i,viewportSizeChanged:a}=this.viewport.update(this.scrollTopOverride??e,t,n,r);i&&(this.rowData.requestVisibleRows(),this.slotPool.syncSlots(),this.emitVisibleRange(),a&&this.emitContentSize())}async setSort(e,t,n=!1){if(!this.rowData.isLoading())return this.sortFilter.setSort(e,t,n)}async setFilter(e,t){if(!this.rowData.isLoading())return this.sortFilter.setFilter(e,t)}hasActiveFilter(e){return this.sortFilter.hasActiveFilter(e)}getDistinctValuesForColumn(e,t=500){return this.sortFilter.getDistinctValuesForColumn(e,t)}openFilterPopup(e,t,n=!0){this.rowData.isLoading()||this.sortFilter.openFilterPopup(e,t,n)}closeFilterPopup(){this.sortFilter.closeFilterPopup()}getSortModel(){return this.sortFilter.getSortModel()}getFilterModel(){return this.sortFilter.getFilterModel()}startEdit(e,t){this.editManager.startEdit(e,t)}startPeek(e,t){let n=this.columns[t];return!n||n.peekable===!1?!1:this.editManager.startPeek(e,t)}stopPeek(){this.editManager.stopPeek()}getPeekState(){return this.editManager.getPeekState()}updateEditValue(e){this.editManager.updateValue(e)}commitEdit(){this.editManager.commit()}cancelEdit(){this.editManager.cancel()}pasteClipboardText(e){if(this.editManager.getState())return!1;let t=this.selection.pasteClipboardText(e);return t.changedCells.length>0&&this.refreshSlotData(),t.handled}getEditState(){return this.editManager.getState()}getCellValue(e,t){return this.rowData.getCellValue(e,t)}setCellValue(e,t,n){this.rowData.setCellValue(e,t,n)}clearSelectionIfInvalid(e){let t=this.selection.getActiveCell();t&&t.row>=e&&this.selection.clearSelection()}computeColumnPositions(){this.columnPositions=ue(this.columns)}emitContentSize(){Je({batcher:this.batcher,scrollVirtualization:this.scrollVirtualization,slotPool:this.slotPool,viewport:this.viewport,columnPositions:this.columnPositions}),this.warnIfOverscanTooLowForScaling()}warnIfOverscanTooLowForScaling(){this.hasWarnedAboutScaledOverscan||this.scrollVirtualization.isScalingActive()!==!1&&(this.hasWarnedAboutScaledOverscan=!0,!(this.overscan>=10)&&console.warn(`[gp-grid] Scroll virtualization is active (${this.rowData.getTotalRows().toLocaleString()} rows) but overscan is ${this.overscan}. Fast momentum scrolling can outrun rendering and show blank rows at this scale — set the overscan option to 10–12.`))}emitHeaders(){Ye({batcher:this.batcher,sortFilter:this.sortFilter,columns:this.columns})}emitVisibleRange(){Xe({batcher:this.batcher,scrollVirtualization:this.scrollVirtualization,slotPool:this.slotPool})}setColumnWidth(e,t){ke(e,t,this.viewport.getViewportWidth(),{batcher:this.batcher,slotPool:this.slotPool,refreshSlots:`sync`,computeColumnPositions:()=>this.computeColumnPositions(),emitContentSize:()=>this.emitContentSize(),emitHeaders:()=>this.emitHeaders(),columns:this.columns,onComplete:()=>this.onColumnResized?.(e,t)})}moveColumn(e,t){let n=Ae(e,t,{batcher:this.batcher,slotPool:this.slotPool,refreshSlots:`all`,computeColumnPositions:()=>this.computeColumnPositions(),emitContentSize:()=>this.emitContentSize(),emitHeaders:()=>this.emitHeaders(),columns:this.columns,onComplete:()=>{}});n!==null&&this.onColumnMoved?.(e,n)}commitRowDrag(e,t){je(e,t,{dataSource:this.rowData.getDataSource(),cachedRows:this.rowData.getCachedRows(),slotPool:this.slotPool,highlight:this.highlight}),this.onRowDragEnd?.(e,t)}isRowDragEntireRow(){return this.rowDragEntireRow}getColumns(){return this.columns}getColumnPositions(){return[...this.columnPositions]}getRowCount(){return this.rowData.getTotalRows()}getRowHeight(){return this.rowHeight}getHeaderHeight(){return this.headerHeight}getTotalWidth(){return this.columnPositions.at(-1)??0}getTotalHeight(){return this.scrollVirtualization.getVirtualHeight()}isScalingActive(){return this.scrollVirtualization.isScalingActive()}getMaxFlingVelocity(){return this.maxFlingVelocity}setScrollTopOverride(e){this.scrollTopOverride=e}getNaturalHeight(){return this.scrollVirtualization.getNaturalHeight()}getScrollRatio(){return this.scrollVirtualization.getScrollRatio()}getVisibleRowRange(){return this.scrollVirtualization.getVisibleRowRange()}getScrollTopForRow(e){return this.scrollVirtualization.getScrollTopForRow(e)}getRowIndexAtDisplayY(e,t){return this.scrollVirtualization.getRowIndexAtDisplayY(e,t)}getRowTranslateY(e){return this.slotPool.getRowTranslateYForIndex(e)}getRowData(e){return this.rowData.getRowData(e)}async refresh(){await this.rowData.loadInitial(),this.highlight?.clearAllCaches(),this.slotPool.refreshAllSlots(),this.emitContentSize(),this.emitVisibleRange()}async refreshFromTransaction(){await this.rowData.refreshFromTransaction(),this.highlight?.clearAllCaches(),this.slotPool.refreshAllSlots(),this.emitContentSize(),this.emitVisibleRange()}refreshSlotData(){this.slotPool.refreshAllSlots()}addRows(e,t){this.rowMutation.addRows(e,t)}updateRows(e){this.rowMutation.updateRows(e)}deleteRows(e){this.rowMutation.deleteRows(e)}getRow(e){return this.rowMutation.getRow(e)}setRow(e,t){this.rowMutation.setRow(e,t)}async setDataSource(e){this.editManager.getState()&&this.editManager.cancel(),this.rowData.setDataSource(e),await this.refresh(),this.clearSelectionIfInvalid(this.rowData.getTotalRows())}setColumns(e){this.columns=e,this.computeColumnPositions(),this.emitContentSize(),this.emitHeaders(),this.slotPool.syncSlots()}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.slotPool.destroy(),this.highlight?.destroy(),this.sortFilter.destroy(),this.rowMutation.destroy(),this.rowData.destroy(),this.batcher.clearListeners())}},Qe=class{workerCode;maxWorkers;workers=[];workerUrl=null;nextRequestId=0;isTerminated=!1;constructor(e,t={}){this.workerCode=e;let n=typeof navigator>`u`?4:navigator.hardwareConcurrency;this.maxWorkers=Math.max(1,t.maxWorkers??n??4),t.preWarm&&this.preWarmWorkers()}getPoolSize(){return this.workers.length}getMaxWorkers(){return this.maxWorkers}isAvailable(){return!this.isTerminated&&typeof Worker<`u`}async execute(e,t){if(this.isTerminated)throw Error(`WorkerPool has been terminated`);if(typeof Worker>`u`)throw TypeError(`Web Workers are not available in this environment`);let n=this.getAvailableWorker(),r=this.nextRequestId++,i={...e,id:r};return new Promise((e,a)=>{n.pendingRequests.set(r,{resolve:e,reject:a}),n.busy=!0,t&&t.length>0?n.worker.postMessage(i,t):n.worker.postMessage(i)})}async executeParallel(e){if(this.isTerminated)throw Error(`WorkerPool has been terminated`);if(e.length===0)return[];let t=Math.min(e.length,this.maxWorkers);this.ensureWorkers(t);let n=e.map((e,t)=>{let n=t%this.workers.length,r=this.workers[n],i=this.nextRequestId++,a={...e.request,id:i};return new Promise((t,n)=>{r.pendingRequests.set(i,{resolve:t,reject:n}),r.busy=!0,e.transferables&&e.transferables.length>0?r.worker.postMessage(a,e.transferables):r.worker.postMessage(a)})});return Promise.all(n)}terminate(){for(let e of this.workers){e.worker.terminate();for(let[,t]of e.pendingRequests)t.reject(Error(`Worker pool terminated`));e.pendingRequests.clear()}this.workers=[],this.workerUrl&&=(URL.revokeObjectURL(this.workerUrl),null),this.isTerminated=!0}preWarmWorkers(){this.ensureWorkers(this.maxWorkers)}ensureWorkers(e){let t=Math.min(e,this.maxWorkers)-this.workers.length;for(let e=0;e<t;e++)this.createWorker()}getAvailableWorker(){return this.workers.find(e=>!e.busy)||(this.workers.length<this.maxWorkers?this.createWorker():this.workers.reduce((e,t)=>t.pendingRequests.size<e.pendingRequests.size?t:e,this.workers[0]))}createWorker(){if(!this.workerUrl){let e=new Blob([this.workerCode],{type:`application/javascript`});this.workerUrl=URL.createObjectURL(e)}let e=new Worker(this.workerUrl),t={worker:e,busy:!1,pendingRequests:new Map};return e.onmessage=e=>{let{id:n}=e.data,r=t.pendingRequests.get(n);r&&(t.pendingRequests.delete(n),t.pendingRequests.size===0&&(t.busy=!1),e.data.type===`error`?r.reject(Error(e.data.error)):r.resolve(e.data))},e.onerror=e=>{for(let[,n]of t.pendingRequests)n.reject(Error(`Worker error: ${e.message}`));t.pendingRequests.clear(),t.busy=!1,this.respawnWorker(t)},this.workers.push(t),t}respawnWorker(e){let t=this.workers.indexOf(e);if(t!==-1){try{e.worker.terminate()}catch{}this.workers.splice(t,1),this.workers.length<this.maxWorkers&&!this.isTerminated&&this.createWorker()}}},$e=class{heap=[];compare;constructor(e){this.compare=e}push(e){this.heap.push(e),this.bubbleUp(this.heap.length-1)}pop(){if(this.heap.length===0)return;let e=this.heap[0],t=this.heap.pop();return this.heap.length>0&&t&&(this.heap[0]=t,this.bubbleDown(0)),e}size(){return this.heap.length}bubbleUp(e){for(;e>0;){let t=Math.floor((e-1)/2);if(this.compare(this.heap[e],this.heap[t])>=0)break;this.swap(e,t),e=t}}bubbleDown(e){let t=this.heap.length;for(;;){let n=2*e+1,r=2*e+2,i=e;if(n<t&&this.compare(this.heap[n],this.heap[i])<0&&(i=n),r<t&&this.compare(this.heap[r],this.heap[i])<0&&(i=r),i===e)break;this.swap(e,i),e=i}}swap(e,t){let n=this.heap[e];this.heap[e]=this.heap[t],this.heap[t]=n}};const et=(e,t,n)=>{let r=[];for(let i=0;i<n;i++)r.push(e.columns[i][t]);return r};function H(e,t){if(e.length===0)return new Uint32Array;if(e.length===1){let t=e[0],n=new Uint32Array(t.indices.length);for(let e=0;e<t.indices.length;e++)n[e]=t.indices[e]+t.offset;return n}let n=0;for(let t of e)n+=t.indices.length;let r=new Uint32Array(n),i=t===`asc`?1:-1,a=new $e((e,t)=>{let n=(e.value-t.value)*i;return n===0?e.globalIndex-t.globalIndex:n});for(let t=0;t<e.length;t++){let n=e[t];if(n.indices.length>0){let e=n.indices[0];a.push({chunkIndex:t,positionInChunk:0,value:n.values[0],globalIndex:e+n.offset})}}let o=0;for(;a.size()>0;){let t=a.pop();r[o++]=t.globalIndex;let n=e[t.chunkIndex],i=t.positionInChunk+1;if(i<n.indices.length){let e=n.indices[i];a.push({chunkIndex:t.chunkIndex,positionInChunk:i,value:n.values[i],globalIndex:e+n.offset})}}return r}function U(e){if(e.length===0)return new Uint32Array;if(e.length===1){let t=e[0],n=new Uint32Array(t.indices.length);for(let e=0;e<t.indices.length;e++)n[e]=t.indices[e]+t.offset;return n}let t=e[0].directions,n=t.length,r=0;for(let t of e)r+=t.indices.length;let i=new Uint32Array(r),a=new $e((e,n)=>{for(let r=0;r<t.length;r++){let i=(e.values[r]-n.values[r])*t[r];if(i!==0)return i}return e.globalIndex-n.globalIndex});for(let t=0;t<e.length;t++){let r=e[t];if(r.indices.length>0){let e=r.indices[0];a.push({chunkIndex:t,positionInChunk:0,values:et(r,0,n),globalIndex:e+r.offset})}}let o=0;for(;a.size()>0;){let t=a.pop();i[o++]=t.globalIndex;let r=e[t.chunkIndex],s=t.positionInChunk+1;if(s<r.indices.length){let e=r.indices[s];a.push({chunkIndex:t.chunkIndex,positionInChunk:s,values:et(r,s,n),globalIndex:e+r.offset})}}return i}function tt(e,t){if(e.length<=1)return new Uint32Array;let n=[],r=0;for(let t=0;t<e.length-1;t++){let i=e[t],a=e[t+1];if(i.indices.length===0||a.indices.length===0){r+=i.indices.length;continue}let o=i.indices.length-1,s=i.values[o],c=a.values[0];if(s===c){let e=o;for(;e>0&&i.values[e-1]===s;)e--;let t=0;for(;t<a.indices.length-1&&a.values[t+1]===c;)t++;let l=r+e,u=r+i.indices.length+t+1;n.push(l,u)}r+=i.indices.length}return new Uint32Array(n)}const nt=(e,t,n)=>{let r=Math.max(n,Math.ceil(e/t)),i=[];for(let t=0;t<e;t+=r)i.push({offset:t,length:Math.min(r,e-t)});return i},rt=e=>{if(e.length<=1)return[];let t=[],n=0;for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1];if(i.indices.length===0||a.indices.length===0){n+=i.indices.length;continue}let o=i.values[i.indices.length-1],s=a.values[0];if(o===s){let e=i.indices.length-1;for(;e>0&&i.values[e-1]===o;)e--;let r=0;for(;r<a.indices.length-1&&a.values[r+1]===s;)r++;t.push(n+e,n+i.indices.length+r+1)}n+=i.indices.length}return t},it=(e,t,n,r)=>{let i=r===`asc`?1:-1;for(let r=0;r<t.length;r+=2){let a=t[r],o=t[r+1];o<=a||o>e.length||at(e,a,o,n,i)}},at=(e,t,n,r,i)=>{let a=Array.from(e.slice(t,n));if(!ot(a,r)){a.sort((e,t)=>i*r[e].localeCompare(r[t]));for(let n=0;n<a.length;n++)e[t+n]=a[n]}},ot=(e,t)=>{let n=t[e[0]];for(let r=1;r<e.length;r++)if(t[e[r]]!==n)return!1;return!0};var W=class{pool;parallelThreshold;minChunkSize;isTerminated=!1;constructor(e={}){let t=e.maxWorkers??(navigator===void 0?4:navigator.hardwareConcurrency)??4;this.pool=new Qe("(function(){let e=(e,t)=>{let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return null;n=n[e]}return n??null},t=e=>e==null?``:Array.isArray(e)?e.join(`, `):typeof e==`object`&&!(e instanceof Date)?JSON.stringify(e):String(e),n=(e,n)=>{if(e==null&&n==null)return 0;if(e==null)return 1;if(n==null)return-1;let r=Number(e),i=Number(n);return!Number.isNaN(r)&&!Number.isNaN(i)?r-i:e instanceof Date&&n instanceof Date?e.getTime()-n.getTime():t(e).localeCompare(t(n))},r=(t,r)=>[...t].sort((t,i)=>{for(let{colId:a,direction:o}of r){let r=n(e(t,a),e(i,a));if(r!==0)return o===`asc`?r:-r}return 0}),i=e=>{let t=new Uint32Array(e);for(let n=0;n<e;n++)t[n]=n;return t},a=(e,t)=>{let n=new Float64Array(t.length);for(let r=0;r<t.length;r++)n[r]=e[t[r]];return n},o=(e,t,n)=>e.some(e=>e[t]!==e[n]),s=(e,t)=>{let n=e.length,r=[],i=0;for(let a=1;a<=n;a++)(a===n||o(t,e[a-1],e[a]))&&(a-i>1&&r.push(i,a),i=a);return new Uint32Array(r)},c=(e,t)=>{let n=i(e.length),r=t===`asc`?1:-1;return n.sort((t,n)=>{let i=e[t],a=e[n];return i<a?-1*r:i>a?1*r:t-n}),n},l=(e,t)=>{let n=e.length,r=i(e[0].length);return r.sort((r,i)=>{for(let a=0;a<n;a++){let n=e[a][r],o=e[a][i];if(n<o)return-1*t[a];if(n>o)return 1*t[a]}return r-i}),r},u=(e,t)=>{let n=e.length,r=i(e[0].length),a=t===`asc`?1:-1;return r.sort((t,r)=>{for(let i=0;i<n;i++){let n=e[i][t],o=e[i][r];if(n<o)return-1*a;if(n>o)return 1*a}return t-r}),{indices:r,collisionRuns:s(r,e)}},d={sort:e=>({type:`sorted`,payload:{data:r(e.data,e.sortModel)},transfer:[]}),sortIndices:e=>{let t=c(e.values,e.direction);return{type:`sortedIndices`,payload:{indices:t},transfer:[t.buffer]}},sortMultiColumn:e=>{let t=l(e.columns,e.directions);return{type:`sortedMultiColumn`,payload:{indices:t},transfer:[t.buffer]}},sortStringHashes:e=>{let t=u(e.hashChunks,e.direction);return{type:`sortedStringHashes`,payload:{indices:t.indices,collisionRuns:t.collisionRuns},transfer:[t.indices.buffer,t.collisionRuns.buffer]}},sortChunk:e=>{let t=c(e.values,e.direction),n=a(e.values,t);return{type:`sortedChunk`,payload:{indices:t,sortedValues:n,chunkOffset:e.chunkOffset},transfer:[t.buffer,n.buffer]}},sortStringChunk:e=>{let t=u(e.hashChunks,e.direction),n=a(e.hashChunks[0],t.indices);return{type:`sortedStringChunk`,payload:{indices:t.indices,sortedHashes:n,collisionRuns:t.collisionRuns,chunkOffset:e.chunkOffset},transfer:[t.indices.buffer,n.buffer,t.collisionRuns.buffer]}},sortMultiColumnChunk:e=>{let t=l(e.columns,e.directions),n=e.columns.map(e=>a(e,t));return{type:`sortedMultiColumnChunk`,payload:{indices:t,sortedColumns:n,chunkOffset:e.chunkOffset},transfer:[t.buffer,...n.map(e=>e.buffer)]}}},f=self;f.onmessage=e=>{let t=e.data,n=d[t.type];if(n)try{let e=n(t);f.postMessage({type:e.type,id:t.id,...e.payload},e.transfer)}catch(e){f.postMessage({type:`error`,id:t.id,error:String(e)})}}})();",{maxWorkers:t}),this.parallelThreshold=e.parallelThreshold??4e5,this.minChunkSize=e.minChunkSize??5e4}isAvailable(){return!this.isTerminated&&this.pool.isAvailable()}terminate(){this.pool.terminate(),this.isTerminated=!0}async sortIndices(e,t){return this.assertNotTerminated(),e.length<this.parallelThreshold?this.sortIndicesSingle(e,t):this.sortIndicesParallel(e,t)}async sortStringHashes(e,t,n){return this.assertNotTerminated(),(e[0]?.length??0)<this.parallelThreshold?this.sortStringHashesSingle(e,t,n):this.sortStringHashesParallel(e,t,n)}async sortMultiColumn(e,t){return this.assertNotTerminated(),(e[0]?.length??0)<this.parallelThreshold?this.sortMultiColumnSingle(e,t):this.sortMultiColumnParallel(e,t)}assertNotTerminated(){if(this.isTerminated)throw Error(`ParallelSortManager has been terminated`)}async sortIndicesSingle(e,t){let n=new Float64Array(e),r={type:`sortIndices`,id:0,values:n,direction:t};return(await this.pool.execute(r,[n.buffer])).indices}async sortStringHashesSingle(e,t,n){let r={type:`sortStringHashes`,id:0,hashChunks:e,direction:t},i=e.map(e=>e.buffer),a=await this.pool.execute(r,i);return a.collisionRuns.length>0&&it(a.indices,a.collisionRuns,n,t),a.indices}async sortMultiColumnSingle(e,t){let n=e.map(e=>new Float64Array(e)),r=new Int8Array(t.map(e=>e===`asc`?1:-1)),i={type:`sortMultiColumn`,id:0,columns:n,directions:r},a=[...n.map(e=>e.buffer),r.buffer];return(await this.pool.execute(i,a)).indices}boundariesFor(e){return nt(e,this.pool.getMaxWorkers(),this.minChunkSize)}async runChunks(e){let t=await this.pool.executeParallel(e);return t.sort((e,t)=>e.chunkOffset-t.chunkOffset),t}async sortIndicesParallel(e,t){let n=this.boundariesFor(e.length).map(n=>{let r=new Float64Array(e.slice(n.offset,n.offset+n.length));return{request:{type:`sortChunk`,id:0,values:r,direction:t,chunkOffset:n.offset},transferables:[r.buffer]}});return H((await this.runChunks(n)).map(e=>({indices:e.indices,values:e.sortedValues,offset:e.chunkOffset})),t)}async sortStringHashesParallel(e,t,n){let r=this.boundariesFor(e[0].length).map(n=>{let r=e.map(e=>{let t=new Float64Array(n.length);return t.set(new Float64Array(e.buffer,n.offset*8,n.length)),t});return{request:{type:`sortStringChunk`,id:0,hashChunks:r,direction:t,chunkOffset:n.offset},transferables:r.map(e=>e.buffer)}}),i=await this.runChunks(r),a=i.map(e=>({indices:e.indices,values:e.sortedHashes,offset:e.chunkOffset})),o=st(i),s=H(a,t),c=rt(a),l=new Uint32Array([...o,...c]);return l.length>0&&it(s,l,n,t),s}async sortMultiColumnParallel(e,t){let n=this.boundariesFor(e[0].length),r=new Int8Array(t.map(e=>e===`asc`?1:-1)),i=n.map(t=>{let n=e.map(e=>{let n=new Float64Array(t.length);for(let r=0;r<t.length;r++)n[r]=e[t.offset+r];return n}),i=new Int8Array(r);return{request:{type:`sortMultiColumnChunk`,id:0,columns:n,directions:i,chunkOffset:t.offset},transferables:[...n.map(e=>e.buffer),i.buffer]}});return U((await this.runChunks(i)).map(e=>({indices:e.indices,columns:e.sortedColumns,directions:r,offset:e.chunkOffset})))}};const st=e=>{let t=[];for(let n of e)for(let e=0;e<n.collisionRuns.length;e+=2)t.push(n.collisionRuns[e]+n.chunkOffset,n.collisionRuns[e+1]+n.chunkOffset);return t};function G(e){let t=e.toLowerCase(),n=Math.min(t.length,10),r=0;for(let e=0;e<n;e++){let n=t.codePointAt(e)??200,i;i=n>=97&&n<=122?n-97:n>=48&&n<=57?n-48+26:0,r=r*36+i}for(let e=n;e<10;e++)r*=36;return r}function K(e,t){let n=e==null||Array.isArray(e)&&e.length===0,r=t==null||Array.isArray(t)&&t.length===0;if(n&&r)return 0;if(n)return 1;if(r)return-1;if(Array.isArray(e)||Array.isArray(t)){let n=Array.isArray(e)?e.join(`, `):y(e),r=Array.isArray(t)?t.join(`, `):y(t);return n.localeCompare(r)}let i=Number(e),a=Number(t);return!Number.isNaN(i)&&!Number.isNaN(a)?i-a:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():y(e).localeCompare(y(t))}function ct(e){if(e==null)return Number.MAX_VALUE;if(typeof e==`number`)return e;if(e instanceof Date)return e.getTime();if(typeof e==`string`)return G(e);if(Array.isArray(e))return e.length===0?Number.MAX_VALUE:G(e.join(`, `));if(typeof e==`object`)return G(JSON.stringify(e));let t=Number(e);return Number.isNaN(t)?0:t}function lt(e,t){let n=[];for(let r of t.sortModel){let i=ct(t.getFieldValue(e,r.colId));n.push(i)}return n}function ut(e,t,n){if(!e||!t)return null;for(let r=0;r<n.length;r++){let i=e[r]-t[r];if(i!==0)return n[r].direction===`asc`?i:-i}return 0}function dt(e,t,n,r){for(let{colId:i,direction:a}of n){let n=K(r(e,i),r(t,i));if(n!==0)return a===`asc`?n:-n}return 0}function ft(e){let t=e.toLowerCase(),n=[];for(let e=0;e<3;e++){let r=e*10,i=0;for(let e=0;e<10;e++){let n=r+e,a=n<t.length?t.codePointAt(n)??200:0,o;o=a>=97&&a<=122?a-97:a>=48&&a<=57?a-48+26:0,i=i*36+o}n.push(i)}return n}function pt(e){if(e==null)return Number.MAX_VALUE;if(Array.isArray(e))return e.length===0?Number.MAX_VALUE:G(e.join(`, `));if(typeof e==`number`)return e;if(e instanceof Date)return e.getTime();if(typeof e==`string`)return G(e);if(typeof e==`object`)return G(JSON.stringify(e));let t=Number(e);return Number.isNaN(t)?0:t}function mt(e,t,n){return[...e].sort((e,r)=>{for(let{colId:i,direction:a}of t){let t=K(n(e,i),n(r,i));if(t!==0)return a===`asc`?t:-t}return 0})}const ht=(e,t,n)=>{for(let r of e){let e=n(r,t);if(e!=null)return typeof e==`string`||Array.isArray(e)||typeof e==`object`&&!(e instanceof Date)?`string`:`numeric`}return`numeric`},gt=(e,t,n)=>{let r=[],i=Array.from({length:3},()=>[]);for(let a of e){let e=y(n(a,t));r.push(e);let o=ft(e);for(let e=0;e<3;e++)i[e].push(o[e])}return{originalStrings:r,hashChunkArrays:i.map(e=>new Float64Array(e))}},_t=(e,t,n)=>e.map(e=>pt(n(e,t))),vt=(e,t,n)=>{let r=[],i=[];for(let{colId:a,direction:o}of t)r.push(e.map(e=>pt(n(e,a)))),i.push(o??`asc`);return{columnValues:r,directions:i}},yt=(e,t)=>{let n=Array(e.length);for(let r=0;r<t.length;r++)n[r]=e[t[r]];return n},bt=async(e,t,n,r)=>{let{colId:i,direction:a}=t,o=a??`asc`;if(ht(e,i,r)===`string`){let{originalStrings:t,hashChunkArrays:a}=gt(e,i,r);return n.sortStringHashes(a,o,t)}let s=_t(e,i,r);return n.sortIndices(s,o)},xt=async(e,t,n,r)=>{let{columnValues:i,directions:a}=vt(e,t,r);return n.sortMultiColumn(i,a)},St=async(e,t,n,r)=>{let i=t.length===1?await bt(e,t[0],n,r):await xt(e,t,n,r);return yt(e,i)};function q(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}const Ct={contains:(e,t)=>e.includes(t),notContains:(e,t)=>!e.includes(t),equals:(e,t)=>e===t,notEquals:(e,t)=>e!==t,startsWith:(e,t)=>e.startsWith(t),endsWith:(e,t)=>e.endsWith(t),blank:(e,t,n)=>n,notBlank:(e,t,n)=>!n},wt=new WeakMap,Tt=e=>{let t=wt.get(e);if(t?.size===e.size)return t.keys;let n=new Set;for(let t of e)n.add(M(t));return wt.set(e,{size:e.size,keys:n}),n};function Et(e,t,n){let r=N(e);if(t.selectedValues!==void 0)return r?t.includeBlank===!0:Tt(t.selectedValues).has(M(e));let i=y(e,n).toLowerCase(),a=String(t.value??``).toLowerCase();return Ct[t.operator](i,a,r)}const Dt={"=":(e,t)=>e===t,"!=":(e,t)=>e!==t,">":(e,t)=>e>t,"<":(e,t)=>e<t,">=":(e,t)=>e>=t,"<=":(e,t)=>e<=t,between:(e,t,n)=>e>=t&&e<=n};function Ot(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=typeof e==`number`?e:Number(e);if(Number.isNaN(r))return!1;let i=t.value??0,a=t.valueTo??0;return Dt[t.operator](r,i,a)}const kt={"=":(e,t)=>q(e,t),"!=":(e,t)=>!q(e,t),">":(e,t)=>e.getTime()>t.getTime(),"<":(e,t)=>e.getTime()<t.getTime(),between:(e,t,n)=>{let r=e.getTime();return r>=t.getTime()&&r<=n.getTime()}};function At(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=e instanceof Date?e:new Date(y(e));if(Number.isNaN(r.getTime()))return!1;let i=t.value instanceof Date?t.value:new Date(String(t.value??``)),a=t.valueTo instanceof Date?t.valueTo:new Date(String(t.valueTo??``));return kt[t.operator](r,i,a)}function jt(e,t,n){switch(t.type){case`text`:return Et(e,t,n);case`number`:return Ot(e,t);case`date`:return At(e,t);default:return!0}}function J(e,t,n){if(!t.conditions||t.conditions.length===0)return!0;let r=t.conditions[0];if(!r)return!0;let i=jt(e,r,n);for(let r=1;r<t.conditions.length;r++){let a=t.conditions[r-1],o=t.conditions[r],s=a.nextOperator??t.combination,c=jt(e,o,n);s===`and`?i&&=c:i||=c}return i}function Mt(e,t,n,r){let i=Object.entries(t).filter(([,e])=>e!=null);if(i.length===0)return!0;for(let[t,a]of i){let i=n(e,t),o=r?.(t);if(!J(i,a,o))return!1}return!0}function Nt(e,t,n,r){let i=Object.entries(t).filter(([,e])=>typeof e==`string`?e.trim()!==``:e.conditions&&e.conditions.length>0);return i.length===0?e:e.filter(e=>{for(let[t,a]of i){let i=n(e,t),o=r?.(t);if(typeof a==`string`){if(!y(i,o).toLowerCase().includes(a.toLowerCase()))return!1;continue}if(!J(i,a,o))return!1}return!0})}function Y(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r}function Pt(e,t={}){let{getFieldValue:n=Y,getValueFormatter:r,useWorker:i=!0,parallelSort:a}=t,o=e,s=!1,c=i?new W(a===!1?{maxWorkers:1}:a):null;return{loadMode:`all`,async query(e){let t=o?[...o]:[];if(e.filter&&Object.keys(e.filter).length>0){let i=e.valueFormatters===null?r:t=>e.valueFormatters?.[t];t=Nt(t,e.filter,n,i)}e.sort&&e.sort.length>0&&(t=c&&c.isAvailable()&&t.length>=2e5?await St(t,e.sort,c,n):mt(t,e.sort,n));let i=t.length;return{rows:t.slice(e.range.startRow,e.range.endRow),totalRows:i}},destroy(){s||(s=!0,o=null,c&&c.terminate())},moveRow(e,t){if(!o||e===t||e<0||e>=o.length||t<0||t>=o.length)return;let[n]=o.splice(e,1),r=t>e?t-1:t;o.splice(r,0,n)}}}function X(e){return Pt(e)}function Ft(e,t={}){return{loadMode:t.loadMode??`paginated`,async query(t){return e(t)}}}var It=class{rows=[];rowById=new Map;sortedIndices=[];sortModel=[];sortModelHash=``;filterModel={};filteredIndices=new Set;distinctValues=new Map;rowSortCache=new Map;options;constructor(e,t=[]){this.options={getRowId:e.getRowId,getFieldValue:e.getFieldValue??g,getValueFormatter:e.getValueFormatter??(()=>void 0)},this.setData(t)}clear(){this.rows=[],this.rowById.clear(),this.sortedIndices=[],this.filterModel={},this.filteredIndices.clear(),this.rowSortCache.clear(),this.distinctValues.clear(),this.sortModel=[],this.sortModelHash=``}setData(e){this.rows=[...e],this.rowById.clear(),this.rowSortCache.clear(),this.distinctValues.clear();for(let e=0;e<this.rows.length;e++){let t=this.rows[e],n=this.options.getRowId(t);this.rowById.set(n,e)}this.rebuildSortedIndices(),this.rebuildFilteredIndices(),this.rebuildDistinctValues()}query(e){this.setSortModel(e.sort??[]),this.setFilterModel(e.filter??{});let t=this.getVisibleIndices(),n=t.length,r=e.range.startRow,i=Math.min(e.range.endRow,n),a=[];for(let e=r;e<i;e++){let n=t[e];n!==void 0&&a.push(this.rows[n])}return{rows:a,totalRows:n}}getRowById(e){let t=this.rowById.get(e);return t===void 0?void 0:this.rows[t]}getRowByIndex(e){return this.rows[e]}getTotalRowCount(){return this.rows.length}getAllRows(){return[...this.rows]}moveRow(e,t){if(e===t||e<0||e>=this.rows.length||t<0||t>=this.rows.length)return;let[n]=this.rows.splice(e,1),r=t>e?t-1:t;this.rows.splice(r,0,n),this.rowById.clear();for(let e=0;e<this.rows.length;e++)this.rowById.set(this.options.getRowId(this.rows[e]),e);this.sortedIndices=Array.from({length:this.rows.length},(e,t)=>t),this.rowSortCache.clear()}getVisibleRowCount(){return Object.keys(this.filterModel).length===0?this.rows.length:this.filteredIndices.size}getDistinctValues(e){let t=this.distinctValues.get(e);return t?Array.from(t.keys()):[]}addRows(e){for(let t of e)this.addRow(t)}addRow(e){let t=this.options.getRowId(e);if(this.rowById.has(t)){console.warn(`Row with ID ${t} already exists. Skipping.`);return}let n=this.rows.length;if(this.rows.push(e),this.rowById.set(t,n),this.updateDistinctValuesForRow(e,`add`),this.sortModel.length>0&&this.computeRowHashes(n,e),this.sortModel.length>0){let e=this.binarySearchInsertPosition(n);this.sortedIndices.splice(e,0,n)}else this.sortedIndices.push(n);this.rowPassesFilter(e)&&this.filteredIndices.add(n)}removeRows(e){let t=[];for(let n of e){let e=this.rowById.get(n);e!==void 0&&t.push(e)}if(t.length===0)return 0;t.sort((e,t)=>t-e);for(let e of t)this.removeRowByIndex(e);return t.length}removeRowByIndex(e){let t=this.rows[e];if(!t)return;let n=this.options.getRowId(t);this.updateDistinctValuesForRow(t,`remove`);let r=this.sortedIndices.indexOf(e);r!==-1&&this.sortedIndices.splice(r,1),this.filteredIndices.delete(e),this.rowSortCache.delete(e),this.rowById.delete(n),this.rows.splice(e,1),this.reindexAfterRemoval(e)}reindexAfterRemoval(e){for(let[t,n]of this.rowById.entries())n>e&&this.rowById.set(t,n-1);for(let t=0;t<this.sortedIndices.length;t++)this.sortedIndices[t]>e&&this.sortedIndices[t]--;let t=new Set;for(let n of this.filteredIndices)n>e?t.add(n-1):t.add(n);this.filteredIndices=t;let n=new Map;for(let[t,r]of this.rowSortCache)t>e?n.set(t-1,r):n.set(t,r);this.rowSortCache=n}updateCell(e,t,n){let r=this.rowById.get(e);if(r===void 0){console.warn(`Row with ID ${e} not found.`);return}let i=this.rows[r],a=this.options.getFieldValue(i,t);if(_(i,t,n),this.updateDistinctValueForField(t,a,n),this.sortModel.some(e=>e.colId===t)&&this.sortModel.length>0){this.computeRowHashes(r,i);let e=this.sortedIndices.indexOf(r);e!==-1&&this.sortedIndices.splice(e,1);let t=this.binarySearchInsertPosition(r);this.sortedIndices.splice(t,0,r)}t in this.filterModel&&(this.rowPassesFilter(i)?this.filteredIndices.add(r):this.filteredIndices.delete(r))}updateRow(e,t){for(let[n,r]of Object.entries(t))this.updateCell(e,n,r)}setSortModel(e){let t=JSON.stringify(e);t!==this.sortModelHash&&(this.sortModelHash=t,this.sortModel=[...e],this.rebuildHashCache(),this.rebuildSortedIndices())}getSortModel(){return[...this.sortModel]}setFilterModel(e){JSON.stringify(e)!==JSON.stringify(this.filterModel)&&(this.filterModel={...e},this.rebuildFilteredIndices())}getFilterModel(){return{...this.filterModel}}rebuildSortedIndices(){this.sortedIndices=Array.from({length:this.rows.length},(e,t)=>t),this.sortModel.length!==0&&this.sortedIndices.sort((e,t)=>this.compareRows(e,t))}rebuildHashCache(){if(this.rowSortCache.clear(),this.sortModel.length!==0)for(let e=0;e<this.rows.length;e++)this.computeRowHashes(e,this.rows[e])}computeRowHashes(e,t){if(this.sortModel.length===0)return;let n=lt(t,{sortModel:this.sortModel,sortModelHash:this.sortModelHash,getFieldValue:this.options.getFieldValue}),r=this.rowSortCache.get(e);r||(r={hashes:new Map},this.rowSortCache.set(e,r)),r.hashes.set(this.sortModelHash,n)}compareRows(e,t){let n=this.rowSortCache.get(e),r=this.rowSortCache.get(t),i=n?.hashes.get(this.sortModelHash),a=r?.hashes.get(this.sortModelHash),o=ut(i,a,this.sortModel);return o===null?dt(this.rows[e],this.rows[t],this.sortModel,this.options.getFieldValue):o}binarySearchInsertPosition(e){let t=0,n=this.sortedIndices.length;for(;t<n;){let r=t+n>>>1,i=this.sortedIndices[r];this.compareRows(e,i)>0?t=r+1:n=r}return t}rebuildFilteredIndices(){if(this.filteredIndices.clear(),Object.entries(this.filterModel).some(([,e])=>e!=null))for(let e=0;e<this.rows.length;e++)this.rowPassesFilter(this.rows[e])&&this.filteredIndices.add(e)}rowPassesFilter(e){return Mt(e,this.filterModel,this.options.getFieldValue,this.options.getValueFormatter)}getVisibleIndices(){return Object.entries(this.filterModel).some(([,e])=>e!=null)?this.sortedIndices.filter(e=>this.filteredIndices.has(e)):this.sortedIndices}rebuildDistinctValues(){this.distinctValues.clear();for(let e of this.rows)this.updateDistinctValuesForRow(e,`add`)}updateDistinctValuesForRow(e,t){if(!(typeof e!=`object`||!e))for(let[n,r]of Object.entries(e))r!=null&&(t===`add`?this.addToDistinctValues(n,r):this.decrementDistinctValues(n,r))}updateDistinctValueForField(e,t,n){t!=null&&this.decrementDistinctValues(e,t),n!=null&&this.addToDistinctValues(e,n)}addToDistinctValues(e,t){let n=this.distinctValues.get(e);if(n||(n=new Map,this.distinctValues.set(e,n)),Array.isArray(t)){for(let e of t)e!=null&&Lt(n,e);return}Lt(n,t)}decrementDistinctValues(e,t){let n=this.distinctValues.get(e);if(n!==void 0){if(Array.isArray(t)){for(let e of t)e!=null&&Rt(n,e);return}Rt(n,t)}}};const Lt=(e,t)=>{e.set(t,(e.get(t)??0)+1)},Rt=(e,t)=>{let n=e.get(t);if(n!==void 0){if(n<=1){e.delete(t);return}e.set(t,n-1)}};function zt(e,t){let{getRowId:n,getFieldValue:r,getValueFormatter:i,debounceMs:a=50,onTransactionProcessed:o,useWorker:s=!0,parallelSort:c}=t,l=new It({getRowId:n,getFieldValue:r??Y,getValueFormatter:i},e),u=new Set,d=v().emit,f=s&&c!==!1?new W(c):null,p=new F({debounceMs:a,store:l,onProcessed:e=>{o?.(e);for(let t of u)t(e)}});return{loadMode:`all`,async query(e){if(p.hasPending()){d({type:`DATA_LOADING`});try{await p.flush()}finally{d({type:`DATA_LOADED`,totalRows:l.getTotalRowCount()})}}let t=l.getAllRows(),n=r??Y;if(e.filter&&Object.keys(e.filter).length>0){let r=e.valueFormatters===null?i:t=>e.valueFormatters?.[t];t=Nt(t,e.filter,n,r)}if(e.sort&&e.sort.length>0)if(f&&f.isAvailable()&&t.length>=2e5){d({type:`DATA_LOADING`});try{t=await St(t,e.sort,f,n)}finally{d({type:`DATA_LOADED`,totalRows:t.length})}}else t=mt(t,e.sort,n);let a=t.length;return{rows:t.slice(e.range.startRow,e.range.endRow),totalRows:a}},addRows(e){p.add(e)},removeRows(e){p.remove(e)},updateCell(e,t,n){p.updateCell(e,t,n)},updateRow(e,t){p.updateRow(e,t)},async flushTransactions(){await p.flush()},hasPendingTransactions(){return p.hasPending()},getDistinctValues(e){return l.getDistinctValues(e)},getRowById(e){return l.getRowById(e)},getTotalRowCount(){return l.getTotalRowCount()},subscribe(e){return u.add(e),()=>{u.delete(e)}},clear(){let e=l.getTotalRowCount();l.clear();let t={added:0,removed:e,updated:0};o?.(t);for(let e of u)e(t)},moveRow(e,t){l.moveRow(e,t)}}}const Bt=e=>({slots:new Map,activeCell:null,selectionRange:null,editingCell:null,peekCell:null,contentWidth:0,contentHeight:e?.initialHeight??0,viewportWidth:e?.initialWidth??0,viewportHeight:e?.initialHeight??0,rowsWrapperOffset:0,headers:new Map,filterPopup:null,isLoading:!1,error:null,totalRows:0,visibleRowRange:null,hoverPosition:null,columns:null,pendingScrollTop:null}),Vt=(e,t,n)=>{switch(e.type){case`CREATE_SLOT`:return t.set(e.slotId,{slotId:e.slotId,rowIndex:-1,rowData:{},translateY:0}),null;case`DESTROY_SLOT`:return t.delete(e.slotId),null;case`ASSIGN_SLOT`:{let n=t.get(e.slotId);return n&&t.set(e.slotId,{...n,rowIndex:e.rowIndex,rowData:e.rowData}),null}case`MOVE_SLOT`:{let n=t.get(e.slotId);return n&&t.set(e.slotId,{...n,translateY:e.translateY}),null}case`SCROLL_TO`:return{pendingScrollTop:e.scrollTop};case`SET_ACTIVE_CELL`:return{activeCell:e.position};case`SET_SELECTION_RANGE`:return{selectionRange:e.range};case`UPDATE_VISIBLE_RANGE`:return{visibleRowRange:{start:e.start,end:e.end},rowsWrapperOffset:e.rowsWrapperOffset};case`SET_HOVER_POSITION`:return{hoverPosition:e.position};case`START_EDIT`:return{editingCell:{row:e.row,col:e.col,initialValue:e.initialValue}};case`STOP_EDIT`:return{editingCell:null};case`START_PEEK`:return{peekCell:{row:e.row,col:e.col}};case`STOP_PEEK`:return{peekCell:null};case`SET_CONTENT_SIZE`:return{contentWidth:e.width,contentHeight:e.height,viewportWidth:e.viewportWidth,viewportHeight:e.viewportHeight,rowsWrapperOffset:e.rowsWrapperOffset};case`UPDATE_HEADER`:return n.set(e.colIndex,{column:e.column,sortDirection:e.sortDirection,sortIndex:e.sortIndex,hasFilter:e.hasFilter}),null;case`OPEN_FILTER_POPUP`:return{filterPopup:{isOpen:!0,colIndex:e.colIndex,column:e.column,anchorRect:e.anchorRect,distinctValues:e.distinctValues,currentFilter:e.currentFilter}};case`CLOSE_FILTER_POPUP`:return{filterPopup:null};case`DATA_LOADING`:return{isLoading:!0,error:null};case`DATA_LOADED`:return{isLoading:!1,totalRows:e.totalRows};case`DATA_ERROR`:return{isLoading:!1,error:e.error};case`ROWS_ADDED`:case`ROWS_REMOVED`:return{totalRows:e.totalRows};case`ROWS_UPDATED`:case`TRANSACTION_PROCESSED`:return null;case`COLUMNS_CHANGED`:return{columns:e.columns};default:return null}},Z={filterTitle:`Filter: {column}`,and:`AND`,or:`OR`,valuePlaceholder:`Value`,betweenSeparator:`to`,addCondition:`+ Add condition`,removeCondition:`×`,clear:`Clear`,apply:`Apply`,valuesMode:`Values`,conditionMode:`Condition`,searchPlaceholder:`Search...`,selectAll:`Select All`,deselectAll:`Deselect All`,blanks:`(Blanks)`,tooManyValues:`Too many unique values ({count}). Use conditions to filter.`,emptyState:`No data to display`,errorPrefix:`Error: {message}`,operators:{contains:`Contains`,notContains:`Does not contain`,startsWith:`Starts with`,endsWith:`Ends with`,equals:`Equals`,notEquals:`Does not equal`,greaterThan:`Greater than`,lessThan:`Less than`,greaterThanOrEqual:`Greater than or equal`,lessThanOrEqual:`Less than or equal`,between:`Between`,blank:`Is blank`,notBlank:`Is not blank`}},Ht=e=>({...Z,...e,operators:{...Z.operators,...e?.operators}}),Ut=(e,t={})=>e.replace(/\{(\w+)\}/g,(e,n)=>{let r=t[n];return r===void 0?e:String(r)}),Wt=e=>{let t=e.operators;return[{value:`contains`,label:t.contains},{value:`notContains`,label:t.notContains},{value:`equals`,label:t.equals},{value:`notEquals`,label:t.notEquals},{value:`startsWith`,label:t.startsWith},{value:`endsWith`,label:t.endsWith},{value:`blank`,label:t.blank},{value:`notBlank`,label:t.notBlank}]},Gt=e=>{let t=e.operators;return[{value:`=`,label:t.equals},{value:`!=`,label:t.notEquals},{value:`>`,label:t.greaterThan},{value:`<`,label:t.lessThan},{value:`>=`,label:t.greaterThanOrEqual},{value:`<=`,label:t.lessThanOrEqual},{value:`between`,label:t.between},{value:`blank`,label:t.blank},{value:`notBlank`,label:t.notBlank}]},Kt=e=>{let t=e.operators;return[{value:`=`,label:t.equals},{value:`!=`,label:t.notEquals},{value:`>`,label:t.greaterThan},{value:`<`,label:t.lessThan},{value:`between`,label:t.between},{value:`blank`,label:t.blank},{value:`notBlank`,label:t.notBlank}]},Q=e=>({clientX:e.clientX,clientY:e.clientY,button:e.button,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,pointerId:e.pointerId,pointerType:e.pointerType});var qt=class{intervalId=null;lastPointerEvent=null;getBodyEl;onTick;constructor(e,t){this.getBodyEl=e,this.onTick=t}recordPointer(e){this.lastPointerEvent=e}clearPointer(){this.lastPointerEvent=null}start(e,t){this.stop(),this.intervalId=setInterval(()=>{let n=this.getBodyEl();if(!n)return;n.scrollTop+=t,n.scrollLeft+=e;let r=this.lastPointerEvent;r&&this.onTick(r)},16)}stop(){this.intervalId!==null&&(clearInterval(this.intervalId),this.intervalId=null)}},Jt=class{timer=null;capture=null;savedContainerOverflow=null;blockTouchMove=e=>e.preventDefault();deps;constructor(e){this.deps=e}start(e){this.reset(),this.capture={pointerId:e.pointerId,target:e.currentTarget};let t=e.clientX,n=e.clientY,r=e=>{let r=e.clientX-t,i=e.clientY-n;(Math.abs(r)>10||Math.abs(i)>10)&&(this.cancel(),a())},i=()=>{this.cancel(),a()},a=()=>{document.removeEventListener(`pointermove`,r),document.removeEventListener(`pointerup`,i),document.removeEventListener(`pointercancel`,i)};document.addEventListener(`pointermove`,r),document.addEventListener(`pointerup`,i,{once:!0}),document.addEventListener(`pointercancel`,i,{once:!0}),this.timer=setTimeout(()=>{this.timer=null,a(),this.confirm()},300)}cancel(){this.reset(),this.deps.getCore()?.input.cancelPendingRowDrag()}reset(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null),this.capture=null}releaseLocks(){if(!this.deps.isBrowser)return;let e=this.deps.getContainer();this.savedContainerOverflow!==null&&e&&(e.style.overflow=this.savedContainerOverflow),this.savedContainerOverflow=null,document.removeEventListener(`touchmove`,this.blockTouchMove)}confirm(){let e=this.deps.getCore(),t=this.capture;this.capture=null,e!==null&&e.input.confirmPendingRowDrag()&&(this.lockContainer(),document.addEventListener(`touchmove`,this.blockTouchMove,{passive:!1}),this.applyPointerCapture(t),this.deps.onDragConfirmed(e.input.getDragState()))}lockContainer(){let e=this.deps.getContainer();e&&(this.savedContainerOverflow=e.style.overflow,e.style.overflow=`hidden`)}applyPointerCapture(e){e&&Yt(e.target,e.pointerId)}};const Yt=(e,t)=>{try{return e.setPointerCapture(t),!0}catch{return!1}};var Xt=class{cleanup=null;deps;constructor(e){this.deps=e}start(e){if(!this.deps.isBrowser)return;this.detachListeners();let t=e.clientX,n=e.clientY,r=e=>{let r=e.clientX-t,i=e.clientY-n;(Math.abs(r)>10||Math.abs(i)>10)&&this.cancel()},i=()=>{this.cancel()},a=()=>{this.detachListeners(),this.deps.getCore()?.input.confirmPendingCellTap()&&this.deps.onTapConfirmed()};document.addEventListener(`pointermove`,r),document.addEventListener(`pointerup`,a,{once:!0}),document.addEventListener(`pointercancel`,i,{once:!0}),this.cleanup=()=>{document.removeEventListener(`pointermove`,r),document.removeEventListener(`pointerup`,a),document.removeEventListener(`pointercancel`,i)}}cancel(){this.detachListeners(),this.deps.getCore()?.input.cancelPendingCellTap()}detachListeners(){this.cleanup!==null&&(this.cleanup(),this.cleanup=null)}};const Zt=e=>150*e/1e3,Qt=(e,t)=>e.filter(e=>t-e.time<=100),$t=(e,t=640)=>{let n=e[0],r=e.at(-1);if(n===void 0||r===void 0||n===r)return 0;let i=r.time-n.time;if(i<=0)return 0;let a=(r.position-n.position)/i,o=Math.min(2.4,t);return Math.max(-o,Math.min(o,a))},en=(e,t,n=640)=>{let r=e*t>0?e+t*4:e;return Math.max(-n,Math.min(n,r))},tn=(e,t)=>{if(t>1500)return e;if(e===null)return t;let n=t>e?.5:.15;return e+(t-e)*n},nn=(e,t=640)=>{if(e===null||e<=0)return t;let n=Math.max(250,t*17)/e;return Math.max(.25,Math.min(t,n))},rn=(e,t)=>({position:e.position+e.velocity*Math.min(t,64),velocity:e.velocity*Math.exp(-t/1200)}),an=e=>Math.abs(e)<.01,$=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));var on=class{deps;attachedEl=null;gesture=null;gestureCleanup=null;flingFrame=null;flingVelocity=0;dragFrame=null;pendingDragTarget=null;savedOverscrollBehavior=null;savedTouchAction=null;overrideActive=!1;subscribedCore=null;contentSizeUnsubscribe=null;lastPipelineRunMs=null;pipelineIntervalEmaMs=null;frameIntervalEmaMs=null;flingThrottled=!1;constructor(e){this.deps=e}attach(){if(!this.deps.isBrowser||this.attachedEl!==null)return;let e=this.deps.getScrollEl();e!==null&&(this.attachedEl=e,this.savedOverscrollBehavior=e.style.overscrollBehavior,this.savedTouchAction=e.style.touchAction,this.syncCore(),e.addEventListener(`touchstart`,this.onTouchStart,{passive:!0}),e.addEventListener(`wheel`,this.onWheel,{passive:!0}))}detach(){this.stop(),this.clearGesture(),this.contentSizeUnsubscribe?.(),this.contentSizeUnsubscribe=null,this.subscribedCore=null;let e=this.attachedEl;e!==null&&(this.attachedEl=null,e.removeEventListener(`touchstart`,this.onTouchStart),e.removeEventListener(`wheel`,this.onWheel),this.savedOverscrollBehavior!==null&&(e.style.overscrollBehavior=this.savedOverscrollBehavior,this.savedOverscrollBehavior=null),this.savedTouchAction!==null&&(e.style.touchAction=this.savedTouchAction,this.savedTouchAction=null))}syncCore(){this.syncPolicySubscription(),this.syncTouchPolicy()}syncPolicySubscription(){let e=this.deps.getCore();e!==this.subscribedCore&&(this.contentSizeUnsubscribe?.(),this.contentSizeUnsubscribe=null,this.subscribedCore=e,e!==null&&(this.contentSizeUnsubscribe=e.onBatchInstruction(e=>{e.some(e=>e.type===`SET_CONTENT_SIZE`)&&this.syncTouchPolicy()})))}syncTouchPolicy(){let e=this.attachedEl;if(e===null)return;let t=this.deps.getCore()?.isScalingActive()===!0,n=t?`none`:this.savedTouchAction??``,r=t?`contain`:this.savedOverscrollBehavior??``;e.style.touchAction!==n&&(e.style.touchAction=n),e.style.overscrollBehavior!==r&&(e.style.overscrollBehavior=r)}stop(){this.flingFrame!==null&&(globalThis.cancelAnimationFrame?.(this.flingFrame),this.flingFrame=null),this.releaseScrollOverride()}applySyntheticScrollTop(e,t,n,r){r!==null&&this.lastPipelineRunMs!==null&&(this.pipelineIntervalEmaMs=tn(this.pipelineIntervalEmaMs,r-this.lastPipelineRunMs)),this.lastPipelineRunMs=r,this.overrideActive=!0,e.setScrollTopOverride(n),t.scrollTop=n,e.setViewport(n,t.scrollLeft,t.clientWidth,t.clientHeight)}updateFlingThrottle(e,t){if(Math.abs(e)<=t){this.flingThrottled=!1;return}let n=this.frameIntervalEmaMs;n!==null&&n>28&&(this.flingThrottled=!0)}isFlingPipelineDue(e){return!this.flingThrottled||this.lastPipelineRunMs===null||e-this.lastPipelineRunMs>=100}releaseScrollOverride(){if(!this.overrideActive)return;this.overrideActive=!1;let e=this.deps.getCore();if(e===null)return;e.setScrollTopOverride(null);let t=this.attachedEl;t!==null&&e.setViewport(t.scrollTop,t.scrollLeft,t.clientWidth,t.clientHeight)}onWheel=()=>{this.stop(),this.syncCore()};onTouchStart=e=>{this.syncCore(),this.gesture===null&&this.startTouchGesture(e)};startTouchGesture=e=>{let t=this.flingFrame===null?0:this.flingVelocity;this.stop();let n=this.deps.getCore(),r=this.attachedEl;if(n!==null&&r!==null&&n.isScalingActive()){if(e.target?.closest(`.gp-grid-fill-handle, .gp-grid-cell--row-drag-handle`))return;let n=e.changedTouches[0];if(n===void 0)return;this.gesture={touchId:n.identifier,startClientX:n.clientX,startClientY:n.clientY,baseScrollTop:r.scrollTop,baseScrollLeft:r.scrollLeft,engaged:!1,slopOffsetX:0,slopOffsetY:0,samples:[{time:e.timeStamp,position:0}],carriedVelocity:t,expectedScrollTop:r.scrollTop,expectedScrollLeft:r.scrollLeft},this.attachGestureListeners(r)}};attachGestureListeners(e){e.addEventListener(`touchmove`,this.onTouchMove,{passive:!1}),e.addEventListener(`touchend`,this.onTouchEnd,{passive:!0}),e.addEventListener(`touchcancel`,this.onTouchCancel,{passive:!0}),this.gestureCleanup=()=>{e.removeEventListener(`touchmove`,this.onTouchMove),e.removeEventListener(`touchend`,this.onTouchEnd),e.removeEventListener(`touchcancel`,this.onTouchCancel)}}clearGesture(){this.gesture=null,this.gestureCleanup?.(),this.gestureCleanup=null,this.dragFrame!==null&&(globalThis.cancelAnimationFrame?.(this.dragFrame),this.dragFrame=null),this.pendingDragTarget=null}findTrackedTouch(e){let t=this.gesture;if(t===null)return null;let n=e.changedTouches;for(let e of Array.from(n))if(e?.identifier===t.touchId)return e;return null}onTouchMove=e=>{let t=this.gesture,n=this.findTrackedTouch(e),r=this.deps.getCore(),i=this.attachedEl;if(t===null||n===null||r===null||i===null)return;if(r.input.getDragState().isDragging){this.clearGesture(),this.releaseScrollOverride();return}if(this.hasNativeScrollTakenOver(t,i)){this.clearGesture(),this.releaseScrollOverride();return}e.cancelable&&e.preventDefault();let a=t.startClientX-n.clientX,o=t.startClientY-n.clientY;if(t.samples.push({time:e.timeStamp,position:o}),t.samples=Qt(t.samples,e.timeStamp),!t.engaged){if(Math.abs(a)<=10&&Math.abs(o)<=10)return;t.engaged=!0,t.slopOffsetX=a,t.slopOffsetY=o}let s=r.getScrollRatio();this.pendingDragTarget={top:$(t.baseScrollTop+(o-t.slopOffsetY)*s,0,i.scrollHeight-i.clientHeight),left:$(t.baseScrollLeft+(a-t.slopOffsetX),0,i.scrollWidth-i.clientWidth)},this.scheduleDragApply(r,i)};hasNativeScrollTakenOver(e,t){let n=Math.abs(t.scrollTop-e.expectedScrollTop),r=Math.abs(t.scrollLeft-e.expectedScrollLeft);return n>4||r>4}scheduleDragApply(e,t){if(this.dragFrame!==null)return;let n=globalThis.requestAnimationFrame;if(n===void 0){this.flushPendingDrag(e,t,null);return}this.dragFrame=n(n=>{this.dragFrame=null,this.flushPendingDrag(e,t,n)})}flushPendingDrag(e,t,n){let r=this.pendingDragTarget;r!==null&&(this.pendingDragTarget=null,t.scrollLeft=r.left,this.gesture!==null&&(this.gesture.expectedScrollTop=r.top,this.gesture.expectedScrollLeft=r.left),this.applySyntheticScrollTop(e,t,r.top,n))}onTouchEnd=e=>{let t=this.gesture;if(t===null||this.findTrackedTouch(e)===null)return;let n=t.engaged,r=t.carriedVelocity,i=Qt(t.samples,e.timeStamp),a=this.pendingDragTarget;this.clearGesture();let o=this.deps.getCore(),s=this.attachedEl;if(a!==null&&o!==null&&s!==null&&(s.scrollLeft=a.left,this.applySyntheticScrollTop(o,s,a.top,e.timeStamp)),!n)return;let c=o?.getMaxFlingVelocity()??640,l=$t(i,c);if(Math.abs(l)<.25){this.releaseScrollOverride();return}this.startFling(en(l,r,c))};onTouchCancel=e=>{this.findTrackedTouch(e)!==null&&(this.clearGesture(),this.releaseScrollOverride())};startFling(e){let t=globalThis.requestAnimationFrame,n=this.deps.getCore(),r=this.attachedEl;if(t===void 0||n===null||r===null)return;let i=n.getMaxFlingVelocity(),a=Zt(n.getRowHeight()),o=nn(this.pipelineIntervalEmaMs,i),s=n.getScrollRatio(),c={position:r.scrollTop/s,velocity:$(e,-o,o)},l=null;this.flingVelocity=c.velocity,this.flingThrottled=!1;let u=e=>{this.flingFrame=null;let o=l===null?16:e-l;l!==null&&(this.frameIntervalEmaMs=tn(this.frameIntervalEmaMs,o)),l=e,c=rn(c,o);let d=nn(this.pipelineIntervalEmaMs,i);c={...c,velocity:$(c.velocity,-d,d)},this.flingVelocity=c.velocity,this.updateFlingThrottle(c.velocity,a);let f=c.position*s,p=r.scrollHeight-r.clientHeight,m=$(f,0,p),h=m!==f,g=an(c.velocity)||h;if(g||this.isFlingPipelineDue(e)?this.applySyntheticScrollTop(n,r,m,e):r.scrollTop=m,g){this.releaseScrollOverride();return}this.flingFrame=t(u)};this.flingFrame=t(u)}};const sn=(e,t,n,r)=>{let i={slots:new Map(t),headers:new Map(n)};for(let t of e){let e=Vt(t,i.slots,i.headers);e!==null&&cn(e,i,r)}return i},cn=(e,t,n)=>{e.slots!==void 0&&un(t.slots,e.slots),e.headers!==void 0&&un(t.headers,e.headers),ln(e,n),e.columns!==void 0&&e.columns!==null&&n.setColumnsOverride(e.columns),e.filterPopup!==void 0&&n.onFilterPopupChange(e.filterPopup)},ln=(e,t)=>{e.contentWidth!==void 0&&t.setContentWidth(e.contentWidth),e.contentHeight!==void 0&&t.setContentHeight(e.contentHeight),e.rowsWrapperOffset!==void 0&&t.setRowsWrapperOffset(e.rowsWrapperOffset),e.isLoading!==void 0&&t.setIsLoading(e.isLoading),e.error!==void 0&&t.setErrorMessage(e.error),e.totalRows!==void 0&&t.setTotalRows(e.totalRows),e.pendingScrollTop!==void 0&&t.setPendingScrollTop(e.pendingScrollTop),e.activeCell!==void 0&&t.setActiveCell(e.activeCell),e.selectionRange!==void 0&&t.setSelectionRange(e.selectionRange),e.editingCell!==void 0&&t.setEditingCell(e.editingCell),e.hoverPosition!==void 0&&t.setHoverPosition(e.hoverPosition),e.peekCell!==void 0&&t.setPeekCell(e.peekCell)},un=(e,t)=>{e.clear(),t.forEach((t,n)=>e.set(n,t))};var dn=class{owned=null;lastAppliedRows=null;lastAppliedColumns=null;initialize(e,t){return e===null?(this.owned=X(t),this.lastAppliedRows=t,this.owned):e}syncRows(e,t){return t!==null||this.lastAppliedRows===e?null:(this.lastAppliedRows=e,e.length>1e4&&console.warn(`[gp-grid] rows input changed with ${e.length} rows — this triggers a full rebuild. Use createGridData() for efficient updates.`),this.owned?.destroy?.(),this.owned=X(e),this.owned)}syncColumns(e){return e.length===0||this.lastAppliedColumns===e?!1:(this.lastAppliedColumns=e,!0)}destroy(){this.owned?.destroy?.(),this.owned=null}},fn=class{deps;constructor(e){this.deps=e}headerPointerDown(e,t,n,r){let i=this.deps.getCore();return i!==null&&i.input.handleHeaderMouseDown(e,t,n,Q(r)).preventDefault}resizePointerDown(e,t,n){let r=this.deps.getCore();return r!==null&&r.input.handleHeaderResizeMouseDown(e,t,Q(n)).preventDefault}cellPointerDown(e,t,n){let r=this.deps.getCore();if(r===null)return{preventDefault:!1,focusContainer:!1};let i=r.input.handleCellMouseDown(e,t,Q(n));return this.dispatchCellDragStart(i,n),{preventDefault:i.preventDefault,focusContainer:i.focusContainer??!1}}cellPointerEnter(e,t){this.deps.getCore()?.input.handleCellMouseEnter(e,t)}cellPointerLeave(){this.deps.getCore()?.input.handleCellMouseLeave()}fillHandlePointerDown(e,t,n){let r=this.deps.getCore();if(r===null)return{preventDefault:!1,stopPropagation:!1};let i=r.input.handleFillHandleMouseDown(e,t,Q(n));return i.startDrag===`fill`&&(pn(n),this.deps.onDragStateChange(r.input.getDragState())),{preventDefault:i.preventDefault,stopPropagation:i.stopPropagation}}dragMove(e){let t=this.deps.getCore(),n=this.deps.getBodyEl();if(t===null||n===null)return;let r=n.getBoundingClientRect(),i=t.input.handleDragMove(Q(e),{top:r.top,left:r.left,width:r.width,height:r.height,scrollTop:n.scrollTop,scrollLeft:n.scrollLeft});this.deps.onDragStateChange(t.input.getDragState()),i?.autoScroll?this.deps.autoScroll.start(i.autoScroll.dx,i.autoScroll.dy):this.deps.autoScroll.stop()}documentPointerMove(e){let t=this.deps.getCore();if(t===null)return!1;let n=t.input.getDragState().isDragging;return this.deps.autoScroll.recordPointer(e),this.dragMove(e),n}documentPointerUp(){let e=this.deps.getCore();if(e===null)return{wasRowDrag:!1};let t=e.input.getDragState().dragType===`row-drag`;return this.deps.autoScroll.stop(),this.deps.autoScroll.clearPointer(),e.input.handleDragEnd(),this.deps.onDragStateChange(e.input.getDragState()),{wasRowDrag:t}}wheel(e,t,n){let r=this.deps.getCore();return r===null?null:r.input.handleWheel(e,t,n)}keyDown(e,t,n,r){let i=this.deps.getCore();return i===null?{preventDefault:!1}:i.input.handleKeyDown({key:e.key,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey},t,n,r)}pasteText(e,t,n){let r=this.deps.getCore();return r===null||t!==null||n?!1:r.pasteClipboardText(e)}dispatchCellDragStart(e,t){let n=this.deps.getCore();if(n!==null){if(e.startTap===!0&&this.deps.pendingCellTap.start(t),e.startDrag===`selection`){n.input.startSelectionDrag(),this.deps.onDragStateChange(n.input.getDragState());return}if(e.startDrag===`row-drag`){this.deps.onDragStateChange(n.input.getDragState());return}e.startDrag===`row-drag-pending`&&this.deps.pendingRowDrag.start(t)}}};const pn=e=>{e.target.setPointerCapture(e.pointerId)};export{qt as AutoScrollDriver,dn as DataSourceOwner,V as EditManager,z as FillManager,Ze as GridCore,C as HighlightManager,It as IndexedDataStore,fn as InputEventAdapter,S as InputHandler,W as ParallelSortManager,Xt as PendingCellTapController,Jt as PendingRowDragController,be as ROW_DRAG_HOLD_MS,O as RowDataManager,w as RowMutationManager,A as ScrollVirtualizationManager,R as SelectionManager,B as SlotPoolManager,P as SortFilterManager,ye as TAP_SLOP_PX,on as TouchScrollController,F as TransactionManager,Qe as WorkerPool,sn as applyBatchInstructions,Vt as applyInstruction,se as bindPeekSelectAll,p as buildCellClasses,n as calculateColumnPositions,ae as calculateFillHandlePosition,oe as calculateFilterPopupPosition,i as calculateScaledColumnPositions,K as compareValues,ct as computeValueHash,Pt as createClientDataSource,X as createDataSourceFromArray,Bt as createInitialState,zt as createMutableClientDataSource,Ft as createServerDataSource,Z as defaultGridLabels,tt as detectBoundaryCollisions,J as evaluateColumnFilter,At as evaluateDateCondition,Ot as evaluateNumberCondition,Et as evaluateTextCondition,a as findColumnAtX,te as findSlotForRow,y as formatCellValue,Ut as formatLabel,Kt as getDateOperatorOptions,g as getFieldValue,Gt as getNumberOperatorOptions,Wt as getTextOperatorOptions,r as getTotalWidth,Pe as groupDistinctValues,N as isBlankCellValue,l as isCellActive,d as isCellEditing,f as isCellInFillPreview,c as isCellSelected,h as isColumnInSelectionRange,m as isRowInSelectionRange,u as isRowVisible,q as isSameDay,H as kWayMerge,U as kWayMergeMultiColumn,Fe as labelsForSelectedValues,M as rawValueKey,Ie as rawValuesForLabels,Ht as resolveGridLabels,Mt as rowPassesFilter,ie as scrollCellIntoView,_ as setFieldValue,G as stringToSortableNumber,Q as toPointerEventData};
|