@keenmate/web-grid 1.0.0-rc05 → 1.0.0-rc06

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,17 +1,17 @@
1
- (function(H,z){typeof exports=="object"&&typeof module<"u"?z(exports):typeof define=="function"&&define.amd?define(["exports"],z):(H=typeof globalThis<"u"?globalThis:H||self,z(H.WebGrid={}))})(this,function(H){"use strict";var Zi=Object.defineProperty;var tr=(H,z,ht)=>z in H?Zi(H,z,{enumerable:!0,configurable:!0,writable:!0,value:ht}):H[z]=ht;var w=(H,z,ht)=>tr(H,typeof z!="symbol"?z+"":z,ht);class z{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,"_invalidCells",[]);w(this,"_showRowToolbar",!1);w(this,"_rowToolbar",["add","delete","duplicate"]);w(this,"_toolbarAlign","center");w(this,"_toolbarTopPosition","center");w(this,"_toolbarTrigger","hover");w(this,"_toolbarPosition","auto");w(this,"_contextMenu");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,"_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,"_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)}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 sortable(){return this._sortMode!=="none"}set sortable(e){this._sortMode=e?"multi":"none",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 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 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 toolbarAlign(){return this._toolbarAlign}set toolbarAlign(e){this._toolbarAlign=e,this.requestUpdate()}get toolbarTopPosition(){return this._toolbarTopPosition}set toolbarTopPosition(e){this._toolbarTopPosition=e,this.requestUpdate()}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 contextMenu(){return this._contextMenu}set contextMenu(e){this._contextMenu=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 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 ondatarequest(){return this._ondatarequest}set ondatarequest(e){this._ondatarequest=e}get onrowdelete(){return this._onrowdelete}set onrowdelete(e){this._onrowdelete=e}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(([o,i])=>i?String(e[o]??"").toLowerCase().includes(i.toLowerCase()):!0))}get sortedItems(){return this._sort.length===0?this.filteredItems:[...this.filteredItems].sort((e,o)=>{for(const i of this._sort){const r=e[i.column],s=o[i.column];if(r===s)continue;let n=0;return typeof r=="string"&&typeof s=="string"?n=r.localeCompare(s):typeof r=="number"&&typeof s=="number"?n=r-s:n=String(r??"").localeCompare(String(s??"")),i.direction==="asc"?n:-n}return 0})}get paginatedItems(){if(!this._pageable)return this.sortedItems;const e=(this._currentPage-1)*this._pageSize,o=e+this._pageSize;return this.sortedItems.slice(e,o)}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 o=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:o};this._ondatarequest(i)}}getColumnSortState(e){return this._sort.find(o=>o.column===e)}getColumnSortPriority(e){const o=this._sort.findIndex(i=>i.column===e);return o>=0?o+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(o=>o.rowIndex!==e),this.requestUpdate()}getDraftRowIndices(){return Array.from(this._draftRows.keys())}discardAllDrafts(){this._draftRows.clear(),this._invalidCells=[],this.requestUpdate()}getCellRawValue(e,o,i){const r=this._draftRows.get(o);return r?r[i]:e[i]}getCellValue(e,o,i){if(o.templateCallback)return o.templateCallback(e);const r=i!==void 0?this.getCellRawValue(e,i,String(o.field)):e[String(o.field)];return o.formatCallback?o.formatCallback(r,e):String(r??"")}isCellInvalid(e,o){return this._invalidCells.some(i=>i.rowIndex===e&&i.field===o)}getCellValidationError(e,o){const i=this._invalidCells.find(r=>r.rowIndex===e&&r.field===o);return(i==null?void 0:i.error)||null}addInvalidCell(e,o,i){const r=this._invalidCells.findIndex(s=>s.rowIndex===e&&s.field===o);r>=0?this._invalidCells[r]={rowIndex:e,field:o,error:i}:this._invalidCells=[...this._invalidCells,{rowIndex:e,field:o,error:i}]}removeInvalidCell(e,o){this._invalidCells=this._invalidCells.filter(i=>!(i.rowIndex===e&&i.field===o))}isEditing(e,o){var i,r;return((i=this._editingCell)==null?void 0:i.rowIndex)===e&&((r=this._editingCell)==null?void 0:r.field)===o}startEdit(e,o,i){var s;const r=this.displayItems[e];r&&(this._draftRows.has(e)||this._draftRows.set(e,{...r}),this._editingCell={rowIndex:e,field:o,initialSearchQuery:i==null?void 0:i.initialSearchQuery,cursorPosition:i==null?void 0:i.cursorPosition},this._currentCellError=null,this.requestUpdate(),(s=this._onroweditstart)==null||s.call(this,{row:r,rowIndex:e,field:o}))}cancelEdit(){var e;if(this._editingCell){const{rowIndex:o,field:i}=this._editingCell,r=this.displayItems[o];r&&((e=this._onroweditcancel)==null||e.call(this,{row:r,rowIndex:o,field:i})),this._editingCell=null,this._currentCellError=null,this.requestUpdate()}}normalizeValidationResult(e,o){return e==null||e===!0?{valid:!0,finalValue:o}:e===!1?{valid:!1,message:"Validation failed",finalValue:o}:typeof e=="string"?{valid:!1,message:e,finalValue:o}:{valid:e.valid,message:e.message,finalValue:e.transformedValue!==void 0?e.transformedValue:o}}async commitEdit(e,o,i){var g,h;const r=this._columns.find(u=>String(u.field)===o);if(!r)return;const s=this.displayItems[e];if(!s)return;const n=s[o];let d=i,a=null,c=!0;this._isValidating=!0;try{if(r.beforeCommitCallback){const u={value:i,oldValue:n,row:s,rowIndex:e,field:o},p=await Promise.resolve(r.beforeCommitCallback(u)),m=this.normalizeValidationResult(p,i);c=m.valid,a=m.message||null,d=m.finalValue}else if(r.validateCallback){const u=await Promise.resolve(r.validateCallback(i,s));u&&(c=!1,a=u)}}catch(u){c=!1,a=u instanceof Error?u.message:"Validation failed"}this._isValidating=!1;let l=this._draftRows.get(e);l||(l={...s},this._draftRows.set(e,l)),l[o]=d,c?(this.removeInvalidCell(e,o),this._currentCellError=null):(this.addInvalidCell(e,o,a||"Invalid value"),this._currentCellError=a,(g=this._onvalidationerror)==null||g.call(this,{row:s,rowIndex:e,field:o,error:a||"Invalid value"})),(h=this._onrowchange)==null||h.call(this,{row:s,draftRow:l,rowIndex:e,field:o,oldValue:n,newValue:d,isValid:c,validationError:a}),this._editingCell=null,this.requestUpdate()}isCellEditable(e){return e.editable===!1?!1:this._editable||e.editor!==void 0}getEditableColumns(){return this._columns.map((e,o)=>({index:o,column:e})).filter(({column:e})=>this.isCellEditable(e))}isCellFocused(e,o){var i,r;return((i=this._focusedCell)==null?void 0:i.rowIndex)===e&&((r=this._focusedCell)==null?void 0:r.colIndex)===o}get focusedCell(){return this._focusedCell}setFocusedCell(e,o){this._focusedCell={rowIndex:e,colIndex:o}}clearFocusedCell(){this._focusedCell=null}}const ht=':host{--wg-rem: 10px;font-family:var(--wg-font-family, var(--base-font-family, system-ui, -apple-system, sans-serif));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-base, 1.4) * var(--wg-rem));--wg-font-size-sm: calc(var(--base-font-size-sm, 1.2) * var(--wg-rem));--wg-font-size-xs: calc(var(--base-font-size-xs, 1.1) * var(--wg-rem));--wg-font-size-lg: calc(var(--base-font-size-lg, 1.6) * var(--wg-rem));--wg-line-height-base: calc(var(--base-line-height-normal, 2) * var(--wg-rem));--wg-font-weight-normal: var(--base-font-weight-normal, 400);--wg-font-weight-semibold: var(--base-font-weight-semibold, 600);--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-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-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-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-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-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}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:max-content;min-width:100%;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__table tbody tr{border-bottom:var(--wg-row-border)}.wg__row-number-header,.wg__row-number{width:40px;min-width:40px;max-width:40px;text-align:center;color:var(--wg-text-color-secondary);background:var(--wg-header-bg);-webkit-user-select:none;user-select:none;font-size:var(--wg-font-size-sm)}.wg__row-number{border-right:var(--wg-cell-border)}.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);text-align:left;-webkit-user-select:none;user-select: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}.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-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__cell{padding:var(--wg-cell-padding);color:var(--wg-cell-color);scroll-margin-top:3rem;scroll-margin-bottom:.5rem}.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)}.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)}.wg__date-input{flex:1;min-width:0;height:100%;border:none;background:transparent;font:inherit;padding:var(--wg-cell-padding-block) var(--wg-cell-padding-inline);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-secondary, #666);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:2px solid var(--wg-focus-border-color, #217346);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-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-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:calc(var(--wg-design-unit, 4) * 4px + 21px);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-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--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, 10000);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__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);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-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-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 Vt(t,e,o){const i=o.valueMember||"value",r=o.displayMember||"label",s=e.find(n=>n[i]===t);return s?String(s[r]??""):t!=null?String(t):""}function _t(t,e){if(e.getDisplayCallback)return e.getDisplayCallback(t);const o=e.displayMember||"label";return String(t[o]??t.label??"")}function lt(t,e){if(e.getValueCallback)return e.getValueCallback(t);const o=e.valueMember||"value";return t[o]??t.value}function Be(t,e){return e.getIconCallback?e.getIconCallback(t):e.iconMember&&t[e.iconMember]||null}function Ke(t,e){return e.getSubtitleCallback?e.getSubtitleCallback(t):e.subtitleMember&&t[e.subtitleMember]||null}function yt(t,e){return e.getDisabledCallback?e.getDisabledCallback(t):e.disabledMember?!!t[e.disabledMember]:!1}const rt=Math.min,F=Math.max,$t=Math.round,Mt=Math.floor,Z=t=>({x:t,y:t}),We={left:"right",right:"left",bottom:"top",top:"bottom"},Xe={start:"end",end:"start"};function qt(t,e,o){return F(t,rt(e,o))}function pt(t,e){return typeof t=="function"?t(e):t}function nt(t){return t.split("-")[0]}function ft(t){return t.split("-")[1]}function ge(t){return t==="x"?"y":"x"}function Yt(t){return t==="y"?"height":"width"}const Qe=new Set(["top","bottom"]);function ot(t){return Qe.has(nt(t))?"y":"x"}function Nt(t){return ge(ot(t))}function Ge(t,e,o){o===void 0&&(o=!1);const i=ft(t),r=Nt(t),s=Yt(r);let n=r==="x"?i===(o?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(n=At(n)),[n,At(n)]}function Je(t){const e=At(t);return[Ut(t),e,Ut(e)]}function Ut(t){return t.replace(/start|end/g,e=>Xe[e])}const ue=["left","right"],he=["right","left"],Ze=["top","bottom"],to=["bottom","top"];function eo(t,e,o){switch(t){case"top":case"bottom":return o?e?he:ue:e?ue:he;case"left":case"right":return e?Ze:to;default:return[]}}function oo(t,e,o,i){const r=ft(t);let s=eo(nt(t),o==="start",i);return r&&(s=s.map(n=>n+"-"+r),e&&(s=s.concat(s.map(Ut)))),s}function At(t){return t.replace(/left|right|bottom|top/g,e=>We[e])}function io(t){return{top:0,right:0,bottom:0,left:0,...t}}function pe(t){return typeof t!="number"?io(t):{top:t,right:t,bottom:t,left:t}}function Ot(t){const{x:e,y:o,width:i,height:r}=t;return{width:i,height:r,top:o,left:e,right:e+i,bottom:o+r,x:e,y:o}}function fe(t,e,o){let{reference:i,floating:r}=t;const s=ot(e),n=Nt(e),d=Yt(n),a=nt(e),c=s==="y",l=i.x+i.width/2-r.width/2,g=i.y+i.height/2-r.height/2,h=i[d]/2-r[d]/2;let u;switch(a){case"top":u={x:l,y:i.y-r.height};break;case"bottom":u={x:l,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:g};break;case"left":u={x:i.x-r.width,y:g};break;default:u={x:i.x,y:i.y}}switch(ft(e)){case"start":u[n]-=h*(o&&c?-1:1);break;case"end":u[n]+=h*(o&&c?-1:1);break}return u}const ro=async(t,e,o)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:n}=o,d=s.filter(Boolean),a=await(n.isRTL==null?void 0:n.isRTL(e));let c=await n.getElementRects({reference:t,floating:e,strategy:r}),{x:l,y:g}=fe(c,i,a),h=i,u={},p=0;for(let m=0;m<d.length;m++){const{name:f,fn:b}=d[m],{x:v,y:_,data:S,reset:y}=await b({x:l,y:g,initialPlacement:i,placement:h,strategy:r,middlewareData:u,rects:c,platform:n,elements:{reference:t,floating:e}});l=v??l,g=_??g,u={...u,[f]:{...u[f],...S}},y&&p<=50&&(p++,typeof y=="object"&&(y.placement&&(h=y.placement),y.rects&&(c=y.rects===!0?await n.getElementRects({reference:t,floating:e,strategy:r}):y.rects),{x:l,y:g}=fe(c,h,a)),m=-1)}return{x:l,y:g,placement:h,strategy:r,middlewareData:u}};async function jt(t,e){var o;e===void 0&&(e={});const{x:i,y:r,platform:s,rects:n,elements:d,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:l="viewport",elementContext:g="floating",altBoundary:h=!1,padding:u=0}=pt(e,t),p=pe(u),f=d[h?g==="floating"?"reference":"floating":g],b=Ot(await s.getClippingRect({element:(o=await(s.isElement==null?void 0:s.isElement(f)))==null||o?f:f.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(d.floating)),boundary:c,rootBoundary:l,strategy:a})),v=g==="floating"?{x:i,y:r,width:n.floating.width,height:n.floating.height}:n.reference,_=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d.floating)),S=await(s.isElement==null?void 0:s.isElement(_))?await(s.getScale==null?void 0:s.getScale(_))||{x:1,y:1}:{x:1,y:1},y=Ot(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:v,offsetParent:_,strategy:a}):v);return{top:(b.top-y.top+p.top)/S.y,bottom:(y.bottom-b.bottom+p.bottom)/S.y,left:(b.left-y.left+p.left)/S.x,right:(y.right-b.right+p.right)/S.x}}const no=t=>({name:"arrow",options:t,async fn(e){const{x:o,y:i,placement:r,rects:s,platform:n,elements:d,middlewareData:a}=e,{element:c,padding:l=0}=pt(t,e)||{};if(c==null)return{};const g=pe(l),h={x:o,y:i},u=Nt(r),p=Yt(u),m=await n.getDimensions(c),f=u==="y",b=f?"top":"left",v=f?"bottom":"right",_=f?"clientHeight":"clientWidth",S=s.reference[p]+s.reference[u]-h[u]-s.floating[p],y=h[u]-s.reference[u],D=await(n.getOffsetParent==null?void 0:n.getOffsetParent(c));let x=D?D[_]:0;(!x||!await(n.isElement==null?void 0:n.isElement(D)))&&(x=d.floating[_]||s.floating[p]);const C=S/2-y/2,T=x/2-m[p]/2-1,k=rt(g[b],T),$=rt(g[v],T),A=k,N=x-m[p]-$,O=x/2-m[p]/2+C,R=qt(A,O,N),U=!a.arrow&&ft(r)!=null&&O!==R&&s.reference[p]/2-(O<A?k:$)-m[p]/2<0,j=U?O<A?O-A:O-N:0;return{[u]:h[u]+j,data:{[u]:R,centerOffset:O-R-j,...U&&{alignmentOffset:j}},reset:U}}}),so=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var o,i;const{placement:r,middlewareData:s,rects:n,initialPlacement:d,platform:a,elements:c}=e,{mainAxis:l=!0,crossAxis:g=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...f}=pt(t,e);if((o=s.arrow)!=null&&o.alignmentOffset)return{};const b=nt(r),v=ot(d),_=nt(d)===d,S=await(a.isRTL==null?void 0:a.isRTL(c.floating)),y=h||(_||!m?[At(d)]:Je(d)),D=p!=="none";!h&&D&&y.push(...oo(d,m,p,S));const x=[d,...y],C=await jt(e,f),T=[];let k=((i=s.flip)==null?void 0:i.overflows)||[];if(l&&T.push(C[b]),g){const O=Ge(r,n,S);T.push(C[O[0]],C[O[1]])}if(k=[...k,{placement:r,overflows:T}],!T.every(O=>O<=0)){var $,A;const O=((($=s.flip)==null?void 0:$.index)||0)+1,R=x[O];if(R&&(!(g==="alignment"?v!==ot(R):!1)||k.every(B=>ot(B.placement)===v?B.overflows[0]>0:!0)))return{data:{index:O,overflows:k},reset:{placement:R}};let U=(A=k.filter(j=>j.overflows[0]<=0).sort((j,B)=>j.overflows[1]-B.overflows[1])[0])==null?void 0:A.placement;if(!U)switch(u){case"bestFit":{var N;const j=(N=k.filter(B=>{if(D){const L=ot(B.placement);return L===v||L==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(L=>L>0).reduce((L,K)=>L+K,0)]).sort((B,L)=>B[1]-L[1])[0])==null?void 0:N[0];j&&(U=j);break}case"initialPlacement":U=d;break}if(r!==U)return{reset:{placement:U}}}return{}}}},ao=new Set(["left","top"]);async function lo(t,e){const{placement:o,platform:i,elements:r}=t,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),n=nt(o),d=ft(o),a=ot(o)==="y",c=ao.has(n)?-1:1,l=s&&a?-1:1,g=pt(e,t);let{mainAxis:h,crossAxis:u,alignmentAxis:p}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return d&&typeof p=="number"&&(u=d==="end"?p*-1:p),a?{x:u*l,y:h*c}:{x:h*c,y:u*l}}const co=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var o,i;const{x:r,y:s,placement:n,middlewareData:d}=e,a=await lo(e,t);return n===((o=d.offset)==null?void 0:o.placement)&&(i=d.arrow)!=null&&i.alignmentOffset?{}:{x:r+a.x,y:s+a.y,data:{...a,placement:n}}}}},go=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:o,y:i,placement:r}=e,{mainAxis:s=!0,crossAxis:n=!1,limiter:d={fn:f=>{let{x:b,y:v}=f;return{x:b,y:v}}},...a}=pt(t,e),c={x:o,y:i},l=await jt(e,a),g=ot(nt(r)),h=ge(g);let u=c[h],p=c[g];if(s){const f=h==="y"?"top":"left",b=h==="y"?"bottom":"right",v=u+l[f],_=u-l[b];u=qt(v,u,_)}if(n){const f=g==="y"?"top":"left",b=g==="y"?"bottom":"right",v=p+l[f],_=p-l[b];p=qt(v,p,_)}const m=d.fn({...e,[h]:u,[g]:p});return{...m,data:{x:m.x-o,y:m.y-i,enabled:{[h]:s,[g]:n}}}}}},uo=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var o,i;const{placement:r,rects:s,platform:n,elements:d}=e,{apply:a=()=>{},...c}=pt(t,e),l=await jt(e,c),g=nt(r),h=ft(r),u=ot(r)==="y",{width:p,height:m}=s.floating;let f,b;g==="top"||g==="bottom"?(f=g,b=h===(await(n.isRTL==null?void 0:n.isRTL(d.floating))?"start":"end")?"left":"right"):(b=g,f=h==="end"?"top":"bottom");const v=m-l.top-l.bottom,_=p-l.left-l.right,S=rt(m-l[f],v),y=rt(p-l[b],_),D=!e.middlewareData.shift;let x=S,C=y;if((o=e.middlewareData.shift)!=null&&o.enabled.x&&(C=_),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(x=v),D&&!h){const k=F(l.left,0),$=F(l.right,0),A=F(l.top,0),N=F(l.bottom,0);u?C=p-2*(k!==0||$!==0?k+$:F(l.left,l.right)):x=m-2*(A!==0||N!==0?A+N:F(l.top,l.bottom))}await a({...e,availableWidth:C,availableHeight:x});const T=await n.getDimensions(d.floating);return p!==T.width||m!==T.height?{reset:{rects:!0}}:{}}}};function Rt(){return typeof window<"u"}function wt(t){return we(t)?(t.nodeName||"").toLowerCase():"#document"}function V(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function tt(t){var e;return(e=(we(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function we(t){return Rt()?t instanceof Node||t instanceof V(t).Node:!1}function Q(t){return Rt()?t instanceof Element||t instanceof V(t).Element:!1}function et(t){return Rt()?t instanceof HTMLElement||t instanceof V(t).HTMLElement:!1}function me(t){return!Rt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof V(t).ShadowRoot}const ho=new Set(["inline","contents"]);function Ct(t){const{overflow:e,overflowX:o,overflowY:i,display:r}=G(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+o)&&!ho.has(r)}const po=new Set(["table","td","th"]);function fo(t){return po.has(wt(t))}const wo=[":popover-open",":modal"];function Pt(t){return wo.some(e=>{try{return t.matches(e)}catch{return!1}})}const mo=["transform","translate","scale","rotate","perspective"],bo=["transform","translate","scale","rotate","perspective","filter"],vo=["paint","layout","strict","content"];function Bt(t){const e=Kt(),o=Q(t)?G(t):t;return mo.some(i=>o[i]?o[i]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!e&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!e&&(o.filter?o.filter!=="none":!1)||bo.some(i=>(o.willChange||"").includes(i))||vo.some(i=>(o.contain||"").includes(i))}function _o(t){let e=st(t);for(;et(e)&&!mt(e);){if(Bt(e))return e;if(Pt(e))return null;e=st(e)}return null}function Kt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const yo=new Set(["html","body","#document"]);function mt(t){return yo.has(wt(t))}function G(t){return V(t).getComputedStyle(t)}function It(t){return Q(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function st(t){if(wt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||me(t)&&t.host||tt(t);return me(e)?e.host:e}function be(t){const e=st(t);return mt(e)?t.ownerDocument?t.ownerDocument.body:t.body:et(e)&&Ct(e)?e:be(e)}function St(t,e,o){var i;e===void 0&&(e=[]),o===void 0&&(o=!0);const r=be(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),n=V(r);if(s){const d=Wt(n);return e.concat(n,n.visualViewport||[],Ct(r)?r:[],d&&o?St(d):[])}return e.concat(r,St(r,[],o))}function Wt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ve(t){const e=G(t);let o=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=et(t),s=r?t.offsetWidth:o,n=r?t.offsetHeight:i,d=$t(o)!==s||$t(i)!==n;return d&&(o=s,i=n),{width:o,height:i,$:d}}function Xt(t){return Q(t)?t:t.contextElement}function bt(t){const e=Xt(t);if(!et(e))return Z(1);const o=e.getBoundingClientRect(),{width:i,height:r,$:s}=ve(e);let n=(s?$t(o.width):o.width)/i,d=(s?$t(o.height):o.height)/r;return(!n||!Number.isFinite(n))&&(n=1),(!d||!Number.isFinite(d))&&(d=1),{x:n,y:d}}const Co=Z(0);function _e(t){const e=V(t);return!Kt()||!e.visualViewport?Co:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function So(t,e,o){return e===void 0&&(e=!1),!o||e&&o!==V(t)?!1:e}function dt(t,e,o,i){e===void 0&&(e=!1),o===void 0&&(o=!1);const r=t.getBoundingClientRect(),s=Xt(t);let n=Z(1);e&&(i?Q(i)&&(n=bt(i)):n=bt(t));const d=So(s,o,i)?_e(s):Z(0);let a=(r.left+d.x)/n.x,c=(r.top+d.y)/n.y,l=r.width/n.x,g=r.height/n.y;if(s){const h=V(s),u=i&&Q(i)?V(i):i;let p=h,m=Wt(p);for(;m&&i&&u!==p;){const f=bt(m),b=m.getBoundingClientRect(),v=G(m),_=b.left+(m.clientLeft+parseFloat(v.paddingLeft))*f.x,S=b.top+(m.clientTop+parseFloat(v.paddingTop))*f.y;a*=f.x,c*=f.y,l*=f.x,g*=f.y,a+=_,c+=S,p=V(m),m=Wt(p)}}return Ot({width:l,height:g,x:a,y:c})}function Lt(t,e){const o=It(t).scrollLeft;return e?e.left+o:dt(tt(t)).left+o}function ye(t,e){const o=t.getBoundingClientRect(),i=o.left+e.scrollLeft-Lt(t,o),r=o.top+e.scrollTop;return{x:i,y:r}}function xo(t){let{elements:e,rect:o,offsetParent:i,strategy:r}=t;const s=r==="fixed",n=tt(i),d=e?Pt(e.floating):!1;if(i===n||d&&s)return o;let a={scrollLeft:0,scrollTop:0},c=Z(1);const l=Z(0),g=et(i);if((g||!g&&!s)&&((wt(i)!=="body"||Ct(n))&&(a=It(i)),et(i))){const u=dt(i);c=bt(i),l.x=u.x+i.clientLeft,l.y=u.y+i.clientTop}const h=n&&!g&&!s?ye(n,a):Z(0);return{width:o.width*c.x,height:o.height*c.y,x:o.x*c.x-a.scrollLeft*c.x+l.x+h.x,y:o.y*c.y-a.scrollTop*c.y+l.y+h.y}}function ko(t){return Array.from(t.getClientRects())}function Do(t){const e=tt(t),o=It(t),i=t.ownerDocument.body,r=F(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=F(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let n=-o.scrollLeft+Lt(t);const d=-o.scrollTop;return G(i).direction==="rtl"&&(n+=F(e.clientWidth,i.clientWidth)-r),{width:r,height:s,x:n,y:d}}const Ce=25;function To(t,e){const o=V(t),i=tt(t),r=o.visualViewport;let s=i.clientWidth,n=i.clientHeight,d=0,a=0;if(r){s=r.width,n=r.height;const l=Kt();(!l||l&&e==="fixed")&&(d=r.offsetLeft,a=r.offsetTop)}const c=Lt(i);if(c<=0){const l=i.ownerDocument,g=l.body,h=getComputedStyle(g),u=l.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(i.clientWidth-g.clientWidth-u);p<=Ce&&(s-=p)}else c<=Ce&&(s+=c);return{width:s,height:n,x:d,y:a}}const Eo=new Set(["absolute","fixed"]);function $o(t,e){const o=dt(t,!0,e==="fixed"),i=o.top+t.clientTop,r=o.left+t.clientLeft,s=et(t)?bt(t):Z(1),n=t.clientWidth*s.x,d=t.clientHeight*s.y,a=r*s.x,c=i*s.y;return{width:n,height:d,x:a,y:c}}function Se(t,e,o){let i;if(e==="viewport")i=To(t,o);else if(e==="document")i=Do(tt(t));else if(Q(e))i=$o(e,o);else{const r=_e(t);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return Ot(i)}function xe(t,e){const o=st(t);return o===e||!Q(o)||mt(o)?!1:G(o).position==="fixed"||xe(o,e)}function Mo(t,e){const o=e.get(t);if(o)return o;let i=St(t,[],!1).filter(d=>Q(d)&&wt(d)!=="body"),r=null;const s=G(t).position==="fixed";let n=s?st(t):t;for(;Q(n)&&!mt(n);){const d=G(n),a=Bt(n);!a&&d.position==="fixed"&&(r=null),(s?!a&&!r:!a&&d.position==="static"&&!!r&&Eo.has(r.position)||Ct(n)&&!a&&xe(t,n))?i=i.filter(l=>l!==n):r=d,n=st(n)}return e.set(t,i),i}function Ao(t){let{element:e,boundary:o,rootBoundary:i,strategy:r}=t;const n=[...o==="clippingAncestors"?Pt(e)?[]:Mo(e,this._c):[].concat(o),i],d=n[0],a=n.reduce((c,l)=>{const g=Se(e,l,r);return c.top=F(g.top,c.top),c.right=rt(g.right,c.right),c.bottom=rt(g.bottom,c.bottom),c.left=F(g.left,c.left),c},Se(e,d,r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Oo(t){const{width:e,height:o}=ve(t);return{width:e,height:o}}function Ro(t,e,o){const i=et(e),r=tt(e),s=o==="fixed",n=dt(t,!0,s,e);let d={scrollLeft:0,scrollTop:0};const a=Z(0);function c(){a.x=Lt(r)}if(i||!i&&!s)if((wt(e)!=="body"||Ct(r))&&(d=It(e)),i){const u=dt(e,!0,s,e);a.x=u.x+e.clientLeft,a.y=u.y+e.clientTop}else r&&c();s&&!i&&r&&c();const l=r&&!i&&!s?ye(r,d):Z(0),g=n.left+d.scrollLeft-a.x-l.x,h=n.top+d.scrollTop-a.y-l.y;return{x:g,y:h,width:n.width,height:n.height}}function Qt(t){return G(t).position==="static"}function ke(t,e){if(!et(t)||G(t).position==="fixed")return null;if(e)return e(t);let o=t.offsetParent;return tt(t)===o&&(o=o.ownerDocument.body),o}function De(t,e){const o=V(t);if(Pt(t))return o;if(!et(t)){let r=st(t);for(;r&&!mt(r);){if(Q(r)&&!Qt(r))return r;r=st(r)}return o}let i=ke(t,e);for(;i&&fo(i)&&Qt(i);)i=ke(i,e);return i&&mt(i)&&Qt(i)&&!Bt(i)?o:i||_o(t)||o}const Po=async function(t){const e=this.getOffsetParent||De,o=this.getDimensions,i=await o(t.floating);return{reference:Ro(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Io(t){return G(t).direction==="rtl"}const Lo={convertOffsetParentRelativeRectToViewportRelativeRect:xo,getDocumentElement:tt,getClippingRect:Ao,getOffsetParent:De,getElementRects:Po,getClientRects:ko,getDimensions:Oo,getScale:bt,isElement:Q,isRTL:Io};function Te(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ho(t,e){let o=null,i;const r=tt(t);function s(){var d;clearTimeout(i),(d=o)==null||d.disconnect(),o=null}function n(d,a){d===void 0&&(d=!1),a===void 0&&(a=1),s();const c=t.getBoundingClientRect(),{left:l,top:g,width:h,height:u}=c;if(d||e(),!h||!u)return;const p=Mt(g),m=Mt(r.clientWidth-(l+h)),f=Mt(r.clientHeight-(g+u)),b=Mt(l),_={rootMargin:-p+"px "+-m+"px "+-f+"px "+-b+"px",threshold:F(0,rt(1,a))||1};let S=!0;function y(D){const x=D[0].intersectionRatio;if(x!==a){if(!S)return n();x?n(!1,x):i=setTimeout(()=>{n(!1,1e-7)},1e3)}x===1&&!Te(c,t.getBoundingClientRect())&&n(),S=!1}try{o=new IntersectionObserver(y,{..._,root:r.ownerDocument})}catch{o=new IntersectionObserver(y,_)}o.observe(t)}return n(!0),s}function zo(t,e,o,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:a=!1}=i,c=Xt(t),l=r||s?[...c?St(c):[],...St(e)]:[];l.forEach(b=>{r&&b.addEventListener("scroll",o,{passive:!0}),s&&b.addEventListener("resize",o)});const g=c&&d?Ho(c,o):null;let h=-1,u=null;n&&(u=new ResizeObserver(b=>{let[v]=b;v&&v.target===c&&u&&(u.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var _;(_=u)==null||_.observe(e)})),o()}),c&&!a&&u.observe(c),u.observe(e));let p,m=a?dt(t):null;a&&f();function f(){const b=dt(t);m&&!Te(m,b)&&o(),m=b,p=requestAnimationFrame(f)}return o(),()=>{var b;l.forEach(v=>{r&&v.removeEventListener("scroll",o),s&&v.removeEventListener("resize",o)}),g==null||g(),(b=u)==null||b.disconnect(),u=null,a&&cancelAnimationFrame(p)}}const Ht=co,Gt=go,xt=so,Fo=uo,Vo=no,kt=(t,e,o)=>{const i=new Map,r={platform:Lo,...o},s={...r.platform,_c:i};return ro(t,e,{...r,platform:s})};function ct(t,e,o,i){var s;P(t);const r=document.createElement("div");if(r.className="wg__dropdown",r.style.cssText=`
1
+ (function(I,z){typeof exports=="object"&&typeof module<"u"?z(exports):typeof define=="function"&&define.amd?define(["exports"],z):(I=typeof globalThis<"u"?globalThis:I||self,z(I.WebGrid={}))})(this,function(I){"use strict";var or=Object.defineProperty;var ir=(I,z,ht)=>z in I?or(I,z,{enumerable:!0,configurable:!0,writable:!0,value:ht}):I[z]=ht;var w=(I,z,ht)=>ir(I,typeof z!="symbol"?z+"":z,ht);class z{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,"_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,"_contextMenu");w(this,"_rowShortcuts");w(this,"_showShortcutsHelp",!1);w(this,"_shortcutsHelpPosition","top-right");w(this,"_shortcutsHelpContentCallback");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,"_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,"_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)}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 sortable(){return this._sortMode!=="none"}set sortable(e){this._sortMode=e?"multi":"none",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 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 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 contextMenu(){return this._contextMenu}set contextMenu(e){this._contextMenu=e,this.requestUpdate()}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 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 ondatarequest(){return this._ondatarequest}set ondatarequest(e){this._ondatarequest=e}get onrowdelete(){return this._onrowdelete}set onrowdelete(e){this._onrowdelete=e}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(([o,i])=>i?String(e[o]??"").toLowerCase().includes(i.toLowerCase()):!0))}get sortedItems(){return this._sort.length===0?this.filteredItems:[...this.filteredItems].sort((e,o)=>{for(const i of this._sort){const r=e[i.column],s=o[i.column];if(r===s)continue;let n=0;return typeof r=="string"&&typeof s=="string"?n=r.localeCompare(s):typeof r=="number"&&typeof s=="number"?n=r-s:n=String(r??"").localeCompare(String(s??"")),i.direction==="asc"?n:-n}return 0})}get paginatedItems(){if(!this._pageable)return this.sortedItems;const e=(this._currentPage-1)*this._pageSize,o=e+this._pageSize;return this.sortedItems.slice(e,o)}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 o=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:o};this._ondatarequest(i)}}getColumnSortState(e){return this._sort.find(o=>o.column===e)}getColumnSortPriority(e){const o=this._sort.findIndex(i=>i.column===e);return o>=0?o+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(o=>o.rowIndex!==e),this.requestUpdate()}getDraftRowIndices(){return Array.from(this._draftRows.keys())}discardAllDrafts(){this._draftRows.clear(),this._invalidCells=[],this.requestUpdate()}getCellRawValue(e,o,i){const r=this._draftRows.get(o);return r?r[i]:e[i]}getCellValue(e,o,i){if(o.templateCallback)return o.templateCallback(e);const r=i!==void 0?this.getCellRawValue(e,i,String(o.field)):e[String(o.field)];return o.formatCallback?o.formatCallback(r,e):String(r??"")}isCellInvalid(e,o){return this._invalidCells.some(i=>i.rowIndex===e&&i.field===o)}getCellValidationError(e,o){const i=this._invalidCells.find(r=>r.rowIndex===e&&r.field===o);return(i==null?void 0:i.error)||null}addInvalidCell(e,o,i){const r=this._invalidCells.findIndex(s=>s.rowIndex===e&&s.field===o);r>=0?this._invalidCells[r]={rowIndex:e,field:o,error:i}:this._invalidCells=[...this._invalidCells,{rowIndex:e,field:o,error:i}]}removeInvalidCell(e,o){this._invalidCells=this._invalidCells.filter(i=>!(i.rowIndex===e&&i.field===o))}isEditing(e,o){var i,r;return((i=this._editingCell)==null?void 0:i.rowIndex)===e&&((r=this._editingCell)==null?void 0:r.field)===o}startEdit(e,o,i){var s;const r=this.displayItems[e];r&&(this._draftRows.has(e)||this._draftRows.set(e,{...r}),this._editingCell={rowIndex:e,field:o,initialSearchQuery:i==null?void 0:i.initialSearchQuery,cursorPosition:i==null?void 0:i.cursorPosition},this._currentCellError=null,this.requestUpdate(),(s=this._onroweditstart)==null||s.call(this,{row:r,rowIndex:e,field:o}))}cancelEdit(){var e;if(this._editingCell){const{rowIndex:o,field:i}=this._editingCell,r=this.displayItems[o];r&&((e=this._onroweditcancel)==null||e.call(this,{row:r,rowIndex:o,field:i})),this._editingCell=null,this._currentCellError=null,this.requestUpdate()}}normalizeValidationResult(e,o){return e==null||e===!0?{valid:!0,finalValue:o}:e===!1?{valid:!1,message:"Validation failed",finalValue:o}:typeof e=="string"?{valid:!1,message:e,finalValue:o}:{valid:e.valid,message:e.message,finalValue:e.transformedValue!==void 0?e.transformedValue:o}}async commitEdit(e,o,i){var l,h;const r=this._columns.find(u=>String(u.field)===o);if(!r)return;const s=this.displayItems[e];if(!s)return;const n=s[o];let d=i,a=null,c=!0;this._isValidating=!0;try{if(r.beforeCommitCallback){const u={value:i,oldValue:n,row:s,rowIndex:e,field:o},p=await Promise.resolve(r.beforeCommitCallback(u)),m=this.normalizeValidationResult(p,i);c=m.valid,a=m.message||null,d=m.finalValue}else if(r.validateCallback){const u=await Promise.resolve(r.validateCallback(i,s));u&&(c=!1,a=u)}}catch(u){c=!1,a=u instanceof Error?u.message:"Validation failed"}this._isValidating=!1;let g=this._draftRows.get(e);g||(g={...s},this._draftRows.set(e,g)),g[o]=d,c?(this.removeInvalidCell(e,o),this._currentCellError=null):(this.addInvalidCell(e,o,a||"Invalid value"),this._currentCellError=a,(l=this._onvalidationerror)==null||l.call(this,{row:s,rowIndex:e,field:o,error:a||"Invalid value"})),(h=this._onrowchange)==null||h.call(this,{row:s,draftRow:g,rowIndex:e,field:o,oldValue:n,newValue:d,isValid:c,validationError:a}),this._editingCell=null,this.requestUpdate()}isCellEditable(e){return e.editable===!1?!1:this._editable||e.editor!==void 0}getEditableColumns(){return this._columns.map((e,o)=>({index:o,column:e})).filter(({column:e})=>this.isCellEditable(e))}isCellFocused(e,o){var i,r;return((i=this._focusedCell)==null?void 0:i.rowIndex)===e&&((r=this._focusedCell)==null?void 0:r.colIndex)===o}get focusedCell(){return this._focusedCell}setFocusedCell(e,o){this._focusedCell={rowIndex:e,colIndex:o}}clearFocusedCell(){this._focusedCell=null}}const ht=':host{--wg-rem: 10px;font-family:var(--wg-font-family, var(--base-font-family, inherit));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-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-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-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-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-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-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-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}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:max-content;min-width:100%;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__table tbody tr{border-bottom:var(--wg-row-border)}.wg__row-number-header,.wg__row-number{width:40px;min-width:40px;max-width:40px;text-align:center;color:var(--wg-text-color-secondary);background:var(--wg-header-bg);-webkit-user-select:none;user-select:none;font-size:var(--wg-font-size-sm)}.wg__row-number{border-right:var(--wg-cell-border)}.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);text-align:left;-webkit-user-select:none;user-select: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}.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__cell{padding:var(--wg-cell-padding);color:var(--wg-cell-color);scroll-margin-top:3rem;scroll-margin-bottom:.5rem}.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)}.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)}.wg__date-input{flex:1;min-width:0;height:100%;border:none;background:transparent;font:inherit;padding:var(--wg-cell-padding-block) var(--wg-cell-padding-inline);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-secondary, #666);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:2px solid var(--wg-focus-border-color, #217346);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:calc(var(--wg-design-unit, 4) * 4px + 21px);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__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-layer-01);color:var(--wg-text-color-2);cursor:pointer;opacity:.7}.wg__shortcuts-help-icon:hover{opacity:1;background:var(--wg-layer-02)}.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-layer-01);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, ui-monospace, monospace);font-size:var(--wg-font-size-xs);font-weight:var(--wg-font-weight-medium);color:var(--wg-text-color-1);background:var(--wg-layer-02);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, 10000);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__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);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 Ft(t,e,o){const i=o.valueMember||"value",r=o.displayMember||"label",s=e.find(n=>n[i]===t);return s?String(s[r]??""):t!=null?String(t):""}function yt(t,e){if(e.getDisplayCallback)return e.getDisplayCallback(t);const o=e.displayMember||"label";return String(t[o]??t.label??"")}function lt(t,e){if(e.getValueCallback)return e.getValueCallback(t);const o=e.valueMember||"value";return t[o]??t.value}function Be(t,e){return e.getIconCallback?e.getIconCallback(t):e.iconMember&&t[e.iconMember]||null}function Ke(t,e){return e.getSubtitleCallback?e.getSubtitleCallback(t):e.subtitleMember&&t[e.subtitleMember]||null}function Ct(t,e){return e.getDisabledCallback?e.getDisabledCallback(t):e.disabledMember?!!t[e.disabledMember]:!1}const rt=Math.min,V=Math.max,$t=Math.round,Mt=Math.floor,Z=t=>({x:t,y:t}),We={left:"right",right:"left",bottom:"top",top:"bottom"},Xe={start:"end",end:"start"};function qt(t,e,o){return V(t,rt(e,o))}function pt(t,e){return typeof t=="function"?t(e):t}function nt(t){return t.split("-")[0]}function ft(t){return t.split("-")[1]}function ge(t){return t==="x"?"y":"x"}function Yt(t){return t==="y"?"height":"width"}const Qe=new Set(["top","bottom"]);function ot(t){return Qe.has(nt(t))?"y":"x"}function Nt(t){return ge(ot(t))}function Ge(t,e,o){o===void 0&&(o=!1);const i=ft(t),r=Nt(t),s=Yt(r);let n=r==="x"?i===(o?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(n=At(n)),[n,At(n)]}function Je(t){const e=At(t);return[Ut(t),e,Ut(e)]}function Ut(t){return t.replace(/start|end/g,e=>Xe[e])}const ue=["left","right"],he=["right","left"],Ze=["top","bottom"],to=["bottom","top"];function eo(t,e,o){switch(t){case"top":case"bottom":return o?e?he:ue:e?ue:he;case"left":case"right":return e?Ze:to;default:return[]}}function oo(t,e,o,i){const r=ft(t);let s=eo(nt(t),o==="start",i);return r&&(s=s.map(n=>n+"-"+r),e&&(s=s.concat(s.map(Ut)))),s}function At(t){return t.replace(/left|right|bottom|top/g,e=>We[e])}function io(t){return{top:0,right:0,bottom:0,left:0,...t}}function pe(t){return typeof t!="number"?io(t):{top:t,right:t,bottom:t,left:t}}function Ot(t){const{x:e,y:o,width:i,height:r}=t;return{width:i,height:r,top:o,left:e,right:e+i,bottom:o+r,x:e,y:o}}function fe(t,e,o){let{reference:i,floating:r}=t;const s=ot(e),n=Nt(e),d=Yt(n),a=nt(e),c=s==="y",g=i.x+i.width/2-r.width/2,l=i.y+i.height/2-r.height/2,h=i[d]/2-r[d]/2;let u;switch(a){case"top":u={x:g,y:i.y-r.height};break;case"bottom":u={x:g,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:l};break;case"left":u={x:i.x-r.width,y:l};break;default:u={x:i.x,y:i.y}}switch(ft(e)){case"start":u[n]-=h*(o&&c?-1:1);break;case"end":u[n]+=h*(o&&c?-1:1);break}return u}const ro=async(t,e,o)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:n}=o,d=s.filter(Boolean),a=await(n.isRTL==null?void 0:n.isRTL(e));let c=await n.getElementRects({reference:t,floating:e,strategy:r}),{x:g,y:l}=fe(c,i,a),h=i,u={},p=0;for(let m=0;m<d.length;m++){const{name:b,fn:f}=d[m],{x:_,y:v,data:S,reset:C}=await f({x:g,y:l,initialPlacement:i,placement:h,strategy:r,middlewareData:u,rects:c,platform:n,elements:{reference:t,floating:e}});g=_??g,l=v??l,u={...u,[b]:{...u[b],...S}},C&&p<=50&&(p++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(c=C.rects===!0?await n.getElementRects({reference:t,floating:e,strategy:r}):C.rects),{x:g,y:l}=fe(c,h,a)),m=-1)}return{x:g,y:l,placement:h,strategy:r,middlewareData:u}};async function jt(t,e){var o;e===void 0&&(e={});const{x:i,y:r,platform:s,rects:n,elements:d,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:g="viewport",elementContext:l="floating",altBoundary:h=!1,padding:u=0}=pt(e,t),p=pe(u),b=d[h?l==="floating"?"reference":"floating":l],f=Ot(await s.getClippingRect({element:(o=await(s.isElement==null?void 0:s.isElement(b)))==null||o?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(d.floating)),boundary:c,rootBoundary:g,strategy:a})),_=l==="floating"?{x:i,y:r,width:n.floating.width,height:n.floating.height}:n.reference,v=await(s.getOffsetParent==null?void 0:s.getOffsetParent(d.floating)),S=await(s.isElement==null?void 0:s.isElement(v))?await(s.getScale==null?void 0:s.getScale(v))||{x:1,y:1}:{x:1,y:1},C=Ot(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:_,offsetParent:v,strategy:a}):_);return{top:(f.top-C.top+p.top)/S.y,bottom:(C.bottom-f.bottom+p.bottom)/S.y,left:(f.left-C.left+p.left)/S.x,right:(C.right-f.right+p.right)/S.x}}const no=t=>({name:"arrow",options:t,async fn(e){const{x:o,y:i,placement:r,rects:s,platform:n,elements:d,middlewareData:a}=e,{element:c,padding:g=0}=pt(t,e)||{};if(c==null)return{};const l=pe(g),h={x:o,y:i},u=Nt(r),p=Yt(u),m=await n.getDimensions(c),b=u==="y",f=b?"top":"left",_=b?"bottom":"right",v=b?"clientHeight":"clientWidth",S=s.reference[p]+s.reference[u]-h[u]-s.floating[p],C=h[u]-s.reference[u],x=await(n.getOffsetParent==null?void 0:n.getOffsetParent(c));let D=x?x[v]:0;(!D||!await(n.isElement==null?void 0:n.isElement(x)))&&(D=d.floating[v]||s.floating[p]);const y=S/2-C/2,T=D/2-m[p]/2-1,k=rt(l[f],T),$=rt(l[_],T),A=k,N=D-m[p]-$,O=D/2-m[p]/2+y,H=qt(A,O,N),U=!a.arrow&&ft(r)!=null&&O!==H&&s.reference[p]/2-(O<A?k:$)-m[p]/2<0,j=U?O<A?O-A:O-N:0;return{[u]:h[u]+j,data:{[u]:H,centerOffset:O-H-j,...U&&{alignmentOffset:j}},reset:U}}}),so=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var o,i;const{placement:r,middlewareData:s,rects:n,initialPlacement:d,platform:a,elements:c}=e,{mainAxis:g=!0,crossAxis:l=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...b}=pt(t,e);if((o=s.arrow)!=null&&o.alignmentOffset)return{};const f=nt(r),_=ot(d),v=nt(d)===d,S=await(a.isRTL==null?void 0:a.isRTL(c.floating)),C=h||(v||!m?[At(d)]:Je(d)),x=p!=="none";!h&&x&&C.push(...oo(d,m,p,S));const D=[d,...C],y=await jt(e,b),T=[];let k=((i=s.flip)==null?void 0:i.overflows)||[];if(g&&T.push(y[f]),l){const O=Ge(r,n,S);T.push(y[O[0]],y[O[1]])}if(k=[...k,{placement:r,overflows:T}],!T.every(O=>O<=0)){var $,A;const O=((($=s.flip)==null?void 0:$.index)||0)+1,H=D[O];if(H&&(!(l==="alignment"?_!==ot(H):!1)||k.every(B=>ot(B.placement)===_?B.overflows[0]>0:!0)))return{data:{index:O,overflows:k},reset:{placement:H}};let U=(A=k.filter(j=>j.overflows[0]<=0).sort((j,B)=>j.overflows[1]-B.overflows[1])[0])==null?void 0:A.placement;if(!U)switch(u){case"bestFit":{var N;const j=(N=k.filter(B=>{if(x){const L=ot(B.placement);return L===_||L==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(L=>L>0).reduce((L,K)=>L+K,0)]).sort((B,L)=>B[1]-L[1])[0])==null?void 0:N[0];j&&(U=j);break}case"initialPlacement":U=d;break}if(r!==U)return{reset:{placement:U}}}return{}}}},ao=new Set(["left","top"]);async function lo(t,e){const{placement:o,platform:i,elements:r}=t,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),n=nt(o),d=ft(o),a=ot(o)==="y",c=ao.has(n)?-1:1,g=s&&a?-1:1,l=pt(e,t);let{mainAxis:h,crossAxis:u,alignmentAxis:p}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return d&&typeof p=="number"&&(u=d==="end"?p*-1:p),a?{x:u*g,y:h*c}:{x:h*c,y:u*g}}const co=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var o,i;const{x:r,y:s,placement:n,middlewareData:d}=e,a=await lo(e,t);return n===((o=d.offset)==null?void 0:o.placement)&&(i=d.arrow)!=null&&i.alignmentOffset?{}:{x:r+a.x,y:s+a.y,data:{...a,placement:n}}}}},go=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:o,y:i,placement:r}=e,{mainAxis:s=!0,crossAxis:n=!1,limiter:d={fn:b=>{let{x:f,y:_}=b;return{x:f,y:_}}},...a}=pt(t,e),c={x:o,y:i},g=await jt(e,a),l=ot(nt(r)),h=ge(l);let u=c[h],p=c[l];if(s){const b=h==="y"?"top":"left",f=h==="y"?"bottom":"right",_=u+g[b],v=u-g[f];u=qt(_,u,v)}if(n){const b=l==="y"?"top":"left",f=l==="y"?"bottom":"right",_=p+g[b],v=p-g[f];p=qt(_,p,v)}const m=d.fn({...e,[h]:u,[l]:p});return{...m,data:{x:m.x-o,y:m.y-i,enabled:{[h]:s,[l]:n}}}}}},uo=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var o,i;const{placement:r,rects:s,platform:n,elements:d}=e,{apply:a=()=>{},...c}=pt(t,e),g=await jt(e,c),l=nt(r),h=ft(r),u=ot(r)==="y",{width:p,height:m}=s.floating;let b,f;l==="top"||l==="bottom"?(b=l,f=h===(await(n.isRTL==null?void 0:n.isRTL(d.floating))?"start":"end")?"left":"right"):(f=l,b=h==="end"?"top":"bottom");const _=m-g.top-g.bottom,v=p-g.left-g.right,S=rt(m-g[b],_),C=rt(p-g[f],v),x=!e.middlewareData.shift;let D=S,y=C;if((o=e.middlewareData.shift)!=null&&o.enabled.x&&(y=v),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(D=_),x&&!h){const k=V(g.left,0),$=V(g.right,0),A=V(g.top,0),N=V(g.bottom,0);u?y=p-2*(k!==0||$!==0?k+$:V(g.left,g.right)):D=m-2*(A!==0||N!==0?A+N:V(g.top,g.bottom))}await a({...e,availableWidth:y,availableHeight:D});const T=await n.getDimensions(d.floating);return p!==T.width||m!==T.height?{reset:{rects:!0}}:{}}}};function Ht(){return typeof window<"u"}function wt(t){return we(t)?(t.nodeName||"").toLowerCase():"#document"}function F(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function tt(t){var e;return(e=(we(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function we(t){return Ht()?t instanceof Node||t instanceof F(t).Node:!1}function Q(t){return Ht()?t instanceof Element||t instanceof F(t).Element:!1}function et(t){return Ht()?t instanceof HTMLElement||t instanceof F(t).HTMLElement:!1}function me(t){return!Ht()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof F(t).ShadowRoot}const ho=new Set(["inline","contents"]);function St(t){const{overflow:e,overflowX:o,overflowY:i,display:r}=G(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+o)&&!ho.has(r)}const po=new Set(["table","td","th"]);function fo(t){return po.has(wt(t))}const wo=[":popover-open",":modal"];function Rt(t){return wo.some(e=>{try{return t.matches(e)}catch{return!1}})}const mo=["transform","translate","scale","rotate","perspective"],bo=["transform","translate","scale","rotate","perspective","filter"],vo=["paint","layout","strict","content"];function Bt(t){const e=Kt(),o=Q(t)?G(t):t;return mo.some(i=>o[i]?o[i]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!e&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!e&&(o.filter?o.filter!=="none":!1)||bo.some(i=>(o.willChange||"").includes(i))||vo.some(i=>(o.contain||"").includes(i))}function _o(t){let e=st(t);for(;et(e)&&!mt(e);){if(Bt(e))return e;if(Rt(e))return null;e=st(e)}return null}function Kt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const yo=new Set(["html","body","#document"]);function mt(t){return yo.has(wt(t))}function G(t){return F(t).getComputedStyle(t)}function Pt(t){return Q(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function st(t){if(wt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||me(t)&&t.host||tt(t);return me(e)?e.host:e}function be(t){const e=st(t);return mt(e)?t.ownerDocument?t.ownerDocument.body:t.body:et(e)&&St(e)?e:be(e)}function xt(t,e,o){var i;e===void 0&&(e=[]),o===void 0&&(o=!0);const r=be(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),n=F(r);if(s){const d=Wt(n);return e.concat(n,n.visualViewport||[],St(r)?r:[],d&&o?xt(d):[])}return e.concat(r,xt(r,[],o))}function Wt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ve(t){const e=G(t);let o=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=et(t),s=r?t.offsetWidth:o,n=r?t.offsetHeight:i,d=$t(o)!==s||$t(i)!==n;return d&&(o=s,i=n),{width:o,height:i,$:d}}function Xt(t){return Q(t)?t:t.contextElement}function bt(t){const e=Xt(t);if(!et(e))return Z(1);const o=e.getBoundingClientRect(),{width:i,height:r,$:s}=ve(e);let n=(s?$t(o.width):o.width)/i,d=(s?$t(o.height):o.height)/r;return(!n||!Number.isFinite(n))&&(n=1),(!d||!Number.isFinite(d))&&(d=1),{x:n,y:d}}const Co=Z(0);function _e(t){const e=F(t);return!Kt()||!e.visualViewport?Co:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function So(t,e,o){return e===void 0&&(e=!1),!o||e&&o!==F(t)?!1:e}function dt(t,e,o,i){e===void 0&&(e=!1),o===void 0&&(o=!1);const r=t.getBoundingClientRect(),s=Xt(t);let n=Z(1);e&&(i?Q(i)&&(n=bt(i)):n=bt(t));const d=So(s,o,i)?_e(s):Z(0);let a=(r.left+d.x)/n.x,c=(r.top+d.y)/n.y,g=r.width/n.x,l=r.height/n.y;if(s){const h=F(s),u=i&&Q(i)?F(i):i;let p=h,m=Wt(p);for(;m&&i&&u!==p;){const b=bt(m),f=m.getBoundingClientRect(),_=G(m),v=f.left+(m.clientLeft+parseFloat(_.paddingLeft))*b.x,S=f.top+(m.clientTop+parseFloat(_.paddingTop))*b.y;a*=b.x,c*=b.y,g*=b.x,l*=b.y,a+=v,c+=S,p=F(m),m=Wt(p)}}return Ot({width:g,height:l,x:a,y:c})}function Lt(t,e){const o=Pt(t).scrollLeft;return e?e.left+o:dt(tt(t)).left+o}function ye(t,e){const o=t.getBoundingClientRect(),i=o.left+e.scrollLeft-Lt(t,o),r=o.top+e.scrollTop;return{x:i,y:r}}function xo(t){let{elements:e,rect:o,offsetParent:i,strategy:r}=t;const s=r==="fixed",n=tt(i),d=e?Rt(e.floating):!1;if(i===n||d&&s)return o;let a={scrollLeft:0,scrollTop:0},c=Z(1);const g=Z(0),l=et(i);if((l||!l&&!s)&&((wt(i)!=="body"||St(n))&&(a=Pt(i)),et(i))){const u=dt(i);c=bt(i),g.x=u.x+i.clientLeft,g.y=u.y+i.clientTop}const h=n&&!l&&!s?ye(n,a):Z(0);return{width:o.width*c.x,height:o.height*c.y,x:o.x*c.x-a.scrollLeft*c.x+g.x+h.x,y:o.y*c.y-a.scrollTop*c.y+g.y+h.y}}function ko(t){return Array.from(t.getClientRects())}function Do(t){const e=tt(t),o=Pt(t),i=t.ownerDocument.body,r=V(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=V(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let n=-o.scrollLeft+Lt(t);const d=-o.scrollTop;return G(i).direction==="rtl"&&(n+=V(e.clientWidth,i.clientWidth)-r),{width:r,height:s,x:n,y:d}}const Ce=25;function To(t,e){const o=F(t),i=tt(t),r=o.visualViewport;let s=i.clientWidth,n=i.clientHeight,d=0,a=0;if(r){s=r.width,n=r.height;const g=Kt();(!g||g&&e==="fixed")&&(d=r.offsetLeft,a=r.offsetTop)}const c=Lt(i);if(c<=0){const g=i.ownerDocument,l=g.body,h=getComputedStyle(l),u=g.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(i.clientWidth-l.clientWidth-u);p<=Ce&&(s-=p)}else c<=Ce&&(s+=c);return{width:s,height:n,x:d,y:a}}const Eo=new Set(["absolute","fixed"]);function $o(t,e){const o=dt(t,!0,e==="fixed"),i=o.top+t.clientTop,r=o.left+t.clientLeft,s=et(t)?bt(t):Z(1),n=t.clientWidth*s.x,d=t.clientHeight*s.y,a=r*s.x,c=i*s.y;return{width:n,height:d,x:a,y:c}}function Se(t,e,o){let i;if(e==="viewport")i=To(t,o);else if(e==="document")i=Do(tt(t));else if(Q(e))i=$o(e,o);else{const r=_e(t);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return Ot(i)}function xe(t,e){const o=st(t);return o===e||!Q(o)||mt(o)?!1:G(o).position==="fixed"||xe(o,e)}function Mo(t,e){const o=e.get(t);if(o)return o;let i=xt(t,[],!1).filter(d=>Q(d)&&wt(d)!=="body"),r=null;const s=G(t).position==="fixed";let n=s?st(t):t;for(;Q(n)&&!mt(n);){const d=G(n),a=Bt(n);!a&&d.position==="fixed"&&(r=null),(s?!a&&!r:!a&&d.position==="static"&&!!r&&Eo.has(r.position)||St(n)&&!a&&xe(t,n))?i=i.filter(g=>g!==n):r=d,n=st(n)}return e.set(t,i),i}function Ao(t){let{element:e,boundary:o,rootBoundary:i,strategy:r}=t;const n=[...o==="clippingAncestors"?Rt(e)?[]:Mo(e,this._c):[].concat(o),i],d=n[0],a=n.reduce((c,g)=>{const l=Se(e,g,r);return c.top=V(l.top,c.top),c.right=rt(l.right,c.right),c.bottom=rt(l.bottom,c.bottom),c.left=V(l.left,c.left),c},Se(e,d,r));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Oo(t){const{width:e,height:o}=ve(t);return{width:e,height:o}}function Ho(t,e,o){const i=et(e),r=tt(e),s=o==="fixed",n=dt(t,!0,s,e);let d={scrollLeft:0,scrollTop:0};const a=Z(0);function c(){a.x=Lt(r)}if(i||!i&&!s)if((wt(e)!=="body"||St(r))&&(d=Pt(e)),i){const u=dt(e,!0,s,e);a.x=u.x+e.clientLeft,a.y=u.y+e.clientTop}else r&&c();s&&!i&&r&&c();const g=r&&!i&&!s?ye(r,d):Z(0),l=n.left+d.scrollLeft-a.x-g.x,h=n.top+d.scrollTop-a.y-g.y;return{x:l,y:h,width:n.width,height:n.height}}function Qt(t){return G(t).position==="static"}function ke(t,e){if(!et(t)||G(t).position==="fixed")return null;if(e)return e(t);let o=t.offsetParent;return tt(t)===o&&(o=o.ownerDocument.body),o}function De(t,e){const o=F(t);if(Rt(t))return o;if(!et(t)){let r=st(t);for(;r&&!mt(r);){if(Q(r)&&!Qt(r))return r;r=st(r)}return o}let i=ke(t,e);for(;i&&fo(i)&&Qt(i);)i=ke(i,e);return i&&mt(i)&&Qt(i)&&!Bt(i)?o:i||_o(t)||o}const Ro=async function(t){const e=this.getOffsetParent||De,o=this.getDimensions,i=await o(t.floating);return{reference:Ho(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Po(t){return G(t).direction==="rtl"}const Lo={convertOffsetParentRelativeRectToViewportRelativeRect:xo,getDocumentElement:tt,getClippingRect:Ao,getOffsetParent:De,getElementRects:Ro,getClientRects:ko,getDimensions:Oo,getScale:bt,isElement:Q,isRTL:Po};function Te(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Io(t,e){let o=null,i;const r=tt(t);function s(){var d;clearTimeout(i),(d=o)==null||d.disconnect(),o=null}function n(d,a){d===void 0&&(d=!1),a===void 0&&(a=1),s();const c=t.getBoundingClientRect(),{left:g,top:l,width:h,height:u}=c;if(d||e(),!h||!u)return;const p=Mt(l),m=Mt(r.clientWidth-(g+h)),b=Mt(r.clientHeight-(l+u)),f=Mt(g),v={rootMargin:-p+"px "+-m+"px "+-b+"px "+-f+"px",threshold:V(0,rt(1,a))||1};let S=!0;function C(x){const D=x[0].intersectionRatio;if(D!==a){if(!S)return n();D?n(!1,D):i=setTimeout(()=>{n(!1,1e-7)},1e3)}D===1&&!Te(c,t.getBoundingClientRect())&&n(),S=!1}try{o=new IntersectionObserver(C,{...v,root:r.ownerDocument})}catch{o=new IntersectionObserver(C,v)}o.observe(t)}return n(!0),s}function zo(t,e,o,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:n=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:a=!1}=i,c=Xt(t),g=r||s?[...c?xt(c):[],...xt(e)]:[];g.forEach(f=>{r&&f.addEventListener("scroll",o,{passive:!0}),s&&f.addEventListener("resize",o)});const l=c&&d?Io(c,o):null;let h=-1,u=null;n&&(u=new ResizeObserver(f=>{let[_]=f;_&&_.target===c&&u&&(u.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var v;(v=u)==null||v.observe(e)})),o()}),c&&!a&&u.observe(c),u.observe(e));let p,m=a?dt(t):null;a&&b();function b(){const f=dt(t);m&&!Te(m,f)&&o(),m=f,p=requestAnimationFrame(b)}return o(),()=>{var f;g.forEach(_=>{r&&_.removeEventListener("scroll",o),s&&_.removeEventListener("resize",o)}),l==null||l(),(f=u)==null||f.disconnect(),u=null,a&&cancelAnimationFrame(p)}}const It=co,Gt=go,kt=so,Vo=uo,Fo=no,Dt=(t,e,o)=>{const i=new Map,r={platform:Lo,...o},s={...r.platform,_c:i};return ro(t,e,{...r,platform:s})};function ct(t,e,o,i){var s;R(t);const r=document.createElement("div");if(r.className="wg__dropdown",r.style.cssText=`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
5
5
  max-height: 200px;
6
6
  overflow-y: auto;
7
7
  z-index: 1000;
8
- `,o.length===0)r.innerHTML=`<div class="wg__dropdown-empty">${t.isSearching?"Searching...":"No options"}</div>`;else{const n=t.grid.editingCell,d=n?(s=t.grid.displayItems[n.rowIndex])==null?void 0:s[n.field]:void 0;r.innerHTML=o.map((a,c)=>{const l=c===t.highlightedIndex,g=lt(a,i)===d,h=yt(a,i);if(i.renderOptionCallback){const _={index:c,isHighlighted:l,isSelected:g,isDisabled:h};return i.renderOptionCallback(a,_)}const u=_t(a,i),p=Be(a,i),m=Ke(a,i),f=["wg__dropdown-option"];l&&f.push("wg__dropdown-option--highlighted"),g&&f.push("wg__dropdown-option--selected"),h&&f.push("wg__dropdown-option--disabled");const b=p?`<span class="wg__dropdown-option-icon">${t.escapeHtml(p)}</span>`:"",v=m?`<span class="wg__dropdown-option-subtitle">${t.escapeHtml(m)}</span>`:"";return`<div class="${f.join(" ")}" data-index="${c}" ${h?'data-disabled="true"':""}>
9
- ${b}
8
+ `,o.length===0)r.innerHTML=`<div class="wg__dropdown-empty">${t.isSearching?"Searching...":"No options"}</div>`;else{const n=t.grid.editingCell,d=n?(s=t.grid.displayItems[n.rowIndex])==null?void 0:s[n.field]:void 0;r.innerHTML=o.map((a,c)=>{const g=c===t.highlightedIndex,l=lt(a,i)===d,h=Ct(a,i);if(i.renderOptionCallback){const v={index:c,isHighlighted:g,isSelected:l,isDisabled:h};return i.renderOptionCallback(a,v)}const u=yt(a,i),p=Be(a,i),m=Ke(a,i),b=["wg__dropdown-option"];g&&b.push("wg__dropdown-option--highlighted"),l&&b.push("wg__dropdown-option--selected"),h&&b.push("wg__dropdown-option--disabled");const f=p?`<span class="wg__dropdown-option-icon">${t.escapeHtml(p)}</span>`:"",_=m?`<span class="wg__dropdown-option-subtitle">${t.escapeHtml(m)}</span>`:"";return`<div class="${b.join(" ")}" data-index="${c}" ${h?'data-disabled="true"':""}>
9
+ ${f}
10
10
  <div class="wg__dropdown-option-content">
11
11
  <span class="wg__dropdown-option-label">${t.escapeHtml(u)}</span>
12
- ${v}
12
+ ${_}
13
13
  </div>
14
- </div>`}).join("")}return t.shadow.appendChild(r),t.dropdownOpen=!0,kt(e,r,{strategy:"fixed",placement:"bottom-start",middleware:[Ht(1),xt({fallbackPlacements:["top-start"]}),Fo({apply({rects:n}){Object.assign(r.style,{width:`${n.reference.width}px`})}})]}).then(({x:n,y:d})=>{Object.assign(r.style,{left:`${n}px`,top:`${d}px`})}),r}function P(t){const e=t.shadow.querySelector(".wg__dropdown");e==null||e.remove(),t.dropdownOpen=!1,t.highlightedIndex=-1,t.filterText=""}function Ee(t,e,o=!0){const i=t.dropdownOptions[e];if(!i)return;const r=t.grid.editingCell;if(!r)return;const s=t.getCurrentEditorOptions();if(yt(i,s))return;const n=lt(i,s),d=t.grid.columns.findIndex(c=>String(c.field)===r.field),a=t.grid.displayItems[r.rowIndex];if(s.onselect&&a&&s.onselect(i,a),t.justSelected=!0,t.isCommittingFromKeyboard=!0,P(t),t.grid.commitEdit(r.rowIndex,r.field,n),o)t.moveFocusAfterCommit(r.rowIndex,r.field,"down");else{const c=t.shadow.querySelector(`[data-row="${r.rowIndex}"][data-col="${d}"]`);c&&(c.classList.remove("wg__cell--editing"),c.classList.add("wg__cell--focused"))}requestAnimationFrame(()=>{t.justSelected=!1})}function it(t){const e=t.shadow.querySelector(".wg__dropdown");if(!e)return;e.querySelectorAll(".wg__dropdown-option").forEach((i,r)=>{i.classList.toggle("wg__dropdown-option--highlighted",r===t.highlightedIndex)})}function $e(t){const e=t.shadow.querySelector(".wg__dropdown-option--highlighted");e==null||e.scrollIntoView({block:"nearest"})}function Me(t,e){const o=t.shadow.querySelector(".wg__loading-indicator");o&&(o.style.display=e?"inline":"none");const i=t.shadow.querySelector(".wg__editor--autocomplete .wg__combobox-toggle");i&&(i.style.display=e?"none":"inline")}function J(t){if(t.justSelected)return;const e=t.getCurrentEditingColumn();if(!e)return;const o=e.editorOptions||{},i=e.editor;let r=0;if(i==="select"){const n=o.options||[];if(t.filterText){const d=t.filterText.toLowerCase();t.dropdownOptions=n.filter(a=>_t(a,o).toLowerCase().includes(d)),r=t.dropdownOptions.length>0?0:-1}else{t.dropdownOptions=n;const d=t.grid.editingCell;if(d){const a=t.grid.displayItems[d.rowIndex],c=a?a[d.field]:void 0,l=t.dropdownOptions.findIndex(g=>lt(g,o)===c);r=l>=0?l:0}else r=t.dropdownOptions.length>0?0:-1}}else if(i==="combobox"||i==="autocomplete"){const n=i==="autocomplete"?o.initialOptions||o.options||[]:o.options||[],d=t.grid.editingCell;let a;if(d){const l=t.grid.displayItems[d.rowIndex];a=l?l[d.field]:void 0}const c=n.findIndex(l=>lt(l,o)===a);if(c>=0)t.dropdownOptions=n,r=c;else if(a!=null&&a!==""){const l=o.valueMember||"value",g=o.displayMember||"label",h=String(a),u={value:a,label:h,[l]:a,[g]:h};t.dropdownOptions=[u,...n],r=0}else t.dropdownOptions=n,r=n.length>0?0:-1}const s=t.shadow.querySelector(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete");if(s&&t.dropdownOptions.length>0){const n=t.filterText;t.isOpeningDropdown=!0;const d=ct(t,s,t.dropdownOptions,o);gt(t,d),t.filterText=n,t.highlightedIndex=r,it(t);const a=t.shadow.querySelector(".wg__select-trigger"),c=t.shadow.querySelector(".wg__combobox-input, .wg__autocomplete-input"),l=a||c;l&&l.focus(),requestAnimationFrame(()=>{t.isOpeningDropdown=!1})}}function Ae(t){t.dropdownOpen?P(t):J(t)}function gt(t,e){e.addEventListener("mousedown",o=>{o.preventDefault();const i=o.target.closest(".wg__dropdown-option");if(i&&!i.hasAttribute("data-disabled")){const r=parseInt(i.getAttribute("data-index")||"0",10);Ee(t,r,!1)}}),e.addEventListener("mouseover",o=>{const i=o.target.closest(".wg__dropdown-option");i&&!i.hasAttribute("data-disabled")&&(t.highlightedIndex=parseInt(i.getAttribute("data-index")||"0",10),it(t))})}function Oe(t,e){const o=e.options||[],i=t.filterText.toLowerCase(),r=t.filterText;t.dropdownOptions=o.filter(n=>_t(n,e).toLowerCase().includes(i)),t.highlightedIndex=t.dropdownOptions.length>0?0:-1;const s=t.shadow.querySelector(".wg__editor--select");if(s)if(t.dropdownOptions.length>0){const n=ct(t,s,t.dropdownOptions,e);gt(t,n),t.filterText=r,t.highlightedIndex=0,it(t)}else P(t)}function qo(t,e){const o=e.target;t.filterText=o.value,t.isUserFiltering=!0;const i=t.getCurrentEditingColumn();if(!i)return;const r=i.editorOptions||{},s=r.options||[];if(t.filterText.trim()){const d=t.filterText.toLowerCase();t.dropdownOptions=s.filter(a=>_t(a,r).toLowerCase().includes(d))}else t.dropdownOptions=s;t.highlightedIndex=t.dropdownOptions.length>0?0:-1;const n=o.closest(".wg__editor--combobox");if(n){const d=ct(t,n,t.dropdownOptions,r);gt(t,d),t.highlightedIndex=t.dropdownOptions.length>0?0:-1,it(t)}}function Yo(t,e){const o=e.target;t.filterText=o.value;const i=t.getCurrentEditingColumn();if(!i)return;const r=i.editorOptions||{},s=r.debounceMs??300,n=r.minSearchLength??1;t.searchDebounceTimer&&clearTimeout(t.searchDebounceTimer);const d=o.closest(".wg__editor--autocomplete");if(!t.dropdownOpen&&d){t.dropdownOptions=r.initialOptions||[];const a=ct(t,d,t.dropdownOptions,r);gt(t,a),t.highlightedIndex=t.dropdownOptions.length>0?0:-1,it(t)}if(t.filterText.length<n){if(t.dropdownOptions=r.initialOptions||[],d){const a=ct(t,d,t.dropdownOptions,r);gt(t,a),t.highlightedIndex=t.dropdownOptions.length>0?0:-1,it(t)}return}t.searchDebounceTimer=setTimeout(()=>{No(t,t.filterText,i)},s)}async function No(t,e,o){const i=o.editorOptions||{};if(!i.onSearchCallback)return;t.searchAbortController&&t.searchAbortController.abort(),t.searchAbortController=new AbortController;const r=t.searchAbortController.signal;t.isSearching=!0,Me(t,!0);try{const s=t.grid.editingCell;if(!s)return;const n=t.grid.displayItems[s.rowIndex],d=await i.onSearchCallback(e,n,r);if(!r.aborted){t.dropdownOptions=d;const a=t.shadow.querySelector(".wg__editor--autocomplete");if(a){const c=ct(t,a,t.dropdownOptions,i);gt(t,c),t.highlightedIndex=d.length>0?0:-1,it(t)}}}catch(s){if(s instanceof Error&&s.name==="AbortError")return;console.error("Autocomplete search failed:",s),t.dropdownOptions=[];const n=t.shadow.querySelector(".wg__editor--autocomplete");if(n){const d=ct(t,n,t.dropdownOptions,i);gt(t,d)}}finally{r.aborted||(t.isSearching=!1,Me(t,!1))}}function Re(t,e,o,i,r){const s=i??t.tooltipShowDelay;t.tooltipHideTimer&&(clearTimeout(t.tooltipHideTimer),t.tooltipHideTimer=null),!(t.tooltipElement&&t.tooltipAnchor===e)&&(t.tooltipShowTimer&&clearTimeout(t.tooltipShowTimer),t.tooltipShowTimer=setTimeout(()=>{jo(t,e,o,r)},s))}function Uo(t,e){const o=e??t.tooltipHideDelay;t.tooltipShowTimer&&(clearTimeout(t.tooltipShowTimer),t.tooltipShowTimer=null),t.tooltipElement&&(t.tooltipHideTimer=setTimeout(()=>{t.tooltipElement&&(t.tooltipElement.classList.remove("wg__tooltip--visible"),setTimeout(()=>{var i;(i=t.tooltipElement)==null||i.remove(),t.tooltipElement=null,t.tooltipArrowElement=null,t.tooltipAnchor=null},100))},o))}function jo(t,e,o,i){var d;(d=t.tooltipElement)==null||d.remove();const r=document.createElement("div");r.className="wg__tooltip";const s=document.createElement("div");s.className="wg__tooltip-content",i?s.innerHTML=o:s.textContent=o,r.appendChild(s);const n=document.createElement("div");n.className="wg__tooltip-arrow",r.appendChild(n),t.shadow.appendChild(r),t.tooltipElement=r,t.tooltipArrowElement=n,t.tooltipAnchor=e,kt(e,r,{strategy:"fixed",placement:"top",middleware:[Ht(8),xt({fallbackPlacements:["bottom","left","right"]}),Vo({element:n})]}).then(({x:a,y:c,placement:l,middlewareData:g})=>{if(r.style.left=`${a}px`,r.style.top=`${c}px`,r.setAttribute("data-placement",l),g.arrow){const{x:h,y:u}=g.arrow;h!=null&&(n.style.left=`${h}px`),u!=null&&(n.style.top=`${u}px`)}requestAnimationFrame(()=>{r.classList.add("wg__tooltip--visible")})})}function Bo(t,e,o){if(t.grid.shouldUseVirtualScroll()){Ko(t,e);const n=t.shadow.querySelector(`[data-row="${e}"][data-col="${o}"]`);n&&n.focus({preventScroll:!0});return}const i=t.shadow.querySelector(`[data-row="${e}"][data-col="${o}"]`);if(!i)return;i.focus({preventScroll:!0}),i.scrollIntoView({block:"nearest",inline:"nearest"});const r=t.shadow.querySelector(".wg__header"),s=t.shadow.querySelector(".wg");if(r&&s){const n=r.getBoundingClientRect(),d=i.getBoundingClientRect();if(d.top<n.bottom){const a=d.top-n.bottom-4;s.scrollBy({top:a,behavior:"instant"})}}}function Ko(t,e){const o=t.shadow.querySelector(".wg");if(!o)return;const i=t.grid.virtualScrollRowHeight,r=o.scrollTop,s=o.clientHeight,n=t.shadow.querySelector(".wg__header"),d=(n==null?void 0:n.offsetHeight)||0,a=e*i,c=a+i,l=r+d,g=r+s;a<l?o.scrollTop=a-d:c>g&&(o.scrollTop=c-s)}function ut(t,e){const o=t.shadow.querySelector(".wg");if(!o)return;const i=t.grid.virtualScrollRowHeight,r=Math.max(0,(e-1)*i),s=Math.max(0,o.scrollHeight-o.clientHeight);o.scrollTop=Math.min(r,s)}function W(t,e,o){if(e){const i=t.shadow.querySelector(`[data-row="${e.rowIndex}"][data-col="${e.colIndex}"]`);i==null||i.classList.remove("wg__cell--focused")}if(o){const i=t.shadow.querySelector(`[data-row="${o.rowIndex}"][data-col="${o.colIndex}"]`);i==null||i.classList.add("wg__cell--focused")}}function q(t){const e=t.grid.editingCell;if(e){const o=t.grid.columns.findIndex(r=>String(r.field)===e.field),i=t.shadow.querySelector(`[data-row="${e.rowIndex}"][data-col="${o}"]`);i&&i.classList.remove("wg__cell--editing")}}function Wo(t,e,o){if(!t.grid.isNavigateMode)return;const i=t.grid.focusedCell,r={rowIndex:e,colIndex:o};t.grid.setFocusedCell(e,o),W(t,i,r)}function E(t,e,o){const i=t.grid.focusedCell,r={rowIndex:e,colIndex:o};t.grid.setFocusedCell(e,o),W(t,i,r),Bo(t,e,o)}function X(t,e,o,i){const s=t.grid.columns[o];if(!s||!t.grid.isCellEditable(s))return;const n=String(s.field);t.grid.startEdit(e,n,i)}function Jt(t,e){const o=e.querySelector(".wg__cell-text");if(!o)return null;const i=o.textContent||"";if(!i.length)return 0;const r=t.clientX,s=o.getBoundingClientRect();if(r<=s.left)return 0;if(r>=s.right)return i.length;const n=o.firstChild;if(!n||n.nodeType!==Node.TEXT_NODE)return null;const d=document.createRange();let a=0,c=i.length;try{for(;a<c;){const l=Math.floor((a+c)/2);d.setStart(n,0),d.setEnd(n,l),d.getBoundingClientRect().right<r?a=l+1:c=l}if(a>0&&a<i.length){d.setStart(n,a-1),d.setEnd(n,a);const l=d.getBoundingClientRect(),g=l.left+l.width/2;r<g&&a--}}catch{return i.length}return a}function Xo(t,e){const o=e.relatedTarget,i=t.shadow.querySelector(".wg__table");if(!o||!(i!=null&&i.contains(o))){const r=t.grid.focusedCell;t.grid.clearFocusedCell(),W(t,r,null)}}function Qo(t,e){if(!t)return null;const[o,i,r]=t.split("-").map(Number),s=new Date(o,i-1,r);if(isNaN(s.getTime()))return null;switch(e){case"date":return s;case"timestamp":return s.getTime();case"iso":default:return t}}function zt(t,e){const o=parseInt(e.dataset.row||"0",10),i=e.dataset.field||"";let r;if(e instanceof HTMLInputElement)if(e.type==="checkbox"){const s=JSON.parse(e.dataset.trueValue||"true"),n=JSON.parse(e.dataset.falseValue||"false");r=e.checked?s:n}else e.classList.contains("wg__editor--number")?r=e.value===""?null:parseFloat(e.value):e.type==="date"?r=Qo(e.value,e.dataset.outputFormat||"iso"):r=e.value;else e instanceof HTMLSelectElement&&(r=e.value);t.grid.commitEdit(o,i,r)}function Go(t,e){zt(t,e)}function Jo(t,e,o){const i=t.grid.columns[o];if(!i)return;const r=String(i.field),s=t.grid.displayItems[e];if(!s)return;const n=i.editorOptions||{},d=n.trueValue??!0,a=n.falseValue??!1,l=s[r]===d?a:d;t.grid.commitEdit(e,r,l);const g=t.grid.displayItems;e<g.length-1&&requestAnimationFrame(()=>{E(t,e+1,o)})}function Zo(t,e){t.isCommittingFromKeyboard||t.grid.editingCell&&zt(t,e)}function Zt(t,e,o,i){const s=t.grid.columns.findIndex(c=>String(c.field)===o),n=t.grid.displayItems;let d=e,a=s;if(i==="down")d=Math.min(e+1,n.length-1);else if(i==="up")d=Math.max(e-1,0);else{const c=t.grid.getEditableColumns(),l=c.findIndex(g=>g.index===s);i==="next"?l>=0&&l<c.length-1?a=c[l+1].index:e<n.length-1&&(d=e+1,a=c[0].index):l>0?a=c[l-1].index:e>0&&(d=e-1,a=c[c.length-1].index)}requestAnimationFrame(()=>{E(t,d,a),t.isCommittingFromKeyboard=!1})}function ti(t,e,o){const r=t.grid.columns.findIndex(s=>String(s.field)===o);r>=0&&requestAnimationFrame(()=>{E(t,e,r),t.isCommittingFromKeyboard=!1})}function Pe(t,e,o,i){const r=String(i.field),s=t.grid.displayItems[e],n=t.grid.getCellRawValue(s,e,r);switch(i.editor||"text"){case"checkbox":return ni(t,e,r,n,i);case"number":return oi(t,e,r,n,i);case"date":return ii(t,e,r,n,i);case"select":return si(t,e,r,n,i);case"combobox":return ai(t,e,r,n,i);case"autocomplete":return li(t,e,r,n,i);case"custom":return di(t,e,r,n,i);case"text":default:return ei(t,e,r,n,i)}}function ei(t,e,o,i,r){var a;const s=r.editorOptions||{},n=(a=t.grid.editingCell)==null?void 0:a.initialSearchQuery,d=n!==void 0?n:i!=null?String(i):"";return`
14
+ </div>`}).join("")}return t.shadow.appendChild(r),t.dropdownOpen=!0,Dt(e,r,{strategy:"fixed",placement:"bottom-start",middleware:[It(1),kt({fallbackPlacements:["top-start"]}),Vo({apply({rects:n}){Object.assign(r.style,{width:`${n.reference.width}px`})}})]}).then(({x:n,y:d})=>{Object.assign(r.style,{left:`${n}px`,top:`${d}px`})}),r}function R(t){const e=t.shadow.querySelector(".wg__dropdown");e==null||e.remove(),t.dropdownOpen=!1,t.highlightedIndex=-1,t.filterText=""}function Ee(t,e,o=!0){const i=t.dropdownOptions[e];if(!i)return;const r=t.grid.editingCell;if(!r)return;const s=t.getCurrentEditorOptions();if(Ct(i,s))return;const n=lt(i,s),d=t.grid.columns.findIndex(c=>String(c.field)===r.field),a=t.grid.displayItems[r.rowIndex];if(s.onselect&&a&&s.onselect(i,a),t.justSelected=!0,t.isCommittingFromKeyboard=!0,R(t),t.grid.commitEdit(r.rowIndex,r.field,n),o)t.moveFocusAfterCommit(r.rowIndex,r.field,"down");else{const c=t.shadow.querySelector(`[data-row="${r.rowIndex}"][data-col="${d}"]`);c&&(c.classList.remove("wg__cell--editing"),c.classList.add("wg__cell--focused"))}requestAnimationFrame(()=>{t.justSelected=!1})}function it(t){const e=t.shadow.querySelector(".wg__dropdown");if(!e)return;e.querySelectorAll(".wg__dropdown-option").forEach((i,r)=>{i.classList.toggle("wg__dropdown-option--highlighted",r===t.highlightedIndex)})}function $e(t){const e=t.shadow.querySelector(".wg__dropdown-option--highlighted");e==null||e.scrollIntoView({block:"nearest"})}function Me(t,e){const o=t.shadow.querySelector(".wg__loading-indicator");o&&(o.style.display=e?"inline":"none");const i=t.shadow.querySelector(".wg__editor--autocomplete .wg__combobox-toggle");i&&(i.style.display=e?"none":"inline")}function J(t){if(t.justSelected)return;const e=t.getCurrentEditingColumn();if(!e)return;const o=e.editorOptions||{},i=e.editor;let r=0;if(i==="select"){const n=o.options||[];if(t.filterText){const d=t.filterText.toLowerCase();t.dropdownOptions=n.filter(a=>yt(a,o).toLowerCase().includes(d)),r=t.dropdownOptions.length>0?0:-1}else{t.dropdownOptions=n;const d=t.grid.editingCell;if(d){const a=t.grid.displayItems[d.rowIndex],c=a?a[d.field]:void 0,g=t.dropdownOptions.findIndex(l=>lt(l,o)===c);r=g>=0?g:0}else r=t.dropdownOptions.length>0?0:-1}}else if(i==="combobox"||i==="autocomplete"){const n=i==="autocomplete"?o.initialOptions||o.options||[]:o.options||[],d=t.grid.editingCell;let a;if(d){const g=t.grid.displayItems[d.rowIndex];a=g?g[d.field]:void 0}const c=n.findIndex(g=>lt(g,o)===a);if(c>=0)t.dropdownOptions=n,r=c;else if(a!=null&&a!==""){const g=o.valueMember||"value",l=o.displayMember||"label",h=String(a),u={value:a,label:h,[g]:a,[l]:h};t.dropdownOptions=[u,...n],r=0}else t.dropdownOptions=n,r=n.length>0?0:-1}const s=t.shadow.querySelector(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete");if(s&&t.dropdownOptions.length>0){const n=t.filterText;t.isOpeningDropdown=!0;const d=ct(t,s,t.dropdownOptions,o);gt(t,d),t.filterText=n,t.highlightedIndex=r,it(t);const a=t.shadow.querySelector(".wg__select-trigger"),c=t.shadow.querySelector(".wg__combobox-input, .wg__autocomplete-input"),g=a||c;g&&g.focus(),requestAnimationFrame(()=>{t.isOpeningDropdown=!1})}}function Ae(t){t.dropdownOpen?R(t):J(t)}function gt(t,e){e.addEventListener("mousedown",o=>{o.preventDefault();const i=o.target.closest(".wg__dropdown-option");if(i&&!i.hasAttribute("data-disabled")){const r=parseInt(i.getAttribute("data-index")||"0",10);Ee(t,r,!1)}}),e.addEventListener("mouseover",o=>{const i=o.target.closest(".wg__dropdown-option");i&&!i.hasAttribute("data-disabled")&&(t.highlightedIndex=parseInt(i.getAttribute("data-index")||"0",10),it(t))})}function Oe(t,e){const o=e.options||[],i=t.filterText.toLowerCase(),r=t.filterText;t.dropdownOptions=o.filter(n=>yt(n,e).toLowerCase().includes(i)),t.highlightedIndex=t.dropdownOptions.length>0?0:-1;const s=t.shadow.querySelector(".wg__editor--select");if(s)if(t.dropdownOptions.length>0){const n=ct(t,s,t.dropdownOptions,e);gt(t,n),t.filterText=r,t.highlightedIndex=0,it(t)}else R(t)}function qo(t,e){const o=e.target;t.filterText=o.value,t.isUserFiltering=!0;const i=t.getCurrentEditingColumn();if(!i)return;const r=i.editorOptions||{},s=r.options||[];if(t.filterText.trim()){const d=t.filterText.toLowerCase();t.dropdownOptions=s.filter(a=>yt(a,r).toLowerCase().includes(d))}else t.dropdownOptions=s;t.highlightedIndex=t.dropdownOptions.length>0?0:-1;const n=o.closest(".wg__editor--combobox");if(n){const d=ct(t,n,t.dropdownOptions,r);gt(t,d),t.highlightedIndex=t.dropdownOptions.length>0?0:-1,it(t)}}function Yo(t,e){const o=e.target;t.filterText=o.value;const i=t.getCurrentEditingColumn();if(!i)return;const r=i.editorOptions||{},s=r.debounceMs??300,n=r.minSearchLength??1;t.searchDebounceTimer&&clearTimeout(t.searchDebounceTimer);const d=o.closest(".wg__editor--autocomplete");if(!t.dropdownOpen&&d){t.dropdownOptions=r.initialOptions||[];const a=ct(t,d,t.dropdownOptions,r);gt(t,a),t.highlightedIndex=t.dropdownOptions.length>0?0:-1,it(t)}if(t.filterText.length<n){if(t.dropdownOptions=r.initialOptions||[],d){const a=ct(t,d,t.dropdownOptions,r);gt(t,a),t.highlightedIndex=t.dropdownOptions.length>0?0:-1,it(t)}return}t.searchDebounceTimer=setTimeout(()=>{No(t,t.filterText,i)},s)}async function No(t,e,o){const i=o.editorOptions||{};if(!i.onSearchCallback)return;t.searchAbortController&&t.searchAbortController.abort(),t.searchAbortController=new AbortController;const r=t.searchAbortController.signal;t.isSearching=!0,Me(t,!0);try{const s=t.grid.editingCell;if(!s)return;const n=t.grid.displayItems[s.rowIndex],d=await i.onSearchCallback(e,n,r);if(!r.aborted){t.dropdownOptions=d;const a=t.shadow.querySelector(".wg__editor--autocomplete");if(a){const c=ct(t,a,t.dropdownOptions,i);gt(t,c),t.highlightedIndex=d.length>0?0:-1,it(t)}}}catch(s){if(s instanceof Error&&s.name==="AbortError")return;console.error("Autocomplete search failed:",s),t.dropdownOptions=[];const n=t.shadow.querySelector(".wg__editor--autocomplete");if(n){const d=ct(t,n,t.dropdownOptions,i);gt(t,d)}}finally{r.aborted||(t.isSearching=!1,Me(t,!1))}}function He(t,e,o,i,r){const s=i??t.tooltipShowDelay;t.tooltipHideTimer&&(clearTimeout(t.tooltipHideTimer),t.tooltipHideTimer=null),!(t.tooltipElement&&t.tooltipAnchor===e)&&(t.tooltipShowTimer&&clearTimeout(t.tooltipShowTimer),t.tooltipShowTimer=setTimeout(()=>{jo(t,e,o,r)},s))}function Uo(t,e){const o=e??t.tooltipHideDelay;t.tooltipShowTimer&&(clearTimeout(t.tooltipShowTimer),t.tooltipShowTimer=null),t.tooltipElement&&(t.tooltipHideTimer=setTimeout(()=>{t.tooltipElement&&(t.tooltipElement.classList.remove("wg__tooltip--visible"),setTimeout(()=>{var i;(i=t.tooltipElement)==null||i.remove(),t.tooltipElement=null,t.tooltipArrowElement=null,t.tooltipAnchor=null},100))},o))}function jo(t,e,o,i){var d;(d=t.tooltipElement)==null||d.remove();const r=document.createElement("div");r.className="wg__tooltip";const s=document.createElement("div");s.className="wg__tooltip-content",i?s.innerHTML=o:s.textContent=o,r.appendChild(s);const n=document.createElement("div");n.className="wg__tooltip-arrow",r.appendChild(n),t.shadow.appendChild(r),t.tooltipElement=r,t.tooltipArrowElement=n,t.tooltipAnchor=e,Dt(e,r,{strategy:"fixed",placement:"top",middleware:[It(8),kt({fallbackPlacements:["bottom","left","right"]}),Fo({element:n})]}).then(({x:a,y:c,placement:g,middlewareData:l})=>{if(r.style.left=`${a}px`,r.style.top=`${c}px`,r.setAttribute("data-placement",g),l.arrow){const{x:h,y:u}=l.arrow;h!=null&&(n.style.left=`${h}px`),u!=null&&(n.style.top=`${u}px`)}requestAnimationFrame(()=>{r.classList.add("wg__tooltip--visible")})})}function Bo(t,e,o){if(t.grid.shouldUseVirtualScroll()){Ko(t,e);const n=t.shadow.querySelector(`[data-row="${e}"][data-col="${o}"]`);n&&n.focus({preventScroll:!0});return}const i=t.shadow.querySelector(`[data-row="${e}"][data-col="${o}"]`);if(!i)return;i.focus({preventScroll:!0}),i.scrollIntoView({block:"nearest",inline:"nearest"});const r=t.shadow.querySelector(".wg__header"),s=t.shadow.querySelector(".wg");if(r&&s){const n=r.getBoundingClientRect(),d=i.getBoundingClientRect();if(d.top<n.bottom){const a=d.top-n.bottom-4;s.scrollBy({top:a,behavior:"instant"})}}}function Ko(t,e){const o=t.shadow.querySelector(".wg");if(!o)return;const i=t.grid.virtualScrollRowHeight,r=o.scrollTop,s=o.clientHeight,n=t.shadow.querySelector(".wg__header"),d=(n==null?void 0:n.offsetHeight)||0,a=e*i,c=a+i,g=r+d,l=r+s;a<g?o.scrollTop=a-d:c>l&&(o.scrollTop=c-s)}function ut(t,e){const o=t.shadow.querySelector(".wg");if(!o)return;const i=t.grid.virtualScrollRowHeight,r=Math.max(0,(e-1)*i),s=Math.max(0,o.scrollHeight-o.clientHeight);o.scrollTop=Math.min(r,s)}function W(t,e,o){if(e){const i=t.shadow.querySelector(`[data-row="${e.rowIndex}"][data-col="${e.colIndex}"]`);i==null||i.classList.remove("wg__cell--focused")}if(o){const i=t.shadow.querySelector(`[data-row="${o.rowIndex}"][data-col="${o.colIndex}"]`);i==null||i.classList.add("wg__cell--focused")}}function q(t){const e=t.grid.editingCell;if(e){const o=t.grid.columns.findIndex(r=>String(r.field)===e.field),i=t.shadow.querySelector(`[data-row="${e.rowIndex}"][data-col="${o}"]`);i&&i.classList.remove("wg__cell--editing")}}function Wo(t,e,o){if(!t.grid.isNavigateMode)return;const i=t.grid.focusedCell,r={rowIndex:e,colIndex:o};t.grid.setFocusedCell(e,o),W(t,i,r)}function E(t,e,o){const i=t.grid.focusedCell,r={rowIndex:e,colIndex:o};t.grid.setFocusedCell(e,o),W(t,i,r),Bo(t,e,o)}function X(t,e,o,i){const s=t.grid.columns[o];if(!s||!t.grid.isCellEditable(s))return;const n=String(s.field);t.grid.startEdit(e,n,i)}function Jt(t,e){const o=e.querySelector(".wg__cell-text");if(!o)return null;const i=o.textContent||"";if(!i.length)return 0;const r=t.clientX,s=o.getBoundingClientRect();if(r<=s.left)return 0;if(r>=s.right)return i.length;const n=o.firstChild;if(!n||n.nodeType!==Node.TEXT_NODE)return null;const d=document.createRange();let a=0,c=i.length;try{for(;a<c;){const g=Math.floor((a+c)/2);d.setStart(n,0),d.setEnd(n,g),d.getBoundingClientRect().right<r?a=g+1:c=g}if(a>0&&a<i.length){d.setStart(n,a-1),d.setEnd(n,a);const g=d.getBoundingClientRect(),l=g.left+g.width/2;r<l&&a--}}catch{return i.length}return a}function Xo(t,e){const o=e.relatedTarget,i=t.shadow.querySelector(".wg__table");if(!o||!(i!=null&&i.contains(o))){const r=t.grid.focusedCell;t.grid.clearFocusedCell(),W(t,r,null)}}function Qo(t,e){if(!t)return null;const[o,i,r]=t.split("-").map(Number),s=new Date(o,i-1,r);if(isNaN(s.getTime()))return null;switch(e){case"date":return s;case"timestamp":return s.getTime();case"iso":default:return t}}function zt(t,e){const o=parseInt(e.dataset.row||"0",10),i=e.dataset.field||"";let r;if(e instanceof HTMLInputElement)if(e.type==="checkbox"){const s=JSON.parse(e.dataset.trueValue||"true"),n=JSON.parse(e.dataset.falseValue||"false");r=e.checked?s:n}else e.classList.contains("wg__editor--number")?r=e.value===""?null:parseFloat(e.value):e.type==="date"?r=Qo(e.value,e.dataset.outputFormat||"iso"):r=e.value;else e instanceof HTMLSelectElement&&(r=e.value);t.grid.commitEdit(o,i,r)}function Go(t,e){zt(t,e)}function Jo(t,e,o){const i=t.grid.columns[o];if(!i)return;const r=String(i.field),s=t.grid.displayItems[e];if(!s)return;const n=i.editorOptions||{},d=n.trueValue??!0,a=n.falseValue??!1,g=s[r]===d?a:d;t.grid.commitEdit(e,r,g);const l=t.grid.displayItems;e<l.length-1&&requestAnimationFrame(()=>{E(t,e+1,o)})}function Zo(t,e){t.isCommittingFromKeyboard||t.grid.editingCell&&zt(t,e)}function Zt(t,e,o,i){const s=t.grid.columns.findIndex(c=>String(c.field)===o),n=t.grid.displayItems;let d=e,a=s;if(i==="down")d=Math.min(e+1,n.length-1);else if(i==="up")d=Math.max(e-1,0);else{const c=t.grid.getEditableColumns(),g=c.findIndex(l=>l.index===s);i==="next"?g>=0&&g<c.length-1?a=c[g+1].index:e<n.length-1&&(d=e+1,a=c[0].index):g>0?a=c[g-1].index:e>0&&(d=e-1,a=c[c.length-1].index)}requestAnimationFrame(()=>{E(t,d,a),t.isCommittingFromKeyboard=!1})}function ti(t,e,o){const r=t.grid.columns.findIndex(s=>String(s.field)===o);r>=0&&requestAnimationFrame(()=>{E(t,e,r),t.isCommittingFromKeyboard=!1})}function Re(t,e,o,i){const r=String(i.field),s=t.grid.displayItems[e],n=t.grid.getCellRawValue(s,e,r);switch(i.editor||"text"){case"checkbox":return ni(t,e,r,n,i);case"number":return oi(t,e,r,n,i);case"date":return ii(t,e,r,n,i);case"select":return si(t,e,r,n,i);case"combobox":return ai(t,e,r,n,i);case"autocomplete":return li(t,e,r,n,i);case"custom":return di(t,e,r,n,i);case"text":default:return ei(t,e,r,n,i)}}function ei(t,e,o,i,r){var a;const s=r.editorOptions||{},n=(a=t.grid.editingCell)==null?void 0:a.initialSearchQuery,d=n!==void 0?n:i!=null?String(i):"";return`
15
15
  <input
16
16
  type="text"
17
17
  class="wg__editor wg__editor--text"
@@ -60,7 +60,7 @@
60
60
  data-true-value="${t.escapeHtml(JSON.stringify(s.trueValue??!0))}"
61
61
  data-false-value="${t.escapeHtml(JSON.stringify(s.falseValue??!1))}"
62
62
  />
63
- `}function si(t,e,o,i,r){var c;const s=r.editorOptions||{},n=s.options||[],d=Vt(i,n,s),a=(c=t.grid.editingCell)==null?void 0:c.initialSearchQuery;return t.dropdownOptions=n,t.filterText=a||"",t.highlightedIndex=n.findIndex(l=>lt(l,s)===i),t.highlightedIndex<0&&n.length>0&&(t.highlightedIndex=0),`
63
+ `}function si(t,e,o,i,r){var c;const s=r.editorOptions||{},n=s.options||[],d=Ft(i,n,s),a=(c=t.grid.editingCell)==null?void 0:c.initialSearchQuery;return t.dropdownOptions=n,t.filterText=a||"",t.highlightedIndex=n.findIndex(g=>lt(g,s)===i),t.highlightedIndex<0&&n.length>0&&(t.highlightedIndex=0),`
64
64
  <div
65
65
  class="wg__editor wg__editor--select wg__select-trigger"
66
66
  tabindex="0"
@@ -72,7 +72,7 @@
72
72
  <span class="wg__select-value">${t.escapeHtml(d)}</span>
73
73
  <span class="wg__select-toggle">▼</span>
74
74
  </div>
75
- `}function ai(t,e,o,i,r){var l;const s=r.editorOptions||{},n=s.options||[],d=Vt(i,n,s),a=(l=t.grid.editingCell)==null?void 0:l.initialSearchQuery,c=a!==void 0?a:d;return t.dropdownOptions=n,t.filterText=c,t.highlightedIndex=n.length>0?0:-1,`
75
+ `}function ai(t,e,o,i,r){var g;const s=r.editorOptions||{},n=s.options||[],d=Ft(i,n,s),a=(g=t.grid.editingCell)==null?void 0:g.initialSearchQuery,c=a!==void 0?a:d;return t.dropdownOptions=n,t.filterText=c,t.highlightedIndex=n.length>0?0:-1,`
76
76
  <div class="wg__editor wg__editor--combobox" data-row="${e}" data-field="${o}">
77
77
  <input
78
78
  type="text"
@@ -83,7 +83,7 @@
83
83
  />
84
84
  <span class="wg__combobox-toggle">▼</span>
85
85
  </div>
86
- `}function li(t,e,o,i,r){var l;const s=r.editorOptions||{},n=s.initialOptions||s.options||[],d=Vt(i,n,s),a=(l=t.grid.editingCell)==null?void 0:l.initialSearchQuery,c=a!==void 0?a:d;return t.dropdownOptions=n,t.filterText=c,t.highlightedIndex=n.length>0?0:-1,`
86
+ `}function li(t,e,o,i,r){var g;const s=r.editorOptions||{},n=s.initialOptions||s.options||[],d=Ft(i,n,s),a=(g=t.grid.editingCell)==null?void 0:g.initialSearchQuery,c=a!==void 0?a:d;return t.dropdownOptions=n,t.filterText=c,t.highlightedIndex=n.length>0?0:-1,`
87
87
  <div class="wg__editor wg__editor--autocomplete" data-row="${e}" data-field="${o}">
88
88
  <input
89
89
  type="text"
@@ -105,7 +105,7 @@
105
105
  >
106
106
  <span class="wg__custom-value">${t.escapeHtml(s)}</span>
107
107
  </div>
108
- `}function Ie(t,e,o,i,r,s){const n=i.editor==="select"||i.editor==="combobox"||i.editor==="autocomplete",d=i.editor==="date",a=String(i.field);return n?`
108
+ `}function Pe(t,e,o,i,r,s){const n=i.editor==="select"||i.editor==="combobox"||i.editor==="autocomplete",d=i.editor==="date",a=String(i.field);return n?`
109
109
  <div class="wg__cell-dropdown-display ${t.grid.getEffectiveToggleVisibility(i)==="on-focus"?"wg__cell-dropdown-display--toggle-on-focus":""}" data-row="${e}" data-field="${a}">
110
110
  <span class="wg__select-value">${t.escapeHtml(r)}</span>
111
111
  <span class="wg__select-toggle">▼</span>
@@ -117,21 +117,21 @@
117
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
118
  </button>
119
119
  </div>
120
- `:i.templateCallback?`<span class="wg__cell-text">${r}</span>`:`<span class="wg__cell-text">${t.escapeHtml(r)}</span>`}let I={path:null,arrowPos:null,arrowDir:"right"};const ci={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 gi(t){return t.map((e,o)=>{if(typeof e=="string"){const i=ci[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-${o}`,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,onclick:e.onclick}}).filter(e=>e!==null)}function ui(t){const e=new Map;for(const r of t){const s=r.row;e.has(s)||e.set(s,[]),e.get(s).push(r)}const o=[],i=[...e.keys()].sort((r,s)=>r-s);for(const r of i){const s=e.get(r),n=new Map;for(const a of s){const c=a.group;n.has(c)||n.set(c,[]),n.get(c).push(a)}const d=[...n.keys()].sort((a,c)=>a-c);o.push({rowNum:r,groups:d.map(a=>({groupNum:a,items:n.get(a)}))})}return o}function hi(t,e,o){return`<div class="wg__toolbar">${ui(t).map(({groups:s})=>`<div class="wg__toolbar-row">${s.map(({items:d},a)=>{const c=a>0?'<div class="wg__toolbar-divider"></div>':"",l=d.map(g=>{const h=typeof g.disabled=="function"?g.disabled(e,o):g.disabled,u=["wg__toolbar-btn",g.danger?"wg__toolbar-btn--danger":""].filter(Boolean).join(" "),p=g.label?`<span class="wg__toolbar-label">${g.label}</span>`:"";return`<button
121
- class="${u}"
122
- data-toolbar-item="${g.id}"
123
- title="${g.title}"
124
- ${h?"disabled":""}
125
- >${g.icon}${p}</button>`}).join("");return c+l}).join("")}</div>`).join("")}</div>`}let M=null;function pi(t,e,o,i,r,s,n){Ft();const d=hi(i,r,o),a=document.createElement("div");a.className="wg__toolbar-container",a.innerHTML=d,t.shadow.appendChild(a);const c=a.querySelector(".wg__toolbar");let l="left";c.style.position="fixed",c.style.visibility="hidden",requestAnimationFrame(()=>{const h=t.shadow.querySelector(`tr[data-row-index="${o}"]`);if(!h){Ft();return}const u=t.grid.toolbarPosition,p=t.grid.toolbarAlign,m=t.grid.toolbarTopPosition;let f,b;const v=p==="top"?"-start":"",_=()=>m==="start"?"top-start":m==="end"?"top-end":"top";u==="left"?(f=`left${v}`,b=[`right${v}`,_()]):u==="right"?(f=`right${v}`,b=[`left${v}`,_()]):u==="top"?(f=_(),b=[`left${v}`,`right${v}`]):(f=`left${v}`,b=[`right${v}`,_()]);let S=h;if(m==="cursor"&&n!==void 0&&u==="top"){const y=h.getBoundingClientRect();S={getBoundingClientRect:()=>({x:n,y:y.top,top:y.top,left:n,bottom:y.bottom,right:n,width:0,height:y.height,toJSON:()=>({})})}}kt(S,c,{strategy:"fixed",placement:f,middleware:[xt({fallbackPlacements:b}),Gt({padding:8})]}).then(({x:y,y:D,placement:x})=>{Object.assign(c.style,{left:`${y}px`,top:`${D}px`,visibility:"visible"}),l=x.split("-")[0],M&&(M.position=l)}).catch(()=>{c.style.visibility="visible"})});const g=h=>{const u=h.target.closest(".wg__toolbar-btn");if(u&&!u.disabled){const p=u.dataset.toolbarItem||"",m=i.find(f=>f.id===p);m&&s(m)}};a.addEventListener("click",g),M={container:a,toolbar:c,rowIndex:o,rowItem:r,position:l,hasRowMoved:!1,cursorX:n,cleanup:()=>{a.removeEventListener("click",g),a.remove()}},I={path:null,arrowPos:null,arrowDir:"right"}}function Ft(){M&&(M.cleanup(),M=null),I={path:null,arrowPos:null,arrowDir:"right"}}function Dt(){return(M==null?void 0:M.rowIndex)??null}function fi(t){return(M==null?void 0:M.container.getRootNode())===t}function ee(t){return(M==null?void 0:M.rowIndex)===t}function wi(){return I}function Le(t,e){if(!M){I={path:null,arrowPos:null,arrowDir:"right"};return}const{toolbar:o,rowItem:i,position:r}=M,s=e.findIndex(y=>y===i);if(s===-1){I={path:null,arrowPos:null,arrowDir:"right"};return}const n=t.shadow.querySelector(`tr[data-row-index="${s}"]`);if(!n){I={path:null,arrowPos:null,arrowDir:"right"};return}if(s===M.rowIndex||(M.hasRowMoved=!0),!M.hasRowMoved){I={path:null,arrowPos:null,arrowDir:"right"};return}const a=o.getBoundingClientRect(),c=n.getBoundingClientRect(),l=t.shadow.querySelector(".wg__table"),g=l==null?void 0:l.getBoundingClientRect(),h=t.shadow.querySelector(".wg"),u=h==null?void 0:h.getBoundingClientRect();if(!g||!u){I={path:null,arrowPos:null,arrowDir:"right"};return}const p=document.dir==="rtl"||document.documentElement.dir==="rtl",m=c.top+c.height/2,f=c.bottom<=u.top,b=c.top>=u.bottom,v=!f&&!b;let _,S="right";if(f?(_=u.top+8,S="up"):b?(_=u.bottom-8,S="down"):_=m,r==="left"){const y=a.right,D=a.top+a.height/2,x=p?u.right+15:u.left-15;if(!v){I={path:`M ${y} ${D} H ${x} V ${_}`,arrowPos:{x,y:_},arrowDir:S};return}const C=p?u.right-8:u.left+8;S=p?"left":"right",I={path:`M ${y} ${D} H ${x} V ${_} H ${C}`,arrowPos:{x:C,y:_},arrowDir:S};return}else if(r==="right"){const y=a.left,D=a.top+a.height/2,x=p?u.left-15:u.right+15;if(!v){I={path:`M ${y} ${D} H ${x} V ${_}`,arrowPos:{x,y:_},arrowDir:S};return}const C=p?u.left+8:u.right-8;S=p?"right":"left",I={path:`M ${y} ${D} H ${x} V ${_} H ${C}`,arrowPos:{x:C,y:_},arrowDir:S};return}else{const D=a.right,x=a.top+a.height/2,C=D+48,T=s-M.rowIndex,k=8;if(T===0){let $=c.top-k;b&&($=u.bottom-k),I={path:`M ${D} ${x} H ${C} V ${$}`,arrowPos:{x:C,y:$},arrowDir:"down"};return}else if(T===-1){const A=a.top+a.height*.25,N=a.top+a.height*.75,O=a.right+24,R=a.right+k;I={path:`M ${a.right} ${A} H ${O} V ${N} H ${R}`,arrowPos:{x:R,y:N},arrowDir:"left"};return}else if(T<0){let $=c.bottom+k;f&&($=u.top+k),I={path:`M ${D} ${x} H ${C} V ${$}`,arrowPos:{x:C,y:$},arrowDir:"up"};return}else{let $=c.top-k;b&&($=u.bottom-k),I={path:`M ${D} ${x} H ${C} V ${$}`,arrowPos:{x:C,y:$},arrowDir:"down"};return}}}function He(t,e){return`<button
120
+ `:i.templateCallback?`<span class="wg__cell-text">${r}</span>`:`<span class="wg__cell-text">${t.escapeHtml(r)}</span>`}let P={path:null,arrowPos:null,arrowDir:"right"};const ci={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 gi(t){return t.map((e,o)=>{if(typeof e=="string"){const i=ci[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-${o}`,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,onclick:e.onclick}}).filter(e=>e!==null)}function ui(t){const e=new Map;for(const r of t){const s=r.row;e.has(s)||e.set(s,[]),e.get(s).push(r)}const o=[],i=[...e.keys()].sort((r,s)=>r-s);for(const r of i){const s=e.get(r),n=new Map;for(const a of s){const c=a.group;n.has(c)||n.set(c,[]),n.get(c).push(a)}const d=[...n.keys()].sort((a,c)=>a-c);o.push({rowNum:r,groups:d.map(a=>({groupNum:a,items:n.get(a)}))})}return o}function hi(t,e,o,i=!1){let r=ui(t);return i&&(r=r.reverse()),`<div class="wg__toolbar">${r.map(({groups:n})=>`<div class="wg__toolbar-row">${n.map(({items:a},c)=>{const g=c>0?'<div class="wg__toolbar-divider"></div>':"",l=a.map(h=>{const u=typeof h.disabled=="function"?h.disabled(e,o):h.disabled,p=["wg__toolbar-btn",h.danger?"wg__toolbar-btn--danger":""].filter(Boolean).join(" "),m=h.label?`<span class="wg__toolbar-label">${h.label}</span>`:"";return`<button
121
+ class="${p}"
122
+ data-toolbar-item="${h.id}"
123
+ title="${h.title}"
124
+ ${u?"disabled":""}
125
+ >${h.icon}${m}</button>`}).join("");return g+l}).join("")}</div>`).join("")}</div>`}let M=null;function pi(t,e,o,i,r,s,n){Vt();const d=t.grid.toolbarVerticalAlign!=="top",a=hi(i,r,o,d),c=document.createElement("div");c.className="wg__toolbar-container",c.innerHTML=a,t.shadow.appendChild(c);const g=c.querySelector(".wg__toolbar");let l="left";g.style.position="fixed",g.style.visibility="hidden",requestAnimationFrame(()=>{const u=t.shadow.querySelector(`tr[data-row-index="${o}"]`);if(!u){Vt();return}const p=t.grid.toolbarPosition,m=t.grid.toolbarVerticalAlign,b=t.grid.toolbarHorizontalAlign;let f,_,v="";m==="top"?v="-end":m==="bottom"&&(v="-start");const S=()=>b==="start"?"top-start":b==="end"?"top-end":"top";p==="left"?(f=`left${v}`,_=[`right${v}`,S()]):p==="right"?(f=`right${v}`,_=[`left${v}`,S()]):p==="top"?(f=S(),_=[`left${v}`,`right${v}`]):(f=`left${v}`,_=[`right${v}`,S()]);let C=u;if(b==="cursor"&&n!==void 0&&p==="top"){const x=u.getBoundingClientRect();C={getBoundingClientRect:()=>({x:n,y:x.top,top:x.top,left:n,bottom:x.bottom,right:n,width:0,height:x.height,toJSON:()=>({})})}}Dt(C,g,{strategy:"fixed",placement:f,middleware:[kt({fallbackPlacements:_}),Gt({padding:8})]}).then(({x,y:D,placement:y})=>{Object.assign(g.style,{left:`${x}px`,top:`${D}px`,visibility:"visible"}),l=y.split("-")[0],M&&(M.position=l)}).catch(()=>{g.style.visibility="visible"})});const h=u=>{const p=u.target.closest(".wg__toolbar-btn");if(p&&!p.disabled){const m=p.dataset.toolbarItem||"",b=i.find(f=>f.id===m);b&&s(b)}};c.addEventListener("click",h),M={container:c,toolbar:g,rowIndex:o,rowItem:r,position:l,hasRowMoved:!1,cursorX:n,cleanup:()=>{c.removeEventListener("click",h),c.remove()}},P={path:null,arrowPos:null,arrowDir:"right"}}function Vt(){M&&(M.cleanup(),M=null),P={path:null,arrowPos:null,arrowDir:"right"}}function Tt(){return(M==null?void 0:M.rowIndex)??null}function fi(t){return(M==null?void 0:M.container.getRootNode())===t}function ee(t){return(M==null?void 0:M.rowIndex)===t}function wi(){return P}function Le(t,e){if(!M){P={path:null,arrowPos:null,arrowDir:"right"};return}const{toolbar:o,rowItem:i,position:r}=M,s=e.findIndex(C=>C===i);if(s===-1){P={path:null,arrowPos:null,arrowDir:"right"};return}const n=t.shadow.querySelector(`tr[data-row-index="${s}"]`);if(!n){P={path:null,arrowPos:null,arrowDir:"right"};return}if(s===M.rowIndex||(M.hasRowMoved=!0),!M.hasRowMoved){P={path:null,arrowPos:null,arrowDir:"right"};return}const a=o.getBoundingClientRect(),c=n.getBoundingClientRect(),g=t.shadow.querySelector(".wg__table"),l=g==null?void 0:g.getBoundingClientRect(),h=t.shadow.querySelector(".wg"),u=h==null?void 0:h.getBoundingClientRect();if(!l||!u){P={path:null,arrowPos:null,arrowDir:"right"};return}const p=document.dir==="rtl"||document.documentElement.dir==="rtl",m=c.top+c.height/2,b=c.bottom<=u.top,f=c.top>=u.bottom,_=!b&&!f;let v,S="right";if(b?(v=u.top+8,S="up"):f?(v=u.bottom-8,S="down"):v=m,r==="left"){const C=a.right,x=a.top+a.height/2,D=p?u.right+15:u.left-15;if(!_){P={path:`M ${C} ${x} H ${D} V ${v}`,arrowPos:{x:D,y:v},arrowDir:S};return}const y=p?u.right-8:u.left+8;S=p?"left":"right",P={path:`M ${C} ${x} H ${D} V ${v} H ${y}`,arrowPos:{x:y,y:v},arrowDir:S};return}else if(r==="right"){const C=a.left,x=a.top+a.height/2,D=p?u.left-15:u.right+15;if(!_){P={path:`M ${C} ${x} H ${D} V ${v}`,arrowPos:{x:D,y:v},arrowDir:S};return}const y=p?u.left+8:u.right-8;S=p?"right":"left",P={path:`M ${C} ${x} H ${D} V ${v} H ${y}`,arrowPos:{x:y,y:v},arrowDir:S};return}else{const x=a.right,D=a.top+a.height/2,y=x+48,T=s-M.rowIndex,k=8;if(T===0){let $=c.top-k;f&&($=u.bottom-k),P={path:`M ${x} ${D} H ${y} V ${$}`,arrowPos:{x:y,y:$},arrowDir:"down"};return}else if(T===-1){const A=a.top+a.height*.25,N=a.top+a.height*.75,O=a.right+24,H=a.right+k;P={path:`M ${a.right} ${A} H ${O} V ${N} H ${H}`,arrowPos:{x:H,y:N},arrowDir:"left"};return}else if(T<0){let $=c.bottom+k;b&&($=u.top+k),P={path:`M ${x} ${D} H ${y} V ${$}`,arrowPos:{x:y,y:$},arrowDir:"up"};return}else{let $=c.top-k;f&&($=u.bottom-k),P={path:`M ${x} ${D} H ${y} V ${$}`,arrowPos:{x:y,y:$},arrowDir:"down"};return}}}function Ie(t,e){return`<button
126
126
  class="wg__toolbar-trigger ${e?"wg__toolbar-trigger--active":""}"
127
127
  data-toolbar-trigger="${t}"
128
128
  title="Row actions"
129
- >⋮</button>`}function mi(t){const e=["wg"];return t.grid.striped&&e.push("wg--striped"),t.grid.hoverable&&e.push("wg--hoverable"),t.grid.editable&&e.push("wg--editable"),t.grid.isNavigateMode&&e.push("wg--navigate-mode"),e.join(" ")}function bi(t){const e=t.grid.columns;if(e.length===0)return"";const o=t.grid.showRowNumbers?'<th class="wg__header wg__row-number-header">#</th>':"",r=t.grid.showRowToolbar&&t.grid.toolbarTrigger==="button"?'<th class="wg__header wg__actions-column"></th>':"",s=e.map(n=>{const d=String(n.field),a=n.sortable!==!1&&t.grid.sortMode!=="none",c=t.grid.getColumnSortState(d),l=t.grid.getColumnSortPriority(d),g=c!==void 0,h=["wg__header"];a&&h.push("wg__header--sortable"),g&&h.push("wg__header--sorted");const u=n.width||n.maxWidth,m=`style="${[u?`width: ${u}`:"",n.minWidth?`min-width: ${n.minWidth}`:"",`text-align: ${n.align||"left"}`].filter(Boolean).join("; ")}"`;let f="";if(a)if(g){const v=c.direction==="asc"?"▲":"▼",_=t.grid.sort.length>1?`<sup class="wg__sort-priority">${l}</sup>`:"";f=`<span class="wg__sort-indicator">${v}${_}</span>`}else f='<span class="wg__sort-indicator wg__sort-placeholder">⬍</span>';let b="";return n.headerInfo&&(b=`<span class="wg__header-info" data-tooltip="${t.escapeHtml(n.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>`),`
129
+ >⋮</button>`}function mi(t){const e=["wg"];return t.grid.striped&&e.push("wg--striped"),t.grid.hoverable&&e.push("wg--hoverable"),t.grid.editable&&e.push("wg--editable"),t.grid.isNavigateMode&&e.push("wg--navigate-mode"),e.join(" ")}function bi(t){const e=t.grid.columns;if(e.length===0)return"";const o=t.grid.showRowNumbers?'<th class="wg__header wg__row-number-header">#</th>':"",r=t.grid.showRowToolbar&&t.grid.toolbarTrigger==="button"?'<th class="wg__header wg__actions-column"></th>':"",s=e.map(n=>{const d=String(n.field),a=n.sortable!==!1&&t.grid.sortMode!=="none",c=t.grid.getColumnSortState(d),g=t.grid.getColumnSortPriority(d),l=c!==void 0,h=["wg__header"];a&&h.push("wg__header--sortable"),l&&h.push("wg__header--sorted");const u=n.width||n.maxWidth,m=`style="${[u?`width: ${u}`:"",n.minWidth?`min-width: ${n.minWidth}`:"",`text-align: ${n.align||"left"}`].filter(Boolean).join("; ")}"`;let b="";if(a)if(l){const _=c.direction==="asc"?"▲":"▼",v=t.grid.sort.length>1?`<sup class="wg__sort-priority">${g}</sup>`:"";b=`<span class="wg__sort-indicator">${_}${v}</span>`}else b='<span class="wg__sort-indicator wg__sort-placeholder">⬍</span>';let f="";return n.headerInfo&&(f=`<span class="wg__header-info" data-tooltip="${t.escapeHtml(n.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>`),`
130
130
  <th class="${h.join(" ")}" ${m} data-field="${d}">
131
131
  <div class="wg__header-content">
132
132
  <span class="wg__header-title">${t.escapeHtml(n.title)}</span>
133
- ${b}
134
133
  ${f}
134
+ ${b}
135
135
  </div>
136
136
  </th>
137
137
  `}).join("");return`<tr>${o}${r}${s}</tr>`}function vi(t){const e=t.grid.displayItems,o=t.grid.columns,i=t.grid.showRowNumbers,r=t.grid.showRowToolbar&&t.grid.toolbarTrigger==="button",s=o.length+(r?1:0)+(i?1:0);if(e.length===0)return`
@@ -140,73 +140,73 @@
140
140
  No items to display
141
141
  </td>
142
142
  </tr>
143
- `;const n=Dt();return e.map((d,a)=>{const c=i?`<td class="wg__cell wg__row-number">${a+1}</td>`:"";let l="";r&&(l=`
143
+ `;const n=Tt();return e.map((d,a)=>{const c=i?`<td class="wg__cell wg__row-number">${a+1}</td>`:"";let g="";r&&(g=`
144
144
  <td class="wg__cell wg__actions-column">
145
- ${He(a,n===a)}
145
+ ${Ie(a,n===a)}
146
146
  </td>
147
- `);const g=o.map((u,p)=>{const m=String(u.field),f=t.grid.getCellValue(d,u,a),b=u.align||"left",v=t.grid.isCellEditable(u),_=t.grid.isCellFocused(a,p),S=["wg__cell"],y=t.grid.isEditing(a,m);if(v&&S.push("wg__cell--editable"),_&&!y&&S.push("wg__cell--focused"),u.textOverflow==="ellipsis"&&S.push("wg__cell--ellipsis"),y&&S.push("wg__cell--editing"),t.grid.isCellInvalid(a,m)&&S.push("wg__cell--invalid"),u.cellClass&&S.push(u.cellClass),u.cellClassCallback){const T=t.grid.getCellRawValue(d,a,m),k=u.cellClassCallback(T,d);k&&S.push(k)}const D=[`text-align: ${b}`,u.width?`width: ${u.width}`:"",u.minWidth?`min-width: ${u.minWidth}`:"",u.maxWidth?`max-width: ${u.maxWidth}`:""].filter(Boolean).join("; "),x=t.grid.isNavigateMode?'tabindex="0"':"";let C="";if(u.tooltipCallback){const T=t.grid.getCellRawValue(d,a,m),k=u.tooltipCallback(T,d);k&&(C=`data-tooltip="${t.escapeHtml(k)}"`)}else if(u.tooltipMember){const T=d[u.tooltipMember];T&&typeof T=="string"&&(C=`data-tooltip="${t.escapeHtml(T)}"`)}if(!C&&t.grid.isCellInvalid(a,m)){const T=t.grid.getCellValidationError(a,m);if(T){const k=u.validationTooltipCallback||t.grid.validationTooltipCallback;if(k){const $=t.grid.getCellRawValue(d,a,m),A=k({field:m,error:T,value:$,row:d,rowIndex:a});A&&(C=`data-tooltip-html="${t.escapeHtml(A)}"`)}C||(C=`data-tooltip="${t.escapeHtml(T)}"`)}}return`
147
+ `);const l=o.map((u,p)=>{const m=String(u.field),b=t.grid.getCellValue(d,u,a),f=u.align||"left",_=t.grid.isCellEditable(u),v=t.grid.isCellFocused(a,p),S=["wg__cell"],C=t.grid.isEditing(a,m);if(_&&S.push("wg__cell--editable"),v&&!C&&S.push("wg__cell--focused"),u.textOverflow==="ellipsis"&&S.push("wg__cell--ellipsis"),C&&S.push("wg__cell--editing"),t.grid.isCellInvalid(a,m)&&S.push("wg__cell--invalid"),u.cellClass&&S.push(u.cellClass),u.cellClassCallback){const T=t.grid.getCellRawValue(d,a,m),k=u.cellClassCallback(T,d);k&&S.push(k)}const x=[`text-align: ${f}`,u.width?`width: ${u.width}`:"",u.minWidth?`min-width: ${u.minWidth}`:"",u.maxWidth?`max-width: ${u.maxWidth}`:""].filter(Boolean).join("; "),D=t.grid.isNavigateMode?'tabindex="0"':"";let y="";if(u.tooltipCallback){const T=t.grid.getCellRawValue(d,a,m),k=u.tooltipCallback(T,d);k&&(y=`data-tooltip="${t.escapeHtml(k)}"`)}else if(u.tooltipMember){const T=d[u.tooltipMember];T&&typeof T=="string"&&(y=`data-tooltip="${t.escapeHtml(T)}"`)}if(!y&&t.grid.isCellInvalid(a,m)){const T=t.grid.getCellValidationError(a,m);if(T){const k=u.validationTooltipCallback||t.grid.validationTooltipCallback;if(k){const $=t.grid.getCellRawValue(d,a,m),A=k({field:m,error:T,value:$,row:d,rowIndex:a});A&&(y=`data-tooltip-html="${t.escapeHtml(A)}"`)}y||(y=`data-tooltip="${t.escapeHtml(T)}"`)}}return`
148
148
  <td
149
149
  class="${S.join(" ")}"
150
- style="${D}"
150
+ style="${x}"
151
151
  data-row="${a}"
152
152
  data-col="${p}"
153
153
  data-field="${m}"
154
- ${x}
155
- ${C}
154
+ ${D}
155
+ ${y}
156
156
  >
157
- ${t.grid.isEditing(a,m)?Pe(t,a,p,u):Ie(t,a,p,u,f)}
157
+ ${t.grid.isEditing(a,m)?Re(t,a,p,u):Pe(t,a,p,u,b)}
158
158
  </td>
159
- `}).join(""),h=["wg__row"];if(t.grid.rowClassCallback){const u=t.grid.rowClassCallback(d,a);u&&h.push(u)}return`<tr class="${h.join(" ")}" data-row-index="${a}">${c}${l}${g}</tr>`}).join("")}function ze(t,e){const o=t.grid.displayItems,i=t.grid.columns,{startIndex:r,endIndex:s,rowHeight:n,totalItems:d}=e,a=t.grid.showRowNumbers,c=t.grid.showRowToolbar&&t.grid.toolbarTrigger==="button",l=i.length+(c?1:0)+(a?1:0);if(o.length===0)return`
159
+ `}).join(""),h=["wg__row"];if(t.grid.rowClassCallback){const u=t.grid.rowClassCallback(d,a);u&&h.push(u)}return`<tr class="${h.join(" ")}" data-row-index="${a}">${c}${g}${l}</tr>`}).join("")}function ze(t,e){const o=t.grid.displayItems,i=t.grid.columns,{startIndex:r,endIndex:s,rowHeight:n,totalItems:d}=e,a=t.grid.showRowNumbers,c=t.grid.showRowToolbar&&t.grid.toolbarTrigger==="button",g=i.length+(c?1:0)+(a?1:0);if(o.length===0)return`
160
160
  <tr>
161
- <td class="wg__empty" colspan="${l}">
161
+ <td class="wg__empty" colspan="${g}">
162
162
  No items to display
163
163
  </td>
164
164
  </tr>
165
- `;const g=Dt(),h=r*n,u=(d-s)*n,p=h>0?`<tr class="wg__spacer-top"><td colspan="${l}" style="height: ${h}px"></td></tr>`:"",m=[];for(let b=r;b<s&&b<o.length;b++){const v=o[b],_=b,S=a?`<td class="wg__cell wg__row-number">${_+1}</td>`:"";let y="";c&&(y=`
165
+ `;const l=Tt(),h=r*n,u=(d-s)*n,p=h>0?`<tr class="wg__spacer-top"><td colspan="${g}" style="height: ${h}px"></td></tr>`:"",m=[];for(let f=r;f<s&&f<o.length;f++){const _=o[f],v=f,S=a?`<td class="wg__cell wg__row-number">${v+1}</td>`:"";let C="";c&&(C=`
166
166
  <td class="wg__cell wg__actions-column">
167
- ${He(_,g===_)}
167
+ ${Ie(v,l===v)}
168
168
  </td>
169
- `);const D=i.map((C,T)=>{const k=String(C.field),$=t.grid.getCellValue(v,C,_),A=C.align||"left",N=t.grid.isCellEditable(C),O=t.grid.isCellFocused(_,T),R=["wg__cell"],U=t.grid.isEditing(_,k);if(N&&R.push("wg__cell--editable"),O&&!U&&R.push("wg__cell--focused"),C.textOverflow==="ellipsis"&&R.push("wg__cell--ellipsis"),U&&R.push("wg__cell--editing"),t.grid.isCellInvalid(_,k)&&R.push("wg__cell--invalid"),C.cellClass&&R.push(C.cellClass),C.cellClassCallback){const K=t.grid.getCellRawValue(v,_,k),at=C.cellClassCallback(K,v);at&&R.push(at)}const j=[`text-align: ${A}`,C.width?`width: ${C.width}`:"",C.minWidth?`min-width: ${C.minWidth}`:"",C.maxWidth?`max-width: ${C.maxWidth}`:""].filter(Boolean).join("; "),B=t.grid.isNavigateMode?'tabindex="0"':"";let L="";if(C.tooltipCallback){const K=t.grid.getCellRawValue(v,_,k),at=C.tooltipCallback(K,v);at&&(L=`data-tooltip="${t.escapeHtml(at)}"`)}else if(C.tooltipMember){const K=v[C.tooltipMember];K&&typeof K=="string"&&(L=`data-tooltip="${t.escapeHtml(K)}"`)}if(!L&&t.grid.isCellInvalid(_,k)){const K=t.grid.getCellValidationError(_,k);if(K){const at=C.validationTooltipCallback||t.grid.validationTooltipCallback;if(at){const Ji=t.grid.getCellRawValue(v,_,k),je=at({field:k,error:K,value:Ji,row:v,rowIndex:_});je&&(L=`data-tooltip-html="${t.escapeHtml(je)}"`)}L||(L=`data-tooltip="${t.escapeHtml(K)}"`)}}return`
169
+ `);const x=i.map((y,T)=>{const k=String(y.field),$=t.grid.getCellValue(_,y,v),A=y.align||"left",N=t.grid.isCellEditable(y),O=t.grid.isCellFocused(v,T),H=["wg__cell"],U=t.grid.isEditing(v,k);if(N&&H.push("wg__cell--editable"),O&&!U&&H.push("wg__cell--focused"),y.textOverflow==="ellipsis"&&H.push("wg__cell--ellipsis"),U&&H.push("wg__cell--editing"),t.grid.isCellInvalid(v,k)&&H.push("wg__cell--invalid"),y.cellClass&&H.push(y.cellClass),y.cellClassCallback){const K=t.grid.getCellRawValue(_,v,k),at=y.cellClassCallback(K,_);at&&H.push(at)}const j=[`text-align: ${A}`,y.width?`width: ${y.width}`:"",y.minWidth?`min-width: ${y.minWidth}`:"",y.maxWidth?`max-width: ${y.maxWidth}`:""].filter(Boolean).join("; "),B=t.grid.isNavigateMode?'tabindex="0"':"";let L="";if(y.tooltipCallback){const K=t.grid.getCellRawValue(_,v,k),at=y.tooltipCallback(K,_);at&&(L=`data-tooltip="${t.escapeHtml(at)}"`)}else if(y.tooltipMember){const K=_[y.tooltipMember];K&&typeof K=="string"&&(L=`data-tooltip="${t.escapeHtml(K)}"`)}if(!L&&t.grid.isCellInvalid(v,k)){const K=t.grid.getCellValidationError(v,k);if(K){const at=y.validationTooltipCallback||t.grid.validationTooltipCallback;if(at){const er=t.grid.getCellRawValue(_,v,k),je=at({field:k,error:K,value:er,row:_,rowIndex:v});je&&(L=`data-tooltip-html="${t.escapeHtml(je)}"`)}L||(L=`data-tooltip="${t.escapeHtml(K)}"`)}}return`
170
170
  <td
171
- class="${R.join(" ")}"
171
+ class="${H.join(" ")}"
172
172
  style="${j}"
173
- data-row="${_}"
173
+ data-row="${v}"
174
174
  data-col="${T}"
175
175
  data-field="${k}"
176
176
  ${B}
177
177
  ${L}
178
178
  >
179
- ${t.grid.isEditing(_,k)?Pe(t,_,T,C):Ie(t,_,T,C,$)}
179
+ ${t.grid.isEditing(v,k)?Re(t,v,T,y):Pe(t,v,T,y,$)}
180
180
  </td>
181
- `}).join(""),x=["wg__row"];if(t.grid.rowClassCallback){const C=t.grid.rowClassCallback(v,_);C&&x.push(C)}m.push(`<tr class="${x.join(" ")}" data-row-index="${_}">${S}${y}${D}</tr>`)}const f=u>0?`<tr class="wg__spacer-bottom"><td colspan="${l}" style="height: ${u}px"></td></tr>`:"";return p+m.join("")+f}function oe(t,e="bottom-center"){const o=t.grid.showPagination;if(!t.grid.pageable||o===!1||o==="auto"&&t.grid.totalPages<=1)return"";const i=t.grid.currentPage,r=t.grid.totalPages,s=t.grid.pageSize,n=t.grid.pageSizes,d=t.grid.totalItems!==null?t.grid.totalItems:t.grid.sortedItems.length,a={first:"First",previous:"Previous",next:"Next",last:"Last",pageInfo:`Page ${i} of ${r}`,itemCount:`(${d} item${d!==1?"s":""})`,perPage:"per page"},c=t.grid.paginationLabelsCallback,l=c?c({currentPage:i,totalPages:r,totalItems:d,pageSize:s}):{},g={...a,...l},h=e.startsWith("top-"),u=e.replace("top-","").replace("bottom-",""),p=["wg__pagination"];u==="left"?p.push("wg__pagination--left"):u==="right"&&p.push("wg__pagination--right"),h&&p.push("wg__pagination--top");const m={first:`
181
+ `}).join(""),D=["wg__row"];if(t.grid.rowClassCallback){const y=t.grid.rowClassCallback(_,v);y&&D.push(y)}m.push(`<tr class="${D.join(" ")}" data-row-index="${v}">${S}${C}${x}</tr>`)}const b=u>0?`<tr class="wg__spacer-bottom"><td colspan="${g}" style="height: ${u}px"></td></tr>`:"";return p+m.join("")+b}function oe(t,e="bottom-center"){const o=t.grid.showPagination;if(!t.grid.pageable||o===!1||o==="auto"&&t.grid.totalPages<=1)return"";const i=t.grid.currentPage,r=t.grid.totalPages,s=t.grid.pageSize,n=t.grid.pageSizes,d=t.grid.totalItems!==null?t.grid.totalItems:t.grid.sortedItems.length,a={first:"First",previous:"Previous",next:"Next",last:"Last",pageInfo:`Page ${i} of ${r}`,itemCount:`(${d} item${d!==1?"s":""})`,perPage:"per page"},c=t.grid.paginationLabelsCallback,g=c?c({currentPage:i,totalPages:r,totalItems:d,pageSize:s}):{},l={...a,...g},h=e.startsWith("top-"),u=e.replace("top-","").replace("bottom-",""),p=["wg__pagination"];u==="left"?p.push("wg__pagination--left"):u==="right"&&p.push("wg__pagination--right"),h&&p.push("wg__pagination--top");const m={first:`
182
182
  <button class="wg__pagination-btn" data-action="first" ${i===1?"disabled":""}>
183
- ${g.first}
183
+ ${l.first}
184
184
  </button>
185
185
  `,previous:`
186
186
  <button class="wg__pagination-btn" data-action="prev" ${i===1?"disabled":""}>
187
- ${g.previous}
187
+ ${l.previous}
188
188
  </button>
189
189
  `,next:`
190
190
  <button class="wg__pagination-btn" data-action="next" ${i===r?"disabled":""}>
191
- ${g.next}
191
+ ${l.next}
192
192
  </button>
193
193
  `,last:`
194
194
  <button class="wg__pagination-btn" data-action="last" ${i===r?"disabled":""}>
195
- ${g.last}
195
+ ${l.last}
196
196
  </button>
197
197
  `,pageInfo:`
198
198
  <div class="wg__pagination-info">
199
- ${g.pageInfo}
200
- <span class="wg__pagination-count">${g.itemCount}</span>
199
+ ${l.pageInfo}
200
+ <span class="wg__pagination-count">${l.itemCount}</span>
201
201
  </div>
202
202
  `,pageSize:n.length>0?`
203
203
  <div class="wg__pagination-pagesize">
204
204
  <select class="wg__pagination-select" data-action="pagesize">
205
- ${n.map(v=>`<option value="${v}" ${v===s?"selected":""}>${v}</option>`).join("")}
205
+ ${n.map(_=>`<option value="${_}" ${_===s?"selected":""}>${_}</option>`).join("")}
206
206
  </select>
207
- <span class="wg__pagination-label">${g.perPage}</span>
207
+ <span class="wg__pagination-label">${l.perPage}</span>
208
208
  </div>
209
- `:""},b=t.grid.paginationLayout.split("|").map(v=>v.trim()).map(v=>m[v]||"").join("");return`<div class="${p.join(" ")}">${b}</div>`}function ie(t,e){const o=t.grid.summaryContentCallback;if(!o)return"";const i=t.grid.currentPage,r=t.grid.pageSize,s=t.grid.sortedItems,n=t.grid.displayItems,d=t.grid.totalItems!==null?t.grid.totalItems:s.length,a=o({items:n,allItems:s,totalItems:d,currentPage:i,pageSize:r,metadata:t.grid.summaryMetadata}),c=e.startsWith("top-"),l=e.replace("top-","").replace("bottom-",""),g=["wg__summary"];return l==="left"?g.push("wg__summary--left"):l==="right"&&g.push("wg__summary--right"),c&&g.push("wg__summary--top"),`<div class="${g.join(" ")}">${a}</div>`}const Fe={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 re(t){const e={};let o="";return t.includes("-")?o="-":t.includes("/")?o="/":t.includes(".")&&(o="."),t.split(o).forEach((r,s)=>{r==="YYYY"||r==="YY"?e.year={index:s,length:r.length}:r==="MM"||r==="M"?e.month={index:s,length:2}:(r==="DD"||r==="D")&&(e.day={index:s,length:2})}),{format:t,separator:o,parts:e,maxLength:t.length}}function Ve(t,e){if(!t||isNaN(t.getTime()))return"";const o=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),{separator:s,parts:n}=e,d=[];for(let a=0;a<3;a++)n.year&&n.year.index===a?d.push(n.year.length===2?String(o).slice(-2):o):n.month&&n.month.index===a?d.push(i):n.day&&n.day.index===a&&d.push(r);return d.join(s)}function _i(t,e){if(!t)return null;const{separator:o,parts:i}=e,r=t.split(o);let s=null,n=null,d=null;if(r.forEach((c,l)=>{if(c){if(i.year&&i.year.index===l){const g=parseInt(c,10);i.year.length===4&&c.length===4?s=g:i.year.length===2&&c.length===2&&(s=g<100?g+2e3:g)}else if(i.month&&i.month.index===l){const g=parseInt(c,10);c.length===2&&g>=1&&g<=12&&(n=g)}else if(i.day&&i.day.index===l){const g=parseInt(c,10);c.length===2&&g>=1&&g<=31&&(d=g)}}}),s===null||n===null||d===null)return null;const a=new Date(s,n-1,d);return a.getMonth()!==n-1||a.getDate()!==d?null:a}function Y(t){if(!t)return null;let e;if(typeof t=="string"){const[o,i,r]=t.split("-").map(Number);!o||!i||!r?e=new Date(t):e=new Date(o,i-1,r)}else e=new Date(t);return e.setHours(0,0,0,0),isNaN(e.getTime())?null:e}function ne(t){const e=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${e}-${o}-${i}`}function Tt(t,e){return!t||!e?!1:t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function yi(t){return Tt(t,new Date)}function vt(t,e){return new Date(t,e+1,0).getDate()}function Ci(t,e){return new Date(t,e,1).getDay()}function Si(t,e){if(!t)return{min:e-10,max:e+10};if(t.includes("-")){const[i,r]=t.split("-");return{min:parseInt(i,10),max:parseInt(r,10)}}const o=parseInt(t,10);return{min:o,max:o}}function xi(t,e,o=Fe){const i=ki(t,o),r=Di(t,e,o),s=Ti(t,e,o),n=e.showTodayButton!==!1?Mi(o):"";return`
209
+ `:""},f=t.grid.paginationLayout.split("|").map(_=>_.trim()).map(_=>m[_]||"").join("");return`<div class="${p.join(" ")}">${f}</div>`}function ie(t,e){const o=t.grid.summaryContentCallback;if(!o)return"";const i=t.grid.currentPage,r=t.grid.pageSize,s=t.grid.sortedItems,n=t.grid.displayItems,d=t.grid.totalItems!==null?t.grid.totalItems:s.length,a=o({items:n,allItems:s,totalItems:d,currentPage:i,pageSize:r,metadata:t.grid.summaryMetadata}),c=e.startsWith("top-"),g=e.replace("top-","").replace("bottom-",""),l=["wg__summary"];return g==="left"?l.push("wg__summary--left"):g==="right"&&l.push("wg__summary--right"),c&&l.push("wg__summary--top"),`<div class="${l.join(" ")}">${a}</div>`}const Ve={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 re(t){const e={};let o="";return t.includes("-")?o="-":t.includes("/")?o="/":t.includes(".")&&(o="."),t.split(o).forEach((r,s)=>{r==="YYYY"||r==="YY"?e.year={index:s,length:r.length}:r==="MM"||r==="M"?e.month={index:s,length:2}:(r==="DD"||r==="D")&&(e.day={index:s,length:2})}),{format:t,separator:o,parts:e,maxLength:t.length}}function Fe(t,e){if(!t||isNaN(t.getTime()))return"";const o=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),{separator:s,parts:n}=e,d=[];for(let a=0;a<3;a++)n.year&&n.year.index===a?d.push(n.year.length===2?String(o).slice(-2):o):n.month&&n.month.index===a?d.push(i):n.day&&n.day.index===a&&d.push(r);return d.join(s)}function _i(t,e){if(!t)return null;const{separator:o,parts:i}=e,r=t.split(o);let s=null,n=null,d=null;if(r.forEach((c,g)=>{if(c){if(i.year&&i.year.index===g){const l=parseInt(c,10);i.year.length===4&&c.length===4?s=l:i.year.length===2&&c.length===2&&(s=l<100?l+2e3:l)}else if(i.month&&i.month.index===g){const l=parseInt(c,10);c.length===2&&l>=1&&l<=12&&(n=l)}else if(i.day&&i.day.index===g){const l=parseInt(c,10);c.length===2&&l>=1&&l<=31&&(d=l)}}}),s===null||n===null||d===null)return null;const a=new Date(s,n-1,d);return a.getMonth()!==n-1||a.getDate()!==d?null:a}function Y(t){if(!t)return null;let e;if(typeof t=="string"){const[o,i,r]=t.split("-").map(Number);!o||!i||!r?e=new Date(t):e=new Date(o,i-1,r)}else e=new Date(t);return e.setHours(0,0,0,0),isNaN(e.getTime())?null:e}function ne(t){const e=t.getFullYear(),o=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${e}-${o}-${i}`}function Et(t,e){return!t||!e?!1:t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function yi(t){return Et(t,new Date)}function vt(t,e){return new Date(t,e+1,0).getDate()}function Ci(t,e){return new Date(t,e,1).getDay()}function Si(t,e){if(!t)return{min:e-10,max:e+10};if(t.includes("-")){const[i,r]=t.split("-");return{min:parseInt(i,10),max:parseInt(r,10)}}const o=parseInt(t,10);return{min:o,max:o}}function xi(t,e,o=Ve){const i=ki(t,o),r=Di(t,e,o),s=Ti(t,e,o),n=e.showTodayButton!==!1?Mi(o):"";return`
210
210
  <div class="wg-datepicker">
211
211
  <div class="wg-datepicker__header">
212
212
  ${i}
@@ -245,43 +245,43 @@
245
245
  <div class="wg-datepicker__days">
246
246
  ${r}
247
247
  </div>
248
- `}function Ei(t){return t.weekdayNamesShort.map(e=>`<div class="wg-datepicker__weekday">${e}</div>`).join("")}function qe(t,e){const{viewYear:o,viewMonth:i,selectedDate:r,focusedDate:s}=t,n=e.minDate?Y(e.minDate):null,d=e.maxDate?Y(e.maxDate):null,a=Ci(o,i),c=vt(o,i),l=vt(o,i-1),g=new Date(o,i-1,1),h=g.getFullYear(),u=g.getMonth(),p=new Date(o,i+1,1),m=p.getFullYear(),f=p.getMonth(),b=[];for(let y=a-1;y>=0;y--){const D=l-y;b.push({date:new Date(h,u,D),day:D,isOtherMonth:!0})}for(let y=1;y<=c;y++)b.push({date:new Date(o,i,y),day:y,isOtherMonth:!1});const _=Math.ceil((a+c)/7)*7-b.length;for(let y=1;y<=_;y++)b.push({date:new Date(m,f,y),day:y,isOtherMonth:!0});let S="";for(const y of b){const D=["wg-datepicker__day"];y.isOtherMonth&&D.push("wg-datepicker__day--other-month"),$i(y.date,n,d)&&D.push("wg-datepicker__day--disabled"),yi(y.date)&&D.push("wg-datepicker__day--today"),Tt(y.date,r)&&D.push("wg-datepicker__day--selected"),Tt(y.date,s)&&D.push("wg-datepicker__day--focused");const C=ne(y.date);S+=`<div class="${D.join(" ")}" data-date="${C}">${y.day}</div>`}return S}function $i(t,e,o){return!!(e&&t<e||o&&t>o)}function Mi(t){return`
248
+ `}function Ei(t){return t.weekdayNamesShort.map(e=>`<div class="wg-datepicker__weekday">${e}</div>`).join("")}function qe(t,e){const{viewYear:o,viewMonth:i,selectedDate:r,focusedDate:s}=t,n=e.minDate?Y(e.minDate):null,d=e.maxDate?Y(e.maxDate):null,a=Ci(o,i),c=vt(o,i),g=vt(o,i-1),l=new Date(o,i-1,1),h=l.getFullYear(),u=l.getMonth(),p=new Date(o,i+1,1),m=p.getFullYear(),b=p.getMonth(),f=[];for(let C=a-1;C>=0;C--){const x=g-C;f.push({date:new Date(h,u,x),day:x,isOtherMonth:!0})}for(let C=1;C<=c;C++)f.push({date:new Date(o,i,C),day:C,isOtherMonth:!1});const v=Math.ceil((a+c)/7)*7-f.length;for(let C=1;C<=v;C++)f.push({date:new Date(m,b,C),day:C,isOtherMonth:!0});let S="";for(const C of f){const x=["wg-datepicker__day"];C.isOtherMonth&&x.push("wg-datepicker__day--other-month"),$i(C.date,n,d)&&x.push("wg-datepicker__day--disabled"),yi(C.date)&&x.push("wg-datepicker__day--today"),Et(C.date,r)&&x.push("wg-datepicker__day--selected"),Et(C.date,s)&&x.push("wg-datepicker__day--focused");const y=ne(C.date);S+=`<div class="${x.join(" ")}" data-date="${y}">${C.day}</div>`}return S}function $i(t,e,o){return!!(e&&t<e||o&&t>o)}function Mi(t){return`
249
249
  <div class="wg-datepicker__footer">
250
250
  <button type="button" class="wg-datepicker__today-btn" data-action="today">
251
251
  ${t.today}
252
252
  </button>
253
253
  </div>
254
- `}function Ai(t,e,o){const i=t.querySelector(".wg-datepicker__days");i&&(i.innerHTML=qe(e,o))}function Oi(t,e,o){const i=t.querySelector(".wg-datepicker__month-year");if(i){const r=o.monthNames[e.viewMonth];i.textContent=`${r} ${e.viewYear}`}}function Ri(t,e){const o=t.querySelector(".wg-datepicker__rolling-selector"),i=t.querySelector(".wg-datepicker__calendar");o&&o.classList.toggle("wg-datepicker__rolling-selector--visible",e),i&&i.classList.toggle("wg-datepicker__calendar--hidden",e)}function Pi(t,e){t.querySelectorAll("[data-year]").forEach(r=>{const s=parseInt(r.dataset.year||"0",10);r.classList.toggle("wg-datepicker__rolling-item--selected",s===e.viewYear)}),t.querySelectorAll("[data-month]").forEach(r=>{const s=parseInt(r.dataset.month||"0",10);r.classList.toggle("wg-datepicker__rolling-item--selected",s===e.viewMonth)})}function Ye(t){const e=t.querySelector("[data-year].wg-datepicker__rolling-item--selected"),o=t.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(o){const i=o.parentElement;if(i){const r=o.offsetTop-i.clientHeight/2+o.clientHeight/2;i.scrollTop=r}}}function se(t){t.viewMonth===0?(t.viewMonth=11,t.viewYear--):t.viewMonth--}function ae(t){t.viewMonth===11?(t.viewMonth=0,t.viewYear++):t.viewMonth++}function Ii(t,e,o,i){var s,n,d,a;const{key:r}=t;if(r==="Escape")return(s=i.onClose)==null||s.call(i),!0;if(e.rollingSelectorOpen)return Hi(t,e);if((r==="ArrowLeft"||r==="ArrowRight")&&(t.ctrlKey||t.metaKey)){if(t.preventDefault(),r==="ArrowLeft"?se(e):ae(e),e.focusedDate){const c=Math.min(e.focusedDate.getDate(),vt(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,c)}return!0}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(r))return t.preventDefault(),Li(e,r,o),!0;if(r==="Enter")return t.preventDefault(),e.focusedDate&&((n=i.onSelect)==null||n.call(i,e.focusedDate,"down")),!0;if(r==="Tab")return e.focusedDate?(d=i.onSelect)==null||d.call(i,e.focusedDate,"next"):(a=i.onClose)==null||a.call(i),!1;if(r==="Home"){if(t.preventDefault(),t.ctrlKey||t.metaKey){let c=e.viewYear;const l=new Date(c,0,1);if(e.focusedDate&&Tt(e.focusedDate,l)&&c--,o.minDate){const g=Y(o.minDate);g&&c<g.getFullYear()&&(c=g.getFullYear())}e.viewMonth=0,e.viewYear=c,e.focusedDate=new Date(c,0,1)}else e.focusedDate=new Date(e.viewYear,e.viewMonth,1);return!0}if(r==="End"){if(t.preventDefault(),t.ctrlKey||t.metaKey){let c=e.viewYear;const l=new Date(c,11,31);if(e.focusedDate&&Tt(e.focusedDate,l)&&c++,o.maxDate){const g=Y(o.maxDate);g&&c>g.getFullYear()&&(c=g.getFullYear())}e.viewMonth=11,e.viewYear=c,e.focusedDate=new Date(c,11,31)}else{const c=vt(e.viewYear,e.viewMonth);e.focusedDate=new Date(e.viewYear,e.viewMonth,c)}return!0}if(r==="PageUp"){if(t.preventDefault(),se(e),e.focusedDate){const c=Math.min(e.focusedDate.getDate(),vt(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,c)}return!0}if(r==="PageDown"){if(t.preventDefault(),ae(e),e.focusedDate){const c=Math.min(e.focusedDate.getDate(),vt(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,c)}return!0}return!1}function Li(t,e,o){if(!t.focusedDate){t.focusedDate=t.selectedDate?new Date(t.selectedDate):new Date(t.viewYear,t.viewMonth,1);return}const i=new Date(t.focusedDate),r=o.minDate?Y(o.minDate):null,s=o.maxDate?Y(o.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||s&&i>s||(t.focusedDate=i,(i.getMonth()!==t.viewMonth||i.getFullYear()!==t.viewYear)&&(t.viewMonth=i.getMonth(),t.viewYear=i.getFullYear()))}function Hi(t,e){const{key:o}=t;if(o==="ArrowUp"||o==="ArrowDown"){t.preventDefault();const i=o==="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 o==="ArrowLeft"||o==="ArrowRight"?(t.preventDefault(),e.rollingSelectorMode=e.rollingSelectorMode==="month"?"year":"month",!0):o==="Enter"||o==="Escape"?(t.preventDefault(),e.rollingSelectorOpen=!1,!0):!1}function zi(t){if(t.selectedDate)t.focusedDate=new Date(t.selectedDate),t.viewYear=t.selectedDate.getFullYear(),t.viewMonth=t.selectedDate.getMonth();else{const e=new Date;t.focusedDate=new Date(t.viewYear,t.viewMonth,e.getDate())}}function Fi(t,e,o){const i=t.dataset.date;if(!i||t.classList.contains("wg-datepicker__day--disabled"))return null;const[r,s,n]=i.split("-").map(Number),d=new Date(r,s-1,n),a=o.minDate?Y(o.minDate):null,c=o.maxDate?Y(o.maxDate):null;return a&&d<a||c&&d>c?null:(e.selectedDate=d,e.focusedDate=d,d)}function Vi(t,e){const o=new Date;o.setHours(0,0,0,0);const i=e.minDate?Y(e.minDate):null,r=e.maxDate?Y(e.maxDate):null;return i&&o<i||r&&o>r?null:(t.selectedDate=o,t.focusedDate=o,t.viewYear=o.getFullYear(),t.viewMonth=o.getMonth(),o)}function qi(t,e){const o=t.dataset.month;o!==void 0&&(e.viewMonth=parseInt(o,10))}function Yi(t,e){const o=t.dataset.year;o!==void 0&&(e.viewYear=parseInt(o,10))}function le(t,e){var g,h,u,p;const{separator:o,parts:i,maxLength:r}=e,s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=t.replace(new RegExp(s,"g"),""),d=((g=i.year)==null?void 0:g.length)??4,a=[{type:"year",pos:((h=i.year)==null?void 0:h.index)??0,length:d},{type:"month",pos:((u=i.month)==null?void 0:u.index)??1,length:2},{type:"day",pos:((p=i.day)==null?void 0:p.index)??2,length:2}].sort((m,f)=>m.pos-f.pos);let c="",l=0;for(let m=0;m<a.length;m++){const f=a[m],b=n.substring(l,l+f.length);if(!b)break;c+=b,l+=b.length,m<a.length-1&&b.length===f.length&&(c+=o)}return c.substring(0,r)}function Ni(t,e,o){const i=t.value,r=t.selectionStart||0,s=i.length<o.length,{separator:n}=e,d=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=i.replace(new RegExp(`[^0-9${d}]`,"g"),""),c=le(a,e);if(c!==i){t.value=c;let l=r;if(s)l=r;else if(c.length>i.length&&c[r]===n)l=r+1;else if(c.length>i.length){const g=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=(i.substring(0,r).match(new RegExp(g,"g"))||[]).length,p=(c.substring(0,r).match(new RegExp(g,"g"))||[]).length-h;l=r+p}t.setSelectionRange(l,l)}return c}function Ui(t,e){const{key:o,ctrlKey:i,metaKey:r}=t,{separator:s}=e;if(["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(o)||i||r)return!1;if(o===s){const d=t.target,a=d.selectionStart||0,c=d.value;let l=0;for(let h=a-1;h>=0;h--)if(c[h]===s){l=h+1;break}const g=c.substring(l,a);if(/^\d$/.test(g)){t.preventDefault();const h=c.substring(0,l)+"0"+g+s+c.substring(a);d.value=h;const u=l+2+s.length;return d.setSelectionRange(u,u),!0}}return!/^\d$/.test(o)&&o!==s?(t.preventDefault(),!0):!1}function ji(t,e,o){var u;t.preventDefault();const i=((u=t.clipboardData)==null?void 0:u.getData("text"))||"",{separator:r}=o,s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=i.replace(new RegExp(`[^0-9${s}]`,"g"),""),d=le(n,o),a=e.selectionStart||0,c=e.selectionEnd||0,l=e.value,g=l.substring(0,a)+d+l.substring(c);e.value=le(g,o);const h=a+d.length;e.setSelectionRange(h,h)}function Bi(t,e,o,i){if(!t||t.length<e.maxLength)return!1;const r=_i(t,e);if(!r)return!1;const s=i.minDate?Y(i.minDate):null,n=i.maxDate?Y(i.maxDate):null;return s&&r<s||n&&r>n?!1:(o.selectedDate=r,o.focusedDate=r,o.viewYear=r.getFullYear(),o.viewMonth=r.getMonth(),!0)}const Ki=`
254
+ `}function Ai(t,e,o){const i=t.querySelector(".wg-datepicker__days");i&&(i.innerHTML=qe(e,o))}function Oi(t,e,o){const i=t.querySelector(".wg-datepicker__month-year");if(i){const r=o.monthNames[e.viewMonth];i.textContent=`${r} ${e.viewYear}`}}function Hi(t,e){const o=t.querySelector(".wg-datepicker__rolling-selector"),i=t.querySelector(".wg-datepicker__calendar");o&&o.classList.toggle("wg-datepicker__rolling-selector--visible",e),i&&i.classList.toggle("wg-datepicker__calendar--hidden",e)}function Ri(t,e){t.querySelectorAll("[data-year]").forEach(r=>{const s=parseInt(r.dataset.year||"0",10);r.classList.toggle("wg-datepicker__rolling-item--selected",s===e.viewYear)}),t.querySelectorAll("[data-month]").forEach(r=>{const s=parseInt(r.dataset.month||"0",10);r.classList.toggle("wg-datepicker__rolling-item--selected",s===e.viewMonth)})}function Ye(t){const e=t.querySelector("[data-year].wg-datepicker__rolling-item--selected"),o=t.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(o){const i=o.parentElement;if(i){const r=o.offsetTop-i.clientHeight/2+o.clientHeight/2;i.scrollTop=r}}}function se(t){t.viewMonth===0?(t.viewMonth=11,t.viewYear--):t.viewMonth--}function ae(t){t.viewMonth===11?(t.viewMonth=0,t.viewYear++):t.viewMonth++}function Pi(t,e,o,i){var s,n,d,a;const{key:r}=t;if(r==="Escape")return(s=i.onClose)==null||s.call(i),!0;if(e.rollingSelectorOpen)return Ii(t,e);if((r==="ArrowLeft"||r==="ArrowRight")&&(t.ctrlKey||t.metaKey)){if(t.preventDefault(),r==="ArrowLeft"?se(e):ae(e),e.focusedDate){const c=Math.min(e.focusedDate.getDate(),vt(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,c)}return!0}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(r))return t.preventDefault(),Li(e,r,o),!0;if(r==="Enter")return t.preventDefault(),t.stopPropagation(),e.focusedDate&&((n=i.onSelect)==null||n.call(i,e.focusedDate,"down")),!0;if(r==="Tab")return e.focusedDate?(d=i.onSelect)==null||d.call(i,e.focusedDate,"next"):(a=i.onClose)==null||a.call(i),!1;if(r==="Home"){if(t.preventDefault(),t.ctrlKey||t.metaKey){let c=e.viewYear;const g=new Date(c,0,1);if(e.focusedDate&&Et(e.focusedDate,g)&&c--,o.minDate){const l=Y(o.minDate);l&&c<l.getFullYear()&&(c=l.getFullYear())}e.viewMonth=0,e.viewYear=c,e.focusedDate=new Date(c,0,1)}else e.focusedDate=new Date(e.viewYear,e.viewMonth,1);return!0}if(r==="End"){if(t.preventDefault(),t.ctrlKey||t.metaKey){let c=e.viewYear;const g=new Date(c,11,31);if(e.focusedDate&&Et(e.focusedDate,g)&&c++,o.maxDate){const l=Y(o.maxDate);l&&c>l.getFullYear()&&(c=l.getFullYear())}e.viewMonth=11,e.viewYear=c,e.focusedDate=new Date(c,11,31)}else{const c=vt(e.viewYear,e.viewMonth);e.focusedDate=new Date(e.viewYear,e.viewMonth,c)}return!0}if(r==="PageUp"){if(t.preventDefault(),se(e),e.focusedDate){const c=Math.min(e.focusedDate.getDate(),vt(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,c)}return!0}if(r==="PageDown"){if(t.preventDefault(),ae(e),e.focusedDate){const c=Math.min(e.focusedDate.getDate(),vt(e.viewYear,e.viewMonth));e.focusedDate=new Date(e.viewYear,e.viewMonth,c)}return!0}return!1}function Li(t,e,o){if(!t.focusedDate){t.focusedDate=t.selectedDate?new Date(t.selectedDate):new Date(t.viewYear,t.viewMonth,1);return}const i=new Date(t.focusedDate),r=o.minDate?Y(o.minDate):null,s=o.maxDate?Y(o.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||s&&i>s||(t.focusedDate=i,(i.getMonth()!==t.viewMonth||i.getFullYear()!==t.viewYear)&&(t.viewMonth=i.getMonth(),t.viewYear=i.getFullYear()))}function Ii(t,e){const{key:o}=t;if(o==="ArrowUp"||o==="ArrowDown"){t.preventDefault();const i=o==="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 o==="ArrowLeft"||o==="ArrowRight"?(t.preventDefault(),e.rollingSelectorMode=e.rollingSelectorMode==="month"?"year":"month",!0):o==="Enter"||o==="Escape"?(t.preventDefault(),e.rollingSelectorOpen=!1,!0):!1}function zi(t){if(t.selectedDate)t.focusedDate=new Date(t.selectedDate),t.viewYear=t.selectedDate.getFullYear(),t.viewMonth=t.selectedDate.getMonth();else{const e=new Date;t.focusedDate=new Date(t.viewYear,t.viewMonth,e.getDate())}}function Vi(t,e,o){const i=t.dataset.date;if(!i||t.classList.contains("wg-datepicker__day--disabled"))return null;const[r,s,n]=i.split("-").map(Number),d=new Date(r,s-1,n),a=o.minDate?Y(o.minDate):null,c=o.maxDate?Y(o.maxDate):null;return a&&d<a||c&&d>c?null:(e.selectedDate=d,e.focusedDate=d,d)}function Fi(t,e){const o=new Date;o.setHours(0,0,0,0);const i=e.minDate?Y(e.minDate):null,r=e.maxDate?Y(e.maxDate):null;return i&&o<i||r&&o>r?null:(t.selectedDate=o,t.focusedDate=o,t.viewYear=o.getFullYear(),t.viewMonth=o.getMonth(),o)}function qi(t,e){const o=t.dataset.month;o!==void 0&&(e.viewMonth=parseInt(o,10))}function Yi(t,e){const o=t.dataset.year;o!==void 0&&(e.viewYear=parseInt(o,10))}function le(t,e){var l,h,u,p;const{separator:o,parts:i,maxLength:r}=e,s=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=t.replace(new RegExp(s,"g"),""),d=((l=i.year)==null?void 0:l.length)??4,a=[{type:"year",pos:((h=i.year)==null?void 0:h.index)??0,length:d},{type:"month",pos:((u=i.month)==null?void 0:u.index)??1,length:2},{type:"day",pos:((p=i.day)==null?void 0:p.index)??2,length:2}].sort((m,b)=>m.pos-b.pos);let c="",g=0;for(let m=0;m<a.length;m++){const b=a[m],f=n.substring(g,g+b.length);if(!f)break;c+=f,g+=f.length,m<a.length-1&&f.length===b.length&&(c+=o)}return c.substring(0,r)}function Ni(t,e,o){const i=t.value,r=t.selectionStart||0,s=i.length<o.length,{separator:n}=e,d=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=i.replace(new RegExp(`[^0-9${d}]`,"g"),""),c=le(a,e);if(c!==i){t.value=c;let g=r;if(s)g=r;else if(c.length>i.length&&c[r]===n)g=r+1;else if(c.length>i.length){const l=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),h=(i.substring(0,r).match(new RegExp(l,"g"))||[]).length,p=(c.substring(0,r).match(new RegExp(l,"g"))||[]).length-h;g=r+p}t.setSelectionRange(g,g)}return c}function Ui(t,e){const{key:o,ctrlKey:i,metaKey:r}=t,{separator:s}=e;if(["Backspace","Delete","Tab","Escape","Enter","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"].includes(o)||i||r)return!1;if(o===s){const d=t.target,a=d.selectionStart||0,c=d.value;let g=0;for(let h=a-1;h>=0;h--)if(c[h]===s){g=h+1;break}const l=c.substring(g,a);if(/^\d$/.test(l)){t.preventDefault();const h=c.substring(0,g)+"0"+l+s+c.substring(a);d.value=h;const u=g+2+s.length;return d.setSelectionRange(u,u),!0}}return!/^\d$/.test(o)&&o!==s?(t.preventDefault(),!0):!1}function ji(t,e,o){var u;t.preventDefault();const i=((u=t.clipboardData)==null?void 0:u.getData("text"))||"",{separator:r}=o,s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=i.replace(new RegExp(`[^0-9${s}]`,"g"),""),d=le(n,o),a=e.selectionStart||0,c=e.selectionEnd||0,g=e.value,l=g.substring(0,a)+d+g.substring(c);e.value=le(l,o);const h=a+d.length;e.setSelectionRange(h,h)}function Bi(t,e,o,i){if(!t||t.length<e.maxLength)return!1;const r=_i(t,e);if(!r)return!1;const s=i.minDate?Y(i.minDate):null,n=i.maxDate?Y(i.maxDate):null;return s&&r<s||n&&r>n?!1:(o.selectedDate=r,o.focusedDate=r,o.viewYear=r.getFullYear(),o.viewMonth=r.getMonth(),!0)}const Ki=`
255
255
  .wg-datepicker-container {
256
256
  position: fixed;
257
257
  z-index: var(--wg-dp-z-index, 9999);
258
258
 
259
259
  /* Colors */
260
- --wg-dp-background: var(--base-layer-01, #fff);
261
- --wg-dp-border-color: var(--base-stroke-default, #e0e0e0);
262
- --wg-dp-text-color: var(--base-text-color-primary, #1a1a1a);
263
- --wg-dp-text-secondary: var(--base-text-color-secondary, #666);
264
- --wg-dp-text-muted: var(--base-text-color-muted, #ccc);
265
- --wg-dp-text-disabled: var(--base-text-color-disabled, #999);
260
+ --wg-dp-background: var(--base-main-bg, #fff);
261
+ --wg-dp-border-color: var(--base-border-color, #e0e0e0);
262
+ --wg-dp-text-color: var(--base-text-color-1, #1a1a1a);
263
+ --wg-dp-text-secondary: var(--base-text-color-3, #666);
264
+ --wg-dp-text-muted: var(--base-text-color-4, #ccc);
265
+ --wg-dp-text-disabled: var(--base-text-color-4, #999);
266
266
  --wg-dp-accent-color: var(--base-accent-color, #0078d4);
267
267
  --wg-dp-accent-hover: var(--base-accent-color-hover, #006cbd);
268
- --wg-dp-hover-bg: var(--base-layer-hover, #f5f5f5);
269
- --wg-dp-hover-border: var(--base-stroke-hover, #ccc);
270
- --wg-dp-selected-text: var(--base-text-on-accent, #fff);
268
+ --wg-dp-hover-bg: var(--base-hover-bg, #f5f5f5);
269
+ --wg-dp-hover-border: var(--base-border-color, #ccc);
270
+ --wg-dp-selected-text: var(--base-text-color-on-accent, #fff);
271
271
 
272
272
  /* Typography */
273
- --wg-dp-font-family: var(--base-font-family, inherit);
274
- --wg-dp-font-size: var(--base-font-size-sm, 13px);
275
- --wg-dp-font-size-sm: var(--base-font-size-xs, 12px);
276
- --wg-dp-font-size-xs: 10px;
277
- --wg-dp-font-weight-normal: var(--base-font-weight-normal, 400);
278
- --wg-dp-font-weight-medium: var(--base-font-weight-medium, 500);
279
- --wg-dp-font-weight-semibold: var(--base-font-weight-semibold, 600);
273
+ --wg-dp-font-family: var(--wg-font-family, var(--base-font-family, inherit));
274
+ --wg-dp-font-size: var(--wg-font-size-base, 14px);
275
+ --wg-dp-font-size-sm: var(--wg-font-size-sm, 12px);
276
+ --wg-dp-font-size-xs: var(--wg-font-size-xs, 11px);
277
+ --wg-dp-font-weight-normal: var(--wg-font-weight-normal, 400);
278
+ --wg-dp-font-weight-medium: 500;
279
+ --wg-dp-font-weight-semibold: var(--wg-font-weight-semibold, 600);
280
280
 
281
281
  /* Sizing */
282
282
  --wg-dp-padding: 8px;
283
283
  --wg-dp-min-width: 220px;
284
- --wg-dp-border-radius: var(--base-border-radius-sm, 4px);
284
+ --wg-dp-border-radius: var(--wg-border-radius-sm, 4px);
285
285
  --wg-dp-nav-size: 24px;
286
286
  --wg-dp-nav-icon-size: 14px;
287
287
  --wg-dp-rolling-list-height: 180px;
@@ -292,7 +292,7 @@
292
292
  --wg-dp-gap-xs: 1px;
293
293
 
294
294
  /* Shadow */
295
- --wg-dp-shadow: var(--base-shadow-lg, 0 4px 16px rgba(0, 0, 0, 0.15));
295
+ --wg-dp-shadow: var(--wg-shadow-lg, 0 4px 16px rgba(0, 0, 0, 0.15));
296
296
  }
297
297
 
298
298
  .wg-datepicker {
@@ -501,7 +501,7 @@
501
501
  .wg-datepicker__today-btn:hover {
502
502
  background-color: color-mix(in srgb, var(--wg-dp-accent-color) 10%, transparent);
503
503
  }
504
- `;let Ne=!1;class de{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 o=new Date;this.state={viewMonth:o.getMonth(),viewYear:o.getFullYear(),selectedDate:null,isOpen:!1,rollingSelectorOpen:!1,rollingSelectorMode:"month",focusedDate:null},this.localeStrings=this.initLocaleStrings(e.locale),this.formatInfo=re(this.options.dateFormat||"YYYY-MM-DD"),this.boundHandleClickOutside=this.handleClickOutside.bind(this),this.boundHandleKeyDown=this.handleKeyDown.bind(this)}initLocaleStrings(e){const o=e||navigator.language||"en";try{const i=new Intl.DateTimeFormat(o,{month:"long"}),r=new Intl.DateTimeFormat(o,{month:"short"}),s=new Intl.DateTimeFormat(o,{weekday:"long"}),n=new Intl.DateTimeFormat(o,{weekday:"short"}),d=[],a=[];for(let g=0;g<12;g++){const h=new Date(2024,g,1);d.push(i.format(h)),a.push(r.format(h))}const c=[],l=[];for(let g=0;g<7;g++){const h=new Date(2024,0,7+g);c.push(s.format(h));const u=n.format(h);l.push(u.substring(0,2))}return{today:"Today",clear:"Clear",monthNames:d,monthNamesShort:a,weekdayNames:c,weekdayNamesShort:l}}catch{return Fe}}static injectStyles(){if(Ne)return;const e=document.createElement("style");e.id="wg-datepicker-styles",e.textContent=Ki,document.head.appendChild(e),Ne=!0}open(e,o=null){de.injectStyles(),this.state.isOpen&&this.close(),this.anchor=e;const i=Y(o);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()}zi(this.state),this.element=document.createElement("div"),this.element.className="wg-datepicker-container",this.element.innerHTML=xi(this.state,this.options,this.localeStrings),document.body.appendChild(this.element),this.position(),this.attachListeners(),this.state.isOpen=!0,this.state.rollingSelectorOpen&&Ye(this.element)}close(e=!1){var o,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=(o=this.options).onClose)==null||i.call(o))}destroy(){this.close(),this.anchor=null,this.input=null}getSelectedDate(){return this.state.selectedDate}getFormattedValue(){return Ve(this.state.selectedDate,this.formatInfo)}position(){if(!this.element||!this.anchor)return;const e=this.element.querySelector(".wg-datepicker");e&&(this.cleanupAutoUpdate=zo(this.anchor,e,()=>{kt(this.anchor,e,{placement:"bottom-start",middleware:[Ht(4),xt({fallbackPlacements:["top-start","bottom-end","top-end"]}),Gt({padding:8})]}).then(({x:o,y:i})=>{Object.assign(e.style,{left:`${o}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 d;const o=e.target,i=(d=o.closest("[data-action]"))==null?void 0:d.getAttribute("data-action");if(i==="prev-month"){e.preventDefault(),se(this.state),this.render();return}if(i==="next-month"){e.preventDefault(),ae(this.state),this.render();return}if(i==="toggle-rolling"){e.preventDefault(),this.state.rollingSelectorOpen=!this.state.rollingSelectorOpen,this.render(),this.state.rollingSelectorOpen&&this.element&&Ye(this.element);return}if(i==="today"){e.preventDefault();const a=Vi(this.state,this.options);a&&this.selectDate(a);return}const r=o.closest(".wg-datepicker__day");if(r){e.preventDefault();const a=Fi(r,this.state,this.options);a&&this.selectDate(a);return}const s=o.closest("[data-month]");if(s&&this.state.rollingSelectorOpen){e.preventDefault(),qi(s,this.state),this.render();return}const n=o.closest("[data-year]");if(n&&this.state.rollingSelectorOpen){e.preventDefault(),Yi(n,this.state),this.render();return}}handleClickOutside(e){if(!this.element||!this.anchor)return;const o=e.target;!this.element.contains(o)&&!this.anchor.contains(o)&&this.close()}handleKeyDown(e){Ii(e,this.state,this.options,{onSelect:(i,r)=>this.selectDate(i,r),onClose:()=>this.close()})&&this.render()}selectDate(e,o){var i,r;this.state.selectedDate=e,(r=(i=this.options).onSelect)==null||r.call(i,e,o),this.close(!0)}render(){if(!this.element)return;const e=this.element.querySelector(".wg-datepicker");e&&(Oi(e,this.state,this.localeStrings),Ri(e,this.state.rollingSelectorOpen),this.state.rollingSelectorOpen?Pi(e,this.state):Ai(e,this.state,this.options))}connectInput(e){this.input=e,this.previousInputValue=e.value,e.addEventListener("input",()=>{this.previousInputValue=Ni(e,this.formatInfo,this.previousInputValue),Bi(e.value,this.formatInfo,this.state,this.options)}),e.addEventListener("keydown",o=>{Ui(o,this.formatInfo)}),e.addEventListener("paste",o=>{ji(o,e,this.formatInfo)}),e.addEventListener("focus",()=>{!this.state.isOpen&&this.anchor&&this.open(this.anchor,e.value)})}}const Wi=`
504
+ `;let Ne=!1;class de{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 o=new Date;this.state={viewMonth:o.getMonth(),viewYear:o.getFullYear(),selectedDate:null,isOpen:!1,rollingSelectorOpen:!1,rollingSelectorMode:"month",focusedDate:null},this.localeStrings=this.initLocaleStrings(e.locale),this.formatInfo=re(this.options.dateFormat||"YYYY-MM-DD"),this.boundHandleClickOutside=this.handleClickOutside.bind(this),this.boundHandleKeyDown=this.handleKeyDown.bind(this)}initLocaleStrings(e){const o=e||navigator.language||"en";try{const i=new Intl.DateTimeFormat(o,{month:"long"}),r=new Intl.DateTimeFormat(o,{month:"short"}),s=new Intl.DateTimeFormat(o,{weekday:"long"}),n=new Intl.DateTimeFormat(o,{weekday:"short"}),d=[],a=[];for(let l=0;l<12;l++){const h=new Date(2024,l,1);d.push(i.format(h)),a.push(r.format(h))}const c=[],g=[];for(let l=0;l<7;l++){const h=new Date(2024,0,7+l);c.push(s.format(h));const u=n.format(h);g.push(u.substring(0,2))}return{today:"Today",clear:"Clear",monthNames:d,monthNamesShort:a,weekdayNames:c,weekdayNamesShort:g}}catch{return Ve}}static injectStyles(){if(Ne)return;const e=document.createElement("style");e.id="wg-datepicker-styles",e.textContent=Ki,document.head.appendChild(e),Ne=!0}open(e,o=null){de.injectStyles(),this.state.isOpen&&this.close(),this.anchor=e;const i=Y(o);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()}zi(this.state),this.element=document.createElement("div"),this.element.className="wg-datepicker-container",this.element.innerHTML=xi(this.state,this.options,this.localeStrings),document.body.appendChild(this.element),this.position(),this.attachListeners(),this.state.isOpen=!0,this.state.rollingSelectorOpen&&Ye(this.element)}close(e=!1){var o,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=(o=this.options).onClose)==null||i.call(o))}destroy(){this.close(),this.anchor=null,this.input=null}getSelectedDate(){return this.state.selectedDate}getFormattedValue(){return Fe(this.state.selectedDate,this.formatInfo)}position(){if(!this.element||!this.anchor)return;const e=this.element.querySelector(".wg-datepicker");e&&(this.cleanupAutoUpdate=zo(this.anchor,e,()=>{Dt(this.anchor,e,{placement:"bottom-start",middleware:[It(4),kt({fallbackPlacements:["top-start","bottom-end","top-end"]}),Gt({padding:8})]}).then(({x:o,y:i})=>{Object.assign(e.style,{left:`${o}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 d;const o=e.target,i=(d=o.closest("[data-action]"))==null?void 0:d.getAttribute("data-action");if(i==="prev-month"){e.preventDefault(),se(this.state),this.render();return}if(i==="next-month"){e.preventDefault(),ae(this.state),this.render();return}if(i==="toggle-rolling"){e.preventDefault(),this.state.rollingSelectorOpen=!this.state.rollingSelectorOpen,this.render(),this.state.rollingSelectorOpen&&this.element&&Ye(this.element);return}if(i==="today"){e.preventDefault();const a=Fi(this.state,this.options);a&&this.selectDate(a);return}const r=o.closest(".wg-datepicker__day");if(r){e.preventDefault();const a=Vi(r,this.state,this.options);a&&this.selectDate(a);return}const s=o.closest("[data-month]");if(s&&this.state.rollingSelectorOpen){e.preventDefault(),qi(s,this.state),this.render();return}const n=o.closest("[data-year]");if(n&&this.state.rollingSelectorOpen){e.preventDefault(),Yi(n,this.state),this.render();return}}handleClickOutside(e){if(!this.element||!this.anchor)return;const o=e.target;!this.element.contains(o)&&!this.anchor.contains(o)&&this.close()}handleKeyDown(e){Pi(e,this.state,this.options,{onSelect:(i,r)=>this.selectDate(i,r),onClose:()=>this.close()})&&this.render()}selectDate(e,o){var i,r;this.state.selectedDate=e,(r=(i=this.options).onSelect)==null||r.call(i,e,o),this.close(!0)}render(){if(!this.element)return;const e=this.element.querySelector(".wg-datepicker");e&&(Oi(e,this.state,this.localeStrings),Hi(e,this.state.rollingSelectorOpen),this.state.rollingSelectorOpen?Ri(e,this.state):Ai(e,this.state,this.options))}connectInput(e){this.input=e,this.previousInputValue=e.value,e.addEventListener("input",()=>{this.previousInputValue=Ni(e,this.formatInfo,this.previousInputValue),Bi(e.value,this.formatInfo,this.state,this.options)}),e.addEventListener("keydown",o=>{Ui(o,this.formatInfo)}),e.addEventListener("paste",o=>{ji(o,e,this.formatInfo)}),e.addEventListener("focus",()=>{!this.state.isOpen&&this.anchor&&this.open(this.anchor,e.value)})}}const Wi=`
505
505
  .wg-context-menu-container {
506
506
  position: fixed;
507
507
  z-index: var(--wg-cm-z-index, 10000);
@@ -584,19 +584,47 @@
584
584
  flex: 1;
585
585
  }
586
586
 
587
+ .wg-context-menu__shortcut {
588
+ margin-left: auto;
589
+ padding-left: 16px;
590
+ color: var(--wg-cm-text-secondary);
591
+ font-size: 0.9em;
592
+ }
593
+
587
594
  .wg-context-menu__divider {
588
595
  height: 1px;
589
596
  background: var(--wg-cm-border-color);
590
597
  margin: var(--wg-cm-padding) 0;
591
598
  }
592
- `;let Ue=!1;function Xi(){if(Ue)return;const t=document.createElement("style");t.id="wg-context-menu-styles",t.textContent=Wi,document.head.appendChild(t),Ue=!0}function Qi(t,e){const o=t.filter(r=>r.visible===void 0?!0:typeof r.visible=="function"?r.visible(e):r.visible);return o.length===0?"":`<div class="wg-context-menu">${o.map((r,s)=>{const n=typeof r.label=="function"?r.label(e):r.label,d=typeof r.icon=="function"?r.icon(e):r.icon,a=typeof r.disabled=="function"?r.disabled(e):r.disabled,c=r.danger===!0,l=["wg-context-menu__item",a?"wg-context-menu__item--disabled":"",c?"wg-context-menu__item--danger":""].filter(Boolean).join(" "),g=r.dividerBefore&&s>0?'<div class="wg-context-menu__divider"></div>':"",h=d?`<span class="wg-context-menu__icon">${d}</span>`:"";return`${g}<div class="${l}" data-item-id="${r.id}" data-disabled="${a?"true":"false"}">${h}<span class="wg-context-menu__label">${n}</span></div>`}).join("")}</div>`}function Gi(t,e,o,i,r,s,n){Xi();const d=Qi(i,r);if(!d)return null;const a=document.createElement("div");a.className="wg-context-menu-container",a.innerHTML=d,document.body.appendChild(a);const c=a.querySelector(".wg-context-menu");kt({getBoundingClientRect:()=>({width:0,height:0,x:e,y:o,top:o,left:e,right:e,bottom:o})},c,{placement:"bottom-start",middleware:[Ht(4),xt({fallbackPlacements:["top-start","bottom-end","top-end"]}),Gt({padding:8})]}).then(({x:u,y:p})=>{Object.assign(c.style,{left:`${u}px`,top:`${p}px`})}),a.addEventListener("click",u=>{const p=u.target.closest(".wg-context-menu__item");if(p&&p.dataset.disabled!=="true"){const m=p.dataset.itemId||"";s(m)}});const g=u=>{a.contains(u.target)||(Et(a,g,h),n())},h=u=>{u.key==="Escape"&&(u.preventDefault(),Et(a,g,h),n())};return setTimeout(()=>{document.addEventListener("mousedown",g),document.addEventListener("keydown",h)},0),a._cleanup={handleOutsideClick:g,handleKeyDown:h},a}function Et(t,e,o){e&&document.removeEventListener("mousedown",e),o&&document.removeEventListener("keydown",o);const i=t._cleanup;i&&(i.handleOutsideClick&&document.removeEventListener("mousedown",i.handleOutsideClick),i.handleKeyDown&&document.removeEventListener("keydown",i.handleKeyDown)),t.remove()}class ce 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,"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,"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,"virtualScrollStart",0);w(this,"virtualScrollEnd",0);w(this,"scrollListenerAdded",!1);w(this,"isLoadingMoreItems",!1);w(this,"handlePaste",o=>{var c;if(!this.grid.isNavigateMode||this.grid.editingCell||!this.grid.focusedCell)return;const{rowIndex:i,colIndex:r}=this.grid.focusedCell,s=this.grid.columns[r],n=this.grid.displayItems[i];if(!s||!n||!this.grid.isCellEditable(s))return;o.preventDefault();let d=((c=o.clipboardData)==null?void 0:c.getData("text"))||"";if(s.beforePasteCallback){const l=s.beforePasteCallback(d,n);d=l!=null?String(l):""}const a=String(s.field);this.grid.commitEdit(i,a,d),this.render()});this.shadow=this.attachShadow({mode:"open"}),this.grid=new z,this.styleElement=document.createElement("style"),this.styleElement.textContent=ht,this.shadow.appendChild(this.styleElement),this.grid.requestUpdate=()=>this.requestUpdate()}get tooltipShowDelay(){return this._tooltipShowDelay}set tooltipShowDelay(o){this._tooltipShowDelay=o}get tooltipHideDelay(){return this._tooltipHideDelay}set tooltipHideDelay(o){this._tooltipHideDelay=o}connectedCallback(){this.render(),this.addEventListener("paste",this.handlePaste)}disconnectedCallback(){this.removeEventListener("paste",this.handlePaste),this.datepicker&&(this.datepicker.destroy(),this.datepicker=null),this.contextMenuElement&&(Et(this.contextMenuElement),this.contextMenuElement=null),Ft()}get items(){return this.grid.items}set items(o){this.grid.items=o,this.isLoadingMoreItems=!1}get columns(){return this.grid.columns}set columns(o){this.grid.columns=o}get sortable(){return this.grid.sortable}set sortable(o){this.grid.sortable=o}get filterable(){return this.grid.filterable}set filterable(o){this.grid.filterable=o}get pageable(){return this.grid.pageable}set pageable(o){this.grid.pageable=o}get pageSize(){return this.grid.pageSize}set pageSize(o){this.grid.pageSize=o}get pageSizes(){return this.grid.pageSizes}set pageSizes(o){this.grid.pageSizes=o}get striped(){return this.grid.striped}set striped(o){this.grid.striped=o}get hoverable(){return this.grid.hoverable}set hoverable(o){this.grid.hoverable=o}get editable(){return this.grid.editable}set editable(o){this.grid.editable=o}get editTrigger(){return this.grid.editTrigger}set editTrigger(o){this.grid.editTrigger=o}get editStartSelection(){return this.grid.editStartSelection}set editStartSelection(o){this.grid.editStartSelection=o}get mode(){return this.grid.mode}set mode(o){this.grid.mode=o}get dropdownToggleVisibility(){return this.grid.dropdownToggleVisibility}set dropdownToggleVisibility(o){this.grid.dropdownToggleVisibility=o}get dropdownShowOnFocus(){return this.grid.dropdownShowOnFocus}set dropdownShowOnFocus(o){this.grid.dropdownShowOnFocus=o}get openDropdownOnEnter(){return this.grid.openDropdownOnEnter}set openDropdownOnEnter(o){this.grid.openDropdownOnEnter=o}get checkboxAlwaysEditable(){return this.grid.checkboxAlwaysEditable}set checkboxAlwaysEditable(o){this.grid.checkboxAlwaysEditable=o}get showRowNumbers(){return this.grid.showRowNumbers}set showRowNumbers(o){this.grid.showRowNumbers=o}get invalidCells(){return this.grid.invalidCells}set invalidCells(o){this.grid.invalidCells=o}get showRowToolbar(){return this.grid.showRowToolbar}set showRowToolbar(o){this.grid.showRowToolbar=o}get rowToolbar(){return this.grid.rowToolbar}set rowToolbar(o){this.grid.rowToolbar=o}get toolbarAlign(){return this.grid.toolbarAlign}set toolbarAlign(o){this.grid.toolbarAlign=o}get toolbarTopPosition(){return this.grid.toolbarTopPosition}set toolbarTopPosition(o){this.grid.toolbarTopPosition=o}get toolbarTrigger(){return this.grid.toolbarTrigger}set toolbarTrigger(o){this.grid.toolbarTrigger=o}get toolbarPosition(){return this.grid.toolbarPosition}set toolbarPosition(o){this.grid.toolbarPosition=o}get contextMenu(){return this.grid.contextMenu}set contextMenu(o){this.grid.contextMenu=o}get showRowActions(){return this.grid.showRowActions}set showRowActions(o){this.grid.showRowActions=o}get rowActions(){return this.grid.rowActions}set rowActions(o){this.grid.rowActions=o}set onrowchange(o){this.grid.onrowchange=o}set onroweditstart(o){this.grid.onroweditstart=o}set onroweditcancel(o){this.grid.onroweditcancel=o}set onvalidationerror(o){this.grid.onvalidationerror=o}get validationTooltipCallback(){return this.grid.validationTooltipCallback}set validationTooltipCallback(o){this.grid.validationTooltipCallback=o}set ontoolbarclick(o){this.grid.ontoolbarclick=o}set onrowaction(o){this.grid.onrowaction=o}set oncontextmenuopen(o){this.grid.oncontextmenuopen=o}get ondatarequest(){return this.grid.ondatarequest}set ondatarequest(o){this.grid.ondatarequest=o}get onrowdelete(){return this.grid.onrowdelete}set onrowdelete(o){this.grid.onrowdelete=o}get sort(){return this.grid.sort}set sort(o){this.grid.sort=o}get sortMode(){return this.grid.sortMode}set sortMode(o){this.grid.sortMode=o}get currentPage(){return this.grid.currentPage}set currentPage(o){this.grid.currentPage=o}get totalItems(){return this.grid.totalItems}set totalItems(o){this.grid.totalItems=o}get showPagination(){return this.grid.showPagination}set showPagination(o){this.grid.showPagination=o}get paginationPosition(){return this.grid.paginationPosition}set paginationPosition(o){this.grid.paginationPosition=o}get paginationLabelsCallback(){return this.grid.paginationLabelsCallback}set paginationLabelsCallback(o){this.grid.paginationLabelsCallback=o}get paginationLayout(){return this.grid.paginationLayout}set paginationLayout(o){this.grid.paginationLayout=o}get summaryPosition(){return this.grid.summaryPosition}set summaryPosition(o){this.grid.summaryPosition=o}get summaryContentCallback(){return this.grid.summaryContentCallback}set summaryContentCallback(o){this.grid.summaryContentCallback=o}get customStylesCallback(){return this.grid.customStylesCallback}set customStylesCallback(o){this.grid.customStylesCallback=o,this.updateCustomStyles()}get rowClassCallback(){return this.grid.rowClassCallback}set rowClassCallback(o){this.grid.rowClassCallback=o}get summaryMetadata(){return this.grid.summaryMetadata}set summaryMetadata(o){this.grid.summaryMetadata=o}get summaryInline(){return this.grid.summaryInline}set summaryInline(o){this.grid.summaryInline=o}get virtualScroll(){return this.grid.virtualScroll}set virtualScroll(o){this.grid.virtualScroll=o}get virtualScrollThreshold(){return this.grid.virtualScrollThreshold}set virtualScrollThreshold(o){this.grid.virtualScrollThreshold=o}get virtualScrollRowHeight(){return this.grid.virtualScrollRowHeight}set virtualScrollRowHeight(o){this.grid.virtualScrollRowHeight=o}get virtualScrollBuffer(){return this.grid.virtualScrollBuffer}set virtualScrollBuffer(o){this.grid.virtualScrollBuffer=o}get infiniteScroll(){return this.grid.infiniteScroll}set infiniteScroll(o){this.grid.infiniteScroll=o}get infiniteScrollThreshold(){return this.grid.infiniteScrollThreshold}set infiniteScrollThreshold(o){this.grid.infiniteScrollThreshold=o}get hasMoreItems(){return this.grid.hasMoreItems}set hasMoreItems(o){this.grid.hasMoreItems=o}get displayItems(){return this.grid.displayItems}get totalPages(){return this.grid.totalPages}get isNavigateMode(){return this.grid.isNavigateMode}getRowDraft(o){return this.grid.getRowDraft(o)}hasRowDraft(o){return this.grid.hasRowDraft(o)}discardRowDraft(o){this.grid.discardRowDraft(o)}getDraftRowIndices(){return this.grid.getDraftRowIndices()}discardAllDrafts(){this.grid.discardAllDrafts()}isCellInvalid(o,i){return this.grid.isCellInvalid(o,i)}getCellValidationError(o,i){return this.grid.getCellValidationError(o,i)}escapeHtml(o){const i=document.createElement("div");return i.textContent=o,i.innerHTML}getCurrentEditingColumn(){const o=this.grid.editingCell;return o&&this.grid.columns.find(i=>String(i.field)===o.field)||null}getCurrentEditorOptions(){const o=this.getCurrentEditingColumn();return(o==null?void 0:o.editorOptions)||{}}moveFocusAfterCommit(o,i,r){Zt(this,o,i,r)}requestUpdate(){this.updatePending||(this.updatePending=!0,queueMicrotask(()=>{this.updatePending=!1,this.render()}))}updateCustomStyles(){const o=this.grid.customStylesCallback;if(o){const i=o();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(o,i,r){var c;if(!this.grid.isNavigateMode)return;const s=this.grid.columns,n=this.grid.displayItems,d=this.grid.getEditableColumns(),a=d.findIndex(l=>l.index===r);if((o.ctrlKey||o.metaKey)&&o.key==="c"){const l=s[r],g=n[i];if(l&&g){let h=this.grid.getCellRawValue(g,i,String(l.field));l.beforeCopyCallback&&(h=l.beforeCopyCallback(h,g));const u=h!=null?String(h):"";navigator.clipboard.writeText(u)}return}switch(o.key){case"ArrowUp":o.preventDefault(),i>0&&E(this,i-1,r);break;case"ArrowDown":o.preventDefault(),i<n.length-1&&E(this,i+1,r);break;case"ArrowLeft":o.preventDefault(),r>0&&E(this,i,r-1);break;case"ArrowRight":o.preventDefault(),r<s.length-1&&E(this,i,r+1);break;case"Tab":if(o.preventDefault(),o.shiftKey){if(a>0){const l=d[a-1].index;E(this,i,l)}else if(i>0){const l=d[d.length-1].index;E(this,i-1,l)}}else if(a>=0&&a<d.length-1){const l=d[a+1].index;E(this,i,l)}else if(a===-1&&d.length>0)E(this,i,d[0].index);else if(i<n.length-1){const l=d[0].index;E(this,i+1,l)}break;case"Home":if(o.preventDefault(),o.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const l=this.grid.focusedCell;this.grid.setFocusedCell(0,0),ut(this,0);const g=this.shadow.querySelector('td[data-row="0"][data-col="0"]');g&&(g.focus({preventScroll:!0}),W(this,l,{rowIndex:0,colIndex:0}))}else E(this,0,0);else E(this,i,0);break;case"End":if(o.preventDefault(),o.ctrlKey){const l=n.length-1,g=s.length-1;if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(l,g),ut(this,l);const u=this.shadow.querySelector(`td[data-row="${l}"][data-col="${g}"]`);u&&(u.focus({preventScroll:!0}),W(this,h,{rowIndex:l,colIndex:g}))}else E(this,l,g)}else E(this,i,s.length-1);break;case"PageUp":if(o.preventDefault(),o.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const l=this.grid.focusedCell;this.grid.setFocusedCell(0,r),ut(this,0);const g=this.shadow.querySelector(`td[data-row="0"][data-col="${r}"]`);g&&(g.focus({preventScroll:!0}),W(this,l,{rowIndex:0,colIndex:r}))}else E(this,0,r);else{const l=Math.max(0,i-10);if(this.grid.shouldUseVirtualScroll()){const g=this.grid.focusedCell;this.grid.setFocusedCell(l,r),ut(this,l);const h=this.shadow.querySelector(`td[data-row="${l}"][data-col="${r}"]`);h&&(h.focus({preventScroll:!0}),W(this,g,{rowIndex:l,colIndex:r}))}else E(this,l,r)}break;case"PageDown":if(o.preventDefault(),o.ctrlKey){const l=n.length-1;if(this.grid.shouldUseVirtualScroll()){const g=this.grid.focusedCell;this.grid.setFocusedCell(l,r),ut(this,l);const h=this.shadow.querySelector(`td[data-row="${l}"][data-col="${r}"]`);h&&(h.focus({preventScroll:!0}),W(this,g,{rowIndex:l,colIndex:r}))}else E(this,l,r)}else{const l=Math.min(n.length-1,i+10);if(this.grid.shouldUseVirtualScroll()){const g=this.grid.focusedCell;this.grid.setFocusedCell(l,r),ut(this,l);const h=this.shadow.querySelector(`td[data-row="${l}"][data-col="${r}"]`);h&&(h.focus({preventScroll:!0}),W(this,g,{rowIndex:l,colIndex:r}))}else E(this,l,r)}break;case"g":case"G":o.ctrlKey&&(o.preventDefault(),this.showGoToRowDialog(r));break;case"Enter":{o.preventDefault();const l=s[r];((l==null?void 0:l.editor)==="select"||(l==null?void 0:l.editor)==="combobox"||(l==null?void 0:l.editor)==="autocomplete")&&this.grid.getEffectiveOpenDropdownOnEnter(l)?(X(this,i,r),requestAnimationFrame(()=>{this.dropdownOpen||J(this)})):i<n.length-1&&E(this,i+1,r);break}case"F2":{o.preventDefault();const l=s[r],g=(l==null?void 0:l.editor)==="select"||(l==null?void 0:l.editor)==="combobox"||(l==null?void 0:l.editor)==="autocomplete",h=(l==null?void 0:l.editor)==="custom";X(this,i,r),g?requestAnimationFrame(()=>{this.dropdownOpen||J(this)}):h&&requestAnimationFrame(()=>{this.openCustomEditor(i,r)});break}case" ":{o.preventDefault();const l=s[r],g=(l==null?void 0:l.editor)==="checkbox",h=(l==null?void 0:l.editor)==="select"||(l==null?void 0:l.editor)==="combobox"||(l==null?void 0:l.editor)==="autocomplete",u=(l==null?void 0:l.editor)==="date",p=(l==null?void 0:l.editor)==="custom";g?Jo(this,i,r):h?(X(this,i,r),requestAnimationFrame(()=>{this.dropdownOpen||J(this)})):u?(X(this,i,r),requestAnimationFrame(()=>{var v;const m=(v=this.shadowRoot)==null?void 0:v.querySelector(`.wg__cell[data-row="${i}"][data-col="${r}"]`),f=m==null?void 0:m.querySelector(".wg__date-input"),b=m==null?void 0:m.querySelector(".wg__editor--date");f&&b&&this.openDatePicker(f,b)})):p&&(X(this,i,r),requestAnimationFrame(()=>{this.openCustomEditor(i,r)}));break}case"Escape":if(o.preventDefault(),this.grid.editingCell)q(this),this.grid.cancelEdit();else{const l=this.grid.focusedCell;this.grid.clearFocusedCell(),W(this,l,null),(c=o.target)==null||c.blur()}break;case"Delete":{o.preventDefault();const l=s[r],g=n[i];if(o.ctrlKey){if(g){const h={rowIndex:i,row:g};this.grid.onrowdelete&&this.grid.onrowdelete(h),this.dispatchEvent(new CustomEvent("rowdelete",{detail:h}))}}else l&&this.grid.isCellEditable(l)&&(this.grid.commitEdit(i,String(l.field),null),this.render(),requestAnimationFrame(()=>{const h=this.shadow.querySelector(`td[data-row="${i}"][data-col="${r}"]`);h==null||h.focus()}));break}default:if(o.key.length===1&&!o.ctrlKey&&!o.altKey&&!o.metaKey){const l=s[r];if((l==null?void 0:l.editor)==="number"&&!/[\d.\-]/.test(o.key))return;X(this,i,r,{initialSearchQuery:o.key}),o.preventDefault()}break}}handleEditorKeyDown(o,i){const r=parseInt(i.dataset.row||"0",10),s=i.dataset.field||"",n=this.grid.columns.find(l=>l.field===s),d=(n==null?void 0:n.editor)||"text",a=d==="select"||d==="combobox"||d==="autocomplete",c=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"];if(a&&!this.dropdownOpen&&c.includes(o.key)){o.preventDefault(),o.stopPropagation();const l=this.grid.columns.findIndex(b=>b.field===s),g=this.grid.columns.map((b,v)=>({index:v,column:b})).filter(b=>b.column.editable!==!1),h=g.findIndex(b=>b.index===l),u=this.grid.displayItems;let p=r,m=l,f=!1;switch(o.key){case"ArrowUp":r>0&&(p=r-1,f=!0);break;case"ArrowDown":r<u.length-1&&(p=r+1,f=!0);break;case"ArrowLeft":h>0&&(m=g[h-1].index,f=!0);break;case"ArrowRight":h<g.length-1&&(m=g[h+1].index,f=!0);break;case"PageUp":p=Math.max(0,r-10),f=!0;break;case"PageDown":p=Math.min(u.length-1,r+10),f=!0;break;case"Home":o.ctrlKey&&(p=0),m=0,f=!0;break;case"End":o.ctrlKey?(p=u.length-1,m=this.grid.columns.length-1):m=this.grid.columns.length-1,f=!0;break}f&&(q(this),this.grid.cancelEdit(),queueMicrotask(()=>{E(this,p,m)}));return}switch(o.key){case"ArrowDown":if(this.dropdownOpen){o.preventDefault(),o.stopPropagation();const l=this.getCurrentEditorOptions();let g=this.highlightedIndex+1;for(;g<this.dropdownOptions.length&&yt(this.dropdownOptions[g],l);)g++;g<this.dropdownOptions.length&&(this.highlightedIndex=g,it(this),$e(this))}break;case"ArrowUp":if(this.dropdownOpen){o.preventDefault(),o.stopPropagation();const l=this.getCurrentEditorOptions();let g=this.highlightedIndex-1;for(;g>=0&&yt(this.dropdownOptions[g],l);)g--;g>=0&&(this.highlightedIndex=g,it(this),$e(this))}break;case"Enter":if(this.datepicker)return;o.preventDefault(),o.stopPropagation(),this.dropdownOpen&&this.highlightedIndex>=0?Ee(this,this.highlightedIndex):a&&!this.dropdownOpen?J(this):(this.isCommittingFromKeyboard=!0,P(this),d==="date"&&i instanceof HTMLInputElement?this.commitDateEditor(i):zt(this,i),Zt(this,r,s,"down"));break;case"Tab":if(this.datepicker)return;if(o.preventDefault(),o.stopPropagation(),this.isCommittingFromKeyboard=!0,this.dropdownOpen&&this.highlightedIndex>=0&&a){const l=this.dropdownOptions[this.highlightedIndex],g=this.getCurrentEditorOptions();if(l&&!yt(l,g)){const h=lt(l,g);this.grid.commitEdit(r,s,h)}P(this)}else P(this),d==="date"&&i instanceof HTMLInputElement?this.commitDateEditor(i):a||zt(this,i);Zt(this,r,s,o.shiftKey?"prev":"next");break;case"Escape":o.preventDefault(),o.stopPropagation(),this.dropdownOpen&&P(this),this.datepicker&&(this.datepicker.close(!0),this.datepicker=null),this.isCommittingFromKeyboard=!0,q(this),this.grid.cancelEdit(),ti(this,r,s);break;case"F2":o.preventDefault(),o.stopPropagation(),a&&!this.dropdownOpen&&J(this);break;case"Backspace":d==="select"&&(o.preventDefault(),o.stopPropagation(),this.filterText.length>0&&(this.filterText=this.filterText.slice(0,-1),Oe(this,n.editorOptions||{})));break;default:d==="select"&&o.key.length===1&&!o.ctrlKey&&!o.altKey&&!o.metaKey&&(o.preventDefault(),o.stopPropagation(),this.filterText+=o.key,Oe(this,n.editorOptions||{}));break}}attachEventListeners(){const o=this.shadow.querySelector(".wg__table");if(!o)return;o.addEventListener("focus",s=>{var d;const n=s.target;if(n.matches(".wg__cell")){const a=parseInt(n.dataset.row||"0",10),c=parseInt(n.dataset.col||"0",10);Wo(this,a,c)}if(n.matches(".wg__select-trigger, .wg__combobox-input, .wg__autocomplete-input")&&!this.justSelected&&!this.dropdownOpen){const a=n.dataset.field||"",c=this.grid.columns.find(h=>h.field===a),l=(c==null?void 0:c.editorOptions)||{};(((d=this.grid.editingCell)==null?void 0:d.initialSearchQuery)!==void 0||l.showOnFocus!==!1)&&J(this)}},!0),o.addEventListener("keydown",s=>{const n=s.target;if(n.matches(".wg__editor, .wg__combobox-input, .wg__autocomplete-input, .wg__date-input")){this.handleEditorKeyDown(s,n);return}if(n.matches(".wg__cell")){const d=parseInt(n.dataset.row||"0",10),a=parseInt(n.dataset.col||"0",10);this.handleCellKeyDown(s,d,a)}}),o.addEventListener("focusout",s=>{Xo(this,s)}),o.addEventListener("dblclick",s=>{s.preventDefault();const d=s.target.closest(".wg__cell");if(d){const a=parseInt(d.dataset.row||"0",10),c=parseInt(d.dataset.col||"0",10),l=this.grid.columns[c];if(l){const g=l.editTrigger||this.grid.editTrigger;if(g==="dblclick"||g==="navigate"){const h=Jt(s,d);X(this,a,c,{cursorPosition:h??void 0});const u=l.editor;u==="select"||u==="combobox"||u==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||J(this)}):u==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(a,c)})}}}}),o.addEventListener("click",s=>{const d=s.target.closest(".wg__cell");if(d&&!d.classList.contains("wg__cell--editing")){const a=parseInt(d.dataset.row||"0",10),c=parseInt(d.dataset.col||"0",10),l=this.grid.columns[c];if(l&&(l.editTrigger||this.grid.editTrigger)==="click"){s.preventDefault();const h=Jt(s,d);X(this,a,c,{cursorPosition:h??void 0});const u=l.editor;u==="select"||u==="combobox"||u==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||J(this)}):u==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(a,c)})}}}),o.addEventListener("mousedown",s=>{const n=s.target;if(n.closest(".wg__date-trigger")){s.preventDefault(),s.stopPropagation();const a=n.closest(".wg__cell-date-display"),c=n.closest(".wg__editor--date");if(c){const l=c.querySelector(".wg__date-input");l&&this.openDatePicker(l,c)}else if(a){const l=parseInt(a.dataset.row||"0",10),g=a.dataset.field||"",h=this.grid.columns.findIndex(u=>String(u.field)===g);h>=0&&(this.isTransitioningCells=!0,this.grid.editingCell&&(P(this),q(this),this.grid.cancelEdit()),X(this,l,h),requestAnimationFrame(()=>{var f;this.isTransitioningCells=!1;const u=(f=this.shadowRoot)==null?void 0:f.querySelector(`.wg__cell[data-row="${l}"][data-field="${g}"]`),p=u==null?void 0:u.querySelector(".wg__date-input"),m=u==null?void 0:u.querySelector(".wg__editor--date");p&&m&&this.openDatePicker(p,m)}))}return}if(this.dropdownOpen||this.grid.editingCell){const a=n.closest(".wg__cell");if(a&&!n.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete, .wg__editor--date")){const c=parseInt(a.dataset.row||"0",10),l=parseInt(a.dataset.col||"0",10),g=this.grid.editingCell,h=n.matches(".wg__combobox-toggle, .wg__select-toggle, .wg__date-trigger");if(g&&!h){const u=this.grid.columns.findIndex(p=>String(p.field)===g.field);if(c!==g.rowIndex||l!==u){s.preventDefault(),this.isTransitioningCells=!0,P(this),q(this),this.grid.cancelEdit();const p=this.grid.columns[l],m=(p==null?void 0:p.editTrigger)||this.grid.editTrigger,b=s.clientX;requestAnimationFrame(()=>{if(this.isTransitioningCells=!1,m==="click"&&p&&this.grid.isCellEditable(p)){const v=this.shadow.querySelector(`td[data-row="${c}"][data-col="${l}"]`),_=v?Jt({clientX:b},v):void 0;X(this,c,l,{cursorPosition:_??void 0})}else E(this,c,l)});return}}}}if(n.matches(".wg__combobox-toggle, .wg__select-toggle")){s.preventDefault(),s.stopPropagation();const a=n.closest(".wg__cell-dropdown-display");if(n.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete"))Ae(this);else if(a){const l=parseInt(a.dataset.row||"0",10),g=a.dataset.field||"",h=this.grid.columns.findIndex(u=>String(u.field)===g);h>=0&&(this.isTransitioningCells=!0,this.grid.editingCell&&(P(this),q(this),this.grid.cancelEdit()),X(this,l,h),requestAnimationFrame(()=>{this.isTransitioningCells=!1,this.dropdownOpen||J(this)}))}}if(n.matches(".wg__cell-dropdown-display")){s.preventDefault(),s.stopPropagation();const a=n.closest(".wg__cell-dropdown-display");if(a){const c=parseInt(a.dataset.row||"0",10),l=a.dataset.field||"",g=this.grid.columns.findIndex(h=>String(h.field)===l);g>=0&&(this.isTransitioningCells=!0,this.grid.editingCell&&(P(this),q(this),this.grid.cancelEdit()),X(this,c,g),requestAnimationFrame(()=>{this.isTransitioningCells=!1,this.dropdownOpen||J(this)}))}}}),o.addEventListener("click",s=>{s.target.matches(".wg__select-trigger, .wg__select-value")&&(s.preventDefault(),s.stopPropagation(),Ae(this))}),o.addEventListener("click",s=>{const n=s,a=n.target.closest(".wg__header--sortable");if(a){const c=a.dataset.field;if(!c)return;const l=[...this.grid.sort],g=l.findIndex(u=>u.column===c);(n.ctrlKey||n.metaKey)&&this.grid.sortMode==="multi"?g>=0?l[g].direction==="asc"?l[g]={column:c,direction:"desc"}:l.splice(g,1):l.push({column:c,direction:"asc"}):g>=0&&l.length===1?l[0].direction==="asc"?l[0]={column:c,direction:"desc"}:l.length=0:(l.length=0,l.push({column:c,direction:"asc"})),this.grid.sort=l,this.grid.pageable&&(this.grid.currentPage=1),this.grid.fireDataRequest("sort"),this.render()}}),o.addEventListener("contextmenu",s=>{this.handleContextMenu(s)}),o.addEventListener("change",s=>{const n=s.target;n.matches(".wg__editor--checkbox")&&Go(this,n)}),o.addEventListener("input",s=>{const n=s.target;n.matches(".wg__combobox-input")?qo(this,s):n.matches(".wg__autocomplete-input")&&Yo(this,s)}),o.addEventListener("blur",s=>{const n=s.target;if(n.matches(".wg__editor--text, .wg__editor--number")&&Zo(this,n),n.matches(".wg__date-input")&&!this.datepicker&&!this.isCommittingFromKeyboard&&!this.isTransitioningCells&&this.commitDateEditor(n),n.matches(".wg__select-trigger")&&!this.isCommittingFromKeyboard&&!this.isTransitioningCells&&!this.dropdownOpen&&!this.isOpeningDropdown&&(P(this),q(this),this.grid.cancelEdit()),n.matches(".wg__combobox-input, .wg__autocomplete-input")){if(this.isCommittingFromKeyboard||this.isTransitioningCells)return;if(P(this),this.grid.editingCell){const d=n,a=this.getCurrentEditingColumn();if(a){const c=a.editorOptions||{},g=(c.options||c.initialOptions||[]).find(h=>_t(h,c).toLowerCase()===d.value.toLowerCase());g?this.grid.commitEdit(this.grid.editingCell.rowIndex,this.grid.editingCell.field,lt(g,c)):this.grid.commitEdit(this.grid.editingCell.rowIndex,this.grid.editingCell.field,d.value)}}}},!0);const i=this.shadow.querySelector(".wg");i&&i.addEventListener("scroll",()=>{this.dropdownOpen&&!this.isTransitioningCells&&!this.isOpeningDropdown&&(P(this),q(this),this.grid.cancelEdit()),this.grid.shouldUseVirtualScroll()&&this.handleVirtualScroll(i),this.grid.infiniteScroll&&this.grid.hasMoreItems&&!this.isLoadingMoreItems&&this.handleInfiniteScroll(i),Dt()!==null&&(Le(this,this.grid.displayItems),this.renderConnector())}),this.wheelListenerAdded||(this.wheelListenerAdded=!0,window.addEventListener("scroll",()=>{this.dropdownOpen&&!this.isTransitioningCells&&(P(this),q(this),this.grid.cancelEdit())},{passive:!0,capture:!0})),o.addEventListener("mouseenter",s=>{const n=s.target,d=n.closest("[data-tooltip-html]");if(d){const c=d.getAttribute("data-tooltip-html");Re(this,d,c,this._tooltipShowDelay,!0);return}const a=n.closest("[data-tooltip]");if(a){const c=a.getAttribute("data-tooltip");Re(this,a,c,this._tooltipShowDelay,!1)}},!0),o.addEventListener("mouseleave",s=>{const n=s,d=n.target,a=n.relatedTarget,c=d.closest("[data-tooltip], [data-tooltip-html]");c&&(a==null?void 0:a.closest("[data-tooltip], [data-tooltip-html]"))===c||c&&Uo(this,this._tooltipHideDelay)},!0),o.addEventListener("click",s=>{const d=s.target.closest(".wg__toolbar-trigger");if(d&&this.grid.toolbarTrigger==="button"){s.preventDefault(),s.stopPropagation();const a=parseInt(d.dataset.toolbarTrigger||"0",10),c=o.querySelector(`tr[data-row-index="${a}"]`);c&&(ee(a)?(this.closeToolbarAndReset(),this.render()):this.showToolbarForRow(c,a))}}),o.addEventListener("mouseenter",s=>{if(this.grid.toolbarTrigger!=="hover")return;this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null);const n=s,a=n.target.closest(".wg__row");if(a){const c=parseInt(a.dataset.rowIndex||"0",10);ee(c)||this.showToolbarForRow(a,c,n.clientX)}},!0),o.addEventListener("mouseleave",s=>{if(this.grid.toolbarTrigger!=="hover")return;if(s.target.closest(".wg__row")){if(this.toolbarMoveInProgress)return;this.toolbarHideTimeout&&clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=setTimeout(()=>{const c=this.shadow.querySelector(".wg__toolbar-container"),l=c==null?void 0:c.matches(":hover"),g=o.matches(":hover");!l&&!g&&(this.closeToolbarAndReset(),this.grid.editingCell||this.render())},150)}},!0),o.addEventListener("click",s=>{if(this.grid.toolbarTrigger!=="click")return;const n=s,d=n.target,a=d.closest(".wg__row");if(a&&!d.closest(".wg__cell--editing")){const c=parseInt(a.dataset.rowIndex||"0",10);ee(c)?(this.closeToolbarAndReset(),this.render()):this.showToolbarForRow(a,c,n.clientX)}}),this.toolbarOutsideClickAdded||(this.toolbarOutsideClickAdded=!0,document.addEventListener("click",s=>{if(!fi(this.shadow))return;const n=s.composedPath(),d=n.some(l=>{var g;return(g=l.classList)==null?void 0:g.contains("wg__toolbar-container")}),a=n.some(l=>{var g;return(g=l.classList)==null?void 0:g.contains("wg__toolbar-trigger")});d||a||n.includes(this)&&(this.grid.toolbarTrigger==="hover"||this.grid.toolbarTrigger==="click")||Dt()!==null&&(this.closeToolbarAndReset(),this.render())})),this.toolbarScrollListenerAdded||(this.toolbarScrollListenerAdded=!0,window.addEventListener("scroll",()=>{Dt()!==null&&(this.closeToolbarAndReset(),this.render())},!0)),this.shadow.querySelectorAll(".wg__pagination").forEach(s=>{s.addEventListener("click",d=>{const c=d.target.closest(".wg__pagination-btn");if(!c||c.hasAttribute("disabled"))return;const l=c.dataset.action;let g=!1;l==="first"&&this.grid.currentPage!==1?(this.grid.currentPage=1,g=!0):l==="prev"&&this.grid.currentPage>1?(this.grid.currentPage--,g=!0):l==="next"&&this.grid.currentPage<this.grid.totalPages?(this.grid.currentPage++,g=!0):l==="last"&&this.grid.currentPage!==this.grid.totalPages&&(this.grid.currentPage=this.grid.totalPages,g=!0),g&&(this.grid.fireDataRequest("page"),this.render())});const n=s.querySelector(".wg__pagination-select");n&&n.addEventListener("change",()=>{const d=parseInt(n.value,10);d!==this.grid.pageSize&&(this.grid.pageSize=d,this.grid.currentPage=1,this.grid.fireDataRequest("pageSize"),this.render())})})}handleVirtualScroll(o){const i=this.grid.displayItems,r=this.grid.virtualScrollRowHeight,s=this.grid.virtualScrollBuffer,n=o.scrollTop,d=o.clientHeight;let a=Math.max(0,Math.floor(n/r)-s);const c=Math.ceil(d/r)+s*2;let l=Math.min(i.length,a+c);const g=this.grid.editingCell;if(g){const h=g.rowIndex;h<a&&(a=h),h>=l&&(l=h+1)}(a!==this.virtualScrollStart||l!==this.virtualScrollEnd)&&(this.virtualScrollStart=a,this.virtualScrollEnd=l,this.renderVirtualRows(o))}renderVirtualRows(o){const i=o.querySelector("tbody");if(!i)return;const r=this.grid.displayItems,s={startIndex:this.virtualScrollStart,endIndex:this.virtualScrollEnd,rowHeight:this.grid.virtualScrollRowHeight,totalItems:r.length},n=this.grid.focusedCell;if(i.innerHTML=ze(this,s),n){this.grid.setFocusedCell(n.rowIndex,n.colIndex);const d=i.querySelector(`td[data-row="${n.rowIndex}"][data-col="${n.colIndex}"]`);d&&(d.focus({preventScroll:!0}),W(this,null,n))}}handleInfiniteScroll(o){const i=o.scrollTop,r=o.scrollHeight,s=o.clientHeight,n=this.grid.infiniteScrollThreshold;r-(i+s)<=n&&(this.isLoadingMoreItems=!0,this.grid.fireDataRequest("loadMore"))}render(){var m;const o=this.shadow.querySelector(".wg"),i=(o==null?void 0:o.scrollTop)||0,r=(o==null?void 0:o.scrollLeft)||0,s=this.grid.focusedCell;o&&o.remove();const n=document.createElement("div");n.className=mi(this);const d=this.grid.paginationPosition.split("|").map(f=>f.trim()),a=this.grid.summaryPosition?this.grid.summaryPosition.split("|").map(f=>f.trim()):[],c=(f,b)=>{const v=d.filter(x=>b?x.startsWith("top-"):x.startsWith("bottom-")),_=a.filter(x=>b?x.startsWith("top-"):x.startsWith("bottom-")),S=v.length>0,y=_.length>0;return!S&&!y?"":y&&S&&this.grid.summaryInline?`<div class="wg__footer${b?" wg__footer--top":""}">
593
- ${ie(this,_[0])}
599
+ `;let Ue=!1;function Xi(){if(Ue)return;const t=document.createElement("style");t.id="wg-context-menu-styles",t.textContent=Wi,document.head.appendChild(t),Ue=!0}function Qi(t,e){const o=t.filter(r=>r.visible===void 0?!0:typeof r.visible=="function"?r.visible(e):r.visible);return o.length===0?"":`<div class="wg-context-menu">${o.map((r,s)=>{const n=typeof r.label=="function"?r.label(e):r.label,d=typeof r.icon=="function"?r.icon(e):r.icon,a=r.shortcut,c=typeof r.disabled=="function"?r.disabled(e):r.disabled,g=r.danger===!0,l=["wg-context-menu__item",c?"wg-context-menu__item--disabled":"",g?"wg-context-menu__item--danger":""].filter(Boolean).join(" "),h=r.dividerBefore&&s>0?'<div class="wg-context-menu__divider"></div>':"",u=d?`<span class="wg-context-menu__icon">${d}</span>`:"",p=a?`<span class="wg-context-menu__shortcut">${a}</span>`:"";return`${h}<div class="${l}" data-item-id="${r.id}" data-disabled="${c?"true":"false"}" data-shortcut="${a||""}">${u}<span class="wg-context-menu__label">${n}</span>${p}</div>`}).join("")}</div>`}function Gi(t,e,o,i,r,s,n){Xi();const d=Qi(i,r);if(!d)return null;const a=document.createElement("div");a.className="wg-context-menu-container",a.innerHTML=d,document.body.appendChild(a);const c=a.querySelector(".wg-context-menu");Dt({getBoundingClientRect:()=>({width:0,height:0,x:e,y:o,top:o,left:e,right:e,bottom:o})},c,{placement:"bottom-start",middleware:[It(4),kt({fallbackPlacements:["top-start","bottom-end","top-end"]}),Gt({padding:8})]}).then(({x:u,y:p})=>{Object.assign(c.style,{left:`${u}px`,top:`${p}px`})}),a.addEventListener("click",u=>{const p=u.target.closest(".wg-context-menu__item");if(p&&p.dataset.disabled!=="true"){const m=p.dataset.itemId||"";s(m)}});const l=u=>{a.contains(u.target)||(_t(a,l,h),n())},h=u=>{if(u.key==="Escape"){u.preventDefault(),_t(a,l,h),n();return}const p=u.key.toLowerCase(),m=a.querySelectorAll(".wg-context-menu__item");for(const b of m){const f=b.dataset.shortcut;if(b.dataset.disabled==="true"||!f)continue;if(f.toLowerCase()===p||f===u.key){u.preventDefault();const S=b.dataset.itemId||"";s(S),_t(a,l,h),n();return}}};return setTimeout(()=>{document.addEventListener("mousedown",l),document.addEventListener("keydown",h)},0),a._cleanup={handleOutsideClick:l,handleKeyDown:h},a}function _t(t,e,o){e&&document.removeEventListener("mousedown",e),o&&document.removeEventListener("keydown",o);const i=t._cleanup;i&&(i.handleOutsideClick&&document.removeEventListener("mousedown",i.handleOutsideClick),i.handleKeyDown&&document.removeEventListener("keydown",i.handleKeyDown)),t.remove()}function Ji(t){const e=t.split("+").map(i=>i.trim()),o={key:"",ctrl:!1,shift:!1,alt:!1,meta:!1};for(const i of e){const r=i.toLowerCase();r==="ctrl"||r==="control"?o.ctrl=!0:r==="shift"?o.shift=!0:r==="alt"?o.alt=!0:r==="meta"||r==="cmd"||r==="command"?o.meta=!0:o.key=i}return o}function Zi(t,e){if(e.ctrl!==t.ctrlKey||e.shift!==t.shiftKey||e.alt!==t.altKey||e.meta!==t.metaKey)return!1;const o=t.key.toLowerCase(),i=e.key.toLowerCase();return o===i}function tr(t){return t.split("+").map(e=>{const o=e.trim();return["ctrl","control","shift","alt","meta","cmd","command"].includes(o.toLowerCase())?o.charAt(0).toUpperCase()+o.slice(1).toLowerCase():o}).join("+")}class ce 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,"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,"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,"virtualScrollStart",0);w(this,"virtualScrollEnd",0);w(this,"scrollListenerAdded",!1);w(this,"isLoadingMoreItems",!1);w(this,"handlePaste",o=>{var c;if(!this.grid.isNavigateMode||this.grid.editingCell||!this.grid.focusedCell)return;const{rowIndex:i,colIndex:r}=this.grid.focusedCell,s=this.grid.columns[r],n=this.grid.displayItems[i];if(!s||!n||!this.grid.isCellEditable(s))return;o.preventDefault();let d=((c=o.clipboardData)==null?void 0:c.getData("text"))||"";if(s.beforePasteCallback){const g=s.beforePasteCallback(d,n);d=g!=null?String(g):""}const a=String(s.field);this.grid.commitEdit(i,a,d),this.render()});this.shadow=this.attachShadow({mode:"open"}),this.grid=new z,this.styleElement=document.createElement("style"),this.styleElement.textContent=ht,this.shadow.appendChild(this.styleElement),this.grid.requestUpdate=()=>this.requestUpdate()}get tooltipShowDelay(){return this._tooltipShowDelay}set tooltipShowDelay(o){this._tooltipShowDelay=o}get tooltipHideDelay(){return this._tooltipHideDelay}set tooltipHideDelay(o){this._tooltipHideDelay=o}connectedCallback(){this.render(),this.addEventListener("paste",this.handlePaste)}disconnectedCallback(){this.removeEventListener("paste",this.handlePaste),this.datepicker&&(this.datepicker.destroy(),this.datepicker=null),this.contextMenuElement&&(_t(this.contextMenuElement),this.contextMenuElement=null),Vt()}get items(){return this.grid.items}set items(o){this.grid.items=o,this.isLoadingMoreItems=!1}get columns(){return this.grid.columns}set columns(o){this.grid.columns=o}get sortable(){return this.grid.sortable}set sortable(o){this.grid.sortable=o}get filterable(){return this.grid.filterable}set filterable(o){this.grid.filterable=o}get pageable(){return this.grid.pageable}set pageable(o){this.grid.pageable=o}get pageSize(){return this.grid.pageSize}set pageSize(o){this.grid.pageSize=o}get pageSizes(){return this.grid.pageSizes}set pageSizes(o){this.grid.pageSizes=o}get striped(){return this.grid.striped}set striped(o){this.grid.striped=o}get hoverable(){return this.grid.hoverable}set hoverable(o){this.grid.hoverable=o}get editable(){return this.grid.editable}set editable(o){this.grid.editable=o}get editTrigger(){return this.grid.editTrigger}set editTrigger(o){this.grid.editTrigger=o}get editStartSelection(){return this.grid.editStartSelection}set editStartSelection(o){this.grid.editStartSelection=o}get mode(){return this.grid.mode}set mode(o){this.grid.mode=o}get dropdownToggleVisibility(){return this.grid.dropdownToggleVisibility}set dropdownToggleVisibility(o){this.grid.dropdownToggleVisibility=o}get dropdownShowOnFocus(){return this.grid.dropdownShowOnFocus}set dropdownShowOnFocus(o){this.grid.dropdownShowOnFocus=o}get openDropdownOnEnter(){return this.grid.openDropdownOnEnter}set openDropdownOnEnter(o){this.grid.openDropdownOnEnter=o}get checkboxAlwaysEditable(){return this.grid.checkboxAlwaysEditable}set checkboxAlwaysEditable(o){this.grid.checkboxAlwaysEditable=o}get showRowNumbers(){return this.grid.showRowNumbers}set showRowNumbers(o){this.grid.showRowNumbers=o}get invalidCells(){return this.grid.invalidCells}set invalidCells(o){this.grid.invalidCells=o}get showRowToolbar(){return this.grid.showRowToolbar}set showRowToolbar(o){this.grid.showRowToolbar=o}get rowToolbar(){return this.grid.rowToolbar}set rowToolbar(o){this.grid.rowToolbar=o}get toolbarVerticalAlign(){return this.grid.toolbarVerticalAlign}set toolbarVerticalAlign(o){this.grid.toolbarVerticalAlign=o}get toolbarHorizontalAlign(){return this.grid.toolbarHorizontalAlign}set toolbarHorizontalAlign(o){this.grid.toolbarHorizontalAlign=o}get toolbarAlign(){return this.grid.toolbarVerticalAlign}set toolbarAlign(o){this.grid.toolbarVerticalAlign=o}get toolbarTopPosition(){return this.grid.toolbarHorizontalAlign}set toolbarTopPosition(o){this.grid.toolbarHorizontalAlign=o}get toolbarTrigger(){return this.grid.toolbarTrigger}set toolbarTrigger(o){this.grid.toolbarTrigger=o}get toolbarPosition(){return this.grid.toolbarPosition}set toolbarPosition(o){this.grid.toolbarPosition=o}get contextMenu(){return this.grid.contextMenu}set contextMenu(o){this.grid.contextMenu=o}get rowShortcuts(){return this.grid.rowShortcuts}set rowShortcuts(o){this.grid.rowShortcuts=o}get showShortcutsHelp(){return this.grid.showShortcutsHelp}set showShortcutsHelp(o){this.grid.showShortcutsHelp=o}get shortcutsHelpPosition(){return this.grid.shortcutsHelpPosition}set shortcutsHelpPosition(o){this.grid.shortcutsHelpPosition=o}get shortcutsHelpContentCallback(){return this.grid.shortcutsHelpContentCallback}set shortcutsHelpContentCallback(o){this.grid.shortcutsHelpContentCallback=o}get showRowActions(){return this.grid.showRowActions}set showRowActions(o){this.grid.showRowActions=o}get rowActions(){return this.grid.rowActions}set rowActions(o){this.grid.rowActions=o}set onrowchange(o){this.grid.onrowchange=o}set onroweditstart(o){this.grid.onroweditstart=o}set onroweditcancel(o){this.grid.onroweditcancel=o}set onvalidationerror(o){this.grid.onvalidationerror=o}get validationTooltipCallback(){return this.grid.validationTooltipCallback}set validationTooltipCallback(o){this.grid.validationTooltipCallback=o}set ontoolbarclick(o){this.grid.ontoolbarclick=o}set onrowaction(o){this.grid.onrowaction=o}set oncontextmenuopen(o){this.grid.oncontextmenuopen=o}get ondatarequest(){return this.grid.ondatarequest}set ondatarequest(o){this.grid.ondatarequest=o}get onrowdelete(){return this.grid.onrowdelete}set onrowdelete(o){this.grid.onrowdelete=o}get sort(){return this.grid.sort}set sort(o){this.grid.sort=o}get sortMode(){return this.grid.sortMode}set sortMode(o){this.grid.sortMode=o}get currentPage(){return this.grid.currentPage}set currentPage(o){this.grid.currentPage=o}get totalItems(){return this.grid.totalItems}set totalItems(o){this.grid.totalItems=o}get showPagination(){return this.grid.showPagination}set showPagination(o){this.grid.showPagination=o}get paginationPosition(){return this.grid.paginationPosition}set paginationPosition(o){this.grid.paginationPosition=o}get paginationLabelsCallback(){return this.grid.paginationLabelsCallback}set paginationLabelsCallback(o){this.grid.paginationLabelsCallback=o}get paginationLayout(){return this.grid.paginationLayout}set paginationLayout(o){this.grid.paginationLayout=o}get summaryPosition(){return this.grid.summaryPosition}set summaryPosition(o){this.grid.summaryPosition=o}get summaryContentCallback(){return this.grid.summaryContentCallback}set summaryContentCallback(o){this.grid.summaryContentCallback=o}get customStylesCallback(){return this.grid.customStylesCallback}set customStylesCallback(o){this.grid.customStylesCallback=o,this.updateCustomStyles()}get rowClassCallback(){return this.grid.rowClassCallback}set rowClassCallback(o){this.grid.rowClassCallback=o}get summaryMetadata(){return this.grid.summaryMetadata}set summaryMetadata(o){this.grid.summaryMetadata=o}get summaryInline(){return this.grid.summaryInline}set summaryInline(o){this.grid.summaryInline=o}get virtualScroll(){return this.grid.virtualScroll}set virtualScroll(o){this.grid.virtualScroll=o}get virtualScrollThreshold(){return this.grid.virtualScrollThreshold}set virtualScrollThreshold(o){this.grid.virtualScrollThreshold=o}get virtualScrollRowHeight(){return this.grid.virtualScrollRowHeight}set virtualScrollRowHeight(o){this.grid.virtualScrollRowHeight=o}get virtualScrollBuffer(){return this.grid.virtualScrollBuffer}set virtualScrollBuffer(o){this.grid.virtualScrollBuffer=o}get infiniteScroll(){return this.grid.infiniteScroll}set infiniteScroll(o){this.grid.infiniteScroll=o}get infiniteScrollThreshold(){return this.grid.infiniteScrollThreshold}set infiniteScrollThreshold(o){this.grid.infiniteScrollThreshold=o}get hasMoreItems(){return this.grid.hasMoreItems}set hasMoreItems(o){this.grid.hasMoreItems=o}get displayItems(){return this.grid.displayItems}get totalPages(){return this.grid.totalPages}get isNavigateMode(){return this.grid.isNavigateMode}getRowDraft(o){return this.grid.getRowDraft(o)}hasRowDraft(o){return this.grid.hasRowDraft(o)}discardRowDraft(o){this.grid.discardRowDraft(o)}getDraftRowIndices(){return this.grid.getDraftRowIndices()}discardAllDrafts(){this.grid.discardAllDrafts()}isCellInvalid(o,i){return this.grid.isCellInvalid(o,i)}getCellValidationError(o,i){return this.grid.getCellValidationError(o,i)}focusCell(o,i){const r=this.grid.columns,s=this.grid.displayItems;o<0||o>=s.length||i<0||i>=r.length||(this.grid.setFocusedCell(o,i),requestAnimationFrame(()=>{E(this,o,i)}))}startEditing(o,i){const r=this.grid.columns;if(i<0||i>=r.length)return;const s=r[i],n=String(s.field);this.grid.startEdit(o,n)}escapeHtml(o){const i=document.createElement("div");return i.textContent=o,i.innerHTML}getCurrentEditingColumn(){const o=this.grid.editingCell;return o&&this.grid.columns.find(i=>String(i.field)===o.field)||null}getCurrentEditorOptions(){const o=this.getCurrentEditingColumn();return(o==null?void 0:o.editorOptions)||{}}moveFocusAfterCommit(o,i,r){Zt(this,o,i,r)}requestUpdate(){this.updatePending||(this.updatePending=!0,queueMicrotask(()=>{this.updatePending=!1,this.render()}))}updateCustomStyles(){const o=this.grid.customStylesCallback;if(o){const i=o();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(o,i,r){var g;if(!this.grid.isNavigateMode)return;const s=this.grid.columns,n=this.grid.displayItems,d=this.grid.getEditableColumns(),a=d.findIndex(l=>l.index===r);if((o.ctrlKey||o.metaKey)&&o.key==="c"){const l=s[r],h=n[i];if(l&&h){let u=this.grid.getCellRawValue(h,i,String(l.field));l.beforeCopyCallback&&(u=l.beforeCopyCallback(u,h));const p=u!=null?String(u):"";navigator.clipboard.writeText(p)}return}const c=this.grid.rowShortcuts;if(c&&c.length>0){const l=s[r],h=n[i];if(l&&h)for(const u of c){const p=Ji(u.key);if(Zi(o,p)){const m={row:h,rowIndex:i,colIndex:r,column:l,cellValue:this.grid.getCellRawValue(h,i,String(l.field))};if(!(typeof u.disabled=="function"?u.disabled(m):u.disabled===!0)){o.preventDefault(),u.action(m);return}}}}switch(o.key){case"ArrowUp":o.preventDefault(),i>0&&E(this,i-1,r);break;case"ArrowDown":o.preventDefault(),i<n.length-1&&E(this,i+1,r);break;case"ArrowLeft":o.preventDefault(),r>0&&E(this,i,r-1);break;case"ArrowRight":o.preventDefault(),r<s.length-1&&E(this,i,r+1);break;case"Tab":if(o.preventDefault(),o.shiftKey){if(a>0){const l=d[a-1].index;E(this,i,l)}else if(i>0){const l=d[d.length-1].index;E(this,i-1,l)}}else if(a>=0&&a<d.length-1){const l=d[a+1].index;E(this,i,l)}else if(a===-1&&d.length>0)E(this,i,d[0].index);else if(i<n.length-1){const l=d[0].index;E(this,i+1,l)}break;case"Home":if(o.preventDefault(),o.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const l=this.grid.focusedCell;this.grid.setFocusedCell(0,0),ut(this,0);const h=this.shadow.querySelector('td[data-row="0"][data-col="0"]');h&&(h.focus({preventScroll:!0}),W(this,l,{rowIndex:0,colIndex:0}))}else E(this,0,0);else E(this,i,0);break;case"End":if(o.preventDefault(),o.ctrlKey){const l=n.length-1,h=s.length-1;if(this.grid.shouldUseVirtualScroll()){const u=this.grid.focusedCell;this.grid.setFocusedCell(l,h),ut(this,l);const p=this.shadow.querySelector(`td[data-row="${l}"][data-col="${h}"]`);p&&(p.focus({preventScroll:!0}),W(this,u,{rowIndex:l,colIndex:h}))}else E(this,l,h)}else E(this,i,s.length-1);break;case"PageUp":if(o.preventDefault(),o.ctrlKey)if(this.grid.shouldUseVirtualScroll()){const l=this.grid.focusedCell;this.grid.setFocusedCell(0,r),ut(this,0);const h=this.shadow.querySelector(`td[data-row="0"][data-col="${r}"]`);h&&(h.focus({preventScroll:!0}),W(this,l,{rowIndex:0,colIndex:r}))}else E(this,0,r);else{const l=Math.max(0,i-10);if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(l,r),ut(this,l);const u=this.shadow.querySelector(`td[data-row="${l}"][data-col="${r}"]`);u&&(u.focus({preventScroll:!0}),W(this,h,{rowIndex:l,colIndex:r}))}else E(this,l,r)}break;case"PageDown":if(o.preventDefault(),o.ctrlKey){const l=n.length-1;if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(l,r),ut(this,l);const u=this.shadow.querySelector(`td[data-row="${l}"][data-col="${r}"]`);u&&(u.focus({preventScroll:!0}),W(this,h,{rowIndex:l,colIndex:r}))}else E(this,l,r)}else{const l=Math.min(n.length-1,i+10);if(this.grid.shouldUseVirtualScroll()){const h=this.grid.focusedCell;this.grid.setFocusedCell(l,r),ut(this,l);const u=this.shadow.querySelector(`td[data-row="${l}"][data-col="${r}"]`);u&&(u.focus({preventScroll:!0}),W(this,h,{rowIndex:l,colIndex:r}))}else E(this,l,r)}break;case"g":case"G":o.ctrlKey&&(o.preventDefault(),this.showGoToRowDialog(r));break;case"Enter":{o.preventDefault();const l=s[r];((l==null?void 0:l.editor)==="select"||(l==null?void 0:l.editor)==="combobox"||(l==null?void 0:l.editor)==="autocomplete")&&this.grid.getEffectiveOpenDropdownOnEnter(l)?(X(this,i,r),requestAnimationFrame(()=>{this.dropdownOpen||J(this)})):i<n.length-1&&E(this,i+1,r);break}case"F2":{o.preventDefault();const l=s[r],h=(l==null?void 0:l.editor)==="select"||(l==null?void 0:l.editor)==="combobox"||(l==null?void 0:l.editor)==="autocomplete",u=(l==null?void 0:l.editor)==="custom";X(this,i,r),h?requestAnimationFrame(()=>{this.dropdownOpen||J(this)}):u&&requestAnimationFrame(()=>{this.openCustomEditor(i,r)});break}case" ":{o.preventDefault();const l=s[r],h=(l==null?void 0:l.editor)==="checkbox",u=(l==null?void 0:l.editor)==="select"||(l==null?void 0:l.editor)==="combobox"||(l==null?void 0:l.editor)==="autocomplete",p=(l==null?void 0:l.editor)==="date",m=(l==null?void 0:l.editor)==="custom";h?Jo(this,i,r):u?(X(this,i,r),requestAnimationFrame(()=>{this.dropdownOpen||J(this)})):p?(X(this,i,r),requestAnimationFrame(()=>{var v;const b=(v=this.shadowRoot)==null?void 0:v.querySelector(`.wg__cell[data-row="${i}"][data-col="${r}"]`),f=b==null?void 0:b.querySelector(".wg__date-input"),_=b==null?void 0:b.querySelector(".wg__editor--date");f&&_&&this.openDatePicker(f,_)})):m&&(X(this,i,r),requestAnimationFrame(()=>{this.openCustomEditor(i,r)}));break}case"Escape":if(o.preventDefault(),this.grid.editingCell)q(this),this.grid.cancelEdit();else{const l=this.grid.focusedCell;this.grid.clearFocusedCell(),W(this,l,null),(g=o.target)==null||g.blur()}break;case"Delete":{o.preventDefault();const l=s[r],h=n[i];if(o.ctrlKey){if(h){const u={rowIndex:i,row:h};this.grid.onrowdelete&&this.grid.onrowdelete(u),this.dispatchEvent(new CustomEvent("rowdelete",{detail:u}))}}else l&&this.grid.isCellEditable(l)&&(this.grid.commitEdit(i,String(l.field),null),this.render(),requestAnimationFrame(()=>{const u=this.shadow.querySelector(`td[data-row="${i}"][data-col="${r}"]`);u==null||u.focus()}));break}default:if(o.key.length===1&&!o.ctrlKey&&!o.altKey&&!o.metaKey){const l=s[r];if((l==null?void 0:l.editor)==="number"&&!/[\d.\-]/.test(o.key))return;X(this,i,r,{initialSearchQuery:o.key}),o.preventDefault()}break}}handleEditorKeyDown(o,i){const r=parseInt(i.dataset.row||"0",10),s=i.dataset.field||"",n=this.grid.columns.find(g=>g.field===s),d=(n==null?void 0:n.editor)||"text",a=d==="select"||d==="combobox"||d==="autocomplete",c=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"];if(a&&!this.dropdownOpen&&c.includes(o.key)){o.preventDefault(),o.stopPropagation();const g=this.grid.columns.findIndex(f=>f.field===s),l=this.grid.columns.map((f,_)=>({index:_,column:f})).filter(f=>f.column.editable!==!1),h=l.findIndex(f=>f.index===g),u=this.grid.displayItems;let p=r,m=g,b=!1;switch(o.key){case"ArrowUp":r>0&&(p=r-1,b=!0);break;case"ArrowDown":r<u.length-1&&(p=r+1,b=!0);break;case"ArrowLeft":h>0&&(m=l[h-1].index,b=!0);break;case"ArrowRight":h<l.length-1&&(m=l[h+1].index,b=!0);break;case"PageUp":p=Math.max(0,r-10),b=!0;break;case"PageDown":p=Math.min(u.length-1,r+10),b=!0;break;case"Home":o.ctrlKey&&(p=0),m=0,b=!0;break;case"End":o.ctrlKey?(p=u.length-1,m=this.grid.columns.length-1):m=this.grid.columns.length-1,b=!0;break}b&&(q(this),this.grid.cancelEdit(),queueMicrotask(()=>{E(this,p,m)}));return}switch(o.key){case"ArrowDown":if(this.dropdownOpen){o.preventDefault(),o.stopPropagation();const g=this.getCurrentEditorOptions();let l=this.highlightedIndex+1;for(;l<this.dropdownOptions.length&&Ct(this.dropdownOptions[l],g);)l++;l<this.dropdownOptions.length&&(this.highlightedIndex=l,it(this),$e(this))}break;case"ArrowUp":if(this.dropdownOpen){o.preventDefault(),o.stopPropagation();const g=this.getCurrentEditorOptions();let l=this.highlightedIndex-1;for(;l>=0&&Ct(this.dropdownOptions[l],g);)l--;l>=0&&(this.highlightedIndex=l,it(this),$e(this))}break;case"Enter":if(this.datepicker)return;o.preventDefault(),o.stopPropagation(),this.dropdownOpen&&this.highlightedIndex>=0?Ee(this,this.highlightedIndex):a&&!this.dropdownOpen?J(this):(this.isCommittingFromKeyboard=!0,R(this),d==="date"&&i instanceof HTMLInputElement?this.commitDateEditor(i):zt(this,i),Zt(this,r,s,"down"));break;case"Tab":if(this.datepicker)return;if(o.preventDefault(),o.stopPropagation(),this.isCommittingFromKeyboard=!0,this.dropdownOpen&&this.highlightedIndex>=0&&a){const g=this.dropdownOptions[this.highlightedIndex],l=this.getCurrentEditorOptions();if(g&&!Ct(g,l)){const h=lt(g,l);this.grid.commitEdit(r,s,h)}R(this)}else R(this),d==="date"&&i instanceof HTMLInputElement?this.commitDateEditor(i):a||zt(this,i);Zt(this,r,s,o.shiftKey?"prev":"next");break;case"Escape":o.preventDefault(),o.stopPropagation(),this.dropdownOpen&&R(this),this.datepicker&&(this.datepicker.close(!0),this.datepicker=null),this.isCommittingFromKeyboard=!0,q(this),this.grid.cancelEdit(),ti(this,r,s);break;case"F2":o.preventDefault(),o.stopPropagation(),a&&!this.dropdownOpen&&J(this);break;case"Backspace":d==="select"&&(o.preventDefault(),o.stopPropagation(),this.filterText.length>0&&(this.filterText=this.filterText.slice(0,-1),Oe(this,n.editorOptions||{})));break;default:d==="select"&&o.key.length===1&&!o.ctrlKey&&!o.altKey&&!o.metaKey&&(o.preventDefault(),o.stopPropagation(),this.filterText+=o.key,Oe(this,n.editorOptions||{}));break}}attachEventListeners(){const o=this.shadow.querySelector(".wg__table");if(!o)return;o.addEventListener("focus",s=>{var d;const n=s.target;if(n.matches(".wg__cell")){const a=parseInt(n.dataset.row||"0",10),c=parseInt(n.dataset.col||"0",10);Wo(this,a,c)}if(n.matches(".wg__select-trigger, .wg__combobox-input, .wg__autocomplete-input")&&!this.justSelected&&!this.dropdownOpen){const a=n.dataset.field||"",c=this.grid.columns.find(h=>h.field===a),g=(c==null?void 0:c.editorOptions)||{};(((d=this.grid.editingCell)==null?void 0:d.initialSearchQuery)!==void 0||g.showOnFocus!==!1)&&J(this)}},!0),o.addEventListener("keydown",s=>{const n=s.target;if(n.matches(".wg__editor, .wg__combobox-input, .wg__autocomplete-input, .wg__date-input")){this.handleEditorKeyDown(s,n);return}if(n.matches(".wg__cell")){const d=parseInt(n.dataset.row||"0",10),a=parseInt(n.dataset.col||"0",10);this.handleCellKeyDown(s,d,a)}}),o.addEventListener("focusout",s=>{Xo(this,s)}),o.addEventListener("dblclick",s=>{s.preventDefault();const d=s.target.closest(".wg__cell");if(d){const a=parseInt(d.dataset.row||"0",10),c=parseInt(d.dataset.col||"0",10),g=this.grid.columns[c];if(g){const l=g.editTrigger||this.grid.editTrigger;if(l==="dblclick"||l==="navigate"){const h=Jt(s,d);X(this,a,c,{cursorPosition:h??void 0});const u=g.editor;u==="select"||u==="combobox"||u==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||J(this)}):u==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(a,c)})}}}}),o.addEventListener("click",s=>{const d=s.target.closest(".wg__cell");if(d&&!d.classList.contains("wg__cell--editing")){const a=parseInt(d.dataset.row||"0",10),c=parseInt(d.dataset.col||"0",10),g=this.grid.columns[c];if(g&&(g.editTrigger||this.grid.editTrigger)==="click"){s.preventDefault();const h=Jt(s,d);X(this,a,c,{cursorPosition:h??void 0});const u=g.editor;u==="select"||u==="combobox"||u==="autocomplete"?requestAnimationFrame(()=>{this.dropdownOpen||J(this)}):u==="custom"&&requestAnimationFrame(()=>{this.openCustomEditor(a,c)})}}}),o.addEventListener("mousedown",s=>{const n=s.target;if(n.closest(".wg__date-trigger")){s.preventDefault(),s.stopPropagation();const a=n.closest(".wg__cell-date-display"),c=n.closest(".wg__editor--date");if(c){const g=c.querySelector(".wg__date-input");g&&this.openDatePicker(g,c)}else if(a){const g=parseInt(a.dataset.row||"0",10),l=a.dataset.field||"",h=this.grid.columns.findIndex(u=>String(u.field)===l);h>=0&&(this.isTransitioningCells=!0,this.grid.editingCell&&(R(this),q(this),this.grid.cancelEdit()),X(this,g,h),requestAnimationFrame(()=>{var b;this.isTransitioningCells=!1;const u=(b=this.shadowRoot)==null?void 0:b.querySelector(`.wg__cell[data-row="${g}"][data-field="${l}"]`),p=u==null?void 0:u.querySelector(".wg__date-input"),m=u==null?void 0:u.querySelector(".wg__editor--date");p&&m&&this.openDatePicker(p,m)}))}return}if(this.dropdownOpen||this.grid.editingCell){const a=n.closest(".wg__cell");if(a&&!n.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete, .wg__editor--date")){const c=parseInt(a.dataset.row||"0",10),g=parseInt(a.dataset.col||"0",10),l=this.grid.editingCell,h=n.matches(".wg__combobox-toggle, .wg__select-toggle, .wg__date-trigger");if(l&&!h){const u=this.grid.columns.findIndex(p=>String(p.field)===l.field);if(c!==l.rowIndex||g!==u){s.preventDefault(),this.isTransitioningCells=!0,R(this),q(this),this.grid.cancelEdit();const p=this.grid.columns[g],m=(p==null?void 0:p.editTrigger)||this.grid.editTrigger,f=s.clientX;requestAnimationFrame(()=>{if(this.isTransitioningCells=!1,m==="click"&&p&&this.grid.isCellEditable(p)){const _=this.shadow.querySelector(`td[data-row="${c}"][data-col="${g}"]`),v=_?Jt({clientX:f},_):void 0;X(this,c,g,{cursorPosition:v??void 0})}else E(this,c,g)});return}}}}if(n.matches(".wg__combobox-toggle, .wg__select-toggle")){s.preventDefault(),s.stopPropagation();const a=n.closest(".wg__cell-dropdown-display");if(n.closest(".wg__editor--select, .wg__editor--combobox, .wg__editor--autocomplete"))Ae(this);else if(a){const g=parseInt(a.dataset.row||"0",10),l=a.dataset.field||"",h=this.grid.columns.findIndex(u=>String(u.field)===l);h>=0&&(this.isTransitioningCells=!0,this.grid.editingCell&&(R(this),q(this),this.grid.cancelEdit()),X(this,g,h),requestAnimationFrame(()=>{this.isTransitioningCells=!1,this.dropdownOpen||J(this)}))}}if(n.matches(".wg__cell-dropdown-display")){s.preventDefault(),s.stopPropagation();const a=n.closest(".wg__cell-dropdown-display");if(a){const c=parseInt(a.dataset.row||"0",10),g=a.dataset.field||"",l=this.grid.columns.findIndex(h=>String(h.field)===g);l>=0&&(this.isTransitioningCells=!0,this.grid.editingCell&&(R(this),q(this),this.grid.cancelEdit()),X(this,c,l),requestAnimationFrame(()=>{this.isTransitioningCells=!1,this.dropdownOpen||J(this)}))}}}),o.addEventListener("click",s=>{s.target.matches(".wg__select-trigger, .wg__select-value")&&(s.preventDefault(),s.stopPropagation(),Ae(this))}),o.addEventListener("click",s=>{const n=s,a=n.target.closest(".wg__header--sortable");if(a){const c=a.dataset.field;if(!c)return;const g=[...this.grid.sort],l=g.findIndex(u=>u.column===c);(n.ctrlKey||n.metaKey)&&this.grid.sortMode==="multi"?l>=0?g[l].direction==="asc"?g[l]={column:c,direction:"desc"}:g.splice(l,1):g.push({column:c,direction:"asc"}):l>=0&&g.length===1?g[0].direction==="asc"?g[0]={column:c,direction:"desc"}:g.length=0:(g.length=0,g.push({column:c,direction:"asc"})),this.grid.sort=g,this.grid.pageable&&(this.grid.currentPage=1),this.grid.fireDataRequest("sort"),this.render()}}),o.addEventListener("contextmenu",s=>{this.handleContextMenu(s)}),o.addEventListener("change",s=>{const n=s.target;n.matches(".wg__editor--checkbox")&&Go(this,n)}),o.addEventListener("input",s=>{const n=s.target;n.matches(".wg__combobox-input")?qo(this,s):n.matches(".wg__autocomplete-input")&&Yo(this,s)}),o.addEventListener("blur",s=>{const n=s.target;if(n.matches(".wg__editor--text, .wg__editor--number")&&Zo(this,n),n.matches(".wg__date-input")&&!this.datepicker&&!this.isCommittingFromKeyboard&&!this.isTransitioningCells&&this.commitDateEditor(n),n.matches(".wg__select-trigger")&&!this.isCommittingFromKeyboard&&!this.isTransitioningCells&&!this.dropdownOpen&&!this.isOpeningDropdown&&(R(this),q(this),this.grid.cancelEdit()),n.matches(".wg__combobox-input, .wg__autocomplete-input")){if(this.isCommittingFromKeyboard||this.isTransitioningCells)return;if(R(this),this.grid.editingCell){const d=n,a=this.getCurrentEditingColumn();if(a){const c=a.editorOptions||{},l=(c.options||c.initialOptions||[]).find(h=>yt(h,c).toLowerCase()===d.value.toLowerCase());l?this.grid.commitEdit(this.grid.editingCell.rowIndex,this.grid.editingCell.field,lt(l,c)):this.grid.commitEdit(this.grid.editingCell.rowIndex,this.grid.editingCell.field,d.value)}}}},!0);const i=this.shadow.querySelector(".wg");i&&i.addEventListener("scroll",()=>{this.dropdownOpen&&!this.isTransitioningCells&&!this.isOpeningDropdown&&(R(this),q(this),this.grid.cancelEdit()),this.grid.shouldUseVirtualScroll()&&this.handleVirtualScroll(i),this.grid.infiniteScroll&&this.grid.hasMoreItems&&!this.isLoadingMoreItems&&this.handleInfiniteScroll(i),Tt()!==null&&(Le(this,this.grid.displayItems),this.renderConnector())}),this.wheelListenerAdded||(this.wheelListenerAdded=!0,window.addEventListener("scroll",()=>{this.dropdownOpen&&!this.isTransitioningCells&&(R(this),q(this),this.grid.cancelEdit())},{passive:!0,capture:!0})),o.addEventListener("mouseenter",s=>{const n=s.target,d=n.closest("[data-tooltip-html]");if(d){const c=d.getAttribute("data-tooltip-html");He(this,d,c,this._tooltipShowDelay,!0);return}const a=n.closest("[data-tooltip]");if(a){const c=a.getAttribute("data-tooltip");He(this,a,c,this._tooltipShowDelay,!1)}},!0),o.addEventListener("mouseleave",s=>{const n=s,d=n.target,a=n.relatedTarget,c=d.closest("[data-tooltip], [data-tooltip-html]");c&&(a==null?void 0:a.closest("[data-tooltip], [data-tooltip-html]"))===c||c&&Uo(this,this._tooltipHideDelay)},!0),o.addEventListener("click",s=>{const d=s.target.closest(".wg__toolbar-trigger");if(d&&this.grid.toolbarTrigger==="button"){s.preventDefault(),s.stopPropagation();const a=parseInt(d.dataset.toolbarTrigger||"0",10),c=o.querySelector(`tr[data-row-index="${a}"]`);c&&(ee(a)?(this.closeToolbarAndReset(),this.render()):this.showToolbarForRow(c,a))}}),o.addEventListener("mouseenter",s=>{if(this.grid.toolbarTrigger!=="hover")return;this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null);const n=s,a=n.target.closest(".wg__row");if(a){const c=parseInt(a.dataset.rowIndex||"0",10);ee(c)||this.showToolbarForRow(a,c,n.clientX)}},!0),o.addEventListener("mouseleave",s=>{if(this.grid.toolbarTrigger!=="hover")return;if(s.target.closest(".wg__row")){if(this.toolbarMoveInProgress)return;this.toolbarHideTimeout&&clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=setTimeout(()=>{const c=this.shadow.querySelector(".wg__toolbar-container"),g=c==null?void 0:c.matches(":hover"),l=o.matches(":hover");!g&&!l&&(this.closeToolbarAndReset(),this.grid.editingCell||this.render())},150)}},!0),o.addEventListener("click",s=>{if(this.grid.toolbarTrigger!=="click")return;const n=s,d=n.target,a=d.closest(".wg__row");if(a&&!d.closest(".wg__cell--editing")){const c=parseInt(a.dataset.rowIndex||"0",10);ee(c)?(this.closeToolbarAndReset(),this.render()):this.showToolbarForRow(a,c,n.clientX)}}),this.toolbarOutsideClickAdded||(this.toolbarOutsideClickAdded=!0,document.addEventListener("click",s=>{if(!fi(this.shadow))return;const n=s.composedPath(),d=n.some(g=>{var l;return(l=g.classList)==null?void 0:l.contains("wg__toolbar-container")}),a=n.some(g=>{var l;return(l=g.classList)==null?void 0:l.contains("wg__toolbar-trigger")});d||a||n.includes(this)&&(this.grid.toolbarTrigger==="hover"||this.grid.toolbarTrigger==="click")||Tt()!==null&&(this.closeToolbarAndReset(),this.render())})),this.toolbarScrollListenerAdded||(this.toolbarScrollListenerAdded=!0,window.addEventListener("scroll",()=>{Tt()!==null&&(this.closeToolbarAndReset(),this.render())},!0)),this.shadow.querySelectorAll(".wg__pagination").forEach(s=>{s.addEventListener("click",d=>{const c=d.target.closest(".wg__pagination-btn");if(!c||c.hasAttribute("disabled"))return;const g=c.dataset.action;let l=!1;g==="first"&&this.grid.currentPage!==1?(this.grid.currentPage=1,l=!0):g==="prev"&&this.grid.currentPage>1?(this.grid.currentPage--,l=!0):g==="next"&&this.grid.currentPage<this.grid.totalPages?(this.grid.currentPage++,l=!0):g==="last"&&this.grid.currentPage!==this.grid.totalPages&&(this.grid.currentPage=this.grid.totalPages,l=!0),l&&(this.grid.fireDataRequest("page"),this.render())});const n=s.querySelector(".wg__pagination-select");n&&n.addEventListener("change",()=>{const d=parseInt(n.value,10);d!==this.grid.pageSize&&(this.grid.pageSize=d,this.grid.currentPage=1,this.grid.fireDataRequest("pageSize"),this.render())})})}handleVirtualScroll(o){const i=this.grid.displayItems,r=this.grid.virtualScrollRowHeight,s=this.grid.virtualScrollBuffer,n=o.scrollTop,d=o.clientHeight;let a=Math.max(0,Math.floor(n/r)-s);const c=Math.ceil(d/r)+s*2;let g=Math.min(i.length,a+c);const l=this.grid.editingCell;if(l){const h=l.rowIndex;h<a&&(a=h),h>=g&&(g=h+1)}(a!==this.virtualScrollStart||g!==this.virtualScrollEnd)&&(this.virtualScrollStart=a,this.virtualScrollEnd=g,this.renderVirtualRows(o))}renderVirtualRows(o){const i=o.querySelector("tbody");if(!i)return;const r=this.grid.displayItems,s={startIndex:this.virtualScrollStart,endIndex:this.virtualScrollEnd,rowHeight:this.grid.virtualScrollRowHeight,totalItems:r.length},n=this.grid.focusedCell;if(i.innerHTML=ze(this,s),n){this.grid.setFocusedCell(n.rowIndex,n.colIndex);const d=i.querySelector(`td[data-row="${n.rowIndex}"][data-col="${n.colIndex}"]`);d&&(d.focus({preventScroll:!0}),W(this,null,n))}}handleInfiniteScroll(o){const i=o.scrollTop,r=o.scrollHeight,s=o.clientHeight,n=this.grid.infiniteScrollThreshold;r-(i+s)<=n&&(this.isLoadingMoreItems=!0,this.grid.fireDataRequest("loadMore"))}renderShortcutsHelpIcon(){var n,d,a;if(!this.grid.showShortcutsHelp||!((n=this.grid.rowShortcuts)!=null&&n.length))return"";const i=this.grid.shortcutsHelpPosition==="top-left"?"wg__shortcuts-help--left":"",r=this.grid.rowShortcuts.map(c=>`<div class="wg__shortcuts-help-item">
600
+ <span class="wg__shortcuts-help-key">${tr(c.key)}</span>
601
+ <span class="wg__shortcuts-help-label">${c.label}</span>
602
+ </div>`).join(""),s=((a=(d=this.grid).shortcutsHelpContentCallback)==null?void 0:a.call(d))||"";return`
603
+ <div class="wg__shortcuts-help ${i}">
604
+ <button class="wg__shortcuts-help-icon" type="button" title="Keyboard shortcuts">
605
+ <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">
606
+ <circle cx="12" cy="12" r="10"></circle>
607
+ <path d="M12 16v-4"></path>
608
+ <path d="M12 8h.01"></path>
609
+ </svg>
610
+ </button>
611
+ <div class="wg__shortcuts-help-overlay">
612
+ ${s?`<div class="wg__shortcuts-help-custom">${s}</div>`:""}
613
+ <div class="wg__shortcuts-help-title">Keyboard Shortcuts</div>
614
+ <div class="wg__shortcuts-help-list">
615
+ ${r}
616
+ </div>
617
+ </div>
618
+ </div>
619
+ `}render(){var b;const o=this.shadow.querySelector(".wg"),i=(o==null?void 0:o.scrollTop)||0,r=(o==null?void 0:o.scrollLeft)||0,s=this.grid.focusedCell;o&&o.remove();const n=document.createElement("div");n.className=mi(this);const d=this.grid.paginationPosition.split("|").map(f=>f.trim()),a=this.grid.summaryPosition?this.grid.summaryPosition.split("|").map(f=>f.trim()):[],c=(f,_)=>{const v=d.filter(y=>_?y.startsWith("top-"):y.startsWith("bottom-")),S=a.filter(y=>_?y.startsWith("top-"):y.startsWith("bottom-")),C=v.length>0,x=S.length>0;return!C&&!x?"":x&&C&&this.grid.summaryInline?`<div class="wg__footer${_?" wg__footer--top":""}">
620
+ ${ie(this,S[0])}
594
621
  ${oe(this,v[0])}
595
- </div>`:[...new Set([...v,..._])].map(x=>{const C=v.includes(x),T=_.includes(x);return T&&C?`<div class="wg__footer${b?" wg__footer--top":""}">
596
- ${ie(this,x)}
597
- ${oe(this,x)}
598
- </div>`:T?ie(this,x):oe(this,x)}).join("")},l=c(d,!0),g=c(d,!1),h=this.grid.shouldUseVirtualScroll();let u;if(h){const f=this.grid.displayItems,b=this.grid.virtualScrollRowHeight,v=this.grid.virtualScrollBuffer,_=(o==null?void 0:o.clientHeight)||400,S=Math.max(0,Math.floor(i/b)-v),y=Math.ceil(_/b)+v*2,D=Math.min(f.length,S+y);this.virtualScrollStart=S,this.virtualScrollEnd=D;const x={startIndex:S,endIndex:D,rowHeight:b,totalItems:f.length};u=ze(this,x)}else u=vi(this);h&&n.classList.add("wg--virtual-scroll");const p=`
599
- ${l}
622
+ </div>`:[...new Set([...v,...S])].map(y=>{const T=v.includes(y),k=S.includes(y);return k&&T?`<div class="wg__footer${_?" wg__footer--top":""}">
623
+ ${ie(this,y)}
624
+ ${oe(this,y)}
625
+ </div>`:k?ie(this,y):oe(this,y)}).join("")},g=c(d,!0),l=c(d,!1),h=this.grid.shouldUseVirtualScroll();let u;if(h){const f=this.grid.displayItems,_=this.grid.virtualScrollRowHeight,v=this.grid.virtualScrollBuffer,S=(o==null?void 0:o.clientHeight)||400,C=Math.max(0,Math.floor(i/_)-v),x=Math.ceil(S/_)+v*2,D=Math.min(f.length,C+x);this.virtualScrollStart=C,this.virtualScrollEnd=D;const y={startIndex:C,endIndex:D,rowHeight:_,totalItems:f.length};u=ze(this,y)}else u=vi(this);h&&n.classList.add("wg--virtual-scroll");const m=`
626
+ ${this.renderShortcutsHelpIcon()}
627
+ ${g}
600
628
  <table class="wg__table">
601
629
  <thead>
602
630
  ${bi(this)}
@@ -605,8 +633,8 @@
605
633
  ${u}
606
634
  </tbody>
607
635
  </table>
608
- ${g}
609
- `;if(n.innerHTML=p,this.shadow.appendChild(n),h){const f=Math.max(0,this.grid.displayItems.length*this.grid.virtualScrollRowHeight-n.clientHeight);n.scrollTop=Math.min(i,f)}else n.scrollTop=i;if(n.scrollLeft=r,this.attachEventListeners(),this.grid.editingCell){let f=this.shadow.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__select-trigger, .wg__date-input");if(f||(f=this.shadow.querySelector(".wg__editor")),f&&(f.focus(),f instanceof HTMLInputElement&&f.type==="text")){const b=this.grid.editingCell.cursorPosition,v=this.getCurrentEditingColumn(),_=((m=v==null?void 0:v.editorOptions)==null?void 0:m.editStartSelection)||this.grid.editStartSelection;if(this.grid.editingCell.initialSearchQuery!==void 0){const S=f.value.length;f.setSelectionRange(S,S)}else switch(_){case"mousePosition":if(b!==void 0){const S=Math.min(b,f.value.length);f.setSelectionRange(S,S)}else f.setSelectionRange(f.value.length,f.value.length);break;case"cursorAtStart":f.setSelectionRange(0,0);break;case"cursorAtEnd":f.setSelectionRange(f.value.length,f.value.length);break;case"selectAll":default:f.select();break}}}else if(s&&!this.grid.editingCell){const f=n.querySelector(`td[data-row="${s.rowIndex}"][data-col="${s.colIndex}"]`);f&&setTimeout(()=>f.focus(),0)}h&&requestAnimationFrame(()=>{n.style.pointerEvents="none",requestAnimationFrame(()=>{n.style.pointerEvents=""})}),this.renderConnector()}renderConnector(){const o=this.shadow.querySelector(".wg__connector");o&&o.remove();const i=wi();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 s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",i.path),s.setAttribute("stroke","var(--wg-accent-color, #0078d4)"),s.setAttribute("stroke-width","2"),s.setAttribute("fill","none"),r.appendChild(s);const n=document.createElementNS("http://www.w3.org/2000/svg","polygon"),d=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";n.setAttribute("points",d),n.setAttribute("fill","var(--wg-accent-color, #0078d4)"),n.setAttribute("transform",`translate(${i.arrowPos.x}, ${i.arrowPos.y})`),r.appendChild(n),this.shadow.appendChild(r)}openDatePicker(o,i){this.datepicker&&(this.datepicker.close(!0),this.datepicker=null);const r=o.dataset.dateFormat||"YYYY-MM-DD",s=o.dataset.minDate,n=o.dataset.maxDate,d=o.dataset.dateValue||"";this.datepicker=new de({dateFormat:r,minDate:s||void 0,maxDate:n||void 0,onSelect:(a,c)=>{this.handleDatePickerSelect(o,a,c)},onClose:()=>{this.datepicker=null,q(this),this.grid.cancelEdit()}}),this.datepicker.open(i,d||null)}handleDatePickerSelect(o,i,r){const s=o.dataset.dateFormat||"YYYY-MM-DD",n=re(s);o.value=Ve(i,n),o.dataset.dateValue=ne(i),this.isCommittingFromKeyboard=!0,this.commitDateEditor(o);const d=parseInt(o.dataset.row||"0",10),a=o.dataset.field||"";this.moveFocusAfterCommit(d,a,r||"down")}commitDateEditor(o){if(!this.grid.editingCell)return;const i=parseInt(o.dataset.row||"0",10),r=o.dataset.field||"",s=o.dataset.outputFormat||"iso",n=o.dataset.dateFormat||"YYYY-MM-DD",d=re(n),a=o.value?this.parseDateInput(o.value,d):null;let c=null;if(a)switch(s){case"date":c=a;break;case"timestamp":c=a.getTime();break;case"iso":default:c=ne(a);break}this.grid.commitEdit(i,r,c)}parseDateInput(o,i){if(!o)return null;const r=o.split(i.separator);let s=null,n=null,d=null;if(r.forEach((c,l)=>{var h,u,p;if(!c)return;const g=parseInt(c,10);((h=i.parts.year)==null?void 0:h.index)===l?s=g<100?g+2e3:g:((u=i.parts.month)==null?void 0:u.index)===l?n=g:((p=i.parts.day)==null?void 0:p.index)===l&&(d=g)}),s===null||n===null||d===null)return null;const a=new Date(s,n-1,d);return a.getMonth()!==n-1||a.getDate()!==d?null:a}showGoToRowDialog(o){const i=this.grid.displayItems;if(i.length===0)return;const r=document.createElement("div");r.className="wg__goto-overlay",r.innerHTML=`
636
+ ${l}
637
+ `;if(n.innerHTML=m,this.shadow.appendChild(n),h){const f=Math.max(0,this.grid.displayItems.length*this.grid.virtualScrollRowHeight-n.clientHeight);n.scrollTop=Math.min(i,f)}else n.scrollTop=i;if(n.scrollLeft=r,this.attachEventListeners(),this.grid.editingCell){let f=this.shadow.querySelector(".wg__combobox-input, .wg__autocomplete-input, .wg__select-trigger, .wg__date-input");if(f||(f=this.shadow.querySelector(".wg__editor")),f&&(f.focus(),f instanceof HTMLInputElement&&f.type==="text")){const _=this.grid.editingCell.cursorPosition,v=this.getCurrentEditingColumn(),S=((b=v==null?void 0:v.editorOptions)==null?void 0:b.editStartSelection)||this.grid.editStartSelection;if(this.grid.editingCell.initialSearchQuery!==void 0){const C=f.value.length;f.setSelectionRange(C,C)}else switch(S){case"mousePosition":if(_!==void 0){const C=Math.min(_,f.value.length);f.setSelectionRange(C,C)}else f.setSelectionRange(f.value.length,f.value.length);break;case"cursorAtStart":f.setSelectionRange(0,0);break;case"cursorAtEnd":f.setSelectionRange(f.value.length,f.value.length);break;case"selectAll":default:f.select();break}}}else if(s&&!this.grid.editingCell){const f=n.querySelector(`td[data-row="${s.rowIndex}"][data-col="${s.colIndex}"]`);f&&setTimeout(()=>f.focus(),0)}h&&requestAnimationFrame(()=>{n.style.pointerEvents="none",requestAnimationFrame(()=>{n.style.pointerEvents=""})}),this.renderConnector()}renderConnector(){const o=this.shadow.querySelector(".wg__connector");o&&o.remove();const i=wi();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 s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",i.path),s.setAttribute("stroke","var(--wg-accent-color, #0078d4)"),s.setAttribute("stroke-width","2"),s.setAttribute("fill","none"),r.appendChild(s);const n=document.createElementNS("http://www.w3.org/2000/svg","polygon"),d=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";n.setAttribute("points",d),n.setAttribute("fill","var(--wg-accent-color, #0078d4)"),n.setAttribute("transform",`translate(${i.arrowPos.x}, ${i.arrowPos.y})`),r.appendChild(n),this.shadow.appendChild(r)}openDatePicker(o,i){this.datepicker&&(this.datepicker.close(!0),this.datepicker=null);const r=o.dataset.dateFormat||"YYYY-MM-DD",s=o.dataset.minDate,n=o.dataset.maxDate,d=o.dataset.dateValue||"";this.datepicker=new de({dateFormat:r,minDate:s||void 0,maxDate:n||void 0,onSelect:(a,c)=>{this.handleDatePickerSelect(o,a,c)},onClose:()=>{this.datepicker=null,q(this),this.grid.cancelEdit()}}),this.datepicker.open(i,d||null)}handleDatePickerSelect(o,i,r){const s=o.dataset.dateFormat||"YYYY-MM-DD",n=re(s);o.value=Fe(i,n),o.dataset.dateValue=ne(i),this.datepicker=null,this.isCommittingFromKeyboard=!0,this.commitDateEditor(o);const d=parseInt(o.dataset.row||"0",10),a=o.dataset.field||"";this.moveFocusAfterCommit(d,a,r||"down")}commitDateEditor(o){if(!this.grid.editingCell)return;const i=parseInt(o.dataset.row||"0",10),r=o.dataset.field||"",s=o.dataset.outputFormat||"iso",n=o.dataset.dateFormat||"YYYY-MM-DD",d=re(n),a=o.value?this.parseDateInput(o.value,d):null;let c=null;if(a)switch(s){case"date":c=a;break;case"timestamp":c=a.getTime();break;case"iso":default:c=ne(a);break}this.grid.commitEdit(i,r,c)}parseDateInput(o,i){if(!o)return null;const r=o.split(i.separator);let s=null,n=null,d=null;if(r.forEach((c,g)=>{var h,u,p;if(!c)return;const l=parseInt(c,10);((h=i.parts.year)==null?void 0:h.index)===g?s=l<100?l+2e3:l:((u=i.parts.month)==null?void 0:u.index)===g?n=l:((p=i.parts.day)==null?void 0:p.index)===g&&(d=l)}),s===null||n===null||d===null)return null;const a=new Date(s,n-1,d);return a.getMonth()!==n-1||a.getDate()!==d?null:a}showGoToRowDialog(o){const i=this.grid.displayItems;if(i.length===0)return;const r=document.createElement("div");r.className="wg__goto-overlay",r.innerHTML=`
610
638
  <div class="wg__goto-dialog">
611
639
  <label class="wg__goto-label">Go to row (1-${i.length}):</label>
612
640
  <input type="number" class="wg__goto-input" min="1" max="${i.length}" value="1" />
@@ -615,4 +643,4 @@
615
643
  <button type="button" class="wg__goto-btn wg__goto-btn--go">Go</button>
616
644
  </div>
617
645
  </div>
618
- `;const s=r.querySelector(".wg__goto-input"),n=r.querySelector(".wg__goto-btn--go"),d=r.querySelector(".wg__goto-btn--cancel"),a=()=>{r.remove()},c=()=>{const l=parseInt(s.value,10);if(isNaN(l)||l<1||l>i.length){s.focus(),s.select();return}a();const g=l-1,h=this.grid.focusedCell;if(this.grid.setFocusedCell(g,o),this.grid.shouldUseVirtualScroll())ut(this,g),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const u=this.shadow.querySelector(`td[data-row="${g}"][data-col="${o}"]`);u==null||u.focus()})});else{const u=this.shadow.querySelector(`td[data-row="${g}"][data-col="${o}"]`);u&&(u.scrollIntoView({block:"nearest",behavior:"auto"}),u.focus(),W(this,h,{rowIndex:g,colIndex:o}))}};n.addEventListener("click",c),d.addEventListener("click",a),r.addEventListener("click",l=>{l.target===r&&a()}),s.addEventListener("keydown",l=>{l.key==="Enter"?(l.preventDefault(),c()):l.key==="Escape"&&(l.preventDefault(),a())}),this.shadow.appendChild(r),s.focus(),s.select()}openCustomEditor(o,i){const r=this.grid.columns[i];if(!r||r.editor!=="custom"||!r.cellEditCallback)return;const s=String(r.field),n=this.grid.displayItems[o];if(!n)return;const a={value:this.grid.getCellRawValue(n,o,s),row:n,rowIndex:o,field:s,commit:c=>{this.grid.commitEdit(o,s,c),q(this),requestAnimationFrame(()=>{E(this,o,i)})},cancel:()=>{q(this),this.grid.cancelEdit(),requestAnimationFrame(()=>{E(this,o,i)})}};r.cellEditCallback(a)}handleContextMenu(o){const i=this.grid.contextMenu;if(!i||i.length===0)return;const s=o.target.closest(".wg__cell");if(!s)return;o.preventDefault(),this.contextMenuElement&&(Et(this.contextMenuElement),this.contextMenuElement=null);const n=parseInt(s.dataset.row||"0",10),d=parseInt(s.dataset.col||"0",10),a=this.grid.columns[d];if(!a)return;const c=this.grid.displayItems[n];if(!c)return;const l=String(a.field),g=this.grid.getCellRawValue(c,n,l),h={row:c,rowIndex:n,colIndex:d,column:a,cellValue:g};this.grid.oncontextmenuopen&&this.grid.oncontextmenuopen(h),this.contextMenuElement=Gi(this,o.clientX,o.clientY,i,h,u=>{const p=i.find(m=>m.id===u);p!=null&&p.onclick&&p.onclick(h),this.contextMenuElement&&(Et(this.contextMenuElement),this.contextMenuElement=null)},()=>{this.contextMenuElement=null})}showToolbarForRow(o,i,r){if(!this.grid.showRowToolbar||!this.grid.rowToolbar.length)return;const s=gi(this.grid.rowToolbar),n=this.grid.displayItems[i];if(!n)return;if(this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),pi(this,o,i,s,n,a=>{this.handleToolbarItemClick(a,i,n)},r),this.renderConnector(),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 c=this.shadow.querySelector(".wg__table"),l=c==null?void 0:c.matches(":hover"),g=a.matches(":hover");!l&&!g&&(this.closeToolbarAndReset(),this.render())},150))}))}const d=this.shadow.querySelector(`[data-toolbar-trigger="${i}"]`);d&&(this.shadow.querySelectorAll(".wg__toolbar-trigger--active").forEach(a=>{a.classList.remove("wg__toolbar-trigger--active")}),d.classList.add("wg__toolbar-trigger--active"))}closeToolbarAndReset(){this.toolbarMoveInProgress=!1,this.toolbarHovered=!1,this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),Ft()}handleToolbarItemClick(o,i,r){const s=this.grid.displayItems.findIndex(d=>d===r);if(s===-1){this.closeToolbarAndReset(),this.render();return}const n=o.id==="moveUp"||o.id==="moveDown";if(n&&(this.toolbarMoveInProgress=!0),o.onclick&&o.onclick({row:r,rowIndex:s}),this.grid.ontoolbarclick&&this.grid.ontoolbarclick({item:o,rowIndex:s,row:r}),o.id==="delete"){this.closeToolbarAndReset(),this.render();return}n?(this.render(),Le(this,this.grid.displayItems),this.renderConnector()):this.render()}}typeof customElements<"u"&&!customElements.get("web-grid")&&customElements.define("web-grid",ce),H.GridElement=ce,H.WebGrid=z,H.default=ce,Object.defineProperties(H,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
646
+ `;const s=r.querySelector(".wg__goto-input"),n=r.querySelector(".wg__goto-btn--go"),d=r.querySelector(".wg__goto-btn--cancel"),a=()=>{r.remove()},c=()=>{const g=parseInt(s.value,10);if(isNaN(g)||g<1||g>i.length){s.focus(),s.select();return}a();const l=g-1,h=this.grid.focusedCell;if(this.grid.setFocusedCell(l,o),this.grid.shouldUseVirtualScroll())ut(this,l),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const u=this.shadow.querySelector(`td[data-row="${l}"][data-col="${o}"]`);u==null||u.focus()})});else{const u=this.shadow.querySelector(`td[data-row="${l}"][data-col="${o}"]`);u&&(u.scrollIntoView({block:"nearest",behavior:"auto"}),u.focus(),W(this,h,{rowIndex:l,colIndex:o}))}};n.addEventListener("click",c),d.addEventListener("click",a),r.addEventListener("click",g=>{g.target===r&&a()}),s.addEventListener("keydown",g=>{g.key==="Enter"?(g.preventDefault(),c()):g.key==="Escape"&&(g.preventDefault(),a())}),this.shadow.appendChild(r),s.focus(),s.select()}openCustomEditor(o,i){const r=this.grid.columns[i];if(!r||r.editor!=="custom"||!r.cellEditCallback)return;const s=String(r.field),n=this.grid.displayItems[o];if(!n)return;const a={value:this.grid.getCellRawValue(n,o,s),row:n,rowIndex:o,field:s,commit:c=>{this.grid.commitEdit(o,s,c),q(this),requestAnimationFrame(()=>{E(this,o,i)})},cancel:()=>{q(this),this.grid.cancelEdit(),requestAnimationFrame(()=>{E(this,o,i)})}};r.cellEditCallback(a)}handleContextMenu(o){const i=this.grid.contextMenu;if(!i||i.length===0)return;const s=o.target.closest(".wg__cell");if(!s)return;o.preventDefault(),this.contextMenuElement&&(_t(this.contextMenuElement),this.contextMenuElement=null);const n=parseInt(s.dataset.row||"0",10),d=parseInt(s.dataset.col||"0",10),a=this.grid.columns[d];if(!a)return;const c=this.grid.displayItems[n];if(!c)return;const g=String(a.field),l=this.grid.getCellRawValue(c,n,g),h={row:c,rowIndex:n,colIndex:d,column:a,cellValue:l};this.grid.oncontextmenuopen&&this.grid.oncontextmenuopen(h),this.contextMenuElement=Gi(this,o.clientX,o.clientY,i,h,u=>{const p=i.find(m=>m.id===u);p!=null&&p.onclick&&p.onclick(h),this.contextMenuElement&&(_t(this.contextMenuElement),this.contextMenuElement=null)},()=>{this.contextMenuElement=null})}showToolbarForRow(o,i,r){if(!this.grid.showRowToolbar||!this.grid.rowToolbar.length)return;const s=gi(this.grid.rowToolbar),n=this.grid.displayItems[i];if(!n)return;if(this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),pi(this,o,i,s,n,a=>{this.handleToolbarItemClick(a,i,n)},r),this.renderConnector(),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 c=this.shadow.querySelector(".wg__table"),g=c==null?void 0:c.matches(":hover"),l=a.matches(":hover");!g&&!l&&(this.closeToolbarAndReset(),this.render())},150))}))}const d=this.shadow.querySelector(`[data-toolbar-trigger="${i}"]`);d&&(this.shadow.querySelectorAll(".wg__toolbar-trigger--active").forEach(a=>{a.classList.remove("wg__toolbar-trigger--active")}),d.classList.add("wg__toolbar-trigger--active"))}closeToolbarAndReset(){this.toolbarMoveInProgress=!1,this.toolbarHovered=!1,this.toolbarHideTimeout&&(clearTimeout(this.toolbarHideTimeout),this.toolbarHideTimeout=null),Vt()}handleToolbarItemClick(o,i,r){const s=this.grid.displayItems.findIndex(d=>d===r);if(s===-1){this.closeToolbarAndReset(),this.render();return}const n=o.id==="moveUp"||o.id==="moveDown";if(n&&(this.toolbarMoveInProgress=!0),o.onclick&&o.onclick({row:r,rowIndex:s}),this.grid.ontoolbarclick&&this.grid.ontoolbarclick({item:o,rowIndex:s,row:r}),o.id==="delete"){this.closeToolbarAndReset(),this.render();return}n?(this.render(),Le(this,this.grid.displayItems),this.renderConnector()):this.render()}}typeof customElements<"u"&&!customElements.get("web-grid")&&customElements.define("web-grid",ce),I.GridElement=ce,I.WebGrid=z,I.default=ce,Object.defineProperties(I,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});