@toolbox-web/grid 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -22
- package/all.js +619 -571
- package/all.js.map +1 -1
- package/index.js +362 -302
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +64 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/row-animation.d.ts +37 -0
- package/lib/core/internal/row-animation.d.ts.map +1 -0
- package/lib/core/types.d.ts +17 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +82 -76
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +1 -0
- package/lib/plugins/clipboard/types.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js +43 -41
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +24 -22
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +83 -52
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +22 -20
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +11 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +160 -125
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +20 -18
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +66 -64
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +51 -49
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +17 -15
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +24 -22
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +25 -23
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +49 -47
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +24 -22
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +19 -17
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +38 -36
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +13 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.d.ts +1 -1
- package/lib/plugins/selection/index.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +118 -85
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +50 -6
- package/lib/plugins/selection/types.d.ts.map +1 -1
- package/lib/plugins/server-side/index.js +34 -32
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +25 -23
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +22 -20
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +21 -19
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +21 -4
- package/public.d.ts +1 -1
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +19 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +9 -9
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +5 -5
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
package/umd/grid.all.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(C,j){typeof exports=="object"&&typeof module<"u"?j(exports):typeof define=="function"&&define.amd?define(["exports"],j):(C=typeof globalThis<"u"?globalThis:C||self,j(C.TbwGrid={}))})(this,(function(C){"use strict";const j='@layer tbw-base,tbw-plugins,tbw-theme;@layer tbw-base{:root{color-scheme:light dark}tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #666666);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-input: 1px solid var(--tbw-color-border-strong);--tbw-border-header: 1px solid var(--tbw-color-border-header);--tbw-row-divider: 1px solid var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline: 2px solid var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-scrollbar-thumb: var(--tbw-color-border-strong);--tbw-scrollbar-track: var(--tbw-color-bg);--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm);position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none}tbw-grid,tbw-grid *{box-sizing:border-box}tbw-grid .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}tbw-grid .header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}tbw-grid .header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start))}tbw-grid .header-group-cell:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30)}tbw-grid .header-row>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:visible;min-width:0}tbw-grid .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0;opacity:.6}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row>.cell.resizable{position:relative}tbw-grid .header-row>.cell.sticky-left,tbw-grid .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}tbw-grid .tbw-grid-root{display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}tbw-grid .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}tbw-grid .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}tbw-grid .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}tbw-grid .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}tbw-grid .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}tbw-grid .faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30)}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style;content-visibility:auto;contain-intrinsic-size:auto var(--tbw-row-height)}tbw-grid .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid .data-grid-row:hover{background:var(--tbw-color-row-hover)}tbw-grid .data-grid-row>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);line-height:calc(var(--tbw-row-height) - 5px);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis}tbw-grid .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}tbw-grid .data-grid-row>.cell:last-child{border-right:0}tbw-grid .data-grid-row>.cell[data-type=boolean]{text-align:center}tbw-grid .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}tbw-grid .data-grid-row>.cell.selected:focus-visible,tbw-grid .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}tbw-grid .data-grid-row>.cell.sticky-left,tbw-grid .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}tbw-grid .selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid .sortable{cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;-webkit-user-select:none;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}tbw-grid .resize-handle:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}tbw-grid .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}tbw-grid .resize-handle:hover:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}tbw-grid[data-has-focus] .cell-focus,tbw-grid[data-has-focus] .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .sticky-left,tbw-grid .sticky-right{position:sticky;z-index:25}tbw-grid .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}tbw-grid .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}tbw-grid .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}tbw-grid .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}tbw-grid .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}tbw-grid .tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}tbw-grid .tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}tbw-grid[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}@media(forced-colors:active){tbw-grid{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight}tbw-grid .cell:focus,tbw-grid .cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}tbw-grid .data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}}',Y={STRETCH:"stretch",FIXED:"fixed"},Ve={mode:"reduced-motion",duration:200,easing:"ease-out"},F={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰"};function hi(o){return Array.from(o.querySelectorAll("tbw-grid-column")).map(t=>{const i=t.getAttribute("field")||"";if(!i)return null;const n=t.getAttribute("type")||void 0,s=n&&new Set(["number","string","date","boolean","select"]).has(n)?n:void 0,l=t.getAttribute("header")||void 0,a=t.hasAttribute("sortable"),c=t.hasAttribute("editable"),d={field:i,type:s,header:l,sortable:a,editable:c},u=t.getAttribute("width");if(u){const v=parseFloat(u);!isNaN(v)&&/^\d+(\.\d+)?$/.test(u.trim())?d.width=v:d.width=u}const h=t.getAttribute("minWidth")||t.getAttribute("min-width");if(h){const v=parseFloat(h);isNaN(v)||(d.minWidth=v)}t.hasAttribute("resizable")&&(d.resizable=!0),t.hasAttribute("sizable")&&(d.resizable=!0);const f=t.getAttribute("editor"),p=t.getAttribute("renderer");f&&(d.__editorName=f),p&&(d.__rendererName=p);const g=t.getAttribute("options");g&&(d.options=g.split(",").map(v=>{const[k,S]=v.includes(":")?v.split(":"):[v.trim(),v.trim()];return{value:k.trim(),label:S?.trim()||k.trim()}}));const w=t.querySelector("tbw-grid-column-view"),m=t.querySelector("tbw-grid-column-editor"),y=t.querySelector("tbw-grid-column-header");w&&(d.__viewTemplate=w),m&&(d.__editorTemplate=m),y&&(d.__headerTemplate=y);const _=globalThis.DataGridElement?.getAdapters?.()??[],x=w??t,A=_.find(v=>v.canHandle(x));if(A){const v=A.createRenderer(x);v&&(d.viewRenderer=v)}const T=m??t,E=_.find(v=>v.canHandle(T));if(E){const v=E.createEditor(T);v&&(d.editor=v)}return d}).filter(t=>!!t)}function $e(o,e){if((!o||!o.length)&&(!e||!e.length))return[];if(!o||!o.length)return e||[];if(!e||!e.length)return o;const t={};e.forEach(n=>{const r=t[n.field];if(r){n.header&&!r.header&&(r.header=n.header),n.type&&!r.type&&(r.type=n.type),n.sortable&&(r.sortable=!0),n.editable&&(r.editable=!0),n.resizable&&(r.resizable=!0),n.width!=null&&r.width==null&&(r.width=n.width),n.minWidth!=null&&r.minWidth==null&&(r.minWidth=n.minWidth),n.__viewTemplate&&(r.__viewTemplate=n.__viewTemplate),n.__editorTemplate&&(r.__editorTemplate=n.__editorTemplate),n.__headerTemplate&&(r.__headerTemplate=n.__headerTemplate);const s=n.renderer||n.viewRenderer,l=r.renderer||r.viewRenderer;s&&!l&&(r.viewRenderer=s,n.renderer&&(r.renderer=s)),n.editor&&!r.editor&&(r.editor=n.editor)}else t[n.field]={...n}});const i=o.map(n=>{const r=t[n.field];if(!r)return n;const s={...n};r.header&&!s.header&&(s.header=r.header),r.type&&!s.type&&(s.type=r.type),s.sortable=n.sortable||r.sortable,(n.resizable===!0||r.resizable===!0)&&(s.resizable=!0),s.editable=n.editable||r.editable,r.width!=null&&s.width==null&&(s.width=r.width),r.minWidth!=null&&s.minWidth==null&&(s.minWidth=r.minWidth),r.__viewTemplate&&(s.__viewTemplate=r.__viewTemplate),r.__editorTemplate&&(s.__editorTemplate=r.__editorTemplate),r.__headerTemplate&&(s.__headerTemplate=r.__headerTemplate);const l=r.renderer||r.viewRenderer,a=s.renderer||s.viewRenderer;return l&&!a&&(s.viewRenderer=l,r.renderer&&(s.renderer=l)),r.editor&&!s.editor&&(s.editor=r.editor),delete t[n.field],s});return Object.keys(t).forEach(n=>i.push(t[n])),i}function Ue(o,e){try{o.part?.add?.(e)}catch{}const t=o.getAttribute("part");t?t.split(/\s+/).includes(e)||o.setAttribute("part",t+" "+e):o.setAttribute("part",e)}function je(o){const e=o.effectiveConfig?.fitMode||o.fitMode||Y.STRETCH;if(e!==Y.STRETCH&&e!==Y.FIXED||o.__didInitialAutoSize||!o.isConnected)return;const t=Array.from(o._headerRowEl?.children||[]);if(!t.length)return;let i=!1;o._visibleColumns.forEach((n,r)=>{if(n.width)return;const s=t[r];let l=s?s.scrollWidth:0;for(const a of o._rowPool){const c=a.children[r];if(c){const d=c.scrollWidth;d>l&&(l=d)}}l>0&&(n.width=l+2,n.__autoSized=!0,i=!0)}),i&&te(o),o.__didInitialAutoSize=!0}function te(o){(o.effectiveConfig?.fitMode||o.fitMode||Y.STRETCH)===Y.STRETCH?o._gridTemplate=o._visibleColumns.map(t=>{if(t.width)return`${t.width}px`;const i=t.minWidth;return i!=null?`minmax(${i}px, 1fr)`:"1fr"}).join(" ").trim():o._gridTemplate=o._visibleColumns.map(t=>t.width?`${t.width}px`:"max-content").join(" "),o.style.setProperty("--tbw-column-template",o._gridTemplate)}function fi(o){return o==null?"string":typeof o=="number"?"number":typeof o=="boolean"?"boolean":o instanceof Date||typeof o=="string"&&/\d{4}-\d{2}-\d{2}/.test(o)&&!isNaN(Date.parse(o))?"date":"string"}function gi(o,e){const t=o[0]||{},i=Object.keys(t).map(r=>{const s=t[r],l=fi(s);return{field:r,header:r.charAt(0).toUpperCase()+r.slice(1),type:l}}),n={};return i.forEach(r=>{n[r.field]=r.type||"string"}),{columns:i,typeMap:n}}const pi=/{{\s*([^}]+)\s*}}/g,z="__DG_EMPTY__",wi=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,mi=/__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/;function bi(o){return!o||typeof o!="string"?"":o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const vi=new Set(["script","iframe","object","embed","form","input","button","textarea","select","link","meta","base","style","template","slot","portal","frame","frameset","applet","noscript","noembed","plaintext","xmp","listing"]),Ye=/^on\w+$/i,yi=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),Ci=/^\s*(javascript|vbscript|data|blob):/i;function ie(o){if(!o||typeof o!="string")return"";if(o.indexOf("<")===-1)return o;const e=document.createElement("template");return e.innerHTML=o,xi(e.content),e.innerHTML}function xi(o){const e=[],t=o.querySelectorAll("*");for(const i of t){const n=i.tagName.toLowerCase();if(vi.has(n)){e.push(i);continue}if((n==="svg"||i.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(i.attributes).some(l=>Ye.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(i);continue}const r=[];for(const s of i.attributes){const l=s.name.toLowerCase();if(Ye.test(l)){r.push(s.name);continue}if(yi.has(l)&&Ci.test(s.value)){r.push(s.name);continue}if(l==="style"&&/expression\s*\(|javascript:|behavior\s*:/i.test(s.value)){r.push(s.name);continue}}r.forEach(s=>i.removeAttribute(s))}e.forEach(i=>i.remove())}function we(o,e){if(!o||o.indexOf("{{")===-1)return o;const t=[],i=o.replace(pi,(l,a)=>{const c=Ri(a,e);return t.push({expr:a.trim(),result:c}),c}),n=Ei(i),r=t.length&&t.every(l=>l.result===""||l.result===z);return/Reflect\.|\bProxy\b|ownKeys\(/.test(o)||r?"":n}function Ri(o,e){if(o=(o||"").trim(),!o||/\b(Reflect|Proxy|ownKeys)\b/.test(o))return z;if(o==="value")return e.value==null?z:String(e.value);if(o.startsWith("row.")&&!/[()?]/.test(o)&&!o.includes(":")){const i=o.slice(4),n=e.row?e.row[i]:void 0;return n==null?z:String(n)}if(o.length>80||!wi.test(o)||mi.test(o))return z;const t=o.match(/\./g);if(t&&t.length>1)return z;try{const n=new Function("value","row",`return (${o});`)(e.value,e.row),r=n==null?"":String(n);return/Reflect|Proxy|ownKeys/.test(r)?z:r||z}catch{return z}}function Ei(o){return o&&o.replace(new RegExp(z,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function Si(o){if(/Reflect|Proxy|ownKeys/.test(o.textContent||"")){if(Array.from(o.childNodes).forEach(e=>{e.nodeType===Node.TEXT_NODE&&/Reflect|Proxy|ownKeys/.test(e.textContent||"")&&(e.textContent="")}),/Reflect|Proxy|ownKeys/.test(o.textContent||"")){if(/Reflect|Proxy|ownKeys/.test(o.textContent||""))for(;o.firstChild;)o.removeChild(o.firstChild);o.textContent=(o.textContent||"").replace(/Reflect|Proxy|ownKeys/g,"")}(o.textContent||"").trim().length===0&&(o.textContent="")}}function Xe(o){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(o),t=(i=>e?"":we(o,i));return t.__blocked=e,t}const _i=100;class Ai{#e;#o;#d;#c;#s;#i={};#h={};#u=!0;#p=[];#l;#w;#m;#a;#b;constructor(e){this.#a=e}get original(){return this.#i}get effective(){return this.#h}get columns(){return this.#h.columns??[]}set columns(e){this.#h.columns=e}get lightDomColumnsCache(){return this.#c}set lightDomColumnsCache(e){this.#c=e}get originalColumnNodes(){return this.#s}set originalColumnNodes(e){this.#s=e}get lightDomTitle(){return this.#b}set lightDomTitle(e){this.#b=e}get initialColumnState(){return this.#m}set initialColumnState(e){this.#m=e}get sourcesChanged(){return this.#u}markSourcesChanged(){this.#u=!0}setGridConfig(e){this.#e=e,this.#u=!0,this.#c=void 0}getGridConfig(){return this.#e}setColumns(e){this.#o=e,this.#u=!0}getColumns(){return this.#o}setFitMode(e){this.#d=e,this.#u=!0}getFitMode(){return this.#d}merge(){const e=(this.#h.columns?.length??0)>0;if(!this.#u&&e)return;const t=this.#y();this.#u=!1,this.#i=t,Object.freeze(this.#i),this.#i.columns&&Object.freeze(this.#i.columns),this.#h=this.#v(this.#i),this.#g()}#v(e){const t={...e};return e.columns&&(t.columns=e.columns.map(i=>({...i}))),e.shell&&(t.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(i=>({...i})),headerContents:e.shell.headerContents?.map(i=>({...i}))}),t}#g(){const e=this.#h;e.rowHeight&&e.rowHeight>0&&this.#a.setRowHeight(e.rowHeight),e.fitMode==="fixed"&&this.columns.forEach(i=>{i.width==null&&(i.width=80)}),this.#a.applyAnimationConfig(e)}#y(){const e=this.#e?{...this.#e}:{},t=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#c??[]).map(s=>({...s}));let n=$e(t,i);this.#o&&this.#o.length&&(n=$e(this.#o,i));const r=this.#a.getRows();return n.length===0&&r.length&&(n=gi(r).columns),n.length&&(n.forEach(s=>{s.sortable===void 0&&(s.sortable=!0),s.resizable===void 0&&(s.resizable=!0),s.__originalWidth===void 0&&typeof s.width=="number"&&(s.__originalWidth=s.width)}),n.forEach(s=>{s.__viewTemplate&&!s.__compiledView&&(s.__compiledView=Xe(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=Xe(s.__editorTemplate.innerHTML))}),e.columns=n),this.#d&&(e.fitMode=this.#d),e.fitMode||(e.fitMode="stretch"),this.#x(e),e.columnState&&!this.#m&&(this.#m=e.columnState),e}#x(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const t=this.#a.getShellLightDomTitle();t&&(this.#b=t),this.#b&&!e.shell.header.title&&(e.shell.header.title=this.#b);const i=this.#a.getShellLightDomHeaderContent();i?.length>0&&(e.shell.header.lightDomContent=i),this.#a.getShellHasToolButtonsContainer()&&(e.shell.header.hasToolButtonsContainer=!0);const n=this.#a.getShellToolPanels();if(n.size>0){const u=Array.from(n.values());u.sort((h,f)=>(h.order??100)-(f.order??100)),e.shell.toolPanels=u}const r=this.#a.getShellHeaderContents();if(r.size>0){const u=Array.from(r.values());u.sort((h,f)=>(h.order??100)-(f.order??100)),e.shell.headerContents=u}const s=this.#a.getShellToolbarContents(),l=Array.from(s.values()),a=this.#e?.shell?.header?.toolbarContents??[],c=new Set(a.map(u=>u.id)),d=[...a];for(const u of l)c.has(u.id)||d.push(u);d.sort((u,h)=>(u.order??0)-(h.order??0)),e.shell.header.toolbarContents=d}collectState(e){const t=this.columns,i=this.#C();return{columns:t.map((n,r)=>{const s={field:n.field,order:r,visible:!n.hidden},l=n;l.__renderedWidth!==void 0?s.width=l.__renderedWidth:n.width!==void 0&&(s.width=typeof n.width=="string"?parseFloat(n.width):n.width);const a=i.get(n.field);a&&(s.sort=a);for(const c of e)if(c.getColumnState){const d=c.getColumnState(n.field);d&&Object.assign(s,d)}return s})}}applyState(e,t){if(!e.columns||e.columns.length===0)return;const i=this.columns,n=new Map(e.columns.map(l=>[l.field,l])),r=i.map(l=>{const a=n.get(l.field);if(!a)return l;const c={...l};return a.width!==void 0&&(c.width=a.width,c.__renderedWidth=a.width),a.visible!==void 0&&(c.hidden=!a.visible),c});r.sort((l,a)=>{const c=n.get(l.field)?.order??1/0,d=n.get(a.field)?.order??1/0;return c-d}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,a)=>(l.sort?.priority??0)-(a.sort?.priority??0));if(s.length>0){const l=s[0];l.sort&&this.#a.setSortState({field:l.field,direction:l.sort.direction==="asc"?1:-1})}else this.#a.setSortState(null);for(const l of t)if(l.applyColumnState)for(const a of e.columns)l.applyColumnState(a.field,a)}resetState(e){this.#m=void 0,this.#a.setSortState(null),this.#h=this.#v(this.#i),this.#g();for(const t of e)if(t.applyColumnState)for(const i of this.columns)t.applyColumnState(i.field,{field:i.field,order:0,visible:!0});this.requestStateChange(e)}#C(){const e=new Map,t=this.#a.getSortState();return t&&e.set(t.field,{direction:t.direction===1?"asc":"desc",priority:0}),e}requestStateChange(e){this.#w&&clearTimeout(this.#w),this.#w=setTimeout(()=>{this.#w=void 0;const t=this.collectState(e);this.#a.emit("column-state-change",t)},_i)}setColumnVisible(e,t){const i=this.columns,n=i.find(s=>s.field===e);return!n||!t&&n.lockVisible||!t&&i.filter(l=>!l.hidden&&l.field!==e).length===0||!!n.hidden===!t?!1:(n.hidden=!t,this.#a.emit("column-visibility",{field:e,visible:t,visibleColumns:i.filter(s=>!s.hidden).map(s=>s.field)}),this.#a.clearRowPool(),this.#a.setup(),!0)}toggleColumnVisibility(e){const t=this.columns.find(i=>i.field===e);return t?this.setColumnVisible(e,!!t.hidden):!1}isColumnVisible(e){const t=this.columns.find(i=>i.field===e);return t?!t.hidden:!1}showAllColumns(){const e=this.columns;e.some(t=>t.hidden)&&(e.forEach(t=>t.hidden=!1),this.#a.emit("column-visibility",{visibleColumns:e.map(t=>t.field)}),this.#a.clearRowPool(),this.#a.setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:e.meta?.utility===!0}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const t=new Map(this.columns.map(n=>[n.field,n])),i=[];for(const n of e){const r=t.get(n);r&&(i.push(r),t.delete(n))}for(const n of t.values())i.push(n);this.columns=i,this.#a.renderHeader(),this.#a.updateTemplate(),this.#a.refreshVirtualWindow()}parseLightDomColumns(e){this.#c||(this.#s=Array.from(e.querySelectorAll("tbw-grid-column")),this.#c=this.#s.length?hi(e):[])}clearLightDomCache(){this.#c=void 0}#R=new Map;registerLightDomHandler(e,t){this.#R.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#R.delete(e.toLowerCase())}observeLightDOM(e){this.#l&&this.#l.disconnect();const t=new Set;let i=null;const n=()=>{i=null;for(const r of t)this.#R.get(r)?.();t.clear()};this.#l=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const c=l.tagName.toLowerCase();this.#R.has(c)&&t.add(c)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const a=s.target.tagName.toLowerCase();this.#R.has(a)&&t.add(a)}}t.size>0&&!i&&(i=setTimeout(n,0))}),this.#l.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#p.push(e)}notifyChange(){for(const e of this.#p)e()}dispose(){this.#l?.disconnect(),this.#p=[],this.#w&&clearTimeout(this.#w)}}function Ze(o){return`<span role="checkbox" aria-checked="${o}" aria-label="${o}">${o?"🗹":"☐"}</span>`}function Je(o){if(o==null||o==="")return"";if(o instanceof Date)return isNaN(o.getTime())?"":o.toLocaleDateString();if(typeof o=="number"||typeof o=="string"){const e=new Date(o);return isNaN(e.getTime())?"":e.toLocaleDateString()}return""}function me(o){if(!o)return-1;const e=o.getAttribute("data-row");if(e)return parseInt(e,10);const t=o.closest(".data-grid-row");if(!t)return-1;const i=t.parentElement;if(!i)return-1;const n=i.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===t)return r;return-1}function Ti(o){if(!o)return-1;const e=o.getAttribute("data-col");return e?parseInt(e,10):-1}function oe(o){o&&o.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function Qe(o,e){const t=e.renderer||e.viewRenderer;if(t)return t;if(!e.type)return;const i=o.effectiveConfig?.typeDefaults;if(i?.[e.type]?.renderer)return i[e.type].renderer;const n=o.__frameworkAdapter;if(n?.getTypeDefault){const r=n.getTypeDefault(e.type);if(r?.renderer)return r.renderer}}const et='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function be(o){return(o.__editingCellCount??0)>0}function ve(o){o.__editingCellCount=0,o.removeAttribute("data-has-editing"),o.querySelectorAll(".cell.editing").forEach(t=>t.classList.remove("editing"))}const tt=document.createElement("template");tt.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const it=document.createElement("template");it.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function ki(){return tt.content.firstElementChild.cloneNode(!0)}function Pi(){return it.content.firstElementChild.cloneNode(!0)}function de(o){o.__cellDisplayCache=void 0,o.__cellCacheEpoch=void 0,o.__hasSpecialColumns=void 0}function Li(o,e,t,i,n){const r=Math.max(0,t-e),s=o._bodyEl,l=o._visibleColumns,a=l.length;let c=o.__cachedHeaderRowCount;for(c===void 0&&(c=o.querySelector(".header-group-row")?2:1,o.__cachedHeaderRowCount=c);o._rowPool.length<r;){const h=Pi();o._rowPool.push(h)}if(o._rowPool.length>r){for(let h=r;h<o._rowPool.length;h++){const f=o._rowPool[h];f.parentNode===s&&f.remove()}o._rowPool.length=r}const d=n&&o.__hasRenderRowPlugins!==!1,u=o._hasAfterRowRenderHook?.()??!1;for(let h=0;h<r;h++){const f=e+h,p=o._rows[f],g=o._rowPool[h];if(g.setAttribute("aria-rowindex",String(f+c+1)),d&&n(p,g,f)){g.__epoch=i,g.__rowDataRef=p,g.parentNode!==s&&s.appendChild(g);continue}const w=g.__epoch,m=g.__rowDataRef,y=g.children.length,_=w===i&&y===a,x=m!==p;let A=!1;if(_&&x){for(let S=0;S<a;S++)if(l[S].externalView&&!g.querySelector(`.cell[data-col="${S}"] [data-external-view]`)){A=!0;break}}if(!_||A){const S=be(g),R=o._activeEditRows===f;S&&!R?(g.__isCustomRow&&(g.className="data-grid-row",g.setAttribute("role","row"),g.__isCustomRow=!1),ve(g),ne(o,g,p,f),g.__epoch=i,g.__rowDataRef=p):S&&R?(ye(o,g,p,f),g.__rowDataRef=p):(g.__isCustomRow&&(g.className="data-grid-row",g.setAttribute("role","row"),g.__isCustomRow=!1),ne(o,g,p,f),g.__epoch=i,g.__rowDataRef=p)}else if(x){const S=be(g),R=o._activeEditRows===f;S&&!R?(ve(g),ne(o,g,p,f),g.__epoch=i,g.__rowDataRef=p):(ye(o,g,p,f),g.__rowDataRef=p)}else{const S=be(g),R=o._activeEditRows===f;S&&!R?(ve(g),ne(o,g,p,f),g.__epoch=i,g.__rowDataRef=p):ye(o,g,p,f)}let T=!1;const E=o.changedRowIds;if(E&&E.length>0)try{const S=o.getRowId?.(p);S&&(T=E.includes(S))}catch{}const v=g.classList.contains("changed");T!==v&&g.classList.toggle("changed",T);const k=o.effectiveConfig?.rowClass;if(k){const S=g.getAttribute("data-dynamic-classes");S&&S.split(" ").forEach(R=>R&&g.classList.remove(R));try{const R=k(p);if(R&&R.length>0){const P=R.filter(O=>O&&typeof O=="string");P.forEach(O=>g.classList.add(O)),g.setAttribute("data-dynamic-classes",P.join(" "))}else g.removeAttribute("data-dynamic-classes")}catch(R){console.warn("[tbw-grid] rowClass callback error:",R),g.removeAttribute("data-dynamic-classes")}}u&&o._afterRowRender?.({row:p,rowIndex:f,rowElement:g}),g.parentNode!==s&&s.appendChild(g)}}function ye(o,e,t,i){const n=e.children,r=o._visibleColumns,s=r.length,l=n.length,a=s<l?s:l,c=o._focusRow,d=o._focusCol,u=o._hasAfterCellRenderHook?.()??!1;let h=o.__hasSpecialColumns;if(h===void 0){h=!1;const p=o.effectiveConfig?.typeDefaults,g=o.__frameworkAdapter;for(let w=0;w<s;w++){const m=r[w];if(m.__viewTemplate||m.__compiledView||m.renderer||m.viewRenderer||m.externalView||m.format||m.type==="date"||m.type==="boolean"||m.type&&p?.[m.type]?.renderer||m.type&&g?.getTypeDefault?.(m.type)?.renderer){h=!0;break}}o.__hasSpecialColumns=h}const f=String(i);if(!h){for(let p=0;p<a;p++){const g=n[p];if(g.classList.contains("editing"))continue;const w=r[p],m=t[w.field];g.textContent=m==null?"":String(m),g.getAttribute("data-row")!==f&&g.setAttribute("data-row",f);const y=c===i&&d===p,b=g.classList.contains("cell-focus");y!==b&&(g.classList.toggle("cell-focus",y),g.setAttribute("aria-selected",String(y))),u&&o._afterCellRender?.({row:t,rowIndex:i,column:w,colIndex:p,value:m,cellElement:g,rowElement:e})}return}for(let p=0;p<a;p++)if(r[p].externalView&&!n[p].querySelector("[data-external-view]")){ne(o,e,t,i);return}for(let p=0;p<a;p++){const g=r[p],w=n[p];w.getAttribute("data-row")!==f&&w.setAttribute("data-row",f);const m=c===i&&d===p,y=w.classList.contains("cell-focus");m!==y&&(w.classList.toggle("cell-focus",m),w.setAttribute("aria-selected",String(m)));const b=g.cellClass;if(b){const T=w.getAttribute("data-dynamic-classes");T&&T.split(" ").forEach(E=>E&&w.classList.remove(E));try{const E=t[g.field],v=b(E,t,g);if(v&&v.length>0){const k=v.filter(S=>S&&typeof S=="string");k.forEach(S=>w.classList.add(S)),w.setAttribute("data-dynamic-classes",k.join(" "))}else w.removeAttribute("data-dynamic-classes")}catch(E){console.warn(`[tbw-grid] cellClass callback error for column '${g.field}':`,E),w.removeAttribute("data-dynamic-classes")}}if(w.classList.contains("editing"))continue;const _=Qe(o,g);if(_){const T=t[g.field],E=_({row:t,value:T,field:g.field,column:g,cellEl:w});typeof E=="string"?w.innerHTML=ie(E):E instanceof Node?E.parentElement!==w&&(w.innerHTML="",w.appendChild(E)):E==null&&(w.textContent=T==null?"":String(T)),u&&o._afterCellRender?.({row:t,rowIndex:i,column:g,colIndex:p,value:T,cellElement:w,rowElement:e});continue}if(g.__viewTemplate||g.__compiledView||g.externalView)continue;const x=t[g.field];let A;if(g.format)try{const T=g.format(x,t);A=T==null?"":String(T)}catch(T){console.warn(`[tbw-grid] Format error in column '${g.field}':`,T),A=x==null?"":String(x)}else g.type==="date"?(A=Je(x),w.textContent=A):g.type==="boolean"?w.innerHTML=Ze(!!x):(A=x==null?"":String(x),w.textContent=A);u&&o._afterCellRender?.({row:t,rowIndex:i,column:g,colIndex:p,value:x,cellElement:w,rowElement:e})}}function ne(o,e,t,i){e.innerHTML="";const n=o._visibleColumns,r=n.length,s=o._focusRow,l=o._focusCol,a=o,c=o._hasAfterCellRenderHook?.()??!1,d=document.createDocumentFragment();for(let u=0;u<r;u++){const h=n[u],f=ki();f.setAttribute("aria-colindex",String(u+1)),f.setAttribute("data-col",String(u)),f.setAttribute("data-row",String(i)),f.setAttribute("data-field",h.field),f.setAttribute("data-header",h.header??h.field),h.type&&f.setAttribute("data-type",h.type);let p=t[h.field];if(h.format)try{p=h.format(p,t)}catch(x){console.warn(`[tbw-grid] Format error in column '${h.field}':`,x)}const g=h.__compiledView,w=h.__viewTemplate,m=Qe(o,h),y=h.externalView;let b=!1;if(m){const x=m({row:t,value:p,field:h.field,column:h,cellEl:f});typeof x=="string"?(f.innerHTML=ie(x),b=!0):x instanceof Node?x.parentElement!==f&&(f.textContent="",f.appendChild(x)):x==null&&(f.textContent=p==null?"":String(p))}else if(y){const x=y,A=document.createElement("div");A.setAttribute("data-external-view",""),A.setAttribute("data-field",h.field),f.appendChild(A);const T={row:t,value:p,field:h.field,column:h};if(x.mount)try{x.mount({placeholder:A,context:T,spec:x})}catch(E){console.warn(`[tbw-grid] External view mount error for column '${h.field}':`,E)}else queueMicrotask(()=>{try{a.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:A,spec:x,context:T}}))}catch(E){console.warn(`[tbw-grid] External view event dispatch error for column '${h.field}':`,E)}});A.setAttribute("data-mounted","")}else if(g){const x=g({row:t,value:p,field:h.field,column:h}),A=g.__blocked;f.innerHTML=A?"":ie(x),b=!0,A&&(f.textContent="",f.setAttribute("data-blocked-template",""))}else if(w){const x=w.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(x)?(f.textContent="",f.setAttribute("data-blocked-template","")):(f.innerHTML=ie(we(x,{row:t,value:p})),b=!0)}else h.type==="date"?f.textContent=Je(p):h.type==="boolean"?f.innerHTML=Ze(!!p):f.textContent=p==null?"":String(p);if(b){Si(f);const x=f.textContent||"";/Proxy|Reflect\.ownKeys/.test(x)&&(f.textContent=x.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(f.textContent||"")&&(f.textContent=""))}f.hasAttribute("data-blocked-template")&&(f.textContent||"").trim().length&&(f.textContent=""),h.editable?f.tabIndex=0:h.type==="boolean"&&(f.hasAttribute("tabindex")||(f.tabIndex=0)),s===i&&l===u?(f.classList.add("cell-focus"),f.setAttribute("aria-selected","true")):f.setAttribute("aria-selected","false");const _=h.cellClass;if(_)try{const x=t[h.field],A=_(x,t,h);if(A&&A.length>0){const T=A.filter(E=>E&&typeof E=="string");T.forEach(E=>f.classList.add(E)),f.setAttribute("data-dynamic-classes",T.join(" "))}}catch(x){console.warn(`[tbw-grid] cellClass callback error for column '${h.field}':`,x)}c&&o._afterCellRender?.({row:t,rowIndex:i,column:h,colIndex:u,value:p,cellElement:f,rowElement:e}),d.appendChild(f)}e.appendChild(d)}function ot(o,e,t){if(e.target?.closest(".resize-handle"))return;const i=t.querySelector(".cell[data-row]"),n=me(i);if(n<0)return;const r=o._rows[n];if(!r||o._dispatchRowClick?.(e,n,r,t))return;const s=e.target?.closest(".cell[data-col]");if(s){const l=Number(s.getAttribute("data-col"));if(!isNaN(l)){if(o._dispatchCellClick?.(e,n,l,s))return;const a=o._focusRow!==n||o._focusCol!==l;if(o._focusRow=n,o._focusCol=l,s.classList.contains("editing")){a&&(oe(o._bodyEl??o),s.classList.add("cell-focus"));const c=s.querySelector(et);try{c?.focus({preventScroll:!0})}catch{}return}N(o)}}}function Di(o,e){if(o._dispatchKeyDown?.(e))return;const t=o._rows.length-1,i=o._visibleColumns.length-1,n=o._activeEditRows!==void 0&&o._activeEditRows!==-1,s=o._visibleColumns[o._focusCol]?.type,l=e.composedPath?.()??[],a=l.length?l[0]:e.target,c=d=>{if(!d)return!1;const u=d.tagName;return!!(u==="INPUT"||u==="SELECT"||u==="TEXTAREA"||d.isContentEditable)};if(!(c(a)&&(e.key==="Home"||e.key==="End"))&&!(c(a)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&a.tagName==="INPUT"&&a.type==="number")&&!(c(a)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(c(a)&&(e.key==="Enter"||e.key==="Escape"))&&!(n&&s==="select"&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{e.preventDefault(),!e.shiftKey?o._focusCol<i?o._focusCol+=1:(typeof o.commitActiveRowEdit=="function"&&o.commitActiveRowEdit(),o._focusRow<t&&(o._focusRow+=1,o._focusCol=0)):o._focusCol>0?o._focusCol-=1:o._focusRow>0&&(typeof o.commitActiveRowEdit=="function"&&o._activeEditRows===o._focusRow&&o.commitActiveRowEdit(),o._focusRow-=1,o._focusCol=i),N(o);return}case"ArrowDown":n&&typeof o.commitActiveRowEdit=="function"&&o.commitActiveRowEdit(),o._focusRow=Math.min(t,o._focusRow+1),e.preventDefault();break;case"ArrowUp":n&&typeof o.commitActiveRowEdit=="function"&&o.commitActiveRowEdit(),o._focusRow=Math.max(0,o._focusRow-1),e.preventDefault();break;case"ArrowRight":o._focusCol=Math.min(i,o._focusCol+1),e.preventDefault();break;case"ArrowLeft":o._focusCol=Math.max(0,o._focusCol-1),e.preventDefault();break;case"Home":(e.ctrlKey||e.metaKey)&&(n&&typeof o.commitActiveRowEdit=="function"&&o.commitActiveRowEdit(),o._focusRow=0),o._focusCol=0,e.preventDefault(),N(o,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(n&&typeof o.commitActiveRowEdit=="function"&&o.commitActiveRowEdit(),o._focusRow=t),o._focusCol=i,e.preventDefault(),N(o,{forceScrollRight:!0});return;case"PageDown":o._focusRow=Math.min(t,o._focusRow+20),e.preventDefault();break;case"PageUp":o._focusRow=Math.max(0,o._focusRow-20),e.preventDefault();break;case"Enter":{const d=o._focusRow,u=o._focusCol,h=o._visibleColumns[u],f=o._rows[d],p=h?.field??"",g=p&&f?f[p]:void 0,w=o.querySelector(`[data-row="${d}"][data-col="${u}"]`),m={rowIndex:d,colIndex:u,field:p,value:g,row:f,cellEl:w,trigger:"keyboard",originalEvent:e},y=new CustomEvent("cell-activate",{cancelable:!0,detail:m});o.dispatchEvent(y);const b=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:d,col:u}});if(o.dispatchEvent(b),y.defaultPrevented||b.defaultPrevented){e.preventDefault();return}break}default:return}N(o)}}function N(o,e){if(o._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:a}=o._virtualization,c=l,d=a?.clientHeight??c?.clientHeight??0;if(c&&d>0){const u=o._focusRow*s;u<c.scrollTop?c.scrollTop=u:u+s>c.scrollTop+d&&(c.scrollTop=u-d+s)}}const t=o._activeEditRows!==void 0&&o._activeEditRows!==-1;t||o.refreshVirtualWindow(!1),oe(o._bodyEl),Array.from(o._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(s=>{s.setAttribute("aria-selected","false")});const i=o._focusRow,n=o._virtualization.start??0,r=o._virtualization.end??o._rows.length;if(i>=n&&i<r){const s=o._bodyEl.querySelectorAll(".data-grid-row")[i-n];let l=s?.children[o._focusCol];if((!l||!l.classList?.contains("cell"))&&(l=s?.querySelector(`.cell[data-col="${o._focusCol}"]`)??s?.querySelector(".cell[data-col]")),l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const a=o.querySelector(".tbw-scroll-area");if(a&&l&&!t)if(e?.forceScrollLeft)a.scrollLeft=0;else if(e?.forceScrollRight)a.scrollLeft=a.scrollWidth-a.clientWidth;else{const c=o._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!c.skipScroll){const d=l.getBoundingClientRect(),u=a.getBoundingClientRect(),h=d.left-u.left+a.scrollLeft,f=h+d.width,p=a.scrollLeft+c.left,g=a.scrollLeft+a.clientWidth-c.right;h<p?a.scrollLeft=h-c.left:f>g&&(a.scrollLeft=f-a.clientWidth+c.right)}}if(o._activeEditRows!==void 0&&o._activeEditRows!==-1&&l.classList.contains("editing")){const c=l.querySelector(et);if(c&&document.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}const ue=new WeakMap;function Hi(o,e){const t=me(e),i=Ti(e);t<0||i<0||(o._focusRow=t,o._focusCol=i,oe(o._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function Ce(o,e,t,i){let n=null;const r=t.composedPath?.();if(r&&r.length>0?n=r[0]:n=t.target,n&&!e.contains(n)){const g=document.elementFromPoint(t.clientX,t.clientY);g&&(n=g)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,u,h,f,p;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(u=o._rows[c],p=o._columns[d],h=p?.field,f=u&&h?u[h]:void 0)),{type:i,row:u,rowIndex:c!==void 0&&c>=0?c:void 0,colIndex:d!==void 0&&d>=0?d:void 0,field:h,value:f,column:p,originalEvent:t,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:c!==void 0&&d!==void 0&&c>=0&&d>=0?{row:c,col:d}:void 0}}function Ii(o,e,t){const i=Ce(o,e,t,"mousedown");(o._dispatchCellMouseDown?.(i)??!1)&&ue.set(o,!0)}function Mi(o,e,t){if(!ue.get(o))return;const i=Ce(o,e,t,"mousemove");o._dispatchCellMouseMove?.(i)}function Oi(o,e,t){if(!ue.get(o))return;const i=Ce(o,e,t,"mouseup");o._dispatchCellMouseUp?.(i),ue.set(o,!1)}function Ni(o,e,t){e.addEventListener("mousedown",i=>{const n=i.target.closest(".cell[data-col]");n&&(n.classList.contains("editing")||Hi(o,n))},{signal:t}),e.addEventListener("click",i=>{const n=i.target.closest(".data-grid-row");n&&ot(o,i,n)},{signal:t}),e.addEventListener("dblclick",i=>{const n=i.target.closest(".data-grid-row");n&&ot(o,i,n)},{signal:t})}function zi(o,e,t,i){e.addEventListener("keydown",n=>Di(o,n),{signal:i}),t.addEventListener("mousedown",n=>Ii(o,t,n),{signal:i}),document.addEventListener("mousemove",n=>Mi(o,t,n),{signal:i}),document.addEventListener("mouseup",n=>Oi(o,t,n),{signal:i})}function nt(o,e){return o==null&&e==null?0:o==null?-1:e==null||o>e?1:o<e?-1:0}function rt(o,e,t){const n=t.find(l=>l.field===e.field)?.sortComparator??nt,{field:r,direction:s}=e;return[...o].sort((l,a)=>n(l[r],a[r],l,a)*s)}function st(o,e,t,i){o._rows=e,o.__rowRenderEpoch++,o._rowPool.forEach(n=>n.__epoch=-1),he(o),o.refreshVirtualWindow(!0),o.dispatchEvent(new CustomEvent("sort-change",{detail:{field:t.field,direction:i}})),o.requestStateChange?.()}function lt(o,e){!o._sortState||o._sortState.field!==e.field?(o._sortState||(o.__originalOrder=o._rows.slice()),at(o,e,1)):o._sortState.direction===1?at(o,e,-1):(o._sortState=null,o.__rowRenderEpoch++,o._rowPool.forEach(i=>i.__epoch=-1),o._rows=o.__originalOrder.slice(),he(o),o._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(i=>{i.getAttribute("aria-sort")?(i.getAttribute("aria-sort")==="ascending"||i.getAttribute("aria-sort")==="descending")&&(o._sortState||i.setAttribute("aria-sort","none")):i.setAttribute("aria-sort","none")}),o.refreshVirtualWindow(!0),o.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),o.requestStateChange?.())}function at(o,e,t){o._sortState={field:e.field,direction:t};const i={field:e.field,direction:t},n=o._columns,s=(o.effectiveConfig?.sortHandler??rt)(o._rows,i,n);s&&typeof s.then=="function"?s.then(l=>{st(o,l,e,t)}):st(o,s,e,t)}function qi(o,e){typeof e=="string"?o.textContent=e:e instanceof HTMLElement&&(o.innerHTML="",o.appendChild(e.cloneNode(!0)))}function he(o){o._headerRowEl=o.findHeaderRow();const e=o._headerRowEl;e&&(e.innerHTML="",o._visibleColumns.forEach((t,i)=>{const n=document.createElement("div");n.className="cell",Ue(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",t.field),n.setAttribute("data-col",String(i));const r=t.__headerTemplate;if(r)Array.from(r.childNodes).forEach(s=>n.appendChild(s.cloneNode(!0)));else{const s=t.header??t.field,l=document.createElement("span");l.textContent=s,n.appendChild(l)}if(t.sortable){n.classList.add("sortable"),n.tabIndex=0;const s=document.createElement("span");Ue(s,"sort-indicator");const l=o._sortState?.field===t.field?o._sortState.direction:0,a={...F,...o.icons},c=l===1?a.sortAsc:l===-1?a.sortDesc:a.sortNone;qi(s,c),n.appendChild(s),n.setAttribute("aria-sort",l===0?"none":l===1?"ascending":"descending"),n.addEventListener("click",d=>{o._resizeController?.isResizing||o._dispatchHeaderClick?.(d,i,n)||lt(o,t)}),n.addEventListener("keydown",d=>{if(d.key==="Enter"||d.key===" "){if(d.preventDefault(),o._dispatchHeaderClick?.(d,i,n))return;lt(o,t)}})}if(t.resizable){n.classList.add("resizable");const s=document.createElement("div");s.className="resize-handle",s.setAttribute("aria-hidden","true"),s.addEventListener("mousedown",l=>{l.stopPropagation(),l.preventDefault(),o._resizeController.start(l,i,n)}),s.addEventListener("dblclick",l=>{l.stopPropagation(),l.preventDefault(),o._resizeController.resetColumn(i)}),n.appendChild(s)}e.appendChild(n)}),e.querySelectorAll(".cell.sortable").forEach(t=>{t.getAttribute("aria-sort")||t.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex")))}const ct=typeof requestIdleCallback=="function";function Fi(o,e){return ct?requestIdleCallback(o,e):window.setTimeout(()=>{const t=Date.now();o({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1)}function dt(o){ct?cancelIdleCallback(o):clearTimeout(o)}var D=(o=>(o[o.STYLE=1]="STYLE",o[o.VIRTUALIZATION=2]="VIRTUALIZATION",o[o.HEADER=3]="HEADER",o[o.ROWS=4]="ROWS",o[o.COLUMNS=5]="COLUMNS",o[o.FULL=6]="FULL",o))(D||{});class Gi{#e;#o=0;#d=0;#c=null;#s=null;#i=null;#h=!1;constructor(e){this.#e=e}requestPhase(e,t){e>this.#o&&(this.#o=e),this.#d===0&&(this.#u(),this.#d=requestAnimationFrame(()=>this.#p()))}whenReady(){return this.#c?this.#c:Promise.resolve()}setInitialReadyResolver(e){this.#i=e}cancel(){this.#d!==0&&(cancelAnimationFrame(this.#d),this.#d=0),this.#o=0,this.#s&&(this.#s(),this.#s=null,this.#c=null)}get isPending(){return this.#o!==0}get pendingPhase(){return this.#o}#u(){this.#c||(this.#c=new Promise(e=>{this.#s=e}))}#p(){if(this.#d=0,!this.#e.isConnected()){this.#o=0,this.#s&&(this.#s(),this.#s=null,this.#c=null);return}const e=this.#o;this.#o=0,e>=5&&this.#e.mergeConfig(),e>=4&&this.#e.processRows(),e>=5&&(this.#e.processColumns(),this.#e.updateTemplate()),e>=3&&this.#e.renderHeader(),e>=2&&this.#e.renderVirtualWindow(),e>=1&&this.#e.afterRender(),!this.#h&&this.#i&&(this.#h=!0,this.#i()),this.#s&&(this.#s(),this.#s=null,this.#c=null)}}function ut(o){let e=null,t=null,i=null,n=null;const r=a=>{if(!e)return;const c=a.clientX-e.startX,d=Math.max(40,e.startWidth+c),u=o._visibleColumns[e.colIndex];u.width=d,u.__userResized=!0,u.__renderedWidth=d,t==null&&(t=requestAnimationFrame(()=>{t=null,o.updateTemplate?.()})),o.dispatchEvent(new CustomEvent("column-resize",{detail:{field:u.field,width:d}}))};let s=!1;const l=()=>{const a=e!==null;a&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),i!==null&&(document.documentElement.style.cursor=i,i=null),n!==null&&(document.body.style.userSelect=n,n=null),e=null,a&&o.requestStateChange&&o.requestStateChange()};return{get isResizing(){return e!==null||s},start(a,c,d){a.preventDefault();const u=o._visibleColumns[c],h=typeof u?.width=="number"?u.width:void 0,f=u?.__renderedWidth??h??d.getBoundingClientRect().width;e={startX:a.clientX,colIndex:c,startWidth:f},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),i===null&&(i=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",n===null&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(a){const c=o._visibleColumns[a];c&&(c.__userResized=!1,c.__renderedWidth=void 0,c.width=c.__originalWidth,o.updateTemplate?.(),o.requestStateChange?.(),o.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:c.field,width:c.width}})))},dispose(){l()}}}function fe(o,e,t){const i=document.createElement(o);if(e)for(const n in e){const r=e[n];r!=null&&i.setAttribute(n,r)}return i}function M(o,e){const t=document.createElement("div");if(o&&(t.className=o),e)for(const i in e){const n=e[i];n!=null&&t.setAttribute(i,n)}return t}function ht(o,e,t){const i=document.createElement("button");if(o&&(i.className=o),e)for(const n in e){const r=e[n];r!=null&&i.setAttribute(n,r)}return i}const ft=document.createElement("template");ft.innerHTML=`
|
|
1
|
+
(function(y,Y){typeof exports=="object"&&typeof module<"u"?Y(exports):typeof define=="function"&&define.amd?define(["exports"],Y):(y=typeof globalThis<"u"?globalThis:y||self,Y(y.TbwGrid={}))})(this,(function(y){"use strict";const Y='@layer tbw-base,tbw-plugins,tbw-theme;@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #666666);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-input: 1px solid var(--tbw-color-border-strong);--tbw-border-header: 1px solid var(--tbw-color-border-header);--tbw-row-divider: 1px solid var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline: 2px solid var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-scrollbar-thumb: var(--tbw-color-border-strong);--tbw-scrollbar-track: var(--tbw-color-bg);--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm);position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none}tbw-grid,tbw-grid *{box-sizing:border-box}tbw-grid .header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}tbw-grid .header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}tbw-grid .header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start))}tbw-grid .header-group-cell:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30)}tbw-grid .header-row>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:visible;min-width:0}tbw-grid .header-row>.cell>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}tbw-grid .header-row>.cell>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;visibility:var(--tbw-sort-indicator-visibility, visible)}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row>.cell.resizable{position:relative}tbw-grid .header-row>.cell.sticky-left,tbw-grid .header-row>.cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}tbw-grid .tbw-grid-root{display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}tbw-grid .rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}tbw-grid .rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}tbw-grid .rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}tbw-grid .rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip}tbw-grid .rows-viewport .rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}tbw-grid .faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30)}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style;content-visibility:auto;contain-intrinsic-size:auto var(--tbw-row-height)}tbw-grid .data-grid-row:nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid .data-grid-row:hover{background:var(--tbw-color-row-hover)}tbw-grid .data-grid-row>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);line-height:calc(var(--tbw-row-height) - 5px);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis}tbw-grid .data-grid-row>.cell>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}tbw-grid .data-grid-row>.cell:last-child{border-right:0}tbw-grid .data-grid-row>.cell[data-type=boolean]{text-align:center}tbw-grid .data-grid-row>.cell[data-type=boolean] input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}tbw-grid .data-grid-row>.cell.selected:focus-visible,tbw-grid .data-grid-row>.cell:focus-visible:not(.cell-focus){outline:none}tbw-grid .data-grid-row>.cell.sticky-left,tbw-grid .data-grid-row>.cell.sticky-right{background:var(--tbw-color-panel-bg)}tbw-grid .selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid .sortable{cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;-webkit-user-select:none;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius)}tbw-grid .resize-handle:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}tbw-grid .resize-handle:hover{background:var(--tbw-resize-handle-color-hover)}tbw-grid .resize-handle:hover:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}tbw-grid[data-has-focus] .cell-focus,tbw-grid[data-has-focus] .row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .sticky-left,tbw-grid .sticky-right{position:sticky;z-index:25}tbw-grid .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}tbw-grid .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}tbw-grid .tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}tbw-grid .tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}tbw-grid .tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}tbw-grid .tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-toolbar-btn:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-toolbar-btn:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}tbw-grid .tbw-toolbar-btn.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}tbw-grid .tbw-toolbar-btn:disabled{opacity:.5;cursor:not-allowed}tbw-grid .tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}tbw-grid .tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}tbw-grid .tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}tbw-grid .tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}tbw-grid .tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}tbw-grid .tbw-tool-panel.open{width:var(--tbw-tool-panel-width)}tbw-grid .tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease)}tbw-grid .tbw-tool-panel-resize[data-handle-position=left]{left:0}tbw-grid .tbw-tool-panel-resize[data-handle-position=right]{right:0}tbw-grid .tbw-tool-panel-resize:hover,tbw-grid .tbw-tool-panel-resize.resizing{background:var(--tbw-color-accent)}tbw-grid .tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}tbw-grid .tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}tbw-grid .tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px}tbw-grid .tbw-tool-panel-close:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}tbw-grid .tbw-tool-panel-content{flex:1;overflow:auto}tbw-grid .tbw-accordion{display:flex;flex-direction:column;gap:0}tbw-grid .tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border)}tbw-grid .tbw-accordion-section:last-child{border-bottom:none}tbw-grid .tbw-accordion-section.single .tbw-accordion-header{cursor:default}tbw-grid .tbw-accordion-section.single .tbw-accordion-header:hover{background:transparent}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-chevron{transform:rotate(90deg)}tbw-grid .tbw-accordion-section.expanded .tbw-accordion-content{display:block}tbw-grid .tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none}tbw-grid .tbw-accordion-header:hover{background:var(--tbw-color-row-hover)}tbw-grid .tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}tbw-grid .tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}tbw-grid .tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}tbw-grid .tbw-accordion-content{display:none}tbw-grid .tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}tbw-grid .tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}tbw-grid[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}tbw-grid[data-animation-mode=off] .data-grid-row[data-animating]{animation:none}@media(forced-colors:active){tbw-grid{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight}tbw-grid .cell:focus,tbw-grid .cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}tbw-grid .data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms}tbw-grid[data-animation-mode=reduced-motion] .data-grid-row[data-animating]{animation:none}}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-row-change{0%{background-color:transparent}20%{background-color:var(--tbw-row-change-color)}to{background-color:transparent}}@keyframes tbw-row-insert{0%{opacity:0;max-height:0;overflow:hidden}to{opacity:1;max-height:var(--tbw-row-height, 28px);overflow:hidden}}@keyframes tbw-row-remove{0%{opacity:1;transform:translateY(0);max-height:var(--tbw-row-height, 28px)}to{opacity:0;max-height:0;transform:translateY(-8px)}}tbw-grid .data-grid-row[data-animating=change]{animation:tbw-row-change var(--tbw-row-change-duration) ease-out}tbw-grid .data-grid-row[data-animating=insert]{animation:tbw-row-insert var(--tbw-row-insert-duration) ease-out;will-change:max-height,opacity}tbw-grid .data-grid-row[data-animating=remove]{animation:tbw-row-remove var(--tbw-row-remove-duration) ease-out forwards;will-change:max-height,opacity,transform;pointer-events:none}}',X={STRETCH:"stretch",FIXED:"fixed"},je={mode:"reduced-motion",duration:200,easing:"ease-out"},Ye='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',q={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:Ye,filterActive:Ye};function mi(o){return Array.from(o.querySelectorAll("tbw-grid-column")).map(t=>{const i=t.getAttribute("field")||"";if(!i)return null;const n=t.getAttribute("type")||void 0,s=n&&new Set(["number","string","date","boolean","select"]).has(n)?n:void 0,l=t.getAttribute("header")||void 0,a=t.hasAttribute("sortable"),c=t.hasAttribute("editable"),d={field:i,type:s,header:l,sortable:a,editable:c},u=t.getAttribute("width");if(u){const _=parseFloat(u);!isNaN(_)&&/^\d+(\.\d+)?$/.test(u.trim())?d.width=_:d.width=u}const h=t.getAttribute("minWidth")||t.getAttribute("min-width");if(h){const _=parseFloat(h);isNaN(_)||(d.minWidth=_)}t.hasAttribute("resizable")&&(d.resizable=!0),t.hasAttribute("sizable")&&(d.resizable=!0);const f=t.getAttribute("editor"),p=t.getAttribute("renderer");f&&(d.__editorName=f),p&&(d.__rendererName=p);const g=t.getAttribute("options");g&&(d.options=g.split(",").map(_=>{const[S,x]=_.includes(":")?_.split(":"):[_.trim(),_.trim()];return{value:S.trim(),label:x?.trim()||S.trim()}}));const w=t.querySelector("tbw-grid-column-view"),m=t.querySelector("tbw-grid-column-editor"),v=t.querySelector("tbw-grid-column-header");w&&(d.__viewTemplate=w),m&&(d.__editorTemplate=m),v&&(d.__headerTemplate=v);const R=globalThis.DataGridElement?.getAdapters?.()??[],C=w??t,k=R.find(_=>_.canHandle(C));if(k){const _=k.createRenderer(C);_&&(d.viewRenderer=_)}const A=m??t,E=R.find(_=>_.canHandle(A));if(E){const _=E.createEditor(A);_&&(d.editor=_)}return d}).filter(t=>!!t)}function Xe(o,e){if((!o||!o.length)&&(!e||!e.length))return[];if(!o||!o.length)return e||[];if(!e||!e.length)return o;const t={};e.forEach(n=>{const r=t[n.field];if(r){n.header&&!r.header&&(r.header=n.header),n.type&&!r.type&&(r.type=n.type),n.sortable&&(r.sortable=!0),n.editable&&(r.editable=!0),n.resizable&&(r.resizable=!0),n.width!=null&&r.width==null&&(r.width=n.width),n.minWidth!=null&&r.minWidth==null&&(r.minWidth=n.minWidth),n.__viewTemplate&&(r.__viewTemplate=n.__viewTemplate),n.__editorTemplate&&(r.__editorTemplate=n.__editorTemplate),n.__headerTemplate&&(r.__headerTemplate=n.__headerTemplate);const s=n.renderer||n.viewRenderer,l=r.renderer||r.viewRenderer;s&&!l&&(r.viewRenderer=s,n.renderer&&(r.renderer=s)),n.editor&&!r.editor&&(r.editor=n.editor)}else t[n.field]={...n}});const i=o.map(n=>{const r=t[n.field];if(!r)return n;const s={...n};r.header&&!s.header&&(s.header=r.header),r.type&&!s.type&&(s.type=r.type),s.sortable=n.sortable||r.sortable,(n.resizable===!0||r.resizable===!0)&&(s.resizable=!0),s.editable=n.editable||r.editable,r.width!=null&&s.width==null&&(s.width=r.width),r.minWidth!=null&&s.minWidth==null&&(s.minWidth=r.minWidth),r.__viewTemplate&&(s.__viewTemplate=r.__viewTemplate),r.__editorTemplate&&(s.__editorTemplate=r.__editorTemplate),r.__headerTemplate&&(s.__headerTemplate=r.__headerTemplate);const l=r.renderer||r.viewRenderer,a=s.renderer||s.viewRenderer;return l&&!a&&(s.viewRenderer=l,r.renderer&&(s.renderer=l)),r.editor&&!s.editor&&(s.editor=r.editor),delete t[n.field],s});return Object.keys(t).forEach(n=>i.push(t[n])),i}function Ze(o,e){try{o.part?.add?.(e)}catch{}const t=o.getAttribute("part");t?t.split(/\s+/).includes(e)||o.setAttribute("part",t+" "+e):o.setAttribute("part",e)}function Je(o){const e=o.effectiveConfig?.fitMode||o.fitMode||X.STRETCH;if(e!==X.STRETCH&&e!==X.FIXED||o.__didInitialAutoSize||!o.isConnected)return;const t=Array.from(o._headerRowEl?.children||[]);if(!t.length)return;let i=!1;o._visibleColumns.forEach((n,r)=>{if(n.width)return;const s=t[r];let l=s?s.scrollWidth:0;for(const a of o._rowPool){const c=a.children[r];if(c){const d=c.scrollWidth;d>l&&(l=d)}}l>0&&(n.width=l+2,n.__autoSized=!0,i=!0)}),i&&ie(o),o.__didInitialAutoSize=!0}function ie(o){(o.effectiveConfig?.fitMode||o.fitMode||X.STRETCH)===X.STRETCH?o._gridTemplate=o._visibleColumns.map(t=>{if(t.width)return`${t.width}px`;const i=t.minWidth;return i!=null?`minmax(${i}px, 1fr)`:"1fr"}).join(" ").trim():o._gridTemplate=o._visibleColumns.map(t=>t.width?`${t.width}px`:"max-content").join(" "),o.style.setProperty("--tbw-column-template",o._gridTemplate)}function bi(o){return o==null?"string":typeof o=="number"?"number":typeof o=="boolean"?"boolean":o instanceof Date||typeof o=="string"&&/\d{4}-\d{2}-\d{2}/.test(o)&&!isNaN(Date.parse(o))?"date":"string"}function vi(o,e){const t=o[0]||{},i=Object.keys(t).map(r=>{const s=t[r],l=bi(s);return{field:r,header:r.charAt(0).toUpperCase()+r.slice(1),type:l}}),n={};return i.forEach(r=>{n[r.field]=r.type||"string"}),{columns:i,typeMap:n}}const yi=/{{\s*([^}]+)\s*}}/g,z="__DG_EMPTY__",Ci=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,xi=/__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/;function Ri(o){return!o||typeof o!="string"?"":o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const Ei=new Set(["script","iframe","object","embed","form","input","button","textarea","select","link","meta","base","style","template","slot","portal","frame","frameset","applet","noscript","noembed","plaintext","xmp","listing"]),Qe=/^on\w+$/i,Si=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),_i=/^\s*(javascript|vbscript|data|blob):/i;function oe(o){if(!o||typeof o!="string")return"";if(o.indexOf("<")===-1)return o;const e=document.createElement("template");return e.innerHTML=o,Ai(e.content),e.innerHTML}function Ai(o){const e=[],t=o.querySelectorAll("*");for(const i of t){const n=i.tagName.toLowerCase();if(Ei.has(n)){e.push(i);continue}if((n==="svg"||i.namespaceURI==="http://www.w3.org/2000/svg")&&Array.from(i.attributes).some(l=>Qe.test(l.name)||l.name==="href"||l.name==="xlink:href")){e.push(i);continue}const r=[];for(const s of i.attributes){const l=s.name.toLowerCase();if(Qe.test(l)){r.push(s.name);continue}if(Si.has(l)&&_i.test(s.value)){r.push(s.name);continue}if(l==="style"&&/expression\s*\(|javascript:|behavior\s*:/i.test(s.value)){r.push(s.name);continue}}r.forEach(s=>i.removeAttribute(s))}e.forEach(i=>i.remove())}function me(o,e){if(!o||o.indexOf("{{")===-1)return o;const t=[],i=o.replace(yi,(l,a)=>{const c=ki(a,e);return t.push({expr:a.trim(),result:c}),c}),n=Ti(i),r=t.length&&t.every(l=>l.result===""||l.result===z);return/Reflect\.|\bProxy\b|ownKeys\(/.test(o)||r?"":n}function ki(o,e){if(o=(o||"").trim(),!o||/\b(Reflect|Proxy|ownKeys)\b/.test(o))return z;if(o==="value")return e.value==null?z:String(e.value);if(o.startsWith("row.")&&!/[()?]/.test(o)&&!o.includes(":")){const i=o.slice(4),n=e.row?e.row[i]:void 0;return n==null?z:String(n)}if(o.length>80||!Ci.test(o)||xi.test(o))return z;const t=o.match(/\./g);if(t&&t.length>1)return z;try{const n=new Function("value","row",`return (${o});`)(e.value,e.row),r=n==null?"":String(n);return/Reflect|Proxy|ownKeys/.test(r)?z:r||z}catch{return z}}function Ti(o){return o&&o.replace(new RegExp(z,"g"),"").replace(/Reflect\.[^<>{}\s]+/g,"").replace(/\bProxy\b/g,"").replace(/ownKeys\([^)]*\)/g,"")}function Pi(o){if(/Reflect|Proxy|ownKeys/.test(o.textContent||"")){if(Array.from(o.childNodes).forEach(e=>{e.nodeType===Node.TEXT_NODE&&/Reflect|Proxy|ownKeys/.test(e.textContent||"")&&(e.textContent="")}),/Reflect|Proxy|ownKeys/.test(o.textContent||"")){if(/Reflect|Proxy|ownKeys/.test(o.textContent||""))for(;o.firstChild;)o.removeChild(o.firstChild);o.textContent=(o.textContent||"").replace(/Reflect|Proxy|ownKeys/g,"")}(o.textContent||"").trim().length===0&&(o.textContent="")}}function et(o){const e=/Reflect\.|\bProxy\b|ownKeys\(/.test(o),t=(i=>e?"":me(o,i));return t.__blocked=e,t}const Li=100;class Di{#e;#o;#d;#c;#s;#i={};#h={};#u=!0;#p=[];#l;#w;#m;#a;#b;constructor(e){this.#a=e}get original(){return this.#i}get effective(){return this.#h}get columns(){return this.#h.columns??[]}set columns(e){this.#h.columns=e}get lightDomColumnsCache(){return this.#c}set lightDomColumnsCache(e){this.#c=e}get originalColumnNodes(){return this.#s}set originalColumnNodes(e){this.#s=e}get lightDomTitle(){return this.#b}set lightDomTitle(e){this.#b=e}get initialColumnState(){return this.#m}set initialColumnState(e){this.#m=e}get sourcesChanged(){return this.#u}markSourcesChanged(){this.#u=!0}setGridConfig(e){this.#e=e,this.#u=!0,this.#c=void 0}getGridConfig(){return this.#e}setColumns(e){this.#o=e,this.#u=!0}getColumns(){return this.#o}setFitMode(e){this.#d=e,this.#u=!0}getFitMode(){return this.#d}merge(){const e=(this.#h.columns?.length??0)>0;if(!this.#u&&e)return;const t=this.#y();this.#u=!1,this.#i=t,Object.freeze(this.#i),this.#i.columns&&Object.freeze(this.#i.columns),this.#h=this.#v(this.#i),this.#g()}#v(e){const t={...e};return e.columns&&(t.columns=e.columns.map(i=>({...i}))),e.shell&&(t.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(i=>({...i})),headerContents:e.shell.headerContents?.map(i=>({...i}))}),t}#g(){const e=this.#h;e.rowHeight&&e.rowHeight>0&&this.#a.setRowHeight(e.rowHeight),e.fitMode==="fixed"&&this.columns.forEach(i=>{i.width==null&&(i.width=80)}),this.#a.applyAnimationConfig(e)}#y(){const e=this.#e?{...this.#e}:{},t=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#c??[]).map(s=>({...s}));let n=Xe(t,i);this.#o&&this.#o.length&&(n=Xe(this.#o,i));const r=this.#a.getRows();return n.length===0&&r.length&&(n=vi(r).columns),n.length&&(n.forEach(s=>{s.sortable===void 0&&(s.sortable=!0),s.resizable===void 0&&(s.resizable=!0),s.__originalWidth===void 0&&typeof s.width=="number"&&(s.__originalWidth=s.width)}),n.forEach(s=>{s.__viewTemplate&&!s.__compiledView&&(s.__compiledView=et(s.__viewTemplate.innerHTML)),s.__editorTemplate&&!s.__compiledEditor&&(s.__compiledEditor=et(s.__editorTemplate.innerHTML))}),e.columns=n),this.#d&&(e.fitMode=this.#d),e.fitMode||(e.fitMode="stretch"),this.#x(e),e.columnState&&!this.#m&&(this.#m=e.columnState),e}#x(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const t=this.#a.getShellLightDomTitle();t&&(this.#b=t),this.#b&&!e.shell.header.title&&(e.shell.header.title=this.#b);const i=this.#a.getShellLightDomHeaderContent();i?.length>0&&(e.shell.header.lightDomContent=i),this.#a.getShellHasToolButtonsContainer()&&(e.shell.header.hasToolButtonsContainer=!0);const n=this.#a.getShellToolPanels();if(n.size>0){const u=Array.from(n.values());u.sort((h,f)=>(h.order??100)-(f.order??100)),e.shell.toolPanels=u}const r=this.#a.getShellHeaderContents();if(r.size>0){const u=Array.from(r.values());u.sort((h,f)=>(h.order??100)-(f.order??100)),e.shell.headerContents=u}const s=this.#a.getShellToolbarContents(),l=Array.from(s.values()),a=this.#e?.shell?.header?.toolbarContents??[],c=new Set(a.map(u=>u.id)),d=[...a];for(const u of l)c.has(u.id)||d.push(u);d.sort((u,h)=>(u.order??0)-(h.order??0)),e.shell.header.toolbarContents=d}collectState(e){const t=this.columns,i=this.#C();return{columns:t.map((n,r)=>{const s={field:n.field,order:r,visible:!n.hidden},l=n;l.__renderedWidth!==void 0?s.width=l.__renderedWidth:n.width!==void 0&&(s.width=typeof n.width=="string"?parseFloat(n.width):n.width);const a=i.get(n.field);a&&(s.sort=a);for(const c of e)if(c.getColumnState){const d=c.getColumnState(n.field);d&&Object.assign(s,d)}return s})}}applyState(e,t){if(!e.columns||e.columns.length===0)return;const i=this.columns,n=new Map(e.columns.map(l=>[l.field,l])),r=i.map(l=>{const a=n.get(l.field);if(!a)return l;const c={...l};return a.width!==void 0&&(c.width=a.width,c.__renderedWidth=a.width),a.visible!==void 0&&(c.hidden=!a.visible),c});r.sort((l,a)=>{const c=n.get(l.field)?.order??1/0,d=n.get(a.field)?.order??1/0;return c-d}),this.columns=r;const s=e.columns.filter(l=>l.sort!==void 0).sort((l,a)=>(l.sort?.priority??0)-(a.sort?.priority??0));if(s.length>0){const l=s[0];l.sort&&this.#a.setSortState({field:l.field,direction:l.sort.direction==="asc"?1:-1})}else this.#a.setSortState(null);for(const l of t)if(l.applyColumnState)for(const a of e.columns)l.applyColumnState(a.field,a)}resetState(e){this.#m=void 0,this.#a.setSortState(null),this.#h=this.#v(this.#i),this.#g();for(const t of e)if(t.applyColumnState)for(const i of this.columns)t.applyColumnState(i.field,{field:i.field,order:0,visible:!0});this.requestStateChange(e)}#C(){const e=new Map,t=this.#a.getSortState();return t&&e.set(t.field,{direction:t.direction===1?"asc":"desc",priority:0}),e}requestStateChange(e){this.#w&&clearTimeout(this.#w),this.#w=setTimeout(()=>{this.#w=void 0;const t=this.collectState(e);this.#a.emit("column-state-change",t)},Li)}setColumnVisible(e,t){const i=this.columns,n=i.find(s=>s.field===e);return!n||!t&&n.lockVisible||!t&&i.filter(l=>!l.hidden&&l.field!==e).length===0||!!n.hidden===!t?!1:(n.hidden=!t,this.#a.emit("column-visibility",{field:e,visible:t,visibleColumns:i.filter(s=>!s.hidden).map(s=>s.field)}),this.#a.clearRowPool(),this.#a.setup(),!0)}toggleColumnVisibility(e){const t=this.columns.find(i=>i.field===e);return t?this.setColumnVisible(e,!!t.hidden):!1}isColumnVisible(e){const t=this.columns.find(i=>i.field===e);return t?!t.hidden:!1}showAllColumns(){const e=this.columns;e.some(t=>t.hidden)&&(e.forEach(t=>t.hidden=!1),this.#a.emit("column-visibility",{visibleColumns:e.map(t=>t.field)}),this.#a.clearRowPool(),this.#a.setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:e.meta?.utility===!0}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const t=new Map(this.columns.map(n=>[n.field,n])),i=[];for(const n of e){const r=t.get(n);r&&(i.push(r),t.delete(n))}for(const n of t.values())i.push(n);this.columns=i,this.#a.renderHeader(),this.#a.updateTemplate(),this.#a.refreshVirtualWindow()}parseLightDomColumns(e){this.#c||(this.#s=Array.from(e.querySelectorAll("tbw-grid-column")),this.#c=this.#s.length?mi(e):[])}clearLightDomCache(){this.#c=void 0}#R=new Map;registerLightDomHandler(e,t){this.#R.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#R.delete(e.toLowerCase())}observeLightDOM(e){this.#l&&this.#l.disconnect();const t=new Set;let i=null;const n=()=>{i=null;for(const r of t)this.#R.get(r)?.();t.clear()};this.#l=new MutationObserver(r=>{for(const s of r){for(const l of s.addedNodes){if(l.nodeType!==Node.ELEMENT_NODE)continue;const c=l.tagName.toLowerCase();this.#R.has(c)&&t.add(c)}if(s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE){const a=s.target.tagName.toLowerCase();this.#R.has(a)&&t.add(a)}}t.size>0&&!i&&(i=setTimeout(n,0))}),this.#l.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#p.push(e)}notifyChange(){for(const e of this.#p)e()}dispose(){this.#l?.disconnect(),this.#p=[],this.#w&&clearTimeout(this.#w)}}function tt(o){return`<span role="checkbox" aria-checked="${o}" aria-label="${o}">${o?"🗹":"☐"}</span>`}function it(o){if(o==null||o==="")return"";if(o instanceof Date)return isNaN(o.getTime())?"":o.toLocaleDateString();if(typeof o=="number"||typeof o=="string"){const e=new Date(o);return isNaN(e.getTime())?"":e.toLocaleDateString()}return""}function be(o){if(!o)return-1;const e=o.getAttribute("data-row");if(e)return parseInt(e,10);const t=o.closest(".data-grid-row");if(!t)return-1;const i=t.parentElement;if(!i)return-1;const n=i.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===t)return r;return-1}function Hi(o){if(!o)return-1;const e=o.getAttribute("data-col");return e?parseInt(e,10):-1}function ne(o){o&&o.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function ot(o,e){const t=e.renderer||e.viewRenderer;if(t)return t;if(!e.type)return;const i=o.effectiveConfig?.typeDefaults;if(i?.[e.type]?.renderer)return i[e.type].renderer;const n=o.__frameworkAdapter;if(n?.getTypeDefault){const r=n.getTypeDefault(e.type);if(r?.renderer)return r.renderer}}const nt='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function ve(o){return(o.__editingCellCount??0)>0}function ye(o){o.__editingCellCount=0,o.removeAttribute("data-has-editing"),o.querySelectorAll(".cell.editing").forEach(t=>t.classList.remove("editing"))}const rt=document.createElement("template");rt.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const st=document.createElement("template");st.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';function Ii(){return rt.content.firstElementChild.cloneNode(!0)}function Mi(){return st.content.firstElementChild.cloneNode(!0)}function ue(o){o.__cellDisplayCache=void 0,o.__cellCacheEpoch=void 0,o.__hasSpecialColumns=void 0}function Oi(o,e,t,i,n){const r=Math.max(0,t-e),s=o._bodyEl,l=o._visibleColumns,a=l.length;let c=o.__cachedHeaderRowCount;for(c===void 0&&(c=o.querySelector(".header-group-row")?2:1,o.__cachedHeaderRowCount=c);o._rowPool.length<r;){const h=Mi();o._rowPool.push(h)}if(o._rowPool.length>r){for(let h=r;h<o._rowPool.length;h++){const f=o._rowPool[h];f.parentNode===s&&f.remove()}o._rowPool.length=r}const d=n&&o.__hasRenderRowPlugins!==!1,u=o._hasAfterRowRenderHook?.()??!1;for(let h=0;h<r;h++){const f=e+h,p=o._rows[f],g=o._rowPool[h];if(g.setAttribute("aria-rowindex",String(f+c+1)),d&&n(p,g,f)){g.__epoch=i,g.__rowDataRef=p,g.parentNode!==s&&s.appendChild(g);continue}const w=g.__epoch,m=g.__rowDataRef,v=g.children.length,R=w===i&&v===a,C=m!==p;let k=!1;if(R&&C){for(let x=0;x<a;x++)if(l[x].externalView&&!g.querySelector(`.cell[data-col="${x}"] [data-external-view]`)){k=!0;break}}if(!R||k){const x=ve(g),P=o._activeEditRows===f;x&&!P?(g.__isCustomRow&&(g.className="data-grid-row",g.setAttribute("role","row"),g.__isCustomRow=!1),ye(g),re(o,g,p,f),g.__epoch=i,g.__rowDataRef=p):x&&P?(Ce(o,g,p,f),g.__rowDataRef=p):(g.__isCustomRow&&(g.className="data-grid-row",g.setAttribute("role","row"),g.__isCustomRow=!1),re(o,g,p,f),g.__epoch=i,g.__rowDataRef=p)}else if(C){const x=ve(g),P=o._activeEditRows===f;x&&!P?(ye(g),re(o,g,p,f),g.__epoch=i,g.__rowDataRef=p):(Ce(o,g,p,f),g.__rowDataRef=p)}else{const x=ve(g),P=o._activeEditRows===f;x&&!P?(ye(g),re(o,g,p,f),g.__epoch=i,g.__rowDataRef=p):Ce(o,g,p,f)}let A=!1;const E=o.changedRowIds;if(E&&E.length>0)try{const x=o.getRowId?.(p);x&&(A=E.includes(x))}catch{}const _=g.classList.contains("changed");A!==_&&g.classList.toggle("changed",A);const S=o.effectiveConfig?.rowClass;if(S){const x=g.getAttribute("data-dynamic-classes");x&&x.split(" ").forEach(P=>P&&g.classList.remove(P));try{const P=S(p);if(P&&P.length>0){const L=P.filter(T=>T&&typeof T=="string");L.forEach(T=>g.classList.add(T)),g.setAttribute("data-dynamic-classes",L.join(" "))}else g.removeAttribute("data-dynamic-classes")}catch(P){console.warn("[tbw-grid] rowClass callback error:",P),g.removeAttribute("data-dynamic-classes")}}u&&o._afterRowRender?.({row:p,rowIndex:f,rowElement:g}),g.parentNode!==s&&s.appendChild(g)}}function Ce(o,e,t,i){const n=e.children,r=o._visibleColumns,s=r.length,l=n.length,a=s<l?s:l,c=o._focusRow,d=o._focusCol,u=o._hasAfterCellRenderHook?.()??!1;let h=o.__hasSpecialColumns;if(h===void 0){h=!1;const p=o.effectiveConfig?.typeDefaults,g=o.__frameworkAdapter;for(let w=0;w<s;w++){const m=r[w];if(m.__viewTemplate||m.__compiledView||m.renderer||m.viewRenderer||m.externalView||m.format||m.type==="date"||m.type==="boolean"||m.type&&p?.[m.type]?.renderer||m.type&&g?.getTypeDefault?.(m.type)?.renderer){h=!0;break}}o.__hasSpecialColumns=h}const f=String(i);if(!h){for(let p=0;p<a;p++){const g=n[p];if(g.classList.contains("editing"))continue;const w=r[p],m=t[w.field];g.textContent=m==null?"":String(m),g.getAttribute("data-row")!==f&&g.setAttribute("data-row",f);const v=c===i&&d===p,b=g.classList.contains("cell-focus");v!==b&&(g.classList.toggle("cell-focus",v),g.setAttribute("aria-selected",String(v))),u&&o._afterCellRender?.({row:t,rowIndex:i,column:w,colIndex:p,value:m,cellElement:g,rowElement:e})}return}for(let p=0;p<a;p++)if(r[p].externalView&&!n[p].querySelector("[data-external-view]")){re(o,e,t,i);return}for(let p=0;p<a;p++){const g=r[p],w=n[p];w.getAttribute("data-row")!==f&&w.setAttribute("data-row",f);const m=c===i&&d===p,v=w.classList.contains("cell-focus");m!==v&&(w.classList.toggle("cell-focus",m),w.setAttribute("aria-selected",String(m)));const b=g.cellClass;if(b){const A=w.getAttribute("data-dynamic-classes");A&&A.split(" ").forEach(E=>E&&w.classList.remove(E));try{const E=t[g.field],_=b(E,t,g);if(_&&_.length>0){const S=_.filter(x=>x&&typeof x=="string");S.forEach(x=>w.classList.add(x)),w.setAttribute("data-dynamic-classes",S.join(" "))}else w.removeAttribute("data-dynamic-classes")}catch(E){console.warn(`[tbw-grid] cellClass callback error for column '${g.field}':`,E),w.removeAttribute("data-dynamic-classes")}}if(w.classList.contains("editing"))continue;const R=ot(o,g);if(R){const A=t[g.field],E=R({row:t,value:A,field:g.field,column:g,cellEl:w});typeof E=="string"?w.innerHTML=oe(E):E instanceof Node?E.parentElement!==w&&(w.innerHTML="",w.appendChild(E)):E==null&&(w.textContent=A==null?"":String(A)),u&&o._afterCellRender?.({row:t,rowIndex:i,column:g,colIndex:p,value:A,cellElement:w,rowElement:e});continue}if(g.__viewTemplate||g.__compiledView||g.externalView)continue;const C=t[g.field];let k;if(g.format)try{const A=g.format(C,t);k=A==null?"":String(A)}catch(A){console.warn(`[tbw-grid] Format error in column '${g.field}':`,A),k=C==null?"":String(C)}else g.type==="date"?(k=it(C),w.textContent=k):g.type==="boolean"?w.innerHTML=tt(!!C):(k=C==null?"":String(C),w.textContent=k);u&&o._afterCellRender?.({row:t,rowIndex:i,column:g,colIndex:p,value:C,cellElement:w,rowElement:e})}}function re(o,e,t,i){e.innerHTML="";const n=o._visibleColumns,r=n.length,s=o._focusRow,l=o._focusCol,a=o,c=o._hasAfterCellRenderHook?.()??!1,d=document.createDocumentFragment();for(let u=0;u<r;u++){const h=n[u],f=Ii();f.setAttribute("aria-colindex",String(u+1)),f.setAttribute("data-col",String(u)),f.setAttribute("data-row",String(i)),f.setAttribute("data-field",h.field),f.setAttribute("data-header",h.header??h.field),h.type&&f.setAttribute("data-type",h.type);let p=t[h.field];if(h.format)try{p=h.format(p,t)}catch(C){console.warn(`[tbw-grid] Format error in column '${h.field}':`,C)}const g=h.__compiledView,w=h.__viewTemplate,m=ot(o,h),v=h.externalView;let b=!1;if(m){const C=m({row:t,value:p,field:h.field,column:h,cellEl:f});typeof C=="string"?(f.innerHTML=oe(C),b=!0):C instanceof Node?C.parentElement!==f&&(f.textContent="",f.appendChild(C)):C==null&&(f.textContent=p==null?"":String(p))}else if(v){const C=v,k=document.createElement("div");k.setAttribute("data-external-view",""),k.setAttribute("data-field",h.field),f.appendChild(k);const A={row:t,value:p,field:h.field,column:h};if(C.mount)try{C.mount({placeholder:k,context:A,spec:C})}catch(E){console.warn(`[tbw-grid] External view mount error for column '${h.field}':`,E)}else queueMicrotask(()=>{try{a.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:k,spec:C,context:A}}))}catch(E){console.warn(`[tbw-grid] External view event dispatch error for column '${h.field}':`,E)}});k.setAttribute("data-mounted","")}else if(g){const C=g({row:t,value:p,field:h.field,column:h}),k=g.__blocked;f.innerHTML=k?"":oe(C),b=!0,k&&(f.textContent="",f.setAttribute("data-blocked-template",""))}else if(w){const C=w.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(C)?(f.textContent="",f.setAttribute("data-blocked-template","")):(f.innerHTML=oe(me(C,{row:t,value:p})),b=!0)}else h.type==="date"?f.textContent=it(p):h.type==="boolean"?f.innerHTML=tt(!!p):f.textContent=p==null?"":String(p);if(b){Pi(f);const C=f.textContent||"";/Proxy|Reflect\.ownKeys/.test(C)&&(f.textContent=C.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(f.textContent||"")&&(f.textContent=""))}f.hasAttribute("data-blocked-template")&&(f.textContent||"").trim().length&&(f.textContent=""),h.editable?f.tabIndex=0:h.type==="boolean"&&(f.hasAttribute("tabindex")||(f.tabIndex=0)),s===i&&l===u?(f.classList.add("cell-focus"),f.setAttribute("aria-selected","true")):f.setAttribute("aria-selected","false");const R=h.cellClass;if(R)try{const C=t[h.field],k=R(C,t,h);if(k&&k.length>0){const A=k.filter(E=>E&&typeof E=="string");A.forEach(E=>f.classList.add(E)),f.setAttribute("data-dynamic-classes",A.join(" "))}}catch(C){console.warn(`[tbw-grid] cellClass callback error for column '${h.field}':`,C)}c&&o._afterCellRender?.({row:t,rowIndex:i,column:h,colIndex:u,value:p,cellElement:f,rowElement:e}),d.appendChild(f)}e.appendChild(d)}function lt(o,e,t){if(e.target?.closest(".resize-handle"))return;const i=t.querySelector(".cell[data-row]"),n=be(i);if(n<0)return;const r=o._rows[n];if(!r||o._dispatchRowClick?.(e,n,r,t))return;const s=e.target?.closest(".cell[data-col]");if(s){const l=Number(s.getAttribute("data-col"));if(!isNaN(l)){if(o._dispatchCellClick?.(e,n,l,s))return;const a=o._focusRow!==n||o._focusCol!==l;if(o._focusRow=n,o._focusCol=l,s.classList.contains("editing")){a&&(ne(o._bodyEl??o),s.classList.add("cell-focus"));const c=s.querySelector(nt);try{c?.focus({preventScroll:!0})}catch{}return}N(o)}}}function Ni(o,e){if(o._dispatchKeyDown?.(e))return;const t=o._rows.length-1,i=o._visibleColumns.length-1,n=o._activeEditRows!==void 0&&o._activeEditRows!==-1,s=o._visibleColumns[o._focusCol]?.type,l=e.composedPath?.()??[],a=l.length?l[0]:e.target,c=d=>{if(!d)return!1;const u=d.tagName;return!!(u==="INPUT"||u==="SELECT"||u==="TEXTAREA"||d.isContentEditable)};if(!(c(a)&&(e.key==="Home"||e.key==="End"))&&!(c(a)&&(e.key==="ArrowUp"||e.key==="ArrowDown")&&a.tagName==="INPUT"&&a.type==="number")&&!(c(a)&&(e.key==="ArrowLeft"||e.key==="ArrowRight"))&&!(c(a)&&(e.key==="Enter"||e.key==="Escape"))&&!(n&&s==="select"&&(e.key==="ArrowDown"||e.key==="ArrowUp"))){switch(e.key){case"Tab":{e.preventDefault(),!e.shiftKey?o._focusCol<i?o._focusCol+=1:(typeof o.commitActiveRowEdit=="function"&&o.commitActiveRowEdit(),o._focusRow<t&&(o._focusRow+=1,o._focusCol=0)):o._focusCol>0?o._focusCol-=1:o._focusRow>0&&(typeof o.commitActiveRowEdit=="function"&&o._activeEditRows===o._focusRow&&o.commitActiveRowEdit(),o._focusRow-=1,o._focusCol=i),N(o);return}case"ArrowDown":n&&typeof o.commitActiveRowEdit=="function"&&o.commitActiveRowEdit(),o._focusRow=Math.min(t,o._focusRow+1),e.preventDefault();break;case"ArrowUp":n&&typeof o.commitActiveRowEdit=="function"&&o.commitActiveRowEdit(),o._focusRow=Math.max(0,o._focusRow-1),e.preventDefault();break;case"ArrowRight":o._focusCol=Math.min(i,o._focusCol+1),e.preventDefault();break;case"ArrowLeft":o._focusCol=Math.max(0,o._focusCol-1),e.preventDefault();break;case"Home":(e.ctrlKey||e.metaKey)&&(n&&typeof o.commitActiveRowEdit=="function"&&o.commitActiveRowEdit(),o._focusRow=0),o._focusCol=0,e.preventDefault(),N(o,{forceScrollLeft:!0});return;case"End":(e.ctrlKey||e.metaKey)&&(n&&typeof o.commitActiveRowEdit=="function"&&o.commitActiveRowEdit(),o._focusRow=t),o._focusCol=i,e.preventDefault(),N(o,{forceScrollRight:!0});return;case"PageDown":o._focusRow=Math.min(t,o._focusRow+20),e.preventDefault();break;case"PageUp":o._focusRow=Math.max(0,o._focusRow-20),e.preventDefault();break;case"Enter":{const d=o._focusRow,u=o._focusCol,h=o._visibleColumns[u],f=o._rows[d],p=h?.field??"",g=p&&f?f[p]:void 0,w=o.querySelector(`[data-row="${d}"][data-col="${u}"]`),m={rowIndex:d,colIndex:u,field:p,value:g,row:f,cellEl:w,trigger:"keyboard",originalEvent:e},v=new CustomEvent("cell-activate",{cancelable:!0,detail:m});o.dispatchEvent(v);const b=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:d,col:u}});if(o.dispatchEvent(b),v.defaultPrevented||b.defaultPrevented){e.preventDefault();return}break}default:return}N(o)}}function N(o,e){if(o._virtualization?.enabled){const{rowHeight:s,container:l,viewportEl:a}=o._virtualization,c=l,d=a?.clientHeight??c?.clientHeight??0;if(c&&d>0){const u=o._focusRow*s;u<c.scrollTop?c.scrollTop=u:u+s>c.scrollTop+d&&(c.scrollTop=u-d+s)}}const t=o._activeEditRows!==void 0&&o._activeEditRows!==-1;t||o.refreshVirtualWindow(!1),ne(o._bodyEl),Array.from(o._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(s=>{s.setAttribute("aria-selected","false")});const i=o._focusRow,n=o._virtualization.start??0,r=o._virtualization.end??o._rows.length;if(i>=n&&i<r){const s=o._bodyEl.querySelectorAll(".data-grid-row")[i-n];let l=s?.children[o._focusCol];if((!l||!l.classList?.contains("cell"))&&(l=s?.querySelector(`.cell[data-col="${o._focusCol}"]`)??s?.querySelector(".cell[data-col]")),l){l.classList.add("cell-focus"),l.setAttribute("aria-selected","true");const a=o.querySelector(".tbw-scroll-area");if(a&&l&&!t)if(e?.forceScrollLeft)a.scrollLeft=0;else if(e?.forceScrollRight)a.scrollLeft=a.scrollWidth-a.clientWidth;else{const c=o._getHorizontalScrollOffsets?.(s??void 0,l)??{left:0,right:0};if(!c.skipScroll){const d=l.getBoundingClientRect(),u=a.getBoundingClientRect(),h=d.left-u.left+a.scrollLeft,f=h+d.width,p=a.scrollLeft+c.left,g=a.scrollLeft+a.clientWidth-c.right;h<p?a.scrollLeft=h-c.left:f>g&&(a.scrollLeft=f-a.clientWidth+c.right)}}if(o._activeEditRows!==void 0&&o._activeEditRows!==-1&&l.classList.contains("editing")){const c=l.querySelector(nt);if(c&&document.activeElement!==c)try{c.focus({preventScroll:!0})}catch{}}else if(!l.contains(document.activeElement)){l.hasAttribute("tabindex")||l.setAttribute("tabindex","-1");try{l.focus({preventScroll:!0})}catch{}}}}}const he=new WeakMap;function zi(o,e){const t=be(e),i=Hi(e);t<0||i<0||(o._focusRow=t,o._focusCol=i,ne(o._bodyEl),e.classList.add("cell-focus"),e.setAttribute("aria-selected","true"))}function xe(o,e,t,i){let n=null;const r=t.composedPath?.();if(r&&r.length>0?n=r[0]:n=t.target,n&&!e.contains(n)){const g=document.elementFromPoint(t.clientX,t.clientY);g&&(n=g)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,u,h,f,p;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(u=o._rows[c],p=o._columns[d],h=p?.field,f=u&&h?u[h]:void 0)),{type:i,row:u,rowIndex:c!==void 0&&c>=0?c:void 0,colIndex:d!==void 0&&d>=0?d:void 0,field:h,value:f,column:p,originalEvent:t,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:c!==void 0&&d!==void 0&&c>=0&&d>=0?{row:c,col:d}:void 0}}function qi(o,e,t){const i=xe(o,e,t,"mousedown");(o._dispatchCellMouseDown?.(i)??!1)&&he.set(o,!0)}function Fi(o,e,t){if(!he.get(o))return;const i=xe(o,e,t,"mousemove");o._dispatchCellMouseMove?.(i)}function Gi(o,e,t){if(!he.get(o))return;const i=xe(o,e,t,"mouseup");o._dispatchCellMouseUp?.(i),he.set(o,!1)}function Ki(o,e,t){e.addEventListener("mousedown",i=>{const n=i.target.closest(".cell[data-col]");n&&(n.classList.contains("editing")||zi(o,n))},{signal:t}),e.addEventListener("click",i=>{const n=i.target.closest(".data-grid-row");n&<(o,i,n)},{signal:t}),e.addEventListener("dblclick",i=>{const n=i.target.closest(".data-grid-row");n&<(o,i,n)},{signal:t})}function Bi(o,e,t,i){e.addEventListener("keydown",n=>Ni(o,n),{signal:i}),t.addEventListener("mousedown",n=>qi(o,t,n),{signal:i}),document.addEventListener("mousemove",n=>Fi(o,t,n),{signal:i}),document.addEventListener("mouseup",n=>Gi(o,t,n),{signal:i})}function at(o,e){return o==null&&e==null?0:o==null?-1:e==null||o>e?1:o<e?-1:0}function ct(o,e,t){const n=t.find(l=>l.field===e.field)?.sortComparator??at,{field:r,direction:s}=e;return[...o].sort((l,a)=>n(l[r],a[r],l,a)*s)}function dt(o,e,t,i){o._rows=e,o.__rowRenderEpoch++,o._rowPool.forEach(n=>n.__epoch=-1),fe(o),o.refreshVirtualWindow(!0),o.dispatchEvent(new CustomEvent("sort-change",{detail:{field:t.field,direction:i}})),o.requestStateChange?.()}function ut(o,e){!o._sortState||o._sortState.field!==e.field?(o._sortState||(o.__originalOrder=o._rows.slice()),ht(o,e,1)):o._sortState.direction===1?ht(o,e,-1):(o._sortState=null,o.__rowRenderEpoch++,o._rowPool.forEach(i=>i.__epoch=-1),o._rows=o.__originalOrder.slice(),fe(o),o._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach(i=>{i.getAttribute("aria-sort")?(i.getAttribute("aria-sort")==="ascending"||i.getAttribute("aria-sort")==="descending")&&(o._sortState||i.setAttribute("aria-sort","none")):i.setAttribute("aria-sort","none")}),o.refreshVirtualWindow(!0),o.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e.field,direction:0}})),o.requestStateChange?.())}function ht(o,e,t){o._sortState={field:e.field,direction:t};const i={field:e.field,direction:t},n=o._columns,s=(o.effectiveConfig?.sortHandler??ct)(o._rows,i,n);s&&typeof s.then=="function"?s.then(l=>{dt(o,l,e,t)}):dt(o,s,e,t)}function Wi(o,e){typeof e=="string"?o.textContent=e:e instanceof HTMLElement&&(o.innerHTML="",o.appendChild(e.cloneNode(!0)))}function fe(o){o._headerRowEl=o.findHeaderRow();const e=o._headerRowEl;e&&(e.innerHTML="",o._visibleColumns.forEach((t,i)=>{const n=document.createElement("div");n.className="cell",Ze(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",t.field),n.setAttribute("data-col",String(i));const r=t.__headerTemplate;if(r)Array.from(r.childNodes).forEach(s=>n.appendChild(s.cloneNode(!0)));else{const s=t.header??t.field,l=document.createElement("span");l.textContent=s,n.appendChild(l)}if(t.sortable){n.classList.add("sortable"),n.tabIndex=0;const s=document.createElement("span");Ze(s,"sort-indicator");const l=o._sortState?.field===t.field?o._sortState.direction:0,a={...q,...o.icons},c=l===1?a.sortAsc:l===-1?a.sortDesc:a.sortNone;Wi(s,c),n.appendChild(s),n.setAttribute("aria-sort",l===0?"none":l===1?"ascending":"descending"),n.addEventListener("click",d=>{o._resizeController?.isResizing||o._dispatchHeaderClick?.(d,i,n)||ut(o,t)}),n.addEventListener("keydown",d=>{if(d.key==="Enter"||d.key===" "){if(d.preventDefault(),o._dispatchHeaderClick?.(d,i,n))return;ut(o,t)}})}if(t.resizable){n.classList.add("resizable");const s=document.createElement("div");s.className="resize-handle",s.setAttribute("aria-hidden","true"),s.addEventListener("mousedown",l=>{l.stopPropagation(),l.preventDefault(),o._resizeController.start(l,i,n)}),s.addEventListener("dblclick",l=>{l.stopPropagation(),l.preventDefault(),o._resizeController.resetColumn(i)}),n.appendChild(s)}e.appendChild(n)}),e.querySelectorAll(".cell.sortable").forEach(t=>{t.getAttribute("aria-sort")||t.setAttribute("aria-sort","none")}),e.children.length>0?(e.setAttribute("role","row"),e.setAttribute("aria-rowindex","1")):(e.removeAttribute("role"),e.removeAttribute("aria-rowindex")))}const ft=typeof requestIdleCallback=="function";function Vi(o,e){return ft?requestIdleCallback(o,e):window.setTimeout(()=>{const t=Date.now();o({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1)}function gt(o){ft?cancelIdleCallback(o):clearTimeout(o)}var H=(o=>(o[o.STYLE=1]="STYLE",o[o.VIRTUALIZATION=2]="VIRTUALIZATION",o[o.HEADER=3]="HEADER",o[o.ROWS=4]="ROWS",o[o.COLUMNS=5]="COLUMNS",o[o.FULL=6]="FULL",o))(H||{});class $i{#e;#o=0;#d=0;#c=null;#s=null;#i=null;#h=!1;constructor(e){this.#e=e}requestPhase(e,t){e>this.#o&&(this.#o=e),this.#d===0&&(this.#u(),this.#d=requestAnimationFrame(()=>this.#p()))}whenReady(){return this.#c?this.#c:Promise.resolve()}setInitialReadyResolver(e){this.#i=e}cancel(){this.#d!==0&&(cancelAnimationFrame(this.#d),this.#d=0),this.#o=0,this.#s&&(this.#s(),this.#s=null,this.#c=null)}get isPending(){return this.#o!==0}get pendingPhase(){return this.#o}#u(){this.#c||(this.#c=new Promise(e=>{this.#s=e}))}#p(){if(this.#d=0,!this.#e.isConnected()){this.#o=0,this.#s&&(this.#s(),this.#s=null,this.#c=null);return}const e=this.#o;this.#o=0,e>=5&&this.#e.mergeConfig(),e>=4&&this.#e.processRows(),e>=5&&(this.#e.processColumns(),this.#e.updateTemplate()),e>=3&&this.#e.renderHeader(),e>=2&&this.#e.renderVirtualWindow(),e>=1&&this.#e.afterRender(),!this.#h&&this.#i&&(this.#h=!0,this.#i()),this.#s&&(this.#s(),this.#s=null,this.#c=null)}}function pt(o){let e=null,t=null,i=null,n=null;const r=a=>{if(!e)return;const c=a.clientX-e.startX,d=Math.max(40,e.startWidth+c),u=o._visibleColumns[e.colIndex];u.width=d,u.__userResized=!0,u.__renderedWidth=d,t==null&&(t=requestAnimationFrame(()=>{t=null,o.updateTemplate?.()})),o.dispatchEvent(new CustomEvent("column-resize",{detail:{field:u.field,width:d}}))};let s=!1;const l=()=>{const a=e!==null;a&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),i!==null&&(document.documentElement.style.cursor=i,i=null),n!==null&&(document.body.style.userSelect=n,n=null),e=null,a&&o.requestStateChange&&o.requestStateChange()};return{get isResizing(){return e!==null||s},start(a,c,d){a.preventDefault();const u=o._visibleColumns[c],h=typeof u?.width=="number"?u.width:void 0,f=u?.__renderedWidth??h??d.getBoundingClientRect().width;e={startX:a.clientX,colIndex:c,startWidth:f},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),i===null&&(i=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",n===null&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(a){const c=o._visibleColumns[a];c&&(c.__userResized=!1,c.__renderedWidth=void 0,c.width=c.__originalWidth,o.updateTemplate?.(),o.requestStateChange?.(),o.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:c.field,width:c.width}})))},dispose(){l()}}}const Re="data-animating",Ui={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},ji={change:500,insert:300,remove:200};function Yi(o){const e=o.trim().toLowerCase();return e.endsWith("ms")?parseFloat(e):e.endsWith("s")?parseFloat(e)*1e3:parseFloat(e)}function Xi(o,e){const t=Ui[e],i=getComputedStyle(o).getPropertyValue(t);if(i){const n=Yi(i);if(!isNaN(n)&&n>0)return n}return ji[e]}function wt(o,e,t){o.removeAttribute(Re),o.offsetWidth,o.setAttribute(Re,e);const i=Xi(o,e);setTimeout(()=>{e!=="remove"&&o.removeAttribute(Re)},i)}function Ee(o,e,t){if(e<0)return!1;const i=o.findRenderedRowElement?.(e);return i?(wt(i,t),!0):!1}function Zi(o,e,t){let i=0;for(const n of e)Ee(o,n,t)&&i++;return i}function Ji(o,e,t){const i=o._rows??[],n=o.getRowId;if(!n)return!1;const r=i.findIndex(s=>n(s)===e);return r<0?!1:Ee(o,r,t)}function ge(o,e,t){const i=document.createElement(o);if(e)for(const n in e){const r=e[n];r!=null&&i.setAttribute(n,r)}return i}function O(o,e){const t=document.createElement("div");if(o&&(t.className=o),e)for(const i in e){const n=e[i];n!=null&&t.setAttribute(i,n)}return t}function mt(o,e,t){const i=document.createElement("button");if(o&&(i.className=o),e)for(const n in e){const r=e[n];r!=null&&i.setAttribute(n,r)}return i}const bt=document.createElement("template");bt.innerHTML=`
|
|
2
2
|
<div class="tbw-scroll-area">
|
|
3
3
|
<div class="rows-body-wrapper">
|
|
4
4
|
<div class="rows-body" role="grid">
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
<div class="faux-vscroll">
|
|
17
17
|
<div class="faux-vscroll-spacer"></div>
|
|
18
18
|
</div>
|
|
19
|
-
`;function
|
|
19
|
+
`;function vt(){return bt.content.cloneNode(!0)}function yt(o){const e=document.createDocumentFragment(),t=O(o.hasShell?"tbw-grid-root has-shell":"tbw-grid-root");if(o.hasShell&&o.shellHeader&&o.shellBody)t.appendChild(o.shellHeader),t.appendChild(o.shellBody);else{const i=O("tbw-grid-content");i.appendChild(vt()),t.appendChild(i)}return e.appendChild(t),e}function Qi(o){const e=O("tbw-shell-header",{part:"shell-header",role:"presentation"});if(o.title){const r=O("tbw-shell-title");r.textContent=o.title,e.appendChild(r)}const t=O("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});e.appendChild(t);const i=O("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const r of o.configButtons)r.hasRender&&i.appendChild(O("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));for(const r of o.apiButtons)r.hasRender&&i.appendChild(O("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));if((o.configButtons.some(r=>r.hasRender)||o.apiButtons.some(r=>r.hasRender))&&o.hasPanels&&i.appendChild(O("tbw-toolbar-separator")),o.hasPanels){const r=mt(o.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(o.isPanelOpen),"aria-controls":"tbw-tool-panel"});r.innerHTML=o.toolPanelIcon,i.appendChild(r)}return e.appendChild(i),e}function eo(o){const e=O("tbw-shell-body"),t=o.panels.length>0,i=o.panels.length===1,n=O("tbw-grid-content");n.appendChild(vt());let r=null;if(t){r=ge("aside",{class:o.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":o.position,role:"presentation",id:"tbw-tool-panel"});const s=o.position==="left"?"right":"left";r.appendChild(O("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":s,"aria-hidden":"true"}));const l=O("tbw-tool-panel-content",{role:"presentation"}),a=O("tbw-accordion");for(const c of o.panels){const d=`tbw-accordion-section${c.isExpanded?" expanded":""}${i?" single":""}`,u=O(d,{"data-section":c.id}),h=mt("tbw-accordion-header",{"aria-expanded":String(c.isExpanded),"aria-controls":`tbw-section-${c.id}`});if(i&&h.setAttribute("aria-disabled","true"),c.icon){const p=ge("span",{class:"tbw-accordion-icon"});p.innerHTML=c.icon,h.appendChild(p)}const f=ge("span",{class:"tbw-accordion-title"});if(f.textContent=c.title,h.appendChild(f),!i){const p=ge("span",{class:"tbw-accordion-chevron"});p.innerHTML=c.isExpanded?o.collapseIcon:o.expandIcon,h.appendChild(p)}u.appendChild(h),u.appendChild(O("tbw-accordion-content",{id:`tbw-section-${c.id}`,role:"presentation"})),a.appendChild(u)}l.appendChild(a),r.appendChild(l)}return o.position==="left"&&r?(e.appendChild(r),e.appendChild(n)):(e.appendChild(n),r&&e.appendChild(r)),e}function $(o){return o?typeof o=="string"?o:o.outerHTML:""}function to(){return{toolPanels:new Map,headerContents:new Map,toolbarContents:new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:new Set,lightDomToolbarContentIds:new Set,apiToolPanelIds:new Set,isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarContentCleanups:new Map,lightDomContentMoved:!1}}function Ct(o){return!!(o?.header?.title||o?.header?.toolbarContents?.length||o?.toolPanels?.length||o?.headerContents?.length||o?.header?.lightDomContent?.length||o?.header?.hasToolButtonsContainer)}function xt(o,e,t="☰"){const i=o?.header?.title??e.lightDomTitle??"",n=!!i,r=$(t),s=o?.header?.toolbarContents??[],l=[...e.toolbarContents.values()],a=new Set(s.map(g=>g.id)),c=[...s];for(const g of l)a.has(g.id)||c.push(g);const d=c.length>0,u=e.toolPanels.size>0,h=d&&u,f=[...c].sort((g,w)=>(g.order??0)-(w.order??0));let p="";for(const g of f)p+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${g.id}"></div>`;if(h&&(p+='<div class="tbw-toolbar-separator"></div>'),u){const g=e.isPanelOpen;p+=`<button class="${g?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${g}" aria-controls="tbw-tool-panel">${r}</button>`}return`
|
|
20
20
|
<div class="tbw-shell-header" part="shell-header" role="presentation">
|
|
21
|
-
${n?`<div class="tbw-shell-title">${
|
|
21
|
+
${n?`<div class="tbw-shell-title">${Ri(i)}</div>`:""}
|
|
22
22
|
<div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>
|
|
23
23
|
<div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">
|
|
24
24
|
${p}
|
|
25
25
|
</div>
|
|
26
26
|
</div>
|
|
27
|
-
`}function X(o,e){const t=o.querySelector("tbw-grid-header");if(!t)return;if(!e.lightDomTitle){const n=t.getAttribute("title");n&&(e.lightDomTitle=n)}const i=t.querySelectorAll("tbw-grid-header-content");i.length>0&&e.lightDomHeaderContent.length===0&&(e.lightDomHeaderContent=Array.from(i)),t.style.display="none"}function Z(o,e,t){const i=o.querySelector(":scope > tbw-grid-tool-buttons");if(!i)return;e.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(e.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:(s=>{for(;i.firstChild;)s.appendChild(i.firstChild)})};e.toolbarContents.set(n,r),e.lightDomToolbarContentIds.add(n),i.style.display="none"}function J(o,e,t){o.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(n=>{const r=n,s=r.getAttribute("id"),l=r.getAttribute("title");if(!s||!l){console.warn(`[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${s??""}", title="${l??""}"`);return}const a=r.getAttribute("icon")??void 0,c=r.getAttribute("tooltip")??void 0,d=parseInt(r.getAttribute("order")??"100",10);let u;const h=t?.(r);if(h)u=h;else{const g=r.innerHTML.trim();u=w=>{const m=document.createElement("div");return m.innerHTML=g,w.appendChild(m),()=>m.remove()}}const f=e.toolPanels.get(s);if(f){if(h){f.render=u,f.order=d,f.icon=a,f.tooltip=c;const g=e.panelCleanups.get(s);g&&(g(),e.panelCleanups.delete(s))}return}const p={id:s,title:l,icon:a,tooltip:c,order:d,render:u};e.toolPanels.set(s,p),e.lightDomToolPanelIds.add(s),r.style.display="none"})}function Vi(o,e,t,i){const n=o.querySelector(".tbw-shell-toolbar");n&&n.addEventListener("click",s=>{if(s.target.closest("[data-panel-toggle]")){i.onPanelToggle();return}});const r=o.querySelector(".tbw-accordion");r&&r.addEventListener("click",s=>{const a=s.target.closest(".tbw-accordion-header");if(a){const d=a.closest("[data-section]")?.getAttribute("data-section");d&&i.onSectionToggle(d)}})}function $i(o,e,t){const i=o.querySelector(".tbw-tool-panel"),n=o.querySelector("[data-resize-handle]"),r=o.querySelector(".tbw-shell-body");if(!i||!n||!r)return()=>{};const s=e?.toolPanel?.position??"right",l=200;let a=0,c=0,d=0,u=!1;const h=g=>{if(!u)return;g.preventDefault();const w=s==="left"?g.clientX-a:a-g.clientX,m=Math.min(d,Math.max(l,c+w));i.style.width=`${m}px`},f=()=>{if(!u)return;u=!1,n.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const g=i.getBoundingClientRect().width;t(g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",f)},p=g=>{g.preventDefault(),u=!0,a=g.clientX,c=i.getBoundingClientRect().width,d=r.getBoundingClientRect().width-20,n.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",f)};return n.addEventListener("mousedown",p),()=>{n.removeEventListener("mousedown",p),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",f)}}function bt(o,e,t){const i=e?.header?.toolbarContents??[],n=[...t.toolbarContents.values()],r=new Set(i.map(l=>l.id)),s=[...i];for(const l of n)r.has(l.id)||s.push(l);for(const l of s){if(t.toolbarContentCleanups.has(l.id)||!l.render)continue;const a=o.querySelector(`[data-toolbar-content="${l.id}"]`);if(!a)continue;const c=l.render(a);c&&t.toolbarContentCleanups.set(l.id,c)}}function xe(o,e){const t=e.lightDomHeaderContent.length>0&&!e.lightDomContentMoved,i=e.headerContents.size>0;if(!t&&!i)return;const n=o.querySelector(".tbw-shell-content");if(!n)return;if(t){for(const s of e.lightDomHeaderContent)s.style.display="",n.appendChild(s);e.lightDomContentMoved=!0}const r=[...e.headerContents.values()].sort((s,l)=>(s.order??100)-(l.order??100));for(const s of r){const l=e.headerContentCleanups.get(s.id);l&&(l(),e.headerContentCleanups.delete(s.id));let a=n.querySelector(`[data-header-content="${s.id}"]`);a||(a=document.createElement("div"),a.setAttribute("data-header-content",s.id),n.appendChild(a));const c=s.render(a);c&&e.headerContentCleanups.set(s.id,c)}}function Ui(o,e,t){if(!e.isPanelOpen)return;const i=V(t?.expand??F.expand),n=V(t?.collapse??F.collapse);for(const[r,s]of e.toolPanels){const l=e.expandedSections.has(r),a=o.querySelector(`[data-section="${r}"]`),c=a?.querySelector(".tbw-accordion-content");if(!a||!c)continue;a.classList.toggle("expanded",l);const d=a.querySelector(".tbw-accordion-header");d&&d.setAttribute("aria-expanded",String(l));const u=a.querySelector(".tbw-accordion-chevron");if(u&&(u.innerHTML=l?n:i),l){if(c.children.length===0){const h=s.render(c);h&&e.panelCleanups.set(r,h)}}else{const h=e.panelCleanups.get(r);h&&(h(),e.panelCleanups.delete(r)),c.innerHTML=""}}}function vt(o,e){const t=o.querySelector("[data-panel-toggle]");t&&(t.classList.toggle("active",e.isPanelOpen),t.setAttribute("aria-pressed",String(e.isPanelOpen)))}function yt(o,e){const t=o.querySelector(".tbw-tool-panel");t&&(t.classList.toggle("open",e.isPanelOpen),e.isPanelOpen||(t.style.width=""))}function ji(o){for(const e of o.headerContentCleanups.values())e();o.headerContentCleanups.clear();for(const e of o.panelCleanups.values())e();o.panelCleanups.clear();for(const e of o.toolbarContentCleanups.values())e();o.toolbarContentCleanups.clear();for(const e of o.toolbarContents.values())e.onDestroy?.();if(o.isPanelOpen)for(const e of o.expandedSections)o.toolPanels.get(e)?.onClose?.();o.isPanelOpen=!1,o.expandedSections.clear(),o.toolPanels.clear(),o.headerContents.clear(),o.toolbarContents.clear(),o.lightDomHeaderContent=[],o.lightDomToolPanelIds.clear(),o.lightDomToolbarContentIds.clear(),o.lightDomContentMoved=!1}function Yi(o,e){let t=!1;const i={get isInitialized(){return t},setInitialized(n){t=n},get isPanelOpen(){return o.isPanelOpen},get activePanel(){return o.isPanelOpen&&o.expandedSections.size>0?[...o.expandedSections][0]:null},get expandedSections(){return[...o.expandedSections]},openToolPanel(){if(o.isPanelOpen)return;if(o.toolPanels.size===0){console.warn("[tbw-grid] No tool panels registered");return}if(o.isPanelOpen=!0,o.expandedSections.size===0&&o.toolPanels.size>0){const s=[...o.toolPanels.values()].sort((l,a)=>(l.order??100)-(a.order??100))[0];s&&o.expandedSections.add(s.id)}const n=e.getShadow();vt(n,o),yt(n,o),Ui(n,o,e.getAccordionIcons()),e.emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!o.isPanelOpen)return;for(const r of o.panelCleanups.values())r();o.panelCleanups.clear();for(const r of o.toolPanels.values())r.onClose?.();o.isPanelOpen=!1;const n=e.getShadow();vt(n,o),yt(n,o),e.emit("tool-panel-close",{})},toggleToolPanel(){o.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(n){const r=o.toolPanels.get(n);if(!r){console.warn(`[tbw-grid] Tool panel section "${n}" not found`);return}if(o.toolPanels.size===1)return;const s=e.getShadow(),l=o.expandedSections.has(n);if(l){const a=o.panelCleanups.get(n);a&&(a(),o.panelCleanups.delete(n)),r.onClose?.(),o.expandedSections.delete(n),Re(s,n,!1)}else{for(const[a,c]of o.toolPanels)if(a!==n&&o.expandedSections.has(a)){const d=o.panelCleanups.get(a);d&&(d(),o.panelCleanups.delete(a)),c.onClose?.(),o.expandedSections.delete(a),Re(s,a,!1);const u=s.querySelector(`[data-section="${a}"] .tbw-accordion-content`);u&&(u.innerHTML="")}o.expandedSections.add(n),Re(s,n,!0),Xi(s,o,n)}e.emit("tool-panel-section-toggle",{id:n,expanded:!l})},getToolPanels(){return[...o.toolPanels.values()]},registerToolPanel(n){if(o.toolPanels.has(n.id)){console.warn(`[tbw-grid] Tool panel "${n.id}" already registered`);return}o.toolPanels.set(n.id,n),t&&e.refreshShellHeader()},unregisterToolPanel(n){if(o.expandedSections.has(n)){const r=o.panelCleanups.get(n);r&&(r(),o.panelCleanups.delete(n)),o.expandedSections.delete(n)}o.toolPanels.delete(n),t&&e.refreshShellHeader()},getHeaderContents(){return[...o.headerContents.values()]},registerHeaderContent(n){if(o.headerContents.has(n.id)){console.warn(`[tbw-grid] Header content "${n.id}" already registered`);return}o.headerContents.set(n.id,n),t&&xe(e.getShadow(),o)},unregisterHeaderContent(n){const r=o.headerContentCleanups.get(n);r&&(r(),o.headerContentCleanups.delete(n)),o.headerContents.get(n)?.onDestroy?.(),o.headerContents.delete(n),e.getShadow().querySelector(`[data-header-content="${n}"]`)?.remove()},getToolbarContents(){return[...o.toolbarContents.values()].sort((n,r)=>(n.order??0)-(r.order??0))},registerToolbarContent(n){if(o.toolbarContents.has(n.id)){console.warn(`[tbw-grid] Toolbar content "${n.id}" already registered`);return}o.toolbarContents.set(n.id,n),t&&e.refreshShellHeader()},unregisterToolbarContent(n){const r=o.toolbarContentCleanups.get(n);r&&(r(),o.toolbarContentCleanups.delete(n));const s=o.toolbarContents.get(n);s?.onDestroy&&s.onDestroy(),o.toolbarContents.delete(n),t&&e.refreshShellHeader()}};return i}function Re(o,e,t){const i=o.querySelector(`[data-section="${e}"]`);i&&i.classList.toggle("expanded",t)}function Xi(o,e,t){const i=e.toolPanels.get(t);if(!i?.render)return;const n=o.querySelector(`[data-section="${t}"] .tbw-accordion-content`);if(!n)return;const r=i.render(n);r&&e.panelCleanups.set(t,r)}function Zi(o,e,t,i){const n=wt(e),r=[],s=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const l of s)o.querySelectorAll(`:scope > ${l}`).forEach(c=>r.push(c));o.replaceChildren();for(const l of r)o.appendChild(l);if(n){const l=V(i?.toolPanel??F.toolPanel),a=V(i?.expand??F.expand),c=V(i?.collapse??F.collapse),u=[...e?.header?.toolbarContents??[]].sort((b,_)=>(b.order??0)-(_.order??0)),f=[...e?.toolPanels??[]].sort((b,_)=>(b.order??100)-(_.order??100)),p={title:e?.header?.title??void 0,hasPanels:f.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:l,configButtons:u.map(b=>({id:b.id,hasElement:!1,hasRender:!!b.render})),apiButtons:[]},g={position:e?.toolPanel?.position??"right",isPanelOpen:t.isPanelOpen,expandIcon:a,collapseIcon:c,panels:f.map(b=>({id:b.id,title:b.title,icon:V(b.icon),isExpanded:t.expandedSections.has(b.id)}))},w=Ki(p),m=Bi(g),y=pt({hasShell:!0,shellHeader:w,shellBody:m});o.appendChild(y)}else{const l=pt({hasShell:!1});o.appendChild(l)}return n}function Ji(){return{startY:null,startX:null,scrollTop:null,scrollLeft:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0}}function Qi(o){o.startY=null,o.startX=null,o.scrollTop=null,o.scrollLeft=null,o.lastY=null,o.lastX=null,o.lastTime=null}function Ct(o){o.momentumRaf&&(cancelAnimationFrame(o.momentumRaf),o.momentumRaf=0)}function eo(o,e,t){if(o.touches.length!==1)return;Ct(e);const i=o.touches[0];e.startY=i.clientY,e.startX=i.clientX,e.lastY=i.clientY,e.lastX=i.clientX,e.lastTime=performance.now(),e.scrollTop=t.fauxScrollbar.scrollTop,e.scrollLeft=t.scrollArea?.scrollLeft??0,e.velocityY=0,e.velocityX=0}function to(o,e,t){if(o.touches.length!==1||e.startY===null||e.startX===null||e.scrollTop===null||e.scrollLeft===null)return!1;const i=o.touches[0],n=i.clientY,r=i.clientX,s=performance.now(),l=e.startY-n,a=e.startX-r;if(e.lastTime!==null&&e.lastY!==null&&e.lastX!==null){const g=s-e.lastTime;g>0&&(e.velocityY=(e.lastY-n)/g,e.velocityX=(e.lastX-r)/g)}e.lastY=n,e.lastX=r,e.lastTime=s;const{scrollTop:c,scrollHeight:d,clientHeight:u}=t.fauxScrollbar,h=d-u,f=l>0&&c<h||l<0&&c>0;let p=!1;if(t.scrollArea){const{scrollLeft:g,scrollWidth:w,clientWidth:m}=t.scrollArea,y=w-m;p=a>0&&g<y||a<0&&g>0}return f&&(t.fauxScrollbar.scrollTop=e.scrollTop+l),p&&t.scrollArea&&(t.scrollArea.scrollLeft=e.scrollLeft+a),f||p}function io(o,e){(Math.abs(o.velocityY)>.1||Math.abs(o.velocityX)>.1)&&oo(o,e),Qi(o)}function oo(o,e){const n=()=>{o.velocityY*=.95,o.velocityX*=.95;const r=o.velocityY*16,s=o.velocityX*16;Math.abs(o.velocityY)>.01&&(e.fauxScrollbar.scrollTop+=r),Math.abs(o.velocityX)>.01&&e.scrollArea&&(e.scrollArea.scrollLeft+=s),Math.abs(o.velocityY)>.01||Math.abs(o.velocityX)>.01?o.momentumRaf=requestAnimationFrame(n):o.momentumRaf=0};o.momentumRaf=requestAnimationFrame(n)}function no(o,e,t,i){o.addEventListener("touchstart",n=>eo(n,e,t),{passive:!0,signal:i}),o.addEventListener("touchmove",n=>{to(n,e,t)&&n.preventDefault()},{passive:!1,signal:i}),o.addEventListener("touchend",()=>io(e,t),{passive:!0,signal:i})}const ro=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",isUsed:o=>o===!0},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';"},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property',importHint:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",isUsed:o=>o==="left"||o==="right"}],so=[{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",isUsed:o=>Array.isArray(o)&&o.length>0}],lo={editing:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",selection:"import { SelectionPlugin } from '@toolbox-web/grid/plugins/selection';",reorder:"import { ReorderPlugin } from '@toolbox-web/grid/plugins/reorder';",clipboard:"import { ClipboardPlugin } from '@toolbox-web/grid/plugins/clipboard';",filtering:"import { FilteringPlugin } from '@toolbox-web/grid/plugins/filtering';",multiSort:"import { MultiSortPlugin } from '@toolbox-web/grid/plugins/multi-sort';",groupingRows:"import { GroupingRowsPlugin } from '@toolbox-web/grid/plugins/grouping-rows';",groupingColumns:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",tree:"import { TreePlugin } from '@toolbox-web/grid/plugins/tree';",masterDetail:"import { MasterDetailPlugin } from '@toolbox-web/grid/plugins/master-detail';",pinnedColumns:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",pinnedRows:"import { PinnedRowsPlugin } from '@toolbox-web/grid/plugins/pinned-rows';",visibility:"import { VisibilityPlugin } from '@toolbox-web/grid/plugins/visibility';",undoRedo:"import { UndoRedoPlugin } from '@toolbox-web/grid/plugins/undo-redo';",export:"import { ExportPlugin } from '@toolbox-web/grid/plugins/export';",contextMenu:"import { ContextMenuPlugin } from '@toolbox-web/grid/plugins/context-menu';",pivot:"import { PivotPlugin } from '@toolbox-web/grid/plugins/pivot';",serverSide:"import { ServerSidePlugin } from '@toolbox-web/grid/plugins/server-side';",columnVirtualization:"import { ColumnVirtualizationPlugin } from '@toolbox-web/grid/plugins/column-virtualization';"};function Ee(o){return lo[o]??`import { ${G(o)}Plugin } from '@toolbox-web/grid/plugins/${o}';`}function xt(){if(typeof window<"u"&&window.location){const o=window.location.hostname;if(o==="localhost"||o==="127.0.0.1"||o==="::1")return!0}return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function G(o){return o.charAt(0).toUpperCase()+o.slice(1)}function Rt(o,e){return o.some(t=>t.name===e)}function ao(o,e){const t=ro,i=so,n=new Map;function r(l,a,c,d,u=!1){n.has(l)||n.set(l,{description:a,importHint:c,fields:[],isConfigProperty:u});const h=n.get(l);h.fields.includes(d)||h.fields.push(d)}for(const l of i){const a=o[l.property];(l.isUsed?l.isUsed(a):a!==void 0)&&!Rt(e,l.pluginName)&&r(l.pluginName,l.description,l.importHint??Ee(l.pluginName),l.property,!0)}const s=o.columns;if(s&&s.length>0)for(const l of s)for(const a of t){const c=l[a.property];if((a.isUsed?a.isUsed(c):c!==void 0)&&!Rt(e,a.pluginName)){const u=l.field||"<unknown>";r(a.pluginName,a.description,a.importHint??Ee(a.pluginName),u)}}if(n.size>0){const l=[];for(const[a,{description:c,importHint:d,fields:u,isConfigProperty:h}]of n)if(h)l.push(`Config uses ${c}, but the required plugin is not loaded.
|
|
27
|
+
`}function Z(o,e){const t=o.querySelector("tbw-grid-header");if(!t)return;if(!e.lightDomTitle){const n=t.getAttribute("title");n&&(e.lightDomTitle=n)}const i=t.querySelectorAll("tbw-grid-header-content");i.length>0&&e.lightDomHeaderContent.length===0&&(e.lightDomHeaderContent=Array.from(i)),t.style.display="none"}function J(o,e,t){const i=o.querySelector(":scope > tbw-grid-tool-buttons");if(!i)return;e.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(e.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:(s=>{for(;i.firstChild;)s.appendChild(i.firstChild)})};e.toolbarContents.set(n,r),e.lightDomToolbarContentIds.add(n),i.style.display="none"}function Q(o,e,t){o.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(n=>{const r=n,s=r.getAttribute("id"),l=r.getAttribute("title");if(!s||!l){console.warn(`[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${s??""}", title="${l??""}"`);return}const a=r.getAttribute("icon")??void 0,c=r.getAttribute("tooltip")??void 0,d=parseInt(r.getAttribute("order")??"100",10);let u;const h=t?.(r);if(h)u=h;else{const g=r.innerHTML.trim();u=w=>{const m=document.createElement("div");return m.innerHTML=g,w.appendChild(m),()=>m.remove()}}const f=e.toolPanels.get(s);if(f){if(h){f.render=u,f.order=d,f.icon=a,f.tooltip=c;const g=e.panelCleanups.get(s);g&&(g(),e.panelCleanups.delete(s))}return}const p={id:s,title:l,icon:a,tooltip:c,order:d,render:u};e.toolPanels.set(s,p),e.lightDomToolPanelIds.add(s),r.style.display="none"})}function io(o,e,t,i){const n=o.querySelector(".tbw-shell-toolbar");n&&n.addEventListener("click",s=>{if(s.target.closest("[data-panel-toggle]")){i.onPanelToggle();return}});const r=o.querySelector(".tbw-accordion");r&&r.addEventListener("click",s=>{const a=s.target.closest(".tbw-accordion-header");if(a){const d=a.closest("[data-section]")?.getAttribute("data-section");d&&i.onSectionToggle(d)}})}function oo(o,e,t){const i=o.querySelector(".tbw-tool-panel"),n=o.querySelector("[data-resize-handle]"),r=o.querySelector(".tbw-shell-body");if(!i||!n||!r)return()=>{};const s=e?.toolPanel?.position??"right",l=200;let a=0,c=0,d=0,u=!1;const h=g=>{if(!u)return;g.preventDefault();const w=s==="left"?g.clientX-a:a-g.clientX,m=Math.min(d,Math.max(l,c+w));i.style.width=`${m}px`},f=()=>{if(!u)return;u=!1,n.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const g=i.getBoundingClientRect().width;t(g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",f)},p=g=>{g.preventDefault(),u=!0,a=g.clientX,c=i.getBoundingClientRect().width,d=r.getBoundingClientRect().width-20,n.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",f)};return n.addEventListener("mousedown",p),()=>{n.removeEventListener("mousedown",p),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",f)}}function Rt(o,e,t){const i=e?.header?.toolbarContents??[],n=[...t.toolbarContents.values()],r=new Set(i.map(l=>l.id)),s=[...i];for(const l of n)r.has(l.id)||s.push(l);for(const l of s){if(t.toolbarContentCleanups.has(l.id)||!l.render)continue;const a=o.querySelector(`[data-toolbar-content="${l.id}"]`);if(!a)continue;const c=l.render(a);c&&t.toolbarContentCleanups.set(l.id,c)}}function Se(o,e){const t=e.lightDomHeaderContent.length>0&&!e.lightDomContentMoved,i=e.headerContents.size>0;if(!t&&!i)return;const n=o.querySelector(".tbw-shell-content");if(!n)return;if(t){for(const s of e.lightDomHeaderContent)s.style.display="",n.appendChild(s);e.lightDomContentMoved=!0}const r=[...e.headerContents.values()].sort((s,l)=>(s.order??100)-(l.order??100));for(const s of r){const l=e.headerContentCleanups.get(s.id);l&&(l(),e.headerContentCleanups.delete(s.id));let a=n.querySelector(`[data-header-content="${s.id}"]`);a||(a=document.createElement("div"),a.setAttribute("data-header-content",s.id),n.appendChild(a));const c=s.render(a);c&&e.headerContentCleanups.set(s.id,c)}}function no(o,e,t){if(!e.isPanelOpen)return;const i=$(t?.expand??q.expand),n=$(t?.collapse??q.collapse);for(const[r,s]of e.toolPanels){const l=e.expandedSections.has(r),a=o.querySelector(`[data-section="${r}"]`),c=a?.querySelector(".tbw-accordion-content");if(!a||!c)continue;a.classList.toggle("expanded",l);const d=a.querySelector(".tbw-accordion-header");d&&d.setAttribute("aria-expanded",String(l));const u=a.querySelector(".tbw-accordion-chevron");if(u&&(u.innerHTML=l?n:i),l){if(c.children.length===0){const h=s.render(c);h&&e.panelCleanups.set(r,h)}}else{const h=e.panelCleanups.get(r);h&&(h(),e.panelCleanups.delete(r)),c.innerHTML=""}}}function Et(o,e){const t=o.querySelector("[data-panel-toggle]");t&&(t.classList.toggle("active",e.isPanelOpen),t.setAttribute("aria-pressed",String(e.isPanelOpen)))}function St(o,e){const t=o.querySelector(".tbw-tool-panel");t&&(t.classList.toggle("open",e.isPanelOpen),e.isPanelOpen||(t.style.width=""))}function ro(o){for(const e of o.headerContentCleanups.values())e();o.headerContentCleanups.clear();for(const e of o.panelCleanups.values())e();o.panelCleanups.clear();for(const e of o.toolbarContentCleanups.values())e();o.toolbarContentCleanups.clear();for(const e of o.toolbarContents.values())e.onDestroy?.();if(o.isPanelOpen)for(const e of o.expandedSections)o.toolPanels.get(e)?.onClose?.();o.isPanelOpen=!1,o.expandedSections.clear(),o.toolPanels.clear(),o.headerContents.clear(),o.toolbarContents.clear(),o.lightDomHeaderContent=[],o.lightDomToolPanelIds.clear(),o.lightDomToolbarContentIds.clear(),o.lightDomContentMoved=!1}function so(o,e){let t=!1;const i={get isInitialized(){return t},setInitialized(n){t=n},get isPanelOpen(){return o.isPanelOpen},get activePanel(){return o.isPanelOpen&&o.expandedSections.size>0?[...o.expandedSections][0]:null},get expandedSections(){return[...o.expandedSections]},openToolPanel(){if(o.isPanelOpen)return;if(o.toolPanels.size===0){console.warn("[tbw-grid] No tool panels registered");return}if(o.isPanelOpen=!0,o.expandedSections.size===0&&o.toolPanels.size>0){const s=[...o.toolPanels.values()].sort((l,a)=>(l.order??100)-(a.order??100))[0];s&&o.expandedSections.add(s.id)}const n=e.getShadow();Et(n,o),St(n,o),no(n,o,e.getAccordionIcons()),e.emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!o.isPanelOpen)return;for(const r of o.panelCleanups.values())r();o.panelCleanups.clear();for(const r of o.toolPanels.values())r.onClose?.();o.isPanelOpen=!1;const n=e.getShadow();Et(n,o),St(n,o),e.emit("tool-panel-close",{})},toggleToolPanel(){o.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(n){const r=o.toolPanels.get(n);if(!r){console.warn(`[tbw-grid] Tool panel section "${n}" not found`);return}if(o.toolPanels.size===1)return;const s=e.getShadow(),l=o.expandedSections.has(n);if(l){const a=o.panelCleanups.get(n);a&&(a(),o.panelCleanups.delete(n)),r.onClose?.(),o.expandedSections.delete(n),_e(s,n,!1)}else{for(const[a,c]of o.toolPanels)if(a!==n&&o.expandedSections.has(a)){const d=o.panelCleanups.get(a);d&&(d(),o.panelCleanups.delete(a)),c.onClose?.(),o.expandedSections.delete(a),_e(s,a,!1);const u=s.querySelector(`[data-section="${a}"] .tbw-accordion-content`);u&&(u.innerHTML="")}o.expandedSections.add(n),_e(s,n,!0),lo(s,o,n)}e.emit("tool-panel-section-toggle",{id:n,expanded:!l})},getToolPanels(){return[...o.toolPanels.values()]},registerToolPanel(n){if(o.toolPanels.has(n.id)){console.warn(`[tbw-grid] Tool panel "${n.id}" already registered`);return}o.toolPanels.set(n.id,n),t&&e.refreshShellHeader()},unregisterToolPanel(n){if(o.expandedSections.has(n)){const r=o.panelCleanups.get(n);r&&(r(),o.panelCleanups.delete(n)),o.expandedSections.delete(n)}o.toolPanels.delete(n),t&&e.refreshShellHeader()},getHeaderContents(){return[...o.headerContents.values()]},registerHeaderContent(n){if(o.headerContents.has(n.id)){console.warn(`[tbw-grid] Header content "${n.id}" already registered`);return}o.headerContents.set(n.id,n),t&&Se(e.getShadow(),o)},unregisterHeaderContent(n){const r=o.headerContentCleanups.get(n);r&&(r(),o.headerContentCleanups.delete(n)),o.headerContents.get(n)?.onDestroy?.(),o.headerContents.delete(n),e.getShadow().querySelector(`[data-header-content="${n}"]`)?.remove()},getToolbarContents(){return[...o.toolbarContents.values()].sort((n,r)=>(n.order??0)-(r.order??0))},registerToolbarContent(n){if(o.toolbarContents.has(n.id)){console.warn(`[tbw-grid] Toolbar content "${n.id}" already registered`);return}o.toolbarContents.set(n.id,n),t&&e.refreshShellHeader()},unregisterToolbarContent(n){const r=o.toolbarContentCleanups.get(n);r&&(r(),o.toolbarContentCleanups.delete(n));const s=o.toolbarContents.get(n);s?.onDestroy&&s.onDestroy(),o.toolbarContents.delete(n),t&&e.refreshShellHeader()}};return i}function _e(o,e,t){const i=o.querySelector(`[data-section="${e}"]`);i&&i.classList.toggle("expanded",t)}function lo(o,e,t){const i=e.toolPanels.get(t);if(!i?.render)return;const n=o.querySelector(`[data-section="${t}"] .tbw-accordion-content`);if(!n)return;const r=i.render(n);r&&e.panelCleanups.set(t,r)}function ao(o,e,t,i){const n=Ct(e),r=[],s=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const l of s)o.querySelectorAll(`:scope > ${l}`).forEach(c=>r.push(c));o.replaceChildren();for(const l of r)o.appendChild(l);if(n){const l=$(i?.toolPanel??q.toolPanel),a=$(i?.expand??q.expand),c=$(i?.collapse??q.collapse),u=[...e?.header?.toolbarContents??[]].sort((b,R)=>(b.order??0)-(R.order??0)),f=[...e?.toolPanels??[]].sort((b,R)=>(b.order??100)-(R.order??100)),p={title:e?.header?.title??void 0,hasPanels:f.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:l,configButtons:u.map(b=>({id:b.id,hasElement:!1,hasRender:!!b.render})),apiButtons:[]},g={position:e?.toolPanel?.position??"right",isPanelOpen:t.isPanelOpen,expandIcon:a,collapseIcon:c,panels:f.map(b=>({id:b.id,title:b.title,icon:$(b.icon),isExpanded:t.expandedSections.has(b.id)}))},w=Qi(p),m=eo(g),v=yt({hasShell:!0,shellHeader:w,shellBody:m});o.appendChild(v)}else{const l=yt({hasShell:!1});o.appendChild(l)}return n}function co(){return{startY:null,startX:null,scrollTop:null,scrollLeft:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0}}function uo(o){o.startY=null,o.startX=null,o.scrollTop=null,o.scrollLeft=null,o.lastY=null,o.lastX=null,o.lastTime=null}function _t(o){o.momentumRaf&&(cancelAnimationFrame(o.momentumRaf),o.momentumRaf=0)}function ho(o,e,t){if(o.touches.length!==1)return;_t(e);const i=o.touches[0];e.startY=i.clientY,e.startX=i.clientX,e.lastY=i.clientY,e.lastX=i.clientX,e.lastTime=performance.now(),e.scrollTop=t.fauxScrollbar.scrollTop,e.scrollLeft=t.scrollArea?.scrollLeft??0,e.velocityY=0,e.velocityX=0}function fo(o,e,t){if(o.touches.length!==1||e.startY===null||e.startX===null||e.scrollTop===null||e.scrollLeft===null)return!1;const i=o.touches[0],n=i.clientY,r=i.clientX,s=performance.now(),l=e.startY-n,a=e.startX-r;if(e.lastTime!==null&&e.lastY!==null&&e.lastX!==null){const g=s-e.lastTime;g>0&&(e.velocityY=(e.lastY-n)/g,e.velocityX=(e.lastX-r)/g)}e.lastY=n,e.lastX=r,e.lastTime=s;const{scrollTop:c,scrollHeight:d,clientHeight:u}=t.fauxScrollbar,h=d-u,f=l>0&&c<h||l<0&&c>0;let p=!1;if(t.scrollArea){const{scrollLeft:g,scrollWidth:w,clientWidth:m}=t.scrollArea,v=w-m;p=a>0&&g<v||a<0&&g>0}return f&&(t.fauxScrollbar.scrollTop=e.scrollTop+l),p&&t.scrollArea&&(t.scrollArea.scrollLeft=e.scrollLeft+a),f||p}function go(o,e){(Math.abs(o.velocityY)>.1||Math.abs(o.velocityX)>.1)&&po(o,e),uo(o)}function po(o,e){const n=()=>{o.velocityY*=.95,o.velocityX*=.95;const r=o.velocityY*16,s=o.velocityX*16;Math.abs(o.velocityY)>.01&&(e.fauxScrollbar.scrollTop+=r),Math.abs(o.velocityX)>.01&&e.scrollArea&&(e.scrollArea.scrollLeft+=s),Math.abs(o.velocityY)>.01||Math.abs(o.velocityX)>.01?o.momentumRaf=requestAnimationFrame(n):o.momentumRaf=0};o.momentumRaf=requestAnimationFrame(n)}function wo(o,e,t,i){o.addEventListener("touchstart",n=>ho(n,e,t),{passive:!0,signal:i}),o.addEventListener("touchmove",n=>{fo(n,e,t)&&n.preventDefault()},{passive:!1,signal:i}),o.addEventListener("touchend",()=>go(e,t),{passive:!0,signal:i})}const mo=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",isUsed:o=>o===!0},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property',importHint:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';"},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';"},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property',importHint:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",isUsed:o=>o==="left"||o==="right"}],bo=[{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',importHint:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",isUsed:o=>Array.isArray(o)&&o.length>0}],vo={editing:"import { EditingPlugin } from '@toolbox-web/grid/plugins/editing';",selection:"import { SelectionPlugin } from '@toolbox-web/grid/plugins/selection';",reorder:"import { ReorderPlugin } from '@toolbox-web/grid/plugins/reorder';",clipboard:"import { ClipboardPlugin } from '@toolbox-web/grid/plugins/clipboard';",filtering:"import { FilteringPlugin } from '@toolbox-web/grid/plugins/filtering';",multiSort:"import { MultiSortPlugin } from '@toolbox-web/grid/plugins/multi-sort';",groupingRows:"import { GroupingRowsPlugin } from '@toolbox-web/grid/plugins/grouping-rows';",groupingColumns:"import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';",tree:"import { TreePlugin } from '@toolbox-web/grid/plugins/tree';",masterDetail:"import { MasterDetailPlugin } from '@toolbox-web/grid/plugins/master-detail';",pinnedColumns:"import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';",pinnedRows:"import { PinnedRowsPlugin } from '@toolbox-web/grid/plugins/pinned-rows';",visibility:"import { VisibilityPlugin } from '@toolbox-web/grid/plugins/visibility';",undoRedo:"import { UndoRedoPlugin } from '@toolbox-web/grid/plugins/undo-redo';",export:"import { ExportPlugin } from '@toolbox-web/grid/plugins/export';",contextMenu:"import { ContextMenuPlugin } from '@toolbox-web/grid/plugins/context-menu';",pivot:"import { PivotPlugin } from '@toolbox-web/grid/plugins/pivot';",serverSide:"import { ServerSidePlugin } from '@toolbox-web/grid/plugins/server-side';",columnVirtualization:"import { ColumnVirtualizationPlugin } from '@toolbox-web/grid/plugins/column-virtualization';"};function Ae(o){return vo[o]??`import { ${G(o)}Plugin } from '@toolbox-web/grid/plugins/${o}';`}function At(){if(typeof window<"u"&&window.location){const o=window.location.hostname;if(o==="localhost"||o==="127.0.0.1"||o==="::1")return!0}return typeof process<"u"&&process.env?.NODE_ENV!=="production"}function G(o){return o.charAt(0).toUpperCase()+o.slice(1)}function kt(o,e){return o.some(t=>t.name===e)}function yo(o,e){const t=mo,i=bo,n=new Map;function r(l,a,c,d,u=!1){n.has(l)||n.set(l,{description:a,importHint:c,fields:[],isConfigProperty:u});const h=n.get(l);h.fields.includes(d)||h.fields.push(d)}for(const l of i){const a=o[l.property];(l.isUsed?l.isUsed(a):a!==void 0)&&!kt(e,l.pluginName)&&r(l.pluginName,l.description,l.importHint??Ae(l.pluginName),l.property,!0)}const s=o.columns;if(s&&s.length>0)for(const l of s)for(const a of t){const c=l[a.property];if((a.isUsed?a.isUsed(c):c!==void 0)&&!kt(e,a.pluginName)){const u=l.field||"<unknown>";r(a.pluginName,a.description,a.importHint??Ae(a.pluginName),u)}}if(n.size>0){const l=[];for(const[a,{description:c,importHint:d,fields:u,isConfigProperty:h}]of n)if(h)l.push(`Config uses ${c}, but the required plugin is not loaded.
|
|
28
28
|
→ Add the plugin to your gridConfig.plugins array:
|
|
29
29
|
${d}
|
|
30
30
|
plugins: [new ${a.charAt(0).toUpperCase()+a.slice(1)}Plugin(), ...]`);else{const f=u.slice(0,3).join(", ")+(u.length>3?`, ... (${u.length} total)`:"");l.push(`Column(s) [${f}] use ${c}, but the required plugin is not loaded.
|
|
@@ -36,45 +36,45 @@ ${l.join(`
|
|
|
36
36
|
|
|
37
37
|
`)}
|
|
38
38
|
|
|
39
|
-
This validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`)}}function
|
|
39
|
+
This validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`)}}function Co(o){const e=[],t=[];for(const i of o){const r=i.constructor.manifest;if(r?.configRules)for(const s of r.configRules){const l=i.config;if(s.check(l)){const c=`${`[tbw-grid:${G(i.name)}Plugin]`} Configuration warning: ${s.message}`;s.severity==="error"?e.push(c):t.push(c)}}}if(t.length>0&&At())for(const i of t)console.warn(i);if(e.length>0)throw new Error(`[tbw-grid] Configuration error:
|
|
40
40
|
|
|
41
41
|
${e.join(`
|
|
42
42
|
|
|
43
|
-
`)}`)}function
|
|
43
|
+
`)}`)}function xo(o,e){const t=o.name,n=o.constructor.dependencies??[];for(const r of n){const s=r.name,l=r.required??!0,a=r.reason;if(!e.some(d=>d.name===s)){const d=a??`${G(t)}Plugin requires ${G(s)}Plugin`,u=Ae(s);if(l)throw new Error(`[tbw-grid] Plugin dependency error:
|
|
44
44
|
|
|
45
45
|
${d}.
|
|
46
46
|
|
|
47
47
|
→ Add the plugin to your gridConfig.plugins array BEFORE ${G(t)}Plugin:
|
|
48
48
|
${u}
|
|
49
|
-
plugins: [new ${G(s)}Plugin(), new ${G(t)}Plugin()]`);console.info(`[tbw-grid] ${G(t)}Plugin: Optional "${s}" plugin not found. Some features may be unavailable.`)}}}function
|
|
49
|
+
plugins: [new ${G(s)}Plugin(), new ${G(t)}Plugin()]`);console.info(`[tbw-grid] ${G(t)}Plugin: Optional "${s}" plugin not found. Some features may be unavailable.`)}}}function Ro(o){if(!At())return;const e=new Set(o.map(i=>i.name)),t=new Set;for(const i of o){const r=i.constructor.manifest;if(r?.incompatibleWith){for(const s of r.incompatibleWith)if(e.has(s.name)){const l=[i.name,s.name].sort().join("↔");if(t.has(l))continue;t.add(l),console.warn(`[tbw-grid] Plugin incompatibility warning:
|
|
50
50
|
|
|
51
51
|
${G(i.name)}Plugin and ${G(s.name)}Plugin are both loaded, but they are currently incompatible.
|
|
52
52
|
|
|
53
53
|
→ ${s.reason}
|
|
54
54
|
|
|
55
|
-
Consider removing one of these plugins to avoid unexpected behavior.`)}}}}class
|
|
55
|
+
Consider removing one of these plugins to avoid unexpected behavior.`)}}}}class Tt{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=new Map;cellRenderers=new Map;headerRenderers=new Map;cellEditors=new Map;attachAll(e){for(const t of e)this.attach(t)}attach(e){if(xo(e,this.plugins),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,i]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,i);if(e.headerRenderers)for(const[t,i]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,i);if(e.cellEditors)for(const[t,i]of Object.entries(e.cellEditors))this.cellEditors.set(t,i);e.attach(this.grid);for(const t of this.plugins)t!==e&&t.onPluginAttached&&t.onPluginAttached(e.name,e)}detachAll(){for(const e of this.plugins)for(const t of this.plugins)t!==e&&t.onPluginDetached&&t.onPluginDetached(e.name);for(let e=this.plugins.length-1;e>=0;e--)this.plugins[e].detach();this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear()}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(t=>t.name===e)}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getRegisteredPluginNames(){return this.plugins.map(e=>e.name)}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getPluginStyles(){return this.plugins.filter(e=>e.styles).map(e=>({name:e.name,styles:e.styles}))}processRows(e){let t=[...e];for(const i of this.plugins)i.processRows&&(t=i.processRows(t));return t}processColumns(e){let t=[...e];for(const i of this.plugins)i.processColumns&&(t=i.processColumns(t));return t}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.plugins)e.afterRender?.()}afterCellRender(e){for(const t of this.plugins)t.afterCellRender?.(e)}hasAfterCellRenderHook(){return this.plugins.some(e=>typeof e.afterCellRender=="function")}afterRowRender(e){for(const t of this.plugins)t.afterRowRender?.(e)}hasAfterRowRenderHook(){return this.plugins.some(e=>typeof e.afterRowRender=="function")}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const t of this.plugins)typeof t.getExtraHeight=="function"&&(e+=t.getExtraHeight());return e}hasExtraHeight(){for(const e of this.plugins)if(typeof e.getExtraHeight=="function"&&e.getExtraHeight()>0)return!0;return!1}getExtraHeightBefore(e){let t=0;for(const i of this.plugins)typeof i.getExtraHeightBefore=="function"&&(t+=i.getExtraHeightBefore(e));return t}adjustVirtualStart(e,t,i){let n=e;for(const r of this.plugins)if(typeof r.adjustVirtualStart=="function"){const s=r.adjustVirtualStart(e,t,i);s<n&&(n=s)}return n}renderRow(e,t,i){for(const n of this.plugins)if(n.renderRow?.(e,t,i))return!0;return!1}queryPlugins(e){const t=[];for(const i of this.plugins){const n=i.onPluginQuery?.(e);n!==void 0&&t.push(n)}return t}onKeyDown(e){for(const t of this.plugins)if(t.onKeyDown?.(e))return!0;return!1}onCellClick(e){for(const t of this.plugins)if(t.onCellClick?.(e))return!0;return!1}onRowClick(e){for(const t of this.plugins)if(t.onRowClick?.(e))return!0;return!1}onHeaderClick(e){for(const t of this.plugins)if(t.onHeaderClick?.(e))return!0;return!1}onScroll(e){for(const t of this.plugins)t.onScroll?.(e)}onCellMouseDown(e){for(const t of this.plugins)if(t.onCellMouseDown?.(e))return!0;return!1}onCellMouseMove(e){for(const t of this.plugins)if(t.onCellMouseMove?.(e))return!0;return!1}onCellMouseUp(e){for(const t of this.plugins)if(t.onCellMouseUp?.(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let i=0,n=0,r=!1;for(const s of this.plugins){const l=s.getHorizontalScrollOffsets?.(e,t);l&&(i+=l.left,n+=l.right,l.skipScroll&&(r=!0))}return{left:i,right:n,skipScroll:r}}getToolPanels(){const e=[];for(const t of this.plugins){const i=t.getToolPanel?.();i&&e.push({plugin:t,panel:i})}return e.sort((t,i)=>(t.panel.order??0)-(i.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const i=t.getHeaderContent?.();i&&e.push({plugin:t,content:i})}return e.sort((t,i)=>(t.content.order??0)-(i.content.order??0))}}class M extends HTMLElement{static tagName="tbw-grid";static version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode"]}get#e(){return this}#o=!1;#d;#c;#s=[];get#i(){return this.#n?.effective??{}}#h=!1;#u=!1;#p={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#l;#w=0;#m=null;#a=!1;#b;#v=co();#g;#y;#x;#C;#R={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#r;#E;#S=!1;#_;#L;#n;#t=to();#f;#H;#D=new Map;_rows=[];#z=[];get _columns(){return this.#i.columns??[]}set _columns(e){this.#i.columns=e}get _visibleColumns(){return this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;_virtualization={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null};_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#n?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#n&&(this.#n.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#n?.originalColumnNodes}set __originalColumnNodes(e){this.#n&&(this.#n.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=this.#s;this.#s=e,t!==e&&this.#N("rows")}get sourceRows(){return this.#s}get columns(){return[...this._columns]}set columns(e){const t=this.#n?.getColumns();this.#n?.setColumns(e),t!==e&&this.#N("columns")}get gridConfig(){return this.#i}set gridConfig(e){const t=this.#n?.getGridConfig();this.#n?.setGridConfig(e),t!==e&&(this.#n.clearLightDomCache(),this.#N("gridConfig"))}get fitMode(){return this.#i.fitMode??"stretch"}set fitMode(e){const t=this.#n?.getFitMode();this.#n?.setFitMode(e),t!==e&&this.#N("fitMode")}get effectiveConfig(){return this.#i}get disconnectSignal(){return this.#g||(this.#g=new AbortController),this.#g.signal}constructor(){super(),this.#le(),this.#d=new Promise(e=>this.#c=e),this.#l=new $i({mergeConfig:()=>{this.#n.parseLightDomColumns(this),this.#n.merge(),this.#X(),yo(this.#i,this.#r?.getPlugins()??[]),Co(this.#r?.getPlugins()??[]),Ro(this.#r?.getPlugins()??[]),this.#z=[...this._columns]},processColumns:()=>this.#me(),processRows:()=>this.#be(),renderHeader:()=>fe(this),updateTemplate:()=>ie(this),renderVirtualWindow:()=>this.refreshVirtualWindow(!0,!0),afterRender:()=>{this.#r?.afterRender(),this.#i.fitMode==="fixed"&&!this.__didInitialAutoSize&&(this.__didInitialAutoSize=!0,Je(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,N(this)),this._virtualization.enabled&&!this.#O&&this.#ce()},isConnected:()=>this.isConnected&&this.#h}),this.#l.setInitialReadyResolver(()=>this.#c?.()),this.#f=so(this.#t,{getShadow:()=>this.#e,getShellConfig:()=>this.#i?.shell,getAccordionIcons:()=>({expand:this.#i?.icons?.expand??q.expand,collapse:this.#i?.icons?.collapse??q.collapse}),emit:(e,t)=>this.#T(e,t),refreshShellHeader:()=>this.refreshShellHeader()}),this.#n=new Di({getRows:()=>this.#s,getSortState:()=>this._sortState,setSortState:e=>{this._sortState=e},onConfigChange:()=>{this.#l.requestPhase(H.FULL,"configChange")},emit:(e,t)=>this.#T(e,t),clearRowPool:()=>{this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++},setup:()=>this.#P(),renderHeader:()=>fe(this),updateTemplate:()=>ie(this),refreshVirtualWindow:()=>this.#l.requestPhase(H.VIRTUALIZATION,"configManager"),getVirtualization:()=>this._virtualization,setRowHeight:e=>{this._virtualization.rowHeight=e},applyAnimationConfig:e=>this.#ve(e),getShellLightDomTitle:()=>this.#t.lightDomTitle,getShellToolPanels:()=>this.#t.toolPanels,getShellHeaderContents:()=>this.#t.headerContents,getShellToolbarContents:()=>this.#t.toolbarContents,getShellLightDomHeaderContent:()=>this.#t.lightDomHeaderContent,getShellHasToolButtonsContainer:()=>this.#t.hasToolButtonsContainer})}static#j="tbw-grid-styles";static#I="";static#q=new Map;static#se(){let e=document.getElementById(this.#j);return e||(e=document.createElement("style"),e.id=this.#j,e.setAttribute("data-tbw-grid","true"),document.head.appendChild(e)),e}static#F(){const e=this.#se(),t=Array.from(this.#q.values()).join(`
|
|
56
56
|
`);e.textContent=`${this.#I}
|
|
57
57
|
|
|
58
58
|
/* Plugin Styles */
|
|
59
|
-
${t}`}async#le(){if(!
|
|
60
|
-
`);if(n.includes(".tbw-grid-root")&&n.includes("tbw-grid")){e=n;break}}catch{continue}e?(I.#I=e,I.#F()):(typeof process>"u"||process.env?.NODE_ENV!=="test")&&console.warn("[tbw-grid] Could not find grid.css in document.styleSheets. Grid styling will not work.","Available stylesheets:",Array.from(document.styleSheets).map(t=>t.href||"(inline)"))}catch(e){console.warn("[tbw-grid] Failed to extract grid.css from document stylesheets:",e)}}}getPlugin(e){return this.#r?.getPlugin(e)}getPluginByName(e){return this.#r?.getPluginByName(e)}requestRender(){this.#l.requestPhase(D.ROWS,"plugin:requestRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#l.requestPhase(D.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){te(this)}requestAfterRender(){this.#l.requestPhase(D.STYLE,"plugin:requestAfterRender")}#Y(){this.#r=new Et(this);const e=this.#i?.plugins,t=Array.isArray(e)?e:[];this.#r.attachAll(t)}#M(){const e=this.#r?.getPluginStyles()??[];let t=!1;for(const{name:i,styles:n}of e)I.#q.has(i)||(I.#q.set(i,n),t=!0);t&&I.#F()}#X(){const e=this.#i?.plugins,t=Array.isArray(e)?e:[];if(this.#E!==t){if(this.#E&&this.#E.length===t.length&&this.#E.every((i,n)=>i===t[n])){this.#E=t;return}this.#r&&this.#r.detachAll();for(const i of this.#t.toolPanels.keys()){const n=this.#t.lightDomToolPanelIds.has(i),r=this.#t.apiToolPanelIds.has(i);if(!n&&!r){const s=this.#t.panelCleanups.get(i);s&&(s(),this.#t.panelCleanups.delete(i)),this.#t.toolPanels.delete(i)}}for(const i of this.#t.headerContents.keys()){const n=this.#t.headerContentCleanups.get(i);n&&(n(),this.#t.headerContentCleanups.delete(i)),this.#t.headerContents.delete(i)}this.#Y(),this.#M(),this.#E=t,this.#Z(),this.#a=this.#r?.getAll().some(i=>i.onScroll)??!1}}#ae(){this.#r?.detachAll()}#Z(){if(!this.#r)return;const e=this.#r.getToolPanels();for(const{panel:i}of e)this.#t.toolPanels.has(i.id)||this.#t.toolPanels.set(i.id,i);const t=this.#r.getHeaderContents();for(const{content:i}of t)this.#t.headerContents.has(i.id)||this.#t.headerContents.set(i.id,i)}#T(){const e=I.getAdapters();if(e.length===0&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return i=>{if(t?.createToolPanelRenderer){const n=t.createToolPanelRenderer(i);if(n)return n}for(const n of e)if(n.createToolPanelRenderer){const r=n.createToolPanelRenderer(i);if(r)return r}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",I.version),this._rows=Array.isArray(this.#s)?[...this.#s]:[],this.#g&&(this.#g.abort(),this.#S=!1),this.#g=new AbortController,this.#C&&(dt(this.#C),this.#C=void 0),X(this,this.#t),Z(this,this.#t),J(this,this.#t,this.#T()),this.#n.parseLightDomColumns(this),this.#n.merge(),this.#Y();const e=this.#i?.plugins;this.#E=Array.isArray(e)?e:[],this.#Z(),this.#o||(this.#$(),this.#M(),this.#o=!0),this.#J(),this.#C=Fi(()=>{this.#Re()},{timeout:100})}disconnectedCallback(){this.#C&&(dt(this.#C),this.#C=void 0),this.#ae(),ji(this.#t),this.#f.setInitialized(!1),this.#H?.(),this.#H=void 0,Ct(this.#v),this.#g&&(this.#g.abort(),this.#g=void 0),this.#_?.abort(),this.#_=void 0,this.#S=!1,this._resizeController&&this._resizeController.dispose(),this.#y&&(this.#y.disconnect(),this.#y=void 0),this.#x&&(this.#x.disconnect(),this.#x=void 0,this.#O=!1),de(this),this.#A.clear(),this.#E=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#h=!1}attributeChangedCallback(e,t,i){if(!(t===i||!i||i==="null"||i==="undefined"))if(e==="rows"||e==="columns"||e==="grid-config")try{const n=JSON.parse(i);e==="rows"?this.rows=n:e==="columns"?this.columns=n:e==="grid-config"&&(this.gridConfig=n)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,i)}else e==="fit-mode"&&(this.fitMode=i)}#J(){const t=this.#e.querySelector(".tbw-grid-content")??this.#e.querySelector(".tbw-grid-root");if(this._headerRowEl=t?.querySelector(".header-row"),this._virtualization.totalHeightEl=t?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=t?.querySelector(".rows-viewport"),this._bodyEl=t?.querySelector(".rows"),this.__rowsBodyEl=t?.querySelector(".rows-body"),this.#f.isInitialized){xe(this.#e,this.#t),bt(this.#e,this.#i?.shell,this.#t);const r=this.#i?.shell?.toolPanel?.defaultOpen;r&&this.#t.toolPanels.has(r)&&(this.openToolPanel(),this.#t.expandedSections.add(r))}if(this.setAttribute("data-upgraded",""),this.#h=!0,this._resizeController=ut(this),this.#P(),this.#ee(t),this.#S)return;this.#S=!0;const i=this.disconnectSignal;zi(this,this,this.#e,i);const n=this.#i.rowHeight;n&&n>0?this._virtualization.rowHeight=n:requestAnimationFrame(()=>this.#Q()),queueMicrotask(()=>this.#de()),this.#l.requestPhase(D.FULL,"afterConnect")}#Q(){if(this.#r.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let i=0;t.forEach(s=>{const l=s.offsetHeight;l>i&&(i=l)});const n=e.getBoundingClientRect(),r=Math.max(n.height,i);r>0&&Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r,this.#l.requestPhase(D.VIRTUALIZATION,"measureRowHeight"))}#ee(e){this.#_?.abort(),this.#_=new AbortController;const t=this.#_.signal,i=e?.querySelector(".faux-vscroll"),n=e?.querySelector(".rows");if(this._virtualization.container=i??this,this.#a=this.#r?.getAll().some(r=>r.onScroll)??!1,i&&n){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#a)return;const l=i.scrollTop,a=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)n.style.transform=`translateY(${-l}px)`;else{const c=Math.floor(l/a),d=c-c%2,u=-(l-d*a);n.style.transform=`translateY(${u}px)`}this.#m=l,this.#w||(this.#w=requestAnimationFrame(()=>{this.#w=0,this.#m!==null&&(this.#ye(this.#m),this.#m=null)}))},{passive:!0,signal:t});const r=this.#e.querySelector(".tbw-grid-content"),s=this.#e.querySelector(".tbw-scroll-area");r&&(r.addEventListener("wheel",l=>{const a=l.shiftKey||Math.abs(l.deltaX)>Math.abs(l.deltaY);if(a&&s){const c=l.shiftKey?l.deltaY:l.deltaX,{scrollLeft:d,scrollWidth:u,clientWidth:h}=s;(c>0&&d<u-h||c<0&&d>0)&&(l.preventDefault(),s.scrollLeft+=c)}else if(!a){const{scrollTop:c,scrollHeight:d,clientHeight:u}=i;(l.deltaY>0&&c<d-u||l.deltaY<0&&c>0)&&(l.preventDefault(),i.scrollTop+=l.deltaY)}},{passive:!1,signal:t}),no(r,this.#v,{fauxScrollbar:i,scrollArea:s},t))}this._bodyEl&&Ni(this,this._bodyEl,t),this.#y?.disconnect(),this._virtualization.viewportEl&&(this.#y=new ResizeObserver(()=>{this.#l.requestPhase(D.VIRTUALIZATION,"resize-observer")}),this.#y.observe(this._virtualization.viewportEl)),this.#e.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#e.addEventListener("focusout",r=>{const s=r.relatedTarget;(!s||!this.#e.contains(s))&&delete this.dataset.hasFocus},{signal:t})}#O=!1;#ce(){if(this.#O)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#O=!0,this.#x?.disconnect(),this.#x=new ResizeObserver(()=>{this.#Q()}),this.#x.observe(e))}#k(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}#de(){this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((t,i)=>{const n=i===this._focusRow;t.setAttribute("aria-selected",String(n)),t.querySelectorAll(".cell").forEach((r,s)=>{r.setAttribute("aria-selected",String(n&&s===this._focusCol))})})}#N(e){this.#p[e]=!0,!this.#u&&(this.#u=!0,queueMicrotask(()=>this.#ue()))}#ue(){if(!this.#u||!this.#h){this.#u=!1;return}const e=this.#p;if(this.#u=!1,this.#p={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig){this.#pe(),e.rows&&this.#te();return}e.columns&&this.#fe(),e.rows&&this.#te(),e.fitMode&&this.#ge()}#te(){this._rows=Array.isArray(this.#s)?[...this.#s]:[],this.#G(),this.#l.requestPhase(D.ROWS,"applyRowsUpdate")}#G(){this.#D.clear();const e=this.#i.getRowId;this._rows.forEach((t,i)=>{const n=this.#ie(t,e);n!==void 0&&this.#D.set(n,{row:t,index:i})})}#ie(e,t){if(t)return t(e);const i=e;if("id"in i&&i.id!=null)return String(i.id);if("_id"in i&&i._id!=null)return String(i._id)}#he(e,t){const i=this.#ie(e,t);if(i===void 0)throw new Error('[tbw-grid] Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.');return i}#fe(){de(this),this.#n.merge(),this.#P()}#ge(){this.#n.merge(),this.#i.fitMode==="fixed"?(this.__didInitialAutoSize=!1,je(this)):(this._columns.forEach(t=>{!t.__userResized&&t.__autoSized&&delete t.width}),te(this))}#pe(){X(this,this.#t),Z(this,this.#t);const e=!!this.#e.querySelector(".has-shell"),t=!!this.#e.querySelector(".tbw-tool-panel"),i=this.#e.querySelectorAll(".tbw-accordion-section").length;this.#n.parseLightDomColumns(this),this.#n.merge(),this.#X(),J(this,this.#t,this.#T()),this.#n.markSourcesChanged(),this.#n.merge();const n=wt(this.#i?.shell),r=(this.#i?.shell?.toolPanels?.length??0)>0,s=(this.#i?.shell?.toolPanels?.length??0)!==i;if(e!==n||!e&&n||!t&&r||t&&s){this.#$(),this.#M(),this.#J(),this.#G();return}e&&this.#we(),this.#G(),this.#l.requestPhase(D.COLUMNS,"applyGridConfigUpdate")}#we(){const e=this.#e.querySelector(".tbw-shell-header");if(!e)return;const t=this.#i.shell?.header?.title??this.#t.lightDomTitle;let i=e.querySelector(".tbw-shell-title");t?(i||(i=document.createElement("h2"),i.className="tbw-shell-title",i.setAttribute("part","shell-title"),e.insertBefore(i,e.firstChild)),i.textContent=t):i&&i.remove()}#me(){if(this.#r){const e=this.#z.length>0?this.#z:this._columns,t=e.filter(r=>!r.hidden),i=e.filter(r=>r.hidden),n=this.#r.processColumns([...t]);if(n!==t){new Set(t.map(l=>l.field));const r=new Set(n.map(l=>l.field));!t.some(l=>r.has(l.field))&&n.length>0?this._columns=[...n,...i]:this._columns=[...n,...i]}else this._columns=[...e]}}#be(){de(this);const e=Array.isArray(this.#s)?[...this.#s]:[],t=this.#r?.processRows(e)??e;this._rows=t}#ve(e){const t={...Ve,...e.animation},i=t.mode??"reduced-motion";let n=1;i===!1||i==="off"?n=0:(i===!0||i==="on")&&(n=1),this.style.setProperty("--tbw-animation-duration",`${t.duration}ms`),this.style.setProperty("--tbw-animation-easing",t.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode=typeof i=="boolean"?i?"on":"off":i}#K(e,t,i=this.__rowRenderEpoch){this.#b||(this.#b=(n,r,s)=>this.#r?.renderRow(n,r,s)??!1),Li(this,e,t,i,this.#b)}#B=-1;#oe=-1;#ne(e,t){if(e===this.#B&&t===this.#oe)return;const i=this.#B;this.#B=e,this.#oe=t,this.__rowsBodyEl&&(this.__rowsBodyEl.setAttribute("aria-rowcount",String(e)),this.__rowsBodyEl.setAttribute("aria-colcount",String(t))),e!==i&&this._bodyEl&&(e>0?this._bodyEl.setAttribute("role","rowgroup"):this._bodyEl.removeAttribute("role"))}#P(){if(this.isConnected&&!(!this._headerRowEl||!this._bodyEl)){if(this.#n.parseLightDomColumns(this),this.#L){const e=this.#L;this.#L=void 0,this.#n.merge();const t=this.#r?.getAll()??[];this.#n.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#l.requestPhase(D.FULL,"setup")}}#ye(e){if(this.refreshVirtualWindow(!1),this.#r?.onScrollRender(),this.#a){const t=this._virtualization.container,i=this.#R;i.scrollTop=e,i.scrollLeft=t?.scrollLeft??0,i.scrollHeight=t?.scrollHeight??0,i.scrollWidth=t?.scrollWidth??0,i.clientHeight=t?.clientHeight??0,i.clientWidth=t?.clientWidth??0,this.#r?.onScroll(i)}}findHeaderRow(){return this.#e.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(t=>{const i=t.querySelector(".cell[data-row]");return i&&Number(i.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,t,i,n){const r=this._rows[t],s=this._columns[i];if(!r||!s)return!1;const l=s.field,a=r[l],c=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:i,field:l,value:a,row:r,cellEl:n,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(c),c.defaultPrevented)return!0;const d={row:r,rowIndex:t,colIndex:i,field:l,value:a,cellEl:n,originalEvent:e},u=this.#r?.onCellClick(d)??!1;return this.#k("cell-click",d),u}_dispatchRowClick(e,t,i,n){if(!i)return!1;const r={rowIndex:t,row:i,rowEl:n,originalEvent:e},s=this.#r?.onRowClick(r)??!1;return this.#k("row-click",r),s}_dispatchHeaderClick(e,t,i){const n=this._columns[t];if(!n)return!1;const r={colIndex:t,field:n.field,column:n,headerEl:i,originalEvent:e};return this.#r?.onHeaderClick(r)??!1}_dispatchKeyDown(e){return this.#r?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#r?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}queryPlugins(e){return this.#r?.queryPlugins(e)??[]}_dispatchCellMouseDown(e){return this.#r?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#r?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#r?.onCellMouseUp(e)}_afterCellRender(e){this.#r?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#r?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#r?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#r?.hasAfterRowRenderHook()??!1}async ready(){return this.#d}async forceLayout(){return this.#l.requestPhase(D.FULL,"forceLayout"),this.#l.whenReady()}async getConfig(){return Object.freeze({...this.#i||{}})}getRowId(e){return this.#he(e,this.#i.getRowId)}getRow(e){return this.#D.get(e)?.row}updateRow(e,t,i="api"){const n=this.#D.get(e);if(!n)throw new Error(`[tbw-grid] Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:r,index:s}=n,l=[];for(const[a,c]of Object.entries(t)){const d=r[a];d!==c&&(l.push({field:a,oldValue:d,newValue:c}),r[a]=c)}for(const{field:a,oldValue:c,newValue:d}of l)this.#k("cell-change",{row:r,rowId:e,rowIndex:s,field:a,oldValue:c,newValue:d,changes:t,source:i});l.length>0&&this.#l.requestPhase(D.ROWS,"updateRow")}updateRows(e,t="api"){let i=!1;for(const{id:n,changes:r}of e){const s=this.#D.get(n);if(!s)throw new Error(`[tbw-grid] Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:l,index:a}=s;for(const[c,d]of Object.entries(r)){const u=l[c];u!==d&&(i=!0,l[c]=d,this.#k("cell-change",{row:l,rowId:n,rowIndex:a,field:c,oldValue:u,newValue:d,changes:r,source:t}))}}i&&this.#l.requestPhase(D.ROWS,"updateRows")}setColumnVisible(e,t){const i=this.#n.setColumnVisible(e,t);return i&&this.requestStateChange(),i}toggleColumnVisibility(e){const t=this.#n.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#n.isColumnVisible(e)}showAllColumns(){this.#n.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#n.getAllColumns()}setColumnOrder(e){this.#n.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#n.getColumnOrder()}getColumnState(){const e=this.#r?.getAll()??[];return this.#n.collectState(e)}set columnState(e){e&&(this.#L=e,this.#n.initialColumnState=e,this.#o&&this.#Ce(e))}get columnState(){return this.getColumnState()}#Ce(e){const t=this.#r?.getAll()??[];this.#n.applyState(e,t),this.#P()}requestStateChange(){const e=this.#r?.getAll()??[];this.#n.requestStateChange(e)}resetColumnState(){this.#L=void 0,this.__originalOrder=[];const e=this.#r?.getAll()??[];this.#n.resetState(e),this.#n.merge(),this.#P()}get isToolPanelOpen(){return this.#f.isPanelOpen}get expandedToolPanelSections(){return this.#f.expandedSections}openToolPanel(){this.#f.openToolPanel()}closeToolPanel(){this.#f.closeToolPanel()}toggleToolPanel(){this.#f.toggleToolPanel()}toggleToolPanelSection(e){this.#f.toggleToolPanelSection(e)}getToolPanels(){return this.#f.getToolPanels()}registerToolPanel(e){this.#t.apiToolPanelIds.add(e.id),this.#f.registerToolPanel(e)}unregisterToolPanel(e){this.#t.apiToolPanelIds.delete(e),this.#f.unregisterToolPanel(e)}getHeaderContents(){return this.#f.getHeaderContents()}registerHeaderContent(e){this.#f.registerHeaderContent(e)}unregisterHeaderContent(e){this.#f.unregisterHeaderContent(e)}getToolbarContents(){return this.#f.getToolbarContents()}registerToolbarContent(e){this.#f.registerToolbarContent(e)}unregisterToolbarContent(e){this.#f.unregisterToolbarContent(e)}#W=!1;refreshShellHeader(){this.#W||(this.#W=!0,queueMicrotask(()=>{this.#W=!1,this.isConnected&&(X(this,this.#t),Z(this,this.#t),J(this,this.#t,this.#T()),this.#n.markSourcesChanged(),this.#n.merge(),this.#$(),this.#M(),this.#xe())}))}#xe(){const t=this.#e.querySelector(".tbw-grid-content")??this.#e.querySelector(".tbw-grid-root");if(this._headerRowEl=t?.querySelector(".header-row"),this._virtualization.totalHeightEl=t?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=t?.querySelector(".rows-viewport"),this._bodyEl=t?.querySelector(".rows"),this.__rowsBodyEl=t?.querySelector(".rows-body"),this.#f.isInitialized){xe(this.#e,this.#t),bt(this.#e,this.#i?.shell,this.#t);const i=this.#i?.shell?.toolPanel?.defaultOpen;i&&this.#t.toolPanels.has(i)&&(this.openToolPanel(),this.#t.expandedSections.add(i))}this._resizeController=ut(this),this.#ee(t),this.#l.requestPhase(D.COLUMNS,"shellRefresh")}#A=new Map;registerStyles(e,t){let i=this.#A.get(e);i||(i=new CSSStyleSheet,this.#A.set(e,i)),i.replaceSync(t),this.#re()}unregisterStyles(e){this.#A.delete(e)&&this.#re()}getRegisteredStyles(){return Array.from(this.#A.keys())}#re(){const e=Array.from(this.#A.values()),t=document.adoptedStyleSheets.filter(i=>!Array.from(this.#A.values()).includes(i));document.adoptedStyleSheets=[...t,...e]}#Re(){const e=()=>{const i=this.#t.lightDomTitle,n=this.#t.hasToolButtonsContainer;X(this,this.#t),Z(this,this.#t),J(this,this.#t,this.#T());const r=this.#t.lightDomTitle,s=this.#t.hasToolButtonsContainer;if(r&&!i||s&&!n){this.#n.markSourcesChanged(),this.#n.merge();const l=this.#e.querySelector(".tbw-shell-header");if(l){const a=mt(this.#i.shell,this.#t,this.#i.icons?.toolPanel),c=document.createElement("div");c.innerHTML=a;const d=c.firstElementChild;d&&(l.replaceWith(d),this.#U())}}},t=()=>{this.__lightDomColumnsCache=void 0,this.#P()};this.#n.registerLightDomHandler("tbw-grid-header",e),this.#n.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#n.registerLightDomHandler("tbw-grid-tool-panel",e),this.#n.registerLightDomHandler("tbw-grid-column",t),this.#n.registerLightDomHandler("tbw-grid-detail",t),this.#n.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,de(this),this.#n.parseLightDomColumns(this);const e=this.#t.lightDomTitle,t=this.#t.hasToolButtonsContainer;X(this,this.#t),Z(this,this.#t),J(this,this.#t,this.#T());const i=this.#t.lightDomTitle,n=this.#t.hasToolButtonsContainer;if(i&&!e||n&&!t){this.#n.markSourcesChanged(),this.#n.merge();const s=this.#e.querySelector(".tbw-shell-header");if(s){const l=mt(this.#i.shell,this.#t,this.#i.icons?.toolPanel),a=document.createElement("div");a.innerHTML=l;const c=a.firstElementChild;c&&(s.replaceWith(c),this.#U())}}this.#l.requestPhase(D.COLUMNS,"refreshColumns")}#V(e){const t=this._virtualization.rowHeight,i=this._virtualization.container??this,n=this._virtualization.viewportEl??i,r=i.clientHeight,s=n.clientHeight,a=this.shadowRoot?.querySelector(".tbw-scroll-area"),c=a?a.clientHeight:r,u=c-s,h=this.#r?.getExtraHeight()??0,f=Math.max(0,r-c);return e*t+u+h+f}refreshVirtualWindow(e=!1,t=!1){if(!this._bodyEl)return;const i=this._rows.length;if(!this._virtualization.enabled){this.#K(0,i),t||this.#r?.afterRender();return}if(this._rows.length<=this._virtualization.bypassThreshold){this._virtualization.start=0,this._virtualization.end=i,e&&(this._bodyEl.style.transform="translateY(0px)"),this.#K(0,i,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${this.#V(i)}px`),this.#ne(i,this._visibleColumns.length),t||this.#r?.afterRender();return}const n=this._virtualization.container??this,r=this._virtualization.viewportEl??n,s=r.clientHeight,l=this._virtualization.rowHeight,a=n.scrollTop;let c=Math.floor(a/l),d=0;const u=10;for(;d<u;){const b=this.#r?.getExtraHeightBefore?.(c)??0,_=Math.floor((a-b)/l);if(_>=c||_<0)break;c=_,d++}c=c-c%2,c<0&&(c=0);const h=this.#r?.adjustVirtualStart(c,a,l);h!==void 0&&h<c&&(c=h,c=c-c%2,c<0&&(c=0));const f=Math.ceil(s/l)+3;let p=c+f;if(p>i&&(p=i),this._virtualization.start=c,this._virtualization.end=p,n.clientHeight===0&&s>0){this.#l.requestPhase(D.VIRTUALIZATION,"stale-refs-retry");return}const w=this.#V(i);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${w}px`);const m=this.#r?.getExtraHeightBefore?.(c)??0,y=-(a-c*l-m);this._bodyEl.style.transform=`translateY(${y}px)`,this.#K(c,p,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this.#ne(i,this._visibleColumns.length),e&&!t&&(this.#r?.afterRender(),queueMicrotask(()=>{const b=n.clientHeight,_=r.clientHeight;if(b===0&&_>0)return;const x=this.#V(i);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${x}px`)}))}#$(){X(this,this.#t),Z(this,this.#t),J(this,this.#t,this.#T()),this.#n.markSourcesChanged(),this.#n.merge();const e=this.#i?.shell;Zi(this.#e,e,{isPanelOpen:this.#t.isPanelOpen,expandedSections:this.#t.expandedSections},this.#i?.icons)&&(this.#U(),this.#f.setInitialized(!0))}#U(){Vi(this.#e,this.#i?.shell,this.#t,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#H?.(),this.#H=$i(this.#e,this.#i?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)})}}customElements.get(I.tagName)||customElements.define(I.tagName,I),globalThis.DataGridElement=I;const Se={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class L{static dependencies;static manifest;version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const i=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}requestRender(){this.grid?.requestRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...F,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(e===!1||e==="off")return!1;if(e===!0||e==="on")return!0;const t=this.gridElement;return t?getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()!=="0":!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(t,10);if(!isNaN(i))return i}return 200}resolveIcon(e,t){return t!==void 0?t:this.gridIcons[e]}setIcon(e,t){typeof t=="string"?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}const H={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},re={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},fo={ROOT:`.${H.ROOT}`,HEADER:`.${H.HEADER}`,HEADER_ROW:`.${H.HEADER_ROW}`,HEADER_CELL:`.${H.HEADER_CELL}`,ROWS_VIEWPORT:`.${H.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${H.ROWS_CONTAINER}`,DATA_ROW:`.${H.DATA_ROW}`,DATA_CELL:`.${H.DATA_CELL}`,GROUP_ROW:`.${H.GROUP_ROW}`,ROW_BY_INDEX:o=>`.${H.DATA_ROW}[${re.ROW_INDEX}="${o}"]`,CELL_BY_FIELD:o=>`.${H.DATA_CELL}[${re.FIELD}="${o}"]`,CELL_AT:(o,e)=>`.${H.DATA_ROW}[${re.ROW_INDEX}="${o}"] .${H.DATA_CELL}[${re.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${H.DATA_ROW}.${H.SELECTED}`,EDITING_CELL:`.${H.DATA_CELL}.${H.EDITING}`},go={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"};function po(o){const e=document.createElement("tbw-grid");return o&&(e.gridConfig=o),e}function wo(o,e=document){return e.querySelector(o)}const mo={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},bo={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},St="__tbw_expander",vo=32;function _e(o){return o.field===St}function B(o){return o.meta?.utility===!0}function yo(o){return o.find(_e)}function Co(o){return{field:St,header:"",width:vo,resizable:!1,sortable:!1,filterable:!1,meta:{lockPosition:!0,suppressMovable:!0,expanderColumn:!0,expanderPlugin:o,utility:!0}}}async function Ae(o){try{return await navigator.clipboard.writeText(o),!0}catch{const e=document.createElement("textarea");e.value=o,e.style.position="fixed",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),e.select();const t=document.execCommand("copy");return document.body.removeChild(e),t}}function _t(o,e){const t=e.delimiter??" ",i=e.newline??`
|
|
59
|
+
${t}`}async#le(){if(!M.#I){if(Y.length>0){M.#I=Y,M.#F();return}await new Promise(e=>setTimeout(e,50));try{let e="";for(const t of Array.from(document.styleSheets))try{const n=Array.from(t.cssRules||[]).map(r=>r.cssText).join(`
|
|
60
|
+
`);if(n.includes(".tbw-grid-root")&&n.includes("tbw-grid")){e=n;break}}catch{continue}e?(M.#I=e,M.#F()):(typeof process>"u"||process.env?.NODE_ENV!=="test")&&console.warn("[tbw-grid] Could not find grid.css in document.styleSheets. Grid styling will not work.","Available stylesheets:",Array.from(document.styleSheets).map(t=>t.href||"(inline)"))}catch(e){console.warn("[tbw-grid] Failed to extract grid.css from document stylesheets:",e)}}}getPlugin(e){return this.#r?.getPlugin(e)}getPluginByName(e){return this.#r?.getPluginByName(e)}requestRender(){this.#l.requestPhase(H.ROWS,"plugin:requestRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#l.requestPhase(H.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){ie(this)}requestAfterRender(){this.#l.requestPhase(H.STYLE,"plugin:requestAfterRender")}#Y(){this.#r=new Tt(this);const e=this.#i?.plugins,t=Array.isArray(e)?e:[];this.#r.attachAll(t)}#M(){const e=this.#r?.getPluginStyles()??[];let t=!1;for(const{name:i,styles:n}of e)M.#q.has(i)||(M.#q.set(i,n),t=!0);t&&M.#F()}#X(){const e=this.#i?.plugins,t=Array.isArray(e)?e:[];if(this.#E!==t){if(this.#E&&this.#E.length===t.length&&this.#E.every((i,n)=>i===t[n])){this.#E=t;return}this.#r&&this.#r.detachAll();for(const i of this.#t.toolPanels.keys()){const n=this.#t.lightDomToolPanelIds.has(i),r=this.#t.apiToolPanelIds.has(i);if(!n&&!r){const s=this.#t.panelCleanups.get(i);s&&(s(),this.#t.panelCleanups.delete(i)),this.#t.toolPanels.delete(i)}}for(const i of this.#t.headerContents.keys()){const n=this.#t.headerContentCleanups.get(i);n&&(n(),this.#t.headerContentCleanups.delete(i)),this.#t.headerContents.delete(i)}this.#Y(),this.#M(),this.#E=t,this.#Z(),this.#a=this.#r?.getAll().some(i=>i.onScroll)??!1}}#ae(){this.#r?.detachAll()}#Z(){if(!this.#r)return;const e=this.#r.getToolPanels();for(const{panel:i}of e)this.#t.toolPanels.has(i.id)||this.#t.toolPanels.set(i.id,i);const t=this.#r.getHeaderContents();for(const{content:i}of t)this.#t.headerContents.has(i.id)||this.#t.headerContents.set(i.id,i)}#k(){const e=M.getAdapters();if(e.length===0&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return i=>{if(t?.createToolPanelRenderer){const n=t.createToolPanelRenderer(i);if(n)return n}for(const n of e)if(n.createToolPanelRenderer){const r=n.createToolPanelRenderer(i);if(r)return r}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",M.version),this._rows=Array.isArray(this.#s)?[...this.#s]:[],this.#g&&(this.#g.abort(),this.#S=!1),this.#g=new AbortController,this.#C&&(gt(this.#C),this.#C=void 0),Z(this,this.#t),J(this,this.#t),Q(this,this.#t,this.#k()),this.#n.parseLightDomColumns(this),this.#n.merge(),this.#Y();const e=this.#i?.plugins;this.#E=Array.isArray(e)?e:[],this.#Z(),this.#o||(this.#$(),this.#M(),this.#o=!0),this.#J(),this.#C=Vi(()=>{this.#Re()},{timeout:100})}disconnectedCallback(){this.#C&&(gt(this.#C),this.#C=void 0),this.#ae(),ro(this.#t),this.#f.setInitialized(!1),this.#H?.(),this.#H=void 0,_t(this.#v),this.#g&&(this.#g.abort(),this.#g=void 0),this.#_?.abort(),this.#_=void 0,this.#S=!1,this._resizeController&&this._resizeController.dispose(),this.#y&&(this.#y.disconnect(),this.#y=void 0),this.#x&&(this.#x.disconnect(),this.#x=void 0,this.#O=!1),ue(this),this.#A.clear(),this.#E=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#h=!1}attributeChangedCallback(e,t,i){if(!(t===i||!i||i==="null"||i==="undefined"))if(e==="rows"||e==="columns"||e==="grid-config")try{const n=JSON.parse(i);e==="rows"?this.rows=n:e==="columns"?this.columns=n:e==="grid-config"&&(this.gridConfig=n)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,i)}else e==="fit-mode"&&(this.fitMode=i)}#J(){const t=this.#e.querySelector(".tbw-grid-content")??this.#e.querySelector(".tbw-grid-root");if(this._headerRowEl=t?.querySelector(".header-row"),this._virtualization.totalHeightEl=t?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=t?.querySelector(".rows-viewport"),this._bodyEl=t?.querySelector(".rows"),this.__rowsBodyEl=t?.querySelector(".rows-body"),this.#f.isInitialized){Se(this.#e,this.#t),Rt(this.#e,this.#i?.shell,this.#t);const r=this.#i?.shell?.toolPanel?.defaultOpen;r&&this.#t.toolPanels.has(r)&&(this.openToolPanel(),this.#t.expandedSections.add(r))}if(this.setAttribute("data-upgraded",""),this.#h=!0,this._resizeController=pt(this),this.#P(),this.#ee(t),this.#S)return;this.#S=!0;const i=this.disconnectSignal;Bi(this,this,this.#e,i);const n=this.#i.rowHeight;n&&n>0?this._virtualization.rowHeight=n:requestAnimationFrame(()=>this.#Q()),queueMicrotask(()=>this.#de()),this.#l.requestPhase(H.FULL,"afterConnect")}#Q(){if(this.#r.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let i=0;t.forEach(s=>{const l=s.offsetHeight;l>i&&(i=l)});const n=e.getBoundingClientRect(),r=Math.max(n.height,i);r>0&&Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r,this.#l.requestPhase(H.VIRTUALIZATION,"measureRowHeight"))}#ee(e){this.#_?.abort(),this.#_=new AbortController;const t=this.#_.signal,i=e?.querySelector(".faux-vscroll"),n=e?.querySelector(".rows");if(this._virtualization.container=i??this,this.#a=this.#r?.getAll().some(r=>r.onScroll)??!1,i&&n){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#a)return;const l=i.scrollTop,a=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)n.style.transform=`translateY(${-l}px)`;else{const c=Math.floor(l/a),d=c-c%2,u=-(l-d*a);n.style.transform=`translateY(${u}px)`}this.#m=l,this.#w||(this.#w=requestAnimationFrame(()=>{this.#w=0,this.#m!==null&&(this.#ye(this.#m),this.#m=null)}))},{passive:!0,signal:t});const r=this.#e.querySelector(".tbw-grid-content"),s=this.#e.querySelector(".tbw-scroll-area");r&&(r.addEventListener("wheel",l=>{const a=l.shiftKey||Math.abs(l.deltaX)>Math.abs(l.deltaY);if(a&&s){const c=l.shiftKey?l.deltaY:l.deltaX,{scrollLeft:d,scrollWidth:u,clientWidth:h}=s;(c>0&&d<u-h||c<0&&d>0)&&(l.preventDefault(),s.scrollLeft+=c)}else if(!a){const{scrollTop:c,scrollHeight:d,clientHeight:u}=i;(l.deltaY>0&&c<d-u||l.deltaY<0&&c>0)&&(l.preventDefault(),i.scrollTop+=l.deltaY)}},{passive:!1,signal:t}),wo(r,this.#v,{fauxScrollbar:i,scrollArea:s},t))}this._bodyEl&&Ki(this,this._bodyEl,t),this.#y?.disconnect(),this._virtualization.viewportEl&&(this.#y=new ResizeObserver(()=>{this.#l.requestPhase(H.VIRTUALIZATION,"resize-observer")}),this.#y.observe(this._virtualization.viewportEl)),this.#e.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#e.addEventListener("focusout",r=>{const s=r.relatedTarget;(!s||!this.#e.contains(s))&&delete this.dataset.hasFocus},{signal:t})}#O=!1;#ce(){if(this.#O)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#O=!0,this.#x?.disconnect(),this.#x=new ResizeObserver(()=>{this.#Q()}),this.#x.observe(e))}#T(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}#de(){this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((t,i)=>{const n=i===this._focusRow;t.setAttribute("aria-selected",String(n)),t.querySelectorAll(".cell").forEach((r,s)=>{r.setAttribute("aria-selected",String(n&&s===this._focusCol))})})}#N(e){this.#p[e]=!0,!this.#u&&(this.#u=!0,queueMicrotask(()=>this.#ue()))}#ue(){if(!this.#u||!this.#h){this.#u=!1;return}const e=this.#p;if(this.#u=!1,this.#p={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig){this.#pe(),e.rows&&this.#te();return}e.columns&&this.#fe(),e.rows&&this.#te(),e.fitMode&&this.#ge()}#te(){this._rows=Array.isArray(this.#s)?[...this.#s]:[],this.#G(),this.#l.requestPhase(H.ROWS,"applyRowsUpdate")}#G(){this.#D.clear();const e=this.#i.getRowId;this._rows.forEach((t,i)=>{const n=this.#ie(t,e);n!==void 0&&this.#D.set(n,{row:t,index:i})})}#ie(e,t){if(t)return t(e);const i=e;if("id"in i&&i.id!=null)return String(i.id);if("_id"in i&&i._id!=null)return String(i._id)}#he(e,t){const i=this.#ie(e,t);if(i===void 0)throw new Error('[tbw-grid] Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.');return i}#fe(){ue(this),this.#n.merge(),this.#P()}#ge(){this.#n.merge(),this.#i.fitMode==="fixed"?(this.__didInitialAutoSize=!1,Je(this)):(this._columns.forEach(t=>{!t.__userResized&&t.__autoSized&&delete t.width}),ie(this))}#pe(){Z(this,this.#t),J(this,this.#t);const e=!!this.#e.querySelector(".has-shell"),t=!!this.#e.querySelector(".tbw-tool-panel"),i=this.#e.querySelectorAll(".tbw-accordion-section").length;this.#n.parseLightDomColumns(this),this.#n.merge(),this.#X(),Q(this,this.#t,this.#k()),this.#n.markSourcesChanged(),this.#n.merge();const n=Ct(this.#i?.shell),r=(this.#i?.shell?.toolPanels?.length??0)>0,s=(this.#i?.shell?.toolPanels?.length??0)!==i;if(e!==n||!e&&n||!t&&r||t&&s){this.#$(),this.#M(),this.#J(),this.#G();return}e&&this.#we(),this.#G(),this.#l.requestPhase(H.COLUMNS,"applyGridConfigUpdate")}#we(){const e=this.#e.querySelector(".tbw-shell-header");if(!e)return;const t=this.#i.shell?.header?.title??this.#t.lightDomTitle;let i=e.querySelector(".tbw-shell-title");t?(i||(i=document.createElement("h2"),i.className="tbw-shell-title",i.setAttribute("part","shell-title"),e.insertBefore(i,e.firstChild)),i.textContent=t):i&&i.remove()}#me(){if(this.#r){const e=this.#z.length>0?this.#z:this._columns,t=e.filter(r=>!r.hidden),i=e.filter(r=>r.hidden),n=this.#r.processColumns([...t]);if(n!==t){new Set(t.map(l=>l.field));const r=new Set(n.map(l=>l.field));!t.some(l=>r.has(l.field))&&n.length>0?this._columns=[...n,...i]:this._columns=[...n,...i]}else this._columns=[...e]}}#be(){ue(this);const e=Array.isArray(this.#s)?[...this.#s]:[],t=this.#r?.processRows(e)??e;this._rows=t}#ve(e){const t={...je,...e.animation},i=t.mode??"reduced-motion";let n=1;i===!1||i==="off"?n=0:(i===!0||i==="on")&&(n=1),this.style.setProperty("--tbw-animation-duration",`${t.duration}ms`),this.style.setProperty("--tbw-animation-easing",t.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode=typeof i=="boolean"?i?"on":"off":i}#K(e,t,i=this.__rowRenderEpoch){this.#b||(this.#b=(n,r,s)=>this.#r?.renderRow(n,r,s)??!1),Oi(this,e,t,i,this.#b)}#B=-1;#oe=-1;#ne(e,t){if(e===this.#B&&t===this.#oe)return;const i=this.#B;this.#B=e,this.#oe=t,this.__rowsBodyEl&&(this.__rowsBodyEl.setAttribute("aria-rowcount",String(e)),this.__rowsBodyEl.setAttribute("aria-colcount",String(t))),e!==i&&this._bodyEl&&(e>0?this._bodyEl.setAttribute("role","rowgroup"):this._bodyEl.removeAttribute("role"))}#P(){if(this.isConnected&&!(!this._headerRowEl||!this._bodyEl)){if(this.#n.parseLightDomColumns(this),this.#L){const e=this.#L;this.#L=void 0,this.#n.merge();const t=this.#r?.getAll()??[];this.#n.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#l.requestPhase(H.FULL,"setup")}}#ye(e){if(this.refreshVirtualWindow(!1),this.#r?.onScrollRender(),this.#a){const t=this._virtualization.container,i=this.#R;i.scrollTop=e,i.scrollLeft=t?.scrollLeft??0,i.scrollHeight=t?.scrollHeight??0,i.scrollWidth=t?.scrollWidth??0,i.clientHeight=t?.clientHeight??0,i.clientWidth=t?.clientWidth??0,this.#r?.onScroll(i)}}findHeaderRow(){return this.#e.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(t=>{const i=t.querySelector(".cell[data-row]");return i&&Number(i.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,t,i,n){const r=this._rows[t],s=this._columns[i];if(!r||!s)return!1;const l=s.field,a=r[l],c=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:i,field:l,value:a,row:r,cellEl:n,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(c),c.defaultPrevented)return!0;const d={row:r,rowIndex:t,colIndex:i,field:l,value:a,cellEl:n,originalEvent:e},u=this.#r?.onCellClick(d)??!1;return this.#T("cell-click",d),u}_dispatchRowClick(e,t,i,n){if(!i)return!1;const r={rowIndex:t,row:i,rowEl:n,originalEvent:e},s=this.#r?.onRowClick(r)??!1;return this.#T("row-click",r),s}_dispatchHeaderClick(e,t,i){const n=this._columns[t];if(!n)return!1;const r={colIndex:t,field:n.field,column:n,headerEl:i,originalEvent:e};return this.#r?.onHeaderClick(r)??!1}_dispatchKeyDown(e){return this.#r?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#r?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}queryPlugins(e){return this.#r?.queryPlugins(e)??[]}_dispatchCellMouseDown(e){return this.#r?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#r?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#r?.onCellMouseUp(e)}_afterCellRender(e){this.#r?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#r?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#r?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#r?.hasAfterRowRenderHook()??!1}async ready(){return this.#d}async forceLayout(){return this.#l.requestPhase(H.FULL,"forceLayout"),this.#l.whenReady()}async getConfig(){return Object.freeze({...this.#i||{}})}getRowId(e){return this.#he(e,this.#i.getRowId)}getRow(e){return this.#D.get(e)?.row}updateRow(e,t,i="api"){const n=this.#D.get(e);if(!n)throw new Error(`[tbw-grid] Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:r,index:s}=n,l=[];for(const[a,c]of Object.entries(t)){const d=r[a];d!==c&&(l.push({field:a,oldValue:d,newValue:c}),r[a]=c)}for(const{field:a,oldValue:c,newValue:d}of l)this.#T("cell-change",{row:r,rowId:e,rowIndex:s,field:a,oldValue:c,newValue:d,changes:t,source:i});l.length>0&&this.#l.requestPhase(H.ROWS,"updateRow")}updateRows(e,t="api"){let i=!1;for(const{id:n,changes:r}of e){const s=this.#D.get(n);if(!s)throw new Error(`[tbw-grid] Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:l,index:a}=s;for(const[c,d]of Object.entries(r)){const u=l[c];u!==d&&(i=!0,l[c]=d,this.#T("cell-change",{row:l,rowId:n,rowIndex:a,field:c,oldValue:u,newValue:d,changes:r,source:t}))}}i&&this.#l.requestPhase(H.ROWS,"updateRows")}animateRow(e,t){Ee(this,e,t)}animateRows(e,t){Zi(this,e,t)}animateRowById(e,t){return Ji(this,e,t)}setColumnVisible(e,t){const i=this.#n.setColumnVisible(e,t);return i&&this.requestStateChange(),i}toggleColumnVisibility(e){const t=this.#n.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#n.isColumnVisible(e)}showAllColumns(){this.#n.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#n.getAllColumns()}setColumnOrder(e){this.#n.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#n.getColumnOrder()}getColumnState(){const e=this.#r?.getAll()??[];return this.#n.collectState(e)}set columnState(e){e&&(this.#L=e,this.#n.initialColumnState=e,this.#o&&this.#Ce(e))}get columnState(){return this.getColumnState()}#Ce(e){const t=this.#r?.getAll()??[];this.#n.applyState(e,t),this.#P()}requestStateChange(){const e=this.#r?.getAll()??[];this.#n.requestStateChange(e)}resetColumnState(){this.#L=void 0,this.__originalOrder=[];const e=this.#r?.getAll()??[];this.#n.resetState(e),this.#n.merge(),this.#P()}get isToolPanelOpen(){return this.#f.isPanelOpen}get expandedToolPanelSections(){return this.#f.expandedSections}openToolPanel(){this.#f.openToolPanel()}closeToolPanel(){this.#f.closeToolPanel()}toggleToolPanel(){this.#f.toggleToolPanel()}toggleToolPanelSection(e){this.#f.toggleToolPanelSection(e)}getToolPanels(){return this.#f.getToolPanels()}registerToolPanel(e){this.#t.apiToolPanelIds.add(e.id),this.#f.registerToolPanel(e)}unregisterToolPanel(e){this.#t.apiToolPanelIds.delete(e),this.#f.unregisterToolPanel(e)}getHeaderContents(){return this.#f.getHeaderContents()}registerHeaderContent(e){this.#f.registerHeaderContent(e)}unregisterHeaderContent(e){this.#f.unregisterHeaderContent(e)}getToolbarContents(){return this.#f.getToolbarContents()}registerToolbarContent(e){this.#f.registerToolbarContent(e)}unregisterToolbarContent(e){this.#f.unregisterToolbarContent(e)}#W=!1;refreshShellHeader(){this.#W||(this.#W=!0,queueMicrotask(()=>{this.#W=!1,this.isConnected&&(Z(this,this.#t),J(this,this.#t),Q(this,this.#t,this.#k()),this.#n.markSourcesChanged(),this.#n.merge(),this.#$(),this.#M(),this.#xe())}))}#xe(){const t=this.#e.querySelector(".tbw-grid-content")??this.#e.querySelector(".tbw-grid-root");if(this._headerRowEl=t?.querySelector(".header-row"),this._virtualization.totalHeightEl=t?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=t?.querySelector(".rows-viewport"),this._bodyEl=t?.querySelector(".rows"),this.__rowsBodyEl=t?.querySelector(".rows-body"),this.#f.isInitialized){Se(this.#e,this.#t),Rt(this.#e,this.#i?.shell,this.#t);const i=this.#i?.shell?.toolPanel?.defaultOpen;i&&this.#t.toolPanels.has(i)&&(this.openToolPanel(),this.#t.expandedSections.add(i))}this._resizeController=pt(this),this.#ee(t),this.#l.requestPhase(H.COLUMNS,"shellRefresh")}#A=new Map;registerStyles(e,t){let i=this.#A.get(e);i||(i=new CSSStyleSheet,this.#A.set(e,i)),i.replaceSync(t),this.#re()}unregisterStyles(e){this.#A.delete(e)&&this.#re()}getRegisteredStyles(){return Array.from(this.#A.keys())}#re(){const e=Array.from(this.#A.values()),t=document.adoptedStyleSheets.filter(i=>!Array.from(this.#A.values()).includes(i));document.adoptedStyleSheets=[...t,...e]}#Re(){const e=()=>{const i=this.#t.lightDomTitle,n=this.#t.hasToolButtonsContainer;Z(this,this.#t),J(this,this.#t),Q(this,this.#t,this.#k());const r=this.#t.lightDomTitle,s=this.#t.hasToolButtonsContainer;if(r&&!i||s&&!n){this.#n.markSourcesChanged(),this.#n.merge();const l=this.#e.querySelector(".tbw-shell-header");if(l){const a=xt(this.#i.shell,this.#t,this.#i.icons?.toolPanel),c=document.createElement("div");c.innerHTML=a;const d=c.firstElementChild;d&&(l.replaceWith(d),this.#U())}}},t=()=>{this.__lightDomColumnsCache=void 0,this.#P()};this.#n.registerLightDomHandler("tbw-grid-header",e),this.#n.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#n.registerLightDomHandler("tbw-grid-tool-panel",e),this.#n.registerLightDomHandler("tbw-grid-column",t),this.#n.registerLightDomHandler("tbw-grid-detail",t),this.#n.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,ue(this),this.#n.parseLightDomColumns(this);const e=this.#t.lightDomTitle,t=this.#t.hasToolButtonsContainer;Z(this,this.#t),J(this,this.#t),Q(this,this.#t,this.#k());const i=this.#t.lightDomTitle,n=this.#t.hasToolButtonsContainer;if(i&&!e||n&&!t){this.#n.markSourcesChanged(),this.#n.merge();const s=this.#e.querySelector(".tbw-shell-header");if(s){const l=xt(this.#i.shell,this.#t,this.#i.icons?.toolPanel),a=document.createElement("div");a.innerHTML=l;const c=a.firstElementChild;c&&(s.replaceWith(c),this.#U())}}this.#l.requestPhase(H.COLUMNS,"refreshColumns")}#V(e){const t=this._virtualization.rowHeight,i=this._virtualization.container??this,n=this._virtualization.viewportEl??i,r=i.clientHeight,s=n.clientHeight,a=this.shadowRoot?.querySelector(".tbw-scroll-area"),c=a?a.clientHeight:r,u=c-s,h=this.#r?.getExtraHeight()??0,f=Math.max(0,r-c);return e*t+u+h+f}refreshVirtualWindow(e=!1,t=!1){if(!this._bodyEl)return;const i=this._rows.length;if(!this._virtualization.enabled){this.#K(0,i),t||this.#r?.afterRender();return}if(this._rows.length<=this._virtualization.bypassThreshold){this._virtualization.start=0,this._virtualization.end=i,e&&(this._bodyEl.style.transform="translateY(0px)"),this.#K(0,i,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${this.#V(i)}px`),this.#ne(i,this._visibleColumns.length),t||this.#r?.afterRender();return}const n=this._virtualization.container??this,r=this._virtualization.viewportEl??n,s=r.clientHeight,l=this._virtualization.rowHeight,a=n.scrollTop;let c=Math.floor(a/l),d=0;const u=10;for(;d<u;){const b=this.#r?.getExtraHeightBefore?.(c)??0,R=Math.floor((a-b)/l);if(R>=c||R<0)break;c=R,d++}c=c-c%2,c<0&&(c=0);const h=this.#r?.adjustVirtualStart(c,a,l);h!==void 0&&h<c&&(c=h,c=c-c%2,c<0&&(c=0));const f=Math.ceil(s/l)+3;let p=c+f;if(p>i&&(p=i),this._virtualization.start=c,this._virtualization.end=p,n.clientHeight===0&&s>0){this.#l.requestPhase(H.VIRTUALIZATION,"stale-refs-retry");return}const w=this.#V(i);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${w}px`);const m=this.#r?.getExtraHeightBefore?.(c)??0,v=-(a-c*l-m);this._bodyEl.style.transform=`translateY(${v}px)`,this.#K(c,p,e?++this.__rowRenderEpoch:this.__rowRenderEpoch),this.#ne(i,this._visibleColumns.length),e&&!t&&(this.#r?.afterRender(),queueMicrotask(()=>{const b=n.clientHeight,R=r.clientHeight;if(b===0&&R>0)return;const C=this.#V(i);this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${C}px`)}))}#$(){Z(this,this.#t),J(this,this.#t),Q(this,this.#t,this.#k()),this.#n.markSourcesChanged(),this.#n.merge();const e=this.#i?.shell;ao(this.#e,e,{isPanelOpen:this.#t.isPanelOpen,expandedSections:this.#t.expandedSections},this.#i?.icons)&&(this.#U(),this.#f.setInitialized(!0))}#U(){io(this.#e,this.#i?.shell,this.#t,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#H?.(),this.#H=oo(this.#e,this.#i?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)})}}customElements.get(M.tagName)||customElements.define(M.tagName,M),globalThis.DataGridElement=M;const ke={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class D{static dependencies;static manifest;version=typeof __GRID_VERSION__<"u"?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const i=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}requestRender(){this.grid?.requestRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid}get disconnectSignal(){return this.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...q,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(e===!1||e==="off")return!1;if(e===!0||e==="on")return!0;const t=this.gridElement;return t?getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()!=="0":!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(t,10);if(!isNaN(i))return i}return 200}resolveIcon(e,t){return t!==void 0?t:this.gridIcons[e]}setIcon(e,t){typeof t=="string"?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}const I={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},se={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},Eo={ROOT:`.${I.ROOT}`,HEADER:`.${I.HEADER}`,HEADER_ROW:`.${I.HEADER_ROW}`,HEADER_CELL:`.${I.HEADER_CELL}`,ROWS_VIEWPORT:`.${I.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${I.ROWS_CONTAINER}`,DATA_ROW:`.${I.DATA_ROW}`,DATA_CELL:`.${I.DATA_CELL}`,GROUP_ROW:`.${I.GROUP_ROW}`,ROW_BY_INDEX:o=>`.${I.DATA_ROW}[${se.ROW_INDEX}="${o}"]`,CELL_BY_FIELD:o=>`.${I.DATA_CELL}[${se.FIELD}="${o}"]`,CELL_AT:(o,e)=>`.${I.DATA_ROW}[${se.ROW_INDEX}="${o}"] .${I.DATA_CELL}[${se.COL_INDEX}="${e}"]`,SELECTED_ROWS:`.${I.DATA_ROW}.${I.SELECTED}`,EDITING_CELL:`.${I.DATA_CELL}.${I.EDITING}`},So={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"};function _o(o){const e=document.createElement("tbw-grid");return o&&(e.gridConfig=o),e}function Ao(o,e=document){return e.querySelector(o)}const ko={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},To={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},Pt="__tbw_expander",Po=32;function Te(o){return o.field===Pt}function W(o){return o.meta?.utility===!0}function Lo(o){return o.find(Te)}function Do(o){return{field:Pt,header:"",width:Po,resizable:!1,sortable:!1,filterable:!1,meta:{lockPosition:!0,suppressMovable:!0,expanderColumn:!0,expanderPlugin:o,utility:!0}}}async function Pe(o){try{return await navigator.clipboard.writeText(o),!0}catch{const e=document.createElement("textarea");e.value=o,e.style.position="fixed",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),e.select();const t=document.execCommand("copy");return document.body.removeChild(e),t}}function Lt(o,e){const t=e.delimiter??" ",i=e.newline??`
|
|
61
61
|
`,n=o.replace(/\r\n/g,`
|
|
62
62
|
`).replace(/\r/g,`
|
|
63
|
-
`),r=[];let s=[],l="",a=!1;for(let c=0;c<n.length;c++){const d=n[c];d==='"'&&!a?a=!0:d==='"'&&a?n[c+1]==='"'?(l+='"',c++):a=!1:d===t&&!a?(s.push(l),l=""):d===i&&!a?(s.push(l),l="",(s.length>1||s.some(u=>u.trim()!==""))&&r.push(s),s=[]):l+=d}return s.push(l),(s.length>1||s.some(c=>c.trim()!==""))&&r.push(s),r}async function
|
|
64
|
-
`,quoteStrings:!1}}lastCopied=null;attach(e){super.attach(e),e.addEventListener("paste",t=>this.#o(t),{signal:this.disconnectSignal})}detach(){this.lastCopied=null}onKeyDown(e){return(e.ctrlKey||e.metaKey)&&e.key==="c"?(this.#e(e.target),!0):!1}#e(e){const t=this.#c(),i=t?.getSelection(),n=this.columns.length-1,r=this.rows.length-1;let s;if(i&&i.ranges.length>0){const{mode:a,ranges:c}=i,d=c[c.length-1];a==="row"?s={startRow:d.from.row,startCol:0,endRow:d.to.row,endCol:n}:s={startRow:d.from.row,startCol:d.from.col,endRow:d.to.row,endCol:d.to.col}}else if(!t)s={startRow:0,startCol:0,endRow:r,endCol:n};else{const a=this.#i(e);if(!a)return;s={startRow:a.row,startCol:a.col,endRow:a.row,endCol:a.col}}const l=this.#s(s);
|
|
65
|
-
`,h=[],f=this.columns.slice(a,c+1).filter(p=>!B(p));if(this.config.includeHeaders){const p=f.map(g=>g.header||g.field);h.push(p.join(d))}for(let p=s;p<=l;p++){const g=this.rows[p];if(!g)continue;const w=f.map(m=>{const y=g[m.field];return y==null?"":y instanceof Date?y.toISOString():String(y)});h.push(w.join(d))}return{text:h.join(u),rowCount:l-s+1,columnCount:c-a+1}}#i(e){const t=e.closest("[data-field-cache]");if(!t)return null;const i=t.dataset.fieldCache,n=t.dataset.row;if(!i||!n)return null;const r=parseInt(n,10);if(isNaN(r))return null;const s=this.columns.findIndex(l=>l.field===i);return s===-1?null:{row:r,col:s}}async copy(){const t=this.#c()?.getSelection(),i=this.columns.length-1;let n={startRow:0,startCol:0,endRow:this.rows.length-1,endCol:i};if(t&&t.ranges.length>0){const s=t.ranges[t.ranges.length-1];t.mode==="row"?n={startRow:s.from.row,startCol:0,endRow:s.to.row,endCol:i}:n={startRow:s.from.row,startCol:s.from.col,endRow:s.to.row,endCol:s.to.col}}const r=this.#s(n);return await Ae(r.text),this.lastCopied={text:r.text,timestamp:Date.now()},r.text}async copyRows(e){if(e.length===0)return"";const t=[...e].sort((s,l)=>s-l),i=this.columns.length-1,n={startRow:t[0],startCol:0,endRow:t[t.length-1],endCol:i},r=this.#s(n);return await Ae(r.text),this.lastCopied={text:r.text,timestamp:Date.now()},r.text}async paste(){const e=await xo();return e?_t(e,this.config):null}getLastCopied(){return this.lastCopied}}const Tt=100;function Te(o){if(o==null)return Tt;if(typeof o=="number")return o;const e=parseFloat(o);return isNaN(e)?Tt:e}function kt(o){return o.map(e=>Te(e.width))}function Pt(o){const e=[];let t=0;for(const i of o)e.push(t),t+=Te(i.width);return e}function Lt(o){return o.reduce((e,t)=>e+Te(t.width),0)}function Eo(o,e,t,i,n){const r=t.length;if(r===0)return{startCol:0,endCol:0,visibleColumns:[]};let s=So(o,t,i);s=Math.max(0,s-n);const l=o+e;let a=s;for(let d=s;d<r;d++){if(t[d]>=l){a=d-1;break}a=d}a=Math.min(r-1,a+n);const c=[];for(let d=s;d<=a;d++)c.push(d);return{startCol:s,endCol:a,visibleColumns:c}}function So(o,e,t){let i=0,n=e.length-1;for(;i<n;){const r=Math.floor((i+n)/2);e[r]+t[r]<=o?i=r+1:n=r}return i}function _o(o,e,t){return t?o>e:!1}class Ao extends L{name="columnVirtualization";get defaultConfig(){return{autoEnable:!0,threshold:30,overscan:3}}isVirtualized=!1;startCol=0;endCol=0;scrollLeft=0;totalWidth=0;columnWidths=[];columnOffsets=[];attach(e){super.attach(e);const t=this.columns;this.columnWidths=kt(t),this.columnOffsets=Pt(t),this.totalWidth=Lt(t),this.endCol=t.length-1}detach(){this.columnWidths=[],this.columnOffsets=[],this.isVirtualized=!1,this.startCol=0,this.endCol=0,this.scrollLeft=0,this.totalWidth=0}processColumns(e){const t=_o(e.length,this.config.threshold??30,this.config.autoEnable??!0);if(this.isVirtualized=t??!1,this.columnWidths=kt(e),this.columnOffsets=Pt(e),this.totalWidth=Lt(e),!t)return this.startCol=0,this.endCol=e.length-1,[...e];const i=this.grid.clientWidth||800,n=Eo(this.scrollLeft,i,this.columnOffsets,this.columnWidths,this.config.overscan??3);return this.startCol=n.startCol,this.endCol=n.endCol,n.visibleColumns.map(r=>e[r])}afterRender(){if(!this.isVirtualized)return;const e=this.gridElement;if(!e)return;const t=this.columnOffsets[this.startCol]??0,i=e.querySelector(".header-row"),n=e.querySelectorAll(".data-grid-row");i&&(i.style.paddingLeft=`${t}px`),n.forEach(s=>{s.style.paddingLeft=`${t}px`});const r=e.querySelector(".rows-viewport .rows");r&&(r.style.width=`${this.totalWidth}px`)}onScroll(e){!this.isVirtualized||Math.abs(e.scrollLeft-this.scrollLeft)<1||(this.scrollLeft=e.scrollLeft,this.requestRender())}getIsVirtualized(){return this.isVirtualized}getVisibleColumnRange(){return{start:this.startCol,end:this.endCol}}scrollToColumn(e){const t=this.columnOffsets[e]??0,i=this.grid;i.scrollLeft=t}getColumnOffset(e){return this.columnOffsets[e]??0}getTotalWidth(){return this.totalWidth}}const ke="@layer tbw-plugins{.tbw-context-menu{position:fixed;background:var(--tbw-context-menu-bg, var(--tbw-color-panel-bg, light-dark(#f5f5f5, #2a2a2a)));color:var(--tbw-context-menu-fg, var(--tbw-color-fg, light-dark(#222, #eee)));border:1px solid var(--tbw-context-menu-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);box-shadow:0 2px 10px var(--tbw-color-shadow, rgba(0, 0, 0, .15));min-width:var(--tbw-menu-min-width, 10rem);padding:var(--tbw-spacing-xs, .25rem) 0;z-index:10000;font-size:var(--tbw-font-size-sm, .8125rem);font-family:var(--tbw-font-family, system-ui, sans-serif)}.tbw-context-menu-item{display:flex;align-items:center;padding:var(--tbw-menu-item-padding, .375rem .75rem);cursor:pointer;gap:var(--tbw-menu-item-gap, .5rem)}.tbw-context-menu-item:hover:not(.disabled){background:var(--tbw-context-menu-hover, var(--tbw-color-row-hover, light-dark(#e8e8e8, #3a3a3a)))}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:light-dark(#c00,#f66)}.tbw-context-menu-icon{width:var(--tbw-icon-size, 1rem);text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:var(--tbw-color-fg-muted, light-dark(#888, #888));font-size:var(--tbw-font-size-xs, .6875rem)}.tbw-context-menu-arrow{font-size:var(--tbw-font-size-2xs, .625rem);color:var(--tbw-color-fg-muted, light-dark(#888, #888))}.tbw-context-menu-separator{height:1px;background:var(--tbw-context-menu-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));margin:var(--tbw-spacing-xs, .25rem) 0}}";function Pe(o,e){return(typeof o=="function"?o(e):o).filter(i=>!(i.hidden===!0||typeof i.hidden=="function"&&i.hidden(e)))}function To(o,e){return o.disabled===!0?!0:typeof o.disabled=="function"?o.disabled(e):!1}function Le(o,e,t,i=F.submenuArrow){const n=document.createElement("div");n.className="tbw-context-menu",n.setAttribute("role","menu");for(const r of o){if(r.separator){const c=document.createElement("div");c.className="tbw-context-menu-separator",c.setAttribute("role","separator"),n.appendChild(c);continue}const s=document.createElement("div");s.className="tbw-context-menu-item",r.cssClass&&s.classList.add(r.cssClass),s.setAttribute("role","menuitem"),s.setAttribute("data-id",r.id);const l=To(r,e);if(l&&(s.classList.add("disabled"),s.setAttribute("aria-disabled","true")),r.icon){const c=document.createElement("span");c.className="tbw-context-menu-icon",c.innerHTML=r.icon,s.appendChild(c)}const a=document.createElement("span");if(a.className="tbw-context-menu-label",a.textContent=r.name,s.appendChild(a),r.shortcut){const c=document.createElement("span");c.className="tbw-context-menu-shortcut",c.textContent=r.shortcut,s.appendChild(c)}if(r.subMenu?.length){const c=document.createElement("span");c.className="tbw-context-menu-arrow",typeof i=="string"?c.innerHTML=i:i instanceof HTMLElement&&c.appendChild(i.cloneNode(!0)),s.appendChild(c),s.addEventListener("mouseenter",()=>{if(s.querySelector(".tbw-context-menu")||!r.subMenu)return;const u=Pe(r.subMenu,e),h=Le(u,e,t,i);h.classList.add("tbw-context-submenu"),h.style.position="absolute",h.style.left="100%",h.style.top="0",s.style.position="relative",s.appendChild(h)}),s.addEventListener("mouseleave",()=>{const d=s.querySelector(".tbw-context-menu");d&&d.remove()})}!l&&r.action&&!r.subMenu&&s.addEventListener("click",c=>{c.stopPropagation(),t(r)}),n.appendChild(s)}return n}function Dt(o,e,t){o.style.position="fixed",o.style.left=`${e}px`,o.style.top=`${t}px`,o.style.visibility="hidden",o.style.zIndex="10000";const i=o.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight;let s=e,l=t;e+i.width>n&&(s=e-i.width),t+i.height>r&&(l=t-i.height),s=Math.max(0,s),l=Math.max(0,l),o.style.left=`${s}px`,o.style.top=`${l}px`,o.style.visibility="visible"}let Q=null,ee=null,W=null,De=0;const He=[{id:"copy",name:"Copy",shortcut:"Ctrl+C",action:o=>{o.grid?.plugins?.clipboard?.copy?.()}},{separator:!0,id:"sep1",name:""},{id:"export-csv",name:"Export CSV",action:o=>{o.grid?.plugins?.export?.exportCsv?.()}}];class ko extends L{name="contextMenu";get defaultConfig(){return{items:He}}isOpen=!1;position={x:0,y:0};params=null;menuElement=null;attach(e){super.attach(e),this.installGlobalHandlers(),De++}detach(){this.menuElement&&(this.menuElement.remove(),this.menuElement=null),this.isOpen=!1,this.params=null,this.uninstallGlobalHandlers()}installGlobalHandlers(){!W&&typeof document<"u"&&typeof ke=="string"&&ke&&(W=document.createElement("style"),W.id="tbw-context-menu-styles",W.textContent=ke,document.head.appendChild(W)),Q||(Q=()=>{document.querySelectorAll(".tbw-context-menu").forEach(t=>t.remove())},document.addEventListener("click",Q)),ee||(ee=e=>{e.key==="Escape"&&document.querySelectorAll(".tbw-context-menu").forEach(i=>i.remove())},document.addEventListener("keydown",ee))}uninstallGlobalHandlers(){De--,!(De>0)&&(Q&&(document.removeEventListener("click",Q),Q=null),ee&&(document.removeEventListener("keydown",ee),ee=null),W&&(W.remove(),W=null))}afterRender(){const e=this.gridElement;if(!e)return;const t=e.children[0];t&&t.getAttribute("data-context-menu-bound")!=="true"&&(t.setAttribute("data-context-menu-bound","true"),t.addEventListener("contextmenu",i=>{const n=i;n.preventDefault();const r=n.target,s=r.closest("[data-row][data-col]"),l=r.closest(".header-cell");let a;if(s){const d=parseInt(s.getAttribute("data-row")??"-1",10),u=parseInt(s.getAttribute("data-col")??"-1",10),h=this.columns[u],f=this.rows[d];a={row:f,rowIndex:d,column:h,columnIndex:u,field:h?.field??"",value:f?.[h?.field]??null,isHeader:!1,event:n}}else if(l){const d=parseInt(l.getAttribute("data-col")??"-1",10),u=this.columns[d];a={row:null,rowIndex:-1,column:u,columnIndex:d,field:u?.field??"",value:null,isHeader:!0,event:n}}else return;this.params=a,this.position={x:n.clientX,y:n.clientY};const c=Pe(this.config.items??He,a);c.length&&(this.menuElement&&this.menuElement.remove(),this.menuElement=Le(c,a,d=>{d.action&&d.action(a),this.menuElement?.remove(),this.menuElement=null,this.isOpen=!1},this.gridIcons.submenuArrow),document.body.appendChild(this.menuElement),Dt(this.menuElement,n.clientX,n.clientY),this.isOpen=!0,this.emit("context-menu-open",{params:a,items:c}))}))}showMenu(e,t,i){const n={row:i.row??null,rowIndex:i.rowIndex??-1,column:i.column??null,columnIndex:i.columnIndex??-1,field:i.field??"",value:i.value??null,isHeader:i.isHeader??!1,event:i.event??new MouseEvent("contextmenu")},r=Pe(this.config.items??He,n);this.menuElement&&this.menuElement.remove(),this.menuElement=Le(r,n,s=>{s.action&&s.action(n),this.menuElement?.remove(),this.menuElement=null,this.isOpen=!1},this.gridIcons.submenuArrow),document.body.appendChild(this.menuElement),Dt(this.menuElement,e,t),this.isOpen=!0}hideMenu(){this.menuElement&&(this.menuElement.remove(),this.menuElement=null,this.isOpen=!1)}isMenuOpen(){return this.isOpen}}const Po="@layer tbw-plugins{tbw-grid{--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px}tbw-grid .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}tbw-grid .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px);align-items:center;justify-content:center}tbw-grid .data-grid-row>.cell.editing input:not([type=checkbox]),tbw-grid .data-grid-row>.cell.editing select,tbw-grid .data-grid-row>.cell.editing textarea{width:100%;height:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}tbw-grid .tbw-editor-host{display:contents}}";function Lo(o){const e=o.options;return e?typeof e=="function"?e():e:[]}function Do(o){return e=>{const t=o.editorParams,i=document.createElement("input");i.type="number",i.value=e.value!=null?String(e.value):"",t?.min!==void 0&&(i.min=String(t.min)),t?.max!==void 0&&(i.max=String(t.max)),t?.step!==void 0&&(i.step=String(t.step)),t?.placeholder&&(i.placeholder=t.placeholder);const n=()=>e.commit(i.value===""?null:Number(i.value));return i.addEventListener("blur",n),i.addEventListener("keydown",r=>{r.key==="Enter"&&n(),r.key==="Escape"&&e.cancel()}),i}}function Ho(){return o=>{const e=document.createElement("input");return e.type="checkbox",e.checked=!!o.value,e.addEventListener("change",()=>o.commit(e.checked)),e}}function Io(o){return e=>{const t=o.editorParams,i=document.createElement("input");return i.type="date",e.value instanceof Date&&(i.valueAsDate=e.value),t?.min&&(i.min=t.min),t?.max&&(i.max=t.max),t?.placeholder&&(i.placeholder=t.placeholder),i.addEventListener("change",()=>e.commit(i.valueAsDate)),i.addEventListener("keydown",n=>{n.key==="Escape"&&e.cancel()}),i}}function Mo(o){return e=>{const t=o.editorParams,i=document.createElement("select");if(o.multi&&(i.multiple=!0),t?.includeEmpty){const s=document.createElement("option");s.value="",s.textContent=t.emptyLabel??"",i.appendChild(s)}Lo(o).forEach(s=>{const l=document.createElement("option");l.value=String(s.value),l.textContent=s.label,(o.multi&&Array.isArray(e.value)&&e.value.includes(s.value)||!o.multi&&e.value===s.value)&&(l.selected=!0),i.appendChild(l)});const r=()=>{if(o.multi){const s=Array.from(i.selectedOptions).map(l=>l.value);e.commit(s)}else e.commit(i.value)};return i.addEventListener("change",r),i.addEventListener("blur",r),i.addEventListener("keydown",s=>{s.key==="Escape"&&e.cancel()}),i}}function Oo(o){return e=>{const t=o.editorParams,i=document.createElement("input");return i.type="text",i.value=e.value!=null?String(e.value):"",t?.maxLength!==void 0&&(i.maxLength=t.maxLength),t?.pattern&&(i.pattern=t.pattern),t?.placeholder&&(i.placeholder=t.placeholder),i.addEventListener("blur",()=>e.commit(i.value)),i.addEventListener("keydown",n=>{n.key==="Enter"&&e.commit(i.value),n.key==="Escape"&&e.cancel()}),i}}function Ht(o){switch(o.type){case"number":return Do(o);case"boolean":return Ho();case"date":return Io(o);case"select":return Mo(o);default:return Oo(o)}}const Ie='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function No(o,e){if(e.editor)return e.editor;if(e.__editorTemplate)return"template";if(!e.type)return;const i=o.effectiveConfig?.typeDefaults;if(i?.[e.type]?.editor)return i[e.type].editor;const n=o.__frameworkAdapter;if(n?.getTypeDefault){const r=n.getTypeDefault(e.type);if(r?.editor)return r.editor}}function se(o){return!(typeof o!="string"||o==="__proto__"||o==="constructor"||o==="prototype")}function zo(o){const e=(o.__editingCellCount??0)+1;o.__editingCellCount=e,o.setAttribute("data-has-editing","")}function qo(o){o.__editingCellCount=0,o.removeAttribute("data-has-editing")}function le(o,e){return o instanceof HTMLInputElement?o.type==="checkbox"?o.checked:o.type==="number"?o.value===""?null:Number(o.value):o.type==="date"?o.valueAsDate:o.value:e?.type==="number"&&o.value!==""?Number(o.value):o.value}function It(o){}function Fo(o,e,t){const i=o.querySelector("input,textarea,select");i&&(i.addEventListener("blur",()=>{t(le(i,e))}),i instanceof HTMLInputElement&&i.type==="checkbox"?i.addEventListener("change",()=>t(i.checked)):i instanceof HTMLSelectElement&&i.addEventListener("change",()=>t(le(i,e))))}class Go extends L{static manifest={ownedProperties:[{property:"editable",level:"column",description:'the "editable" column property',isUsed:e=>e===!0},{property:"editor",level:"column",description:'the "editor" column property'},{property:"editorParams",level:"column",description:'the "editorParams" column property'}]};name="editing";styles=Po;get defaultConfig(){return{editOn:"click"}}#e=-1;#o=-1;#d=new Map;#c=new Set;#s=new Set;#i=!1;attach(e){super.attach(e);const t=this.disconnectSignal,i=e;i._activeEditRows=-1,i._rowEditSnapshots=new Map,Object.defineProperty(e,"changedRows",{get:()=>this.changedRows,configurable:!0}),Object.defineProperty(e,"changedRowIds",{get:()=>this.changedRowIds,configurable:!0}),e.resetChangedRows=n=>this.resetChangedRows(n),e.beginBulkEdit=(n,r)=>{r&&this.beginCellEdit(n,r)},document.addEventListener("keydown",n=>{n.key==="Escape"&&this.#e!==-1&&this.#l(this.#e,!0)},{capture:!0,signal:t}),document.addEventListener("mousedown",n=>{if(this.#e===-1)return;const r=i.findRenderedRowElement?.(this.#e);!r||(n.composedPath&&n.composedPath()||[]).includes(r)||this.#l(this.#e,!1)},{signal:t})}detach(){this.#e=-1,this.#o=-1,this.#d.clear(),this.#c.clear(),this.#s.clear(),super.detach()}onCellClick(e){const t=this.grid,i=this.config.editOn??t.effectiveConfig?.editOn;if(i===!1||i==="manual"||i!=="click"&&i!=="dblclick")return!1;const n=e.originalEvent.type==="dblclick";if(i==="click"&&n||i==="dblclick"&&!n)return!1;const{rowIndex:r}=e;return t._columns?.some(l=>l.editable)?(e.originalEvent.stopPropagation(),this.beginBulkEdit(r),!0):!1}onKeyDown(e){const t=this.grid;if(e.key==="Escape"&&this.#e!==-1)return this.#l(this.#e,!0),!0;if(e.key===" "||e.key==="Spacebar"){const i=t._focusRow,n=t._focusCol;if(i>=0&&n>=0){const r=t._visibleColumns[n],s=t._rows[i];if(r?.editable&&r.type==="boolean"&&s){const l=r.field;if(se(l)){const c=!s[l];return this.#w(i,r,c,s),e.preventDefault(),this.requestRender(),!0}}}return!1}if(e.key==="Enter"&&!e.shiftKey){if(this.#e!==-1)return!1;const i=this.config.editOn??t.effectiveConfig?.editOn;if(i===!1||i==="manual")return!1;const n=t._focusRow,r=t._focusCol;if(n>=0&&t._columns?.some(l=>l.editable)){const l=t._visibleColumns[r],a=t._rows[n],c=l?.field??"",d=c&&a?a[c]:void 0,u=this.gridElement.querySelector(`[data-row="${n}"][data-col="${r}"]`),h=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,detail:{rowIndex:n,colIndex:r,field:c,value:d,row:a,cellEl:u,trigger:"keyboard",originalEvent:e}});this.gridElement.dispatchEvent(h);const f=new CustomEvent("activate-cell",{cancelable:!0,bubbles:!0,detail:{row:n,col:r}});return this.gridElement.dispatchEvent(f),h.defaultPrevented||f.defaultPrevented?(e.preventDefault(),!0):(this.beginBulkEdit(n),!0)}return!1}return!1}processColumns(e){const t=this.grid,i=t.effectiveConfig?.typeDefaults,n=t.__frameworkAdapter;return!i&&!n?.getTypeDefault?e:e.map(r=>{if(!r.type)return r;let s;if(i?.[r.type]?.editorParams&&(s=i[r.type].editorParams),!s&&n?.getTypeDefault){const l=n.getTypeDefault(r.type);l?.editorParams&&(s=l.editorParams)}return s?{...r,editorParams:{...s,...r.editorParams}}:r})}afterRender(){const e=this.grid;if(this.#i&&(this.#i=!1,this.#b(e)),this.#s.size!==0)for(const t of this.#s){const[i,n]=t.split(":"),r=parseInt(i,10),s=parseInt(n,10),l=e.findRenderedRowElement?.(r);if(!l)continue;const a=l.querySelector(`.cell[data-col="${s}"]`);if(!a||a.classList.contains("editing"))continue;const c=e._rows[r],d=e._visibleColumns[s];c&&d&&this.#m(c,r,d,s,a,!0)}}onScrollRender(){this.afterRender()}get changedRows(){const e=[];for(const t of this.#c){const i=this.grid.getRow(t);i&&e.push(i)}return e}get changedRowIds(){return Array.from(this.#c)}get activeEditRow(){return this.#e}get activeEditCol(){return this.#o}isRowEditing(e){return this.#e===e}isCellEditing(e,t){return this.#s.has(`${e}:${t}`)}isRowChanged(e){const t=this.grid,i=t._rows[e];if(!i)return!1;try{const n=t.getRowId?.(i);return n?this.#c.has(n):!1}catch{return!1}}isRowChangedById(e){return this.#c.has(e)}resetChangedRows(e){const t=this.changedRows,i=this.changedRowIds;this.#c.clear(),this.#u(),e||this.emit("changed-rows-reset",{rows:t,ids:i}),this.grid._rowPool?.forEach(r=>r.classList.remove("changed"))}beginCellEdit(e,t){const i=this.grid,n=i._visibleColumns.findIndex(a=>a.field===t);if(n===-1||!i._visibleColumns[n]?.editable)return;const l=i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${n}"]`);l&&this.#h(e,n,l)}beginBulkEdit(e){const t=this.grid;if((this.config.editOn??t.effectiveConfig?.editOn)===!1||!t._columns?.some(l=>l.editable))return;const r=t.findRenderedRowElement?.(e);if(!r)return;const s=t._rows[e];this.#p(e,s),Array.from(r.children).forEach((l,a)=>{const c=t._visibleColumns[a];if(c?.editable){const d=l;d.classList.contains("editing")||this.#m(s,e,c,a,d,!0)}}),setTimeout(()=>{let l=r.querySelector(`.cell[data-col="${t._focusCol}"]`);if(l?.classList.contains("editing")||(l=r.querySelector(".cell.editing")),l?.classList.contains("editing")){const a=l.querySelector(Ie);try{a?.focus({preventScroll:!0})}catch{}}},0)}commitActiveRowEdit(){this.#e!==-1&&this.#l(this.#e,!1)}cancelActiveRowEdit(){this.#e!==-1&&this.#l(this.#e,!0)}#h(e,t,i){const n=this.grid,r=n._rows[e],s=n._visibleColumns[t];!r||!s?.editable||i.classList.contains("editing")||(this.#e!==e&&this.#p(e,r),this.#o=t,this.#m(r,e,s,t,i,!1))}#u(){const e=this.grid;e._activeEditRows=this.#e,e._rowEditSnapshots=this.#d}#p(e,t){this.#e!==e&&(this.#d.set(e,{...t}),this.#e=e,this.#u())}#l(e,t){if(this.#e!==e)return;const i=this.grid,n=this.#d.get(e),r=i._rows[e],s=i.findRenderedRowElement?.(e);let l;if(r)try{l=i.getRowId?.(r)}catch{}if(!t&&s&&r&&s.querySelectorAll(".cell.editing").forEach(c=>{const d=Number(c.getAttribute("data-col"));if(isNaN(d))return;const u=i._visibleColumns[d];if(!u)return;const h=c.querySelector("input,textarea,select");if(h){const f=le(h,u);r[u.field]!==f&&this.#w(e,u,f,r)}}),t&&n&&r)Object.keys(n).forEach(a=>{r[a]=n[a]}),l&&this.#c.delete(l);else if(!t&&r){const a=l?this.#c.has(l):!1;this.emit("row-commit",{rowIndex:e,rowId:l??"",row:r,changed:a,changedRows:this.changedRows,changedRowIds:this.changedRowIds})}this.#d.delete(e),this.#e=-1,this.#o=-1,this.#u();for(const a of this.#s)a.startsWith(`${e}:`)&&this.#s.delete(a);s&&(s.querySelectorAll(".cell.editing").forEach(a=>{a.classList.remove("editing"),qo(a.parentElement)}),this.requestRender()),this.#i=!0,s||(this.#b(i),this.#i=!1)}#w(e,t,i,n){const r=t.field;if(!se(r))return;const s=n[r];if(s===i)return;const l=this.grid;let a;try{a=this.grid.getRowId(n)}catch{}const c=a?!this.#c.has(a):!0,d=a?f=>this.grid.updateRow(a,f,"cascade"):It;if(this.emitCancelable("cell-commit",{row:n,rowId:a??"",field:r,oldValue:s,value:i,rowIndex:e,changedRows:this.changedRows,changedRowIds:this.changedRowIds,firstTimeForRow:c,updateRow:d}))return;n[r]=i,a&&this.#c.add(a),this.#u();const h=l.findRenderedRowElement?.(e);h&&h.classList.add("changed")}#m(e,t,i,n,r,s){if(!i.editable||r.classList.contains("editing"))return;let l;try{l=this.grid.getRowId(e)}catch{}const a=l?b=>this.grid.updateRow(l,b,"cascade"):It,c=se(i.field)?e[i.field]:void 0;r.classList.add("editing"),this.#s.add(`${t}:${n}`);const d=r.parentElement;d&&zo(d);let u=!1;const h=b=>{u||this.#e===-1||this.#w(t,i,b,e)},f=()=>{u=!0,se(i.field)&&(e[i.field]=c)},p=document.createElement("div");p.className="tbw-editor-host",r.innerHTML="",r.appendChild(p),p.addEventListener("keydown",b=>{b.key==="Enter"&&(b.stopPropagation(),b.preventDefault(),u=!0,this.#l(t,!1)),b.key==="Escape"&&(b.stopPropagation(),b.preventDefault(),f(),this.#l(t,!0))});const g=i,w=g.__editorTemplate,m=No(this.grid,g)??Ht(i),y=c;if(m==="template"&&w)this.#a(p,g,e,c,h,f,s,t);else if(typeof m=="string"){const b=document.createElement(m);b.value=y,b.addEventListener("change",()=>h(b.value)),p.appendChild(b),s||queueMicrotask(()=>{p.querySelector(Ie)?.focus({preventScroll:!0})})}else if(typeof m=="function"){const b={row:e,rowId:l??"",value:y,field:i.field,column:i,commit:h,cancel:f,updateRow:a},_=m(b);typeof _=="string"?(p.innerHTML=_,Fo(p,i,h)):_ instanceof Node&&p.appendChild(_),s||queueMicrotask(()=>{p.querySelector(Ie)?.focus({preventScroll:!0})})}else if(m&&typeof m=="object"){const b=document.createElement("div");b.setAttribute("data-external-editor",""),b.setAttribute("data-field",i.field),p.appendChild(b);const _={row:e,rowId:l??"",value:y,field:i.field,column:i,commit:h,cancel:f,updateRow:a};if(m.mount)try{m.mount({placeholder:b,context:_,spec:m})}catch(x){console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`,x)}else this.grid.dispatchEvent(new CustomEvent("mount-external-editor",{detail:{placeholder:b,spec:m,context:_}}))}}#a(e,t,i,n,r,s,l,a){const c=t.__editorTemplate;if(!c)return;const d=c.cloneNode(!0),u=t.__compiledEditor;u?d.innerHTML=u({row:i,value:n,field:t.field,column:t,commit:r,cancel:s}):d.querySelectorAll("*").forEach(f=>{f.childNodes.length===1&&f.firstChild?.nodeType===Node.TEXT_NODE&&(f.textContent=f.textContent?.replace(/{{\s*value\s*}}/g,n==null?"":String(n)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g,(p,g)=>{if(!se(g))return"";const w=i[g];return w==null?"":String(w)})||"")});const h=d.querySelector("input,textarea,select");if(h){h instanceof HTMLInputElement&&h.type==="checkbox"?h.checked=!!n:h.value=String(n??"");let f=!1;h.addEventListener("blur",()=>{f||r(le(h,t))}),h.addEventListener("keydown",p=>{const g=p;g.key==="Enter"&&(g.stopPropagation(),g.preventDefault(),f=!0,r(le(h,t)),this.#l(a,!1)),g.key==="Escape"&&(g.stopPropagation(),g.preventDefault(),s(),this.#l(a,!0))}),h instanceof HTMLInputElement&&h.type==="checkbox"&&h.addEventListener("change",()=>r(h.checked)),l||setTimeout(()=>h.focus({preventScroll:!0}),0)}e.appendChild(d)}#b(e){queueMicrotask(()=>{try{const t=e._focusRow,i=e._focusCol,n=e.findRenderedRowElement?.(t);if(n){Array.from(e._bodyEl.querySelectorAll(".cell-focus")).forEach(s=>s.classList.remove("cell-focus"));const r=n.querySelector(`.cell[data-row="${t}"][data-col="${i}"]`);r&&(r.classList.add("cell-focus"),r.setAttribute("aria-selected","true"),r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0}))}}catch{}})}}function Mt(o,e=!0){if(o==null)return"";if(o instanceof Date)return o.toISOString();if(typeof o=="object")return JSON.stringify(o);const t=String(o);return e&&(t.includes(",")||t.includes('"')||t.includes(`
|
|
66
|
-
`)||t.includes("\r"))?`"${t.replace(/"/g,'""')}"`:t}function
|
|
67
|
-
`,s=[],l=i.bom?"\uFEFF":"";if(t.includeHeaders!==!1){const a=e.map(c=>{const d=c.header||c.field,u=t.processHeader?t.processHeader(d,c.field):d;return
|
|
63
|
+
`),r=[];let s=[],l="",a=!1;for(let c=0;c<n.length;c++){const d=n[c];d==='"'&&!a?a=!0:d==='"'&&a?n[c+1]==='"'?(l+='"',c++):a=!1:d===t&&!a?(s.push(l),l=""):d===i&&!a?(s.push(l),l="",(s.length>1||s.some(u=>u.trim()!==""))&&r.push(s),s=[]):l+=d}return s.push(l),(s.length>1||s.some(c=>c.trim()!==""))&&r.push(s),r}async function Ho(){try{return await navigator.clipboard.readText()}catch{return""}}function Dt(o,e){const{rows:t,target:i,fields:n}=o;if(!i)return;const r=e.rows,s=e.effectiveConfig.columns??[],l=s.map(u=>u.field),a=new Map;s.forEach(u=>{a.set(u.field,u.editable===!0)});const c=[...r],d=i.bounds?i.bounds.endRow:1/0;t.forEach((u,h)=>{const f=i.row+h;if(!(f>d)){if(i.bounds){if(f>=c.length)return}else for(;f>=c.length;){const p={};l.forEach(g=>p[g]=""),c.push(p)}c[f]={...c[f]},u.forEach((p,g)=>{const w=n[g];w&&a.get(w)&&(c[f][w]=p)})}}),e.rows=c}class Io extends D{static dependencies=[{name:"selection",required:!1,reason:"Enables copy/paste of selected cells instead of entire grid"}];name="clipboard";get defaultConfig(){return{includeHeaders:!1,delimiter:" ",newline:`
|
|
64
|
+
`,quoteStrings:!1}}lastCopied=null;attach(e){super.attach(e),e.addEventListener("paste",t=>this.#o(t),{signal:this.disconnectSignal})}detach(){this.lastCopied=null}onKeyDown(e){return(e.ctrlKey||e.metaKey)&&e.key==="c"?(this.#e(e.target),!0):!1}#e(e){const t=this.#c(),i=t?.getSelection(),n=this.columns.length-1,r=this.rows.length-1;let s;if(i&&i.ranges.length>0){const{mode:a,ranges:c}=i,d=c[c.length-1];a==="row"?s={startRow:d.from.row,startCol:0,endRow:d.to.row,endCol:n}:s={startRow:d.from.row,startCol:d.from.col,endRow:d.to.row,endCol:d.to.col}}else if(!t)s={startRow:0,startCol:0,endRow:r,endCol:n};else{const a=this.#i(e);if(!a)return;s={startRow:a.row,startCol:a.col,endRow:a.row,endCol:a.col}}const l=this.#s(s);Pe(l.text).then(()=>{this.lastCopied={text:l.text,timestamp:Date.now()},this.emit("copy",{text:l.text,rowCount:l.rowCount,columnCount:l.columnCount})})}#o(e){const t=e.clipboardData?.getData("text/plain");if(!t)return;e.preventDefault();const i=Lt(t,this.config),r=this.#c()?.getSelection(),s=r?.ranges?.[0],l=s?.from.row??0,a=s?.from.col??0,d=s&&(r?.mode==="range"||r?.mode==="row")&&(s.from.row!==s.to.row||s.from.col!==s.to.col)?{endRow:s.to.row,endCol:s.to.col}:null,u=d?.endCol??this.columns.length-1,h=this.columns[a],f=h?{row:l,col:a,field:h.field,bounds:d}:null,p=[],g=i[0]?.length??0;for(let m=0;m<g&&a+m<=u;m++){const v=this.columns[a+m];v&&!v.hidden&&p.push(v.field)}const w={rows:i,text:t,target:f,fields:p};this.emit("paste",w),this.#d(w)}#d(e){if(!this.grid)return;const{pasteHandler:t}=this.config;if(t===null)return;(t??Dt)(e,this.grid)}#c(){try{const e=this.grid?.getPluginByName("selection");if(e)return e}catch{}}#s(e){const{startRow:t,startCol:i,endRow:n,endCol:r}=e,s=Math.min(t,n),l=Math.max(t,n),a=Math.min(i,r),c=Math.max(i,r),d=this.config.delimiter??" ",u=this.config.newline??`
|
|
65
|
+
`,h=[],f=this.columns.slice(a,c+1).filter(p=>!W(p));if(this.config.includeHeaders){const p=f.map(g=>g.header||g.field);h.push(p.join(d))}for(let p=s;p<=l;p++){const g=this.rows[p];if(!g)continue;const w=f.map(m=>{const v=g[m.field];return v==null?"":v instanceof Date?v.toISOString():String(v)});h.push(w.join(d))}return{text:h.join(u),rowCount:l-s+1,columnCount:c-a+1}}#i(e){const t=e.closest("[data-field-cache]");if(!t)return null;const i=t.dataset.fieldCache,n=t.dataset.row;if(!i||!n)return null;const r=parseInt(n,10);if(isNaN(r))return null;const s=this.columns.findIndex(l=>l.field===i);return s===-1?null:{row:r,col:s}}async copy(){const t=this.#c()?.getSelection(),i=this.columns.length-1;let n={startRow:0,startCol:0,endRow:this.rows.length-1,endCol:i};if(t&&t.ranges.length>0){const s=t.ranges[t.ranges.length-1];t.mode==="row"?n={startRow:s.from.row,startCol:0,endRow:s.to.row,endCol:i}:n={startRow:s.from.row,startCol:s.from.col,endRow:s.to.row,endCol:s.to.col}}const r=this.#s(n);return await Pe(r.text),this.lastCopied={text:r.text,timestamp:Date.now()},r.text}async copyRows(e){if(e.length===0)return"";const t=[...e].sort((s,l)=>s-l),i=this.columns.length-1,n={startRow:t[0],startCol:0,endRow:t[t.length-1],endCol:i},r=this.#s(n);return await Pe(r.text),this.lastCopied={text:r.text,timestamp:Date.now()},r.text}async paste(){const e=await Ho();return e?Lt(e,this.config):null}getLastCopied(){return this.lastCopied}}const Ht=100;function Le(o){if(o==null)return Ht;if(typeof o=="number")return o;const e=parseFloat(o);return isNaN(e)?Ht:e}function It(o){return o.map(e=>Le(e.width))}function Mt(o){const e=[];let t=0;for(const i of o)e.push(t),t+=Le(i.width);return e}function Ot(o){return o.reduce((e,t)=>e+Le(t.width),0)}function Mo(o,e,t,i,n){const r=t.length;if(r===0)return{startCol:0,endCol:0,visibleColumns:[]};let s=Oo(o,t,i);s=Math.max(0,s-n);const l=o+e;let a=s;for(let d=s;d<r;d++){if(t[d]>=l){a=d-1;break}a=d}a=Math.min(r-1,a+n);const c=[];for(let d=s;d<=a;d++)c.push(d);return{startCol:s,endCol:a,visibleColumns:c}}function Oo(o,e,t){let i=0,n=e.length-1;for(;i<n;){const r=Math.floor((i+n)/2);e[r]+t[r]<=o?i=r+1:n=r}return i}function No(o,e,t){return t?o>e:!1}class zo extends D{name="columnVirtualization";get defaultConfig(){return{autoEnable:!0,threshold:30,overscan:3}}isVirtualized=!1;startCol=0;endCol=0;scrollLeft=0;totalWidth=0;columnWidths=[];columnOffsets=[];attach(e){super.attach(e);const t=this.columns;this.columnWidths=It(t),this.columnOffsets=Mt(t),this.totalWidth=Ot(t),this.endCol=t.length-1}detach(){this.columnWidths=[],this.columnOffsets=[],this.isVirtualized=!1,this.startCol=0,this.endCol=0,this.scrollLeft=0,this.totalWidth=0}processColumns(e){const t=No(e.length,this.config.threshold??30,this.config.autoEnable??!0);if(this.isVirtualized=t??!1,this.columnWidths=It(e),this.columnOffsets=Mt(e),this.totalWidth=Ot(e),!t)return this.startCol=0,this.endCol=e.length-1,[...e];const i=this.grid.clientWidth||800,n=Mo(this.scrollLeft,i,this.columnOffsets,this.columnWidths,this.config.overscan??3);return this.startCol=n.startCol,this.endCol=n.endCol,n.visibleColumns.map(r=>e[r])}afterRender(){if(!this.isVirtualized)return;const e=this.gridElement;if(!e)return;const t=this.columnOffsets[this.startCol]??0,i=e.querySelector(".header-row"),n=e.querySelectorAll(".data-grid-row");i&&(i.style.paddingLeft=`${t}px`),n.forEach(s=>{s.style.paddingLeft=`${t}px`});const r=e.querySelector(".rows-viewport .rows");r&&(r.style.width=`${this.totalWidth}px`)}onScroll(e){!this.isVirtualized||Math.abs(e.scrollLeft-this.scrollLeft)<1||(this.scrollLeft=e.scrollLeft,this.requestRender())}getIsVirtualized(){return this.isVirtualized}getVisibleColumnRange(){return{start:this.startCol,end:this.endCol}}scrollToColumn(e){const t=this.columnOffsets[e]??0,i=this.grid;i.scrollLeft=t}getColumnOffset(e){return this.columnOffsets[e]??0}getTotalWidth(){return this.totalWidth}}const De="@layer tbw-plugins{.tbw-context-menu{position:fixed;background:var(--tbw-context-menu-bg, var(--tbw-color-panel-bg, light-dark(#f5f5f5, #2a2a2a)));color:var(--tbw-context-menu-fg, var(--tbw-color-fg, light-dark(#222, #eee)));border:1px solid var(--tbw-context-menu-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);box-shadow:0 2px 10px var(--tbw-color-shadow, rgba(0, 0, 0, .15));min-width:var(--tbw-menu-min-width, 10rem);padding:var(--tbw-spacing-xs, .25rem) 0;z-index:10000;font-size:var(--tbw-font-size-sm, .8125rem);font-family:var(--tbw-font-family, system-ui, sans-serif)}.tbw-context-menu-item{display:flex;align-items:center;padding:var(--tbw-menu-item-padding, .375rem .75rem);cursor:pointer;gap:var(--tbw-menu-item-gap, .5rem)}.tbw-context-menu-item:hover:not(.disabled){background:var(--tbw-context-menu-hover, var(--tbw-color-row-hover, light-dark(#e8e8e8, #3a3a3a)))}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:light-dark(#c00,#f66)}.tbw-context-menu-icon{width:var(--tbw-icon-size, 1rem);text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:var(--tbw-color-fg-muted, light-dark(#888, #888));font-size:var(--tbw-font-size-xs, .6875rem)}.tbw-context-menu-arrow{font-size:var(--tbw-font-size-2xs, .625rem);color:var(--tbw-color-fg-muted, light-dark(#888, #888))}.tbw-context-menu-separator{height:1px;background:var(--tbw-context-menu-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));margin:var(--tbw-spacing-xs, .25rem) 0}}";function He(o,e){return(typeof o=="function"?o(e):o).filter(i=>!(i.hidden===!0||typeof i.hidden=="function"&&i.hidden(e)))}function qo(o,e){return o.disabled===!0?!0:typeof o.disabled=="function"?o.disabled(e):!1}function Ie(o,e,t,i=q.submenuArrow){const n=document.createElement("div");n.className="tbw-context-menu",n.setAttribute("role","menu");for(const r of o){if(r.separator){const c=document.createElement("div");c.className="tbw-context-menu-separator",c.setAttribute("role","separator"),n.appendChild(c);continue}const s=document.createElement("div");s.className="tbw-context-menu-item",r.cssClass&&s.classList.add(r.cssClass),s.setAttribute("role","menuitem"),s.setAttribute("data-id",r.id);const l=qo(r,e);if(l&&(s.classList.add("disabled"),s.setAttribute("aria-disabled","true")),r.icon){const c=document.createElement("span");c.className="tbw-context-menu-icon",c.innerHTML=r.icon,s.appendChild(c)}const a=document.createElement("span");if(a.className="tbw-context-menu-label",a.textContent=r.name,s.appendChild(a),r.shortcut){const c=document.createElement("span");c.className="tbw-context-menu-shortcut",c.textContent=r.shortcut,s.appendChild(c)}if(r.subMenu?.length){const c=document.createElement("span");c.className="tbw-context-menu-arrow",typeof i=="string"?c.innerHTML=i:i instanceof HTMLElement&&c.appendChild(i.cloneNode(!0)),s.appendChild(c),s.addEventListener("mouseenter",()=>{if(s.querySelector(".tbw-context-menu")||!r.subMenu)return;const u=He(r.subMenu,e),h=Ie(u,e,t,i);h.classList.add("tbw-context-submenu"),h.style.position="absolute",h.style.left="100%",h.style.top="0",s.style.position="relative",s.appendChild(h)}),s.addEventListener("mouseleave",()=>{const d=s.querySelector(".tbw-context-menu");d&&d.remove()})}!l&&r.action&&!r.subMenu&&s.addEventListener("click",c=>{c.stopPropagation(),t(r)}),n.appendChild(s)}return n}function Nt(o,e,t){o.style.position="fixed",o.style.left=`${e}px`,o.style.top=`${t}px`,o.style.visibility="hidden",o.style.zIndex="10000";const i=o.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight;let s=e,l=t;e+i.width>n&&(s=e-i.width),t+i.height>r&&(l=t-i.height),s=Math.max(0,s),l=Math.max(0,l),o.style.left=`${s}px`,o.style.top=`${l}px`,o.style.visibility="visible"}let ee=null,te=null,V=null,Me=0;const Oe=[{id:"copy",name:"Copy",shortcut:"Ctrl+C",action:o=>{o.grid?.plugins?.clipboard?.copy?.()}},{separator:!0,id:"sep1",name:""},{id:"export-csv",name:"Export CSV",action:o=>{o.grid?.plugins?.export?.exportCsv?.()}}];class Fo extends D{name="contextMenu";get defaultConfig(){return{items:Oe}}isOpen=!1;position={x:0,y:0};params=null;menuElement=null;attach(e){super.attach(e),this.installGlobalHandlers(),Me++}detach(){this.menuElement&&(this.menuElement.remove(),this.menuElement=null),this.isOpen=!1,this.params=null,this.uninstallGlobalHandlers()}installGlobalHandlers(){!V&&typeof document<"u"&&typeof De=="string"&&De&&(V=document.createElement("style"),V.id="tbw-context-menu-styles",V.textContent=De,document.head.appendChild(V)),ee||(ee=()=>{document.querySelectorAll(".tbw-context-menu").forEach(t=>t.remove())},document.addEventListener("click",ee)),te||(te=e=>{e.key==="Escape"&&document.querySelectorAll(".tbw-context-menu").forEach(i=>i.remove())},document.addEventListener("keydown",te))}uninstallGlobalHandlers(){Me--,!(Me>0)&&(ee&&(document.removeEventListener("click",ee),ee=null),te&&(document.removeEventListener("keydown",te),te=null),V&&(V.remove(),V=null))}afterRender(){const e=this.gridElement;if(!e)return;const t=e.children[0];t&&t.getAttribute("data-context-menu-bound")!=="true"&&(t.setAttribute("data-context-menu-bound","true"),t.addEventListener("contextmenu",i=>{const n=i;n.preventDefault();const r=n.target,s=r.closest("[data-row][data-col]"),l=r.closest(".header-cell");let a;if(s){const d=parseInt(s.getAttribute("data-row")??"-1",10),u=parseInt(s.getAttribute("data-col")??"-1",10),h=this.columns[u],f=this.rows[d];a={row:f,rowIndex:d,column:h,columnIndex:u,field:h?.field??"",value:f?.[h?.field]??null,isHeader:!1,event:n}}else if(l){const d=parseInt(l.getAttribute("data-col")??"-1",10),u=this.columns[d];a={row:null,rowIndex:-1,column:u,columnIndex:d,field:u?.field??"",value:null,isHeader:!0,event:n}}else return;this.params=a,this.position={x:n.clientX,y:n.clientY};const c=He(this.config.items??Oe,a);c.length&&(this.menuElement&&this.menuElement.remove(),this.menuElement=Ie(c,a,d=>{d.action&&d.action(a),this.menuElement?.remove(),this.menuElement=null,this.isOpen=!1},this.gridIcons.submenuArrow),document.body.appendChild(this.menuElement),Nt(this.menuElement,n.clientX,n.clientY),this.isOpen=!0,this.emit("context-menu-open",{params:a,items:c}))}))}showMenu(e,t,i){const n={row:i.row??null,rowIndex:i.rowIndex??-1,column:i.column??null,columnIndex:i.columnIndex??-1,field:i.field??"",value:i.value??null,isHeader:i.isHeader??!1,event:i.event??new MouseEvent("contextmenu")},r=He(this.config.items??Oe,n);this.menuElement&&this.menuElement.remove(),this.menuElement=Ie(r,n,s=>{s.action&&s.action(n),this.menuElement?.remove(),this.menuElement=null,this.isOpen=!1},this.gridIcons.submenuArrow),document.body.appendChild(this.menuElement),Nt(this.menuElement,e,t),this.isOpen=!0}hideMenu(){this.menuElement&&(this.menuElement.remove(),this.menuElement=null,this.isOpen=!1)}isMenuOpen(){return this.isOpen}}const Go="@layer tbw-plugins{tbw-grid{--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px}tbw-grid .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}tbw-grid .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px);align-items:center;justify-content:center}tbw-grid .data-grid-row>.cell.editing input:not([type=checkbox]),tbw-grid .data-grid-row>.cell.editing select,tbw-grid .data-grid-row>.cell.editing textarea{width:100%;height:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}tbw-grid .tbw-editor-host{display:contents}}";function Ko(o){const e=o.options;return e?typeof e=="function"?e():e:[]}function Bo(o){return e=>{const t=o.editorParams,i=document.createElement("input");i.type="number",i.value=e.value!=null?String(e.value):"",t?.min!==void 0&&(i.min=String(t.min)),t?.max!==void 0&&(i.max=String(t.max)),t?.step!==void 0&&(i.step=String(t.step)),t?.placeholder&&(i.placeholder=t.placeholder);const n=()=>e.commit(i.value===""?null:Number(i.value));return i.addEventListener("blur",n),i.addEventListener("keydown",r=>{r.key==="Enter"&&n(),r.key==="Escape"&&e.cancel()}),i}}function Wo(){return o=>{const e=document.createElement("input");return e.type="checkbox",e.checked=!!o.value,e.addEventListener("change",()=>o.commit(e.checked)),e}}function Vo(o){return e=>{const t=o.editorParams,i=document.createElement("input");return i.type="date",e.value instanceof Date&&(i.valueAsDate=e.value),t?.min&&(i.min=t.min),t?.max&&(i.max=t.max),t?.placeholder&&(i.placeholder=t.placeholder),i.addEventListener("change",()=>e.commit(i.valueAsDate)),i.addEventListener("keydown",n=>{n.key==="Escape"&&e.cancel()}),i}}function $o(o){return e=>{const t=o.editorParams,i=document.createElement("select");if(o.multi&&(i.multiple=!0),t?.includeEmpty){const s=document.createElement("option");s.value="",s.textContent=t.emptyLabel??"",i.appendChild(s)}Ko(o).forEach(s=>{const l=document.createElement("option");l.value=String(s.value),l.textContent=s.label,(o.multi&&Array.isArray(e.value)&&e.value.includes(s.value)||!o.multi&&e.value===s.value)&&(l.selected=!0),i.appendChild(l)});const r=()=>{if(o.multi){const s=Array.from(i.selectedOptions).map(l=>l.value);e.commit(s)}else e.commit(i.value)};return i.addEventListener("change",r),i.addEventListener("blur",r),i.addEventListener("keydown",s=>{s.key==="Escape"&&e.cancel()}),i}}function Uo(o){return e=>{const t=o.editorParams,i=document.createElement("input");return i.type="text",i.value=e.value!=null?String(e.value):"",t?.maxLength!==void 0&&(i.maxLength=t.maxLength),t?.pattern&&(i.pattern=t.pattern),t?.placeholder&&(i.placeholder=t.placeholder),i.addEventListener("blur",()=>e.commit(i.value)),i.addEventListener("keydown",n=>{n.key==="Enter"&&e.commit(i.value),n.key==="Escape"&&e.cancel()}),i}}function zt(o){switch(o.type){case"number":return Bo(o);case"boolean":return Wo();case"date":return Vo(o);case"select":return $o(o);default:return Uo(o)}}const Ne='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function jo(o,e){if(e.editor)return e.editor;if(e.__editorTemplate)return"template";if(!e.type)return;const i=o.effectiveConfig?.typeDefaults;if(i?.[e.type]?.editor)return i[e.type].editor;const n=o.__frameworkAdapter;if(n?.getTypeDefault){const r=n.getTypeDefault(e.type);if(r?.editor)return r.editor}}function le(o){return!(typeof o!="string"||o==="__proto__"||o==="constructor"||o==="prototype")}function Yo(o){const e=(o.__editingCellCount??0)+1;o.__editingCellCount=e,o.setAttribute("data-has-editing","")}function Xo(o){o.__editingCellCount=0,o.removeAttribute("data-has-editing")}function ae(o,e){return o instanceof HTMLInputElement?o.type==="checkbox"?o.checked:o.type==="number"?o.value===""?null:Number(o.value):o.type==="date"?o.valueAsDate:o.value:e?.type==="number"&&o.value!==""?Number(o.value):o.value}function qt(o){}function Zo(o,e,t){const i=o.querySelector("input,textarea,select");i&&(i.addEventListener("blur",()=>{t(ae(i,e))}),i instanceof HTMLInputElement&&i.type==="checkbox"?i.addEventListener("change",()=>t(i.checked)):i instanceof HTMLSelectElement&&i.addEventListener("change",()=>t(ae(i,e))))}class Jo extends D{static manifest={ownedProperties:[{property:"editable",level:"column",description:'the "editable" column property',isUsed:e=>e===!0},{property:"editor",level:"column",description:'the "editor" column property'},{property:"editorParams",level:"column",description:'the "editorParams" column property'}]};name="editing";styles=Go;get defaultConfig(){return{editOn:"click"}}#e=-1;#o=-1;#d=new Map;#c=new Set;#s=new Set;#i=!1;attach(e){super.attach(e);const t=this.disconnectSignal,i=e;i._activeEditRows=-1,i._rowEditSnapshots=new Map,Object.defineProperty(e,"changedRows",{get:()=>this.changedRows,configurable:!0}),Object.defineProperty(e,"changedRowIds",{get:()=>this.changedRowIds,configurable:!0}),e.resetChangedRows=n=>this.resetChangedRows(n),e.beginBulkEdit=(n,r)=>{r&&this.beginCellEdit(n,r)},document.addEventListener("keydown",n=>{n.key==="Escape"&&this.#e!==-1&&this.#l(this.#e,!0)},{capture:!0,signal:t}),document.addEventListener("mousedown",n=>{if(this.#e===-1)return;const r=i.findRenderedRowElement?.(this.#e);!r||(n.composedPath&&n.composedPath()||[]).includes(r)||this.#l(this.#e,!1)},{signal:t})}detach(){this.#e=-1,this.#o=-1,this.#d.clear(),this.#c.clear(),this.#s.clear(),super.detach()}onCellClick(e){const t=this.grid,i=this.config.editOn??t.effectiveConfig?.editOn;if(i===!1||i==="manual"||i!=="click"&&i!=="dblclick")return!1;const n=e.originalEvent.type==="dblclick";if(i==="click"&&n||i==="dblclick"&&!n)return!1;const{rowIndex:r}=e;return t._columns?.some(l=>l.editable)?(e.originalEvent.stopPropagation(),this.beginBulkEdit(r),!0):!1}onKeyDown(e){const t=this.grid;if(e.key==="Escape"&&this.#e!==-1)return this.#l(this.#e,!0),!0;if(e.key===" "||e.key==="Spacebar"){const i=t._focusRow,n=t._focusCol;if(i>=0&&n>=0){const r=t._visibleColumns[n],s=t._rows[i];if(r?.editable&&r.type==="boolean"&&s){const l=r.field;if(le(l)){const c=!s[l];return this.#w(i,r,c,s),e.preventDefault(),this.requestRender(),!0}}}return!1}if(e.key==="Enter"&&!e.shiftKey){if(this.#e!==-1)return!1;const i=this.config.editOn??t.effectiveConfig?.editOn;if(i===!1||i==="manual")return!1;const n=t._focusRow,r=t._focusCol;if(n>=0&&t._columns?.some(l=>l.editable)){const l=t._visibleColumns[r],a=t._rows[n],c=l?.field??"",d=c&&a?a[c]:void 0,u=this.gridElement.querySelector(`[data-row="${n}"][data-col="${r}"]`),h=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,detail:{rowIndex:n,colIndex:r,field:c,value:d,row:a,cellEl:u,trigger:"keyboard",originalEvent:e}});this.gridElement.dispatchEvent(h);const f=new CustomEvent("activate-cell",{cancelable:!0,bubbles:!0,detail:{row:n,col:r}});return this.gridElement.dispatchEvent(f),h.defaultPrevented||f.defaultPrevented?(e.preventDefault(),!0):(this.beginBulkEdit(n),!0)}return!1}return!1}processColumns(e){const t=this.grid,i=t.effectiveConfig?.typeDefaults,n=t.__frameworkAdapter;return!i&&!n?.getTypeDefault?e:e.map(r=>{if(!r.type)return r;let s;if(i?.[r.type]?.editorParams&&(s=i[r.type].editorParams),!s&&n?.getTypeDefault){const l=n.getTypeDefault(r.type);l?.editorParams&&(s=l.editorParams)}return s?{...r,editorParams:{...s,...r.editorParams}}:r})}afterRender(){const e=this.grid;if(this.#i&&(this.#i=!1,this.#b(e)),this.#s.size!==0)for(const t of this.#s){const[i,n]=t.split(":"),r=parseInt(i,10),s=parseInt(n,10),l=e.findRenderedRowElement?.(r);if(!l)continue;const a=l.querySelector(`.cell[data-col="${s}"]`);if(!a||a.classList.contains("editing"))continue;const c=e._rows[r],d=e._visibleColumns[s];c&&d&&this.#m(c,r,d,s,a,!0)}}onScrollRender(){this.afterRender()}get changedRows(){const e=[];for(const t of this.#c){const i=this.grid.getRow(t);i&&e.push(i)}return e}get changedRowIds(){return Array.from(this.#c)}get activeEditRow(){return this.#e}get activeEditCol(){return this.#o}isRowEditing(e){return this.#e===e}isCellEditing(e,t){return this.#s.has(`${e}:${t}`)}isRowChanged(e){const t=this.grid,i=t._rows[e];if(!i)return!1;try{const n=t.getRowId?.(i);return n?this.#c.has(n):!1}catch{return!1}}isRowChangedById(e){return this.#c.has(e)}resetChangedRows(e){const t=this.changedRows,i=this.changedRowIds;this.#c.clear(),this.#u(),e||this.emit("changed-rows-reset",{rows:t,ids:i}),this.grid._rowPool?.forEach(r=>r.classList.remove("changed"))}beginCellEdit(e,t){const i=this.grid,n=i._visibleColumns.findIndex(a=>a.field===t);if(n===-1||!i._visibleColumns[n]?.editable)return;const l=i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${n}"]`);l&&this.#h(e,n,l)}beginBulkEdit(e){const t=this.grid;if((this.config.editOn??t.effectiveConfig?.editOn)===!1||!t._columns?.some(l=>l.editable))return;const r=t.findRenderedRowElement?.(e);if(!r)return;const s=t._rows[e];this.#p(e,s),Array.from(r.children).forEach((l,a)=>{const c=t._visibleColumns[a];if(c?.editable){const d=l;d.classList.contains("editing")||this.#m(s,e,c,a,d,!0)}}),setTimeout(()=>{let l=r.querySelector(`.cell[data-col="${t._focusCol}"]`);if(l?.classList.contains("editing")||(l=r.querySelector(".cell.editing")),l?.classList.contains("editing")){const a=l.querySelector(Ne);try{a?.focus({preventScroll:!0})}catch{}}},0)}commitActiveRowEdit(){this.#e!==-1&&this.#l(this.#e,!1)}cancelActiveRowEdit(){this.#e!==-1&&this.#l(this.#e,!0)}#h(e,t,i){const n=this.grid,r=n._rows[e],s=n._visibleColumns[t];!r||!s?.editable||i.classList.contains("editing")||(this.#e!==e&&this.#p(e,r),this.#o=t,this.#m(r,e,s,t,i,!1))}#u(){const e=this.grid;e._activeEditRows=this.#e,e._rowEditSnapshots=this.#d}#p(e,t){this.#e!==e&&(this.#d.set(e,{...t}),this.#e=e,this.#u())}#l(e,t){if(this.#e!==e)return;const i=this.grid,n=this.#d.get(e),r=i._rows[e],s=i.findRenderedRowElement?.(e);let l;if(r)try{l=i.getRowId?.(r)}catch{}if(!t&&s&&r&&s.querySelectorAll(".cell.editing").forEach(c=>{const d=Number(c.getAttribute("data-col"));if(isNaN(d))return;const u=i._visibleColumns[d];if(!u)return;const h=c.querySelector("input,textarea,select");if(h){const f=ae(h,u);r[u.field]!==f&&this.#w(e,u,f,r)}}),t&&n&&r)Object.keys(n).forEach(a=>{r[a]=n[a]}),l&&this.#c.delete(l);else if(!t&&r){const a=l?this.#c.has(l):!1;this.emit("row-commit",{rowIndex:e,rowId:l??"",row:r,changed:a,changedRows:this.changedRows,changedRowIds:this.changedRowIds}),a&&this.isAnimationEnabled&&i.animateRow?.(e,"change")}this.#d.delete(e),this.#e=-1,this.#o=-1,this.#u();for(const a of this.#s)a.startsWith(`${e}:`)&&this.#s.delete(a);s&&(s.querySelectorAll(".cell.editing").forEach(a=>{a.classList.remove("editing"),Xo(a.parentElement)}),this.requestRender()),this.#i=!0,s||(this.#b(i),this.#i=!1)}#w(e,t,i,n){const r=t.field;if(!le(r))return;const s=n[r];if(s===i)return;const l=this.grid;let a;try{a=this.grid.getRowId(n)}catch{}const c=a?!this.#c.has(a):!0,d=a?f=>this.grid.updateRow(a,f,"cascade"):qt;if(this.emitCancelable("cell-commit",{row:n,rowId:a??"",field:r,oldValue:s,value:i,rowIndex:e,changedRows:this.changedRows,changedRowIds:this.changedRowIds,firstTimeForRow:c,updateRow:d}))return;n[r]=i,a&&this.#c.add(a),this.#u();const h=l.findRenderedRowElement?.(e);h&&(h.classList.add("changed"),wt(h,"change"))}#m(e,t,i,n,r,s){if(!i.editable||r.classList.contains("editing"))return;let l;try{l=this.grid.getRowId(e)}catch{}const a=l?b=>this.grid.updateRow(l,b,"cascade"):qt,c=le(i.field)?e[i.field]:void 0;r.classList.add("editing"),this.#s.add(`${t}:${n}`);const d=r.parentElement;d&&Yo(d);let u=!1;const h=b=>{u||this.#e===-1||this.#w(t,i,b,e)},f=()=>{u=!0,le(i.field)&&(e[i.field]=c)},p=document.createElement("div");p.className="tbw-editor-host",r.innerHTML="",r.appendChild(p),p.addEventListener("keydown",b=>{b.key==="Enter"&&(b.stopPropagation(),b.preventDefault(),u=!0,this.#l(t,!1)),b.key==="Escape"&&(b.stopPropagation(),b.preventDefault(),f(),this.#l(t,!0))});const g=i,w=g.__editorTemplate,m=jo(this.grid,g)??zt(i),v=c;if(m==="template"&&w)this.#a(p,g,e,c,h,f,s,t);else if(typeof m=="string"){const b=document.createElement(m);b.value=v,b.addEventListener("change",()=>h(b.value)),p.appendChild(b),s||queueMicrotask(()=>{p.querySelector(Ne)?.focus({preventScroll:!0})})}else if(typeof m=="function"){const b={row:e,rowId:l??"",value:v,field:i.field,column:i,commit:h,cancel:f,updateRow:a},R=m(b);typeof R=="string"?(p.innerHTML=R,Zo(p,i,h)):R instanceof Node&&p.appendChild(R),s||queueMicrotask(()=>{p.querySelector(Ne)?.focus({preventScroll:!0})})}else if(m&&typeof m=="object"){const b=document.createElement("div");b.setAttribute("data-external-editor",""),b.setAttribute("data-field",i.field),p.appendChild(b);const R={row:e,rowId:l??"",value:v,field:i.field,column:i,commit:h,cancel:f,updateRow:a};if(m.mount)try{m.mount({placeholder:b,context:R,spec:m})}catch(C){console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`,C)}else this.grid.dispatchEvent(new CustomEvent("mount-external-editor",{detail:{placeholder:b,spec:m,context:R}}))}}#a(e,t,i,n,r,s,l,a){const c=t.__editorTemplate;if(!c)return;const d=c.cloneNode(!0),u=t.__compiledEditor;u?d.innerHTML=u({row:i,value:n,field:t.field,column:t,commit:r,cancel:s}):d.querySelectorAll("*").forEach(f=>{f.childNodes.length===1&&f.firstChild?.nodeType===Node.TEXT_NODE&&(f.textContent=f.textContent?.replace(/{{\s*value\s*}}/g,n==null?"":String(n)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g,(p,g)=>{if(!le(g))return"";const w=i[g];return w==null?"":String(w)})||"")});const h=d.querySelector("input,textarea,select");if(h){h instanceof HTMLInputElement&&h.type==="checkbox"?h.checked=!!n:h.value=String(n??"");let f=!1;h.addEventListener("blur",()=>{f||r(ae(h,t))}),h.addEventListener("keydown",p=>{const g=p;g.key==="Enter"&&(g.stopPropagation(),g.preventDefault(),f=!0,r(ae(h,t)),this.#l(a,!1)),g.key==="Escape"&&(g.stopPropagation(),g.preventDefault(),s(),this.#l(a,!0))}),h instanceof HTMLInputElement&&h.type==="checkbox"&&h.addEventListener("change",()=>r(h.checked)),l||setTimeout(()=>h.focus({preventScroll:!0}),0)}e.appendChild(d)}#b(e){queueMicrotask(()=>{try{const t=e._focusRow,i=e._focusCol,n=e.findRenderedRowElement?.(t);if(n){Array.from(e._bodyEl.querySelectorAll(".cell-focus")).forEach(s=>s.classList.remove("cell-focus"));const r=n.querySelector(`.cell[data-row="${t}"][data-col="${i}"]`);r&&(r.classList.add("cell-focus"),r.setAttribute("aria-selected","true"),r.hasAttribute("tabindex")||r.setAttribute("tabindex","-1"),r.focus({preventScroll:!0}))}}catch{}})}}function Ft(o,e=!0){if(o==null)return"";if(o instanceof Date)return o.toISOString();if(typeof o=="object")return JSON.stringify(o);const t=String(o);return e&&(t.includes(",")||t.includes('"')||t.includes(`
|
|
66
|
+
`)||t.includes("\r"))?`"${t.replace(/"/g,'""')}"`:t}function Qo(o,e,t,i={}){const n=i.delimiter??",",r=i.newline??`
|
|
67
|
+
`,s=[],l=i.bom?"\uFEFF":"";if(t.includeHeaders!==!1){const a=e.map(c=>{const d=c.header||c.field,u=t.processHeader?t.processHeader(d,c.field):d;return Ft(u)});s.push(a.join(n))}for(const a of o){const c=e.map(d=>{let u=a[d.field];return t.processCell&&(u=t.processCell(u,d.field,a)),Ft(u)});s.push(c.join(n))}return l+s.join(r)}function ze(o,e){const t=URL.createObjectURL(o),i=document.createElement("a");i.href=t,i.download=e,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}function en(o,e){const t=new Blob([o],{type:"text/csv;charset=utf-8;"});ze(t,e)}function Gt(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function tn(o,e,t){let i=`<?xml version="1.0" encoding="UTF-8"?>
|
|
68
68
|
<?mso-application progid="Excel.Sheet"?>
|
|
69
69
|
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
|
70
70
|
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
|
|
71
71
|
<Worksheet ss:Name="Sheet1">
|
|
72
72
|
<Table>`;if(t.includeHeaders!==!1){i+=`
|
|
73
|
-
<Row>`;for(const n of e){const r=n.header||n.field,s=t.processHeader?t.processHeader(r,n.field):r;i+=`<Cell><Data ss:Type="String">${
|
|
74
|
-
<Row>`;for(const r of e){let s=n[r.field];t.processCell&&(s=t.processCell(s,r.field,n));let l="String",a="";s==null?a="":typeof s=="number"&&!isNaN(s)?(l="Number",a=String(s)):s instanceof Date?(l="DateTime",a=s.toISOString()):a=
|
|
73
|
+
<Row>`;for(const n of e){const r=n.header||n.field,s=t.processHeader?t.processHeader(r,n.field):r;i+=`<Cell><Data ss:Type="String">${Gt(s)}</Data></Cell>`}i+="</Row>"}for(const n of o){i+=`
|
|
74
|
+
<Row>`;for(const r of e){let s=n[r.field];t.processCell&&(s=t.processCell(s,r.field,n));let l="String",a="";s==null?a="":typeof s=="number"&&!isNaN(s)?(l="Number",a=String(s)):s instanceof Date?(l="DateTime",a=s.toISOString()):a=Gt(String(s)),i+=`<Cell><Data ss:Type="${l}">${a}</Data></Cell>`}i+="</Row>"}return i+=`
|
|
75
75
|
</Table>
|
|
76
76
|
</Worksheet>
|
|
77
|
-
</Workbook>`,i}function Vo(o,e){const t=e.endsWith(".xls")?e:`${e}.xls`,i=new Blob([o],{type:"application/vnd.ms-excel;charset=utf-8;"});Me(i,t)}class $o extends L{name="export";get defaultConfig(){return{fileName:"export",includeHeaders:!0,onlyVisible:!0,onlySelected:!1}}isExportingFlag=!1;lastExportInfo=null;performExport(e,t){const i=this.config,n={format:e,fileName:t?.fileName??i.fileName??"export",includeHeaders:t?.includeHeaders??i.includeHeaders,processCell:t?.processCell,processHeader:t?.processHeader,columns:t?.columns,rowIndices:t?.rowIndices};let r=[...this.columns];if(i.onlyVisible&&(r=r.filter(a=>!a.hidden&&!a.field.startsWith("__"))),t?.columns){const a=new Set(t.columns);r=r.filter(c=>a.has(c.field))}let s=[...this.rows];if(i.onlySelected){const a=this.getSelectionState();a?.selected?.size&&(s=[...a.selected].sort((d,u)=>d-u).map(d=>this.rows[d]).filter(Boolean))}t?.rowIndices&&(s=t.rowIndices.map(a=>this.rows[a]).filter(Boolean)),this.isExportingFlag=!0;let l=n.fileName;try{switch(e){case"csv":{const a=Ko(s,r,n,{bom:!0});l=l.endsWith(".csv")?l:`${l}.csv`,Bo(a,l);break}case"excel":{const a=Wo(s,r,n);l=l.endsWith(".xls")?l:`${l}.xls`,Vo(a,l);break}case"json":{const a=s.map(u=>{const h={};for(const f of r){let p=u[f.field];n.processCell&&(p=n.processCell(p,f.field,u)),h[f.field]=p}return h}),c=JSON.stringify(a,null,2);l=l.endsWith(".json")?l:`${l}.json`;const d=new Blob([c],{type:"application/json"});Me(d,l);break}}this.lastExportInfo={format:e,timestamp:new Date},this.emit("export-complete",{format:e,fileName:l,rowCount:s.length,columnCount:r.length})}finally{this.isExportingFlag=!1}}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}exportCsv(e){this.performExport("csv",e)}exportExcel(e){this.performExport("excel",e)}exportJson(e){this.performExport("json",e)}isExporting(){return this.isExportingFlag}getLastExport(){return this.lastExportInfo}}function Uo(o){const{totalRows:e,viewportHeight:t,scrollTop:i,rowHeight:n,overscan:r}=o,s=Math.ceil(t/n);let l=Math.floor(i/n)-r;l<0&&(l=0);let a=l+s+r*2;return a>e&&(a=e),a===e&&l>0&&(l=Math.max(0,a-s-r*2)),{start:l,end:a,offsetY:l*n,totalHeight:e*n}}function jo(o,e){return o<=e}function Yo(o,e,t=!1){const i=o[e.field];if(e.operator==="blank")return i==null||i==="";if(e.operator==="notBlank")return i!=null&&i!=="";if(i==null)return!1;const n=String(i),r=t?n:n.toLowerCase(),s=t?String(e.value):String(e.value).toLowerCase();switch(e.operator){case"contains":return r.includes(s);case"notContains":return!r.includes(s);case"equals":return r===s;case"notEquals":return r!==s;case"startsWith":return r.startsWith(s);case"endsWith":return r.endsWith(s);case"lessThan":return Number(i)<Number(e.value);case"lessThanOrEqual":return Number(i)<=Number(e.value);case"greaterThan":return Number(i)>Number(e.value);case"greaterThanOrEqual":return Number(i)>=Number(e.value);case"between":return Number(i)>=Number(e.value)&&Number(i)<=Number(e.valueTo);case"in":return Array.isArray(e.value)&&e.value.includes(i);case"notIn":return Array.isArray(e.value)&&!e.value.includes(i);default:return!0}}function Xo(o,e,t=!1){return e.length?o.filter(i=>e.every(n=>Yo(i,n,t))):o}function Zo(o){return JSON.stringify(o.map(e=>({field:e.field,operator:e.operator,value:e.value,valueTo:e.valueTo})))}function Nt(o,e){const t=new Set;for(const i of o){const n=i[e];n!=null&&t.add(n)}return[...t].sort((i,n)=>typeof i=="number"&&typeof n=="number"?i-n:String(i).localeCompare(String(n)))}const Jo='@layer tbw-plugins{tbw-grid .tbw-quick-filter-input{flex:1;max-width:300px;height:var(--tbw-input-height, 1.75rem);padding:var(--tbw-input-padding, 0 .5rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:var(--tbw-font-size-sm, .8125rem)}tbw-grid .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}tbw-grid .header-cell.filtered:before{content:"";position:absolute;top:var(--tbw-spacing-xs, .25rem);right:var(--tbw-spacing-xs, .25rem);width:var(--tbw-indicator-size, .375rem);height:var(--tbw-indicator-size, .375rem);background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}tbw-grid .tbw-filter-btn{display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:var(--tbw-spacing-xs, .25rem);opacity:.4;transition:opacity .15s;color:inherit;vertical-align:middle}tbw-grid .tbw-filter-btn:hover,tbw-grid .tbw-filter-btn.active{opacity:1}tbw-grid .tbw-filter-btn.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}}',Qo="@layer tbw-plugins{.tbw-filter-panel{position:fixed;background:var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));color:var(--tbw-filter-panel-fg, var(--tbw-color-fg, light-dark(#222222, #eeeeee)));border:1px solid var(--tbw-filter-panel-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-panel-radius, var(--tbw-border-radius, .25rem));box-shadow:0 4px 16px var(--tbw-filter-panel-shadow, var(--tbw-color-shadow, light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3))));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));z-index:10000;min-width:200px;max-width:280px;max-height:350px;display:flex;flex-direction:column;font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-font-size, .8125rem);transform-origin:top center}.tbw-filter-panel.tbw-filter-panel-above{transform-origin:bottom center}.tbw-filter-panel.tbw-filter-panel-animated{animation:tbw-filter-panel-enter var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}.tbw-filter-panel.tbw-filter-panel-above.tbw-filter-panel-animated{animation:tbw-filter-panel-enter-above var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}@keyframes tbw-filter-panel-enter{0%{opacity:0;transform:scaleY(.3) translateY(-10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@keyframes tbw-filter-panel-enter-above{0%{opacity:0;transform:scaleY(.3) translateY(10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@supports (anchor-name: --test){.tbw-filter-panel{position-anchor:--tbw-filter-anchor;top:anchor(bottom);left:anchor(left);margin-top:4px;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}.tbw-filter-search{margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-search-input{width:100%;padding:var(--tbw-button-padding, .375rem .625rem);background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-search-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-actions{display:flex;padding:var(--tbw-button-padding-sm, .25rem .125rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-bottom:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-action-btn{background:transparent;border:none;color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));cursor:pointer;font-size:var(--tbw-font-size-xs, .75rem);padding:2px 0}.tbw-filter-action-btn:hover{text-decoration:underline}.tbw-filter-values{flex:1;overflow-y:auto;margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));max-height:180px;position:relative}.tbw-filter-values-spacer{width:1px}.tbw-filter-values-content{position:absolute;top:0;left:0;right:0}.tbw-filter-value-item{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding-sm, .25rem .125rem);cursor:pointer;border-radius:3px}.tbw-filter-value-item:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-checkbox{margin:0;cursor:pointer;accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}.tbw-filter-no-match{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem)) 0;text-align:center;font-style:italic}.tbw-filter-buttons{display:flex;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding-top:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-top:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-apply-btn{flex:1;padding:var(--tbw-button-padding, .375rem .75rem);background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));color:var(--tbw-filter-accent-fg, var(--tbw-color-accent-fg, light-dark(#ffffff, #000000)));border:none;border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;padding:var(--tbw-button-padding, .375rem .75rem);background:transparent;color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}}";class q extends L{name="filtering";styles=Jo;get defaultConfig(){return{debounceMs:300,caseSensitive:!1,trimInput:!0,useWorker:!0}}filters=new Map;cachedResult=null;cacheKey=null;openPanelField=null;panelElement=null;panelAnchorElement=null;searchText=new Map;excludedValues=new Map;panelAbortController=null;globalStylesInjected=!1;static LIST_ITEM_HEIGHT=28;static LIST_OVERSCAN=3;static LIST_BYPASS_THRESHOLD=50;syncExcludedValues(e,t){t?t.type==="set"&&t.operator==="notIn"&&Array.isArray(t.value)?this.excludedValues.set(e,new Set(t.value)):t.type==="set"&&this.excludedValues.delete(e):this.excludedValues.delete(e)}attach(e){super.attach(e),this.injectGlobalStyles()}detach(){this.filters.clear(),this.cachedResult=null,this.cacheKey=null,this.openPanelField=null,this.panelElement&&(this.panelElement.remove(),this.panelElement=null),this.searchText.clear(),this.excludedValues.clear(),this.panelAbortController?.abort(),this.panelAbortController=null}processRows(e){const t=[...this.filters.values()];if(!t.length)return[...e];if(this.config.filterHandler)return this.cachedResult?this.cachedResult:[...e];const i=Zo(t);if(this.cacheKey===i&&this.cachedResult)return this.cachedResult;const n=Xo([...e],t,this.config.caseSensitive);return this.cachedResult=n,this.cacheKey=i,n}afterRender(){const e=this.gridElement;if(!e)return;e.querySelectorAll('[part~="header-cell"]').forEach(i=>{const n=i.getAttribute("data-col");if(n===null)return;const r=this.visibleColumns[parseInt(n,10)];if(!r||r.filterable===!1||B(r))return;const s=r.field;if(!s)return;const l=this.filters.has(s);let a=i.querySelector(".tbw-filter-btn");if(a){a.classList.toggle("active",l),i.classList.toggle("filtered",l);return}a=document.createElement("button"),a.className="tbw-filter-btn",a.setAttribute("aria-label",`Filter ${r.header??s}`),a.innerHTML='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',l&&(a.classList.add("active"),i.classList.add("filtered")),a.addEventListener("click",d=>{d.stopPropagation(),this.toggleFilterPanel(s,r,a)});const c=i.querySelector(".resize-handle");c?i.insertBefore(a,c):i.appendChild(a)})}setFilter(e,t){if(t===null)this.filters.delete(e),this.syncExcludedValues(e,null);else{const i={...t,field:e};this.filters.set(e,i),this.syncExcludedValues(e,i)}this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}getFilter(e){return this.filters.get(e)}getFilters(){return[...this.filters.values()]}getFilterModel(){return this.getFilters()}setFilterModel(e){this.filters.clear(),this.excludedValues.clear();for(const t of e)this.filters.set(t.field,t),this.syncExcludedValues(t.field,t);this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}clearAllFilters(){this.filters.clear(),this.excludedValues.clear(),this.searchText.clear(),this.applyFiltersInternal()}clearFieldFilter(e){this.filters.delete(e),this.excludedValues.delete(e),this.searchText.delete(e),this.applyFiltersInternal()}isFieldFiltered(e){return this.filters.has(e)}getFilteredRowCount(){return this.cachedResult?.length??this.rows.length}getActiveFilters(){return this.getFilters()}getUniqueValues(e){return Nt(this.sourceRows,e)}injectGlobalStyles(){if(this.globalStylesInjected)return;if(document.getElementById("tbw-filter-panel-styles")){this.globalStylesInjected=!0;return}const e=document.createElement("style");e.id="tbw-filter-panel-styles",e.textContent=Qo,document.head.appendChild(e),this.globalStylesInjected=!0}toggleFilterPanel(e,t,i){if(this.openPanelField===e){this.closeFilterPanel();return}this.closeFilterPanel();const n=document.createElement("div");if(n.className="tbw-filter-panel",this.isAnimationEnabled&&n.classList.add("tbw-filter-panel-animated"),this.panelElement=n,this.openPanelField=e,this.config.valuesHandler){n.innerHTML='<div class="tbw-filter-loading">Loading...</div>',document.body.appendChild(n),this.positionPanel(n,i),this.setupPanelCloseHandler(n,i),this.config.valuesHandler(e,t).then(s=>{this.openPanelField!==e||!this.panelElement||(n.innerHTML="",this.renderPanelContent(e,t,n,s))});return}const r=Nt(this.sourceRows,e);this.renderPanelContent(e,t,n,r),document.body.appendChild(n),this.positionPanel(n,i),this.setupPanelCloseHandler(n,i)}renderPanelContent(e,t,i,n){let r=this.excludedValues.get(e);r||(r=new Set,this.excludedValues.set(e,r));const s=this.searchText.get(e)??"",l={field:e,column:t,uniqueValues:n,excludedValues:r,searchText:s,applySetFilter:c=>{this.applySetFilter(e,c),this.closeFilterPanel()},applyTextFilter:(c,d,u)=>{this.applyTextFilter(e,c,d,u),this.closeFilterPanel()},clearFilter:()=>{this.clearFieldFilter(e),this.closeFilterPanel()},closePanel:()=>this.closeFilterPanel()};let a=!1;this.config.filterPanelRenderer&&(this.config.filterPanelRenderer(i,l),a=i.children.length>0),a||this.renderDefaultFilterPanel(i,l,n,r)}setupPanelCloseHandler(e,t){this.panelAbortController=new AbortController,setTimeout(()=>{document.addEventListener("click",i=>{!e.contains(i.target)&&i.target!==t&&this.closeFilterPanel()},{signal:this.panelAbortController?.signal})},0)}closeFilterPanel(){const e=this.panelElement;e&&(e.remove(),this.panelElement=null),this.panelAnchorElement&&(this.panelAnchorElement.style.anchorName="",this.panelAnchorElement=null),this.openPanelField=null,this.panelAbortController?.abort(),this.panelAbortController=null}static supportsAnchorPositioning=null;static checkAnchorPositioningSupport(){return q.supportsAnchorPositioning===null&&(q.supportsAnchorPositioning=CSS.supports("anchor-name","--test")),q.supportsAnchorPositioning}positionPanel(e,t){const n=t.closest(".cell")??t;if(n.style.anchorName="--tbw-filter-anchor",this.panelAnchorElement=n,q.checkAnchorPositioningSupport()){requestAnimationFrame(()=>{const s=e.getBoundingClientRect(),l=n.getBoundingClientRect();s.top<l.top&&e.classList.add("tbw-filter-panel-above")});return}const r=n.getBoundingClientRect();e.style.position="fixed",e.style.top=`${r.bottom+4}px`,e.style.left=`${r.left}px`,requestAnimationFrame(()=>{const s=e.getBoundingClientRect();s.right>window.innerWidth-8&&(e.style.left=`${r.right-s.width}px`),s.bottom>window.innerHeight-8&&(e.style.top=`${r.top-s.height-4}px`,e.classList.add("tbw-filter-panel-above"))})}renderDefaultFilterPanel(e,t,i,n){const{field:r}=t,s=document.createElement("div");s.className="tbw-filter-search";const l=document.createElement("input");l.type="text",l.placeholder="Search...",l.className="tbw-filter-search-input",l.value=this.searchText.get(r)??"",s.appendChild(l),e.appendChild(s);const a=document.createElement("div");a.className="tbw-filter-actions";const c=document.createElement("label");c.className="tbw-filter-value-item",c.style.padding="0",c.style.margin="0";const d=document.createElement("input");d.type="checkbox",d.className="tbw-filter-checkbox";const u=document.createElement("span");u.textContent="Select All",c.appendChild(d),c.appendChild(u),a.appendChild(c);const h=()=>{const v=[...w.values()],k=v.every(R=>R),S=v.every(R=>!R);d.checked=k,d.indeterminate=!k&&!S};d.addEventListener("change",()=>{const v=d.checked;for(const k of w.keys())w.set(k,v);h(),b()}),e.appendChild(a);const f=document.createElement("div");f.className="tbw-filter-values";const p=document.createElement("div");p.className="tbw-filter-values-spacer",f.appendChild(p);const g=document.createElement("div");g.className="tbw-filter-values-content",f.appendChild(g);const w=new Map;i.forEach(v=>{const k=v==null?"__null__":String(v);w.set(k,!n.has(v))}),h();let m=[];const y=(v,k)=>{const S=v==null?"(Blank)":String(v),R=v==null?"__null__":String(v),P=document.createElement("label");P.className="tbw-filter-value-item",P.style.position="absolute",P.style.top=`${k*q.LIST_ITEM_HEIGHT}px`,P.style.left="0",P.style.right="0",P.style.height=`${q.LIST_ITEM_HEIGHT}px`,P.style.boxSizing="border-box";const O=document.createElement("input");O.type="checkbox",O.className="tbw-filter-checkbox",O.checked=w.get(R)??!0,O.dataset.value=R,O.addEventListener("change",()=>{w.set(R,O.checked),h()});const ui=document.createElement("span");return ui.textContent=S,P.appendChild(O),P.appendChild(ui),P},b=()=>{const v=m.length,k=f.clientHeight,S=f.scrollTop;if(p.style.height=`${v*q.LIST_ITEM_HEIGHT}px`,jo(v,q.LIST_BYPASS_THRESHOLD/3)){g.innerHTML="",g.style.transform="translateY(0px)",m.forEach((P,O)=>{g.appendChild(y(P,O))});return}const R=Uo({totalRows:v,viewportHeight:k,scrollTop:S,rowHeight:q.LIST_ITEM_HEIGHT,overscan:q.LIST_OVERSCAN});g.style.transform=`translateY(${R.offsetY}px)`,g.innerHTML="";for(let P=R.start;P<R.end;P++)g.appendChild(y(m[P],P-R.start))},_=v=>{const k=this.config.caseSensitive??!1,S=k?v:v.toLowerCase();if(m=i.filter(R=>{const P=R==null?"(Blank)":String(R),O=k?P:P.toLowerCase();return!v||O.includes(S)}),m.length===0){p.style.height="0px",g.innerHTML="";const R=document.createElement("div");R.className="tbw-filter-no-match",R.textContent="No matching values",g.appendChild(R);return}b()};f.addEventListener("scroll",()=>{m.length>0&&b()},{passive:!0}),_(l.value),e.appendChild(f);let x;l.addEventListener("input",()=>{clearTimeout(x),x=setTimeout(()=>{this.searchText.set(r,l.value),_(l.value)},this.config.debounceMs??150)});const A=document.createElement("div");A.className="tbw-filter-buttons";const T=document.createElement("button");T.className="tbw-filter-apply-btn",T.textContent="Apply",T.addEventListener("click",()=>{const v=[];for(const[k,S]of w)if(!S)if(k==="__null__")v.push(null);else{const R=i.find(P=>String(P)===k);v.push(R!==void 0?R:k)}t.applySetFilter(v)}),A.appendChild(T);const E=document.createElement("button");E.className="tbw-filter-clear-btn",E.textContent="Clear Filter",E.addEventListener("click",()=>{t.clearFilter()}),A.appendChild(E),e.appendChild(A)}applySetFilter(e,t){this.excludedValues.set(e,new Set(t)),t.length===0?this.filters.delete(e):this.filters.set(e,{field:e,type:"set",operator:"notIn",value:t}),this.applyFiltersInternal()}applyTextFilter(e,t,i,n){this.filters.set(e,{field:e,type:"text",operator:t,value:i,valueTo:n}),this.applyFiltersInternal()}applyFiltersInternal(){this.cachedResult=null,this.cacheKey=null;const e=[...this.filters.values()];if(this.config.filterHandler){const t=this.grid;t.setAttribute("aria-busy","true");const i=this.config.filterHandler(e,this.sourceRows),n=r=>{t.removeAttribute("aria-busy"),this.cachedResult=r,this.grid.rows=r,this.emit("filter-change",{filters:e,filteredRowCount:r.length}),this.requestRender()};i&&typeof i.then=="function"?i.then(n):n(i);return}this.emit("filter-change",{filters:e,filteredRowCount:0}),this.requestRender()}getColumnState(e){const t=this.filters.get(e);if(t)return{filter:{type:t.type,operator:t.operator,value:t.value,valueTo:t.valueTo}}}applyColumnState(e,t){if(!t.filter){this.filters.delete(e);return}const i={field:e,type:t.filter.type,operator:t.filter.operator,value:t.filter.value,valueTo:t.filter.valueTo};this.filters.set(e,i),this.cachedResult=null,this.cacheKey=null}}function zt(o){if(!o.length)return[];const e=new Map,t=[],i=(s,l)=>{if(!l.length)return;const a=t[t.length-1];if(a&&a.implicit&&a.firstIndex+a.columns.length===s){a.columns.push(...l);return}t.push({id:"__implicit__"+s,label:void 0,columns:l,firstIndex:s,implicit:!0})};let n=[],r=0;return o.forEach((s,l)=>{const a=s.group;if(!a){n.length===0&&(r=l),n.push(s);return}n.length&&(i(r,n.slice()),n=[]);const c=typeof a=="string"?a:a.id;let d=e.get(c);d||(d={id:c,label:typeof a=="string"?void 0:a.label,columns:[],firstIndex:l},e.set(c,d),t.push(d)),d.columns.push(s)}),n.length&&i(r,n),t.length===1&&t[0].implicit&&t[0].columns.length===o.length?[]:t}function en(o,e,t){if(!e.length||!o)return;const i=new Map;for(const r of e)for(const s of r.columns)s.field&&i.set(s.field,r.id);const n=Array.from(o.querySelectorAll(".cell[data-field]"));n.forEach(r=>{const s=r.getAttribute("data-field")||"",l=i.get(s);l&&(r.classList.add("grouped"),r.getAttribute("data-group")||r.setAttribute("data-group",l))});for(const r of e){const s=r.columns[r.columns.length-1],l=n.find(a=>a.getAttribute("data-field")===s.field);l&&l.classList.add("group-end")}}function tn(o,e){if(o.length===0)return null;const t=document.createElement("div");t.className="header-group-row",t.setAttribute("role","row");for(const i of o){const n=i.columns[0],r=n?e.findIndex(c=>c.field===n.field):-1;if(r===-1)continue;const s=String(i.id).startsWith("__implicit__"),l=s?"":i.label||i.id,a=document.createElement("div");a.className="cell header-group-cell",s&&a.classList.add("implicit-group"),a.setAttribute("data-group",String(i.id)),a.style.gridColumn=`${r+1} / span ${i.columns.length}`,a.textContent=l,t.appendChild(a)}return t}function on(o){return o.some(e=>e.group!=null)}const nn="@layer tbw-plugins{.header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:var(--tbw-button-padding-sm, .25rem .5rem);font-weight:600;font-size:var(--tbw-font-size-sm, .9em);text-transform:uppercase;letter-spacing:.5px;border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.header-group-cell:last-child{border-right:none}.header-row .cell.grouped{border-top:none}.header-row .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.header-row .cell.group-end:last-child{border-right:none}.rows .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.rows .cell.group-end:last-child{border-right:none}.header-group-row.no-borders{border-bottom:none}.header-group-row.no-borders .header-group-cell{border-right:none}.header-row.no-group-borders .cell.group-end{border-right:1px solid var(--tbw-color-border)}}";class rn extends L{static manifest={ownedProperties:[{property:"group",level:"column",description:'the "group" column property'},{property:"columnGroups",level:"config",description:'the "columnGroups" config property',isUsed:e=>Array.isArray(e)&&e.length>0}]};name="groupingColumns";styles=nn;get defaultConfig(){return{showGroupBorders:!0}}groups=[];isActive=!1;detach(){this.groups=[],this.isActive=!1}static detect(e,t){if(t?.columnGroups&&Array.isArray(t.columnGroups)&&t.columnGroups.length>0)return!0;const i=t?.columns;return Array.isArray(i)?on(i):!1}processColumns(e){const t=this.grid?.gridConfig?.columnGroups;let i;if(t&&Array.isArray(t)&&t.length>0){const r=new Map;for(const s of t)for(const l of s.children)r.set(l,{id:s.id,label:s.header});i=e.map(s=>{const l=r.get(s.field);return l&&!s.group?{...s,group:l}:s})}else i=[...e];const n=zt(i);return n.length===0?(this.isActive=!1,this.groups=[],i):(this.isActive=!0,this.groups=n,i)}afterRender(){if(!this.isActive){const a=this.gridElement?.querySelector(".header")?.querySelector(".header-group-row");a&&a.remove();return}const e=this.gridElement?.querySelector(".header");if(!e)return;const t=e.querySelector(".header-group-row");t&&t.remove();const i=this.columns,n=zt(i);if(n.length===0)return;const r=tn(n,i);if(r){r.classList.toggle("no-borders",!this.config.showGroupBorders);const l=e.querySelector(".header-row");l?e.insertBefore(r,l):e.appendChild(r)}const s=e.querySelector(".header-row");s&&(s.classList.toggle("no-group-borders",!this.config.showGroupBorders),en(s,n)),this.#e(n)}#e(e){if(!this.config.showGroupBorders)return;const t=this.gridElement;if(!t)return;const i=new Set;for(const r of e){const s=r.columns[r.columns.length-1];s?.field&&i.add(s.field)}const n=t.querySelectorAll(".rows .cell[data-field]");for(const r of n){const s=r.getAttribute("data-field");s&&i.has(s)?r.classList.add("group-end"):r.classList.remove("group-end")}}isGroupingActive(){return this.isActive}getGroups(){return this.groups}getGroupColumns(e){const t=this.groups.find(i=>i.id===e);return t?t.columns:[]}refresh(){this.requestRender()}}const Oe={sum:(o,e)=>o.reduce((t,i)=>t+(Number(i[e])||0),0),avg:(o,e)=>{const t=o.reduce((i,n)=>i+(Number(n[e])||0),0);return o.length?t/o.length:0},count:o=>o.length,min:(o,e)=>Math.min(...o.map(t=>Number(t[e])||1/0)),max:(o,e)=>Math.max(...o.map(t=>Number(t[e])||-1/0)),first:(o,e)=>o[0]?.[e],last:(o,e)=>o[o.length-1]?.[e]},ae=new Map,K={register(o,e){ae.set(o,e)},unregister(o){ae.delete(o)},get(o){if(o!==void 0)return typeof o=="function"?o:ae.get(o)??Oe[o]},run(o,e,t,i){const n=this.get(o);return n?n(e,t,i):void 0},has(o){return ae.has(o)||o in Oe},list(){return[...Object.keys(Oe),...ae.keys()]}},qt={sum:o=>o.reduce((e,t)=>e+t,0),avg:o=>o.length?o.reduce((e,t)=>e+t,0)/o.length:0,count:o=>o.length,min:o=>o.length?Math.min(...o):0,max:o=>o.length?Math.max(...o):0,first:o=>o[0]??0,last:o=>o[o.length-1]??0};function sn(o){return qt[o]??qt.sum}K.register.bind(K),K.unregister.bind(K);const Ft=K.get.bind(K),Gt=K.run.bind(K);K.list.bind(K);function ln({rows:o,config:e,expanded:t}){const i=e.groupOn;if(typeof i!="function")return[];const n={key:"__root__",value:null,depth:-1,rows:[],children:new Map};if(o.forEach(l=>{let a=i(l);a==null||a===!1?a=["__ungrouped__"]:Array.isArray(a)||(a=[a]);let c=n;a.forEach((d,u)=>{const h=d==null?"∅":String(d),f=c.key==="__root__"?h:c.key+"||"+h;let p=c.children.get(h);p||(p={key:f,value:d,depth:u,rows:[],children:new Map,parent:c},c.children.set(h,p)),c=p}),c.rows.push(l)}),n.children.size===1&&n.children.has("__ungrouped__")&&n.children.get("__ungrouped__").rows.length===o.length)return[];const r=[],s=l=>{if(l===n){l.children.forEach(c=>s(c));return}const a=t.has(l.key);r.push({kind:"group",key:l.key,value:l.value,depth:l.depth,rows:l.rows,expanded:a}),a&&(l.children.size?l.children.forEach(c=>s(c)):l.rows.forEach(c=>r.push({kind:"data",row:c,rowIndex:o.indexOf(c)})))};return s(n),r}function an(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function cn(o){const e=new Set;for(const t of o)t.kind==="group"&&e.add(t.key);return e}function dn(){return new Set}function un(o){return o.kind!=="group"?0:o.rows.length}const hn="@layer tbw-plugins{.group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-grouping-rows-bg, var(--tbw-color-panel-bg));font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}.group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, .125rem .5rem)}.group-row:hover{background:var(--tbw-grouping-rows-bg-hover, var(--tbw-color-row-hover))}.group-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toggle-size, 1.25rem);height:var(--tbw-toggle-size, 1.25rem);margin-right:.25rem;background:none;border:0;font:inherit}.group-toggle:hover{background:var(--tbw-grouping-rows-toggle-hover, var(--tbw-color-row-hover));border-radius:var(--tbw-border-radius, .125rem)}.group-label{display:inline-flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.group-count{color:var(--tbw-grouping-rows-count-color, var(--tbw-color-fg-muted));font-size:var(--tbw-font-size-xs, .85em);font-weight:400}.group-row{padding-left:calc(var(--tbw-group-depth, 0) * var(--tbw-group-indent-width, 1.25em))}.data-grid-row.tbw-group-slide-in{animation:tbw-group-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-group-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.data-grid-row.tbw-group-fade-in{animation:tbw-group-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-group-fade-in{0%{opacity:0}to{opacity:1}}}";class fn extends L{name="groupingRows";styles=hn;get defaultConfig(){return{defaultExpanded:!1,showRowCount:!0,indentWidth:20,aggregators:{},animation:"slide"}}expandedKeys=new Set;flattenedRows=[];isActive=!1;previousVisibleKeys=new Set;keysToAnimate=new Set;get animationStyle(){return this.isAnimationEnabled?this.config.animation??"slide":!1}detach(){this.expandedKeys.clear(),this.flattenedRows=[],this.isActive=!1,this.previousVisibleKeys.clear(),this.keysToAnimate.clear()}static detect(e,t){return typeof t?.groupOn=="function"||typeof t?.enableRowGrouping=="boolean"}processRows(e){const t=this.config;if(typeof t.groupOn!="function")return this.isActive=!1,this.flattenedRows=[],[...e];const i=ln({rows:[...e],config:t,expanded:this.expandedKeys});if(i.length===0)return this.isActive=!1,this.flattenedRows=[],[...e];this.isActive=!0,this.flattenedRows=i,this.keysToAnimate.clear();const n=new Set;return i.forEach((r,s)=>{if(r.kind==="data"){const l=`data-${s}`;n.add(l),this.previousVisibleKeys.has(l)||this.keysToAnimate.add(l)}}),this.previousVisibleKeys=n,i.map(r=>r.kind==="group"?{__isGroupRow:!0,__groupKey:r.key,__groupValue:r.value,__groupDepth:r.depth,__groupRows:r.rows,__groupExpanded:r.expanded,__groupRowCount:un(r)}:r.row)}onCellClick(e){const t=e.row;if(t?.__isGroupRow&&e.originalEvent.target?.closest(".group-toggle"))return this.toggle(t.__groupKey),!0}onKeyDown(e){if(e.key!==" ")return;const t=this.grid._focusRow,i=this.rows[t];if(i?.__isGroupRow)return e.preventDefault(),this.toggle(i.__groupKey),this.requestRenderWithFocus(),!0}renderRow(e,t,i){if(!e?.__isGroupRow)return!1;const n=this.config;if(n.groupRowRenderer){const l=()=>{this.toggle(e.__groupKey)},a=n.groupRowRenderer({key:e.__groupKey,value:e.__groupValue,depth:e.__groupDepth,rows:e.__groupRows,expanded:e.__groupExpanded,toggleExpand:l});if(a)return t.className="data-grid-row group-row",t.__isCustomRow=!0,t.setAttribute("data-group-depth",String(e.__groupDepth)),typeof a=="string"?t.innerHTML=a:(t.innerHTML="",t.appendChild(a)),!0}const r=()=>{this.toggle(e.__groupKey)};return t.className="data-grid-row group-row",t.__isCustomRow=!0,t.setAttribute("data-group-depth",String(e.__groupDepth)),t.setAttribute("role","row"),t.setAttribute("aria-expanded",String(e.__groupExpanded)),t.style.setProperty("--tbw-group-depth",String(e.__groupDepth||0)),n.indentWidth!==void 0&&t.style.setProperty("--tbw-group-indent-width",`${n.indentWidth}px`),t.style.height="",t.innerHTML="",n.fullWidth!==!1?this.renderFullWidthGroupRow(e,t,r):this.renderPerColumnGroupRow(e,t,r),!0}afterRender(){const e=this.animationStyle;if(e===!1||this.keysToAnimate.size===0)return;const t=this.gridElement?.querySelector(".rows");if(!t)return;const i=e==="fade"?"tbw-group-fade-in":"tbw-group-slide-in";for(const n of t.querySelectorAll(".data-grid-row:not(.group-row)")){const r=n.querySelector(".cell[data-row]"),s=r?parseInt(r.getAttribute("data-row")??"-1",10):-1,a=this.flattenedRows[s]?.kind==="data"?`data-${s}`:void 0;a&&this.keysToAnimate.has(a)&&(n.classList.add(i),n.addEventListener("animationend",()=>n.classList.remove(i),{once:!0}))}this.keysToAnimate.clear()}createToggleButton(e,t){const i=document.createElement("button");return i.type="button",i.className=`group-toggle${e?" expanded":""}`,i.setAttribute("aria-label",e?"Collapse group":"Expand group"),this.setIcon(i,this.resolveIcon(e?"collapse":"expand")),i.addEventListener("click",n=>{n.stopPropagation(),t()}),i}getGroupLabelText(e,t,i){const n=this.config;return n.formatLabel?n.formatLabel(e,t,i):String(e)}renderFullWidthGroupRow(e,t,i){const n=this.config,r=document.createElement("div");r.className="cell group-full",r.style.gridColumn="1 / -1",r.setAttribute("role","gridcell"),r.setAttribute("data-col","0"),r.appendChild(this.createToggleButton(e.__groupExpanded,i));const s=document.createElement("span");if(s.className="group-label",s.textContent=this.getGroupLabelText(e.__groupValue,e.__groupDepth||0,e.__groupKey),r.appendChild(s),n.showRowCount!==!1){const l=document.createElement("span");l.className="group-count",l.textContent=`(${e.__groupRowCount??e.__groupRows?.length??0})`,r.appendChild(l)}t.appendChild(r)}renderPerColumnGroupRow(e,t,i){const n=this.config,r=n.aggregators??{},s=this.columns,l=e.__groupRows??[],c=this.gridElement?.querySelector(".body")?.style.gridTemplateColumns||"";c&&(t.style.display="grid",t.style.gridTemplateColumns=c);let d=!1;s.forEach((u,h)=>{const f=document.createElement("div");if(f.className="cell group-cell",f.setAttribute("data-col",String(h)),f.setAttribute("role","gridcell"),_e(u)){f.setAttribute("data-field",u.field),t.appendChild(f);return}if(d){const p=r[u.field];if(p){const g=Gt(p,l,u.field,u);f.textContent=g!=null?String(g):""}else f.textContent=""}else{d=!0,f.appendChild(this.createToggleButton(e.__groupExpanded,i));const p=document.createElement("span"),g=r[u.field];if(g){const w=Gt(g,l,u.field,u);p.textContent=w!=null?String(w):String(e.__groupValue)}else p.textContent=this.getGroupLabelText(e.__groupValue,e.__groupDepth||0,e.__groupKey);if(f.appendChild(p),n.showRowCount!==!1){const w=document.createElement("span");w.className="group-count",w.textContent=` (${l.length})`,f.appendChild(w)}}t.appendChild(f)})}expandAll(){this.expandedKeys=cn(this.flattenedRows),this.requestRender()}collapseAll(){this.expandedKeys=dn(),this.requestRender()}toggle(e){this.expandedKeys=an(this.expandedKeys,e);const t=this.flattenedRows.find(i=>i.kind==="group"&&i.key===e);this.emit("group-toggle",{key:e,expanded:this.expandedKeys.has(e),value:t?.value,depth:t?.depth??0}),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}expand(e){this.expandedKeys.has(e)||(this.expandedKeys=new Set([...this.expandedKeys,e]),this.requestRender())}collapse(e){if(this.expandedKeys.has(e)){const t=new Set(this.expandedKeys);t.delete(e),this.expandedKeys=t,this.requestRender()}}getGroupState(){const e=this.flattenedRows.filter(t=>t.kind==="group");return{isActive:this.isActive,expandedCount:this.expandedKeys.size,totalGroups:e.length,expandedKeys:[...this.expandedKeys]}}getRowCount(){return this.flattenedRows.length}refreshGroups(){this.requestRender()}getExpandedGroups(){return[...this.expandedKeys]}getFlattenedRows(){return this.flattenedRows}isGroupingActive(){return this.isActive}setGroupOn(e){this.config.groupOn=e,this.requestRender()}}function Kt(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function gn(o,e){const t=new Set(o);return t.add(e),t}function pn(o,e){const t=new Set(o);return t.delete(e),t}function wn(o,e){return o.has(e)}function mn(o,e,t,i){const n=document.createElement("div");n.className="master-detail-row",n.setAttribute("data-detail-for",String(e)),n.setAttribute("role","row");const r=document.createElement("div");r.className="master-detail-cell",r.setAttribute("role","cell"),r.style.gridColumn=`1 / ${i+1}`;const s=t(o,e);return typeof s=="string"?r.innerHTML=s:s instanceof HTMLElement&&r.appendChild(s),n.appendChild(r),n}const bn="@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:center}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}tbw-grid .master-detail-expander{display:flex;align-items:center;justify-content:center;width:100%;height:100%}tbw-grid .master-detail-toggle{cursor:pointer;opacity:.7;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center}tbw-grid .master-detail-toggle:hover{opacity:1}tbw-grid .master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border));overflow:hidden}tbw-grid .master-detail-cell{padding:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem));overflow:auto}tbw-grid .master-detail-row.tbw-expanding{animation:tbw-detail-expand var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}tbw-grid .master-detail-row.tbw-collapsing{animation:tbw-detail-collapse var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-detail-expand{0%{opacity:0;max-height:0;padding-top:0;padding-bottom:0}to{opacity:1;max-height:var(--tbw-detail-max-height, 31.25rem);padding-top:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem));padding-bottom:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem))}}@keyframes tbw-detail-collapse{0%{opacity:1;max-height:var(--tbw-detail-max-height, 31.25rem)}to{opacity:0;max-height:0}}}";class Ne extends L{name="masterDetail";styles=bn;get defaultConfig(){return{detailHeight:"auto",expandOnRowClick:!1,collapseOnClickOutside:!1,animation:"slide"}}attach(e){super.attach(e),this.parseLightDomDetail()}parseLightDomDetail(){const e=this.grid;if(!e||typeof e.querySelector!="function")return;const t=e.querySelector("tbw-grid-detail");if(!t)return;const i=e;if(i.__frameworkAdapter?.parseDetailElement){const u=i.__frameworkAdapter.parseDetailElement(t);if(u){this.config={...this.config,detailRenderer:u};return}}const n=t.getAttribute("animation"),r=t.getAttribute("show-expand-column"),s=t.getAttribute("expand-on-row-click"),l=t.getAttribute("collapse-on-click-outside"),a=t.getAttribute("height"),c={};n!==null&&(c.animation=n==="false"?!1:n),r!==null&&(c.showExpandColumn=r!=="false"),s!==null&&(c.expandOnRowClick=s==="true"),l!==null&&(c.collapseOnClickOutside=l==="true"),a!==null&&(c.detailHeight=a==="auto"?"auto":parseInt(a,10));const d=t.innerHTML.trim();d&&!this.config.detailRenderer&&(c.detailRenderer=(u,h)=>{const f=we(d,{value:u,row:u});return ie(f)}),Object.keys(c).length>0&&(this.config={...this.config,...c})}get animationStyle(){return this.isAnimationEnabled?this.config.animation??"slide":!1}animateExpand(e){!this.isAnimationEnabled||this.animationStyle===!1||(e.classList.add("tbw-expanding"),e.addEventListener("animationend",()=>{e.classList.remove("tbw-expanding")},{once:!0}))}animateCollapse(e,t){if(!this.isAnimationEnabled||this.animationStyle===!1){t();return}e.classList.add("tbw-collapsing");const i=()=>{e.classList.remove("tbw-collapsing"),t()};e.addEventListener("animationend",i,{once:!0}),setTimeout(i,this.animationDuration+50)}expandedRows=new Set;detailElements=new Map;static DEFAULT_DETAIL_HEIGHT=150;getDetailHeight(e){const t=this.detailElements.get(e);return t?t.offsetHeight:typeof this.config?.detailHeight=="number"?this.config.detailHeight:Ne.DEFAULT_DETAIL_HEIGHT}toggleAndEmit(e,t){this.expandedRows=Kt(this.expandedRows,e),this.emit("detail-expand",{rowIndex:t,row:e,expanded:this.expandedRows.has(e)}),this.requestRender()}detach(){this.expandedRows.clear(),this.detailElements.clear()}processColumns(e){if(!(this.config.showExpandColumn===!0||this.config.showExpandColumn!==!1&&!!this.config.detailRenderer))return[...e];const i=[...e];if(yo(i))return i;const r=Co(this.name);return r.viewRenderer=s=>{const{row:l}=s,a=this.expandedRows.has(l),c=document.createElement("span");c.className="master-detail-expander expander-cell";const d=document.createElement("span");return d.className=`master-detail-toggle${a?" expanded":""}`,this.setIcon(d,this.resolveIcon(a?"collapse":"expand")),d.setAttribute("role","button"),d.setAttribute("tabindex","0"),d.setAttribute("aria-expanded",String(a)),d.setAttribute("aria-label",a?"Collapse details":"Expand details"),c.appendChild(d),c},[r,...i]}onRowClick(e){if(!(!this.config.expandOnRowClick||!this.config.detailRenderer))return this.toggleAndEmit(e.row,e.rowIndex),!1}onCellClick(e){if(e.originalEvent?.target?.classList.contains("master-detail-toggle"))return this.toggleAndEmit(e.row,e.rowIndex),!0;this.expandedRows.size>0&&queueMicrotask(()=>this.#e())}onKeyDown(e){if(e.key!==" ")return;const t=this.grid._focusCol,i=this.grid._focusRow,n=this.columns[t];if(!n||!_e(n))return;const r=this.rows[i];if(r)return e.preventDefault(),this.toggleAndEmit(r,i),this.requestRenderWithFocus(),!0}afterRender(){this.#e()}onScrollRender(){!this.config.detailRenderer||this.expandedRows.size===0||this.#e()}#e(){if(!this.config.detailRenderer)return;const e=this.gridElement?.querySelector(".rows");if(!e)return;const t=new Map,i=e.querySelectorAll(".data-grid-row"),n=this.columns.length;for(const s of i){const l=s.querySelector(".cell[data-row]"),a=l?parseInt(l.getAttribute("data-row")??"-1",10):-1;a>=0&&t.set(a,s)}const r=e.querySelectorAll(".master-detail-row");for(const s of r){const l=parseInt(s.getAttribute("data-detail-for")??"-1",10),a=l>=0?this.rows[l]:void 0,c=a&&this.expandedRows.has(a),d=t.has(l);(!c||!d)&&(s.remove(),a&&this.detailElements.delete(a))}for(const[s,l]of t){const a=this.rows[s];if(!a||!this.expandedRows.has(a))continue;const c=this.detailElements.get(a);if(c){c.previousElementSibling!==l&&l.after(c);continue}const d=mn(a,s,this.config.detailRenderer,n);typeof this.config.detailHeight=="number"&&(d.style.height=`${this.config.detailHeight}px`),l.after(d),this.detailElements.set(a,d),this.animateExpand(d)}}getExtraHeight(){let e=0;for(const t of this.expandedRows)e+=this.getDetailHeight(t);return e}getExtraHeightBefore(e){let t=0;for(const i of this.expandedRows){const n=this.rows.indexOf(i);n>=0&&n<e&&(t+=this.getDetailHeight(i))}return t}adjustVirtualStart(e,t,i){if(this.expandedRows.size===0)return e;const n=[];for(const l of this.expandedRows){const a=this.rows.indexOf(l);a>=0&&n.push({index:a,row:l})}n.sort((l,a)=>l.index-a.index);let r=e,s=0;for(const{index:l,row:a}of n){const c=l*i+s,d=this.getDetailHeight(a),u=c+i+d;s+=d,!(l>=e)&&u>t&&l<r&&(r=l)}return r}expand(e){const t=this.rows[e];t&&(this.expandedRows=gn(this.expandedRows,t),this.requestRender())}collapse(e){const t=this.rows[e];t&&(this.expandedRows=pn(this.expandedRows,t),this.requestRender())}toggle(e){const t=this.rows[e];t&&(this.expandedRows=Kt(this.expandedRows,t),this.requestRender())}isExpanded(e){const t=this.rows[e];return t?wn(this.expandedRows,t):!1}expandAll(){for(const e of this.rows)this.expandedRows.add(e);this.requestRender()}collapseAll(){this.expandedRows.clear(),this.requestRender()}getExpandedRows(){const e=[];for(const t of this.expandedRows){const i=this.rows.indexOf(t);i>=0&&e.push(i)}return e}getDetailElement(e){const t=this.rows[e];return t?this.detailElements.get(t):void 0}refreshDetailRenderer(){const e=this.config.detailRenderer;if(this.config={...this.config,detailRenderer:void 0},this.parseLightDomDetail(),!this.config.detailRenderer&&e&&(this.config={...this.config,detailRenderer:e}),this.config.detailRenderer){const t=this.grid;typeof t.refreshColumns=="function"?t.refreshColumns():this.requestRender()}}}function vn(o,e,t){return e.length?[...o].sort((i,n)=>{for(const r of e){const l=t.find(u=>u.field===r.field)?.sortComparator??yn,a=i[r.field],c=n[r.field],d=l(a,c,i,n);if(d!==0)return r.direction==="asc"?d:-d}return 0}):[...o]}function yn(o,e){return o==null&&e==null?0:o==null?1:e==null?-1:typeof o=="number"&&typeof e=="number"?o-e:o instanceof Date&&e instanceof Date?o.getTime()-e.getTime():typeof o=="boolean"&&typeof e=="boolean"?o===e?0:o?-1:1:String(o).localeCompare(String(e))}function Cn(o,e,t,i){const n=o.find(r=>r.field===e);return t?n?n.direction==="asc"?o.map(r=>r.field===e?{...r,direction:"desc"}:r):o.filter(r=>r.field!==e):o.length<i?[...o,{field:e,direction:"asc"}]:o:n?.direction==="asc"?[{field:e,direction:"desc"}]:n?.direction==="desc"?[]:[{field:e,direction:"asc"}]}function Bt(o,e){const t=o.findIndex(i=>i.field===e);return t>=0?t+1:void 0}function Wt(o,e){return o.find(t=>t.field===e)?.direction}const xn='@layer tbw-plugins{.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-indicator{margin-left:4px;opacity:.8}.sort-index{font-size:10px;background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}}';class Rn extends L{name="multiSort";styles=xn;get defaultConfig(){return{maxSortColumns:3,showSortIndex:!0}}sortModel=[];detach(){this.sortModel=[]}processRows(e){return this.sortModel.length===0?[...e]:vn([...e],this.sortModel,[...this.columns])}onHeaderClick(e){if(!this.columns.find(r=>r.field===e.field)?.sortable)return!1;const i=e.originalEvent.shiftKey,n=this.config.maxSortColumns??3;return this.sortModel=Cn(this.sortModel,e.field,i,n),this.emit("sort-change",{sortModel:[...this.sortModel]}),this.requestRender(),!0}afterRender(){const e=this.gridElement;if(!e)return;const t=this.config.showSortIndex!==!1;e.querySelectorAll(".header-row .cell[data-field]").forEach(n=>{const r=n.getAttribute("data-field");if(!r)return;const s=Bt(this.sortModel,r),l=Wt(this.sortModel,r);if(n.querySelector(".sort-index")?.remove(),l){n.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(),n.setAttribute("data-sort",l);const d=document.createElement("span");d.className="sort-indicator",this.setIcon(d,this.resolveIcon(l==="asc"?"sortAsc":"sortDesc"));const u=n.querySelector(".tbw-filter-btn"),h=n.querySelector(".resize-handle"),f=u??h;if(f?n.insertBefore(d,f):n.appendChild(d),t&&this.sortModel.length>1&&s!==void 0){const p=document.createElement("span");p.className="sort-index",p.textContent=String(s),d.nextSibling?n.insertBefore(p,d.nextSibling):n.appendChild(p)}}else n.removeAttribute("data-sort")})}getSortModel(){return[...this.sortModel]}setSortModel(e){this.sortModel=[...e],this.emit("sort-change",{sortModel:[...e]}),this.requestRender()}clearSort(){this.sortModel=[],this.emit("sort-change",{sortModel:[]}),this.requestRender()}getSortIndex(e){return Bt(this.sortModel,e)}getSortDirection(e){return Wt(this.sortModel,e)}getColumnState(e){const t=this.sortModel.findIndex(n=>n.field===e);return t===-1?void 0:{sort:{direction:this.sortModel[t].direction,priority:t}}}applyColumnState(e,t){if(!t.sort){this.sortModel=this.sortModel.filter(r=>r.field!==e);return}const i=this.sortModel.findIndex(r=>r.field===e),n={field:e,direction:t.sort.direction};i!==-1?this.sortModel[i]=n:this.sortModel.splice(t.sort.priority,0,n)}}function En(o){return o.filter(e=>e.sticky==="left")}function Sn(o){return o.filter(e=>e.sticky==="right")}function ze(o){return o.some(e=>e.sticky==="left"||e.sticky==="right")}function Vt(o,e){const t=Array.from(o.querySelectorAll(".header-row .cell"));if(!t.length)return;const i=new Map;e.forEach((s,l)=>{s.field&&i.set(s.field,l)});let n=0;for(const s of e)if(s.sticky==="left"){const l=i.get(s.field),a=t.find(c=>c.getAttribute("data-field")===s.field);a&&(a.classList.add("sticky-left"),a.style.position="sticky",a.style.left=n+"px",l!==void 0&&o.querySelectorAll(`.data-grid-row .cell[data-col="${l}"]`).forEach(c=>{c.classList.add("sticky-left"),c.style.position="sticky",c.style.left=n+"px"}),n+=a.offsetWidth)}let r=0;for(const s of[...e].reverse())if(s.sticky==="right"){const l=i.get(s.field),a=t.find(c=>c.getAttribute("data-field")===s.field);a&&(a.classList.add("sticky-right"),a.style.position="sticky",a.style.right=r+"px",l!==void 0&&o.querySelectorAll(`.data-grid-row .cell[data-col="${l}"]`).forEach(c=>{c.classList.add("sticky-right"),c.style.position="sticky",c.style.right=r+"px"}),r+=a.offsetWidth)}}function $t(o){o.querySelectorAll(".sticky-left, .sticky-right").forEach(t=>{t.classList.remove("sticky-left","sticky-right"),t.style.position="",t.style.left="",t.style.right=""})}class _n extends L{static manifest={ownedProperties:[{property:"sticky",level:"column",description:'the "sticky" column property',isUsed:e=>e==="left"||e==="right"}]};name="pinnedColumns";get defaultConfig(){return{}}isApplied=!1;leftOffsets=new Map;rightOffsets=new Map;detach(){this.leftOffsets.clear(),this.rightOffsets.clear(),this.isApplied=!1}static detect(e,t){const i=t?.columns;return Array.isArray(i)?ze(i):!1}processColumns(e){return this.isApplied=ze([...e]),[...e]}afterRender(){if(!this.isApplied)return;const e=this.grid,t=[...this.columns];if(!ze(t)){$t(e),this.isApplied=!1;return}queueMicrotask(()=>{Vt(e,t)})}onPluginQuery(e){switch(e.type){case Se.CAN_MOVE_COLUMN:{const t=e.context,i=t.sticky;if(i==="left"||i==="right")return!1;const n=t.meta?.sticky;return n==="left"||n==="right"?!1:void 0}default:return}}refreshStickyOffsets(){const e=[...this.columns];Vt(this.grid,e)}getLeftPinnedColumns(){const e=[...this.columns];return En(e)}getRightPinnedColumns(){const e=[...this.columns];return Sn(e)}clearStickyPositions(){$t(this.grid)}getHorizontalScrollOffsets(e,t){if(!this.isApplied)return;let i=0,n=0;if(e){const s=e.querySelectorAll(".sticky-left"),l=e.querySelectorAll(".sticky-right");s.forEach(a=>{i+=a.offsetWidth}),l.forEach(a=>{n+=a.offsetWidth})}else this.grid.querySelectorAll(".header-row .cell").forEach(a=>{a.classList.contains("sticky-left")?i+=a.offsetWidth:a.classList.contains("sticky-right")&&(n+=a.offsetWidth)});const r=t?.classList.contains("sticky-left")||t?.classList.contains("sticky-right");return{left:i,right:n,skipScroll:r}}}function An(o){return typeof o=="object"&&o!==null&&"aggFunc"in o}function qe(o,e){const t=document.createElement("div");t.className="tbw-pinned-rows",t.setAttribute("role","presentation"),t.setAttribute("aria-live","polite");const i=document.createElement("div");i.className="tbw-pinned-rows-left";const n=document.createElement("div");n.className="tbw-pinned-rows-center";const r=document.createElement("div");if(r.className="tbw-pinned-rows-right",o.showRowCount!==!1){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-row-count",s.textContent=`Total: ${e.totalRows} rows`,i.appendChild(s)}if(o.showFilteredCount&&e.filteredRows!==e.totalRows){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-filtered-count",s.textContent=`Filtered: ${e.filteredRows}`,i.appendChild(s)}if(o.showSelectedCount&&e.selectedRows>0){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-selected-count",s.textContent=`Selected: ${e.selectedRows}`,r.appendChild(s)}if(o.customPanels)for(const s of o.customPanels){const l=Tn(s,e);switch(s.position){case"left":i.appendChild(l);break;case"center":n.appendChild(l);break;case"right":r.appendChild(l);break}}return t.appendChild(i),t.appendChild(n),t.appendChild(r),t}function Ut(o){const e=document.createElement("div");return e.className=`tbw-aggregation-rows tbw-aggregation-rows-${o}`,e.setAttribute("role","presentation"),e}function jt(o,e,t,i){o.innerHTML="";for(const n of e){const r=document.createElement("div");if(r.className="tbw-aggregation-row",r.setAttribute("role","presentation"),n.id&&r.setAttribute("data-aggregation-id",n.id),n.fullWidth){const s=document.createElement("div");s.className="tbw-aggregation-cell tbw-aggregation-cell-full",s.style.gridColumn="1 / -1",s.textContent=n.label||"",r.appendChild(s)}else for(const s of t){const l=document.createElement("div");l.className="tbw-aggregation-cell",l.setAttribute("data-field",s.field);let a,c;const d=n.aggregators?.[s.field];if(d)if(An(d)){const u=Ft(d.aggFunc);u&&(a=u(i,s.field,s)),c=d.formatter}else{const u=Ft(d);u&&(a=u(i,s.field,s))}else if(n.cells&&Object.prototype.hasOwnProperty.call(n.cells,s.field)){const u=n.cells[s.field];typeof u=="function"?a=u(i,s.field,s):a=u}a!=null?l.textContent=c?c(a,s.field,s):String(a):l.textContent="",r.appendChild(l)}o.appendChild(r)}}function Tn(o,e){const t=document.createElement("div");t.className="tbw-status-panel tbw-status-panel-custom",t.id=`status-panel-${o.id}`;const i=o.render(e);return typeof i=="string"?t.innerHTML=i:t.appendChild(i),t}function Yt(o,e,t,i,n){return{totalRows:o.length,filteredRows:n?.cachedResult?.length??o.length,selectedRows:i?.selected?.size??0,columns:e,rows:o,grid:t}}const kn="@layer tbw-plugins{.tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:var(--tbw-spacing-xl, 1rem)}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, .125rem .5rem);min-height:var(--tbw-row-height, 1.75rem);display:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}}";class Pn extends L{name="pinnedRows";styles=kn;get defaultConfig(){return{position:"bottom",showRowCount:!0,showSelectedCount:!0,showFilteredCount:!0}}infoBarElement=null;topAggregationContainer=null;bottomAggregationContainer=null;footerWrapper=null;detach(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}afterRender(){const e=this.gridElement;if(!e)return;const t=e.querySelector(".tbw-scroll-area")??e.querySelector(".tbw-grid-content")??e.children[0];if(!t)return;this.footerWrapper&&!t.contains(this.footerWrapper)&&(this.footerWrapper=null,this.bottomAggregationContainer=null,this.infoBarElement=null),this.topAggregationContainer&&!t.contains(this.topAggregationContainer)&&(this.topAggregationContainer=null),this.infoBarElement&&!t.contains(this.infoBarElement)&&(this.infoBarElement=null);const i=this.getSelectionState(),n=this.getFilterState(),r=Yt(this.rows,this.columns,this.grid,i,n),s=this.config.aggregationRows||[],l=s.filter(h=>h.position==="top"),a=s.filter(h=>h.position!=="top");if(l.length>0){if(!this.topAggregationContainer){this.topAggregationContainer=Ut("top");const h=e.querySelector(".header");h&&h.nextSibling?t.insertBefore(this.topAggregationContainer,h.nextSibling):t.appendChild(this.topAggregationContainer)}jt(this.topAggregationContainer,l,this.visibleColumns,this.rows)}else this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null);const c=this.config.showRowCount!==!1||this.config.showSelectedCount&&r.selectedRows>0||this.config.showFilteredCount&&r.filteredRows!==r.totalRows||this.config.customPanels&&this.config.customPanels.length>0,d=c&&this.config.position!=="top",u=a.length>0||d;if(c&&this.config.position==="top")if(!this.infoBarElement)this.infoBarElement=qe(this.config,r),t.insertBefore(this.infoBarElement,t.firstChild);else{const h=qe(this.config,r);this.infoBarElement.replaceWith(h),this.infoBarElement=h}else this.config.position==="top"&&this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null);u?(this.footerWrapper||(this.footerWrapper=document.createElement("div"),this.footerWrapper.className="tbw-footer",t.appendChild(this.footerWrapper)),this.footerWrapper.innerHTML="",a.length>0&&(this.bottomAggregationContainer||(this.bottomAggregationContainer=Ut("bottom")),this.footerWrapper.appendChild(this.bottomAggregationContainer),jt(this.bottomAggregationContainer,a,this.visibleColumns,this.rows)),d&&(this.infoBarElement=qe(this.config,r),this.footerWrapper.appendChild(this.infoBarElement))):this.cleanupFooter()}cleanup(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}cleanupFooter(){this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.infoBarElement&&this.config.position!=="top"&&(this.infoBarElement.remove(),this.infoBarElement=null)}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}getFilterState(){try{return this.grid?.getPluginState?.("filtering")??null}catch{return null}}refresh(){this.requestRender()}getContext(){const e=this.getSelectionState(),t=this.getFilterState();return Yt(this.rows,this.columns,this.grid,e,t)}addPanel(e){this.config.customPanels||(this.config.customPanels=[]),this.config.customPanels.push(e),this.requestRender()}removePanel(e){this.config.customPanels&&(this.config.customPanels=this.config.customPanels.filter(t=>t.id!==e),this.requestRender())}addAggregationRow(e){this.config.aggregationRows||(this.config.aggregationRows=[]),this.config.aggregationRows.push(e),this.requestRender()}removeAggregationRow(e){this.config.aggregationRows&&(this.config.aggregationRows=this.config.aggregationRows.filter(t=>t.id!==e),this.requestRender())}}const Ln=sn;function Dn(o){const e=[];return!o.rowGroupFields?.length&&!o.columnGroupFields?.length&&e.push("At least one row or column group field is required"),o.valueFields?.length||e.push("At least one value field is required"),e}function Fe(o,e){return[...o,e].join("|")}function Hn(o,e){const t=e.rowGroupFields??[],i=e.columnGroupFields??[],n=e.valueFields??[],r=In(o,i),s=Xt(o,t,i,r,n,0,""),l=On(s,r,n),a=Object.values(l).reduce((c,d)=>c+d,0);return{rows:s,columnKeys:r,totals:l,grandTotal:a}}function In(o,e){if(e.length===0)return["value"];const t=new Set;for(const i of o){const n=e.map(r=>String(i[r]??"")).join("|");t.add(n)}return[...t].sort()}function Mn(o,e){const t=new Map;for(const i of o){const n=String(i[e]??""),r=t.get(n);r?r.push(i):t.set(n,[i])}return t}function Xt(o,e,t,i,n,r,s){const l=[];if(e.length===0){const h=Zt(o,t,i,n),f=Jt(h);return l.push({rowKey:s||"all",rowLabel:s||"All",depth:r,values:h,total:f,isGroup:!1,rowCount:o.length}),l}const a=e[0],c=e.slice(1),d=c.length>0,u=Mn(o,a);for(const[h,f]of u){const p=s?`${s}|${h}`:h,g=Zt(f,t,i,n),w=Jt(g);let m;d&&(m=Xt(f,c,t,i,n,r+1,p)),l.push({rowKey:p,rowLabel:h||"(blank)",depth:r,values:g,total:w,isGroup:d,children:m,rowCount:f.length})}return l}function Zt(o,e,t,i){const n={};for(const r of t)for(const s of i){const a=(e.length>0?o.filter(h=>e.map(f=>String(h[f]??"")).join("|")===r):o).map(h=>Number(h[s.field])||0),c=Ln(s.aggFunc),d=a.length>0?c(a):null,u=Fe([r],s.field);n[u]=d}return n}function Jt(o){let e=0;for(const t of Object.values(o))e+=t??0;return e}function On(o,e,t){const i={};function n(r){for(const s of r)if(!s.isGroup||!s.children?.length)for(const l of e)for(const a of t){const c=Fe([l],a.field);i[c]=(i[c]??0)+(s.values[c]??0)}else s.children&&n(s.children)}return n(o),i}function Nn(o,e,t=!0){const i=[];function n(r){i.push(r);const s=e?e.has(r.rowKey):t;if(r.children&&s)for(const l of r.children)n(l)}for(const r of o)n(r);return i}function zn(o){const e=[];function t(i){if(i.isGroup&&e.push(i.rowKey),i.children)for(const n of i.children)t(n)}for(const i of o)t(i);return e}const qn=["sum","avg","count","min","max","first","last"];function Fn(o,e,t,i){const n=new AbortController,r={config:e,callbacks:i,signal:n.signal},s=document.createElement("div");return s.className="tbw-pivot-panel",s.appendChild(ce("Options",()=>Vn(t,r))),s.appendChild(ce("Row Groups",()=>Qt("rowGroups",r))),s.appendChild(ce("Column Groups",()=>Qt("columnGroups",r))),s.appendChild(ce("Values",()=>Kn(r))),s.appendChild(ce("Available Fields",()=>Wn(r))),o.appendChild(s),()=>{n.abort(),s.remove()}}function ce(o,e){const t=document.createElement("div");t.className="tbw-pivot-section";const i=document.createElement("div");i.className="tbw-pivot-section-header",i.textContent=o;const n=document.createElement("div");return n.className="tbw-pivot-section-content",n.appendChild(e()),t.appendChild(i),t.appendChild(n),t}function Qt(o,e){const{config:t,callbacks:i,signal:n}=e,r=document.createElement("div");r.className="tbw-pivot-drop-zone",r.setAttribute("data-zone",o);const s=o==="rowGroups"?t.rowGroupFields??[]:t.columnGroupFields??[];if(s.length===0){const l=document.createElement("div");l.className="tbw-pivot-placeholder",l.textContent="Drag fields here or click to add",r.appendChild(l)}else for(const l of s)r.appendChild(Gn(l,o,e));return r.addEventListener("dragover",l=>{l.preventDefault(),r.classList.add("drag-over")},{signal:n}),r.addEventListener("dragleave",()=>{r.classList.remove("drag-over")},{signal:n}),r.addEventListener("drop",l=>{l.preventDefault(),r.classList.remove("drag-over");const a=l.dataTransfer?.getData("text/plain");a&&i.onAddFieldToZone(a,o)},{signal:n}),r}function Gn(o,e,t){const{callbacks:i,signal:n}=t,r=document.createElement("div");r.className="tbw-pivot-field-chip",r.draggable=!0;const s=i.getAvailableFields().find(c=>c.field===o),l=document.createElement("span");l.className="tbw-pivot-chip-label",l.textContent=s?.header??o;const a=document.createElement("button");return a.className="tbw-pivot-chip-remove",a.innerHTML="×",a.title="Remove field",a.addEventListener("click",c=>{c.stopPropagation(),i.onRemoveFieldFromZone(o,e)},{signal:n}),r.appendChild(l),r.appendChild(a),r.addEventListener("dragstart",c=>{c.dataTransfer?.setData("text/plain",o),c.dataTransfer?.setData("source-zone",e),r.classList.add("dragging")},{signal:n}),r.addEventListener("dragend",()=>{r.classList.remove("dragging")},{signal:n}),r}function Kn(o){const{config:e,callbacks:t,signal:i}=o,n=document.createElement("div");n.className="tbw-pivot-drop-zone tbw-pivot-values-zone",n.setAttribute("data-zone","values");const r=e.valueFields??[];if(r.length===0){const s=document.createElement("div");s.className="tbw-pivot-placeholder",s.textContent="Drag numeric fields here for aggregation",n.appendChild(s)}else for(const s of r)n.appendChild(Bn(s,o));return n.addEventListener("dragover",s=>{s.preventDefault(),n.classList.add("drag-over")},{signal:i}),n.addEventListener("dragleave",()=>{n.classList.remove("drag-over")},{signal:i}),n.addEventListener("drop",s=>{s.preventDefault(),n.classList.remove("drag-over");const l=s.dataTransfer?.getData("text/plain");l&&t.onAddValueField(l,"sum")},{signal:i}),n}function Bn(o,e){const{callbacks:t,signal:i}=e,n=document.createElement("div");n.className="tbw-pivot-field-chip tbw-pivot-value-chip";const r=t.getAvailableFields().find(d=>d.field===o.field),s=document.createElement("div");s.className="tbw-pivot-value-label-wrapper";const l=document.createElement("span");l.className="tbw-pivot-chip-label",l.textContent=r?.header??o.field;const a=document.createElement("select");a.className="tbw-pivot-agg-select",a.title="Aggregation function";for(const d of qn){const u=document.createElement("option");u.value=d,u.textContent=d.toUpperCase(),u.selected=d===o.aggFunc,a.appendChild(u)}a.addEventListener("change",()=>{t.onUpdateValueAggFunc(o.field,a.value)},{signal:i});const c=document.createElement("button");return c.className="tbw-pivot-chip-remove",c.innerHTML="×",c.title="Remove value field",c.addEventListener("click",d=>{d.stopPropagation(),t.onRemoveValueField(o.field)},{signal:i}),s.appendChild(l),s.appendChild(a),n.appendChild(s),n.appendChild(c),n}function Wn(o){const{config:e,callbacks:t,signal:i}=o,n=document.createElement("div");n.className="tbw-pivot-available-fields";const r=t.getAvailableFields(),s=new Set([...e.rowGroupFields??[],...e.columnGroupFields??[],...e.valueFields?.map(a=>a.field)??[]]),l=r.filter(a=>!s.has(a.field));if(l.length===0){const a=document.createElement("div");a.className="tbw-pivot-placeholder",a.textContent="All fields are in use",n.appendChild(a)}else for(const a of l){const c=document.createElement("div");c.className="tbw-pivot-field-chip available",c.textContent=a.header,c.draggable=!0,c.title=`Drag to add "${a.field}" to a zone`,c.addEventListener("dragstart",d=>{d.dataTransfer?.setData("text/plain",a.field),c.classList.add("dragging")},{signal:i}),c.addEventListener("dragend",()=>{c.classList.remove("dragging")},{signal:i}),n.appendChild(c)}return n}function Vn(o,e){const{config:t,callbacks:i,signal:n}=e,r=document.createElement("div");return r.className="tbw-pivot-options",r.appendChild(Ge("Enable Pivot View",o,s=>{i.onTogglePivot(s)},n)),r.appendChild(Ge("Show Row Totals",t.showTotals??!0,s=>{i.onOptionChange("showTotals",s)},n)),r.appendChild(Ge("Show Grand Total",t.showGrandTotal??!0,s=>{i.onOptionChange("showGrandTotal",s)},n)),r}function Ge(o,e,t,i){const n=document.createElement("label");n.className="tbw-pivot-checkbox";const r=document.createElement("input");r.type="checkbox",r.checked=e,r.addEventListener("change",()=>t(r.checked),{signal:i});const s=document.createElement("span");return s.textContent=o,n.appendChild(r),n.appendChild(s),n}function $n(o,e,t){return e.className="data-grid-row pivot-group-row",e.setAttribute("data-pivot-depth",String(o.__pivotDepth??0)),e.setAttribute("data-pivot-key",String(o.__pivotRowKey??"")),e.setAttribute("role","row"),e.innerHTML="",t.columns.forEach((i,n)=>{const r=document.createElement("div");if(r.className="cell",r.setAttribute("data-col",String(n)),r.setAttribute("data-row",String(t.rowIndex)),r.setAttribute("role","gridcell"),n===0){const s=Number(o.__pivotIndent)||0;r.style.paddingLeft=`${s}px`;const l=String(o.__pivotRowKey),a=document.createElement("button");a.type="button",a.className="pivot-toggle",a.setAttribute("aria-label",o.__pivotExpanded?"Collapse group":"Expand group"),t.setIcon(a,t.resolveIcon(o.__pivotExpanded?"collapse":"expand")),a.addEventListener("click",u=>{u.stopPropagation(),t.onToggle(l)}),r.appendChild(a);const c=document.createElement("span");c.className="pivot-label",c.textContent=String(o.__pivotLabel??""),r.appendChild(c);const d=document.createElement("span");d.className="pivot-count",d.textContent=` (${Number(o.__pivotRowCount)||0})`,r.appendChild(d)}else{const s=o[i.field];r.textContent=s!=null?String(s):""}e.appendChild(r)}),!0}function Un(o,e,t,i){return e.className="data-grid-row pivot-leaf-row",e.setAttribute("data-pivot-depth",String(o.__pivotDepth??0)),e.setAttribute("data-pivot-key",String(o.__pivotRowKey??"")),e.innerHTML="",t.forEach((n,r)=>{const s=document.createElement("div");if(s.className="cell",s.setAttribute("data-col",String(r)),s.setAttribute("data-row",String(i)),s.setAttribute("role","gridcell"),r===0){const l=Number(o.__pivotIndent)||0;s.style.paddingLeft=`${l+20}px`;const a=document.createElement("span");a.className="pivot-label",a.textContent=String(o.__pivotLabel??""),s.appendChild(a)}else{const l=o[n.field];s.textContent=l!=null?String(l):""}e.appendChild(s)}),!0}function jn(o,e,t){return e.className="pivot-grand-total-row",e.setAttribute("role","presentation"),e.innerHTML="",t.forEach((i,n)=>{const r=document.createElement("div");if(r.className="cell",r.setAttribute("data-col",String(n)),n===0){const s=document.createElement("span");s.className="pivot-label",s.textContent="Grand Total",r.appendChild(s)}else{const s=o[i.field];r.textContent=s!=null?String(s):""}e.appendChild(r)}),!0}const Yn='@layer tbw-plugins{.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-right:6px;border:none;background:transparent;cursor:pointer;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background .15s,color .15s}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));height:100%;overflow-y:auto;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));cursor:pointer}.tbw-pivot-toggle-label input{width:var(--tbw-icon-size, 1rem);height:var(--tbw-icon-size, 1rem);cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:var(--tbw-spacing-sm, .375rem);align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:var(--tbw-spacing-sm, .375rem);padding:var(--tbw-button-padding-sm, var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:var(--tbw-font-size-xs, .75rem);transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:var(--tbw-icon-size, 1rem);height:var(--tbw-icon-size, 1rem);padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:var(--tbw-font-size-sm, .875rem);font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:var(--tbw-button-padding-sm, var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-md, .5rem))}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));flex:1;min-width:0}.tbw-pivot-agg-select{padding:var(--tbw-spacing-xs, .125rem) var(--tbw-spacing-xs, .25rem);font-size:var(--tbw-font-size-xs, .6875rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:var(--tbw-spacing-sm, .375rem);min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-pivot-checkbox{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));cursor:pointer}.tbw-pivot-checkbox input{width:var(--tbw-icon-size-sm, .875rem);height:var(--tbw-icon-size-sm, .875rem);cursor:pointer}.pivot-group-row.tbw-pivot-slide-in,.pivot-leaf-row.tbw-pivot-slide-in{animation:tbw-pivot-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.pivot-group-row.tbw-pivot-fade-in,.pivot-leaf-row.tbw-pivot-fade-in{animation:tbw-pivot-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-fade-in{0%{opacity:0}to{opacity:1}}}';class $ extends L{name="pivot";styles=Yn;static PANEL_ID="pivot";get defaultConfig(){return{active:!0,showTotals:!0,showGrandTotal:!0,showToolPanel:!0,animation:"slide"}}isActive=!1;hasInitialized=!1;pivotResult=null;fieldHeaderMap=new Map;expandedKeys=new Set;defaultExpanded=!0;originalColumns=[];panelContainer=null;grandTotalFooter=null;previousVisibleKeys=new Set;keysToAnimate=new Set;hasValidPivotConfig(){return(this.config.valueFields?.length??0)>0}get animationStyle(){return this.isAnimationEnabled?this.config.animation??"slide":!1}detach(){this.isActive=!1,this.hasInitialized=!1,this.pivotResult=null,this.fieldHeaderMap.clear(),this.originalColumns=[],this.panelContainer=null,this.cleanupGrandTotalFooter(),this.previousVisibleKeys.clear(),this.keysToAnimate.clear()}getToolPanel(){if((this.config?.showToolPanel??this.userConfig?.showToolPanel??!0)!==!1)return{id:$.PANEL_ID,title:"Pivot",icon:"⊞",tooltip:"Configure pivot table",order:90,render:t=>this.renderPanel(t)}}processRows(e){if(!this.hasInitialized&&this.config.active!==!1&&this.hasValidPivotConfig()&&(this.hasInitialized=!0,this.isActive=!0),!this.isActive)return[...e];const t=Dn(this.config);if(t.length>0)return this.warn(`Config errors: ${t.join(", ")}`),[...e];this.buildFieldHeaderMap(),this.defaultExpanded=this.config.defaultExpanded??!0,this.expandedKeys.size===0&&this.defaultExpanded&&this.pivotResult&&this.expandAllKeys(),this.pivotResult=Hn(e,this.config),this.expandedKeys.size===0&&this.defaultExpanded&&this.expandAllKeys();const i=this.config.indentWidth??20,n=Nn(this.pivotResult.rows,this.expandedKeys,this.defaultExpanded).map(s=>({__pivotRowKey:s.rowKey,__pivotLabel:s.rowLabel,__pivotDepth:s.depth,__pivotIsGroup:s.isGroup,__pivotHasChildren:!!s.children?.length,__pivotExpanded:this.expandedKeys.has(s.rowKey),__pivotRowCount:s.rowCount??0,__pivotIndent:s.depth*i,__pivotTotal:s.total,...s.values}));this.keysToAnimate.clear();const r=new Set;for(const s of n){const l=s.__pivotRowKey;r.add(l),!this.previousVisibleKeys.has(l)&&s.__pivotDepth>0&&this.keysToAnimate.add(l)}return this.previousVisibleKeys=r,n}processColumns(e){if(!this.isActive||!this.pivotResult)return[...e];const t=[],i=(this.config.rowGroupFields??[]).map(n=>this.fieldHeaderMap.get(n)??n).join(" / ");t.push({field:"__pivotLabel",header:i||"Group",width:200});for(const n of this.pivotResult.columnKeys)for(const r of this.config.valueFields??[]){const s=Fe([n],r.field),l=r.header||this.fieldHeaderMap.get(r.field)||r.field;t.push({field:s,header:`${n} - ${l} (${r.aggFunc})`,width:120,type:"number"})}return this.config.showTotals&&t.push({field:"__pivotTotal",header:"Total",width:100,type:"number"}),t}renderRow(e,t,i){const n=e;return n.__pivotRowKey&&n.__pivotHasChildren?$n(n,t,{columns:this.gridColumns,rowIndex:i,onToggle:r=>this.toggle(r),resolveIcon:r=>this.resolveIcon(r),setIcon:(r,s)=>this.setIcon(r,s)}):n.__pivotRowKey!==void 0&&this.isActive?Un(n,t,this.gridColumns,i):(this.cleanupPivotStyling(t),!1)}cleanupPivotStyling(e){(e.classList.contains("pivot-group-row")||e.classList.contains("pivot-leaf-row")||e.classList.contains("pivot-grand-total-row"))&&(e.classList.remove("pivot-group-row","pivot-leaf-row","pivot-grand-total-row"),e.classList.add("data-grid-row"),e.removeAttribute("data-pivot-depth"),e.innerHTML="")}onKeyDown(e){if(e.key!==" "||!this.isActive)return;const t=this.grid._focusRow,i=this.rows[t];if(!(!i?.__pivotIsGroup||!i.__pivotHasChildren))return e.preventDefault(),this.toggle(i.__pivotRowKey),this.requestRenderWithFocus(),!0}afterRender(){this.isActive&&this.config.showGrandTotal&&this.pivotResult?this.renderGrandTotalFooter():this.cleanupGrandTotalFooter();const e=this.animationStyle;if(e===!1||this.keysToAnimate.size===0)return;const t=this.gridElement?.querySelector(".rows");if(!t)return;const i=e==="fade"?"tbw-pivot-fade-in":"tbw-pivot-slide-in";for(const n of t.querySelectorAll(".pivot-group-row, .pivot-leaf-row")){const r=n.dataset.pivotKey;r&&this.keysToAnimate.has(r)&&(n.classList.add(i),n.addEventListener("animationend",()=>n.classList.remove(i),{once:!0}))}this.keysToAnimate.clear()}renderGrandTotalFooter(){if(!this.pivotResult)return;const e=this.gridElement;if(!e)return;const t=e.querySelector(".tbw-scroll-area")??e.querySelector(".tbw-grid-content")??e.children[0];if(!t)return;this.grandTotalFooter||(this.grandTotalFooter=document.createElement("div"),this.grandTotalFooter.className="pivot-grand-total-footer",t.appendChild(this.grandTotalFooter));const i={__pivotRowKey:"__grandTotal",__pivotLabel:"Grand Total",__pivotIsGrandTotal:!0,__pivotTotal:this.pivotResult.grandTotal,...this.pivotResult.totals};jn(i,this.grandTotalFooter,this.gridColumns)}cleanupGrandTotalFooter(){this.grandTotalFooter&&(this.grandTotalFooter.remove(),this.grandTotalFooter=null)}toggle(e){this.expandedKeys.has(e)?this.expandedKeys.delete(e):this.expandedKeys.add(e),this.requestRender()}expand(e){this.expandedKeys.add(e),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}expandAll(){this.expandAllKeys(),this.requestRender()}collapseAll(){this.expandedKeys.clear(),this.requestRender()}expandAllKeys(){if(!this.pivotResult)return;const e=zn(this.pivotResult.rows);for(const t of e)this.expandedKeys.add(t)}isExpanded(e){return this.expandedKeys.has(e)}enablePivot(){this.originalColumns.length===0&&this.captureOriginalColumns(),this.isActive=!0,this.requestRender()}disablePivot(){this.isActive=!1,this.pivotResult=null,this.requestRender()}isPivotActive(){return this.isActive}getPivotResult(){return this.pivotResult}setRowGroupFields(e){this.config.rowGroupFields=e,this.requestRender()}setColumnGroupFields(e){this.config.columnGroupFields=e,this.requestRender()}setValueFields(e){this.config.valueFields=e,this.requestRender()}refresh(){this.pivotResult=null,this.requestRender()}showPanel(){this.grid.openToolPanel(),this.grid.expandedToolPanelSections.includes($.PANEL_ID)||this.grid.toggleToolPanelSection($.PANEL_ID)}hidePanel(){this.grid.closeToolPanel()}togglePanel(){this.grid.isToolPanelOpen||this.grid.openToolPanel(),this.grid.toggleToolPanelSection($.PANEL_ID)}isPanelVisible(){return this.grid.isToolPanelOpen&&this.grid.expandedToolPanelSections.includes($.PANEL_ID)}get gridColumns(){return this.grid.columns??[]}refreshIfActive(){this.isActive&&this.refresh(),this.refreshPanel()}buildFieldHeaderMap(){const e=this.getAvailableFields();this.fieldHeaderMap.clear();for(const t of e)this.fieldHeaderMap.set(t.field,t.header)}getAvailableFields(){return this.originalColumns.length>0?this.originalColumns:this.captureOriginalColumns()}captureOriginalColumns(){try{const e=this.grid.getAllColumns?.()??this.grid.columns??[];return this.originalColumns=e.filter(t=>!t.field.startsWith("__pivot")).map(t=>({field:t.field,header:t.header??t.field})),this.originalColumns}catch{return[]}}renderPanel(e){this.panelContainer=e,this.originalColumns.length===0&&this.captureOriginalColumns();const t={onTogglePivot:i=>{i?this.enablePivot():this.disablePivot(),this.refreshPanel()},onAddFieldToZone:(i,n)=>this.addFieldToZone(i,n),onRemoveFieldFromZone:(i,n)=>this.removeFieldFromZone(i,n),onAddValueField:(i,n)=>this.addValueField(i,n),onRemoveValueField:i=>this.removeValueField(i),onUpdateValueAggFunc:(i,n)=>this.updateValueAggFunc(i,n),onOptionChange:(i,n)=>{this.config[i]=n,this.isActive&&this.refresh()},getAvailableFields:()=>this.getAvailableFields()};return Fn(e,this.config,this.isActive,t)}refreshPanel(){this.panelContainer&&(this.panelContainer.innerHTML="",this.renderPanel(this.panelContainer))}addFieldToZone(e,t){if(t==="rowGroups"){const i=this.config.rowGroupFields??[];i.includes(e)||(this.config.rowGroupFields=[...i,e])}else{const i=this.config.columnGroupFields??[];i.includes(e)||(this.config.columnGroupFields=[...i,e])}this.removeFromOtherZones(e,t),this.refreshIfActive()}removeFieldFromZone(e,t){t==="rowGroups"?this.config.rowGroupFields=(this.config.rowGroupFields??[]).filter(i=>i!==e):this.config.columnGroupFields=(this.config.columnGroupFields??[]).filter(i=>i!==e),this.refreshIfActive()}removeFromOtherZones(e,t){t!=="rowGroups"&&(this.config.rowGroupFields=(this.config.rowGroupFields??[]).filter(i=>i!==e)),t!=="columnGroups"&&(this.config.columnGroupFields=(this.config.columnGroupFields??[]).filter(i=>i!==e)),t!=="values"&&(this.config.valueFields=(this.config.valueFields??[]).filter(i=>i.field!==e))}addValueField(e,t){const i=this.config.valueFields??[];i.some(n=>n.field===e)||(this.config.valueFields=[...i,{field:e,aggFunc:t}]),this.removeFromOtherZones(e,"values"),this.refreshIfActive()}removeValueField(e){this.config.valueFields=(this.config.valueFields??[]).filter(t=>t.field!==e),this.refreshIfActive()}updateValueAggFunc(e,t){const i=this.config.valueFields??[],n=i.findIndex(r=>r.field===e);n>=0&&(i[n]={...i[n],aggFunc:t},this.config.valueFields=[...i]),this.isActive&&this.refresh()}}function Xn(o){const e=o.meta??{};return e.lockPosition!==!0&&e.suppressMovable!==!0}function ei(o,e,t){if(e===t||e<0||e>=o.length||t<0||t>o.length)return o;const i=[...o],[n]=i.splice(e,1);return i.splice(t,0,n),i}const Zn='@layer tbw-plugins{.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}}';class Jn extends L{name="reorder";styles=Zn;get defaultConfig(){return{animation:"flip"}}get animationType(){return this.isAnimationEnabled?this.config.animation!==void 0?this.config.animation:"flip":!1}get animationDuration(){return this.config.animationDuration!==void 0?this.config.animationDuration:super.animationDuration}isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;canMoveColumnWithPlugins(e){return!e||!Xn(e)?!1:!this.grid.queryPlugins({type:Se.CAN_MOVE_COLUMN,context:e}).includes(!1)}clearDragClasses(){this.gridElement?.querySelectorAll(".header-row > .cell").forEach(e=>{e.classList.remove("dragging","drop-target","drop-before","drop-after")})}attach(e){super.attach(e),e.addEventListener("column-reorder-request",t=>{const i=t.detail;i?.field&&typeof i.toIndex=="number"&&this.moveColumn(i.field,i.toIndex)},{signal:this.disconnectSignal})}detach(){this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}afterRender(){const e=this.gridElement;if(!e)return;e.querySelectorAll(".header-row > .cell").forEach(i=>{const n=i,r=n.getAttribute("data-field");if(!r)return;const s=this.columns.find(l=>l.field===r);if(!this.canMoveColumnWithPlugins(s)){n.draggable=!1;return}n.draggable=!0,!n.getAttribute("data-dragstart-bound")&&(n.setAttribute("data-dragstart-bound","true"),n.addEventListener("dragstart",l=>{const c=this.getColumnOrder().indexOf(r);this.isDragging=!0,this.draggedField=r,this.draggedIndex=c,l.dataTransfer&&(l.dataTransfer.effectAllowed="move",l.dataTransfer.setData("text/plain",r)),n.classList.add("dragging")}),n.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.clearDragClasses()}),n.addEventListener("dragover",l=>{if(l.preventDefault(),!this.isDragging||this.draggedField===r)return;const a=n.getBoundingClientRect(),c=a.left+a.width/2,u=this.getColumnOrder().indexOf(r);this.dropIndex=l.clientX<c?u:u+1,n.classList.add("drop-target"),n.classList.toggle("drop-before",l.clientX<c),n.classList.toggle("drop-after",l.clientX>=c)}),n.addEventListener("dragleave",()=>{n.classList.remove("drop-target","drop-before","drop-after")}),n.addEventListener("drop",l=>{l.preventDefault();const a=this.draggedField,c=this.draggedIndex,d=this.dropIndex;if(!this.isDragging||a===null||c===null||d===null)return;const u=d>c?d-1:d,h=this.getColumnOrder(),f=ei(h,c,u),p={field:a,fromIndex:c,toIndex:u,columnOrder:f};this.emitCancelable("column-move",p)||this.updateColumnOrder(f)}))})}onKeyDown(e){if(!e.altKey||e.key!=="ArrowLeft"&&e.key!=="ArrowRight")return;const t=this.grid,i=t._focusCol,n=t._visibleColumns;if(i<0||i>=n.length)return;const r=n[i];if(!this.canMoveColumnWithPlugins(r))return;const s=this.getColumnOrder(),l=s.indexOf(r.field);if(l===-1)return;const a=e.key==="ArrowLeft"?l-1:l+1;if(a<0||a>=s.length)return;const c=n.find(d=>d.field===s[a]);if(this.canMoveColumnWithPlugins(c))return this.moveColumn(r.field,a),t._focusCol=a,N(this.grid),e.preventDefault(),e.stopPropagation(),!0}getColumnOrder(){return this.grid.getColumnOrder()}moveColumn(e,t){const i=this.getColumnOrder(),n=i.indexOf(e);if(n===-1)return;const r=ei(i,n,t);this.emitCancelable("column-move",{field:e,fromIndex:n,toIndex:t,columnOrder:r})||this.updateColumnOrder(r)}setColumnOrder(e){this.updateColumnOrder(e)}resetColumnOrder(){const e=this.columns.map(t=>t.field);this.updateColumnOrder(e)}captureHeaderPositions(){const e=new Map;return this.gridElement?.querySelectorAll(".header-row > .cell[data-field]").forEach(t=>{const i=t.getAttribute("data-field");i&&e.set(i,t.getBoundingClientRect().left)}),e}animateFLIP(e){const t=this.gridElement;if(!t||e.size===0)return;const i=new Map;if(t.querySelectorAll(".header-row > .cell[data-field]").forEach(s=>{const l=s.getAttribute("data-field");if(!l)return;const a=e.get(l);if(a===void 0)return;const c=a-s.getBoundingClientRect().left;Math.abs(c)>1&&i.set(l,c)}),i.size===0)return;const n=[];if(t.querySelectorAll(".cell[data-field]").forEach(s=>{const l=i.get(s.getAttribute("data-field")??"");if(l!==void 0){const a=s;a.style.transform=`translateX(${l}px)`,n.push(a)}}),n.length===0)return;this.gridElement.offsetHeight;const r=this.animationDuration;requestAnimationFrame(()=>{n.forEach(s=>{s.classList.add("flip-animating"),s.style.transform=""}),setTimeout(()=>{n.forEach(s=>{s.style.transform="",s.classList.remove("flip-animating")})},r+50)})}animateFade(e){const t=this.gridElement;if(!t){e();return}const i=this.captureHeaderPositions();e();const n=new Set;if(t.querySelectorAll(".header-row > .cell[data-field]").forEach(l=>{const a=l.getAttribute("data-field");if(!a)return;const c=i.get(a);if(c===void 0)return;const d=l.getBoundingClientRect().left;Math.abs(c-d)>1&&n.add(a)}),n.size===0)return;const r=[];if(t.querySelectorAll(".cell[data-field]").forEach(l=>{const a=l.getAttribute("data-field");if(a&&n.has(a)){const c=l;c.classList.add("fade-animating"),r.push(c)}}),r.length===0)return;const s=this.animationDuration;setTimeout(()=>{r.forEach(l=>l.classList.remove("fade-animating"))},s+50)}updateColumnOrder(e){const t=this.animationType;if(t==="flip"&&this.gridElement){const i=this.captureHeaderPositions();this.grid.setColumnOrder(e),requestAnimationFrame(()=>{this.gridElement.offsetHeight,this.animateFLIP(i)})}else t==="fade"?this.animateFade(()=>this.grid.setColumnOrder(e)):this.grid.setColumnOrder(e);this.grid.requestStateChange?.()}}const Qn='tbw-grid[data-responsive-animate] .data-grid-row,tbw-grid[data-responsive-animate] .data-grid-row>.cell{transition:opacity var(--tbw-responsive-duration, .2s) ease-out,transform var(--tbw-responsive-duration, .2s) ease-out}tbw-grid[data-responsive][data-responsive-animate] .data-grid-row{animation:responsive-card-enter var(--tbw-responsive-duration, .2s) ease-out}@keyframes responsive-card-enter{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}tbw-grid[data-responsive] .header{display:none!important}tbw-grid[data-responsive] .footer-row{display:none}tbw-grid[data-responsive] .tbw-scroll-area{overflow-x:hidden;min-width:0!important}tbw-grid[data-responsive] .rows-body-wrapper{min-width:0!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row){display:block!important;grid-template-columns:none!important;padding:var(--tbw-cell-padding);padding-left:var(--tbw-spacing-xl);border-bottom:1px solid var(--tbw-color-border);min-height:auto!important;height:auto!important;contain:none!important;content-visibility:visible!important;background:var(--tbw-color-bg);position:relative}tbw-grid[data-responsive] .data-grid-row:not(.group-row):nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid[data-responsive] .data-grid-row:not(.group-row):hover{background:var(--tbw-color-row-hover)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]{background:var(--tbw-color-selection)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]:before{content:"";position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--tbw-color-accent)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell{display:flex!important;justify-content:space-between;align-items:center;padding:var(--tbw-spacing-xs) var(--tbw-spacing-md);width:100%!important;min-width:0!important;min-height:auto!important;height:auto!important;line-height:1.5!important;position:static!important;left:auto!important;right:auto!important;border:none!important;border-bottom:none!important;border-right:none!important;background:transparent!important;white-space:normal!important;overflow:visible!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:before{content:attr(data-header) ": ";font-weight:600;color:var(--tbw-color-header-fg);flex-shrink:0;margin-right:var(--tbw-spacing-md);min-width:100px}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:after{content:none}tbw-grid[data-responsive] .cell[data-utility]{display:none!important}tbw-grid[data-responsive] .cell[data-responsive-hidden]{display:none!important}tbw-grid[data-responsive] .cell[data-responsive-value-only]{justify-content:flex-start!important;font-weight:500}tbw-grid[data-responsive] .cell[data-responsive-value-only]:before{display:none!important}tbw-grid:not([data-responsive]) .cell[data-responsive-hidden]{display:none!important}tbw-grid[data-responsive] .tbw-footer,tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows{display:none!important}tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows,tbw-grid[data-responsive] .tbw-aggregation-row{min-width:0!important}tbw-grid[data-responsive] .data-grid-row.responsive-card{display:block!important;padding:var(--tbw-cell-padding);border-bottom:1px solid var(--tbw-color-border)}tbw-grid[data-responsive] .data-grid-row.responsive-card>*{width:100%}tbw-grid[data-responsive] .data-grid-row.responsive-card .cell:before{display:none}';class er extends L{name="responsive";version="1.0.0";styles=Qn;static manifest={incompatibleWith:[{name:"groupingRows",reason:"Responsive card layout does not yet support row grouping. The variable row heights (cards vs group headers) cause scroll calculation issues."}]};#e;#o=!1;#d;#c=!1;#s=0;#i=new Set;#h=new Set;#u=null;#p=[];isResponsive(){return this.#o}setResponsive(e){e!==this.#o&&(this.#o=e,this.#b(),this.emit("responsive-change",{isResponsive:e,width:this.#s,breakpoint:this.config.breakpoint??0}))}setBreakpoint(e){this.config.breakpoint=e,this.#w(this.#s)}setCardRenderer(e){this.config.cardRenderer=e,this.#o&&this.requestRender()}getWidth(){return this.#s}getActiveBreakpoint(){return this.#u}attach(e){super.attach(e),this.#l(this.config.hiddenColumns),this.config.breakpoints?.length&&(this.#p=[...this.config.breakpoints].sort((t,i)=>i.maxWidth-t.maxWidth)),this.#e=new ResizeObserver(t=>{const i=t[0]?.contentRect.width??0;this.#s=i,clearTimeout(this.#d),this.#d=setTimeout(()=>{this.#w(i)},this.config.debounceMs??100)}),this.#e.observe(this.gridElement)}#l(e){if(this.#i.clear(),this.#h.clear(),!!e)for(const t of e)typeof t=="string"?this.#i.add(t):t.showValue?this.#h.add(t.field):this.#i.add(t.field)}detach(){this.#e?.disconnect(),this.#e=void 0,clearTimeout(this.#d),this.#d=void 0,this.gridElement&&this.gridElement.removeAttribute("data-responsive"),super.detach()}afterRender(){if(this.#_(),!(this.#p.length>0?this.#u!==null:this.#o))return;const t=this.#i.size>0,i=this.#h.size>0;if(!t&&!i)return;const n=this.gridElement.querySelectorAll(".cell[data-field]");for(const r of n){const s=r.getAttribute("data-field");s&&(this.#i.has(s)?(r.setAttribute("data-responsive-hidden",""),r.removeAttribute("data-responsive-value-only")):this.#h.has(s)?(r.setAttribute("data-responsive-value-only",""),r.removeAttribute("data-responsive-hidden")):(r.removeAttribute("data-responsive-hidden"),r.removeAttribute("data-responsive-value-only")))}}#w(e){if(this.#p.length>0){this.#m(e);return}const t=this.config.breakpoint??0;t===0&&!this.#c&&(this.#c=!0,console.warn("[tbw-grid:ResponsivePlugin] No breakpoint configured. Responsive mode is disabled. Set a breakpoint based on your grid's column count."));const i=t>0&&e<t;i!==this.#o&&(this.#o=i,this.#b(),this.emit("responsive-change",{isResponsive:i,width:e,breakpoint:t}),this.requestRender())}#m(e){let t=null;for(const n of this.#p)e<=n.maxWidth&&(t=n);if(t!==this.#u){this.#u=t,t?.hiddenColumns?this.#l(t.hiddenColumns):this.#l(this.config.hiddenColumns);const n=t?.cardLayout===!0;n!==this.#o&&(this.#o=n,this.#b()),this.emit("responsive-change",{isResponsive:this.#o,width:e,breakpoint:t?.maxWidth??0}),this.requestRender()}}#a;#b(){this.gridElement.toggleAttribute("data-responsive",this.#o);const e=this.config.animate!==!1;this.gridElement.toggleAttribute("data-responsive-animate",e),this.config.animationDuration&&this.gridElement.style.setProperty("--tbw-responsive-duration",`${this.config.animationDuration}ms`);const t=this.grid;if(this.#o){t._virtualization&&(this.#a=t._virtualization.rowHeight);const i=this.gridElement.querySelector(".tbw-scroll-area");i&&(i.scrollLeft=0)}else{const i=this.gridElement.querySelectorAll(".data-grid-row");for(const n of i)n.style.height="",n.classList.remove("responsive-card");this.#a&&this.#a>0&&t._virtualization&&(t._virtualization.rowHeight=this.#a,this.#a=void 0),this.#v=void 0,this.#g=void 0,this.#y=void 0}}renderRow(e,t,i){if(!this.#o||!this.config.cardRenderer||e.__isGroupRow)return;t.replaceChildren();const n=this.config.cardRenderer(e,i);t.className="data-grid-row responsive-card";const r=this.config.cardRowHeight??"auto";return r!=="auto"?t.style.height=`${r}px`:t.style.height="auto",t.appendChild(n),!0}onKeyDown(e){if(!this.#o||this.config.cardRenderer&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return!1;const t=this.rows.length-1,i=this.visibleColumns.length-1;switch(e.key){case"ArrowDown":if(this.grid._focusCol<i)return this.grid._focusCol+=1,e.preventDefault(),N(this.grid),!0;if(this.grid._focusRow<t)return this.grid._focusRow+=1,this.grid._focusCol=0,e.preventDefault(),N(this.grid),!0;break;case"ArrowUp":if(this.grid._focusCol>0)return this.grid._focusCol-=1,e.preventDefault(),N(this.grid),!0;if(this.grid._focusRow>0)return this.grid._focusRow-=1,this.grid._focusCol=i,e.preventDefault(),N(this.grid),!0;break;case"ArrowRight":if(this.grid._focusRow<t)return this.grid._focusRow+=1,e.preventDefault(),N(this.grid),!0;break;case"ArrowLeft":if(this.grid._focusRow>0)return this.grid._focusRow-=1,e.preventDefault(),N(this.grid),!0;break}return!1}#v;#g;#y;#x(){if(this.#v&&this.#v>0)return this.#v;const e=this.config.cardRowHeight;return typeof e=="number"&&e>0?e:80}#C(){return this.#g&&this.#g>0?this.#g:this.#a??28}#R(){for(const e of this.rows)if(e.__isGroupRow)return!0;return!1}#r(){let e=0,t=0;for(const i of this.rows)i.__isGroupRow?e++:t++;return{groupCount:e,cardCount:t}}getExtraHeight(){if(!this.#o||!this.config.cardRenderer||!this.#R())return 0;const e=this.#a??28,t=this.#C(),i=this.#x(),{groupCount:n,cardCount:r}=this.#r(),s=n*Math.max(0,t-e),l=r*Math.max(0,i-e);return s+l}getExtraHeightBefore(e){if(!this.#o||!this.config.cardRenderer||!this.#R())return 0;const t=this.#a??28,i=this.#C(),n=this.#x(),r=Math.max(0,i-t),s=Math.max(0,n-t);let l=0,a=0;const c=this.rows,d=Math.min(e,c.length);for(let u=0;u<d;u++)c[u].__isGroupRow?l++:a++;return l*r+a*s}#E(){let e=0;for(const t of this.rows)t.__isGroupRow||e++;return e}#S=!1;#_(){if(!this.#o||!this.config.cardRenderer)return;let e=!1;const t=this.grid,i=this.#R(),n=this.#E();if(n!==this.#y&&(this.#y=n,e=!0),i){const s=this.gridElement.querySelector(".data-grid-row.group-row");if(s){const l=s.getBoundingClientRect().height;l>0&&l!==this.#g&&(this.#g=l,e=!0)}}const r=this.gridElement.querySelector(".data-grid-row.responsive-card");if(r){const s=r.getBoundingClientRect().height;s>0&&s!==this.#v&&(this.#v=s,e=!0,!i&&t._virtualization&&(t._virtualization.rowHeight=s))}e&&!this.#S&&(this.#S=!0,queueMicrotask(()=>{this.#S=!1,this.grid&&this.#o&&this.grid.refreshVirtualWindow?.(!0,!0)}))}}const tr='.dg-row-drag-handle{display:flex;align-items:center;justify-content:center;cursor:grab;-webkit-user-select:none;user-select:none;color:var(--tbw-color-fg-muted, #999);transition:color .15s ease;font-size:14px;letter-spacing:-2px}.dg-row-drag-handle:hover{color:var(--tbw-color-fg, #333)}.dg-row-drag-handle:active{cursor:grabbing}.data-grid-row.dragging{opacity:.6}.data-grid-row.drop-target{position:relative}.data-grid-row.drop-target.drop-before:before{content:"";position:absolute;top:0;left:0;right:0;height:2px;background-color:var(--tbw-color-accent, #1976d2);z-index:10}.data-grid-row.drop-target.drop-after:after{content:"";position:absolute;bottom:0;left:0;right:0;height:2px;background-color:var(--tbw-color-accent, #1976d2);z-index:10}.data-grid-row.keyboard-moving{background-color:var(--tbw-color-bg-selected, #e3f2fd);box-shadow:0 0 0 1px var(--tbw-color-accent, #1976d2) inset}.data-grid-row.animate-flip{transition:transform var(--tbw-animation-duration, .2s) ease-out}',ti="__tbw_row_drag";class ir extends L{name="rowReorder";styles=tr;get defaultConfig(){return{enableKeyboard:!0,showDragHandle:!0,dragHandlePosition:"left",dragHandleWidth:40,debounceMs:150,animation:"flip"}}isDragging=!1;draggedRowIndex=null;dropRowIndex=null;pendingMove=null;debounceTimer=null;lastFocusCol=0;detach(){this.clearDebounceTimer(),this.isDragging=!1,this.draggedRowIndex=null,this.dropRowIndex=null,this.pendingMove=null}processColumns(e){if(!this.config.showDragHandle)return[...e];const t={field:ti,header:"",width:this.config.dragHandleWidth??40,resizable:!1,sortable:!1,filterable:!1,meta:{lockPosition:!0,suppressMovable:!0,utility:!0},viewRenderer:()=>{const i=document.createElement("div");return i.className="dg-row-drag-handle",i.setAttribute("aria-label","Drag to reorder"),i.setAttribute("role","button"),i.setAttribute("tabindex","-1"),i.draggable=!0,this.setIcon(i,this.resolveIcon("dragHandle")),i}};return this.config.dragHandlePosition==="right"?[...e,t]:[t,...e]}afterRender(){if(!this.config.showDragHandle)return;const e=this.gridElement;if(!e)return;e.querySelectorAll(".dg-row-drag-handle").forEach(n=>{const r=n;if(r.getAttribute("data-drag-bound"))return;r.setAttribute("data-drag-bound","true");const s=r.closest(".data-grid-row");s&&this.setupHandleDragListeners(r,s)}),e.querySelectorAll(".data-grid-row").forEach(n=>{const r=n;r.getAttribute("data-drop-bound")||(r.setAttribute("data-drop-bound","true"),this.setupRowDropListeners(r))})}onKeyDown(e){if(!this.config.enableKeyboard||!e.ctrlKey||e.key!=="ArrowUp"&&e.key!=="ArrowDown")return;const t=this.grid,i=t._focusRow,n=t._rows??this.sourceRows;if(i<0||i>=n.length)return;const r=e.key==="ArrowUp"?"up":"down",s=r==="up"?i-1:i+1;if(s<0||s>=n.length)return;const l=n[i];if(!(this.config.canMove&&!this.config.canMove(l,i,s,r)))return this.handleKeyboardMove(l,i,s,r,t._focusCol),e.preventDefault(),e.stopPropagation(),!0}onCellClick(){this.flushPendingMove()}moveRow(e,t){const i=[...this.sourceRows];if(e<0||e>=i.length||t<0||t>=i.length||e===t)return;const n=t<e?"up":"down",r=i[e];this.config.canMove&&!this.config.canMove(r,e,t,n)||this.executeMove(r,e,t,"keyboard")}canMoveRow(e,t){const i=this.sourceRows;if(e<0||e>=i.length||t<0||t>=i.length||e===t)return!1;if(!this.config.canMove)return!0;const n=t<e?"up":"down";return this.config.canMove(i[e],e,t,n)}setupHandleDragListeners(e,t){e.addEventListener("dragstart",i=>{const n=this.getRowIndex(t);n<0||(this.isDragging=!0,this.draggedRowIndex=n,i.dataTransfer&&(i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",String(n))),t.classList.add("dragging"))}),e.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedRowIndex=null,this.dropRowIndex=null,this.clearDragClasses()})}setupRowDropListeners(e){e.addEventListener("dragover",t=>{if(t.preventDefault(),!this.isDragging||this.draggedRowIndex===null)return;const i=this.getRowIndex(e);if(i<0||i===this.draggedRowIndex)return;const n=e.getBoundingClientRect(),r=n.top+n.height/2,s=t.clientY<r;this.dropRowIndex=s?i:i+1,e.classList.add("drop-target"),e.classList.toggle("drop-before",s),e.classList.toggle("drop-after",!s)}),e.addEventListener("dragleave",()=>{e.classList.remove("drop-target","drop-before","drop-after")}),e.addEventListener("drop",t=>{t.preventDefault();const i=this.draggedRowIndex;let n=this.dropRowIndex;if(!(!this.isDragging||i===null||n===null)&&(n>i&&n--,i!==n)){const s=this.sourceRows[i],l=n<i?"up":"down";(!this.config.canMove||this.config.canMove(s,i,n,l))&&this.executeMove(s,i,n,"drag")}})}handleKeyboardMove(e,t,i,n,r){this.pendingMove?this.pendingMove.currentIndex=i:this.pendingMove={originalIndex:t,currentIndex:i,row:e},this.lastFocusCol=r;const s=this.grid,l=[...s._rows??this.sourceRows],[a]=l.splice(t,1);l.splice(i,0,a),s._rows=l,s._focusRow=i,s._focusCol=r,s.refreshVirtualWindow(!0),N(s),this.clearDebounceTimer(),this.debounceTimer=setTimeout(()=>{this.flushPendingMove()},this.config.debounceMs??300)}flushPendingMove(){if(this.clearDebounceTimer(),!this.pendingMove)return;const{originalIndex:e,currentIndex:t,row:i}=this.pendingMove;if(this.pendingMove=null,e===t)return;const n={row:i,fromIndex:e,toIndex:t,rows:[...this.sourceRows],source:"keyboard"};if(this.emitCancelable("row-move",n)){const s=[...this.sourceRows],[l]=s.splice(t,1);s.splice(e,0,l);const a=this.grid;a._rows=s,a._focusRow=e,a._focusCol=this.lastFocusCol,a.refreshVirtualWindow(!0),N(a)}}executeMove(e,t,i,n){const r=[...this.sourceRows],[s]=r.splice(t,1);r.splice(i,0,s);const l={row:e,fromIndex:t,toIndex:i,rows:r,source:n};this.emitCancelable("row-move",l)||(this.grid.rows=r)}getRowIndex(e){const t=e.querySelector(".cell[data-row]");return t?parseInt(t.getAttribute("data-row")??"-1",10):-1}clearDragClasses(){this.gridElement?.querySelectorAll(".data-grid-row").forEach(e=>{e.classList.remove("dragging","drop-target","drop-before","drop-after")})}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}}function ge(o){return{startRow:Math.min(o.startRow,o.endRow),startCol:Math.min(o.startCol,o.endCol),endRow:Math.max(o.startRow,o.endRow),endCol:Math.max(o.startCol,o.endCol)}}function or(o){const e=ge(o);return{from:{row:e.startRow,col:e.startCol},to:{row:e.endRow,col:e.endCol}}}function ii(o){return o.map(or)}function nr(o,e,t){const i=ge(t);return o>=i.startRow&&o<=i.endRow&&e>=i.startCol&&e<=i.endCol}function oi(o,e,t){return t.some(i=>nr(o,e,i))}function rr(o){const e=[],t=ge(o);for(let i=t.startRow;i<=t.endRow;i++)for(let n=t.startCol;n<=t.endCol;n++)e.push({row:i,col:n});return e}function sr(o){const e=new Map;for(const t of o)for(const i of rr(t))e.set(`${i.row},${i.col}`,i);return[...e.values()]}function Ke(o,e){return{startRow:o.row,startCol:o.col,endRow:e.row,endCol:e.col}}const lr="@layer tbw-plugins{tbw-grid.selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid[data-has-focus] .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}tbw-grid[data-selection-mode=row] .cell-focus{outline:none}tbw-grid .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}tbw-grid .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}tbw-grid .tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}}";function ar(o,e,t){if(o==="cell"&&e.selectedCell)return{mode:o,ranges:[{from:{row:e.selectedCell.row,col:e.selectedCell.col},to:{row:e.selectedCell.row,col:e.selectedCell.col}}]};if(o==="row"&&e.selected.size>0){const i=[...e.selected].map(n=>({from:{row:n,col:0},to:{row:n,col:t-1}}));return{mode:o,ranges:i}}return o==="range"&&e.ranges.length>0?{mode:o,ranges:ii(e.ranges)}:{mode:o,ranges:[]}}class cr extends L{static manifest={configRules:[{id:"selection/range-dblclick",severity:"warn",message:`"triggerOn: 'dblclick'" has no effect when mode is "range".
|
|
77
|
+
</Workbook>`,i}function on(o,e){const t=e.endsWith(".xls")?e:`${e}.xls`,i=new Blob([o],{type:"application/vnd.ms-excel;charset=utf-8;"});ze(i,t)}class nn extends D{name="export";get defaultConfig(){return{fileName:"export",includeHeaders:!0,onlyVisible:!0,onlySelected:!1}}isExportingFlag=!1;lastExportInfo=null;performExport(e,t){const i=this.config,n={format:e,fileName:t?.fileName??i.fileName??"export",includeHeaders:t?.includeHeaders??i.includeHeaders,processCell:t?.processCell,processHeader:t?.processHeader,columns:t?.columns,rowIndices:t?.rowIndices};let r=[...this.columns];if(i.onlyVisible&&(r=r.filter(a=>!a.hidden&&!a.field.startsWith("__"))),t?.columns){const a=new Set(t.columns);r=r.filter(c=>a.has(c.field))}let s=[...this.rows];if(i.onlySelected){const a=this.getSelectionState();a?.selected?.size&&(s=[...a.selected].sort((d,u)=>d-u).map(d=>this.rows[d]).filter(Boolean))}t?.rowIndices&&(s=t.rowIndices.map(a=>this.rows[a]).filter(Boolean)),this.isExportingFlag=!0;let l=n.fileName;try{switch(e){case"csv":{const a=Qo(s,r,n,{bom:!0});l=l.endsWith(".csv")?l:`${l}.csv`,en(a,l);break}case"excel":{const a=tn(s,r,n);l=l.endsWith(".xls")?l:`${l}.xls`,on(a,l);break}case"json":{const a=s.map(u=>{const h={};for(const f of r){let p=u[f.field];n.processCell&&(p=n.processCell(p,f.field,u)),h[f.field]=p}return h}),c=JSON.stringify(a,null,2);l=l.endsWith(".json")?l:`${l}.json`;const d=new Blob([c],{type:"application/json"});ze(d,l);break}}this.lastExportInfo={format:e,timestamp:new Date},this.emit("export-complete",{format:e,fileName:l,rowCount:s.length,columnCount:r.length})}finally{this.isExportingFlag=!1}}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}exportCsv(e){this.performExport("csv",e)}exportExcel(e){this.performExport("excel",e)}exportJson(e){this.performExport("json",e)}isExporting(){return this.isExportingFlag}getLastExport(){return this.lastExportInfo}}function rn(o){const{totalRows:e,viewportHeight:t,scrollTop:i,rowHeight:n,overscan:r}=o,s=Math.ceil(t/n);let l=Math.floor(i/n)-r;l<0&&(l=0);let a=l+s+r*2;return a>e&&(a=e),a===e&&l>0&&(l=Math.max(0,a-s-r*2)),{start:l,end:a,offsetY:l*n,totalHeight:e*n}}function sn(o,e){return o<=e}function ln(o,e,t=!1){const i=o[e.field];if(e.operator==="blank")return i==null||i==="";if(e.operator==="notBlank")return i!=null&&i!=="";if(i==null)return!1;const n=String(i),r=t?n:n.toLowerCase(),s=t?String(e.value):String(e.value).toLowerCase();switch(e.operator){case"contains":return r.includes(s);case"notContains":return!r.includes(s);case"equals":return r===s;case"notEquals":return r!==s;case"startsWith":return r.startsWith(s);case"endsWith":return r.endsWith(s);case"lessThan":return Number(i)<Number(e.value);case"lessThanOrEqual":return Number(i)<=Number(e.value);case"greaterThan":return Number(i)>Number(e.value);case"greaterThanOrEqual":return Number(i)>=Number(e.value);case"between":return Number(i)>=Number(e.value)&&Number(i)<=Number(e.valueTo);case"in":return Array.isArray(e.value)&&e.value.includes(i);case"notIn":return Array.isArray(e.value)&&!e.value.includes(i);default:return!0}}function an(o,e,t=!1){return e.length?o.filter(i=>e.every(n=>ln(i,n,t))):o}function cn(o){return JSON.stringify(o.map(e=>({field:e.field,operator:e.operator,value:e.value,valueTo:e.valueTo})))}function Kt(o,e){const t=new Set;for(const i of o){const n=i[e];n!=null&&t.add(n)}return[...t].sort((i,n)=>typeof i=="number"&&typeof n=="number"?i-n:String(i).localeCompare(String(n)))}const dn='@layer tbw-plugins{tbw-grid .tbw-quick-filter-input{flex:1;max-width:300px;height:var(--tbw-input-height, 1.75rem);padding:var(--tbw-input-padding, 0 .5rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:var(--tbw-font-size-sm, .8125rem)}tbw-grid .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}tbw-grid .header-cell.filtered:before{content:"";position:absolute;top:var(--tbw-spacing-xs, .25rem);right:var(--tbw-spacing-xs, .25rem);width:var(--tbw-indicator-size, .375rem);height:var(--tbw-indicator-size, .375rem);background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}tbw-grid .tbw-filter-btn{display:var(--tbw-filter-btn-display, inline-flex);visibility:var(--tbw-filter-btn-visibility, visible);align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:var(--tbw-spacing-xs, .25rem);opacity:.4;transition:opacity .15s,visibility 0s;color:inherit;vertical-align:middle}tbw-grid .tbw-filter-btn:hover,tbw-grid .tbw-filter-btn.active{opacity:1;visibility:visible}tbw-grid .tbw-filter-btn.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}}',un="@layer tbw-plugins{.tbw-filter-panel{position:fixed;background:var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));color:var(--tbw-filter-panel-fg, var(--tbw-color-fg, light-dark(#222222, #eeeeee)));border:1px solid var(--tbw-filter-panel-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-panel-radius, var(--tbw-border-radius, .25rem));box-shadow:0 4px 16px var(--tbw-filter-panel-shadow, var(--tbw-color-shadow, light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3))));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));z-index:10000;min-width:200px;max-width:280px;max-height:350px;display:flex;flex-direction:column;font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-font-size, .8125rem);transform-origin:top center}.tbw-filter-panel.tbw-filter-panel-above{transform-origin:bottom center}.tbw-filter-panel.tbw-filter-panel-animated{animation:tbw-filter-panel-enter var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}.tbw-filter-panel.tbw-filter-panel-above.tbw-filter-panel-animated{animation:tbw-filter-panel-enter-above var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}@keyframes tbw-filter-panel-enter{0%{opacity:0;transform:scaleY(.3) translateY(-10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@keyframes tbw-filter-panel-enter-above{0%{opacity:0;transform:scaleY(.3) translateY(10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@supports (anchor-name: --test){.tbw-filter-panel{position-anchor:--tbw-filter-anchor;top:anchor(bottom);left:anchor(left);margin-top:4px;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}.tbw-filter-search{margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-search-input{width:100%;padding:var(--tbw-filter-search-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-search-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-actions{display:flex;padding:var(--tbw-button-padding-sm, .25rem .125rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-bottom:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-action-btn{background:transparent;border:none;color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));cursor:pointer;font-size:var(--tbw-font-size-xs, .75rem);padding:2px 0}.tbw-filter-action-btn:hover{text-decoration:underline}.tbw-filter-values{flex:1;overflow-y:auto;margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));max-height:180px;position:relative}.tbw-filter-values-spacer{width:1px}.tbw-filter-values-content{position:absolute;top:0;left:0;right:0}.tbw-filter-value-item{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding-sm, .25rem .125rem);cursor:pointer;border-radius:3px;min-height:var(--tbw-filter-item-height, 28px)}.tbw-filter-value-item:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-checkbox{margin:0;cursor:pointer;accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}.tbw-filter-no-match{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem)) 0;text-align:center;font-style:italic}.tbw-filter-buttons{display:flex;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding-top:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-top:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-apply-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));color:var(--tbw-filter-accent-fg, var(--tbw-color-accent-fg, light-dark(#ffffff, #000000)));border:none;border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:transparent;color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}}";class B extends D{name="filtering";styles=dn;get defaultConfig(){return{debounceMs:300,caseSensitive:!1,trimInput:!0,useWorker:!0}}filters=new Map;cachedResult=null;cacheKey=null;openPanelField=null;panelElement=null;panelAnchorElement=null;searchText=new Map;excludedValues=new Map;panelAbortController=null;globalStylesInjected=!1;static DEFAULT_LIST_ITEM_HEIGHT=28;static LIST_OVERSCAN=3;static LIST_BYPASS_THRESHOLD=50;getListItemHeight(){if(this.panelElement){const e=getComputedStyle(this.panelElement).getPropertyValue("--tbw-filter-item-height");if(e&&e.trim()){const t=parseFloat(e);if(!isNaN(t)&&t>0)return t}}return B.DEFAULT_LIST_ITEM_HEIGHT}syncExcludedValues(e,t){t?t.type==="set"&&t.operator==="notIn"&&Array.isArray(t.value)?this.excludedValues.set(e,new Set(t.value)):t.type==="set"&&this.excludedValues.delete(e):this.excludedValues.delete(e)}attach(e){super.attach(e),this.injectGlobalStyles()}detach(){this.filters.clear(),this.cachedResult=null,this.cacheKey=null,this.openPanelField=null,this.panelElement&&(this.panelElement.remove(),this.panelElement=null),this.searchText.clear(),this.excludedValues.clear(),this.panelAbortController?.abort(),this.panelAbortController=null}processRows(e){const t=[...this.filters.values()];if(!t.length)return[...e];if(this.config.filterHandler)return this.cachedResult?this.cachedResult:[...e];const i=cn(t);if(this.cacheKey===i&&this.cachedResult)return this.cachedResult;const n=an([...e],t,this.config.caseSensitive);return this.cachedResult=n,this.cacheKey=i,n}afterRender(){const e=this.gridElement;if(!e)return;e.querySelectorAll('[part~="header-cell"]').forEach(i=>{const n=i.getAttribute("data-col");if(n===null)return;const r=this.visibleColumns[parseInt(n,10)];if(!r||r.filterable===!1||W(r))return;const s=r.field;if(!s)return;const l=this.filters.has(s);let a=i.querySelector(".tbw-filter-btn");if(a){const u=a.classList.contains("active");if(a.classList.toggle("active",l),i.classList.toggle("filtered",l),u!==l){const h=l?"filterActive":"filter";this.setIcon(a,this.resolveIcon(h))}return}a=document.createElement("button"),a.className="tbw-filter-btn",a.setAttribute("aria-label",`Filter ${r.header??s}`);const c=l?"filterActive":"filter";this.setIcon(a,this.resolveIcon(c)),l&&(a.classList.add("active"),i.classList.add("filtered")),a.addEventListener("click",u=>{u.stopPropagation(),this.toggleFilterPanel(s,r,a)});const d=i.querySelector(".resize-handle");d?i.insertBefore(a,d):i.appendChild(a)})}setFilter(e,t){if(t===null)this.filters.delete(e),this.syncExcludedValues(e,null);else{const i={...t,field:e};this.filters.set(e,i),this.syncExcludedValues(e,i)}this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}getFilter(e){return this.filters.get(e)}getFilters(){return[...this.filters.values()]}getFilterModel(){return this.getFilters()}setFilterModel(e){this.filters.clear(),this.excludedValues.clear();for(const t of e)this.filters.set(t.field,t),this.syncExcludedValues(t.field,t);this.cachedResult=null,this.cacheKey=null,this.emit("filter-change",{filters:[...this.filters.values()],filteredRowCount:0}),this.requestRender()}clearAllFilters(){this.filters.clear(),this.excludedValues.clear(),this.searchText.clear(),this.applyFiltersInternal()}clearFieldFilter(e){this.filters.delete(e),this.excludedValues.delete(e),this.searchText.delete(e),this.applyFiltersInternal()}isFieldFiltered(e){return this.filters.has(e)}getFilteredRowCount(){return this.cachedResult?.length??this.rows.length}getActiveFilters(){return this.getFilters()}getUniqueValues(e){return Kt(this.sourceRows,e)}copyGridThemeContext(e){const t=this.gridElement;if(!t)return;for(const n of t.classList)n.startsWith("tbw-")||n==="selecting"||e.classList.add(n);const i=t.dataset.theme;i&&(e.dataset.theme=i)}injectGlobalStyles(){if(this.globalStylesInjected)return;if(document.getElementById("tbw-filter-panel-styles")){this.globalStylesInjected=!0;return}const e=document.createElement("style");e.id="tbw-filter-panel-styles",e.textContent=un,document.head.appendChild(e),this.globalStylesInjected=!0}toggleFilterPanel(e,t,i){if(this.openPanelField===e){this.closeFilterPanel();return}this.closeFilterPanel();const n=document.createElement("div");if(n.className="tbw-filter-panel",this.copyGridThemeContext(n),this.isAnimationEnabled&&n.classList.add("tbw-filter-panel-animated"),this.panelElement=n,this.openPanelField=e,this.config.valuesHandler){n.innerHTML='<div class="tbw-filter-loading">Loading...</div>',document.body.appendChild(n),this.positionPanel(n,i),this.setupPanelCloseHandler(n,i),this.config.valuesHandler(e,t).then(s=>{this.openPanelField!==e||!this.panelElement||(n.innerHTML="",this.renderPanelContent(e,t,n,s))});return}const r=Kt(this.sourceRows,e);this.renderPanelContent(e,t,n,r),document.body.appendChild(n),this.positionPanel(n,i),this.setupPanelCloseHandler(n,i)}renderPanelContent(e,t,i,n){let r=this.excludedValues.get(e);r||(r=new Set,this.excludedValues.set(e,r));const s=this.searchText.get(e)??"",l={field:e,column:t,uniqueValues:n,excludedValues:r,searchText:s,applySetFilter:c=>{this.applySetFilter(e,c),this.closeFilterPanel()},applyTextFilter:(c,d,u)=>{this.applyTextFilter(e,c,d,u),this.closeFilterPanel()},clearFilter:()=>{this.clearFieldFilter(e),this.closeFilterPanel()},closePanel:()=>this.closeFilterPanel()};let a=!1;this.config.filterPanelRenderer&&(this.config.filterPanelRenderer(i,l),a=i.children.length>0),a||this.renderDefaultFilterPanel(i,l,n,r)}setupPanelCloseHandler(e,t){this.panelAbortController=new AbortController,setTimeout(()=>{document.addEventListener("click",i=>{!e.contains(i.target)&&i.target!==t&&this.closeFilterPanel()},{signal:this.panelAbortController?.signal})},0)}closeFilterPanel(){const e=this.panelElement;e&&(e.remove(),this.panelElement=null),this.panelAnchorElement&&(this.panelAnchorElement.style.anchorName="",this.panelAnchorElement=null),this.openPanelField=null,this.panelAbortController?.abort(),this.panelAbortController=null}static supportsAnchorPositioning=null;static checkAnchorPositioningSupport(){return B.supportsAnchorPositioning===null&&(B.supportsAnchorPositioning=CSS.supports("anchor-name","--test")),B.supportsAnchorPositioning}positionPanel(e,t){const n=t.closest(".cell")??t;if(n.style.anchorName="--tbw-filter-anchor",this.panelAnchorElement=n,B.checkAnchorPositioningSupport()){requestAnimationFrame(()=>{const s=e.getBoundingClientRect(),l=n.getBoundingClientRect();s.top<l.top&&e.classList.add("tbw-filter-panel-above")});return}const r=n.getBoundingClientRect();e.style.position="fixed",e.style.top=`${r.bottom+4}px`,e.style.left=`${r.left}px`,requestAnimationFrame(()=>{const s=e.getBoundingClientRect();s.right>window.innerWidth-8&&(e.style.left=`${r.right-s.width}px`),s.bottom>window.innerHeight-8&&(e.style.top=`${r.top-s.height-4}px`,e.classList.add("tbw-filter-panel-above"))})}renderDefaultFilterPanel(e,t,i,n){const{field:r}=t,s=this.getListItemHeight(),l=document.createElement("div");l.className="tbw-filter-search";const a=document.createElement("input");a.type="text",a.placeholder="Search...",a.className="tbw-filter-search-input",a.value=this.searchText.get(r)??"",l.appendChild(a),e.appendChild(l);const c=document.createElement("div");c.className="tbw-filter-actions";const d=document.createElement("label");d.className="tbw-filter-value-item",d.style.padding="0",d.style.margin="0";const u=document.createElement("input");u.type="checkbox",u.className="tbw-filter-checkbox";const h=document.createElement("span");h.textContent="Select All",d.appendChild(u),d.appendChild(h),c.appendChild(d);const f=()=>{const S=[...m.values()],x=S.every(L=>L),P=S.every(L=>!L);u.checked=x,u.indeterminate=!x&&!P};u.addEventListener("change",()=>{const S=u.checked;for(const x of m.keys())m.set(x,S);f(),R()}),e.appendChild(c);const p=document.createElement("div");p.className="tbw-filter-values";const g=document.createElement("div");g.className="tbw-filter-values-spacer",p.appendChild(g);const w=document.createElement("div");w.className="tbw-filter-values-content",p.appendChild(w);const m=new Map;i.forEach(S=>{const x=S==null?"__null__":String(S);m.set(x,!n.has(S))}),f();let v=[];const b=(S,x)=>{const P=S==null?"(Blank)":String(S),L=S==null?"__null__":String(S),T=document.createElement("label");T.className="tbw-filter-value-item",T.style.position="absolute",T.style.top=`${x*s}px`,T.style.left="0",T.style.right="0",T.style.height=`${s}px`,T.style.boxSizing="border-box";const F=document.createElement("input");F.type="checkbox",F.className="tbw-filter-checkbox",F.checked=m.get(L)??!0,F.dataset.value=L,F.addEventListener("change",()=>{m.set(L,F.checked),f()});const wi=document.createElement("span");return wi.textContent=P,T.appendChild(F),T.appendChild(wi),T},R=()=>{const S=v.length,x=p.clientHeight,P=p.scrollTop;if(g.style.height=`${S*s}px`,sn(S,B.LIST_BYPASS_THRESHOLD/3)){w.innerHTML="",w.style.transform="translateY(0px)",v.forEach((T,F)=>{w.appendChild(b(T,F))});return}const L=rn({totalRows:S,viewportHeight:x,scrollTop:P,rowHeight:s,overscan:B.LIST_OVERSCAN});w.style.transform=`translateY(${L.offsetY}px)`,w.innerHTML="";for(let T=L.start;T<L.end;T++)w.appendChild(b(v[T],T-L.start))},C=S=>{const x=this.config.caseSensitive??!1,P=x?S:S.toLowerCase();if(v=i.filter(L=>{const T=L==null?"(Blank)":String(L),F=x?T:T.toLowerCase();return!S||F.includes(P)}),v.length===0){g.style.height="0px",w.innerHTML="";const L=document.createElement("div");L.className="tbw-filter-no-match",L.textContent="No matching values",w.appendChild(L);return}R()};p.addEventListener("scroll",()=>{v.length>0&&R()},{passive:!0}),C(a.value),e.appendChild(p);let k;a.addEventListener("input",()=>{clearTimeout(k),k=setTimeout(()=>{this.searchText.set(r,a.value),C(a.value)},this.config.debounceMs??150)});const A=document.createElement("div");A.className="tbw-filter-buttons";const E=document.createElement("button");E.className="tbw-filter-apply-btn",E.textContent="Apply",E.addEventListener("click",()=>{const S=[];for(const[x,P]of m)if(!P)if(x==="__null__")S.push(null);else{const L=i.find(T=>String(T)===x);S.push(L!==void 0?L:x)}t.applySetFilter(S)}),A.appendChild(E);const _=document.createElement("button");_.className="tbw-filter-clear-btn",_.textContent="Clear Filter",_.addEventListener("click",()=>{t.clearFilter()}),A.appendChild(_),e.appendChild(A)}applySetFilter(e,t){this.excludedValues.set(e,new Set(t)),t.length===0?this.filters.delete(e):this.filters.set(e,{field:e,type:"set",operator:"notIn",value:t}),this.applyFiltersInternal()}applyTextFilter(e,t,i,n){this.filters.set(e,{field:e,type:"text",operator:t,value:i,valueTo:n}),this.applyFiltersInternal()}applyFiltersInternal(){this.cachedResult=null,this.cacheKey=null;const e=[...this.filters.values()];if(this.config.filterHandler){const t=this.grid;t.setAttribute("aria-busy","true");const i=this.config.filterHandler(e,this.sourceRows),n=r=>{t.removeAttribute("aria-busy"),this.cachedResult=r,this.grid.rows=r,this.emit("filter-change",{filters:e,filteredRowCount:r.length}),this.requestRender()};i&&typeof i.then=="function"?i.then(n):n(i);return}this.emit("filter-change",{filters:e,filteredRowCount:0}),this.requestRender()}getColumnState(e){const t=this.filters.get(e);if(t)return{filter:{type:t.type,operator:t.operator,value:t.value,valueTo:t.valueTo}}}applyColumnState(e,t){if(!t.filter){this.filters.delete(e);return}const i={field:e,type:t.filter.type,operator:t.filter.operator,value:t.filter.value,valueTo:t.filter.valueTo};this.filters.set(e,i),this.cachedResult=null,this.cacheKey=null}}function Bt(o){if(!o.length)return[];const e=new Map,t=[],i=(s,l)=>{if(!l.length)return;const a=t[t.length-1];if(a&&a.implicit&&a.firstIndex+a.columns.length===s){a.columns.push(...l);return}t.push({id:"__implicit__"+s,label:void 0,columns:l,firstIndex:s,implicit:!0})};let n=[],r=0;return o.forEach((s,l)=>{const a=s.group;if(!a){n.length===0&&(r=l),n.push(s);return}n.length&&(i(r,n.slice()),n=[]);const c=typeof a=="string"?a:a.id;let d=e.get(c);d||(d={id:c,label:typeof a=="string"?void 0:a.label,columns:[],firstIndex:l},e.set(c,d),t.push(d)),d.columns.push(s)}),n.length&&i(r,n),t.length===1&&t[0].implicit&&t[0].columns.length===o.length?[]:t}function hn(o,e,t){if(!e.length||!o)return;const i=new Map;for(const r of e)for(const s of r.columns)s.field&&i.set(s.field,r.id);const n=Array.from(o.querySelectorAll(".cell[data-field]"));n.forEach(r=>{const s=r.getAttribute("data-field")||"",l=i.get(s);l&&(r.classList.add("grouped"),r.getAttribute("data-group")||r.setAttribute("data-group",l))});for(const r of e){const s=r.columns[r.columns.length-1],l=n.find(a=>a.getAttribute("data-field")===s.field);l&&l.classList.add("group-end")}}function fn(o,e){if(o.length===0)return null;const t=document.createElement("div");t.className="header-group-row",t.setAttribute("role","row");for(const i of o){const n=i.columns[0],r=n?e.findIndex(c=>c.field===n.field):-1;if(r===-1)continue;const s=String(i.id).startsWith("__implicit__"),l=s?"":i.label||i.id,a=document.createElement("div");a.className="cell header-group-cell",s&&a.classList.add("implicit-group"),a.setAttribute("data-group",String(i.id)),a.style.gridColumn=`${r+1} / span ${i.columns.length}`,a.textContent=l,t.appendChild(a)}return t}function gn(o){return o.some(e=>e.group!=null)}const pn="@layer tbw-plugins{.header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:var(--tbw-button-padding-sm, .25rem .5rem);font-weight:600;font-size:var(--tbw-font-size-sm, .9em);text-transform:uppercase;letter-spacing:.5px;border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.header-group-cell:last-child{border-right:none}.header-row .cell.grouped{border-top:none}.header-row .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.header-row .cell.group-end:last-child{border-right:none}.rows .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.rows .cell.group-end:last-child{border-right:none}.header-group-row.no-borders{border-bottom:none}.header-group-row.no-borders .header-group-cell{border-right:none}.header-row.no-group-borders .cell.group-end{border-right:1px solid var(--tbw-color-border)}}";class wn extends D{static manifest={ownedProperties:[{property:"group",level:"column",description:'the "group" column property'},{property:"columnGroups",level:"config",description:'the "columnGroups" config property',isUsed:e=>Array.isArray(e)&&e.length>0}]};name="groupingColumns";styles=pn;get defaultConfig(){return{showGroupBorders:!0}}groups=[];isActive=!1;detach(){this.groups=[],this.isActive=!1}static detect(e,t){if(t?.columnGroups&&Array.isArray(t.columnGroups)&&t.columnGroups.length>0)return!0;const i=t?.columns;return Array.isArray(i)?gn(i):!1}processColumns(e){const t=this.grid?.gridConfig?.columnGroups;let i;if(t&&Array.isArray(t)&&t.length>0){const r=new Map;for(const s of t)for(const l of s.children)r.set(l,{id:s.id,label:s.header});i=e.map(s=>{const l=r.get(s.field);return l&&!s.group?{...s,group:l}:s})}else i=[...e];const n=Bt(i);return n.length===0?(this.isActive=!1,this.groups=[],i):(this.isActive=!0,this.groups=n,i)}afterRender(){if(!this.isActive){const a=this.gridElement?.querySelector(".header")?.querySelector(".header-group-row");a&&a.remove();return}const e=this.gridElement?.querySelector(".header");if(!e)return;const t=e.querySelector(".header-group-row");t&&t.remove();const i=this.columns,n=Bt(i);if(n.length===0)return;const r=fn(n,i);if(r){r.classList.toggle("no-borders",!this.config.showGroupBorders);const l=e.querySelector(".header-row");l?e.insertBefore(r,l):e.appendChild(r)}const s=e.querySelector(".header-row");s&&(s.classList.toggle("no-group-borders",!this.config.showGroupBorders),hn(s,n)),this.#e(n)}#e(e){if(!this.config.showGroupBorders)return;const t=this.gridElement;if(!t)return;const i=new Set;for(const r of e){const s=r.columns[r.columns.length-1];s?.field&&i.add(s.field)}const n=t.querySelectorAll(".rows .cell[data-field]");for(const r of n){const s=r.getAttribute("data-field");s&&i.has(s)?r.classList.add("group-end"):r.classList.remove("group-end")}}isGroupingActive(){return this.isActive}getGroups(){return this.groups}getGroupColumns(e){const t=this.groups.find(i=>i.id===e);return t?t.columns:[]}refresh(){this.requestRender()}}const qe={sum:(o,e)=>o.reduce((t,i)=>t+(Number(i[e])||0),0),avg:(o,e)=>{const t=o.reduce((i,n)=>i+(Number(n[e])||0),0);return o.length?t/o.length:0},count:o=>o.length,min:(o,e)=>Math.min(...o.map(t=>Number(t[e])||1/0)),max:(o,e)=>Math.max(...o.map(t=>Number(t[e])||-1/0)),first:(o,e)=>o[0]?.[e],last:(o,e)=>o[o.length-1]?.[e]},ce=new Map,K={register(o,e){ce.set(o,e)},unregister(o){ce.delete(o)},get(o){if(o!==void 0)return typeof o=="function"?o:ce.get(o)??qe[o]},run(o,e,t,i){const n=this.get(o);return n?n(e,t,i):void 0},has(o){return ce.has(o)||o in qe},list(){return[...Object.keys(qe),...ce.keys()]}},Wt={sum:o=>o.reduce((e,t)=>e+t,0),avg:o=>o.length?o.reduce((e,t)=>e+t,0)/o.length:0,count:o=>o.length,min:o=>o.length?Math.min(...o):0,max:o=>o.length?Math.max(...o):0,first:o=>o[0]??0,last:o=>o[o.length-1]??0};function mn(o){return Wt[o]??Wt.sum}K.register.bind(K),K.unregister.bind(K);const Vt=K.get.bind(K),$t=K.run.bind(K);K.list.bind(K);function bn({rows:o,config:e,expanded:t}){const i=e.groupOn;if(typeof i!="function")return[];const n={key:"__root__",value:null,depth:-1,rows:[],children:new Map};if(o.forEach(l=>{let a=i(l);a==null||a===!1?a=["__ungrouped__"]:Array.isArray(a)||(a=[a]);let c=n;a.forEach((d,u)=>{const h=d==null?"∅":String(d),f=c.key==="__root__"?h:c.key+"||"+h;let p=c.children.get(h);p||(p={key:f,value:d,depth:u,rows:[],children:new Map,parent:c},c.children.set(h,p)),c=p}),c.rows.push(l)}),n.children.size===1&&n.children.has("__ungrouped__")&&n.children.get("__ungrouped__").rows.length===o.length)return[];const r=[],s=l=>{if(l===n){l.children.forEach(c=>s(c));return}const a=t.has(l.key);r.push({kind:"group",key:l.key,value:l.value,depth:l.depth,rows:l.rows,expanded:a}),a&&(l.children.size?l.children.forEach(c=>s(c)):l.rows.forEach(c=>r.push({kind:"data",row:c,rowIndex:o.indexOf(c)})))};return s(n),r}function vn(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function yn(o){const e=new Set;for(const t of o)t.kind==="group"&&e.add(t.key);return e}function Cn(){return new Set}function xn(o){return o.kind!=="group"?0:o.rows.length}const Rn="@layer tbw-plugins{.group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-grouping-rows-bg, var(--tbw-color-panel-bg));font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}.group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, .125rem .5rem)}.group-row:hover{background:var(--tbw-grouping-rows-bg-hover, var(--tbw-color-row-hover))}.group-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toggle-size, 1.25rem);height:var(--tbw-toggle-size, 1.25rem);margin-right:.25rem;background:none;border:0;font:inherit}.group-toggle:hover{background:var(--tbw-grouping-rows-toggle-hover, var(--tbw-color-row-hover));border-radius:var(--tbw-border-radius, .125rem)}.group-label{display:inline-flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.group-count{color:var(--tbw-grouping-rows-count-color, var(--tbw-color-fg-muted));font-size:var(--tbw-font-size-xs, .85em);font-weight:400}.group-row{padding-left:calc(var(--tbw-group-depth, 0) * var(--tbw-group-indent-width, 1.25em))}.data-grid-row.tbw-group-slide-in{animation:tbw-group-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-group-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.data-grid-row.tbw-group-fade-in{animation:tbw-group-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-group-fade-in{0%{opacity:0}to{opacity:1}}}";class En extends D{name="groupingRows";styles=Rn;get defaultConfig(){return{defaultExpanded:!1,showRowCount:!0,indentWidth:20,aggregators:{},animation:"slide"}}expandedKeys=new Set;flattenedRows=[];isActive=!1;previousVisibleKeys=new Set;keysToAnimate=new Set;get animationStyle(){return this.isAnimationEnabled?this.config.animation??"slide":!1}detach(){this.expandedKeys.clear(),this.flattenedRows=[],this.isActive=!1,this.previousVisibleKeys.clear(),this.keysToAnimate.clear()}static detect(e,t){return typeof t?.groupOn=="function"||typeof t?.enableRowGrouping=="boolean"}processRows(e){const t=this.config;if(typeof t.groupOn!="function")return this.isActive=!1,this.flattenedRows=[],[...e];const i=bn({rows:[...e],config:t,expanded:this.expandedKeys});if(i.length===0)return this.isActive=!1,this.flattenedRows=[],[...e];this.isActive=!0,this.flattenedRows=i,this.keysToAnimate.clear();const n=new Set;return i.forEach((r,s)=>{if(r.kind==="data"){const l=`data-${s}`;n.add(l),this.previousVisibleKeys.has(l)||this.keysToAnimate.add(l)}}),this.previousVisibleKeys=n,i.map(r=>r.kind==="group"?{__isGroupRow:!0,__groupKey:r.key,__groupValue:r.value,__groupDepth:r.depth,__groupRows:r.rows,__groupExpanded:r.expanded,__groupRowCount:xn(r)}:r.row)}onCellClick(e){const t=e.row;if(t?.__isGroupRow&&e.originalEvent.target?.closest(".group-toggle"))return this.toggle(t.__groupKey),!0}onKeyDown(e){if(e.key!==" ")return;const t=this.grid._focusRow,i=this.rows[t];if(i?.__isGroupRow)return e.preventDefault(),this.toggle(i.__groupKey),this.requestRenderWithFocus(),!0}renderRow(e,t,i){if(!e?.__isGroupRow)return!1;const n=this.config;if(n.groupRowRenderer){const l=()=>{this.toggle(e.__groupKey)},a=n.groupRowRenderer({key:e.__groupKey,value:e.__groupValue,depth:e.__groupDepth,rows:e.__groupRows,expanded:e.__groupExpanded,toggleExpand:l});if(a)return t.className="data-grid-row group-row",t.__isCustomRow=!0,t.setAttribute("data-group-depth",String(e.__groupDepth)),typeof a=="string"?t.innerHTML=a:(t.innerHTML="",t.appendChild(a)),!0}const r=()=>{this.toggle(e.__groupKey)};return t.className="data-grid-row group-row",t.__isCustomRow=!0,t.setAttribute("data-group-depth",String(e.__groupDepth)),t.setAttribute("role","row"),t.setAttribute("aria-expanded",String(e.__groupExpanded)),t.style.setProperty("--tbw-group-depth",String(e.__groupDepth||0)),n.indentWidth!==void 0&&t.style.setProperty("--tbw-group-indent-width",`${n.indentWidth}px`),t.style.height="",t.innerHTML="",n.fullWidth!==!1?this.renderFullWidthGroupRow(e,t,r):this.renderPerColumnGroupRow(e,t,r),!0}afterRender(){const e=this.animationStyle;if(e===!1||this.keysToAnimate.size===0)return;const t=this.gridElement?.querySelector(".rows");if(!t)return;const i=e==="fade"?"tbw-group-fade-in":"tbw-group-slide-in";for(const n of t.querySelectorAll(".data-grid-row:not(.group-row)")){const r=n.querySelector(".cell[data-row]"),s=r?parseInt(r.getAttribute("data-row")??"-1",10):-1,a=this.flattenedRows[s]?.kind==="data"?`data-${s}`:void 0;a&&this.keysToAnimate.has(a)&&(n.classList.add(i),n.addEventListener("animationend",()=>n.classList.remove(i),{once:!0}))}this.keysToAnimate.clear()}createToggleButton(e,t){const i=document.createElement("button");return i.type="button",i.className=`group-toggle${e?" expanded":""}`,i.setAttribute("aria-label",e?"Collapse group":"Expand group"),this.setIcon(i,this.resolveIcon(e?"collapse":"expand")),i.addEventListener("click",n=>{n.stopPropagation(),t()}),i}getGroupLabelText(e,t,i){const n=this.config;return n.formatLabel?n.formatLabel(e,t,i):String(e)}renderFullWidthGroupRow(e,t,i){const n=this.config,r=document.createElement("div");r.className="cell group-full",r.style.gridColumn="1 / -1",r.setAttribute("role","gridcell"),r.setAttribute("data-col","0"),r.appendChild(this.createToggleButton(e.__groupExpanded,i));const s=document.createElement("span");if(s.className="group-label",s.textContent=this.getGroupLabelText(e.__groupValue,e.__groupDepth||0,e.__groupKey),r.appendChild(s),n.showRowCount!==!1){const l=document.createElement("span");l.className="group-count",l.textContent=`(${e.__groupRowCount??e.__groupRows?.length??0})`,r.appendChild(l)}t.appendChild(r)}renderPerColumnGroupRow(e,t,i){const n=this.config,r=n.aggregators??{},s=this.columns,l=e.__groupRows??[],c=this.gridElement?.querySelector(".body")?.style.gridTemplateColumns||"";c&&(t.style.display="grid",t.style.gridTemplateColumns=c);let d=!1;s.forEach((u,h)=>{const f=document.createElement("div");if(f.className="cell group-cell",f.setAttribute("data-col",String(h)),f.setAttribute("role","gridcell"),Te(u)){f.setAttribute("data-field",u.field),t.appendChild(f);return}if(d){const p=r[u.field];if(p){const g=$t(p,l,u.field,u);f.textContent=g!=null?String(g):""}else f.textContent=""}else{d=!0,f.appendChild(this.createToggleButton(e.__groupExpanded,i));const p=document.createElement("span"),g=r[u.field];if(g){const w=$t(g,l,u.field,u);p.textContent=w!=null?String(w):String(e.__groupValue)}else p.textContent=this.getGroupLabelText(e.__groupValue,e.__groupDepth||0,e.__groupKey);if(f.appendChild(p),n.showRowCount!==!1){const w=document.createElement("span");w.className="group-count",w.textContent=` (${l.length})`,f.appendChild(w)}}t.appendChild(f)})}expandAll(){this.expandedKeys=yn(this.flattenedRows),this.requestRender()}collapseAll(){this.expandedKeys=Cn(),this.requestRender()}toggle(e){this.expandedKeys=vn(this.expandedKeys,e);const t=this.flattenedRows.find(i=>i.kind==="group"&&i.key===e);this.emit("group-toggle",{key:e,expanded:this.expandedKeys.has(e),value:t?.value,depth:t?.depth??0}),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}expand(e){this.expandedKeys.has(e)||(this.expandedKeys=new Set([...this.expandedKeys,e]),this.requestRender())}collapse(e){if(this.expandedKeys.has(e)){const t=new Set(this.expandedKeys);t.delete(e),this.expandedKeys=t,this.requestRender()}}getGroupState(){const e=this.flattenedRows.filter(t=>t.kind==="group");return{isActive:this.isActive,expandedCount:this.expandedKeys.size,totalGroups:e.length,expandedKeys:[...this.expandedKeys]}}getRowCount(){return this.flattenedRows.length}refreshGroups(){this.requestRender()}getExpandedGroups(){return[...this.expandedKeys]}getFlattenedRows(){return this.flattenedRows}isGroupingActive(){return this.isActive}setGroupOn(e){this.config.groupOn=e,this.requestRender()}}function Ut(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function Sn(o,e){const t=new Set(o);return t.add(e),t}function _n(o,e){const t=new Set(o);return t.delete(e),t}function An(o,e){return o.has(e)}function kn(o,e,t,i){const n=document.createElement("div");n.className="master-detail-row",n.setAttribute("data-detail-for",String(e)),n.setAttribute("role","row");const r=document.createElement("div");r.className="master-detail-cell",r.setAttribute("role","cell"),r.style.gridColumn=`1 / ${i+1}`;const s=t(o,e);return typeof s=="string"?r.innerHTML=s:s instanceof HTMLElement&&r.appendChild(s),n.appendChild(r),n}const Tn="@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:center}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}tbw-grid .master-detail-expander{display:flex;align-items:center;justify-content:center;width:100%;height:100%}tbw-grid .master-detail-toggle{cursor:pointer;opacity:.7;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center}tbw-grid .master-detail-toggle:hover{opacity:1}tbw-grid .master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border));overflow:hidden}tbw-grid .master-detail-cell{padding:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem));overflow:auto}tbw-grid .master-detail-row.tbw-expanding{animation:tbw-detail-expand var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}tbw-grid .master-detail-row.tbw-collapsing{animation:tbw-detail-collapse var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-detail-expand{0%{opacity:0;max-height:0;padding-top:0;padding-bottom:0}to{opacity:1;max-height:var(--tbw-detail-max-height, 31.25rem);padding-top:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem));padding-bottom:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem))}}@keyframes tbw-detail-collapse{0%{opacity:1;max-height:var(--tbw-detail-max-height, 31.25rem)}to{opacity:0;max-height:0}}}";class Fe extends D{name="masterDetail";styles=Tn;get defaultConfig(){return{detailHeight:"auto",expandOnRowClick:!1,collapseOnClickOutside:!1,animation:"slide"}}attach(e){super.attach(e),this.parseLightDomDetail()}parseLightDomDetail(){const e=this.grid;if(!e||typeof e.querySelector!="function")return;const t=e.querySelector("tbw-grid-detail");if(!t)return;const i=e;if(i.__frameworkAdapter?.parseDetailElement){const u=i.__frameworkAdapter.parseDetailElement(t);if(u){this.config={...this.config,detailRenderer:u};return}}const n=t.getAttribute("animation"),r=t.getAttribute("show-expand-column"),s=t.getAttribute("expand-on-row-click"),l=t.getAttribute("collapse-on-click-outside"),a=t.getAttribute("height"),c={};n!==null&&(c.animation=n==="false"?!1:n),r!==null&&(c.showExpandColumn=r!=="false"),s!==null&&(c.expandOnRowClick=s==="true"),l!==null&&(c.collapseOnClickOutside=l==="true"),a!==null&&(c.detailHeight=a==="auto"?"auto":parseInt(a,10));const d=t.innerHTML.trim();d&&!this.config.detailRenderer&&(c.detailRenderer=(u,h)=>{const f=me(d,{value:u,row:u});return oe(f)}),Object.keys(c).length>0&&(this.config={...this.config,...c})}get animationStyle(){return this.isAnimationEnabled?this.config.animation??"slide":!1}animateExpand(e){!this.isAnimationEnabled||this.animationStyle===!1||(e.classList.add("tbw-expanding"),e.addEventListener("animationend",()=>{e.classList.remove("tbw-expanding")},{once:!0}))}animateCollapse(e,t){if(!this.isAnimationEnabled||this.animationStyle===!1){t();return}e.classList.add("tbw-collapsing");const i=()=>{e.classList.remove("tbw-collapsing"),t()};e.addEventListener("animationend",i,{once:!0}),setTimeout(i,this.animationDuration+50)}expandedRows=new Set;detailElements=new Map;static DEFAULT_DETAIL_HEIGHT=150;getDetailHeight(e){const t=this.detailElements.get(e);return t?t.offsetHeight:typeof this.config?.detailHeight=="number"?this.config.detailHeight:Fe.DEFAULT_DETAIL_HEIGHT}toggleAndEmit(e,t){this.expandedRows=Ut(this.expandedRows,e),this.emit("detail-expand",{rowIndex:t,row:e,expanded:this.expandedRows.has(e)}),this.requestRender()}detach(){this.expandedRows.clear(),this.detailElements.clear()}processColumns(e){if(!(this.config.showExpandColumn===!0||this.config.showExpandColumn!==!1&&!!this.config.detailRenderer))return[...e];const i=[...e];if(Lo(i))return i;const r=Do(this.name);return r.viewRenderer=s=>{const{row:l}=s,a=this.expandedRows.has(l),c=document.createElement("span");c.className="master-detail-expander expander-cell";const d=document.createElement("span");return d.className=`master-detail-toggle${a?" expanded":""}`,this.setIcon(d,this.resolveIcon(a?"collapse":"expand")),d.setAttribute("role","button"),d.setAttribute("tabindex","0"),d.setAttribute("aria-expanded",String(a)),d.setAttribute("aria-label",a?"Collapse details":"Expand details"),c.appendChild(d),c},[r,...i]}onRowClick(e){if(!(!this.config.expandOnRowClick||!this.config.detailRenderer))return this.toggleAndEmit(e.row,e.rowIndex),!1}onCellClick(e){if(e.originalEvent?.target?.classList.contains("master-detail-toggle"))return this.toggleAndEmit(e.row,e.rowIndex),!0;this.expandedRows.size>0&&queueMicrotask(()=>this.#e())}onKeyDown(e){if(e.key!==" ")return;const t=this.grid._focusCol,i=this.grid._focusRow,n=this.columns[t];if(!n||!Te(n))return;const r=this.rows[i];if(r)return e.preventDefault(),this.toggleAndEmit(r,i),this.requestRenderWithFocus(),!0}afterRender(){this.#e()}onScrollRender(){!this.config.detailRenderer||this.expandedRows.size===0||this.#e()}#e(){if(!this.config.detailRenderer)return;const e=this.gridElement?.querySelector(".rows");if(!e)return;const t=new Map,i=e.querySelectorAll(".data-grid-row"),n=this.columns.length;for(const s of i){const l=s.querySelector(".cell[data-row]"),a=l?parseInt(l.getAttribute("data-row")??"-1",10):-1;a>=0&&t.set(a,s)}const r=e.querySelectorAll(".master-detail-row");for(const s of r){const l=parseInt(s.getAttribute("data-detail-for")??"-1",10),a=l>=0?this.rows[l]:void 0,c=a&&this.expandedRows.has(a),d=t.has(l);(!c||!d)&&(s.remove(),a&&this.detailElements.delete(a))}for(const[s,l]of t){const a=this.rows[s];if(!a||!this.expandedRows.has(a))continue;const c=this.detailElements.get(a);if(c){c.previousElementSibling!==l&&l.after(c);continue}const d=kn(a,s,this.config.detailRenderer,n);typeof this.config.detailHeight=="number"&&(d.style.height=`${this.config.detailHeight}px`),l.after(d),this.detailElements.set(a,d),this.animateExpand(d)}}getExtraHeight(){let e=0;for(const t of this.expandedRows)e+=this.getDetailHeight(t);return e}getExtraHeightBefore(e){let t=0;for(const i of this.expandedRows){const n=this.rows.indexOf(i);n>=0&&n<e&&(t+=this.getDetailHeight(i))}return t}adjustVirtualStart(e,t,i){if(this.expandedRows.size===0)return e;const n=[];for(const l of this.expandedRows){const a=this.rows.indexOf(l);a>=0&&n.push({index:a,row:l})}n.sort((l,a)=>l.index-a.index);let r=e,s=0;for(const{index:l,row:a}of n){const c=l*i+s,d=this.getDetailHeight(a),u=c+i+d;s+=d,!(l>=e)&&u>t&&l<r&&(r=l)}return r}expand(e){const t=this.rows[e];t&&(this.expandedRows=Sn(this.expandedRows,t),this.requestRender())}collapse(e){const t=this.rows[e];t&&(this.expandedRows=_n(this.expandedRows,t),this.requestRender())}toggle(e){const t=this.rows[e];t&&(this.expandedRows=Ut(this.expandedRows,t),this.requestRender())}isExpanded(e){const t=this.rows[e];return t?An(this.expandedRows,t):!1}expandAll(){for(const e of this.rows)this.expandedRows.add(e);this.requestRender()}collapseAll(){this.expandedRows.clear(),this.requestRender()}getExpandedRows(){const e=[];for(const t of this.expandedRows){const i=this.rows.indexOf(t);i>=0&&e.push(i)}return e}getDetailElement(e){const t=this.rows[e];return t?this.detailElements.get(t):void 0}refreshDetailRenderer(){const e=this.config.detailRenderer;if(this.config={...this.config,detailRenderer:void 0},this.parseLightDomDetail(),!this.config.detailRenderer&&e&&(this.config={...this.config,detailRenderer:e}),this.config.detailRenderer){const t=this.grid;typeof t.refreshColumns=="function"?t.refreshColumns():this.requestRender()}}}function Pn(o,e,t){return e.length?[...o].sort((i,n)=>{for(const r of e){const l=t.find(u=>u.field===r.field)?.sortComparator??Ln,a=i[r.field],c=n[r.field],d=l(a,c,i,n);if(d!==0)return r.direction==="asc"?d:-d}return 0}):[...o]}function Ln(o,e){return o==null&&e==null?0:o==null?1:e==null?-1:typeof o=="number"&&typeof e=="number"?o-e:o instanceof Date&&e instanceof Date?o.getTime()-e.getTime():typeof o=="boolean"&&typeof e=="boolean"?o===e?0:o?-1:1:String(o).localeCompare(String(e))}function Dn(o,e,t,i){const n=o.find(r=>r.field===e);return t?n?n.direction==="asc"?o.map(r=>r.field===e?{...r,direction:"desc"}:r):o.filter(r=>r.field!==e):o.length<i?[...o,{field:e,direction:"asc"}]:o:n?.direction==="asc"?[{field:e,direction:"desc"}]:n?.direction==="desc"?[]:[{field:e,direction:"asc"}]}function jt(o,e){const t=o.findIndex(i=>i.field===e);return t>=0?t+1:void 0}function Yt(o,e){return o.find(t=>t.field===e)?.direction}const Hn='@layer tbw-plugins{.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-indicator{margin-left:4px;opacity:.8}.sort-index{font-size:10px;background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}}';class In extends D{name="multiSort";styles=Hn;get defaultConfig(){return{maxSortColumns:3,showSortIndex:!0}}sortModel=[];detach(){this.sortModel=[]}processRows(e){return this.sortModel.length===0?[...e]:Pn([...e],this.sortModel,[...this.columns])}onHeaderClick(e){if(!this.columns.find(r=>r.field===e.field)?.sortable)return!1;const i=e.originalEvent.shiftKey,n=this.config.maxSortColumns??3;return this.sortModel=Dn(this.sortModel,e.field,i,n),this.emit("sort-change",{sortModel:[...this.sortModel]}),this.requestRender(),!0}afterRender(){const e=this.gridElement;if(!e)return;const t=this.config.showSortIndex!==!1;e.querySelectorAll(".header-row .cell[data-field]").forEach(n=>{const r=n.getAttribute("data-field");if(!r)return;const s=jt(this.sortModel,r),l=Yt(this.sortModel,r);if(n.querySelector(".sort-index")?.remove(),l){n.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(),n.setAttribute("data-sort",l);const d=document.createElement("span");d.className="sort-indicator",this.setIcon(d,this.resolveIcon(l==="asc"?"sortAsc":"sortDesc"));const u=n.querySelector(".tbw-filter-btn"),h=n.querySelector(".resize-handle"),f=u??h;if(f?n.insertBefore(d,f):n.appendChild(d),t&&this.sortModel.length>1&&s!==void 0){const p=document.createElement("span");p.className="sort-index",p.textContent=String(s),d.nextSibling?n.insertBefore(p,d.nextSibling):n.appendChild(p)}}else n.removeAttribute("data-sort")})}getSortModel(){return[...this.sortModel]}setSortModel(e){this.sortModel=[...e],this.emit("sort-change",{sortModel:[...e]}),this.requestRender()}clearSort(){this.sortModel=[],this.emit("sort-change",{sortModel:[]}),this.requestRender()}getSortIndex(e){return jt(this.sortModel,e)}getSortDirection(e){return Yt(this.sortModel,e)}getColumnState(e){const t=this.sortModel.findIndex(n=>n.field===e);return t===-1?void 0:{sort:{direction:this.sortModel[t].direction,priority:t}}}applyColumnState(e,t){if(!t.sort){this.sortModel=this.sortModel.filter(r=>r.field!==e);return}const i=this.sortModel.findIndex(r=>r.field===e),n={field:e,direction:t.sort.direction};i!==-1?this.sortModel[i]=n:this.sortModel.splice(t.sort.priority,0,n)}}function Mn(o){return o.filter(e=>e.sticky==="left")}function On(o){return o.filter(e=>e.sticky==="right")}function Ge(o){return o.some(e=>e.sticky==="left"||e.sticky==="right")}function Xt(o,e){const t=Array.from(o.querySelectorAll(".header-row .cell"));if(!t.length)return;const i=new Map;e.forEach((s,l)=>{s.field&&i.set(s.field,l)});let n=0;for(const s of e)if(s.sticky==="left"){const l=i.get(s.field),a=t.find(c=>c.getAttribute("data-field")===s.field);a&&(a.classList.add("sticky-left"),a.style.position="sticky",a.style.left=n+"px",l!==void 0&&o.querySelectorAll(`.data-grid-row .cell[data-col="${l}"]`).forEach(c=>{c.classList.add("sticky-left"),c.style.position="sticky",c.style.left=n+"px"}),n+=a.offsetWidth)}let r=0;for(const s of[...e].reverse())if(s.sticky==="right"){const l=i.get(s.field),a=t.find(c=>c.getAttribute("data-field")===s.field);a&&(a.classList.add("sticky-right"),a.style.position="sticky",a.style.right=r+"px",l!==void 0&&o.querySelectorAll(`.data-grid-row .cell[data-col="${l}"]`).forEach(c=>{c.classList.add("sticky-right"),c.style.position="sticky",c.style.right=r+"px"}),r+=a.offsetWidth)}}function Zt(o){o.querySelectorAll(".sticky-left, .sticky-right").forEach(t=>{t.classList.remove("sticky-left","sticky-right"),t.style.position="",t.style.left="",t.style.right=""})}class Nn extends D{static manifest={ownedProperties:[{property:"sticky",level:"column",description:'the "sticky" column property',isUsed:e=>e==="left"||e==="right"}]};name="pinnedColumns";get defaultConfig(){return{}}isApplied=!1;leftOffsets=new Map;rightOffsets=new Map;detach(){this.leftOffsets.clear(),this.rightOffsets.clear(),this.isApplied=!1}static detect(e,t){const i=t?.columns;return Array.isArray(i)?Ge(i):!1}processColumns(e){return this.isApplied=Ge([...e]),[...e]}afterRender(){if(!this.isApplied)return;const e=this.grid,t=[...this.columns];if(!Ge(t)){Zt(e),this.isApplied=!1;return}queueMicrotask(()=>{Xt(e,t)})}onPluginQuery(e){switch(e.type){case ke.CAN_MOVE_COLUMN:{const t=e.context,i=t.sticky;if(i==="left"||i==="right")return!1;const n=t.meta?.sticky;return n==="left"||n==="right"?!1:void 0}default:return}}refreshStickyOffsets(){const e=[...this.columns];Xt(this.grid,e)}getLeftPinnedColumns(){const e=[...this.columns];return Mn(e)}getRightPinnedColumns(){const e=[...this.columns];return On(e)}clearStickyPositions(){Zt(this.grid)}getHorizontalScrollOffsets(e,t){if(!this.isApplied)return;let i=0,n=0;if(e){const s=e.querySelectorAll(".sticky-left"),l=e.querySelectorAll(".sticky-right");s.forEach(a=>{i+=a.offsetWidth}),l.forEach(a=>{n+=a.offsetWidth})}else this.grid.querySelectorAll(".header-row .cell").forEach(a=>{a.classList.contains("sticky-left")?i+=a.offsetWidth:a.classList.contains("sticky-right")&&(n+=a.offsetWidth)});const r=t?.classList.contains("sticky-left")||t?.classList.contains("sticky-right");return{left:i,right:n,skipScroll:r}}}function zn(o){return typeof o=="object"&&o!==null&&"aggFunc"in o}function Ke(o,e){const t=document.createElement("div");t.className="tbw-pinned-rows",t.setAttribute("role","presentation"),t.setAttribute("aria-live","polite");const i=document.createElement("div");i.className="tbw-pinned-rows-left";const n=document.createElement("div");n.className="tbw-pinned-rows-center";const r=document.createElement("div");if(r.className="tbw-pinned-rows-right",o.showRowCount!==!1){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-row-count",s.textContent=`Total: ${e.totalRows} rows`,i.appendChild(s)}if(o.showFilteredCount&&e.filteredRows!==e.totalRows){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-filtered-count",s.textContent=`Filtered: ${e.filteredRows}`,i.appendChild(s)}if(o.showSelectedCount&&e.selectedRows>0){const s=document.createElement("span");s.className="tbw-status-panel tbw-status-panel-selected-count",s.textContent=`Selected: ${e.selectedRows}`,r.appendChild(s)}if(o.customPanels)for(const s of o.customPanels){const l=qn(s,e);switch(s.position){case"left":i.appendChild(l);break;case"center":n.appendChild(l);break;case"right":r.appendChild(l);break}}return t.appendChild(i),t.appendChild(n),t.appendChild(r),t}function Jt(o){const e=document.createElement("div");return e.className=`tbw-aggregation-rows tbw-aggregation-rows-${o}`,e.setAttribute("role","presentation"),e}function Qt(o,e,t,i){o.innerHTML="";for(const n of e){const r=document.createElement("div");if(r.className="tbw-aggregation-row",r.setAttribute("role","presentation"),n.id&&r.setAttribute("data-aggregation-id",n.id),n.fullWidth){const s=document.createElement("div");s.className="tbw-aggregation-cell tbw-aggregation-cell-full",s.style.gridColumn="1 / -1",s.textContent=n.label||"",r.appendChild(s)}else for(const s of t){const l=document.createElement("div");l.className="tbw-aggregation-cell",l.setAttribute("data-field",s.field);let a,c;const d=n.aggregators?.[s.field];if(d)if(zn(d)){const u=Vt(d.aggFunc);u&&(a=u(i,s.field,s)),c=d.formatter}else{const u=Vt(d);u&&(a=u(i,s.field,s))}else if(n.cells&&Object.prototype.hasOwnProperty.call(n.cells,s.field)){const u=n.cells[s.field];typeof u=="function"?a=u(i,s.field,s):a=u}a!=null?l.textContent=c?c(a,s.field,s):String(a):l.textContent="",r.appendChild(l)}o.appendChild(r)}}function qn(o,e){const t=document.createElement("div");t.className="tbw-status-panel tbw-status-panel-custom",t.id=`status-panel-${o.id}`;const i=o.render(e);return typeof i=="string"?t.innerHTML=i:t.appendChild(i),t}function ei(o,e,t,i,n){return{totalRows:o.length,filteredRows:n?.cachedResult?.length??o.length,selectedRows:i?.selected?.size??0,columns:e,rows:o,grid:t}}const Fn="@layer tbw-plugins{.tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:var(--tbw-spacing-xl, 1rem)}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, .125rem .5rem);min-height:var(--tbw-row-height, 1.75rem);display:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}}";class Gn extends D{name="pinnedRows";styles=Fn;get defaultConfig(){return{position:"bottom",showRowCount:!0,showSelectedCount:!0,showFilteredCount:!0}}infoBarElement=null;topAggregationContainer=null;bottomAggregationContainer=null;footerWrapper=null;detach(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}afterRender(){const e=this.gridElement;if(!e)return;const t=e.querySelector(".tbw-scroll-area")??e.querySelector(".tbw-grid-content")??e.children[0];if(!t)return;this.footerWrapper&&!t.contains(this.footerWrapper)&&(this.footerWrapper=null,this.bottomAggregationContainer=null,this.infoBarElement=null),this.topAggregationContainer&&!t.contains(this.topAggregationContainer)&&(this.topAggregationContainer=null),this.infoBarElement&&!t.contains(this.infoBarElement)&&(this.infoBarElement=null);const i=this.getSelectionState(),n=this.getFilterState(),r=ei(this.rows,this.columns,this.grid,i,n),s=this.config.aggregationRows||[],l=s.filter(h=>h.position==="top"),a=s.filter(h=>h.position!=="top");if(l.length>0){if(!this.topAggregationContainer){this.topAggregationContainer=Jt("top");const h=e.querySelector(".header");h&&h.nextSibling?t.insertBefore(this.topAggregationContainer,h.nextSibling):t.appendChild(this.topAggregationContainer)}Qt(this.topAggregationContainer,l,this.visibleColumns,this.rows)}else this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null);const c=this.config.showRowCount!==!1||this.config.showSelectedCount&&r.selectedRows>0||this.config.showFilteredCount&&r.filteredRows!==r.totalRows||this.config.customPanels&&this.config.customPanels.length>0,d=c&&this.config.position!=="top",u=a.length>0||d;if(c&&this.config.position==="top")if(!this.infoBarElement)this.infoBarElement=Ke(this.config,r),t.insertBefore(this.infoBarElement,t.firstChild);else{const h=Ke(this.config,r);this.infoBarElement.replaceWith(h),this.infoBarElement=h}else this.config.position==="top"&&this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null);u?(this.footerWrapper||(this.footerWrapper=document.createElement("div"),this.footerWrapper.className="tbw-footer",t.appendChild(this.footerWrapper)),this.footerWrapper.innerHTML="",a.length>0&&(this.bottomAggregationContainer||(this.bottomAggregationContainer=Jt("bottom")),this.footerWrapper.appendChild(this.bottomAggregationContainer),Qt(this.bottomAggregationContainer,a,this.visibleColumns,this.rows)),d&&(this.infoBarElement=Ke(this.config,r),this.footerWrapper.appendChild(this.infoBarElement))):this.cleanupFooter()}cleanup(){this.infoBarElement&&(this.infoBarElement.remove(),this.infoBarElement=null),this.topAggregationContainer&&(this.topAggregationContainer.remove(),this.topAggregationContainer=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null)}cleanupFooter(){this.footerWrapper&&(this.footerWrapper.remove(),this.footerWrapper=null),this.bottomAggregationContainer&&(this.bottomAggregationContainer.remove(),this.bottomAggregationContainer=null),this.infoBarElement&&this.config.position!=="top"&&(this.infoBarElement.remove(),this.infoBarElement=null)}getSelectionState(){try{return this.grid?.getPluginState?.("selection")??null}catch{return null}}getFilterState(){try{return this.grid?.getPluginState?.("filtering")??null}catch{return null}}refresh(){this.requestRender()}getContext(){const e=this.getSelectionState(),t=this.getFilterState();return ei(this.rows,this.columns,this.grid,e,t)}addPanel(e){this.config.customPanels||(this.config.customPanels=[]),this.config.customPanels.push(e),this.requestRender()}removePanel(e){this.config.customPanels&&(this.config.customPanels=this.config.customPanels.filter(t=>t.id!==e),this.requestRender())}addAggregationRow(e){this.config.aggregationRows||(this.config.aggregationRows=[]),this.config.aggregationRows.push(e),this.requestRender()}removeAggregationRow(e){this.config.aggregationRows&&(this.config.aggregationRows=this.config.aggregationRows.filter(t=>t.id!==e),this.requestRender())}}const Kn=mn;function Bn(o){const e=[];return!o.rowGroupFields?.length&&!o.columnGroupFields?.length&&e.push("At least one row or column group field is required"),o.valueFields?.length||e.push("At least one value field is required"),e}function Be(o,e){return[...o,e].join("|")}function Wn(o,e){const t=e.rowGroupFields??[],i=e.columnGroupFields??[],n=e.valueFields??[],r=Vn(o,i),s=ti(o,t,i,r,n,0,""),l=Un(s,r,n),a=Object.values(l).reduce((c,d)=>c+d,0);return{rows:s,columnKeys:r,totals:l,grandTotal:a}}function Vn(o,e){if(e.length===0)return["value"];const t=new Set;for(const i of o){const n=e.map(r=>String(i[r]??"")).join("|");t.add(n)}return[...t].sort()}function $n(o,e){const t=new Map;for(const i of o){const n=String(i[e]??""),r=t.get(n);r?r.push(i):t.set(n,[i])}return t}function ti(o,e,t,i,n,r,s){const l=[];if(e.length===0){const h=ii(o,t,i,n),f=oi(h);return l.push({rowKey:s||"all",rowLabel:s||"All",depth:r,values:h,total:f,isGroup:!1,rowCount:o.length}),l}const a=e[0],c=e.slice(1),d=c.length>0,u=$n(o,a);for(const[h,f]of u){const p=s?`${s}|${h}`:h,g=ii(f,t,i,n),w=oi(g);let m;d&&(m=ti(f,c,t,i,n,r+1,p)),l.push({rowKey:p,rowLabel:h||"(blank)",depth:r,values:g,total:w,isGroup:d,children:m,rowCount:f.length})}return l}function ii(o,e,t,i){const n={};for(const r of t)for(const s of i){const a=(e.length>0?o.filter(h=>e.map(f=>String(h[f]??"")).join("|")===r):o).map(h=>Number(h[s.field])||0),c=Kn(s.aggFunc),d=a.length>0?c(a):null,u=Be([r],s.field);n[u]=d}return n}function oi(o){let e=0;for(const t of Object.values(o))e+=t??0;return e}function Un(o,e,t){const i={};function n(r){for(const s of r)if(!s.isGroup||!s.children?.length)for(const l of e)for(const a of t){const c=Be([l],a.field);i[c]=(i[c]??0)+(s.values[c]??0)}else s.children&&n(s.children)}return n(o),i}function jn(o,e,t=!0){const i=[];function n(r){i.push(r);const s=e?e.has(r.rowKey):t;if(r.children&&s)for(const l of r.children)n(l)}for(const r of o)n(r);return i}function Yn(o){const e=[];function t(i){if(i.isGroup&&e.push(i.rowKey),i.children)for(const n of i.children)t(n)}for(const i of o)t(i);return e}const Xn=["sum","avg","count","min","max","first","last"];function Zn(o,e,t,i){const n=new AbortController,r={config:e,callbacks:i,signal:n.signal},s=document.createElement("div");return s.className="tbw-pivot-panel",s.appendChild(de("Options",()=>ir(t,r))),s.appendChild(de("Row Groups",()=>ni("rowGroups",r))),s.appendChild(de("Column Groups",()=>ni("columnGroups",r))),s.appendChild(de("Values",()=>Qn(r))),s.appendChild(de("Available Fields",()=>tr(r))),o.appendChild(s),()=>{n.abort(),s.remove()}}function de(o,e){const t=document.createElement("div");t.className="tbw-pivot-section";const i=document.createElement("div");i.className="tbw-pivot-section-header",i.textContent=o;const n=document.createElement("div");return n.className="tbw-pivot-section-content",n.appendChild(e()),t.appendChild(i),t.appendChild(n),t}function ni(o,e){const{config:t,callbacks:i,signal:n}=e,r=document.createElement("div");r.className="tbw-pivot-drop-zone",r.setAttribute("data-zone",o);const s=o==="rowGroups"?t.rowGroupFields??[]:t.columnGroupFields??[];if(s.length===0){const l=document.createElement("div");l.className="tbw-pivot-placeholder",l.textContent="Drag fields here or click to add",r.appendChild(l)}else for(const l of s)r.appendChild(Jn(l,o,e));return r.addEventListener("dragover",l=>{l.preventDefault(),r.classList.add("drag-over")},{signal:n}),r.addEventListener("dragleave",()=>{r.classList.remove("drag-over")},{signal:n}),r.addEventListener("drop",l=>{l.preventDefault(),r.classList.remove("drag-over");const a=l.dataTransfer?.getData("text/plain");a&&i.onAddFieldToZone(a,o)},{signal:n}),r}function Jn(o,e,t){const{callbacks:i,signal:n}=t,r=document.createElement("div");r.className="tbw-pivot-field-chip",r.draggable=!0;const s=i.getAvailableFields().find(c=>c.field===o),l=document.createElement("span");l.className="tbw-pivot-chip-label",l.textContent=s?.header??o;const a=document.createElement("button");return a.className="tbw-pivot-chip-remove",a.innerHTML="×",a.title="Remove field",a.addEventListener("click",c=>{c.stopPropagation(),i.onRemoveFieldFromZone(o,e)},{signal:n}),r.appendChild(l),r.appendChild(a),r.addEventListener("dragstart",c=>{c.dataTransfer?.setData("text/plain",o),c.dataTransfer?.setData("source-zone",e),r.classList.add("dragging")},{signal:n}),r.addEventListener("dragend",()=>{r.classList.remove("dragging")},{signal:n}),r}function Qn(o){const{config:e,callbacks:t,signal:i}=o,n=document.createElement("div");n.className="tbw-pivot-drop-zone tbw-pivot-values-zone",n.setAttribute("data-zone","values");const r=e.valueFields??[];if(r.length===0){const s=document.createElement("div");s.className="tbw-pivot-placeholder",s.textContent="Drag numeric fields here for aggregation",n.appendChild(s)}else for(const s of r)n.appendChild(er(s,o));return n.addEventListener("dragover",s=>{s.preventDefault(),n.classList.add("drag-over")},{signal:i}),n.addEventListener("dragleave",()=>{n.classList.remove("drag-over")},{signal:i}),n.addEventListener("drop",s=>{s.preventDefault(),n.classList.remove("drag-over");const l=s.dataTransfer?.getData("text/plain");l&&t.onAddValueField(l,"sum")},{signal:i}),n}function er(o,e){const{callbacks:t,signal:i}=e,n=document.createElement("div");n.className="tbw-pivot-field-chip tbw-pivot-value-chip";const r=t.getAvailableFields().find(d=>d.field===o.field),s=document.createElement("div");s.className="tbw-pivot-value-label-wrapper";const l=document.createElement("span");l.className="tbw-pivot-chip-label",l.textContent=r?.header??o.field;const a=document.createElement("select");a.className="tbw-pivot-agg-select",a.title="Aggregation function";for(const d of Xn){const u=document.createElement("option");u.value=d,u.textContent=d.toUpperCase(),u.selected=d===o.aggFunc,a.appendChild(u)}a.addEventListener("change",()=>{t.onUpdateValueAggFunc(o.field,a.value)},{signal:i});const c=document.createElement("button");return c.className="tbw-pivot-chip-remove",c.innerHTML="×",c.title="Remove value field",c.addEventListener("click",d=>{d.stopPropagation(),t.onRemoveValueField(o.field)},{signal:i}),s.appendChild(l),s.appendChild(a),n.appendChild(s),n.appendChild(c),n}function tr(o){const{config:e,callbacks:t,signal:i}=o,n=document.createElement("div");n.className="tbw-pivot-available-fields";const r=t.getAvailableFields(),s=new Set([...e.rowGroupFields??[],...e.columnGroupFields??[],...e.valueFields?.map(a=>a.field)??[]]),l=r.filter(a=>!s.has(a.field));if(l.length===0){const a=document.createElement("div");a.className="tbw-pivot-placeholder",a.textContent="All fields are in use",n.appendChild(a)}else for(const a of l){const c=document.createElement("div");c.className="tbw-pivot-field-chip available",c.textContent=a.header,c.draggable=!0,c.title=`Drag to add "${a.field}" to a zone`,c.addEventListener("dragstart",d=>{d.dataTransfer?.setData("text/plain",a.field),c.classList.add("dragging")},{signal:i}),c.addEventListener("dragend",()=>{c.classList.remove("dragging")},{signal:i}),n.appendChild(c)}return n}function ir(o,e){const{config:t,callbacks:i,signal:n}=e,r=document.createElement("div");return r.className="tbw-pivot-options",r.appendChild(We("Enable Pivot View",o,s=>{i.onTogglePivot(s)},n)),r.appendChild(We("Show Row Totals",t.showTotals??!0,s=>{i.onOptionChange("showTotals",s)},n)),r.appendChild(We("Show Grand Total",t.showGrandTotal??!0,s=>{i.onOptionChange("showGrandTotal",s)},n)),r}function We(o,e,t,i){const n=document.createElement("label");n.className="tbw-pivot-checkbox";const r=document.createElement("input");r.type="checkbox",r.checked=e,r.addEventListener("change",()=>t(r.checked),{signal:i});const s=document.createElement("span");return s.textContent=o,n.appendChild(r),n.appendChild(s),n}function or(o,e,t){return e.className="data-grid-row pivot-group-row",e.setAttribute("data-pivot-depth",String(o.__pivotDepth??0)),e.setAttribute("data-pivot-key",String(o.__pivotRowKey??"")),e.setAttribute("role","row"),e.innerHTML="",t.columns.forEach((i,n)=>{const r=document.createElement("div");if(r.className="cell",r.setAttribute("data-col",String(n)),r.setAttribute("data-row",String(t.rowIndex)),r.setAttribute("role","gridcell"),n===0){const s=Number(o.__pivotIndent)||0;r.style.paddingLeft=`${s}px`;const l=String(o.__pivotRowKey),a=document.createElement("button");a.type="button",a.className="pivot-toggle",a.setAttribute("aria-label",o.__pivotExpanded?"Collapse group":"Expand group"),t.setIcon(a,t.resolveIcon(o.__pivotExpanded?"collapse":"expand")),a.addEventListener("click",u=>{u.stopPropagation(),t.onToggle(l)}),r.appendChild(a);const c=document.createElement("span");c.className="pivot-label",c.textContent=String(o.__pivotLabel??""),r.appendChild(c);const d=document.createElement("span");d.className="pivot-count",d.textContent=` (${Number(o.__pivotRowCount)||0})`,r.appendChild(d)}else{const s=o[i.field];r.textContent=s!=null?String(s):""}e.appendChild(r)}),!0}function nr(o,e,t,i){return e.className="data-grid-row pivot-leaf-row",e.setAttribute("data-pivot-depth",String(o.__pivotDepth??0)),e.setAttribute("data-pivot-key",String(o.__pivotRowKey??"")),e.innerHTML="",t.forEach((n,r)=>{const s=document.createElement("div");if(s.className="cell",s.setAttribute("data-col",String(r)),s.setAttribute("data-row",String(i)),s.setAttribute("role","gridcell"),r===0){const l=Number(o.__pivotIndent)||0;s.style.paddingLeft=`${l+20}px`;const a=document.createElement("span");a.className="pivot-label",a.textContent=String(o.__pivotLabel??""),s.appendChild(a)}else{const l=o[n.field];s.textContent=l!=null?String(l):""}e.appendChild(s)}),!0}function rr(o,e,t){return e.className="pivot-grand-total-row",e.setAttribute("role","presentation"),e.innerHTML="",t.forEach((i,n)=>{const r=document.createElement("div");if(r.className="cell",r.setAttribute("data-col",String(n)),n===0){const s=document.createElement("span");s.className="pivot-label",s.textContent="Grand Total",r.appendChild(s)}else{const s=o[i.field];r.textContent=s!=null?String(s):""}e.appendChild(r)}),!0}const sr='@layer tbw-plugins{.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-right:6px;border:none;background:transparent;cursor:pointer;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background .15s,color .15s}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));height:100%;overflow-y:auto;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));cursor:pointer}.tbw-pivot-toggle-label input{width:var(--tbw-icon-size, 1rem);height:var(--tbw-icon-size, 1rem);cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:var(--tbw-spacing-sm, .375rem);align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:var(--tbw-spacing-sm, .375rem);padding:var(--tbw-button-padding-sm, var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:var(--tbw-font-size-xs, .75rem);transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:var(--tbw-icon-size, 1rem);height:var(--tbw-icon-size, 1rem);padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:var(--tbw-font-size-sm, .875rem);font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:var(--tbw-button-padding-sm, var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-md, .5rem))}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));flex:1;min-width:0}.tbw-pivot-agg-select{padding:var(--tbw-spacing-xs, .125rem) var(--tbw-spacing-xs, .25rem);font-size:var(--tbw-font-size-xs, .6875rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:var(--tbw-spacing-sm, .375rem);min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-pivot-checkbox{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));cursor:pointer}.tbw-pivot-checkbox input{width:var(--tbw-icon-size-sm, .875rem);height:var(--tbw-icon-size-sm, .875rem);cursor:pointer}.pivot-group-row.tbw-pivot-slide-in,.pivot-leaf-row.tbw-pivot-slide-in{animation:tbw-pivot-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.pivot-group-row.tbw-pivot-fade-in,.pivot-leaf-row.tbw-pivot-fade-in{animation:tbw-pivot-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-fade-in{0%{opacity:0}to{opacity:1}}}';class U extends D{name="pivot";styles=sr;static PANEL_ID="pivot";get defaultConfig(){return{active:!0,showTotals:!0,showGrandTotal:!0,showToolPanel:!0,animation:"slide"}}isActive=!1;hasInitialized=!1;pivotResult=null;fieldHeaderMap=new Map;expandedKeys=new Set;defaultExpanded=!0;originalColumns=[];panelContainer=null;grandTotalFooter=null;previousVisibleKeys=new Set;keysToAnimate=new Set;hasValidPivotConfig(){return(this.config.valueFields?.length??0)>0}get animationStyle(){return this.isAnimationEnabled?this.config.animation??"slide":!1}detach(){this.isActive=!1,this.hasInitialized=!1,this.pivotResult=null,this.fieldHeaderMap.clear(),this.originalColumns=[],this.panelContainer=null,this.cleanupGrandTotalFooter(),this.previousVisibleKeys.clear(),this.keysToAnimate.clear()}getToolPanel(){if((this.config?.showToolPanel??this.userConfig?.showToolPanel??!0)!==!1)return{id:U.PANEL_ID,title:"Pivot",icon:"⊞",tooltip:"Configure pivot table",order:90,render:t=>this.renderPanel(t)}}processRows(e){if(!this.hasInitialized&&this.config.active!==!1&&this.hasValidPivotConfig()&&(this.hasInitialized=!0,this.isActive=!0),!this.isActive)return[...e];const t=Bn(this.config);if(t.length>0)return this.warn(`Config errors: ${t.join(", ")}`),[...e];this.buildFieldHeaderMap(),this.defaultExpanded=this.config.defaultExpanded??!0,this.expandedKeys.size===0&&this.defaultExpanded&&this.pivotResult&&this.expandAllKeys(),this.pivotResult=Wn(e,this.config),this.expandedKeys.size===0&&this.defaultExpanded&&this.expandAllKeys();const i=this.config.indentWidth??20,n=jn(this.pivotResult.rows,this.expandedKeys,this.defaultExpanded).map(s=>({__pivotRowKey:s.rowKey,__pivotLabel:s.rowLabel,__pivotDepth:s.depth,__pivotIsGroup:s.isGroup,__pivotHasChildren:!!s.children?.length,__pivotExpanded:this.expandedKeys.has(s.rowKey),__pivotRowCount:s.rowCount??0,__pivotIndent:s.depth*i,__pivotTotal:s.total,...s.values}));this.keysToAnimate.clear();const r=new Set;for(const s of n){const l=s.__pivotRowKey;r.add(l),!this.previousVisibleKeys.has(l)&&s.__pivotDepth>0&&this.keysToAnimate.add(l)}return this.previousVisibleKeys=r,n}processColumns(e){if(!this.isActive||!this.pivotResult)return[...e];const t=[],i=(this.config.rowGroupFields??[]).map(n=>this.fieldHeaderMap.get(n)??n).join(" / ");t.push({field:"__pivotLabel",header:i||"Group",width:200});for(const n of this.pivotResult.columnKeys)for(const r of this.config.valueFields??[]){const s=Be([n],r.field),l=r.header||this.fieldHeaderMap.get(r.field)||r.field;t.push({field:s,header:`${n} - ${l} (${r.aggFunc})`,width:120,type:"number"})}return this.config.showTotals&&t.push({field:"__pivotTotal",header:"Total",width:100,type:"number"}),t}renderRow(e,t,i){const n=e;return n.__pivotRowKey&&n.__pivotHasChildren?or(n,t,{columns:this.gridColumns,rowIndex:i,onToggle:r=>this.toggle(r),resolveIcon:r=>this.resolveIcon(r),setIcon:(r,s)=>this.setIcon(r,s)}):n.__pivotRowKey!==void 0&&this.isActive?nr(n,t,this.gridColumns,i):(this.cleanupPivotStyling(t),!1)}cleanupPivotStyling(e){(e.classList.contains("pivot-group-row")||e.classList.contains("pivot-leaf-row")||e.classList.contains("pivot-grand-total-row"))&&(e.classList.remove("pivot-group-row","pivot-leaf-row","pivot-grand-total-row"),e.classList.add("data-grid-row"),e.removeAttribute("data-pivot-depth"),e.innerHTML="")}onKeyDown(e){if(e.key!==" "||!this.isActive)return;const t=this.grid._focusRow,i=this.rows[t];if(!(!i?.__pivotIsGroup||!i.__pivotHasChildren))return e.preventDefault(),this.toggle(i.__pivotRowKey),this.requestRenderWithFocus(),!0}afterRender(){this.isActive&&this.config.showGrandTotal&&this.pivotResult?this.renderGrandTotalFooter():this.cleanupGrandTotalFooter();const e=this.animationStyle;if(e===!1||this.keysToAnimate.size===0)return;const t=this.gridElement?.querySelector(".rows");if(!t)return;const i=e==="fade"?"tbw-pivot-fade-in":"tbw-pivot-slide-in";for(const n of t.querySelectorAll(".pivot-group-row, .pivot-leaf-row")){const r=n.dataset.pivotKey;r&&this.keysToAnimate.has(r)&&(n.classList.add(i),n.addEventListener("animationend",()=>n.classList.remove(i),{once:!0}))}this.keysToAnimate.clear()}renderGrandTotalFooter(){if(!this.pivotResult)return;const e=this.gridElement;if(!e)return;const t=e.querySelector(".tbw-scroll-area")??e.querySelector(".tbw-grid-content")??e.children[0];if(!t)return;this.grandTotalFooter||(this.grandTotalFooter=document.createElement("div"),this.grandTotalFooter.className="pivot-grand-total-footer",t.appendChild(this.grandTotalFooter));const i={__pivotRowKey:"__grandTotal",__pivotLabel:"Grand Total",__pivotIsGrandTotal:!0,__pivotTotal:this.pivotResult.grandTotal,...this.pivotResult.totals};rr(i,this.grandTotalFooter,this.gridColumns)}cleanupGrandTotalFooter(){this.grandTotalFooter&&(this.grandTotalFooter.remove(),this.grandTotalFooter=null)}toggle(e){this.expandedKeys.has(e)?this.expandedKeys.delete(e):this.expandedKeys.add(e),this.requestRender()}expand(e){this.expandedKeys.add(e),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}expandAll(){this.expandAllKeys(),this.requestRender()}collapseAll(){this.expandedKeys.clear(),this.requestRender()}expandAllKeys(){if(!this.pivotResult)return;const e=Yn(this.pivotResult.rows);for(const t of e)this.expandedKeys.add(t)}isExpanded(e){return this.expandedKeys.has(e)}enablePivot(){this.originalColumns.length===0&&this.captureOriginalColumns(),this.isActive=!0,this.requestRender()}disablePivot(){this.isActive=!1,this.pivotResult=null,this.requestRender()}isPivotActive(){return this.isActive}getPivotResult(){return this.pivotResult}setRowGroupFields(e){this.config.rowGroupFields=e,this.requestRender()}setColumnGroupFields(e){this.config.columnGroupFields=e,this.requestRender()}setValueFields(e){this.config.valueFields=e,this.requestRender()}refresh(){this.pivotResult=null,this.requestRender()}showPanel(){this.grid.openToolPanel(),this.grid.expandedToolPanelSections.includes(U.PANEL_ID)||this.grid.toggleToolPanelSection(U.PANEL_ID)}hidePanel(){this.grid.closeToolPanel()}togglePanel(){this.grid.isToolPanelOpen||this.grid.openToolPanel(),this.grid.toggleToolPanelSection(U.PANEL_ID)}isPanelVisible(){return this.grid.isToolPanelOpen&&this.grid.expandedToolPanelSections.includes(U.PANEL_ID)}get gridColumns(){return this.grid.columns??[]}refreshIfActive(){this.isActive&&this.refresh(),this.refreshPanel()}buildFieldHeaderMap(){const e=this.getAvailableFields();this.fieldHeaderMap.clear();for(const t of e)this.fieldHeaderMap.set(t.field,t.header)}getAvailableFields(){return this.originalColumns.length>0?this.originalColumns:this.captureOriginalColumns()}captureOriginalColumns(){try{const e=this.grid.getAllColumns?.()??this.grid.columns??[];return this.originalColumns=e.filter(t=>!t.field.startsWith("__pivot")).map(t=>({field:t.field,header:t.header??t.field})),this.originalColumns}catch{return[]}}renderPanel(e){this.panelContainer=e,this.originalColumns.length===0&&this.captureOriginalColumns();const t={onTogglePivot:i=>{i?this.enablePivot():this.disablePivot(),this.refreshPanel()},onAddFieldToZone:(i,n)=>this.addFieldToZone(i,n),onRemoveFieldFromZone:(i,n)=>this.removeFieldFromZone(i,n),onAddValueField:(i,n)=>this.addValueField(i,n),onRemoveValueField:i=>this.removeValueField(i),onUpdateValueAggFunc:(i,n)=>this.updateValueAggFunc(i,n),onOptionChange:(i,n)=>{this.config[i]=n,this.isActive&&this.refresh()},getAvailableFields:()=>this.getAvailableFields()};return Zn(e,this.config,this.isActive,t)}refreshPanel(){this.panelContainer&&(this.panelContainer.innerHTML="",this.renderPanel(this.panelContainer))}addFieldToZone(e,t){if(t==="rowGroups"){const i=this.config.rowGroupFields??[];i.includes(e)||(this.config.rowGroupFields=[...i,e])}else{const i=this.config.columnGroupFields??[];i.includes(e)||(this.config.columnGroupFields=[...i,e])}this.removeFromOtherZones(e,t),this.refreshIfActive()}removeFieldFromZone(e,t){t==="rowGroups"?this.config.rowGroupFields=(this.config.rowGroupFields??[]).filter(i=>i!==e):this.config.columnGroupFields=(this.config.columnGroupFields??[]).filter(i=>i!==e),this.refreshIfActive()}removeFromOtherZones(e,t){t!=="rowGroups"&&(this.config.rowGroupFields=(this.config.rowGroupFields??[]).filter(i=>i!==e)),t!=="columnGroups"&&(this.config.columnGroupFields=(this.config.columnGroupFields??[]).filter(i=>i!==e)),t!=="values"&&(this.config.valueFields=(this.config.valueFields??[]).filter(i=>i.field!==e))}addValueField(e,t){const i=this.config.valueFields??[];i.some(n=>n.field===e)||(this.config.valueFields=[...i,{field:e,aggFunc:t}]),this.removeFromOtherZones(e,"values"),this.refreshIfActive()}removeValueField(e){this.config.valueFields=(this.config.valueFields??[]).filter(t=>t.field!==e),this.refreshIfActive()}updateValueAggFunc(e,t){const i=this.config.valueFields??[],n=i.findIndex(r=>r.field===e);n>=0&&(i[n]={...i[n],aggFunc:t},this.config.valueFields=[...i]),this.isActive&&this.refresh()}}function lr(o){const e=o.meta??{};return e.lockPosition!==!0&&e.suppressMovable!==!0}function ri(o,e,t){if(e===t||e<0||e>=o.length||t<0||t>o.length)return o;const i=[...o],[n]=i.splice(e,1);return i.splice(t,0,n),i}const ar='@layer tbw-plugins{.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}}';class cr extends D{name="reorder";styles=ar;get defaultConfig(){return{animation:"flip"}}get animationType(){return this.isAnimationEnabled?this.config.animation!==void 0?this.config.animation:"flip":!1}get animationDuration(){return this.config.animationDuration!==void 0?this.config.animationDuration:super.animationDuration}isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;canMoveColumnWithPlugins(e){return!e||!lr(e)?!1:!this.grid.queryPlugins({type:ke.CAN_MOVE_COLUMN,context:e}).includes(!1)}clearDragClasses(){this.gridElement?.querySelectorAll(".header-row > .cell").forEach(e=>{e.classList.remove("dragging","drop-target","drop-before","drop-after")})}attach(e){super.attach(e),e.addEventListener("column-reorder-request",t=>{const i=t.detail;i?.field&&typeof i.toIndex=="number"&&this.moveColumn(i.field,i.toIndex)},{signal:this.disconnectSignal})}detach(){this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}afterRender(){const e=this.gridElement;if(!e)return;e.querySelectorAll(".header-row > .cell").forEach(i=>{const n=i,r=n.getAttribute("data-field");if(!r)return;const s=this.columns.find(l=>l.field===r);if(!this.canMoveColumnWithPlugins(s)){n.draggable=!1;return}n.draggable=!0,!n.getAttribute("data-dragstart-bound")&&(n.setAttribute("data-dragstart-bound","true"),n.addEventListener("dragstart",l=>{const c=this.getColumnOrder().indexOf(r);this.isDragging=!0,this.draggedField=r,this.draggedIndex=c,l.dataTransfer&&(l.dataTransfer.effectAllowed="move",l.dataTransfer.setData("text/plain",r)),n.classList.add("dragging")}),n.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.clearDragClasses()}),n.addEventListener("dragover",l=>{if(l.preventDefault(),!this.isDragging||this.draggedField===r)return;const a=n.getBoundingClientRect(),c=a.left+a.width/2,u=this.getColumnOrder().indexOf(r);this.dropIndex=l.clientX<c?u:u+1,n.classList.add("drop-target"),n.classList.toggle("drop-before",l.clientX<c),n.classList.toggle("drop-after",l.clientX>=c)}),n.addEventListener("dragleave",()=>{n.classList.remove("drop-target","drop-before","drop-after")}),n.addEventListener("drop",l=>{l.preventDefault();const a=this.draggedField,c=this.draggedIndex,d=this.dropIndex;if(!this.isDragging||a===null||c===null||d===null)return;const u=d>c?d-1:d,h=this.getColumnOrder(),f=ri(h,c,u),p={field:a,fromIndex:c,toIndex:u,columnOrder:f};this.emitCancelable("column-move",p)||this.updateColumnOrder(f)}))})}onKeyDown(e){if(!e.altKey||e.key!=="ArrowLeft"&&e.key!=="ArrowRight")return;const t=this.grid,i=t._focusCol,n=t._visibleColumns;if(i<0||i>=n.length)return;const r=n[i];if(!this.canMoveColumnWithPlugins(r))return;const s=this.getColumnOrder(),l=s.indexOf(r.field);if(l===-1)return;const a=e.key==="ArrowLeft"?l-1:l+1;if(a<0||a>=s.length)return;const c=n.find(d=>d.field===s[a]);if(this.canMoveColumnWithPlugins(c))return this.moveColumn(r.field,a),t._focusCol=a,N(this.grid),e.preventDefault(),e.stopPropagation(),!0}getColumnOrder(){return this.grid.getColumnOrder()}moveColumn(e,t){const i=this.getColumnOrder(),n=i.indexOf(e);if(n===-1)return;const r=ri(i,n,t);this.emitCancelable("column-move",{field:e,fromIndex:n,toIndex:t,columnOrder:r})||this.updateColumnOrder(r)}setColumnOrder(e){this.updateColumnOrder(e)}resetColumnOrder(){const e=this.columns.map(t=>t.field);this.updateColumnOrder(e)}captureHeaderPositions(){const e=new Map;return this.gridElement?.querySelectorAll(".header-row > .cell[data-field]").forEach(t=>{const i=t.getAttribute("data-field");i&&e.set(i,t.getBoundingClientRect().left)}),e}animateFLIP(e){const t=this.gridElement;if(!t||e.size===0)return;const i=new Map;if(t.querySelectorAll(".header-row > .cell[data-field]").forEach(s=>{const l=s.getAttribute("data-field");if(!l)return;const a=e.get(l);if(a===void 0)return;const c=a-s.getBoundingClientRect().left;Math.abs(c)>1&&i.set(l,c)}),i.size===0)return;const n=[];if(t.querySelectorAll(".cell[data-field]").forEach(s=>{const l=i.get(s.getAttribute("data-field")??"");if(l!==void 0){const a=s;a.style.transform=`translateX(${l}px)`,n.push(a)}}),n.length===0)return;this.gridElement.offsetHeight;const r=this.animationDuration;requestAnimationFrame(()=>{n.forEach(s=>{s.classList.add("flip-animating"),s.style.transform=""}),setTimeout(()=>{n.forEach(s=>{s.style.transform="",s.classList.remove("flip-animating")})},r+50)})}animateFade(e){const t=this.gridElement;if(!t){e();return}const i=this.captureHeaderPositions();e();const n=new Set;if(t.querySelectorAll(".header-row > .cell[data-field]").forEach(l=>{const a=l.getAttribute("data-field");if(!a)return;const c=i.get(a);if(c===void 0)return;const d=l.getBoundingClientRect().left;Math.abs(c-d)>1&&n.add(a)}),n.size===0)return;const r=[];if(t.querySelectorAll(".cell[data-field]").forEach(l=>{const a=l.getAttribute("data-field");if(a&&n.has(a)){const c=l;c.classList.add("fade-animating"),r.push(c)}}),r.length===0)return;const s=this.animationDuration;setTimeout(()=>{r.forEach(l=>l.classList.remove("fade-animating"))},s+50)}updateColumnOrder(e){const t=this.animationType;if(t==="flip"&&this.gridElement){const i=this.captureHeaderPositions();this.grid.setColumnOrder(e),requestAnimationFrame(()=>{this.gridElement.offsetHeight,this.animateFLIP(i)})}else t==="fade"?this.animateFade(()=>this.grid.setColumnOrder(e)):this.grid.setColumnOrder(e);this.grid.requestStateChange?.()}}const dr='tbw-grid[data-responsive-animate] .data-grid-row,tbw-grid[data-responsive-animate] .data-grid-row>.cell{transition:opacity var(--tbw-responsive-duration, .2s) ease-out,transform var(--tbw-responsive-duration, .2s) ease-out}tbw-grid[data-responsive][data-responsive-animate] .data-grid-row{animation:responsive-card-enter var(--tbw-responsive-duration, .2s) ease-out}@keyframes responsive-card-enter{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}tbw-grid[data-responsive] .header{display:none!important}tbw-grid[data-responsive] .footer-row{display:none}tbw-grid[data-responsive] .tbw-scroll-area{overflow-x:hidden;min-width:0!important}tbw-grid[data-responsive] .rows-body-wrapper{min-width:0!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row){display:block!important;grid-template-columns:none!important;padding:var(--tbw-cell-padding);padding-left:var(--tbw-spacing-xl);border-bottom:1px solid var(--tbw-color-border);min-height:auto!important;height:auto!important;contain:none!important;content-visibility:visible!important;background:var(--tbw-color-bg);position:relative}tbw-grid[data-responsive] .data-grid-row:not(.group-row):nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid[data-responsive] .data-grid-row:not(.group-row):hover{background:var(--tbw-color-row-hover)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]{background:var(--tbw-color-selection)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]:before{content:"";position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--tbw-color-accent)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell{display:flex!important;justify-content:space-between;align-items:center;padding:var(--tbw-spacing-xs) var(--tbw-spacing-md);width:100%!important;min-width:0!important;min-height:auto!important;height:auto!important;line-height:1.5!important;position:static!important;left:auto!important;right:auto!important;border:none!important;border-bottom:none!important;border-right:none!important;background:transparent!important;white-space:normal!important;overflow:visible!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:before{content:attr(data-header) ": ";font-weight:600;color:var(--tbw-color-header-fg);flex-shrink:0;margin-right:var(--tbw-spacing-md);min-width:100px}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:after{content:none}tbw-grid[data-responsive] .cell[data-utility]{display:none!important}tbw-grid[data-responsive] .cell[data-responsive-hidden]{display:none!important}tbw-grid[data-responsive] .cell[data-responsive-value-only]{justify-content:flex-start!important;font-weight:500}tbw-grid[data-responsive] .cell[data-responsive-value-only]:before{display:none!important}tbw-grid:not([data-responsive]) .cell[data-responsive-hidden]{display:none!important}tbw-grid[data-responsive] .tbw-footer,tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows{display:none!important}tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows,tbw-grid[data-responsive] .tbw-aggregation-row{min-width:0!important}tbw-grid[data-responsive] .data-grid-row.responsive-card{display:block!important;padding:var(--tbw-cell-padding);border-bottom:1px solid var(--tbw-color-border)}tbw-grid[data-responsive] .data-grid-row.responsive-card>*{width:100%}tbw-grid[data-responsive] .data-grid-row.responsive-card .cell:before{display:none}';class ur extends D{name="responsive";version="1.0.0";styles=dr;static manifest={incompatibleWith:[{name:"groupingRows",reason:"Responsive card layout does not yet support row grouping. The variable row heights (cards vs group headers) cause scroll calculation issues."}]};#e;#o=!1;#d;#c=!1;#s=0;#i=new Set;#h=new Set;#u=null;#p=[];isResponsive(){return this.#o}setResponsive(e){e!==this.#o&&(this.#o=e,this.#b(),this.emit("responsive-change",{isResponsive:e,width:this.#s,breakpoint:this.config.breakpoint??0}))}setBreakpoint(e){this.config.breakpoint=e,this.#w(this.#s)}setCardRenderer(e){this.config.cardRenderer=e,this.#o&&this.requestRender()}getWidth(){return this.#s}getActiveBreakpoint(){return this.#u}attach(e){super.attach(e),this.#l(this.config.hiddenColumns),this.config.breakpoints?.length&&(this.#p=[...this.config.breakpoints].sort((t,i)=>i.maxWidth-t.maxWidth)),this.#e=new ResizeObserver(t=>{const i=t[0]?.contentRect.width??0;this.#s=i,clearTimeout(this.#d),this.#d=setTimeout(()=>{this.#w(i)},this.config.debounceMs??100)}),this.#e.observe(this.gridElement)}#l(e){if(this.#i.clear(),this.#h.clear(),!!e)for(const t of e)typeof t=="string"?this.#i.add(t):t.showValue?this.#h.add(t.field):this.#i.add(t.field)}detach(){this.#e?.disconnect(),this.#e=void 0,clearTimeout(this.#d),this.#d=void 0,this.gridElement&&this.gridElement.removeAttribute("data-responsive"),super.detach()}afterRender(){if(this.#_(),!(this.#p.length>0?this.#u!==null:this.#o))return;const t=this.#i.size>0,i=this.#h.size>0;if(!t&&!i)return;const n=this.gridElement.querySelectorAll(".cell[data-field]");for(const r of n){const s=r.getAttribute("data-field");s&&(this.#i.has(s)?(r.setAttribute("data-responsive-hidden",""),r.removeAttribute("data-responsive-value-only")):this.#h.has(s)?(r.setAttribute("data-responsive-value-only",""),r.removeAttribute("data-responsive-hidden")):(r.removeAttribute("data-responsive-hidden"),r.removeAttribute("data-responsive-value-only")))}}#w(e){if(this.#p.length>0){this.#m(e);return}const t=this.config.breakpoint??0;t===0&&!this.#c&&(this.#c=!0,console.warn("[tbw-grid:ResponsivePlugin] No breakpoint configured. Responsive mode is disabled. Set a breakpoint based on your grid's column count."));const i=t>0&&e<t;i!==this.#o&&(this.#o=i,this.#b(),this.emit("responsive-change",{isResponsive:i,width:e,breakpoint:t}),this.requestRender())}#m(e){let t=null;for(const n of this.#p)e<=n.maxWidth&&(t=n);if(t!==this.#u){this.#u=t,t?.hiddenColumns?this.#l(t.hiddenColumns):this.#l(this.config.hiddenColumns);const n=t?.cardLayout===!0;n!==this.#o&&(this.#o=n,this.#b()),this.emit("responsive-change",{isResponsive:this.#o,width:e,breakpoint:t?.maxWidth??0}),this.requestRender()}}#a;#b(){this.gridElement.toggleAttribute("data-responsive",this.#o);const e=this.config.animate!==!1;this.gridElement.toggleAttribute("data-responsive-animate",e),this.config.animationDuration&&this.gridElement.style.setProperty("--tbw-responsive-duration",`${this.config.animationDuration}ms`);const t=this.grid;if(this.#o){t._virtualization&&(this.#a=t._virtualization.rowHeight);const i=this.gridElement.querySelector(".tbw-scroll-area");i&&(i.scrollLeft=0)}else{const i=this.gridElement.querySelectorAll(".data-grid-row");for(const n of i)n.style.height="",n.classList.remove("responsive-card");this.#a&&this.#a>0&&t._virtualization&&(t._virtualization.rowHeight=this.#a,this.#a=void 0),this.#v=void 0,this.#g=void 0,this.#y=void 0}}renderRow(e,t,i){if(!this.#o||!this.config.cardRenderer||e.__isGroupRow)return;t.replaceChildren();const n=this.config.cardRenderer(e,i);t.className="data-grid-row responsive-card";const r=this.config.cardRowHeight??"auto";return r!=="auto"?t.style.height=`${r}px`:t.style.height="auto",t.appendChild(n),!0}onKeyDown(e){if(!this.#o||this.config.cardRenderer&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return!1;const t=this.rows.length-1,i=this.visibleColumns.length-1;switch(e.key){case"ArrowDown":if(this.grid._focusCol<i)return this.grid._focusCol+=1,e.preventDefault(),N(this.grid),!0;if(this.grid._focusRow<t)return this.grid._focusRow+=1,this.grid._focusCol=0,e.preventDefault(),N(this.grid),!0;break;case"ArrowUp":if(this.grid._focusCol>0)return this.grid._focusCol-=1,e.preventDefault(),N(this.grid),!0;if(this.grid._focusRow>0)return this.grid._focusRow-=1,this.grid._focusCol=i,e.preventDefault(),N(this.grid),!0;break;case"ArrowRight":if(this.grid._focusRow<t)return this.grid._focusRow+=1,e.preventDefault(),N(this.grid),!0;break;case"ArrowLeft":if(this.grid._focusRow>0)return this.grid._focusRow-=1,e.preventDefault(),N(this.grid),!0;break}return!1}#v;#g;#y;#x(){if(this.#v&&this.#v>0)return this.#v;const e=this.config.cardRowHeight;return typeof e=="number"&&e>0?e:80}#C(){return this.#g&&this.#g>0?this.#g:this.#a??28}#R(){for(const e of this.rows)if(e.__isGroupRow)return!0;return!1}#r(){let e=0,t=0;for(const i of this.rows)i.__isGroupRow?e++:t++;return{groupCount:e,cardCount:t}}getExtraHeight(){if(!this.#o||!this.config.cardRenderer||!this.#R())return 0;const e=this.#a??28,t=this.#C(),i=this.#x(),{groupCount:n,cardCount:r}=this.#r(),s=n*Math.max(0,t-e),l=r*Math.max(0,i-e);return s+l}getExtraHeightBefore(e){if(!this.#o||!this.config.cardRenderer||!this.#R())return 0;const t=this.#a??28,i=this.#C(),n=this.#x(),r=Math.max(0,i-t),s=Math.max(0,n-t);let l=0,a=0;const c=this.rows,d=Math.min(e,c.length);for(let u=0;u<d;u++)c[u].__isGroupRow?l++:a++;return l*r+a*s}#E(){let e=0;for(const t of this.rows)t.__isGroupRow||e++;return e}#S=!1;#_(){if(!this.#o||!this.config.cardRenderer)return;let e=!1;const t=this.grid,i=this.#R(),n=this.#E();if(n!==this.#y&&(this.#y=n,e=!0),i){const s=this.gridElement.querySelector(".data-grid-row.group-row");if(s){const l=s.getBoundingClientRect().height;l>0&&l!==this.#g&&(this.#g=l,e=!0)}}const r=this.gridElement.querySelector(".data-grid-row.responsive-card");if(r){const s=r.getBoundingClientRect().height;s>0&&s!==this.#v&&(this.#v=s,e=!0,!i&&t._virtualization&&(t._virtualization.rowHeight=s))}e&&!this.#S&&(this.#S=!0,queueMicrotask(()=>{this.#S=!1,this.grid&&this.#o&&this.grid.refreshVirtualWindow?.(!0,!0)}))}}const hr='.dg-row-drag-handle{display:flex;align-items:center;justify-content:center;cursor:grab;-webkit-user-select:none;user-select:none;color:var(--tbw-color-fg-muted, #999);transition:color .15s ease;font-size:14px;letter-spacing:-2px}.dg-row-drag-handle:hover{color:var(--tbw-color-fg, #333)}.dg-row-drag-handle:active{cursor:grabbing}.data-grid-row.dragging{opacity:.6}.data-grid-row.drop-target{position:relative}.data-grid-row.drop-target.drop-before:before{content:"";position:absolute;top:0;left:0;right:0;height:2px;background-color:var(--tbw-color-accent, #1976d2);z-index:10}.data-grid-row.drop-target.drop-after:after{content:"";position:absolute;bottom:0;left:0;right:0;height:2px;background-color:var(--tbw-color-accent, #1976d2);z-index:10}.data-grid-row.keyboard-moving{background-color:var(--tbw-color-bg-selected, #e3f2fd);box-shadow:0 0 0 1px var(--tbw-color-accent, #1976d2) inset}.data-grid-row.animate-flip{transition:transform var(--tbw-animation-duration, .2s) ease-out}',si="__tbw_row_drag";class fr extends D{name="rowReorder";styles=hr;get defaultConfig(){return{enableKeyboard:!0,showDragHandle:!0,dragHandlePosition:"left",dragHandleWidth:40,debounceMs:150,animation:"flip"}}isDragging=!1;draggedRowIndex=null;dropRowIndex=null;pendingMove=null;debounceTimer=null;lastFocusCol=0;detach(){this.clearDebounceTimer(),this.isDragging=!1,this.draggedRowIndex=null,this.dropRowIndex=null,this.pendingMove=null}processColumns(e){if(!this.config.showDragHandle)return[...e];const t={field:si,header:"",width:this.config.dragHandleWidth??40,resizable:!1,sortable:!1,filterable:!1,meta:{lockPosition:!0,suppressMovable:!0,utility:!0},viewRenderer:()=>{const i=document.createElement("div");return i.className="dg-row-drag-handle",i.setAttribute("aria-label","Drag to reorder"),i.setAttribute("role","button"),i.setAttribute("tabindex","-1"),i.draggable=!0,this.setIcon(i,this.resolveIcon("dragHandle")),i}};return this.config.dragHandlePosition==="right"?[...e,t]:[t,...e]}afterRender(){if(!this.config.showDragHandle)return;const e=this.gridElement;if(!e)return;e.querySelectorAll(".dg-row-drag-handle").forEach(n=>{const r=n;if(r.getAttribute("data-drag-bound"))return;r.setAttribute("data-drag-bound","true");const s=r.closest(".data-grid-row");s&&this.setupHandleDragListeners(r,s)}),e.querySelectorAll(".data-grid-row").forEach(n=>{const r=n;r.getAttribute("data-drop-bound")||(r.setAttribute("data-drop-bound","true"),this.setupRowDropListeners(r))})}onKeyDown(e){if(!this.config.enableKeyboard||!e.ctrlKey||e.key!=="ArrowUp"&&e.key!=="ArrowDown")return;const t=this.grid,i=t._focusRow,n=t._rows??this.sourceRows;if(i<0||i>=n.length)return;const r=e.key==="ArrowUp"?"up":"down",s=r==="up"?i-1:i+1;if(s<0||s>=n.length)return;const l=n[i];if(!(this.config.canMove&&!this.config.canMove(l,i,s,r)))return this.handleKeyboardMove(l,i,s,r,t._focusCol),e.preventDefault(),e.stopPropagation(),!0}onCellClick(){this.flushPendingMove()}moveRow(e,t){const i=[...this.sourceRows];if(e<0||e>=i.length||t<0||t>=i.length||e===t)return;const n=t<e?"up":"down",r=i[e];this.config.canMove&&!this.config.canMove(r,e,t,n)||this.executeMove(r,e,t,"keyboard")}canMoveRow(e,t){const i=this.sourceRows;if(e<0||e>=i.length||t<0||t>=i.length||e===t)return!1;if(!this.config.canMove)return!0;const n=t<e?"up":"down";return this.config.canMove(i[e],e,t,n)}setupHandleDragListeners(e,t){e.addEventListener("dragstart",i=>{const n=this.getRowIndex(t);n<0||(this.isDragging=!0,this.draggedRowIndex=n,i.dataTransfer&&(i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",String(n))),t.classList.add("dragging"))}),e.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedRowIndex=null,this.dropRowIndex=null,this.clearDragClasses()})}setupRowDropListeners(e){e.addEventListener("dragover",t=>{if(t.preventDefault(),!this.isDragging||this.draggedRowIndex===null)return;const i=this.getRowIndex(e);if(i<0||i===this.draggedRowIndex)return;const n=e.getBoundingClientRect(),r=n.top+n.height/2,s=t.clientY<r;this.dropRowIndex=s?i:i+1,e.classList.add("drop-target"),e.classList.toggle("drop-before",s),e.classList.toggle("drop-after",!s)}),e.addEventListener("dragleave",()=>{e.classList.remove("drop-target","drop-before","drop-after")}),e.addEventListener("drop",t=>{t.preventDefault();const i=this.draggedRowIndex;let n=this.dropRowIndex;if(!(!this.isDragging||i===null||n===null)&&(n>i&&n--,i!==n)){const s=this.sourceRows[i],l=n<i?"up":"down";(!this.config.canMove||this.config.canMove(s,i,n,l))&&this.executeMove(s,i,n,"drag")}})}handleKeyboardMove(e,t,i,n,r){this.pendingMove?this.pendingMove.currentIndex=i:this.pendingMove={originalIndex:t,currentIndex:i,row:e},this.lastFocusCol=r;const s=this.grid,l=[...s._rows??this.sourceRows],[a]=l.splice(t,1);l.splice(i,0,a),s._rows=l,s._focusRow=i,s._focusCol=r,s.refreshVirtualWindow(!0),N(s),this.clearDebounceTimer(),this.debounceTimer=setTimeout(()=>{this.flushPendingMove()},this.config.debounceMs??300)}flushPendingMove(){if(this.clearDebounceTimer(),!this.pendingMove)return;const{originalIndex:e,currentIndex:t,row:i}=this.pendingMove;if(this.pendingMove=null,e===t)return;const n={row:i,fromIndex:e,toIndex:t,rows:[...this.sourceRows],source:"keyboard"};if(this.emitCancelable("row-move",n)){const s=[...this.sourceRows],[l]=s.splice(t,1);s.splice(e,0,l);const a=this.grid;a._rows=s,a._focusRow=e,a._focusCol=this.lastFocusCol,a.refreshVirtualWindow(!0),N(a)}}executeMove(e,t,i,n){const r=[...this.sourceRows],[s]=r.splice(t,1);r.splice(i,0,s);const l={row:e,fromIndex:t,toIndex:i,rows:r,source:n};this.emitCancelable("row-move",l)||(this.grid.rows=r)}getRowIndex(e){const t=e.querySelector(".cell[data-row]");return t?parseInt(t.getAttribute("data-row")??"-1",10):-1}clearDragClasses(){this.gridElement?.querySelectorAll(".data-grid-row").forEach(e=>{e.classList.remove("dragging","drop-target","drop-before","drop-after")})}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}}function pe(o){return{startRow:Math.min(o.startRow,o.endRow),startCol:Math.min(o.startCol,o.endCol),endRow:Math.max(o.startRow,o.endRow),endCol:Math.max(o.startCol,o.endCol)}}function gr(o){const e=pe(o);return{from:{row:e.startRow,col:e.startCol},to:{row:e.endRow,col:e.endCol}}}function li(o){return o.map(gr)}function pr(o,e,t){const i=pe(t);return o>=i.startRow&&o<=i.endRow&&e>=i.startCol&&e<=i.endCol}function ai(o,e,t){return t.some(i=>pr(o,e,i))}function wr(o){const e=[],t=pe(o);for(let i=t.startRow;i<=t.endRow;i++)for(let n=t.startCol;n<=t.endCol;n++)e.push({row:i,col:n});return e}function mr(o){const e=new Map;for(const t of o)for(const i of wr(t))e.set(`${i.row},${i.col}`,i);return[...e.values()]}function Ve(o,e){return{startRow:o.row,startCol:o.col,endRow:e.row,endCol:e.col}}const br="@layer tbw-plugins{tbw-grid.selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid[data-has-focus] .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}tbw-grid[data-selection-mode=row] .cell-focus{outline:none}tbw-grid .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}tbw-grid .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row[data-selectable=false]{cursor:not-allowed;opacity:.6}tbw-grid .data-grid-row[data-selectable=false].row-focus{background-color:var(--tbw-color-row-alt)}tbw-grid .data-grid-row>.cell[data-selectable=false]{cursor:not-allowed;opacity:.6}tbw-grid .data-grid-row>.cell[data-selectable=false].selected{background-color:var(--tbw-color-warning-bg, rgba(255, 243, 205, .5))}tbw-grid .tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}}";function vr(o,e,t){if(o==="cell"&&e.selectedCell)return{mode:o,ranges:[{from:{row:e.selectedCell.row,col:e.selectedCell.col},to:{row:e.selectedCell.row,col:e.selectedCell.col}}]};if(o==="row"&&e.selected.size>0){const i=[...e.selected].map(n=>({from:{row:n,col:0},to:{row:n,col:t-1}}));return{mode:o,ranges:i}}return o==="range"&&e.ranges.length>0?{mode:o,ranges:li(e.ranges)}:{mode:o,ranges:[]}}class yr extends D{static manifest={configRules:[{id:"selection/range-dblclick",severity:"warn",message:`"triggerOn: 'dblclick'" has no effect when mode is "range".
|
|
78
78
|
→ Range selection uses drag interaction (mousedown → mousemove), not click events.
|
|
79
|
-
→ The "triggerOn" option only affects "cell" and "row" selection modes.`,check:e=>e.mode==="range"&&e.triggerOn==="dblclick"}]};name="selection";styles=lr;get defaultConfig(){return{mode:"cell",triggerOn:"click"}}selected=new Set;lastSelected=null;anchor=null;ranges=[];activeRange=null;cellAnchor=null;isDragging=!1;pendingKeyboardUpdate=null;selectedCell=null;detach(){this.selected.clear(),this.ranges=[],this.activeRange=null,this.cellAnchor=null,this.isDragging=!1,this.selectedCell=null,this.pendingKeyboardUpdate=null}onCellClick(e){const{rowIndex:t,colIndex:i,originalEvent:n}=e,{mode:r,triggerOn:s="click"}=this.config;if(n.type!==s)return!1;const l=this.columns[i],a=l&&B(l);if(r==="cell")return a||(this.selectedCell={row:t,col:i},this.emit("selection-change",this.#o()),this.requestAfterRender()),!1;if(r==="row")return this.selected.clear(),this.selected.add(t),this.lastSelected=t,this.emit("selection-change",this.#o()),this.requestAfterRender(),!1;if(r==="range"){if(a)return!1;const c=n.shiftKey,d=n.ctrlKey||n.metaKey;if(c&&this.cellAnchor){const u=Ke(this.cellAnchor,{row:t,col:i});d?this.ranges.length>0?this.ranges[this.ranges.length-1]=u:this.ranges.push(u):this.ranges=[u],this.activeRange=u}else if(d){const u={startRow:t,startCol:i,endRow:t,endCol:i};this.ranges.push(u),this.activeRange=u,this.cellAnchor={row:t,col:i}}else{const u={startRow:t,startCol:i,endRow:t,endCol:i};this.ranges=[u],this.activeRange=u,this.cellAnchor={row:t,col:i}}return this.emit("selection-change",this.#o()),this.requestAfterRender(),!1}return!1}onKeyDown(e){const{mode:t}=this.config,n=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab","Home","End","PageUp","PageDown"].includes(e.key);if(e.key==="Escape")return t==="cell"?this.selectedCell=null:t==="row"?(this.selected.clear(),this.anchor=null):t==="range"&&(this.ranges=[],this.activeRange=null,this.cellAnchor=null),this.emit("selection-change",this.#o()),this.requestAfterRender(),!0;if(t==="cell"&&n)return queueMicrotask(()=>{this.selectedCell={row:this.grid._focusRow,col:this.grid._focusCol},this.emit("selection-change",this.#o()),this.requestAfterRender()}),!1;if(t==="row"&&(e.key==="ArrowUp"||e.key==="ArrowDown"))return queueMicrotask(()=>{this.selected.clear(),this.selected.add(this.grid._focusRow),this.lastSelected=this.grid._focusRow,this.emit("selection-change",this.#o()),this.requestAfterRender()}),!1;if(t==="range"&&n){const r=e.key==="Tab",s=e.shiftKey&&!r;return s&&!this.cellAnchor&&(this.cellAnchor={row:this.grid._focusRow,col:this.grid._focusCol}),this.pendingKeyboardUpdate={shiftKey:s},queueMicrotask(()=>this.requestAfterRender()),!1}if(t==="range"&&e.key==="a"&&(e.ctrlKey||e.metaKey)){const r=this.rows.length,s=this.columns.length;if(r>0&&s>0){const l={startRow:0,startCol:0,endRow:r-1,endCol:s-1};return this.ranges=[l],this.activeRange=l,this.emit("selection-change",this.#o()),this.requestAfterRender(),!0}}return!1}onCellMouseDown(e){if(this.config.mode!=="range"||e.rowIndex===void 0||e.colIndex===void 0||e.rowIndex<0)return;const t=this.columns[e.colIndex];if(t&&B(t)||e.originalEvent.shiftKey&&this.cellAnchor)return;this.isDragging=!0;const i=e.rowIndex,n=e.colIndex;this.cellAnchor={row:i,col:n},e.originalEvent.ctrlKey||e.originalEvent.metaKey||(this.ranges=[]);const s={startRow:i,startCol:n,endRow:i,endCol:n};return this.ranges.push(s),this.activeRange=s,this.emit("selection-change",this.#o()),this.requestAfterRender(),!0}onCellMouseMove(e){if(this.config.mode!=="range"||!this.isDragging||!this.cellAnchor||e.rowIndex===void 0||e.colIndex===void 0||e.rowIndex<0)return;let t=e.colIndex;const i=this.columns[t];if(i&&B(i)){const r=this.columns.findIndex(s=>!B(s));r>=0&&(t=r)}const n=Ke(this.cellAnchor,{row:e.rowIndex,col:t});return this.ranges.length>0?this.ranges[this.ranges.length-1]=n:this.ranges.push(n),this.activeRange=n,this.emit("selection-change",this.#o()),this.requestAfterRender(),!0}onCellMouseUp(e){if(this.config.mode==="range"&&this.isDragging)return this.isDragging=!1,!0}#e(){const e=this.gridElement;if(!e)return;const{mode:t}=this.config;e.querySelectorAll(".cell").forEach(r=>{r.classList.remove("selected","top","bottom","first","last")});const n=e.querySelectorAll(".data-grid-row");if(n.forEach(r=>{r.classList.remove("selected","row-focus")}),t==="row"&&(oe(e),n.forEach(r=>{const s=r.querySelector(".cell[data-row]"),l=me(s);l>=0&&this.selected.has(l)&&r.classList.add("selected","row-focus")})),t==="range"&&this.ranges.length>0){oe(e);const r=this.activeRange?ge(this.activeRange):null,s=this.columns.findIndex(a=>!B(a));this.columns.length-1,e.querySelectorAll(".cell[data-row][data-col]").forEach(a=>{const c=parseInt(a.getAttribute("data-row")??"-1",10),d=parseInt(a.getAttribute("data-col")??"-1",10);if(c>=0&&d>=0){const u=this.columns[d];if(u&&B(u))return;if(oi(c,d,this.ranges)&&(a.classList.add("selected"),r)){c===r.startRow&&a.classList.add("top"),c===r.endRow&&a.classList.add("bottom");const f=Math.max(r.startCol,s);d===f&&a.classList.add("first"),d===r.endCol&&a.classList.add("last")}}})}}afterRender(){const e=this.gridElement;if(!e)return;const t=e.children[0],{mode:i}=this.config;if(this.pendingKeyboardUpdate&&i==="range"){const{shiftKey:n}=this.pendingKeyboardUpdate;this.pendingKeyboardUpdate=null;const r=this.grid._focusRow,s=this.grid._focusCol;if(n&&this.cellAnchor){const l=Ke(this.cellAnchor,{row:r,col:s});this.ranges=[l],this.activeRange=l}else n||(this.ranges=[],this.activeRange=null,this.cellAnchor={row:r,col:s});this.emit("selection-change",this.#o())}this.grid.setAttribute("data-selection-mode",i),t&&t.classList.toggle("selecting",this.isDragging),this.#e()}onScrollRender(){this.#e()}getSelection(){return{mode:this.config.mode,ranges:this.#o().ranges,anchor:this.cellAnchor}}getSelectedCells(){return sr(this.ranges)}isCellSelected(e,t){return oi(e,t,this.ranges)}clearSelection(){this.selectedCell=null,this.selected.clear(),this.anchor=null,this.ranges=[],this.activeRange=null,this.cellAnchor=null,this.emit("selection-change",{mode:this.config.mode,ranges:[]}),this.requestAfterRender()}setRanges(e){this.ranges=e.map(t=>({startRow:t.from.row,startCol:t.from.col,endRow:t.to.row,endCol:t.to.col})),this.activeRange=this.ranges.length>0?this.ranges[this.ranges.length-1]:null,this.emit("selection-change",{mode:this.config.mode,ranges:ii(this.ranges)}),this.requestAfterRender()}#o(){return ar(this.config.mode,{selectedCell:this.selectedCell,selected:this.selected,ranges:this.ranges},this.columns.length)}}function pe(o,e){return Math.floor(o/e)}function dr(o,e){return{start:o*e,end:(o+1)*e}}function ur(o,e,t){const i=pe(o,t),n=pe(e-1,t),r=[];for(let s=i;s<=n;s++)r.push(s);return r}async function ni(o,e,t,i){const n=dr(e,t);return o.getRows({startRow:n.start,endRow:n.end,sortModel:i.sortModel,filterModel:i.filterModel})}function hr(o,e,t){const i=pe(o,e),n=t.get(i);if(!n)return;const r=o%e;return n[r]}const fr=100;class gr extends L{name="serverSide";get defaultConfig(){return{pageSize:100,cacheBlockSize:100,maxConcurrentRequests:2}}dataSource=null;totalRowCount=0;loadedBlocks=new Map;loadingBlocks=new Set;lastRequestId=0;scrollDebounceTimer;detach(){this.dataSource=null,this.totalRowCount=0,this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.lastRequestId=0,this.scrollDebounceTimer&&(clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=void 0)}loadRequiredBlocks(){if(!this.dataSource)return;const e=this.grid,t=this.config.cacheBlockSize??100,i={startRow:e._virtualization.start,endRow:e._virtualization.end},n=ur(i.startRow,i.endRow,t);for(const r of n)if(!(this.loadedBlocks.has(r)||this.loadingBlocks.has(r))){if(this.loadingBlocks.size>=(this.config.maxConcurrentRequests??2))break;this.loadingBlocks.add(r),ni(this.dataSource,r,t,{}).then(s=>{this.loadedBlocks.set(r,s.rows),this.totalRowCount=s.totalRowCount,this.loadingBlocks.delete(r),this.requestRender(),this.loadRequiredBlocks()}).catch(()=>{this.loadingBlocks.delete(r)})}}processRows(e){if(!this.dataSource)return[...e];const t=[];for(let i=0;i<this.totalRowCount;i++){const n=hr(i,this.config.cacheBlockSize??100,this.loadedBlocks);t.push(n??{__loading:!0,__index:i})}return t}onScroll(e){this.dataSource&&(this.loadRequiredBlocks(),this.scrollDebounceTimer&&clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=setTimeout(()=>{this.loadRequiredBlocks()},fr))}setDataSource(e){this.dataSource=e,this.loadedBlocks.clear(),this.loadingBlocks.clear();const t=this.config.cacheBlockSize??100;ni(e,0,t,{}).then(i=>{this.loadedBlocks.set(0,i.rows),this.totalRowCount=i.totalRowCount,this.requestRender()})}refresh(){this.dataSource&&(this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.requestRender())}purgeCache(){this.loadedBlocks.clear()}getTotalRowCount(){return this.totalRowCount}isRowLoaded(e){const t=this.config.cacheBlockSize??100,i=pe(e,t);return this.loadedBlocks.has(i)}getLoadedBlockCount(){return this.loadedBlocks.size}}function ri(o,e,t){return o.id!==void 0?String(o.id):t?`${t}-${e}`:String(e)}function Be(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function We(o,e,t=null,i=0){const n=e.childrenField??"children",r=new Set;for(let s=0;s<o.length;s++){const l=o[s],a=ri(l,s,t),c=l[n];if(Array.isArray(c)&&c.length>0){r.add(a);const d=We(c,e,a,i+1);for(const u of d)r.add(u)}}return r}function pr(){return new Set}function si(o,e,t,i=null,n=0){const r=t.childrenField??"children";for(let s=0;s<o.length;s++){const l=o[s],a=ri(l,s,i);if(a===e)return[a];const c=l[r];if(Array.isArray(c)&&c.length>0){const d=si(c,e,t,a,n+1);if(d)return[a,...d]}}return null}function wr(o,e,t,i){const n=si(o,e,t);if(!n)return i;const r=new Set(i);for(let s=0;s<n.length-1;s++)r.add(n[s]);return r}function li(o,e="children"){if(!Array.isArray(o)||o.length===0)return!1;for(const t of o){if(!t)continue;const i=t[e];if(Array.isArray(i)&&i.length>0)return!0}return!1}function mr(o){if(!Array.isArray(o)||o.length===0)return null;const e=["children","items","nodes","subRows","nested"];for(const t of o)if(!(!t||typeof t!="object"))for(const i of e){const n=t[i];if(Array.isArray(n)&&n.length>0)return i}return null}const br="@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:flex-start}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}tbw-grid .tree-cell-wrapper{display:inline-flex;align-items:center;padding-left:calc(var(--tbw-tree-depth, 0) * var(--tbw-tree-indent-width, var(--tbw-tree-toggle-size, 1.25em)))}tbw-grid .tree-expander{display:flex;align-items:center;justify-content:flex-start;width:100%;height:100%;box-sizing:border-box}tbw-grid .tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-tree-toggle-size, 1.25em);height:var(--tbw-tree-toggle-size, 1.25em);flex-shrink:0}tbw-grid .tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}tbw-grid .tree-spacer{width:var(--tbw-tree-toggle-size, 1.25em);display:inline-block;flex-shrink:0}tbw-grid .data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}tbw-grid .data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}}";class vr extends L{name="tree";styles=br;get defaultConfig(){return{childrenField:"children",autoDetect:!0,defaultExpanded:!1,indentWidth:20,showExpandIcons:!0,animation:"slide"}}expandedKeys=new Set;initialExpansionDone=!1;flattenedRows=[];rowKeyMap=new Map;previousVisibleKeys=new Set;keysToAnimate=new Set;sortState=null;detach(){this.expandedKeys.clear(),this.initialExpansionDone=!1,this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),this.keysToAnimate.clear(),this.sortState=null}get animationStyle(){return this.isAnimationEnabled?this.config.animation??"slide":!1}detect(e){if(!this.config.autoDetect)return!1;const t=e,i=this.config.childrenField??mr(t)??"children";return li(t,i)}processRows(e){const t=this.config.childrenField??"children",i=e;if(!li(i,t))return this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),[...e];let n=this.withStableKeys(i);this.sortState&&(n=this.sortTree(n,this.sortState.field,this.sortState.direction)),this.config.defaultExpanded&&!this.initialExpansionDone&&(this.expandedKeys=We(n,this.config),this.initialExpansionDone=!0),this.flattenedRows=this.flattenTree(n,this.expandedKeys),this.rowKeyMap.clear(),this.keysToAnimate.clear();const r=new Set;for(const s of this.flattenedRows)this.rowKeyMap.set(s.key,s),r.add(s.key),!this.previousVisibleKeys.has(s.key)&&s.depth>0&&this.keysToAnimate.add(s.key);return this.previousVisibleKeys=r,this.flattenedRows.map(s=>({...s.data,__treeKey:s.key,__treeDepth:s.depth,__treeHasChildren:s.hasChildren,__treeExpanded:s.isExpanded}))}withStableKeys(e,t=null){const i=this.config.childrenField??"children";return e.map((n,r)=>{const s=n.__stableKey,l=n.id!==void 0?String(n.id):s??(t?`${t}-${r}`:String(r)),a=n[i],c=Array.isArray(a)&&a.length>0;return{...n,__stableKey:l,...c?{[i]:this.withStableKeys(a,l)}:{}}})}flattenTree(e,t,i=0){const n=this.config.childrenField??"children",r=[];for(const s of e){const a=s.__stableKey??String(s.id??"?"),c=s[n],d=Array.isArray(c)&&c.length>0,u=t.has(a);r.push({key:a,data:s,depth:i,hasChildren:d,isExpanded:u,parentKey:i>0&&a.substring(0,a.lastIndexOf("-"))||null}),d&&u&&r.push(...this.flattenTree(c,t,i+1))}return r}sortTree(e,t,i){const n=this.config.childrenField??"children";return[...e].sort((s,l)=>{const a=s[t],c=l[t];return a==null&&c==null?0:a==null?-1:c==null?1:a>c?i:a<c?-i:0}).map(s=>{const l=s[n];return Array.isArray(l)&&l.length>0?{...s,[n]:this.sortTree(l,t,i)}:s})}processColumns(e){if(this.flattenedRows.length===0)return[...e];const t=[...e];if(t.length===0)return t;const i=t[0],n=i.viewRenderer,r=()=>this.config,s=this.setIcon.bind(this),l=this.resolveIcon.bind(this),a=c=>{const{row:d,value:u}=c,{showExpandIcons:h=!0,indentWidth:f}=r(),p=d,g=p.__treeDepth??0,w=document.createElement("span");if(w.className="tree-cell-wrapper",w.style.setProperty("--tbw-tree-depth",String(g)),f!==void 0&&w.style.setProperty("--tbw-tree-indent-width",`${f}px`),h)if(p.__treeHasChildren){const y=document.createElement("span");y.className=`tree-toggle${p.__treeExpanded?" expanded":""}`,s(y,l(p.__treeExpanded?"collapse":"expand")),y.setAttribute("data-tree-key",String(p.__treeKey??"")),w.appendChild(y)}else{const y=document.createElement("span");y.className="tree-spacer",w.appendChild(y)}const m=document.createElement("span");if(m.className="tree-content",n){const y=n(c);y instanceof Node?m.appendChild(y):typeof y=="string"&&(m.innerHTML=y)}else m.textContent=u!=null?String(u):"";return w.appendChild(m),w};return t[0]={...i,viewRenderer:a},t}onCellClick(e){const t=e.originalEvent?.target;if(!t?.classList.contains("tree-toggle"))return!1;const i=t.getAttribute("data-tree-key");if(!i)return!1;const n=this.rowKeyMap.get(i);return n?(this.expandedKeys=Be(this.expandedKeys,i),this.emit("tree-expand",{key:i,row:n.data,expanded:this.expandedKeys.has(i),depth:n.depth}),this.requestRender(),!0):!1}onKeyDown(e){if(e.key!==" ")return;const t=this.grid._focusRow,i=this.flattenedRows[t];if(i?.hasChildren)return e.preventDefault(),this.expandedKeys=Be(this.expandedKeys,i.key),this.emit("tree-expand",{key:i.key,row:i.data,expanded:this.expandedKeys.has(i.key),depth:i.depth}),this.requestRenderWithFocus(),!0}onHeaderClick(e){if(this.flattenedRows.length===0||!e.column.sortable)return!1;const{field:t}=e.column;!this.sortState||this.sortState.field!==t?this.sortState={field:t,direction:1}:this.sortState.direction===1?this.sortState={field:t,direction:-1}:this.sortState=null;const i=this.grid;return i._sortState!==void 0&&(i._sortState=this.sortState?{...this.sortState}:null),this.emit("sort-change",{field:t,direction:this.sortState?.direction??0}),this.requestRender(),!0}afterRender(){const e=this.animationStyle;if(e===!1||this.keysToAnimate.size===0)return;const t=this.gridElement?.querySelector(".rows");if(!t)return;const i=e==="fade"?"tbw-tree-fade-in":"tbw-tree-slide-in";for(const n of t.querySelectorAll(".data-grid-row")){const r=n.querySelector(".cell[data-row]"),s=r?parseInt(r.getAttribute("data-row")??"-1",10):-1,l=this.flattenedRows[s]?.key;l&&this.keysToAnimate.has(l)&&(n.classList.add(i),n.addEventListener("animationend",()=>n.classList.remove(i),{once:!0}))}this.keysToAnimate.clear()}expand(e){this.expandedKeys.add(e),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}toggle(e){this.expandedKeys=Be(this.expandedKeys,e),this.requestRender()}expandAll(){this.expandedKeys=We(this.rows,this.config),this.requestRender()}collapseAll(){this.expandedKeys=pr(),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}getExpandedKeys(){return[...this.expandedKeys]}getFlattenedRows(){return[...this.flattenedRows]}getRowByKey(e){return this.rowKeyMap.get(e)?.data}expandToKey(e){this.expandedKeys=wr(this.rows,e,this.config,this.expandedKeys),this.requestRender()}}function yr(o,e,t){const i=[...o.undoStack,e];for(;i.length>t;)i.shift();return{undoStack:i,redoStack:[]}}function ai(o){if(o.undoStack.length===0)return{newState:o,action:null};const e=[...o.undoStack],t=e.pop();return t?{newState:{undoStack:e,redoStack:[...o.redoStack,t]},action:t}:{newState:o,action:null}}function ci(o){if(o.redoStack.length===0)return{newState:o,action:null};const e=[...o.redoStack],t=e.pop();return t?{newState:{undoStack:[...o.undoStack,t],redoStack:e},action:t}:{newState:o,action:null}}function Cr(o){return o.undoStack.length>0}function xr(o){return o.redoStack.length>0}function Rr(){return{undoStack:[],redoStack:[]}}function Er(o,e,t,i){return{type:"cell-edit",rowIndex:o,field:e,oldValue:t,newValue:i,timestamp:Date.now()}}class Sr extends L{static dependencies=[{name:"editing",required:!0,reason:"UndoRedoPlugin tracks cell edit history"}];name="undoRedo";get defaultConfig(){return{maxHistorySize:100}}undoStack=[];redoStack=[];detach(){this.undoStack=[],this.redoStack=[]}onKeyDown(e){const t=(e.ctrlKey||e.metaKey)&&e.key==="z"&&!e.shiftKey,i=(e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="z"&&e.shiftKey);if(t){const n=ai({undoStack:this.undoStack,redoStack:this.redoStack});if(n.action){const r=this.rows;r[n.action.rowIndex]&&(r[n.action.rowIndex][n.action.field]=n.action.oldValue),this.undoStack=n.newState.undoStack,this.redoStack=n.newState.redoStack,this.emit("undo",{action:n.action,type:"undo"}),this.requestRender()}return!0}if(i){const n=ci({undoStack:this.undoStack,redoStack:this.redoStack});if(n.action){const r=this.rows;r[n.action.rowIndex]&&(r[n.action.rowIndex][n.action.field]=n.action.newValue),this.undoStack=n.newState.undoStack,this.redoStack=n.newState.redoStack,this.emit("redo",{action:n.action,type:"redo"}),this.requestRender()}return!0}return!1}recordEdit(e,t,i,n){const r=Er(e,t,i,n),s=yr({undoStack:this.undoStack,redoStack:this.redoStack},r,this.config.maxHistorySize??100);this.undoStack=s.undoStack,this.redoStack=s.redoStack}undo(){const e=ai({undoStack:this.undoStack,redoStack:this.redoStack});if(e.action){const t=this.rows;t[e.action.rowIndex]&&(t[e.action.rowIndex][e.action.field]=e.action.oldValue),this.undoStack=e.newState.undoStack,this.redoStack=e.newState.redoStack,this.requestRender()}return e.action}redo(){const e=ci({undoStack:this.undoStack,redoStack:this.redoStack});if(e.action){const t=this.rows;t[e.action.rowIndex]&&(t[e.action.rowIndex][e.action.field]=e.action.newValue),this.undoStack=e.newState.undoStack,this.redoStack=e.newState.redoStack,this.requestRender()}return e.action}canUndo(){return Cr({undoStack:this.undoStack,redoStack:this.redoStack})}canRedo(){return xr({undoStack:this.undoStack,redoStack:this.redoStack})}clearHistory(){const e=Rr();this.undoStack=e.undoStack,this.redoStack=e.redoStack}getUndoStack(){return[...this.undoStack]}getRedoStack(){return[...this.redoStack]}}const _r='@layer tbw-plugins{.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem))}.tbw-visibility-row{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-menu-item-padding, .375rem .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);border-radius:var(--tbw-border-radius, .25rem);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted, #888)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted, #888);font-size:var(--tbw-font-size-2xs, .625rem);letter-spacing:-2px;-webkit-user-select:none;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg, #1f2937)}.tbw-visibility-label{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-show-all{margin:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding, .5rem .75rem);border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, .25rem);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}}';function di(o){const e=o.meta??{};return e.lockPosition!==!0&&e.suppressMovable!==!0}class U extends L{static dependencies=[{name:"reorder",required:!1,reason:"Enables drag-to-reorder columns in visibility panel"}];name="visibility";static PANEL_ID="columns";styles=_r;get defaultConfig(){return{allowHideAll:!1}}columnListElement=null;isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;clearDragClasses(e){e.querySelectorAll(".tbw-visibility-row").forEach(t=>{t.classList.remove("dragging","drop-target","drop-before","drop-after")})}detach(){this.columnListElement=null,this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}getToolPanel(){return{id:U.PANEL_ID,title:"Columns",icon:"☰",tooltip:"Column visibility",order:100,render:e=>this.renderPanelContent(e)}}show(){this.grid.openToolPanel(),this.grid.expandedToolPanelSections.includes(U.PANEL_ID)||this.grid.toggleToolPanelSection(U.PANEL_ID)}hide(){this.grid.closeToolPanel()}toggle(){this.grid.isToolPanelOpen||this.grid.openToolPanel(),this.grid.toggleToolPanelSection(U.PANEL_ID)}isColumnVisible(e){return this.grid.isColumnVisible(e)}setColumnVisible(e,t){this.grid.setColumnVisible(e,t)}getVisibleColumns(){return this.grid.getAllColumns().filter(e=>e.visible).map(e=>e.field)}getHiddenColumns(){return this.grid.getAllColumns().filter(e=>!e.visible).map(e=>e.field)}showAll(){this.grid.showAllColumns()}toggleColumn(e){this.grid.toggleColumnVisibility(e)}showColumn(e){this.setColumnVisible(e,!0)}hideColumn(e){this.setColumnVisible(e,!1)}getAllColumns(){return this.grid.getAllColumns()}isPanelVisible(){return this.grid.isToolPanelOpen&&this.grid.expandedToolPanelSections.includes(U.PANEL_ID)}renderPanelContent(e){const t=document.createElement("div");t.className="tbw-visibility-content";const i=document.createElement("div");i.className="tbw-visibility-list",t.appendChild(i);const n=document.createElement("button");return n.className="tbw-visibility-show-all",n.textContent="Show All",n.addEventListener("click",()=>{this.grid.showAllColumns(),this.rebuildToggles(i)}),t.appendChild(n),this.columnListElement=i,this.rebuildToggles(i),e.appendChild(t),()=>{this.columnListElement=null,t.remove()}}hasReorderPlugin(){const e=this.grid?.getPluginByName?.("reorder");return!!(e&&typeof e.moveColumn=="function")}rebuildToggles(e){const t=this.hasReorderPlugin();e.innerHTML="";const i=this.grid.getAllColumns().filter(n=>!n.utility);for(let n=0;n<i.length;n++){const r=i[n],s=r.header||r.field,l=document.createElement("div");l.className=r.lockVisible?"tbw-visibility-row locked":"tbw-visibility-row",l.setAttribute("data-field",r.field),l.setAttribute("data-index",String(n)),t&&di(r)&&(l.draggable=!0,l.classList.add("reorderable"),this.setupDragListeners(l,r.field,n,e));const a=document.createElement("label");a.className="tbw-visibility-label";const c=document.createElement("input");c.type="checkbox",c.checked=r.visible,c.disabled=r.lockVisible??!1,c.addEventListener("change",()=>{this.grid.toggleColumnVisibility(r.field),setTimeout(()=>this.rebuildToggles(e),0)});const d=document.createElement("span");if(d.textContent=s,a.appendChild(c),a.appendChild(d),t&&di(r)){const u=document.createElement("span");u.className="tbw-visibility-handle",this.setIcon(u,this.resolveIcon("dragHandle")),u.title="Drag to reorder",l.appendChild(u)}l.appendChild(a),e.appendChild(l)}}setupDragListeners(e,t,i,n){e.addEventListener("dragstart",r=>{this.isDragging=!0,this.draggedField=t,this.draggedIndex=i,r.dataTransfer&&(r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",t)),e.classList.add("dragging")}),e.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.clearDragClasses(n)}),e.addEventListener("dragover",r=>{if(r.preventDefault(),!this.isDragging||this.draggedField===t)return;const s=e.getBoundingClientRect(),l=s.top+s.height/2;this.dropIndex=r.clientY<l?i:i+1,n.querySelectorAll(".tbw-visibility-row").forEach(a=>{a!==e&&a.classList.remove("drop-target","drop-before","drop-after")}),e.classList.add("drop-target"),e.classList.toggle("drop-before",r.clientY<l),e.classList.toggle("drop-after",r.clientY>=l)}),e.addEventListener("dragleave",()=>{e.classList.remove("drop-target","drop-before","drop-after")}),e.addEventListener("drop",r=>{r.preventDefault();const s=this.draggedField,l=this.draggedIndex,a=this.dropIndex;if(!this.isDragging||s===null||l===null||a===null)return;const c=a>l?a-1:a;if(c!==l){const d=this.grid.getAllColumns(),h=d.filter(g=>!g.utility)[c]?.field,f=h?d.findIndex(g=>g.field===h):d.length,p={field:s,fromIndex:l,toIndex:f};this.emit("column-reorder-request",p),setTimeout(()=>{this.rebuildToggles(n)},0)}})}}C.BaseGridPlugin=L,C.ClipboardPlugin=Ro,C.ColumnVirtualizationPlugin=Ao,C.ContextMenuPlugin=ko,C.DEFAULT_ANIMATION_CONFIG=Ve,C.DEFAULT_GRID_ICONS=F,C.DGEvents=mo,C.DataGridElement=I,C.EditingPlugin=Go,C.ExportPlugin=$o,C.FilteringPlugin=q,C.FitModeEnum=Y,C.GridCSSVars=go,C.GridClasses=H,C.GridDataAttrs=re,C.GridElement=I,C.GridSelectors=fo,C.GroupingColumnsPlugin=rn,C.GroupingRowsPlugin=fn,C.MasterDetailPlugin=Ne,C.MultiSortPlugin=Rn,C.PLUGIN_QUERIES=Se,C.PinnedColumnsPlugin=_n,C.PinnedRowsPlugin=Pn,C.PivotPlugin=$,C.PluginEvents=bo,C.PluginManager=Et,C.ROW_DRAG_HANDLE_FIELD=ti,C.RenderPhase=D,C.ReorderPlugin=Jn,C.ResponsivePlugin=er,C.RowReorderPlugin=ir,C.SelectionPlugin=cr,C.ServerSidePlugin=gr,C.TreePlugin=vr,C.UndoRedoPlugin=Sr,C.VisibilityPlugin=U,C.builtInSort=rt,C.createGrid=po,C.defaultComparator=nt,C.defaultEditorFor=Ht,C.defaultPasteHandler=At,C.queryGrid=wo,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})}));
|
|
79
|
+
→ The "triggerOn" option only affects "cell" and "row" selection modes.`,check:e=>e.mode==="range"&&e.triggerOn==="dblclick"}]};name="selection";styles=br;get defaultConfig(){return{mode:"cell",triggerOn:"click"}}selected=new Set;lastSelected=null;anchor=null;ranges=[];activeRange=null;cellAnchor=null;isDragging=!1;pendingKeyboardUpdate=null;selectedCell=null;checkSelectable(e,t){const{isSelectable:i}=this.config;if(!i)return!0;const n=this.rows[e];if(!n)return!1;const r=t!==void 0?this.columns[t]:void 0;return i(n,e,r,t)}isRowSelectable(e){return this.checkSelectable(e)}isCellSelectable(e,t){return this.checkSelectable(e,t)}detach(){this.selected.clear(),this.ranges=[],this.activeRange=null,this.cellAnchor=null,this.isDragging=!1,this.selectedCell=null,this.pendingKeyboardUpdate=null}onCellClick(e){const{rowIndex:t,colIndex:i,originalEvent:n}=e,{mode:r,triggerOn:s="click"}=this.config;if(n.type!==s)return!1;const l=this.columns[i],a=l&&W(l);if(r==="cell")return a||!this.isCellSelectable(t,i)||(this.selectedCell={row:t,col:i},this.emit("selection-change",this.#o()),this.requestAfterRender()),!1;if(r==="row")return this.isRowSelectable(t)&&(this.selected.clear(),this.selected.add(t),this.lastSelected=t,this.emit("selection-change",this.#o()),this.requestAfterRender()),!1;if(r==="range"){if(a||!this.isCellSelectable(t,i))return!1;const c=n.shiftKey,d=n.ctrlKey||n.metaKey;if(c&&this.cellAnchor){const u=Ve(this.cellAnchor,{row:t,col:i});d?this.ranges.length>0?this.ranges[this.ranges.length-1]=u:this.ranges.push(u):this.ranges=[u],this.activeRange=u}else if(d){const u={startRow:t,startCol:i,endRow:t,endCol:i};this.ranges.push(u),this.activeRange=u,this.cellAnchor={row:t,col:i}}else{const u={startRow:t,startCol:i,endRow:t,endCol:i};this.ranges=[u],this.activeRange=u,this.cellAnchor={row:t,col:i}}return this.emit("selection-change",this.#o()),this.requestAfterRender(),!1}return!1}onKeyDown(e){const{mode:t}=this.config,n=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Tab","Home","End","PageUp","PageDown"].includes(e.key);if(e.key==="Escape")return t==="cell"?this.selectedCell=null:t==="row"?(this.selected.clear(),this.anchor=null):t==="range"&&(this.ranges=[],this.activeRange=null,this.cellAnchor=null),this.emit("selection-change",this.#o()),this.requestAfterRender(),!0;if(t==="cell"&&n)return queueMicrotask(()=>{const r=this.grid._focusRow,s=this.grid._focusCol;this.isCellSelectable(r,s)?this.selectedCell={row:r,col:s}:this.selectedCell=null,this.emit("selection-change",this.#o()),this.requestAfterRender()}),!1;if(t==="row"&&(e.key==="ArrowUp"||e.key==="ArrowDown"))return queueMicrotask(()=>{const r=this.grid._focusRow;this.isRowSelectable(r)?(this.selected.clear(),this.selected.add(r),this.lastSelected=r):this.selected.clear(),this.emit("selection-change",this.#o()),this.requestAfterRender()}),!1;if(t==="range"&&n){const r=e.key==="Tab",s=e.shiftKey&&!r;return s&&!this.cellAnchor&&(this.cellAnchor={row:this.grid._focusRow,col:this.grid._focusCol}),this.pendingKeyboardUpdate={shiftKey:s},queueMicrotask(()=>this.requestAfterRender()),!1}if(t==="range"&&e.key==="a"&&(e.ctrlKey||e.metaKey)){const r=this.rows.length,s=this.columns.length;if(r>0&&s>0){const l={startRow:0,startCol:0,endRow:r-1,endCol:s-1};return this.ranges=[l],this.activeRange=l,this.emit("selection-change",this.#o()),this.requestAfterRender(),!0}}return!1}onCellMouseDown(e){if(this.config.mode!=="range"||e.rowIndex===void 0||e.colIndex===void 0||e.rowIndex<0)return;const t=this.columns[e.colIndex];if(t&&W(t)||!this.isCellSelectable(e.rowIndex,e.colIndex)||e.originalEvent.shiftKey&&this.cellAnchor)return;this.isDragging=!0;const i=e.rowIndex,n=e.colIndex;this.cellAnchor={row:i,col:n},e.originalEvent.ctrlKey||e.originalEvent.metaKey||(this.ranges=[]);const s={startRow:i,startCol:n,endRow:i,endCol:n};return this.ranges.push(s),this.activeRange=s,this.emit("selection-change",this.#o()),this.requestAfterRender(),!0}onCellMouseMove(e){if(this.config.mode!=="range"||!this.isDragging||!this.cellAnchor||e.rowIndex===void 0||e.colIndex===void 0||e.rowIndex<0)return;let t=e.colIndex;const i=this.columns[t];if(i&&W(i)){const r=this.columns.findIndex(s=>!W(s));r>=0&&(t=r)}const n=Ve(this.cellAnchor,{row:e.rowIndex,col:t});return this.ranges.length>0?this.ranges[this.ranges.length-1]=n:this.ranges.push(n),this.activeRange=n,this.emit("selection-change",this.#o()),this.requestAfterRender(),!0}onCellMouseUp(e){if(this.config.mode==="range"&&this.isDragging)return this.isDragging=!1,!0}#e(){const e=this.gridElement;if(!e)return;const{mode:t}=this.config,i=!!this.config.isSelectable;e.querySelectorAll(".cell").forEach(s=>{s.classList.remove("selected","top","bottom","first","last"),i&&s.removeAttribute("data-selectable")});const r=e.querySelectorAll(".data-grid-row");if(r.forEach(s=>{s.classList.remove("selected","row-focus"),i&&s.removeAttribute("data-selectable")}),t==="row"&&(ne(e),r.forEach(s=>{const l=s.querySelector(".cell[data-row]"),a=be(l);a>=0&&(i&&!this.isRowSelectable(a)&&s.setAttribute("data-selectable","false"),this.selected.has(a)&&s.classList.add("selected","row-focus"))})),(t==="cell"||t==="range")&&i&&e.querySelectorAll(".cell[data-row][data-col]").forEach(l=>{const a=parseInt(l.getAttribute("data-row")??"-1",10),c=parseInt(l.getAttribute("data-col")??"-1",10);a>=0&&c>=0&&(this.isCellSelectable(a,c)||l.setAttribute("data-selectable","false"))}),t==="range"&&this.ranges.length>0){ne(e);const s=this.activeRange?pe(this.activeRange):null,l=this.columns.findIndex(c=>!W(c));this.columns.length-1,e.querySelectorAll(".cell[data-row][data-col]").forEach(c=>{const d=parseInt(c.getAttribute("data-row")??"-1",10),u=parseInt(c.getAttribute("data-col")??"-1",10);if(d>=0&&u>=0){const h=this.columns[u];if(h&&W(h))return;if(ai(d,u,this.ranges)&&(c.classList.add("selected"),s)){d===s.startRow&&c.classList.add("top"),d===s.endRow&&c.classList.add("bottom");const p=Math.max(s.startCol,l);u===p&&c.classList.add("first"),u===s.endCol&&c.classList.add("last")}}})}}afterRender(){const e=this.gridElement;if(!e)return;const t=e.children[0],{mode:i}=this.config;if(this.pendingKeyboardUpdate&&i==="range"){const{shiftKey:n}=this.pendingKeyboardUpdate;this.pendingKeyboardUpdate=null;const r=this.grid._focusRow,s=this.grid._focusCol;if(n&&this.cellAnchor){const l=Ve(this.cellAnchor,{row:r,col:s});this.ranges=[l],this.activeRange=l}else n||(this.ranges=[],this.activeRange=null,this.cellAnchor={row:r,col:s});this.emit("selection-change",this.#o())}this.grid.setAttribute("data-selection-mode",i),t&&t.classList.toggle("selecting",this.isDragging),this.#e()}onScrollRender(){this.#e()}getSelection(){return{mode:this.config.mode,ranges:this.#o().ranges,anchor:this.cellAnchor}}getSelectedCells(){return mr(this.ranges)}isCellSelected(e,t){return ai(e,t,this.ranges)}clearSelection(){this.selectedCell=null,this.selected.clear(),this.anchor=null,this.ranges=[],this.activeRange=null,this.cellAnchor=null,this.emit("selection-change",{mode:this.config.mode,ranges:[]}),this.requestAfterRender()}setRanges(e){this.ranges=e.map(t=>({startRow:t.from.row,startCol:t.from.col,endRow:t.to.row,endCol:t.to.col})),this.activeRange=this.ranges.length>0?this.ranges[this.ranges.length-1]:null,this.emit("selection-change",{mode:this.config.mode,ranges:li(this.ranges)}),this.requestAfterRender()}#o(){return vr(this.config.mode,{selectedCell:this.selectedCell,selected:this.selected,ranges:this.ranges},this.columns.length)}}function we(o,e){return Math.floor(o/e)}function Cr(o,e){return{start:o*e,end:(o+1)*e}}function xr(o,e,t){const i=we(o,t),n=we(e-1,t),r=[];for(let s=i;s<=n;s++)r.push(s);return r}async function ci(o,e,t,i){const n=Cr(e,t);return o.getRows({startRow:n.start,endRow:n.end,sortModel:i.sortModel,filterModel:i.filterModel})}function Rr(o,e,t){const i=we(o,e),n=t.get(i);if(!n)return;const r=o%e;return n[r]}const Er=100;class Sr extends D{name="serverSide";get defaultConfig(){return{pageSize:100,cacheBlockSize:100,maxConcurrentRequests:2}}dataSource=null;totalRowCount=0;loadedBlocks=new Map;loadingBlocks=new Set;lastRequestId=0;scrollDebounceTimer;detach(){this.dataSource=null,this.totalRowCount=0,this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.lastRequestId=0,this.scrollDebounceTimer&&(clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=void 0)}loadRequiredBlocks(){if(!this.dataSource)return;const e=this.grid,t=this.config.cacheBlockSize??100,i={startRow:e._virtualization.start,endRow:e._virtualization.end},n=xr(i.startRow,i.endRow,t);for(const r of n)if(!(this.loadedBlocks.has(r)||this.loadingBlocks.has(r))){if(this.loadingBlocks.size>=(this.config.maxConcurrentRequests??2))break;this.loadingBlocks.add(r),ci(this.dataSource,r,t,{}).then(s=>{this.loadedBlocks.set(r,s.rows),this.totalRowCount=s.totalRowCount,this.loadingBlocks.delete(r),this.requestRender(),this.loadRequiredBlocks()}).catch(()=>{this.loadingBlocks.delete(r)})}}processRows(e){if(!this.dataSource)return[...e];const t=[];for(let i=0;i<this.totalRowCount;i++){const n=Rr(i,this.config.cacheBlockSize??100,this.loadedBlocks);t.push(n??{__loading:!0,__index:i})}return t}onScroll(e){this.dataSource&&(this.loadRequiredBlocks(),this.scrollDebounceTimer&&clearTimeout(this.scrollDebounceTimer),this.scrollDebounceTimer=setTimeout(()=>{this.loadRequiredBlocks()},Er))}setDataSource(e){this.dataSource=e,this.loadedBlocks.clear(),this.loadingBlocks.clear();const t=this.config.cacheBlockSize??100;ci(e,0,t,{}).then(i=>{this.loadedBlocks.set(0,i.rows),this.totalRowCount=i.totalRowCount,this.requestRender()})}refresh(){this.dataSource&&(this.loadedBlocks.clear(),this.loadingBlocks.clear(),this.requestRender())}purgeCache(){this.loadedBlocks.clear()}getTotalRowCount(){return this.totalRowCount}isRowLoaded(e){const t=this.config.cacheBlockSize??100,i=we(e,t);return this.loadedBlocks.has(i)}getLoadedBlockCount(){return this.loadedBlocks.size}}function di(o,e,t){return o.id!==void 0?String(o.id):t?`${t}-${e}`:String(e)}function $e(o,e){const t=new Set(o);return t.has(e)?t.delete(e):t.add(e),t}function Ue(o,e,t=null,i=0){const n=e.childrenField??"children",r=new Set;for(let s=0;s<o.length;s++){const l=o[s],a=di(l,s,t),c=l[n];if(Array.isArray(c)&&c.length>0){r.add(a);const d=Ue(c,e,a,i+1);for(const u of d)r.add(u)}}return r}function _r(){return new Set}function ui(o,e,t,i=null,n=0){const r=t.childrenField??"children";for(let s=0;s<o.length;s++){const l=o[s],a=di(l,s,i);if(a===e)return[a];const c=l[r];if(Array.isArray(c)&&c.length>0){const d=ui(c,e,t,a,n+1);if(d)return[a,...d]}}return null}function Ar(o,e,t,i){const n=ui(o,e,t);if(!n)return i;const r=new Set(i);for(let s=0;s<n.length-1;s++)r.add(n[s]);return r}function hi(o,e="children"){if(!Array.isArray(o)||o.length===0)return!1;for(const t of o){if(!t)continue;const i=t[e];if(Array.isArray(i)&&i.length>0)return!0}return!1}function kr(o){if(!Array.isArray(o)||o.length===0)return null;const e=["children","items","nodes","subRows","nested"];for(const t of o)if(!(!t||typeof t!="object"))for(const i of e){const n=t[i];if(Array.isArray(n)&&n.length>0)return i}return null}const Tr="@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:flex-start}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}tbw-grid .tree-cell-wrapper{display:inline-flex;align-items:center;padding-left:calc(var(--tbw-tree-depth, 0) * var(--tbw-tree-indent-width, var(--tbw-tree-toggle-size, 1.25em)))}tbw-grid .tree-expander{display:flex;align-items:center;justify-content:flex-start;width:100%;height:100%;box-sizing:border-box}tbw-grid .tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-tree-toggle-size, 1.25em);height:var(--tbw-tree-toggle-size, 1.25em);flex-shrink:0}tbw-grid .tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}tbw-grid .tree-spacer{width:var(--tbw-tree-toggle-size, 1.25em);display:inline-block;flex-shrink:0}tbw-grid .data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}tbw-grid .data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}}";class Pr extends D{name="tree";styles=Tr;get defaultConfig(){return{childrenField:"children",autoDetect:!0,defaultExpanded:!1,indentWidth:20,showExpandIcons:!0,animation:"slide"}}expandedKeys=new Set;initialExpansionDone=!1;flattenedRows=[];rowKeyMap=new Map;previousVisibleKeys=new Set;keysToAnimate=new Set;sortState=null;detach(){this.expandedKeys.clear(),this.initialExpansionDone=!1,this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),this.keysToAnimate.clear(),this.sortState=null}get animationStyle(){return this.isAnimationEnabled?this.config.animation??"slide":!1}detect(e){if(!this.config.autoDetect)return!1;const t=e,i=this.config.childrenField??kr(t)??"children";return hi(t,i)}processRows(e){const t=this.config.childrenField??"children",i=e;if(!hi(i,t))return this.flattenedRows=[],this.rowKeyMap.clear(),this.previousVisibleKeys.clear(),[...e];let n=this.withStableKeys(i);this.sortState&&(n=this.sortTree(n,this.sortState.field,this.sortState.direction)),this.config.defaultExpanded&&!this.initialExpansionDone&&(this.expandedKeys=Ue(n,this.config),this.initialExpansionDone=!0),this.flattenedRows=this.flattenTree(n,this.expandedKeys),this.rowKeyMap.clear(),this.keysToAnimate.clear();const r=new Set;for(const s of this.flattenedRows)this.rowKeyMap.set(s.key,s),r.add(s.key),!this.previousVisibleKeys.has(s.key)&&s.depth>0&&this.keysToAnimate.add(s.key);return this.previousVisibleKeys=r,this.flattenedRows.map(s=>({...s.data,__treeKey:s.key,__treeDepth:s.depth,__treeHasChildren:s.hasChildren,__treeExpanded:s.isExpanded}))}withStableKeys(e,t=null){const i=this.config.childrenField??"children";return e.map((n,r)=>{const s=n.__stableKey,l=n.id!==void 0?String(n.id):s??(t?`${t}-${r}`:String(r)),a=n[i],c=Array.isArray(a)&&a.length>0;return{...n,__stableKey:l,...c?{[i]:this.withStableKeys(a,l)}:{}}})}flattenTree(e,t,i=0){const n=this.config.childrenField??"children",r=[];for(const s of e){const a=s.__stableKey??String(s.id??"?"),c=s[n],d=Array.isArray(c)&&c.length>0,u=t.has(a);r.push({key:a,data:s,depth:i,hasChildren:d,isExpanded:u,parentKey:i>0&&a.substring(0,a.lastIndexOf("-"))||null}),d&&u&&r.push(...this.flattenTree(c,t,i+1))}return r}sortTree(e,t,i){const n=this.config.childrenField??"children";return[...e].sort((s,l)=>{const a=s[t],c=l[t];return a==null&&c==null?0:a==null?-1:c==null?1:a>c?i:a<c?-i:0}).map(s=>{const l=s[n];return Array.isArray(l)&&l.length>0?{...s,[n]:this.sortTree(l,t,i)}:s})}processColumns(e){if(this.flattenedRows.length===0)return[...e];const t=[...e];if(t.length===0)return t;const i=t[0],n=i.viewRenderer,r=()=>this.config,s=this.setIcon.bind(this),l=this.resolveIcon.bind(this),a=c=>{const{row:d,value:u}=c,{showExpandIcons:h=!0,indentWidth:f}=r(),p=d,g=p.__treeDepth??0,w=document.createElement("span");if(w.className="tree-cell-wrapper",w.style.setProperty("--tbw-tree-depth",String(g)),f!==void 0&&w.style.setProperty("--tbw-tree-indent-width",`${f}px`),h)if(p.__treeHasChildren){const v=document.createElement("span");v.className=`tree-toggle${p.__treeExpanded?" expanded":""}`,s(v,l(p.__treeExpanded?"collapse":"expand")),v.setAttribute("data-tree-key",String(p.__treeKey??"")),w.appendChild(v)}else{const v=document.createElement("span");v.className="tree-spacer",w.appendChild(v)}const m=document.createElement("span");if(m.className="tree-content",n){const v=n(c);v instanceof Node?m.appendChild(v):typeof v=="string"&&(m.innerHTML=v)}else m.textContent=u!=null?String(u):"";return w.appendChild(m),w};return t[0]={...i,viewRenderer:a},t}onCellClick(e){const t=e.originalEvent?.target;if(!t?.classList.contains("tree-toggle"))return!1;const i=t.getAttribute("data-tree-key");if(!i)return!1;const n=this.rowKeyMap.get(i);return n?(this.expandedKeys=$e(this.expandedKeys,i),this.emit("tree-expand",{key:i,row:n.data,expanded:this.expandedKeys.has(i),depth:n.depth}),this.requestRender(),!0):!1}onKeyDown(e){if(e.key!==" ")return;const t=this.grid._focusRow,i=this.flattenedRows[t];if(i?.hasChildren)return e.preventDefault(),this.expandedKeys=$e(this.expandedKeys,i.key),this.emit("tree-expand",{key:i.key,row:i.data,expanded:this.expandedKeys.has(i.key),depth:i.depth}),this.requestRenderWithFocus(),!0}onHeaderClick(e){if(this.flattenedRows.length===0||!e.column.sortable)return!1;const{field:t}=e.column;!this.sortState||this.sortState.field!==t?this.sortState={field:t,direction:1}:this.sortState.direction===1?this.sortState={field:t,direction:-1}:this.sortState=null;const i=this.grid;return i._sortState!==void 0&&(i._sortState=this.sortState?{...this.sortState}:null),this.emit("sort-change",{field:t,direction:this.sortState?.direction??0}),this.requestRender(),!0}afterRender(){const e=this.animationStyle;if(e===!1||this.keysToAnimate.size===0)return;const t=this.gridElement?.querySelector(".rows");if(!t)return;const i=e==="fade"?"tbw-tree-fade-in":"tbw-tree-slide-in";for(const n of t.querySelectorAll(".data-grid-row")){const r=n.querySelector(".cell[data-row]"),s=r?parseInt(r.getAttribute("data-row")??"-1",10):-1,l=this.flattenedRows[s]?.key;l&&this.keysToAnimate.has(l)&&(n.classList.add(i),n.addEventListener("animationend",()=>n.classList.remove(i),{once:!0}))}this.keysToAnimate.clear()}expand(e){this.expandedKeys.add(e),this.requestRender()}collapse(e){this.expandedKeys.delete(e),this.requestRender()}toggle(e){this.expandedKeys=$e(this.expandedKeys,e),this.requestRender()}expandAll(){this.expandedKeys=Ue(this.rows,this.config),this.requestRender()}collapseAll(){this.expandedKeys=_r(),this.requestRender()}isExpanded(e){return this.expandedKeys.has(e)}getExpandedKeys(){return[...this.expandedKeys]}getFlattenedRows(){return[...this.flattenedRows]}getRowByKey(e){return this.rowKeyMap.get(e)?.data}expandToKey(e){this.expandedKeys=Ar(this.rows,e,this.config,this.expandedKeys),this.requestRender()}}function Lr(o,e,t){const i=[...o.undoStack,e];for(;i.length>t;)i.shift();return{undoStack:i,redoStack:[]}}function fi(o){if(o.undoStack.length===0)return{newState:o,action:null};const e=[...o.undoStack],t=e.pop();return t?{newState:{undoStack:e,redoStack:[...o.redoStack,t]},action:t}:{newState:o,action:null}}function gi(o){if(o.redoStack.length===0)return{newState:o,action:null};const e=[...o.redoStack],t=e.pop();return t?{newState:{undoStack:[...o.undoStack,t],redoStack:e},action:t}:{newState:o,action:null}}function Dr(o){return o.undoStack.length>0}function Hr(o){return o.redoStack.length>0}function Ir(){return{undoStack:[],redoStack:[]}}function Mr(o,e,t,i){return{type:"cell-edit",rowIndex:o,field:e,oldValue:t,newValue:i,timestamp:Date.now()}}class Or extends D{static dependencies=[{name:"editing",required:!0,reason:"UndoRedoPlugin tracks cell edit history"}];name="undoRedo";get defaultConfig(){return{maxHistorySize:100}}undoStack=[];redoStack=[];detach(){this.undoStack=[],this.redoStack=[]}onKeyDown(e){const t=(e.ctrlKey||e.metaKey)&&e.key==="z"&&!e.shiftKey,i=(e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="z"&&e.shiftKey);if(t){const n=fi({undoStack:this.undoStack,redoStack:this.redoStack});if(n.action){const r=this.rows;r[n.action.rowIndex]&&(r[n.action.rowIndex][n.action.field]=n.action.oldValue),this.undoStack=n.newState.undoStack,this.redoStack=n.newState.redoStack,this.emit("undo",{action:n.action,type:"undo"}),this.requestRender()}return!0}if(i){const n=gi({undoStack:this.undoStack,redoStack:this.redoStack});if(n.action){const r=this.rows;r[n.action.rowIndex]&&(r[n.action.rowIndex][n.action.field]=n.action.newValue),this.undoStack=n.newState.undoStack,this.redoStack=n.newState.redoStack,this.emit("redo",{action:n.action,type:"redo"}),this.requestRender()}return!0}return!1}recordEdit(e,t,i,n){const r=Mr(e,t,i,n),s=Lr({undoStack:this.undoStack,redoStack:this.redoStack},r,this.config.maxHistorySize??100);this.undoStack=s.undoStack,this.redoStack=s.redoStack}undo(){const e=fi({undoStack:this.undoStack,redoStack:this.redoStack});if(e.action){const t=this.rows;t[e.action.rowIndex]&&(t[e.action.rowIndex][e.action.field]=e.action.oldValue),this.undoStack=e.newState.undoStack,this.redoStack=e.newState.redoStack,this.requestRender()}return e.action}redo(){const e=gi({undoStack:this.undoStack,redoStack:this.redoStack});if(e.action){const t=this.rows;t[e.action.rowIndex]&&(t[e.action.rowIndex][e.action.field]=e.action.newValue),this.undoStack=e.newState.undoStack,this.redoStack=e.newState.redoStack,this.requestRender()}return e.action}canUndo(){return Dr({undoStack:this.undoStack,redoStack:this.redoStack})}canRedo(){return Hr({undoStack:this.undoStack,redoStack:this.redoStack})}clearHistory(){const e=Ir();this.undoStack=e.undoStack,this.redoStack=e.redoStack}getUndoStack(){return[...this.undoStack]}getRedoStack(){return[...this.redoStack]}}const Nr='@layer tbw-plugins{.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem))}.tbw-visibility-row{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-menu-item-padding, .375rem .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);border-radius:var(--tbw-border-radius, .25rem);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted, #888)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted, #888);font-size:var(--tbw-font-size-2xs, .625rem);letter-spacing:-2px;-webkit-user-select:none;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg, #1f2937)}.tbw-visibility-label{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-show-all{margin:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding, .5rem .75rem);border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, .25rem);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}}';function pi(o){const e=o.meta??{};return e.lockPosition!==!0&&e.suppressMovable!==!0}class j extends D{static dependencies=[{name:"reorder",required:!1,reason:"Enables drag-to-reorder columns in visibility panel"}];name="visibility";static PANEL_ID="columns";styles=Nr;get defaultConfig(){return{allowHideAll:!1}}columnListElement=null;isDragging=!1;draggedField=null;draggedIndex=null;dropIndex=null;clearDragClasses(e){e.querySelectorAll(".tbw-visibility-row").forEach(t=>{t.classList.remove("dragging","drop-target","drop-before","drop-after")})}detach(){this.columnListElement=null,this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null}getToolPanel(){return{id:j.PANEL_ID,title:"Columns",icon:"☰",tooltip:"Column visibility",order:100,render:e=>this.renderPanelContent(e)}}show(){this.grid.openToolPanel(),this.grid.expandedToolPanelSections.includes(j.PANEL_ID)||this.grid.toggleToolPanelSection(j.PANEL_ID)}hide(){this.grid.closeToolPanel()}toggle(){this.grid.isToolPanelOpen||this.grid.openToolPanel(),this.grid.toggleToolPanelSection(j.PANEL_ID)}isColumnVisible(e){return this.grid.isColumnVisible(e)}setColumnVisible(e,t){this.grid.setColumnVisible(e,t)}getVisibleColumns(){return this.grid.getAllColumns().filter(e=>e.visible).map(e=>e.field)}getHiddenColumns(){return this.grid.getAllColumns().filter(e=>!e.visible).map(e=>e.field)}showAll(){this.grid.showAllColumns()}toggleColumn(e){this.grid.toggleColumnVisibility(e)}showColumn(e){this.setColumnVisible(e,!0)}hideColumn(e){this.setColumnVisible(e,!1)}getAllColumns(){return this.grid.getAllColumns()}isPanelVisible(){return this.grid.isToolPanelOpen&&this.grid.expandedToolPanelSections.includes(j.PANEL_ID)}renderPanelContent(e){const t=document.createElement("div");t.className="tbw-visibility-content";const i=document.createElement("div");i.className="tbw-visibility-list",t.appendChild(i);const n=document.createElement("button");return n.className="tbw-visibility-show-all",n.textContent="Show All",n.addEventListener("click",()=>{this.grid.showAllColumns(),this.rebuildToggles(i)}),t.appendChild(n),this.columnListElement=i,this.rebuildToggles(i),e.appendChild(t),()=>{this.columnListElement=null,t.remove()}}hasReorderPlugin(){const e=this.grid?.getPluginByName?.("reorder");return!!(e&&typeof e.moveColumn=="function")}rebuildToggles(e){const t=this.hasReorderPlugin();e.innerHTML="";const i=this.grid.getAllColumns().filter(n=>!n.utility);for(let n=0;n<i.length;n++){const r=i[n],s=r.header||r.field,l=document.createElement("div");l.className=r.lockVisible?"tbw-visibility-row locked":"tbw-visibility-row",l.setAttribute("data-field",r.field),l.setAttribute("data-index",String(n)),t&&pi(r)&&(l.draggable=!0,l.classList.add("reorderable"),this.setupDragListeners(l,r.field,n,e));const a=document.createElement("label");a.className="tbw-visibility-label";const c=document.createElement("input");c.type="checkbox",c.checked=r.visible,c.disabled=r.lockVisible??!1,c.addEventListener("change",()=>{this.grid.toggleColumnVisibility(r.field),setTimeout(()=>this.rebuildToggles(e),0)});const d=document.createElement("span");if(d.textContent=s,a.appendChild(c),a.appendChild(d),t&&pi(r)){const u=document.createElement("span");u.className="tbw-visibility-handle",this.setIcon(u,this.resolveIcon("dragHandle")),u.title="Drag to reorder",l.appendChild(u)}l.appendChild(a),e.appendChild(l)}}setupDragListeners(e,t,i,n){e.addEventListener("dragstart",r=>{this.isDragging=!0,this.draggedField=t,this.draggedIndex=i,r.dataTransfer&&(r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",t)),e.classList.add("dragging")}),e.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedField=null,this.draggedIndex=null,this.dropIndex=null,this.clearDragClasses(n)}),e.addEventListener("dragover",r=>{if(r.preventDefault(),!this.isDragging||this.draggedField===t)return;const s=e.getBoundingClientRect(),l=s.top+s.height/2;this.dropIndex=r.clientY<l?i:i+1,n.querySelectorAll(".tbw-visibility-row").forEach(a=>{a!==e&&a.classList.remove("drop-target","drop-before","drop-after")}),e.classList.add("drop-target"),e.classList.toggle("drop-before",r.clientY<l),e.classList.toggle("drop-after",r.clientY>=l)}),e.addEventListener("dragleave",()=>{e.classList.remove("drop-target","drop-before","drop-after")}),e.addEventListener("drop",r=>{r.preventDefault();const s=this.draggedField,l=this.draggedIndex,a=this.dropIndex;if(!this.isDragging||s===null||l===null||a===null)return;const c=a>l?a-1:a;if(c!==l){const d=this.grid.getAllColumns(),h=d.filter(g=>!g.utility)[c]?.field,f=h?d.findIndex(g=>g.field===h):d.length,p={field:s,fromIndex:l,toIndex:f};this.emit("column-reorder-request",p),setTimeout(()=>{this.rebuildToggles(n)},0)}})}}y.BaseGridPlugin=D,y.ClipboardPlugin=Io,y.ColumnVirtualizationPlugin=zo,y.ContextMenuPlugin=Fo,y.DEFAULT_ANIMATION_CONFIG=je,y.DEFAULT_GRID_ICONS=q,y.DGEvents=ko,y.DataGridElement=M,y.EditingPlugin=Jo,y.ExportPlugin=nn,y.FilteringPlugin=B,y.FitModeEnum=X,y.GridCSSVars=So,y.GridClasses=I,y.GridDataAttrs=se,y.GridElement=M,y.GridSelectors=Eo,y.GroupingColumnsPlugin=wn,y.GroupingRowsPlugin=En,y.MasterDetailPlugin=Fe,y.MultiSortPlugin=In,y.PLUGIN_QUERIES=ke,y.PinnedColumnsPlugin=Nn,y.PinnedRowsPlugin=Gn,y.PivotPlugin=U,y.PluginEvents=To,y.PluginManager=Tt,y.ROW_DRAG_HANDLE_FIELD=si,y.RenderPhase=H,y.ReorderPlugin=cr,y.ResponsivePlugin=ur,y.RowReorderPlugin=fr,y.SelectionPlugin=yr,y.ServerSidePlugin=Sr,y.TreePlugin=Pr,y.UndoRedoPlugin=Or,y.VisibilityPlugin=j,y.builtInSort=ct,y.createGrid=_o,y.defaultComparator=at,y.defaultEditorFor=zt,y.defaultPasteHandler=Dt,y.queryGrid=Ao,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
|
80
80
|
//# sourceMappingURL=grid.all.umd.js.map
|