@keenmate/web-grid 1.0.0-rc09 → 1.0.0-rc11

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.
@@ -1,261 +1,49 @@
1
- (function(B,U){typeof exports=="object"&&typeof module<"u"?U(exports):typeof define=="function"&&define.amd?define(["exports"],U):(B=typeof globalThis<"u"?globalThis:B||self,U(B.WebGrid={}))})(this,function(B){"use strict";var In=Object.defineProperty;var Ln=(B,U,Ce)=>U in B?In(B,U,{enumerable:!0,configurable:!0,writable:!0,value:Ce}):B[U]=Ce;var w=(B,U,Ce)=>Ln(B,typeof U!="symbol"?U+"":U,Ce);const U={rowActions:"Row actions",inlineActionsHeader:"Actions",keyboardShortcuts:"Keyboard shortcuts",paginationFirst:"⏮",paginationPrevious:"◀",paginationNext:"▶",paginationLast:"⏭",paginationPageInfo:"Page {current} of {total}",paginationItemCount:"{count} items",paginationPerPage:"per page",dropdownNoOptions:"No options",dropdownSearching:"Searching...",contextMenu:{sortAsc:"Sort Ascending",sortDesc:"Sort Descending",clearSort:"Clear Sort",hideColumn:"Hide Column",freezeColumn:"Freeze Column",unfreezeColumn:"Unfreeze Column",columnVisibility:"Column Visibility",showAll:"Show all"}};class Ce{constructor(){w(this,"_items",[]);w(this,"_columns",[]);w(this,"_sortMode","none");w(this,"_filterable",!1);w(this,"_pageable",!1);w(this,"_pageSize",10);w(this,"_pageSizes",[10,25,50,100]);w(this,"_striped",!0);w(this,"_hoverable",!0);w(this,"_editable",!1);w(this,"_editTrigger","dblclick");w(this,"_editStartSelection","mousePosition");w(this,"_mode","excel");w(this,"_dropdownToggleVisibility","always");w(this,"_dropdownShowOnFocus",!0);w(this,"_openDropdownOnEnter",!1);w(this,"_checkboxAlwaysEditable",!1);w(this,"_showRowNumbers",!1);w(this,"_stickyRowNumbers",!1);w(this,"_freezeColumns",0);w(this,"_invalidCells",[]);w(this,"_showRowToolbar",!1);w(this,"_rowToolbar",["add","delete","duplicate"]);w(this,"_toolbarVerticalAlign","bottom");w(this,"_toolbarHorizontalAlign","center");w(this,"_toolbarTrigger","hover");w(this,"_toolbarPosition","auto");w(this,"_inlineActionsTitle","");w(this,"_contextMenu");w(this,"_contextMenuXOffset",8);w(this,"_contextMenuYOffset",0);w(this,"_headerContextMenu");w(this,"_rowShortcuts");w(this,"_showShortcutsHelp",!1);w(this,"_shortcutsHelpPosition","top-right");w(this,"_shortcutsHelpContentCallback");w(this,"_idValueMember");w(this,"_idValueCallback");w(this,"_rowLocking");w(this,"_externalLocks",new Map);w(this,"_onrowlockchange");w(this,"_gridName",null);w(this,"_persistColumnWidths",!1);w(this,"_columnWidths",new Map);w(this,"_oncolumnresize");w(this,"_allowColumnReorder",!1);w(this,"_persistColumnOrder",!1);w(this,"_columnOrder",new Map);w(this,"_oncolumnreorder");w(this,"_fillDirection","vertical");w(this,"_onfilldrag");w(this,"_onrowchange");w(this,"_onroweditstart");w(this,"_onroweditcancel");w(this,"_onvalidationerror");w(this,"_validationTooltipCallback");w(this,"_ontoolbarclick");w(this,"_onrowaction");w(this,"_oncontextmenuopen");w(this,"_onheadercontextmenuopen");w(this,"_ondatarequest");w(this,"_onrowdelete");w(this,"_sort",[]);w(this,"_filters",{});w(this,"_currentPage",1);w(this,"_totalItems",null);w(this,"_showPagination",!0);w(this,"_paginationPosition","bottom-center");w(this,"_paginationLabelsCallback");w(this,"_paginationLayout","pageSize|previous|pageInfo|next");w(this,"_summaryPosition");w(this,"_summaryContentCallback");w(this,"_summaryMetadata");w(this,"_summaryInline",!0);w(this,"_customStylesCallback");w(this,"_rowClassCallback");w(this,"_labels",{...U});w(this,"_virtualScroll",!1);w(this,"_virtualScrollThreshold",100);w(this,"_virtualScrollRowHeight",38);w(this,"_virtualScrollBuffer",10);w(this,"_infiniteScroll",!1);w(this,"_infiniteScrollThreshold",100);w(this,"_hasMoreItems",!0);w(this,"_isLoadingMore",!1);w(this,"_editingCell",null);w(this,"_currentCellError",null);w(this,"_isValidating",!1);w(this,"_draftRows",new Map);w(this,"_focusedCell",null);w(this,"_isCommittingFromKeyboard",!1);w(this,"_skipNextDropdownAutoEdit",!1);w(this,"_hoveredRowIndex",null);w(this,"_onInteractionChange",null);w(this,"_selectedRows",new Set);w(this,"_lastSelectedRowIndex",null);w(this,"_rangeShortcuts",[])}get items(){return this._items}set items(e){this._items=e,this.requestUpdate()}get columns(){return this._columns}set columns(e){this._columns=e,this.requestUpdate()}get sortMode(){return this._sortMode}set sortMode(e){this._sortMode=e,this.requestUpdate()}get filterable(){return this._filterable}set filterable(e){this._filterable=e,this.requestUpdate()}get pageable(){return this._pageable}set pageable(e){this._pageable=e,this.requestUpdate()}get pageSize(){return this._pageSize}set pageSize(e){this._pageSize=e,this.requestUpdate()}get pageSizes(){return this._pageSizes}set pageSizes(e){this._pageSizes=e,this.requestUpdate()}get striped(){return this._striped}set striped(e){this._striped=e,this.requestUpdate()}get hoverable(){return this._hoverable}set hoverable(e){this._hoverable=e,this.requestUpdate()}get editable(){return this._editable}set editable(e){this._editable=e,this.requestUpdate()}get editTrigger(){return this._editTrigger}set editTrigger(e){this._editTrigger=e,this.requestUpdate()}get editStartSelection(){return this._editStartSelection}set editStartSelection(e){this._editStartSelection=e}get mode(){return this._mode}set mode(e){this._mode=e,this.applyModeDefaults(),this.requestUpdate()}get dropdownToggleVisibility(){return this._dropdownToggleVisibility}set dropdownToggleVisibility(e){this._dropdownToggleVisibility=e,this.requestUpdate()}getEffectiveToggleVisibility(e){return e.dropdownToggleVisibility??this._dropdownToggleVisibility}get dropdownShowOnFocus(){return this._dropdownShowOnFocus}set dropdownShowOnFocus(e){this._dropdownShowOnFocus=e}get openDropdownOnEnter(){return this._openDropdownOnEnter}set openDropdownOnEnter(e){this._openDropdownOnEnter=e}getEffectiveOpenDropdownOnEnter(e){return e.openDropdownOnEnter??this._openDropdownOnEnter}get checkboxAlwaysEditable(){return this._checkboxAlwaysEditable}set checkboxAlwaysEditable(e){this._checkboxAlwaysEditable=e,this.requestUpdate()}get showRowNumbers(){return this._showRowNumbers}set showRowNumbers(e){this._showRowNumbers=e,this.requestUpdate()}get stickyRowNumbers(){return this._stickyRowNumbers}set stickyRowNumbers(e){this._stickyRowNumbers=e,this.requestUpdate()}get freezeColumns(){return this._freezeColumns}set freezeColumns(e){this._freezeColumns=Math.max(0,Math.floor(e)),this.requestUpdate()}get visualColumns(){const e=[],t=[];this._columns.filter(n=>n.frozen&&!n.hidden).length,this._columns.forEach((n,s)=>{if(n.hidden)return;const a={column:n,originalIndex:s};n.frozen?e.push(a):t.push(a)});const i=[],r=[];return t.forEach((n,s)=>{s<this._freezeColumns?i.push(n):r.push(n)}),this._columnOrder.size>0&&r.sort((n,s)=>{const a=String(n.column.field),l=String(s.column.field),d=this._columnOrder.get(a)??n.originalIndex,g=this._columnOrder.get(l)??s.originalIndex;return d-g}),[...e,...i,...r]}get totalFrozenColumns(){return this._columns.filter(t=>t.frozen).length+this._freezeColumns}isColumnFrozen(e){return e<this.totalFrozenColumns}get invalidCells(){return this._invalidCells}set invalidCells(e){this._invalidCells=e,this.requestUpdate()}get editingCell(){return this._editingCell}get isValidating(){return this._isValidating}get currentCellError(){return this._currentCellError}get hoveredRowIndex(){return this._hoveredRowIndex}get showRowToolbar(){return this._showRowToolbar}set showRowToolbar(e){this._showRowToolbar=e,this.requestUpdate()}get rowToolbar(){return this._rowToolbar}set rowToolbar(e){this._rowToolbar=e,this.requestUpdate()}get toolbarVerticalAlign(){return this._toolbarVerticalAlign}set toolbarVerticalAlign(e){this._toolbarVerticalAlign=e,this.requestUpdate()}get toolbarHorizontalAlign(){return this._toolbarHorizontalAlign}set toolbarHorizontalAlign(e){this._toolbarHorizontalAlign=e,this.requestUpdate()}get toolbarAlign(){return this._toolbarVerticalAlign}set toolbarAlign(e){this.toolbarVerticalAlign=e}get toolbarTopPosition(){return this._toolbarHorizontalAlign}set toolbarTopPosition(e){this.toolbarHorizontalAlign=e}get toolbarTrigger(){return this._toolbarTrigger}set toolbarTrigger(e){this._toolbarTrigger=e,this.requestUpdate()}get toolbarPosition(){return this._toolbarPosition}set toolbarPosition(e){this._toolbarPosition=e,this.requestUpdate()}get inlineActionsTitle(){return this._inlineActionsTitle}set inlineActionsTitle(e){this._inlineActionsTitle=e,this.requestUpdate()}get contextMenu(){return this._contextMenu}set contextMenu(e){this._contextMenu=e,this.requestUpdate()}get contextMenuXOffset(){return this._contextMenuXOffset}set contextMenuXOffset(e){this._contextMenuXOffset=e}get contextMenuYOffset(){return this._contextMenuYOffset}set contextMenuYOffset(e){this._contextMenuYOffset=e}get headerContextMenu(){return this._headerContextMenu}set headerContextMenu(e){this._headerContextMenu=e}get rowShortcuts(){return this._rowShortcuts}set rowShortcuts(e){this._rowShortcuts=e,this.requestUpdate()}get showShortcutsHelp(){return this._showShortcutsHelp}set showShortcutsHelp(e){this._showShortcutsHelp=e,this.requestUpdate()}get shortcutsHelpPosition(){return this._shortcutsHelpPosition}set shortcutsHelpPosition(e){this._shortcutsHelpPosition=e,this.requestUpdate()}get shortcutsHelpContentCallback(){return this._shortcutsHelpContentCallback}set shortcutsHelpContentCallback(e){this._shortcutsHelpContentCallback=e,this.requestUpdate()}get sort(){return this._sort}set sort(e){this._sort=e,this.requestUpdate()}get currentPage(){return this._currentPage}set currentPage(e){this._currentPage=e,this.requestUpdate()}get totalItems(){return this._totalItems}set totalItems(e){this._totalItems=e,this.requestUpdate()}get showPagination(){return this._showPagination}set showPagination(e){this._showPagination=e,this.requestUpdate()}get paginationPosition(){return this._paginationPosition}set paginationPosition(e){this._paginationPosition=e,this.requestUpdate()}get paginationLabelsCallback(){return this._paginationLabelsCallback}set paginationLabelsCallback(e){this._paginationLabelsCallback=e,this.requestUpdate()}get paginationLayout(){return this._paginationLayout}set paginationLayout(e){this._paginationLayout=e,this.requestUpdate()}get summaryPosition(){return this._summaryPosition}set summaryPosition(e){this._summaryPosition=e,this.requestUpdate()}get summaryContentCallback(){return this._summaryContentCallback}set summaryContentCallback(e){this._summaryContentCallback=e,this.requestUpdate()}get summaryMetadata(){return this._summaryMetadata}set summaryMetadata(e){this._summaryMetadata=e,this.requestUpdate()}get summaryInline(){return this._summaryInline}set summaryInline(e){this._summaryInline=e,this.requestUpdate()}get customStylesCallback(){return this._customStylesCallback}set customStylesCallback(e){this._customStylesCallback=e}get rowClassCallback(){return this._rowClassCallback}set rowClassCallback(e){this._rowClassCallback=e,this.requestUpdate()}get labels(){return this._labels}set labels(e){this._labels={...U,...e},this.requestUpdate()}get virtualScroll(){return this._virtualScroll}set virtualScroll(e){this._virtualScroll=e,this.requestUpdate()}get virtualScrollThreshold(){return this._virtualScrollThreshold}set virtualScrollThreshold(e){this._virtualScrollThreshold=e,this.requestUpdate()}get virtualScrollRowHeight(){return this._virtualScrollRowHeight}set virtualScrollRowHeight(e){this._virtualScrollRowHeight=e,this.requestUpdate()}get virtualScrollBuffer(){return this._virtualScrollBuffer}set virtualScrollBuffer(e){this._virtualScrollBuffer=e,this.requestUpdate()}get infiniteScroll(){return this._infiniteScroll}set infiniteScroll(e){this._infiniteScroll=e,this.requestUpdate()}get infiniteScrollThreshold(){return this._infiniteScrollThreshold}set infiniteScrollThreshold(e){this._infiniteScrollThreshold=e}get hasMoreItems(){return this._hasMoreItems}set hasMoreItems(e){this._hasMoreItems=e}get isLoadingMore(){return this._isLoadingMore}set isLoadingMore(e){this._isLoadingMore=e}shouldUseVirtualScroll(){return this._virtualScroll===!1?!1:this._virtualScroll===!0?!0:this.displayItems.length>=this._virtualScrollThreshold}get showRowActions(){return this._showRowToolbar}set showRowActions(e){this.showRowToolbar=e}get rowActions(){return this._rowToolbar}set rowActions(e){this.rowToolbar=e}set onrowchange(e){this._onrowchange=e}set onroweditstart(e){this._onroweditstart=e}set onroweditcancel(e){this._onroweditcancel=e}set onvalidationerror(e){this._onvalidationerror=e}get validationTooltipCallback(){return this._validationTooltipCallback}set validationTooltipCallback(e){this._validationTooltipCallback=e}get ontoolbarclick(){return this._ontoolbarclick}set ontoolbarclick(e){this._ontoolbarclick=e}set onrowaction(e){this._onrowaction=e}set oncontextmenuopen(e){this._oncontextmenuopen=e}get onheadercontextmenuopen(){return this._onheadercontextmenuopen}set onheadercontextmenuopen(e){this._onheadercontextmenuopen=e}get ondatarequest(){return this._ondatarequest}set ondatarequest(e){this._ondatarequest=e}get onrowdelete(){return this._onrowdelete}set onrowdelete(e){this._onrowdelete=e}get idValueMember(){return this._idValueMember}set idValueMember(e){this._idValueMember=e}get idValueCallback(){return this._idValueCallback}set idValueCallback(e){this._idValueCallback=e}get rowLocking(){return this._rowLocking}set rowLocking(e){this._rowLocking=e,this.requestUpdate()}get onrowlockchange(){return this._onrowlockchange}set onrowlockchange(e){this._onrowlockchange=e}get gridName(){return this._gridName}set gridName(e){this._gridName=e}get persistColumnWidths(){return this._persistColumnWidths}set persistColumnWidths(e){this._persistColumnWidths=e}get oncolumnresize(){return this._oncolumnresize}set oncolumnresize(e){this._oncolumnresize=e}get allowColumnReorder(){return this._allowColumnReorder}set allowColumnReorder(e){this._allowColumnReorder=e}get persistColumnOrder(){return this._persistColumnOrder}set persistColumnOrder(e){this._persistColumnOrder=e}get oncolumnreorder(){return this._oncolumnreorder}set oncolumnreorder(e){this._oncolumnreorder=e}get fillDirection(){return this._fillDirection}set fillDirection(e){this._fillDirection=e}get onfilldrag(){return this._onfilldrag}set onfilldrag(e){this._onfilldrag=e}get selectedRows(){return Array.from(this._selectedRows).sort((e,t)=>e-t)}get rangeShortcuts(){return this._rangeShortcuts}set rangeShortcuts(e){this._rangeShortcuts=e}isRowSelected(e){return this._selectedRows.has(e)}selectRow(e,t="replace"){switch(t){case"replace":this._selectedRows.clear(),this._selectedRows.add(e),this._lastSelectedRowIndex=e;break;case"toggle":this._selectedRows.has(e)?this._selectedRows.delete(e):this._selectedRows.add(e),this._lastSelectedRowIndex=e;break;case"range":if(this._lastSelectedRowIndex!==null){const i=Math.min(this._lastSelectedRowIndex,e),r=Math.max(this._lastSelectedRowIndex,e);for(let n=i;n<=r;n++)this._selectedRows.add(n)}else this._selectedRows.add(e),this._lastSelectedRowIndex=e;break}this.requestUpdate()}selectRowRange(e,t){this._selectedRows.clear();const i=Math.min(e,t),r=Math.max(e,t);for(let n=i;n<=r;n++)this._selectedRows.add(n);this._lastSelectedRowIndex=t,this.requestUpdate()}clearSelection(){this._selectedRows.size>0&&(this._selectedRows.clear(),this._lastSelectedRowIndex=null,this.requestUpdate())}getSelectedRowsData(){return this.selectedRows.map(e=>this.displayItems[e]).filter(Boolean)}get isNavigateMode(){return this._editTrigger==="navigate"||this._columns.some(e=>e.editTrigger==="navigate")}get filteredItems(){return!this._filterable||Object.keys(this._filters).length===0?this._items:this._items.filter(e=>Object.entries(this._filters).every(([t,i])=>i?String(e[t]??"").toLowerCase().includes(i.toLowerCase()):!0))}get sortedItems(){return this._sort.length===0?this.filteredItems:[...this.filteredItems].sort((e,t)=>{for(const i of this._sort){const r=e[i.column],n=t[i.column];if(r===n)continue;let s=0;return typeof r=="string"&&typeof n=="string"?s=r.localeCompare(n):typeof r=="number"&&typeof n=="number"?s=r-n:s=String(r??"").localeCompare(String(n??"")),i.direction==="asc"?s:-s}return 0})}get paginatedItems(){if(!this._pageable)return this.sortedItems;const e=(this._currentPage-1)*this._pageSize,t=e+this._pageSize;return this.sortedItems.slice(e,t)}get totalPages(){const e=this._totalItems!==null?this._totalItems:this.sortedItems.length;return Math.max(1,Math.ceil(e/this._pageSize))}get displayItems(){return this.paginatedItems}fireDataRequest(e){if(this._ondatarequest){const t=e==="loadMore"?this._items.length:(this._currentPage-1)*this._pageSize,i={sort:[...this._sort],page:this._currentPage,pageSize:this._pageSize,trigger:e,mode:e==="loadMore"?"append":"replace",skip:t};this._ondatarequest(i)}}getColumnSortState(e){return this._sort.find(t=>t.column===e)}getColumnSortPriority(e){const t=this._sort.findIndex(i=>i.column===e);return t>=0?t+1:0}applyModeDefaults(){switch(this._mode){case"read-only":this._editable=!1,this._dropdownToggleVisibility="on-focus";break;case"excel":this._editable=!0,this._editTrigger="navigate",this._dropdownToggleVisibility="always",this._dropdownShowOnFocus=!1;break;case"input-matrix":this._editable=!0,this._editTrigger="always",this._dropdownToggleVisibility="always",this._dropdownShowOnFocus=!0;break}}requestUpdate(){}getRowDraft(e){return this._draftRows.get(e)}hasRowDraft(e){return this._draftRows.has(e)}discardRowDraft(e){this._draftRows.delete(e),this._invalidCells=this._invalidCells.filter(t=>t.rowIndex!==e),this.requestUpdate()}getDraftRowIndices(){return Array.from(this._draftRows.keys())}discardAllDrafts(){this._draftRows.clear(),this._invalidCells=[],this.requestUpdate()}getCellRawValue(e,t,i){const r=this._draftRows.get(t);return r?r[i]:e[i]}getCellValue(e,t,i){if(t.templateCallback)return t.templateCallback(e);const r=i!==void 0?this.getCellRawValue(e,i,String(t.field)):e[String(t.field)];return t.formatCallback?t.formatCallback(r,e):String(r??"")}isCellInvalid(e,t){return this._invalidCells.some(i=>i.rowIndex===e&&i.field===t)}getCellValidationError(e,t){const i=this._invalidCells.find(r=>r.rowIndex===e&&r.field===t);return(i==null?void 0:i.error)||null}addInvalidCell(e,t,i){const r=this._invalidCells.findIndex(n=>n.rowIndex===e&&n.field===t);r>=0?this._invalidCells[r]={rowIndex:e,field:t,error:i}:this._invalidCells=[...this._invalidCells,{rowIndex:e,field:t,error:i}]}removeInvalidCell(e,t){this._invalidCells=this._invalidCells.filter(i=>!(i.rowIndex===e&&i.field===t))}isEditing(e,t){var i,r;return((i=this._editingCell)==null?void 0:i.rowIndex)===e&&((r=this._editingCell)==null?void 0:r.field)===t}startEdit(e,t,i){var s,a;if(!this.canEditCell(e,t))return;const r=this.displayItems[e];if(!r)return;this._draftRows.has(e)||this._draftRows.set(e,{...r});const n=this._editingCell;this._editingCell={rowIndex:e,field:t,initialSearchQuery:i==null?void 0:i.initialSearchQuery,cursorPosition:i==null?void 0:i.cursorPosition},(s=this._onInteractionChange)==null||s.call(this,"editingCell",{prev:n,current:this._editingCell}),this._currentCellError=null,(a=this._onroweditstart)==null||a.call(this,{row:r,rowIndex:e,field:t})}cancelEdit(){var e,t;if(this._editingCell){const i=this._editingCell,{rowIndex:r,field:n}=i,s=this.displayItems[r];s&&((e=this._onroweditcancel)==null||e.call(this,{row:s,rowIndex:r,field:n})),this._editingCell=null,(t=this._onInteractionChange)==null||t.call(this,"editingCell",{prev:i,current:null}),this._currentCellError=null}}normalizeValidationResult(e,t){return e==null||e===!0?{valid:!0,finalValue:t}:e===!1?{valid:!1,message:"Validation failed",finalValue:t}:typeof e=="string"?{valid:!1,message:e,finalValue:t}:{valid:e.valid,message:e.message,finalValue:e.transformedValue!==void 0?e.transformedValue:t}}async commitEdit(e,t,i){var c,h,f;const r=this._columns.find(p=>String(p.field)===t);if(!r)return;const n=this.displayItems[e];if(!n)return;const s=n[t];let a=i,l=null,d=!0;this._isValidating=!0;try{if(r.beforeCommitCallback){const p={value:i,oldValue:s,row:n,rowIndex:e,field:t},v=await Promise.resolve(r.beforeCommitCallback(p)),m=this.normalizeValidationResult(v,i);d=m.valid,l=m.message||null,a=m.finalValue}else if(r.validateCallback){const p=await Promise.resolve(r.validateCallback(i,n));p&&(d=!1,l=p)}}catch(p){d=!1,l=p instanceof Error?p.message:"Validation failed"}this._isValidating=!1;let g=this._draftRows.get(e);g||(g={...n},this._draftRows.set(e,g)),g[t]=a,d?(this.removeInvalidCell(e,t),this._currentCellError=null):(this.addInvalidCell(e,t,l||"Invalid value"),this._currentCellError=l,(c=this._onvalidationerror)==null||c.call(this,{row:n,rowIndex:e,field:t,error:l||"Invalid value"})),(h=this._onrowchange)==null||h.call(this,{row:n,draftRow:g,rowIndex:e,field:t,oldValue:s,newValue:a,isValid:d,validationError:l});const u=this._editingCell;this._editingCell=null,(f=this._onInteractionChange)==null||f.call(this,"editingCell",{prev:u,current:null})}isCellEditable(e){return e.editable===!1?!1:this._editable||e.editor!==void 0}getEditableColumns(){return this._columns.map((e,t)=>({index:t,column:e})).filter(({column:e})=>this.isCellEditable(e))}isCellFocused(e,t){var i,r;return((i=this._focusedCell)==null?void 0:i.rowIndex)===e&&((r=this._focusedCell)==null?void 0:r.colIndex)===t}get focusedCell(){return this._focusedCell}setFocusedCell(e,t){var n;const i=this._focusedCell,r={rowIndex:e,colIndex:t};(i==null?void 0:i.rowIndex)===r.rowIndex&&(i==null?void 0:i.colIndex)===r.colIndex||(this._focusedCell=r,(n=this._onInteractionChange)==null||n.call(this,"focusedCell",{prev:i,current:r}))}clearFocusedCell(){var t;const e=this._focusedCell;e!==null&&(this._focusedCell=null,(t=this._onInteractionChange)==null||t.call(this,"focusedCell",{prev:e,current:null}))}setHoveredRow(e){var i;if(this._hoveredRowIndex===e)return;const t=this._hoveredRowIndex;this._hoveredRowIndex=e,(i=this._onInteractionChange)==null||i.call(this,"hoveredRow",{prev:t,current:e})}getRowId(e){if(this._idValueCallback)return this._idValueCallback(e);if(this._idValueMember)return e[String(this._idValueMember)]}findRowById(e){const t=this._items.findIndex(i=>this.getRowId(i)===e);return t===-1?null:{row:this._items[t],index:t}}getRowLockInfo(e){let t,i,r=-1;if(typeof e=="object"&&e!==null)t=e,i=this.getRowId(t),r=this._items.indexOf(t),r===-1&&(r=this.displayItems.indexOf(t));else{i=e;const s=this.findRowById(i);s&&(t=s.row,r=s.index)}if(i!==void 0&&this._externalLocks.has(i))return this._externalLocks.get(i);if(!t)return null;const n=this._rowLocking;if(!n)return null;if(n.getLockInfoCallback){const s=n.getLockInfoCallback(t,r);if(s!=null&&s.isLocked)return s}if(n.isLockedCallback&&n.isLockedCallback(t,r))return{isLocked:!0};if(n.lockInfoMember){const s=t[String(n.lockInfoMember)];if(s!=null&&s.isLocked)return s}return n.lockedMember&&t[String(n.lockedMember)]?{isLocked:!0}:null}isRowLocked(e){const t=this.getRowLockInfo(e);return(t==null?void 0:t.isLocked)===!0}lockRowById(e,t){var n;const i={isLocked:!0,lockedBy:t==null?void 0:t.lockedBy,lockedAt:(t==null?void 0:t.lockedAt)??new Date,reason:t==null?void 0:t.reason,...t};this._externalLocks.set(e,i);const r=this.findRowById(e);return r&&this._editingCell&&this._editingCell.rowIndex===r.index&&this.cancelEdit(),this.requestUpdate(),(n=this._onrowlockchange)==null||n.call(this,{rowId:e,row:(r==null?void 0:r.row)??null,rowIndex:(r==null?void 0:r.index)??-1,lockInfo:i,source:"external"}),!0}unlockRowById(e){var i;const t=this._externalLocks.has(e);if(this._externalLocks.delete(e),t){this.requestUpdate();const r=this.findRowById(e);(i=this._onrowlockchange)==null||i.call(this,{rowId:e,row:(r==null?void 0:r.row)??null,rowIndex:(r==null?void 0:r.index)??-1,lockInfo:null,source:"external"})}return t}getExternalLocks(){return new Map(this._externalLocks)}clearExternalLocks(){this._externalLocks.clear(),this.requestUpdate()}updateRowById(e,t){const i=this.findRowById(e);if(!i)return!1;Object.assign(this._items[i.index],t);const r=this._draftRows.get(i.index);return r&&Object.assign(r,t),this.requestUpdate(),!0}replaceRowById(e,t){const i=this.findRowById(e);return i?(this._items[i.index]=t,this._draftRows.delete(i.index),this.requestUpdate(),!0):!1}canEditCell(e,t){var l;const i=this._columns.find(d=>String(d.field)===t);if(!i||!this.isCellEditable(i))return!1;const r=this.displayItems[e];if(!r)return!1;const n=this.getRowLockInfo(r);if(!(n!=null&&n.isLocked))return!0;const s=this._rowLocking;switch((s==null?void 0:s.lockedEditBehavior)??"block"){case"allow":return!0;case"callback":return((l=s==null?void 0:s.canEditLockedCallback)==null?void 0:l.call(s,r,n))??!1;case"block":default:return!1}}getColumnWidth(e){return this._columnWidths.get(e)}setColumnWidth(e,t,i=!1){this._columnWidths.set(e,t),i||this.requestUpdate()}setColumnWidths(e){for(const{field:t,width:i}of e)t&&i&&this._columnWidths.set(t,i);this.requestUpdate()}getColumnWidthsState(){return this._columns.map(e=>{const t=String(e.field),i=this._columnWidths.get(t)||e.width||"";return{field:t,width:i}}).filter(e=>e.width)}loadPersistedWidths(){this.loadPersistedState()}savePersistedWidths(){this.savePersistedState()}loadPersistedState(){if(!(!this._gridName||typeof localStorage>"u"))try{const e=`wg-${this._gridName}-state`,t=localStorage.getItem(e);if(!t)return;const i=JSON.parse(t),r=new Set(this._columns.map(s=>String(s.field)));let n=!1;if(i.columnWidths){this._columnWidths.clear();for(const s of i.columnWidths)r.has(s.field)?this._columnWidths.set(s.field,s.width):n=!0}if(i.columnOrder){this._columnOrder.clear();for(const s of i.columnOrder)r.has(s.field)?this._columnOrder.set(s.field,s.order):n=!0}n&&this.savePersistedState()}catch(e){console.warn("WebGrid: Failed to load persisted state",e)}}savePersistedState(){if(!(!this._gridName||typeof localStorage>"u"))try{const e=`wg-${this._gridName}-state`,t={};this._persistColumnWidths&&(t.columnWidths=this.getColumnWidthsState()),this._persistColumnOrder&&(t.columnOrder=this.getColumnOrderState()),localStorage.setItem(e,JSON.stringify(t))}catch(e){console.warn("WebGrid: Failed to save persisted state",e)}}getColumnOrder(e){return this._columnOrder.get(e)}setColumnOrder(e){this._columnOrder.clear();for(const{field:t,order:i}of e)t!==void 0&&i!==void 0&&this._columnOrder.set(t,i);this.requestUpdate()}getColumnOrderState(){const e=this.visualColumns,t=this.totalFrozenColumns;return e.slice(t).map((i,r)=>({field:String(i.column.field),order:r}))}moveColumn(e,t){const i=this.visualColumns,r=this.totalFrozenColumns,n=i.slice(r),s=n.findIndex(d=>String(d.column.field)===e);if(s===-1||s===t)return;this._columnOrder.clear();const a=[...n],[l]=a.splice(s,1);a.splice(t,0,l),a.forEach((d,g)=>{this._columnOrder.set(String(d.column.field),g)}),this.requestUpdate()}}const Yo=':host{--wg-rem: 10px;font-family:var(--wg-font-family);display:block;--wg-accent-color: var(--base-accent-color, #0078d4);--wg-accent-color-hover: var(--base-accent-color-hover, #106ebe);--wg-accent-color-active: var(--base-accent-color-active, #005a9e);--wg-accent-color-light: var(--base-accent-color-light, #e6f2ff);--wg-text-color-1: var(--base-text-color-1, #242424);--wg-text-color-2: var(--base-text-color-2, #424242);--wg-text-color-3: var(--base-text-color-3, #707070);--wg-text-on-accent: var(--base-text-color-on-accent, #ffffff);--wg-surface-1: var(--base-main-bg, #ffffff);--wg-surface-2: var(--base-elevated-bg, #f5f5f5);--wg-surface-3: var(--base-hover-bg, #ebebeb);--wg-surface-floating: var(--base-dropdown-bg, var(--base-main-bg, #ffffff));--wg-border-color: var(--base-border-color, #e0e0e0);--wg-border-color-hover: var(--base-border-color, #d1d1d1);--wg-input-bg: var(--base-input-bg, #ffffff);--wg-input-color: var(--base-input-color, var(--wg-text-color-1));--wg-input-border: var(--base-input-border, 1px solid #d1d1d1);--wg-input-border-hover: var(--base-input-border-hover, 1px solid #0078d4);--wg-input-border-focus: var(--base-input-border-focus, 1px solid #0078d4);--wg-input-placeholder-color: var(--base-input-placeholder-color, #707070);--wg-danger-color: var(--base-danger-color, #d13438);--wg-danger-bg-light: var(--base-danger-bg-light, #fde7e9);--wg-hover-bg: var(--base-hover-bg, #f0f0f0);--wg-active-bg: var(--base-hover-bg, #e0e0e0);--wg-font-size-base: calc(var(--base-font-size-sm, 1.4) * var(--wg-rem));--wg-font-size-sm: calc(var(--base-font-size-xs, 1.2) * var(--wg-rem));--wg-font-size-xs: calc(var(--base-font-size-2xs, 1.1) * var(--wg-rem));--wg-font-size-lg: calc(var(--base-font-size-base, 1.6) * var(--wg-rem));--wg-font-family: var(--base-font-family, inherit);--wg-line-height-base: var(--base-line-height-normal, 1.5);--wg-font-weight-normal: var(--base-font-weight-normal, 400);--wg-font-weight-semibold: var(--base-font-weight-semibold, 600);--wg-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;--wg-border-radius-sm: calc(var(--base-border-radius-sm, .4) * var(--wg-rem));--wg-border-radius-md: calc(var(--base-border-radius-md, .6) * var(--wg-rem));--wg-border-radius-lg: calc(var(--base-border-radius-lg, .8) * var(--wg-rem));--wg-spacing-xs: calc(.4 * var(--wg-rem));--wg-spacing-sm: calc(.8 * var(--wg-rem));--wg-spacing-md: calc(1.2 * var(--wg-rem));--wg-spacing-lg: calc(1.6 * var(--wg-rem));--wg-spacing-xl: calc(2.4 * var(--wg-rem));--wg-table-bg: var(--wg-surface-1);--wg-table-border: 1px solid var(--wg-border-color);--wg-header-bg: var(--wg-surface-2);--wg-header-bg-hover: var(--wg-surface-3);--wg-header-bg-sorted: var(--wg-surface-3);--wg-header-color: var(--wg-text-color-1);--wg-header-border: 2px solid var(--wg-border-color);--wg-header-separator: 1px solid var(--wg-border-color);--wg-header-padding: var(--wg-spacing-sm) var(--wg-spacing-md);--wg-header-font-weight: var(--wg-font-weight-semibold);--wg-cell-padding: var(--wg-spacing-sm) var(--wg-spacing-md);--wg-cell-padding-block: var(--wg-spacing-sm);--wg-cell-padding-inline: var(--wg-spacing-md);--wg-cell-color: var(--wg-text-color-1);--wg-cell-border: 1px solid var(--wg-border-color);--wg-cell-bg-hover: var(--wg-hover-bg);--wg-cell-bg-editing: var(--wg-surface-1);--wg-cell-readonly-bg: var(--base-disabled-bg, var(--wg-surface-2));--wg-row-border: 1px solid var(--wg-border-color);--wg-row-bg-even: var(--wg-surface-2);--wg-row-bg-hover: var(--wg-surface-3);--wg-filter-bg: var(--wg-surface-1);--wg-filter-border: 1px solid var(--wg-border-color);--wg-filter-padding: var(--wg-spacing-xs) var(--wg-spacing-sm);--wg-filter-input-padding: calc(.4 * var(--wg-rem)) calc(.8 * var(--wg-rem));--wg-filter-input-bg: var(--wg-input-bg);--wg-filter-input-border: var(--wg-input-border);--wg-filter-input-border-focus: var(--wg-input-border-focus);--wg-filter-input-border-radius: var(--wg-border-radius-sm);--wg-filter-input-font-size: var(--wg-font-size-sm);--wg-sort-indicator-size: calc(1.4 * var(--wg-rem));--wg-sort-indicator-opacity: .9;--wg-sort-placeholder-opacity: .3;--wg-sort-priority-size: calc(1.1 * var(--wg-rem));--wg-pagination-padding: var(--wg-spacing-md);--wg-pagination-gap: calc(1.6 * var(--wg-rem));--wg-pagination-bg: var(--wg-surface-1);--wg-pagination-border: 1px solid var(--wg-border-color);--wg-pagination-btn-padding: calc(.6 * var(--wg-rem)) calc(1.6 * var(--wg-rem));--wg-pagination-btn-bg: var(--wg-surface-1);--wg-pagination-btn-bg-hover: var(--wg-surface-2);--wg-pagination-btn-bg-active: var(--wg-surface-3);--wg-pagination-btn-border: 1px solid var(--wg-border-color);--wg-pagination-btn-border-hover: 1px solid var(--wg-border-color-hover);--wg-pagination-btn-border-radius: var(--wg-border-radius-sm);--wg-pagination-btn-disabled-opacity: .4;--wg-empty-padding: var(--wg-spacing-xl);--wg-empty-color: var(--wg-text-color-3);--wg-error-cell-bg: var(--wg-danger-bg-light);--wg-error-cell-border: 1px solid var(--wg-danger-color);--wg-error-message-color: var(--wg-danger-color);--wg-error-message-font-size: var(--wg-font-size-xs);--wg-error-indicator-color: var(--wg-danger-color);--wg-editor-bg: var(--wg-surface-1);--wg-editor-outline: 2px solid var(--wg-accent-color);--wg-editor-outline-offset: -2px;--wg-editor-validating-opacity: .7;--wg-dropdown-toggle-right: var(--wg-spacing-md);--wg-dropdown-toggle-size: calc(1.2 * var(--wg-rem));--wg-dropdown-toggle-hitbox: calc(2.4 * var(--wg-rem));--wg-date-trigger-size: calc(2.8 * var(--wg-rem));--wg-toolbar-bg: var(--wg-surface-floating);--wg-toolbar-border: 1px solid var(--wg-border-color);--wg-toolbar-border-radius: var(--wg-border-radius-sm);--wg-toolbar-shadow: var(--base-dropdown-box-shadow, 0 2px 8px rgba(0, 0, 0, .15));--wg-toolbar-divider-color: var(--wg-border-color);--wg-toolbar-row-height: calc(3.7 * var(--wg-rem));--wg-toolbar-btn-min-width: calc(2.4 * var(--wg-rem));--wg-toolbar-btn-padding: 0 calc(.4 * var(--wg-rem));--wg-toolbar-btn-border-radius: var(--wg-border-radius-sm);--wg-toolbar-btn-bg-hover: var(--wg-hover-bg);--wg-toolbar-btn-bg-active: var(--wg-active-bg);--wg-toolbar-btn-color: var(--wg-text-color-1);--wg-toolbar-trigger-color: var(--wg-text-color-3);--wg-toolbar-trigger-color-hover: var(--wg-text-color-1);--wg-toolbar-trigger-bg-hover: var(--wg-hover-bg);--wg-tooltip-bg: var(--base-tooltip-bg, #333);--wg-tooltip-color: var(--base-tooltip-color, #fff);--wg-context-menu-z-index: 1001;--wg-context-menu-min-width: calc(16 * var(--wg-rem));--wg-focus-outline: 2px solid var(--wg-accent-color);--wg-focus-outline-offset: -2px;--wg-focus-bg: var(--wg-hover-bg);--wg-transition-fast: .1s ease;--wg-transition-normal: .15s ease;--wg-z-dropdown: 9999;--wg-z-toolbar: 1000;--wg-z-context-menu: 1001;--wg-z-tooltip: 10000;--wg-frozen-column-bg: var(--wg-surface-1);--wg-frozen-header-bg: var(--wg-header-bg);--wg-frozen-column-shadow: 2px 0 4px rgba(0, 0, 0, .1);--wg-frozen-column-shadow-active: 6px 0 12px rgba(0, 0, 0, .25);--wg-frozen-column-border: 2px solid var(--wg-border-color);--wg-resize-handle-width: 12px;--wg-resize-handle-offset: -6px;--wg-resize-handle-line-width: 2px;--wg-resize-handle-color: var(--wg-border-color);--wg-resize-handle-active-color: var(--wg-accent-color);--wg-fill-handle-size: 8px;--wg-fill-handle-bg: var(--wg-background);--wg-fill-handle-border-color: var(--wg-accent-color);--wg-fill-handle-border-width: 2px;--wg-fill-range-bg: color-mix(in srgb, var(--wg-accent-color) 15%, transparent);--wg-fill-range-border-color: var(--wg-accent-color);--wg-selection-bg: color-mix(in srgb, var(--wg-accent-color) 15%, transparent);--wg-selection-row-number-bg: var(--wg-accent-color);--wg-selection-row-number-color: var(--base-text-inverted, #fff)}web-grid:not(:defined){display:block;min-height:calc(10 * var(--wg-rem));color:transparent!important;background:transparent}.wg{position:relative;width:100%;max-height:inherit;overflow:auto;overscroll-behavior:contain;border:var(--wg-table-border)}.wg__table{width:100%;min-width:max-content;border-collapse:collapse;table-layout:fixed;background:var(--wg-table-bg);font-size:var(--wg-font-size-base);line-height:var(--wg-line-height-base)}.wg__filler{width:auto;min-width:0;padding:0!important;border:none!important;box-shadow:none!important}th.wg__filler{position:sticky;top:0;z-index:1;background:var(--wg-header-bg);border-bottom:var(--wg-header-border)!important}td.wg__filler{background:transparent}.wg__table tbody tr{border-bottom:var(--wg-row-border)}.wg__row-number-header,.wg__row-number{width:40px;min-width:40px;max-width:40px;box-sizing:border-box;text-align:center;color:var(--wg-text-color-2);background:var(--wg-header-bg);-webkit-user-select:none;user-select:none;font-size:var(--wg-font-size-sm)}.wg__row-number{box-shadow:inset -1px 0 0 var(--wg-border-color)}.wg__actions-column{width:32px;min-width:32px;max-width:32px;padding:0!important;text-align:center}thead .wg__actions-column{background:var(--wg-header-bg);border-bottom:var(--wg-header-border)}.wg__filter-row .wg__actions-column{background:var(--wg-filter-bg);border-bottom:var(--wg-filter-border)}.wg__header{position:sticky;top:0;z-index:1;background:var(--wg-header-bg);color:var(--wg-header-color);font-weight:var(--wg-header-font-weight);padding:var(--wg-header-padding);border-bottom:var(--wg-header-border);box-shadow:inset -1px 0 0 var(--wg-border-color);box-sizing:border-box;text-align:left;-webkit-user-select:none;user-select:none;overflow:hidden}.wg__header:last-child{box-shadow:none}.wg__header--sortable{cursor:pointer}.wg__header--sortable:hover{background:var(--wg-header-bg-hover)}.wg__header--sorted{background:var(--wg-header-bg-sorted)}.wg__header-content{display:flex;align-items:center;gap:4px;justify-content:space-between}.wg__header-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__sort-indicator{font-size:var(--wg-sort-indicator-size);opacity:var(--wg-sort-indicator-opacity);min-width:16px;text-align:center;display:inline-flex;align-items:center}.wg__sort-placeholder{opacity:var(--wg-sort-placeholder-opacity)}.wg__sort-priority{font-size:var(--wg-sort-priority-size);font-weight:600;margin-left:2px;vertical-align:super;line-height:1}.wg__header-info{display:inline-flex;align-items:center;color:var(--wg-accent-color);cursor:help;opacity:.7;margin-left:4px;vertical-align:middle}.wg__header-info:hover{opacity:1}.wg__filter-row th{padding:var(--wg-filter-padding);background:var(--wg-filter-bg);border-bottom:var(--wg-filter-border)}.wg__filter-input{width:100%;padding:var(--wg-filter-input-padding);border:var(--wg-filter-input-border);border-radius:var(--wg-filter-input-border-radius);background:var(--wg-surface-1);color:var(--wg-text-color-1);font-family:inherit;font-size:var(--wg-filter-input-font-size);box-sizing:border-box}.wg__filter-input:focus{outline:none;border:var(--wg-filter-input-border-focus);box-shadow:0 0 0 1px var(--wg-accent-color)}.wg__resize-handle{position:absolute;top:0;right:var(--wg-resize-handle-offset);bottom:0;width:var(--wg-resize-handle-width);cursor:col-resize;z-index:2;opacity:0;transition:opacity .1s ease}.wg__header:hover .wg__resize-handle{opacity:1}.wg__resize-handle:after{content:"";position:absolute;top:25%;bottom:25%;left:50%;width:var(--wg-resize-handle-line-width);background:var(--wg-resize-handle-color);transform:translate(-50%);border-radius:1px}.wg__resize-handle:hover:after{background:var(--wg-resize-handle-active-color);top:15%;bottom:15%}.wg__resize-handle--active:after{background:var(--wg-resize-handle-active-color);top:0;bottom:0}.wg__resize-handle--disabled{cursor:not-allowed}.wg__resize-handle--disabled:after{display:none}.wg--resizing .wg__resize-handle{opacity:1}.wg--resizing{-webkit-user-select:none;user-select:none;cursor:col-resize}.wg--resizing .wg__cell,.wg--resizing .wg__header{cursor:col-resize}.wg--resizing .wg__table{min-width:0!important}.wg__header--dragging{opacity:1;background:var(--wg-header-bg)!important;outline:2px dashed var(--wg-accent-color);outline-offset:-2px}.wg__reorder-ghost{position:fixed;z-index:10000;background:var(--wg-header-bg);border:2px solid var(--wg-accent-color);border-radius:var(--wg-border-radius-sm);padding:.4em .8em;font-size:var(--wg-font-size-sm);font-weight:var(--wg-header-font-weight);color:var(--wg-header-color);box-shadow:0 4px 12px #00000026;opacity:.95;pointer-events:none;white-space:nowrap}.wg__drop-indicator{position:absolute;width:3px;background:var(--wg-accent-color);z-index:999;pointer-events:none;display:none}.wg__drop-indicator:before{content:"";position:absolute;top:0;left:50%;transform:translate(-50%);border-left:6px solid transparent;border-right:6px solid transparent;border-top:8px solid var(--wg-accent-color)}.wg--reordering{cursor:grabbing;-webkit-user-select:none;user-select:none}.wg--reordering .wg__cell,.wg--reordering .wg__header{cursor:grabbing}.wg--reorderable .wg__header:not(.wg__header--frozen):hover{cursor:grab}.wg__header--frozen{cursor:default}.wg__fill-handle{position:absolute;width:var(--wg-fill-handle-size);height:var(--wg-fill-handle-size);background:var(--wg-fill-handle-bg);border:var(--wg-fill-handle-border-width) solid var(--wg-fill-handle-border-color);cursor:crosshair;z-index:10;pointer-events:auto;box-sizing:border-box}.wg__fill-handle:hover{transform:scale(1.2)}.wg__fill-range{position:absolute;background:var(--wg-fill-range-bg);border:1px dashed var(--wg-fill-range-border-color);pointer-events:none;z-index:5;box-sizing:border-box}.wg--filling{cursor:crosshair;-webkit-user-select:none;user-select:none}.wg--filling .wg__cell,.wg--filling .wg__header{cursor:crosshair}.wg__cell--editing .wg__fill-handle{display:none}.wg__row--selected>.wg__cell{background:var(--wg-selection-bg)}.wg__row--selected>.wg__row-number{background:var(--wg-selection-row-number-bg);color:var(--wg-selection-row-number-color)}.wg__row-number[data-row-number]{cursor:pointer;-webkit-user-select:none;user-select:none}.wg__row-number[data-row-number]:hover{background:var(--wg-hover-bg)}.wg__row--selected>.wg__row-number:hover{background:var(--wg-selection-row-number-bg)}.wg--selecting{cursor:default;-webkit-user-select:none;user-select:none}.wg--selecting *{-webkit-user-select:none;user-select:none}.wg:focus{outline:none}.wg__header--frozen{background:var(--wg-frozen-header-bg, var(--wg-header-bg))}.wg__row-number-header.wg__header--frozen{z-index:4!important}.wg__cell--frozen{background:var(--wg-frozen-column-bg, var(--wg-surface-1))}.wg__cell--frozen-last{box-shadow:inset -1px 0 0 var(--wg-border-color)}.wg__row-number.wg__cell--frozen{background:var(--wg-header-bg);z-index:2!important}.wg--striped tbody tr:nth-child(2n) .wg__cell--frozen{background:var(--wg-row-bg-even)}.wg--hoverable tbody tr:hover .wg__cell--frozen{background:var(--wg-row-bg-hover)}.wg__row--focused .wg__cell--frozen{background:var(--wg-focus-bg)}.wg__header.wg__header--frozen-last,.wg__cell.wg__cell--frozen-last{overflow:visible}.wg--scrolled-horizontal .wg__header--frozen-last:after,.wg--scrolled-horizontal .wg__cell--frozen-last:after{content:"";position:absolute;top:0;right:-8px;bottom:0;width:8px;background:linear-gradient(to right,rgba(0,0,0,.15),transparent);pointer-events:none}.wg__cell{padding:var(--wg-cell-padding);color:var(--wg-cell-color);box-sizing:border-box;scroll-margin-top:3rem;scroll-margin-bottom:.5rem;-webkit-user-select:none;user-select:none;overflow:hidden}.wg__cell-text{-webkit-user-select:none;user-select:none}.wg__cell--ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__cell--editable{cursor:pointer;position:relative}.wg__cell--editable:hover{background:var(--wg-cell-bg-hover)}.wg__cell--editable:hover:after{content:"";position:absolute;top:2px;right:2px;bottom:2px;left:2px;border:1px dashed var(--wg-border-color);border-radius:2px;pointer-events:none}.wg__cell--editing{position:relative;background:var(--wg-surface-1);outline:2px solid var(--wg-accent-color);outline-offset:-2px}.wg__cell--editing:after{display:none}.wg__cell--invalid{background:var(--wg-danger-bg-light, #fee);box-shadow:inset 0 0 0 2px var(--wg-danger-color, #c00)}.wg--navigate-mode .wg__cell:not(.wg__cell--editable){background:var(--wg-cell-readonly-bg, #f5f5f5)}:host{--wg-row-locked-bg: var(--base-disabled-bg, #f5f5f5);--wg-row-locked-opacity: .7}.wg__row--locked{background:var(--wg-row-locked-bg)!important}.wg__row--locked .wg__cell{opacity:var(--wg-row-locked-opacity)}.wg__row--locked .wg__cell--editable{cursor:not-allowed}.wg__row--locked .wg__cell--editable:hover{background:inherit}.wg__row--locked .wg__cell--editable:hover:after{display:none}.wg__row-number--locked{opacity:1!important;cursor:help}.wg__editor{position:absolute;top:0;left:0;right:0;width:100%;padding:var(--wg-cell-padding);border:none;background:transparent;color:var(--wg-text-color-1);font-size:var(--wg-font-size-base);font-family:inherit;line-height:inherit;box-sizing:border-box}.wg__editor:focus,.wg__editor:focus-visible{outline:none;box-shadow:none}.wg__editor--text{text-align:inherit}.wg__editor--number{text-align:right}.wg__editor--date{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:var(--wg-editor-bg);padding:var(--wg-cell-padding)}.wg__date-input{flex:1;min-width:0;height:100%;border:none;background:transparent;font:inherit;padding:0;outline:none;color:inherit}.wg__date-trigger{width:var(--wg-date-trigger-size, 28px);height:100%;display:flex;align-items:center;justify-content:center;border:none;background:transparent;color:var(--wg-text-color-3);cursor:pointer;padding:0;flex-shrink:0}.wg__date-trigger:hover{color:var(--wg-accent-color, #0078d4);background:var(--wg-hover-bg, rgba(0, 0, 0, .05))}.wg__editor--checkbox{width:auto;height:auto;margin:0 auto}.wg__editor--custom{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:var(--wg-editor-bg);padding:var(--wg-cell-padding-block) var(--wg-cell-padding-inline);cursor:pointer}.wg__editor--custom:focus{outline:none}.wg__custom-value{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;cursor:pointer}.wg__editor--combobox,.wg__editor--autocomplete{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;padding:var(--wg-cell-padding);padding-right:0;background:transparent;box-sizing:border-box}.wg__combobox-input,.wg__autocomplete-input{flex:1;width:100%;height:100%;padding:0 24px 0 0;border:none;background:transparent;color:var(--wg-text-color-1);font-size:var(--wg-font-size-base);font-family:inherit;line-height:var(--wg-line-height-base);outline:none;box-sizing:border-box;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.wg__combobox-input:focus,.wg__autocomplete-input:focus{outline:none}.wg__combobox-toggle{position:absolute;right:var(--wg-dropdown-toggle-right);top:50%;transform:translateY(-50%);font-size:var(--wg-dropdown-toggle-size);color:var(--wg-text-color-2);pointer-events:auto;cursor:pointer}.wg__combobox-toggle:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:48px}.wg__loading-indicator{position:absolute;right:var(--wg-dropdown-toggle-right);top:50%;transform:translateY(-50%);font-size:12px;animation:wg-pulse 1s infinite}@keyframes wg-pulse{0%,to{opacity:1}50%{opacity:.4}}.wg__select-trigger{display:flex;align-items:center;justify-content:space-between;cursor:pointer;background:transparent}.wg__select-trigger:focus,.wg__select-trigger:focus-visible{outline:none;box-shadow:none}.wg__select-value{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__select-toggle{position:relative;font-size:var(--wg-dropdown-toggle-size);opacity:.6;margin-left:4px;flex-shrink:0;pointer-events:auto;cursor:pointer}.wg__select-toggle:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:48px}.wg__cell-dropdown-display{display:flex;align-items:center;justify-content:space-between;width:100%;cursor:pointer}.wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle{opacity:0}.wg__cell:hover .wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle,.wg__cell--focused .wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle{opacity:.6}.wg__cell-date-display{display:flex;align-items:center;justify-content:space-between;width:100%;cursor:pointer}.wg__cell-date-display .wg__date-trigger{position:relative;background:none;border:none;padding:0;margin:0;cursor:pointer;opacity:.6;display:flex;align-items:center;justify-content:center;color:inherit}.wg__cell-date-display .wg__date-trigger:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:48px}.wg__cell-date-display--toggle-on-focus .wg__date-trigger{opacity:0}.wg__cell:hover .wg__cell-date-display--toggle-on-focus .wg__date-trigger,.wg__cell--focused .wg__cell-date-display--toggle-on-focus .wg__date-trigger{opacity:.6}.wg__dropdown{background:var(--wg-surface-floating, #fff);border:1px solid var(--wg-border-color, #d1d1d1);border-radius:4px;box-shadow:var(--wg-toolbar-shadow);max-height:200px;overflow-y:auto;font-size:var(--wg-font-size-base);font-family:inherit;line-height:var(--wg-line-height-base)}.wg__dropdown-option{display:flex;align-items:center;gap:var(--wg-spacing-sm);padding:6px 12px;cursor:pointer;color:var(--wg-text-color-1)}.wg__dropdown-option:hover,.wg__dropdown-option--highlighted{background:var(--wg-hover-bg, #f0f0f0)}.wg__dropdown-option--selected{background:var(--wg-accent-color-light, #e6f2ff)}.wg__dropdown-option--disabled{opacity:.5;cursor:not-allowed;pointer-events:none}.wg__dropdown-option-icon{flex-shrink:0;width:1.5em;text-align:center}.wg__dropdown-option-content{flex:1;min-width:0;overflow:hidden}.wg__dropdown-option-label{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wg__dropdown-option-subtitle{display:block;font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wg__dropdown-empty{padding:8px 12px;color:var(--wg-text-color-2);font-style:italic;text-align:center}.wg--navigate-mode .wg__cell{cursor:cell}.wg--navigate-mode .wg__cell:focus{outline:none}.wg--navigate-mode .wg__cell.wg__cell--focused{outline:var(--wg-focus-outline);outline-offset:-2px}.wg__cell--focused:after{display:none}.wg__pagination{display:flex;align-items:center;justify-content:center;gap:var(--wg-pagination-gap);padding:var(--wg-pagination-padding);border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg)}.wg__pagination-btn{padding:var(--wg-pagination-btn-padding);background:var(--wg-pagination-btn-bg);border:var(--wg-pagination-btn-border);border-radius:var(--wg-pagination-btn-border-radius);color:var(--wg-cell-color);font-family:inherit;font-size:var(--wg-font-size-base);cursor:pointer;transition:all var(--wg-transition-fast)}.wg__pagination-btn:hover:not(:disabled){background:var(--wg-pagination-btn-bg-hover);border:var(--wg-pagination-btn-border-hover)}.wg__pagination-btn:active:not(:disabled){background:var(--wg-pagination-btn-bg-active)}.wg__pagination-btn:disabled{opacity:var(--wg-pagination-btn-disabled-opacity);cursor:not-allowed}.wg__pagination-info{font-size:var(--wg-font-size-base);color:var(--wg-cell-color)}.wg__pagination-count{font-size:var(--wg-font-size-sm);color:var(--wg-text-color-3);margin-left:4px}.wg__pagination-pagesize{display:flex;align-items:center;gap:6px}.wg__pagination-select{padding:4px 8px;background:var(--wg-pagination-btn-bg);border:var(--wg-pagination-btn-border);border-radius:var(--wg-pagination-btn-border-radius);color:var(--wg-cell-color);font-family:inherit;font-size:var(--wg-font-size-base);cursor:pointer}.wg__pagination-select:hover{background:var(--wg-pagination-btn-bg-hover);border:var(--wg-pagination-btn-border-hover)}.wg__pagination-select:focus{outline:2px solid var(--wg-accent-color);outline-offset:-2px}.wg__pagination-label{font-size:var(--wg-font-size-sm);color:var(--wg-text-color-3)}.wg__pagination--left{justify-content:flex-start}.wg__pagination--right{justify-content:flex-end}.wg__pagination--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__summary{display:flex;align-items:center;padding:var(--wg-pagination-padding);border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg);font-size:var(--wg-font-size-base);color:var(--wg-cell-color)}.wg__summary--left{justify-content:flex-start}.wg__summary--right{justify-content:flex-end}.wg__summary--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__footer{display:flex;align-items:center;justify-content:space-between;border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg)}.wg__footer--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__footer .wg__summary,.wg__footer .wg__pagination{border:none}.wg__footer .wg__summary{flex:0 0 auto}.wg__footer .wg__pagination{flex:0 0 auto;margin-left:auto}.wg__toolbar-container{position:fixed;z-index:var(--wg-z-toolbar, 1000)}.wg__toolbar{display:flex;flex-direction:column-reverse;gap:0;padding:0;background:var(--wg-toolbar-bg);border:var(--wg-toolbar-border);border-radius:var(--wg-toolbar-border-radius);box-shadow:var(--wg-toolbar-shadow)}.wg__toolbar-row{display:flex;gap:2px;align-items:center;height:var(--wg-toolbar-row-height);padding:0 4px}.wg__toolbar-row+.wg__toolbar-row{border-top:1px solid var(--wg-toolbar-divider-color)}.wg__toolbar-divider{width:1px;height:16px;background:var(--wg-toolbar-divider-color);margin:0 4px;flex-shrink:0}.wg__toolbar-btn{min-width:var(--wg-toolbar-btn-min-width);height:100%;border:none;border-radius:var(--wg-toolbar-btn-border-radius);background:transparent;color:var(--wg-toolbar-btn-color);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:4px;font-family:inherit;font-size:var(--wg-font-size-base);font-weight:500;padding:var(--wg-toolbar-btn-padding);transition:background .1s ease}.wg__toolbar-btn:hover{background:var(--wg-toolbar-btn-bg-hover)}.wg__toolbar-btn:active{background:var(--wg-toolbar-btn-bg-active)}.wg__toolbar-btn:disabled{opacity:.5;cursor:not-allowed}.wg__toolbar-btn:disabled:hover{background:transparent}.wg__toolbar-btn--danger:hover{background:var(--wg-danger-bg-light);color:var(--wg-danger-color)}.wg__toolbar-label{font-size:12px;white-space:nowrap}.wg__actions-column{width:24px;min-width:24px;max-width:24px;padding:0!important;text-align:center}.wg__header .wg__actions-column{background:var(--wg-header-bg)}.wg__filter-row .wg__actions-column{background:var(--wg-filter-bg)}.wg__toolbar-trigger{position:relative;padding:0;background:transparent;border:none;border-radius:var(--wg-border-radius-sm);cursor:pointer;font-size:var(--wg-font-size-base);line-height:1;color:var(--wg-toolbar-trigger-color)}.wg__toolbar-trigger:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:48px}.wg__toolbar-trigger:hover,.wg__toolbar-trigger--active{color:var(--wg-toolbar-trigger-color-hover);background:var(--wg-toolbar-trigger-bg-hover)}.wg__inline-actions-header,.wg__inline-actions-cell{width:1%;white-space:nowrap;text-align:center;padding:var(--wg-spacing-xs) var(--wg-spacing-sm)}.wg__inline-actions-header{background:var(--wg-header-bg)}.wg__inline-actions-wrap{display:flex;flex-direction:column;gap:2px;align-items:center}.wg__inline-actions-row{display:flex;gap:2px;align-items:center;justify-content:center}.wg__inline-action-btn{min-width:var(--wg-toolbar-btn-min-width);height:calc(2.4 * var(--wg-rem));border:none;border-radius:var(--wg-toolbar-btn-border-radius);background:transparent;color:var(--wg-toolbar-btn-color);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0 var(--wg-spacing-xs);font-family:inherit;font-size:var(--wg-font-size-base);transition:background var(--wg-transition-fast)}.wg__inline-action-btn:hover{background:var(--wg-toolbar-btn-bg-hover)}.wg__inline-action-btn:active{background:var(--wg-toolbar-btn-bg-active)}.wg__inline-action-btn:disabled,.wg__inline-action-btn--disabled{opacity:.5;cursor:not-allowed}.wg__inline-action-btn:disabled:hover,.wg__inline-action-btn--disabled:hover{background:transparent}.wg__inline-action-btn--danger:hover{background:var(--wg-danger-bg-light);color:var(--wg-danger-color)}.wg__shortcuts-help{position:absolute;top:var(--wg-spacing-xs);right:var(--wg-spacing-sm);z-index:5}.wg__shortcuts-help--left{right:auto;left:var(--wg-spacing-sm)}.wg__shortcuts-help-icon{display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:50%;background:var(--wg-surface-1);color:var(--wg-text-color-2);cursor:pointer;opacity:.7}.wg__shortcuts-help-icon:hover{opacity:1;background:var(--wg-surface-2)}.wg__shortcuts-help-icon svg{width:16px;height:16px}.wg__shortcuts-help-overlay{display:none;position:absolute;top:100%;right:0;margin-top:var(--wg-spacing-xs);padding:var(--wg-spacing-md);background:var(--wg-surface-1);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-md);box-shadow:0 4px 16px #00000026;min-width:200px;max-width:300px;z-index:100}.wg__shortcuts-help--left .wg__shortcuts-help-overlay{right:auto;left:0}.wg__shortcuts-help:hover .wg__shortcuts-help-overlay,.wg__shortcuts-help:focus-within .wg__shortcuts-help-overlay{display:block}.wg__shortcuts-help-title{font-weight:var(--wg-font-weight-semibold);font-size:var(--wg-font-size-base);color:var(--wg-text-color-1);margin-bottom:var(--wg-spacing-sm);padding-bottom:var(--wg-spacing-xs);border-bottom:1px solid var(--wg-border-color)}.wg__shortcuts-help-custom{margin-bottom:var(--wg-spacing-sm);padding-bottom:var(--wg-spacing-sm);border-bottom:1px solid var(--wg-border-color);font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2)}.wg__shortcuts-help-list{display:flex;flex-direction:column;gap:var(--wg-spacing-xs)}.wg__shortcuts-help-item{display:flex;align-items:center;gap:var(--wg-spacing-md)}.wg__shortcuts-help-key{display:inline-flex;align-items:center;justify-content:center;min-width:28px;padding:2px 6px;font-family:var(--wg-font-family-mono);font-size:var(--wg-font-size-xs);font-weight:var(--wg-font-weight-semibold);color:var(--wg-text-color-1);background:var(--wg-surface-2);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm)}.wg__shortcuts-help-label{flex:1;font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2)}.wg--striped tbody tr:nth-child(2n){background:var(--wg-row-bg-even)}.wg--hoverable tbody tr:hover{background:var(--wg-row-bg-hover)}.wg__empty{text-align:center;padding:var(--wg-empty-padding);color:var(--wg-empty-color);font-style:italic}.wg__loading-more{text-align:center;padding:var(--wg-cell-padding);color:var(--wg-text-color-2);font-size:var(--wg-font-size-sm)}.wg__tooltip{position:fixed;z-index:var(--wg-z-tooltip);max-width:300px;padding:6px 10px;background:var(--wg-tooltip-bg, #333);color:var(--wg-tooltip-color, #fff);font-size:var(--wg-font-size-sm);line-height:1.4;border-radius:var(--wg-border-radius-sm);box-shadow:0 2px 8px #0003;pointer-events:none;opacity:0;transition:opacity var(--wg-transition-fast)}.wg__tooltip--visible{opacity:1}.wg__tooltip-arrow{position:absolute;width:8px;height:8px;background:var(--wg-tooltip-bg, #333);transform:rotate(45deg)}.wg__tooltip[data-placement^=top] .wg__tooltip-arrow{bottom:-4px}.wg__tooltip[data-placement^=bottom] .wg__tooltip-arrow{top:-4px}.wg__tooltip[data-placement^=left] .wg__tooltip-arrow{right:-4px}.wg__tooltip[data-placement^=right] .wg__tooltip-arrow{left:-4px}.wg__tooltip-title{font-weight:600}.wg__tooltip-desc{opacity:.85;margin-top:2px}.wg__tooltip-shortcut{margin-top:4px;opacity:.7;font-size:.9em}.wg__goto-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0006;display:flex;align-items:center;justify-content:center;z-index:1000}.wg__goto-dialog{background:var(--wg-surface-1);border-radius:var(--wg-border-radius-md);padding:var(--wg-spacing-lg);box-shadow:0 4px 20px #00000026;min-width:250px}.wg__goto-label{display:block;margin-bottom:var(--wg-spacing-sm);font-size:var(--wg-font-size-base);color:var(--wg-text-color-1)}.wg__goto-input{width:100%;padding:var(--wg-spacing-sm) var(--wg-spacing-md);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm);font-family:inherit;font-size:var(--wg-font-size-base);margin-bottom:var(--wg-spacing-md);box-sizing:border-box}.wg__goto-input:focus{outline:none;border-color:var(--wg-accent-color);box-shadow:0 0 0 2px #0078d433}.wg__goto-buttons{display:flex;gap:var(--wg-spacing-sm);justify-content:flex-end}.wg__goto-btn{padding:var(--wg-spacing-sm) var(--wg-spacing-md);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm);font-family:inherit;font-size:var(--wg-font-size-sm);cursor:pointer;background:var(--wg-surface-1);color:var(--wg-text-color-1)}.wg__goto-btn:hover{background:var(--wg-surface-2)}.wg__goto-btn--go{background:var(--wg-accent-color);border-color:var(--wg-accent-color);color:#fff}.wg__goto-btn--go:hover{background:var(--wg-accent-color-hover, #106ebe)}.wg__spacer-top td,.wg__spacer-bottom td{padding:0;border:none;background:transparent;height:inherit;line-height:0}@media (prefers-color-scheme: dark){:host{--wg-surface-1: #1f1f1f;--wg-surface-2: #2b2b2b;--wg-surface-3: #333333;--wg-surface-floating: #2b2b2b;--wg-text-color-1: #e0e0e0;--wg-text-color-2: #c0c0c0;--wg-text-color-3: #a0a0a0;--wg-border-color: #3d3d3d;--wg-border-color-hover: #5a5a5a;--wg-input-bg: #1f1f1f;--wg-input-border: 1px solid #5a5a5a;--wg-hover-bg: #3a3a3a;--wg-active-bg: #4a4a4a;--wg-danger-bg-light: #442726;--wg-danger-color: #f87c86}}:host([data-theme="dark"]),[data-theme=dark] :host,:host([data-bs-theme="dark"]),[data-bs-theme=dark] :host,.dark :host{--wg-surface-1: #1f1f1f;--wg-surface-2: #2b2b2b;--wg-surface-3: #333333;--wg-surface-floating: #2b2b2b;--wg-text-color-1: #e0e0e0;--wg-text-color-2: #c0c0c0;--wg-text-color-3: #a0a0a0;--wg-border-color: #3d3d3d;--wg-border-color-hover: #5a5a5a;--wg-input-bg: #1f1f1f;--wg-input-border: 1px solid #5a5a5a;--wg-hover-bg: #3a3a3a;--wg-active-bg: #4a4a4a;--wg-danger-bg-light: #442726;--wg-danger-color: #f87c86}';function it(o,e,t){const i=t.valueMember||"value",r=t.displayMember||"label",n=e.find(s=>s[i]===o);return n?String(n[r]??""):o!=null?String(o):""}function He(o,e){if(e.getDisplayCallback)return e.getDisplayCallback(o);const t=e.displayMember||"label";return String(o[t]??o.label??"")}function Se(o,e){if(e.getValueCallback)return e.getValueCallback(o);const t=e.valueMember||"value";return o[t]??o.value}function Wo(o,e){return e.getIconCallback?e.getIconCallback(o):e.iconMember&&o[e.iconMember]||null}function Bo(o,e){return e.getSubtitleCallback?e.getSubtitleCallback(o):e.subtitleMember&&o[e.subtitleMember]||null}function Pe(o,e){return e.getDisabledCallback?e.getDisabledCallback(o):e.disabledMember?!!o[e.disabledMember]:!1}const pe=Math.min,K=Math.max,Be=Math.round,Ue=Math.floor,ae=o=>({x:o,y:o}),Uo={left:"right",right:"left",bottom:"top",top:"bottom"},jo={start:"end",end:"start"};function rt(o,e,t){return K(o,pe(e,t))}function Re(o,e){return typeof o=="function"?o(e):o}function me(o){return o.split("-")[0]}function $e(o){return o.split("-")[1]}function Ft(o){return o==="x"?"y":"x"}function nt(o){return o==="y"?"height":"width"}const Ko=new Set(["top","bottom"]);function ge(o){return Ko.has(me(o))?"y":"x"}function st(o){return Ft(ge(o))}function Xo(o,e,t){t===void 0&&(t=!1);const i=$e(o),r=st(o),n=nt(r);let s=r==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[n]>e.floating[n]&&(s=je(s)),[s,je(s)]}function Go(o){const e=je(o);return[lt(o),e,lt(e)]}function lt(o){return o.replace(/start|end/g,e=>jo[e])}const qt=["left","right"],Vt=["right","left"],Qo=["top","bottom"],Jo=["bottom","top"];function Zo(o,e,t){switch(o){case"top":case"bottom":return t?e?Vt:qt:e?qt:Vt;case"left":case"right":return e?Qo:Jo;default:return[]}}function ei(o,e,t,i){const r=$e(o);let n=Zo(me(o),t==="start",i);return r&&(n=n.map(s=>s+"-"+r),e&&(n=n.concat(n.map(lt)))),n}function je(o){return o.replace(/left|right|bottom|top/g,e=>Uo[e])}function ti(o){return{top:0,right:0,bottom:0,left:0,...o}}function Nt(o){return typeof o!="number"?ti(o):{top:o,right:o,bottom:o,left:o}}function Ke(o){const{x:e,y:t,width:i,height:r}=o;return{width:i,height:r,top:t,left:e,right:e+i,bottom:t+r,x:e,y:t}}function Yt(o,e,t){let{reference:i,floating:r}=o;const n=ge(e),s=st(e),a=nt(s),l=me(e),d=n==="y",g=i.x+i.width/2-r.width/2,u=i.y+i.height/2-r.height/2,c=i[a]/2-r[a]/2;let h;switch(l){case"top":h={x:g,y:i.y-r.height};break;case"bottom":h={x:g,y:i.y+i.height};break;case"right":h={x:i.x+i.width,y:u};break;case"left":h={x:i.x-r.width,y:u};break;default:h={x:i.x,y:i.y}}switch($e(e)){case"start":h[s]-=c*(t&&d?-1:1);break;case"end":h[s]+=c*(t&&d?-1:1);break}return h}const oi=async(o,e,t)=>{const{placement:i="bottom",strategy:r="absolute",middleware:n=[],platform:s}=t,a=n.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(e));let d=await s.getElementRects({reference:o,floating:e,strategy:r}),{x:g,y:u}=Yt(d,i,l),c=i,h={},f=0;for(let p=0;p<a.length;p++){const{name:v,fn:m}=a[p],{x:y,y:_,data:S,reset:b}=await m({x:g,y:u,initialPlacement:i,placement:c,strategy:r,middlewareData:h,rects:d,platform:s,elements:{reference:o,floating:e}});g=y??g,u=_??u,h={...h,[v]:{...h[v],...S}},b&&f<=50&&(f++,typeof b=="object"&&(b.placement&&(c=b.placement),b.rects&&(d=b.rects===!0?await s.getElementRects({reference:o,floating:e,strategy:r}):b.rects),{x:g,y:u}=Yt(d,c,l)),p=-1)}return{x:g,y:u,placement:c,strategy:r,middlewareData:h}};async function at(o,e){var t;e===void 0&&(e={});const{x:i,y:r,platform:n,rects:s,elements:a,strategy:l}=o,{boundary:d="clippingAncestors",rootBoundary:g="viewport",elementContext:u="floating",altBoundary:c=!1,padding:h=0}=Re(e,o),f=Nt(h),v=a[c?u==="floating"?"reference":"floating":u],m=Ke(await n.getClippingRect({element:(t=await(n.isElement==null?void 0:n.isElement(v)))==null||t?v:v.contextElement||await(n.getDocumentElement==null?void 0:n.getDocumentElement(a.floating)),boundary:d,rootBoundary:g,strategy:l})),y=u==="floating"?{x:i,y:r,width:s.floating.width,height:s.floating.height}:s.reference,_=await(n.getOffsetParent==null?void 0:n.getOffsetParent(a.floating)),S=await(n.isElement==null?void 0:n.isElement(_))?await(n.getScale==null?void 0:n.getScale(_))||{x:1,y:1}:{x:1,y:1},b=Ke(n.convertOffsetParentRelativeRectToViewportRelativeRect?await n.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:_,strategy:l}):y);return{top:(m.top-b.top+f.top)/S.y,bottom:(b.bottom-m.bottom+f.bottom)/S.y,left:(m.left-b.left+f.left)/S.x,right:(b.right-m.right+f.right)/S.x}}const ii=o=>({name:"arrow",options:o,async fn(e){const{x:t,y:i,placement:r,rects:n,platform:s,elements:a,middlewareData:l}=e,{element:d,padding:g=0}=Re(o,e)||{};if(d==null)return{};const u=Nt(g),c={x:t,y:i},h=st(r),f=nt(h),p=await s.getDimensions(d),v=h==="y",m=v?"top":"left",y=v?"bottom":"right",_=v?"clientHeight":"clientWidth",S=n.reference[f]+n.reference[h]-c[h]-n.floating[f],b=c[h]-n.reference[h],C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d));let x=C?C[_]:0;(!x||!await(s.isElement==null?void 0:s.isElement(C)))&&(x=a.floating[_]||n.floating[f]);const k=S/2-b/2,T=x/2-p[f]/2-1,E=pe(u[m],T),M=pe(u[y],T),F=E,O=x-p[f]-M,I=x/2-p[f]/2+k,L=rt(F,I,O),D=!l.arrow&&$e(r)!=null&&I!==L&&n.reference[f]/2-(I<F?E:M)-p[f]/2<0,q=D?I<F?I-F:I-O:0;return{[h]:c[h]+q,data:{[h]:L,centerOffset:I-L-q,...D&&{alignmentOffset:q}},reset:D}}}),ri=function(o){return o===void 0&&(o={}),{name:"flip",options:o,async fn(e){var t,i;const{placement:r,middlewareData:n,rects:s,initialPlacement:a,platform:l,elements:d}=e,{mainAxis:g=!0,crossAxis:u=!0,fallbackPlacements:c,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:p=!0,...v}=Re(o,e);if((t=n.arrow)!=null&&t.alignmentOffset)return{};const m=me(r),y=ge(a),_=me(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(d.floating)),b=c||(_||!p?[je(a)]:Go(a)),C=f!=="none";!c&&C&&b.push(...ei(a,p,f,S));const x=[a,...b],k=await at(e,v),T=[];let E=((i=n.flip)==null?void 0:i.overflows)||[];if(g&&T.push(k[m]),u){const I=Xo(r,s,S);T.push(k[I[0]],k[I[1]])}if(E=[...E,{placement:r,overflows:T}],!T.every(I=>I<=0)){var M,F;const I=(((M=n.flip)==null?void 0:M.index)||0)+1,L=x[I];if(L&&(!(u==="alignment"?y!==ge(L):!1)||E.every(V=>ge(V.placement)===y?V.overflows[0]>0:!0)))return{data:{index:I,overflows:E},reset:{placement:L}};let D=(F=E.filter(q=>q.overflows[0]<=0).sort((q,V)=>q.overflows[1]-V.overflows[1])[0])==null?void 0:F.placement;if(!D)switch(h){case"bestFit":{var O;const q=(O=E.filter(V=>{if(C){const A=ge(V.placement);return A===y||A==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(A=>A>0).reduce((A,We)=>A+We,0)]).sort((V,A)=>V[1]-A[1])[0])==null?void 0:O[0];q&&(D=q);break}case"initialPlacement":D=a;break}if(r!==D)return{reset:{placement:D}}}return{}}}},ni=new Set(["left","top"]);async function si(o,e){const{placement:t,platform:i,elements:r}=o,n=await(i.isRTL==null?void 0:i.isRTL(r.floating)),s=me(t),a=$e(t),l=ge(t)==="y",d=ni.has(s)?-1:1,g=n&&l?-1:1,u=Re(e,o);let{mainAxis:c,crossAxis:h,alignmentAxis:f}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof f=="number"&&(h=a==="end"?f*-1:f),l?{x:h*g,y:c*d}:{x:c*d,y:h*g}}const li=function(o){return o===void 0&&(o=0),{name:"offset",options:o,async fn(e){var t,i;const{x:r,y:n,placement:s,middlewareData:a}=e,l=await si(e,o);return s===((t=a.offset)==null?void 0:t.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:r+l.x,y:n+l.y,data:{...l,placement:s}}}}},ai=function(o){return o===void 0&&(o={}),{name:"shift",options:o,async fn(e){const{x:t,y:i,placement:r}=e,{mainAxis:n=!0,crossAxis:s=!1,limiter:a={fn:v=>{let{x:m,y}=v;return{x:m,y}}},...l}=Re(o,e),d={x:t,y:i},g=await at(e,l),u=ge(me(r)),c=Ft(u);let h=d[c],f=d[u];if(n){const v=c==="y"?"top":"left",m=c==="y"?"bottom":"right",y=h+g[v],_=h-g[m];h=rt(y,h,_)}if(s){const v=u==="y"?"top":"left",m=u==="y"?"bottom":"right",y=f+g[v],_=f-g[m];f=rt(y,f,_)}const p=a.fn({...e,[c]:h,[u]:f});return{...p,data:{x:p.x-t,y:p.y-i,enabled:{[c]:n,[u]:s}}}}}},di=function(o){return o===void 0&&(o={}),{name:"size",options:o,async fn(e){var t,i;const{placement:r,rects:n,platform:s,elements:a}=e,{apply:l=()=>{},...d}=Re(o,e),g=await at(e,d),u=me(r),c=$e(r),h=ge(r)==="y",{width:f,height:p}=n.floating;let v,m;u==="top"||u==="bottom"?(v=u,m=c===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(m=u,v=c==="end"?"top":"bottom");const y=p-g.top-g.bottom,_=f-g.left-g.right,S=pe(p-g[v],y),b=pe(f-g[m],_),C=!e.middlewareData.shift;let x=S,k=b;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(k=_),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(x=y),C&&!c){const E=K(g.left,0),M=K(g.right,0),F=K(g.top,0),O=K(g.bottom,0);h?k=f-2*(E!==0||M!==0?E+M:K(g.left,g.right)):x=p-2*(F!==0||O!==0?F+O:K(g.top,g.bottom))}await l({...e,availableWidth:k,availableHeight:x});const T=await s.getDimensions(a.floating);return f!==T.width||p!==T.height?{reset:{rects:!0}}:{}}}};function Xe(){return typeof window<"u"}function Me(o){return Wt(o)?(o.nodeName||"").toLowerCase():"#document"}function X(o){var e;return(o==null||(e=o.ownerDocument)==null?void 0:e.defaultView)||window}function de(o){var e;return(e=(Wt(o)?o.ownerDocument:o.document)||window.document)==null?void 0:e.documentElement}function Wt(o){return Xe()?o instanceof Node||o instanceof X(o).Node:!1}function ie(o){return Xe()?o instanceof Element||o instanceof X(o).Element:!1}function ce(o){return Xe()?o instanceof HTMLElement||o instanceof X(o).HTMLElement:!1}function Bt(o){return!Xe()||typeof ShadowRoot>"u"?!1:o instanceof ShadowRoot||o instanceof X(o).ShadowRoot}const ci=new Set(["inline","contents"]);function Fe(o){const{overflow:e,overflowX:t,overflowY:i,display:r}=re(o);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!ci.has(r)}const gi=new Set(["table","td","th"]);function ui(o){return gi.has(Me(o))}const hi=[":popover-open",":modal"];function Ge(o){return hi.some(e=>{try{return o.matches(e)}catch{return!1}})}const fi=["transform","translate","scale","rotate","perspective"],wi=["transform","translate","scale","rotate","perspective","filter"],pi=["paint","layout","strict","content"];function dt(o){const e=ct(),t=ie(o)?re(o):o;return fi.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||wi.some(i=>(t.willChange||"").includes(i))||pi.some(i=>(t.contain||"").includes(i))}function mi(o){let e=be(o);for(;ce(e)&&!Te(e);){if(dt(e))return e;if(Ge(e))return null;e=be(e)}return null}function ct(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const bi=new Set(["html","body","#document"]);function Te(o){return bi.has(Me(o))}function re(o){return X(o).getComputedStyle(o)}function Qe(o){return ie(o)?{scrollLeft:o.scrollLeft,scrollTop:o.scrollTop}:{scrollLeft:o.scrollX,scrollTop:o.scrollY}}function be(o){if(Me(o)==="html")return o;const e=o.assignedSlot||o.parentNode||Bt(o)&&o.host||de(o);return Bt(e)?e.host:e}function Ut(o){const e=be(o);return Te(e)?o.ownerDocument?o.ownerDocument.body:o.body:ce(e)&&Fe(e)?e:Ut(e)}function qe(o,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const r=Ut(o),n=r===((i=o.ownerDocument)==null?void 0:i.body),s=X(r);if(n){const a=gt(s);return e.concat(s,s.visualViewport||[],Fe(r)?r:[],a&&t?qe(a):[])}return e.concat(r,qe(r,[],t))}function gt(o){return o.parent&&Object.getPrototypeOf(o.parent)?o.frameElement:null}function jt(o){const e=re(o);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=ce(o),n=r?o.offsetWidth:t,s=r?o.offsetHeight:i,a=Be(t)!==n||Be(i)!==s;return a&&(t=n,i=s),{width:t,height:i,$:a}}function ut(o){return ie(o)?o:o.contextElement}function ze(o){const e=ut(o);if(!ce(e))return ae(1);const t=e.getBoundingClientRect(),{width:i,height:r,$:n}=jt(e);let s=(n?Be(t.width):t.width)/i,a=(n?Be(t.height):t.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}const _i=ae(0);function Kt(o){const e=X(o);return!ct()||!e.visualViewport?_i:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function vi(o,e,t){return e===void 0&&(e=!1),!t||e&&t!==X(o)?!1:e}function xe(o,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const r=o.getBoundingClientRect(),n=ut(o);let s=ae(1);e&&(i?ie(i)&&(s=ze(i)):s=ze(o));const a=vi(n,t,i)?Kt(n):ae(0);let l=(r.left+a.x)/s.x,d=(r.top+a.y)/s.y,g=r.width/s.x,u=r.height/s.y;if(n){const c=X(n),h=i&&ie(i)?X(i):i;let f=c,p=gt(f);for(;p&&i&&h!==f;){const v=ze(p),m=p.getBoundingClientRect(),y=re(p),_=m.left+(p.clientLeft+parseFloat(y.paddingLeft))*v.x,S=m.top+(p.clientTop+parseFloat(y.paddingTop))*v.y;l*=v.x,d*=v.y,g*=v.x,u*=v.y,l+=_,d+=S,f=X(p),p=gt(f)}}return Ke({width:g,height:u,x:l,y:d})}function Je(o,e){const t=Qe(o).scrollLeft;return e?e.left+t:xe(de(o)).left+t}function Xt(o,e){const t=o.getBoundingClientRect(),i=t.left+e.scrollLeft-Je(o,t),r=t.top+e.scrollTop;return{x:i,y:r}}function yi(o){let{elements:e,rect:t,offsetParent:i,strategy:r}=o;const n=r==="fixed",s=de(i),a=e?Ge(e.floating):!1;if(i===s||a&&n)return t;let l={scrollLeft:0,scrollTop:0},d=ae(1);const g=ae(0),u=ce(i);if((u||!u&&!n)&&((Me(i)!=="body"||Fe(s))&&(l=Qe(i)),ce(i))){const h=xe(i);d=ze(i),g.x=h.x+i.clientLeft,g.y=h.y+i.clientTop}const c=s&&!u&&!n?Xt(s,l):ae(0);return{width:t.width*d.x,height:t.height*d.y,x:t.x*d.x-l.scrollLeft*d.x+g.x+c.x,y:t.y*d.y-l.scrollTop*d.y+g.y+c.y}}function Ci(o){return Array.from(o.getClientRects())}function Si(o){const e=de(o),t=Qe(o),i=o.ownerDocument.body,r=K(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),n=K(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let s=-t.scrollLeft+Je(o);const a=-t.scrollTop;return re(i).direction==="rtl"&&(s+=K(e.clientWidth,i.clientWidth)-r),{width:r,height:n,x:s,y:a}}const Gt=25;function xi(o,e){const t=X(o),i=de(o),r=t.visualViewport;let n=i.clientWidth,s=i.clientHeight,a=0,l=0;if(r){n=r.width,s=r.height;const g=ct();(!g||g&&e==="fixed")&&(a=r.offsetLeft,l=r.offsetTop)}const d=Je(i);if(d<=0){const g=i.ownerDocument,u=g.body,c=getComputedStyle(u),h=g.compatMode==="CSS1Compat"&&parseFloat(c.marginLeft)+parseFloat(c.marginRight)||0,f=Math.abs(i.clientWidth-u.clientWidth-h);f<=Gt&&(n-=f)}else d<=Gt&&(n+=d);return{width:n,height:s,x:a,y:l}}const ki=new Set(["absolute","fixed"]);function Di(o,e){const t=xe(o,!0,e==="fixed"),i=t.top+o.clientTop,r=t.left+o.clientLeft,n=ce(o)?ze(o):ae(1),s=o.clientWidth*n.x,a=o.clientHeight*n.y,l=r*n.x,d=i*n.y;return{width:s,height:a,x:l,y:d}}function Qt(o,e,t){let i;if(e==="viewport")i=xi(o,t);else if(e==="document")i=Si(de(o));else if(ie(e))i=Di(e,t);else{const r=Kt(o);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return Ke(i)}function Jt(o,e){const t=be(o);return t===e||!ie(t)||Te(t)?!1:re(t).position==="fixed"||Jt(t,e)}function Ei(o,e){const t=e.get(o);if(t)return t;let i=qe(o,[],!1).filter(a=>ie(a)&&Me(a)!=="body"),r=null;const n=re(o).position==="fixed";let s=n?be(o):o;for(;ie(s)&&!Te(s);){const a=re(s),l=dt(s);!l&&a.position==="fixed"&&(r=null),(n?!l&&!r:!l&&a.position==="static"&&!!r&&ki.has(r.position)||Fe(s)&&!l&&Jt(o,s))?i=i.filter(g=>g!==s):r=a,s=be(s)}return e.set(o,i),i}function Ri(o){let{element:e,boundary:t,rootBoundary:i,strategy:r}=o;const s=[...t==="clippingAncestors"?Ge(e)?[]:Ei(e,this._c):[].concat(t),i],a=s[0],l=s.reduce((d,g)=>{const u=Qt(e,g,r);return d.top=K(u.top,d.top),d.right=pe(u.right,d.right),d.bottom=pe(u.bottom,d.bottom),d.left=K(u.left,d.left),d},Qt(e,a,r));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function $i(o){const{width:e,height:t}=jt(o);return{width:e,height:t}}function Mi(o,e,t){const i=ce(e),r=de(e),n=t==="fixed",s=xe(o,!0,n,e);let a={scrollLeft:0,scrollTop:0};const l=ae(0);function d(){l.x=Je(r)}if(i||!i&&!n)if((Me(e)!=="body"||Fe(r))&&(a=Qe(e)),i){const h=xe(e,!0,n,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else r&&d();n&&!i&&r&&d();const g=r&&!i&&!n?Xt(r,a):ae(0),u=s.left+a.scrollLeft-l.x-g.x,c=s.top+a.scrollTop-l.y-g.y;return{x:u,y:c,width:s.width,height:s.height}}function ht(o){return re(o).position==="static"}function Zt(o,e){if(!ce(o)||re(o).position==="fixed")return null;if(e)return e(o);let t=o.offsetParent;return de(o)===t&&(t=t.ownerDocument.body),t}function eo(o,e){const t=X(o);if(Ge(o))return t;if(!ce(o)){let r=be(o);for(;r&&!Te(r);){if(ie(r)&&!ht(r))return r;r=be(r)}return t}let i=Zt(o,e);for(;i&&ui(i)&&ht(i);)i=Zt(i,e);return i&&Te(i)&&ht(i)&&!dt(i)?t:i||mi(o)||t}const Ti=async function(o){const e=this.getOffsetParent||eo,t=this.getDimensions,i=await t(o.floating);return{reference:Mi(o.reference,await e(o.floating),o.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function zi(o){return re(o).direction==="rtl"}const Ii={convertOffsetParentRelativeRectToViewportRelativeRect:yi,getDocumentElement:de,getClippingRect:Ri,getOffsetParent:eo,getElementRects:Ti,getClientRects:Ci,getDimensions:$i,getScale:ze,isElement:ie,isRTL:zi};function to(o,e){return o.x===e.x&&o.y===e.y&&o.width===e.width&&o.height===e.height}function Li(o,e){let t=null,i;const r=de(o);function n(){var a;clearTimeout(i),(a=t)==null||a.disconnect(),t=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),n();const d=o.getBoundingClientRect(),{left:g,top:u,width:c,height:h}=d;if(a||e(),!c||!h)return;const f=Ue(u),p=Ue(r.clientWidth-(g+c)),v=Ue(r.clientHeight-(u+h)),m=Ue(g),_={rootMargin:-f+"px "+-p+"px "+-v+"px "+-m+"px",threshold:K(0,pe(1,l))||1};let S=!0;function b(C){const x=C[0].intersectionRatio;if(x!==l){if(!S)return s();x?s(!1,x):i=setTimeout(()=>{s(!1,1e-7)},1e3)}x===1&&!to(d,o.getBoundingClientRect())&&s(),S=!1}try{t=new IntersectionObserver(b,{..._,root:r.ownerDocument})}catch{t=new IntersectionObserver(b,_)}t.observe(o)}return s(!0),n}function Ai(o,e,t,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:n=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,d=ut(o),g=r||n?[...d?qe(d):[],...qe(e)]:[];g.forEach(m=>{r&&m.addEventListener("scroll",t,{passive:!0}),n&&m.addEventListener("resize",t)});const u=d&&a?Li(d,t):null;let c=-1,h=null;s&&(h=new ResizeObserver(m=>{let[y]=m;y&&y.target===d&&h&&(h.unobserve(e),cancelAnimationFrame(c),c=requestAnimationFrame(()=>{var _;(_=h)==null||_.observe(e)})),t()}),d&&!l&&h.observe(d),h.observe(e));let f,p=l?xe(o):null;l&&v();function v(){const m=xe(o);p&&!to(p,m)&&t(),p=m,f=requestAnimationFrame(v)}return t(),()=>{var m;g.forEach(y=>{r&&y.removeEventListener("scroll",t),n&&y.removeEventListener("resize",t)}),u==null||u(),(m=h)==null||m.disconnect(),h=null,l&&cancelAnimationFrame(f)}}const ft=li,Ze=ai,Ie=ri,Oi=di,Hi=ii,Le=(o,e,t)=>{const i=new Map,r={platform:Ii,...t},n={...r.platform,_c:i};return oi(o,e,{...r,platform:n})};function ke(o,e,t,i){var n;N(o);const r=document.createElement("div");if(r.className="wg__dropdown",r.style.cssText=`
2
- position: fixed;
3
- top: 0;
4
- left: 0;
5
- max-height: 200px;
6
- overflow-y: auto;
7
- z-index: 1000;
8
- `,t.length===0){const s=o.isSearching?i.searchingText||o.grid.labels.dropdownSearching:i.noOptionsText||o.grid.labels.dropdownNoOptions;r.innerHTML=`<div class="wg__dropdown-empty">${o.escapeHtml(s)}</div>`}else{const s=o.grid.editingCell,a=s?(n=o.grid.displayItems[s.rowIndex])==null?void 0:n[s.field]:void 0;r.innerHTML=t.map((l,d)=>{const g=d===o.highlightedIndex,u=Se(l,i)===a,c=Pe(l,i);if(i.renderOptionCallback){const _={index:d,isHighlighted:g,isSelected:u,isDisabled:c};return i.renderOptionCallback(l,_)}const h=He(l,i),f=Wo(l,i),p=Bo(l,i),v=["wg__dropdown-option"];g&&v.push("wg__dropdown-option--highlighted"),u&&v.push("wg__dropdown-option--selected"),c&&v.push("wg__dropdown-option--disabled");const m=f?`<span class="wg__dropdown-option-icon">${o.escapeHtml(f)}</span>`:"",y=p?`<span class="wg__dropdown-option-subtitle">${o.escapeHtml(p)}</span>`:"";return`<div class="${v.join(" ")}" data-index="${d}" ${c?'data-disabled="true"':""}>
9
- ${m}
10
- <div class="wg__dropdown-option-content">
11
- <span class="wg__dropdown-option-label">${o.escapeHtml(h)}</span>
12
- ${y}
13
- </div>
14
- </div>`}).join("")}return o.shadow.appendChild(r),o.dropdownOpen=!0,Le(e,r,{strategy:"fixed",placement:"bottom-start",middleware:[ft(1),Ie({fallbackPlacements:["top-start"]}),Oi({apply({rects:s}){Object.assign(r.style,{width:`${s.reference.width}px`})}})]}).then(({x:s,y:a})=>{Object.assign(r.style,{left:`${s}px`,top:`${a}px`})}),r}function N(o){const e=o.shadow.querySelector(".wg__dropdown");e==null||e.remove(),o.dropdownOpen=!1,o.highlightedIndex=-1,o.filterText=""}function Pi(o,e,t){if(o.grid.shouldUseVirtualScroll()){Fi(o,e);const s=o.shadow.querySelector(`[data-row="${e}"][data-col="${t}"]`);s&&s.focus({preventScroll:!0});return}const i=o.shadow.querySelector(`[data-row="${e}"][data-col="${t}"]`);if(!i)return;i.focus({preventScroll:!0}),i.scrollIntoView({block:"nearest",inline:"nearest"});const r=o.shadow.querySelector(".wg__header"),n=o.shadow.querySelector(".wg");if(r&&n){const s=r.getBoundingClientRect(),a=i.getBoundingClientRect();if(a.top<s.bottom){const l=a.top-s.bottom-4;n.scrollBy({top:l,behavior:"instant"})}}}function Fi(o,e){const t=o.shadow.querySelector(".wg");if(!t)return;const i=o.grid.virtualScrollRowHeight,r=t.scrollTop,n=t.clientHeight,s=o.shadow.querySelector(".wg__header"),a=(s==null?void 0:s.offsetHeight)||0,l=e*i,d=l+i,g=r+a,u=r+n;l<g?t.scrollTop=l-a:d>u&&(t.scrollTop=d-n)}let oo=0;const qi=100;function te(o,e,t){const i=e&&t&&e.rowIndex===t.rowIndex&&e.colIndex===t.colIndex,r=Date.now();if(i&&r-oo<qi)return;oo=r;const n=o.grid.editingCell;e&&(n&&n.rowIndex===e.rowIndex&&o.grid.columns.findIndex(a=>String(a.field)===n.field)===e.colIndex||j(o,e.rowIndex,e.colIndex)),t&&(n&&n.rowIndex===t.rowIndex&&o.grid.columns.findIndex(a=>String(a.field)===n.field)===t.colIndex||j(o,t.rowIndex,t.colIndex))}function G(o){const e=o.grid.editingCell;if(e){const t=o.grid.columns.findIndex(r=>String(r.field)===e.field),i=o.shadow.querySelector(`[data-row="${e.rowIndex}"][data-col="${t}"]`);i&&i.classList.remove("wg__cell--editing")}}let io=0;const Vi=50;function Ni(o,e,t){if(!o.grid.isNavigateMode)return;const i=Date.now();if(i-io<Vi){o.grid.setFocusedCell(e,t);return}io=i;const r=o.grid.focusedCell,n={rowIndex:e,colIndex:t};o.grid.setFocusedCell(e,t),te(o,r,n)}function z(o,e,t){const i=o.grid.focusedCell,r={rowIndex:e,colIndex:t};o.grid.setFocusedCell(e,t),te(o,i,r),Pi(o,e,t)}function oe(o,e,t,i){const r=o.grid.columns[t];if(!r||!o.grid.isCellEditable(r))return;const n=String(r.field);o.dropdownOpen&&N(o);const s=o.grid.focusedCell;s&&(s.rowIndex!==e||s.colIndex!==t)&&(o.grid.clearFocusedCell(),j(o,s.rowIndex,s.colIndex)),o.grid.startEdit(e,n,i),j(o,e,t,{focusEditor:!0,cursorPosition:i==null?void 0:i.cursorPosition,initialSearchQuery:i==null?void 0:i.initialSearchQuery})}function wt(o,e){const t=e.querySelector(".wg__cell-text");if(!t)return null;const i=t.textContent||"";if(!i.length)return 0;const r=o.clientX,n=t.getBoundingClientRect();if(r<=n.left)return 0;if(r>=n.right)return i.length;const s=t.firstChild;if(!s||s.nodeType!==Node.TEXT_NODE)return null;const a=document.createRange();let l=0,d=i.length;try{for(;l<d;){const g=Math.floor((l+d)/2);a.setStart(s,0),a.setEnd(s,g),a.getBoundingClientRect().right<r?l=g+1:d=g}if(l>0&&l<i.length){a.setStart(s,l-1),a.setEnd(s,l);const g=a.getBoundingClientRect(),u=g.left+g.width/2;r<u&&l--}}catch{return i.length}return l}function Yi(o,e){const t=e.relatedTarget,i=o.shadow.querySelector(".wg__table");if(!t||!(i!=null&&i.contains(t))){const r=o.grid.focusedCell;o.grid.clearFocusedCell(),te(o,r,null)}}function Wi(o,e){if(!o)return null;const[t,i,r]=o.split("-").map(Number),n=new Date(t,i-1,r);if(isNaN(n.getTime()))return null;switch(e){case"date":return n;case"timestamp":return n.getTime();case"iso":default:return o}}function pt(o,e,t){j(o,e,t)}function et(o,e){const t=parseInt(e.dataset.row||"0",10),i=e.dataset.field||"";let r;if(e instanceof HTMLInputElement)if(e.type==="checkbox"){const n=JSON.parse(e.dataset.trueValue||"true"),s=JSON.parse(e.dataset.falseValue||"false");r=e.checked?n:s}else e.classList.contains("wg__editor--number")?r=e.value===""?null:parseFloat(e.value):e.type==="date"?r=Wi(e.value,e.dataset.outputFormat||"iso"):r=e.value;else e instanceof HTMLSelectElement&&(r=e.value);o.grid.commitEdit(t,i,r)}function Bi(o,e){et(o,e)}function Ui(o,e,t){const i=o.grid.columns[t];if(!i)return;const r=String(i.field),n=o.grid.displayItems[e];if(!n)return;const s=i.editorOptions||{},a=s.trueValue??!0,l=s.falseValue??!1,g=n[r]===a?l:a;o.grid.commitEdit(e,r,g),j(o,e,t);const u=o.grid.displayItems;e<u.length-1&&requestAnimationFrame(()=>{z(o,e+1,t)})}function ji(o,e){if(!o.isCommittingFromKeyboard&&o.grid.editingCell){const t=parseInt(e.dataset.row||"0",10),i=e.dataset.field||"",r=o.grid.columns.findIndex(n=>String(n.field)===i);et(o,e),r>=0&&pt(o,t,r)}}function mt(o,e,t,i){const n=o.grid.columns.findIndex(d=>String(d.field)===t),s=o.grid.displayItems;let a=e,l=n;if(i==="down")a=Math.min(e+1,s.length-1);else if(i==="up")a=Math.max(e-1,0);else{const d=o.grid.getEditableColumns(),g=d.findIndex(u=>u.index===n);i==="next"?g>=0&&g<d.length-1?l=d[g+1].index:e<s.length-1&&(a=e+1,l=d[0].index):g>0?l=d[g-1].index:e>0&&(a=e-1,l=d[d.length-1].index)}pt(o,e,n),z(o,a,l),o.isCommittingFromKeyboard=!1}function Ki(o,e,t){const r=o.grid.columns.findIndex(n=>String(n.field)===t);r>=0&&(pt(o,e,r),z(o,e,r),o.isCommittingFromKeyboard=!1)}function tt(o,e,t,i){const r=String(i.field),n=o.grid.displayItems[e],s=o.grid.getCellRawValue(n,e,r);switch(i.editor||"text"){case"checkbox":return Zi(o,e,r,s,i);case"number":return Gi(o,e,r,s,i);case"date":return Qi(o,e,r,s,i);case"select":return er(o,e,r,s,i);case"combobox":return tr(o,e,r,s,i);case"autocomplete":return or(o,e,r,s,i);case"custom":return ir(o,e,r,s,i);case"text":default:return Xi(o,e,r,s,i)}}function Xi(o,e,t,i,r){var l;const n=r.editorOptions||{},s=(l=o.grid.editingCell)==null?void 0:l.initialSearchQuery,a=s!==void 0?s:i!=null?String(i):"";return`
15
- <input
16
- type="text"
17
- class="wg__editor wg__editor--text"
18
- value="${o.escapeHtml(a)}"
19
- data-row="${e}"
20
- data-field="${t}"
21
- ${n.maxLength?`maxlength="${n.maxLength}"`:""}
22
- ${n.placeholder?`placeholder="${o.escapeHtml(n.placeholder)}"`:""}
23
- ${n.pattern?`pattern="${o.escapeHtml(n.pattern)}"`:""}
24
- />
25
- `}function Gi(o,e,t,i,r){var a;r.editorOptions;const n=(a=o.grid.editingCell)==null?void 0:a.initialSearchQuery;return`
26
- <input
27
- type="text"
28
- inputmode="numeric"
29
- class="wg__editor wg__editor--number"
30
- value="${n!==void 0?n:i!=null?String(i):""}"
31
- data-row="${e}"
32
- data-field="${t}"
33
- />
34
- `}function Qi(o,e,t,i,r){var d;const n=r.editorOptions||{},s=(d=o.grid.editingCell)==null?void 0:d.initialSearchQuery,a=bt(i),l=s!==void 0?s:Ji(i,n.dateFormat);return`
35
- <div class="wg__editor wg__editor--date" data-row="${e}" data-field="${t}">
36
- <input
37
- type="text"
38
- class="wg__date-input"
39
- value="${o.escapeHtml(l)}"
40
- data-row="${e}"
41
- data-field="${t}"
42
- data-date-value="${a}"
43
- data-output-format="${n.outputFormat||"iso"}"
44
- data-date-format="${n.dateFormat||"YYYY-MM-DD"}"
45
- ${n.minDate?`data-min-date="${bt(n.minDate)}"`:""}
46
- ${n.maxDate?`data-max-date="${bt(n.maxDate)}"`:""}
47
- placeholder="${o.escapeHtml(n.dateFormat||"YYYY-MM-DD")}"
48
- />
49
- <button type="button" class="wg__date-trigger" tabindex="-1">
50
- <svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM9 10H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm-8 4H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2z"/></svg>
51
- </button>
52
- </div>
53
- `}function Ji(o,e){if(!o)return"";let t=null;if(o instanceof Date?t=o:typeof o=="number"?t=new Date(o):typeof o=="string"&&(t=new Date(o)),!t||isNaN(t.getTime()))return"";const i=e||"YYYY-MM-DD",r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return i.replace("YYYY",String(r)).replace("YY",String(r).slice(-2)).replace("MM",n).replace("DD",s)}function bt(o){if(!o)return"";let e=null;if(o instanceof Date?e=o:typeof o=="number"?e=new Date(o):typeof o=="string"&&(e=new Date(o)),!e||isNaN(e.getTime()))return"";const t=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${t}-${i}-${r}`}function Zi(o,e,t,i,r){const n=r.editorOptions||{},s=n.trueValue!==void 0?n.trueValue:!0;return`
54
- <input
55
- type="checkbox"
56
- class="wg__editor wg__editor--checkbox"
57
- ${i===s?"checked":""}
58
- data-row="${e}"
59
- data-field="${t}"
60
- data-true-value="${o.escapeHtml(JSON.stringify(n.trueValue??!0))}"
61
- data-false-value="${o.escapeHtml(JSON.stringify(n.falseValue??!1))}"
62
- />
63
- `}function er(o,e,t,i,r){var d;const n=r.editorOptions||{},s=n.options||[],a=it(i,s,n),l=(d=o.grid.editingCell)==null?void 0:d.initialSearchQuery;return o.dropdownOptions=s,o.filterText=l||"",o.highlightedIndex=s.findIndex(g=>Se(g,n)===i),o.highlightedIndex<0&&s.length>0&&(o.highlightedIndex=0),`
64
- <div
65
- class="wg__editor wg__editor--select wg__select-trigger"
66
- tabindex="0"
67
- role="combobox"
68
- aria-haspopup="listbox"
69
- data-row="${e}"
70
- data-field="${t}"
71
- >
72
- <span class="wg__select-value">${o.escapeHtml(a)}</span>
73
- <span class="wg__select-toggle">▼</span>
74
- </div>
75
- `}function tr(o,e,t,i,r){var g;const n=r.editorOptions||{},s=n.options||[],a=it(i,s,n),l=(g=o.grid.editingCell)==null?void 0:g.initialSearchQuery,d=l!==void 0?l:a;return o.dropdownOptions=s,o.filterText=d,o.highlightedIndex=s.length>0?0:-1,`
76
- <div class="wg__editor wg__editor--combobox" data-row="${e}" data-field="${t}">
77
- <input
78
- type="text"
79
- class="wg__combobox-input"
80
- value="${o.escapeHtml(d)}"
81
- data-row="${e}"
82
- data-field="${t}"
83
- />
84
- <span class="wg__combobox-toggle">▼</span>
85
- </div>
86
- `}function or(o,e,t,i,r){var g;const n=r.editorOptions||{},s=n.initialOptions||n.options||[],a=it(i,s,n),l=(g=o.grid.editingCell)==null?void 0:g.initialSearchQuery,d=l!==void 0?l:a;return o.dropdownOptions=s,o.filterText=d,o.highlightedIndex=s.length>0?0:-1,`
87
- <div class="wg__editor wg__editor--autocomplete" data-row="${e}" data-field="${t}">
88
- <input
89
- type="text"
90
- class="wg__autocomplete-input"
91
- value="${o.escapeHtml(d)}"
92
- placeholder="${o.escapeHtml(n.placeholder||"")}"
93
- data-row="${e}"
94
- data-field="${t}"
95
- />
96
- <span class="wg__combobox-toggle">▼</span>
97
- <span class="wg__loading-indicator" style="display: none;">⏳</span>
98
- </div>
99
- `}function ir(o,e,t,i,r){const n=r.formatCallback?r.formatCallback(i,o.grid.displayItems[e]):i!=null?String(i):"";return`
100
- <div
101
- class="wg__editor wg__editor--custom"
102
- tabindex="0"
103
- data-row="${e}"
104
- data-field="${t}"
105
- >
106
- <span class="wg__custom-value">${o.escapeHtml(n)}</span>
107
- </div>
108
- `}function _t(o,e,t,i,r,n){const s=i.editor==="select"||i.editor==="combobox"||i.editor==="autocomplete",a=i.editor==="date",l=String(i.field);return s?`
109
- <div class="wg__cell-dropdown-display ${o.grid.getEffectiveToggleVisibility(i)==="on-focus"?"wg__cell-dropdown-display--toggle-on-focus":""}" data-row="${e}" data-field="${l}">
110
- <span class="wg__select-value">${o.escapeHtml(r)}</span>
111
- <span class="wg__select-toggle">▼</span>
112
- </div>
113
- `:a?`
114
- <div class="wg__cell-date-display ${o.grid.getEffectiveToggleVisibility(i)==="on-focus"?"wg__cell-date-display--toggle-on-focus":""}" data-row="${e}" data-field="${l}">
115
- <span class="wg__date-value">${o.escapeHtml(r)}</span>
116
- <button type="button" class="wg__date-trigger" tabindex="-1">
117
- <svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM9 10H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm-8 4H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2z"/></svg>
118
- </button>
119
- </div>
120
- `:i.templateCallback?`<span class="wg__cell-text">${r}</span>`:`<span class="wg__cell-text">${o.escapeHtml(r)}</span>`}let Y={path:null,arrowPos:null,arrowDir:"right"};const rr={add:{icon:"+",title:"Add row"},delete:{icon:"−",title:"Delete row",danger:!0},duplicate:{icon:"⧉",title:"Duplicate row"},moveUp:{icon:"↑",title:"Move up"},moveDown:{icon:"↓",title:"Move down"}};function vt(o){return o.map((e,t)=>{if(typeof e=="string"){const i=rr[e];return i?{id:e,icon:i.icon,title:i.title,row:1,group:1,type:e,danger:i.danger}:(console.warn(`Unknown predefined toolbar action: ${e}`),null)}return{id:e.id||`toolbar-item-${t}`,icon:e.icon,title:e.title,label:e.label,row:e.row??1,group:e.group??1,type:e.type,danger:e.danger,disabled:e.disabled,hidden:e.hidden,onclick:e.onclick,tooltip:e.tooltip,tooltipCallback:e.tooltipCallback}}).filter(e=>e!==null)}function nr(o){const e=new Map;for(const r of o){const n=r.row;e.has(n)||e.set(n,[]),e.get(n).push(r)}const t=[],i=[...e.keys()].sort((r,n)=>r-n);for(const r of i){const n=e.get(r),s=new Map;for(const l of n){const d=l.group;s.has(d)||s.set(d,[]),s.get(d).push(l)}const a=[...s.keys()].sort((l,d)=>l-d);t.push({rowNum:r,groups:a.map(l=>({groupNum:l,items:s.get(l)}))})}return t}function sr(o){return o.replace(/\+/g," + ")}function lr(o,e){var r,n;const t=[];t.push(`<span class="wg__tooltip-title">${o.title}</span>`),(r=o.tooltip)!=null&&r.description&&t.push(`<div class="wg__tooltip-desc">${o.tooltip.description}</div>`);const i=((n=o.tooltip)==null?void 0:n.shortcut)||e;return i&&t.push(`<div class="wg__tooltip-shortcut">${sr(i)}</div>`),t.join("")}function ar(o,e,t,i=!1){let r=nr(o);return i&&(r=r.reverse()),`<div class="wg__toolbar">${r.map(({groups:s})=>`<div class="wg__toolbar-row">${s.map(({items:l},d)=>{const g=d>0?'<div class="wg__toolbar-divider"></div>':"",u=l.map(c=>{const h=typeof c.disabled=="function"?c.disabled(e,t):c.disabled,f=["wg__toolbar-btn",c.danger?"wg__toolbar-btn--danger":""].filter(Boolean).join(" "),p=c.label?`<span class="wg__toolbar-label">${c.label}</span>`:"";return`<button
121
- class="${f}"
122
- data-toolbar-item="${c.id}"
123
- title="${c.title}"
124
- ${h?"disabled":""}
125
- >${c.icon}${p}</button>`}).join("");return g+u}).join("")}</div>`).join("")}</div>`}let H=null;function dr(o,e,t,i,r,n,s){ot();const a=o.grid.toolbarVerticalAlign!=="top",l=ar(i,r,t,a),d=document.createElement("div");d.className="wg__toolbar-container",d.innerHTML=l,o.shadow.appendChild(d);const g=d.querySelector(".wg__toolbar");let u="left";g.style.position="fixed",g.style.visibility="hidden",requestAnimationFrame(()=>{const h=o.shadow.querySelector(`tr[data-row-index="${t}"]`);if(!h){ot();return}const f=o.grid.toolbarPosition,p=o.grid.toolbarVerticalAlign,v=o.grid.toolbarHorizontalAlign;let m,y,_="";p==="top"?_="-end":p==="bottom"&&(_="-start");const S=()=>v==="start"?"top-start":v==="end"?"top-end":"top";f==="left"?(m=`left${_}`,y=[`right${_}`,S()]):f==="right"?(m=`right${_}`,y=[`left${_}`,S()]):f==="top"?(m=S(),y=[`left${_}`,`right${_}`]):(m=`left${_}`,y=[`right${_}`,S()]);let b=h;if(v==="cursor"&&s!==void 0&&f==="top"){const C=h.getBoundingClientRect();b={getBoundingClientRect:()=>({x:s,y:C.top,top:C.top,left:s,bottom:C.bottom,right:s,width:0,height:C.height,toJSON:()=>({})})}}Le(b,g,{strategy:"fixed",placement:m,middleware:[Ie({fallbackPlacements:y}),Ze({padding:8})]}).then(({x:C,y:x,placement:k})=>{Object.assign(g.style,{left:`${C}px`,top:`${x}px`,visibility:"visible"}),u=k.split("-")[0],H&&(H.position=u)}).catch(()=>{g.style.visibility="visible"})});const c=h=>{const f=h.target.closest(".wg__toolbar-btn");if(f&&!f.disabled){const p=f.dataset.toolbarItem||"",v=i.find(m=>m.id===p);v&&n(v)}};d.addEventListener("click",c),H={container:d,toolbar:g,rowIndex:t,rowItem:r,position:u,hasRowMoved:!1,cursorX:s,cleanup:()=>{d.removeEventListener("click",c),d.remove()}},Y={path:null,arrowPos:null,arrowDir:"right"}}function ot(){H&&(H.cleanup(),H=null),Y={path:null,arrowPos:null,arrowDir:"right"}}function Ae(){return(H==null?void 0:H.rowIndex)??null}function ro(o){return(H==null?void 0:H.container.getRootNode())===o}function yt(o){return(H==null?void 0:H.rowIndex)===o}function cr(){return Y}function no(o,e){if(!H){Y={path:null,arrowPos:null,arrowDir:"right"};return}const{toolbar:t,rowItem:i,position:r}=H,n=e.findIndex(b=>b===i);if(n===-1){Y={path:null,arrowPos:null,arrowDir:"right"};return}const s=o.shadow.querySelector(`tr[data-row-index="${n}"]`);if(!s){Y={path:null,arrowPos:null,arrowDir:"right"};return}if(n===H.rowIndex||(H.hasRowMoved=!0),!H.hasRowMoved){Y={path:null,arrowPos:null,arrowDir:"right"};return}const l=t.getBoundingClientRect(),d=s.getBoundingClientRect(),g=o.shadow.querySelector(".wg__table"),u=g==null?void 0:g.getBoundingClientRect(),c=o.shadow.querySelector(".wg"),h=c==null?void 0:c.getBoundingClientRect();if(!u||!h){Y={path:null,arrowPos:null,arrowDir:"right"};return}const f=document.dir==="rtl"||document.documentElement.dir==="rtl",p=d.top+d.height/2,v=d.bottom<=h.top,m=d.top>=h.bottom,y=!v&&!m;let _,S="right";if(v?(_=h.top+8,S="up"):m?(_=h.bottom-8,S="down"):_=p,r==="left"){const b=l.right,C=l.top+l.height/2,x=f?h.right+15:h.left-15;if(!y){Y={path:`M ${b} ${C} H ${x} V ${_}`,arrowPos:{x,y:_},arrowDir:S};return}const k=f?h.right-8:h.left+8;S=f?"left":"right",Y={path:`M ${b} ${C} H ${x} V ${_} H ${k}`,arrowPos:{x:k,y:_},arrowDir:S};return}else if(r==="right"){const b=l.left,C=l.top+l.height/2,x=f?h.left-15:h.right+15;if(!y){Y={path:`M ${b} ${C} H ${x} V ${_}`,arrowPos:{x,y:_},arrowDir:S};return}const k=f?h.left+8:h.right-8;S=f?"right":"left",Y={path:`M ${b} ${C} H ${x} V ${_} H ${k}`,arrowPos:{x:k,y:_},arrowDir:S};return}else{const C=l.right,x=l.top+l.height/2,k=C+48,T=n-H.rowIndex,E=8;if(T===0){let M=d.top-E;m&&(M=h.bottom-E),Y={path:`M ${C} ${x} H ${k} V ${M}`,arrowPos:{x:k,y:M},arrowDir:"down"};return}else if(T===-1){const F=l.top+l.height*.25,O=l.top+l.height*.75,I=l.right+24,L=l.right+E;Y={path:`M ${l.right} ${F} H ${I} V ${O} H ${L}`,arrowPos:{x:L,y:O},arrowDir:"left"};return}else if(T<0){let M=d.bottom+E;v&&(M=h.top+E),Y={path:`M ${C} ${x} H ${k} V ${M}`,arrowPos:{x:k,y:M},arrowDir:"up"};return}else{let M=d.top-E;m&&(M=h.bottom-E),Y={path:`M ${C} ${x} H ${k} V ${M}`,arrowPos:{x:k,y:M},arrowDir:"down"};return}}}function so(o,e,t="Row actions"){return`<button
126
- class="wg__toolbar-trigger ${e?"wg__toolbar-trigger--active":""}"
127
- data-toolbar-trigger="${o}"
128
- title="${t}"
129
- >⋮</button>`}const Ct=40;function St(o){if(!o||o==="auto")return 150;const e=o.match(/^([\d.]+)(px|em|rem|%)?$/);if(!e)return 150;const t=parseFloat(e[1]);switch(e[2]||"px"){case"px":return t;case"em":return t*16;case"rem":return t*10;case"%":return 150;default:return t}}function gr(o){const e=["wg"];return o.grid.striped&&e.push("wg--striped"),o.grid.hoverable&&e.push("wg--hoverable"),o.grid.editable&&e.push("wg--editable"),o.grid.isNavigateMode&&e.push("wg--navigate-mode"),o.grid.allowColumnReorder&&e.push("wg--reorderable"),e.join(" ")}function ur(o){const e=o.grid.visualColumns;if(e.length===0)return"";let t=0,i="";if(o.grid.showRowNumbers){const d=o.grid.stickyRowNumbers;i=`<th class="wg__header wg__row-number-header${d?" wg__header--frozen":""}" style="${d?"position: sticky; left: 0; z-index: 4;":""}">#</th>`,t+=Ct}const n=o.grid.showRowToolbar&&o.grid.toolbarPosition==="inline"?`<th class="wg__header wg__inline-actions-header">${o.escapeHtml(o.grid.inlineActionsTitle||o.grid.labels.inlineActionsHeader)}</th>`:"",a=o.grid.showRowToolbar&&o.grid.toolbarTrigger==="button"&&o.grid.toolbarPosition!=="inline"?'<th class="wg__header wg__actions-column"></th>':"",l=e.map(({column:d,originalIndex:g},u)=>{const c=String(d.field),h=d.sortable!==!1&&o.grid.sortMode!=="none",f=o.grid.getColumnSortState(c),p=o.grid.getColumnSortPriority(c),v=f!==void 0,m=o.grid.isColumnFrozen(u),y=m&&u===o.grid.totalFrozenColumns-1,_=["wg__header"];h&&_.push("wg__header--sortable"),v&&_.push("wg__header--sorted"),m&&_.push("wg__header--frozen"),y&&_.push("wg__header--frozen-last");const b=o.grid.getColumnWidth(c)||d.width||d.maxWidth,C=St(b),x=d.minWidth,T=`style="${[m?"position: sticky":"",m?`left: ${t}px`:"",m?"z-index: 2":"",b?`width: ${b}`:"",b?`max-width: ${b}`:"",x?`min-width: ${x}`:"",`text-align: ${d.align||"left"}`].filter(Boolean).join("; ")}"`;m&&(t+=C);let E="";if(h)if(v){const I=f.direction==="asc"?"▲":"▼",L=o.grid.sort.length>1?`<sup class="wg__sort-priority">${p}</sup>`:"";E=`<span class="wg__sort-indicator">${I}${L}</span>`}else E='<span class="wg__sort-indicator wg__sort-placeholder">⬍</span>';let M="";d.headerInfo&&(M=`<span class="wg__header-info" data-tooltip="${o.escapeHtml(d.headerInfo)}"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></span>`);const O=`<div class="wg__resize-handle${d.resizable!==!1?"":" wg__resize-handle--disabled"}" data-field="${c}"></div>`;return`
130
- <th class="${_.join(" ")}" ${T} data-field="${c}">
131
- <div class="wg__header-content">
132
- <span class="wg__header-title">${o.escapeHtml(d.title)}</span>
133
- ${M}
134
- ${E}
135
- </div>
136
- ${O}
137
- </th>
138
- `}).join("");return`<tr>${i}${n}${a}${l}<th class="wg__filler">&nbsp;</th></tr>`}function hr(o){const e=o.grid.displayItems,t=o.grid.visualColumns,i=o.grid.showRowNumbers,r=o.grid.stickyRowNumbers,n=o.grid.showRowToolbar&&o.grid.toolbarPosition==="inline",s=o.grid.showRowToolbar&&o.grid.toolbarTrigger==="button"&&o.grid.toolbarPosition!=="inline",a=t.length+(s?1:0)+(i?1:0)+(n?1:0);if(e.length===0)return`
139
- <tr>
140
- <td class="wg__empty" colspan="${a}">
141
- No items to display
142
- </td>
143
- </tr>
144
- `;const l=Ae(),d=t.map(({column:g})=>St(g.width||g.maxWidth));return e.map((g,u)=>{const c=o.grid.getRowLockInfo(g),h=(c==null?void 0:c.isLocked)===!0;let f=0,p="";if(i){const b=r?"position: sticky; left: 0; z-index: 2;":"",C=r?" wg__cell--frozen":"";if(h){const x=c!=null&&c.lockedBy?`Locked by ${c.lockedBy}`:"This row is locked";p=`<td class="wg__cell wg__row-number wg__row-number--locked${C}" style="${b}" data-tooltip="${o.escapeHtml(x)}" data-row-number="${u}">🔒</td>`}else p=`<td class="wg__cell wg__row-number${C}" style="${b}" data-row-number="${u}">${u+1}</td>`;f+=Ct}const v=n?lo(o,g,u):"";let m="";s&&(m=`
145
- <td class="wg__cell wg__actions-column">
146
- ${so(u,l===u,o.grid.labels.rowActions)}
147
- </td>
148
- `);const y=t.map(({column:b,originalIndex:C},x)=>{const k=String(b.field),T=o.grid.getCellValue(g,b,u),E=b.align||"left",M=o.grid.isCellEditable(b),F=o.grid.isCellFocused(u,C),O=o.grid.isColumnFrozen(x),I=O&&x===o.grid.totalFrozenColumns-1,L=["wg__cell"],D=o.grid.isEditing(u,k);if(M&&L.push("wg__cell--editable"),F&&!D&&L.push("wg__cell--focused"),b.textOverflow!=="wrap"&&L.push("wg__cell--ellipsis"),D&&L.push("wg__cell--editing"),o.grid.isCellInvalid(u,k)&&L.push("wg__cell--invalid"),O&&L.push("wg__cell--frozen"),I&&L.push("wg__cell--frozen-last"),b.cellClass&&L.push(b.cellClass),b.cellClassCallback){const Z=o.grid.getCellRawValue(g,u,k),W=b.cellClassCallback(Z,g);W&&L.push(W)}const V=o.grid.getColumnWidth(k)||b.width,A=b.minWidth,We=[O?"position: sticky":"",O?`left: ${f}px`:"",O?"z-index: 1":"",`text-align: ${E}`,V?`width: ${V}`:"",A?`min-width: ${A}`:"",b.maxWidth?`max-width: ${b.maxWidth}`:""].filter(Boolean).join("; ");O&&(f+=d[x]);const Ht=o.grid.isNavigateMode?'tabindex="0"':"";let we="";if(b.tooltipCallback){const Z=o.grid.getCellRawValue(g,u,k),W=b.tooltipCallback(Z,g);W&&(we=`data-tooltip="${o.escapeHtml(W)}"`)}else if(b.tooltipMember){const Z=g[b.tooltipMember];Z&&typeof Z=="string"&&(we=`data-tooltip="${o.escapeHtml(Z)}"`)}if(!we&&o.grid.isCellInvalid(u,k)){const Z=o.grid.getCellValidationError(u,k);if(Z){const W=b.validationTooltipCallback||o.grid.validationTooltipCallback;if(W){const Pt=o.grid.getCellRawValue(g,u,k),ee=W({field:k,error:Z,value:Pt,row:g,rowIndex:u});ee&&(we=`data-tooltip-html="${o.escapeHtml(ee)}"`)}we||(we=`data-tooltip="${o.escapeHtml(Z)}"`)}}return`
149
- <td
150
- class="${L.join(" ")}"
151
- style="${We}"
152
- data-row="${u}"
153
- data-col="${C}"
154
- data-field="${k}"
155
- ${Ht}
156
- ${we}
157
- >
158
- ${o.grid.isEditing(u,k)?tt(o,u,C,b):_t(o,u,C,b,T)}
159
- </td>
160
- `}).join(""),_=["wg__row"];if(h&&_.push("wg__row--locked"),o.grid.isRowSelected(u)&&_.push("wg__row--selected"),o.grid.rowClassCallback){const b=o.grid.rowClassCallback(g,u);b&&_.push(b)}const S=h&&!i?`data-tooltip="${o.escapeHtml(c!=null&&c.lockedBy?`Locked by ${c.lockedBy}`:"This row is locked")}"`:"";return`<tr class="${_.join(" ")}" data-row-index="${u}" ${S}>${p}${v}${m}${y}<td class="wg__filler"></td></tr>`}).join("")}function lo(o,e,t){const r=vt(o.grid.rowToolbar).filter(l=>typeof l.hidden=="function"?!l.hidden(e,t):!l.hidden),n=new Map;for(const l of r){const d=l.row??1;n.has(d)||n.set(d,[]),n.get(d).push(l)}return`<td class="wg__cell wg__inline-actions-cell"><div class="wg__inline-actions-wrap">${[...n.keys()].sort((l,d)=>l-d).map(l=>`<div class="wg__inline-actions-row">${n.get(l).map(u=>{const c=typeof u.disabled=="function"?u.disabled(e,t):u.disabled,h=["wg__inline-action-btn",u.danger?"wg__inline-action-btn--danger":"",c?"wg__inline-action-btn--disabled":""].filter(Boolean).join(" "),f=c?"disabled":"";return`<button class="${h}" data-action-id="${u.id}" data-row="${t}" title="${o.escapeHtml(u.title)}" ${f}>${u.icon}</button>`}).join("")}</div>`).join("")}</div></td>`}function ao(o,e){const t=o.grid.displayItems,i=o.grid.visualColumns,{startIndex:r,endIndex:n,rowHeight:s,totalItems:a}=e,l=o.grid.showRowNumbers,d=o.grid.stickyRowNumbers,g=o.grid.showRowToolbar&&o.grid.toolbarPosition==="inline",u=o.grid.showRowToolbar&&o.grid.toolbarTrigger==="button"&&o.grid.toolbarPosition!=="inline",c=i.length+(u?1:0)+(l?1:0)+(g?1:0);if(t.length===0)return`
161
- <tr>
162
- <td class="wg__empty" colspan="${c}">
163
- No items to display
164
- </td>
165
- </tr>
166
- `;const h=Ae(),f=i.map(({column:S})=>St(S.width||S.maxWidth)),p=r*s,v=(a-n)*s,m=p>0?`<tr class="wg__spacer-top"><td colspan="${c}" style="height: ${p}px"></td></tr>`:"",y=[];for(let S=r;S<n&&S<t.length;S++){const b=t[S],C=S,x=o.grid.getRowLockInfo(b),k=(x==null?void 0:x.isLocked)===!0;let T=0,E="";if(l){const D=d?"position: sticky; left: 0; z-index: 2;":"",q=d?" wg__cell--frozen":"";if(k){const V=x!=null&&x.lockedBy?`Locked by ${x.lockedBy}`:"This row is locked";E=`<td class="wg__cell wg__row-number wg__row-number--locked${q}" style="${D}" data-tooltip="${o.escapeHtml(V)}" data-row-number="${C}">🔒</td>`}else E=`<td class="wg__cell wg__row-number${q}" style="${D}" data-row-number="${C}">${C+1}</td>`;T+=Ct}const M=g?lo(o,b,C):"";let F="";u&&(F=`
167
- <td class="wg__cell wg__actions-column">
168
- ${so(C,h===C,o.grid.labels.rowActions)}
169
- </td>
170
- `);const O=i.map(({column:D,originalIndex:q},V)=>{const A=String(D.field),We=o.grid.getCellValue(b,D,C),Ht=D.align||"left",we=o.grid.isCellEditable(D),Z=o.grid.isCellFocused(C,q),W=o.grid.isColumnFrozen(V),Pt=W&&V===o.grid.totalFrozenColumns-1,ee=["wg__cell"],Fo=o.grid.isEditing(C,A);if(we&&ee.push("wg__cell--editable"),Z&&!Fo&&ee.push("wg__cell--focused"),D.textOverflow!=="wrap"&&ee.push("wg__cell--ellipsis"),Fo&&ee.push("wg__cell--editing"),o.grid.isCellInvalid(C,A)&&ee.push("wg__cell--invalid"),W&&ee.push("wg__cell--frozen"),Pt&&ee.push("wg__cell--frozen-last"),D.cellClass&&ee.push(D.cellClass),D.cellClassCallback){const le=o.grid.getCellRawValue(b,C,A),ye=D.cellClassCallback(le,b);ye&&ee.push(ye)}const qo=o.grid.getColumnWidth(A)||D.width,Vo=D.minWidth,Mn=[W?"position: sticky":"",W?`left: ${T}px`:"",W?"z-index: 1":"",`text-align: ${Ht}`,qo?`width: ${qo}`:"",Vo?`min-width: ${Vo}`:"",D.maxWidth?`max-width: ${D.maxWidth}`:""].filter(Boolean).join("; ");W&&(T+=f[V]);const Tn=o.grid.isNavigateMode?'tabindex="0"':"";let Ee="";if(D.tooltipCallback){const le=o.grid.getCellRawValue(b,C,A),ye=D.tooltipCallback(le,b);ye&&(Ee=`data-tooltip="${o.escapeHtml(ye)}"`)}else if(D.tooltipMember){const le=b[D.tooltipMember];le&&typeof le=="string"&&(Ee=`data-tooltip="${o.escapeHtml(le)}"`)}if(!Ee&&o.grid.isCellInvalid(C,A)){const le=o.grid.getCellValidationError(C,A);if(le){const ye=D.validationTooltipCallback||o.grid.validationTooltipCallback;if(ye){const zn=o.grid.getCellRawValue(b,C,A),No=ye({field:A,error:le,value:zn,row:b,rowIndex:C});No&&(Ee=`data-tooltip-html="${o.escapeHtml(No)}"`)}Ee||(Ee=`data-tooltip="${o.escapeHtml(le)}"`)}}return`
171
- <td
172
- class="${ee.join(" ")}"
173
- style="${Mn}"
174
- data-row="${C}"
175
- data-col="${q}"
176
- data-field="${A}"
177
- ${Tn}
178
- ${Ee}
179
- >
180
- ${o.grid.isEditing(C,A)?tt(o,C,q,D):_t(o,C,q,D,We)}
181
- </td>
182
- `}).join(""),I=["wg__row"];if(k&&I.push("wg__row--locked"),o.grid.isRowSelected(C)&&I.push("wg__row--selected"),o.grid.rowClassCallback){const D=o.grid.rowClassCallback(b,C);D&&I.push(D)}const L=k&&!l?`data-tooltip="${o.escapeHtml(x!=null&&x.lockedBy?`Locked by ${x.lockedBy}`:"This row is locked")}"`:"";y.push(`<tr class="${I.join(" ")}" data-row-index="${C}" ${L}>${E}${M}${F}${O}<td class="wg__filler"></td></tr>`)}const _=v>0?`<tr class="wg__spacer-bottom"><td colspan="${c}" style="height: ${v}px"></td></tr>`:"";return m+y.join("")+_}function xt(o,e="bottom-center"){const t=o.grid.showPagination;if(!o.grid.pageable||t===!1||t==="auto"&&o.grid.totalPages<=1)return"";const i=o.grid.currentPage,r=o.grid.totalPages,n=o.grid.pageSize,s=o.grid.pageSizes,a=o.grid.totalItems!==null?o.grid.totalItems:o.grid.sortedItems.length,l=o.grid.labels,d={first:l.paginationFirst,previous:l.paginationPrevious,next:l.paginationNext,last:l.paginationLast,pageInfo:l.paginationPageInfo.replace("{current}",String(i)).replace("{total}",String(r)),itemCount:l.paginationItemCount.replace("{count}",String(a)),perPage:l.paginationPerPage},g=o.grid.paginationLabelsCallback,u=g?g({currentPage:i,totalPages:r,totalItems:a,pageSize:n}):{},c={...d,...u},h=e.startsWith("top-"),f=e.replace("top-","").replace("bottom-",""),p=["wg__pagination"];f==="left"?p.push("wg__pagination--left"):f==="right"&&p.push("wg__pagination--right"),h&&p.push("wg__pagination--top");const v={first:`
183
- <button class="wg__pagination-btn" data-action="first" ${i===1?"disabled":""}>
184
- ${c.first}
185
- </button>
186
- `,previous:`
187
- <button class="wg__pagination-btn" data-action="prev" ${i===1?"disabled":""}>
188
- ${c.previous}
189
- </button>
190
- `,next:`
191
- <button class="wg__pagination-btn" data-action="next" ${i===r?"disabled":""}>
192
- ${c.next}
193
- </button>
194
- `,last:`
195
- <button class="wg__pagination-btn" data-action="last" ${i===r?"disabled":""}>
196
- ${c.last}
197
- </button>
198
- `,pageInfo:`
199
- <div class="wg__pagination-info">
200
- ${c.pageInfo}
201
- <span class="wg__pagination-count">${c.itemCount}</span>
202
- </div>
203
- `,pageSize:s.length>0?`
204
- <div class="wg__pagination-pagesize">
205
- <select class="wg__pagination-select" data-action="pagesize">
206
- ${s.map(_=>`<option value="${_}" ${_===n?"selected":""}>${_}</option>`).join("")}
207
- </select>
208
- <span class="wg__pagination-label">${c.perPage}</span>
209
- </div>
210
- `:""},y=o.grid.paginationLayout.split("|").map(_=>_.trim()).map(_=>v[_]||"").join("");return`<div class="${p.join(" ")}">${y}</div>`}function kt(o,e){const t=o.grid.summaryContentCallback;if(!t)return"";const i=o.grid.currentPage,r=o.grid.pageSize,n=o.grid.sortedItems,s=o.grid.displayItems,a=o.grid.totalItems!==null?o.grid.totalItems:n.length,l=t({items:s,allItems:n,totalItems:a,currentPage:i,pageSize:r,metadata:o.grid.summaryMetadata}),d=e.startsWith("top-"),g=e.replace("top-","").replace("bottom-",""),u=["wg__summary"];return g==="left"?u.push("wg__summary--left"):g==="right"&&u.push("wg__summary--right"),d&&u.push("wg__summary--top"),`<div class="${u.join(" ")}">${l}</div>`}function j(o,e,t,i={}){const r=o.grid.columns[t];if(!r)return;const n=o.shadow.querySelector(`td[data-row="${e}"][data-col="${t}"]`);if(!n)return;const s=String(r.field),a=o.grid.displayItems[e];if(!a)return;const l=o.grid.isEditing(e,s),d=o.grid.isCellFocused(e,t),g=o.grid.isCellEditable(r),u=o.grid.isCellInvalid(e,s),c=["wg__cell"];if(g&&c.push("wg__cell--editable"),d&&!l&&c.push("wg__cell--focused"),r.textOverflow!=="wrap"&&c.push("wg__cell--ellipsis"),l&&c.push("wg__cell--editing"),u&&c.push("wg__cell--invalid"),r.cellClass&&c.push(r.cellClass),r.cellClassCallback){const h=o.grid.getCellRawValue(a,e,s),f=r.cellClassCallback(h,a);f&&c.push(f)}if(n.className=c.join(" "),l)n.innerHTML=tt(o,e,t,r),i.focusEditor&&fr(o,n,r,i);else{const h=o.grid.getCellValue(a,r,e);n.innerHTML=_t(o,e,t,r,h)}}function fr(o,e,t,i){var n;let r=e.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__select-trigger, .wg__date-input");if(r||(r=e.querySelector(".wg__editor")),!!r&&(r.focus(),r instanceof HTMLInputElement&&r.type==="text")){const s=i.cursorPosition,a=((n=t.editorOptions)==null?void 0:n.editStartSelection)||o.grid.editStartSelection;if(i.initialSearchQuery!==void 0){const l=r.value.length;r.setSelectionRange(l,l)}else switch(a){case"mousePosition":if(s!==void 0){const l=Math.min(s,r.value.length);r.setSelectionRange(l,l)}else r.setSelectionRange(r.value.length,r.value.length);break;case"cursorAtStart":r.setSelectionRange(0,0);break;case"cursorAtEnd":r.setSelectionRange(r.value.length,r.value.length);break;case"selectAll":default:r.select();break}}}function co(o,e,t=!0){const i=o.dropdownOptions[e];if(!i)return;const r=o.grid.editingCell;if(!r)return;const n=o.getCurrentEditorOptions();if(Pe(i,n))return;const s=Se(i,n),a=o.grid.columns.findIndex(d=>String(d.field)===r.field),l=o.grid.displayItems[r.rowIndex];n.onselect&&l&&n.onselect(i,l),o.justSelected=!0,o.isCommittingFromKeyboard=!0,N(o),o.grid.commitEdit(r.rowIndex,r.field,s),t?o.moveFocusAfterCommit(r.rowIndex,r.field,"down"):j(o,r.rowIndex,a),requestAnimationFrame(()=>{o.justSelected=!1})}function ue(o){const e=o.shadow.querySelector(".wg__dropdown");if(!e)return;e.querySelectorAll(".wg__dropdown-option").forEach((i,r)=>{i.classList.toggle("wg__dropdown-option--highlighted",r===o.highlightedIndex)})}function go(o){const e=o.shadow.querySelector(".wg__dropdown-option--highlighted");e==null||e.scrollIntoView({block:"nearest"})}function Dt(o,e){const t=o.shadow.querySelector(".wg__loading-indicator");t&&(t.style.display=e?"inline":"none");const i=o.shadow.querySelector(".wg__editor--autocomplete .wg__combobox-toggle");i&&(i.style.display=e?"none":"inline")}function ne(o){if(o.justSelected)return;const e=o.getCurrentEditingColumn();if(!e)return;const t=e.editorOptions||{},i=e.editor;let r=0;if(i==="select"){const d=t.options||[];if(o.filterText){const g=o.filterText.toLowerCase();o.dropdownOptions=d.filter(u=>He(u,t).toLowerCase().includes(g)),r=o.dropdownOptions.length>0?0:-1}else{o.dropdownOptions=d;const g=o.grid.editingCell;if(g){const u=o.grid.displayItems[g.rowIndex],c=u?u[g.field]:void 0,h=o.dropdownOptions.findIndex(f=>Se(f,t)===c);r=h>=0?h:0}else r=o.dropdownOptions.length>0?0:-1}}else if(i==="combobox"||i==="autocomplete"){const d=i==="autocomplete"?t.initialOptions||t.options||[]:t.options||[],g=o.grid.editingCell;let u;if(g){const h=o.grid.displayItems[g.rowIndex];u=h?h[g.field]:void 0}const c=d.findIndex(h=>Se(h,t)===u);if(c>=0)o.dropdownOptions=d,r=c;else if(u!=null&&u!==""){const h=t.valueMember||"value",f=t.displayMember||"label",p=String(u),v={value:u,label:p,[h]:u,[f]:p};o.dropdownOptions=[v,...d],r=0}else o.dropdownOptions=d,r=d.length>0?0:-1}const n=o.grid.editingCell;if(!n)return;const{rowIndex:s,field:a}=n,l=o.shadow.querySelector(`.wg__editor--select[data-row="${s}"][data-field="${a}"],
211
- .wg__editor--combobox[data-row="${s}"][data-field="${a}"],
212
- .wg__editor--autocomplete[data-row="${s}"][data-field="${a}"]`);if(l&&o.dropdownOptions.length>0){const d=o.filterText;o.isOpeningDropdown=!0;const g=ke(o,l,o.dropdownOptions,t);De(o,g),o.filterText=d,o.highlightedIndex=r,ue(o);const u=o.shadow.querySelector(`.wg__select-trigger[data-row="${s}"][data-field="${a}"]`),c=o.shadow.querySelector(`.wg__combobox-input[data-row="${s}"][data-field="${a}"],
213
- .wg__autocomplete-input[data-row="${s}"][data-field="${a}"]`),h=u||c;h&&h.focus(),requestAnimationFrame(()=>{o.isOpeningDropdown=!1})}}function uo(o){o.dropdownOpen?N(o):ne(o)}function De(o,e){e.addEventListener("mousedown",t=>{t.preventDefault();const i=t.target.closest(".wg__dropdown-option");if(i&&!i.hasAttribute("data-disabled")){const r=parseInt(i.getAttribute("data-index")||"0",10);co(o,r,!1)}}),e.addEventListener("mouseover",t=>{const i=t.target.closest(".wg__dropdown-option");i&&!i.hasAttribute("data-disabled")&&(o.highlightedIndex=parseInt(i.getAttribute("data-index")||"0",10),ue(o))})}function ho(o,e){const t=e.options||[],i=o.filterText.toLowerCase(),r=o.filterText;o.dropdownOptions=t.filter(s=>He(s,e).toLowerCase().includes(i)),o.highlightedIndex=o.dropdownOptions.length>0?0:-1;const n=o.shadow.querySelector(".wg__editor--select");if(n){const s=ke(o,n,o.dropdownOptions,e);De(o,s),o.filterText=r,o.dropdownOptions.length>0&&(o.highlightedIndex=0,ue(o))}}function wr(o,e){const t=e.target;o.filterText=t.value,o.isUserFiltering=!0;const i=o.getCurrentEditingColumn();if(!i)return;const r=i.editorOptions||{},n=r.options||[];if(o.filterText.trim()){const a=o.filterText.toLowerCase();o.dropdownOptions=n.filter(l=>He(l,r).toLowerCase().includes(a))}else o.dropdownOptions=n;o.highlightedIndex=o.dropdownOptions.length>0?0:-1;const s=t.closest(".wg__editor--combobox");if(s){const a=ke(o,s,o.dropdownOptions,r);De(o,a),o.highlightedIndex=o.dropdownOptions.length>0?0:-1,ue(o)}}function pr(o,e){const t=e.target;o.filterText=t.value;const i=o.getCurrentEditingColumn();if(!i)return;const r=i.editorOptions||{},n=r.debounceMs??300,s=r.minSearchLength??1;o.searchDebounceTimer&&clearTimeout(o.searchDebounceTimer);const a=t.closest(".wg__editor--autocomplete");if(!o.dropdownOpen&&a){o.dropdownOptions=r.initialOptions||[];const l=ke(o,a,o.dropdownOptions,r);De(o,l),o.highlightedIndex=o.dropdownOptions.length>0?0:-1,ue(o)}if(o.filterText.length<s){if(o.dropdownOptions=r.initialOptions||[],a){const l=ke(o,a,o.dropdownOptions,r);De(o,l),o.highlightedIndex=o.dropdownOptions.length>0?0:-1,ue(o)}return}o.searchDebounceTimer=setTimeout(()=>{mr(o,o.filterText,i)},n)}async function mr(o,e,t){const i=t.editorOptions||{};if(!i.onSearchCallback)return;o.searchAbortController&&o.searchAbortController.abort(),o.searchAbortController=new AbortController;const r=o.searchAbortController.signal;o.isSearching=!0,Dt(o,!0);try{const n=o.grid.editingCell;if(!n)return;const s=o.grid.displayItems[n.rowIndex],a=await i.onSearchCallback(e,s,r);if(!r.aborted){o.isSearching=!1,Dt(o,!1),o.dropdownOptions=a;const{rowIndex:l,field:d}=n,g=o.shadow.querySelector(`.wg__editor--autocomplete[data-row="${l}"][data-field="${d}"]`);if(g){const u=ke(o,g,o.dropdownOptions,i);De(o,u),o.highlightedIndex=a.length>0?0:-1,ue(o)}}}catch(n){if(n instanceof Error&&n.name==="AbortError")return;console.error("Autocomplete search failed:",n),o.isSearching=!1,Dt(o,!1),o.dropdownOptions=[];const s=o.grid.editingCell;if(s){const{rowIndex:a,field:l}=s,d=o.shadow.querySelector(`.wg__editor--autocomplete[data-row="${a}"][data-field="${l}"]`);if(d){const g=ke(o,d,o.dropdownOptions,i);De(o,g)}}}}function Et(o,e,t,i,r){const n=i??o.tooltipShowDelay;o.tooltipHideTimer&&(clearTimeout(o.tooltipHideTimer),o.tooltipHideTimer=null),!(o.tooltipElement&&o.tooltipAnchor===e)&&(o.tooltipShowTimer&&clearTimeout(o.tooltipShowTimer),o.tooltipShowTimer=setTimeout(()=>{br(o,e,t,r)},n))}function fo(o,e){const t=e??o.tooltipHideDelay;o.tooltipShowTimer&&(clearTimeout(o.tooltipShowTimer),o.tooltipShowTimer=null),o.tooltipElement&&(o.tooltipHideTimer=setTimeout(()=>{o.tooltipElement&&(o.tooltipElement.classList.remove("wg__tooltip--visible"),setTimeout(()=>{var i;(i=o.tooltipElement)==null||i.remove(),o.tooltipElement=null,o.tooltipArrowElement=null,o.tooltipAnchor=null},100))},t))}function br(o,e,t,i){var a;(a=o.tooltipElement)==null||a.remove();const r=document.createElement("div");r.className="wg__tooltip";const n=document.createElement("div");n.className="wg__tooltip-content",i?n.innerHTML=t:n.textContent=t,r.appendChild(n);const s=document.createElement("div");s.className="wg__tooltip-arrow",r.appendChild(s),o.shadow.appendChild(r),o.tooltipElement=r,o.tooltipArrowElement=s,o.tooltipAnchor=e,Le(e,r,{strategy:"fixed",placement:"top",middleware:[ft(8),Ie({fallbackPlacements:["bottom","left","right"]}),Hi({element:s})]}).then(({x:l,y:d,placement:g,middlewareData:u})=>{if(r.style.left=`${l}px`,r.style.top=`${d}px`,r.setAttribute("data-placement",g),u.arrow){const{x:c,y:h}=u.arrow;c!=null&&(s.style.left=`${c}px`),h!=null&&(s.style.top=`${h}px`)}requestAnimationFrame(()=>{r.classList.add("wg__tooltip--visible")})})}const wo={today:"Today",clear:"Clear",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdayNamesShort:["Su","Mo","Tu","We","Th","Fr","Sa"]};function Rt(o){const e={};let t="";return o.includes("-")?t="-":o.includes("/")?t="/":o.includes(".")&&(t="."),o.split(t).forEach((r,n)=>{r==="YYYY"||r==="YY"?e.year={index:n,length:r.length}:r==="MM"||r==="M"?e.month={index:n,length:2}:(r==="DD"||r==="D")&&(e.day={index:n,length:2})}),{format:o,separator:t,parts:e,maxLength:o.length}}function po(o,e){if(!o||isNaN(o.getTime()))return"";const t=o.getFullYear(),i=String(o.getMonth()+1).padStart(2,"0"),r=String(o.getDate()).padStart(2,"0"),{separator:n,parts:s}=e,a=[];for(let l=0;l<3;l++)s.year&&s.year.index===l?a.push(s.year.length===2?String(t).slice(-2):t):s.month&&s.month.index===l?a.push(i):s.day&&s.day.index===l&&a.push(r);return a.join(n)}function _r(o,e){if(!o)return null;const{separator:t,parts:i}=e,r=o.split(t);let n=null,s=null,a=null;if(r.forEach((d,g)=>{if(d){if(i.year&&i.year.index===g){const u=parseInt(d,10);i.year.length===4&&d.length===4?n=u:i.year.length===2&&d.length===2&&(n=u<100?u+2e3:u)}else if(i.month&&i.month.index===g){const u=parseInt(d,10);d.length===2&&u>=1&&u<=12&&(s=u)}else if(i.day&&i.day.index===g){const u=parseInt(d,10);d.length===2&&u>=1&&u<=31&&(a=u)}}}),n===null||s===null||a===null)return null;const l=new Date(n,s-1,a);return l.getMonth()!==s-1||l.getDate()!==a?null:l}function Q(o){if(!o)return null;let e;if(typeof o=="string"){const[t,i,r]=o.split("-").map(Number);!t||!i||!r?e=new Date(o):e=new Date(t,i-1,r)}else e=new Date(o);return e.setHours(0,0,0,0),isNaN(e.getTime())?null:e}function $t(o){const e=o.getFullYear(),t=String(o.getMonth()+1).padStart(2,"0"),i=String(o.getDate()).padStart(2,"0");return`${e}-${t}-${i}`}function Ve(o,e){return!o||!e?!1:o.getFullYear()===e.getFullYear()&&o.getMonth()===e.getMonth()&&o.getDate()===e.getDate()}function vr(o){return Ve(o,new Date)}function Oe(o,e){return new Date(o,e+1,0).getDate()}function yr(o,e){return new Date(o,e,1).getDay()}function Cr(o,e){if(!o)return{min:e-10,max:e+10};if(o.includes("-")){const[i,r]=o.split("-");return{min:parseInt(i,10),max:parseInt(r,10)}}const t=parseInt(o,10);return{min:t,max:t}}function Sr(o,e,t=wo){const i=xr(o,t),r=kr(o,e,t),n=Dr(o,e,t),s=e.showTodayButton!==!1?$r(t):"";return`
1
+ (function(G,F){typeof exports=="object"&&typeof module<"u"?F(exports):typeof define=="function"&&define.amd?define(["exports"],F):(G=typeof globalThis<"u"?globalThis:G||self,F(G.WebGrid={}))})(this,function(G){"use strict";var es=Object.defineProperty;var ts=(G,F,N)=>F in G?es(G,F,{enumerable:!0,configurable:!0,writable:!0,value:N}):G[F]=N;var b=(G,F,N)=>ts(G,typeof F!="symbol"?F+"":F,N);const F=Math.min,N=Math.max,Ue=Math.round,je=Math.floor,de=o=>({x:o,y:o}),oi={left:"right",right:"left",bottom:"top",top:"bottom"},ii={start:"end",end:"start"};function lt(o,t,e){return N(o,F(t,e))}function Me(o,t){return typeof o=="function"?o(t):o}function ve(o){return o.split("-")[0]}function $e(o){return o.split("-")[1]}function jt(o){return o==="x"?"y":"x"}function at(o){return o==="y"?"height":"width"}const ni=new Set(["top","bottom"]);function we(o){return ni.has(ve(o))?"y":"x"}function dt(o){return jt(we(o))}function ri(o,t,e){e===void 0&&(e=!1);const i=$e(o),n=dt(o),r=at(n);let s=n==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(s=Ke(s)),[s,Ke(s)]}function si(o){const t=Ke(o);return[ct(o),t,ct(t)]}function ct(o){return o.replace(/start|end/g,t=>ii[t])}const Kt=["left","right"],Xt=["right","left"],li=["top","bottom"],ai=["bottom","top"];function di(o,t,e){switch(o){case"top":case"bottom":return e?t?Xt:Kt:t?Kt:Xt;case"left":case"right":return t?li:ai;default:return[]}}function ci(o,t,e,i){const n=$e(o);let r=di(ve(o),e==="start",i);return n&&(r=r.map(s=>s+"-"+n),t&&(r=r.concat(r.map(ct)))),r}function Ke(o){return o.replace(/left|right|bottom|top/g,t=>oi[t])}function gi(o){return{top:0,right:0,bottom:0,left:0,...o}}function Gt(o){return typeof o!="number"?gi(o):{top:o,right:o,bottom:o,left:o}}function Xe(o){const{x:t,y:e,width:i,height:n}=o;return{width:i,height:n,top:e,left:t,right:t+i,bottom:e+n,x:t,y:e}}function Qt(o,t,e){let{reference:i,floating:n}=o;const r=we(t),s=dt(t),l=at(s),a=ve(t),d=r==="y",g=i.x+i.width/2-n.width/2,u=i.y+i.height/2-n.height/2,c=i[l]/2-n[l]/2;let h;switch(a){case"top":h={x:g,y:i.y-n.height};break;case"bottom":h={x:g,y:i.y+i.height};break;case"right":h={x:i.x+i.width,y:u};break;case"left":h={x:i.x-n.width,y:u};break;default:h={x:i.x,y:i.y}}switch($e(t)){case"start":h[s]-=c*(e&&d?-1:1);break;case"end":h[s]+=c*(e&&d?-1:1);break}return h}const ui=async(o,t,e)=>{const{placement:i="bottom",strategy:n="absolute",middleware:r=[],platform:s}=e,l=r.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(t));let d=await s.getElementRects({reference:o,floating:t,strategy:n}),{x:g,y:u}=Qt(d,i,a),c=i,h={},f=0;for(let w=0;w<l.length;w++){const{name:p,fn:m}=l[w],{x:y,y:_,data:S,reset:v}=await m({x:g,y:u,initialPlacement:i,placement:c,strategy:n,middlewareData:h,rects:d,platform:s,elements:{reference:o,floating:t}});g=y??g,u=_??u,h={...h,[p]:{...h[p],...S}},v&&f<=50&&(f++,typeof v=="object"&&(v.placement&&(c=v.placement),v.rects&&(d=v.rects===!0?await s.getElementRects({reference:o,floating:t,strategy:n}):v.rects),{x:g,y:u}=Qt(d,c,a)),w=-1)}return{x:g,y:u,placement:c,strategy:n,middlewareData:h}};async function gt(o,t){var e;t===void 0&&(t={});const{x:i,y:n,platform:r,rects:s,elements:l,strategy:a}=o,{boundary:d="clippingAncestors",rootBoundary:g="viewport",elementContext:u="floating",altBoundary:c=!1,padding:h=0}=Me(t,o),f=Gt(h),p=l[c?u==="floating"?"reference":"floating":u],m=Xe(await r.getClippingRect({element:(e=await(r.isElement==null?void 0:r.isElement(p)))==null||e?p:p.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(l.floating)),boundary:d,rootBoundary:g,strategy:a})),y=u==="floating"?{x:i,y:n,width:s.floating.width,height:s.floating.height}:s.reference,_=await(r.getOffsetParent==null?void 0:r.getOffsetParent(l.floating)),S=await(r.isElement==null?void 0:r.isElement(_))?await(r.getScale==null?void 0:r.getScale(_))||{x:1,y:1}:{x:1,y:1},v=Xe(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:_,strategy:a}):y);return{top:(m.top-v.top+f.top)/S.y,bottom:(v.bottom-m.bottom+f.bottom)/S.y,left:(m.left-v.left+f.left)/S.x,right:(v.right-m.right+f.right)/S.x}}const hi=o=>({name:"arrow",options:o,async fn(t){const{x:e,y:i,placement:n,rects:r,platform:s,elements:l,middlewareData:a}=t,{element:d,padding:g=0}=Me(o,t)||{};if(d==null)return{};const u=Gt(g),c={x:e,y:i},h=dt(n),f=at(h),w=await s.getDimensions(d),p=h==="y",m=p?"top":"left",y=p?"bottom":"right",_=p?"clientHeight":"clientWidth",S=r.reference[f]+r.reference[h]-c[h]-r.floating[f],v=c[h]-r.reference[h],C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d));let x=C?C[_]:0;(!x||!await(s.isElement==null?void 0:s.isElement(C)))&&(x=l.floating[_]||r.floating[f]);const k=S/2-v/2,T=x/2-w[f]/2-1,M=F(u[m],T),z=F(u[y],T),A=M,W=x-w[f]-z,I=x/2-w[f]/2+k,U=lt(A,I,W),D=!a.arrow&&$e(n)!=null&&I!==U&&r.reference[f]/2-(I<A?M:z)-w[f]/2<0,H=D?I<A?I-A:I-W:0;return{[h]:c[h]+H,data:{[h]:U,centerOffset:I-U-H,...D&&{alignmentOffset:H}},reset:D}}}),fi=function(o){return o===void 0&&(o={}),{name:"flip",options:o,async fn(t){var e,i;const{placement:n,middlewareData:r,rects:s,initialPlacement:l,platform:a,elements:d}=t,{mainAxis:g=!0,crossAxis:u=!0,fallbackPlacements:c,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:w=!0,...p}=Me(o,t);if((e=r.arrow)!=null&&e.alignmentOffset)return{};const m=ve(n),y=we(l),_=ve(l)===l,S=await(a.isRTL==null?void 0:a.isRTL(d.floating)),v=c||(_||!w?[Ke(l)]:si(l)),C=f!=="none";!c&&C&&v.push(...ci(l,w,f,S));const x=[l,...v],k=await gt(t,p),T=[];let M=((i=r.flip)==null?void 0:i.overflows)||[];if(g&&T.push(k[m]),u){const I=ri(n,s,S);T.push(k[I[0]],k[I[1]])}if(M=[...M,{placement:n,overflows:T}],!T.every(I=>I<=0)){var z,A;const I=(((z=r.flip)==null?void 0:z.index)||0)+1,U=x[I];if(U&&(!(u==="alignment"?y!==we(U):!1)||M.every(q=>we(q.placement)===y?q.overflows[0]>0:!0)))return{data:{index:I,overflows:M},reset:{placement:U}};let D=(A=M.filter(H=>H.overflows[0]<=0).sort((H,q)=>H.overflows[1]-q.overflows[1])[0])==null?void 0:A.placement;if(!D)switch(h){case"bestFit":{var W;const H=(W=M.filter(q=>{if(C){const O=we(q.placement);return O===y||O==="y"}return!0}).map(q=>[q.placement,q.overflows.filter(O=>O>0).reduce((O,Pe)=>O+Pe,0)]).sort((q,O)=>q[1]-O[1])[0])==null?void 0:W[0];H&&(D=H);break}case"initialPlacement":D=l;break}if(n!==D)return{reset:{placement:D}}}return{}}}},wi=new Set(["left","top"]);async function pi(o,t){const{placement:e,platform:i,elements:n}=o,r=await(i.isRTL==null?void 0:i.isRTL(n.floating)),s=ve(e),l=$e(e),a=we(e)==="y",d=wi.has(s)?-1:1,g=r&&a?-1:1,u=Me(t,o);let{mainAxis:c,crossAxis:h,alignmentAxis:f}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof f=="number"&&(h=l==="end"?f*-1:f),a?{x:h*g,y:c*d}:{x:c*d,y:h*g}}const mi=function(o){return o===void 0&&(o=0),{name:"offset",options:o,async fn(t){var e,i;const{x:n,y:r,placement:s,middlewareData:l}=t,a=await pi(t,o);return s===((e=l.offset)==null?void 0:e.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:n+a.x,y:r+a.y,data:{...a,placement:s}}}}},bi=function(o){return o===void 0&&(o={}),{name:"shift",options:o,async fn(t){const{x:e,y:i,placement:n}=t,{mainAxis:r=!0,crossAxis:s=!1,limiter:l={fn:p=>{let{x:m,y}=p;return{x:m,y}}},...a}=Me(o,t),d={x:e,y:i},g=await gt(t,a),u=we(ve(n)),c=jt(u);let h=d[c],f=d[u];if(r){const p=c==="y"?"top":"left",m=c==="y"?"bottom":"right",y=h+g[p],_=h-g[m];h=lt(y,h,_)}if(s){const p=u==="y"?"top":"left",m=u==="y"?"bottom":"right",y=f+g[p],_=f-g[m];f=lt(y,f,_)}const w=l.fn({...t,[c]:h,[u]:f});return{...w,data:{x:w.x-e,y:w.y-i,enabled:{[c]:r,[u]:s}}}}}},_i=function(o){return o===void 0&&(o={}),{name:"size",options:o,async fn(t){var e,i;const{placement:n,rects:r,platform:s,elements:l}=t,{apply:a=()=>{},...d}=Me(o,t),g=await gt(t,d),u=ve(n),c=$e(n),h=we(n)==="y",{width:f,height:w}=r.floating;let p,m;u==="top"||u==="bottom"?(p=u,m=c===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(m=u,p=c==="end"?"top":"bottom");const y=w-g.top-g.bottom,_=f-g.left-g.right,S=F(w-g[p],y),v=F(f-g[m],_),C=!t.middlewareData.shift;let x=S,k=v;if((e=t.middlewareData.shift)!=null&&e.enabled.x&&(k=_),(i=t.middlewareData.shift)!=null&&i.enabled.y&&(x=y),C&&!c){const M=N(g.left,0),z=N(g.right,0),A=N(g.top,0),W=N(g.bottom,0);h?k=f-2*(M!==0||z!==0?M+z:N(g.left,g.right)):x=w-2*(A!==0||W!==0?A+W:N(g.top,g.bottom))}await a({...t,availableWidth:k,availableHeight:x});const T=await s.getDimensions(l.floating);return f!==T.width||w!==T.height?{reset:{rects:!0}}:{}}}};function Ge(){return typeof window<"u"}function Ie(o){return Jt(o)?(o.nodeName||"").toLowerCase():"#document"}function Q(o){var t;return(o==null||(t=o.ownerDocument)==null?void 0:t.defaultView)||window}function ce(o){var t;return(t=(Jt(o)?o.ownerDocument:o.document)||window.document)==null?void 0:t.documentElement}function Jt(o){return Ge()?o instanceof Node||o instanceof Q(o).Node:!1}function ie(o){return Ge()?o instanceof Element||o instanceof Q(o).Element:!1}function ge(o){return Ge()?o instanceof HTMLElement||o instanceof Q(o).HTMLElement:!1}function Zt(o){return!Ge()||typeof ShadowRoot>"u"?!1:o instanceof ShadowRoot||o instanceof Q(o).ShadowRoot}const vi=new Set(["inline","contents"]);function Ve(o){const{overflow:t,overflowX:e,overflowY:i,display:n}=ne(o);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!vi.has(n)}const yi=new Set(["table","td","th"]);function Ci(o){return yi.has(Ie(o))}const Si=[":popover-open",":modal"];function Qe(o){return Si.some(t=>{try{return o.matches(t)}catch{return!1}})}const xi=["transform","translate","scale","rotate","perspective"],ki=["transform","translate","scale","rotate","perspective","filter"],Di=["paint","layout","strict","content"];function ut(o){const t=ht(),e=ie(o)?ne(o):o;return xi.some(i=>e[i]?e[i]!=="none":!1)||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||ki.some(i=>(e.willChange||"").includes(i))||Di.some(i=>(e.contain||"").includes(i))}function Ri(o){let t=ye(o);for(;ge(t)&&!Te(t);){if(ut(t))return t;if(Qe(t))return null;t=ye(t)}return null}function ht(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Ei=new Set(["html","body","#document"]);function Te(o){return Ei.has(Ie(o))}function ne(o){return Q(o).getComputedStyle(o)}function Je(o){return ie(o)?{scrollLeft:o.scrollLeft,scrollTop:o.scrollTop}:{scrollLeft:o.scrollX,scrollTop:o.scrollY}}function ye(o){if(Ie(o)==="html")return o;const t=o.assignedSlot||o.parentNode||Zt(o)&&o.host||ce(o);return Zt(t)?t.host:t}function eo(o){const t=ye(o);return Te(t)?o.ownerDocument?o.ownerDocument.body:o.body:ge(t)&&Ve(t)?t:eo(t)}function Fe(o,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);const n=eo(o),r=n===((i=o.ownerDocument)==null?void 0:i.body),s=Q(n);if(r){const l=ft(s);return t.concat(s,s.visualViewport||[],Ve(n)?n:[],l&&e?Fe(l):[])}return t.concat(n,Fe(n,[],e))}function ft(o){return o.parent&&Object.getPrototypeOf(o.parent)?o.frameElement:null}function to(o){const t=ne(o);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const n=ge(o),r=n?o.offsetWidth:e,s=n?o.offsetHeight:i,l=Ue(e)!==r||Ue(i)!==s;return l&&(e=r,i=s),{width:e,height:i,$:l}}function wt(o){return ie(o)?o:o.contextElement}function ze(o){const t=wt(o);if(!ge(t))return de(1);const e=t.getBoundingClientRect(),{width:i,height:n,$:r}=to(t);let s=(r?Ue(e.width):e.width)/i,l=(r?Ue(e.height):e.height)/n;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const Mi=de(0);function oo(o){const t=Q(o);return!ht()||!t.visualViewport?Mi:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $i(o,t,e){return t===void 0&&(t=!1),!e||t&&e!==Q(o)?!1:t}function xe(o,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const n=o.getBoundingClientRect(),r=wt(o);let s=de(1);t&&(i?ie(i)&&(s=ze(i)):s=ze(o));const l=$i(r,e,i)?oo(r):de(0);let a=(n.left+l.x)/s.x,d=(n.top+l.y)/s.y,g=n.width/s.x,u=n.height/s.y;if(r){const c=Q(r),h=i&&ie(i)?Q(i):i;let f=c,w=ft(f);for(;w&&i&&h!==f;){const p=ze(w),m=w.getBoundingClientRect(),y=ne(w),_=m.left+(w.clientLeft+parseFloat(y.paddingLeft))*p.x,S=m.top+(w.clientTop+parseFloat(y.paddingTop))*p.y;a*=p.x,d*=p.y,g*=p.x,u*=p.y,a+=_,d+=S,f=Q(w),w=ft(f)}}return Xe({width:g,height:u,x:a,y:d})}function Ze(o,t){const e=Je(o).scrollLeft;return t?t.left+e:xe(ce(o)).left+e}function io(o,t){const e=o.getBoundingClientRect(),i=e.left+t.scrollLeft-Ze(o,e),n=e.top+t.scrollTop;return{x:i,y:n}}function Ii(o){let{elements:t,rect:e,offsetParent:i,strategy:n}=o;const r=n==="fixed",s=ce(i),l=t?Qe(t.floating):!1;if(i===s||l&&r)return e;let a={scrollLeft:0,scrollTop:0},d=de(1);const g=de(0),u=ge(i);if((u||!u&&!r)&&((Ie(i)!=="body"||Ve(s))&&(a=Je(i)),ge(i))){const h=xe(i);d=ze(i),g.x=h.x+i.clientLeft,g.y=h.y+i.clientTop}const c=s&&!u&&!r?io(s,a):de(0);return{width:e.width*d.x,height:e.height*d.y,x:e.x*d.x-a.scrollLeft*d.x+g.x+c.x,y:e.y*d.y-a.scrollTop*d.y+g.y+c.y}}function Ti(o){return Array.from(o.getClientRects())}function zi(o){const t=ce(o),e=Je(o),i=o.ownerDocument.body,n=N(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),r=N(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let s=-e.scrollLeft+Ze(o);const l=-e.scrollTop;return ne(i).direction==="rtl"&&(s+=N(t.clientWidth,i.clientWidth)-n),{width:n,height:r,x:s,y:l}}const no=25;function Li(o,t){const e=Q(o),i=ce(o),n=e.visualViewport;let r=i.clientWidth,s=i.clientHeight,l=0,a=0;if(n){r=n.width,s=n.height;const g=ht();(!g||g&&t==="fixed")&&(l=n.offsetLeft,a=n.offsetTop)}const d=Ze(i);if(d<=0){const g=i.ownerDocument,u=g.body,c=getComputedStyle(u),h=g.compatMode==="CSS1Compat"&&parseFloat(c.marginLeft)+parseFloat(c.marginRight)||0,f=Math.abs(i.clientWidth-u.clientWidth-h);f<=no&&(r-=f)}else d<=no&&(r+=d);return{width:r,height:s,x:l,y:a}}const Ai=new Set(["absolute","fixed"]);function Hi(o,t){const e=xe(o,!0,t==="fixed"),i=e.top+o.clientTop,n=e.left+o.clientLeft,r=ge(o)?ze(o):de(1),s=o.clientWidth*r.x,l=o.clientHeight*r.y,a=n*r.x,d=i*r.y;return{width:s,height:l,x:a,y:d}}function ro(o,t,e){let i;if(t==="viewport")i=Li(o,e);else if(t==="document")i=zi(ce(o));else if(ie(t))i=Hi(t,e);else{const n=oo(o);i={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Xe(i)}function so(o,t){const e=ye(o);return e===t||!ie(e)||Te(e)?!1:ne(e).position==="fixed"||so(e,t)}function Oi(o,t){const e=t.get(o);if(e)return e;let i=Fe(o,[],!1).filter(l=>ie(l)&&Ie(l)!=="body"),n=null;const r=ne(o).position==="fixed";let s=r?ye(o):o;for(;ie(s)&&!Te(s);){const l=ne(s),a=ut(s);!a&&l.position==="fixed"&&(n=null),(r?!a&&!n:!a&&l.position==="static"&&!!n&&Ai.has(n.position)||Ve(s)&&!a&&so(o,s))?i=i.filter(g=>g!==s):n=l,s=ye(s)}return t.set(o,i),i}function Pi(o){let{element:t,boundary:e,rootBoundary:i,strategy:n}=o;const s=[...e==="clippingAncestors"?Qe(t)?[]:Oi(t,this._c):[].concat(e),i],l=s[0],a=s.reduce((d,g)=>{const u=ro(t,g,n);return d.top=N(u.top,d.top),d.right=F(u.right,d.right),d.bottom=F(u.bottom,d.bottom),d.left=N(u.left,d.left),d},ro(t,l,n));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Vi(o){const{width:t,height:e}=to(o);return{width:t,height:e}}function Fi(o,t,e){const i=ge(t),n=ce(t),r=e==="fixed",s=xe(o,!0,r,t);let l={scrollLeft:0,scrollTop:0};const a=de(0);function d(){a.x=Ze(n)}if(i||!i&&!r)if((Ie(t)!=="body"||Ve(n))&&(l=Je(t)),i){const h=xe(t,!0,r,t);a.x=h.x+t.clientLeft,a.y=h.y+t.clientTop}else n&&d();r&&!i&&n&&d();const g=n&&!i&&!r?io(n,l):de(0),u=s.left+l.scrollLeft-a.x-g.x,c=s.top+l.scrollTop-a.y-g.y;return{x:u,y:c,width:s.width,height:s.height}}function pt(o){return ne(o).position==="static"}function lo(o,t){if(!ge(o)||ne(o).position==="fixed")return null;if(t)return t(o);let e=o.offsetParent;return ce(o)===e&&(e=e.ownerDocument.body),e}function ao(o,t){const e=Q(o);if(Qe(o))return e;if(!ge(o)){let n=ye(o);for(;n&&!Te(n);){if(ie(n)&&!pt(n))return n;n=ye(n)}return e}let i=lo(o,t);for(;i&&Ci(i)&&pt(i);)i=lo(i,t);return i&&Te(i)&&pt(i)&&!ut(i)?e:i||Ri(o)||e}const qi=async function(o){const t=this.getOffsetParent||ao,e=this.getDimensions,i=await e(o.floating);return{reference:Fi(o.reference,await t(o.floating),o.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Ni(o){return ne(o).direction==="rtl"}const Wi={convertOffsetParentRelativeRectToViewportRelativeRect:Ii,getDocumentElement:ce,getClippingRect:Pi,getOffsetParent:ao,getElementRects:qi,getClientRects:Ti,getDimensions:Vi,getScale:ze,isElement:ie,isRTL:Ni};function co(o,t){return o.x===t.x&&o.y===t.y&&o.width===t.width&&o.height===t.height}function Yi(o,t){let e=null,i;const n=ce(o);function r(){var l;clearTimeout(i),(l=e)==null||l.disconnect(),e=null}function s(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),r();const d=o.getBoundingClientRect(),{left:g,top:u,width:c,height:h}=d;if(l||t(),!c||!h)return;const f=je(u),w=je(n.clientWidth-(g+c)),p=je(n.clientHeight-(u+h)),m=je(g),_={rootMargin:-f+"px "+-w+"px "+-p+"px "+-m+"px",threshold:N(0,F(1,a))||1};let S=!0;function v(C){const x=C[0].intersectionRatio;if(x!==a){if(!S)return s();x?s(!1,x):i=setTimeout(()=>{s(!1,1e-7)},1e3)}x===1&&!co(d,o.getBoundingClientRect())&&s(),S=!1}try{e=new IntersectionObserver(v,{..._,root:n.ownerDocument})}catch{e=new IntersectionObserver(v,_)}e.observe(o)}return s(!0),r}function Bi(o,t,e,i){i===void 0&&(i={});const{ancestorScroll:n=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=i,d=wt(o),g=n||r?[...d?Fe(d):[],...Fe(t)]:[];g.forEach(m=>{n&&m.addEventListener("scroll",e,{passive:!0}),r&&m.addEventListener("resize",e)});const u=d&&l?Yi(d,e):null;let c=-1,h=null;s&&(h=new ResizeObserver(m=>{let[y]=m;y&&y.target===d&&h&&(h.unobserve(t),cancelAnimationFrame(c),c=requestAnimationFrame(()=>{var _;(_=h)==null||_.observe(t)})),e()}),d&&!a&&h.observe(d),h.observe(t));let f,w=a?xe(o):null;a&&p();function p(){const m=xe(o);w&&!co(w,m)&&e(),w=m,f=requestAnimationFrame(p)}return e(),()=>{var m;g.forEach(y=>{n&&y.removeEventListener("scroll",e),r&&y.removeEventListener("resize",e)}),u==null||u(),(m=h)==null||m.disconnect(),h=null,a&&cancelAnimationFrame(f)}}const mt=mi,et=bi,Le=fi,Ui=_i,ji=hi,Ae=(o,t,e)=>{const i=new Map,n={platform:Wi,...e},r={...n.platform,_c:i};return ui(o,t,{...n,platform:r})},go={today:"Today",clear:"Clear",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdayNamesShort:["Su","Mo","Tu","We","Th","Fr","Sa"]};function tt(o){const t={};let e="";return o.includes("-")?e="-":o.includes("/")?e="/":o.includes(".")&&(e="."),o.split(e).forEach((n,r)=>{n==="YYYY"||n==="YY"?t.year={index:r,length:n.length}:n==="MM"||n==="M"?t.month={index:r,length:2}:(n==="DD"||n==="D")&&(t.day={index:r,length:2})}),{format:o,separator:e,parts:t,maxLength:o.length}}function bt(o,t){if(!o||isNaN(o.getTime()))return"";const e=o.getFullYear(),i=String(o.getMonth()+1).padStart(2,"0"),n=String(o.getDate()).padStart(2,"0"),{separator:r,parts:s}=t,l=[];for(let a=0;a<3;a++)s.year&&s.year.index===a?l.push(s.year.length===2?String(e).slice(-2):e):s.month&&s.month.index===a?l.push(i):s.day&&s.day.index===a&&l.push(n);return l.join(r)}function Ki(o,t){if(!o)return null;const{separator:e,parts:i}=t,n=o.split(e);let r=null,s=null,l=null;if(n.forEach((d,g)=>{if(d){if(i.year&&i.year.index===g){const u=parseInt(d,10);i.year.length===4&&d.length===4?r=u:i.year.length===2&&d.length===2&&(r=u<100?u+2e3:u)}else if(i.month&&i.month.index===g){const u=parseInt(d,10);d.length===2&&u>=1&&u<=12&&(s=u)}else if(i.day&&i.day.index===g){const u=parseInt(d,10);d.length===2&&u>=1&&u<=31&&(l=u)}}}),r===null||s===null||l===null)return null;const a=new Date(r,s-1,l);return a.getMonth()!==s-1||a.getDate()!==l?null:a}function J(o){if(!o)return null;let t;if(typeof o=="string"){const[e,i,n]=o.split("-").map(Number);!e||!i||!n?t=new Date(o):t=new Date(e,i-1,n)}else t=new Date(o);return t.setHours(0,0,0,0),isNaN(t.getTime())?null:t}function _t(o){const t=o.getFullYear(),e=String(o.getMonth()+1).padStart(2,"0"),i=String(o.getDate()).padStart(2,"0");return`${t}-${e}-${i}`}function qe(o,t){return!o||!t?!1:o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth()&&o.getDate()===t.getDate()}function Xi(o){return qe(o,new Date)}function He(o,t){return new Date(o,t+1,0).getDate()}function Gi(o,t){return new Date(o,t,1).getDay()}function Qi(o,t){if(!o)return{min:t-10,max:t+10};if(o.includes("-")){const[i,n]=o.split("-");return{min:parseInt(i,10),max:parseInt(n,10)}}const e=parseInt(o,10);return{min:e,max:e}}function Ji(o,t,e=go){const i=Zi(o,e),n=en(o,t,e),r=tn(o,t,e),s=t.showTodayButton!==!1?rn(e):"";return`
214
2
  <div class="wg-datepicker">
215
3
  <div class="wg-datepicker__header">
216
4
  ${i}
217
5
  </div>
218
6
  <div class="wg-datepicker__rolling-selector${o.rollingSelectorOpen?" wg-datepicker__rolling-selector--visible":""}">
219
- ${r}
7
+ ${n}
220
8
  </div>
221
9
  <div class="wg-datepicker__calendar${o.rollingSelectorOpen?" wg-datepicker__calendar--hidden":""}">
222
- ${n}
10
+ ${r}
223
11
  </div>
224
12
  ${s}
225
13
  </div>
226
- `}function xr(o,e){return`
14
+ `}function Zi(o,t){return`
227
15
  <button type="button" class="wg-datepicker__nav wg-datepicker__nav--prev" data-action="prev-month">
228
16
  <svg viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/></svg>
229
17
  </button>
230
18
  <button type="button" class="wg-datepicker__month-year" data-action="toggle-rolling">
231
- ${e.monthNames[o.viewMonth]} ${o.viewYear}
19
+ ${t.monthNames[o.viewMonth]} ${o.viewYear}
232
20
  </button>
233
21
  <button type="button" class="wg-datepicker__nav wg-datepicker__nav--next" data-action="next-month">
234
22
  <svg viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"/></svg>
235
23
  </button>
236
- `}function kr(o,e,t){const i=Cr(e.rollingYearRange,new Date().getFullYear());let r="";for(let s=i.min;s<=i.max;s++){const a=s===o.viewYear?" wg-datepicker__rolling-item--selected":"";r+=`<div class="wg-datepicker__rolling-item${a}" data-year="${s}">${s}</div>`}let n="";for(let s=0;s<12;s++){const a=s===o.viewMonth?" wg-datepicker__rolling-item--selected":"";n+=`<div class="wg-datepicker__rolling-item${a}" data-month="${s}">${t.monthNamesShort[s]}</div>`}return`
24
+ `}function en(o,t,e){const i=Qi(t.rollingYearRange,new Date().getFullYear());let n="";for(let s=i.min;s<=i.max;s++){const l=s===o.viewYear?" wg-datepicker__rolling-item--selected":"";n+=`<div class="wg-datepicker__rolling-item${l}" data-year="${s}">${s}</div>`}let r="";for(let s=0;s<12;s++){const l=s===o.viewMonth?" wg-datepicker__rolling-item--selected":"";r+=`<div class="wg-datepicker__rolling-item${l}" data-month="${s}">${e.monthNamesShort[s]}</div>`}return`
237
25
  <div class="wg-datepicker__rolling-lists">
238
26
  <div class="wg-datepicker__rolling-list" data-list="months">
239
- ${n}
27
+ ${r}
240
28
  </div>
241
29
  <div class="wg-datepicker__rolling-list" data-list="years">
242
- ${r}
30
+ ${n}
243
31
  </div>
244
32
  </div>
245
- `}function Dr(o,e,t){const i=Er(t),r=mo(o,e);return`
33
+ `}function tn(o,t,e){const i=on(e),n=uo(o,t);return`
246
34
  <div class="wg-datepicker__weekdays">
247
35
  ${i}
248
36
  </div>
249
37
  <div class="wg-datepicker__days">
250
- ${r}
38
+ ${n}
251
39
  </div>
252
- `}function Er(o){return o.weekdayNamesShort.map(e=>`<div class="wg-datepicker__weekday">${e}</div>`).join("")}function mo(o,e){const{viewYear:t,viewMonth:i,selectedDate:r,focusedDate:n}=o,s=e.minDate?Q(e.minDate):null,a=e.maxDate?Q(e.maxDate):null,l=yr(t,i),d=Oe(t,i),g=Oe(t,i-1),u=new Date(t,i-1,1),c=u.getFullYear(),h=u.getMonth(),f=new Date(t,i+1,1),p=f.getFullYear(),v=f.getMonth(),m=[];for(let b=l-1;b>=0;b--){const C=g-b;m.push({date:new Date(c,h,C),day:C,isOtherMonth:!0})}for(let b=1;b<=d;b++)m.push({date:new Date(t,i,b),day:b,isOtherMonth:!1});const _=Math.ceil((l+d)/7)*7-m.length;for(let b=1;b<=_;b++)m.push({date:new Date(p,v,b),day:b,isOtherMonth:!0});let S="";for(const b of m){const C=["wg-datepicker__day"];b.isOtherMonth&&C.push("wg-datepicker__day--other-month"),Rr(b.date,s,a)&&C.push("wg-datepicker__day--disabled"),vr(b.date)&&C.push("wg-datepicker__day--today"),Ve(b.date,r)&&C.push("wg-datepicker__day--selected"),Ve(b.date,n)&&C.push("wg-datepicker__day--focused");const k=$t(b.date);S+=`<div class="${C.join(" ")}" data-date="${k}">${b.day}</div>`}return S}function Rr(o,e,t){return!!(e&&o<e||t&&o>t)}function $r(o){return`
40
+ `}function on(o){return o.weekdayNamesShort.map(t=>`<div class="wg-datepicker__weekday">${t}</div>`).join("")}function uo(o,t){const{viewYear:e,viewMonth:i,selectedDate:n,focusedDate:r}=o,s=t.minDate?J(t.minDate):null,l=t.maxDate?J(t.maxDate):null,a=Gi(e,i),d=He(e,i),g=He(e,i-1),u=new Date(e,i-1,1),c=u.getFullYear(),h=u.getMonth(),f=new Date(e,i+1,1),w=f.getFullYear(),p=f.getMonth(),m=[];for(let v=a-1;v>=0;v--){const C=g-v;m.push({date:new Date(c,h,C),day:C,isOtherMonth:!0})}for(let v=1;v<=d;v++)m.push({date:new Date(e,i,v),day:v,isOtherMonth:!1});const _=Math.ceil((a+d)/7)*7-m.length;for(let v=1;v<=_;v++)m.push({date:new Date(w,p,v),day:v,isOtherMonth:!0});let S="";for(const v of m){const C=["wg-datepicker__day"];v.isOtherMonth&&C.push("wg-datepicker__day--other-month"),nn(v.date,s,l)&&C.push("wg-datepicker__day--disabled"),Xi(v.date)&&C.push("wg-datepicker__day--today"),qe(v.date,n)&&C.push("wg-datepicker__day--selected"),qe(v.date,r)&&C.push("wg-datepicker__day--focused");const k=_t(v.date);S+=`<div class="${C.join(" ")}" data-date="${k}">${v.day}</div>`}return S}function nn(o,t,e){return!!(t&&o<t||e&&o>e)}function rn(o){return`
253
41
  <div class="wg-datepicker__footer">
254
42
  <button type="button" class="wg-datepicker__today-btn" data-action="today">
255
43
  ${o.today}
256
44
  </button>
257
45
  </div>
258
- `}function Mr(o,e,t){const i=o.querySelector(".wg-datepicker__days");i&&(i.innerHTML=mo(e,t))}function Tr(o,e,t){const i=o.querySelector(".wg-datepicker__month-year");if(i){const r=t.monthNames[e.viewMonth];i.textContent=`${r} ${e.viewYear}`}}function zr(o,e){const t=o.querySelector(".wg-datepicker__rolling-selector"),i=o.querySelector(".wg-datepicker__calendar");t&&t.classList.toggle("wg-datepicker__rolling-selector--visible",e),i&&i.classList.toggle("wg-datepicker__calendar--hidden",e)}function Ir(o,e){o.querySelectorAll("[data-year]").forEach(r=>{const n=parseInt(r.dataset.year||"0",10);r.classList.toggle("wg-datepicker__rolling-item--selected",n===e.viewYear)}),o.querySelectorAll("[data-month]").forEach(r=>{const n=parseInt(r.dataset.month||"0",10);r.classList.toggle("wg-datepicker__rolling-item--selected",n===e.viewMonth)})}function bo(o){const e=o.querySelector("[data-year].wg-datepicker__rolling-item--selected"),t=o.querySelector("[data-month].wg-datepicker__rolling-item--selected");if(e){const i=e.parentElement;if(i){const r=e.offsetTop-i.clientHeight/2+e.clientHeight/2;i.scrollTop=r}}if(t){const i=t.parentElement;if(i){const r=t.offsetTop-i.clientHeight/2+t.clientHeight/2;i.scrollTop=r}}}function Mt(o){o.viewMonth===0?(o.viewMonth=11,o.viewYear--):o.viewMonth--}function Tt(o){o.viewMonth===11?(o.viewMonth=0,o.viewYear++):o.viewMonth++}function Lr(o,e,t,i){var n,s,a,l;const{key:r}=o;if(r==="Escape")return(n=i.onClose)==null||n.call(i),!0;if(e.rollingSelectorOpen)return Or(o,e);if((r==="ArrowLeft"||r==="ArrowRight")&&(o.ctrlKey||o.metaKey)){if(o.preventDefault(),r==="ArrowLeft"?Mt(e):Tt(e),e.focusedDate){const d=Math.min(e.focusedDate.getDate(),Oe(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,d)}return!0}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(r))return o.preventDefault(),Ar(e,r,t),!0;if(r==="Enter")return o.preventDefault(),o.stopPropagation(),e.focusedDate&&((s=i.onSelect)==null||s.call(i,e.focusedDate,"down")),!0;if(r==="Tab")return e.focusedDate?(a=i.onSelect)==null||a.call(i,e.focusedDate,"next"):(l=i.onClose)==null||l.call(i),!1;if(r==="Home"){if(o.preventDefault(),o.ctrlKey||o.metaKey){let d=e.viewYear;const g=new Date(d,0,1);if(e.focusedDate&&Ve(e.focusedDate,g)&&d--,t.minDate){const u=Q(t.minDate);u&&d<u.getFullYear()&&(d=u.getFullYear())}e.viewMonth=0,e.viewYear=d,e.focusedDate=new Date(d,0,1)}else e.focusedDate=new Date(e.viewYear,e.viewMonth,1);return!0}if(r==="End"){if(o.preventDefault(),o.ctrlKey||o.metaKey){let d=e.viewYear;const g=new Date(d,11,31);if(e.focusedDate&&Ve(e.focusedDate,g)&&d++,t.maxDate){const u=Q(t.maxDate);u&&d>u.getFullYear()&&(d=u.getFullYear())}e.viewMonth=11,e.viewYear=d,e.focusedDate=new Date(d,11,31)}else{const d=Oe(e.viewYear,e.viewMonth);e.focusedDate=new Date(e.viewYear,e.viewMonth,d)}return!0}if(r==="PageUp"){if(o.preventDefault(),Mt(e),e.focusedDate){const d=Math.min(e.focusedDate.getDate(),Oe(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,d)}return!0}if(r==="PageDown"){if(o.preventDefault(),Tt(e),e.focusedDate){const d=Math.min(e.focusedDate.getDate(),Oe(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,d)}return!0}return!1}function Ar(o,e,t){if(!o.focusedDate){o.focusedDate=o.selectedDate?new Date(o.selectedDate):new Date(o.viewYear,o.viewMonth,1);return}const i=new Date(o.focusedDate),r=t.minDate?Q(t.minDate):null,n=t.maxDate?Q(t.maxDate):null;switch(e){case"ArrowLeft":i.setDate(i.getDate()-1);break;case"ArrowRight":i.setDate(i.getDate()+1);break;case"ArrowUp":i.setDate(i.getDate()-7);break;case"ArrowDown":i.setDate(i.getDate()+7);break}r&&i<r||n&&i>n||(o.focusedDate=i,(i.getMonth()!==o.viewMonth||i.getFullYear()!==o.viewYear)&&(o.viewMonth=i.getMonth(),o.viewYear=i.getFullYear()))}function Or(o,e){const{key:t}=o;if(t==="ArrowUp"||t==="ArrowDown"){o.preventDefault();const i=t==="ArrowUp"?-1:1;if(e.rollingSelectorMode==="month"){const r=e.viewMonth+i;r>=0&&r<=11&&(e.viewMonth=r)}else e.viewYear+=i;return!0}return t==="ArrowLeft"||t==="ArrowRight"?(o.preventDefault(),e.rollingSelectorMode=e.rollingSelectorMode==="month"?"year":"month",!0):t==="Enter"||t==="Escape"?(o.preventDefault(),e.rollingSelectorOpen=!1,!0):!1}function Hr(o){if(o.selectedDate)o.focusedDate=new Date(o.selectedDate),o.viewYear=o.selectedDate.getFullYear(),o.viewMonth=o.selectedDate.getMonth();else{const e=new Date;o.focusedDate=new Date(o.viewYear,o.viewMonth,e.getDate())}}function Pr(o,e,t){const i=o.dataset.date;if(!i||o.classList.contains("wg-datepicker__day--disabled"))return null;const[r,n,s]=i.split("-").map(Number),a=new Date(r,n-1,s),l=t.minDate?Q(t.minDate):null,d=t.maxDate?Q(t.maxDate):null;return l&&a<l||d&&a>d?null:(e.selectedDate=a,e.focusedDate=a,a)}function Fr(o,e){const t=new Date;t.setHours(0,0,0,0);const i=e.minDate?Q(e.minDate):null,r=e.maxDate?Q(e.maxDate):null;return i&&t<i||r&&t>r?null:(o.selectedDate=t,o.focusedDate=t,o.viewYear=t.getFullYear(),o.viewMonth=t.getMonth(),t)}function qr(o,e){const t=o.dataset.month;t!==void 0&&(e.viewMonth=parseInt(t,10))}function Vr(o,e){const t=o.dataset.year;t!==void 0&&(e.viewYear=parseInt(t,10))}function zt(o,e){var u,c,h,f;const{separator:t,parts:i,maxLength:r}=e,n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=o.replace(new RegExp(n,"g"),""),a=((u=i.year)==null?void 0:u.length)??4,l=[{type:"year",pos:((c=i.year)==null?void 0:c.index)??0,length:a},{type:"month",pos:((h=i.month)==null?void 0:h.index)??1,length:2},{type:"day",pos:((f=i.day)==null?void 0:f.index)??2,length:2}].sort((p,v)=>p.pos-v.pos);let d="",g=0;for(let p=0;p<l.length;p++){const v=l[p],m=s.substring(g,g+v.length);if(!m)break;d+=m,g+=m.length,p<l.length-1&&m.length===v.length&&(d+=t)}return d.substring(0,r)}function Nr(o,e,t){const i=o.value,r=o.selectionStart||0,n=i.length<t.length,{separator:s}=e,a=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=i.replace(new RegExp(`[^0-9${a}]`,"g"),""),d=zt(l,e);if(d!==i){o.value=d;let g=r;if(n)g=r;else if(d.length>i.length&&d[r]===s)g=r+1;else if(d.length>i.length){const u=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=(i.substring(0,r).match(new RegExp(u,"g"))||[]).length,f=(d.substring(0,r).match(new RegExp(u,"g"))||[]).length-c;g=r+f}o.setSelectionRange(g,g)}return d}function Yr(o,e){const{key:t,ctrlKey:i,metaKey:r}=o,{separator:n}=e;if(["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(t)||i||r)return!1;if(t===n){const a=o.target,l=a.selectionStart||0,d=a.value;let g=0;for(let c=l-1;c>=0;c--)if(d[c]===n){g=c+1;break}const u=d.substring(g,l);if(/^\d$/.test(u)){o.preventDefault();const c=d.substring(0,g)+"0"+u+n+d.substring(l);a.value=c;const h=g+2+n.length;return a.setSelectionRange(h,h),!0}}return!/^\d$/.test(t)&&t!==n?(o.preventDefault(),!0):!1}function Wr(o,e,t){var h;o.preventDefault();const i=((h=o.clipboardData)==null?void 0:h.getData("text"))||"",{separator:r}=t,n=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=i.replace(new RegExp(`[^0-9${n}]`,"g"),""),a=zt(s,t),l=e.selectionStart||0,d=e.selectionEnd||0,g=e.value,u=g.substring(0,l)+a+g.substring(d);e.value=zt(u,t);const c=l+a.length;e.setSelectionRange(c,c)}function Br(o,e,t,i){if(!o||o.length<e.maxLength)return!1;const r=_r(o,e);if(!r)return!1;const n=i.minDate?Q(i.minDate):null,s=i.maxDate?Q(i.maxDate):null;return n&&r<n||s&&r>s?!1:(t.selectedDate=r,t.focusedDate=r,t.viewYear=r.getFullYear(),t.viewMonth=r.getMonth(),!0)}const Ur=`
46
+ `}function sn(o,t,e){const i=o.querySelector(".wg-datepicker__days");i&&(i.innerHTML=uo(t,e))}function ln(o,t,e){const i=o.querySelector(".wg-datepicker__month-year");if(i){const n=e.monthNames[t.viewMonth];i.textContent=`${n} ${t.viewYear}`}}function an(o,t){const e=o.querySelector(".wg-datepicker__rolling-selector"),i=o.querySelector(".wg-datepicker__calendar");e&&e.classList.toggle("wg-datepicker__rolling-selector--visible",t),i&&i.classList.toggle("wg-datepicker__calendar--hidden",t)}function dn(o,t){o.querySelectorAll("[data-year]").forEach(n=>{const r=parseInt(n.dataset.year||"0",10);n.classList.toggle("wg-datepicker__rolling-item--selected",r===t.viewYear)}),o.querySelectorAll("[data-month]").forEach(n=>{const r=parseInt(n.dataset.month||"0",10);n.classList.toggle("wg-datepicker__rolling-item--selected",r===t.viewMonth)})}function ho(o){const t=o.querySelector("[data-year].wg-datepicker__rolling-item--selected"),e=o.querySelector("[data-month].wg-datepicker__rolling-item--selected");if(t){const i=t.parentElement;if(i){const n=t.offsetTop-i.clientHeight/2+t.clientHeight/2;i.scrollTop=n}}if(e){const i=e.parentElement;if(i){const n=e.offsetTop-i.clientHeight/2+e.clientHeight/2;i.scrollTop=n}}}function vt(o){o.viewMonth===0?(o.viewMonth=11,o.viewYear--):o.viewMonth--}function yt(o){o.viewMonth===11?(o.viewMonth=0,o.viewYear++):o.viewMonth++}function cn(o,t,e,i){var r,s,l,a;const{key:n}=o;if(n==="Escape")return(r=i.onClose)==null||r.call(i),!0;if(t.rollingSelectorOpen)return un(o,t);if((n==="ArrowLeft"||n==="ArrowRight")&&(o.ctrlKey||o.metaKey)){if(o.preventDefault(),n==="ArrowLeft"?vt(t):yt(t),t.focusedDate){const d=Math.min(t.focusedDate.getDate(),He(t.viewYear,t.viewMonth));t.focusedDate=new Date(t.viewYear,t.viewMonth,d)}return!0}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n))return o.preventDefault(),gn(t,n,e),!0;if(n==="Enter")return o.preventDefault(),o.stopPropagation(),t.focusedDate&&((s=i.onSelect)==null||s.call(i,t.focusedDate,"down")),!0;if(n==="Tab")return t.focusedDate?(l=i.onSelect)==null||l.call(i,t.focusedDate,"next"):(a=i.onClose)==null||a.call(i),!1;if(n==="Home"){if(o.preventDefault(),o.ctrlKey||o.metaKey){let d=t.viewYear;const g=new Date(d,0,1);if(t.focusedDate&&qe(t.focusedDate,g)&&d--,e.minDate){const u=J(e.minDate);u&&d<u.getFullYear()&&(d=u.getFullYear())}t.viewMonth=0,t.viewYear=d,t.focusedDate=new Date(d,0,1)}else t.focusedDate=new Date(t.viewYear,t.viewMonth,1);return!0}if(n==="End"){if(o.preventDefault(),o.ctrlKey||o.metaKey){let d=t.viewYear;const g=new Date(d,11,31);if(t.focusedDate&&qe(t.focusedDate,g)&&d++,e.maxDate){const u=J(e.maxDate);u&&d>u.getFullYear()&&(d=u.getFullYear())}t.viewMonth=11,t.viewYear=d,t.focusedDate=new Date(d,11,31)}else{const d=He(t.viewYear,t.viewMonth);t.focusedDate=new Date(t.viewYear,t.viewMonth,d)}return!0}if(n==="PageUp"){if(o.preventDefault(),vt(t),t.focusedDate){const d=Math.min(t.focusedDate.getDate(),He(t.viewYear,t.viewMonth));t.focusedDate=new Date(t.viewYear,t.viewMonth,d)}return!0}if(n==="PageDown"){if(o.preventDefault(),yt(t),t.focusedDate){const d=Math.min(t.focusedDate.getDate(),He(t.viewYear,t.viewMonth));t.focusedDate=new Date(t.viewYear,t.viewMonth,d)}return!0}return!1}function gn(o,t,e){if(!o.focusedDate){o.focusedDate=o.selectedDate?new Date(o.selectedDate):new Date(o.viewYear,o.viewMonth,1);return}const i=new Date(o.focusedDate),n=e.minDate?J(e.minDate):null,r=e.maxDate?J(e.maxDate):null;switch(t){case"ArrowLeft":i.setDate(i.getDate()-1);break;case"ArrowRight":i.setDate(i.getDate()+1);break;case"ArrowUp":i.setDate(i.getDate()-7);break;case"ArrowDown":i.setDate(i.getDate()+7);break}n&&i<n||r&&i>r||(o.focusedDate=i,(i.getMonth()!==o.viewMonth||i.getFullYear()!==o.viewYear)&&(o.viewMonth=i.getMonth(),o.viewYear=i.getFullYear()))}function un(o,t){const{key:e}=o;if(e==="ArrowUp"||e==="ArrowDown"){o.preventDefault();const i=e==="ArrowUp"?-1:1;if(t.rollingSelectorMode==="month"){const n=t.viewMonth+i;n>=0&&n<=11&&(t.viewMonth=n)}else t.viewYear+=i;return!0}return e==="ArrowLeft"||e==="ArrowRight"?(o.preventDefault(),t.rollingSelectorMode=t.rollingSelectorMode==="month"?"year":"month",!0):e==="Enter"||e==="Escape"?(o.preventDefault(),t.rollingSelectorOpen=!1,!0):!1}function hn(o){if(o.selectedDate)o.focusedDate=new Date(o.selectedDate),o.viewYear=o.selectedDate.getFullYear(),o.viewMonth=o.selectedDate.getMonth();else{const t=new Date;o.focusedDate=new Date(o.viewYear,o.viewMonth,t.getDate())}}function fn(o,t,e){const i=o.dataset.date;if(!i||o.classList.contains("wg-datepicker__day--disabled"))return null;const[n,r,s]=i.split("-").map(Number),l=new Date(n,r-1,s),a=e.minDate?J(e.minDate):null,d=e.maxDate?J(e.maxDate):null;return a&&l<a||d&&l>d?null:(t.selectedDate=l,t.focusedDate=l,l)}function wn(o,t){const e=new Date;e.setHours(0,0,0,0);const i=t.minDate?J(t.minDate):null,n=t.maxDate?J(t.maxDate):null;return i&&e<i||n&&e>n?null:(o.selectedDate=e,o.focusedDate=e,o.viewYear=e.getFullYear(),o.viewMonth=e.getMonth(),e)}function pn(o,t){const e=o.dataset.month;e!==void 0&&(t.viewMonth=parseInt(e,10))}function mn(o,t){const e=o.dataset.year;e!==void 0&&(t.viewYear=parseInt(e,10))}function Ct(o,t){var u,c,h,f;const{separator:e,parts:i,maxLength:n}=t,r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=o.replace(new RegExp(r,"g"),""),l=((u=i.year)==null?void 0:u.length)??4,a=[{type:"year",pos:((c=i.year)==null?void 0:c.index)??0,length:l},{type:"month",pos:((h=i.month)==null?void 0:h.index)??1,length:2},{type:"day",pos:((f=i.day)==null?void 0:f.index)??2,length:2}].sort((w,p)=>w.pos-p.pos);let d="",g=0;for(let w=0;w<a.length;w++){const p=a[w],m=s.substring(g,g+p.length);if(!m)break;d+=m,g+=m.length,w<a.length-1&&m.length===p.length&&(d+=e)}return d.substring(0,n)}function bn(o,t,e){const i=o.value,n=o.selectionStart||0,r=i.length<e.length,{separator:s}=t,l=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=i.replace(new RegExp(`[^0-9${l}]`,"g"),""),d=Ct(a,t);if(d!==i){o.value=d;let g=n;if(r)g=n;else if(d.length>i.length&&d[n]===s)g=n+1;else if(d.length>i.length){const u=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=(i.substring(0,n).match(new RegExp(u,"g"))||[]).length,f=(d.substring(0,n).match(new RegExp(u,"g"))||[]).length-c;g=n+f}o.setSelectionRange(g,g)}return d}function _n(o,t){const{key:e,ctrlKey:i,metaKey:n}=o,{separator:r}=t;if(["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(e)||i||n)return!1;if(e===r){const l=o.target,a=l.selectionStart||0,d=l.value;let g=0;for(let c=a-1;c>=0;c--)if(d[c]===r){g=c+1;break}const u=d.substring(g,a);if(/^\d$/.test(u)){o.preventDefault();const c=d.substring(0,g)+"0"+u+r+d.substring(a);l.value=c;const h=g+2+r.length;return l.setSelectionRange(h,h),!0}}return!/^\d$/.test(e)&&e!==r?(o.preventDefault(),!0):!1}function vn(o,t,e){var h;o.preventDefault();const i=((h=o.clipboardData)==null?void 0:h.getData("text"))||"",{separator:n}=e,r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=i.replace(new RegExp(`[^0-9${r}]`,"g"),""),l=Ct(s,e),a=t.selectionStart||0,d=t.selectionEnd||0,g=t.value,u=g.substring(0,a)+l+g.substring(d);t.value=Ct(u,e);const c=a+l.length;t.setSelectionRange(c,c)}function yn(o,t,e,i){if(!o||o.length<t.maxLength)return!1;const n=Ki(o,t);if(!n)return!1;const r=i.minDate?J(i.minDate):null,s=i.maxDate?J(i.maxDate):null;return r&&n<r||s&&n>s?!1:(e.selectedDate=n,e.focusedDate=n,e.viewYear=n.getFullYear(),e.viewMonth=n.getMonth(),!0)}const Cn=`
259
47
  .wg-datepicker-container {
260
48
  position: fixed;
261
49
  z-index: var(--wg-dp-z-index, 9999);
@@ -505,7 +293,225 @@
505
293
  .wg-datepicker__today-btn:hover {
506
294
  background-color: color-mix(in srgb, var(--wg-dp-accent-color) 10%, transparent);
507
295
  }
508
- `;let _o=!1;class It{constructor(e={}){w(this,"options");w(this,"state");w(this,"localeStrings");w(this,"formatInfo");w(this,"element",null);w(this,"anchor",null);w(this,"input",null);w(this,"cleanupAutoUpdate",null);w(this,"previousInputValue","");w(this,"boundHandleClickOutside");w(this,"boundHandleKeyDown");this.options={dateFormat:"YYYY-MM-DD",showTodayButton:!0,...e};const t=new Date;this.state={viewMonth:t.getMonth(),viewYear:t.getFullYear(),selectedDate:null,isOpen:!1,rollingSelectorOpen:!1,rollingSelectorMode:"month",focusedDate:null},this.localeStrings=this.initLocaleStrings(e.locale),this.formatInfo=Rt(this.options.dateFormat||"YYYY-MM-DD"),this.boundHandleClickOutside=this.handleClickOutside.bind(this),this.boundHandleKeyDown=this.handleKeyDown.bind(this)}initLocaleStrings(e){const t=e||navigator.language||"en";try{const i=new Intl.DateTimeFormat(t,{month:"long"}),r=new Intl.DateTimeFormat(t,{month:"short"}),n=new Intl.DateTimeFormat(t,{weekday:"long"}),s=new Intl.DateTimeFormat(t,{weekday:"short"}),a=[],l=[];for(let u=0;u<12;u++){const c=new Date(2024,u,1);a.push(i.format(c)),l.push(r.format(c))}const d=[],g=[];for(let u=0;u<7;u++){const c=new Date(2024,0,7+u);d.push(n.format(c));const h=s.format(c);g.push(h.substring(0,2))}return{today:"Today",clear:"Clear",monthNames:a,monthNamesShort:l,weekdayNames:d,weekdayNamesShort:g}}catch{return wo}}static injectStyles(){if(_o)return;const e=document.createElement("style");e.id="wg-datepicker-styles",e.textContent=Ur,document.head.appendChild(e),_o=!0}open(e,t=null){It.injectStyles(),this.state.isOpen&&this.close(),this.anchor=e;const i=Q(t);if(i)this.state.selectedDate=i,this.state.viewYear=i.getFullYear(),this.state.viewMonth=i.getMonth();else{const r=new Date;this.state.viewYear=r.getFullYear(),this.state.viewMonth=r.getMonth()}Hr(this.state),this.element=document.createElement("div"),this.element.className="wg-datepicker-container",this.element.innerHTML=Sr(this.state,this.options,this.localeStrings),document.body.appendChild(this.element),this.position(),this.attachListeners(),this.state.isOpen=!0,this.state.rollingSelectorOpen&&bo(this.element)}close(e=!1){var t,i;this.state.isOpen&&(this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null),document.removeEventListener("mousedown",this.boundHandleClickOutside),document.removeEventListener("keydown",this.boundHandleKeyDown),this.element&&(this.element.remove(),this.element=null),this.state.isOpen=!1,this.state.rollingSelectorOpen=!1,e||(i=(t=this.options).onClose)==null||i.call(t))}destroy(){this.close(),this.anchor=null,this.input=null}getSelectedDate(){return this.state.selectedDate}getFormattedValue(){return po(this.state.selectedDate,this.formatInfo)}position(){if(!this.element||!this.anchor)return;const e=this.element.querySelector(".wg-datepicker");e&&(this.cleanupAutoUpdate=Ai(this.anchor,e,()=>{if(!this.anchor.isConnected){this.close(!0);return}Le(this.anchor,e,{placement:"bottom-start",middleware:[ft(4),Ie({fallbackPlacements:["top-start","bottom-end","top-end"]}),Ze({padding:8})]}).then(({x:t,y:i})=>{Object.assign(e.style,{left:`${t}px`,top:`${i}px`})})}))}attachListeners(){this.element&&(this.element.addEventListener("click",e=>this.handleClick(e)),setTimeout(()=>{document.addEventListener("mousedown",this.boundHandleClickOutside)},0),document.addEventListener("keydown",this.boundHandleKeyDown))}handleClick(e){var a;const t=e.target,i=(a=t.closest("[data-action]"))==null?void 0:a.getAttribute("data-action");if(i==="prev-month"){e.preventDefault(),Mt(this.state),this.render();return}if(i==="next-month"){e.preventDefault(),Tt(this.state),this.render();return}if(i==="toggle-rolling"){e.preventDefault(),this.state.rollingSelectorOpen=!this.state.rollingSelectorOpen,this.render(),this.state.rollingSelectorOpen&&this.element&&bo(this.element);return}if(i==="today"){e.preventDefault();const l=Fr(this.state,this.options);l&&this.selectDate(l);return}const r=t.closest(".wg-datepicker__day");if(r){e.preventDefault();const l=Pr(r,this.state,this.options);l&&this.selectDate(l);return}const n=t.closest("[data-month]");if(n&&this.state.rollingSelectorOpen){e.preventDefault(),qr(n,this.state),this.render();return}const s=t.closest("[data-year]");if(s&&this.state.rollingSelectorOpen){e.preventDefault(),Vr(s,this.state),this.render();return}}handleClickOutside(e){if(!this.element||!this.anchor)return;const t=e.target;!this.element.contains(t)&&!this.anchor.contains(t)&&this.close()}handleKeyDown(e){Lr(e,this.state,this.options,{onSelect:(i,r)=>this.selectDate(i,r),onClose:()=>this.close()})&&this.render()}selectDate(e,t){var i,r;this.state.selectedDate=e,(r=(i=this.options).onSelect)==null||r.call(i,e,t),this.close(!0)}render(){if(!this.element)return;const e=this.element.querySelector(".wg-datepicker");e&&(Tr(e,this.state,this.localeStrings),zr(e,this.state.rollingSelectorOpen),this.state.rollingSelectorOpen?Ir(e,this.state):Mr(e,this.state,this.options))}connectInput(e){this.input=e,this.previousInputValue=e.value,e.addEventListener("input",()=>{this.previousInputValue=Nr(e,this.formatInfo,this.previousInputValue),Br(e.value,this.formatInfo,this.state,this.options)}),e.addEventListener("keydown",t=>{Yr(t,this.formatInfo)}),e.addEventListener("paste",t=>{Wr(t,e,this.formatInfo)}),e.addEventListener("focus",()=>{!this.state.isOpen&&this.anchor&&this.open(this.anchor,e.value)})}}const jr=`
296
+ `;let fo=!1;class St{constructor(t={}){b(this,"options");b(this,"state");b(this,"localeStrings");b(this,"formatInfo");b(this,"element",null);b(this,"anchor",null);b(this,"input",null);b(this,"cleanupAutoUpdate",null);b(this,"previousInputValue","");b(this,"boundHandleClickOutside");b(this,"boundHandleKeyDown");this.options={dateFormat:"YYYY-MM-DD",showTodayButton:!0,...t};const e=new Date;this.state={viewMonth:e.getMonth(),viewYear:e.getFullYear(),selectedDate:null,isOpen:!1,rollingSelectorOpen:!1,rollingSelectorMode:"month",focusedDate:null},this.localeStrings=this.initLocaleStrings(t.locale),this.formatInfo=tt(this.options.dateFormat||"YYYY-MM-DD"),this.boundHandleClickOutside=this.handleClickOutside.bind(this),this.boundHandleKeyDown=this.handleKeyDown.bind(this)}initLocaleStrings(t){const e=t||navigator.language||"en";try{const i=new Intl.DateTimeFormat(e,{month:"long"}),n=new Intl.DateTimeFormat(e,{month:"short"}),r=new Intl.DateTimeFormat(e,{weekday:"long"}),s=new Intl.DateTimeFormat(e,{weekday:"short"}),l=[],a=[];for(let u=0;u<12;u++){const c=new Date(2024,u,1);l.push(i.format(c)),a.push(n.format(c))}const d=[],g=[];for(let u=0;u<7;u++){const c=new Date(2024,0,7+u);d.push(r.format(c));const h=s.format(c);g.push(h.substring(0,2))}return{today:"Today",clear:"Clear",monthNames:l,monthNamesShort:a,weekdayNames:d,weekdayNamesShort:g}}catch{return go}}static injectStyles(){if(fo)return;const t=document.createElement("style");t.id="wg-datepicker-styles",t.textContent=Cn,document.head.appendChild(t),fo=!0}open(t,e=null){St.injectStyles(),this.state.isOpen&&this.close(),this.anchor=t;const i=J(e);if(i)this.state.selectedDate=i,this.state.viewYear=i.getFullYear(),this.state.viewMonth=i.getMonth();else{const n=new Date;this.state.viewYear=n.getFullYear(),this.state.viewMonth=n.getMonth()}hn(this.state),this.element=document.createElement("div"),this.element.className="wg-datepicker-container",this.element.innerHTML=Ji(this.state,this.options,this.localeStrings),document.body.appendChild(this.element),this.position(),this.attachListeners(),this.state.isOpen=!0,this.state.rollingSelectorOpen&&ho(this.element)}close(t=!1){var e,i;this.state.isOpen&&(this.cleanupAutoUpdate&&(this.cleanupAutoUpdate(),this.cleanupAutoUpdate=null),document.removeEventListener("mousedown",this.boundHandleClickOutside),document.removeEventListener("keydown",this.boundHandleKeyDown),this.element&&(this.element.remove(),this.element=null),this.state.isOpen=!1,this.state.rollingSelectorOpen=!1,t||(i=(e=this.options).onClose)==null||i.call(e))}destroy(){this.close(),this.anchor=null,this.input=null}getSelectedDate(){return this.state.selectedDate}getFormattedValue(){return bt(this.state.selectedDate,this.formatInfo)}position(){if(!this.element||!this.anchor)return;const t=this.element.querySelector(".wg-datepicker");t&&(this.cleanupAutoUpdate=Bi(this.anchor,t,()=>{if(!this.anchor.isConnected){this.close(!0);return}Ae(this.anchor,t,{placement:"bottom-start",middleware:[mt(4),Le({fallbackPlacements:["top-start","bottom-end","top-end"]}),et({padding:8})]}).then(({x:e,y:i})=>{Object.assign(t.style,{left:`${e}px`,top:`${i}px`})})}))}attachListeners(){this.element&&(this.element.addEventListener("click",t=>this.handleClick(t)),setTimeout(()=>{document.addEventListener("mousedown",this.boundHandleClickOutside)},0),document.addEventListener("keydown",this.boundHandleKeyDown))}handleClick(t){var l;const e=t.target,i=(l=e.closest("[data-action]"))==null?void 0:l.getAttribute("data-action");if(i==="prev-month"){t.preventDefault(),vt(this.state),this.render();return}if(i==="next-month"){t.preventDefault(),yt(this.state),this.render();return}if(i==="toggle-rolling"){t.preventDefault(),this.state.rollingSelectorOpen=!this.state.rollingSelectorOpen,this.render(),this.state.rollingSelectorOpen&&this.element&&ho(this.element);return}if(i==="today"){t.preventDefault();const a=wn(this.state,this.options);a&&this.selectDate(a);return}const n=e.closest(".wg-datepicker__day");if(n){t.preventDefault();const a=fn(n,this.state,this.options);a&&this.selectDate(a);return}const r=e.closest("[data-month]");if(r&&this.state.rollingSelectorOpen){t.preventDefault(),pn(r,this.state),this.render();return}const s=e.closest("[data-year]");if(s&&this.state.rollingSelectorOpen){t.preventDefault(),mn(s,this.state),this.render();return}}handleClickOutside(t){if(!this.element||!this.anchor)return;const e=t.target;!this.element.contains(e)&&!this.anchor.contains(e)&&this.close()}handleKeyDown(t){cn(t,this.state,this.options,{onSelect:(i,n)=>this.selectDate(i,n),onClose:()=>this.close()})&&this.render()}selectDate(t,e){var i,n;this.state.selectedDate=t,(n=(i=this.options).onSelect)==null||n.call(i,t,e),this.close(!0)}render(){if(!this.element)return;const t=this.element.querySelector(".wg-datepicker");t&&(ln(t,this.state,this.localeStrings),an(t,this.state.rollingSelectorOpen),this.state.rollingSelectorOpen?dn(t,this.state):sn(t,this.state,this.options))}connectInput(t){this.input=t,this.previousInputValue=t.value,t.addEventListener("input",()=>{this.previousInputValue=bn(t,this.formatInfo,this.previousInputValue),yn(t.value,this.formatInfo,this.state,this.options)}),t.addEventListener("keydown",e=>{_n(e,this.formatInfo)}),t.addEventListener("paste",e=>{vn(e,t,this.formatInfo)}),t.addEventListener("focus",()=>{!this.state.isOpen&&this.anchor&&this.open(this.anchor,t.value)})}}const wo={rowActions:"Row actions",inlineActionsHeader:"Actions",keyboardShortcuts:"Keyboard shortcuts",paginationFirst:"⏮",paginationPrevious:"◀",paginationNext:"▶",paginationLast:"⏭",paginationPageInfo:"Page {current} of {total}",paginationItemCount:"{count} items",paginationPerPage:"per page",dropdownNoOptions:"No options",dropdownSearching:"Searching...",contextMenu:{sortAsc:"Sort Ascending",sortDesc:"Sort Descending",clearSort:"Clear Sort",hideColumn:"Hide Column",freezeColumn:"Freeze Column",unfreezeColumn:"Unfreeze Column",columnVisibility:"Column Visibility",showAll:"Show all"}};class po{constructor(){b(this,"_items",[]);b(this,"_columns",[]);b(this,"_sortMode","none");b(this,"_isFilterable",!1);b(this,"_isPageable",!1);b(this,"_pageSize",10);b(this,"_pageSizes",[10,25,50,100]);b(this,"_isStriped",!0);b(this,"_isHoverable",!0);b(this,"_isEditable",!1);b(this,"_editTrigger","dblclick");b(this,"_editStartSelection","mousePosition");b(this,"_mode","excel");b(this,"_dropdownToggleVisibility","always");b(this,"_shouldShowDropdownOnFocus",!0);b(this,"_shouldOpenDropdownOnEnter",!1);b(this,"_isCheckboxAlwaysEditable",!1);b(this,"_isRowNumbersVisible",!1);b(this,"_isStickyRowNumbers",!1);b(this,"_freezeColumns",0);b(this,"_invalidCells",[]);b(this,"_isRowToolbarVisible",!1);b(this,"_rowToolbar",["add","delete","duplicate"]);b(this,"_toolbarVerticalAlign","bottom");b(this,"_toolbarHorizontalAlign","center");b(this,"_toolbarTrigger","hover");b(this,"_toolbarPosition","auto");b(this,"_inlineActionsTitle","");b(this,"_contextMenu");b(this,"_contextMenuXOffset",8);b(this,"_contextMenuYOffset",0);b(this,"_headerContextMenu");b(this,"_rowShortcuts");b(this,"_isShortcutsHelpVisible",!1);b(this,"_shortcutsHelpPosition","top-right");b(this,"_shortcutsHelpContentCallback");b(this,"_idValueMember");b(this,"_idValueCallback");b(this,"_rowLocking");b(this,"_externalLocks",new Map);b(this,"_onrowlockchange");b(this,"_gridName",null);b(this,"_shouldPersistColumnWidths",!1);b(this,"_columnWidths",new Map);b(this,"_oncolumnresize");b(this,"_isColumnReorderAllowed",!1);b(this,"_shouldPersistColumnOrder",!1);b(this,"_columnOrder",new Map);b(this,"_oncolumnreorder");b(this,"_fillDirection","vertical");b(this,"_fillDragCallback");b(this,"_onrowchange");b(this,"_onroweditstart");b(this,"_onroweditcancel");b(this,"_onvalidationerror");b(this,"_validationTooltipCallback");b(this,"_ontoolbarclick");b(this,"_onrowaction");b(this,"_oncontextmenuopen");b(this,"_onheadercontextmenuopen");b(this,"_ondatarequest");b(this,"_onrowdelete");b(this,"_sort",[]);b(this,"_filters",{});b(this,"_currentPage",1);b(this,"_totalItems",null);b(this,"_showPagination",!0);b(this,"_paginationPosition","bottom-center");b(this,"_paginationLabelsCallback");b(this,"_paginationLayout","pageSize|previous|pageInfo|next");b(this,"_summaryPosition");b(this,"_summaryContentCallback");b(this,"_summaryMetadata");b(this,"_isSummaryInline",!0);b(this,"_customStylesCallback");b(this,"_rowClassCallback");b(this,"_labels",{...wo});b(this,"_isVirtualScrollEnabled",!1);b(this,"_virtualScrollThreshold",100);b(this,"_virtualScrollRowHeight",38);b(this,"_virtualScrollBuffer",10);b(this,"_isInfiniteScrollEnabled",!1);b(this,"_infiniteScrollThreshold",100);b(this,"_hasMoreItems",!0);b(this,"_isLoadingMore",!1);b(this,"_editingCell",null);b(this,"_currentCellError",null);b(this,"_isValidating",!1);b(this,"_draftRows",new Map);b(this,"_focusedCell",null);b(this,"_isCommittingFromKeyboard",!1);b(this,"_skipNextDropdownAutoEdit",!1);b(this,"_hoveredRowIndex",null);b(this,"_onInteractionChange",null);b(this,"_selectedRows",new Set);b(this,"_lastSelectedRowIndex",null);b(this,"_rangeShortcuts",[]);b(this,"_cellSelectionMode","click");b(this,"_selectedCellRange",null);b(this,"_lastClickedCell",null);b(this,"_shouldCopyWithHeaders",!1);b(this,"_oncellselectionchange",null)}get items(){return this._items}set items(t){this._items=t,this.requestUpdate()}get columns(){return this._columns}set columns(t){this._columns=t,this.requestUpdate()}get sortMode(){return this._sortMode}set sortMode(t){this._sortMode=t,this.requestUpdate()}get isFilterable(){return this._isFilterable}set isFilterable(t){this._isFilterable=t,this.requestUpdate()}get isPageable(){return this._isPageable}set isPageable(t){this._isPageable=t,this.requestUpdate()}get pageSize(){return this._pageSize}set pageSize(t){this._pageSize=t,this.requestUpdate()}get pageSizes(){return this._pageSizes}set pageSizes(t){this._pageSizes=t,this.requestUpdate()}get isStriped(){return this._isStriped}set isStriped(t){this._isStriped=t,this.requestUpdate()}get isHoverable(){return this._isHoverable}set isHoverable(t){this._isHoverable=t,this.requestUpdate()}get isEditable(){return this._isEditable}set isEditable(t){this._isEditable=t,this.requestUpdate()}get editTrigger(){return this._editTrigger}set editTrigger(t){this._editTrigger=t,this.checkSelectionConflicts(),this.requestUpdate()}get editStartSelection(){return this._editStartSelection}set editStartSelection(t){this._editStartSelection=t}get mode(){return this._mode}set mode(t){this._mode=t,this.applyModeDefaults(),this.requestUpdate()}get dropdownToggleVisibility(){return this._dropdownToggleVisibility}set dropdownToggleVisibility(t){this._dropdownToggleVisibility=t,this.requestUpdate()}getEffectiveToggleVisibility(t){return t.dropdownToggleVisibility??this._dropdownToggleVisibility}get shouldShowDropdownOnFocus(){return this._shouldShowDropdownOnFocus}set shouldShowDropdownOnFocus(t){this._shouldShowDropdownOnFocus=t}get shouldOpenDropdownOnEnter(){return this._shouldOpenDropdownOnEnter}set shouldOpenDropdownOnEnter(t){this._shouldOpenDropdownOnEnter=t}getEffectiveShouldOpenDropdownOnEnter(t){return t.shouldOpenDropdownOnEnter??this._shouldOpenDropdownOnEnter}get isCheckboxAlwaysEditable(){return this._isCheckboxAlwaysEditable}set isCheckboxAlwaysEditable(t){this._isCheckboxAlwaysEditable=t,this.requestUpdate()}get isRowNumbersVisible(){return this._isRowNumbersVisible}set isRowNumbersVisible(t){this._isRowNumbersVisible=t,this.requestUpdate()}get isStickyRowNumbers(){return this._isStickyRowNumbers}set isStickyRowNumbers(t){this._isStickyRowNumbers=t,this.requestUpdate()}get freezeColumns(){return this._freezeColumns}set freezeColumns(t){this._freezeColumns=Math.max(0,Math.floor(t)),this.requestUpdate()}get visualColumns(){const t=[],e=[];this._columns.filter(r=>r.isFrozen&&!r.isHidden).length,this._columns.forEach((r,s)=>{if(r.isHidden)return;const l={column:r,originalIndex:s};r.isFrozen?t.push(l):e.push(l)});const i=[],n=[];return e.forEach((r,s)=>{s<this._freezeColumns?i.push(r):n.push(r)}),this._columnOrder.size>0&&n.sort((r,s)=>{const l=String(r.column.field),a=String(s.column.field),d=this._columnOrder.get(l)??r.originalIndex,g=this._columnOrder.get(a)??s.originalIndex;return d-g}),[...t,...i,...n]}get totalFrozenColumns(){return this._columns.filter(e=>e.isFrozen).length+this._freezeColumns}isColumnFrozen(t){return t<this.totalFrozenColumns}get invalidCells(){return this._invalidCells}set invalidCells(t){this._invalidCells=t,this.requestUpdate()}get editingCell(){return this._editingCell}get isValidating(){return this._isValidating}get currentCellError(){return this._currentCellError}get hoveredRowIndex(){return this._hoveredRowIndex}get isRowToolbarVisible(){return this._isRowToolbarVisible}set isRowToolbarVisible(t){this._isRowToolbarVisible=t,this.requestUpdate()}get rowToolbar(){return this._rowToolbar}set rowToolbar(t){this._rowToolbar=t,this.requestUpdate()}get toolbarVerticalAlign(){return this._toolbarVerticalAlign}set toolbarVerticalAlign(t){this._toolbarVerticalAlign=t,this.requestUpdate()}get toolbarHorizontalAlign(){return this._toolbarHorizontalAlign}set toolbarHorizontalAlign(t){this._toolbarHorizontalAlign=t,this.requestUpdate()}get toolbarAlign(){return this._toolbarVerticalAlign}set toolbarAlign(t){this.toolbarVerticalAlign=t}get toolbarTopPosition(){return this._toolbarHorizontalAlign}set toolbarTopPosition(t){this.toolbarHorizontalAlign=t}get toolbarTrigger(){return this._toolbarTrigger}set toolbarTrigger(t){this._toolbarTrigger=t,this.requestUpdate()}get toolbarPosition(){return this._toolbarPosition}set toolbarPosition(t){this._toolbarPosition=t,this.requestUpdate()}get inlineActionsTitle(){return this._inlineActionsTitle}set inlineActionsTitle(t){this._inlineActionsTitle=t,this.requestUpdate()}get contextMenu(){return this._contextMenu}set contextMenu(t){this._contextMenu=t,this.requestUpdate()}get contextMenuXOffset(){return this._contextMenuXOffset}set contextMenuXOffset(t){this._contextMenuXOffset=t}get contextMenuYOffset(){return this._contextMenuYOffset}set contextMenuYOffset(t){this._contextMenuYOffset=t}get headerContextMenu(){return this._headerContextMenu}set headerContextMenu(t){this._headerContextMenu=t}get rowShortcuts(){return this._rowShortcuts}set rowShortcuts(t){this._rowShortcuts=t,this.requestUpdate()}get isShortcutsHelpVisible(){return this._isShortcutsHelpVisible}set isShortcutsHelpVisible(t){this._isShortcutsHelpVisible=t,this.requestUpdate()}get shortcutsHelpPosition(){return this._shortcutsHelpPosition}set shortcutsHelpPosition(t){this._shortcutsHelpPosition=t,this.requestUpdate()}get shortcutsHelpContentCallback(){return this._shortcutsHelpContentCallback}set shortcutsHelpContentCallback(t){this._shortcutsHelpContentCallback=t,this.requestUpdate()}get sort(){return this._sort}set sort(t){this._sort=t,this.requestUpdate()}get currentPage(){return this._currentPage}set currentPage(t){this._currentPage=t,this.requestUpdate()}get totalItems(){return this._totalItems}set totalItems(t){this._totalItems=t,this.requestUpdate()}get showPagination(){return this._showPagination}set showPagination(t){this._showPagination=t,this.requestUpdate()}get paginationPosition(){return this._paginationPosition}set paginationPosition(t){this._paginationPosition=t,this.requestUpdate()}get paginationLabelsCallback(){return this._paginationLabelsCallback}set paginationLabelsCallback(t){this._paginationLabelsCallback=t,this.requestUpdate()}get paginationLayout(){return this._paginationLayout}set paginationLayout(t){this._paginationLayout=t,this.requestUpdate()}get summaryPosition(){return this._summaryPosition}set summaryPosition(t){this._summaryPosition=t,this.requestUpdate()}get summaryContentCallback(){return this._summaryContentCallback}set summaryContentCallback(t){this._summaryContentCallback=t,this.requestUpdate()}get summaryMetadata(){return this._summaryMetadata}set summaryMetadata(t){this._summaryMetadata=t,this.requestUpdate()}get isSummaryInline(){return this._isSummaryInline}set isSummaryInline(t){this._isSummaryInline=t,this.requestUpdate()}get customStylesCallback(){return this._customStylesCallback}set customStylesCallback(t){this._customStylesCallback=t}get rowClassCallback(){return this._rowClassCallback}set rowClassCallback(t){this._rowClassCallback=t,this.requestUpdate()}get labels(){return this._labels}set labels(t){this._labels={...wo,...t},this.requestUpdate()}get isVirtualScrollEnabled(){return this._isVirtualScrollEnabled}set isVirtualScrollEnabled(t){this._isVirtualScrollEnabled=t,this.requestUpdate()}get virtualScrollThreshold(){return this._virtualScrollThreshold}set virtualScrollThreshold(t){this._virtualScrollThreshold=t,this.requestUpdate()}get virtualScrollRowHeight(){return this._virtualScrollRowHeight}set virtualScrollRowHeight(t){this._virtualScrollRowHeight=t,this.requestUpdate()}get virtualScrollBuffer(){return this._virtualScrollBuffer}set virtualScrollBuffer(t){this._virtualScrollBuffer=t,this.requestUpdate()}get isInfiniteScrollEnabled(){return this._isInfiniteScrollEnabled}set isInfiniteScrollEnabled(t){this._isInfiniteScrollEnabled=t,this.requestUpdate()}get infiniteScrollThreshold(){return this._infiniteScrollThreshold}set infiniteScrollThreshold(t){this._infiniteScrollThreshold=t}get hasMoreItems(){return this._hasMoreItems}set hasMoreItems(t){this._hasMoreItems=t}get isLoadingMore(){return this._isLoadingMore}set isLoadingMore(t){this._isLoadingMore=t}shouldUseVirtualScroll(){return this._isVirtualScrollEnabled===!1?!1:this._isVirtualScrollEnabled===!0?!0:this.displayItems.length>=this._virtualScrollThreshold}set onrowchange(t){this._onrowchange=t}set onroweditstart(t){this._onroweditstart=t}set onroweditcancel(t){this._onroweditcancel=t}set onvalidationerror(t){this._onvalidationerror=t}get validationTooltipCallback(){return this._validationTooltipCallback}set validationTooltipCallback(t){this._validationTooltipCallback=t}get ontoolbarclick(){return this._ontoolbarclick}set ontoolbarclick(t){this._ontoolbarclick=t}set onrowaction(t){this._onrowaction=t}set oncontextmenuopen(t){this._oncontextmenuopen=t}get onheadercontextmenuopen(){return this._onheadercontextmenuopen}set onheadercontextmenuopen(t){this._onheadercontextmenuopen=t}get ondatarequest(){return this._ondatarequest}set ondatarequest(t){this._ondatarequest=t}get onrowdelete(){return this._onrowdelete}set onrowdelete(t){this._onrowdelete=t}get idValueMember(){return this._idValueMember}set idValueMember(t){this._idValueMember=t}get idValueCallback(){return this._idValueCallback}set idValueCallback(t){this._idValueCallback=t}get rowLocking(){return this._rowLocking}set rowLocking(t){this._rowLocking=t,this.requestUpdate()}get onrowlockchange(){return this._onrowlockchange}set onrowlockchange(t){this._onrowlockchange=t}get gridName(){return this._gridName}set gridName(t){this._gridName=t}get shouldPersistColumnWidths(){return this._shouldPersistColumnWidths}set shouldPersistColumnWidths(t){this._shouldPersistColumnWidths=t}get oncolumnresize(){return this._oncolumnresize}set oncolumnresize(t){this._oncolumnresize=t}get isColumnReorderAllowed(){return this._isColumnReorderAllowed}set isColumnReorderAllowed(t){this._isColumnReorderAllowed=t}get shouldPersistColumnOrder(){return this._shouldPersistColumnOrder}set shouldPersistColumnOrder(t){this._shouldPersistColumnOrder=t}get oncolumnreorder(){return this._oncolumnreorder}set oncolumnreorder(t){this._oncolumnreorder=t}get fillDirection(){return this._fillDirection}set fillDirection(t){this._fillDirection=t}get fillDragCallback(){return this._fillDragCallback}set fillDragCallback(t){this._fillDragCallback=t}get selectedRows(){return Array.from(this._selectedRows).sort((t,e)=>t-e)}get rangeShortcuts(){return this._rangeShortcuts}set rangeShortcuts(t){this._rangeShortcuts=t}isRowSelected(t){return this._selectedRows.has(t)}selectRow(t,e="replace"){switch(this._selectedCellRange&&(this._selectedCellRange=null),e){case"replace":this._selectedRows.clear(),this._selectedRows.add(t),this._lastSelectedRowIndex=t;break;case"toggle":this._selectedRows.has(t)?this._selectedRows.delete(t):this._selectedRows.add(t),this._lastSelectedRowIndex=t;break;case"range":if(this._lastSelectedRowIndex!==null){const i=Math.min(this._lastSelectedRowIndex,t),n=Math.max(this._lastSelectedRowIndex,t);for(let r=i;r<=n;r++)this._selectedRows.add(r)}else this._selectedRows.add(t),this._lastSelectedRowIndex=t;break}this.requestUpdate()}selectRowRange(t,e){this._selectedRows.clear();const i=Math.min(t,e),n=Math.max(t,e);for(let r=i;r<=n;r++)this._selectedRows.add(r);this._lastSelectedRowIndex=e,this.requestUpdate()}clearSelection(){this._selectedRows.size>0&&(this._selectedRows.clear(),this._lastSelectedRowIndex=null,this.requestUpdate())}getSelectedRowsData(){return this.selectedRows.map(t=>this.displayItems[t]).filter(Boolean)}async copySelectedRowsToClipboard(){const t=this.selectedRows;if(t.length===0)return!1;const e=[];if(this._shouldCopyWithHeaders){const n=[];for(const r of this.visualColumns){const s=r.column.title??r.column.field??"";n.push(String(s))}e.push(n.join(" "))}for(const n of t){const r=this.displayItems[n];if(!r)continue;const s=[];for(const l of this.visualColumns){const a=String(l.column.field),d=r[a],g=d==null?"":String(d);s.push(g)}e.push(s.join(" "))}const i=e.join(`
297
+ `);try{return await navigator.clipboard.writeText(i),!0}catch{return!1}}get cellSelectionMode(){return this._cellSelectionMode}set cellSelectionMode(t){this._cellSelectionMode=t,this.checkSelectionConflicts(),this.requestUpdate()}get shouldCopyWithHeaders(){return this._shouldCopyWithHeaders}set shouldCopyWithHeaders(t){this._shouldCopyWithHeaders=t}get selectedCellRange(){return this._selectedCellRange}get lastClickedCell(){return this._lastClickedCell}set lastClickedCell(t){this._lastClickedCell=t}get oncellselectionchange(){return this._oncellselectionchange}set oncellselectionchange(t){this._oncellselectionchange=t}selectCellRange(t){if(this._selectedRows.size>0&&(this._selectedRows.clear(),this._lastSelectedRowIndex=null),this._selectedCellRange=t,this.requestUpdate(),this._oncellselectionchange){const e=this.getSelectedCells();this._oncellselectionchange({range:t,cellCount:e.length})}}clearCellSelection(){this._selectedCellRange&&(this._selectedCellRange=null,this.requestUpdate(),this._oncellselectionchange&&this._oncellselectionchange({range:null,cellCount:0}))}getSelectedCells(){var g;if(!this._selectedCellRange)return[];const{startRowIndex:t,endRowIndex:e,startColIndex:i,endColIndex:n}=this._selectedCellRange,r=Math.min(t,e),s=Math.max(t,e),l=Math.min(i,n),a=Math.max(i,n),d=[];for(let u=r;u<=s;u++)for(let c=l;c<=a;c++){const h=(g=this.visualColumns[c])==null?void 0:g.column;if(!h)continue;const f=this.displayItems[u];if(!f)continue;const w=String(h.field),p=f[w];d.push({row:f,rowIndex:u,colIndex:c,field:w,value:p})}return d}isCellInSelectedRange(t,e){if(!this._selectedCellRange)return!1;const{startRowIndex:i,endRowIndex:n,startColIndex:r,endColIndex:s}=this._selectedCellRange,l=Math.min(i,n),a=Math.max(i,n),d=Math.min(r,s),g=Math.max(r,s);return t>=l&&t<=a&&e>=d&&e<=g}async copyCellSelectionToClipboard(){var u,c;if(!this._selectedCellRange)return!1;const{startRowIndex:t,endRowIndex:e,startColIndex:i,endColIndex:n}=this._selectedCellRange,r=Math.min(t,e),s=Math.max(t,e),l=Math.min(i,n),a=Math.max(i,n),d=[];if(this._shouldCopyWithHeaders){const h=[];for(let f=l;f<=a;f++){const w=(u=this.visualColumns[f])==null?void 0:u.column,p=(w==null?void 0:w.title)??(w==null?void 0:w.field)??"";h.push(String(p))}d.push(h.join(" "))}for(let h=r;h<=s;h++){const f=this.displayItems[h];if(!f)continue;const w=[];for(let p=l;p<=a;p++){const m=(c=this.visualColumns[p])==null?void 0:c.column;if(!m){w.push("");continue}const y=String(m.field),_=f[y],S=_==null?"":String(_);w.push(S)}d.push(w.join(" "))}const g=d.join(`
298
+ `);try{return await navigator.clipboard.writeText(g),!0}catch{return!1}}get isNavigateMode(){return this._editTrigger==="navigate"||this._columns.some(t=>t.editTrigger==="navigate")}get filteredItems(){return!this._isFilterable||Object.keys(this._filters).length===0?this._items:this._items.filter(t=>Object.entries(this._filters).every(([e,i])=>i?String(t[e]??"").toLowerCase().includes(i.toLowerCase()):!0))}get sortedItems(){return this._sort.length===0?this.filteredItems:[...this.filteredItems].sort((t,e)=>{for(const i of this._sort){const n=t[i.column],r=e[i.column];if(n===r)continue;let s=0;return typeof n=="string"&&typeof r=="string"?s=n.localeCompare(r):typeof n=="number"&&typeof r=="number"?s=n-r:s=String(n??"").localeCompare(String(r??"")),i.direction==="asc"?s:-s}return 0})}get paginatedItems(){if(!this._isPageable)return this.sortedItems;const t=(this._currentPage-1)*this._pageSize,e=t+this._pageSize;return this.sortedItems.slice(t,e)}get totalPages(){const t=this._totalItems!==null?this._totalItems:this.sortedItems.length;return Math.max(1,Math.ceil(t/this._pageSize))}get displayItems(){return this.paginatedItems}fireDataRequest(t){if(this._ondatarequest){const e=t==="loadMore"?this._items.length:(this._currentPage-1)*this._pageSize,i={sort:[...this._sort],page:this._currentPage,pageSize:this._pageSize,trigger:t,mode:t==="loadMore"?"append":"replace",skip:e};this._ondatarequest(i)}}getColumnSortState(t){return this._sort.find(e=>e.column===t)}getColumnSortPriority(t){const e=this._sort.findIndex(i=>i.column===t);return e>=0?e+1:0}applyModeDefaults(){switch(this._mode){case"read-only":this._isEditable=!1,this._dropdownToggleVisibility="on-focus",this._cellSelectionMode="click";break;case"excel":this._isEditable=!0,this._editTrigger="navigate",this._dropdownToggleVisibility="always",this._shouldShowDropdownOnFocus=!1,this._cellSelectionMode="click";break;case"input-matrix":this._isEditable=!0,this._editTrigger="always",this._dropdownToggleVisibility="always",this._shouldShowDropdownOnFocus=!0,this._cellSelectionMode="shift";break}}checkSelectionConflicts(){this._cellSelectionMode==="click"&&this._editTrigger==="click"&&console.warn('WebGrid: cellSelectionMode="click" conflicts with editTrigger="click". Cell range selection takes priority. Use Shift+click to enter edit mode, or change to cellSelectionMode="shift" to avoid confusion.')}requestUpdate(){}getRowDraft(t){return this._draftRows.get(t)}hasRowDraft(t){return this._draftRows.has(t)}discardRowDraft(t){this._draftRows.delete(t),this._invalidCells=this._invalidCells.filter(e=>e.rowIndex!==t),this.requestUpdate()}getDraftRowIndices(){return Array.from(this._draftRows.keys())}discardAllDrafts(){this._draftRows.clear(),this._invalidCells=[],this.requestUpdate()}getCellRawValue(t,e,i){const n=this._draftRows.get(e);return n?n[i]:t[i]}getCellValue(t,e,i){var r;if(e.templateCallback)return e.templateCallback(t);const n=i!==void 0?this.getCellRawValue(t,i,String(e.field)):t[String(e.field)];if(e.formatCallback)return e.formatCallback(n,t);if(e.editor==="date"&&((r=e.editorOptions)!=null&&r.dateFormat)&&n)try{const s=n instanceof Date?n:new Date(n);if(!isNaN(s.getTime())){const l=tt(e.editorOptions.dateFormat);return bt(s,l)}}catch{}return String(n??"")}isCellInvalid(t,e){return this._invalidCells.some(i=>i.rowIndex===t&&i.field===e)}getCellValidationError(t,e){const i=this._invalidCells.find(n=>n.rowIndex===t&&n.field===e);return(i==null?void 0:i.error)||null}addInvalidCell(t,e,i){const n=this._invalidCells.findIndex(r=>r.rowIndex===t&&r.field===e);n>=0?this._invalidCells[n]={rowIndex:t,field:e,error:i}:this._invalidCells=[...this._invalidCells,{rowIndex:t,field:e,error:i}]}removeInvalidCell(t,e){this._invalidCells=this._invalidCells.filter(i=>!(i.rowIndex===t&&i.field===e))}isEditing(t,e){var i,n;return((i=this._editingCell)==null?void 0:i.rowIndex)===t&&((n=this._editingCell)==null?void 0:n.field)===e}startEdit(t,e,i){var s,l;if(!this.canEditCell(t,e))return;const n=this.displayItems[t];if(!n)return;this._draftRows.has(t)||this._draftRows.set(t,{...n});const r=this._editingCell;this._editingCell={rowIndex:t,field:e,initialSearchQuery:i==null?void 0:i.initialSearchQuery,cursorPosition:i==null?void 0:i.cursorPosition},(s=this._onInteractionChange)==null||s.call(this,"editingCell",{prev:r,current:this._editingCell}),this._currentCellError=null,(l=this._onroweditstart)==null||l.call(this,{row:n,rowIndex:t,field:e})}cancelEdit(){var t,e;if(this._editingCell){const i=this._editingCell,{rowIndex:n,field:r}=i,s=this.displayItems[n];s&&((t=this._onroweditcancel)==null||t.call(this,{row:s,rowIndex:n,field:r})),this._editingCell=null,(e=this._onInteractionChange)==null||e.call(this,"editingCell",{prev:i,current:null}),this._currentCellError=null}}normalizeValidationResult(t,e){return t==null||t===!0?{valid:!0,finalValue:e}:t===!1?{valid:!1,message:"Validation failed",finalValue:e}:typeof t=="string"?{valid:!1,message:t,finalValue:e}:{valid:t.valid,message:t.message,finalValue:t.transformedValue!==void 0?t.transformedValue:e}}async commitEdit(t,e,i){var c,h,f;const n=this._columns.find(w=>String(w.field)===e);if(!n)return;const r=this.displayItems[t];if(!r)return;const s=r[e];let l=i,a=null,d=!0;this._isValidating=!0;try{if(n.beforeCommitCallback){const w={value:i,oldValue:s,row:r,rowIndex:t,field:e},p=await Promise.resolve(n.beforeCommitCallback(w)),m=this.normalizeValidationResult(p,i);d=m.valid,a=m.message||null,l=m.finalValue}else if(n.validateCallback){const w=await Promise.resolve(n.validateCallback(i,r));w&&(d=!1,a=w)}}catch(w){d=!1,a=w instanceof Error?w.message:"Validation failed"}this._isValidating=!1;let g=this._draftRows.get(t);g||(g={...r},this._draftRows.set(t,g)),g[e]=l,d?(this.removeInvalidCell(t,e),this._currentCellError=null):(this.addInvalidCell(t,e,a||"Invalid value"),this._currentCellError=a,(c=this._onvalidationerror)==null||c.call(this,{row:r,rowIndex:t,field:e,error:a||"Invalid value"})),(h=this._onrowchange)==null||h.call(this,{row:r,draftRow:g,rowIndex:t,field:e,oldValue:s,newValue:l,isValid:d,validationError:a});const u=this._editingCell;this._editingCell=null,(f=this._onInteractionChange)==null||f.call(this,"editingCell",{prev:u,current:null})}isCellEditable(t){return t.isEditable===!1?!1:this._isEditable||t.editor!==void 0}getEditableColumns(){return this._columns.map((t,e)=>({index:e,column:t})).filter(({column:t})=>this.isCellEditable(t))}isCellFocused(t,e){var i,n;return((i=this._focusedCell)==null?void 0:i.rowIndex)===t&&((n=this._focusedCell)==null?void 0:n.colIndex)===e}get focusedCell(){return this._focusedCell}setFocusedCell(t,e){var r;const i=this._focusedCell,n={rowIndex:t,colIndex:e};(i==null?void 0:i.rowIndex)===n.rowIndex&&(i==null?void 0:i.colIndex)===n.colIndex||(this._focusedCell=n,(r=this._onInteractionChange)==null||r.call(this,"focusedCell",{prev:i,current:n}))}clearFocusedCell(){var e;const t=this._focusedCell;t!==null&&(this._focusedCell=null,(e=this._onInteractionChange)==null||e.call(this,"focusedCell",{prev:t,current:null}))}setHoveredRow(t){var i;if(this._hoveredRowIndex===t)return;const e=this._hoveredRowIndex;this._hoveredRowIndex=t,(i=this._onInteractionChange)==null||i.call(this,"hoveredRow",{prev:e,current:t})}getRowId(t){if(this._idValueCallback)return this._idValueCallback(t);if(this._idValueMember)return t[String(this._idValueMember)]}findRowById(t){const e=this._items.findIndex(i=>this.getRowId(i)===t);return e===-1?null:{row:this._items[e],index:e}}getRowLockInfo(t){let e,i,n=-1;if(typeof t=="object"&&t!==null)e=t,i=this.getRowId(e),n=this._items.indexOf(e),n===-1&&(n=this.displayItems.indexOf(e));else{i=t;const s=this.findRowById(i);s&&(e=s.row,n=s.index)}if(i!==void 0&&this._externalLocks.has(i))return this._externalLocks.get(i);if(!e)return null;const r=this._rowLocking;if(!r)return null;if(r.getLockInfoCallback){const s=r.getLockInfoCallback(e,n);if(s!=null&&s.isLocked)return s}if(r.isLockedCallback&&r.isLockedCallback(e,n))return{isLocked:!0};if(r.lockInfoMember){const s=e[String(r.lockInfoMember)];if(s!=null&&s.isLocked)return s}return r.lockedMember&&e[String(r.lockedMember)]?{isLocked:!0}:null}isRowLocked(t){const e=this.getRowLockInfo(t);return(e==null?void 0:e.isLocked)===!0}lockRowById(t,e){var r;const i={isLocked:!0,lockedBy:e==null?void 0:e.lockedBy,lockedAt:(e==null?void 0:e.lockedAt)??new Date,reason:e==null?void 0:e.reason,...e};this._externalLocks.set(t,i);const n=this.findRowById(t);return n&&this._editingCell&&this._editingCell.rowIndex===n.index&&this.cancelEdit(),this.requestUpdate(),(r=this._onrowlockchange)==null||r.call(this,{rowId:t,row:(n==null?void 0:n.row)??null,rowIndex:(n==null?void 0:n.index)??-1,lockInfo:i,source:"external"}),!0}unlockRowById(t){var i;const e=this._externalLocks.has(t);if(this._externalLocks.delete(t),e){this.requestUpdate();const n=this.findRowById(t);(i=this._onrowlockchange)==null||i.call(this,{rowId:t,row:(n==null?void 0:n.row)??null,rowIndex:(n==null?void 0:n.index)??-1,lockInfo:null,source:"external"})}return e}getExternalLocks(){return new Map(this._externalLocks)}clearExternalLocks(){this._externalLocks.clear(),this.requestUpdate()}updateRowById(t,e){const i=this.findRowById(t);if(!i)return!1;Object.assign(this._items[i.index],e);const n=this._draftRows.get(i.index);return n&&Object.assign(n,e),this.requestUpdate(),!0}replaceRowById(t,e){const i=this.findRowById(t);return i?(this._items[i.index]=e,this._draftRows.delete(i.index),this.requestUpdate(),!0):!1}canEditCell(t,e){var a;const i=this._columns.find(d=>String(d.field)===e);if(!i||!this.isCellEditable(i))return!1;const n=this.displayItems[t];if(!n)return!1;const r=this.getRowLockInfo(n);if(!(r!=null&&r.isLocked))return!0;const s=this._rowLocking;switch((s==null?void 0:s.lockedEditBehavior)??"block"){case"allow":return!0;case"callback":return((a=s==null?void 0:s.canEditLockedCallback)==null?void 0:a.call(s,n,r))??!1;case"block":default:return!1}}getColumnWidth(t){return this._columnWidths.get(t)}setColumnWidth(t,e,i=!1){this._columnWidths.set(t,e),i||this.requestUpdate()}setColumnWidths(t){for(const{field:e,width:i}of t)e&&i&&this._columnWidths.set(e,i);this.requestUpdate()}getColumnWidthsState(){return this._columns.map(t=>{const e=String(t.field),i=this._columnWidths.get(e)||t.width||"";return{field:e,width:i}}).filter(t=>t.width)}loadPersistedWidths(){this.loadPersistedState()}savePersistedWidths(){this.savePersistedState()}loadPersistedState(){if(!(!this._gridName||typeof localStorage>"u"))try{const t=`wg-${this._gridName}-state`,e=localStorage.getItem(t);if(!e)return;const i=JSON.parse(e),n=new Set(this._columns.map(s=>String(s.field)));let r=!1;if(i.columnWidths){this._columnWidths.clear();for(const s of i.columnWidths)n.has(s.field)?this._columnWidths.set(s.field,s.width):r=!0}if(i.columnOrder){this._columnOrder.clear();for(const s of i.columnOrder)n.has(s.field)?this._columnOrder.set(s.field,s.order):r=!0}r&&this.savePersistedState()}catch(t){console.warn("WebGrid: Failed to load persisted state",t)}}savePersistedState(){if(!(!this._gridName||typeof localStorage>"u"))try{const t=`wg-${this._gridName}-state`,e={};this._shouldPersistColumnWidths&&(e.columnWidths=this.getColumnWidthsState()),this._shouldPersistColumnOrder&&(e.columnOrder=this.getColumnOrderState()),localStorage.setItem(t,JSON.stringify(e))}catch(t){console.warn("WebGrid: Failed to save persisted state",t)}}getColumnOrder(t){return this._columnOrder.get(t)}setColumnOrder(t){this._columnOrder.clear();for(const{field:e,order:i}of t)e!==void 0&&i!==void 0&&this._columnOrder.set(e,i);this.requestUpdate()}getColumnOrderState(){const t=this.visualColumns,e=this.totalFrozenColumns;return t.slice(e).map((i,n)=>({field:String(i.column.field),order:n}))}moveColumn(t,e){const i=this.visualColumns,n=this.totalFrozenColumns,r=i.slice(n),s=r.findIndex(d=>String(d.column.field)===t);if(s===-1||s===e)return;this._columnOrder.clear();const l=[...r],[a]=l.splice(s,1);l.splice(e,0,a),l.forEach((d,g)=>{this._columnOrder.set(String(d.column.field),g)}),this.requestUpdate()}}const Sn=':host{--wg-rem: 10px;font-family:var(--wg-font-family);display:block;--wg-accent-color: var(--base-accent-color, #0078d4);--wg-accent-color-hover: var(--base-accent-color-hover, #106ebe);--wg-accent-color-active: var(--base-accent-color-active, #005a9e);--wg-accent-color-light: var(--base-accent-color-light, #e6f2ff);--wg-text-color-1: var(--base-text-color-1, #242424);--wg-text-color-2: var(--base-text-color-2, #424242);--wg-text-color-3: var(--base-text-color-3, #707070);--wg-text-on-accent: var(--base-text-color-on-accent, #ffffff);--wg-surface-1: var(--base-main-bg, #ffffff);--wg-surface-2: var(--base-elevated-bg, #f5f5f5);--wg-surface-3: var(--base-hover-bg, #ebebeb);--wg-surface-floating: var(--base-dropdown-bg, var(--base-main-bg, #ffffff));--wg-border-color: var(--base-border-color, #e0e0e0);--wg-border-color-hover: var(--base-border-color, #d1d1d1);--wg-input-bg: var(--base-input-bg, #ffffff);--wg-input-color: var(--base-input-color, var(--wg-text-color-1));--wg-input-border: var(--base-input-border, 1px solid #d1d1d1);--wg-input-border-hover: var(--base-input-border-hover, 1px solid #0078d4);--wg-input-border-focus: var(--base-input-border-focus, 1px solid #0078d4);--wg-input-placeholder-color: var(--base-input-placeholder-color, #707070);--wg-danger-color: var(--base-danger-color, #d13438);--wg-danger-bg-light: var(--base-danger-bg-light, #fde7e9);--wg-hover-bg: var(--base-hover-bg, #f0f0f0);--wg-active-bg: var(--base-hover-bg, #e0e0e0);--wg-font-size-base: calc(var(--base-font-size-sm, 1.4) * var(--wg-rem));--wg-font-size-sm: calc(var(--base-font-size-xs, 1.2) * var(--wg-rem));--wg-font-size-xs: calc(var(--base-font-size-2xs, 1.1) * var(--wg-rem));--wg-font-size-lg: calc(var(--base-font-size-base, 1.6) * var(--wg-rem));--wg-font-family: var(--base-font-family, inherit);--wg-line-height-base: var(--base-line-height-normal, 1.5);--wg-font-weight-normal: var(--base-font-weight-normal, 400);--wg-font-weight-semibold: var(--base-font-weight-semibold, 600);--wg-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;--wg-border-radius-sm: calc(var(--base-border-radius-sm, .4) * var(--wg-rem));--wg-border-radius-md: calc(var(--base-border-radius-md, .6) * var(--wg-rem));--wg-border-radius-lg: calc(var(--base-border-radius-lg, .8) * var(--wg-rem));--wg-spacing-xs: calc(.4 * var(--wg-rem));--wg-spacing-sm: calc(.8 * var(--wg-rem));--wg-spacing-md: calc(1.2 * var(--wg-rem));--wg-spacing-lg: calc(1.6 * var(--wg-rem));--wg-spacing-xl: calc(2.4 * var(--wg-rem));--wg-table-bg: var(--wg-surface-1);--wg-table-border: 1px solid var(--wg-border-color);--wg-header-bg: var(--wg-surface-2);--wg-header-bg-hover: var(--wg-surface-3);--wg-header-bg-sorted: var(--wg-surface-3);--wg-header-color: var(--wg-text-color-1);--wg-header-border: 2px solid var(--wg-border-color);--wg-header-separator: 1px solid var(--wg-border-color);--wg-header-padding: var(--wg-spacing-sm);--wg-header-font-weight: var(--wg-font-weight-semibold);--wg-header-min-height: auto;--wg-cell-padding: var(--wg-spacing-sm);--wg-cell-padding-block: var(--wg-spacing-sm);--wg-cell-padding-inline: var(--wg-spacing-sm);--wg-row-min-height: auto;--wg-cell-color: var(--wg-text-color-1);--wg-cell-border: 1px solid var(--wg-border-color);--wg-cell-bg-hover: var(--wg-hover-bg);--wg-cell-bg-editing: var(--wg-surface-1);--wg-cell-readonly-bg: var(--base-disabled-bg, var(--wg-surface-2));--wg-row-border: 1px solid var(--wg-border-color);--wg-row-bg-even: var(--wg-surface-2);--wg-row-bg-hover: var(--wg-surface-3);--wg-filter-bg: var(--wg-surface-1);--wg-filter-border: 1px solid var(--wg-border-color);--wg-filter-padding: var(--wg-spacing-xs) var(--wg-spacing-sm);--wg-filter-input-padding: calc(.4 * var(--wg-rem)) calc(.8 * var(--wg-rem));--wg-filter-input-bg: var(--wg-input-bg);--wg-filter-input-border: var(--wg-input-border);--wg-filter-input-border-focus: var(--wg-input-border-focus);--wg-filter-input-border-radius: var(--wg-border-radius-sm);--wg-filter-input-font-size: var(--wg-font-size-sm);--wg-sort-indicator-size: calc(1.4 * var(--wg-rem));--wg-sort-indicator-opacity: .9;--wg-sort-placeholder-opacity: .3;--wg-sort-priority-size: calc(1.1 * var(--wg-rem));--wg-pagination-padding: var(--wg-spacing-md);--wg-pagination-gap: calc(1.6 * var(--wg-rem));--wg-pagination-bg: var(--wg-surface-1);--wg-pagination-border: 1px solid var(--wg-border-color);--wg-pagination-btn-padding: calc(.6 * var(--wg-rem)) calc(1.6 * var(--wg-rem));--wg-pagination-btn-bg: var(--wg-surface-1);--wg-pagination-btn-bg-hover: var(--wg-surface-2);--wg-pagination-btn-bg-active: var(--wg-surface-3);--wg-pagination-btn-border: 1px solid var(--wg-border-color);--wg-pagination-btn-border-hover: 1px solid var(--wg-border-color-hover);--wg-pagination-btn-border-radius: var(--wg-border-radius-sm);--wg-pagination-btn-disabled-opacity: .4;--wg-empty-padding: var(--wg-spacing-xl);--wg-empty-color: var(--wg-text-color-3);--wg-error-cell-bg: var(--wg-danger-bg-light);--wg-error-cell-border: 1px solid var(--wg-danger-color);--wg-error-message-color: var(--wg-danger-color);--wg-error-message-font-size: var(--wg-font-size-xs);--wg-error-indicator-color: var(--wg-danger-color);--wg-editor-bg: var(--wg-surface-1);--wg-editor-outline: 2px solid var(--wg-accent-color);--wg-editor-outline-offset: -2px;--wg-editor-validating-opacity: .7;--wg-dropdown-toggle-right: var(--wg-spacing-sm);--wg-dropdown-toggle-size: calc(1.2 * var(--wg-rem));--wg-dropdown-toggle-hitbox: calc(2.4 * var(--wg-rem));--wg-date-trigger-size: calc(2.8 * var(--wg-rem));--wg-toolbar-bg: var(--wg-surface-floating);--wg-toolbar-border: 1px solid var(--wg-border-color);--wg-toolbar-border-radius: var(--wg-border-radius-sm);--wg-toolbar-shadow: var(--base-dropdown-box-shadow, 0 2px 8px rgba(0, 0, 0, .15));--wg-toolbar-divider-color: var(--wg-border-color);--wg-toolbar-row-height: calc(3.7 * var(--wg-rem));--wg-toolbar-btn-min-width: calc(2.4 * var(--wg-rem));--wg-toolbar-btn-padding: 0 calc(.4 * var(--wg-rem));--wg-toolbar-btn-border-radius: var(--wg-border-radius-sm);--wg-toolbar-btn-bg-hover: var(--wg-hover-bg);--wg-toolbar-btn-bg-active: var(--wg-active-bg);--wg-toolbar-btn-color: var(--wg-text-color-1);--wg-toolbar-trigger-color: var(--wg-text-color-3);--wg-toolbar-trigger-color-hover: var(--wg-text-color-1);--wg-toolbar-trigger-bg-hover: var(--wg-hover-bg);--wg-tooltip-bg: var(--base-tooltip-bg, #333);--wg-tooltip-color: var(--base-tooltip-color, #fff);--wg-context-menu-z-index: 1001;--wg-context-menu-min-width: calc(16 * var(--wg-rem));--wg-focus-outline: 2px solid var(--wg-accent-color);--wg-focus-outline-offset: -2px;--wg-focus-bg: var(--wg-hover-bg);--wg-transition-fast: .1s ease;--wg-transition-normal: .15s ease;--wg-z-dropdown: 9999;--wg-z-toolbar: 1000;--wg-z-context-menu: 1001;--wg-z-tooltip: 10000;--wg-frozen-column-bg: var(--wg-surface-1);--wg-frozen-header-bg: var(--wg-header-bg);--wg-frozen-column-shadow: 2px 0 4px rgba(0, 0, 0, .1);--wg-frozen-column-shadow-active: 6px 0 12px rgba(0, 0, 0, .25);--wg-frozen-column-border: 2px solid var(--wg-border-color);--wg-resize-handle-width: 12px;--wg-resize-handle-offset: -6px;--wg-resize-handle-line-width: 2px;--wg-resize-handle-color: var(--wg-border-color);--wg-resize-handle-active-color: var(--wg-accent-color);--wg-fill-handle-size: 8px;--wg-fill-handle-bg: var(--wg-surface-1);--wg-fill-handle-border-color: var(--wg-accent-color);--wg-fill-handle-border-width: 2px;--wg-fill-range-bg: color-mix(in srgb, var(--wg-accent-color) 15%, transparent);--wg-fill-range-border-color: var(--wg-accent-color);--wg-selection-bg: color-mix(in srgb, var(--wg-accent-color) 15%, transparent);--wg-selection-row-number-bg: var(--wg-accent-color);--wg-selection-row-number-color: var(--base-text-inverted, #fff);--wg-cell-selection-bg: color-mix(in srgb, var(--wg-accent-color) 10%, transparent);--wg-cell-selection-border: var(--wg-accent-color);--wg-cell-selection-border-width: 2px;--wg-dropdown-option-gap: var(--wg-spacing-sm);--wg-dropdown-option-padding: calc(.6 * var(--wg-rem)) var(--wg-spacing-sm) calc(.6 * var(--wg-rem)) calc(var(--wg-spacing-sm) - 1px);--wg-dropdown-empty-padding: calc(.8 * var(--wg-rem)) var(--wg-spacing-sm) calc(.8 * var(--wg-rem)) calc(var(--wg-spacing-sm) - 1px);--wg-inline-actions-padding: var(--wg-spacing-xs) var(--wg-spacing-sm);--wg-inline-actions-gap: calc(.2 * var(--wg-rem));--wg-toolbar-row-gap: calc(.2 * var(--wg-rem));--wg-toolbar-row-padding: 0 calc(.4 * var(--wg-rem));--wg-toolbar-label-font-size: var(--wg-font-size-sm);--wg-toolbar-btn-gap: calc(.4 * var(--wg-rem));--wg-tooltip-padding: calc(.6 * var(--wg-rem)) calc(1 * var(--wg-rem));--wg-tooltip-shadow: 0 2px 8px rgba(0, 0, 0, .2)}web-grid:not(:defined){display:block;min-height:calc(10 * var(--wg-rem));color:transparent!important;background:transparent}.wg{position:relative;width:100%;max-height:inherit;overflow:auto;overscroll-behavior:contain;border:var(--wg-table-border)}.wg__table{width:100%;min-width:max-content;border-collapse:collapse;table-layout:fixed;background:var(--wg-table-bg);font-size:var(--wg-font-size-base);line-height:var(--wg-line-height-base)}.wg__filler{width:auto;min-width:0;padding:0!important;border:none!important;box-shadow:none!important}th.wg__filler{position:sticky;top:0;z-index:1;background:var(--wg-header-bg);border-bottom:var(--wg-header-border)!important}td.wg__filler{background:transparent}.wg__table tbody tr{border-bottom:var(--wg-row-border)}.wg__row-number-header,.wg__row-number{width:40px;min-width:40px;max-width:40px;box-sizing:border-box;text-align:center;color:var(--wg-text-color-2);background:var(--wg-header-bg);-webkit-user-select:none;user-select:none;font-size:var(--wg-font-size-sm)}.wg__row-number{box-shadow:inset -1px 0 0 var(--wg-border-color)}.wg__actions-column{width:32px;min-width:32px;max-width:32px;padding:0!important;text-align:center}thead .wg__actions-column{background:var(--wg-header-bg);border-bottom:var(--wg-header-border)}.wg__filter-row .wg__actions-column{background:var(--wg-filter-bg);border-bottom:var(--wg-filter-border)}.wg__header{position:sticky;top:0;z-index:1;background:var(--wg-header-bg);color:var(--wg-header-color);font-weight:var(--wg-header-font-weight);padding:var(--wg-header-padding);height:var(--wg-header-min-height);border-bottom:var(--wg-header-border);box-shadow:inset -1px 0 0 var(--wg-border-color);box-sizing:border-box;-webkit-user-select:none;user-select:none;overflow:hidden}.wg__header:last-child{box-shadow:none}.wg__header--sortable{cursor:pointer}.wg__header--sortable:hover{background:var(--wg-header-bg-hover)}.wg__header--sorted{background:var(--wg-header-bg-sorted)}.wg__header-container{display:flex;align-items:stretch;gap:4px;height:100%}.wg__header-content{flex:1;min-width:0;display:flex;align-items:center;justify-content:flex-start}.wg__header-content--align-left{justify-content:flex-start}.wg__header-content--align-center{justify-content:center}.wg__header-content--align-right{justify-content:flex-end}.wg__header-content--align-justify{justify-content:flex-start}.wg__header-content--valign-top{align-items:flex-start}.wg__header-content--valign-middle{align-items:center}.wg__header-content--valign-bottom{align-items:flex-end}.wg__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__header-controls{flex-shrink:0;display:flex;align-items:center}.wg__sort-indicator{font-size:var(--wg-sort-indicator-size);opacity:var(--wg-sort-indicator-opacity);min-width:16px;text-align:center}.wg__sort-placeholder{opacity:var(--wg-sort-placeholder-opacity)}.wg__sort-priority{font-size:var(--wg-sort-priority-size);font-weight:600;margin-left:2px;vertical-align:super;line-height:1}.wg__header-info{display:inline-flex;align-items:center;color:var(--wg-accent-color);cursor:help;opacity:.7;margin-left:4px;vertical-align:middle}.wg__header-info:hover{opacity:1}.wg__filter-row th{padding:var(--wg-filter-padding);background:var(--wg-filter-bg);border-bottom:var(--wg-filter-border)}.wg__filter-input{width:100%;padding:var(--wg-filter-input-padding);border:var(--wg-filter-input-border);border-radius:var(--wg-filter-input-border-radius);background:var(--wg-surface-1);color:var(--wg-text-color-1);font-family:inherit;font-size:var(--wg-filter-input-font-size);box-sizing:border-box}.wg__filter-input:focus{outline:none;border:var(--wg-filter-input-border-focus);box-shadow:0 0 0 1px var(--wg-accent-color)}.wg__resize-handle{position:absolute;top:0;right:var(--wg-resize-handle-offset);bottom:0;width:var(--wg-resize-handle-width);cursor:col-resize;z-index:2;opacity:0;transition:opacity .1s ease}.wg__header:hover .wg__resize-handle{opacity:1}.wg__resize-handle:after{content:"";position:absolute;top:25%;bottom:25%;left:50%;width:var(--wg-resize-handle-line-width);background:var(--wg-resize-handle-color);transform:translate(-50%);border-radius:1px}.wg__resize-handle:hover:after{background:var(--wg-resize-handle-active-color);top:15%;bottom:15%}.wg__resize-handle--active:after{background:var(--wg-resize-handle-active-color);top:0;bottom:0}.wg__resize-handle--disabled{cursor:not-allowed}.wg__resize-handle--disabled:after{display:none}.wg--resizing .wg__resize-handle{opacity:1}.wg--resizing{-webkit-user-select:none;user-select:none;cursor:col-resize}.wg--resizing .wg__cell,.wg--resizing .wg__header{cursor:col-resize}.wg--resizing .wg__table{min-width:0!important}.wg__header--dragging{opacity:1;background:var(--wg-header-bg)!important;outline:2px dashed var(--wg-accent-color);outline-offset:-2px}.wg__reorder-ghost{position:fixed;z-index:10000;background:var(--wg-header-bg);border:2px solid var(--wg-accent-color);border-radius:var(--wg-border-radius-sm);padding:.4em .8em;font-size:var(--wg-font-size-sm);font-weight:var(--wg-header-font-weight);color:var(--wg-header-color);box-shadow:0 4px 12px #00000026;opacity:.95;pointer-events:none;white-space:nowrap}.wg__drop-indicator{position:absolute;width:3px;background:var(--wg-accent-color);z-index:999;pointer-events:none;display:none}.wg__drop-indicator:before{content:"";position:absolute;top:0;left:50%;transform:translate(-50%);border-left:6px solid transparent;border-right:6px solid transparent;border-top:8px solid var(--wg-accent-color)}.wg--reordering{cursor:grabbing;-webkit-user-select:none;user-select:none}.wg--reordering .wg__cell,.wg--reordering .wg__header{cursor:grabbing}.wg--reorderable .wg__header:not(.wg__header--frozen):hover{cursor:grab}.wg__header--frozen{cursor:default}.wg__fill-handle{position:absolute;width:var(--wg-fill-handle-size);height:var(--wg-fill-handle-size);background:var(--wg-fill-handle-bg);border:var(--wg-fill-handle-border-width) solid var(--wg-fill-handle-border-color);cursor:crosshair;z-index:10;pointer-events:auto;box-sizing:border-box}.wg__fill-handle:hover{transform:scale(1.2)}.wg__fill-range{position:absolute;background:var(--wg-fill-range-bg);border:1px dashed var(--wg-fill-range-border-color);pointer-events:none;z-index:5;box-sizing:border-box}.wg--filling{cursor:crosshair;-webkit-user-select:none;user-select:none}.wg--filling .wg__cell,.wg--filling .wg__header{cursor:crosshair}.wg__cell--editing .wg__fill-handle{display:none}.wg__row--selected>.wg__cell{background:var(--wg-selection-bg)}.wg__row--selected>.wg__row-number{background:var(--wg-selection-row-number-bg);color:var(--wg-selection-row-number-color)}.wg__row-number[data-row-number]{cursor:pointer;-webkit-user-select:none;user-select:none}.wg__row-number[data-row-number]:hover{background:var(--wg-hover-bg)}.wg__row--selected>.wg__row-number:hover{background:var(--wg-selection-row-number-bg)}.wg--selecting{cursor:default;-webkit-user-select:none;user-select:none}.wg--selecting *{-webkit-user-select:none;user-select:none}.wg:focus{outline:none}.wg__cell--in-range{background:var(--wg-cell-selection-bg)!important;position:relative;z-index:1}.wg__cell--editing.wg__cell--in-range{background:var(--wg-input-bg)!important}.wg__cell--editable.wg__cell--in-range:hover{background:var(--wg-cell-selection-bg)!important}.wg__cell--editable.wg__cell--in-range:hover:after{display:none}.wg__cell-range-border{position:absolute;border:var(--wg-cell-selection-border-width) solid var(--wg-cell-selection-border);pointer-events:none;z-index:3;box-sizing:border-box;border-radius:1px}.wg--selecting-cells,.wg--selecting-cells *{cursor:crosshair!important;-webkit-user-select:none;user-select:none}.wg--selecting-cells .wg__cell{cursor:crosshair!important}.wg:has(.wg__cell-range-border) .wg__fill-handle{display:none}.wg__header--frozen{background:var(--wg-frozen-header-bg, var(--wg-header-bg))}.wg__row-number-header.wg__header--frozen{z-index:4!important}.wg__cell--frozen{background:var(--wg-frozen-column-bg, var(--wg-surface-1))}.wg__cell--frozen-last{box-shadow:inset -1px 0 0 var(--wg-border-color)}.wg__row-number.wg__cell--frozen{background:var(--wg-header-bg);z-index:2!important}.wg--striped tbody tr:nth-child(2n) .wg__cell--frozen{background:var(--wg-row-bg-even)}.wg--hoverable tbody tr:hover .wg__cell--frozen{background:var(--wg-row-bg-hover)}.wg__row--focused .wg__cell--frozen{background:var(--wg-focus-bg)}.wg__header.wg__header--frozen-last,.wg__cell.wg__cell--frozen-last{overflow:visible}.wg--scrolled-horizontal .wg__header--frozen-last:after,.wg--scrolled-horizontal .wg__cell--frozen-last:after{content:"";position:absolute;top:0;right:-8px;bottom:0;width:8px;background:linear-gradient(to right,rgba(0,0,0,.15),transparent);pointer-events:none}.wg__cell{padding:var(--wg-cell-padding);color:var(--wg-cell-color);height:var(--wg-row-min-height);box-sizing:border-box;scroll-margin-top:3rem;scroll-margin-bottom:.5rem;-webkit-user-select:none;user-select:none;overflow:hidden}.wg__cell-text{-webkit-user-select:none;user-select:none}.wg__cell--ellipsis .wg__cell-text{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__cell--line-clamp .wg__cell-text{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}.wg__cell--editable{cursor:pointer;position:relative}.wg__cell--editable:hover{background:var(--wg-cell-bg-hover)}.wg__cell--editable:hover:after{content:"";position:absolute;top:2px;right:2px;bottom:2px;left:2px;border:1px dashed var(--wg-border-color);border-radius:2px;pointer-events:none}.wg__cell--editing{position:relative;background:var(--wg-surface-1);outline:2px solid var(--wg-accent-color);outline-offset:-2px}.wg__cell--editing:after{display:none}.wg__cell--invalid{background:var(--wg-danger-bg-light, #fee);box-shadow:inset 0 0 0 2px var(--wg-danger-color, #c00)}.wg--navigate-mode .wg__cell:not(.wg__cell--editable){background:var(--wg-cell-readonly-bg, #f5f5f5)}:host{--wg-row-locked-bg: var(--base-disabled-bg, #f5f5f5);--wg-row-locked-opacity: .7}.wg__row--locked{background:var(--wg-row-locked-bg)!important}.wg__row--locked .wg__cell{opacity:var(--wg-row-locked-opacity)}.wg__row--locked .wg__cell--editable{cursor:not-allowed}.wg__row--locked .wg__cell--editable:hover{background:inherit}.wg__row--locked .wg__cell--editable:hover:after{display:none}.wg__row-number--locked{opacity:1!important;cursor:help}.wg__editor{position:absolute;top:0;left:0;right:0;width:100%;padding:var(--wg-cell-padding);border:none;background:transparent;color:var(--wg-text-color-1);font-size:var(--wg-font-size-base);font-family:inherit;line-height:inherit;box-sizing:border-box}.wg__editor:focus,.wg__editor:focus-visible{outline:none;box-shadow:none}.wg__editor--text{text-align:inherit}.wg__editor--number{text-align:right}.wg__editor--date{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:var(--wg-editor-bg);padding:var(--wg-cell-padding)}.wg__date-input{flex:1;min-width:0;height:100%;border:none;background:transparent;font:inherit;padding:0;outline:none;color:inherit}.wg__date-trigger{width:var(--wg-date-trigger-size, 28px);height:100%;display:flex;align-items:center;justify-content:center;border:none;background:transparent;color:var(--wg-text-color-3);cursor:pointer;padding:0;flex-shrink:0}.wg__date-trigger:hover{color:var(--wg-accent-color, #0078d4);background:var(--wg-hover-bg, rgba(0, 0, 0, .05))}.wg__editor--checkbox{width:auto;height:auto;margin:0 auto}.wg__editor--custom{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;background:var(--wg-editor-bg);padding:var(--wg-cell-padding-block) var(--wg-cell-padding-inline);cursor:pointer}.wg__editor--custom:focus{outline:none}.wg__custom-value{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;cursor:pointer}.wg__editor--combobox,.wg__editor--autocomplete{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;padding:var(--wg-cell-padding);padding-right:0;background:transparent;box-sizing:border-box}.wg__combobox-input,.wg__autocomplete-input{flex:1;width:100%;height:100%;padding:0 24px 0 0;border:none;background:transparent;color:var(--wg-text-color-1);font-size:var(--wg-font-size-base);font-family:inherit;line-height:var(--wg-line-height-base);outline:none;box-sizing:border-box;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none}.wg__combobox-input:focus,.wg__autocomplete-input:focus{outline:none}.wg__combobox-toggle{position:absolute;right:var(--wg-dropdown-toggle-right);top:50%;transform:translateY(-50%);font-size:var(--wg-dropdown-toggle-size);color:var(--wg-text-color-2);pointer-events:auto;cursor:pointer}.wg__combobox-toggle:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:48px}.wg__loading-indicator{position:absolute;right:var(--wg-dropdown-toggle-right);top:50%;transform:translateY(-50%);font-size:12px;animation:wg-pulse 1s infinite}@keyframes wg-pulse{0%,to{opacity:1}50%{opacity:.4}}.wg__select-trigger{display:flex;align-items:center;justify-content:space-between;cursor:pointer;background:transparent}.wg__select-trigger:focus,.wg__select-trigger:focus-visible{outline:none;box-shadow:none}.wg__select-value{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wg__select-toggle{position:relative;font-size:var(--wg-dropdown-toggle-size);opacity:.6;margin-left:4px;flex-shrink:0;pointer-events:auto;cursor:pointer}.wg__select-toggle:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:48px}.wg__cell-dropdown-display{display:flex;align-items:center;justify-content:space-between;width:100%;cursor:pointer}.wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle{opacity:0}.wg__cell:hover .wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle,.wg__cell--focused .wg__cell-dropdown-display--toggle-on-focus .wg__select-toggle{opacity:.6}.wg__cell-date-display{display:flex;align-items:center;justify-content:space-between;width:100%;cursor:pointer}.wg__cell-date-display .wg__date-trigger{position:relative;background:none;border:none;padding:0;margin:0;cursor:pointer;opacity:.6;display:flex;align-items:center;justify-content:center;color:inherit}.wg__cell-date-display .wg__date-trigger:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:48px}.wg__cell-date-display--toggle-on-focus .wg__date-trigger{opacity:0}.wg__cell:hover .wg__cell-date-display--toggle-on-focus .wg__date-trigger,.wg__cell--focused .wg__cell-date-display--toggle-on-focus .wg__date-trigger{opacity:.6}.wg__dropdown{background:var(--wg-surface-floating, #fff);border:1px solid var(--wg-border-color, #d1d1d1);border-radius:4px;box-shadow:var(--wg-toolbar-shadow);max-height:200px;overflow-y:auto;font-size:var(--wg-font-size-base);font-family:inherit;line-height:var(--wg-line-height-base)}.wg__dropdown-option{display:flex;align-items:center;gap:var(--wg-dropdown-option-gap);padding:var(--wg-dropdown-option-padding);cursor:pointer;color:var(--wg-text-color-1)}.wg__dropdown-option:hover,.wg__dropdown-option--highlighted{background:var(--wg-hover-bg, #f0f0f0);box-shadow:inset 0 0 0 2px var(--wg-accent-color, #0078d4)}.wg__dropdown-option--selected{background:var(--wg-accent-color-light, #e6f2ff)}.wg__dropdown-option--disabled{opacity:.5;cursor:not-allowed;pointer-events:none}.wg__dropdown-option-icon{flex-shrink:0;width:1.5em;text-align:center}.wg__dropdown-option-content{flex:1;min-width:0;overflow:hidden}.wg__dropdown-option-label{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wg__dropdown-option-subtitle{display:block;font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wg__dropdown-empty{padding:var(--wg-dropdown-empty-padding);color:var(--wg-text-color-2);font-style:italic;text-align:center}.wg__dropdown-option--align-left{justify-content:flex-start}.wg__dropdown-option--align-left .wg__dropdown-option-content{text-align:left}.wg__dropdown-option--align-center{justify-content:center}.wg__dropdown-option--align-center .wg__dropdown-option-content{text-align:center}.wg__dropdown-option--align-right{justify-content:flex-end}.wg__dropdown-option--align-right .wg__dropdown-option-content{text-align:right}.wg__dropdown-option--align-justify{justify-content:flex-start}.wg__dropdown-option--align-justify .wg__dropdown-option-content{text-align:justify}.wg--navigate-mode .wg__cell{cursor:cell}.wg--navigate-mode .wg__cell:focus{outline:none}.wg--navigate-mode .wg__cell.wg__cell--focused{outline:var(--wg-focus-outline);outline-offset:-2px}.wg__cell--focused:after{display:none}.wg--navigate-mode .wg__cell--dragging-from.wg__cell--focused{outline:none}.wg__pagination{display:flex;align-items:center;justify-content:center;gap:var(--wg-pagination-gap);padding:var(--wg-pagination-padding);border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg)}.wg__pagination-btn{padding:var(--wg-pagination-btn-padding);background:var(--wg-pagination-btn-bg);border:var(--wg-pagination-btn-border);border-radius:var(--wg-pagination-btn-border-radius);color:var(--wg-cell-color);font-family:inherit;font-size:var(--wg-font-size-base);cursor:pointer;transition:all var(--wg-transition-fast)}.wg__pagination-btn:hover:not(:disabled){background:var(--wg-pagination-btn-bg-hover);border:var(--wg-pagination-btn-border-hover)}.wg__pagination-btn:active:not(:disabled){background:var(--wg-pagination-btn-bg-active)}.wg__pagination-btn:disabled{opacity:var(--wg-pagination-btn-disabled-opacity);cursor:not-allowed}.wg__pagination-info{font-size:var(--wg-font-size-base);color:var(--wg-cell-color)}.wg__pagination-count{font-size:var(--wg-font-size-sm);color:var(--wg-text-color-3);margin-left:4px}.wg__pagination-pagesize{display:flex;align-items:center;gap:6px}.wg__pagination-select{padding:4px 8px;background:var(--wg-pagination-btn-bg);border:var(--wg-pagination-btn-border);border-radius:var(--wg-pagination-btn-border-radius);color:var(--wg-cell-color);font-family:inherit;font-size:var(--wg-font-size-base);cursor:pointer}.wg__pagination-select:hover{background:var(--wg-pagination-btn-bg-hover);border:var(--wg-pagination-btn-border-hover)}.wg__pagination-select:focus{outline:2px solid var(--wg-accent-color);outline-offset:-2px}.wg__pagination-label{font-size:var(--wg-font-size-sm);color:var(--wg-text-color-3)}.wg__pagination--left{justify-content:flex-start}.wg__pagination--right{justify-content:flex-end}.wg__pagination--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__summary{display:flex;align-items:center;padding:var(--wg-pagination-padding);border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg);font-size:var(--wg-font-size-base);color:var(--wg-cell-color)}.wg__summary--left{justify-content:flex-start}.wg__summary--right{justify-content:flex-end}.wg__summary--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__footer{display:flex;align-items:center;justify-content:space-between;border-top:var(--wg-pagination-border);background:var(--wg-pagination-bg)}.wg__footer--top{border-top:none;border-bottom:var(--wg-pagination-border)}.wg__footer .wg__summary,.wg__footer .wg__pagination{border:none}.wg__footer .wg__summary{flex:0 0 auto}.wg__footer .wg__pagination{flex:0 0 auto;margin-left:auto}.wg__toolbar-container{position:fixed;z-index:var(--wg-z-toolbar, 1000)}.wg__toolbar{display:flex;flex-direction:column-reverse;gap:0;padding:0;background:var(--wg-toolbar-bg);border:var(--wg-toolbar-border);border-radius:var(--wg-toolbar-border-radius);box-shadow:var(--wg-toolbar-shadow)}.wg__toolbar-row{display:flex;gap:var(--wg-toolbar-row-gap);align-items:center;height:var(--wg-toolbar-row-height);padding:var(--wg-toolbar-row-padding)}.wg__toolbar-row+.wg__toolbar-row{border-top:1px solid var(--wg-toolbar-divider-color)}.wg__toolbar-divider{width:1px;height:16px;background:var(--wg-toolbar-divider-color);margin:0 4px;flex-shrink:0}.wg__toolbar-btn{min-width:var(--wg-toolbar-btn-min-width);height:100%;border:none;border-radius:var(--wg-toolbar-btn-border-radius);background:transparent;color:var(--wg-toolbar-btn-color);cursor:pointer;display:flex;align-items:center;justify-content:center;gap:var(--wg-toolbar-btn-gap);font-family:inherit;font-size:var(--wg-font-size-base);font-weight:500;padding:var(--wg-toolbar-btn-padding);transition:background .1s ease}.wg__toolbar-btn:hover{background:var(--wg-toolbar-btn-bg-hover)}.wg__toolbar-btn:active{background:var(--wg-toolbar-btn-bg-active)}.wg__toolbar-btn:disabled{opacity:.5;cursor:not-allowed}.wg__toolbar-btn:disabled:hover{background:transparent}.wg__toolbar-btn--danger:hover{background:var(--wg-danger-bg-light);color:var(--wg-danger-color)}.wg__toolbar-label{font-size:var(--wg-toolbar-label-font-size);white-space:nowrap}.wg__actions-column{width:24px;min-width:24px;max-width:24px;padding:0!important;text-align:center}.wg__header .wg__actions-column{background:var(--wg-header-bg)}.wg__filter-row .wg__actions-column{background:var(--wg-filter-bg)}.wg__toolbar-trigger{position:relative;padding:0;background:transparent;border:none;border-radius:var(--wg-border-radius-sm);cursor:pointer;font-size:var(--wg-font-size-base);line-height:1;color:var(--wg-toolbar-trigger-color)}.wg__toolbar-trigger:before{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:var(--wg-dropdown-toggle-hitbox);height:48px}.wg__toolbar-trigger:hover,.wg__toolbar-trigger--active{color:var(--wg-toolbar-trigger-color-hover);background:var(--wg-toolbar-trigger-bg-hover)}.wg__inline-actions-header,.wg__inline-actions-cell{width:1%;white-space:nowrap;text-align:center;padding:var(--wg-inline-actions-padding)}.wg__inline-actions-header{background:var(--wg-header-bg)}.wg__inline-actions-wrap{display:flex;flex-direction:column;gap:var(--wg-inline-actions-gap);align-items:center}.wg__inline-actions-row{display:flex;gap:var(--wg-inline-actions-gap);align-items:center;justify-content:center}.wg__inline-action-btn{min-width:var(--wg-toolbar-btn-min-width);height:calc(2.4 * var(--wg-rem));border:none;border-radius:var(--wg-toolbar-btn-border-radius);background:transparent;color:var(--wg-toolbar-btn-color);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0 var(--wg-spacing-xs);font-family:inherit;font-size:var(--wg-font-size-base);transition:background var(--wg-transition-fast)}.wg__inline-action-btn:hover{background:var(--wg-toolbar-btn-bg-hover)}.wg__inline-action-btn:active{background:var(--wg-toolbar-btn-bg-active)}.wg__inline-action-btn:disabled,.wg__inline-action-btn--disabled{opacity:.5;cursor:not-allowed}.wg__inline-action-btn:disabled:hover,.wg__inline-action-btn--disabled:hover{background:transparent}.wg__inline-action-btn--danger:hover{background:var(--wg-danger-bg-light);color:var(--wg-danger-color)}.wg__shortcuts-help{position:absolute;top:var(--wg-spacing-xs);right:var(--wg-spacing-sm);z-index:5}.wg__shortcuts-help--left{right:auto;left:var(--wg-spacing-sm)}.wg__shortcuts-help-icon{display:flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:50%;background:var(--wg-surface-1);color:var(--wg-text-color-2);cursor:pointer;opacity:.7}.wg__shortcuts-help-icon:hover{opacity:1;background:var(--wg-surface-2)}.wg__shortcuts-help-icon svg{width:16px;height:16px}.wg__shortcuts-help-overlay{display:none;position:absolute;top:100%;right:0;margin-top:var(--wg-spacing-xs);padding:var(--wg-spacing-md);background:var(--wg-surface-1);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-md);box-shadow:0 4px 16px #00000026;min-width:200px;max-width:300px;z-index:100}.wg__shortcuts-help--left .wg__shortcuts-help-overlay{right:auto;left:0}.wg__shortcuts-help:hover .wg__shortcuts-help-overlay,.wg__shortcuts-help:focus-within .wg__shortcuts-help-overlay{display:block}.wg__shortcuts-help-title{font-weight:var(--wg-font-weight-semibold);font-size:var(--wg-font-size-base);color:var(--wg-text-color-1);margin-bottom:var(--wg-spacing-sm);padding-bottom:var(--wg-spacing-xs);border-bottom:1px solid var(--wg-border-color)}.wg__shortcuts-help-custom{margin-bottom:var(--wg-spacing-sm);padding-bottom:var(--wg-spacing-sm);border-bottom:1px solid var(--wg-border-color);font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2)}.wg__shortcuts-help-list{display:flex;flex-direction:column;gap:var(--wg-spacing-xs)}.wg__shortcuts-help-item{display:flex;align-items:center;gap:var(--wg-spacing-md)}.wg__shortcuts-help-key{display:inline-flex;align-items:center;justify-content:center;min-width:28px;padding:2px 6px;font-family:var(--wg-font-family-mono);font-size:var(--wg-font-size-xs);font-weight:var(--wg-font-weight-semibold);color:var(--wg-text-color-1);background:var(--wg-surface-2);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm)}.wg__shortcuts-help-label{flex:1;font-size:var(--wg-font-size-sm);color:var(--wg-text-color-2)}.wg--striped tbody tr:nth-child(2n){background:var(--wg-row-bg-even)}.wg--hoverable tbody tr:hover{background:var(--wg-row-bg-hover)}.wg__empty{text-align:center;padding:var(--wg-empty-padding);color:var(--wg-empty-color);font-style:italic}.wg__loading-more{text-align:center;padding:var(--wg-cell-padding);color:var(--wg-text-color-2);font-size:var(--wg-font-size-sm)}.wg__tooltip{position:fixed;z-index:var(--wg-z-tooltip);max-width:300px;padding:var(--wg-tooltip-padding);background:var(--wg-tooltip-bg, #333);color:var(--wg-tooltip-color, #fff);font-size:var(--wg-font-size-sm);line-height:1.4;border-radius:var(--wg-border-radius-sm);box-shadow:var(--wg-tooltip-shadow);pointer-events:none;opacity:0;transition:opacity var(--wg-transition-fast)}.wg__tooltip--visible{opacity:1}.wg__tooltip-arrow{position:absolute;width:8px;height:8px;background:var(--wg-tooltip-bg, #333);transform:rotate(45deg)}.wg__tooltip[data-placement^=top] .wg__tooltip-arrow{bottom:-4px}.wg__tooltip[data-placement^=bottom] .wg__tooltip-arrow{top:-4px}.wg__tooltip[data-placement^=left] .wg__tooltip-arrow{right:-4px}.wg__tooltip[data-placement^=right] .wg__tooltip-arrow{left:-4px}.wg__tooltip-title{font-weight:600}.wg__tooltip-desc{opacity:.85;margin-top:2px}.wg__tooltip-shortcut{margin-top:4px;opacity:.7;font-size:.9em}.wg__goto-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0006;display:flex;align-items:center;justify-content:center;z-index:1000}.wg__goto-dialog{background:var(--wg-surface-1);border-radius:var(--wg-border-radius-md);padding:var(--wg-spacing-lg);box-shadow:0 4px 20px #00000026;min-width:250px}.wg__goto-label{display:block;margin-bottom:var(--wg-spacing-sm);font-size:var(--wg-font-size-base);color:var(--wg-text-color-1)}.wg__goto-input{width:100%;padding:var(--wg-spacing-sm) var(--wg-spacing-md);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm);font-family:inherit;font-size:var(--wg-font-size-base);margin-bottom:var(--wg-spacing-md);box-sizing:border-box}.wg__goto-input:focus{outline:none;border-color:var(--wg-accent-color);box-shadow:0 0 0 2px #0078d433}.wg__goto-buttons{display:flex;gap:var(--wg-spacing-sm);justify-content:flex-end}.wg__goto-btn{padding:var(--wg-spacing-sm) var(--wg-spacing-md);border:1px solid var(--wg-border-color);border-radius:var(--wg-border-radius-sm);font-family:inherit;font-size:var(--wg-font-size-sm);cursor:pointer;background:var(--wg-surface-1);color:var(--wg-text-color-1)}.wg__goto-btn:hover{background:var(--wg-surface-2)}.wg__goto-btn--go{background:var(--wg-accent-color);border-color:var(--wg-accent-color);color:#fff}.wg__goto-btn--go:hover{background:var(--wg-accent-color-hover, #106ebe)}.wg__spacer-top td,.wg__spacer-bottom td{padding:0;border:none;background:transparent;height:inherit;line-height:0}@media (prefers-color-scheme: dark){:host{--wg-surface-1: #1f1f1f;--wg-surface-2: #2b2b2b;--wg-surface-3: #333333;--wg-surface-floating: #2b2b2b;--wg-text-color-1: #e0e0e0;--wg-text-color-2: #c0c0c0;--wg-text-color-3: #a0a0a0;--wg-border-color: #3d3d3d;--wg-border-color-hover: #5a5a5a;--wg-input-bg: #1f1f1f;--wg-input-border: 1px solid #5a5a5a;--wg-hover-bg: #3a3a3a;--wg-active-bg: #4a4a4a;--wg-danger-bg-light: #442726;--wg-danger-color: #f87c86}}:host([data-theme="dark"]),[data-theme=dark] :host,:host([data-bs-theme="dark"]),[data-bs-theme=dark] :host,.dark :host{--wg-surface-1: #1f1f1f;--wg-surface-2: #2b2b2b;--wg-surface-3: #333333;--wg-surface-floating: #2b2b2b;--wg-text-color-1: #e0e0e0;--wg-text-color-2: #c0c0c0;--wg-text-color-3: #a0a0a0;--wg-border-color: #3d3d3d;--wg-border-color-hover: #5a5a5a;--wg-input-bg: #1f1f1f;--wg-input-border: 1px solid #5a5a5a;--wg-hover-bg: #3a3a3a;--wg-active-bg: #4a4a4a;--wg-danger-bg-light: #442726;--wg-danger-color: #f87c86}';function xt(o,t,e){const i=e.valueMember||"value",n=e.displayMember||"label",r=t.find(s=>s[i]===o);return r?String(r[n]??""):o!=null?String(o):""}function Ne(o,t){if(t.getDisplayCallback)return t.getDisplayCallback(o);const e=t.displayMember||"label";return String(o[e]??o.label??"")}function ke(o,t){if(t.getValueCallback)return t.getValueCallback(o);const e=t.valueMember||"value";return o[e]??o.value}function xn(o,t){return t.getIconCallback?t.getIconCallback(o):t.iconMember&&o[t.iconMember]||null}function kn(o,t){return t.getSubtitleCallback?t.getSubtitleCallback(o):t.subtitleMember&&o[t.subtitleMember]||null}function We(o,t){return t.getDisabledCallback?t.getDisabledCallback(o):t.disabledMember?!!o[t.disabledMember]:!1}function kt(o,t,e,i,n,r){const s=i.editor==="select"||i.editor==="combobox"||i.editor==="autocomplete",l=i.editor==="date",a=String(i.field);if(s)return`
299
+ <div class="wg__cell-dropdown-display ${o.grid.getEffectiveToggleVisibility(i)==="on-focus"?"wg__cell-dropdown-display--toggle-on-focus":""}" data-row="${t}" data-field="${a}">
300
+ <span class="wg__select-value">${o.escapeHtml(n)}</span>
301
+ <span class="wg__select-toggle">▼</span>
302
+ </div>
303
+ `;if(l)return`
304
+ <div class="wg__cell-date-display ${o.grid.getEffectiveToggleVisibility(i)==="on-focus"?"wg__cell-date-display--toggle-on-focus":""}" data-row="${t}" data-field="${a}">
305
+ <span class="wg__date-value">${o.escapeHtml(n)}</span>
306
+ <button type="button" class="wg__date-trigger" tabindex="-1">
307
+ <svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM9 10H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm-8 4H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2z"/></svg>
308
+ </button>
309
+ </div>
310
+ `;const d=i.maxLines?`style="-webkit-line-clamp: ${i.maxLines}"`:"";return i.templateCallback?`<span class="wg__cell-text" ${d}>${n}</span>`:`<span class="wg__cell-text" ${d}>${o.escapeHtml(n)}</span>`}let Y={path:null,arrowPos:null,arrowDir:"right"};const Dn={add:{icon:"+",title:"Add row"},delete:{icon:"−",title:"Delete row",danger:!0},duplicate:{icon:"⧉",title:"Duplicate row"},moveUp:{icon:"↑",title:"Move up"},moveDown:{icon:"↓",title:"Move down"}};function Dt(o){return o.map((t,e)=>{if(typeof t=="string"){const i=Dn[t];return i?{id:t,icon:i.icon,title:i.title,row:1,group:1,type:t,danger:i.danger}:(console.warn(`Unknown predefined toolbar action: ${t}`),null)}return{id:t.id||`toolbar-item-${e}`,icon:t.icon,title:t.title,label:t.label,row:t.row??1,group:t.group??1,type:t.type,danger:t.danger,disabled:t.disabled,hidden:t.hidden,onclick:t.onclick,tooltip:t.tooltip,tooltipCallback:t.tooltipCallback}}).filter(t=>t!==null)}function Rn(o){const t=new Map;for(const n of o){const r=n.row;t.has(r)||t.set(r,[]),t.get(r).push(n)}const e=[],i=[...t.keys()].sort((n,r)=>n-r);for(const n of i){const r=t.get(n),s=new Map;for(const a of r){const d=a.group;s.has(d)||s.set(d,[]),s.get(d).push(a)}const l=[...s.keys()].sort((a,d)=>a-d);e.push({rowNum:n,groups:l.map(a=>({groupNum:a,items:s.get(a)}))})}return e}function En(o){return o.replace(/\+/g," + ")}function Mn(o,t){var n,r;const e=[];e.push(`<span class="wg__tooltip-title">${o.title}</span>`),(n=o.tooltip)!=null&&n.description&&e.push(`<div class="wg__tooltip-desc">${o.tooltip.description}</div>`);const i=((r=o.tooltip)==null?void 0:r.shortcut)||t;return i&&e.push(`<div class="wg__tooltip-shortcut">${En(i)}</div>`),e.join("")}function $n(o,t,e,i=!1){let n=Rn(o);return i&&(n=n.reverse()),`<div class="wg__toolbar">${n.map(({groups:s})=>`<div class="wg__toolbar-row">${s.map(({items:a},d)=>{const g=d>0?'<div class="wg__toolbar-divider"></div>':"",u=a.map(c=>{const h=typeof c.disabled=="function"?c.disabled(t,e):c.disabled,f=["wg__toolbar-btn",c.danger?"wg__toolbar-btn--danger":""].filter(Boolean).join(" "),w=c.label?`<span class="wg__toolbar-label">${c.label}</span>`:"";return`<button
311
+ class="${f}"
312
+ data-toolbar-item="${c.id}"
313
+ title="${c.title}"
314
+ ${h?"disabled":""}
315
+ >${c.icon}${w}</button>`}).join("");return g+u}).join("")}</div>`).join("")}</div>`}let P=null;function In(o,t,e,i,n,r,s){ot();const l=o.grid.toolbarVerticalAlign!=="top",a=$n(i,n,e,l),d=document.createElement("div");d.className="wg__toolbar-container",d.innerHTML=a,o.shadow.appendChild(d);const g=d.querySelector(".wg__toolbar");let u="left";g.style.position="fixed",g.style.visibility="hidden",requestAnimationFrame(()=>{const h=o.shadow.querySelector(`tr[data-row-index="${e}"]`);if(!h){ot();return}const f=o.grid.toolbarPosition,w=o.grid.toolbarVerticalAlign,p=o.grid.toolbarHorizontalAlign;let m,y,_="";w==="top"?_="-end":w==="bottom"&&(_="-start");const S=()=>p==="start"?"top-start":p==="end"?"top-end":"top";f==="left"?(m=`left${_}`,y=[`right${_}`,S()]):f==="right"?(m=`right${_}`,y=[`left${_}`,S()]):f==="top"?(m=S(),y=[`left${_}`,`right${_}`]):(m=`left${_}`,y=[`right${_}`,S()]);let v=h;if(p==="cursor"&&s!==void 0&&f==="top"){const C=h.getBoundingClientRect();v={getBoundingClientRect:()=>({x:s,y:C.top,top:C.top,left:s,bottom:C.bottom,right:s,width:0,height:C.height,toJSON:()=>({})})}}Ae(v,g,{strategy:"fixed",placement:m,middleware:[Le({fallbackPlacements:y}),et({padding:8})]}).then(({x:C,y:x,placement:k})=>{Object.assign(g.style,{left:`${C}px`,top:`${x}px`,visibility:"visible"}),u=k.split("-")[0],P&&(P.position=u)}).catch(()=>{g.style.visibility="visible"})});const c=h=>{const f=h.target.closest(".wg__toolbar-btn");if(f&&!f.disabled){const w=f.dataset.toolbarItem||"",p=i.find(m=>m.id===w);p&&r(p)}};d.addEventListener("click",c),P={container:d,toolbar:g,rowIndex:e,rowItem:n,position:u,hasRowMoved:!1,cursorX:s,cleanup:()=>{d.removeEventListener("click",c),d.remove()}},Y={path:null,arrowPos:null,arrowDir:"right"}}function ot(){P&&(P.cleanup(),P=null),Y={path:null,arrowPos:null,arrowDir:"right"}}function Oe(){return(P==null?void 0:P.rowIndex)??null}function mo(o){return(P==null?void 0:P.container.getRootNode())===o}function Rt(o){return(P==null?void 0:P.rowIndex)===o}function Tn(){return Y}function bo(o,t){if(!P){Y={path:null,arrowPos:null,arrowDir:"right"};return}const{toolbar:e,rowItem:i,position:n}=P,r=t.findIndex(v=>v===i);if(r===-1){Y={path:null,arrowPos:null,arrowDir:"right"};return}const s=o.shadow.querySelector(`tr[data-row-index="${r}"]`);if(!s){Y={path:null,arrowPos:null,arrowDir:"right"};return}if(r===P.rowIndex||(P.hasRowMoved=!0),!P.hasRowMoved){Y={path:null,arrowPos:null,arrowDir:"right"};return}const a=e.getBoundingClientRect(),d=s.getBoundingClientRect(),g=o.shadow.querySelector(".wg__table"),u=g==null?void 0:g.getBoundingClientRect(),c=o.shadow.querySelector(".wg"),h=c==null?void 0:c.getBoundingClientRect();if(!u||!h){Y={path:null,arrowPos:null,arrowDir:"right"};return}const f=document.dir==="rtl"||document.documentElement.dir==="rtl",w=d.top+d.height/2,p=d.bottom<=h.top,m=d.top>=h.bottom,y=!p&&!m;let _,S="right";if(p?(_=h.top+8,S="up"):m?(_=h.bottom-8,S="down"):_=w,n==="left"){const v=a.right,C=a.top+a.height/2,x=f?h.right+15:h.left-15;if(!y){Y={path:`M ${v} ${C} H ${x} V ${_}`,arrowPos:{x,y:_},arrowDir:S};return}const k=f?h.right-8:h.left+8;S=f?"left":"right",Y={path:`M ${v} ${C} H ${x} V ${_} H ${k}`,arrowPos:{x:k,y:_},arrowDir:S};return}else if(n==="right"){const v=a.left,C=a.top+a.height/2,x=f?h.left-15:h.right+15;if(!y){Y={path:`M ${v} ${C} H ${x} V ${_}`,arrowPos:{x,y:_},arrowDir:S};return}const k=f?h.left+8:h.right-8;S=f?"right":"left",Y={path:`M ${v} ${C} H ${x} V ${_} H ${k}`,arrowPos:{x:k,y:_},arrowDir:S};return}else{const C=a.right,x=a.top+a.height/2,k=C+48,T=r-P.rowIndex,M=8;if(T===0){let z=d.top-M;m&&(z=h.bottom-M),Y={path:`M ${C} ${x} H ${k} V ${z}`,arrowPos:{x:k,y:z},arrowDir:"down"};return}else if(T===-1){const A=a.top+a.height*.25,W=a.top+a.height*.75,I=a.right+24,U=a.right+M;Y={path:`M ${a.right} ${A} H ${I} V ${W} H ${U}`,arrowPos:{x:U,y:W},arrowDir:"left"};return}else if(T<0){let z=d.bottom+M;p&&(z=h.top+M),Y={path:`M ${C} ${x} H ${k} V ${z}`,arrowPos:{x:k,y:z},arrowDir:"up"};return}else{let z=d.top-M;m&&(z=h.bottom-M),Y={path:`M ${C} ${x} H ${k} V ${z}`,arrowPos:{x:k,y:z},arrowDir:"down"};return}}}function _o(o,t,e="Row actions"){return`<button
316
+ class="wg__toolbar-trigger ${t?"wg__toolbar-trigger--active":""}"
317
+ data-toolbar-trigger="${o}"
318
+ title="${e}"
319
+ >⋮</button>`}const Et=40;function Mt(o){if(!o||o==="auto")return 150;const t=o.match(/^([\d.]+)(px|em|rem|%)?$/);if(!t)return 150;const e=parseFloat(t[1]);switch(t[2]||"px"){case"px":return e;case"em":return e*16;case"rem":return e*10;case"%":return 150;default:return e}}function zn(o){const t=["wg"];return o.grid.isStriped&&t.push("wg--striped"),o.grid.isHoverable&&t.push("wg--hoverable"),o.grid.isEditable&&t.push("wg--editable"),o.grid.isNavigateMode&&t.push("wg--navigate-mode"),o.grid.isColumnReorderAllowed&&t.push("wg--reorderable"),t.join(" ")}function Ln(o){const t=o.grid.visualColumns;if(t.length===0)return"";let e=0,i="";if(o.grid.isRowNumbersVisible){const d=o.grid.isStickyRowNumbers;i=`<th class="wg__header wg__row-number-header${d?" wg__header--frozen":""}" style="${d?"position: sticky; left: 0; z-index: 4;":""}">#</th>`,e+=Et}const r=o.grid.isRowToolbarVisible&&o.grid.toolbarPosition==="inline"?`<th class="wg__header wg__inline-actions-header">${o.escapeHtml(o.grid.inlineActionsTitle||o.grid.labels.inlineActionsHeader)}</th>`:"",l=o.grid.isRowToolbarVisible&&o.grid.toolbarTrigger==="button"&&o.grid.toolbarPosition!=="inline"?'<th class="wg__header wg__actions-column"></th>':"",a=t.map(({column:d,originalIndex:g},u)=>{const c=String(d.field),h=d.isSortable!==!1&&o.grid.sortMode!=="none",f=o.grid.getColumnSortState(c),w=o.grid.getColumnSortPriority(c),p=f!==void 0,m=o.grid.isColumnFrozen(u),y=m&&u===o.grid.totalFrozenColumns-1,_=["wg__header"];h&&_.push("wg__header--sortable"),p&&_.push("wg__header--sorted"),m&&_.push("wg__header--frozen"),y&&_.push("wg__header--frozen-last");const v=o.grid.getColumnWidth(c)||d.width||d.maxWidth,C=Mt(v),x=d.minWidth,k=d.headerHorizontalAlign||d.horizontalAlign||"left",T=d.headerVerticalAlign||d.verticalAlign||"middle",z=`style="${[m?"position: sticky":"",m?`left: ${e}px`:"",m?"z-index: 2":"",v?`width: ${v}`:"",v?`max-width: ${v}`:"",x?`min-width: ${x}`:"",`text-align: ${k}`,`vertical-align: ${T}`].filter(Boolean).join("; ")}"`;m&&(e+=C);let A="";if(h)if(p){const D=f.direction==="asc"?"▲":"▼",H=o.grid.sort.length>1?`<sup class="wg__sort-priority">${w}</sup>`:"";A=`<span class="wg__sort-indicator">${D}${H}</span>`}else A='<span class="wg__sort-indicator wg__sort-placeholder">⬍</span>';let W="";d.headerInfo&&(W=`<span class="wg__header-info" data-tooltip="${o.escapeHtml(d.headerInfo)}"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg></span>`);const U=`<div class="wg__resize-handle${d.isResizable!==!1?"":" wg__resize-handle--disabled"}" data-field="${c}"></div>`;return`
320
+ <th class="${_.join(" ")}" ${z} data-field="${c}">
321
+ <div class="wg__header-container">
322
+ <div class="wg__header-content wg__header-content--align-${k} wg__header-content--valign-${T}">
323
+ <span class="wg__header-title">${o.escapeHtml(d.title)}</span>
324
+ ${W}
325
+ </div>
326
+ <div class="wg__header-controls">
327
+ ${A}
328
+ </div>
329
+ </div>
330
+ ${U}
331
+ </th>
332
+ `}).join("");return`<tr>${i}${r}${l}${a}<th class="wg__filler">&nbsp;</th></tr>`}function An(o){const t=o.grid.displayItems,e=o.grid.visualColumns,i=o.grid.isRowNumbersVisible,n=o.grid.isStickyRowNumbers,r=o.grid.isRowToolbarVisible&&o.grid.toolbarPosition==="inline",s=o.grid.isRowToolbarVisible&&o.grid.toolbarTrigger==="button"&&o.grid.toolbarPosition!=="inline",l=e.length+(s?1:0)+(i?1:0)+(r?1:0);if(t.length===0)return`
333
+ <tr>
334
+ <td class="wg__empty" colspan="${l}">
335
+ No items to display
336
+ </td>
337
+ </tr>
338
+ `;const a=Oe(),d=e.map(({column:g})=>Mt(g.width||g.maxWidth));return t.map((g,u)=>{const c=o.grid.getRowLockInfo(g),h=(c==null?void 0:c.isLocked)===!0;let f=0,w="";if(i){const v=n?"position: sticky; left: 0; z-index: 2;":"",C=n?" wg__cell--frozen":"";if(h){const x=c!=null&&c.lockedBy?`Locked by ${c.lockedBy}`:"This row is locked";w=`<td class="wg__cell wg__row-number wg__row-number--locked${C}" style="${v}" data-tooltip="${o.escapeHtml(x)}" data-row-number="${u}">🔒</td>`}else w=`<td class="wg__cell wg__row-number${C}" style="${v}" data-row-number="${u}">${u+1}</td>`;f+=Et}const p=r?vo(o,g,u):"";let m="";s&&(m=`
339
+ <td class="wg__cell wg__actions-column">
340
+ ${_o(u,a===u,o.grid.labels.rowActions)}
341
+ </td>
342
+ `);const y=e.map(({column:v,originalIndex:C},x)=>{const k=String(v.field),T=o.grid.getCellValue(g,v,u),M=v.horizontalAlign||"left",z=v.verticalAlign||"middle",A=o.grid.isCellEditable(v),W=o.grid.isCellFocused(u,C),I=o.grid.isColumnFrozen(x),U=I&&x===o.grid.totalFrozenColumns-1,D=["wg__cell"],H=o.grid.isEditing(u,k);if(A&&D.push("wg__cell--editable"),W&&!H&&D.push("wg__cell--focused"),v.textOverflow!=="wrap"&&D.push("wg__cell--ellipsis"),v.maxLines&&D.push("wg__cell--line-clamp"),H&&D.push("wg__cell--editing"),o.grid.isCellInvalid(u,k)&&D.push("wg__cell--invalid"),o.grid.isCellInSelectedRange(u,x)&&D.push("wg__cell--in-range"),I&&D.push("wg__cell--frozen"),U&&D.push("wg__cell--frozen-last"),v.cellClass&&D.push(v.cellClass),v.cellClassCallback){const Z=o.grid.getCellRawValue(g,u,k),K=v.cellClassCallback(Z,g);K&&D.push(K)}const O=o.grid.getColumnWidth(k)||v.width,Pe=v.minWidth,Yt=[I?"position: sticky":"",I?`left: ${f}px`:"",I?"z-index: 1":"",`text-align: ${M}`,`vertical-align: ${z}`,O?`width: ${O}`:"",Pe?`min-width: ${Pe}`:"",v.maxWidth?`max-width: ${v.maxWidth}`:""].filter(Boolean).join("; ");I&&(f+=d[x]);const Bt=o.grid.isNavigateMode?'tabindex="0"':"";let _e="";if(v.tooltipCallback){const Z=o.grid.getCellRawValue(g,u,k),K=v.tooltipCallback(Z,g);K&&(_e=`data-tooltip="${o.escapeHtml(K)}"`)}else if(v.tooltipMember){const Z=g[v.tooltipMember];Z&&typeof Z=="string"&&(_e=`data-tooltip="${o.escapeHtml(Z)}"`)}if(!_e&&o.grid.isCellInvalid(u,k)){const Z=o.grid.getCellValidationError(u,k);if(Z){const K=v.validationTooltipCallback||o.grid.validationTooltipCallback;if(K){const Ut=o.grid.getCellRawValue(g,u,k),X=K({field:k,error:Z,value:Ut,row:g,rowIndex:u});X&&(_e=`data-tooltip-html="${o.escapeHtml(X)}"`)}_e||(_e=`data-tooltip="${o.escapeHtml(Z)}"`)}}return`
343
+ <td
344
+ class="${D.join(" ")}"
345
+ style="${Yt}"
346
+ data-row="${u}"
347
+ data-col="${C}"
348
+ data-field="${k}"
349
+ ${Bt}
350
+ ${_e}
351
+ >
352
+ ${o.grid.isEditing(u,k)?nt(o,u,C,v):kt(o,u,C,v,T)}
353
+ </td>
354
+ `}).join(""),_=["wg__row"];if(h&&_.push("wg__row--locked"),o.grid.isRowSelected(u)&&_.push("wg__row--selected"),o.grid.rowClassCallback){const v=o.grid.rowClassCallback(g,u);v&&_.push(v)}const S=h&&!i?`data-tooltip="${o.escapeHtml(c!=null&&c.lockedBy?`Locked by ${c.lockedBy}`:"This row is locked")}"`:"";return`<tr class="${_.join(" ")}" data-row-index="${u}" ${S}>${w}${p}${m}${y}<td class="wg__filler"></td></tr>`}).join("")}function vo(o,t,e){const n=Dt(o.grid.rowToolbar).filter(a=>typeof a.hidden=="function"?!a.hidden(t,e):!a.hidden),r=new Map;for(const a of n){const d=a.row??1;r.has(d)||r.set(d,[]),r.get(d).push(a)}return`<td class="wg__cell wg__inline-actions-cell"><div class="wg__inline-actions-wrap">${[...r.keys()].sort((a,d)=>a-d).map(a=>`<div class="wg__inline-actions-row">${r.get(a).map(u=>{const c=typeof u.disabled=="function"?u.disabled(t,e):u.disabled,h=["wg__inline-action-btn",u.danger?"wg__inline-action-btn--danger":"",c?"wg__inline-action-btn--disabled":""].filter(Boolean).join(" "),f=c?"disabled":"";return`<button class="${h}" data-action-id="${u.id}" data-row="${e}" title="${o.escapeHtml(u.title)}" ${f}>${u.icon}</button>`}).join("")}</div>`).join("")}</div></td>`}function yo(o,t){const e=o.grid.displayItems,i=o.grid.visualColumns,{startIndex:n,endIndex:r,rowHeight:s,totalItems:l}=t,a=o.grid.isRowNumbersVisible,d=o.grid.isStickyRowNumbers,g=o.grid.isRowToolbarVisible&&o.grid.toolbarPosition==="inline",u=o.grid.isRowToolbarVisible&&o.grid.toolbarTrigger==="button"&&o.grid.toolbarPosition!=="inline",c=i.length+(u?1:0)+(a?1:0)+(g?1:0);if(e.length===0)return`
355
+ <tr>
356
+ <td class="wg__empty" colspan="${c}">
357
+ No items to display
358
+ </td>
359
+ </tr>
360
+ `;const h=Oe(),f=i.map(({column:S})=>Mt(S.width||S.maxWidth)),w=n*s,p=(l-r)*s,m=w>0?`<tr class="wg__spacer-top"><td colspan="${c}" style="height: ${w}px"></td></tr>`:"",y=[];for(let S=n;S<r&&S<e.length;S++){const v=e[S],C=S,x=o.grid.getRowLockInfo(v),k=(x==null?void 0:x.isLocked)===!0;let T=0,M="";if(a){const D=d?"position: sticky; left: 0; z-index: 2;":"",H=d?" wg__cell--frozen":"";if(k){const q=x!=null&&x.lockedBy?`Locked by ${x.lockedBy}`:"This row is locked";M=`<td class="wg__cell wg__row-number wg__row-number--locked${H}" style="${D}" data-tooltip="${o.escapeHtml(q)}" data-row-number="${C}">🔒</td>`}else M=`<td class="wg__cell wg__row-number${H}" style="${D}" data-row-number="${C}">${C+1}</td>`;T+=Et}const z=g?vo(o,v,C):"";let A="";u&&(A=`
361
+ <td class="wg__cell wg__actions-column">
362
+ ${_o(C,h===C,o.grid.labels.rowActions)}
363
+ </td>
364
+ `);const W=i.map(({column:D,originalIndex:H},q)=>{const O=String(D.field),Pe=o.grid.getCellValue(v,D,C),Yt=D.horizontalAlign||"left",Bt=D.verticalAlign||"middle",_e=o.grid.isCellEditable(D),Z=o.grid.isCellFocused(C,H),K=o.grid.isColumnFrozen(q),Ut=K&&q===o.grid.totalFrozenColumns-1,X=["wg__cell"],Jo=o.grid.isEditing(C,O);if(_e&&X.push("wg__cell--editable"),Z&&!Jo&&X.push("wg__cell--focused"),D.textOverflow!=="wrap"&&X.push("wg__cell--ellipsis"),D.maxLines&&X.push("wg__cell--line-clamp"),Jo&&X.push("wg__cell--editing"),o.grid.isCellInvalid(C,O)&&X.push("wg__cell--invalid"),o.grid.isCellInSelectedRange(C,q)&&X.push("wg__cell--in-range"),K&&X.push("wg__cell--frozen"),Ut&&X.push("wg__cell--frozen-last"),D.cellClass&&X.push(D.cellClass),D.cellClassCallback){const ae=o.grid.getCellRawValue(v,C,O),Se=D.cellClassCallback(ae,v);Se&&X.push(Se)}const Zo=o.grid.getColumnWidth(O)||D.width,ei=D.minWidth,Qr=[K?"position: sticky":"",K?`left: ${T}px`:"",K?"z-index: 1":"",`text-align: ${Yt}`,`vertical-align: ${Bt}`,Zo?`width: ${Zo}`:"",ei?`min-width: ${ei}`:"",D.maxWidth?`max-width: ${D.maxWidth}`:""].filter(Boolean).join("; ");K&&(T+=f[q]);const Jr=o.grid.isNavigateMode?'tabindex="0"':"";let Ee="";if(D.tooltipCallback){const ae=o.grid.getCellRawValue(v,C,O),Se=D.tooltipCallback(ae,v);Se&&(Ee=`data-tooltip="${o.escapeHtml(Se)}"`)}else if(D.tooltipMember){const ae=v[D.tooltipMember];ae&&typeof ae=="string"&&(Ee=`data-tooltip="${o.escapeHtml(ae)}"`)}if(!Ee&&o.grid.isCellInvalid(C,O)){const ae=o.grid.getCellValidationError(C,O);if(ae){const Se=D.validationTooltipCallback||o.grid.validationTooltipCallback;if(Se){const Zr=o.grid.getCellRawValue(v,C,O),ti=Se({field:O,error:ae,value:Zr,row:v,rowIndex:C});ti&&(Ee=`data-tooltip-html="${o.escapeHtml(ti)}"`)}Ee||(Ee=`data-tooltip="${o.escapeHtml(ae)}"`)}}return`
365
+ <td
366
+ class="${X.join(" ")}"
367
+ style="${Qr}"
368
+ data-row="${C}"
369
+ data-col="${H}"
370
+ data-field="${O}"
371
+ ${Jr}
372
+ ${Ee}
373
+ >
374
+ ${o.grid.isEditing(C,O)?nt(o,C,H,D):kt(o,C,H,D,Pe)}
375
+ </td>
376
+ `}).join(""),I=["wg__row"];if(k&&I.push("wg__row--locked"),o.grid.isRowSelected(C)&&I.push("wg__row--selected"),o.grid.rowClassCallback){const D=o.grid.rowClassCallback(v,C);D&&I.push(D)}const U=k&&!a?`data-tooltip="${o.escapeHtml(x!=null&&x.lockedBy?`Locked by ${x.lockedBy}`:"This row is locked")}"`:"";y.push(`<tr class="${I.join(" ")}" data-row-index="${C}" ${U}>${M}${z}${A}${W}<td class="wg__filler"></td></tr>`)}const _=p>0?`<tr class="wg__spacer-bottom"><td colspan="${c}" style="height: ${p}px"></td></tr>`:"";return m+y.join("")+_}function $t(o,t="bottom-center"){const e=o.grid.showPagination;if(!o.grid.isPageable||e===!1||e==="auto"&&o.grid.totalPages<=1)return"";const i=o.grid.currentPage,n=o.grid.totalPages,r=o.grid.pageSize,s=o.grid.pageSizes,l=o.grid.totalItems!==null?o.grid.totalItems:o.grid.sortedItems.length,a=o.grid.labels,d={first:a.paginationFirst,previous:a.paginationPrevious,next:a.paginationNext,last:a.paginationLast,pageInfo:a.paginationPageInfo.replace("{current}",String(i)).replace("{total}",String(n)),itemCount:a.paginationItemCount.replace("{count}",String(l)),perPage:a.paginationPerPage},g=o.grid.paginationLabelsCallback,u=g?g({currentPage:i,totalPages:n,totalItems:l,pageSize:r}):{},c={...d,...u},h=t.startsWith("top-"),f=t.replace("top-","").replace("bottom-",""),w=["wg__pagination"];f==="left"?w.push("wg__pagination--left"):f==="right"&&w.push("wg__pagination--right"),h&&w.push("wg__pagination--top");const p={first:`
377
+ <button class="wg__pagination-btn" data-action="first" ${i===1?"disabled":""}>
378
+ ${c.first}
379
+ </button>
380
+ `,previous:`
381
+ <button class="wg__pagination-btn" data-action="prev" ${i===1?"disabled":""}>
382
+ ${c.previous}
383
+ </button>
384
+ `,next:`
385
+ <button class="wg__pagination-btn" data-action="next" ${i===n?"disabled":""}>
386
+ ${c.next}
387
+ </button>
388
+ `,last:`
389
+ <button class="wg__pagination-btn" data-action="last" ${i===n?"disabled":""}>
390
+ ${c.last}
391
+ </button>
392
+ `,pageInfo:`
393
+ <div class="wg__pagination-info">
394
+ ${c.pageInfo}
395
+ <span class="wg__pagination-count">${c.itemCount}</span>
396
+ </div>
397
+ `,pageSize:s.length>0?`
398
+ <div class="wg__pagination-pagesize">
399
+ <select class="wg__pagination-select" data-action="pagesize">
400
+ ${s.map(_=>`<option value="${_}" ${_===r?"selected":""}>${_}</option>`).join("")}
401
+ </select>
402
+ <span class="wg__pagination-label">${c.perPage}</span>
403
+ </div>
404
+ `:""},y=o.grid.paginationLayout.split("|").map(_=>_.trim()).map(_=>p[_]||"").join("");return`<div class="${w.join(" ")}">${y}</div>`}function It(o,t){const e=o.grid.summaryContentCallback;if(!e)return"";const i=o.grid.currentPage,n=o.grid.pageSize,r=o.grid.sortedItems,s=o.grid.displayItems,l=o.grid.totalItems!==null?o.grid.totalItems:r.length,a=e({items:s,allItems:r,totalItems:l,currentPage:i,pageSize:n,metadata:o.grid.summaryMetadata}),d=t.startsWith("top-"),g=t.replace("top-","").replace("bottom-",""),u=["wg__summary"];return g==="left"?u.push("wg__summary--left"):g==="right"&&u.push("wg__summary--right"),d&&u.push("wg__summary--top"),`<div class="${u.join(" ")}">${a}</div>`}function Hn(o,t,e){if(o.grid.shouldUseVirtualScroll()){On(o,t);const s=o.shadow.querySelector(`[data-row="${t}"][data-col="${e}"]`);s&&s.focus({preventScroll:!0});return}const i=o.shadow.querySelector(`[data-row="${t}"][data-col="${e}"]`);if(!i)return;i.focus({preventScroll:!0}),i.scrollIntoView({block:"nearest",inline:"nearest"});const n=o.shadow.querySelector(".wg__header"),r=o.shadow.querySelector(".wg");if(n&&r){const s=n.getBoundingClientRect(),l=i.getBoundingClientRect();if(l.top<s.bottom){const a=l.top-s.bottom-4;r.scrollBy({top:a,behavior:"instant"})}}}function On(o,t){const e=o.shadow.querySelector(".wg");if(!e)return;const i=o.grid.virtualScrollRowHeight,n=e.scrollTop,r=e.clientHeight,s=o.shadow.querySelector(".wg__header"),l=(s==null?void 0:s.offsetHeight)||0,a=t*i,d=a+i,g=n+l,u=n+r;a<g?e.scrollTop=a-l:d>u&&(e.scrollTop=d-r)}let Co=0;const Pn=100;function ee(o,t,e){const i=t&&e&&t.rowIndex===e.rowIndex&&t.colIndex===e.colIndex,n=Date.now();if(i&&n-Co<Pn)return;Co=n;const r=o.grid.editingCell;t&&(r&&r.rowIndex===t.rowIndex&&o.grid.columns.findIndex(l=>String(l.field)===r.field)===t.colIndex||j(o,t.rowIndex,t.colIndex)),e&&(r&&r.rowIndex===e.rowIndex&&o.grid.columns.findIndex(l=>String(l.field)===r.field)===e.colIndex||j(o,e.rowIndex,e.colIndex))}function te(o){const t=o.grid.editingCell;if(t){const e=o.grid.columns.findIndex(n=>String(n.field)===t.field),i=o.shadow.querySelector(`[data-row="${t.rowIndex}"][data-col="${e}"]`);i&&i.classList.remove("wg__cell--editing")}}function Vn(o,t,e){j(o,t,e)}function Fn(o,t,e){if(!o.grid.isNavigateMode)return;const i=o.grid.focusedCell,n={rowIndex:t,colIndex:e};(i==null?void 0:i.rowIndex)===t&&(i==null?void 0:i.colIndex)===e||(o.grid.setFocusedCell(t,e),ee(o,i,n))}function L(o,t,e){const i=o.grid.focusedCell,n={rowIndex:t,colIndex:e};o.grid.setFocusedCell(t,e),ee(o,i,n),Hn(o,t,e)}function oe(o,t,e,i){const n=o.grid.columns[e];if(!n||!o.grid.isCellEditable(n))return;const r=String(n.field);o.dropdownOpen&&B(o);const s=o.grid.focusedCell;s&&(s.rowIndex!==t||s.colIndex!==e)&&(o.grid.clearFocusedCell(),j(o,s.rowIndex,s.colIndex)),o.grid.startEdit(t,r,i),j(o,t,e,{focusEditor:!0,cursorPosition:i==null?void 0:i.cursorPosition,initialSearchQuery:i==null?void 0:i.initialSearchQuery})}function Tt(o,t){const e=t.querySelector(".wg__cell-text");if(!e)return null;const i=e.textContent||"";if(!i.length)return 0;const n=o.clientX,r=e.getBoundingClientRect();if(n<=r.left)return 0;if(n>=r.right)return i.length;const s=e.firstChild;if(!s||s.nodeType!==Node.TEXT_NODE)return null;const l=document.createRange();let a=0,d=i.length;try{for(;a<d;){const g=Math.floor((a+d)/2);l.setStart(s,0),l.setEnd(s,g),l.getBoundingClientRect().right<n?a=g+1:d=g}if(a>0&&a<i.length){l.setStart(s,a-1),l.setEnd(s,a);const g=l.getBoundingClientRect(),u=g.left+g.width/2;n<u&&a--}}catch{return i.length}return a}function qn(o,t){const e=t.relatedTarget,i=o.shadow.querySelector(".wg__table");if(!e||!(i!=null&&i.contains(e))){const n=o.grid.focusedCell;o.grid.clearFocusedCell(),ee(o,n,null),rt()}}function Nn(o,t){if(!o)return null;const[e,i,n]=o.split("-").map(Number),r=new Date(e,i-1,n);if(isNaN(r.getTime()))return null;switch(t){case"date":return r;case"timestamp":return r.getTime();case"iso":default:return o}}function zt(o,t,e){j(o,t,e)}function it(o,t){const e=parseInt(t.dataset.row||"0",10),i=t.dataset.field||"";let n;if(t instanceof HTMLInputElement)if(t.type==="checkbox"){const r=JSON.parse(t.dataset.trueValue||"true"),s=JSON.parse(t.dataset.falseValue||"false");n=t.checked?r:s}else t.classList.contains("wg__editor--number")?n=t.value===""?null:parseFloat(t.value):t.type==="date"?n=Nn(t.value,t.dataset.outputFormat||"iso"):n=t.value;else t instanceof HTMLSelectElement&&(n=t.value);o.grid.commitEdit(e,i,n)}function Wn(o,t){it(o,t)}function Yn(o,t,e){const i=o.grid.columns[e];if(!i)return;const n=String(i.field),r=o.grid.displayItems[t];if(!r)return;const s=i.editorOptions||{},l=s.trueValue??!0,a=s.falseValue??!1,g=r[n]===l?a:l;o.grid.commitEdit(t,n,g),j(o,t,e);const u=o.grid.displayItems;t<u.length-1&&requestAnimationFrame(()=>{L(o,t+1,e)})}function Bn(o,t){if(!o.isCommittingFromKeyboard&&o.grid.editingCell){const e=parseInt(t.dataset.row||"0",10),i=t.dataset.field||"",n=o.grid.columns.findIndex(r=>String(r.field)===i);it(o,t),n>=0&&zt(o,e,n)}}function Lt(o,t,e,i){const r=o.grid.columns.findIndex(d=>String(d.field)===e),s=o.grid.displayItems;let l=t,a=r;if(i==="down")l=Math.min(t+1,s.length-1);else if(i==="up")l=Math.max(t-1,0);else{const d=o.grid.getEditableColumns(),g=d.findIndex(u=>u.index===r);i==="next"?g>=0&&g<d.length-1?a=d[g+1].index:t<s.length-1&&(l=t+1,a=d[0].index):g>0?a=d[g-1].index:t>0&&(l=t-1,a=d[d.length-1].index)}zt(o,t,r),L(o,l,a),o.isCommittingFromKeyboard=!1}function Un(o,t,e){const n=o.grid.columns.findIndex(r=>String(r.field)===e);n>=0&&(zt(o,t,n),L(o,t,n),o.isCommittingFromKeyboard=!1)}function nt(o,t,e,i){const n=String(i.field),r=o.grid.displayItems[t],s=o.grid.getCellRawValue(r,t,n);switch(i.editor||"text"){case"checkbox":return Qn(o,t,n,s,i);case"number":return Kn(o,t,n,s,i);case"date":return Xn(o,t,n,s,i);case"select":return Jn(o,t,n,s,i);case"combobox":return Zn(o,t,n,s,i);case"autocomplete":return er(o,t,n,s,i);case"custom":return tr(o,t,n,s,i);case"text":default:return jn(o,t,n,s,i)}}function jn(o,t,e,i,n){var a;const r=n.editorOptions||{},s=(a=o.grid.editingCell)==null?void 0:a.initialSearchQuery,l=s!==void 0?s:i!=null?String(i):"";return`
405
+ <input
406
+ type="text"
407
+ class="wg__editor wg__editor--text"
408
+ value="${o.escapeHtml(l)}"
409
+ data-row="${t}"
410
+ data-field="${e}"
411
+ ${r.maxLength?`maxlength="${r.maxLength}"`:""}
412
+ ${r.placeholder?`placeholder="${o.escapeHtml(r.placeholder)}"`:""}
413
+ ${r.pattern?`pattern="${o.escapeHtml(r.pattern)}"`:""}
414
+ />
415
+ `}function Kn(o,t,e,i,n){var l;n.editorOptions;const r=(l=o.grid.editingCell)==null?void 0:l.initialSearchQuery;return`
416
+ <input
417
+ type="text"
418
+ inputmode="numeric"
419
+ class="wg__editor wg__editor--number"
420
+ value="${r!==void 0?r:i!=null?String(i):""}"
421
+ data-row="${t}"
422
+ data-field="${e}"
423
+ />
424
+ `}function Xn(o,t,e,i,n){var d;const r=n.editorOptions||{},s=(d=o.grid.editingCell)==null?void 0:d.initialSearchQuery,l=At(i),a=s!==void 0?s:Gn(i,r.dateFormat);return`
425
+ <div class="wg__editor wg__editor--date" data-row="${t}" data-field="${e}">
426
+ <input
427
+ type="text"
428
+ class="wg__date-input"
429
+ value="${o.escapeHtml(a)}"
430
+ data-row="${t}"
431
+ data-field="${e}"
432
+ data-date-value="${l}"
433
+ data-output-format="${r.outputFormat||"iso"}"
434
+ data-date-format="${r.dateFormat||"YYYY-MM-DD"}"
435
+ ${r.minDate?`data-min-date="${At(r.minDate)}"`:""}
436
+ ${r.maxDate?`data-max-date="${At(r.maxDate)}"`:""}
437
+ placeholder="${o.escapeHtml(r.dateFormat||"YYYY-MM-DD")}"
438
+ />
439
+ <button type="button" class="wg__date-trigger" tabindex="-1">
440
+ <svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M19 3h-1V1h-2v2H8V1H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V8h14v11zM9 10H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm-8 4H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2z"/></svg>
441
+ </button>
442
+ </div>
443
+ `}function Gn(o,t){if(!o)return"";let e=null;if(o instanceof Date?e=o:typeof o=="number"?e=new Date(o):typeof o=="string"&&(e=new Date(o)),!e||isNaN(e.getTime()))return"";const i=t||"YYYY-MM-DD",n=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return i.replace("YYYY",String(n)).replace("YY",String(n).slice(-2)).replace("MM",r).replace("DD",s)}function At(o){if(!o)return"";let t=null;if(o instanceof Date?t=o:typeof o=="number"?t=new Date(o):typeof o=="string"&&(t=new Date(o)),!t||isNaN(t.getTime()))return"";const e=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0");return`${e}-${i}-${n}`}function Qn(o,t,e,i,n){const r=n.editorOptions||{},s=r.trueValue!==void 0?r.trueValue:!0;return`
444
+ <input
445
+ type="checkbox"
446
+ class="wg__editor wg__editor--checkbox"
447
+ ${i===s?"checked":""}
448
+ data-row="${t}"
449
+ data-field="${e}"
450
+ data-true-value="${o.escapeHtml(JSON.stringify(r.trueValue??!0))}"
451
+ data-false-value="${o.escapeHtml(JSON.stringify(r.falseValue??!1))}"
452
+ />
453
+ `}function Jn(o,t,e,i,n){var d;const r=n.editorOptions||{},s=r.options||[],l=xt(i,s,r),a=(d=o.grid.editingCell)==null?void 0:d.initialSearchQuery;return o.dropdownOptions=s,o.filterText=a||"",o.highlightedIndex=s.findIndex(g=>ke(g,r)===i),o.highlightedIndex<0&&s.length>0&&(o.highlightedIndex=0),`
454
+ <div
455
+ class="wg__editor wg__editor--select wg__select-trigger"
456
+ tabindex="0"
457
+ role="combobox"
458
+ aria-haspopup="listbox"
459
+ data-row="${t}"
460
+ data-field="${e}"
461
+ >
462
+ <span class="wg__select-value">${o.escapeHtml(l)}</span>
463
+ <span class="wg__select-toggle">▼</span>
464
+ </div>
465
+ `}function Zn(o,t,e,i,n){var g;const r=n.editorOptions||{},s=r.options||[],l=xt(i,s,r),a=(g=o.grid.editingCell)==null?void 0:g.initialSearchQuery,d=a!==void 0?a:l;return o.dropdownOptions=s,o.filterText=d,o.highlightedIndex=s.length>0?0:-1,`
466
+ <div class="wg__editor wg__editor--combobox" data-row="${t}" data-field="${e}">
467
+ <input
468
+ type="text"
469
+ class="wg__combobox-input"
470
+ value="${o.escapeHtml(d)}"
471
+ data-row="${t}"
472
+ data-field="${e}"
473
+ />
474
+ <span class="wg__combobox-toggle">▼</span>
475
+ </div>
476
+ `}function er(o,t,e,i,n){var g;const r=n.editorOptions||{},s=r.initialOptions||r.options||[],l=xt(i,s,r),a=(g=o.grid.editingCell)==null?void 0:g.initialSearchQuery,d=a!==void 0?a:l;return o.dropdownOptions=s,o.filterText=d,o.highlightedIndex=s.length>0?0:-1,`
477
+ <div class="wg__editor wg__editor--autocomplete" data-row="${t}" data-field="${e}">
478
+ <input
479
+ type="text"
480
+ class="wg__autocomplete-input"
481
+ value="${o.escapeHtml(d)}"
482
+ placeholder="${o.escapeHtml(r.placeholder||"")}"
483
+ data-row="${t}"
484
+ data-field="${e}"
485
+ />
486
+ <span class="wg__combobox-toggle">▼</span>
487
+ <span class="wg__loading-indicator" style="display: none;">⏳</span>
488
+ </div>
489
+ `}function tr(o,t,e,i,n){const r=n.formatCallback?n.formatCallback(i,o.grid.displayItems[t]):i!=null?String(i):"";return`
490
+ <div
491
+ class="wg__editor wg__editor--custom"
492
+ tabindex="0"
493
+ data-row="${t}"
494
+ data-field="${e}"
495
+ >
496
+ <span class="wg__custom-value">${o.escapeHtml(r)}</span>
497
+ </div>
498
+ `}function j(o,t,e,i={}){const n=o.grid.columns[e];if(!n)return;const r=o.shadow.querySelector(`td[data-row="${t}"][data-col="${e}"]`);if(!r)return;const s=String(n.field),l=o.grid.displayItems[t];if(!l)return;const a=o.grid.isEditing(t,s),d=o.grid.isCellFocused(t,e),g=o.grid.isCellEditable(n),u=o.grid.isCellInvalid(t,s),c=o.grid.visualColumns.findIndex(p=>p.originalIndex===e),h=c>=0&&o.grid.isColumnFrozen(c),f=h&&c===o.grid.totalFrozenColumns-1,w=["wg__cell"];if(g&&w.push("wg__cell--editable"),d&&!a&&w.push("wg__cell--focused"),n.textOverflow!=="wrap"&&w.push("wg__cell--ellipsis"),n.maxLines&&w.push("wg__cell--line-clamp"),a&&w.push("wg__cell--editing"),u&&w.push("wg__cell--invalid"),c>=0&&o.grid.isCellInSelectedRange(t,c)&&w.push("wg__cell--in-range"),h&&w.push("wg__cell--frozen"),f&&w.push("wg__cell--frozen-last"),n.cellClass&&w.push(n.cellClass),n.cellClassCallback){const p=o.grid.getCellRawValue(l,t,s),m=n.cellClassCallback(p,l);m&&w.push(m)}if(r.className=w.join(" "),a)r.innerHTML=nt(o,t,e,n),i.focusEditor&&or(o,r,n,i);else{const p=o.grid.getCellValue(l,n,t);r.innerHTML=kt(o,t,e,n,p)}}function or(o,t,e,i){var r;let n=t.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__select-trigger, .wg__date-input");if(n||(n=t.querySelector(".wg__editor")),!!n&&(n.focus(),n instanceof HTMLInputElement&&n.type==="text")){const s=i.cursorPosition,l=((r=e.editorOptions)==null?void 0:r.editStartSelection)||o.grid.editStartSelection;if(i.initialSearchQuery!==void 0){const a=n.value.length;n.setSelectionRange(a,a)}else switch(l){case"mousePosition":if(s!==void 0){const a=Math.min(s,n.value.length);n.setSelectionRange(a,a)}else n.setSelectionRange(n.value.length,n.value.length);break;case"cursorAtStart":n.setSelectionRange(0,0);break;case"cursorAtEnd":n.setSelectionRange(n.value.length,n.value.length);break;case"selectAll":default:n.select();break}}}const ir=5;function nr(o,t){var i,n;switch(t.editor||"text"){case"number":return typeof o=="number"&&!isNaN(o);case"select":case"combobox":{const r=(i=t.editorOptions)==null?void 0:i.options;if(!r||r.length===0)return!0;const s=((n=t.editorOptions)==null?void 0:n.valueMember)||"value";return r.some(l=>l[s]===o)}case"date":{if(o==null||o==="")return!0;if(o instanceof Date)return!isNaN(o.getTime());if(typeof o=="string"){if(!/\d{4}[-/]\d{1,2}[-/]\d{1,2}/.test(o)&&!/\d{1,2}[-/.]\d{1,2}[-/.]\d{2,4}/.test(o))return!1;const r=new Date(o);return!isNaN(r.getTime())}if(typeof o=="number"){const r=new Date("2000-01-01").getTime(),s=new Date("2100-01-01").getTime();if(o<r||o>s)return!1;const l=new Date(o);return!isNaN(l.getTime())}return!1}case"text":case"autocomplete":case"checkbox":case"custom":default:return!0}}let E={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startField:"",startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,handleElement:null,rangeElement:null},ue=null;function Ht(o){const t=o.grid.focusedCell;if(!t||o.grid.editingCell||o.dropdownOpen){rt();return}const{rowIndex:e,colIndex:i}=t,n=o.shadow.querySelector(`[data-row="${e}"][data-col="${i}"]`);if(!n){rt();return}const r=o.shadow.querySelector(".wg");if(!r)return;const s=r.getBoundingClientRect(),l=n.getBoundingClientRect(),a=r.scrollLeft,d=r.scrollTop,g=8,u=l.right-s.left+a-g/2,c=l.bottom-s.top+d-g/2;if(!E.handleElement){const h=document.createElement("div");h.className="wg__fill-handle",r.appendChild(h),E.handleElement=h,h.addEventListener("mousedown",f=>rr(o,f))}E.handleElement.style.left=`${u}px`,E.handleElement.style.top=`${c}px`}function rt(){E.handleElement&&(E.handleElement.remove(),E.handleElement=null)}function rr(o,t){var l;t.preventDefault(),t.stopPropagation();const e=o.grid.focusedCell;if(!e)return;const{rowIndex:i,colIndex:n}=e,s=(l=o.grid.visualColumns[n])==null?void 0:l.column;s&&(E={...E,isPending:!0,isDragging:!1,startRowIndex:i,startColIndex:n,startField:String(s.field),startX:t.clientX,startY:t.clientY,currentRowIndex:i,currentColIndex:n},ue=o,document.addEventListener("mousemove",So),document.addEventListener("mouseup",ko),document.addEventListener("keydown",Do))}function So(o){if(!ue)return;if(E.isPending){const e=o.clientX-E.startX,i=o.clientY-E.startY;Math.sqrt(e*e+i*i)>=ir&&sr(ue);return}if(!E.isDragging)return;const t=ar(ue,o.clientX,o.clientY);t&&(t.rowIndex!==E.currentRowIndex||t.colIndex!==E.currentColIndex)&&(E.currentRowIndex=t.rowIndex,E.currentColIndex=t.colIndex,xo(ue))}function sr(o){E.isPending=!1,E.isDragging=!0;const t=o.shadow.querySelector(".wg");t==null||t.classList.add("wg--filling"),lr(o)}function lr(o){const t=o.shadow.querySelector(".wg");if(!t)return;const e=document.createElement("div");e.className="wg__fill-range",t.appendChild(e),E.rangeElement=e,xo(o)}function xo(o){if(!E.rangeElement)return;const t=o.shadow.querySelector(".wg");if(!t)return;const{startRowIndex:e,startColIndex:i,currentRowIndex:n,currentColIndex:r}=E,s=Math.min(e,n),l=Math.max(e,n),a=Math.min(i,r),d=Math.max(i,r),g=o.shadow.querySelector(`[data-row="${s}"][data-col="${a}"]`),u=o.shadow.querySelector(`[data-row="${l}"][data-col="${d}"]`);if(!g||!u)return;const c=t.getBoundingClientRect(),h=g.getBoundingClientRect(),f=u.getBoundingClientRect(),w=t.scrollLeft,p=t.scrollTop,m=h.left-c.left+w,y=h.top-c.top+p,_=f.right-h.left,S=f.bottom-h.top;E.rangeElement.style.left=`${m}px`,E.rangeElement.style.top=`${y}px`,E.rangeElement.style.width=`${_}px`,E.rangeElement.style.height=`${S}px`}function ko(o){if(!ue)return;const t=ue;if(E.isPending){Ot(t);return}E.isDragging&&(cr(t),Ot(t))}function Do(o){o.key==="Escape"&&ue&&(o.preventDefault(),Ot(ue))}function ar(o,t,e){if(!o.shadow.querySelector(".wg"))return null;const n=o.shadow.querySelectorAll(".wg__cell[data-row][data-col]");for(const r of n){const s=r.getBoundingClientRect();if(t>=s.left&&t<=s.right&&e>=s.top&&e<=s.bottom){const l=parseInt(r.dataset.row||"-1",10),a=parseInt(r.dataset.col||"-1",10);if(l>=0&&a>=0)return{rowIndex:l,colIndex:a}}}return null}function dr(o,t,e,i){const n=e-o,r=i-t;return n===0&&r===0?"down":Math.abs(n)>=Math.abs(r)?n>0?"down":"up":r>0?"right":"left"}async function cr(o){var y,_;const{startRowIndex:t,startColIndex:e,currentRowIndex:i,currentColIndex:n,startField:r}=E,s=o.grid.visualColumns,l=(y=s[e])==null?void 0:y.column;if(!l)return;const a=o.grid.getRowDraft(t)??o.grid.displayItems[t];if(!a)return;const d=a[r],g=dr(t,e,i,n),u=l.fillDirection??o.grid.fillDirection,c=[],h=Math.min(t,i),f=Math.max(t,i),w=u==="vertical"?e:Math.min(e,n),p=u==="vertical"?e:Math.max(e,n);for(let S=h;S<=f;S++)for(let v=w;v<=p;v++){if(S===t&&v===e)continue;const C=(_=s[v])==null?void 0:_.column;if(!C)continue;const x=String(C.field);!o.grid.displayItems[S]||!(C.isEditable!==!1&&o.grid.isEditable)||nr(d,C)&&c.push({rowIndex:S,colIndex:v,field:x})}if(c.length===0)return;const m={sourceCell:{rowIndex:t,colIndex:e,field:r,value:d},targetCells:c,direction:g};if(!(o.grid.fillDragCallback&&o.grid.fillDragCallback(m)===!1))for(const S of c)await o.grid.commitEdit(S.rowIndex,S.field,d),j(o,S.rowIndex,S.colIndex)}function Ot(o){E.rangeElement&&(E.rangeElement.remove(),E.rangeElement=null);const t=o.shadow.querySelector(".wg");t==null||t.classList.remove("wg--filling"),document.removeEventListener("mousemove",So),document.removeEventListener("mouseup",ko),document.removeEventListener("keydown",Do),E={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startField:"",startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,handleElement:E.handleElement,rangeElement:null},ue=null}function De(o,t,e,i){var r;B(o);const n=document.createElement("div");if(n.className="wg__dropdown",n.style.cssText=`
499
+ position: fixed;
500
+ top: 0;
501
+ left: 0;
502
+ max-height: 200px;
503
+ overflow-y: auto;
504
+ z-index: 1000;
505
+ `,e.length===0){const s=o.isSearching?i.searchingText||o.grid.labels.dropdownSearching:i.noOptionsText||o.grid.labels.dropdownNoOptions;n.innerHTML=`<div class="wg__dropdown-empty">${o.escapeHtml(s)}</div>`}else{const s=o.grid.editingCell,l=s?(r=o.grid.displayItems[s.rowIndex])==null?void 0:r[s.field]:void 0,a=o.getCurrentEditingColumn(),d=(a==null?void 0:a.horizontalAlign)||"left";n.innerHTML=e.map((g,u)=>{const c=u===o.highlightedIndex,h=ke(g,i)===l,f=We(g,i);if(i.renderOptionCallback){const v={index:u,isHighlighted:c,isSelected:h,isDisabled:f};return i.renderOptionCallback(g,v)}const w=Ne(g,i),p=xn(g,i),m=kn(g,i),y=["wg__dropdown-option",`wg__dropdown-option--align-${d}`];c&&y.push("wg__dropdown-option--highlighted"),h&&y.push("wg__dropdown-option--selected"),f&&y.push("wg__dropdown-option--disabled");const _=p?`<span class="wg__dropdown-option-icon">${o.escapeHtml(p)}</span>`:"",S=m?`<span class="wg__dropdown-option-subtitle">${o.escapeHtml(m)}</span>`:"";return`<div class="${y.join(" ")}" data-index="${u}" ${f?'data-disabled="true"':""}>
506
+ ${_}
507
+ <div class="wg__dropdown-option-content">
508
+ <span class="wg__dropdown-option-label">${o.escapeHtml(w)}</span>
509
+ ${S}
510
+ </div>
511
+ </div>`}).join("")}return o.shadow.appendChild(n),o.dropdownOpen=!0,rt(),Ae(t,n,{strategy:"fixed",placement:"bottom-start",middleware:[mt(1),Le({fallbackPlacements:["top-start"]}),Ui({apply({rects:s}){Object.assign(n.style,{minWidth:i.dropdownMinWidth||`${s.reference.width}px`})}})]}).then(({x:s,y:l})=>{Object.assign(n.style,{left:`${s}px`,top:`${l}px`})}),n}function B(o){const t=o.shadow.querySelector(".wg__dropdown");t==null||t.remove(),o.dropdownOpen=!1,o.highlightedIndex=-1,o.filterText=""}function Ro(o,t,e=!0){const i=o.dropdownOptions[t];if(!i)return;const n=o.grid.editingCell;if(!n)return;const r=o.getCurrentEditorOptions();if(We(i,r))return;const s=ke(i,r),l=o.grid.columns.findIndex(d=>String(d.field)===n.field),a=o.grid.displayItems[n.rowIndex];r.onselect&&a&&r.onselect(i,a),o.justSelected=!0,o.isCommittingFromKeyboard=!0,B(o),o.grid.commitEdit(n.rowIndex,n.field,s),e?o.moveFocusAfterCommit(n.rowIndex,n.field,"down"):j(o,n.rowIndex,l),requestAnimationFrame(()=>{o.justSelected=!1})}function pe(o){const t=o.shadow.querySelector(".wg__dropdown");if(!t)return;t.querySelectorAll(".wg__dropdown-option").forEach((i,n)=>{i.classList.toggle("wg__dropdown-option--highlighted",n===o.highlightedIndex)})}function Eo(o){const t=o.shadow.querySelector(".wg__dropdown-option--highlighted");t==null||t.scrollIntoView({block:"nearest"})}function Pt(o,t){const e=o.shadow.querySelector(".wg__loading-indicator");e&&(e.style.display=t?"inline":"none");const i=o.shadow.querySelector(".wg__editor--autocomplete .wg__combobox-toggle");i&&(i.style.display=t?"none":"inline")}function re(o){if(o.justSelected)return;const t=o.getCurrentEditingColumn();if(!t)return;const e=t.editorOptions||{},i=t.editor;let n=0;if(i==="select"){const d=e.options||[];if(o.filterText){const g=o.filterText.toLowerCase();o.dropdownOptions=d.filter(u=>Ne(u,e).toLowerCase().includes(g)),n=o.dropdownOptions.length>0?0:-1}else{o.dropdownOptions=d;const g=o.grid.editingCell;if(g){const u=o.grid.displayItems[g.rowIndex],c=u?u[g.field]:void 0,h=o.dropdownOptions.findIndex(f=>ke(f,e)===c);n=h>=0?h:0}else n=o.dropdownOptions.length>0?0:-1}}else if(i==="combobox"||i==="autocomplete"){const d=i==="autocomplete"?e.initialOptions||e.options||[]:e.options||[],g=o.grid.editingCell;let u;if(g){const h=o.grid.displayItems[g.rowIndex];u=h?h[g.field]:void 0}const c=d.findIndex(h=>ke(h,e)===u);if(c>=0)o.dropdownOptions=d,n=c;else if(u!=null&&u!==""){const h=e.valueMember||"value",f=e.displayMember||"label",w=String(u),p={value:u,label:w,[h]:u,[f]:w};o.dropdownOptions=[p,...d],n=0}else o.dropdownOptions=d,n=d.length>0?0:-1}const r=o.grid.editingCell;if(!r)return;const{rowIndex:s,field:l}=r,a=o.shadow.querySelector(`.wg__editor--select[data-row="${s}"][data-field="${l}"],
512
+ .wg__editor--combobox[data-row="${s}"][data-field="${l}"],
513
+ .wg__editor--autocomplete[data-row="${s}"][data-field="${l}"]`);if(a&&o.dropdownOptions.length>0){const d=o.filterText;o.isOpeningDropdown=!0;const g=De(o,a,o.dropdownOptions,e);Re(o,g),o.filterText=d,o.highlightedIndex=n,pe(o);const u=o.shadow.querySelector(`.wg__select-trigger[data-row="${s}"][data-field="${l}"]`),c=o.shadow.querySelector(`.wg__combobox-input[data-row="${s}"][data-field="${l}"],
514
+ .wg__autocomplete-input[data-row="${s}"][data-field="${l}"]`),h=u||c;h&&h.focus(),requestAnimationFrame(()=>{o.isOpeningDropdown=!1})}}function Mo(o){o.dropdownOpen?B(o):re(o)}function Re(o,t){t.addEventListener("mousedown",e=>{e.preventDefault();const i=e.target.closest(".wg__dropdown-option");if(i&&!i.hasAttribute("data-disabled")){const n=parseInt(i.getAttribute("data-index")||"0",10);Ro(o,n,!1)}}),t.addEventListener("mouseover",e=>{const i=e.target.closest(".wg__dropdown-option");i&&!i.hasAttribute("data-disabled")&&(o.highlightedIndex=parseInt(i.getAttribute("data-index")||"0",10),pe(o))})}function $o(o,t){const e=t.options||[],i=o.filterText.toLowerCase(),n=o.filterText;o.dropdownOptions=e.filter(s=>Ne(s,t).toLowerCase().includes(i)),o.highlightedIndex=o.dropdownOptions.length>0?0:-1;const r=o.shadow.querySelector(".wg__editor--select");if(r){const s=De(o,r,o.dropdownOptions,t);Re(o,s),o.filterText=n,o.dropdownOptions.length>0&&(o.highlightedIndex=0,pe(o))}}function gr(o,t){const e=t.target;o.filterText=e.value,o.isUserFiltering=!0;const i=o.getCurrentEditingColumn();if(!i)return;const n=i.editorOptions||{},r=n.options||[];if(o.filterText.trim()){const l=o.filterText.toLowerCase();o.dropdownOptions=r.filter(a=>Ne(a,n).toLowerCase().includes(l))}else o.dropdownOptions=r;o.highlightedIndex=o.dropdownOptions.length>0?0:-1;const s=e.closest(".wg__editor--combobox");if(s){const l=De(o,s,o.dropdownOptions,n);Re(o,l),o.highlightedIndex=o.dropdownOptions.length>0?0:-1,pe(o)}}function ur(o,t){const e=t.target;o.filterText=e.value;const i=o.getCurrentEditingColumn();if(!i)return;const n=i.editorOptions||{},r=n.debounceMs??300,s=n.minSearchLength??1;o.searchDebounceTimer&&clearTimeout(o.searchDebounceTimer);const l=e.closest(".wg__editor--autocomplete");if(!o.dropdownOpen&&l){o.dropdownOptions=n.initialOptions||[];const a=De(o,l,o.dropdownOptions,n);Re(o,a),o.highlightedIndex=o.dropdownOptions.length>0?0:-1,pe(o)}if(o.filterText.length<s){if(o.dropdownOptions=n.initialOptions||[],l){const a=De(o,l,o.dropdownOptions,n);Re(o,a),o.highlightedIndex=o.dropdownOptions.length>0?0:-1,pe(o)}return}o.searchDebounceTimer=setTimeout(()=>{hr(o,o.filterText,i)},r)}async function hr(o,t,e){const i=e.editorOptions||{};if(!i.searchCallback)return;o.searchAbortController&&o.searchAbortController.abort(),o.searchAbortController=new AbortController;const n=o.searchAbortController.signal;o.isSearching=!0,Pt(o,!0);try{const r=o.grid.editingCell;if(!r)return;const s=o.grid.displayItems[r.rowIndex],l=await i.searchCallback(t,s,n);if(!n.aborted){o.isSearching=!1,Pt(o,!1),o.dropdownOptions=l;const{rowIndex:a,field:d}=r,g=o.shadow.querySelector(`.wg__editor--autocomplete[data-row="${a}"][data-field="${d}"]`);if(g){const u=De(o,g,o.dropdownOptions,i);Re(o,u),o.highlightedIndex=l.length>0?0:-1,pe(o)}}}catch(r){if(r instanceof Error&&r.name==="AbortError")return;console.error("Autocomplete search failed:",r),o.isSearching=!1,Pt(o,!1),o.dropdownOptions=[];const s=o.grid.editingCell;if(s){const{rowIndex:l,field:a}=s,d=o.shadow.querySelector(`.wg__editor--autocomplete[data-row="${l}"][data-field="${a}"]`);if(d){const g=De(o,d,o.dropdownOptions,i);Re(o,g)}}}}function Vt(o,t,e,i,n){const r=i??o.tooltipShowDelay;o.tooltipHideTimer&&(clearTimeout(o.tooltipHideTimer),o.tooltipHideTimer=null),!(o.tooltipElement&&o.tooltipAnchor===t)&&(o.tooltipShowTimer&&clearTimeout(o.tooltipShowTimer),o.tooltipShowTimer=setTimeout(()=>{fr(o,t,e,n)},r))}function Io(o,t){const e=t??o.tooltipHideDelay;o.tooltipShowTimer&&(clearTimeout(o.tooltipShowTimer),o.tooltipShowTimer=null),o.tooltipElement&&(o.tooltipHideTimer=setTimeout(()=>{o.tooltipElement&&(o.tooltipElement.classList.remove("wg__tooltip--visible"),setTimeout(()=>{var i;(i=o.tooltipElement)==null||i.remove(),o.tooltipElement=null,o.tooltipArrowElement=null,o.tooltipAnchor=null},100))},e))}function fr(o,t,e,i){var l;(l=o.tooltipElement)==null||l.remove();const n=document.createElement("div");n.className="wg__tooltip";const r=document.createElement("div");r.className="wg__tooltip-content",i?r.innerHTML=e:r.textContent=e,n.appendChild(r);const s=document.createElement("div");s.className="wg__tooltip-arrow",n.appendChild(s),o.shadow.appendChild(n),o.tooltipElement=n,o.tooltipArrowElement=s,o.tooltipAnchor=t,Ae(t,n,{strategy:"fixed",placement:"top",middleware:[mt(8),Le({fallbackPlacements:["bottom","left","right"]}),ji({element:s})]}).then(({x:a,y:d,placement:g,middlewareData:u})=>{if(n.style.left=`${a}px`,n.style.top=`${d}px`,n.setAttribute("data-placement",g),u.arrow){const{x:c,y:h}=u.arrow;c!=null&&(s.style.left=`${c}px`),h!=null&&(s.style.top=`${h}px`)}requestAnimationFrame(()=>{n.classList.add("wg__tooltip--visible")})})}const wr=`
509
515
  .wg-context-menu-container {
510
516
  position: fixed;
511
517
  z-index: var(--wg-cm-z-index, 10000);
@@ -634,10 +640,10 @@
634
640
  .wg-context-menu__item--toggle.wg-context-menu__item--checked .wg-context-menu__icon {
635
641
  opacity: 1;
636
642
  }
637
- `;let vo=!1;function yo(){if(vo)return;const o=document.createElement("style");o.id="wg-context-menu-styles",o.textContent=jr,document.head.appendChild(o),vo=!0}function Kr(o,e){const t=o.filter(r=>r.visible===void 0?!0:typeof r.visible=="function"?r.visible(e):r.visible);return t.length===0?"":`<div class="wg-context-menu">${t.map((r,n)=>{const s=typeof r.label=="function"?r.label(e):r.label,a=typeof r.icon=="function"?r.icon(e):r.icon,l=r.shortcut,d=typeof r.disabled=="function"?r.disabled(e):r.disabled,g=r.danger===!0,u=["wg-context-menu__item",d?"wg-context-menu__item--disabled":"",g?"wg-context-menu__item--danger":""].filter(Boolean).join(" "),c=r.dividerBefore&&n>0?'<div class="wg-context-menu__divider"></div>':"",h=a?`<span class="wg-context-menu__icon">${a}</span>`:"",f=l?`<span class="wg-context-menu__shortcut">${l}</span>`:"";return`${c}<div class="${u}" data-item-id="${r.id}" data-disabled="${d?"true":"false"}" data-shortcut="${l||""}">${h}<span class="wg-context-menu__label">${s}</span>${f}</div>`}).join("")}</div>`}function Xr(o,e,t,i,r,n,s,a,l){yo();const d=Kr(n,s);if(!d)return null;const g=document.createElement("div");g.className="wg-context-menu-container",g.innerHTML=d,document.body.appendChild(g);const u=g.querySelector(".wg-context-menu"),c=e+i,h=t+r;Le({getBoundingClientRect:()=>({width:0,height:0,x:c,y:h,top:h,left:c,right:c,bottom:h})},u,{placement:"bottom-start",middleware:[Ie({fallbackPlacements:["top-start","bottom-end","top-end"]}),Ze({padding:8})]}).then(({x:m,y})=>{Object.assign(u.style,{left:`${m}px`,top:`${y}px`})}),g.addEventListener("click",m=>{const y=m.target.closest(".wg-context-menu__item");if(y&&y.dataset.disabled!=="true"){const _=y.dataset.itemId||"";a(_)}});const p=m=>{g.contains(m.target)||(J(g,p,v),l())},v=m=>{if(m.key==="Escape"){m.preventDefault(),J(g,p,v),l();return}const y=m.key.toLowerCase(),_=g.querySelectorAll(".wg-context-menu__item");for(const S of _){const b=S.dataset.shortcut;if(S.dataset.disabled==="true"||!b)continue;if(b.toLowerCase()===y||b===m.key){m.preventDefault();const k=S.dataset.itemId||"";a(k),J(g,p,v),l();return}}};return setTimeout(()=>{document.addEventListener("mousedown",p),document.addEventListener("keydown",v)},0),g._cleanup={handleOutsideClick:p,handleKeyDown:v},g}function J(o,e,t){e&&document.removeEventListener("mousedown",e),t&&document.removeEventListener("keydown",t);const i=o._cleanup;i&&(i.handleOutsideClick&&document.removeEventListener("mousedown",i.handleOutsideClick),i.handleKeyDown&&document.removeEventListener("keydown",i.handleKeyDown)),o.remove()}const Gr={sortAsc:{icon:"↑",labelKey:"sortAsc"},sortDesc:{icon:"↓",labelKey:"sortDesc"},clearSort:{icon:"✕",labelKey:"clearSort"},hideColumn:{icon:"👁",labelKey:"hideColumn"},freezeColumn:{icon:"❄",labelKey:"freezeColumn"},unfreezeColumn:{icon:"☀",labelKey:"unfreezeColumn"},columnVisibility:{icon:"👁",labelKey:"columnVisibility",hasSubmenu:!0}};function Co(o,e){const t=[];let i=!1;for(let r=0;r<o.length;r++){const n=o[r];if(typeof n=="string"){const s=Gr[n];if(!s){console.warn(`Unknown predefined header menu action: ${n}`);continue}let a=!0;n==="sortAsc"||n==="sortDesc"?a=d=>d.column.sortable!==!1:n==="clearSort"?a=d=>d.sortDirection!==null:n==="freezeColumn"?a=d=>!d.isFrozen:n==="unfreezeColumn"&&(a=d=>d.isFrozen);let l;n==="columnVisibility"&&(l=d=>{const u=[{id:"show-all-columns",icon:d.allColumns.every(c=>!c.hidden)?"☑":"☐",label:d.labels.contextMenu.showAll,onclick:()=>{d.allColumns.forEach(c=>{c.hidden=!1})}}];return d.allColumns.forEach(c=>{u.push({id:`toggle-col-${String(c.field)}`,icon:c.hidden?"☐":"☑",label:c.title||String(c.field),onclick:()=>{c.hidden=!c.hidden}})}),u}),t.push({id:n,icon:s.icon,label:e.labels.contextMenu[s.labelKey],danger:s.danger,visible:a,dividerBefore:i,submenu:l}),i=!1}else n.dividerBefore&&!n.id&&!n.label?i=!0:(t.push({id:n.id||`header-menu-item-${r}`,...n,dividerBefore:i||n.dividerBefore}),i=!1)}return t}function So(o,e,t,i=!1){var y,_;const r=typeof o.label=="function"?o.label(e):o.label,n=typeof o.icon=="function"?o.icon(e):o.icon,s=o.shortcut,a=typeof o.disabled=="function"?o.disabled(e):o.disabled,l=o.danger===!0,d=((y=o.children)==null?void 0:y.length)||o.submenu,g=o.children||(o.submenu?o.submenu(e):[]);let u="";d&&g.length>0&&(u=`<div class="wg-context-menu wg-context-menu--submenu">${g.map((b,C)=>So(b,e,C,!0)).join("")}</div>`);const c=i&&((_=o.id)==null?void 0:_.startsWith("toggle-col-")),f=["wg-context-menu__item",a?"wg-context-menu__item--disabled":"",l?"wg-context-menu__item--danger":"",d?"wg-context-menu__item--has-submenu":"",c?"wg-context-menu__item--toggle":"",c&&n==="☑"?"wg-context-menu__item--checked":""].filter(Boolean).join(" "),p=o.dividerBefore&&t>0?'<div class="wg-context-menu__divider"></div>':"",v=n?`<span class="wg-context-menu__icon">${n}</span>`:"",m=s?`<span class="wg-context-menu__shortcut">${s}</span>`:"";return`${p}<div class="${f}" data-item-id="${o.id}" data-disabled="${a?"true":"false"}" data-shortcut="${s||""}">${v}<span class="wg-context-menu__label">${r}</span>${m}${u}</div>`}function xo(o,e){const t=o.filter(r=>r.visible===void 0?!0:typeof r.visible=="function"?r.visible(e):r.visible);return t.length===0?"":`<div class="wg-context-menu">${t.map((r,n)=>So(r,e,n)).join("")}</div>`}function Qr(o,e,t,i=!1){const{field:r,columnIndex:n}=t;switch(e){case"sortAsc":case"sortDesc":{const s=e==="sortAsc"?"asc":"desc",a=[...o.grid.sort];if(i&&o.grid.sortMode==="multi"){const l=a.findIndex(d=>d.column===r);l>=0?a[l]={column:r,direction:s}:a.push({column:r,direction:s}),o.grid.sort=a}else o.grid.sort=[{column:r,direction:s}];break}case"clearSort":o.grid.sort=o.grid.sort.filter(s=>s.column!==r);break;case"hideColumn":{const s=o.grid.columns.find(a=>String(a.field)===r);s&&(s.hidden=!0,o.grid.columns=[...o.grid.columns]);break}case"freezeColumn":o.grid.freezeColumns=n+1;break;case"unfreezeColumn":o.grid.freezeColumns=Math.max(0,n);break}}function ko(o,e,t,i,r,n,s){yo();const a=xo(i,r);if(!a)return null;const l=document.createElement("div");l.className="wg-context-menu-container",l.innerHTML=a,document.body.appendChild(l);let d=l.querySelector(".wg-context-menu");Le({getBoundingClientRect:()=>({width:0,height:0,x:e,y:t,top:t,left:e,right:e,bottom:t})},d,{placement:"bottom-start",middleware:[Ie({fallbackPlacements:["top-start","bottom-end","top-end"]}),Ze({padding:8})]}).then(({x:p,y:v})=>{Object.assign(d.style,{left:`${p}px`,top:`${v}px`})}),l.addEventListener("click",p=>{const v=p.target.closest(".wg-context-menu__item");if(!v||v.dataset.disabled==="true")return;const m=v.dataset.itemId||"",y=p.ctrlKey;if(!v.classList.contains("wg-context-menu__item--has-submenu")){if(m.startsWith("toggle-col-")||m==="show-all-columns"){n(m,!0,y);const _=xo(i,r),S=document.createElement("div");S.innerHTML=_;const b=S.querySelector(".wg-context-menu");if(b&&d.parentNode){b.style.left=d.style.left,b.style.top=d.style.top,d.parentNode.replaceChild(b,d),d=b;const C=b.querySelector(".wg-context-menu--submenu");C&&(C.style.display="block")}return}n(m,!1,y)}});const u=()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",f),window.removeEventListener("scroll",h,!0),l.remove()},c=p=>{l.contains(p.target)||(u(),s())},h=()=>{u(),s()},f=p=>{if(p.key==="Escape"){p.preventDefault(),u(),s();return}const v=p.key.toLowerCase(),m=l.querySelectorAll(".wg-context-menu__item");for(const y of m){const _=y.dataset.shortcut;if(y.dataset.disabled==="true"||!_)continue;if(_.toLowerCase()===v||_===p.key){p.preventDefault();const C=y.dataset.itemId||"";n(C),u(),s();return}}};return setTimeout(()=>{document.addEventListener("mousedown",c),document.addEventListener("keydown",f),window.addEventListener("scroll",h,!0)},0),l._cleanup=u,l}function Ne(o){const e=o.split("+").map(i=>i.trim()),t={key:"",ctrl:!1,shift:!1,alt:!1,meta:!1};for(const i of e){const r=i.toLowerCase();r==="ctrl"||r==="control"?t.ctrl=!0:r==="shift"?t.shift=!0:r==="alt"?t.alt=!0:r==="meta"||r==="cmd"||r==="command"?t.meta=!0:t.key=i}return t}function Ye(o,e){if(e.ctrl!==o.ctrlKey||e.shift!==o.shiftKey||e.alt!==o.altKey||e.meta!==o.metaKey)return!1;const t=o.key.toLowerCase(),i=e.key.toLowerCase();return t===i}function Jr(o){return o.split("+").map(e=>{const t=e.trim();return["ctrl","control","shift","alt","meta","cmd","command"].includes(t.toLowerCase())?t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():t}).join("+")}function Zr(o){const{scrollTop:e,viewportHeight:t,rowHeight:i,buffer:r,totalItems:n,editingRowIndex:s}=o;let a=Math.max(0,Math.floor(e/i)-r);const l=Math.ceil(t/i)+r*2;let d=Math.min(n,a+l);return s!==void 0&&(s<a&&(a=s),s>=d&&(d=s+1)),{startIndex:a,endIndex:d}}function en(o){const{targetRow:e,rowHeight:t,buffer:i,totalItems:r,viewportHeight:n,scrollHeight:s,clientHeight:a}=o,l=Math.max(0,(e-1)*t),d=Math.max(0,s-a),g=Math.min(l,d);let u=Math.max(0,Math.floor(g/t)-i);const c=Math.ceil(n/t)+i*2;let h=Math.min(r,u+c);return e<u&&(u=e),e>=h&&(h=e+1),{scrollTop:g,startIndex:u,endIndex:h}}function tn(o,e,t,i){return e-(o+t)<=i}function on(o,e){const i=e.target.closest(".wg__header--sortable");if(!i)return;const r=i.dataset.field;if(!r)return;const n=[...o.grid.sort],s=n.findIndex(l=>l.column===r);(e.ctrlKey||e.metaKey)&&o.grid.sortMode==="multi"?s>=0?n[s].direction==="asc"?n[s]={column:r,direction:"desc"}:n.splice(s,1):n.push({column:r,direction:"asc"}):s>=0&&n.length===1?n[0].direction==="asc"?n[0]={column:r,direction:"desc"}:n.length=0:(n.length=0,n.push({column:r,direction:"asc"})),o.grid.sort=n,o.grid.pageable&&(o.grid.currentPage=1),o.grid.fireDataRequest("sort")}function rn(o,e){const i=e.target.closest(".wg__pagination-btn");if(!i||i.hasAttribute("disabled"))return!1;const r=i.dataset.action;let n=!1;return r==="first"&&o.grid.currentPage!==1?(o.grid.currentPage=1,n=!0):r==="prev"&&o.grid.currentPage>1?(o.grid.currentPage--,n=!0):r==="next"&&o.grid.currentPage<o.grid.totalPages?(o.grid.currentPage++,n=!0):r==="last"&&o.grid.currentPage!==o.grid.totalPages&&(o.grid.currentPage=o.grid.totalPages,n=!0),n&&o.grid.fireDataRequest("page"),n}function nn(o,e){const t=parseInt(e.value,10);return t!==o.grid.pageSize?(o.grid.pageSize=t,o.grid.currentPage=1,o.grid.fireDataRequest("pageSize"),!0):!1}let P={isResizing:!1,startX:0,startWidth:0,field:"",headerCell:null,minWidth:30,maxWidth:null},he=null;function Do(o,e){if(!o)return e;const t=parseFloat(o);return isNaN(t)?e:t}function sn(o,e,t){const i=e.target,r=i.closest(".wg__header");if(!r)return;const n=o.grid.columns.find(l=>String(l.field)===t);if(!n||n.resizable===!1)return;const s=r.getBoundingClientRect().width;P={isResizing:!0,startX:e.clientX,startWidth:s,field:t,headerCell:r,minWidth:Do(n.minWidth,30),maxWidth:n.maxWidth?Do(n.maxWidth,1/0):null},he=o,n.minWidth?r.style.minWidth=n.minWidth:r.style.minWidth=`${P.minWidth}px`;const a=o.shadow.querySelector(".wg");a==null||a.classList.add("wg--resizing"),i.classList.add("wg__resize-handle--active"),document.addEventListener("mousemove",Eo),document.addEventListener("mouseup",Ro),e.preventDefault()}function Eo(o){if(!P.isResizing||!he)return;const e=o.clientX-P.startX;let t=P.startWidth+e;t=Math.max(t,P.minWidth),P.maxWidth!==null&&(t=Math.min(t,P.maxWidth)),P.headerCell&&(P.headerCell.style.width=`${t}px`,P.headerCell.style.maxWidth=`${t}px`),ln(he,P.field,`${t}px`),(he.grid.freezeColumns>0||he.grid.stickyRowNumbers)&&dn(he)}function Ro(o){if(!P.isResizing||!he)return;const e=he,t=P.field,i=`${P.startWidth}px`,r=o.clientX-P.startX;let n=P.startWidth+r;n=Math.max(n,P.minWidth),P.maxWidth!==null&&(n=Math.min(n,P.maxWidth));const s=`${n}px`;e.grid.setColumnWidth(t,s,!0);const a=e.shadow.querySelector(`col[data-field="${t}"]`);a&&(a.style.width=s);const l=e.shadow.querySelector(".wg");l==null||l.classList.remove("wg--resizing");const d=e.shadow.querySelector(".wg__resize-handle--active");d==null||d.classList.remove("wg__resize-handle--active"),e.grid.oncolumnresize&&e.grid.oncolumnresize({field:t,oldWidth:i,newWidth:s,allWidths:e.grid.getColumnWidthsState()}),e.grid.persistColumnWidths&&e.grid.gridName&&e.grid.savePersistedWidths(),document.removeEventListener("mousemove",Eo),document.removeEventListener("mouseup",Ro),P={isResizing:!1,startX:0,startWidth:0,field:"",headerCell:null,minWidth:30,maxWidth:null},he=null}function ln(o,e,t){o.shadow.querySelectorAll(`td[data-field="${e}"]`).forEach(r=>{r.style.width=t,r.style.maxWidth=t})}const an=40;function dn(o){const e=o.grid.freezeColumns;let i=o.grid.showRowNumbers&&o.grid.stickyRowNumbers?an:0;const r=o.grid.visualColumns;for(let n=0;n<e&&n<r.length;n++){const{column:s}=r[n],a=String(s.field),l=o.shadow.querySelector(`th[data-field="${a}"]`);l&&(l.style.left=`${i}px`,o.shadow.querySelectorAll(`td[data-field="${a}"]`).forEach(g=>{g.style.left=`${i}px`}),i+=l.getBoundingClientRect().width)}}const cn=5;let $={isPending:!1,isReordering:!1,field:"",startX:0,startY:0,headerCell:null,ghost:null,dropIndicator:null,fromIndex:-1,currentDropIndex:-1},fe=null,Lt=!1;function gn(){return Lt?(Lt=!1,!0):$.isReordering}function un(o,e,t){const i=e.target,r=i.closest(".wg__header");if(!r||i.classList.contains("wg__resize-handle"))return;const n=o.grid.visualColumns,s=o.grid.totalFrozenColumns,a=n.findIndex(d=>String(d.column.field)===t);if(a<s)return;const l=a-s;$={isPending:!0,isReordering:!1,field:t,startX:e.clientX,startY:e.clientY,headerCell:r,ghost:null,dropIndicator:null,fromIndex:l,currentDropIndex:l},fe=o,document.addEventListener("mousemove",$o),document.addEventListener("mouseup",Mo),e.preventDefault()}function hn(o,e,t){var r;const i=document.createElement("div");i.className="wg__reorder-ghost",i.textContent=((r=e.querySelector(".wg__header-title"))==null?void 0:r.textContent)||"",i.style.left=`${t.clientX+10}px`,i.style.top=`${t.clientY-10}px`,o.shadow.appendChild(i),$.ghost=i}function fn(o){var t;const e=document.createElement("div");e.className="wg__drop-indicator",(t=o.shadow.querySelector(".wg"))==null||t.appendChild(e),$.dropIndicator=e}function wn(o,e){$.isPending=!1,$.isReordering=!0;const t=o.shadow.querySelector(".wg");t==null||t.classList.add("wg--reordering"),$.headerCell&&$.headerCell.classList.add("wg__header--dragging"),$.headerCell&&hn(o,$.headerCell,e),fn(o)}function $o(o){if(!fe)return;if($.isPending){const i=o.clientX-$.startX,r=o.clientY-$.startY;Math.sqrt(i*i+r*r)>=cn&&wn(fe,o);return}if(!$.isReordering||!fe.shadow.querySelector(".wg"))return;$.ghost&&($.ghost.style.left=`${o.clientX+10}px`,$.ghost.style.top=`${o.clientY-10}px`);const t=pn(fe,o.clientX);t!==$.currentDropIndex&&($.currentDropIndex=t,mn(fe,t))}function pn(o,e){const t=o.grid.visualColumns,i=o.grid.totalFrozenColumns,r=t.slice(i);if(r.length===0)return 0;const n=String(r[0].column.field),s=o.shadow.querySelector(`th[data-field="${n}"]`);if(s){const a=s.getBoundingClientRect();if(e<a.left)return 0}for(let a=0;a<r.length;a++){const l=String(r[a].column.field),d=o.shadow.querySelector(`th[data-field="${l}"]`);if(d){const g=d.getBoundingClientRect(),u=g.left+g.width/2;if(e<u)return a}}return r.length}function mn(o,e){const t=$.dropIndicator;if(!t)return;const i=o.grid.visualColumns,r=o.grid.totalFrozenColumns,n=i.slice(r),s=o.shadow.querySelector(".wg"),a=s==null?void 0:s.getBoundingClientRect();if(!a||!s)return;let l;if(e>=n.length){const u=String(n[n.length-1].column.field),c=o.shadow.querySelector(`th[data-field="${u}"]`);if(c)l=c.getBoundingClientRect().right-a.left+s.scrollLeft;else return}else{const u=String(n[e].column.field),c=o.shadow.querySelector(`th[data-field="${u}"]`);if(c)l=c.getBoundingClientRect().left-a.left+s.scrollLeft;else return}const d=s.scrollTop,g=s.clientHeight;t.style.left=`${l}px`,t.style.top=`${d}px`,t.style.height=`${g}px`,t.style.display="block"}function Mo(o){if(!fe)return;const e=fe;if($.isPending){To(e);return}if(!$.isReordering)return;const t=$.field,i=$.fromIndex,r=$.currentDropIndex;if(i!==r&&r!==i+1){const n=r>i?r-1:r;e.grid.moveColumn(t,n),e.grid.oncolumnreorder&&e.grid.oncolumnreorder({field:t,fromIndex:i,toIndex:n,allOrder:e.grid.getColumnOrderState()}),e.grid.persistColumnOrder&&e.grid.gridName&&e.grid.savePersistedState()}Lt=!0,To(e)}function To(o){$.ghost&&$.ghost.remove(),$.dropIndicator&&$.dropIndicator.remove();const e=o.shadow.querySelector(".wg");e==null||e.classList.remove("wg--reordering"),$.headerCell&&$.headerCell.classList.remove("wg__header--dragging"),document.removeEventListener("mousemove",$o),document.removeEventListener("mouseup",Mo),$={isPending:!1,isReordering:!1,field:"",startX:0,startY:0,headerCell:null,ghost:null,dropIndicator:null,fromIndex:-1,currentDropIndex:-1},fe=null}const bn=5;function _n(o,e){var i,r;switch(e.editor||"text"){case"number":return typeof o=="number"&&!isNaN(o);case"select":case"combobox":{const n=(i=e.editorOptions)==null?void 0:i.options;if(!n||n.length===0)return!0;const s=((r=e.editorOptions)==null?void 0:r.valueMember)||"value";return n.some(a=>a[s]===o)}case"date":{if(o==null||o==="")return!0;if(o instanceof Date)return!isNaN(o.getTime());if(typeof o=="string"){if(!/\d{4}[-/]\d{1,2}[-/]\d{1,2}/.test(o)&&!/\d{1,2}[-/.]\d{1,2}[-/.]\d{2,4}/.test(o))return!1;const n=new Date(o);return!isNaN(n.getTime())}if(typeof o=="number"){const n=new Date("2000-01-01").getTime(),s=new Date("2100-01-01").getTime();if(o<n||o>s)return!1;const a=new Date(o);return!isNaN(a.getTime())}return!1}case"text":case"autocomplete":case"checkbox":case"custom":default:return!0}}let R={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startField:"",startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,handleElement:null,rangeElement:null},_e=null;function At(o){const e=o.grid.focusedCell;if(!e||o.grid.editingCell){zo();return}const{rowIndex:t,colIndex:i}=e,r=o.shadow.querySelector(`[data-row="${t}"][data-col="${i}"]`);if(!r){zo();return}const n=o.shadow.querySelector(".wg");if(!n)return;if(!R.handleElement){const h=document.createElement("div");h.className="wg__fill-handle",n.appendChild(h),R.handleElement=h,h.addEventListener("mousedown",f=>vn(o,f))}const s=n.getBoundingClientRect(),a=r.getBoundingClientRect(),l=n.scrollLeft,d=n.scrollTop,g=8,u=a.right-s.left+l-g/2,c=a.bottom-s.top+d-g/2;R.handleElement.style.left=`${u}px`,R.handleElement.style.top=`${c}px`}function zo(){R.handleElement&&(R.handleElement.remove(),R.handleElement=null)}function vn(o,e){var a;e.preventDefault(),e.stopPropagation();const t=o.grid.focusedCell;if(!t)return;const{rowIndex:i,colIndex:r}=t,s=(a=o.grid.visualColumns[r])==null?void 0:a.column;s&&(R={...R,isPending:!0,isDragging:!1,startRowIndex:i,startColIndex:r,startField:String(s.field),startX:e.clientX,startY:e.clientY,currentRowIndex:i,currentColIndex:r},_e=o,document.addEventListener("mousemove",Io),document.addEventListener("mouseup",Ao))}function Io(o){if(!_e)return;if(R.isPending){const t=o.clientX-R.startX,i=o.clientY-R.startY;Math.sqrt(t*t+i*i)>=bn&&yn(_e);return}if(!R.isDragging)return;const e=Sn(_e,o.clientX,o.clientY);e&&(e.rowIndex!==R.currentRowIndex||e.colIndex!==R.currentColIndex)&&(R.currentRowIndex=e.rowIndex,R.currentColIndex=e.colIndex,Lo(_e))}function yn(o){R.isPending=!1,R.isDragging=!0;const e=o.shadow.querySelector(".wg");e==null||e.classList.add("wg--filling"),Cn(o)}function Cn(o){const e=o.shadow.querySelector(".wg");if(!e)return;const t=document.createElement("div");t.className="wg__fill-range",e.appendChild(t),R.rangeElement=t,Lo(o)}function Lo(o){if(!R.rangeElement)return;const e=o.shadow.querySelector(".wg");if(!e)return;const{startRowIndex:t,startColIndex:i,currentRowIndex:r,currentColIndex:n}=R,s=Math.min(t,r),a=Math.max(t,r),l=Math.min(i,n),d=Math.max(i,n),g=o.shadow.querySelector(`[data-row="${s}"][data-col="${l}"]`),u=o.shadow.querySelector(`[data-row="${a}"][data-col="${d}"]`);if(!g||!u)return;const c=e.getBoundingClientRect(),h=g.getBoundingClientRect(),f=u.getBoundingClientRect(),p=e.scrollLeft,v=e.scrollTop,m=h.left-c.left+p,y=h.top-c.top+v,_=f.right-h.left,S=f.bottom-h.top;R.rangeElement.style.left=`${m}px`,R.rangeElement.style.top=`${y}px`,R.rangeElement.style.width=`${_}px`,R.rangeElement.style.height=`${S}px`}function Ao(o){if(!_e)return;const e=_e;if(R.isPending){Oo(e);return}R.isDragging&&(kn(e),Oo(e))}function Sn(o,e,t){if(!o.shadow.querySelector(".wg"))return null;const r=o.shadow.querySelectorAll(".wg__cell[data-row][data-col]");for(const n of r){const s=n.getBoundingClientRect();if(e>=s.left&&e<=s.right&&t>=s.top&&t<=s.bottom){const a=parseInt(n.dataset.row||"-1",10),l=parseInt(n.dataset.col||"-1",10);if(a>=0&&l>=0)return{rowIndex:a,colIndex:l}}}return null}function xn(o,e,t,i){const r=t-o,n=i-e;return r===0&&n===0?"down":Math.abs(r)>=Math.abs(n)?r>0?"down":"up":n>0?"right":"left"}async function kn(o){var y,_;const{startRowIndex:e,startColIndex:t,currentRowIndex:i,currentColIndex:r,startField:n}=R,s=o.grid.visualColumns,a=(y=s[t])==null?void 0:y.column;if(!a)return;const l=o.grid.getRowDraft(e)??o.grid.displayItems[e];if(!l)return;const d=l[n],g=xn(e,t,i,r),u=a.fillDirection??o.grid.fillDirection,c=[],h=Math.min(e,i),f=Math.max(e,i),p=u==="vertical"?t:Math.min(t,r),v=u==="vertical"?t:Math.max(t,r);for(let S=h;S<=f;S++)for(let b=p;b<=v;b++){if(S===e&&b===t)continue;const C=(_=s[b])==null?void 0:_.column;if(!C)continue;const x=String(C.field);!o.grid.displayItems[S]||!(C.editable!==!1&&o.grid.editable)||_n(d,C)&&c.push({rowIndex:S,colIndex:b,field:x})}if(c.length===0)return;const m={sourceCell:{rowIndex:e,colIndex:t,field:n,value:d},targetCells:c,direction:g};if(!(o.grid.onfilldrag&&o.grid.onfilldrag(m)===!1))for(const S of c)await o.grid.commitEdit(S.rowIndex,S.field,d),j(o,S.rowIndex,S.colIndex)}function Oo(o){R.rangeElement&&(R.rangeElement.remove(),R.rangeElement=null);const e=o.shadow.querySelector(".wg");e==null||e.classList.remove("wg--filling"),document.removeEventListener("mousemove",Io),document.removeEventListener("mouseup",Ao),R={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startField:"",startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,handleElement:R.handleElement,rangeElement:null},_e=null}const Dn=5;let se={isPending:!1,isDragging:!1,startRowIndex:-1,startX:0,startY:0,currentRowIndex:-1},ve=null;function En(o,e,t){if(t.preventDefault(),t.stopPropagation(),t.ctrlKey||t.metaKey){o.grid.selectRow(e,"toggle"),requestAnimationFrame(()=>{const i=o.shadow.querySelector(".wg");i==null||i.focus()});return}if(t.shiftKey){o.grid.selectRow(e,"range"),requestAnimationFrame(()=>{const i=o.shadow.querySelector(".wg");i==null||i.focus()});return}se={isPending:!0,isDragging:!1,startRowIndex:e,startX:t.clientX,startY:t.clientY,currentRowIndex:e},ve=o,o.grid.selectRow(e,"replace"),document.addEventListener("mousemove",Ho),document.addEventListener("mouseup",Po)}function Ho(o){if(!ve)return;if(se.isPending){const t=o.clientX-se.startX,i=o.clientY-se.startY;Math.sqrt(t*t+i*i)>=Dn&&Rn(ve);return}if(!se.isDragging)return;const e=$n(ve,o.clientY);e!==null&&e!==se.currentRowIndex&&(se.currentRowIndex=e,ve.grid.selectRowRange(se.startRowIndex,e))}function Rn(o){se.isPending=!1,se.isDragging=!0;const e=o.shadow.querySelector(".wg");e==null||e.classList.add("wg--selecting")}function Po(){if(!ve)return;const o=ve,e=o.shadow.querySelector(".wg");e==null||e.classList.remove("wg--selecting"),requestAnimationFrame(()=>{const t=o.shadow.querySelector(".wg");t==null||t.focus()}),document.removeEventListener("mousemove",Ho),document.removeEventListener("mouseup",Po),se={isPending:!1,isDragging:!1,startRowIndex:-1,startX:0,startY:0,currentRowIndex:-1},ve=null}function $n(o,e){const t=o.shadow.querySelectorAll(".wg__row[data-row-index]");for(const i of t){const r=i.getBoundingClientRect();if(e>=r.top&&e<=r.bottom){const n=parseInt(i.dataset.rowIndex||"-1",10);if(n>=0)return n}}if(t.length>0){const i=t[0],r=t[t.length-1],n=i.getBoundingClientRect(),s=r.getBoundingClientRect();if(e<n.top)return parseInt(i.dataset.rowIndex||"0",10);if(e>s.bottom)return parseInt(r.dataset.rowIndex||"0",10)}return null}class Ot extends HTMLElement{constructor(){super();w(this,"grid");w(this,"shadow");w(this,"styleElement");w(this,"customStyleElement",null);w(this,"updatePending",!1);w(this,"isCommittingFromKeyboard",!1);w(this,"isTransitioningCells",!1);w(this,"wheelListenerAdded",!1);w(this,"toolbarOutsideClickAdded",!1);w(this,"toolbarScrollListenerAdded",!1);w(this,"toolbarMoveInProgress",!1);w(this,"toolbarHideTimeout",null);w(this,"toolbarHovered",!1);w(this,"toolbarShortcutHandler",null);w(this,"inlineShortcutHandler",null);w(this,"dropdownOpen",!1);w(this,"dropdownOptions",[]);w(this,"highlightedIndex",-1);w(this,"filterText","");w(this,"isUserFiltering",!1);w(this,"justSelected",!1);w(this,"isOpeningDropdown",!1);w(this,"isProgrammaticScroll",!1);w(this,"searchDebounceTimer",null);w(this,"searchAbortController",null);w(this,"isSearching",!1);w(this,"tooltipElement",null);w(this,"tooltipArrowElement",null);w(this,"tooltipAnchor",null);w(this,"tooltipShowTimer",null);w(this,"tooltipHideTimer",null);w(this,"_tooltipShowDelay",400);w(this,"_tooltipHideDelay",100);w(this,"datepicker",null);w(this,"contextMenuElement",null);w(this,"headerContextMenuElement",null);w(this,"virtualScrollStart",0);w(this,"virtualScrollEnd",0);w(this,"scrollListenerAdded",!1);w(this,"isLoadingMoreItems",!1);w(this,"handlePaste",t=>{var d;if(!this.grid.isNavigateMode||this.grid.editingCell||!this.grid.focusedCell)return;const{rowIndex:i,colIndex:r}=this.grid.focusedCell,n=this.grid.columns[r],s=this.grid.displayItems[i];if(!n||!s||!this.grid.isCellEditable(n))return;t.preventDefault();let a=((d=t.clipboardData)==null?void 0:d.getData("text"))||"";if(n.beforePasteCallback){const g=n.beforePasteCallback(a,s);a=g!=null?String(g):""}const l=String(n.field);this.grid.commitEdit(i,l,a),this.render()});this.shadow=this.attachShadow({mode:"open"}),this.grid=new Ce,this.styleElement=document.createElement("style"),this.styleElement.textContent=Yo,this.shadow.appendChild(this.styleElement),this.grid.requestUpdate=()=>this.requestUpdate(),this.grid._onInteractionChange=(t,i)=>{t==="editingCell"&&i.current===null&&N(this)}}get tooltipShowDelay(){return this._tooltipShowDelay}set tooltipShowDelay(t){this._tooltipShowDelay=t}get tooltipHideDelay(){return this._tooltipHideDelay}set tooltipHideDelay(t){this._tooltipHideDelay=t}connectedCallback(){this.grid.gridName&&this.grid.persistColumnWidths&&this.grid.loadPersistedWidths(),this.render(),this.addEventListener("paste",this.handlePaste)}disconnectedCallback(){this.removeEventListener("paste",this.handlePaste),this.datepicker&&(this.datepicker.destroy(),this.datepicker=null),this.contextMenuElement&&(J(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(J(this.headerContextMenuElement),this.headerContextMenuElement=null),ot(),this.removeInlineShortcuts()}get items(){return this.grid.items}set items(t){this.grid.items=t,this.isLoadingMoreItems=!1}get columns(){return this.grid.columns}set columns(t){this.grid.columns=t}get filterable(){return this.grid.filterable}set filterable(t){this.grid.filterable=t}get pageable(){return this.grid.pageable}set pageable(t){this.grid.pageable=t}get pageSize(){return this.grid.pageSize}set pageSize(t){this.grid.pageSize=t}get pageSizes(){return this.grid.pageSizes}set pageSizes(t){this.grid.pageSizes=t}get striped(){return this.grid.striped}set striped(t){this.grid.striped=t}get hoverable(){return this.grid.hoverable}set hoverable(t){this.grid.hoverable=t}get editable(){return this.grid.editable}set editable(t){this.grid.editable=t}get editTrigger(){return this.grid.editTrigger}set editTrigger(t){this.grid.editTrigger=t}get editStartSelection(){return this.grid.editStartSelection}set editStartSelection(t){this.grid.editStartSelection=t}get mode(){return this.grid.mode}set mode(t){this.grid.mode=t}get dropdownToggleVisibility(){return this.grid.dropdownToggleVisibility}set dropdownToggleVisibility(t){this.grid.dropdownToggleVisibility=t}get dropdownShowOnFocus(){return this.grid.dropdownShowOnFocus}set dropdownShowOnFocus(t){this.grid.dropdownShowOnFocus=t}get openDropdownOnEnter(){return this.grid.openDropdownOnEnter}set openDropdownOnEnter(t){this.grid.openDropdownOnEnter=t}get checkboxAlwaysEditable(){return this.grid.checkboxAlwaysEditable}set checkboxAlwaysEditable(t){this.grid.checkboxAlwaysEditable=t}get showRowNumbers(){return this.grid.showRowNumbers}set showRowNumbers(t){this.grid.showRowNumbers=t}get stickyRowNumbers(){return this.grid.stickyRowNumbers}set stickyRowNumbers(t){this.grid.stickyRowNumbers=t}get freezeColumns(){return this.grid.freezeColumns}set freezeColumns(t){this.grid.freezeColumns=t}get invalidCells(){return this.grid.invalidCells}set invalidCells(t){this.grid.invalidCells=t}get showRowToolbar(){return this.grid.showRowToolbar}set showRowToolbar(t){this.grid.showRowToolbar=t}get rowToolbar(){return this.grid.rowToolbar}set rowToolbar(t){this.grid.rowToolbar=t}get toolbarVerticalAlign(){return this.grid.toolbarVerticalAlign}set toolbarVerticalAlign(t){this.grid.toolbarVerticalAlign=t}get toolbarHorizontalAlign(){return this.grid.toolbarHorizontalAlign}set toolbarHorizontalAlign(t){this.grid.toolbarHorizontalAlign=t}get toolbarAlign(){return this.grid.toolbarVerticalAlign}set toolbarAlign(t){this.grid.toolbarVerticalAlign=t}get toolbarTopPosition(){return this.grid.toolbarHorizontalAlign}set toolbarTopPosition(t){this.grid.toolbarHorizontalAlign=t}get toolbarTrigger(){return this.grid.toolbarTrigger}set toolbarTrigger(t){this.grid.toolbarTrigger=t}get toolbarPosition(){return this.grid.toolbarPosition}set toolbarPosition(t){this.grid.toolbarPosition=t}get inlineActionsTitle(){return this.grid.inlineActionsTitle}set inlineActionsTitle(t){this.grid.inlineActionsTitle=t}get contextMenu(){return this.grid.contextMenu}set contextMenu(t){this.grid.contextMenu=t}get contextMenuXOffset(){return this.grid.contextMenuXOffset}set contextMenuXOffset(t){this.grid.contextMenuXOffset=t}get contextMenuYOffset(){return this.grid.contextMenuYOffset}set contextMenuYOffset(t){this.grid.contextMenuYOffset=t}get headerContextMenu(){return this.grid.headerContextMenu}set headerContextMenu(t){this.grid.headerContextMenu=t}set onheadercontextmenuopen(t){this.grid.onheadercontextmenuopen=t}get rowShortcuts(){return this.grid.rowShortcuts}set rowShortcuts(t){this.grid.rowShortcuts=t}get rangeShortcuts(){return this.grid.rangeShortcuts}set rangeShortcuts(t){this.grid.rangeShortcuts=t}get selectedRows(){return this.grid.selectedRows}selectRow(t,i="replace"){this.grid.selectRow(t,i)}selectRowRange(t,i){this.grid.selectRowRange(t,i)}clearSelection(){this.grid.clearSelection()}isRowSelected(t){return this.grid.isRowSelected(t)}getSelectedRowsData(){return this.grid.getSelectedRowsData()}get showShortcutsHelp(){return this.grid.showShortcutsHelp}set showShortcutsHelp(t){this.grid.showShortcutsHelp=t}get shortcutsHelpPosition(){return this.grid.shortcutsHelpPosition}set shortcutsHelpPosition(t){this.grid.shortcutsHelpPosition=t}get shortcutsHelpContentCallback(){return this.grid.shortcutsHelpContentCallback}set shortcutsHelpContentCallback(t){this.grid.shortcutsHelpContentCallback=t}get showRowActions(){return this.grid.showRowActions}set showRowActions(t){this.grid.showRowActions=t}get rowActions(){return this.grid.rowActions}set rowActions(t){this.grid.rowActions=t}set onrowchange(t){this.grid.onrowchange=t}set onroweditstart(t){this.grid.onroweditstart=t}set onroweditcancel(t){this.grid.onroweditcancel=t}set onvalidationerror(t){this.grid.onvalidationerror=t}get validationTooltipCallback(){return this.grid.validationTooltipCallback}set validationTooltipCallback(t){this.grid.validationTooltipCallback=t}set ontoolbarclick(t){this.grid.ontoolbarclick=t}set onrowaction(t){this.grid.onrowaction=t}set oncontextmenuopen(t){this.grid.oncontextmenuopen=t}get ondatarequest(){return this.grid.ondatarequest}set ondatarequest(t){this.grid.ondatarequest=t}get onrowdelete(){return this.grid.onrowdelete}set onrowdelete(t){this.grid.onrowdelete=t}get sort(){return this.grid.sort}set sort(t){this.grid.sort=t}get sortMode(){return this.grid.sortMode}set sortMode(t){this.grid.sortMode=t}get currentPage(){return this.grid.currentPage}set currentPage(t){this.grid.currentPage=t}get totalItems(){return this.grid.totalItems}set totalItems(t){this.grid.totalItems=t}get showPagination(){return this.grid.showPagination}set showPagination(t){this.grid.showPagination=t}get paginationPosition(){return this.grid.paginationPosition}set paginationPosition(t){this.grid.paginationPosition=t}get paginationLabelsCallback(){return this.grid.paginationLabelsCallback}set paginationLabelsCallback(t){this.grid.paginationLabelsCallback=t}get paginationLayout(){return this.grid.paginationLayout}set paginationLayout(t){this.grid.paginationLayout=t}get summaryPosition(){return this.grid.summaryPosition}set summaryPosition(t){this.grid.summaryPosition=t}get summaryContentCallback(){return this.grid.summaryContentCallback}set summaryContentCallback(t){this.grid.summaryContentCallback=t}get customStylesCallback(){return this.grid.customStylesCallback}set customStylesCallback(t){this.grid.customStylesCallback=t,this.updateCustomStyles()}get rowClassCallback(){return this.grid.rowClassCallback}set rowClassCallback(t){this.grid.rowClassCallback=t}get labels(){return this.grid.labels}set labels(t){this.grid.labels=t}get summaryMetadata(){return this.grid.summaryMetadata}set summaryMetadata(t){this.grid.summaryMetadata=t}get summaryInline(){return this.grid.summaryInline}set summaryInline(t){this.grid.summaryInline=t}get idValueMember(){return this.grid.idValueMember}set idValueMember(t){this.grid.idValueMember=t}get idValueCallback(){return this.grid.idValueCallback}set idValueCallback(t){this.grid.idValueCallback=t}get rowLocking(){return this.grid.rowLocking}set rowLocking(t){this.grid.rowLocking=t}get onrowlockchange(){return this.grid.onrowlockchange}set onrowlockchange(t){this.grid.onrowlockchange=t}get gridName(){return this.grid.gridName}set gridName(t){this.grid.gridName=t,this.tryLoadPersistedWidths()}get persistColumnWidths(){return this.grid.persistColumnWidths}set persistColumnWidths(t){this.grid.persistColumnWidths=t,this.tryLoadPersistedState()}get allowColumnReorder(){return this.grid.allowColumnReorder}set allowColumnReorder(t){this.grid.allowColumnReorder=t}get persistColumnOrder(){return this.grid.persistColumnOrder}set persistColumnOrder(t){this.grid.persistColumnOrder=t,this.tryLoadPersistedState()}tryLoadPersistedState(){this.grid.gridName&&(this.grid.persistColumnWidths||this.grid.persistColumnOrder)&&(this.grid.loadPersistedState(),this.isConnected&&this.render())}tryLoadPersistedWidths(){this.tryLoadPersistedState()}get oncolumnresize(){return this.grid.oncolumnresize}set oncolumnresize(t){this.grid.oncolumnresize=t}get oncolumnreorder(){return this.grid.oncolumnreorder}set oncolumnreorder(t){this.grid.oncolumnreorder=t}get onfilldrag(){return this.grid.onfilldrag}set onfilldrag(t){this.grid.onfilldrag=t}get virtualScroll(){return this.grid.virtualScroll}set virtualScroll(t){this.grid.virtualScroll=t}get virtualScrollThreshold(){return this.grid.virtualScrollThreshold}set virtualScrollThreshold(t){this.grid.virtualScrollThreshold=t}get virtualScrollRowHeight(){return this.grid.virtualScrollRowHeight}set virtualScrollRowHeight(t){this.grid.virtualScrollRowHeight=t}get virtualScrollBuffer(){return this.grid.virtualScrollBuffer}set virtualScrollBuffer(t){this.grid.virtualScrollBuffer=t}get infiniteScroll(){return this.grid.infiniteScroll}set infiniteScroll(t){this.grid.infiniteScroll=t}get infiniteScrollThreshold(){return this.grid.infiniteScrollThreshold}set infiniteScrollThreshold(t){this.grid.infiniteScrollThreshold=t}get hasMoreItems(){return this.grid.hasMoreItems}set hasMoreItems(t){this.grid.hasMoreItems=t}get displayItems(){return this.grid.displayItems}get totalPages(){return this.grid.totalPages}get isNavigateMode(){return this.grid.isNavigateMode}getRowDraft(t){return this.grid.getRowDraft(t)}hasRowDraft(t){return this.grid.hasRowDraft(t)}discardRowDraft(t){this.grid.discardRowDraft(t)}getDraftRowIndices(){return this.grid.getDraftRowIndices()}discardAllDrafts(){this.grid.discardAllDrafts()}isCellInvalid(t,i){return this.grid.isCellInvalid(t,i)}getCellValidationError(t,i){return this.grid.getCellValidationError(t,i)}getRowId(t){return this.grid.getRowId(t)}findRowById(t){return this.grid.findRowById(t)}isRowLocked(t){return this.grid.isRowLocked(t)}getRowLockInfo(t){return this.grid.getRowLockInfo(t)}lockRowById(t,i){return this.grid.lockRowById(t,i)}unlockRowById(t){return this.grid.unlockRowById(t)}getExternalLocks(){return this.grid.getExternalLocks()}clearExternalLocks(){this.grid.clearExternalLocks()}updateRowById(t,i){return this.grid.updateRowById(t,i)}replaceRowById(t,i){return this.grid.replaceRowById(t,i)}canEditCell(t,i){return this.grid.canEditCell(t,i)}setColumnWidth(t,i){this.grid.setColumnWidth(t,i)}setColumnWidths(t){this.grid.setColumnWidths(t)}getColumnWidthsState(){return this.grid.getColumnWidthsState()}setColumnOrder(t){this.grid.setColumnOrder(t)}getColumnOrderState(){return this.grid.getColumnOrderState()}focusCell(t,i){const r=this.grid.columns,n=this.grid.displayItems;t<0||t>=n.length||i<0||i>=r.length||(this.grid.setFocusedCell(t,i),requestAnimationFrame(()=>{z(this,t,i)}))}startEditing(t,i){const r=this.grid.columns;if(i<0||i>=r.length)return;const n=r[i],s=String(n.field);this.grid.startEdit(t,s);const a=this.shadow.querySelector(`td[data-row="${t}"][data-col="${i}"]`);a&&(a.classList.remove("wg__cell--focused"),a.classList.add("wg__cell--editing"),a.innerHTML=tt(this,t,i,n))}escapeHtml(t){const i=document.createElement("div");return i.textContent=t,i.innerHTML}getCurrentEditingColumn(){const t=this.grid.editingCell;return t&&this.grid.columns.find(i=>String(i.field)===t.field)||null}getCurrentEditorOptions(){const t=this.getCurrentEditingColumn();return(t==null?void 0:t.editorOptions)||{}}moveFocusAfterCommit(t,i,r){mt(this,t,i,r)}requestUpdate(){this.updatePending||(this.updatePending=!0,queueMicrotask(()=>{this.updatePending=!1,this.render()}))}updateCustomStyles(){const t=this.grid.customStylesCallback;if(t){const i=t();this.customStyleElement||(this.customStyleElement=document.createElement("style"),this.shadow.appendChild(this.customStyleElement)),this.customStyleElement.textContent=i}else this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}handleCellKeyDown(t,i,r){var u;if(!this.grid.isNavigateMode)return;const n=this.grid.columns,s=this.grid.displayItems,a=this.grid.getEditableColumns(),l=a.findIndex(c=>c.index===r);if((t.ctrlKey||t.metaKey)&&t.key==="c"){const c=n[r],h=s[i];if(c&&h){let f=this.grid.getCellRawValue(h,i,String(c.field));c.beforeCopyCallback&&(f=c.beforeCopyCallback(f,h));const p=f!=null?String(f):"";navigator.clipboard.writeText(p)}return}const d=this.grid.selectedRows;if(d.length>0){const c=this.grid.rangeShortcuts;if(c&&c.length>0)for(const h of c){const f=Ne(h.key);if(Ye(t,f)){const p={rows:this.grid.getSelectedRowsData(),rowIndices:d};if(!(typeof h.disabled=="function"?h.disabled(p):h.disabled===!0)){t.preventDefault(),h.action(p);return}}}}const g=this.grid.rowShortcuts;if(g&&g.length>0){const c=n[r],h=s[i];if(c&&h)for(const f of g){const p=Ne(f.key);if(Ye(t,p)){const v={row:h,rowIndex:i,colIndex:r,column:c,cellValue:this.grid.getCellRawValue(h,i,String(c.field))};if(!(typeof f.disabled=="function"?f.disabled(v):f.disabled===!0)){t.preventDefault(),f.action(v);return}}}}switch(t.key){case"ArrowUp":t.preventDefault(),i>0&&z(this,i-1,r);break;case"ArrowDown":t.preventDefault(),i<s.length-1&&z(this,i+1,r);break;case"ArrowLeft":t.preventDefault(),r>0&&z(this,i,r-1);break;case"ArrowRight":t.preventDefault(),r<n.length-1&&z(this,i,r+1);break;case"Tab":if(t.preventDefault(),t.shiftKey){if(l>0){const c=a[l-1].index;z(this,i,c)}else if(i>0){const c=a[a.length-1].index;z(this,i-1,c)}}else if(l>=0&&l<a.length-1){const c=a[l+1].index;z(this,i,c)}else if(l===-1&&a.length>0)z(this,i,a[0].index);else if(i<s.length-1){const c=a[0].index;z(this,i+1,c)}break;case"Home":if(t.preventDefault(),t.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const c=this.grid.focusedCell;this.grid.setFocusedCell(0,0),this.scrollToRowProgrammatically(0);const h=this.shadow.querySelector('td[data-row="0"][data-col="0"]');h&&(h.focus({preventScroll:!0}),te(this,c,{rowIndex:0,colIndex:0}))}else z(this,0,0);else z(this,i,0);break;case"End":if(t.preventDefault(),t.ctrlKey){const c=s.length-1,h=n.length-1;if(this.grid.shouldUseVirtualScroll()){const f=this.grid.focusedCell;this.grid.setFocusedCell(c,h),this.scrollToRowProgrammatically(c);const p=this.shadow.querySelector(`td[data-row="${c}"][data-col="${h}"]`);p&&(p.focus({preventScroll:!0}),te(this,f,{rowIndex:c,colIndex:h}))}else z(this,c,h)}else z(this,i,n.length-1);break;case"PageUp":if(t.preventDefault(),t.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const c=this.grid.focusedCell;this.grid.setFocusedCell(0,r),this.scrollToRowProgrammatically(0);const h=this.shadow.querySelector(`td[data-row="0"][data-col="${r}"]`);h&&(h.focus({preventScroll:!0}),te(this,c,{rowIndex:0,colIndex:r}))}else z(this,0,r);else{const c=Math.max(0,i-10);if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(c,r),this.scrollToRowProgrammatically(c);const f=this.shadow.querySelector(`td[data-row="${c}"][data-col="${r}"]`);f&&(f.focus({preventScroll:!0}),te(this,h,{rowIndex:c,colIndex:r}))}else z(this,c,r)}break;case"PageDown":if(t.preventDefault(),t.ctrlKey){const c=s.length-1;if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(c,r),this.scrollToRowProgrammatically(c);const f=this.shadow.querySelector(`td[data-row="${c}"][data-col="${r}"]`);f&&(f.focus({preventScroll:!0}),te(this,h,{rowIndex:c,colIndex:r}))}else z(this,c,r)}else{const c=Math.min(s.length-1,i+10);if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(c,r),this.scrollToRowProgrammatically(c);const f=this.shadow.querySelector(`td[data-row="${c}"][data-col="${r}"]`);f&&(f.focus({preventScroll:!0}),te(this,h,{rowIndex:c,colIndex:r}))}else z(this,c,r)}break;case"g":case"G":t.ctrlKey&&(t.preventDefault(),this.showGoToRowDialog(r));break;case"Enter":{t.preventDefault();const c=n[r];((c==null?void 0:c.editor)==="select"||(c==null?void 0:c.editor)==="combobox"||(c==null?void 0:c.editor)==="autocomplete")&&this.grid.getEffectiveOpenDropdownOnEnter(c)?(oe(this,i,r),requestAnimationFrame(()=>{this.dropdownOpen||ne(this)})):i<s.length-1&&z(this,i+1,r);break}case"F2":{t.preventDefault();const c=n[r],h=(c==null?void 0:c.editor)==="select"||(c==null?void 0:c.editor)==="combobox"||(c==null?void 0:c.editor)==="autocomplete",f=(c==null?void 0:c.editor)==="custom";oe(this,i,r),h?requestAnimationFrame(()=>{this.dropdownOpen||ne(this)}):f&&requestAnimationFrame(()=>{this.openCustomEditor(i,r)});break}case" ":{t.preventDefault();const c=n[r],h=(c==null?void 0:c.editor)==="checkbox",f=(c==null?void 0:c.editor)==="select"||(c==null?void 0:c.editor)==="combobox"||(c==null?void 0:c.editor)==="autocomplete",p=(c==null?void 0:c.editor)==="date",v=(c==null?void 0:c.editor)==="custom";h?Ui(this,i,r):f?(oe(this,i,r),requestAnimationFrame(()=>{this.dropdownOpen||ne(this)})):p?(oe(this,i,r),requestAnimationFrame(()=>{var S;const m=(S=this.shadowRoot)==null?void 0:S.querySelector(`.wg__cell[data-row="${i}"][data-col="${r}"]`),y=m==null?void 0:m.querySelector(".wg__date-input"),_=m==null?void 0:m.querySelector(".wg__editor--date");y&&_&&this.openDatePicker(y,_)})):v&&(oe(this,i,r),requestAnimationFrame(()=>{this.openCustomEditor(i,r)}));break}case"Escape":if(t.preventDefault(),this.grid.editingCell)G(this),this.grid.cancelEdit();else if(this.grid.selectedRows.length>0)this.grid.clearSelection();else{const c=this.grid.focusedCell;this.grid.clearFocusedCell(),te(this,c,null),(u=t.target)==null||u.blur()}break;case"Delete":{t.preventDefault();const c=n[r],h=s[i];if(t.ctrlKey){if(h){const f={rowIndex:i,row:h};this.grid.onrowdelete&&this.grid.onrowdelete(f),this.dispatchEvent(new CustomEvent("rowdelete",{detail:f}))}}else c&&this.grid.isCellEditable(c)&&(this.grid.commitEdit(i,String(c.field),null),this.render(),requestAnimationFrame(()=>{const f=this.shadow.querySelector(`td[data-row="${i}"][data-col="${r}"]`);f==null||f.focus()}));break}default:if(t.key.length===1&&!t.ctrlKey&&!t.altKey&&!t.metaKey){const c=n[r];if((c==null?void 0:c.editor)==="number"&&!/[\d.\-]/.test(t.key))return;oe(this,i,r,{initialSearchQuery:t.key}),t.preventDefault()}break}}handleEditorKeyDown(t,i){const r=parseInt(i.dataset.row||"0",10),n=i.dataset.field||"",s=this.grid.columns.find(g=>g.field===n),a=(s==null?void 0:s.editor)||"text",l=a==="select"||a==="combobox"||a==="autocomplete",d=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"];if(l&&!this.dropdownOpen&&d.includes(t.key)){t.preventDefault(),t.stopPropagation();const g=this.grid.columns.findIndex(m=>m.field===n),u=this.grid.columns.map((m,y)=>({index:y,column:m})).filter(m=>m.column.editable!==!1),c=u.findIndex(m=>m.index===g),h=this.grid.displayItems;let f=r,p=g,v=!1;switch(t.key){case"ArrowUp":r>0&&(f=r-1,v=!0);break;case"ArrowDown":r<h.length-1&&(f=r+1,v=!0);break;case"ArrowLeft":c>0&&(p=u[c-1].index,v=!0);break;case"ArrowRight":c<u.length-1&&(p=u[c+1].index,v=!0);break;case"PageUp":f=Math.max(0,r-10),v=!0;break;case"PageDown":f=Math.min(h.length-1,r+10),v=!0;break;case"Home":t.ctrlKey&&(f=0),p=0,v=!0;break;case"End":t.ctrlKey?(f=h.length-1,p=this.grid.columns.length-1):p=this.grid.columns.length-1,v=!0;break}v&&(G(this),this.grid.cancelEdit(),queueMicrotask(()=>{z(this,f,p)}));return}switch(t.key){case"ArrowDown":if(this.dropdownOpen){t.preventDefault(),t.stopPropagation();const g=this.getCurrentEditorOptions();let u=this.highlightedIndex+1;for(;u<this.dropdownOptions.length&&Pe(this.dropdownOptions[u],g);)u++;u<this.dropdownOptions.length&&(this.highlightedIndex=u,ue(this),go(this))}break;case"ArrowUp":if(this.dropdownOpen){t.preventDefault(),t.stopPropagation();const g=this.getCurrentEditorOptions();let u=this.highlightedIndex-1;for(;u>=0&&Pe(this.dropdownOptions[u],g);)u--;u>=0&&(this.highlightedIndex=u,ue(this),go(this))}break;case"Enter":if(this.datepicker)return;t.preventDefault(),t.stopPropagation(),this.dropdownOpen&&this.highlightedIndex>=0?co(this,this.highlightedIndex):l&&!this.dropdownOpen?ne(this):(this.isCommittingFromKeyboard=!0,N(this),a==="date"&&i instanceof HTMLInputElement?this.commitDateEditor(i):et(this,i),mt(this,r,n,"down"));break;case"Tab":if(this.datepicker)return;if(t.preventDefault(),t.stopPropagation(),this.isCommittingFromKeyboard=!0,this.dropdownOpen&&this.highlightedIndex>=0&&l){const g=this.dropdownOptions[this.highlightedIndex],u=this.getCurrentEditorOptions();if(g&&!Pe(g,u)){const c=Se(g,u);this.grid.commitEdit(r,n,c)}N(this)}else N(this),a==="date"&&i instanceof HTMLInputElement?this.commitDateEditor(i):l||et(this,i);mt(this,r,n,t.shiftKey?"prev":"next");break;case"Escape":t.preventDefault(),t.stopPropagation(),this.dropdownOpen&&N(this),this.datepicker&&(this.datepicker.close(!0),this.datepicker=null),this.isCommittingFromKeyboard=!0,G(this),this.grid.cancelEdit(),Ki(this,r,n);break;case"F2":t.preventDefault(),t.stopPropagation(),l&&!this.dropdownOpen&&ne(this);break;case"Backspace":a==="select"&&(t.preventDefault(),t.stopPropagation(),this.filterText.length>0&&(this.filterText=this.filterText.slice(0,-1),ho(this,s.editorOptions||{})));break;default:a==="select"&&t.key.length===1&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&(t.preventDefault(),t.stopPropagation(),this.filterText+=t.key,ho(this,s.editorOptions||{}));break}}attachEventListeners(){const t=this.shadow.querySelector(".wg__table");if(!t)return;t.addEventListener("focus",n=>{var a;const s=n.target;if(s.matches(".wg__cell")){const l=parseInt(s.dataset.row||"0",10),d=parseInt(s.dataset.col||"0",10);Ni(this,l,d),At(this)}if(s.matches(".wg__select-trigger, .wg__combobox-input, .wg__autocomplete-input")&&!this.justSelected&&!this.dropdownOpen){const l=s.dataset.field||"",d=this.grid.columns.find(c=>c.field===l),g=(d==null?void 0:d.editorOptions)||{};(((a=this.grid.editingCell)==null?void 0:a.initialSearchQuery)!==void 0||g.showOnFocus!==!1)&&ne(this)}},!0),t.addEventListener("keydown",n=>{const s=n.target;if(s.matches(".wg__editor, .wg__combobox-input, .wg__autocomplete-input, .wg__date-input")){this.handleEditorKeyDown(n,s);return}if(s.matches(".wg__cell")){const a=parseInt(s.dataset.row||"0",10),l=parseInt(s.dataset.col||"0",10);this.handleCellKeyDown(n,a,l)}}),t.addEventListener("focusout",n=>{Yi(this,n)}),t.addEventListener("dblclick",n=>{n.preventDefault();const a=n.target.closest(".wg__cell");if(a){const l=parseInt(a.dataset.row||"0",10),d=parseInt(a.dataset.col||"0",10),g=this.grid.columns[d];if(g){const u=g.editTrigger||this.grid.editTrigger;if(u==="dblclick"||u==="navigate"){const c=wt(n,a);oe(this,l,d,{cursorPosition:c??void 0});const h=g.editor;h==="select"||h==="combobox"||h==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||ne(this)}):h==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(l,d)})}}}}),t.addEventListener("click",n=>{const a=n.target.closest(".wg__cell");if(a&&!a.classList.contains("wg__cell--editing")){const l=parseInt(a.dataset.row||"0",10),d=parseInt(a.dataset.col||"0",10),g=this.grid.columns[d];if(g&&(g.editTrigger||this.grid.editTrigger)==="click"){n.preventDefault();const c=wt(n,a);oe(this,l,d,{cursorPosition:c??void 0});const h=g.editor;h==="select"||h==="combobox"||h==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||ne(this)}):h==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(l,d)})}}}),t.addEventListener("mousedown",n=>{const s=n.target;if(s.closest(".wg__date-trigger")){n.preventDefault(),n.stopPropagation();const l=s.closest(".wg__cell-date-display"),d=s.closest(".wg__editor--date");if(d){const g=d.querySelector(".wg__date-input");g&&this.openDatePicker(g,d)}else if(l){const g=parseInt(l.dataset.row||"0",10),u=l.dataset.field||"",c=this.grid.columns.findIndex(h=>String(h.field)===u);if(c>=0){if(this.isTransitioningCells=!0,this.grid.editingCell){const h=this.grid.editingCell,f=this.grid.columns.findIndex(p=>String(p.field)===h.field);N(this),G(this),this.grid.cancelEdit(),f>=0&&j(this,h.rowIndex,f)}oe(this,g,c),requestAnimationFrame(()=>{var v;this.isTransitioningCells=!1;const h=(v=this.shadowRoot)==null?void 0:v.querySelector(`.wg__cell[data-row="${g}"][data-field="${u}"]`),f=h==null?void 0:h.querySelector(".wg__date-input"),p=h==null?void 0:h.querySelector(".wg__editor--date");f&&p&&this.openDatePicker(f,p)})}}return}if(this.dropdownOpen||this.grid.editingCell){const l=s.closest(".wg__cell");if(l&&!s.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete, .wg__editor--date")){const d=parseInt(l.dataset.row||"0",10),g=parseInt(l.dataset.col||"0",10),u=this.grid.editingCell,c=s.matches(".wg__combobox-toggle, .wg__select-toggle, .wg__date-trigger");if(u&&!c){const h=this.grid.columns.findIndex(f=>String(f.field)===u.field);if(d!==u.rowIndex||g!==h){n.preventDefault(),this.isTransitioningCells=!0;const f=u.rowIndex,p=h;N(this),G(this),this.grid.cancelEdit(),p>=0&&j(this,f,p);const v=this.grid.columns[g],m=(v==null?void 0:v.editTrigger)||this.grid.editTrigger,_=n.clientX;requestAnimationFrame(()=>{if(this.isTransitioningCells=!1,m==="click"&&v&&this.grid.isCellEditable(v)){const S=this.shadow.querySelector(`td[data-row="${d}"][data-col="${g}"]`),b=S?wt({clientX:_},S):void 0;oe(this,d,g,{cursorPosition:b??void 0})}else z(this,d,g)});return}}}}if(s.matches(".wg__combobox-toggle, .wg__select-toggle")){n.preventDefault(),n.stopPropagation();const l=s.closest(".wg__cell-dropdown-display");if(s.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete"))uo(this);else if(l){const g=parseInt(l.dataset.row||"0",10),u=l.dataset.field||"",c=this.grid.columns.findIndex(h=>String(h.field)===u);if(c>=0){this.isTransitioningCells=!0;const h=this.grid.editingCell,f=h?this.grid.columns.findIndex(p=>String(p.field)===h.field):-1;h&&(N(this),G(this),this.grid.cancelEdit(),f>=0&&j(this,h.rowIndex,f)),oe(this,g,c),requestAnimationFrame(()=>{this.isTransitioningCells=!1,this.dropdownOpen||ne(this)})}}}if(s.matches(".wg__cell-dropdown-display")){n.preventDefault(),n.stopPropagation();const l=s.closest(".wg__cell-dropdown-display");if(l){const d=parseInt(l.dataset.row||"0",10),g=l.dataset.field||"",u=this.grid.columns.findIndex(c=>String(c.field)===g);if(u>=0){this.isTransitioningCells=!0;const c=this.grid.editingCell,h=c?this.grid.columns.findIndex(f=>String(f.field)===c.field):-1;c&&(N(this),G(this),this.grid.cancelEdit(),h>=0&&j(this,c.rowIndex,h)),oe(this,d,u),requestAnimationFrame(()=>{this.isTransitioningCells=!1,this.dropdownOpen||ne(this)})}}}}),t.addEventListener("click",n=>{n.target.matches(".wg__select-trigger, .wg__select-value")&&(n.preventDefault(),n.stopPropagation(),uo(this))}),t.addEventListener("mousedown",n=>{const s=n.target,a=s.closest(".wg__resize-handle");if(a){n.preventDefault(),n.stopPropagation();const d=a.dataset.field;d&&sn(this,n,d);return}if(this.grid.allowColumnReorder){const d=s.closest(".wg__header");if(d&&!d.classList.contains("wg__header--frozen")&&!d.classList.contains("wg__row-number-header")){const g=d.dataset.field;g&&un(this,n,g)}}const l=s.closest(".wg__row-number[data-row-number]");if(l){const d=parseInt(l.dataset.rowNumber||"-1",10);d>=0&&En(this,d,n)}}),t.addEventListener("click",n=>{const s=n,a=s.target;if(a.closest(".wg__resize-handle")||gn())return;a.closest(".wg__header--sortable")&&(on(this,s),this.render())}),t.addEventListener("contextmenu",n=>{this.handleContextMenu(n)}),t.addEventListener("change",n=>{const s=n.target;s.matches(".wg__editor--checkbox")&&Bi(this,s)}),t.addEventListener("input",n=>{const s=n.target;s.matches(".wg__combobox-input")?wr(this,n):s.matches(".wg__autocomplete-input")&&pr(this,n)}),t.addEventListener("blur",n=>{const s=n.target;if(s.matches(".wg__editor--text, .wg__editor--number")&&ji(this,s),s.matches(".wg__date-input")&&!this.datepicker&&!this.isCommittingFromKeyboard&&!this.isTransitioningCells&&this.commitDateEditor(s),s.matches(".wg__select-trigger")&&!this.isCommittingFromKeyboard&&!this.isTransitioningCells&&!this.dropdownOpen&&!this.isOpeningDropdown&&(N(this),G(this),this.grid.cancelEdit()),s.matches(".wg__combobox-input, .wg__autocomplete-input")){if(this.isCommittingFromKeyboard||this.isTransitioningCells)return;if(N(this),this.grid.editingCell){const a=s,l=this.getCurrentEditingColumn();if(l){const d=l.editorOptions||{},u=(d.options||d.initialOptions||[]).find(c=>He(c,d).toLowerCase()===a.value.toLowerCase());u?this.grid.commitEdit(this.grid.editingCell.rowIndex,this.grid.editingCell.field,Se(u,d)):this.grid.commitEdit(this.grid.editingCell.rowIndex,this.grid.editingCell.field,a.value)}}}},!0);const i=this.shadow.querySelector(".wg");i&&(i.setAttribute("tabindex","-1"),i.addEventListener("keydown",n=>{const s=this.grid.selectedRows;if(s.length===0||n.target.matches('input, textarea, select, [contenteditable="true"]'))return;if(n.key==="Escape"){n.preventDefault(),this.grid.clearSelection();return}const l=this.grid.rangeShortcuts;if(l!=null&&l.length)for(const d of l){const g=Ne(d.key);if(Ye(n,g)){const u={rows:this.grid.getSelectedRowsData(),rowIndices:s};if(!(typeof d.disabled=="function"?d.disabled(u):d.disabled===!0)){n.preventDefault(),d.action(u);return}}}}),i.addEventListener("scroll",()=>{const n=i.scrollLeft>0;if(i.classList.toggle("wg--scrolled-horizontal",n),this.dropdownOpen&&!this.isTransitioningCells&&!this.isOpeningDropdown){const s=this.grid.editingCell,a=s?this.grid.columns.findIndex(l=>String(l.field)===s.field):-1;N(this),G(this),this.grid.cancelEdit(),s&&a>=0&&j(this,s.rowIndex,a)}this.grid.shouldUseVirtualScroll()&&this.handleVirtualScroll(i),this.grid.infiniteScroll&&this.grid.hasMoreItems&&!this.isLoadingMoreItems&&this.handleInfiniteScroll(i),Ae()!==null&&(no(this,this.grid.displayItems),this.renderConnector()),At(this)})),this.wheelListenerAdded||(this.wheelListenerAdded=!0,window.addEventListener("scroll",()=>{if(this.dropdownOpen&&!this.isTransitioningCells){const n=this.grid.editingCell,s=n?this.grid.columns.findIndex(a=>String(a.field)===n.field):-1;N(this),G(this),this.grid.cancelEdit(),n&&s>=0&&j(this,n.rowIndex,s)}},{passive:!0,capture:!0})),t.addEventListener("mouseenter",n=>{const s=n.target,a=s.closest("[data-tooltip-html]");if(a){const d=a.getAttribute("data-tooltip-html");Et(this,a,d,this._tooltipShowDelay,!0);return}const l=s.closest("[data-tooltip]");if(l){const d=l.getAttribute("data-tooltip");Et(this,l,d,this._tooltipShowDelay,!1)}},!0),t.addEventListener("mouseleave",n=>{const s=n,a=s.target,l=s.relatedTarget,d=a.closest("[data-tooltip], [data-tooltip-html]");d&&(l==null?void 0:l.closest("[data-tooltip], [data-tooltip-html]"))===d||d&&fo(this,this._tooltipHideDelay)},!0),t.addEventListener("click",n=>{const a=n.target.closest(".wg__toolbar-trigger");if(a&&this.grid.toolbarTrigger==="button"){n.preventDefault(),n.stopPropagation();const l=parseInt(a.dataset.toolbarTrigger||"0",10),d=t.querySelector(`tr[data-row-index="${l}"]`);d&&(yt(l)?this.closeToolbarAndReset():this.showToolbarForRow(d,l))}}),t.addEventListener("click",n=>{if(this.grid.toolbarPosition!=="inline")return;const a=n.target.closest(".wg__inline-action-btn");if(a&&!a.disabled){n.preventDefault(),n.stopPropagation();const l=a.dataset.actionId,d=parseInt(a.dataset.row||"0",10);this.handleInlineActionClick(l,d)}}),t.addEventListener("mouseenter",n=>{const s=n,l=s.target.closest(".wg__row");if(l){const d=parseInt(l.dataset.rowIndex||"0",10);this.grid.setHoveredRow(d),this.grid.toolbarPosition==="inline"&&this.setupInlineShortcuts(),this.grid.toolbarTrigger==="hover"&&this.grid.toolbarPosition!=="inline"&&(this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),yt(d)||this.showToolbarForRow(l,d,s.clientX))}},!0),t.addEventListener("mouseleave",n=>{if(n.target.closest(".wg__row")&&(this.grid.toolbarPosition==="inline"&&setTimeout(()=>{t.matches(":hover")||(this.grid.setHoveredRow(null),this.removeInlineShortcuts())},50),this.grid.toolbarTrigger==="hover"&&this.grid.toolbarPosition!=="inline")){if(this.toolbarMoveInProgress)return;this.toolbarHideTimeout&&clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=setTimeout(()=>{const d=this.shadow.querySelector(".wg__toolbar-container"),g=d==null?void 0:d.matches(":hover"),u=t.matches(":hover");!g&&!u&&(this.grid.setHoveredRow(null),this.closeToolbarAndReset())},150)}},!0),t.addEventListener("click",n=>{if(this.grid.toolbarTrigger!=="click")return;const s=n,a=s.target,l=a.closest(".wg__row");if(l&&!a.closest(".wg__cell--editing")){const d=parseInt(l.dataset.rowIndex||"0",10);yt(d)?this.closeToolbarAndReset():this.showToolbarForRow(l,d,s.clientX)}}),this.toolbarOutsideClickAdded||(this.toolbarOutsideClickAdded=!0,document.addEventListener("click",n=>{if(!ro(this.shadow))return;const s=n.composedPath(),a=s.some(g=>{var u;return(u=g.classList)==null?void 0:u.contains("wg__toolbar-container")}),l=s.some(g=>{var u;return(u=g.classList)==null?void 0:u.contains("wg__toolbar-trigger")});a||l||s.includes(this)&&(this.grid.toolbarTrigger==="hover"||this.grid.toolbarTrigger==="click")||Ae()!==null&&this.closeToolbarAndReset()})),this.toolbarScrollListenerAdded||(this.toolbarScrollListenerAdded=!0,window.addEventListener("scroll",()=>{Ae()!==null&&this.closeToolbarAndReset()},!0)),this.shadow.querySelectorAll(".wg__pagination").forEach(n=>{n.addEventListener("click",a=>{rn(this,a)&&this.render()});const s=n.querySelector(".wg__pagination-select");s&&s.addEventListener("change",()=>{nn(this,s)&&this.render()})})}scrollToRowProgrammatically(t){const i=this.shadow.querySelector(".wg");if(!i)return;const{scrollTop:r,startIndex:n,endIndex:s}=en({targetRow:t,rowHeight:this.grid.virtualScrollRowHeight,buffer:this.grid.virtualScrollBuffer,totalItems:this.grid.displayItems.length,viewportHeight:i.clientHeight,scrollHeight:i.scrollHeight,clientHeight:i.clientHeight});(n!==this.virtualScrollStart||s!==this.virtualScrollEnd)&&(this.virtualScrollStart=n,this.virtualScrollEnd=s,this.renderVirtualRows(i)),this.isProgrammaticScroll=!0,i.scrollTop=r,queueMicrotask(()=>{this.isProgrammaticScroll=!1})}handleVirtualScroll(t){var n;if(this.isProgrammaticScroll)return;const{startIndex:i,endIndex:r}=Zr({scrollTop:t.scrollTop,viewportHeight:t.clientHeight,rowHeight:this.grid.virtualScrollRowHeight,buffer:this.grid.virtualScrollBuffer,totalItems:this.grid.displayItems.length,editingRowIndex:(n=this.grid.editingCell)==null?void 0:n.rowIndex});(i!==this.virtualScrollStart||r!==this.virtualScrollEnd)&&(this.virtualScrollStart=i,this.virtualScrollEnd=r,this.renderVirtualRows(t))}renderVirtualRows(t){const i=t.querySelector("tbody");if(!i)return;const r=this.grid.displayItems,n={startIndex:this.virtualScrollStart,endIndex:this.virtualScrollEnd,rowHeight:this.grid.virtualScrollRowHeight,totalItems:r.length},s=this.grid.focusedCell;if(i.innerHTML=ao(this,n),s){this.grid.setFocusedCell(s.rowIndex,s.colIndex);const a=i.querySelector(`td[data-row="${s.rowIndex}"][data-col="${s.colIndex}"]`);a&&(a.focus({preventScroll:!0}),te(this,null,s))}}handleInfiniteScroll(t){tn(t.scrollTop,t.scrollHeight,t.clientHeight,this.grid.infiniteScrollThreshold)&&(this.isLoadingMoreItems=!0,this.grid.fireDataRequest("loadMore"))}renderShortcutsHelpIcon(){var s,a,l;if(!this.grid.showShortcutsHelp||!((s=this.grid.rowShortcuts)!=null&&s.length))return"";const i=this.grid.shortcutsHelpPosition==="top-left"?"wg__shortcuts-help--left":"",r=this.grid.rowShortcuts.map(d=>`<div class="wg__shortcuts-help-item">
638
- <span class="wg__shortcuts-help-key">${Jr(d.key)}</span>
643
+ `;let To=!1;function zo(){if(To)return;const o=document.createElement("style");o.id="wg-context-menu-styles",o.textContent=wr,document.head.appendChild(o),To=!0}function pr(o,t){const e=o.filter(n=>n.visible===void 0?!0:typeof n.visible=="function"?n.visible(t):n.visible);return e.length===0?"":`<div class="wg-context-menu">${e.map((n,r)=>{const s=typeof n.label=="function"?n.label(t):n.label,l=typeof n.icon=="function"?n.icon(t):n.icon,a=n.shortcut,d=typeof n.disabled=="function"?n.disabled(t):n.disabled,g=n.danger===!0,u=["wg-context-menu__item",d?"wg-context-menu__item--disabled":"",g?"wg-context-menu__item--danger":""].filter(Boolean).join(" "),c=n.dividerBefore&&r>0?'<div class="wg-context-menu__divider"></div>':"",h=l?`<span class="wg-context-menu__icon">${l}</span>`:"",f=a?`<span class="wg-context-menu__shortcut">${a}</span>`:"";return`${c}<div class="${u}" data-item-id="${n.id}" data-disabled="${d?"true":"false"}" data-shortcut="${a||""}">${h}<span class="wg-context-menu__label">${s}</span>${f}</div>`}).join("")}</div>`}function mr(o,t,e,i,n,r,s,l,a){zo();const d=pr(r,s);if(!d)return null;const g=document.createElement("div");g.className="wg-context-menu-container",g.innerHTML=d,document.body.appendChild(g);const u=g.querySelector(".wg-context-menu"),c=t+i,h=e+n;Ae({getBoundingClientRect:()=>({width:0,height:0,x:c,y:h,top:h,left:c,right:c,bottom:h})},u,{placement:"bottom-start",middleware:[Le({fallbackPlacements:["top-start","bottom-end","top-end"]}),et({padding:8})]}).then(({x:_,y:S})=>{Object.assign(u.style,{left:`${_}px`,top:`${S}px`})}),g.addEventListener("click",_=>{const S=_.target.closest(".wg-context-menu__item");if(S&&S.dataset.disabled!=="true"){const v=S.dataset.itemId||"";l(v)}});const w=o.scrollEvents.subscribe("window",()=>{p(),a()}),p=()=>{w.unsubscribe(),document.removeEventListener("mousedown",m),document.removeEventListener("keydown",y),g.remove()},m=_=>{g.contains(_.target)||(p(),a())},y=_=>{if(_.key==="Escape"){_.preventDefault(),p(),a();return}const S=_.key.toLowerCase(),v=g.querySelectorAll(".wg-context-menu__item");for(const C of v){const x=C.dataset.shortcut;if(C.dataset.disabled==="true"||!x)continue;if(x.toLowerCase()===S||x===_.key){_.preventDefault();const M=C.dataset.itemId||"";l(M),p(),a();return}}};return setTimeout(()=>{document.addEventListener("mousedown",m),document.addEventListener("keydown",y)},0),g._cleanup=p,g}function he(o,t,e){const i=o._cleanup;if(typeof i=="function"){i();return}o.remove()}const br={sortAsc:{icon:"↑",labelKey:"sortAsc"},sortDesc:{icon:"↓",labelKey:"sortDesc"},clearSort:{icon:"✕",labelKey:"clearSort"},hideColumn:{icon:"👁",labelKey:"hideColumn"},freezeColumn:{icon:"❄",labelKey:"freezeColumn"},unfreezeColumn:{icon:"☀",labelKey:"unfreezeColumn"},columnVisibility:{icon:"👁",labelKey:"columnVisibility",hasSubmenu:!0}};function Lo(o,t){const e=[];let i=!1;for(let n=0;n<o.length;n++){const r=o[n];if(typeof r=="string"){const s=br[r];if(!s){console.warn(`Unknown predefined header menu action: ${r}`);continue}let l=!0;r==="sortAsc"||r==="sortDesc"?l=d=>d.column.isSortable!==!1:r==="clearSort"?l=d=>d.sortDirection!==null:r==="freezeColumn"?l=d=>!d.isFrozen:r==="unfreezeColumn"&&(l=d=>d.isFrozen);let a;r==="columnVisibility"&&(a=d=>{const u=[{id:"show-all-columns",icon:d.allColumns.every(c=>!c.isHidden)?"☑":"☐",label:d.labels.contextMenu.showAll,onclick:()=>{d.allColumns.forEach(c=>{c.isHidden=!1})}}];return d.allColumns.forEach(c=>{u.push({id:`toggle-col-${String(c.field)}`,icon:c.isHidden?"☐":"☑",label:c.title||String(c.field),onclick:()=>{c.isHidden=!c.isHidden}})}),u}),e.push({id:r,icon:s.icon,label:t.labels.contextMenu[s.labelKey],danger:s.danger,visible:l,dividerBefore:i,submenu:a}),i=!1}else r.dividerBefore&&!r.id&&!r.label?i=!0:(e.push({id:r.id||`header-menu-item-${n}`,...r,dividerBefore:i||r.dividerBefore}),i=!1)}return e}function Ao(o,t,e,i=!1){var y,_;const n=typeof o.label=="function"?o.label(t):o.label,r=typeof o.icon=="function"?o.icon(t):o.icon,s=o.shortcut,l=typeof o.disabled=="function"?o.disabled(t):o.disabled,a=o.danger===!0,d=((y=o.children)==null?void 0:y.length)||o.submenu,g=o.children||(o.submenu?o.submenu(t):[]);let u="";d&&g.length>0&&(u=`<div class="wg-context-menu wg-context-menu--submenu">${g.map((v,C)=>Ao(v,t,C,!0)).join("")}</div>`);const c=i&&((_=o.id)==null?void 0:_.startsWith("toggle-col-")),f=["wg-context-menu__item",l?"wg-context-menu__item--disabled":"",a?"wg-context-menu__item--danger":"",d?"wg-context-menu__item--has-submenu":"",c?"wg-context-menu__item--toggle":"",c&&r==="☑"?"wg-context-menu__item--checked":""].filter(Boolean).join(" "),w=o.dividerBefore&&e>0?'<div class="wg-context-menu__divider"></div>':"",p=r?`<span class="wg-context-menu__icon">${r}</span>`:"",m=s?`<span class="wg-context-menu__shortcut">${s}</span>`:"";return`${w}<div class="${f}" data-item-id="${o.id}" data-disabled="${l?"true":"false"}" data-shortcut="${s||""}">${p}<span class="wg-context-menu__label">${n}</span>${m}${u}</div>`}function Ho(o,t){const e=o.filter(n=>n.visible===void 0?!0:typeof n.visible=="function"?n.visible(t):n.visible);return e.length===0?"":`<div class="wg-context-menu">${e.map((n,r)=>Ao(n,t,r)).join("")}</div>`}function _r(o,t,e,i=!1){const{field:n,columnIndex:r}=e;switch(t){case"sortAsc":case"sortDesc":{const s=t==="sortAsc"?"asc":"desc",l=[...o.grid.sort];if(i&&o.grid.sortMode==="multi"){const a=l.findIndex(d=>d.column===n);a>=0?l[a]={column:n,direction:s}:l.push({column:n,direction:s}),o.grid.sort=l}else o.grid.sort=[{column:n,direction:s}];break}case"clearSort":o.grid.sort=o.grid.sort.filter(s=>s.column!==n);break;case"hideColumn":{const s=o.grid.columns.find(l=>String(l.field)===n);s&&(s.isHidden=!0,o.grid.columns=[...o.grid.columns]);break}case"freezeColumn":o.grid.freezeColumns=r+1;break;case"unfreezeColumn":o.grid.freezeColumns=Math.max(0,r);break}}function Oo(o,t,e,i,n,r,s){zo();const l=Ho(i,n);if(!l)return null;const a=document.createElement("div");a.className="wg-context-menu-container",a.innerHTML=l,document.body.appendChild(a);let d=a.querySelector(".wg-context-menu");Ae({getBoundingClientRect:()=>({width:0,height:0,x:t,y:e,top:e,left:t,right:t,bottom:e})},d,{placement:"bottom-start",middleware:[Le({fallbackPlacements:["top-start","bottom-end","top-end"]}),et({padding:8})]}).then(({x:w,y:p})=>{Object.assign(d.style,{left:`${w}px`,top:`${p}px`})}),a.addEventListener("click",w=>{const p=w.target.closest(".wg-context-menu__item");if(!p||p.dataset.disabled==="true")return;const m=p.dataset.itemId||"",y=w.ctrlKey;if(!p.classList.contains("wg-context-menu__item--has-submenu")){if(m.startsWith("toggle-col-")||m==="show-all-columns"){r(m,!0,y);const _=Ho(i,n),S=document.createElement("div");S.innerHTML=_;const v=S.querySelector(".wg-context-menu");if(v&&d.parentNode){v.style.left=d.style.left,v.style.top=d.style.top,d.parentNode.replaceChild(v,d),d=v;const C=v.querySelector(".wg-context-menu--submenu");C&&(C.style.display="block")}return}r(m,!1,y)}});const u=o.scrollEvents.subscribe("window",()=>{c(),s()}),c=()=>{u.unsubscribe(),document.removeEventListener("mousedown",h),document.removeEventListener("keydown",f),a.remove()},h=w=>{a.contains(w.target)||(c(),s())},f=w=>{if(w.key==="Escape"){w.preventDefault(),c(),s();return}const p=w.key.toLowerCase(),m=a.querySelectorAll(".wg-context-menu__item");for(const y of m){const _=y.dataset.shortcut;if(y.dataset.disabled==="true"||!_)continue;if(_.toLowerCase()===p||_===w.key){w.preventDefault();const C=y.dataset.itemId||"";r(C),c(),s();return}}};return setTimeout(()=>{document.addEventListener("mousedown",h),document.addEventListener("keydown",f)},0),a._cleanup=c,a}function Ye(o){const t=o.split("+").map(i=>i.trim()),e={key:"",ctrl:!1,shift:!1,alt:!1,meta:!1};for(const i of t){const n=i.toLowerCase();n==="ctrl"||n==="control"?e.ctrl=!0:n==="shift"?e.shift=!0:n==="alt"?e.alt=!0:n==="meta"||n==="cmd"||n==="command"?e.meta=!0:e.key=i}return e}function Be(o,t){if(t.ctrl!==o.ctrlKey||t.shift!==o.shiftKey||t.alt!==o.altKey||t.meta!==o.metaKey)return!1;const e=o.key.toLowerCase(),i=t.key.toLowerCase();return e===i}function vr(o){return o.split("+").map(t=>{const e=t.trim();return["ctrl","control","shift","alt","meta","cmd","command"].includes(e.toLowerCase())?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e}).join("+")}function yr(o){const{scrollTop:t,viewportHeight:e,rowHeight:i,buffer:n,totalItems:r,editingRowIndex:s}=o;let l=Math.max(0,Math.floor(t/i)-n);const a=Math.ceil(e/i)+n*2;let d=Math.min(r,l+a);return s!==void 0&&(s<l&&(l=s),s>=d&&(d=s+1)),{startIndex:l,endIndex:d}}function Cr(o){const{targetRow:t,rowHeight:e,buffer:i,totalItems:n,viewportHeight:r,scrollHeight:s,clientHeight:l}=o,a=Math.max(0,(t-1)*e),d=Math.max(0,s-l),g=Math.min(a,d);let u=Math.max(0,Math.floor(g/e)-i);const c=Math.ceil(r/e)+i*2;let h=Math.min(n,u+c);return t<u&&(u=t),t>=h&&(h=t+1),{scrollTop:g,startIndex:u,endIndex:h}}function Sr(o,t,e,i){return t-(o+e)<=i}function xr(o,t){const i=t.target.closest(".wg__header--sortable");if(!i)return;const n=i.dataset.field;if(!n)return;const r=[...o.grid.sort],s=r.findIndex(a=>a.column===n);(t.ctrlKey||t.metaKey)&&o.grid.sortMode==="multi"?s>=0?r[s].direction==="asc"?r[s]={column:n,direction:"desc"}:r.splice(s,1):r.push({column:n,direction:"asc"}):s>=0&&r.length===1?r[0].direction==="asc"?r[0]={column:n,direction:"desc"}:r.length=0:(r.length=0,r.push({column:n,direction:"asc"})),o.grid.sort=r,o.grid.isPageable&&(o.grid.currentPage=1),o.grid.fireDataRequest("sort")}function kr(o,t){const i=t.target.closest(".wg__pagination-btn");if(!i||i.hasAttribute("disabled"))return!1;const n=i.dataset.action;let r=!1;return n==="first"&&o.grid.currentPage!==1?(o.grid.currentPage=1,r=!0):n==="prev"&&o.grid.currentPage>1?(o.grid.currentPage--,r=!0):n==="next"&&o.grid.currentPage<o.grid.totalPages?(o.grid.currentPage++,r=!0):n==="last"&&o.grid.currentPage!==o.grid.totalPages&&(o.grid.currentPage=o.grid.totalPages,r=!0),r&&o.grid.fireDataRequest("page"),r}function Dr(o,t){const e=parseInt(t.value,10);return e!==o.grid.pageSize?(o.grid.pageSize=e,o.grid.currentPage=1,o.grid.fireDataRequest("pageSize"),!0):!1}let V={isResizing:!1,startX:0,startWidth:0,field:"",headerCell:null,minWidth:30,maxWidth:null},me=null;function Po(o,t){if(!o)return t;const e=parseFloat(o);return isNaN(e)?t:e}function Rr(o,t,e){const i=t.target,n=i.closest(".wg__header");if(!n)return;const r=o.grid.columns.find(a=>String(a.field)===e);if(!r||r.isResizable===!1)return;const s=n.getBoundingClientRect().width;V={isResizing:!0,startX:t.clientX,startWidth:s,field:e,headerCell:n,minWidth:Po(r.minWidth,30),maxWidth:r.maxWidth?Po(r.maxWidth,1/0):null},me=o,r.minWidth?n.style.minWidth=r.minWidth:n.style.minWidth=`${V.minWidth}px`;const l=o.shadow.querySelector(".wg");l==null||l.classList.add("wg--resizing"),i.classList.add("wg__resize-handle--active"),document.addEventListener("mousemove",Vo),document.addEventListener("mouseup",Fo),t.preventDefault()}function Vo(o){if(!V.isResizing||!me)return;const t=o.clientX-V.startX;let e=V.startWidth+t;e=Math.max(e,V.minWidth),V.maxWidth!==null&&(e=Math.min(e,V.maxWidth)),V.headerCell&&(V.headerCell.style.width=`${e}px`,V.headerCell.style.maxWidth=`${e}px`),Er(me,V.field,`${e}px`),(me.grid.freezeColumns>0||me.grid.isStickyRowNumbers)&&$r(me)}function Fo(o){if(!V.isResizing||!me)return;const t=me,e=V.field,i=`${V.startWidth}px`,n=o.clientX-V.startX;let r=V.startWidth+n;r=Math.max(r,V.minWidth),V.maxWidth!==null&&(r=Math.min(r,V.maxWidth));const s=`${r}px`;t.grid.setColumnWidth(e,s,!0);const l=t.shadow.querySelector(`col[data-field="${e}"]`);l&&(l.style.width=s);const a=t.shadow.querySelector(".wg");a==null||a.classList.remove("wg--resizing");const d=t.shadow.querySelector(".wg__resize-handle--active");d==null||d.classList.remove("wg__resize-handle--active"),t.grid.oncolumnresize&&t.grid.oncolumnresize({field:e,oldWidth:i,newWidth:s,allWidths:t.grid.getColumnWidthsState()}),t.grid.shouldPersistColumnWidths&&t.grid.gridName&&t.grid.savePersistedWidths(),document.removeEventListener("mousemove",Vo),document.removeEventListener("mouseup",Fo),V={isResizing:!1,startX:0,startWidth:0,field:"",headerCell:null,minWidth:30,maxWidth:null},me=null}function Er(o,t,e){o.shadow.querySelectorAll(`td[data-field="${t}"]`).forEach(n=>{n.style.width=e,n.style.maxWidth=e})}const Mr=40;function $r(o){const t=o.grid.freezeColumns;let i=o.grid.isRowNumbersVisible&&o.grid.isStickyRowNumbers?Mr:0;const n=o.grid.visualColumns;for(let r=0;r<t&&r<n.length;r++){const{column:s}=n[r],l=String(s.field),a=o.shadow.querySelector(`th[data-field="${l}"]`);a&&(a.style.left=`${i}px`,o.shadow.querySelectorAll(`td[data-field="${l}"]`).forEach(g=>{g.style.left=`${i}px`}),i+=a.getBoundingClientRect().width)}}const Ir=5;let $={isPending:!1,isReordering:!1,field:"",startX:0,startY:0,headerCell:null,ghost:null,dropIndicator:null,fromIndex:-1,currentDropIndex:-1},be=null,Ft=!1;function Tr(){return Ft?(Ft=!1,!0):$.isReordering}function zr(o,t,e){const i=t.target,n=i.closest(".wg__header");if(!n||i.classList.contains("wg__resize-handle"))return;const r=o.grid.visualColumns,s=o.grid.totalFrozenColumns,l=r.findIndex(d=>String(d.column.field)===e);if(l<s)return;const a=l-s;$={isPending:!0,isReordering:!1,field:e,startX:t.clientX,startY:t.clientY,headerCell:n,ghost:null,dropIndicator:null,fromIndex:a,currentDropIndex:a},be=o,document.addEventListener("mousemove",qo),document.addEventListener("mouseup",No),t.preventDefault()}function Lr(o,t,e){var n;const i=document.createElement("div");i.className="wg__reorder-ghost",i.textContent=((n=t.querySelector(".wg__header-title"))==null?void 0:n.textContent)||"",i.style.left=`${e.clientX+10}px`,i.style.top=`${e.clientY-10}px`,o.shadow.appendChild(i),$.ghost=i}function Ar(o){var e;const t=document.createElement("div");t.className="wg__drop-indicator",(e=o.shadow.querySelector(".wg"))==null||e.appendChild(t),$.dropIndicator=t}function Hr(o,t){$.isPending=!1,$.isReordering=!0;const e=o.shadow.querySelector(".wg");e==null||e.classList.add("wg--reordering"),$.headerCell&&$.headerCell.classList.add("wg__header--dragging"),$.headerCell&&Lr(o,$.headerCell,t),Ar(o)}function qo(o){if(!be)return;if($.isPending){const i=o.clientX-$.startX,n=o.clientY-$.startY;Math.sqrt(i*i+n*n)>=Ir&&Hr(be,o);return}if(!$.isReordering||!be.shadow.querySelector(".wg"))return;$.ghost&&($.ghost.style.left=`${o.clientX+10}px`,$.ghost.style.top=`${o.clientY-10}px`);const e=Or(be,o.clientX);e!==$.currentDropIndex&&($.currentDropIndex=e,Pr(be,e))}function Or(o,t){const e=o.grid.visualColumns,i=o.grid.totalFrozenColumns,n=e.slice(i);if(n.length===0)return 0;const r=String(n[0].column.field),s=o.shadow.querySelector(`th[data-field="${r}"]`);if(s){const l=s.getBoundingClientRect();if(t<l.left)return 0}for(let l=0;l<n.length;l++){const a=String(n[l].column.field),d=o.shadow.querySelector(`th[data-field="${a}"]`);if(d){const g=d.getBoundingClientRect(),u=g.left+g.width/2;if(t<u)return l}}return n.length}function Pr(o,t){const e=$.dropIndicator;if(!e)return;const i=o.grid.visualColumns,n=o.grid.totalFrozenColumns,r=i.slice(n),s=o.shadow.querySelector(".wg"),l=s==null?void 0:s.getBoundingClientRect();if(!l||!s)return;let a;if(t>=r.length){const u=String(r[r.length-1].column.field),c=o.shadow.querySelector(`th[data-field="${u}"]`);if(c)a=c.getBoundingClientRect().right-l.left+s.scrollLeft;else return}else{const u=String(r[t].column.field),c=o.shadow.querySelector(`th[data-field="${u}"]`);if(c)a=c.getBoundingClientRect().left-l.left+s.scrollLeft;else return}const d=s.scrollTop,g=s.clientHeight;e.style.left=`${a}px`,e.style.top=`${d}px`,e.style.height=`${g}px`,e.style.display="block"}function No(o){if(!be)return;const t=be;if($.isPending){Wo(t);return}if(!$.isReordering)return;const e=$.field,i=$.fromIndex,n=$.currentDropIndex;if(i!==n&&n!==i+1){const r=n>i?n-1:n;t.grid.moveColumn(e,r),t.grid.oncolumnreorder&&t.grid.oncolumnreorder({field:e,fromIndex:i,toIndex:r,allOrder:t.grid.getColumnOrderState()}),t.grid.shouldPersistColumnOrder&&t.grid.gridName&&t.grid.savePersistedState()}Ft=!0,Wo(t)}function Wo(o){$.ghost&&$.ghost.remove(),$.dropIndicator&&$.dropIndicator.remove();const t=o.shadow.querySelector(".wg");t==null||t.classList.remove("wg--reordering"),$.headerCell&&$.headerCell.classList.remove("wg__header--dragging"),document.removeEventListener("mousemove",qo),document.removeEventListener("mouseup",No),$={isPending:!1,isReordering:!1,field:"",startX:0,startY:0,headerCell:null,ghost:null,dropIndicator:null,fromIndex:-1,currentDropIndex:-1},be=null}function Vr(){const o=new Set,t=new Set;let e=null,i=!1;const n=()=>{o.forEach(s=>s())},r=()=>{t.forEach(s=>s())};return{subscribe(s,l){const a=s==="container"?o:t;return a.add(l),{unsubscribe:()=>{a.delete(l)}}},init(s){e=s,s.addEventListener("scroll",n),i||(window.addEventListener("scroll",r,{capture:!0,passive:!0}),i=!0)},destroy(){e&&(e.removeEventListener("scroll",n),e=null),i&&(window.removeEventListener("scroll",r,!0),i=!1),o.clear(),t.clear()}}}function Fr(o,t){const e=new Set,i=new Set;let n=null;const r=l=>{const a=l.target,d=l.relatedTarget;e.forEach(g=>g(a,d))},s=l=>{const a=l.target,d=l.relatedTarget;i.forEach(g=>g(a,d))};return{subscribe(l,a){const d=l==="blur"?e:i;return d.add(a),{unsubscribe:()=>{d.delete(a)}}},shouldSkipBlur(){const l=o();return l.isClosingViaToggle?(t(),!0):l.isCommittingFromKeyboard||l.isTransitioningCells||l.isOpeningDropdown},init(l){n=l,l.addEventListener("blur",r,!0),l.addEventListener("focusout",s)},destroy(){n&&(n.removeEventListener("blur",r,!0),n.removeEventListener("focusout",s),n=null),e.clear(),i.clear()}}}const qr=5;let R={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,rangeBorder:null},se=null;function Yo(o,t,e,i){var l;const n=i.shiftKey&&o.grid.cellSelectionMode==="shift";o.grid.selectedCellRange&&!n&&(o.grid.clearCellSelection(),fe()),(l=o.grid.visualColumns[e])!=null&&l.column&&(R={...R,isPending:!0,isDragging:!1,startRowIndex:t,startColIndex:e,startX:i.clientX,startY:i.clientY,currentRowIndex:t,currentColIndex:e},se=o,document.addEventListener("mousemove",Bo),document.addEventListener("mouseup",jo),document.addEventListener("keydown",Ko))}function Nr(o,t,e){var i,n;if(fe(),o.grid.lastClickedCell){const{rowIndex:r,colIndex:s}=o.grid.lastClickedCell,l=o.grid.visualColumns,a=(i=l[s])==null?void 0:i.column,d=(n=l[e])==null?void 0:n.column;if(a&&d){const g={startRowIndex:r,startColIndex:s,endRowIndex:t,endColIndex:e,startField:String(a.field),endField:String(d.field)};o.grid.clearFocusedCell(),o.grid.selectCellRange(g),Nt(o),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const u=o.shadow.querySelector(".wg");u==null||u.focus({preventScroll:!0})})})}}else o.grid.lastClickedCell={rowIndex:t,colIndex:e}}function Bo(o){if(!se)return;if(R.isPending){const e=o.clientX-R.startX,i=o.clientY-R.startY;Math.sqrt(e*e+i*i)>=qr&&Wr(se);return}if(!R.isDragging)return;const t=Yr(se,o.clientX,o.clientY);t&&(t.rowIndex!==R.currentRowIndex||t.colIndex!==R.currentColIndex)&&(R.currentRowIndex=t.rowIndex,R.currentColIndex=t.colIndex,Uo(se),Ur(se))}function Wr(o){R.isPending=!1,R.isDragging=!0;const t=o.shadow.querySelector(".wg");t==null||t.classList.add("wg--selecting-cells");const e=o.shadow.querySelector(`[data-row="${R.startRowIndex}"][data-col="${R.startColIndex}"]`);e&&e.classList.add("wg__cell--dragging-from"),Uo(o),qt(o)}function Uo(o){const{startRowIndex:t,startColIndex:e,currentRowIndex:i,currentColIndex:n}=R,r=Math.min(t,i),s=Math.max(t,i),l=Math.min(e,n),a=Math.max(e,n);o.shadow.querySelectorAll(".wg__cell--in-range").forEach(g=>g.classList.remove("wg__cell--in-range"));for(let g=r;g<=s;g++)for(let u=l;u<=a;u++){const c=o.shadow.querySelector(`[data-row="${g}"][data-col="${u}"]`);c&&c.classList.add("wg__cell--in-range")}}function jo(o){if(!se)return;const t=se;if(R.isPending){o.shiftKey&&t.grid.cellSelectionMode==="shift"&&t.grid.lastClickedCell?Nr(t,R.startRowIndex,R.startColIndex):t.grid.lastClickedCell={rowIndex:R.startRowIndex,colIndex:R.startColIndex},st(t);return}if(!R.isDragging)return;const e=t.shadow.querySelector(`[data-row="${R.startRowIndex}"][data-col="${R.startColIndex}"]`);e&&e.classList.remove("wg__cell--dragging-from"),R.startRowIndex===R.currentRowIndex&&R.startColIndex===R.currentColIndex?(t.shadow.querySelectorAll(".wg__cell--in-range").forEach(r=>r.classList.remove("wg__cell--in-range")),fe(),st(t)):(Br(t),st(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const n=t.shadow.querySelector(".wg");n==null||n.focus({preventScroll:!0})})}))}function Ko(o){o.key==="Escape"&&se&&(o.preventDefault(),st(se))}function Yr(o,t,e){if(!o.shadow.querySelector(".wg"))return null;const n=o.shadow.querySelectorAll(".wg__cell[data-row][data-col]");for(const r of n){const s=r.getBoundingClientRect();if(t>=s.left&&t<=s.right&&e>=s.top&&e<=s.bottom){const l=parseInt(r.dataset.row||"-1",10),a=parseInt(r.dataset.col||"-1",10);if(l>=0&&a>=0)return{rowIndex:l,colIndex:a}}}return null}function Br(o){var d,g;const{startRowIndex:t,startColIndex:e,currentRowIndex:i,currentColIndex:n}=R,r=o.grid.visualColumns,s=(d=r[e])==null?void 0:d.column,l=(g=r[n])==null?void 0:g.column;if(!s||!l)return;const a={startRowIndex:t,startColIndex:e,endRowIndex:i,endColIndex:n,startField:String(s.field),endField:String(l.field)};o.grid.clearFocusedCell(),o.grid.selectCellRange(a),Nt(o)}function qt(o){fe();const{startRowIndex:t,startColIndex:e,currentRowIndex:i,currentColIndex:n}=R,r=o.shadow.querySelector(".wg");if(!r)return;const s=Math.min(t,i),l=Math.max(t,i),a=Math.min(e,n),d=Math.max(e,n),g=o.shadow.querySelector(`[data-row="${s}"][data-col="${a}"]`),u=o.shadow.querySelector(`[data-row="${l}"][data-col="${d}"]`);if(!g||!u)return;const c=r.getBoundingClientRect(),h=g.getBoundingClientRect(),f=u.getBoundingClientRect(),w=r.scrollLeft,p=r.scrollTop,m=h.left-c.left+w-r.clientLeft,y=h.top-c.top+p-r.clientTop,_=f.right-h.left,S=f.bottom-h.top,v=document.createElement("div");v.className="wg__cell-range-border",v.style.left=`${m}px`,v.style.top=`${y}px`,v.style.width=`${_}px`,v.style.height=`${S}px`,r.appendChild(v),R.rangeBorder=v}function Ur(o){qt(o)}function Nt(o){fe();const t=o.grid.selectedCellRange;if(!t)return;const e=o.shadow.querySelector(".wg");if(!e)return;const{startRowIndex:i,endRowIndex:n,startColIndex:r,endColIndex:s}=t,l=Math.min(i,n),a=Math.max(i,n),d=Math.min(r,s),g=Math.max(r,s),u=o.shadow.querySelector(`[data-row="${l}"][data-col="${d}"]`),c=o.shadow.querySelector(`[data-row="${a}"][data-col="${g}"]`);if(!u||!c)return;const h=e.getBoundingClientRect(),f=u.getBoundingClientRect(),w=c.getBoundingClientRect(),p=e.scrollLeft,m=e.scrollTop,y=f.left-h.left+p-e.clientLeft,_=f.top-h.top+m-e.clientTop,S=w.right-f.left,v=w.bottom-f.top,C=document.createElement("div");C.className="wg__cell-range-border",C.style.left=`${y}px`,C.style.top=`${_}px`,C.style.width=`${S}px`,C.style.height=`${v}px`,e.appendChild(C),R.rangeBorder=C}function Xo(o){R.rangeBorder&&(fe(),R.isDragging?qt(o):Nt(o))}function fe(){R.rangeBorder&&(R.rangeBorder.remove(),R.rangeBorder=null)}function st(o){const t=o.shadow.querySelector(".wg");if(t==null||t.classList.remove("wg--selecting-cells"),R.startRowIndex>=0&&R.startColIndex>=0){const i=o.shadow.querySelector(`[data-row="${R.startRowIndex}"][data-col="${R.startColIndex}"]`);i&&i.classList.remove("wg__cell--dragging-from")}document.removeEventListener("mousemove",Bo),document.removeEventListener("mouseup",jo),document.removeEventListener("keydown",Ko),R={isPending:!1,isDragging:!1,startRowIndex:-1,startColIndex:-1,startX:0,startY:0,currentRowIndex:-1,currentColIndex:-1,rangeBorder:R.rangeBorder},se=null}const jr=5;let le={isPending:!1,isDragging:!1,startRowIndex:-1,startX:0,startY:0,currentRowIndex:-1},Ce=null;function Kr(o,t,e){if(e.preventDefault(),e.stopPropagation(),o.grid.selectedCellRange&&(o.grid.clearCellSelection(),fe()),e.ctrlKey||e.metaKey){o.grid.selectRow(t,"toggle"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=o.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})});return}if(e.shiftKey){o.grid.selectRow(t,"range"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=o.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})});return}le={isPending:!0,isDragging:!1,startRowIndex:t,startX:e.clientX,startY:e.clientY,currentRowIndex:t},Ce=o,o.grid.selectRow(t,"replace"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const i=o.shadow.querySelector(".wg");i==null||i.focus({preventScroll:!0})})}),document.addEventListener("mousemove",Go),document.addEventListener("mouseup",Qo)}function Go(o){if(!Ce)return;if(le.isPending){const e=o.clientX-le.startX,i=o.clientY-le.startY;Math.sqrt(e*e+i*i)>=jr&&Xr(Ce);return}if(!le.isDragging)return;const t=Gr(Ce,o.clientY);t!==null&&t!==le.currentRowIndex&&(le.currentRowIndex=t,Ce.grid.selectRowRange(le.startRowIndex,t))}function Xr(o){le.isPending=!1,le.isDragging=!0;const t=o.shadow.querySelector(".wg");t==null||t.classList.add("wg--selecting")}function Qo(){if(!Ce)return;const o=Ce,t=o.shadow.querySelector(".wg");t==null||t.classList.remove("wg--selecting"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=o.shadow.querySelector(".wg");e==null||e.focus({preventScroll:!0})})}),document.removeEventListener("mousemove",Go),document.removeEventListener("mouseup",Qo),le={isPending:!1,isDragging:!1,startRowIndex:-1,startX:0,startY:0,currentRowIndex:-1},Ce=null}function Gr(o,t){const e=o.shadow.querySelectorAll(".wg__row[data-row-index]");for(const i of e){const n=i.getBoundingClientRect();if(t>=n.top&&t<=n.bottom){const r=parseInt(i.dataset.rowIndex||"-1",10);if(r>=0)return r}}if(e.length>0){const i=e[0],n=e[e.length-1],r=i.getBoundingClientRect(),s=n.getBoundingClientRect();if(t<r.top)return parseInt(i.dataset.rowIndex||"0",10);if(t>s.bottom)return parseInt(n.dataset.rowIndex||"0",10)}return null}class Wt extends HTMLElement{constructor(){super();b(this,"grid");b(this,"shadow");b(this,"styleElement");b(this,"customStyleElement",null);b(this,"updatePending",!1);b(this,"isCommittingFromKeyboard",!1);b(this,"isTransitioningCells",!1);b(this,"toolbarOutsideClickAdded",!1);b(this,"toolbarMoveInProgress",!1);b(this,"toolbarHideTimeout",null);b(this,"toolbarHovered",!1);b(this,"toolbarShortcutHandler",null);b(this,"inlineShortcutHandler",null);b(this,"dropdownOpen",!1);b(this,"dropdownOptions",[]);b(this,"highlightedIndex",-1);b(this,"filterText","");b(this,"isUserFiltering",!1);b(this,"justSelected",!1);b(this,"isOpeningDropdown",!1);b(this,"isClosingViaToggle",!1);b(this,"isProgrammaticScroll",!1);b(this,"searchDebounceTimer",null);b(this,"searchAbortController",null);b(this,"isSearching",!1);b(this,"tooltipElement",null);b(this,"tooltipArrowElement",null);b(this,"tooltipAnchor",null);b(this,"tooltipShowTimer",null);b(this,"tooltipHideTimer",null);b(this,"_tooltipShowDelay",400);b(this,"_tooltipHideDelay",100);b(this,"datepicker",null);b(this,"contextMenuElement",null);b(this,"headerContextMenuElement",null);b(this,"virtualScrollStart",0);b(this,"virtualScrollEnd",0);b(this,"isLoadingMoreItems",!1);b(this,"scrollEvents");b(this,"focusEvents");b(this,"handlePaste",e=>{var d;if(!this.grid.isNavigateMode||this.grid.editingCell||!this.grid.focusedCell)return;const{rowIndex:i,colIndex:n}=this.grid.focusedCell,r=this.grid.columns[n],s=this.grid.displayItems[i];if(!r||!s||!this.grid.isCellEditable(r))return;e.preventDefault();let l=((d=e.clipboardData)==null?void 0:d.getData("text"))||"";if(r.beforePasteCallback){const g=r.beforePasteCallback(l,s);l=g!=null?String(g):""}const a=String(r.field);this.grid.commitEdit(i,a,l),this.render()});this.shadow=this.attachShadow({mode:"open"}),this.grid=new po,this.scrollEvents=Vr(),this.focusEvents=Fr(()=>({isCommittingFromKeyboard:this.isCommittingFromKeyboard,isTransitioningCells:this.isTransitioningCells,isClosingViaToggle:this.isClosingViaToggle,isOpeningDropdown:this.isOpeningDropdown}),()=>{this.isClosingViaToggle=!1}),this.styleElement=document.createElement("style"),this.styleElement.textContent=Sn,this.shadow.appendChild(this.styleElement),this.grid.requestUpdate=()=>this.requestUpdate(),this.grid._onInteractionChange=(e,i)=>{e==="editingCell"&&i.current===null&&B(this)}}get tooltipShowDelay(){return this._tooltipShowDelay}set tooltipShowDelay(e){this._tooltipShowDelay=e}get tooltipHideDelay(){return this._tooltipHideDelay}set tooltipHideDelay(e){this._tooltipHideDelay=e}connectedCallback(){this.grid.gridName&&this.grid.shouldPersistColumnWidths&&this.grid.loadPersistedWidths(),this.render(),this.addEventListener("paste",this.handlePaste)}disconnectedCallback(){this.scrollEvents.destroy(),this.focusEvents.destroy(),this.removeEventListener("paste",this.handlePaste),this.datepicker&&(this.datepicker.destroy(),this.datepicker=null),this.contextMenuElement&&(he(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(he(this.headerContextMenuElement),this.headerContextMenuElement=null),ot(),this.removeInlineShortcuts()}get items(){return this.grid.items}set items(e){this.grid.items=e,this.isLoadingMoreItems=!1}get columns(){return this.grid.columns}set columns(e){this.grid.columns=e}get isFilterable(){return this.grid.isFilterable}set isFilterable(e){this.grid.isFilterable=e}get isPageable(){return this.grid.isPageable}set isPageable(e){this.grid.isPageable=e}get pageSize(){return this.grid.pageSize}set pageSize(e){this.grid.pageSize=e}get pageSizes(){return this.grid.pageSizes}set pageSizes(e){this.grid.pageSizes=e}get isStriped(){return this.grid.isStriped}set isStriped(e){this.grid.isStriped=e}get isHoverable(){return this.grid.isHoverable}set isHoverable(e){this.grid.isHoverable=e}get isEditable(){return this.grid.isEditable}set isEditable(e){this.grid.isEditable=e}get editTrigger(){return this.grid.editTrigger}set editTrigger(e){this.grid.editTrigger=e}get editStartSelection(){return this.grid.editStartSelection}set editStartSelection(e){this.grid.editStartSelection=e}get mode(){return this.grid.mode}set mode(e){this.grid.mode=e}get dropdownToggleVisibility(){return this.grid.dropdownToggleVisibility}set dropdownToggleVisibility(e){this.grid.dropdownToggleVisibility=e}get shouldShowDropdownOnFocus(){return this.grid.shouldShowDropdownOnFocus}set shouldShowDropdownOnFocus(e){this.grid.shouldShowDropdownOnFocus=e}get shouldOpenDropdownOnEnter(){return this.grid.shouldOpenDropdownOnEnter}set shouldOpenDropdownOnEnter(e){this.grid.shouldOpenDropdownOnEnter=e}get isCheckboxAlwaysEditable(){return this.grid.isCheckboxAlwaysEditable}set isCheckboxAlwaysEditable(e){this.grid.isCheckboxAlwaysEditable=e}get isRowNumbersVisible(){return this.grid.isRowNumbersVisible}set isRowNumbersVisible(e){this.grid.isRowNumbersVisible=e}get isStickyRowNumbers(){return this.grid.isStickyRowNumbers}set isStickyRowNumbers(e){this.grid.isStickyRowNumbers=e}get freezeColumns(){return this.grid.freezeColumns}set freezeColumns(e){this.grid.freezeColumns=e}get invalidCells(){return this.grid.invalidCells}set invalidCells(e){this.grid.invalidCells=e}get isRowToolbarVisible(){return this.grid.isRowToolbarVisible}set isRowToolbarVisible(e){this.grid.isRowToolbarVisible=e}get rowToolbar(){return this.grid.rowToolbar}set rowToolbar(e){this.grid.rowToolbar=e}get toolbarVerticalAlign(){return this.grid.toolbarVerticalAlign}set toolbarVerticalAlign(e){this.grid.toolbarVerticalAlign=e}get toolbarHorizontalAlign(){return this.grid.toolbarHorizontalAlign}set toolbarHorizontalAlign(e){this.grid.toolbarHorizontalAlign=e}get toolbarAlign(){return this.grid.toolbarVerticalAlign}set toolbarAlign(e){this.grid.toolbarVerticalAlign=e}get toolbarTopPosition(){return this.grid.toolbarHorizontalAlign}set toolbarTopPosition(e){this.grid.toolbarHorizontalAlign=e}get toolbarTrigger(){return this.grid.toolbarTrigger}set toolbarTrigger(e){this.grid.toolbarTrigger=e}get toolbarPosition(){return this.grid.toolbarPosition}set toolbarPosition(e){this.grid.toolbarPosition=e}get inlineActionsTitle(){return this.grid.inlineActionsTitle}set inlineActionsTitle(e){this.grid.inlineActionsTitle=e}get contextMenu(){return this.grid.contextMenu}set contextMenu(e){this.grid.contextMenu=e}get contextMenuXOffset(){return this.grid.contextMenuXOffset}set contextMenuXOffset(e){this.grid.contextMenuXOffset=e}get contextMenuYOffset(){return this.grid.contextMenuYOffset}set contextMenuYOffset(e){this.grid.contextMenuYOffset=e}get headerContextMenu(){return this.grid.headerContextMenu}set headerContextMenu(e){this.grid.headerContextMenu=e}set onheadercontextmenuopen(e){this.grid.onheadercontextmenuopen=e}get rowShortcuts(){return this.grid.rowShortcuts}set rowShortcuts(e){this.grid.rowShortcuts=e}get rangeShortcuts(){return this.grid.rangeShortcuts}set rangeShortcuts(e){this.grid.rangeShortcuts=e}get selectedRows(){return this.grid.selectedRows}selectRow(e,i="replace"){this.grid.selectRow(e,i)}selectRowRange(e,i){this.grid.selectRowRange(e,i)}clearSelection(){this.grid.clearSelection()}isRowSelected(e){return this.grid.isRowSelected(e)}getSelectedRowsData(){return this.grid.getSelectedRowsData()}copySelectedRowsToClipboard(){return this.grid.copySelectedRowsToClipboard()}get cellSelectionMode(){return this.grid.cellSelectionMode}set cellSelectionMode(e){this.grid.cellSelectionMode=e}get selectedCellRange(){return this.grid.selectedCellRange}selectCellRange(e){this.grid.selectCellRange(e)}clearCellSelection(){this.grid.clearCellSelection()}getSelectedCells(){return this.grid.getSelectedCells()}copyCellSelectionToClipboard(){return this.grid.copyCellSelectionToClipboard()}get shouldCopyWithHeaders(){return this.grid.shouldCopyWithHeaders}set shouldCopyWithHeaders(e){this.grid.shouldCopyWithHeaders=e}get oncellselectionchange(){return this.grid.oncellselectionchange}set oncellselectionchange(e){this.grid.oncellselectionchange=e}get isShortcutsHelpVisible(){return this.grid.isShortcutsHelpVisible}set isShortcutsHelpVisible(e){this.grid.isShortcutsHelpVisible=e}get shortcutsHelpPosition(){return this.grid.shortcutsHelpPosition}set shortcutsHelpPosition(e){this.grid.shortcutsHelpPosition=e}get shortcutsHelpContentCallback(){return this.grid.shortcutsHelpContentCallback}set shortcutsHelpContentCallback(e){this.grid.shortcutsHelpContentCallback=e}set onrowchange(e){this.grid.onrowchange=e}set onroweditstart(e){this.grid.onroweditstart=e}set onroweditcancel(e){this.grid.onroweditcancel=e}set onvalidationerror(e){this.grid.onvalidationerror=e}get validationTooltipCallback(){return this.grid.validationTooltipCallback}set validationTooltipCallback(e){this.grid.validationTooltipCallback=e}set ontoolbarclick(e){this.grid.ontoolbarclick=e}set onrowaction(e){this.grid.onrowaction=e}set oncontextmenuopen(e){this.grid.oncontextmenuopen=e}get ondatarequest(){return this.grid.ondatarequest}set ondatarequest(e){this.grid.ondatarequest=e}get onrowdelete(){return this.grid.onrowdelete}set onrowdelete(e){this.grid.onrowdelete=e}get sort(){return this.grid.sort}set sort(e){this.grid.sort=e}get sortMode(){return this.grid.sortMode}set sortMode(e){this.grid.sortMode=e}get currentPage(){return this.grid.currentPage}set currentPage(e){this.grid.currentPage=e}get totalItems(){return this.grid.totalItems}set totalItems(e){this.grid.totalItems=e}get showPagination(){return this.grid.showPagination}set showPagination(e){this.grid.showPagination=e}get paginationPosition(){return this.grid.paginationPosition}set paginationPosition(e){this.grid.paginationPosition=e}get paginationLabelsCallback(){return this.grid.paginationLabelsCallback}set paginationLabelsCallback(e){this.grid.paginationLabelsCallback=e}get paginationLayout(){return this.grid.paginationLayout}set paginationLayout(e){this.grid.paginationLayout=e}get summaryPosition(){return this.grid.summaryPosition}set summaryPosition(e){this.grid.summaryPosition=e}get summaryContentCallback(){return this.grid.summaryContentCallback}set summaryContentCallback(e){this.grid.summaryContentCallback=e}get customStylesCallback(){return this.grid.customStylesCallback}set customStylesCallback(e){this.grid.customStylesCallback=e,this.updateCustomStyles()}get rowClassCallback(){return this.grid.rowClassCallback}set rowClassCallback(e){this.grid.rowClassCallback=e}get labels(){return this.grid.labels}set labels(e){this.grid.labels=e}get summaryMetadata(){return this.grid.summaryMetadata}set summaryMetadata(e){this.grid.summaryMetadata=e}get isSummaryInline(){return this.grid.isSummaryInline}set isSummaryInline(e){this.grid.isSummaryInline=e}get idValueMember(){return this.grid.idValueMember}set idValueMember(e){this.grid.idValueMember=e}get idValueCallback(){return this.grid.idValueCallback}set idValueCallback(e){this.grid.idValueCallback=e}get rowLocking(){return this.grid.rowLocking}set rowLocking(e){this.grid.rowLocking=e}get onrowlockchange(){return this.grid.onrowlockchange}set onrowlockchange(e){this.grid.onrowlockchange=e}get gridName(){return this.grid.gridName}set gridName(e){this.grid.gridName=e,this.tryLoadPersistedWidths()}get shouldPersistColumnWidths(){return this.grid.shouldPersistColumnWidths}set shouldPersistColumnWidths(e){this.grid.shouldPersistColumnWidths=e,this.tryLoadPersistedState()}get isColumnReorderAllowed(){return this.grid.isColumnReorderAllowed}set isColumnReorderAllowed(e){this.grid.isColumnReorderAllowed=e}get shouldPersistColumnOrder(){return this.grid.shouldPersistColumnOrder}set shouldPersistColumnOrder(e){this.grid.shouldPersistColumnOrder=e,this.tryLoadPersistedState()}tryLoadPersistedState(){this.grid.gridName&&(this.grid.shouldPersistColumnWidths||this.grid.shouldPersistColumnOrder)&&(this.grid.loadPersistedState(),this.isConnected&&this.render())}tryLoadPersistedWidths(){this.tryLoadPersistedState()}get oncolumnresize(){return this.grid.oncolumnresize}set oncolumnresize(e){this.grid.oncolumnresize=e}get oncolumnreorder(){return this.grid.oncolumnreorder}set oncolumnreorder(e){this.grid.oncolumnreorder=e}get fillDragCallback(){return this.grid.fillDragCallback}set fillDragCallback(e){this.grid.fillDragCallback=e}get isVirtualScrollEnabled(){return this.grid.isVirtualScrollEnabled}set isVirtualScrollEnabled(e){this.grid.isVirtualScrollEnabled=e}get virtualScrollThreshold(){return this.grid.virtualScrollThreshold}set virtualScrollThreshold(e){this.grid.virtualScrollThreshold=e}get virtualScrollRowHeight(){return this.grid.virtualScrollRowHeight}set virtualScrollRowHeight(e){this.grid.virtualScrollRowHeight=e}get virtualScrollBuffer(){return this.grid.virtualScrollBuffer}set virtualScrollBuffer(e){this.grid.virtualScrollBuffer=e}get isInfiniteScrollEnabled(){return this.grid.isInfiniteScrollEnabled}set isInfiniteScrollEnabled(e){this.grid.isInfiniteScrollEnabled=e}get infiniteScrollThreshold(){return this.grid.infiniteScrollThreshold}set infiniteScrollThreshold(e){this.grid.infiniteScrollThreshold=e}get hasMoreItems(){return this.grid.hasMoreItems}set hasMoreItems(e){this.grid.hasMoreItems=e}get displayItems(){return this.grid.displayItems}get totalPages(){return this.grid.totalPages}get isNavigateMode(){return this.grid.isNavigateMode}getRowDraft(e){return this.grid.getRowDraft(e)}hasRowDraft(e){return this.grid.hasRowDraft(e)}discardRowDraft(e){this.grid.discardRowDraft(e)}getDraftRowIndices(){return this.grid.getDraftRowIndices()}discardAllDrafts(){this.grid.discardAllDrafts()}isCellInvalid(e,i){return this.grid.isCellInvalid(e,i)}getCellValidationError(e,i){return this.grid.getCellValidationError(e,i)}getRowId(e){return this.grid.getRowId(e)}findRowById(e){return this.grid.findRowById(e)}isRowLocked(e){return this.grid.isRowLocked(e)}getRowLockInfo(e){return this.grid.getRowLockInfo(e)}lockRowById(e,i){return this.grid.lockRowById(e,i)}unlockRowById(e){return this.grid.unlockRowById(e)}getExternalLocks(){return this.grid.getExternalLocks()}clearExternalLocks(){this.grid.clearExternalLocks()}updateRowById(e,i){return this.grid.updateRowById(e,i)}replaceRowById(e,i){return this.grid.replaceRowById(e,i)}canEditCell(e,i){return this.grid.canEditCell(e,i)}setColumnWidth(e,i){this.grid.setColumnWidth(e,i)}setColumnWidths(e){this.grid.setColumnWidths(e)}getColumnWidthsState(){return this.grid.getColumnWidthsState()}setColumnOrder(e){this.grid.setColumnOrder(e)}getColumnOrderState(){return this.grid.getColumnOrderState()}focusCell(e,i){const n=this.grid.columns,r=this.grid.displayItems;e<0||e>=r.length||i<0||i>=n.length||(this.grid.setFocusedCell(e,i),requestAnimationFrame(()=>{L(this,e,i)}))}startEditing(e,i){const n=this.grid.columns;if(i<0||i>=n.length)return;const r=n[i],s=String(r.field);this.grid.startEdit(e,s);const l=this.shadow.querySelector(`td[data-row="${e}"][data-col="${i}"]`);l&&(l.classList.remove("wg__cell--focused"),l.classList.add("wg__cell--editing"),l.innerHTML=nt(this,e,i,r))}escapeHtml(e){const i=document.createElement("div");return i.textContent=e,i.innerHTML}getCurrentEditingColumn(){const e=this.grid.editingCell;return e&&this.grid.columns.find(i=>String(i.field)===e.field)||null}getCurrentEditorOptions(){const e=this.getCurrentEditingColumn();return(e==null?void 0:e.editorOptions)||{}}moveFocusAfterCommit(e,i,n){Lt(this,e,i,n)}requestUpdate(){this.updatePending||(this.updatePending=!0,queueMicrotask(()=>{this.updatePending=!1,this.render()}))}updateCustomStyles(){const e=this.grid.customStylesCallback;if(e){const i=e();this.customStyleElement||(this.customStyleElement=document.createElement("style"),this.shadow.appendChild(this.customStyleElement)),this.customStyleElement.textContent=i}else this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}handleCellKeyDown(e,i,n){var u;if(!this.grid.isNavigateMode)return;const r=this.grid.columns,s=this.grid.displayItems,l=this.grid.getEditableColumns(),a=l.findIndex(c=>c.index===n);if((e.ctrlKey||e.metaKey)&&e.key==="c"){const c=r[n],h=s[i];if(c&&h){let f=this.grid.getCellRawValue(h,i,String(c.field));c.beforeCopyCallback&&(f=c.beforeCopyCallback(f,h));const w=f!=null?String(f):"";navigator.clipboard.writeText(w)}return}const d=this.grid.selectedRows;if(d.length>0){const c=this.grid.rangeShortcuts;if(c&&c.length>0)for(const h of c){const f=Ye(h.key);if(Be(e,f)){const w={rows:this.grid.getSelectedRowsData(),rowIndices:d};if(!(typeof h.disabled=="function"?h.disabled(w):h.disabled===!0)){e.preventDefault(),h.action(w);return}}}}const g=this.grid.rowShortcuts;if(g&&g.length>0){const c=r[n],h=s[i];if(c&&h)for(const f of g){const w=Ye(f.key);if(Be(e,w)){const p={row:h,rowIndex:i,colIndex:n,column:c,cellValue:this.grid.getCellRawValue(h,i,String(c.field))};if(!(typeof f.disabled=="function"?f.disabled(p):f.disabled===!0)){e.preventDefault(),f.action(p);return}}}}switch(e.key){case"ArrowUp":e.preventDefault(),i>0&&L(this,i-1,n);break;case"ArrowDown":e.preventDefault(),i<s.length-1&&L(this,i+1,n);break;case"ArrowLeft":e.preventDefault(),n>0&&L(this,i,n-1);break;case"ArrowRight":e.preventDefault(),n<r.length-1&&L(this,i,n+1);break;case"Tab":if(e.preventDefault(),e.shiftKey){if(a>0){const c=l[a-1].index;L(this,i,c)}else if(i>0){const c=l[l.length-1].index;L(this,i-1,c)}}else if(a>=0&&a<l.length-1){const c=l[a+1].index;L(this,i,c)}else if(a===-1&&l.length>0)L(this,i,l[0].index);else if(i<s.length-1){const c=l[0].index;L(this,i+1,c)}break;case"Home":if(e.preventDefault(),e.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const c=this.grid.focusedCell;this.grid.setFocusedCell(0,0),this.scrollToRowProgrammatically(0);const h=this.shadow.querySelector('td[data-row="0"][data-col="0"]');h&&(h.focus({preventScroll:!0}),ee(this,c,{rowIndex:0,colIndex:0}))}else L(this,0,0);else L(this,i,0);break;case"End":if(e.preventDefault(),e.ctrlKey){const c=s.length-1,h=r.length-1;if(this.grid.shouldUseVirtualScroll()){const f=this.grid.focusedCell;this.grid.setFocusedCell(c,h),this.scrollToRowProgrammatically(c);const w=this.shadow.querySelector(`td[data-row="${c}"][data-col="${h}"]`);w&&(w.focus({preventScroll:!0}),ee(this,f,{rowIndex:c,colIndex:h}))}else L(this,c,h)}else L(this,i,r.length-1);break;case"PageUp":if(e.preventDefault(),e.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const c=this.grid.focusedCell;this.grid.setFocusedCell(0,n),this.scrollToRowProgrammatically(0);const h=this.shadow.querySelector(`td[data-row="0"][data-col="${n}"]`);h&&(h.focus({preventScroll:!0}),ee(this,c,{rowIndex:0,colIndex:n}))}else L(this,0,n);else{const c=Math.max(0,i-10);if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(c,n),this.scrollToRowProgrammatically(c);const f=this.shadow.querySelector(`td[data-row="${c}"][data-col="${n}"]`);f&&(f.focus({preventScroll:!0}),ee(this,h,{rowIndex:c,colIndex:n}))}else L(this,c,n)}break;case"PageDown":if(e.preventDefault(),e.ctrlKey){const c=s.length-1;if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(c,n),this.scrollToRowProgrammatically(c);const f=this.shadow.querySelector(`td[data-row="${c}"][data-col="${n}"]`);f&&(f.focus({preventScroll:!0}),ee(this,h,{rowIndex:c,colIndex:n}))}else L(this,c,n)}else{const c=Math.min(s.length-1,i+10);if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(c,n),this.scrollToRowProgrammatically(c);const f=this.shadow.querySelector(`td[data-row="${c}"][data-col="${n}"]`);f&&(f.focus({preventScroll:!0}),ee(this,h,{rowIndex:c,colIndex:n}))}else L(this,c,n)}break;case"g":case"G":e.ctrlKey&&(e.preventDefault(),this.showGoToRowDialog(n));break;case"Enter":{e.preventDefault();const c=r[n];((c==null?void 0:c.editor)==="select"||(c==null?void 0:c.editor)==="combobox"||(c==null?void 0:c.editor)==="autocomplete")&&this.grid.getEffectiveShouldOpenDropdownOnEnter(c)?(oe(this,i,n),requestAnimationFrame(()=>{this.dropdownOpen||re(this)})):i<s.length-1&&L(this,i+1,n);break}case"F2":{e.preventDefault();const c=r[n],h=(c==null?void 0:c.editor)==="select"||(c==null?void 0:c.editor)==="combobox"||(c==null?void 0:c.editor)==="autocomplete",f=(c==null?void 0:c.editor)==="custom";oe(this,i,n),h?requestAnimationFrame(()=>{this.dropdownOpen||re(this)}):f&&requestAnimationFrame(()=>{this.openCustomEditor(i,n)});break}case" ":{e.preventDefault();const c=r[n],h=(c==null?void 0:c.editor)==="checkbox",f=(c==null?void 0:c.editor)==="select"||(c==null?void 0:c.editor)==="combobox"||(c==null?void 0:c.editor)==="autocomplete",w=(c==null?void 0:c.editor)==="date",p=(c==null?void 0:c.editor)==="custom";h?Yn(this,i,n):f?(oe(this,i,n),requestAnimationFrame(()=>{this.dropdownOpen||re(this)})):w?(oe(this,i,n),requestAnimationFrame(()=>{var S;const m=(S=this.shadowRoot)==null?void 0:S.querySelector(`.wg__cell[data-row="${i}"][data-col="${n}"]`),y=m==null?void 0:m.querySelector(".wg__date-input"),_=m==null?void 0:m.querySelector(".wg__editor--date");y&&_&&this.openDatePicker(y,_)})):p&&(oe(this,i,n),requestAnimationFrame(()=>{this.openCustomEditor(i,n)}));break}case"Escape":if(e.preventDefault(),this.grid.editingCell)te(this),this.grid.cancelEdit();else if(this.grid.selectedRows.length>0)this.grid.clearSelection();else{const c=this.grid.focusedCell;this.grid.clearFocusedCell(),ee(this,c,null),(u=e.target)==null||u.blur()}break;case"Delete":{e.preventDefault();const c=r[n],h=s[i];if(e.ctrlKey){if(h){const f={rowIndex:i,row:h};this.grid.onrowdelete&&this.grid.onrowdelete(f),this.dispatchEvent(new CustomEvent("rowdelete",{detail:f}))}}else c&&this.grid.isCellEditable(c)&&(this.grid.commitEdit(i,String(c.field),null),this.render(),requestAnimationFrame(()=>{const f=this.shadow.querySelector(`td[data-row="${i}"][data-col="${n}"]`);f==null||f.focus()}));break}default:if(e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey){const c=r[n];if((c==null?void 0:c.editor)==="number"&&!/[\d.\-]/.test(e.key))return;oe(this,i,n,{initialSearchQuery:e.key}),e.preventDefault()}break}}handleEditorKeyDown(e,i){const n=parseInt(i.dataset.row||"0",10),r=i.dataset.field||"",s=this.grid.columns.find(g=>g.field===r),l=(s==null?void 0:s.editor)||"text",a=l==="select"||l==="combobox"||l==="autocomplete",d=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"];if(a&&!this.dropdownOpen&&d.includes(e.key)){e.preventDefault(),e.stopPropagation();const g=this.grid.columns.findIndex(m=>m.field===r),u=this.grid.columns.map((m,y)=>({index:y,column:m})).filter(m=>m.column.isEditable!==!1),c=u.findIndex(m=>m.index===g),h=this.grid.displayItems;let f=n,w=g,p=!1;switch(e.key){case"ArrowUp":n>0&&(f=n-1,p=!0);break;case"ArrowDown":n<h.length-1&&(f=n+1,p=!0);break;case"ArrowLeft":c>0&&(w=u[c-1].index,p=!0);break;case"ArrowRight":c<u.length-1&&(w=u[c+1].index,p=!0);break;case"PageUp":f=Math.max(0,n-10),p=!0;break;case"PageDown":f=Math.min(h.length-1,n+10),p=!0;break;case"Home":e.ctrlKey&&(f=0),w=0,p=!0;break;case"End":e.ctrlKey?(f=h.length-1,w=this.grid.columns.length-1):w=this.grid.columns.length-1,p=!0;break}p&&(te(this),this.grid.cancelEdit(),queueMicrotask(()=>{L(this,f,w)}));return}switch(e.key){case"ArrowDown":if(this.dropdownOpen){e.preventDefault(),e.stopPropagation();const g=this.getCurrentEditorOptions();let u=this.highlightedIndex+1;for(;u<this.dropdownOptions.length&&We(this.dropdownOptions[u],g);)u++;u<this.dropdownOptions.length&&(this.highlightedIndex=u,pe(this),Eo(this))}break;case"ArrowUp":if(this.dropdownOpen){e.preventDefault(),e.stopPropagation();const g=this.getCurrentEditorOptions();let u=this.highlightedIndex-1;for(;u>=0&&We(this.dropdownOptions[u],g);)u--;u>=0&&(this.highlightedIndex=u,pe(this),Eo(this))}break;case"Enter":if(this.datepicker)return;e.preventDefault(),e.stopPropagation(),this.dropdownOpen&&this.highlightedIndex>=0?Ro(this,this.highlightedIndex):a&&!this.dropdownOpen?re(this):(this.isCommittingFromKeyboard=!0,B(this),l==="date"&&i instanceof HTMLInputElement?this.commitDateEditor(i):it(this,i),Lt(this,n,r,"down"));break;case"Tab":if(this.datepicker)return;if(e.preventDefault(),e.stopPropagation(),this.isCommittingFromKeyboard=!0,this.dropdownOpen&&this.highlightedIndex>=0&&a){const g=this.dropdownOptions[this.highlightedIndex],u=this.getCurrentEditorOptions();if(g&&!We(g,u)){const c=ke(g,u);this.grid.commitEdit(n,r,c)}B(this)}else B(this),l==="date"&&i instanceof HTMLInputElement?this.commitDateEditor(i):a||it(this,i);Lt(this,n,r,e.shiftKey?"prev":"next");break;case"Escape":e.preventDefault(),e.stopPropagation(),this.dropdownOpen&&B(this),this.datepicker&&(this.datepicker.close(!0),this.datepicker=null),this.isCommittingFromKeyboard=!0,te(this),this.grid.cancelEdit(),Un(this,n,r);break;case"F2":e.preventDefault(),e.stopPropagation(),a&&!this.dropdownOpen&&re(this);break;case"Backspace":l==="select"&&(e.preventDefault(),e.stopPropagation(),this.filterText.length>0&&(this.filterText=this.filterText.slice(0,-1),$o(this,s.editorOptions||{})));break;default:l==="select"&&e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&(e.preventDefault(),e.stopPropagation(),this.filterText+=e.key,$o(this,s.editorOptions||{}));break}}attachEventListeners(){const e=this.shadow.querySelector(".wg__table");if(!e)return;e.addEventListener("focus",r=>{var l;const s=r.target;if(s.matches(".wg__cell")){const a=parseInt(s.dataset.row||"0",10),d=parseInt(s.dataset.col||"0",10);Fn(this,a,d),Ht(this)}if(s.matches(".wg__select-trigger, .wg__combobox-input, .wg__autocomplete-input")&&!this.justSelected&&!this.dropdownOpen){const a=s.dataset.field||"",d=this.grid.columns.find(c=>c.field===a),g=(d==null?void 0:d.editorOptions)||{};(((l=this.grid.editingCell)==null?void 0:l.initialSearchQuery)!==void 0||g.showOnFocus!==!1)&&re(this)}},!0),e.addEventListener("keydown",r=>{const s=r.target;if(s.matches(".wg__editor, .wg__combobox-input, .wg__autocomplete-input, .wg__date-input")){this.handleEditorKeyDown(r,s);return}if(s.matches(".wg__cell")){const l=parseInt(s.dataset.row||"0",10),a=parseInt(s.dataset.col||"0",10);this.handleCellKeyDown(r,l,a)}}),this.focusEvents.init(e),this.focusEvents.subscribe("focusout",(r,s)=>{(!s||!e.contains(s))&&qn(this,{relatedTarget:s})}),e.addEventListener("dblclick",r=>{r.preventDefault();const l=r.target.closest(".wg__cell");if(l){const a=parseInt(l.dataset.row||"0",10),d=parseInt(l.dataset.col||"0",10),g=this.grid.columns[d];if(g){const u=g.editTrigger||this.grid.editTrigger;if(u==="dblclick"||u==="navigate"){const c=Tt(r,l);oe(this,a,d,{cursorPosition:c??void 0});const h=g.editor;h==="select"||h==="combobox"||h==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||re(this)}):h==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(a,d)})}}}}),e.addEventListener("click",r=>{const l=r.target.closest(".wg__cell");if(l&&!l.classList.contains("wg__cell--editing")){const a=parseInt(l.dataset.row||"0",10),d=parseInt(l.dataset.col||"0",10),g=this.grid.columns[d];if(g&&(g.editTrigger||this.grid.editTrigger)==="click"){r.preventDefault();const c=Tt(r,l);oe(this,a,d,{cursorPosition:c??void 0});const h=g.editor;h==="select"||h==="combobox"||h==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||re(this)}):h==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(a,d)})}}}),e.addEventListener("mousedown",r=>{var g;const s=r.target,l=r,a=s.closest(".wg__cell");if(a&&!a.classList.contains("wg__cell--editing")&&!s.closest(".wg__row-number")){const u=parseInt(a.dataset.row||"0",10),c=parseInt(a.dataset.col||"0",10),h=(g=this.grid.visualColumns[c])==null?void 0:g.column;if(h){const f=this.grid.cellSelectionMode,w=l.shiftKey,p=h.editTrigger||this.grid.editTrigger;if(f!=="disabled"&&(f==="click"&&!w||f==="shift"&&w)){if(p==="click"&&f==="click"){Yo(this,u,c,l);return}if(p!=="click"){Yo(this,u,c,l);return}}else this.grid.selectedCellRange&&(this.grid.clearCellSelection(),fe())}}if(s.closest(".wg__date-trigger")){r.preventDefault(),r.stopPropagation();const u=s.closest(".wg__cell-date-display"),c=s.closest(".wg__editor--date");if(c){const h=c.querySelector(".wg__date-input");h&&this.openDatePicker(h,c)}else if(u){const h=parseInt(u.dataset.row||"0",10),f=u.dataset.field||"",w=this.grid.columns.findIndex(p=>String(p.field)===f);if(w>=0){if(this.isTransitioningCells=!0,this.grid.editingCell){const p=this.grid.editingCell,m=this.grid.columns.findIndex(y=>String(y.field)===p.field);B(this),te(this),this.grid.cancelEdit(),m>=0&&j(this,p.rowIndex,m)}oe(this,h,w),requestAnimationFrame(()=>{var _;this.isTransitioningCells=!1;const p=(_=this.shadowRoot)==null?void 0:_.querySelector(`.wg__cell[data-row="${h}"][data-field="${f}"]`),m=p==null?void 0:p.querySelector(".wg__date-input"),y=p==null?void 0:p.querySelector(".wg__editor--date");m&&y&&this.openDatePicker(m,y)})}}return}if(this.dropdownOpen||this.grid.editingCell){const u=s.closest(".wg__cell");if(u&&!s.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete, .wg__editor--date")){const c=parseInt(u.dataset.row||"0",10),h=parseInt(u.dataset.col||"0",10),f=this.grid.editingCell,w=s.matches(".wg__combobox-toggle, .wg__select-toggle, .wg__date-trigger");if(f&&!w){const p=this.grid.columns.findIndex(m=>String(m.field)===f.field);if(c!==f.rowIndex||h!==p){r.preventDefault(),this.isTransitioningCells=!0;const m=f.rowIndex,y=p;B(this),te(this),this.grid.cancelEdit(),y>=0&&j(this,m,y);const _=this.grid.columns[h],S=(_==null?void 0:_.editTrigger)||this.grid.editTrigger,C=r.clientX;requestAnimationFrame(()=>{if(this.isTransitioningCells=!1,S==="click"&&_&&this.grid.isCellEditable(_)){const x=this.shadow.querySelector(`td[data-row="${c}"][data-col="${h}"]`),k=x?Tt({clientX:C},x):void 0;oe(this,c,h,{cursorPosition:k??void 0})}else L(this,c,h)});return}}}}if(s.matches(".wg__combobox-toggle, .wg__select-toggle")){r.preventDefault(),r.stopPropagation();const u=s.closest(".wg__cell-dropdown-display");if(s.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete"))this.dropdownOpen&&(this.isClosingViaToggle=!0),Mo(this);else if(u){const h=parseInt(u.dataset.row||"0",10),f=u.dataset.field||"",w=this.grid.columns.findIndex(p=>String(p.field)===f);if(w>=0){this.isTransitioningCells=!0;const p=this.grid.editingCell,m=p?this.grid.columns.findIndex(y=>String(y.field)===p.field):-1;p&&(B(this),te(this),this.grid.cancelEdit(),m>=0&&j(this,p.rowIndex,m)),oe(this,h,w),requestAnimationFrame(()=>{this.isTransitioningCells=!1,this.dropdownOpen||re(this)})}}}if(s.matches(".wg__cell-dropdown-display")){r.preventDefault(),r.stopPropagation();const u=s.closest(".wg__cell-dropdown-display");if(u){const c=parseInt(u.dataset.row||"0",10),h=u.dataset.field||"",f=this.grid.columns.findIndex(w=>String(w.field)===h);if(f>=0){this.isTransitioningCells=!0;const w=this.grid.editingCell,p=w?this.grid.columns.findIndex(m=>String(m.field)===w.field):-1;w&&(B(this),te(this),this.grid.cancelEdit(),p>=0&&j(this,w.rowIndex,p)),oe(this,c,f),requestAnimationFrame(()=>{this.isTransitioningCells=!1,this.dropdownOpen||re(this)})}}}}),e.addEventListener("click",r=>{r.target.matches(".wg__select-trigger, .wg__select-value")&&(r.preventDefault(),r.stopPropagation(),Mo(this))}),e.addEventListener("mousedown",r=>{const s=r.target,l=s.closest(".wg__resize-handle");if(l){r.preventDefault(),r.stopPropagation();const d=l.dataset.field;d&&Rr(this,r,d);return}if(this.grid.isColumnReorderAllowed){const d=s.closest(".wg__header");if(d&&!d.classList.contains("wg__header--frozen")&&!d.classList.contains("wg__row-number-header")){const g=d.dataset.field;g&&zr(this,r,g)}}const a=s.closest(".wg__row-number[data-row-number]");if(a){const d=parseInt(a.dataset.rowNumber||"-1",10);d>=0&&Kr(this,d,r)}s.closest(".wg__cell, .wg__row-number, .wg__header, .wg__toolbar, button, input, select, textarea")||this.grid.selectedCellRange&&(this.grid.clearCellSelection(),fe())}),e.addEventListener("click",r=>{const s=r,l=s.target;if(l.closest(".wg__resize-handle")||Tr())return;l.closest(".wg__header--sortable")&&(xr(this,s),this.render())}),e.addEventListener("contextmenu",r=>{this.handleContextMenu(r)}),e.addEventListener("change",r=>{const s=r.target;s.matches(".wg__editor--checkbox")&&Wn(this,s)}),e.addEventListener("input",r=>{const s=r.target;s.matches(".wg__combobox-input")?gr(this,r):s.matches(".wg__autocomplete-input")&&ur(this,r)}),this.focusEvents.subscribe("blur",(r,s)=>{this.focusEvents.shouldSkipBlur()||(r.matches(".wg__editor--text, .wg__editor--number")?Bn(this,r):r.matches(".wg__date-input")?this.datepicker||this.commitDateEditor(r):r.matches(".wg__select-trigger")?this.handleSelectBlur():r.matches(".wg__combobox-input, .wg__autocomplete-input")&&this.handleComboboxBlur(r))});const i=this.shadow.querySelector(".wg");i&&(i.setAttribute("tabindex","-1"),i.addEventListener("keydown",r=>{const s=this.grid.selectedRows,l=!!this.grid.selectedCellRange;if(s.length===0&&!l||r.target.matches('input, textarea, select, [contenteditable="true"]'))return;if(r.key==="Escape"){r.preventDefault(),this.grid.selectedCellRange?(this.grid.clearCellSelection(),fe()):this.grid.clearSelection();return}const d=this.grid.rangeShortcuts;if(d!=null&&d.length)for(const g of d){const u=Ye(g.key);if(Be(r,u)){const c=l?{rows:[],rowIndices:[],cellRange:this.grid.selectedCellRange,cells:this.grid.getSelectedCells()}:{rows:this.grid.getSelectedRowsData(),rowIndices:s};if(!(typeof g.disabled=="function"?g.disabled(c):g.disabled===!0)){r.preventDefault(),g.action(c);return}}}}),this.scrollEvents.init(i),this.scrollEvents.subscribe("container",()=>{const r=i.scrollLeft>0;i.classList.toggle("wg--scrolled-horizontal",r),this.dropdownOpen&&!this.isTransitioningCells&&!this.isOpeningDropdown&&this.handleScrollCloseDropdown(),this.grid.shouldUseVirtualScroll()&&this.handleVirtualScroll(i),this.grid.isInfiniteScrollEnabled&&this.grid.hasMoreItems&&!this.isLoadingMoreItems&&this.handleInfiniteScroll(i),Oe()!==null&&(bo(this,this.grid.displayItems),this.renderConnector()),Ht(this),this.grid.selectedCellRange&&Xo(this)}),this.scrollEvents.subscribe("window",()=>{this.dropdownOpen&&!this.isTransitioningCells&&this.handleScrollCloseDropdown(),Oe()!==null&&this.closeToolbarAndReset()})),e.addEventListener("mouseenter",r=>{const s=r.target,l=s.closest("[data-tooltip-html]");if(l){const d=l.getAttribute("data-tooltip-html");Vt(this,l,d,this._tooltipShowDelay,!0);return}const a=s.closest("[data-tooltip]");if(a){const d=a.getAttribute("data-tooltip");Vt(this,a,d,this._tooltipShowDelay,!1)}},!0),e.addEventListener("mouseleave",r=>{const s=r,l=s.target,a=s.relatedTarget,d=l.closest("[data-tooltip], [data-tooltip-html]");d&&(a==null?void 0:a.closest("[data-tooltip], [data-tooltip-html]"))===d||d&&Io(this,this._tooltipHideDelay)},!0),e.addEventListener("click",r=>{const l=r.target.closest(".wg__toolbar-trigger");if(l&&this.grid.toolbarTrigger==="button"){r.preventDefault(),r.stopPropagation();const a=parseInt(l.dataset.toolbarTrigger||"0",10),d=e.querySelector(`tr[data-row-index="${a}"]`);d&&(Rt(a)?this.closeToolbarAndReset():this.showToolbarForRow(d,a))}}),e.addEventListener("click",r=>{if(this.grid.toolbarPosition!=="inline")return;const l=r.target.closest(".wg__inline-action-btn");if(l&&!l.disabled){r.preventDefault(),r.stopPropagation();const a=l.dataset.actionId,d=parseInt(l.dataset.row||"0",10);this.handleInlineActionClick(a,d)}}),e.addEventListener("mouseenter",r=>{const s=r,a=s.target.closest(".wg__row");if(a){const d=parseInt(a.dataset.rowIndex||"0",10);this.grid.setHoveredRow(d),this.grid.toolbarPosition==="inline"&&this.setupInlineShortcuts(),this.grid.toolbarTrigger==="hover"&&this.grid.toolbarPosition!=="inline"&&(this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),Rt(d)||this.showToolbarForRow(a,d,s.clientX))}},!0),e.addEventListener("mouseleave",r=>{if(r.target.closest(".wg__row")&&(this.grid.toolbarPosition==="inline"&&setTimeout(()=>{e.matches(":hover")||(this.grid.setHoveredRow(null),this.removeInlineShortcuts())},50),this.grid.toolbarTrigger==="hover"&&this.grid.toolbarPosition!=="inline")){if(this.toolbarMoveInProgress)return;this.toolbarHideTimeout&&clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=setTimeout(()=>{const d=this.shadow.querySelector(".wg__toolbar-container"),g=d==null?void 0:d.matches(":hover"),u=e.matches(":hover");!g&&!u&&(this.grid.setHoveredRow(null),this.closeToolbarAndReset())},150)}},!0),e.addEventListener("click",r=>{if(this.grid.toolbarTrigger!=="click")return;const s=r,l=s.target,a=l.closest(".wg__row");if(a&&!l.closest(".wg__cell--editing")){const d=parseInt(a.dataset.rowIndex||"0",10);Rt(d)?this.closeToolbarAndReset():this.showToolbarForRow(a,d,s.clientX)}}),this.toolbarOutsideClickAdded||(this.toolbarOutsideClickAdded=!0,document.addEventListener("click",r=>{if(!mo(this.shadow))return;const s=r.composedPath(),l=s.some(g=>{var u;return(u=g.classList)==null?void 0:u.contains("wg__toolbar-container")}),a=s.some(g=>{var u;return(u=g.classList)==null?void 0:u.contains("wg__toolbar-trigger")});l||a||s.includes(this)&&(this.grid.toolbarTrigger==="hover"||this.grid.toolbarTrigger==="click")||Oe()!==null&&this.closeToolbarAndReset()})),this.shadow.querySelectorAll(".wg__pagination").forEach(r=>{r.addEventListener("click",l=>{kr(this,l)&&this.render()});const s=r.querySelector(".wg__pagination-select");s&&s.addEventListener("change",()=>{Dr(this,s)&&this.render()})})}scrollToRowProgrammatically(e){const i=this.shadow.querySelector(".wg");if(!i)return;const{scrollTop:n,startIndex:r,endIndex:s}=Cr({targetRow:e,rowHeight:this.grid.virtualScrollRowHeight,buffer:this.grid.virtualScrollBuffer,totalItems:this.grid.displayItems.length,viewportHeight:i.clientHeight,scrollHeight:i.scrollHeight,clientHeight:i.clientHeight});(r!==this.virtualScrollStart||s!==this.virtualScrollEnd)&&(this.virtualScrollStart=r,this.virtualScrollEnd=s,this.renderVirtualRows(i)),this.isProgrammaticScroll=!0,i.scrollTop=n,queueMicrotask(()=>{this.isProgrammaticScroll=!1})}handleVirtualScroll(e){var r;if(this.isProgrammaticScroll)return;const{startIndex:i,endIndex:n}=yr({scrollTop:e.scrollTop,viewportHeight:e.clientHeight,rowHeight:this.grid.virtualScrollRowHeight,buffer:this.grid.virtualScrollBuffer,totalItems:this.grid.displayItems.length,editingRowIndex:(r=this.grid.editingCell)==null?void 0:r.rowIndex});(i!==this.virtualScrollStart||n!==this.virtualScrollEnd)&&(this.virtualScrollStart=i,this.virtualScrollEnd=n,this.renderVirtualRows(e))}renderVirtualRows(e){const i=e.querySelector("tbody");if(!i)return;const n=this.grid.displayItems,r={startIndex:this.virtualScrollStart,endIndex:this.virtualScrollEnd,rowHeight:this.grid.virtualScrollRowHeight,totalItems:n.length},s=this.grid.focusedCell;if(i.innerHTML=yo(this,r),s){this.grid.setFocusedCell(s.rowIndex,s.colIndex);const l=i.querySelector(`td[data-row="${s.rowIndex}"][data-col="${s.colIndex}"]`);l&&(l.focus({preventScroll:!0}),ee(this,null,s))}}handleInfiniteScroll(e){Sr(e.scrollTop,e.scrollHeight,e.clientHeight,this.grid.infiniteScrollThreshold)&&(this.isLoadingMoreItems=!0,this.grid.fireDataRequest("loadMore"))}renderShortcutsHelpIcon(){var s,l,a;if(!this.grid.isShortcutsHelpVisible||!((s=this.grid.rowShortcuts)!=null&&s.length))return"";const i=this.grid.shortcutsHelpPosition==="top-left"?"wg__shortcuts-help--left":"",n=this.grid.rowShortcuts.map(d=>`<div class="wg__shortcuts-help-item">
644
+ <span class="wg__shortcuts-help-key">${vr(d.key)}</span>
639
645
  <span class="wg__shortcuts-help-label">${d.label}</span>
640
- </div>`).join(""),n=((l=(a=this.grid).shortcutsHelpContentCallback)==null?void 0:l.call(a))||"";return`
646
+ </div>`).join(""),r=((a=(l=this.grid).shortcutsHelpContentCallback)==null?void 0:a.call(l))||"";return`
641
647
  <div class="wg__shortcuts-help ${i}">
642
648
  <button class="wg__shortcuts-help-icon" type="button" title="${this.grid.labels.keyboardShortcuts}">
643
649
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
@@ -647,35 +653,35 @@
647
653
  </svg>
648
654
  </button>
649
655
  <div class="wg__shortcuts-help-overlay">
650
- ${n?`<div class="wg__shortcuts-help-custom">${n}</div>`:""}
656
+ ${r?`<div class="wg__shortcuts-help-custom">${r}</div>`:""}
651
657
  <div class="wg__shortcuts-help-title">${this.grid.labels.keyboardShortcuts}</div>
652
658
  <div class="wg__shortcuts-help-list">
653
- ${r}
659
+ ${n}
654
660
  </div>
655
661
  </div>
656
662
  </div>
657
- `}render(){var v;const t=this.shadow.querySelector(".wg"),i=(t==null?void 0:t.scrollTop)||0,r=(t==null?void 0:t.scrollLeft)||0,n=this.grid.focusedCell;t&&t.remove();const s=document.createElement("div");s.className=gr(this);const a=this.grid.paginationPosition.split("|").map(m=>m.trim()),l=this.grid.summaryPosition?this.grid.summaryPosition.split("|").map(m=>m.trim()):[],d=(m,y)=>{const _=a.filter(k=>y?k.startsWith("top-"):k.startsWith("bottom-")),S=l.filter(k=>y?k.startsWith("top-"):k.startsWith("bottom-")),b=_.length>0,C=S.length>0;return!b&&!C?"":C&&b&&this.grid.summaryInline?`<div class="wg__footer${y?" wg__footer--top":""}">
658
- ${kt(this,S[0])}
659
- ${xt(this,_[0])}
660
- </div>`:[...new Set([..._,...S])].map(k=>{const T=_.includes(k),E=S.includes(k);return E&&T?`<div class="wg__footer${y?" wg__footer--top":""}">
661
- ${kt(this,k)}
662
- ${xt(this,k)}
663
- </div>`:E?kt(this,k):xt(this,k)}).join("")},g=d(a,!0),u=d(a,!1),c=this.grid.shouldUseVirtualScroll();let h;if(c){const m=this.grid.displayItems,y=this.grid.virtualScrollRowHeight,_=this.grid.virtualScrollBuffer,S=(t==null?void 0:t.clientHeight)||400,b=Math.max(0,Math.floor(i/y)-_),C=Math.ceil(S/y)+_*2,x=Math.min(m.length,b+C);this.virtualScrollStart=b,this.virtualScrollEnd=x;const k={startIndex:b,endIndex:x,rowHeight:y,totalItems:m.length};h=ao(this,k)}else h=hr(this);c&&s.classList.add("wg--virtual-scroll");const p=`
663
+ `}render(){var p;const e=this.shadow.querySelector(".wg"),i=(e==null?void 0:e.scrollTop)||0,n=(e==null?void 0:e.scrollLeft)||0,r=this.grid.focusedCell;e&&e.remove();const s=document.createElement("div");s.className=zn(this);const l=this.grid.paginationPosition.split("|").map(m=>m.trim()),a=this.grid.summaryPosition?this.grid.summaryPosition.split("|").map(m=>m.trim()):[],d=(m,y)=>{const _=l.filter(k=>y?k.startsWith("top-"):k.startsWith("bottom-")),S=a.filter(k=>y?k.startsWith("top-"):k.startsWith("bottom-")),v=_.length>0,C=S.length>0;return!v&&!C?"":C&&v&&this.grid.isSummaryInline?`<div class="wg__footer${y?" wg__footer--top":""}">
664
+ ${It(this,S[0])}
665
+ ${$t(this,_[0])}
666
+ </div>`:[...new Set([..._,...S])].map(k=>{const T=_.includes(k),M=S.includes(k);return M&&T?`<div class="wg__footer${y?" wg__footer--top":""}">
667
+ ${It(this,k)}
668
+ ${$t(this,k)}
669
+ </div>`:M?It(this,k):$t(this,k)}).join("")},g=d(l,!0),u=d(l,!1),c=this.grid.shouldUseVirtualScroll();let h;if(c){const m=this.grid.displayItems,y=this.grid.virtualScrollRowHeight,_=this.grid.virtualScrollBuffer,S=(e==null?void 0:e.clientHeight)||400,v=Math.max(0,Math.floor(i/y)-_),C=Math.ceil(S/y)+_*2,x=Math.min(m.length,v+C);this.virtualScrollStart=v,this.virtualScrollEnd=x;const k={startIndex:v,endIndex:x,rowHeight:y,totalItems:m.length};h=yo(this,k)}else h=An(this);c&&s.classList.add("wg--virtual-scroll");const w=`
664
670
  ${this.renderShortcutsHelpIcon()}
665
671
  ${g}
666
672
  <table class="wg__table">
667
673
  <thead>
668
- ${ur(this)}
674
+ ${Ln(this)}
669
675
  </thead>
670
676
  <tbody>
671
677
  ${h}
672
678
  </tbody>
673
679
  </table>
674
680
  ${u}
675
- `;if(s.innerHTML=p,this.shadow.appendChild(s),c){const m=Math.max(0,this.grid.displayItems.length*this.grid.virtualScrollRowHeight-s.clientHeight);s.scrollTop=Math.min(i,m)}else s.scrollTop=i;if(s.scrollLeft=r,this.attachEventListeners(),this.grid.editingCell){const{rowIndex:m,field:y}=this.grid.editingCell;let _=this.shadow.querySelector(`.wg__combobox-input[data-row="${m}"][data-field="${y}"],
681
+ `;if(s.innerHTML=w,this.shadow.appendChild(s),c){const m=Math.max(0,this.grid.displayItems.length*this.grid.virtualScrollRowHeight-s.clientHeight);s.scrollTop=Math.min(i,m)}else s.scrollTop=i;if(s.scrollLeft=n,this.attachEventListeners(),this.grid.editingCell){const{rowIndex:m,field:y}=this.grid.editingCell;let _=this.shadow.querySelector(`.wg__combobox-input[data-row="${m}"][data-field="${y}"],
676
682
  .wg__autocomplete-input[data-row="${m}"][data-field="${y}"],
677
683
  .wg__select-trigger[data-row="${m}"][data-field="${y}"],
678
- .wg__date-input[data-row="${m}"][data-field="${y}"]`);if(_||(_=this.shadow.querySelector(`.wg__editor[data-row="${m}"][data-field="${y}"]`)),_&&(_.focus(),_ instanceof HTMLInputElement&&_.type==="text")){const S=this.grid.editingCell.cursorPosition,b=this.getCurrentEditingColumn(),C=((v=b==null?void 0:b.editorOptions)==null?void 0:v.editStartSelection)||this.grid.editStartSelection;if(this.grid.editingCell.initialSearchQuery!==void 0){const x=_.value.length;_.setSelectionRange(x,x)}else switch(C){case"mousePosition":if(S!==void 0){const x=Math.min(S,_.value.length);_.setSelectionRange(x,x)}else _.setSelectionRange(_.value.length,_.value.length);break;case"cursorAtStart":_.setSelectionRange(0,0);break;case"cursorAtEnd":_.setSelectionRange(_.value.length,_.value.length);break;case"selectAll":default:_.select();break}}}else if(n&&!this.grid.editingCell){const m=s.querySelector(`td[data-row="${n.rowIndex}"][data-col="${n.colIndex}"]`);m&&setTimeout(()=>m.focus(),0)}c&&requestAnimationFrame(()=>{s.style.pointerEvents="none",requestAnimationFrame(()=>{s.style.pointerEvents=""})}),this.renderConnector(),At(this)}renderConnector(){const t=this.shadow.querySelector(".wg__connector");t&&t.remove();const i=cr();if(!i.path||!i.arrowPos)return;const r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("class","wg__connector"),r.setAttribute("style","position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 999;");const n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",i.path),n.setAttribute("stroke","var(--wg-accent-color, #0078d4)"),n.setAttribute("stroke-width","2"),n.setAttribute("fill","none"),r.appendChild(n);const s=document.createElementNS("http://www.w3.org/2000/svg","polygon"),a=i.arrowDir==="down"?"-4,0 4,0 0,8":i.arrowDir==="up"?"-4,0 4,0 0,-8":i.arrowDir==="left"?"0,-4 -8,0 0,4":"0,-4 8,0 0,4";s.setAttribute("points",a),s.setAttribute("fill","var(--wg-accent-color, #0078d4)"),s.setAttribute("transform",`translate(${i.arrowPos.x}, ${i.arrowPos.y})`),r.appendChild(s),this.shadow.appendChild(r)}openDatePicker(t,i){this.datepicker&&(this.datepicker.close(!0),this.datepicker=null);const r=t.dataset.dateFormat||"YYYY-MM-DD",n=t.dataset.minDate,s=t.dataset.maxDate,a=t.dataset.dateValue||"";this.datepicker=new It({dateFormat:r,minDate:n||void 0,maxDate:s||void 0,onSelect:(l,d)=>{this.handleDatePickerSelect(t,l,d)},onClose:()=>{this.datepicker=null,G(this),this.grid.cancelEdit()}}),this.datepicker.open(i,a||null)}handleDatePickerSelect(t,i,r){const n=t.dataset.dateFormat||"YYYY-MM-DD",s=Rt(n);t.value=po(i,s),t.dataset.dateValue=$t(i),this.datepicker=null,this.isCommittingFromKeyboard=!0,this.commitDateEditor(t);const a=parseInt(t.dataset.row||"0",10),l=t.dataset.field||"";this.moveFocusAfterCommit(a,l,r||"down")}commitDateEditor(t){if(!this.grid.editingCell)return;const i=parseInt(t.dataset.row||"0",10),r=t.dataset.field||"",n=t.dataset.outputFormat||"iso",s=t.dataset.dateFormat||"YYYY-MM-DD",a=Rt(s),l=t.value?this.parseDateInput(t.value,a):null;let d=null;if(l)switch(n){case"date":d=l;break;case"timestamp":d=l.getTime();break;case"iso":default:d=$t(l);break}this.grid.commitEdit(i,r,d)}parseDateInput(t,i){if(!t)return null;const r=t.split(i.separator);let n=null,s=null,a=null;if(r.forEach((d,g)=>{var c,h,f;if(!d)return;const u=parseInt(d,10);((c=i.parts.year)==null?void 0:c.index)===g?n=u<100?u+2e3:u:((h=i.parts.month)==null?void 0:h.index)===g?s=u:((f=i.parts.day)==null?void 0:f.index)===g&&(a=u)}),n===null||s===null||a===null)return null;const l=new Date(n,s-1,a);return l.getMonth()!==s-1||l.getDate()!==a?null:l}showGoToRowDialog(t){const i=this.grid.displayItems;if(i.length===0)return;const r=document.createElement("div");r.className="wg__goto-overlay",r.innerHTML=`
684
+ .wg__date-input[data-row="${m}"][data-field="${y}"]`);if(_||(_=this.shadow.querySelector(`.wg__editor[data-row="${m}"][data-field="${y}"]`)),_&&(_.focus(),_ instanceof HTMLInputElement&&_.type==="text")){const S=this.grid.editingCell.cursorPosition,v=this.getCurrentEditingColumn(),C=((p=v==null?void 0:v.editorOptions)==null?void 0:p.editStartSelection)||this.grid.editStartSelection;if(this.grid.editingCell.initialSearchQuery!==void 0){const x=_.value.length;_.setSelectionRange(x,x)}else switch(C){case"mousePosition":if(S!==void 0){const x=Math.min(S,_.value.length);_.setSelectionRange(x,x)}else _.setSelectionRange(_.value.length,_.value.length);break;case"cursorAtStart":_.setSelectionRange(0,0);break;case"cursorAtEnd":_.setSelectionRange(_.value.length,_.value.length);break;case"selectAll":default:_.select();break}}}else if(r&&!this.grid.editingCell){const m=s.querySelector(`td[data-row="${r.rowIndex}"][data-col="${r.colIndex}"]`);m&&setTimeout(()=>m.focus(),0)}c&&requestAnimationFrame(()=>{s.style.pointerEvents="none",requestAnimationFrame(()=>{s.style.pointerEvents=""})}),this.renderConnector(),Ht(this),this.grid.selectedCellRange&&Xo(this)}renderConnector(){const e=this.shadow.querySelector(".wg__connector");e&&e.remove();const i=Tn();if(!i.path||!i.arrowPos)return;const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("class","wg__connector"),n.setAttribute("style","position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 999;");const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",i.path),r.setAttribute("stroke","var(--wg-accent-color, #0078d4)"),r.setAttribute("stroke-width","2"),r.setAttribute("fill","none"),n.appendChild(r);const s=document.createElementNS("http://www.w3.org/2000/svg","polygon"),l=i.arrowDir==="down"?"-4,0 4,0 0,8":i.arrowDir==="up"?"-4,0 4,0 0,-8":i.arrowDir==="left"?"0,-4 -8,0 0,4":"0,-4 8,0 0,4";s.setAttribute("points",l),s.setAttribute("fill","var(--wg-accent-color, #0078d4)"),s.setAttribute("transform",`translate(${i.arrowPos.x}, ${i.arrowPos.y})`),n.appendChild(s),this.shadow.appendChild(n)}openDatePicker(e,i){this.datepicker&&(this.datepicker.close(!0),this.datepicker=null);const n=e.dataset.dateFormat||"YYYY-MM-DD",r=e.dataset.minDate,s=e.dataset.maxDate,l=e.dataset.dateValue||"";this.datepicker=new St({dateFormat:n,minDate:r||void 0,maxDate:s||void 0,onSelect:(a,d)=>{this.handleDatePickerSelect(e,a,d)},onClose:()=>{const a=this.grid.editingCell,d=a?this.grid.columns.findIndex(u=>String(u.field)===a.field):-1,g=(a==null?void 0:a.rowIndex)??-1;this.datepicker=null,te(this),this.grid.cancelEdit(),g>=0&&d>=0&&Vn(this,g,d)}}),this.datepicker.open(i,l||null)}handleDatePickerSelect(e,i,n){const r=e.dataset.dateFormat||"YYYY-MM-DD",s=tt(r);e.value=bt(i,s),e.dataset.dateValue=_t(i),this.datepicker=null,this.isCommittingFromKeyboard=!0,this.commitDateEditor(e);const l=parseInt(e.dataset.row||"0",10),a=e.dataset.field||"";this.moveFocusAfterCommit(l,a,n||"down")}commitDateEditor(e){if(!this.grid.editingCell)return;const i=parseInt(e.dataset.row||"0",10),n=e.dataset.field||"",r=e.dataset.outputFormat||"iso",s=e.dataset.dateFormat||"YYYY-MM-DD",l=tt(s),a=e.value?this.parseDateInput(e.value,l):null;let d=null;if(a)switch(r){case"date":d=a;break;case"timestamp":d=a.getTime();break;case"iso":default:d=_t(a);break}this.grid.commitEdit(i,n,d)}parseDateInput(e,i){if(!e)return null;const n=e.split(i.separator);let r=null,s=null,l=null;if(n.forEach((d,g)=>{var c,h,f;if(!d)return;const u=parseInt(d,10);((c=i.parts.year)==null?void 0:c.index)===g?r=u<100?u+2e3:u:((h=i.parts.month)==null?void 0:h.index)===g?s=u:((f=i.parts.day)==null?void 0:f.index)===g&&(l=u)}),r===null||s===null||l===null)return null;const a=new Date(r,s-1,l);return a.getMonth()!==s-1||a.getDate()!==l?null:a}showGoToRowDialog(e){const i=this.grid.displayItems;if(i.length===0)return;const n=document.createElement("div");n.className="wg__goto-overlay",n.innerHTML=`
679
685
  <div class="wg__goto-dialog">
680
686
  <label class="wg__goto-label">Go to row (1-${i.length}):</label>
681
687
  <input type="number" class="wg__goto-input" min="1" max="${i.length}" value="1" />
@@ -684,4 +690,4 @@
684
690
  <button type="button" class="wg__goto-btn wg__goto-btn--go">Go</button>
685
691
  </div>
686
692
  </div>
687
- `;const n=r.querySelector(".wg__goto-input"),s=r.querySelector(".wg__goto-btn--go"),a=r.querySelector(".wg__goto-btn--cancel"),l=()=>{r.remove()},d=()=>{const g=parseInt(n.value,10);if(isNaN(g)||g<1||g>i.length){n.focus(),n.select();return}l();const u=g-1,c=this.grid.focusedCell;if(this.grid.setFocusedCell(u,t),this.grid.shouldUseVirtualScroll())this.scrollToRowProgrammatically(u),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const h=this.shadow.querySelector(`td[data-row="${u}"][data-col="${t}"]`);h==null||h.focus()})});else{const h=this.shadow.querySelector(`td[data-row="${u}"][data-col="${t}"]`);h&&(h.scrollIntoView({block:"nearest",behavior:"auto"}),h.focus(),te(this,c,{rowIndex:u,colIndex:t}))}};s.addEventListener("click",d),a.addEventListener("click",l),r.addEventListener("click",g=>{g.target===r&&l()}),n.addEventListener("keydown",g=>{g.key==="Enter"?(g.preventDefault(),d()):g.key==="Escape"&&(g.preventDefault(),l())}),this.shadow.appendChild(r),n.focus(),n.select()}openCustomEditor(t,i){const r=this.grid.columns[i];if(!r||r.editor!=="custom"||!r.cellEditCallback)return;const n=String(r.field),s=this.grid.displayItems[t];if(!s)return;const l={value:this.grid.getCellRawValue(s,t,n),row:s,rowIndex:t,field:n,commit:d=>{this.grid.commitEdit(t,n,d),G(this),requestAnimationFrame(()=>{z(this,t,i)})},cancel:()=>{G(this),this.grid.cancelEdit(),requestAnimationFrame(()=>{z(this,t,i)})}};r.cellEditCallback(l)}handleContextMenu(t){const i=t.target,r=i.closest(".wg__header");if(r){this.handleHeaderContextMenu(t,r);return}if(i.closest("th.wg__filler")){this.handleFillerContextMenu(t);return}const s=this.grid.contextMenu;if(!s||s.length===0)return;const a=i.closest(".wg__cell");if(!a)return;t.preventDefault(),this.contextMenuElement&&(J(this.contextMenuElement),this.contextMenuElement=null);const l=parseInt(a.dataset.row||"0",10),d=parseInt(a.dataset.col||"0",10),g=this.grid.columns[d];if(!g)return;const u=this.grid.displayItems[l];if(!u)return;const c=String(g.field),h=this.grid.getCellRawValue(u,l,c),f={row:u,rowIndex:l,colIndex:d,column:g,cellValue:h};this.grid.oncontextmenuopen&&this.grid.oncontextmenuopen(f);const p=Object.getOwnPropertyDescriptor(this,"contextMenuXOffset"),v=Object.getOwnPropertyDescriptor(this,"contextMenuYOffset");p&&"value"in p&&(this.grid.contextMenuXOffset=p.value,delete this.contextMenuXOffset),v&&"value"in v&&(this.grid.contextMenuYOffset=v.value,delete this.contextMenuYOffset),this.contextMenuElement=Xr(this,t.clientX,t.clientY,this.grid.contextMenuXOffset,this.grid.contextMenuYOffset,s,f,m=>{const y=s.find(_=>_.id===m);y!=null&&y.onclick&&y.onclick(f),this.contextMenuElement&&(J(this.contextMenuElement),this.contextMenuElement=null)},()=>{this.contextMenuElement=null})}handleHeaderContextMenu(t,i){const r=this.grid.headerContextMenu;if(!r||r.length===0)return;t.preventDefault(),this.contextMenuElement&&(J(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(J(this.headerContextMenuElement),this.headerContextMenuElement=null);const n=i.dataset.field;if(!n)return;const s=this.grid.columns.findIndex(f=>String(f.field)===n);if(s===-1)return;const a=this.grid.columns[s],l=this.grid.freezeColumns,d=s<l,g=this.grid.sort.find(f=>f.column===n),u=(g==null?void 0:g.direction)??null,c={column:a,field:n,columnIndex:s,sortDirection:u,isFrozen:d,allColumns:this.grid.columns,labels:this.grid.labels};this.grid.onheadercontextmenuopen&&this.grid.onheadercontextmenuopen(c);const h=Co(r,c);h.length!==0&&(this.headerContextMenuElement=ko(this,t.clientX,t.clientY,h,c,(f,p,v)=>{if(["sortAsc","sortDesc","clearSort","hideColumn","freezeColumn","unfreezeColumn"].includes(f)&&Qr(this,f,c,v),f==="show-all-columns"){this.grid.columns.forEach(_=>{_.hidden=!1}),this.grid.columns=[...this.grid.columns];return}if(f.startsWith("toggle-col-")){const _=f.replace("toggle-col-",""),S=this.grid.columns.find(b=>String(b.field)===_);S&&(S.hidden=!S.hidden,this.grid.columns=[...this.grid.columns]);return}const y=h.find(_=>_.id===f);y!=null&&y.onclick&&y.onclick(c),!p&&this.headerContextMenuElement&&(J(this.headerContextMenuElement),this.headerContextMenuElement=null)},()=>{this.headerContextMenuElement=null}))}handleFillerContextMenu(t){const i=this.grid.headerContextMenu;if(!i||i.length===0)return;t.preventDefault(),this.contextMenuElement&&(J(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(J(this.headerContextMenuElement),this.headerContextMenuElement=null);const r=i.filter(a=>a==="columnVisibility"?!0:typeof a=="object"&&a.id?!(typeof a.label=="function"||typeof a.icon=="function"):(typeof a=="string"||typeof a=="object"&&a.dividerBefore&&!a.id&&!a.label,!1));if(r.length===0)return;const n={column:null,field:"",columnIndex:-1,sortDirection:null,isFrozen:!1,allColumns:this.grid.columns,labels:this.grid.labels},s=Co(r,n);s.length!==0&&(this.headerContextMenuElement=ko(this,t.clientX,t.clientY,s,n,(a,l,d)=>{if(a==="show-all-columns"){this.grid.columns.forEach(u=>{u.hidden=!1}),this.grid.columns=[...this.grid.columns];return}if(a.startsWith("toggle-col-")){const u=a.replace("toggle-col-",""),c=this.grid.columns.find(h=>String(h.field)===u);c&&(c.hidden=!c.hidden,this.grid.columns=[...this.grid.columns]);return}const g=s.find(u=>u.id===a);g!=null&&g.onclick&&g.onclick(n),!l&&this.headerContextMenuElement&&(J(this.headerContextMenuElement),this.headerContextMenuElement=null)},()=>{this.headerContextMenuElement=null}))}setupToolbarShortcuts(){this.toolbarShortcutHandler&&document.removeEventListener("keydown",this.toolbarShortcutHandler);const t=this.grid.rowShortcuts;t!=null&&t.length&&(this.toolbarShortcutHandler=i=>{if(i.target.matches('input, textarea, select, [contenteditable="true"]'))return;const n=Ae();if(n===null||!ro(this.shadow))return;const s=this.grid.displayItems[n];if(!s)return;const a=this.grid.columns;for(const l of t){const d=Ne(l.key);if(Ye(i,d)){const g={row:s,rowIndex:n,colIndex:0,column:a[0],cellValue:null};if(!(typeof l.disabled=="function"?l.disabled(g):l.disabled===!0)){i.preventDefault(),i.stopPropagation(),l.action(g);return}}}},document.addEventListener("keydown",this.toolbarShortcutHandler))}setupInlineShortcuts(){this.removeInlineShortcuts();const t=this.grid.rowShortcuts;!(t!=null&&t.length)||this.grid.hoveredRowIndex===null||(this.inlineShortcutHandler=i=>{if(i.target.matches('input, textarea, select, [contenteditable="true"]'))return;const n=this.grid.hoveredRowIndex;if(n===null)return;const s=this.grid.displayItems[n];if(!s)return;const a=this.grid.columns;for(const l of t){const d=Ne(l.key);if(Ye(i,d)){const g={row:s,rowIndex:n,colIndex:0,column:a[0],cellValue:null};if(!(typeof l.disabled=="function"?l.disabled(g):l.disabled===!0)){i.preventDefault(),i.stopPropagation(),l.action(g);return}}}},document.addEventListener("keydown",this.inlineShortcutHandler))}removeInlineShortcuts(){this.inlineShortcutHandler&&(document.removeEventListener("keydown",this.inlineShortcutHandler),this.inlineShortcutHandler=null)}setupToolbarTooltips(t,i,r){const n=this.shadow.querySelector(".wg__toolbar-container");if(!n)return;n.querySelectorAll(".wg__toolbar-btn").forEach(a=>{var c;const l=a,d=l.dataset.toolbarItem,g=t.find(h=>h.id===d);if(!g)return;const u=(c=this.grid.rowShortcuts)==null?void 0:c.find(h=>h.id===g.id);l.addEventListener("mouseenter",()=>{const h=g.tooltipCallback?g.tooltipCallback(i,r):lr(g,u==null?void 0:u.key);Et(this,l,h,0,!0)}),l.addEventListener("mouseleave",()=>{fo(this)})})}showToolbarForRow(t,i,r){if(this.grid.toolbarPosition==="inline"||!this.grid.showRowToolbar||!this.grid.rowToolbar.length)return;const n=vt(this.grid.rowToolbar),s=this.grid.displayItems[i];if(!s)return;if(this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),dr(this,t,i,n,s,l=>{this.handleToolbarItemClick(l,i,s)},r),this.setupToolbarShortcuts(),this.renderConnector(),this.setupToolbarTooltips(n,s,i),this.grid.toolbarTrigger==="hover"){const l=this.shadow.querySelector(".wg__toolbar-container");l&&(l.addEventListener("mouseenter",()=>{this.toolbarHovered=!0,this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null)}),l.addEventListener("mouseleave",()=>{this.toolbarHovered=!1,!this.toolbarMoveInProgress&&(this.toolbarHideTimeout=setTimeout(()=>{const d=this.shadow.querySelector(".wg__table"),g=d==null?void 0:d.matches(":hover"),u=l.matches(":hover");!g&&!u&&this.closeToolbarAndReset()},150))}))}const a=this.shadow.querySelector(`[data-toolbar-trigger="${i}"]`);a&&(this.shadow.querySelectorAll(".wg__toolbar-trigger--active").forEach(l=>{l.classList.remove("wg__toolbar-trigger--active")}),a.classList.add("wg__toolbar-trigger--active"))}closeToolbarAndReset(){this.toolbarMoveInProgress=!1,this.toolbarHovered=!1,this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),this.toolbarShortcutHandler&&(document.removeEventListener("keydown",this.toolbarShortcutHandler),this.toolbarShortcutHandler=null),ot()}handleToolbarItemClick(t,i,r){const n=this.grid.displayItems.findIndex(a=>a===r);if(n===-1){this.closeToolbarAndReset();return}const s=t.id==="moveUp"||t.id==="moveDown";if(s&&(this.toolbarMoveInProgress=!0),t.onclick&&t.onclick({row:r,rowIndex:n}),this.grid.ontoolbarclick&&this.grid.ontoolbarclick({item:t,rowIndex:n,row:r}),t.id==="delete"){this.closeToolbarAndReset();return}s?(this.render(),no(this,this.grid.displayItems),this.renderConnector()):this.render()}handleInlineActionClick(t,i){if(!t)return;const n=vt(this.grid.rowToolbar).find(a=>a.id===t),s=this.grid.displayItems[i];!n||!s||(n.onclick&&n.onclick({row:s,rowIndex:i}),this.grid.ontoolbarclick&&this.grid.ontoolbarclick({item:n,rowIndex:i,row:s}),this.render())}}typeof customElements<"u"&&!customElements.get("web-grid")&&customElements.define("web-grid",Ot),B.GridElement=Ot,B.WebGrid=Ce,B.default=Ot,Object.defineProperties(B,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
693
+ `;const r=n.querySelector(".wg__goto-input"),s=n.querySelector(".wg__goto-btn--go"),l=n.querySelector(".wg__goto-btn--cancel"),a=()=>{n.remove()},d=()=>{const g=parseInt(r.value,10);if(isNaN(g)||g<1||g>i.length){r.focus(),r.select();return}a();const u=g-1,c=this.grid.focusedCell;if(this.grid.setFocusedCell(u,e),this.grid.shouldUseVirtualScroll())this.scrollToRowProgrammatically(u),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const h=this.shadow.querySelector(`td[data-row="${u}"][data-col="${e}"]`);h==null||h.focus()})});else{const h=this.shadow.querySelector(`td[data-row="${u}"][data-col="${e}"]`);h&&(h.scrollIntoView({block:"nearest",behavior:"auto"}),h.focus(),ee(this,c,{rowIndex:u,colIndex:e}))}};s.addEventListener("click",d),l.addEventListener("click",a),n.addEventListener("click",g=>{g.target===n&&a()}),r.addEventListener("keydown",g=>{g.key==="Enter"?(g.preventDefault(),d()):g.key==="Escape"&&(g.preventDefault(),a())}),this.shadow.appendChild(n),r.focus(),r.select()}openCustomEditor(e,i){const n=this.grid.columns[i];if(!n||n.editor!=="custom"||!n.cellEditCallback)return;const r=String(n.field),s=this.grid.displayItems[e];if(!s)return;const a={value:this.grid.getCellRawValue(s,e,r),row:s,rowIndex:e,field:r,commit:d=>{this.grid.commitEdit(e,r,d),te(this),requestAnimationFrame(()=>{L(this,e,i)})},cancel:()=>{te(this),this.grid.cancelEdit(),requestAnimationFrame(()=>{L(this,e,i)})}};n.cellEditCallback(a)}handleContextMenu(e){const i=e.target,n=i.closest(".wg__header");if(n){this.handleHeaderContextMenu(e,n);return}if(i.closest("th.wg__filler")){this.handleFillerContextMenu(e);return}const s=this.grid.contextMenu;if(!s||s.length===0)return;const l=i.closest(".wg__cell");if(!l)return;e.preventDefault(),this.contextMenuElement&&(he(this.contextMenuElement),this.contextMenuElement=null);const a=parseInt(l.dataset.row||"0",10),d=parseInt(l.dataset.col||"0",10),g=this.grid.columns[d];if(!g)return;const u=this.grid.displayItems[a];if(!u)return;const c=String(g.field),h=this.grid.getCellRawValue(u,a,c),f={row:u,rowIndex:a,colIndex:d,column:g,cellValue:h};this.grid.oncontextmenuopen&&this.grid.oncontextmenuopen(f);const w=Object.getOwnPropertyDescriptor(this,"contextMenuXOffset"),p=Object.getOwnPropertyDescriptor(this,"contextMenuYOffset");w&&"value"in w&&(this.grid.contextMenuXOffset=w.value,delete this.contextMenuXOffset),p&&"value"in p&&(this.grid.contextMenuYOffset=p.value,delete this.contextMenuYOffset),this.contextMenuElement=mr(this,e.clientX,e.clientY,this.grid.contextMenuXOffset,this.grid.contextMenuYOffset,s,f,m=>{const y=s.find(_=>_.id===m);y!=null&&y.onclick&&y.onclick(f),this.contextMenuElement&&(he(this.contextMenuElement),this.contextMenuElement=null)},()=>{this.contextMenuElement=null})}handleHeaderContextMenu(e,i){const n=this.grid.headerContextMenu;if(!n||n.length===0)return;e.preventDefault(),this.contextMenuElement&&(he(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(he(this.headerContextMenuElement),this.headerContextMenuElement=null);const r=i.dataset.field;if(!r)return;const s=this.grid.columns.findIndex(f=>String(f.field)===r);if(s===-1)return;const l=this.grid.columns[s],a=this.grid.freezeColumns,d=s<a,g=this.grid.sort.find(f=>f.column===r),u=(g==null?void 0:g.direction)??null,c={column:l,field:r,columnIndex:s,sortDirection:u,isFrozen:d,allColumns:this.grid.columns,labels:this.grid.labels};this.grid.onheadercontextmenuopen&&this.grid.onheadercontextmenuopen(c);const h=Lo(n,c);h.length!==0&&(this.headerContextMenuElement=Oo(this,e.clientX,e.clientY,h,c,(f,w,p)=>{if(["sortAsc","sortDesc","clearSort","hideColumn","freezeColumn","unfreezeColumn"].includes(f)&&_r(this,f,c,p),f==="show-all-columns"){this.grid.columns.forEach(_=>{_.isHidden=!1}),this.grid.columns=[...this.grid.columns];return}if(f.startsWith("toggle-col-")){const _=f.replace("toggle-col-",""),S=this.grid.columns.find(v=>String(v.field)===_);S&&(S.isHidden=!S.isHidden,this.grid.columns=[...this.grid.columns]);return}const y=h.find(_=>_.id===f);y!=null&&y.onclick&&y.onclick(c),!w&&this.headerContextMenuElement&&(he(this.headerContextMenuElement),this.headerContextMenuElement=null)},()=>{this.headerContextMenuElement=null}))}handleFillerContextMenu(e){const i=this.grid.headerContextMenu;if(!i||i.length===0)return;e.preventDefault(),this.contextMenuElement&&(he(this.contextMenuElement),this.contextMenuElement=null),this.headerContextMenuElement&&(he(this.headerContextMenuElement),this.headerContextMenuElement=null);const n=i.filter(l=>l==="columnVisibility"?!0:typeof l=="object"&&l.id?!(typeof l.label=="function"||typeof l.icon=="function"):(typeof l=="string"||typeof l=="object"&&l.dividerBefore&&!l.id&&!l.label,!1));if(n.length===0)return;const r={column:null,field:"",columnIndex:-1,sortDirection:null,isFrozen:!1,allColumns:this.grid.columns,labels:this.grid.labels},s=Lo(n,r);s.length!==0&&(this.headerContextMenuElement=Oo(this,e.clientX,e.clientY,s,r,(l,a,d)=>{if(l==="show-all-columns"){this.grid.columns.forEach(u=>{u.isHidden=!1}),this.grid.columns=[...this.grid.columns];return}if(l.startsWith("toggle-col-")){const u=l.replace("toggle-col-",""),c=this.grid.columns.find(h=>String(h.field)===u);c&&(c.isHidden=!c.isHidden,this.grid.columns=[...this.grid.columns]);return}const g=s.find(u=>u.id===l);g!=null&&g.onclick&&g.onclick(r),!a&&this.headerContextMenuElement&&(he(this.headerContextMenuElement),this.headerContextMenuElement=null)},()=>{this.headerContextMenuElement=null}))}setupToolbarShortcuts(){this.toolbarShortcutHandler&&document.removeEventListener("keydown",this.toolbarShortcutHandler);const e=this.grid.rowShortcuts;e!=null&&e.length&&(this.toolbarShortcutHandler=i=>{if(i.target.matches('input, textarea, select, [contenteditable="true"]'))return;const r=Oe();if(r===null||!mo(this.shadow))return;const s=this.grid.displayItems[r];if(!s)return;const l=this.grid.columns;for(const a of e){const d=Ye(a.key);if(Be(i,d)){const g={row:s,rowIndex:r,colIndex:0,column:l[0],cellValue:null};if(!(typeof a.disabled=="function"?a.disabled(g):a.disabled===!0)){i.preventDefault(),i.stopPropagation(),a.action(g);return}}}},document.addEventListener("keydown",this.toolbarShortcutHandler))}setupInlineShortcuts(){this.removeInlineShortcuts();const e=this.grid.rowShortcuts;!(e!=null&&e.length)||this.grid.hoveredRowIndex===null||(this.inlineShortcutHandler=i=>{if(i.target.matches('input, textarea, select, [contenteditable="true"]'))return;const r=this.grid.hoveredRowIndex;if(r===null)return;const s=this.grid.displayItems[r];if(!s)return;const l=this.grid.columns;for(const a of e){const d=Ye(a.key);if(Be(i,d)){const g={row:s,rowIndex:r,colIndex:0,column:l[0],cellValue:null};if(!(typeof a.disabled=="function"?a.disabled(g):a.disabled===!0)){i.preventDefault(),i.stopPropagation(),a.action(g);return}}}},document.addEventListener("keydown",this.inlineShortcutHandler))}removeInlineShortcuts(){this.inlineShortcutHandler&&(document.removeEventListener("keydown",this.inlineShortcutHandler),this.inlineShortcutHandler=null)}setupToolbarTooltips(e,i,n){const r=this.shadow.querySelector(".wg__toolbar-container");if(!r)return;r.querySelectorAll(".wg__toolbar-btn").forEach(l=>{var c;const a=l,d=a.dataset.toolbarItem,g=e.find(h=>h.id===d);if(!g)return;const u=(c=this.grid.rowShortcuts)==null?void 0:c.find(h=>h.id===g.id);a.addEventListener("mouseenter",()=>{const h=g.tooltipCallback?g.tooltipCallback(i,n):Mn(g,u==null?void 0:u.key);Vt(this,a,h,0,!0)}),a.addEventListener("mouseleave",()=>{Io(this)})})}showToolbarForRow(e,i,n){if(this.grid.toolbarPosition==="inline"||!this.grid.isRowToolbarVisible||!this.grid.rowToolbar.length)return;const r=Dt(this.grid.rowToolbar),s=this.grid.displayItems[i];if(!s)return;if(this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),In(this,e,i,r,s,a=>{this.handleToolbarItemClick(a,i,s)},n),this.setupToolbarShortcuts(),this.renderConnector(),this.setupToolbarTooltips(r,s,i),this.grid.toolbarTrigger==="hover"){const a=this.shadow.querySelector(".wg__toolbar-container");a&&(a.addEventListener("mouseenter",()=>{this.toolbarHovered=!0,this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null)}),a.addEventListener("mouseleave",()=>{this.toolbarHovered=!1,!this.toolbarMoveInProgress&&(this.toolbarHideTimeout=setTimeout(()=>{const d=this.shadow.querySelector(".wg__table"),g=d==null?void 0:d.matches(":hover"),u=a.matches(":hover");!g&&!u&&this.closeToolbarAndReset()},150))}))}const l=this.shadow.querySelector(`[data-toolbar-trigger="${i}"]`);l&&(this.shadow.querySelectorAll(".wg__toolbar-trigger--active").forEach(a=>{a.classList.remove("wg__toolbar-trigger--active")}),l.classList.add("wg__toolbar-trigger--active"))}closeToolbarAndReset(){this.toolbarMoveInProgress=!1,this.toolbarHovered=!1,this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),this.toolbarShortcutHandler&&(document.removeEventListener("keydown",this.toolbarShortcutHandler),this.toolbarShortcutHandler=null),ot()}handleScrollCloseDropdown(){const e=this.grid.editingCell,i=e?this.grid.columns.findIndex(n=>String(n.field)===e.field):-1;B(this),te(this),this.grid.cancelEdit(),e&&i>=0&&j(this,e.rowIndex,i)}handleSelectBlur(){if(this.dropdownOpen||this.isOpeningDropdown)return;const e=this.grid.editingCell,i=e?this.grid.columns.findIndex(n=>String(n.field)===e.field):-1;B(this),te(this),this.grid.cancelEdit(),e&&i>=0&&j(this,e.rowIndex,i)}handleComboboxBlur(e){if(B(this),this.grid.editingCell){const i=this.getCurrentEditingColumn();if(i){const n=i.editorOptions||{},s=(n.options||n.initialOptions||[]).find(a=>Ne(a,n).toLowerCase()===e.value.toLowerCase()),l=s?ke(s,n):e.value;this.grid.commitEdit(this.grid.editingCell.rowIndex,this.grid.editingCell.field,l)}}}handleToolbarItemClick(e,i,n){const r=this.grid.displayItems.findIndex(l=>l===n);if(r===-1){this.closeToolbarAndReset();return}const s=e.id==="moveUp"||e.id==="moveDown";if(s&&(this.toolbarMoveInProgress=!0),e.onclick&&e.onclick({row:n,rowIndex:r}),this.grid.ontoolbarclick&&this.grid.ontoolbarclick({item:e,rowIndex:r,row:n}),e.id==="delete"){this.closeToolbarAndReset();return}s?(this.render(),bo(this,this.grid.displayItems),this.renderConnector()):this.render()}handleInlineActionClick(e,i){if(!e)return;const r=Dt(this.grid.rowToolbar).find(l=>l.id===e),s=this.grid.displayItems[i];!r||!s||(r.onclick&&r.onclick({row:s,rowIndex:i}),this.grid.ontoolbarclick&&this.grid.ontoolbarclick({item:r,rowIndex:i,row:s}),this.render())}}typeof customElements<"u"&&!customElements.get("web-grid")&&customElements.define("web-grid",Wt),G.GridElement=Wt,G.WebGrid=po,G.default=Wt,Object.defineProperties(G,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});