@toolbox-web/grid 1.26.2 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +2 -2
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +64 -1
- package/lib/core/internal/diagnostics.d.ts +4 -3
- package/lib/core/internal/row-manager.d.ts +3 -1
- package/lib/core/plugin/base-plugin.d.ts +2 -2
- package/lib/core/types.d.ts +59 -3
- package/lib/features/registry.js.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +24 -5
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/ExportPlugin.d.ts +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.d.ts +2 -2
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +2 -2
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +18 -3
- package/lib/plugins/grouping-columns/index.d.ts +0 -1
- package/lib/plugins/grouping-columns/index.js +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-columns/types.d.ts +1 -7
- package/lib/plugins/grouping-rows/index.d.ts +2 -1
- package/lib/plugins/grouping-rows/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -0
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/types.d.ts +20 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +8 -1
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +11 -1
- package/lib/plugins/pinned-rows/index.d.ts +1 -1
- package/lib/plugins/pinned-rows/index.js +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pinned-rows/types.d.ts +10 -3
- package/lib/plugins/pivot/PivotPlugin.d.ts +107 -1
- package/lib/plugins/pivot/index.d.ts +2 -1
- package/lib/plugins/pivot/index.js +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/print/types.d.ts +0 -3
- package/lib/plugins/reorder-columns/ReorderPlugin.d.ts +19 -2
- package/lib/plugins/reorder-columns/index.js +1 -1
- package/lib/plugins/reorder-columns/index.js.map +1 -1
- package/lib/plugins/reorder-rows/index.d.ts +1 -1
- package/lib/plugins/reorder-rows/index.js.map +1 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts +1 -1
- package/lib/plugins/responsive/index.js +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +1 -1
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +3 -3
- package/lib/plugins/server-side/ServerSidePlugin.d.ts +6 -1
- package/lib/plugins/server-side/index.js +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +116 -0
- package/lib/plugins/tree/index.d.ts +1 -1
- package/lib/plugins/tree/index.js +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/types.d.ts +16 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/undo-redo/types.d.ts +15 -3
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +18 -5
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +2 -4
- package/themes/dg-theme-material.css +16 -4
- package/umd/grid.all.umd.js +1 -1
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -1
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/export.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/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder-columns.umd.js +1 -1
- package/umd/plugins/reorder-columns.umd.js.map +1 -1
- package/umd/plugins/responsive.umd.js +1 -1
- package/umd/plugins/responsive.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
package/umd/grid.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TbwGrid={})}(this,function(e){"use strict";function t(e,t){const i=e.querySelector?.(".tbw-sr-only");i&&(i.textContent="",requestAnimationFrame(()=>{i.textContent=t}))}const i={STRETCH:"stretch",FIXED:"fixed"},o={mode:"reduced-motion",duration:200,easing:"ease-out"},r='<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>',n={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:r,filterActive:r,print:"🖨️"};function s(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const l="TBW041",a="TBW061",d="TBW062";function c(e,t,i,o){return`${s(i,o)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function h(e,t,i,o){throw new Error(c(e,t,i,o))}function u(e,t,i,o){console.warn(c(e,t,i,o))}function g(e,t,i,o){console.info(c(e,t,i,o))}function f(e,t,i,o){console.error(c(e,t,i,o))}function p(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const i={};t.forEach(e=>{const t=i[e.field];if(t){e.header&&!t.header&&(t.header=e.header),e.type&&!t.type&&(t.type=e.type),e.sortable&&(t.sortable=!0),e.editable&&(t.editable=!0),e.resizable&&(t.resizable=!0),null!=e.width&&null==t.width&&(t.width=e.width),null!=e.minWidth&&null==t.minWidth&&(t.minWidth=e.minWidth),e.__viewTemplate&&(t.__viewTemplate=e.__viewTemplate),e.__editorTemplate&&(t.__editorTemplate=e.__editorTemplate),e.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate);const i=e.renderer||e.viewRenderer,o=t.renderer||t.viewRenderer;i&&!o&&(t.viewRenderer=i,e.renderer&&(t.renderer=i)),e.editor&&!t.editor&&(t.editor=e.editor)}else i[e.field]={...e}});const o=e.map(e=>{const t=i[e.field];if(!t)return e;const o={...e};t.header&&!o.header&&(o.header=t.header),t.type&&!o.type&&(o.type=t.type),o.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(o.resizable=!0),o.editable=e.editable||t.editable,null!=t.width&&null==o.width&&(o.width=t.width),null!=t.minWidth&&null==o.minWidth&&(o.minWidth=t.minWidth),t.__viewTemplate&&(o.__viewTemplate=t.__viewTemplate),t.__editorTemplate&&(o.__editorTemplate=t.__editorTemplate),t.__headerTemplate&&(o.__headerTemplate=t.__headerTemplate);const r=t.renderer||t.viewRenderer,n=o.renderer||o.viewRenderer;return r&&!n&&(o.viewRenderer=r,t.renderer&&(o.renderer=r)),t.editor&&!o.editor&&(o.editor=t.editor),delete i[e.field],o});return Object.keys(i).forEach(e=>o.push(i[e])),o}function w(e,t){try{e.part?.add?.(t)}catch{}const i=e.getAttribute("part");i?i.split(/\s+/).includes(t)||e.setAttribute("part",i+" "+t):e.setAttribute("part",t)}function b(e){const t=e.effectiveConfig?.fitMode||e.fitMode||i.STRETCH;if(t!==i.STRETCH&&t!==i.FIXED)return;if(e.__didInitialAutoSize)return;if(!e.isConnected)return;const o=Array.from(e._headerRowEl?.children||[]);if(!o.length)return;let r=!1;e._visibleColumns.forEach((t,i)=>{if(t.width)return;const n=o[i];let s=n?n.scrollWidth:0;for(const o of e._rowPool){const e=o.children[i];if(e){const t=e.scrollWidth;t>s&&(s=t)}}s>0&&(t.width=s+2,t.__autoSized=!0,r=!0)}),r&&C(e),e.__didInitialAutoSize=!0}const m=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function v(e,t){return"number"==typeof e?`${e}px`:(m.test(e)||u("TBW050",`Column '${t??"?"}' has an invalid CSS width value: '${e}'. Expected a number (px) or a valid CSS unit string (e.g. '30%', '2fr', 'calc(...)').`),e)}function C(e){const t=e.effectiveConfig?.fitMode||e.fitMode||i.STRETCH;e._gridTemplate=t===i.STRETCH?e._visibleColumns.map(e=>{if(null!=e.width)return v(e.width,e.field);const t=e.minWidth;return null!=t?`minmax(${t}px, 1fr)`:"1fr"}).join(" ").trim():e._visibleColumns.map(e=>null!=e.width?v(e.width,e.field):"max-content").join(" "),e.style.setProperty("--tbw-column-template",e._gridTemplate)}const _=/{{\s*([^}]+)\s*}}/g,y="__DG_EMPTY__",R=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,S=/__(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/;const E=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"]),x=/^on\w+$/i,A=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),T=/^\s*(javascript|vbscript|data|blob):/i;function P(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],i=e.querySelectorAll("*");for(const o of i){const e=o.tagName.toLowerCase();if(E.has(e)){t.push(o);continue}if("svg"===e||"http://www.w3.org/2000/svg"===o.namespaceURI){if(Array.from(o.attributes).some(e=>x.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(o);continue}}const i=[];for(const t of o.attributes){const e=t.name.toLowerCase();x.test(e)?i.push(t.name):(A.has(e)&&T.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&i.push(t.name)}i.forEach(e=>o.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function H(e,t){if(!e||-1===e.indexOf("{{"))return e;const i=[],o=e.replace(_,(e,o)=>{const r=function(e,t){if(e=(e||"").trim(),!e)return y;if(M.test(e))return y;if("value"===e)return null==t.value?y:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const i=e.slice(4),o=t.row?t.row[i]:void 0;return null==o?y:String(o)}if(e.length>80)return y;if(!R.test(e)||S.test(e))return y;const i=e.match(/\./g);if(i&&i.length>1)return y;try{const i=new Function("value","row",`return (${e});`)(t.value,t.row),o=null==i?"":String(i);return M.test(o)?y:o||y}catch{return y}}(o,t);return i.push({expr:o.trim(),result:r}),r}),r=(n=o)?n.replace(new RegExp(y,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):n;var n;const s=i.length&&i.every(e=>""===e.result||e.result===y);return M.test(e)||s?"":r}const M=/Reflect|Proxy|ownKeys/;function L(e){if(M.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&M.test(t.textContent||"")&&(t.textContent="");M.test(e.textContent||"")&&(e.textContent="")}}function D(e){const t=M.test(e),i=i=>{if(t)return"";return H(e,i)};return i.__blocked=t,i}function O(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0}function I(e,t,i){const o=i.find(e=>e.field===t.field),r=o?.sortComparator??O,{field:n,direction:s}=t;return[...e].sort((e,t)=>r(e[n],t[n],e,t)*s)}function z(e,i,o,r){e._rows=i,e.__rowRenderEpoch++,e._rowPool.forEach(e=>e.__epoch=-1),U(e),e.refreshVirtualWindow(!0),e.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:r}})),t(e,`Sorted by ${o.header??o.field}, ${1===r?"ascending":"descending"}`),e.requestStateChange?.()}function k(e,i){if(e._sortState&&e._sortState.field===i.field)if(1===e._sortState.direction)N(e,i,-1);else{e._sortState=null,e.__rowRenderEpoch++,e._rowPool.forEach(e=>e.__epoch=-1),e._rows=e.__originalOrder.slice(),U(e);const o=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');o?.forEach(t=>{t.getAttribute("aria-sort")&&("ascending"!==t.getAttribute("aria-sort")&&"descending"!==t.getAttribute("aria-sort")||e._sortState)||t.setAttribute("aria-sort","none")}),e.refreshVirtualWindow(!0),e.dispatchEvent(new CustomEvent("sort-change",{detail:{field:i.field,direction:0}})),t(e,"Sort cleared"),e.requestStateChange?.()}else e._sortState||(e.__originalOrder=e._rows.slice()),N(e,i,1)}function N(e,t,i){e._sortState={field:t.field,direction:i};const o={field:t.field,direction:i},r=e._columns,n=(e.effectiveConfig?.sortHandler??I)(e._rows,o,r);n&&"function"==typeof n.then?n.then(o=>{z(e,o,t,i)}):z(e,n,t,i)}function q(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function $(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function W(e,t){const i=document.createElement("span");w(i,"sort-indicator");const o=e._sortState?.field===t.field?e._sortState.direction:0,r={...n,...e.icons};return function(e,t){"string"==typeof t?e.textContent=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(i,1===o?r.sortAsc:-1===o?r.sortDesc:r.sortNone),i}function F(e,t,i){const o=document.createElement("div");return o.className="resize-handle",o.setAttribute("aria-hidden","true"),o.addEventListener("mousedown",o=>{o.stopPropagation(),o.preventDefault(),e._resizeController.start(o,t,i)}),o.addEventListener("dblclick",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.resetColumn(t)}),o}function V(e,t,i,o){o.classList.add("sortable"),o.tabIndex=0;const r=e._sortState?.field===t.field?e._sortState.direction:0;o.setAttribute("aria-sort",0===r?"none":1===r?"ascending":"descending"),o.addEventListener("click",i=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(i,t,o)||k(e,t)}),o.addEventListener("keydown",i=>{if("Enter"===i.key||" "===i.key){if(i.preventDefault(),e._dispatchHeaderClick?.(i,t,o))return;k(e,t)}})}function U(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((i,o)=>{const r=document.createElement("div");r.className="cell",w(r,"header-cell"),r.setAttribute("role","columnheader"),r.setAttribute("aria-colindex",String(o+1)),r.setAttribute("data-field",i.field),r.setAttribute("data-col",String(o)),i.type&&r.setAttribute("data-type",i.type);const n=i.header??i.field,s=e._sortState?.field===i.field?e._sortState.direction:0,l=1===s?"asc":-1===s?"desc":null;if(i.headerRenderer){const t={column:i,value:n,sortState:l,filterActive:!1,cellEl:r,renderSortIcon:()=>q(e,i)?W(e,i):null,renderFilterButton:()=>null},s=i.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const i=document.createElement("span");for(i.innerHTML=P(t);i.firstChild;)e.appendChild(i.firstChild)}else t instanceof Node&&e.appendChild(t)}(r,s),q(e,i)&&V(e,i,0,r),$(e,i)&&(r.classList.add("resizable"),r.appendChild(F(e,o,r)))}else if(i.headerLabelRenderer){const t={column:i,value:n},s=i.headerLabelRenderer(t),l=document.createElement("span");null==s?l.textContent=n:"string"==typeof s?l.innerHTML=P(s):s instanceof Node&&l.appendChild(s),r.appendChild(l),q(e,i)&&(V(e,i,0,r),r.appendChild(W(e,i))),$(e,i)&&(r.classList.add("resizable"),r.appendChild(F(e,o,r)))}else if(i.__headerTemplate)Array.from(i.__headerTemplate.childNodes).forEach(e=>r.appendChild(e.cloneNode(!0))),q(e,i)&&(V(e,i,0,r),r.appendChild(W(e,i))),$(e,i)&&(r.classList.add("resizable"),r.appendChild(F(e,o,r)));else{const t=document.createElement("span");t.textContent=n,r.appendChild(t),q(e,i)&&(V(e,i,0,r),r.appendChild(W(e,i))),$(e,i)&&(r.classList.add("resizable"),r.appendChild(F(e,o,r)))}t.appendChild(r)}),t.querySelectorAll(".cell.sortable").forEach(e=>{e.getAttribute("aria-sort")||e.setAttribute("aria-sort","none")}),t.children.length>0?(t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1")):(t.removeAttribute("role"),t.removeAttribute("aria-rowindex")))}function B(e,t){const i=e[0]||{},o=Object.keys(i).map(e=>{const t=i[e],o=null==(r=t)?"string":"number"==typeof r?"number":"boolean"==typeof r?"boolean":r instanceof Date||"string"==typeof r&&/\d{4}-\d{2}-\d{2}/.test(r)&&!isNaN(Date.parse(r))?"date":"string";var r;return{field:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:o}}),r={};return o.forEach(e=>{r[e.field]=e.type||"string"}),{columns:o,typeMap:r}}var G=(e=>(e[e.STYLE=1]="STYLE",e[e.VIRTUALIZATION=2]="VIRTUALIZATION",e[e.HEADER=3]="HEADER",e[e.ROWS=4]="ROWS",e[e.COLUMNS=5]="COLUMNS",e[e.FULL=6]="FULL",e))(G||{});class j{#e;#t=0;#i=0;#o=null;#r=null;#n=null;#s=!1;constructor(e){this.#e=e}requestPhase(e,t){e>this.#t&&(this.#t=e),0===this.#i&&(this.#l(),this.#i=requestAnimationFrame(()=>this.#a()))}whenReady(){return this.#o?this.#o:Promise.resolve()}setInitialReadyResolver(e){this.#n=e}cancel(){0!==this.#i&&(cancelAnimationFrame(this.#i),this.#i=0),this.#t=0,this.#r&&(this.#r(),this.#r=null,this.#o=null)}get isPending(){return 0!==this.#t}get pendingPhase(){return this.#t}#l(){this.#o||(this.#o=new Promise(e=>{this.#r=e}))}#a(){if(this.#i=0,!this.#e._schedulerIsConnected)return this.#t=0,void(this.#r&&(this.#r(),this.#r=null,this.#o=null));const e=this.#t;this.#t=0,e>=5&&this.#e._schedulerMergeConfig(),e>=4&&this.#e._schedulerProcessRows(),e>=5&&(this.#e._schedulerProcessColumns(),this.#e._schedulerUpdateTemplate()),e>=3&&this.#e._schedulerRenderHeader(),e>=2&&this.#e.refreshVirtualWindow(!0,!0),e>=1&&this.#e._schedulerAfterRender(),!this.#s&&this.#n&&(this.#s=!0,this.#n()),this.#r&&(this.#r(),this.#r=null,this.#o=null)}}class X{#d;#c;#h;#u;#g;#f={};#p={};#w=!0;#b=[];#m;#v;#C;#_;#e;#y;constructor(e){this.#e=e}get original(){return this.#f}get effective(){return this.#p}get columns(){return this.#p.columns??[]}set columns(e){this.#p.columns=e}get lightDomColumnsCache(){return this.#u}set lightDomColumnsCache(e){this.#u=e}get originalColumnNodes(){return this.#g}set originalColumnNodes(e){this.#g=e}get lightDomTitle(){return this.#y}set lightDomTitle(e){this.#y=e}get initialColumnState(){return this.#_}set initialColumnState(e){this.#_=e}get sourcesChanged(){return this.#w}markSourcesChanged(){this.#w=!0}setGridConfig(e){this.#d=e,this.#w=!0,this.#u=void 0}getGridConfig(){return this.#d}setColumns(e){this.#c=e,this.#w=!0}getColumns(){return this.#c}setFitMode(e){this.#h=e,this.#w=!0}getFitMode(){return this.#h}merge(){const e=(this.#p.columns?.length??0)>0;if(!this.#w&&e)return;const t=this.#R();this.#w=!1,this.#f=t,Object.freeze(this.#f),this.#f.columns&&Object.freeze(this.#f.columns),this.#p=this.#S(this.#f),this.#E()}#S(e){const t={...e};return e.columns&&(t.columns=e.columns.map(e=>({...e}))),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(e=>({...e})),headerContents:e.shell.headerContents?.map(e=>({...e}))}),t}#E(){const e=this.#p;if(this.#x(),"number"==typeof e.rowHeight&&e.rowHeight>0&&(this.#e._virtualization.rowHeight=e.rowHeight),"fixed"===e.fitMode){this.columns.forEach(e=>{null==e.width&&(e.width=80)})}this.#e._applyAnimationConfig(e)}#x(){const e=this.#p.typeDefaults;if(!e)return;const t=this.columns;for(const i of t){if(!i.type)continue;const t=e[i.type];t&&(i.renderer||i.viewRenderer||!t.renderer||(i.renderer=t.renderer),!i.format&&t.format&&(i.format=t.format),!i.editor&&t.editor&&(i.editor=t.editor),!i.editorParams&&t.editorParams&&(i.editorParams=t.editorParams))}}#R(){const e=this.#d?{...this.#d}:{},t=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#u??[]).map(e=>({...e}));let o=p(t,i);this.#c&&this.#c.length&&(o=p(this.#c,i));const r=this.#e.sourceRows;if(0===o.length&&r.length){o=B(r).columns}return o.length&&(o.forEach(e=>{void 0===e.sortable&&(e.sortable=!0),void 0===e.resizable&&(e.resizable=!0),void 0===e.__originalWidth&&"number"==typeof e.width&&(e.__originalWidth=e.width)}),o.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=D(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=D(e.__editorTemplate.innerHTML))}),e.columns=o),this.#h&&(e.fitMode=this.#h),e.fitMode||(e.fitMode="stretch"),this.#A(e),e.columnState&&!this.#_&&(this.#_=e.columnState),e}#A(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const t=this.#e._shellState.lightDomTitle;t&&(this.#y=t),this.#y&&!e.shell.header.title&&(e.shell.header.title=this.#y);const i=this.#e._shellState.lightDomHeaderContent;i?.length>0&&(e.shell.header.lightDomContent=i),this.#e._shellState.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0);const o=this.#e._shellState.toolPanels;if(o.size>0){const t=Array.from(o.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=t}const r=this.#e._shellState.headerContents;if(r.size>0){const t=Array.from(r.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=t}const n=this.#e._shellState.toolbarContents,s=Array.from(n.values()),l=this.#d?.shell?.header?.toolbarContents??[],a=new Set(l.map(e=>e.id)),d=[...l];for(const c of s)a.has(c.id)||d.push(c);d.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=d}collectState(e){const t=this.columns,i=this.#T();return{columns:t.map((t,o)=>{const r={field:t.field,order:o,visible:!t.hidden},n=t;void 0!==n.__renderedWidth?r.width=n.__renderedWidth:void 0!==t.width&&(r.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=i.get(t.field);s&&(r.sort=s);for(const i of e)if(i.getColumnState){const e=i.getColumnState(t.field);e&&Object.assign(r,e)}return r})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const i=this.columns,o=new Map(e.columns.map(e=>[e.field,e])),r=i.map(e=>{const t=o.get(e.field);if(!t)return e;const i={...e};return void 0!==t.width&&(i.width=t.width,i.__renderedWidth=t.width),void 0!==t.visible&&(i.hidden=!t.visible),i});r.sort((e,t)=>(o.get(e.field)?.order??1/0)-(o.get(t.field)?.order??1/0)),this.columns=r;const n=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(n.length>0){const e=n[0];e.sort&&(this.#e._sortState={field:e.field,direction:"asc"===e.sort.direction?1:-1})}else this.#e._sortState=null;for(const s of t)if(s.applyColumnState)for(const t of e.columns)s.applyColumnState(t.field,t)}resetState(e){this.#_=void 0,this.#e._sortState=null,this.#p=this.#S(this.#f),this.#E();for(const t of e)if(t.applyColumnState)for(const e of this.columns)t.applyColumnState(e.field,{field:e.field,order:0,visible:!0});this.requestStateChange(e)}#T(){const e=new Map,t=this.#e._sortState;return t&&e.set(t.field,{direction:1===t.direction?"asc":"desc",priority:0}),e}requestStateChange(e){this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=void 0;const t=this.collectState(e);this.#e._emit("column-state-change",t)},100)}setColumnVisible(e,t){const i=this.columns,o=i.find(t=>t.field===e);if(!o)return!1;if(!t&&o.lockVisible)return!1;if(!t){if(0===i.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!o.hidden!=!t&&(o.hidden=!t,this.#e._emit("column-visibility",{field:e,visible:t,visibleColumns:i.filter(e=>!e.hidden).map(e=>e.field)}),this.#e._clearRowPool(),this.#e._setup(),!0)}toggleColumnVisibility(e){const t=this.columns.find(t=>t.field===e);return!!t&&this.setColumnVisible(e,!!t.hidden)}isColumnVisible(e){const t=this.columns.find(t=>t.field===e);return!!t&&!t.hidden}showAllColumns(){const e=this.columns;e.some(e=>e.hidden)&&(e.forEach(e=>e.hidden=!1),this.#e._emit("column-visibility",{visibleColumns:e.map(e=>e.field)}),this.#e._clearRowPool(),this.#e._setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:!0===e.meta?.utility}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const t=new Map(this.columns.map(e=>[e.field,e])),i=[];for(const o of e){const e=t.get(o);e&&(i.push(e),t.delete(o))}for(const o of t.values())i.push(o);this.columns=i,U(this.#e),C(this.#e),this.#e._requestSchedulerPhase(G.VIRTUALIZATION,"configManager")}parseLightDomColumns(e){this.#u||(this.#g=Array.from(e.querySelectorAll("tbw-grid-column")),this.#u=this.#g.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const i=e.getAttribute("type")||void 0,o={field:t,type:i&&new Set(["number","string","date","boolean","select"]).has(i)?i:void 0,header:e.getAttribute("header")||void 0,sortable:e.hasAttribute("sortable"),editable:e.hasAttribute("editable")},r=e.getAttribute("width");if(r){const e=parseFloat(r);!isNaN(e)&&/^\d+(\.\d+)?$/.test(r.trim())?o.width=e:o.width=r}const n=e.getAttribute("minWidth")||e.getAttribute("min-width");if(n){const e=parseFloat(n);isNaN(e)||(o.minWidth=e)}e.hasAttribute("resizable")&&(o.resizable=!0),e.hasAttribute("sizable")&&(o.resizable=!0);const s=e.getAttribute("editor"),l=e.getAttribute("renderer");s&&(o.__editorName=s),l&&(o.__rendererName=l);const a=e.getAttribute("options");a&&(o.options=a.split(",").map(e=>{const[t,i]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:i?.trim()||t.trim()}}));const d=e.querySelector("tbw-grid-column-view"),c=e.querySelector("tbw-grid-column-editor"),h=e.querySelector("tbw-grid-column-header");d&&(o.__viewTemplate=d),c&&(o.__editorTemplate=c),h&&(o.__headerTemplate=h);const u=globalThis.DataGridElement,g=u?.getAdapters?.()??[],f=d??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(o.viewRenderer=e)}const w=c??e,b=g.find(e=>e.canHandle(w));if(b){const e=b.createEditor(w);e&&(o.editor=e)}return o}).filter(e=>!!e)}(e):[])}clearLightDomCache(){this.#u=void 0}#P=new Map;registerLightDomHandler(e,t){this.#P.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#P.delete(e.toLowerCase())}observeLightDOM(e){this.#m&&this.#m.disconnect();const t=new Set,i=()=>{this.#C=void 0;for(const e of t){const t=this.#P.get(e);t?.()}t.clear()};this.#m=new MutationObserver(e=>{for(const i of e){for(const e of i.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const i=e.tagName.toLowerCase();this.#P.has(i)&&t.add(i)}if("attributes"===i.type&&i.target.nodeType===Node.ELEMENT_NODE){const e=i.target.tagName.toLowerCase();this.#P.has(e)&&t.add(e)}}t.size>0&&!this.#C&&(this.#C=setTimeout(i,0))}),this.#m.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#b.push(e)}notifyChange(){for(const e of this.#b)e()}dispose(){this.#m?.disconnect(),this.#b=[],this.#v&&clearTimeout(this.#v),this.#C&&(clearTimeout(this.#C),this.#C=void 0)}}function Y(){if("undefined"!=typeof window&&window.location){const e=window.location.hostname;if("localhost"===e||"127.0.0.1"===e||"::1"===e)return!0}return"undefined"!=typeof process&&"production"!==process.env?.NODE_ENV}function K(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"🗹":"☐"}</span>`}function Z(e){if(null==e||""===e)return"";if(e instanceof Date)return isNaN(e.getTime())?"":e.toLocaleDateString();if("number"==typeof e||"string"==typeof e){const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleDateString()}return""}function Q(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const i=e.closest(".data-grid-row");if(!i)return-1;const o=i.parentElement;if(!o)return-1;const r=o.querySelectorAll(":scope > .data-grid-row");for(let n=0;n<r.length;n++)if(r[n]===i)return n;return-1}function J(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function ee(e){return"rtl"===function(e){try{if("rtl"===getComputedStyle(e).direction)return"rtl"}catch{}try{const t=e.closest?.("[dir]")?.getAttribute("dir");if("rtl"===t)return"rtl"}catch{}return"ltr"}(e)}function te(e,t){const i=t.renderer||t.viewRenderer;if(i)return i;if(!t.type)return;const o=e.__frameworkAdapter;if(o?.getTypeDefault){const e=o.getTypeDefault(t.type);if(e?.renderer)return e.renderer}}function ie(e,t){if(t.format)return t.format;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const e=i.getTypeDefault(t.type);if(e?.format)return e.format}}const oe='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function re(e){return(e.__editingCellCount??0)>0}function ne(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(".cell.editing").forEach(e=>e.classList.remove("editing"))}const se=document.createElement("template");se.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const le=document.createElement("template");function ae(){return se.content.firstElementChild.cloneNode(!0)}function de(){return le.content.firstElementChild.cloneNode(!0)}function ce(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function he(e,t,i,o){const r=t.children,n=e._visibleColumns,s=n.length,l=r.length,c=s<l?s:l,h=e._focusRow,g=e._focusCol,f=e._hasAfterCellRenderHook?.()??!1;let p=e.__hasSpecialColumns;if(void 0===p){p=!1;const t=e.__frameworkAdapter;for(let e=0;e<s;e++){const i=n[e];if(i.__viewTemplate||i.__compiledView||i.renderer||i.viewRenderer||i.externalView||i.format||i.cellClass||"date"===i.type||"boolean"===i.type||i.type&&t?.getTypeDefault?.(i.type)?.renderer||i.type&&t?.getTypeDefault?.(i.type)?.format){p=!0;break}}e.__hasSpecialColumns=p}const w=String(o);if(p){for(let s=0;s<c;s++){if(n[s].externalView){if(!r[s].querySelector("[data-external-view]"))return void ue(e,t,i,o)}}for(let s=0;s<c;s++){const l=n[s],c=r[s];c.getAttribute("data-row")!==w&&c.setAttribute("data-row",w);const p=c.classList.contains("editing");if(!p){const e=h===o&&g===s;e!==c.classList.contains("cell-focus")&&(c.classList.toggle("cell-focus",e),c.setAttribute("aria-selected",String(e)))}const m=l.cellClass;if(m){const t=c.getAttribute("data-dynamic-classes");t&&t.split(" ").forEach(e=>e&&c.classList.remove(e));try{const e=m(i[l.field],i,l),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){const e=t.filter(e=>e&&"string"==typeof e);e.forEach(e=>c.classList.add(e)),c.setAttribute("data-dynamic-classes",e.join(" "))}else c.removeAttribute("data-dynamic-classes")}catch(b){u(a,`cellClass callback error for column '${l.field}': ${b}`,e.id),c.removeAttribute("data-dynamic-classes")}}if(p)continue;const v=te(e,l);if(v){const r=i[l.field],n=v({row:i,value:r,field:l.field,column:l,cellEl:c});"string"==typeof n?(e.__frameworkAdapter?.releaseCell?.(c),c.innerHTML=P(n)):n instanceof Node?n.parentElement!==c&&(e.__frameworkAdapter?.releaseCell?.(c),c.innerHTML="",c.appendChild(n)):null==n&&(e.__frameworkAdapter?.releaseCell?.(c),c.textContent=null==r?"":String(r)),f&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:r,cellElement:c,rowElement:t});continue}if(l.__compiledView){const r=i[l.field],n=l.__compiledView({row:i,value:r,field:l.field,column:l});l.__compiledView.__blocked?c.textContent="":(c.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(c),c.innerHTML=P(n),L(c)),f&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:r,cellElement:c,rowElement:t});continue}if(l.__viewTemplate){const r=i[l.field],n=l.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(n)?c.textContent="":(c.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(c),c.innerHTML=P(H(n,{row:i,value:r})),L(c)),f&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:r,cellElement:c,rowElement:t});continue}if(l.externalView)continue;const C=i[l.field];let _;const y=ie(e,l);if(y){try{const e=y(C,i);_=null==e?"":String(e)}catch(b){u(d,`Format error in column '${l.field}': ${b}`,e.id),_=null==C?"":String(C)}c.textContent=_}else"date"===l.type?(_=Z(C),c.textContent=_):"boolean"===l.type?c.innerHTML=K(!!C):(_=null==C?"":String(C),c.textContent=_);f&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:C,cellElement:c,rowElement:t})}}else for(let a=0;a<c;a++){const s=r[a];if(s.classList.contains("editing"))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const l=n[a],d=i[l.field];s.textContent=null==d?"":String(d),s.getAttribute("data-row")!==w&&s.setAttribute("data-row",w);const c=h===o&&g===a;c!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",c),s.setAttribute("aria-selected",String(c))),f&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:a,value:d,cellElement:s,rowElement:t})}}function ue(e,t,i,o){t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy");const r=e.__frameworkAdapter;if(r?.releaseCell){const e=t.children;for(let t=e.length-1;t>=0;t--)r.releaseCell(e[t])}t.innerHTML="";const n=e._visibleColumns,s=n.length,l=e._focusRow,c=e._focusCol,h=e._hasAfterCellRenderHook?.()??!1,g=document.createDocumentFragment();for(let p=0;p<s;p++){const r=n[p],s=ae();s.setAttribute("aria-colindex",String(p+1)),s.setAttribute("data-col",String(p)),s.setAttribute("data-row",String(o)),s.setAttribute("data-field",r.field),s.setAttribute("data-header",r.header??r.field),r.type&&s.setAttribute("data-type",r.type);let w=i[r.field];const b=ie(e,r);if(b)try{w=b(w,i)}catch(f){u(d,`Format error in column '${r.field}': ${f}`,e.id)}const m=r.__compiledView,v=r.__viewTemplate,C=te(e,r),_=r.externalView;let y=!1;if(C){const e=C({row:i,value:w,field:r.field,column:r,cellEl:s});"string"==typeof e?(s.innerHTML=P(e),y=!0):e instanceof Node?e.parentElement!==s&&(s.textContent="",s.appendChild(e)):null==e&&(s.textContent=null==w?"":String(w))}else if(_){const t=_,o=document.createElement("div");o.setAttribute("data-external-view",""),o.setAttribute("data-field",r.field),s.appendChild(o);const n={row:i,value:w,field:r.field,column:r};if(t.mount)try{t.mount({placeholder:o,context:n,spec:t})}catch(f){u("TBW063",`External view mount error for column '${r.field}': ${f}`,e.id)}else queueMicrotask(()=>{try{e.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:o,spec:t,context:n}}))}catch(f){u("TBW064",`External view event dispatch error for column '${r.field}': ${f}`,e.id)}});o.setAttribute("data-mounted","")}else if(m){const e=m({row:i,value:w,field:r.field,column:r}),t=m.__blocked;s.innerHTML=t?"":P(e),y=!0,t&&(s.textContent="",s.setAttribute("data-blocked-template",""))}else if(v){const e=v.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(s.textContent="",s.setAttribute("data-blocked-template","")):(s.innerHTML=P(H(e,{row:i,value:w})),y=!0)}else b?s.textContent=null==w?"":String(w):"date"===r.type?s.textContent=Z(w):"boolean"===r.type?s.innerHTML=K(!!w):s.textContent=null==w?"":String(w);if(y){L(s);const e=s.textContent||"";/Proxy|Reflect\.ownKeys/.test(e)&&(s.textContent=e.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(s.textContent||"")&&(s.textContent=""))}s.hasAttribute("data-blocked-template")&&(s.textContent||"").trim().length&&(s.textContent="");("function"==typeof r.editable?r.editable(i):r.editable)?s.tabIndex=0:"boolean"===r.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),l===o&&c===p?(s.classList.add("cell-focus"),s.setAttribute("aria-selected","true")):s.setAttribute("aria-selected","false");const R=r.cellClass;if(R)try{const e=R(i[r.field],i,r),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const i of t)i&&"string"==typeof i&&(s.classList.add(i),e+=(e?" ":"")+i);s.setAttribute("data-dynamic-classes",e)}}catch(f){u(a,`cellClass callback error for column '${r.field}': ${f}`,e.id)}h&&e._afterCellRender?.({row:i,rowIndex:o,column:r,colIndex:p,value:w,cellElement:s,rowElement:t}),g.appendChild(s)}t.appendChild(g)}function ge(e,t,i){if(t.target?.closest(".resize-handle"))return;const o=Q(i.querySelector(".cell[data-row]"));if(o<0)return;const r=e._rows[o];if(!r)return;if(e._dispatchRowClick?.(t,o,r,i))return;const n=t.target?.closest(".cell[data-col]");if(n){const i=Number(n.getAttribute("data-col"));if(!isNaN(i)){if(e._dispatchCellClick?.(t,o,i,n))return;const r=e._focusRow!==o||e._focusCol!==i;if(e._focusRow=o,e._focusCol=i,n.classList.contains("editing")){r&&(J(e._bodyEl??e),n.classList.add("cell-focus"));const i=t.target,o=n.contains(i)&&i.matches(oe)?i:n.querySelector(oe);try{o?.focus({preventScroll:!0})}catch{}return}fe(e)}}}function fe(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:i,viewportEl:o}=e._virtualization,r=i,n=o?.clientHeight??r?.clientHeight??0;if(r&&n>0){const i=e._focusRow*t;i<r.scrollTop?r.scrollTop=i:i+t>r.scrollTop+n&&(r.scrollTop=i-n+t)}}const i=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;i||e.refreshVirtualWindow(!1),J(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const o=e._focusRow,r=e._virtualization.start??0,n=e._virtualization.end??e._rows.length;if(o>=r&&o<n){const n=e._bodyEl.querySelectorAll(".data-grid-row")[o-r];let s=n?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=n?.querySelector(`.cell[data-col="${e._focusCol}"]`)??n?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const o=e.querySelector(".tbw-scroll-area");if(o&&s&&(!i||t?.forceHorizontalScroll))if(t?.forceScrollLeft)o.scrollLeft=0;else if(t?.forceScrollRight)o.scrollLeft=o.scrollWidth-o.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(n??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),i=o.getBoundingClientRect(),r=e.left-i.left+o.scrollLeft,n=r+e.width,l=o.scrollLeft+t.left,a=o.scrollLeft+o.clientWidth-t.right;r<l?o.scrollLeft=r-t.left:n>a&&(o.scrollLeft=n-o.clientWidth+t.right)}}if(i&&s.classList.contains("editing")){const e=s.querySelector(oe);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(i&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else i||document.activeElement!==e&&e.focus({preventScroll:!0})}}}le.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const pe=new WeakMap;function we(e,t){const i=Q(t),o=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(i<0||o<0)return;e._focusRow=i,e._focusCol=o,J(e._bodyEl),t.classList.add("cell-focus"),t.setAttribute("aria-selected","true");const r=t.closest("tbw-grid");r&&document.activeElement!==r&&r.focus({preventScroll:!0})}function be(e,t,i,o){let r=null;const n=i.composedPath?.();if(r=n&&n.length>0?n[0]:i.target,r&&!t.contains(r)){const e=document.elementFromPoint(i.clientX,i.clientY);e&&(r=e)}const s=r?.closest?.("[data-col]"),l=r?.closest?.(".data-grid-row"),a=r?.closest?.(".header-row");let d,c,h,u,g,f;return s&&(d=parseInt(s.getAttribute("data-row")??"-1",10),c=parseInt(s.getAttribute("data-col")??"-1",10),d>=0&&c>=0&&(h=e._rows[d],f=e._visibleColumns[c],u=f?.field,g=h&&u?h[u]:void 0)),{type:o,row:h,rowIndex:void 0!==d&&d>=0?d:void 0,colIndex:void 0!==c&&c>=0?c:void 0,field:u,value:g,column:f,originalEvent:i,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:void 0!==d&&void 0!==c&&d>=0&&c>=0?{row:d,col:c}:void 0}}function me(e,t,i,o){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const i=e._rows.length-1,o=e._visibleColumns.length-1,r=void 0!==e._activeEditRows&&-1!==e._activeEditRows,n=e._visibleColumns[e._focusCol],s=n?.type,l=t.composedPath?.()??[],a=l.length?l[0]:t.target,d=e=>{if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable};if((!d(a)||"Home"!==t.key&&"End"!==t.key)&&!(d(a)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===a.tagName&&"number"===a.type||d(a)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||d(a)&&("Enter"===t.key||"Escape"===t.key)||r&&"select"===s&&("ArrowDown"===t.key||"ArrowUp"===t.key))){switch(t.key){case"Tab":return t.preventDefault(),t.shiftKey?e._focusCol>0?e._focusCol-=1:e._focusRow>0&&("function"==typeof e.commitActiveRowEdit&&e._activeEditRows===e._focusRow&&e.commitActiveRowEdit(),e._focusRow-=1,e._focusCol=o):e._focusCol<o?e._focusCol+=1:("function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow<i&&(e._focusRow+=1,e._focusCol=0)),void fe(e);case"ArrowDown":r&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=Math.min(i,e._focusRow+1),t.preventDefault();break;case"ArrowUp":r&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const i=ee(e);e._focusCol=i?Math.max(0,e._focusCol-1):Math.min(o,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const i=ee(e);e._focusCol=i?Math.min(o,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(r&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void fe(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(r&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=i,e._focusCol=o):e._focusCol=o,t.preventDefault(),void fe(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(i,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const i=e._focusRow,o=e._focusCol,r=e._visibleColumns[o],n=e._rows[i],s=r?.field??"",l=s&&n?n[s]:void 0,a=e.querySelector(`[data-row="${i}"][data-col="${o}"]`),d=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:i,colIndex:o,column:r,field:s,value:l,row:n,cellEl:a,trigger:"keyboard",originalEvent:t}});e.dispatchEvent(d);const c=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:i,col:o}});if(e.dispatchEvent(c),d.defaultPrevented||c.defaultPrevented)return void t.preventDefault();break}default:return}fe(e)}}(e,t),{signal:o}),i.addEventListener("mousedown",t=>function(e,t,i){const o=be(e,t,i,"mousedown");e._dispatchCellMouseDown?.(o)&&pe.set(e,!0)}(e,i,t),{signal:o}),document.addEventListener("mousemove",t=>function(e,t,i){if(!pe.get(e))return;const o=be(e,t,i,"mousemove");e._dispatchCellMouseMove?.(o)}(e,i,t),{signal:o}),document.addEventListener("mouseup",t=>function(e,t,i){if(!pe.get(e))return;const o=be(e,t,i,"mouseup");e._dispatchCellMouseUp?.(o),pe.set(e,!1)}(e,i,t),{signal:o})}let ve;class Ce{#e;#H=new Set;#M=new Map;constructor(e){this.#e=e}focusCell(e,t){const i=this.#e,o=i._rows.length-1;if(o<0)return;let r;if("string"==typeof t){if(r=i._visibleColumns.findIndex(e=>e.field===t),r<0)return}else r=t;const n=i._visibleColumns.length-1;n<0||(i._focusRow=Math.max(0,Math.min(e,o)),i._focusCol=Math.max(0,Math.min(r,n)),fe(i))}get focusedCell(){const e=this.#e;if(0===e._rows.length||0===e._visibleColumns.length)return null;const t=e._visibleColumns[e._focusCol];return{rowIndex:e._focusRow,colIndex:e._focusCol,field:t?.field??""}}scrollToRow(e,t){const i=this.#e._virtualization;if(!i.enabled)return;const o=i.container;if(!o)return;const r=this.#e._rows.length;if(0===r)return;const n=Math.max(0,Math.min(e,r-1)),s=t?.align??"nearest",l=t?.behavior??"instant";let a,d;const c=i.positionCache;i.variableHeights&&c&&c.length>n?(a=c[n].offset,d=c[n].height):(a=n*i.rowHeight,d=i.rowHeight);const h=i.viewportEl?.clientHeight??o.clientHeight??0;if(h<=0)return;const u=o.scrollTop,g=a+d,f=u+h;let p;switch(s){case"start":p=a;break;case"center":p=a-h/2+d/2;break;case"end":p=g-h;break;default:if(a>=u&&g<=f)return;p=a<u?a:g-h}p=Math.max(0,p),"smooth"===l?o.scrollTo({top:p,behavior:"smooth"}):o.scrollTop=p}scrollToRowById(e,t){const i=this.#e._getRowEntry(e);i&&this.scrollToRow(i.index,t)}registerExternalFocusContainer(e){if(this.#H.has(e))return;this.#H.add(e);const t=new AbortController,i=t.signal,o=this.#e;e.addEventListener("focusin",()=>{o.dataset.hasFocus=""},{signal:i}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete o.dataset.hasFocus},{signal:i}),this.#M.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#H.delete(e);const t=this.#M.get(e);t&&(t(),this.#M.delete(e))}containsFocus(e){const t=e??document.activeElement;return!!t&&(!!this.#e.contains(t)||this.isInExternalFocusContainer(t))}isInExternalFocusContainer(e){for(const t of this.#H)if(t.contains(e))return!0;return!1}destroy(){for(const e of this.#M.values())e();this.#M.clear(),this.#H.clear()}}const _e="function"==typeof requestIdleCallback;function ye(e){_e?cancelIdleCallback(e):clearTimeout(e)}function Re(e,t){if(t){const i=t({size:e});if("string"==typeof i){const e=document.createElement("div");return e.innerHTML=i,e}return i}return function(e){const t=document.createElement("div");return t.className=`tbw-spinner tbw-spinner--${e}`,t.setAttribute("role","progressbar"),t.setAttribute("aria-label","Loading"),t}(e)}function Se(e){let t=null,i=null,o=null,r=null;const n=o=>{if(!t)return;const r=o.clientX-t.startX,n=Math.max(40,t.startWidth+r),s=e._visibleColumns[t.colIndex];s.width=n,s.__userResized=!0,s.__renderedWidth=n,null==i&&(i=requestAnimationFrame(()=>{i=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:s.field,width:n}}))};let s=!1;const l=()=>{const i=null!==t;i&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",l),null!==o&&(document.documentElement.style.cursor=o,o=null),null!==r&&(document.body.style.userSelect=r,r=null),t=null,i&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(i,s,a){i.preventDefault();const d=e._visibleColumns[s],c="number"==typeof d?.width?d.width:void 0,h=d?.__renderedWidth??c??a.getBoundingClientRect().width;t={startX:i.clientX,colIndex:s,startWidth:h},window.addEventListener("mousemove",n),window.addEventListener("mouseup",l),null===o&&(o=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",null===r&&(r=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(t){const i=e._visibleColumns[t];i&&(i.__userResized=!1,i.__renderedWidth=void 0,i.width=i.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:i.field,width:i.width}})))},dispose(){l()}}}const Ee="data-animating",xe={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},Ae={change:500,insert:300,remove:200};function Te(e,t){const i=xe[t],o=getComputedStyle(e).getPropertyValue(i);if(o){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(o);if(!isNaN(e)&&e>0)return e}return Ae[t]}function Pe(e,t,i){if(t<0)return Promise.resolve(!1);const o=e.findRenderedRowElement?.(t);return o?new Promise(e=>{!function(e,t,i){e.removeAttribute(Ee),e.offsetWidth,e.setAttribute(Ee,t);const o=Te(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(Ee),i?.()},o)}(o,i,()=>e(!0))}):Promise.resolve(!1)}function He(e,t){if(t)return t(e);const i=e;return"id"in i&&null!=i.id?String(i.id):"_id"in i&&null!=i._id?String(i._id):void 0}function Me(e,t,i){const o=He(e,i);return void 0===o&&h("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),o}class Le{#e;constructor(e){this.#e=e}resolveRowId(e){return Me(e,this.#e.id,this.#e.effectiveConfig?.getRowId)}getRow(e){return this.#e._getRowEntry(e)?.row}getRowEntry(e){return this.#e._getRowEntry(e)}updateRow(e,t,i="api"){const o=this.#e,r=o._getRowEntry(e);r||h(l,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,o.id);const{row:n,index:s}=r,a=[];for(const[l,d]of Object.entries(t)){const e=n[l];e!==d&&(a.push({field:l,oldValue:e,newValue:d}),n[l]=d)}for(const{field:l,oldValue:d,newValue:c}of a)o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:n,rowId:e,rowIndex:s,field:l,oldValue:d,newValue:c,changes:t,source:i},bubbles:!0,composed:!0}));a.length>0&&(ce(o),o._requestSchedulerPhase(G.VIRTUALIZATION,"updateRow"),o._emitDataChange())}updateRows(e,t="api"){const i=this.#e;let o=!1;for(const{id:r,changes:n}of e){const e=i._getRowEntry(r);e||h(l,`Row with ID "${r}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id);const{row:s,index:a}=e;for(const[l,d]of Object.entries(n)){const e=s[l];e!==d&&(o=!0,s[l]=d,i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:s,rowId:r,rowIndex:a,field:l,oldValue:e,newValue:d,changes:n,source:t},bubbles:!0,composed:!0})))}}o&&(ce(i),i._requestSchedulerPhase(G.VIRTUALIZATION,"updateRows"),i._emitDataChange())}async insertRow(e,t,i=!0){const o=this.#e,r=Math.max(0,Math.min(e,o._rows.length));o.sourceRows=[...o.sourceRows,t];const n=[...o._rows];n.splice(r,0,t),o._rows=n,o._sortState&&(o.__originalOrder=[...o.__originalOrder,t]),ce(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(const s of o._rowPool)s.__epoch=-1;o.refreshVirtualWindow(!0),o._emitPluginEvent("row-inserted",{row:t,index:r}),o._emitDataChange(),i&&(await new Promise(e=>requestAnimationFrame(()=>e())),await Pe(o,r,"insert"))}async removeRow(e,t=!0){const i=this.#e,o=i._rows[e];if(!o)return;t&&await Pe(i,e,"remove");const r=i._rows.indexOf(o);if(r<0)return o;const n=[...i._rows];n.splice(r,1),i._rows=n;const s=i.sourceRows.indexOf(o);if(s>=0){const e=[...i.sourceRows];e.splice(s,1),i.sourceRows=e}if(i._sortState){const e=i.__originalOrder.indexOf(o);if(e>=0){const t=[...i.__originalOrder];t.splice(e,1),i.__originalOrder=t}}ce(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(const l of i._rowPool)l.__epoch=-1;return i.refreshVirtualWindow(!0),i._emitDataChange(),t&&requestAnimationFrame(()=>{i.querySelectorAll('[data-animating="remove"]').forEach(e=>{e.removeAttribute("data-animating")})}),o}}function De(e,t,i){const o=document.createElement(e);if(t)for(const r in t){const e=t[r];null!=e&&o.setAttribute(r,e)}return o}function Oe(e,t){const i=document.createElement("div");if(e&&(i.className=e),t)for(const o in t){const e=t[o];null!=e&&i.setAttribute(o,e)}return i}function Ie(e,t,i){const o=document.createElement("button");if(e&&(o.className=e),t)for(const r in t){const e=t[r];null!=e&&o.setAttribute(r,e)}return o}const ze=document.createElement("template");function ke(){return ze.content.cloneNode(!0)}function Ne(e){const t=document.createDocumentFragment(),i=Oe(e.hasShell?"tbw-grid-root has-shell":"tbw-grid-root");if(e.hasShell&&e.shellHeader&&e.shellBody)i.appendChild(e.shellHeader),i.appendChild(e.shellBody);else{const e=Oe("tbw-grid-content");e.appendChild(ke()),i.appendChild(e)}return t.appendChild(i),t}function qe(e){return e?"string"==typeof e?e:e.outerHTML:""}function $e(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function We(e,t){const i=e.querySelector("tbw-grid-header");if(!i)return;if(!t.lightDomTitle){const e=i.getAttribute("title");e&&(t.lightDomTitle=e)}const o=i.querySelectorAll("tbw-grid-header-content");o.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(o)),i.style.display="none"}function Fe(e,t,i){const o=e.querySelector(":scope > tbw-grid-tool-buttons");if(!o)return;t.hasToolButtonsContainer=!0;const r="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(r))return;const n={id:r,order:0,render:e=>{for(;o.firstChild;)e.appendChild(o.firstChild);return()=>{for(;e.firstChild;)o.appendChild(e.firstChild)}}};t.toolbarContents.set(r,n),t.lightDomToolbarContentIds.add(r),o.style.display="none"}function Ve(e,t,i){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const o=e,r=o.getAttribute("id"),n=o.getAttribute("title");if(!r||!n)return void u("TBW070",`Tool panel missing required id or title attribute: id="${r??""}", title="${n??""}"`);const s=o.getAttribute("icon")??void 0,l=o.getAttribute("tooltip")??void 0,a=parseInt(o.getAttribute("order")??"100",10);let d;const c=i?.(o);if(c)d=c;else{const e=o.innerHTML.trim();d=t=>{const i=document.createElement("div");return i.innerHTML=e,t.appendChild(i),()=>i.remove()}}const h=t.toolPanels.get(r);if(h){if(c){h.render=d,h.order=a,h.icon=s,h.tooltip=l;const e=t.panelCleanups.get(r);e&&(e(),t.panelCleanups.delete(r))}return}const g={id:r,title:n,icon:s,tooltip:l,order:a,render:d};t.toolPanels.set(r,g),t.lightDomToolPanelIds.add(r),o.style.display="none"})}function Ue(e,t,i){const o=t?.header?.toolbarContents??[],r=[...i.toolbarContents.values()],n=new Set(o.map(e=>e.id)),s=[...o];for(const l of r)n.has(l.id)||s.push(l);for(const l of s){if(i.toolbarContentCleanups.has(l.id))continue;if(!l.render)continue;const t=e.querySelector(`[data-toolbar-content="${l.id}"]`);if(!t)continue;const o=l.render(t);o&&i.toolbarContentCleanups.set(l.id,o)}}function Be(e,t){const i=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,o=t.headerContents.size>0;if(!i&&!o)return;const r=e.querySelector(".tbw-shell-content");if(!r)return;if(i){for(const e of t.lightDomHeaderContent)e.style.display="",r.appendChild(e);t.lightDomContentMoved=!0}const n=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of n){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let i=r.querySelector(`[data-header-content="${s.id}"]`);i||(i=document.createElement("div"),i.setAttribute("data-header-content",s.id),r.appendChild(i));const o=s.render(i);o&&t.headerContentCleanups.set(s.id,o)}}function Ge(e,t,i){if(t.isPanelOpen)for(const[o,r]of t.toolPanels){const i=t.expandedSections.has(o),n=e.querySelector(`[data-section="${o}"]`),s=n?.querySelector(".tbw-accordion-content");if(!n||!s)continue;n.classList.toggle("expanded",i);const l=n.querySelector(".tbw-accordion-header");if(l&&l.setAttribute("aria-expanded",String(i)),i){if(0===s.children.length){const e=r.render(s);e&&t.panelCleanups.set(o,e)}}else{const e=t.panelCleanups.get(o);e&&(e(),t.panelCleanups.delete(o)),s.innerHTML=""}}}function je(e,t){const i=e.querySelector("[data-panel-toggle]");i&&(i.classList.toggle("active",t.isPanelOpen),i.setAttribute("aria-pressed",String(t.isPanelOpen)))}function Xe(e,t){const i=e.querySelector(".tbw-tool-panel");i&&(i.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(i.style.width=""))}function Ye(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear(),e.lightDomContentMoved=!1}function Ke(e,t,i){const o=e.querySelector(`[data-section="${t}"]`);o&&o.classList.toggle("expanded",i)}function Ze(e,t,i,o){const r=$e(t),s=[],l=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const n of l){e.querySelectorAll(`:scope > ${n}`).forEach(e=>s.push(e))}e.replaceChildren();for(const n of s)e.appendChild(n);if(r){const r=qe(o?.toolPanel??n.toolPanel),s=qe(o?.expand??n.expand);qe(o?.collapse??n.collapse);const l=[...t?.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),a=[...t?.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100)),d={title:t?.header?.title??void 0,hasPanels:a.length>0,isPanelOpen:i.isPanelOpen,toolPanelIcon:r,configButtons:l.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},c={position:t?.toolPanel?.position??"right",isPanelOpen:i.isPanelOpen,expandIcon:s,panels:a.map(e=>({id:e.id,title:e.title,icon:qe(e.icon),isExpanded:i.expandedSections.has(e.id)}))},h=Ne({hasShell:!0,shellHeader:function(e){const t=Oe("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const i=Oe("tbw-shell-title");i.textContent=e.title,t.appendChild(i)}const i=Oe("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(i);const o=Oe("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const r of e.configButtons)r.hasRender&&o.appendChild(Oe("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));for(const r of e.apiButtons)r.hasRender&&o.appendChild(Oe("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));if((e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender))&&e.hasPanels&&o.appendChild(Oe("tbw-toolbar-separator")),e.hasPanels){const t=Ie(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.innerHTML=e.toolPanelIcon,o.appendChild(t)}return t.appendChild(o),t}(d),shellBody:function(e){const t=Oe("tbw-shell-body"),i=e.panels.length>0,o=1===e.panels.length,r=Oe("tbw-grid-content");r.appendChild(ke());let n=null;if(i){n=De("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel"});const t="left"===e.position?"right":"left";n.appendChild(Oe("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":t,"aria-hidden":"true"}));const i=Oe("tbw-tool-panel-content",{role:"presentation"}),r=Oe("tbw-accordion");for(const n of e.panels){const t=Oe(`tbw-accordion-section${n.isExpanded?" expanded":""}${o?" single":""}`,{"data-section":n.id}),i=Ie("tbw-accordion-header",{"aria-expanded":String(n.isExpanded),"aria-controls":`tbw-section-${n.id}`});if(o&&i.setAttribute("aria-disabled","true"),n.icon){const e=De("span",{class:"tbw-accordion-icon"});e.innerHTML=n.icon,i.appendChild(e)}const s=De("span",{class:"tbw-accordion-title"});if(s.textContent=n.title,i.appendChild(s),!o){const t=De("span",{class:"tbw-accordion-chevron"});t.innerHTML=e.expandIcon,i.appendChild(t)}t.appendChild(i),t.appendChild(Oe("tbw-accordion-content",{id:`tbw-section-${n.id}`,role:"presentation"})),r.appendChild(t)}i.appendChild(r),n.appendChild(i)}return"left"===e.position&&n?(t.appendChild(n),t.appendChild(r)):(t.appendChild(r),n&&t.appendChild(n)),t}(c)});e.appendChild(h)}else{const t=Ne({hasShell:!1});e.appendChild(t)}return r}ze.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n <div class="tbw-sr-only" aria-live="polite" aria-atomic="true"></div>\n';const Qe="tbw-grid-styles";let Je="";const et=new Map;function tt(){const e=function(){let e=document.getElementById(Qe);return e||(e=document.createElement("style"),e.id=Qe,e.setAttribute("data-tbw-grid","true"),document.head.appendChild(e)),e}(),t=Array.from(et.values()).join("\n");e.textContent=`${Je}\n\n/* Plugin Styles */\n${t}`}async function it(e){if(Je)return;if("string"==typeof e&&e.length>0)return Je=e,void tt();await new Promise(e=>setTimeout(e,50));const t=function(){try{for(const e of Array.from(document.styleSheets))try{const t=Array.from(e.cssRules||[]).map(e=>e.cssText).join("\n");if(t.includes(".tbw-grid-root")&&t.includes("tbw-grid"))return t}catch{continue}}catch(e){u("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(Je=t,tt()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||u("TBW121",`Could not find grid.css in document.styleSheets. Grid styling will not work. Available stylesheets: ${Array.from(document.styleSheets).map(e=>e.href||"(inline)").join(", ")}`)}function ot(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function rt(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function nt(e,t){(Math.abs(e.velocityY)>.1||Math.abs(e.velocityX)>.1)&&function(e,t){const i=.95,o=.01,r=()=>{e.velocityY*=i,e.velocityX*=i;const n=16*e.velocityY,s=16*e.velocityX;Math.abs(e.velocityY)>o&&(t.fauxScrollbar.scrollTop+=n),Math.abs(e.velocityX)>o&&t.scrollArea&&(t.scrollArea.scrollLeft+=s),Math.abs(e.velocityY)>o||Math.abs(e.velocityX)>o?e.momentumRaf=requestAnimationFrame(r):e.momentumRaf=0};e.momentumRaf=requestAnimationFrame(r)}(e,t),ot(e)}function st(e,t,i,o){e.addEventListener("pointerdown",i=>{"touch"===i.pointerType&&null===t.activePointerId&&(t.activePointerId=i.pointerId,e.setPointerCapture(i.pointerId),function(e,t,i){rt(i),i.startY=t,i.startX=e,i.lastY=t,i.lastX=e,i.lastTime=performance.now(),i.velocityY=0,i.velocityX=0,i.locked=!1}(i.clientX,i.clientY,t))},{passive:!0,signal:o}),e.addEventListener("pointermove",e=>{if(e.pointerId!==t.activePointerId)return;const o=function(e,t,i,o){if(null===i.lastY||null===i.lastX)return!1;const r=performance.now(),n=i.lastY-t,s=i.lastX-e;if(null!==i.lastTime){const e=r-i.lastTime;e>0&&(i.velocityY=n/e,i.velocityX=s/e)}if(i.lastY=t,i.lastX=e,i.lastTime=r,i.locked)return o.fauxScrollbar.scrollTop+=n,o.scrollArea&&(o.scrollArea.scrollLeft+=s),!0;const l=null!==i.startY?Math.abs(i.startY-t):0,a=null!==i.startX?Math.abs(i.startX-e):0;if(l<3&&a<3)return!1;const d=l>=a,{scrollHeight:c,clientHeight:h}=o.fauxScrollbar,u=c-h>0;let g=!1;if(o.scrollArea){const{scrollWidth:e,clientWidth:t}=o.scrollArea;g=e-t>0}return!!(d&&u||!d&&g)&&(i.locked=!0,o.fauxScrollbar.scrollTop+=n,o.scrollArea&&(o.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,i);o&&e.preventDefault()},{passive:!1,signal:o}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,nt(t,i))},{passive:!0,signal:o}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,ot(t))},{passive:!0,signal:o}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,ot(t))},{passive:!0,signal:o})}const lt=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',isUsed:e=>!0===e||"function"==typeof e},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property'},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property'},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property'},{property:"pinned",pluginName:"pinnedColumns",level:"column",description:'the "pinned" column property',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property (deprecated, use "pinned")',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e}],at=[{property:"rowEditable",pluginName:"editing",level:"config",description:'the "rowEditable" config property',isUsed:e=>"function"==typeof e},{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',isUsed:e=>Array.isArray(e)&&e.length>0}];function dt(e){return`import { ${ct(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function ct(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ht(e,t){return e.some(e=>e.name===t)}function ut(e,t){return e&&"object"==typeof e?"__rowCacheKey"in e?e.__rowCacheKey:"rowId"in e&&null!=e.rowId?`id:${e.rowId}`:t?`id:${t(e)}`:e:e}function gt(e,t,i){const o=ut(t,i);return"string"==typeof o?e.byKey.get(o):o&&"object"==typeof o?e.byRef.get(o):void 0}function ft(e,t,i){if(t<0||t>=e.length)return;const o=e[t],r=i-o.height;if(0!==r){o.height=i,o.measured=!0;for(let i=t+1;i<e.length;i++)e[i].offset+=r}}function pt(e,t){if(0===e.length)return-1;if(t<=0)return 0;let i=0,o=e.length-1;for(;i<=o;){const r=Math.floor((i+o)/2),n=e[r],s=n.offset+n.height;if(t<n.offset)o=r-1;else{if(!(t>=s))return r;i=r+1}}return Math.max(0,Math.min(i,e.length-1))}function wt(e,t){const{positionCache:i,heightCache:o,rows:r,start:n,end:s,getPluginHeight:l,getRowId:a}=e;let d=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const c=parseInt(t,10);if(c<n||c>=s||c>=r.length)return;const h=r[c],u=l?.(h,c);if(void 0!==u){const e=i[c];return void((!e.measured||Math.abs(e.height-u)>1)&&(ft(i,c,u),d=!0))}const g=e.offsetHeight;if(g>0){const e=i[c];(!e.measured||Math.abs(e.height-g)>1)&&(ft(i,c,g),function(e,t,i,o){const r=ut(t,o);"string"==typeof r?e.byKey.set(r,i):r&&"object"==typeof r&&e.byRef.set(r,i)}(o,h,g,a),d=!0)}});const c=d?function(e){let t=0;for(const i of e)i.measured&&t++;return t}(i):0,h=d?function(e,t){let i=0,o=0;for(const r of e)r.measured&&(i+=r.height,o++);return o>0?i/o:t}(i,e.defaultHeight):0;return{hasChanges:d,measuredCount:c,averageHeight:h}}class bt{#e;state;constructor(e,t){this.#e=e,this.state={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null,positionCache:null,heightCache:{byKey:new Map,byRef:new WeakMap},averageHeight:28,measuredCount:0,variableHeights:!1,cachedViewportHeight:0,cachedFauxHeight:0,cachedScrollAreaHeight:0,scrollAreaEl:null,...t}}updateCachedGeometry(){const e=this.state,t=e.container,i=e.viewportEl??t;i&&(e.cachedViewportHeight=i.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const o=e.scrollAreaEl;o&&(e.cachedScrollAreaHeight=o.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const i=this.state;let o,r,n;if(t){const e=i.container??this.#e._hostElement,t=i.viewportEl??e,s=i.scrollAreaEl;o=e?.clientHeight??0,r=t?.clientHeight??0,n=s?s.clientHeight:o,i.cachedFauxHeight=o,i.cachedViewportHeight=r,i.cachedScrollAreaHeight=n}else o=i.cachedFauxHeight,r=i.cachedViewportHeight,n=i.cachedScrollAreaHeight||o;const s=n-r,l=Math.max(0,o-n);let a,d=0;return i.variableHeights&&i.positionCache?a=function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(i.positionCache):(a=e*i.rowHeight,d=this.#e._getPluginExtraHeight()),a+s+d+l}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#e,i=t._rows,o=e.rowHeight||28,r=t.effectiveConfig?.rowHeight,n=t.effectiveConfig?.getRowId,s=n?e=>n(e):void 0;e.positionCache=function(e,t,i,o,r){const n=new Array(e.length);let s=0;for(let l=0;l<e.length;l++){const a=e[l];let d=r?.(a,l),c=void 0!==d;void 0===d&&(d=gt(t,a,o.rowId),c=void 0!==d),void 0===d&&(d=i,c=!1),n[l]={offset:s,height:d,measured:c},s+=d}return n}(i,e.heightCache,o,{rowId:s},(e,i)=>{const o=t._getPluginRowHeight(e,i);if(void 0!==o)return o;if(r){const t=r(e,i);if(void 0!==t&&t>0)return t}});const l=function(e,t,i,o){let r=0,n=0;for(let s=0;s<e.length;s++){const i=e[s];if(i.measured){const e=o?.(t[s],s);void 0===e&&(n+=i.height,r++)}}return{measuredCount:r,averageHeight:r>0?n/r:i}}(e.positionCache,i,o,(e,i)=>t._getPluginRowHeight(e,i));e.measuredCount=l.measuredCount,l.measuredCount>0&&(e.averageHeight=l.averageHeight)}invalidateRowHeight(e,t){const i=this.state;if(!i.variableHeights)return;if(!i.positionCache)return;const o=this.#e._rows;if(e<0||e>=o.length)return;const r=o[e];let n=t;void 0===n&&(n=this.#e._getPluginRowHeight(r,e)),void 0===n&&(n=i.rowHeight);const s=i.positionCache[e];if(s&&!(Math.abs(s.height-n)<1)&&(ft(i.positionCache,e,n),i.totalHeightEl)){const e=this.calculateTotalSpacerHeight(o.length);i.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const i=this.state;if(!i.variableHeights)return;if(!i.positionCache)return;const o=this.#e,r=o._bodyEl;if(!r)return;const n=r.querySelectorAll(".data-grid-row"),s=o.effectiveConfig?.getRowId,l=o._rows,a=wt({positionCache:i.positionCache,heightCache:i.heightCache,rows:l,defaultHeight:i.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>o._getPluginRowHeight(e,t),getRowId:s?e=>s(e):void 0},n);if(a.hasChanges&&(i.measuredCount=a.measuredCount,i.averageHeight=a.averageHeight,i.totalHeightEl)){const e=this.calculateTotalSpacerHeight(l.length);i.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){const i=this.state,o=this.#e,r=o._bodyEl;if(!r)return!1;const n=o._rows.length;if(!i.enabled)return o._renderVisibleRows(0,n),t||o._afterPluginRender(),!0;if(n<=i.bypassThreshold)return i.start=0,i.end=n,e&&(r.style.transform="translateY(0px)"),o._renderVisibleRows(0,n,o.__rowRenderEpoch),e&&i.variableHeights&&this.initializePositionCache(),e&&i.totalHeightEl&&(i.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(n,!0)}px`),o._updateAriaCounts(n,o._visibleColumns.length),t||o._afterPluginRender(),!0;const s=i.container,l=i.viewportEl??s,a=e?i.cachedViewportHeight=l.clientHeight:i.cachedViewportHeight||(i.cachedViewportHeight=l.clientHeight),d=i.rowHeight,c=s.scrollTop;let h;e&&i.variableHeights&&this.initializePositionCache();const u=i.positionCache;if(i.variableHeights&&u&&u.length>0)h=pt(u,c),-1===h&&(h=0);else{h=Math.floor(c/d);let e=0;const t=10;for(;e<t;){const t=o._getPluginExtraHeightBefore(h),i=Math.floor((c-t)/d);if(i>=h||i<0)break;h=i,e++}}h-=h%2,h<0&&(h=0);const g=o._adjustPluginVirtualStart(h,c,d);let f;if(void 0!==g&&g<h&&(h=g,h-=h%2,h<0&&(h=0)),i.variableHeights&&u&&u.length>0){const e=a+3*d;let t=0;for(f=h;f<n&&t<e;)t+=u[f].height,f++;const i=Math.ceil(a/d)+3;f-h<i&&(f=Math.min(h+i,n))}else{f=h+(Math.ceil(a/d)+3)}f>n&&(f=n);const p=i.start,w=i.end;if(!e&&h===p&&f===w)return!1;i.start=h,i.end=f;const b=e?i.cachedFauxHeight=s.clientHeight:i.cachedFauxHeight||(i.cachedFauxHeight=s.clientHeight);if(e){const e=i.scrollAreaEl;e&&(i.cachedScrollAreaHeight=e.clientHeight)}if(0===b&&a>0)return o._requestSchedulerPhase(G.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&i.totalHeightEl){const e=this.calculateTotalSpacerHeight(n);i.totalHeightEl.style.height=`${e}px`}let m;if(i.variableHeights&&u&&u[h])m=u[h].offset;else{m=h*d+o._getPluginExtraHeightBefore(h)}const v=-(c-m);return r.style.transform=`translateY(${v}px)`,o._renderVisibleRows(h,f,o.__rowRenderEpoch),e&&i.variableHeights&&this.measureRenderedRowHeights(h,f),o._updateAriaCounts(n,o._visibleColumns.length),e&&!t&&(o._afterPluginRender(),queueMicrotask(()=>{if(!i.totalHeightEl)return;const e=this.calculateTotalSpacerHeight(n);0===i.cachedFauxHeight&&i.cachedViewportHeight>0||(i.totalHeightEl.style.height=`${e}px`)})),!0}}class mt{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=new Map;cellRenderers=new Map;headerRenderers=new Map;cellEditors=new Map;_hasAfterCellRender=!1;_hasAfterRowRender=!1;eventListeners=new Map;queryHandlers=new Map;static deprecationWarned=new WeakSet;attachAll(e){for(const t of e)this.attach(t)}attach(e){if(function(e,t,i){const o=e.name,r=e.constructor.dependencies??[];for(const n of r){const e=n.name,r=n.required??!0,s=n.reason;if(!t.some(t=>t.name===e)){const t=s??`${ct(o)}Plugin requires ${ct(e)}Plugin`,n=dt(e);r?h("TBW020",`Plugin dependency error:\n\n${t}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${ct(o)}Plugin:\n ${n}\n plugins: [new ${ct(e)}Plugin(), new ${ct(o)}Plugin()]`,i):g("TBW021",`${ct(o)}Plugin: Optional "${e}" plugin not found. Some features may be unavailable.`,i)}}}(e,this.plugins,this.grid.getAttribute("id")??void 0),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);this.registerQueryHandlers(e),this.warnDeprecatedHooks(e),e.attach(this.grid),this.#L();for(const t of this.plugins)t!==e&&t.onPluginAttached&&t.onPluginAttached(e.name,e)}registerQueryHandlers(e){const t=e.constructor.manifest;if(t?.queries)for(const i of t.queries){let t=this.queryHandlers.get(i.type);t||(t=new Set,this.queryHandlers.set(i.type,t)),t.add(e)}}warnDeprecatedHooks(e){const t=e.constructor;if(mt.deprecationWarned.has(t))return;if(!Y())return;const i="function"==typeof e.getExtraHeight||"function"==typeof e.getExtraHeightBefore,o="function"==typeof e.getRowHeight;i&&!o&&(mt.deprecationWarned.add(t),u("TBW023",`"${e.name}" uses getExtraHeight() / getExtraHeightBefore() which are deprecated and will be removed in v2.0.\n → Migrate to getRowHeight(row, index) for better variable row height support.`,this.grid.getAttribute("id")??void 0))}unregisterQueryHandlers(e){for(const[t,i]of this.queryHandlers)i.delete(e),0===i.size&&this.queryHandlers.delete(t)}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--){const t=this.plugins[e];this.unsubscribeAll(t),this.unregisterQueryHandlers(t),t.detach()}this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear(),this.eventListeners.clear(),this.queryHandlers.clear(),this._hasAfterCellRender=!1,this._hasAfterRowRender=!1}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(t=>t.name===e||t.aliases?.includes(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._hasAfterCellRender}afterRowRender(e){for(const t of this.plugins)t.afterRowRender?.(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#L(){this._hasAfterCellRender=this.plugins.some(e=>"function"==typeof e.afterCellRender),this._hasAfterRowRender=this.plugins.some(e=>"function"==typeof e.afterRowRender)}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const t of this.plugins)"function"==typeof t.getExtraHeight&&(e+=t.getExtraHeight());return e}hasExtraHeight(){for(const e of this.plugins)if("function"==typeof e.getExtraHeight&&e.getExtraHeight()>0)return!0;return!1}getExtraHeightBefore(e){let t=0;for(const i of this.plugins)"function"==typeof i.getExtraHeightBefore&&(t+=i.getExtraHeightBefore(e));return t}getRowHeight(e,t){for(const i of this.plugins)if("function"==typeof i.getRowHeight){const o=i.getRowHeight(e,t);if(void 0!==o)return o}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,i){let o=e;for(const r of this.plugins)if("function"==typeof r.adjustVirtualStart){const n=r.adjustVirtualStart(e,t,i);n<o&&(o=n)}return o}renderRow(e,t,i){for(const o of this.plugins)if(o.renderRow?.(e,t,i))return!0;return!1}queryPlugins(e){const t=[],i=this.queryHandlers.get(e.type);if(i&&i.size>0){for(const o of i){const i=o.handleQuery?.(e)??o.onPluginQuery?.(e);void 0!==i&&t.push(i)}return t}for(const o of this.plugins){const i=o.handleQuery?.(e)??o.onPluginQuery?.(e);void 0!==i&&t.push(i)}return t}subscribe(e,t,i){let o=this.eventListeners.get(t);o||(o=new Map,this.eventListeners.set(t,o)),o.set(e,i)}unsubscribe(e,t){const i=this.eventListeners.get(t);i&&(i.delete(e),0===i.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,i]of this.eventListeners)i.delete(e),0===i.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const i=this.eventListeners.get(e);if(i)for(const r of i.values())try{r(t)}catch(o){f("TBW024",`Error in plugin event handler for "${e}": ${o}`,this.grid.getAttribute("id")??void 0)}}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,o=0,r=!1;for(const n of this.plugins){const s=n.getHorizontalScrollOffsets?.(e,t);s&&(i+=s.left,o+=s.right,s.skipScroll&&(r=!0))}return{left:i,right:o,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((e,t)=>(e.panel.order??0)-(t.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((e,t)=>(e.content.order??0)-(t.content.order??0))}}class vt extends HTMLElement{static tagName="tbw-grid";static version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";static#D=0;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","loading"]}get#O(){return this}#I=!1;#o;#r;#z=[];get#p(){return this.#k?.effective??{}}#N=!1;#q=!1;#$={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#W;#F=0;#V=null;#U=!1;#B=!1;#G=0;#j;#X={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#Y;#K;#Z;#Q;#J={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#ee;#te;#ie;#oe;#re;#ne;get _pluginManager(){return this.#ee}#se=!1;#le;#ae;#_;#k;#de=function(){return{toolPanels:new Map,headerContents:new Map,toolbarContents:new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:new Set,lightDomToolbarContentIds:new Set,apiToolPanelIds:new Set,apiHeaderContentIds:new Set,isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarContentCleanups:new Map,lightDomContentMoved:!1}}();#ce;#he;#ue;#ge=!1;#fe=new Set;#pe=new Map;#we;#be=new Map;_rows=[];#me=[];get _columns(){return this.#p.columns??[]}set _columns(e){this.#p.columns=e,this.#ve=void 0}#ve;get _visibleColumns(){return this.#ve??=this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#oe.state}set _virtualization(e){Object.assign(this.#oe.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#k?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#k&&(this.#k.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#k?.originalColumnNodes}set __originalColumnNodes(e){this.#k&&(this.#k.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=this.#z;this.#z=e,t!==e&&this.#Ce("rows")}get sourceRows(){return this.#z}set sourceRows(e){this.#z=e}get columns(){return[...this._columns]}set columns(e){const t=this.#k?.getColumns();this.#k?.setColumns(e),t!==e&&this.#Ce("columns")}get gridConfig(){return this.#p}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#k?.getGridConfig();this.#k?.setGridConfig(e),t!==e&&(this.#k.clearLightDomCache(),this.#Ce("gridConfig"))}get fitMode(){return this.#p.fitMode??"stretch"}set fitMode(e){const t=this.#k?.getFitMode();this.#k?.setFitMode(e),t!==e&&this.#Ce("fitMode")}get loading(){return this.#ge}set loading(e){const t=this.#ge;this.#ge=e,e?this.setAttribute("loading",""):this.removeAttribute("loading"),t!==e&&this.#_e()}setRowLoading(e,t){const i=this.#fe.has(e);t?this.#fe.add(e):this.#fe.delete(e),i!==t&&this.#ye(e,t)}setCellLoading(e,t,i){let o=this.#pe.get(e);const r=o?.has(t)??!1;i?(o||(o=new Set,this.#pe.set(e,o)),o.add(t)):(o?.delete(t),0===o?.size&&this.#pe.delete(e)),r!==i&&this.#Re(e,t,i)}isRowLoading(e){return this.#fe.has(e)}isCellLoading(e,t){return this.#pe.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#fe)this.#ye(e,!1);this.#fe.clear();for(const[e,t]of this.#pe)for(const i of t)this.#Re(e,i,!1);this.#pe.clear()}get effectiveConfig(){return this.#p}get disconnectSignal(){return this.#Y||(this.#Y=new AbortController),this.#Y.signal}constructor(){super(),this.#Se(),this.#o=new Promise(e=>this.#r=e),this.#oe=new bt(this),this.#re=new Ce(this),this.#ne=new Le(this),this.#W=new j(this),this.#W.setInitialReadyResolver(()=>this.#r?.()),this.#ce=function(e,t){let i=!1;const o={get isInitialized(){return i},setInitialized(e){i=e},get isPanelOpen(){return e.isPanelOpen},get activePanel(){return e.isPanelOpen&&e.expandedSections.size>0?[...e.expandedSections][0]:null},get expandedSections(){return[...e.expandedSections]},openToolPanel(){if(e.isPanelOpen)return;if(0===e.toolPanels.size)return void u("TBW071","No tool panels registered",t.id);if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0){const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}const i=t._renderRoot;je(i,e),Xe(i,e),Ge(i,e,t._accordionIcons),t._emit("tool-panel-open",{sections:o.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolPanels.values())t.onClose?.();e.isPanelOpen=!1;const i=t._renderRoot;je(i,e),Xe(i,e),t._emit("tool-panel-close",{})},toggleToolPanel(){e.isPanelOpen?o.closeToolPanel():o.openToolPanel()},toggleToolPanelSection(i){const o=e.toolPanels.get(i);if(!o)return void u("TBW072",`Tool panel section "${i}" not found`,t.id);if(1===e.toolPanels.size)return;const r=t._renderRoot,n=e.expandedSections.has(i);if(n){const t=e.panelCleanups.get(i);t&&(t(),e.panelCleanups.delete(i)),o.onClose?.(),e.expandedSections.delete(i),Ke(r,i,!1)}else{for(const[t,o]of e.toolPanels)if(t!==i&&e.expandedSections.has(t)){const i=e.panelCleanups.get(t);i&&(i(),e.panelCleanups.delete(t)),o.onClose?.(),e.expandedSections.delete(t),Ke(r,t,!1);const n=r.querySelector(`[data-section="${t}"] .tbw-accordion-content`);n&&(n.innerHTML="")}e.expandedSections.add(i),Ke(r,i,!0),function(e,t,i){const o=t.toolPanels.get(i);if(!o?.render)return;const r=e.querySelector(`[data-section="${i}"] .tbw-accordion-content`);if(!r)return;const n=o.render(r);n&&t.panelCleanups.set(i,n)}(r,e,i)}t._emit("tool-panel-section-toggle",{id:i,expanded:!n})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(o){e.toolPanels.has(o.id)?u("TBW073",`Tool panel "${o.id}" already registered`,t.id):(e.toolPanels.set(o.id,o),i&&t.refreshShellHeader?.())},unregisterToolPanel(o){if(e.expandedSections.has(o)){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),e.expandedSections.delete(o)}e.toolPanels.delete(o),i&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(o){e.headerContents.has(o.id)?u("TBW074",`Header content "${o.id}" already registered`,t.id):(e.headerContents.set(o.id,o),i&&Be(t._renderRoot,e))},unregisterHeaderContent(i){const o=e.headerContentCleanups.get(i);o&&(o(),e.headerContentCleanups.delete(i));const r=e.headerContents.get(i);r?.onDestroy?.(),e.headerContents.delete(i);const n=t._renderRoot.querySelector(`[data-header-content="${i}"]`);n?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(o){e.toolbarContents.has(o.id)?u("TBW075",`Toolbar content "${o.id}" already registered`,t.id):(e.toolbarContents.set(o.id,o),i&&t.refreshShellHeader?.())},unregisterToolbarContent(o){const r=e.toolbarContentCleanups.get(o);r&&(r(),e.toolbarContentCleanups.delete(o));const n=e.toolbarContents.get(o);n?.onDestroy&&n.onDestroy(),e.toolbarContents.delete(o),i&&t.refreshShellHeader?.()}};return o}(this.#de,this),this.#k=new X(this)}async#Se(){await it('@layer tbw-base, tbw-plugins, tbw-theme;\n\n@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-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--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-v: var(--tbw-spacing-xs);--tbw-cell-padding-h: var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-cell-padding-v) var(--tbw-cell-padding-h);--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-width: 1px;--tbw-border-style: solid;--tbw-border-input: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-strong);--tbw-border-header: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-header);--tbw-row-divider: var(--tbw-border-width) var(--tbw-border-style) 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-width: 2px;--tbw-focus-outline: var(--tbw-focus-outline-width) var(--tbw-border-style) 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-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-display: inline-flex;--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)}}\n@layer tbw-base{tbw-grid{color-scheme:inherit;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);font-feature-settings:"tnum","lnum";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 .tbw-grid-root{position:relative;display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root:has(.selected){-webkit-user-select:none;user-select:none}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;touch-action:none}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);touch-action:none}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid .tbw-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}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)}}\n@layer tbw-base{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);text-transform:var(--tbw-header-text-transform);letter-spacing:var(--tbw-header-letter-spacing)}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;color:var(--tbw-sort-indicator-color);display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}tbw-grid .header-row>.cell:hover>span[part~=sort-indicator]{display:inline-flex;visibility:visible}tbw-grid .header-row>.cell[aria-sort=ascending]>span[part~=sort-indicator],tbw-grid .header-row>.cell[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color)}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell:last-child .resize-handle{right:0;width:calc(var(--tbw-resize-handle-width) / 2)}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 .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}}\n@layer tbw-base{tbw-grid .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style}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);align-content:center;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}}\n@layer tbw-base{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;touch-action:none}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}}\n@layer tbw-base{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:var(--tbw-z-layer-toolpanel, 31);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:start;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}}\n@layer tbw-base{.tbw-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:1000;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-spinner{--tbw-spinner-size: 48px;--tbw-spinner-border-width: 3px;--tbw-spinner-color: var(--tbw-color-accent);--tbw-spinner-track-color: var(--tbw-color-border);width:var(--tbw-spinner-size);height:var(--tbw-spinner-size);border:var(--tbw-spinner-border-width) solid var(--tbw-spinner-track-color);border-top-color:var(--tbw-spinner-color);border-radius:50%;animation:tbw-spin .8s linear infinite}.tbw-spinner--large{--tbw-spinner-size: min(48px, calc(100% - 16px) )}.tbw-spinner--small{--tbw-spinner-size: calc(var(--tbw-row-height, 28px) * .6);--tbw-spinner-border-width: 2px}.data-grid-row.tbw-row-loading{position:relative;pointer-events:none}.tbw-row-loading-overlay{position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out;pointer-events:none;display:flex;align-items:center}.tbw-row-loading-spinner{--_spinner-size: calc(var(--tbw-row-height, 28px) * .6);margin-left:var(--tbw-spacing-md);width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite}.cell.tbw-cell-loading{position:relative;pointer-events:none}.cell.tbw-cell-loading:before{content:"";position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out}.cell.tbw-cell-loading:after{--_spinner-size: calc(var(--tbw-row-height, 28px) * .5);content:"";position:absolute;left:var(--tbw-spacing-sm);top:0;bottom:0;margin:auto 0;width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite;z-index:27}}\n@layer tbw-base{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}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}}@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)}}@keyframes tbw-spin{to{transform:rotate(360deg)}}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}\n@layer tbw-base{@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}}}\n')}getPlugin(e){return this.#ee?.getPlugin(e)}getPluginByName(e){return this.#ee?.getPluginByName(e)}requestRender(){this.#W.requestPhase(G.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#W.requestPhase(G.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#W.requestPhase(G.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){C(this)}requestAfterRender(){this.#W.requestPhase(G.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this._virtualization.start=-1,this.refreshVirtualWindow(!1)}#Ee(){this.#ee=new mt(this);const e=this.#p?.plugins,t=Array.isArray(e)?e:[],i=this.#p?.features;let o=[];i&&ve&&(o=ve(i));const r=o.length>0?[...o,...t]:t;this.#ee.attachAll(r)}#xe(){!function(e){let t=!1;for(const{name:i,styles:o}of e)et.has(i)||(et.set(i,o),t=!0);t&&tt()}(this.#ee?.getPluginStyles()??[])}#Ae(){const e=this.#p?.plugins,t=Array.isArray(e)?e:[],i=this.#p?.features??void 0,o=i!==this.#ie;if((this.#te===t||void 0!==this.#te&&this.#te.length===t.length&&this.#te.every((e,i)=>e===t[i]))&&!o)return void(this.#te=t);this.#ee&&this.#ee.detachAll();for(const n of this.#de.toolPanels.keys()){const e=this.#de.lightDomToolPanelIds.has(n),t=this.#de.apiToolPanelIds.has(n);if(!e&&!t){const e=this.#de.panelCleanups.get(n);e&&(e(),this.#de.panelCleanups.delete(n)),this.#de.toolPanels.delete(n)}}for(const n of this.#de.headerContents.keys()){if(this.#de.apiHeaderContentIds.has(n))continue;const e=this.#de.headerContentCleanups.get(n);e&&(e(),this.#de.headerContentCleanups.delete(n)),this.#de.headerContents.delete(n)}this.#Ee(),this.#xe(),this.#te=t,this.#ie=i,this.#Te(),this.#Pe();const r=this.#U;if(this.#U=this.#ee?.getAll().some(e=>e.onScroll)??!1,!r&&this.#U){const e=this.#O.querySelector(".tbw-grid-content")??this.#O.querySelector(".tbw-grid-root");this.#He(e)}}#Me(){this.#ee?.detachAll()}#Pe(){if(!this.#ee)return;const e=this.#ee.getToolPanels();for(const{panel:i}of e)this.#de.toolPanels.has(i.id)||this.#de.toolPanels.set(i.id,i);const t=this.#ee.getHeaderContents();for(const{content:i}of t)this.#de.headerContents.has(i.id)||this.#de.headerContents.set(i.id,i)}#Le(){const e=vt.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return i=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(i);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(i);if(e)return e}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",vt.version),this.id||(this.id="tbw-grid-"+ ++vt.#D),this._rows=Array.isArray(this.#z)?[...this.#z]:[],this.#Y&&(this.#Y.abort(),this.#se=!1),this.#Y=new AbortController,this.#Q&&(ye(this.#Q),this.#Q=void 0),this.#De(),this.#k.parseLightDomColumns(this),this.#k.merge(),this.#Ee();const e=this.#p?.plugins;var t,i;this.#te=Array.isArray(e)?e:[],this.#ie=this.#p?.features??void 0,this.#Pe(),this.#I||(this.#Oe(),this.#xe(),this.#I=!0),this.#Ie(),this.#Q=(t=()=>{this.#ze()},i={timeout:100},_e?requestIdleCallback(t,i):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#Q&&(ye(this.#Q),this.#Q=void 0),this.#G&&(clearTimeout(this.#G),this.#G=0),this.#Me(),function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const i=e.toolPanels.get(t);i?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#de),this.#ce.setInitialized(!1),this.#he?.(),this.#he=void 0,this.#ue?.(),this.#ue=void 0,rt(this.#X),this.#Y&&(this.#Y.abort(),this.#Y=void 0),this.#le?.abort(),this.#le=void 0,this.#se=!1,this._resizeController&&this._resizeController.dispose(),this.#K&&(this.#K.disconnect(),this.#K=void 0),this.#Z&&(this.#Z.disconnect(),this.#Z=void 0,this.#ke=!1),ce(this),this.#Ne.clear(),this._virtualization.heightCache?.byKey.clear(),this.#te=void 0,this.#ie=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#N=!1}attributeChangedCallback(e,t,i){if("loading"===e){const e=null!==i&&"false"!==i;return void(this.loading!==e&&(this.loading=e))}if(t!==i&&i&&"null"!==i&&"undefined"!==i)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(i);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{u("TBW130",`Invalid JSON for '${e}' attribute: ${i}`,this.id)}else"fit-mode"===e&&(this.fitMode=i)}#Ie(){const e=this.#O.querySelector(".tbw-grid-content")??this.#O.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.#ce.isInitialized){Be(this.#O,this.#de),Ue(this.#O,this.#p?.shell,this.#de);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#de.toolPanels.has(e)&&(this.openToolPanel(),this.#de.expandedSections.add(e)),this.#de.isPanelOpen&&(Xe(this.#O,this.#de),Ge(this.#O,this.#de,(this.#p,this.#p)),je(this.#O,this.#de))}if(this.setAttribute("data-upgraded",""),this.#N=!0,this._resizeController=Se(this),this.#qe(),this.#He(e),this.#se)return;this.#se=!0;const t=this.disconnectSignal;me(this,this,this.#O,t),this.#Te(),queueMicrotask(()=>this.#$e()),this.#W.requestPhase(G.FULL,"afterConnect")}#Te(){const e=this.#p.rowHeight,t=this.#ee.hasRowHeightPlugin();"function"==typeof e||t?this._virtualization.variableHeights||(this._virtualization.variableHeights=!0,this._virtualization.rowHeight="number"==typeof e&&e>0?e:this._virtualization.rowHeight||28,this.#oe.initializePositionCache(),"function"!=typeof e&&(this.#B=!0)):!t&&"function"!=typeof e&&this._virtualization.variableHeights?(this._virtualization.variableHeights=!1,this._virtualization.positionCache=null):"number"==typeof e&&e>0?(this._virtualization.rowHeight=e,this._virtualization.variableHeights=!1):requestAnimationFrame(()=>this.#We())}#We(){if(this.#ee.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;if(e.style.getPropertyValue("--tbw-row-height"))return;const t=e.querySelectorAll(".cell");let i=0;t.forEach(e=>{const t=e.offsetHeight;t>i&&(i=t)});const o=e.getBoundingClientRect(),r=Math.max(o.height,i);r>0&&r-this._virtualization.rowHeight>1&&(this._virtualization.rowHeight=r,this.#W.requestPhase(G.VIRTUALIZATION,"measureRowHeight"))}#Fe(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let i=0;t.forEach(e=>{const t=e.offsetHeight;t>i&&(i=t)});const o=e.getBoundingClientRect(),r=Math.max(o.height,i);if(r>0){if(Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r),this.#oe.initializePositionCache(),this._virtualization.totalHeightEl){const e=this.#oe.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#He(e){this.#le?.abort(),this.#le=new AbortController;const t=this.#le.signal,i=e?.querySelector(".faux-vscroll"),o=e?.querySelector(".rows");if(this._virtualization.container=i??this,this.#U=this.#ee?.getAll().some(e=>e.onScroll)??!1,i&&o){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#U)return;const e=i.scrollTop,t=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)o.style.transform=`translateY(${-e}px)`;else{const i=this._virtualization.positionCache;let r,n;if(this._virtualization.variableHeights&&i&&i.length>0){r=pt(i,e),-1===r&&(r=0);const o=r-r%2;n=i[o]?.offset??o*t}else{r=Math.floor(e/t);n=(r-r%2)*t}const s=-(e-n);o.style.transform=`translateY(${s}px)`}this.#V=e,this.#F||(this.#F=requestAnimationFrame(()=>{this.#F=0,null!==this.#V&&(this.#Ve(this.#V),this.#V=null)}))},{passive:!0,signal:t});const e=this.#O.querySelector(".tbw-scroll-area");this.#ae=e,this._virtualization.scrollAreaEl=e,e&&this.#U&&e.addEventListener("scroll",()=>{const t=this.#J;t.scrollTop=i.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=i.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=i.clientHeight,t.clientWidth=e.clientWidth,this.#ee?.onScroll(t)},{passive:!0,signal:t});const r=this.#O.querySelector(".tbw-grid-content"),n=this.#ae;r&&(r.addEventListener("wheel",e=>{try{if(r.querySelector("select:open"))return}catch{}const t=e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY);if(t&&n){const t=e.shiftKey?e.deltaY:e.deltaX,{scrollLeft:i,scrollWidth:o,clientWidth:r}=n;(t>0&&i<o-r||t<0&&i>0)&&(e.preventDefault(),n.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:o,clientHeight:r}=i;(e.deltaY>0&&t<o-r||e.deltaY<0&&t>0)&&(e.preventDefault(),i.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),st(r,this.#X,{fauxScrollbar:i,scrollArea:n},t))}var r,n,s;this._bodyEl&&(r=this,n=this._bodyEl,s=t,n.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");if(!t)return;if(t.classList.contains("editing"))return;const i=e.target;i.draggable||i.closest('[draggable="true"]')||e.preventDefault(),we(r,t)},{signal:s}),n.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&ge(r,e,t),!document.activeElement?.closest(".cell.editing")){const t=e.target.closest("tbw-grid");t&&t.focus({preventScroll:!0})}},{signal:s}),n.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&ge(r,e,t)},{signal:s})),this.#K?.disconnect(),this._virtualization.viewportEl&&(this.#K=new ResizeObserver(()=>{this.#Ue(),this.#W.requestPhase(G.VIRTUALIZATION,"resize-observer")}),this.#K.observe(this._virtualization.viewportEl)),this.#O.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#O.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#O.contains(t)||this.#re.isInExternalFocusContainer(t))||delete this.dataset.hasFocus},{signal:t})}#ke=!1;#Be(){if(this.#ke)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#ke=!0,this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#We()}),this.#Z.observe(e))}addEventListener(e,t,i){super.addEventListener(e,t,i)}removeEventListener(e,t,i){super.removeEventListener(e,t,i)}on(e,t){const i=e=>{t(e.detail,e)};return this.addEventListener(e,i),()=>this.removeEventListener(e,i)}#Ge(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#Ge("data-change",{rowCount:this._rows.length,sourceRowCount:this.#z.length})}#$e(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const i=t===this._focusRow;e.setAttribute("aria-selected",String(i)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(i&&t===this._focusCol))})})}#Ce(e){this.#$[e]=!0,this.#q||(this.#q=!0,queueMicrotask(()=>this.#je()))}#je(){if(!this.#q||!this.#N)return void(this.#q=!1);const e=this.#$;if(this.#q=!1,this.#$={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig)return this.#Xe(),void(e.rows&&this.#Ye());e.columns&&this.#Ke(),e.rows&&this.#Ye(),e.fitMode&&this.#Ze()}#Ye(){this._rows=Array.isArray(this.#z)?[...this.#z]:[],this._rebuildRowIdMap(),this.#W.requestPhase(G.ROWS,"applyRowsUpdate")}_rebuildRowIdMap(){this.#be.clear();const e=this.#p.getRowId;this._rows.forEach((t,i)=>{const o=He(t,e);void 0!==o&&this.#be.set(o,{row:t,index:i})})}#Ke(){ce(this),this.#k.merge(),this.#qe()}#Ze(){this.#k.merge();"fixed"===this.#p.fitMode?(this.__didInitialAutoSize=!1,b(this)):(this._columns.forEach(e=>{!e.__userResized&&e.__autoSized&&delete e.width}),C(this))}#Xe(){We(this,this.#de),Fe(this,this.#de);const e=!!this.#O.querySelector(".has-shell"),t=!!this.#O.querySelector(".tbw-tool-panel"),i=this.#O.querySelectorAll(".tbw-accordion-section").length,o=this.#O.querySelector(".tbw-tool-panel")?.dataset.position??"right";this.#k.parseLightDomColumns(this),this.#k.merge(),this.#Ae(),this.#Te(),Ve(this,this.#de,this.#Le()),this.#k.markSourcesChanged(),this.#k.merge();const r=$e(this.#p?.shell),n=(this.#p?.shell?.toolPanels?.length??0)>0,s=this.#p?.shell?.toolPanels?.length??0,l=this.#p?.shell?.toolPanel?.position??"right";if(e!==r||!t&&n||t&&s!==i||t&&o!==l)return Ye(this.#de),this.#Oe(),this.#xe(),this.#Ie(),void this._rebuildRowIdMap();e&&this.#Qe(),this._rebuildRowIdMap(),this.#W.requestPhase(G.COLUMNS,"applyGridConfigUpdate")}#Qe(){const e=this.#O.querySelector(".tbw-shell-header");if(!e)return;const t=this.#p.shell?.header?.title??this.#de.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()}#Je(){if(this.__rowRenderEpoch++,this.#ee){const e=this.#me.length>0?this.#me:this._columns,t=e.filter(e=>!e.hidden),i=e.filter(e=>e.hidden),o=this.#ee.processColumns([...t]);if(o!==t){const r=new Set(o.map(e=>e.field));!t.some(e=>r.has(e.field))&&o.length>0?this._columns=[...o,...i]:this._columns=this.#et(e,o,i)}else this._columns=[...e]}}#et(e,t,i){if(0===i.length)return t;const o=new Map;for(const l of t)o.set(l.field,l);const r=new Set(e.map(e=>e.field)),n=[];for(const l of t)r.has(l.field)||n.push(l);const s=[];for(const l of e){const e=o.get(l.field);e?s.push(e):l.hidden&&s.push(l)}return s.push(...n),s}#tt(){ce(this);const e=function(e,t){if(!e._sortState)return t;e.__originalOrder=[...t];const i=(e.effectiveConfig?.sortHandler??I)(t,e._sortState,e._columns);return i&&"function"==typeof i.then?t:i}(this,Array.isArray(this.#z)?[...this.#z]:[]),t=this.#ee?.processRows(e)??e;this._rows=t,this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#oe.initializePositionCache(),this._emitDataChange()}#it(e){const t={...o,...e.animation},i=t.mode??"reduced-motion";let r=1;!1===i||"off"===i?r=0:!0!==i&&"on"!==i||(r=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(r)),this.dataset.animationMode="boolean"==typeof i?i?"on":"off":i}_renderVisibleRows(e,t,i=this.__rowRenderEpoch){if(this.#j||(this.#j=(e,t,i)=>this.#ee?.renderRow(e,t,i)??!1),function(e,t,i,o,r){const n=Math.max(0,i-t),s=e._bodyEl,l=e._visibleColumns,a=l.length;let d=e.__cachedHeaderRowCount;for(void 0===d&&(d=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=d);e._rowPool.length<n;){const t=de();e._rowPool.push(t)}if(e._rowPool.length>n){for(let t=n;t<e._rowPool.length;t++){const i=e._rowPool[t];i.parentNode===s&&i.remove()}e._rowPool.length=n}const c=r&&!1!==e.__hasRenderRowPlugins,h=e._hasAfterRowRenderHook?.()??!1,g=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let p=0;p<n;p++){const i=t+p,n=e._rows[i],w=e._rowPool[p];if(w.setAttribute("aria-rowindex",String(i+d+1)),c&&r(n,w,i)){w.__epoch=o,w.__rowDataRef=n,w.parentNode!==s&&s.appendChild(w);continue}const b=w.__epoch,m=w.__rowDataRef;let v=w.children.length;v>a&&w.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&v--;const C=b===o&&v===a,_=m!==n,y=!!e._isGridEditMode;let R=!1;if(C&&_)for(let e=0;e<a;e++)if(l[e].externalView&&!w.querySelector(`.cell[data-col="${e}"] [data-external-view]`)){R=!0;break}if(!C||R){const t=re(w),r=y&&!_||e._activeEditRows===i;t&&!r?(w.__isCustomRow&&(w.className="data-grid-row",w.setAttribute("role","row"),w.__isCustomRow=!1),ne(w),ue(e,w,n,i),w.__epoch=o,w.__rowDataRef=n):t&&r?(he(e,w,n,i),w.__rowDataRef=n):(w.__isCustomRow&&(w.className="data-grid-row",w.setAttribute("role","row"),w.__isCustomRow=!1),ue(e,w,n,i),w.__epoch=o,w.__rowDataRef=n)}else if(_){const t=re(w),r=e._activeEditRows===i;t&&!r?(ne(w),ue(e,w,n,i),w.__epoch=o,w.__rowDataRef=n):(he(e,w,n,i),w.__rowDataRef=n)}else{const t=re(w),r=y||e._activeEditRows===i;t&&!r?(ne(w),ue(e,w,n,i),w.__epoch=o,w.__rowDataRef=n):he(e,w,n,i)}let S=!1;const E=e._changedRowIdSet;if(E&&E.size>0)try{const t=e.getRowId?.(n);t&&(S=E.has(t))}catch{}S!==w.classList.contains("changed")&&w.classList.toggle("changed",S);const x=e.effectiveConfig?.rowClass;if(x){const t=w.getAttribute("data-dynamic-classes");t&&t.split(" ").forEach(e=>e&&w.classList.remove(e));try{const e=x(n),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const i of t)i&&"string"==typeof i&&(w.classList.add(i),e+=(e?" ":"")+i);w.setAttribute("data-dynamic-classes",e)}else w.removeAttribute("data-dynamic-classes")}catch(f){u("TBW060",`rowClass callback error: ${f}`,e.id),w.removeAttribute("data-dynamic-classes")}}if(g){const e=g(n,i);void 0!==e&&e>0?w.style.setProperty("--tbw-row-height",`${e}px`):w.style.removeProperty("--tbw-row-height")}h&&e._afterRowRender?.({row:n,rowIndex:i,rowElement:w}),w.parentNode!==s&&s.appendChild(w)}}(this,e,t,i,this.#j),this.#fe.size>0)for(const o of this.#fe)this.#ye(o,!0)}#ot={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaDescribedBy:void 0};_updateAriaCounts(e,t){!function(e,t,i,o,r){if(o===e.rowCount&&r===e.colCount)return!1;const n=e.rowCount;e.rowCount=o,e.colCount=r,t&&(t.setAttribute("aria-rowcount",String(o)),t.setAttribute("aria-colcount",String(r))),o!==n&&i&&(o>0?i.setAttribute("role","rowgroup"):i.removeAttribute("role"))}(this.#ot,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#W.requestPhase(e,t)}_getPluginExtraHeight(){return this.#ee?.getExtraHeight()??0}_getPluginRowHeight(e,t){return this.#ee?.getRowHeight?.(e,t)}_getPluginExtraHeightBefore(e){return this.#ee?.getExtraHeightBefore?.(e)??0}_adjustPluginVirtualStart(e,t,i){return this.#ee?.adjustVirtualStart(e,t,i)}_afterPluginRender(){this.#ee?.afterRender()}_emitPluginEvent(e,t){this.#ee?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#k.parseLightDomColumns(this),this.#k.merge(),this.#Ae(),function(e,t,i){const o=lt,r=at,n=new Map;function s(e,t,i,o,r=!1){n.has(e)||n.set(e,{description:t,importHint:i,fields:[],isConfigProperty:r});const s=n.get(e);s.fields.includes(o)||s.fields.push(o)}for(const a of r){const i=e[a.property];(a.isUsed?a.isUsed(i):void 0!==i)&&!ht(t,a.pluginName)&&s(a.pluginName,a.description,dt(a.pluginName),a.property,!0)}const l=e.columns;if(l&&l.length>0)for(const a of l)for(const e of o){const i=a[e.property];if((e.isUsed?e.isUsed(i):void 0!==i)&&!ht(t,e.pluginName)){const t=a.field||"<unknown>";s(e.pluginName,e.description,dt(e.pluginName),t)}}if(n.size>0){const e=[];for(const[t,{description:i,importHint:o,fields:r,isConfigProperty:s}]of n)if(s)e.push(`Config uses ${i}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${o}\n plugins: [new ${ct(t)}Plugin(), ...]`);else{const n=r.slice(0,3).join(", ")+(r.length>3?`, ... (${r.length} total)`:"");e.push(`Column(s) [${n}] use ${i}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${o}\n plugins: [new ${ct(t)}Plugin(), ...]`)}h([...n.values()].some(e=>e.isConfigProperty)?"TBW002":"TBW001",`Configuration error:\n\n${e.join("\n\n")}\n\nThis validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`,i)}}(this.#p,this.#ee?.getPlugins()??[],this.id),function(e,t){const i=[],o=[];for(const r of e){const e=r.constructor.manifest;if(e?.configRules)for(const t of e.configRules){const e=r.config;if(t.check(e)){const e=`[${ct(r.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?i.push(e):o.push(e)}}}if(o.length>0&&Y())for(const r of o)u("TBW004",r,t);i.length>0&&h("TBW003",`Configuration error:\n\n${i.join("\n\n")}`,t)}(this.#ee?.getPlugins()??[],this.id),function(e,t){if(!Y())return;const i=new Set(e.map(e=>e.name)),o=new Set;for(const r of e){const e=r.constructor.manifest;if(e?.incompatibleWith)for(const n of e.incompatibleWith)if(i.has(n.name)){const e=[r.name,n.name].sort().join("↔");if(o.has(e))continue;o.add(e),u("TBW022",`${ct(r.name)}Plugin and ${ct(n.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${n.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`,t)}}}(this.#ee?.getPlugins()??[],this.id),this.#rt(),this.#me=[...this._columns]}_schedulerProcessColumns(){this.#Je()}_schedulerProcessRows(){this.#tt()}_schedulerRenderHeader(){U(this)}_schedulerUpdateTemplate(){C(this)}_schedulerAfterRender(){this.#ee?.afterRender(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#oe.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`});"fixed"!==this.#p.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,b(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,fe(this)),this._virtualization.enabled&&!this.#ke&&this.#Be(),this.#B&&(this.#B=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#Fe()})})),this.#ge&&this.#_e()}get _schedulerIsConnected(){return this.isConnected&&this.#N}get _hostElement(){return this}get _renderRoot(){return this.#O}_emit(e,t){this.#Ge(e,t)}get _accordionIcons(){return{expand:this.#p?.icons?.expand??n.expand,collapse:this.#p?.icons?.collapse??n.collapse}}get _shellState(){return this.#de}_clearRowPool(){this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++}_setup(){this.#qe()}_applyAnimationConfig(e){this.#it(e)}#rt(){!function(e,t,i,o){if(!t)return!1;let r=!1;const n=function(e,t){const i=e?.gridAriaLabel;return i||(e?.shell?.header?.title??t?.lightDomTitle??void 0)}(i,o);n!==e.ariaLabel&&(e.ariaLabel=n,n?t.setAttribute("aria-label",n):t.removeAttribute("aria-label"),r=!0);const s=i?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),r=!0)}(this.#ot,this.__rowsBodyEl,this.#p,this.#de)}#_e(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#ge?(this.#we||(this.#we=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(Re("large",e)),t}(this.#p?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#we)):(t=this.#we,t?.remove()))}#ye(e,t){const i=this.#be.get(e);if(!i)return;const o=this.findRenderedRowElement?.(i.index);o&&function(e,t){if(t){if(e.classList.add("tbw-row-loading"),e.setAttribute("aria-busy","true"),!e.querySelector(".tbw-row-loading-overlay")){const t=document.createElement("div");t.className="tbw-row-loading-overlay",t.setAttribute("aria-hidden","true");const i=document.createElement("div");i.className="tbw-row-loading-spinner",t.appendChild(i),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}(o,t)}#Re(e,t,i){const o=this.#be.get(e);if(!o)return;const r=this.findRenderedRowElement?.(o.index);if(!r)return;const n=this._visibleColumns.findIndex(e=>e.field===t);if(n<0)return;const s=r.children[n];s&&function(e,t){t?(e.classList.add("tbw-cell-loading"),e.setAttribute("aria-busy","true")):(e.classList.remove("tbw-cell-loading"),e.removeAttribute("aria-busy"))}(s,i)}#qe(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#k.parseLightDomColumns(this),this.#_){const e=this.#_;this.#_=void 0,this.#k.merge();const t=this.#ee?.getAll()??[];this.#k.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#W.requestPhase(G.FULL,"setup")}}#Ve(e){let t=0,i=0,o=0,r=0,n=0;if(this.#U){const e=this._virtualization.container,s=this.#ae;t=s?.scrollLeft??0,i=e?.scrollHeight??0,o=s?.scrollWidth??0,r=e?.clientHeight??0,n=s?.clientWidth??0}if(this.refreshVirtualWindow(!1)&&this.#ee?.onScrollRender(),this._virtualization.variableHeights&&(this.#G&&clearTimeout(this.#G),this.#G=window.setTimeout(()=>{this.#G=0,this.#oe.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#U){const s=this.#J;s.scrollTop=e,s.scrollLeft=t,s.scrollHeight=i,s.scrollWidth=o,s.clientHeight=r,s.clientWidth=n,this.#ee?.onScroll(s)}}findHeaderRow(){return this.#O.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,i=e-t.start;return i>=0&&i<this._rowPool.length&&i<t.end-t.start?this._rowPool[i]:null}_dispatchCellClick(e,t,i,o){const r=this._rows[t],n=this._visibleColumns[i];if(!r||!n)return!1;const s=n.field,l=r[s],a=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:i,column:n,field:s,value:l,row:r,cellEl:o,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const d={row:r,rowIndex:t,colIndex:i,column:n,field:s,value:l,cellEl:o,originalEvent:e},c=this.#ee?.onCellClick(d)??!1;return this.#Ge("cell-click",d),c}_dispatchRowClick(e,t,i,o){if(!i)return!1;const r={rowIndex:t,row:i,rowEl:o,originalEvent:e},n=this.#ee?.onRowClick(r)??!1;return this.#Ge("row-click",r),n}_dispatchHeaderClick(e,t,i){if(!t)return!1;const o={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:i,originalEvent:e};return this.#ee?.onHeaderClick(o)??!1}_dispatchKeyDown(e){return this.#ee?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#ee?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}queryPlugins(e){return this.#ee?.queryPlugins(e)??[]}query(e,t){return this.#ee?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#ee?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#ee?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#ee?.onCellMouseUp(e)}_afterCellRender(e){this.#ee?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#ee?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#ee?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#ee?.hasAfterRowRenderHook()??!1}async ready(){return this.#o}async forceLayout(){return this.#W.requestPhase(G.FULL,"forceLayout"),this.#W.whenReady()}async getConfig(){return Object.freeze({...this.#p||{}})}getRowId(e){return Me(e,this.id,this.#p.getRowId)}getRow(e){return this.#ne.getRow(e)}_getRowEntry(e){return this.#be.get(e)}updateRow(e,t,i="api"){this.#ne.updateRow(e,t,i)}updateRows(e,t="api"){this.#ne.updateRows(e,t)}animateRow(e,t){return Pe(this,e,t)}animateRows(e,t){return function(e,t,i){return Promise.all(t.map(t=>Pe(e,t,i))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,i){const o=e._rows??[],r=e.getRowId;if(!r)return Promise.resolve(!1);const n=o.findIndex(e=>{if(null==e)return!1;try{return r(e)===t}catch{return!1}});return n<0?Promise.resolve(!1):Pe(e,n,i)}(this,e,t)}async insertRow(e,t,i=!0){return this.#ne.insertRow(e,t,i)}async removeRow(e,t=!0){return this.#ne.removeRow(e,t)}suspendProcessing(){}focusCell(e,t){this.#re.focusCell(e,t)}get focusedCell(){return this.#re.focusedCell}scrollToRow(e,t){this.#re.scrollToRow(e,t)}scrollToRowById(e,t){this.#re.scrollToRowById(e,t)}setColumnVisible(e,t){const i=this.#k.setColumnVisible(e,t);return i&&this.requestStateChange(),i}toggleColumnVisibility(e){const t=this.#k.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#k.isColumnVisible(e)}showAllColumns(){this.#k.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#k.getAllColumns()}setColumnOrder(e){this.#k.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#k.getColumnOrder()}getColumnState(){const e=this.#ee?.getAll()??[];return this.#k.collectState(e)}set columnState(e){e&&(this.#_=e,this.#k.initialColumnState=e,this.#I&&this.#nt(e))}get columnState(){return this.getColumnState()}#nt(e){const t=this.#ee?.getAll()??[];this.#k.applyState(e,t),this.#qe()}requestStateChange(){const e=this.#ee?.getAll()??[];this.#k.requestStateChange(e)}resetColumnState(){this.#_=void 0,this.__originalOrder=[];const e=this.#ee?.getAll()??[];this.#k.resetState(e),this.#k.merge(),this.#qe()}get isToolPanelOpen(){return this.#ce.isPanelOpen}get defaultRowHeight(){return this._virtualization.rowHeight}get expandedToolPanelSections(){return this.#ce.expandedSections}openToolPanel(){this.#ce.openToolPanel()}closeToolPanel(){this.#ce.closeToolPanel()}toggleToolPanel(){this.#ce.toggleToolPanel()}toggleToolPanelSection(e){this.#ce.toggleToolPanelSection(e)}getToolPanels(){return this.#ce.getToolPanels()}registerToolPanel(e){this.#de.apiToolPanelIds.add(e.id),this.#ce.registerToolPanel(e)}unregisterToolPanel(e){this.#de.apiToolPanelIds.delete(e),this.#ce.unregisterToolPanel(e)}getHeaderContents(){return this.#ce.getHeaderContents()}registerHeaderContent(e){this.#de.apiHeaderContentIds.add(e.id),this.#ce.registerHeaderContent(e)}unregisterHeaderContent(e){this.#de.apiHeaderContentIds.delete(e),this.#ce.unregisterHeaderContent(e)}getToolbarContents(){return this.#ce.getToolbarContents()}registerToolbarContent(e){this.#ce.registerToolbarContent(e)}unregisterToolbarContent(e){this.#ce.unregisterToolbarContent(e)}#st=!1;refreshShellHeader(){this.#st||(this.#st=!0,queueMicrotask(()=>{this.#st=!1,this.isConnected&&(this.#De(),this.#k.markSourcesChanged(),this.#k.merge(),Ye(this.#de),this.#Oe(),this.#xe(),this.#lt())}))}#lt(){const e=this.#O.querySelector(".tbw-grid-content")??this.#O.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.#ce.isInitialized){Be(this.#O,this.#de),Ue(this.#O,this.#p?.shell,this.#de);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#de.toolPanels.has(e)&&(this.openToolPanel(),this.#de.expandedSections.add(e)),this.#de.isPanelOpen&&(Xe(this.#O,this.#de),Ge(this.#O,this.#de,(this.#p,this.#p)),je(this.#O,this.#de))}this._resizeController=Se(this),this.#He(e),this.#W.requestPhase(G.COLUMNS,"shellRefresh")}#Ne=new Map;registerStyles(e,t){let i=this.#Ne.get(e);i||(i=new CSSStyleSheet,this.#Ne.set(e,i)),i.replaceSync(t),this.#at()}unregisterStyles(e){this.#Ne.delete(e)&&this.#at()}getRegisteredStyles(){return Array.from(this.#Ne.keys())}#at(){const e=Array.from(this.#Ne.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#Ne.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#re.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#re.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#re.containsFocus(e)}#De(){We(this,this.#de),Fe(this,this.#de),Ve(this,this.#de,this.#Le())}#dt(){const e=this.#O.querySelector(".tbw-shell-header");if(!e)return;Ye(this.#de);const t=function(e,t,i="☰"){const o=e?.header?.title??t.lightDomTitle??"",r=!!o,n=qe(i),s=e?.header?.toolbarContents??[],l=[...t.toolbarContents.values()],a=new Set(s.map(e=>e.id)),d=[...s];for(const w of l)a.has(w.id)||d.push(w);const c=d.length>0,h=t.toolPanels.size>0,u=c&&h,g=[...d].sort((e,t)=>(e.order??0)-(t.order??0));let f="";for(const w of g)f+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${w.id}"></div>`;if(u&&(f+='<div class="tbw-toolbar-separator"></div>'),h){const e=t.isPanelOpen;f+=`<button class="${e?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${e}" aria-controls="tbw-tool-panel">${n}</button>`}return`\n <div class="tbw-shell-header" part="shell-header" role="presentation">\n ${r?`<div class="tbw-shell-title">${p=o,p&&"string"==typeof p?p.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}</div>`:""}\n <div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>\n <div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">\n ${f}\n </div>\n </div>\n `;var p}(this.#p.shell,this.#de,this.#p.icons?.toolPanel),i=document.createElement("div");i.innerHTML=t;const o=i.firstElementChild;o&&(e.replaceWith(o),this.#ct(),Ue(this.#O,this.#p?.shell,this.#de))}#ze(){const e=()=>{const e=this.#de.lightDomTitle,t=this.#de.hasToolButtonsContainer;this.#De();const i=this.#de.lightDomTitle,o=this.#de.hasToolButtonsContainer;(i&&!e||o&&!t)&&(this.#k.markSourcesChanged(),this.#k.merge(),this.#dt())},t=()=>{this.__lightDomColumnsCache=void 0,this.#qe()};this.#k.registerLightDomHandler("tbw-grid-header",e),this.#k.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#k.registerLightDomHandler("tbw-grid-tool-panel",e),this.#k.registerLightDomHandler("tbw-grid-column",t),this.#k.registerLightDomHandler("tbw-grid-detail",t),this.#k.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,ce(this),this.#k.parseLightDomColumns(this);const e=this.#de.lightDomTitle,t=this.#de.hasToolButtonsContainer;this.#De();const i=this.#de.lightDomTitle,o=this.#de.hasToolButtonsContainer;(i&&!e||o&&!t)&&(this.#k.markSourcesChanged(),this.#k.merge(),this.#dt()),this.#W.requestPhase(G.COLUMNS,"refreshColumns")}#Ue(){this.#oe.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#oe.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#oe.invalidateRowHeight(e,t)}#Oe(){this.#De(),this.#k.markSourcesChanged(),this.#k.merge();const e=this.#p?.shell;Ze(this.#O,e,{isPanelOpen:this.#de.isPanelOpen,expandedSections:this.#de.expandedSections},this.#p?.icons)&&(this.#ct(),this.#ce.setInitialized(!0))}#ct(){!function(e,t,i,o){const r=e.querySelector(".tbw-shell-toolbar");r&&r.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&o.onPanelToggle()});const n=e.querySelector(".tbw-accordion");n&&n.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),i=e?.getAttribute("data-section");i&&o.onSectionToggle(i)}})}(this.#O,this.#p,this.#de,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#he?.(),this.#he=function(e,t,i){const o=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),n=e.querySelector(".tbw-shell-body");if(!o||!r||!n)return()=>{};const s=t?.toolPanel?.position??"right";let l=0,a=0,d=0,c=!1;const h=e=>{if(!c)return;e.preventDefault();const t="left"===s?e.clientX-l:l-e.clientX,i=Math.min(d,Math.max(200,a+t));o.style.width=`${i}px`},u=()=>{if(!c)return;c=!1,r.classList.remove("resizing"),o.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=o.getBoundingClientRect().width;i(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)},g=e=>{e.preventDefault(),c=!0,l=e.clientX,a=o.getBoundingClientRect().width,d=n.getBoundingClientRect().width-20,r.classList.add("resizing"),o.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)};return r.addEventListener("mousedown",g),()=>{r.removeEventListener("mousedown",g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}}(this.#O,this.#p?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)}),this.#ue?.(),this.#ue=function(e,t,i,o){if(!t?.toolPanel?.closeOnClickOutside)return()=>{};const r=e=>{if(!i.isPanelOpen)return;const t=e.target;t&&(t.closest(".tbw-tool-panel")||t.closest("[data-panel-toggle]")||o())};return e.addEventListener("mousedown",r),()=>e.removeEventListener("mousedown",r)}(this,this.#p?.shell,this.#de,()=>this.closeToolPanel())}}customElements.get(vt.tagName)||customElements.define(vt.tagName,vt),globalThis.DataGridElement=vt;const Ct={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"},_t={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"},yt={ROOT:`.${Ct.ROOT}`,HEADER:`.${Ct.HEADER}`,HEADER_ROW:`.${Ct.HEADER_ROW}`,HEADER_CELL:`.${Ct.HEADER_CELL}`,ROWS_VIEWPORT:`.${Ct.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${Ct.ROWS_CONTAINER}`,DATA_ROW:`.${Ct.DATA_ROW}`,DATA_CELL:`.${Ct.DATA_CELL}`,GROUP_ROW:`.${Ct.GROUP_ROW}`,ROW_BY_INDEX:e=>`.${Ct.DATA_ROW}[${_t.ROW_INDEX}="${e}"]`,CELL_BY_FIELD:e=>`.${Ct.DATA_CELL}[${_t.FIELD}="${e}"]`,CELL_AT:(e,t)=>`.${Ct.DATA_ROW}[${_t.ROW_INDEX}="${e}"] .${Ct.DATA_CELL}[${_t.COL_INDEX}="${t}"]`,SELECTED_ROWS:`.${Ct.DATA_ROW}.${Ct.SELECTED}`,EDITING_CELL:`.${Ct.DATA_CELL}.${Ct.EDITING}`};const Rt={sum:(e,t)=>e.reduce((e,i)=>e+(Number(i[t])||0),0),avg:(e,t)=>{const i=e.reduce((e,i)=>e+(Number(i[t])||0),0);return e.length?i/e.length:0},count:e=>e.length,min:(e,t)=>e.length?Math.min(...e.map(e=>Number(e[t])||1/0)):0,max:(e,t)=>e.length?Math.max(...e.map(e=>Number(e[t])||-1/0)):0,first:(e,t)=>e[0]?.[t],last:(e,t)=>e[e.length-1]?.[t]},St=new Map,Et={register(e,t){St.set(e,t)},unregister(e){St.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:St.get(e)??Rt[e]},run(e,t,i,o){const r=this.get(e);return r?r(t,i,o):void 0},has:e=>St.has(e)||e in Rt,list:()=>[...Object.keys(Rt),...St.keys()]},xt={sum:e=>e.reduce((e,t)=>e+t,0),avg:e=>e.length?e.reduce((e,t)=>e+t,0)/e.length:0,count:e=>e.length,min:e=>e.length?Math.min(...e):0,max:e=>e.length?Math.max(...e):0,first:e=>e[0]??0,last:e=>e[e.length-1]??0};function At(e){return xt[e]??xt.sum}const Tt=Et.register.bind(Et),Pt=Et.unregister.bind(Et),Ht=Et.get.bind(Et),Mt=Et.run.bind(Et),Lt=Et.list.bind(Et);e.BaseGridPlugin=class{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#ht;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#ht?.abort(),this.#ht=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#ht?.abort(),this.#ht=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}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}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?._hostElement}get disconnectSignal(){return this.#ht?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...n,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!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 void 0!==t?t:this.gridIcons[e]}setIcon(e,t){"string"==typeof t?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e,t){void 0!==t?console.warn(c(e,t,this.gridElement.id,this.name)):console.warn(`${s(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(c(e,t,this.gridElement.id,this.name))}},e.DEFAULT_ANIMATION_CONFIG=o,e.DEFAULT_GRID_ICONS=n,e.DGEvents={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",EDIT_OPEN:"edit-open",EDIT_CLOSE:"edit-close",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",DATA_CHANGE:"data-change"},e.DataGridElement=vt,e.FitModeEnum=i,e.GridCSSVars={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"},e.GridClasses=Ct,e.GridDataAttrs=_t,e.GridElement=vt,e.GridSelectors=yt,e.PLUGIN_QUERIES={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"},e.PluginEvents={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"},e.PluginManager=mt,e.RenderPhase=G,e.aggregatorRegistry=Et,e.builtInSort=I,e.createGrid=function(e){const t=document.createElement("tbw-grid");return e&&(t.gridConfig=e),t},e.defaultComparator=O,e.getAggregator=Ht,e.getValueAggregator=At,e.listAggregators=Lt,e.queryGrid=function(e,t,i){let o=document,r=!1;return"boolean"==typeof t?r=t:t&&(o=t,r=!!i),r?customElements.whenDefined(vt.tagName).then(()=>o.querySelector(e)):o.querySelector(e)},e.registerAggregator=Tt,e.runAggregator=Mt,e.runValueAggregator=function(e,t){return At(e)(t)},e.setFeatureResolver=function(e){ve=e},e.unregisterAggregator=Pt,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TbwGrid={})}(this,function(e){"use strict";function t(e,t){const i=e.querySelector?.(".tbw-sr-only");i&&(i.textContent="",requestAnimationFrame(()=>{i.textContent=t}))}const i={STRETCH:"stretch",FIXED:"fixed"},o={mode:"reduced-motion",duration:200,easing:"ease-out"},r='<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>',n={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:r,filterActive:r,print:"🖨️"};function s(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const l="TBW041",a="TBW061",d="TBW062";function c(e,t,i,o){return`${s(i,o)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function h(e,t,i,o){throw new Error(c(e,t,i,o))}function u(e,t,i,o){console.warn(c(e,t,i,o))}function g(e,t,i,o){console.debug(c(e,t,i,o))}function f(e,t,i,o){console.error(c(e,t,i,o))}function p(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const i={};t.forEach(e=>{const t=i[e.field];if(t){e.header&&!t.header&&(t.header=e.header),e.type&&!t.type&&(t.type=e.type),e.sortable&&(t.sortable=!0),e.editable&&(t.editable=!0),e.resizable&&(t.resizable=!0),null!=e.width&&null==t.width&&(t.width=e.width),null!=e.minWidth&&null==t.minWidth&&(t.minWidth=e.minWidth),e.__viewTemplate&&(t.__viewTemplate=e.__viewTemplate),e.__editorTemplate&&(t.__editorTemplate=e.__editorTemplate),e.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate);const i=e.renderer||e.viewRenderer,o=t.renderer||t.viewRenderer;i&&!o&&(t.viewRenderer=i,e.renderer&&(t.renderer=i)),e.editor&&!t.editor&&(t.editor=e.editor)}else i[e.field]={...e}});const o=e.map(e=>{const t=i[e.field];if(!t)return e;const o={...e};t.header&&!o.header&&(o.header=t.header),t.type&&!o.type&&(o.type=t.type),o.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(o.resizable=!0),o.editable=e.editable||t.editable,null!=t.width&&null==o.width&&(o.width=t.width),null!=t.minWidth&&null==o.minWidth&&(o.minWidth=t.minWidth),t.__viewTemplate&&(o.__viewTemplate=t.__viewTemplate),t.__editorTemplate&&(o.__editorTemplate=t.__editorTemplate),t.__headerTemplate&&(o.__headerTemplate=t.__headerTemplate);const r=t.renderer||t.viewRenderer,n=o.renderer||o.viewRenderer;return r&&!n&&(o.viewRenderer=r,t.renderer&&(o.renderer=r)),t.editor&&!o.editor&&(o.editor=t.editor),delete i[e.field],o});return Object.keys(i).forEach(e=>o.push(i[e])),o}function w(e,t){try{e.part?.add?.(t)}catch{}const i=e.getAttribute("part");i?i.split(/\s+/).includes(t)||e.setAttribute("part",i+" "+t):e.setAttribute("part",t)}function b(e){const t=e.effectiveConfig?.fitMode||e.fitMode||i.STRETCH;if(t!==i.STRETCH&&t!==i.FIXED)return;if(e.__didInitialAutoSize)return;if(!e.isConnected)return;const o=Array.from(e._headerRowEl?.children||[]);if(!o.length)return;let r=!1;e._visibleColumns.forEach((t,i)=>{if(t.width)return;const n=o[i];let s=n?n.scrollWidth:0;for(const o of e._rowPool){const e=o.children[i];if(e){const t=e.scrollWidth;t>s&&(s=t)}}s>0&&(t.width=s+2,t.__autoSized=!0,r=!0)}),r&&C(e),e.__didInitialAutoSize=!0}const m=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function v(e,t){return"number"==typeof e?`${e}px`:(m.test(e)||u("TBW050",`Column '${t??"?"}' has an invalid CSS width value: '${e}'. Expected a number (px) or a valid CSS unit string (e.g. '30%', '2fr', 'calc(...)').`),e)}function C(e){const t=e.effectiveConfig?.fitMode||e.fitMode||i.STRETCH;e._gridTemplate=t===i.STRETCH?e._visibleColumns.map(e=>{if(null!=e.width)return v(e.width,e.field);const t=e.minWidth;return null!=t?`minmax(${t}px, 1fr)`:"1fr"}).join(" ").trim():e._visibleColumns.map(e=>null!=e.width?v(e.width,e.field):"max-content").join(" "),e.style.setProperty("--tbw-column-template",e._gridTemplate)}const _=/{{\s*([^}]+)\s*}}/g,y="__DG_EMPTY__",R=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,S=/__(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/;const E=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"]),x=/^on\w+$/i,A=new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),T=/^\s*(javascript|vbscript|data|blob):/i;function P(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],i=e.querySelectorAll("*");for(const o of i){const e=o.tagName.toLowerCase();if(E.has(e)){t.push(o);continue}if("svg"===e||"http://www.w3.org/2000/svg"===o.namespaceURI){if(Array.from(o.attributes).some(e=>x.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(o);continue}}const i=[];for(const t of o.attributes){const e=t.name.toLowerCase();x.test(e)?i.push(t.name):(A.has(e)&&T.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&i.push(t.name)}i.forEach(e=>o.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function H(e,t){if(!e||-1===e.indexOf("{{"))return e;const i=[],o=e.replace(_,(e,o)=>{const r=function(e,t){if(e=(e||"").trim(),!e)return y;if(M.test(e))return y;if("value"===e)return null==t.value?y:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const i=e.slice(4),o=t.row?t.row[i]:void 0;return null==o?y:String(o)}if(e.length>80)return y;if(!R.test(e)||S.test(e))return y;const i=e.match(/\./g);if(i&&i.length>1)return y;try{const i=new Function("value","row",`return (${e});`)(t.value,t.row),o=null==i?"":String(i);return M.test(o)?y:o||y}catch{return y}}(o,t);return i.push({expr:o.trim(),result:r}),r}),r=(n=o)?n.replace(new RegExp(y,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):n;var n;const s=i.length&&i.every(e=>""===e.result||e.result===y);return M.test(e)||s?"":r}const M=/Reflect|Proxy|ownKeys/;function L(e){if(M.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&M.test(t.textContent||"")&&(t.textContent="");M.test(e.textContent||"")&&(e.textContent="")}}function O(e){const t=M.test(e),i=i=>{if(t)return"";return H(e,i)};return i.__blocked=t,i}function D(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0}function I(e,t,i){const o=i.find(e=>e.field===t.field),r=o?.sortComparator??D,{field:n,direction:s}=t;return[...e].sort((e,t)=>r(e[n],t[n],e,t)*s)}function z(e,i,o,r){e._rows=i,e.__rowRenderEpoch++,e._rowPool.forEach(e=>e.__epoch=-1),U(e),e.refreshVirtualWindow(!0),e.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:r}})),t(e,`Sorted by ${o.header??o.field}, ${1===r?"ascending":"descending"}`),e.requestStateChange?.()}function k(e,i){if(e._sortState&&e._sortState.field===i.field)if(1===e._sortState.direction)N(e,i,-1);else{e._sortState=null,e.__rowRenderEpoch++,e._rowPool.forEach(e=>e.__epoch=-1),e._rows=e.__originalOrder.slice(),U(e);const o=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');o?.forEach(t=>{t.getAttribute("aria-sort")&&("ascending"!==t.getAttribute("aria-sort")&&"descending"!==t.getAttribute("aria-sort")||e._sortState)||t.setAttribute("aria-sort","none")}),e.refreshVirtualWindow(!0),e.dispatchEvent(new CustomEvent("sort-change",{detail:{field:i.field,direction:0}})),t(e,"Sort cleared"),e.requestStateChange?.()}else e._sortState||(e.__originalOrder=e._rows.slice()),N(e,i,1)}function N(e,t,i){e._sortState={field:t.field,direction:i};const o={field:t.field,direction:i},r=e._columns,n=(e.effectiveConfig?.sortHandler??I)(e._rows,o,r);n&&"function"==typeof n.then?n.then(o=>{z(e,o,t,i)}):z(e,n,t,i)}function q(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function $(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function W(e,t){const i=document.createElement("span");w(i,"sort-indicator");const o=e._sortState?.field===t.field?e._sortState.direction:0,r={...n,...e.icons};return function(e,t){"string"==typeof t?e.textContent=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(i,1===o?r.sortAsc:-1===o?r.sortDesc:r.sortNone),i}function F(e,t,i){const o=document.createElement("div");return o.className="resize-handle",o.setAttribute("aria-hidden","true"),o.addEventListener("mousedown",o=>{o.stopPropagation(),o.preventDefault(),e._resizeController.start(o,t,i)}),o.addEventListener("dblclick",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.resetColumn(t)}),o}function V(e,t,i,o){o.classList.add("sortable"),o.tabIndex=0;const r=e._sortState?.field===t.field?e._sortState.direction:0;o.setAttribute("aria-sort",0===r?"none":1===r?"ascending":"descending"),o.addEventListener("click",i=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(i,t,o)||k(e,t)}),o.addEventListener("keydown",i=>{if("Enter"===i.key||" "===i.key){if(i.preventDefault(),e._dispatchHeaderClick?.(i,t,o))return;k(e,t)}})}function U(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((i,o)=>{const r=document.createElement("div");r.className="cell",w(r,"header-cell"),r.setAttribute("role","columnheader"),r.setAttribute("aria-colindex",String(o+1)),r.setAttribute("data-field",i.field),r.setAttribute("data-col",String(o)),i.type&&r.setAttribute("data-type",i.type);const n=i.header??i.field,s=e._sortState?.field===i.field?e._sortState.direction:0,l=1===s?"asc":-1===s?"desc":null;if(i.headerRenderer){const t={column:i,value:n,sortState:l,filterActive:!1,cellEl:r,renderSortIcon:()=>q(e,i)?W(e,i):null,renderFilterButton:()=>null},s=i.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const i=document.createElement("span");for(i.innerHTML=P(t);i.firstChild;)e.appendChild(i.firstChild)}else t instanceof Node&&e.appendChild(t)}(r,s),q(e,i)&&V(e,i,0,r),$(e,i)&&(r.classList.add("resizable"),r.appendChild(F(e,o,r)))}else if(i.headerLabelRenderer){const t={column:i,value:n},s=i.headerLabelRenderer(t),l=document.createElement("span");null==s?l.textContent=n:"string"==typeof s?l.innerHTML=P(s):s instanceof Node&&l.appendChild(s),r.appendChild(l),q(e,i)&&(V(e,i,0,r),r.appendChild(W(e,i))),$(e,i)&&(r.classList.add("resizable"),r.appendChild(F(e,o,r)))}else if(i.__headerTemplate)Array.from(i.__headerTemplate.childNodes).forEach(e=>r.appendChild(e.cloneNode(!0))),q(e,i)&&(V(e,i,0,r),r.appendChild(W(e,i))),$(e,i)&&(r.classList.add("resizable"),r.appendChild(F(e,o,r)));else{const t=document.createElement("span");t.textContent=n,r.appendChild(t),q(e,i)&&(V(e,i,0,r),r.appendChild(W(e,i))),$(e,i)&&(r.classList.add("resizable"),r.appendChild(F(e,o,r)))}t.appendChild(r)}),t.querySelectorAll(".cell.sortable").forEach(e=>{e.getAttribute("aria-sort")||e.setAttribute("aria-sort","none")}),t.children.length>0?(t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1")):(t.removeAttribute("role"),t.removeAttribute("aria-rowindex")))}function B(e,t){const i=e[0]||{},o=Object.keys(i).map(e=>{const t=i[e],o=null==(r=t)?"string":"number"==typeof r?"number":"boolean"==typeof r?"boolean":r instanceof Date||"string"==typeof r&&/\d{4}-\d{2}-\d{2}/.test(r)&&!isNaN(Date.parse(r))?"date":"string";var r;return{field:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:o}}),r={};return o.forEach(e=>{r[e.field]=e.type||"string"}),{columns:o,typeMap:r}}var G=(e=>(e[e.STYLE=1]="STYLE",e[e.VIRTUALIZATION=2]="VIRTUALIZATION",e[e.HEADER=3]="HEADER",e[e.ROWS=4]="ROWS",e[e.COLUMNS=5]="COLUMNS",e[e.FULL=6]="FULL",e))(G||{});class j{#e;#t=0;#i=0;#o=null;#r=null;#n=null;#s=!1;constructor(e){this.#e=e}requestPhase(e,t){e>this.#t&&(this.#t=e),0===this.#i&&(this.#l(),this.#i=requestAnimationFrame(()=>this.#a()))}whenReady(){return this.#o?this.#o:Promise.resolve()}setInitialReadyResolver(e){this.#n=e}cancel(){0!==this.#i&&(cancelAnimationFrame(this.#i),this.#i=0),this.#t=0,this.#r&&(this.#r(),this.#r=null,this.#o=null)}get isPending(){return 0!==this.#t}get pendingPhase(){return this.#t}#l(){this.#o||(this.#o=new Promise(e=>{this.#r=e}))}#a(){if(this.#i=0,!this.#e._schedulerIsConnected)return this.#t=0,void(this.#r&&(this.#r(),this.#r=null,this.#o=null));const e=this.#t;this.#t=0,e>=5&&this.#e._schedulerMergeConfig(),e>=4&&this.#e._schedulerProcessRows(),e>=5&&(this.#e._schedulerProcessColumns(),this.#e._schedulerUpdateTemplate()),e>=3&&this.#e._schedulerRenderHeader(),e>=2&&this.#e.refreshVirtualWindow(!0,!0),e>=1&&this.#e._schedulerAfterRender(),!this.#s&&this.#n&&(this.#s=!0,this.#n()),this.#r&&(this.#r(),this.#r=null,this.#o=null)}}class X{#d;#c;#h;#u;#g;#f={};#p={};#w=!0;#b=[];#m;#v;#C;#_;#e;#y;constructor(e){this.#e=e}get original(){return this.#f}get effective(){return this.#p}get columns(){return this.#p.columns??[]}set columns(e){this.#p.columns=e}get lightDomColumnsCache(){return this.#u}set lightDomColumnsCache(e){this.#u=e}get originalColumnNodes(){return this.#g}set originalColumnNodes(e){this.#g=e}get lightDomTitle(){return this.#y}set lightDomTitle(e){this.#y=e}get initialColumnState(){return this.#_}set initialColumnState(e){this.#_=e}get sourcesChanged(){return this.#w}markSourcesChanged(){this.#w=!0}setGridConfig(e){this.#d=e,this.#w=!0,this.#u=void 0}getGridConfig(){return this.#d}setColumns(e){this.#c=e,this.#w=!0}getColumns(){return this.#c}setFitMode(e){this.#h=e,this.#w=!0}getFitMode(){return this.#h}merge(){const e=(this.#p.columns?.length??0)>0;if(!this.#w&&e)return;const t=this.#R();this.#w=!1,this.#f=t,Object.freeze(this.#f),this.#f.columns&&Object.freeze(this.#f.columns),this.#p=this.#S(this.#f),this.#E()}#S(e){const t={...e};return e.columns&&(t.columns=e.columns.map(e=>({...e}))),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(e=>({...e})),headerContents:e.shell.headerContents?.map(e=>({...e}))}),t}#E(){const e=this.#p;if(this.#x(),"number"==typeof e.rowHeight&&e.rowHeight>0&&(this.#e._virtualization.rowHeight=e.rowHeight),"fixed"===e.fitMode){this.columns.forEach(e=>{null==e.width&&(e.width=80)})}this.#e._applyAnimationConfig(e)}#x(){const e=this.#p.typeDefaults;if(!e)return;const t=this.columns;for(const i of t){if(!i.type)continue;const t=e[i.type];t&&(i.renderer||i.viewRenderer||!t.renderer||(i.renderer=t.renderer),!i.format&&t.format&&(i.format=t.format),!i.editor&&t.editor&&(i.editor=t.editor),!i.editorParams&&t.editorParams&&(i.editorParams=t.editorParams))}}#R(){const e=this.#d?{...this.#d}:{},t=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#u??[]).map(e=>({...e}));let o=p(t,i);this.#c&&this.#c.length&&(o=p(this.#c,i));const r=this.#e.sourceRows;if(0===o.length&&r.length){o=B(r).columns}return o.length&&(o.forEach(e=>{void 0===e.sortable&&(e.sortable=!0),void 0===e.resizable&&(e.resizable=!0),void 0===e.__originalWidth&&"number"==typeof e.width&&(e.__originalWidth=e.width)}),o.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=O(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=O(e.__editorTemplate.innerHTML))}),e.columns=o),this.#h&&(e.fitMode=this.#h),e.fitMode||(e.fitMode="stretch"),this.#A(e),e.columnState&&!this.#_&&(this.#_=e.columnState),e}#A(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const t=this.#e._shellState.lightDomTitle;t&&(this.#y=t),this.#y&&!e.shell.header.title&&(e.shell.header.title=this.#y);const i=this.#e._shellState.lightDomHeaderContent;i?.length>0&&(e.shell.header.lightDomContent=i),this.#e._shellState.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0);const o=this.#e._shellState.toolPanels;if(o.size>0){const t=Array.from(o.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=t}const r=this.#e._shellState.headerContents;if(r.size>0){const t=Array.from(r.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=t}const n=this.#e._shellState.toolbarContents,s=Array.from(n.values()),l=this.#d?.shell?.header?.toolbarContents??[],a=new Set(l.map(e=>e.id)),d=[...l];for(const c of s)a.has(c.id)||d.push(c);d.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=d}collectState(e){const t=this.columns,i=this.#T();return{columns:t.map((t,o)=>{const r={field:t.field,order:o,visible:!t.hidden},n=t;void 0!==n.__renderedWidth?r.width=n.__renderedWidth:void 0!==t.width&&(r.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=i.get(t.field);s&&(r.sort=s);for(const i of e)if(i.getColumnState){const e=i.getColumnState(t.field);e&&Object.assign(r,e)}return r})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const i=this.columns,o=new Map(e.columns.map(e=>[e.field,e])),r=i.map(e=>{const t=o.get(e.field);if(!t)return e;const i={...e};return void 0!==t.width&&(i.width=t.width,i.__renderedWidth=t.width),void 0!==t.visible&&(i.hidden=!t.visible),i});r.sort((e,t)=>(o.get(e.field)?.order??1/0)-(o.get(t.field)?.order??1/0)),this.columns=r;const n=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(n.length>0){const e=n[0];e.sort&&(this.#e._sortState={field:e.field,direction:"asc"===e.sort.direction?1:-1})}else this.#e._sortState=null;for(const s of t)if(s.applyColumnState)for(const t of e.columns)s.applyColumnState(t.field,t)}resetState(e){this.#_=void 0,this.#e._sortState=null,this.#p=this.#S(this.#f),this.#E();for(const t of e)if(t.applyColumnState)for(const e of this.columns)t.applyColumnState(e.field,{field:e.field,order:0,visible:!0});this.requestStateChange(e)}#T(){const e=new Map,t=this.#e._sortState;return t&&e.set(t.field,{direction:1===t.direction?"asc":"desc",priority:0}),e}requestStateChange(e){this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=void 0;const t=this.collectState(e);this.#e._emit("column-state-change",t)},100)}setColumnVisible(e,t){const i=this.columns,o=i.find(t=>t.field===e);if(!o)return!1;if(!t&&o.lockVisible)return!1;if(!t){if(0===i.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!o.hidden!=!t&&(o.hidden=!t,this.#e._emit("column-visibility",{field:e,visible:t,visibleColumns:i.filter(e=>!e.hidden).map(e=>e.field)}),this.#e._clearRowPool(),this.#e._setup(),!0)}toggleColumnVisibility(e){const t=this.columns.find(t=>t.field===e);return!!t&&this.setColumnVisible(e,!!t.hidden)}isColumnVisible(e){const t=this.columns.find(t=>t.field===e);return!!t&&!t.hidden}showAllColumns(){const e=this.columns;e.some(e=>e.hidden)&&(e.forEach(e=>e.hidden=!1),this.#e._emit("column-visibility",{visibleColumns:e.map(e=>e.field)}),this.#e._clearRowPool(),this.#e._setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:!0===e.meta?.utility}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const t=new Map(this.columns.map(e=>[e.field,e])),i=[];for(const o of e){const e=t.get(o);e&&(i.push(e),t.delete(o))}for(const o of t.values())i.push(o);this.columns=i,U(this.#e),C(this.#e),this.#e._requestSchedulerPhase(G.VIRTUALIZATION,"configManager")}parseLightDomColumns(e){this.#u||(this.#g=Array.from(e.querySelectorAll("tbw-grid-column")),this.#u=this.#g.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const i=e.getAttribute("type")||void 0,o={field:t,type:i&&new Set(["number","string","date","boolean","select"]).has(i)?i:void 0,header:e.getAttribute("header")||void 0,sortable:e.hasAttribute("sortable"),editable:e.hasAttribute("editable")},r=e.getAttribute("width");if(r){const e=parseFloat(r);!isNaN(e)&&/^\d+(\.\d+)?$/.test(r.trim())?o.width=e:o.width=r}const n=e.getAttribute("minWidth")||e.getAttribute("min-width");if(n){const e=parseFloat(n);isNaN(e)||(o.minWidth=e)}e.hasAttribute("resizable")&&(o.resizable=!0),e.hasAttribute("sizable")&&(o.resizable=!0);const s=e.getAttribute("editor"),l=e.getAttribute("renderer");s&&(o.__editorName=s),l&&(o.__rendererName=l);const a=e.getAttribute("options");a&&(o.options=a.split(",").map(e=>{const[t,i]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:i?.trim()||t.trim()}}));const d=e.querySelector("tbw-grid-column-view"),c=e.querySelector("tbw-grid-column-editor"),h=e.querySelector("tbw-grid-column-header");d&&(o.__viewTemplate=d),c&&(o.__editorTemplate=c),h&&(o.__headerTemplate=h);const u=globalThis.DataGridElement,g=u?.getAdapters?.()??[],f=d??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(o.viewRenderer=e)}const w=c??e,b=g.find(e=>e.canHandle(w));if(b){const e=b.createEditor(w);e&&(o.editor=e)}return o}).filter(e=>!!e)}(e):[])}clearLightDomCache(){this.#u=void 0}#P=new Map;registerLightDomHandler(e,t){this.#P.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#P.delete(e.toLowerCase())}observeLightDOM(e){this.#m&&this.#m.disconnect();const t=new Set,i=()=>{this.#C=void 0;for(const e of t){const t=this.#P.get(e);t?.()}t.clear()};this.#m=new MutationObserver(e=>{for(const i of e){for(const e of i.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const i=e.tagName.toLowerCase();this.#P.has(i)&&t.add(i)}if("attributes"===i.type&&i.target.nodeType===Node.ELEMENT_NODE){const e=i.target.tagName.toLowerCase();this.#P.has(e)&&t.add(e)}}t.size>0&&!this.#C&&(this.#C=setTimeout(i,0))}),this.#m.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#b.push(e)}notifyChange(){for(const e of this.#b)e()}dispose(){this.#m?.disconnect(),this.#b=[],this.#v&&clearTimeout(this.#v),this.#C&&(clearTimeout(this.#C),this.#C=void 0)}}function Y(){if("undefined"!=typeof window&&window.location){const e=window.location.hostname;if("localhost"===e||"127.0.0.1"===e||"::1"===e)return!0}return"undefined"!=typeof process&&"production"!==process.env?.NODE_ENV}function K(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"🗹":"☐"}</span>`}function Z(e){if(null==e||""===e)return"";if(e instanceof Date)return isNaN(e.getTime())?"":e.toLocaleDateString();if("number"==typeof e||"string"==typeof e){const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleDateString()}return""}function Q(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const i=e.closest(".data-grid-row");if(!i)return-1;const o=i.parentElement;if(!o)return-1;const r=o.querySelectorAll(":scope > .data-grid-row");for(let n=0;n<r.length;n++)if(r[n]===i)return n;return-1}function J(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function ee(e){return"rtl"===function(e){try{if("rtl"===getComputedStyle(e).direction)return"rtl"}catch{}try{const t=e.closest?.("[dir]")?.getAttribute("dir");if("rtl"===t)return"rtl"}catch{}return"ltr"}(e)}function te(e,t){const i=t.renderer||t.viewRenderer;if(i)return i;if(!t.type)return;const o=e.__frameworkAdapter;if(o?.getTypeDefault){const e=o.getTypeDefault(t.type);if(e?.renderer)return e.renderer}}function ie(e,t){if(t.format)return t.format;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const e=i.getTypeDefault(t.type);if(e?.format)return e.format}}const oe='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function re(e){return(e.__editingCellCount??0)>0}function ne(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(".cell.editing").forEach(e=>e.classList.remove("editing"))}const se=document.createElement("template");se.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const le=document.createElement("template");function ae(){return se.content.firstElementChild.cloneNode(!0)}function de(){return le.content.firstElementChild.cloneNode(!0)}function ce(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function he(e,t,i,o){const r=t.children,n=e._visibleColumns,s=n.length,l=r.length,c=s<l?s:l,h=e._focusRow,g=e._focusCol,f=e._hasAfterCellRenderHook?.()??!1;let p=e.__hasSpecialColumns;if(void 0===p){p=!1;const t=e.__frameworkAdapter;for(let e=0;e<s;e++){const i=n[e];if(i.__viewTemplate||i.__compiledView||i.renderer||i.viewRenderer||i.externalView||i.format||i.cellClass||"date"===i.type||"boolean"===i.type||i.type&&t?.getTypeDefault?.(i.type)?.renderer||i.type&&t?.getTypeDefault?.(i.type)?.format){p=!0;break}}e.__hasSpecialColumns=p}const w=String(o);if(p){for(let s=0;s<c;s++){if(n[s].externalView){if(!r[s].querySelector("[data-external-view]"))return void ue(e,t,i,o)}}for(let s=0;s<c;s++){const l=n[s],c=r[s];c.getAttribute("data-row")!==w&&c.setAttribute("data-row",w);const p=c.classList.contains("editing");if(!p){const e=h===o&&g===s;e!==c.classList.contains("cell-focus")&&(c.classList.toggle("cell-focus",e),c.setAttribute("aria-selected",String(e)))}const m=l.cellClass;if(m){const t=c.getAttribute("data-dynamic-classes");t&&t.split(" ").forEach(e=>e&&c.classList.remove(e));try{const e=m(i[l.field],i,l),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){const e=t.filter(e=>e&&"string"==typeof e);e.forEach(e=>c.classList.add(e)),c.setAttribute("data-dynamic-classes",e.join(" "))}else c.removeAttribute("data-dynamic-classes")}catch(b){u(a,`cellClass callback error for column '${l.field}': ${b}`,e.id),c.removeAttribute("data-dynamic-classes")}}if(p)continue;const v=te(e,l);if(v){const r=i[l.field],n=v({row:i,value:r,field:l.field,column:l,cellEl:c});"string"==typeof n?(e.__frameworkAdapter?.releaseCell?.(c),c.innerHTML=P(n)):n instanceof Node?n.parentElement!==c&&(e.__frameworkAdapter?.releaseCell?.(c),c.innerHTML="",c.appendChild(n)):null==n&&(e.__frameworkAdapter?.releaseCell?.(c),c.textContent=null==r?"":String(r)),f&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:r,cellElement:c,rowElement:t});continue}if(l.__compiledView){const r=i[l.field],n=l.__compiledView({row:i,value:r,field:l.field,column:l});l.__compiledView.__blocked?c.textContent="":(c.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(c),c.innerHTML=P(n),L(c)),f&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:r,cellElement:c,rowElement:t});continue}if(l.__viewTemplate){const r=i[l.field],n=l.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(n)?c.textContent="":(c.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(c),c.innerHTML=P(H(n,{row:i,value:r})),L(c)),f&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:r,cellElement:c,rowElement:t});continue}if(l.externalView)continue;const C=i[l.field];let _;const y=ie(e,l);if(y){try{const e=y(C,i);_=null==e?"":String(e)}catch(b){u(d,`Format error in column '${l.field}': ${b}`,e.id),_=null==C?"":String(C)}c.textContent=_}else"date"===l.type?(_=Z(C),c.textContent=_):"boolean"===l.type?c.innerHTML=K(!!C):(_=null==C?"":String(C),c.textContent=_);f&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:C,cellElement:c,rowElement:t})}}else for(let a=0;a<c;a++){const s=r[a];if(s.classList.contains("editing"))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const l=n[a],d=i[l.field];s.textContent=null==d?"":String(d),s.getAttribute("data-row")!==w&&s.setAttribute("data-row",w);const c=h===o&&g===a;c!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",c),s.setAttribute("aria-selected",String(c))),f&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:a,value:d,cellElement:s,rowElement:t})}}function ue(e,t,i,o){t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy");const r=e.__frameworkAdapter;if(r?.releaseCell){const e=t.children;for(let t=e.length-1;t>=0;t--)r.releaseCell(e[t])}t.innerHTML="";const n=e._visibleColumns,s=n.length,l=e._focusRow,c=e._focusCol,h=e._hasAfterCellRenderHook?.()??!1,g=document.createDocumentFragment();for(let p=0;p<s;p++){const r=n[p],s=ae();s.setAttribute("aria-colindex",String(p+1)),s.setAttribute("data-col",String(p)),s.setAttribute("data-row",String(o)),s.setAttribute("data-field",r.field),s.setAttribute("data-header",r.header??r.field),r.type&&s.setAttribute("data-type",r.type);let w=i[r.field];const b=ie(e,r);if(b)try{w=b(w,i)}catch(f){u(d,`Format error in column '${r.field}': ${f}`,e.id)}const m=r.__compiledView,v=r.__viewTemplate,C=te(e,r),_=r.externalView;let y=!1;if(C){const e=C({row:i,value:w,field:r.field,column:r,cellEl:s});"string"==typeof e?(s.innerHTML=P(e),y=!0):e instanceof Node?e.parentElement!==s&&(s.textContent="",s.appendChild(e)):null==e&&(s.textContent=null==w?"":String(w))}else if(_){const t=_,o=document.createElement("div");o.setAttribute("data-external-view",""),o.setAttribute("data-field",r.field),s.appendChild(o);const n={row:i,value:w,field:r.field,column:r};if(t.mount)try{t.mount({placeholder:o,context:n,spec:t})}catch(f){u("TBW063",`External view mount error for column '${r.field}': ${f}`,e.id)}else queueMicrotask(()=>{try{e.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:o,spec:t,context:n}}))}catch(f){u("TBW064",`External view event dispatch error for column '${r.field}': ${f}`,e.id)}});o.setAttribute("data-mounted","")}else if(m){const e=m({row:i,value:w,field:r.field,column:r}),t=m.__blocked;s.innerHTML=t?"":P(e),y=!0,t&&(s.textContent="",s.setAttribute("data-blocked-template",""))}else if(v){const e=v.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(s.textContent="",s.setAttribute("data-blocked-template","")):(s.innerHTML=P(H(e,{row:i,value:w})),y=!0)}else b?s.textContent=null==w?"":String(w):"date"===r.type?s.textContent=Z(w):"boolean"===r.type?s.innerHTML=K(!!w):s.textContent=null==w?"":String(w);if(y){L(s);const e=s.textContent||"";/Proxy|Reflect\.ownKeys/.test(e)&&(s.textContent=e.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(s.textContent||"")&&(s.textContent=""))}s.hasAttribute("data-blocked-template")&&(s.textContent||"").trim().length&&(s.textContent="");("function"==typeof r.editable?r.editable(i):r.editable)?s.tabIndex=0:"boolean"===r.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),l===o&&c===p?(s.classList.add("cell-focus"),s.setAttribute("aria-selected","true")):s.setAttribute("aria-selected","false");const R=r.cellClass;if(R)try{const e=R(i[r.field],i,r),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const i of t)i&&"string"==typeof i&&(s.classList.add(i),e+=(e?" ":"")+i);s.setAttribute("data-dynamic-classes",e)}}catch(f){u(a,`cellClass callback error for column '${r.field}': ${f}`,e.id)}h&&e._afterCellRender?.({row:i,rowIndex:o,column:r,colIndex:p,value:w,cellElement:s,rowElement:t}),g.appendChild(s)}t.appendChild(g)}function ge(e,t,i){if(t.target?.closest(".resize-handle"))return;const o=Q(i.querySelector(".cell[data-row]"));if(o<0)return;const r=e._rows[o];if(!r)return;if(e._dispatchRowClick?.(t,o,r,i))return;const n=t.target?.closest(".cell[data-col]");if(n){const i=Number(n.getAttribute("data-col"));if(!isNaN(i)){if(e._dispatchCellClick?.(t,o,i,n))return;const r=e._focusRow!==o||e._focusCol!==i;if(e._focusRow=o,e._focusCol=i,n.classList.contains("editing")){r&&(J(e._bodyEl??e),n.classList.add("cell-focus"));const i=t.target,o=n.contains(i)&&i.matches(oe)?i:n.querySelector(oe);try{o?.focus({preventScroll:!0})}catch{}return}fe(e)}}}function fe(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:i,viewportEl:o}=e._virtualization,r=i,n=o?.clientHeight??r?.clientHeight??0;if(r&&n>0){const i=e._focusRow*t;i<r.scrollTop?r.scrollTop=i:i+t>r.scrollTop+n&&(r.scrollTop=i-n+t)}}const i=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;i||e.refreshVirtualWindow(!1),J(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const o=e._focusRow,r=e._virtualization.start??0,n=e._virtualization.end??e._rows.length;if(o>=r&&o<n){const n=e._bodyEl.querySelectorAll(".data-grid-row")[o-r];let s=n?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=n?.querySelector(`.cell[data-col="${e._focusCol}"]`)??n?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const o=e.querySelector(".tbw-scroll-area");if(o&&s&&(!i||t?.forceHorizontalScroll))if(t?.forceScrollLeft)o.scrollLeft=0;else if(t?.forceScrollRight)o.scrollLeft=o.scrollWidth-o.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(n??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),i=o.getBoundingClientRect(),r=e.left-i.left+o.scrollLeft,n=r+e.width,l=o.scrollLeft+t.left,a=o.scrollLeft+o.clientWidth-t.right;r<l?o.scrollLeft=r-t.left:n>a&&(o.scrollLeft=n-o.clientWidth+t.right)}}if(i&&s.classList.contains("editing")){const e=s.querySelector(oe);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(i&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else i||document.activeElement!==e&&e.focus({preventScroll:!0})}}}le.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const pe=new WeakMap;function we(e,t){const i=Q(t),o=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(i<0||o<0)return;e._focusRow=i,e._focusCol=o,J(e._bodyEl),t.classList.add("cell-focus"),t.setAttribute("aria-selected","true");const r=t.closest("tbw-grid");r&&document.activeElement!==r&&r.focus({preventScroll:!0})}function be(e,t,i,o){let r=null;const n=i.composedPath?.();if(r=n&&n.length>0?n[0]:i.target,r&&!t.contains(r)){const e=document.elementFromPoint(i.clientX,i.clientY);e&&(r=e)}const s=r?.closest?.("[data-col]"),l=r?.closest?.(".data-grid-row"),a=r?.closest?.(".header-row");let d,c,h,u,g,f;return s&&(d=parseInt(s.getAttribute("data-row")??"-1",10),c=parseInt(s.getAttribute("data-col")??"-1",10),d>=0&&c>=0&&(h=e._rows[d],f=e._visibleColumns[c],u=f?.field,g=h&&u?h[u]:void 0)),{type:o,row:h,rowIndex:void 0!==d&&d>=0?d:void 0,colIndex:void 0!==c&&c>=0?c:void 0,field:u,value:g,column:f,originalEvent:i,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:void 0!==d&&void 0!==c&&d>=0&&c>=0?{row:d,col:c}:void 0}}function me(e,t,i,o){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const i=e._rows.length-1,o=e._visibleColumns.length-1,r=void 0!==e._activeEditRows&&-1!==e._activeEditRows,n=e._visibleColumns[e._focusCol],s=n?.type,l=t.composedPath?.()??[],a=l.length?l[0]:t.target,d=e=>{if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable};if((!d(a)||"Home"!==t.key&&"End"!==t.key)&&!(d(a)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===a.tagName&&"number"===a.type||d(a)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||d(a)&&("Enter"===t.key||"Escape"===t.key)||r&&"select"===s&&("ArrowDown"===t.key||"ArrowUp"===t.key))){switch(t.key){case"Tab":return t.preventDefault(),t.shiftKey?e._focusCol>0?e._focusCol-=1:e._focusRow>0&&("function"==typeof e.commitActiveRowEdit&&e._activeEditRows===e._focusRow&&e.commitActiveRowEdit(),e._focusRow-=1,e._focusCol=o):e._focusCol<o?e._focusCol+=1:("function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow<i&&(e._focusRow+=1,e._focusCol=0)),void fe(e);case"ArrowDown":r&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=Math.min(i,e._focusRow+1),t.preventDefault();break;case"ArrowUp":r&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const i=ee(e);e._focusCol=i?Math.max(0,e._focusCol-1):Math.min(o,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const i=ee(e);e._focusCol=i?Math.min(o,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(r&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void fe(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(r&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=i,e._focusCol=o):e._focusCol=o,t.preventDefault(),void fe(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(i,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const i=e._focusRow,o=e._focusCol,r=e._visibleColumns[o],n=e._rows[i],s=r?.field??"",l=s&&n?n[s]:void 0,a=e.querySelector(`[data-row="${i}"][data-col="${o}"]`),d=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:i,colIndex:o,column:r,field:s,value:l,row:n,cellEl:a,trigger:"keyboard",originalEvent:t}});e.dispatchEvent(d);const c=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:i,col:o}});if(e.dispatchEvent(c),d.defaultPrevented||c.defaultPrevented)return void t.preventDefault();break}default:return}fe(e)}}(e,t),{signal:o}),i.addEventListener("mousedown",t=>function(e,t,i){const o=be(e,t,i,"mousedown");e._dispatchCellMouseDown?.(o)&&pe.set(e,!0)}(e,i,t),{signal:o}),document.addEventListener("mousemove",t=>function(e,t,i){if(!pe.get(e))return;const o=be(e,t,i,"mousemove");e._dispatchCellMouseMove?.(o)}(e,i,t),{signal:o}),document.addEventListener("mouseup",t=>function(e,t,i){if(!pe.get(e))return;const o=be(e,t,i,"mouseup");e._dispatchCellMouseUp?.(o),pe.set(e,!1)}(e,i,t),{signal:o})}let ve;class Ce{#e;#H=new Set;#M=new Map;constructor(e){this.#e=e}focusCell(e,t){const i=this.#e,o=i._rows.length-1;if(o<0)return;let r;if("string"==typeof t){if(r=i._visibleColumns.findIndex(e=>e.field===t),r<0)return}else r=t;const n=i._visibleColumns.length-1;n<0||(i._focusRow=Math.max(0,Math.min(e,o)),i._focusCol=Math.max(0,Math.min(r,n)),fe(i))}get focusedCell(){const e=this.#e;if(0===e._rows.length||0===e._visibleColumns.length)return null;const t=e._visibleColumns[e._focusCol];return{rowIndex:e._focusRow,colIndex:e._focusCol,field:t?.field??""}}scrollToRow(e,t){const i=this.#e._virtualization;if(!i.enabled)return;const o=i.container;if(!o)return;const r=this.#e._rows.length;if(0===r)return;const n=Math.max(0,Math.min(e,r-1)),s=t?.align??"nearest",l=t?.behavior??"instant";let a,d;const c=i.positionCache;i.variableHeights&&c&&c.length>n?(a=c[n].offset,d=c[n].height):(a=n*i.rowHeight,d=i.rowHeight);const h=i.viewportEl?.clientHeight??o.clientHeight??0;if(h<=0)return;const u=o.scrollTop,g=a+d,f=u+h;let p;switch(s){case"start":p=a;break;case"center":p=a-h/2+d/2;break;case"end":p=g-h;break;default:if(a>=u&&g<=f)return;p=a<u?a:g-h}p=Math.max(0,p),"smooth"===l?o.scrollTo({top:p,behavior:"smooth"}):o.scrollTop=p}scrollToRowById(e,t){const i=this.#e._getRowEntry(e);i&&this.scrollToRow(i.index,t)}registerExternalFocusContainer(e){if(this.#H.has(e))return;this.#H.add(e);const t=new AbortController,i=t.signal,o=this.#e;e.addEventListener("focusin",()=>{o.dataset.hasFocus=""},{signal:i}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete o.dataset.hasFocus},{signal:i}),this.#M.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#H.delete(e);const t=this.#M.get(e);t&&(t(),this.#M.delete(e))}containsFocus(e){const t=e??document.activeElement;return!!t&&(!!this.#e.contains(t)||this.isInExternalFocusContainer(t))}isInExternalFocusContainer(e){for(const t of this.#H)if(t.contains(e))return!0;return!1}destroy(){for(const e of this.#M.values())e();this.#M.clear(),this.#H.clear()}}const _e="function"==typeof requestIdleCallback;function ye(e){_e?cancelIdleCallback(e):clearTimeout(e)}function Re(e,t){if(t){const i=t({size:e});if("string"==typeof i){const e=document.createElement("div");return e.innerHTML=i,e}return i}return function(e){const t=document.createElement("div");return t.className=`tbw-spinner tbw-spinner--${e}`,t.setAttribute("role","progressbar"),t.setAttribute("aria-label","Loading"),t}(e)}function Se(e){let t=null,i=null,o=null,r=null;const n=o=>{if(!t)return;const r=o.clientX-t.startX,n=Math.max(40,t.startWidth+r),s=e._visibleColumns[t.colIndex];s.width=n,s.__userResized=!0,s.__renderedWidth=n,null==i&&(i=requestAnimationFrame(()=>{i=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:s.field,width:n}}))};let s=!1;const l=()=>{const i=null!==t;i&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",l),null!==o&&(document.documentElement.style.cursor=o,o=null),null!==r&&(document.body.style.userSelect=r,r=null),t=null,i&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(i,s,a){i.preventDefault();const d=e._headerRowEl??e.findHeaderRow?.();d&&function(t,i){const o=i.querySelectorAll(".cell");for(let r=0;r<e._visibleColumns.length;r++){if(r===t)continue;const i=e._visibleColumns[r];if(null==i.width&&!i.__userResized){const e=o[r],t=e?.getBoundingClientRect().width;t&&(i.width=Math.round(t),i.__userResized=!0,i.__renderedWidth=i.width)}}}(s,d);const c=e._visibleColumns[s],h="number"==typeof c?.width?c.width:void 0,u=c?.__renderedWidth??h??a.getBoundingClientRect().width;t={startX:i.clientX,colIndex:s,startWidth:u},window.addEventListener("mousemove",n),window.addEventListener("mouseup",l),null===o&&(o=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",null===r&&(r=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(t){const i=e._visibleColumns[t];i&&(i.__userResized=!1,i.__renderedWidth=void 0,i.width=i.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:i.field,width:i.width}})))},dispose(){l()}}}const Ee="data-animating",xe={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},Ae={change:500,insert:300,remove:200};function Te(e,t){const i=xe[t],o=getComputedStyle(e).getPropertyValue(i);if(o){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(o);if(!isNaN(e)&&e>0)return e}return Ae[t]}function Pe(e,t,i){if(t<0)return Promise.resolve(!1);const o=e.findRenderedRowElement?.(t);return o?new Promise(e=>{!function(e,t,i){e.removeAttribute(Ee),e.offsetWidth,e.setAttribute(Ee,t);const o=Te(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(Ee),i?.()},o)}(o,i,()=>e(!0))}):Promise.resolve(!1)}function He(e,t){if(t)return t(e);const i=e;return"id"in i&&null!=i.id?String(i.id):"_id"in i&&null!=i._id?String(i._id):void 0}function Me(e,t,i){const o=He(e,i);return void 0===o&&h("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),o}class Le{#e;constructor(e){this.#e=e}resolveRowId(e){return Me(e,this.#e.id,this.#e.effectiveConfig?.getRowId)}getRow(e){return this.#e._getRowEntry(e)?.row}getRowEntry(e){return this.#e._getRowEntry(e)}updateRow(e,t,i="api"){const o=this.#e,r=o._getRowEntry(e);r||h(l,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,o.id);const{row:n,index:s}=r,a=[];for(const[l,d]of Object.entries(t)){const e=n[l];e!==d&&(a.push({field:l,oldValue:e,newValue:d}),n[l]=d)}for(const{field:l,oldValue:d,newValue:c}of a)o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:n,rowId:e,rowIndex:s,field:l,oldValue:d,newValue:c,changes:t,source:i},bubbles:!0,composed:!0}));a.length>0&&(ce(o),o._requestSchedulerPhase(G.VIRTUALIZATION,"updateRow"),o._emitDataChange())}updateRows(e,t="api"){const i=this.#e;let o=!1;for(const{id:r,changes:n}of e){const e=i._getRowEntry(r);e||h(l,`Row with ID "${r}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id);const{row:s,index:a}=e;for(const[l,d]of Object.entries(n)){const e=s[l];e!==d&&(o=!0,s[l]=d,i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:s,rowId:r,rowIndex:a,field:l,oldValue:e,newValue:d,changes:n,source:t},bubbles:!0,composed:!0})))}}o&&(ce(i),i._requestSchedulerPhase(G.VIRTUALIZATION,"updateRows"),i._emitDataChange())}async insertRow(e,t,i=!0){const o=this.#e,r=Math.max(0,Math.min(e,o._rows.length));o.sourceRows=[...o.sourceRows,t];const n=[...o._rows];n.splice(r,0,t),o._rows=n,o._sortState&&(o.__originalOrder=[...o.__originalOrder,t]),ce(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(const s of o._rowPool)s.__epoch=-1;o.refreshVirtualWindow(!0),o._emitPluginEvent("row-inserted",{row:t,index:r}),o._emitDataChange(),i&&(await new Promise(e=>requestAnimationFrame(()=>e())),await Pe(o,r,"insert"))}async removeRow(e,t=!0){const i=this.#e,o=i._rows[e];if(!o)return;t&&await Pe(i,e,"remove");const r=i._rows.indexOf(o);if(r<0)return o;const n=[...i._rows];n.splice(r,1),i._rows=n;const s=i.sourceRows.indexOf(o);if(s>=0){const e=[...i.sourceRows];e.splice(s,1),i.sourceRows=e}if(i._sortState){const e=i.__originalOrder.indexOf(o);if(e>=0){const t=[...i.__originalOrder];t.splice(e,1),i.__originalOrder=t}}ce(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(const l of i._rowPool)l.__epoch=-1;return i.refreshVirtualWindow(!0),i._emitDataChange(),t&&requestAnimationFrame(()=>{i.querySelectorAll('[data-animating="remove"]').forEach(e=>{e.removeAttribute("data-animating")})}),o}async applyTransaction(e,t=!0){const i=this.#e,o={added:[],updated:[],removed:[]};if(e.remove?.length)for(const{id:l}of e.remove){const e=i._getRowEntry(l);if(!e)continue;const{row:r}=e;if(t){const e=i._rows.indexOf(r);e>=0&&await Pe(i,e,"remove")}const n=i._rows.indexOf(r);if(n<0){o.removed.push(r);continue}const s=[...i._rows];s.splice(n,1),i._rows=s;const a=i.sourceRows.indexOf(r);if(a>=0){const e=[...i.sourceRows];e.splice(a,1),i.sourceRows=e}if(i._sortState){const e=i.__originalOrder.indexOf(r);if(e>=0){const t=[...i.__originalOrder];t.splice(e,1),i.__originalOrder=t}}o.removed.push(r)}const r=new Set(e.remove?.map(e=>e.id));if(e.update?.length)for(const{id:l,changes:a}of e.update){if(r.has(l))continue;const e=i._getRowEntry(l);if(!e)continue;const{row:t,index:n}=e;let s=!1;for(const[o,r]of Object.entries(a)){const e=t[o];e!==r&&(s=!0,t[o]=r,i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:l,rowIndex:n,field:o,oldValue:e,newValue:r,changes:a,source:"api"},bubbles:!0,composed:!0})))}s&&o.updated.push(t)}if(e.add?.length)for(const l of e.add){i.sourceRows=[...i.sourceRows,l];const e=[...i._rows];e.push(l),i._rows=e,i._sortState&&(i.__originalOrder=[...i.__originalOrder,l]),o.added.push(l)}const n=o.added.length>0||o.removed.length>0,s=o.updated.length>0;if(n){ce(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(const e of i._rowPool)e.__epoch=-1;i.refreshVirtualWindow(!0)}else s&&(ce(i),i._requestSchedulerPhase(G.VIRTUALIZATION,"applyTransaction"));if((n||s)&&i._emitDataChange(),t&&o.added.length>0){await new Promise(e=>requestAnimationFrame(()=>e()));for(const e of o.added){const t=i._rows.indexOf(e);t>=0&&await Pe(i,t,"insert")}}if(t&&o.updated.length>0)for(const l of o.updated){const e=i._rows.indexOf(l);e>=0&&await Pe(i,e,"change")}return t&&o.removed.length>0&&requestAnimationFrame(()=>{i.querySelectorAll('[data-animating="remove"]').forEach(e=>{e.removeAttribute("data-animating")})}),o}#L=null;#O=[];#D=null;applyTransactionAsync(e){return this.#L||(this.#L={add:[],update:[],remove:[]}),e.add&&this.#L.add.push(...e.add),e.update&&this.#L.update.push(...e.update),e.remove&&this.#L.remove.push(...e.remove),new Promise(e=>{this.#O.push(e),null===this.#D&&(this.#D=requestAnimationFrame(()=>{this.#D=null;const e=this.#L,t=this.#O;this.#L=null,this.#O=[],this.applyTransaction(e,!1).then(e=>{for(const i of t)i(e)})}))})}}function Oe(e,t,i){const o=document.createElement(e);if(t)for(const r in t){const e=t[r];null!=e&&o.setAttribute(r,e)}return o}function De(e,t){const i=document.createElement("div");if(e&&(i.className=e),t)for(const o in t){const e=t[o];null!=e&&i.setAttribute(o,e)}return i}function Ie(e,t,i){const o=document.createElement("button");if(e&&(o.className=e),t)for(const r in t){const e=t[r];null!=e&&o.setAttribute(r,e)}return o}const ze=document.createElement("template");function ke(){return ze.content.cloneNode(!0)}function Ne(e){const t=document.createDocumentFragment(),i=De(e.hasShell?"tbw-grid-root has-shell":"tbw-grid-root");if(e.hasShell&&e.shellHeader&&e.shellBody)i.appendChild(e.shellHeader),i.appendChild(e.shellBody);else{const e=De("tbw-grid-content");e.appendChild(ke()),i.appendChild(e)}return t.appendChild(i),t}function qe(e){return e?"string"==typeof e?e:e.outerHTML:""}function $e(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function We(e,t){const i=e.querySelector("tbw-grid-header");if(!i)return;if(!t.lightDomTitle){const e=i.getAttribute("title");e&&(t.lightDomTitle=e)}const o=i.querySelectorAll("tbw-grid-header-content");o.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(o)),i.style.display="none"}function Fe(e,t,i){const o=e.querySelector(":scope > tbw-grid-tool-buttons");if(!o)return;t.hasToolButtonsContainer=!0;const r="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(r))return;const n={id:r,order:0,render:e=>{for(;o.firstChild;)e.appendChild(o.firstChild);return()=>{for(;e.firstChild;)o.appendChild(e.firstChild)}}};t.toolbarContents.set(r,n),t.lightDomToolbarContentIds.add(r),o.style.display="none"}function Ve(e,t,i){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const o=e,r=o.getAttribute("id"),n=o.getAttribute("title");if(!r||!n)return void u("TBW070",`Tool panel missing required id or title attribute: id="${r??""}", title="${n??""}"`);const s=o.getAttribute("icon")??void 0,l=o.getAttribute("tooltip")??void 0,a=parseInt(o.getAttribute("order")??"100",10);let d;const c=i?.(o);if(c)d=c;else{const e=o.innerHTML.trim();d=t=>{const i=document.createElement("div");return i.innerHTML=e,t.appendChild(i),()=>i.remove()}}const h=t.toolPanels.get(r);if(h){if(c){h.render=d,h.order=a,h.icon=s,h.tooltip=l;const e=t.panelCleanups.get(r);e&&(e(),t.panelCleanups.delete(r))}return}const g={id:r,title:n,icon:s,tooltip:l,order:a,render:d};t.toolPanels.set(r,g),t.lightDomToolPanelIds.add(r),o.style.display="none"})}function Ue(e,t,i){const o=t?.header?.toolbarContents??[],r=[...i.toolbarContents.values()],n=new Set(o.map(e=>e.id)),s=[...o];for(const l of r)n.has(l.id)||s.push(l);for(const l of s){if(i.toolbarContentCleanups.has(l.id))continue;if(!l.render)continue;const t=e.querySelector(`[data-toolbar-content="${l.id}"]`);if(!t)continue;const o=l.render(t);o&&i.toolbarContentCleanups.set(l.id,o)}}function Be(e,t){const i=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,o=t.headerContents.size>0;if(!i&&!o)return;const r=e.querySelector(".tbw-shell-content");if(!r)return;if(i){for(const e of t.lightDomHeaderContent)e.style.display="",r.appendChild(e);t.lightDomContentMoved=!0}const n=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of n){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let i=r.querySelector(`[data-header-content="${s.id}"]`);i||(i=document.createElement("div"),i.setAttribute("data-header-content",s.id),r.appendChild(i));const o=s.render(i);o&&t.headerContentCleanups.set(s.id,o)}}function Ge(e,t,i){if(t.isPanelOpen)for(const[o,r]of t.toolPanels){const i=t.expandedSections.has(o),n=e.querySelector(`[data-section="${o}"]`),s=n?.querySelector(".tbw-accordion-content");if(!n||!s)continue;n.classList.toggle("expanded",i);const l=n.querySelector(".tbw-accordion-header");if(l&&l.setAttribute("aria-expanded",String(i)),i){if(0===s.children.length){const e=r.render(s);e&&t.panelCleanups.set(o,e)}}else{const e=t.panelCleanups.get(o);e&&(e(),t.panelCleanups.delete(o)),s.innerHTML=""}}}function je(e,t){const i=e.querySelector("[data-panel-toggle]");i&&(i.classList.toggle("active",t.isPanelOpen),i.setAttribute("aria-pressed",String(t.isPanelOpen)))}function Xe(e,t){const i=e.querySelector(".tbw-tool-panel");i&&(i.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(i.style.width=""))}function Ye(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear(),e.lightDomContentMoved=!1}function Ke(e,t,i){const o=e.querySelector(`[data-section="${t}"]`);o&&o.classList.toggle("expanded",i)}function Ze(e,t,i,o){const r=$e(t),s=[],l=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const n of l){e.querySelectorAll(`:scope > ${n}`).forEach(e=>s.push(e))}e.replaceChildren();for(const n of s)e.appendChild(n);if(r){const r=qe(o?.toolPanel??n.toolPanel),s=qe(o?.expand??n.expand);qe(o?.collapse??n.collapse);const l=[...t?.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),a=[...t?.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100)),d={title:t?.header?.title??void 0,hasPanels:a.length>0,isPanelOpen:i.isPanelOpen,toolPanelIcon:r,configButtons:l.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},c={position:t?.toolPanel?.position??"right",isPanelOpen:i.isPanelOpen,expandIcon:s,panels:a.map(e=>({id:e.id,title:e.title,icon:qe(e.icon),isExpanded:i.expandedSections.has(e.id)}))},h=Ne({hasShell:!0,shellHeader:function(e){const t=De("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const i=De("tbw-shell-title");i.textContent=e.title,t.appendChild(i)}const i=De("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(i);const o=De("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const r of e.configButtons)r.hasRender&&o.appendChild(De("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));for(const r of e.apiButtons)r.hasRender&&o.appendChild(De("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));if((e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender))&&e.hasPanels&&o.appendChild(De("tbw-toolbar-separator")),e.hasPanels){const t=Ie(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.innerHTML=e.toolPanelIcon,o.appendChild(t)}return t.appendChild(o),t}(d),shellBody:function(e){const t=De("tbw-shell-body"),i=e.panels.length>0,o=1===e.panels.length,r=De("tbw-grid-content");r.appendChild(ke());let n=null;if(i){n=Oe("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel"});const t="left"===e.position?"right":"left";n.appendChild(De("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":t,"aria-hidden":"true"}));const i=De("tbw-tool-panel-content",{role:"presentation"}),r=De("tbw-accordion");for(const n of e.panels){const t=De(`tbw-accordion-section${n.isExpanded?" expanded":""}${o?" single":""}`,{"data-section":n.id}),i=Ie("tbw-accordion-header",{"aria-expanded":String(n.isExpanded),"aria-controls":`tbw-section-${n.id}`});if(o&&i.setAttribute("aria-disabled","true"),n.icon){const e=Oe("span",{class:"tbw-accordion-icon"});e.innerHTML=n.icon,i.appendChild(e)}const s=Oe("span",{class:"tbw-accordion-title"});if(s.textContent=n.title,i.appendChild(s),!o){const t=Oe("span",{class:"tbw-accordion-chevron"});t.innerHTML=e.expandIcon,i.appendChild(t)}t.appendChild(i),t.appendChild(De("tbw-accordion-content",{id:`tbw-section-${n.id}`,role:"presentation"})),r.appendChild(t)}i.appendChild(r),n.appendChild(i)}return"left"===e.position&&n?(t.appendChild(n),t.appendChild(r)):(t.appendChild(r),n&&t.appendChild(n)),t}(c)});e.appendChild(h)}else{const t=Ne({hasShell:!1});e.appendChild(t)}return r}ze.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n <div class="tbw-sr-only" aria-live="polite" aria-atomic="true"></div>\n';const Qe="tbw-grid-styles";let Je="";const et=new Map;function tt(){const e=function(){let e=document.getElementById(Qe);return e||(e=document.createElement("style"),e.id=Qe,e.setAttribute("data-tbw-grid","true"),document.head.appendChild(e)),e}(),t=Array.from(et.values()).join("\n");e.textContent=`${Je}\n\n/* Plugin Styles */\n${t}`}async function it(e){if(Je)return;if("string"==typeof e&&e.length>0)return Je=e,void tt();await new Promise(e=>setTimeout(e,50));const t=function(){try{for(const e of Array.from(document.styleSheets))try{const t=Array.from(e.cssRules||[]).map(e=>e.cssText).join("\n");if(t.includes(".tbw-grid-root")&&t.includes("tbw-grid"))return t}catch{continue}}catch(e){u("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(Je=t,tt()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||u("TBW121",`Could not find grid.css in document.styleSheets. Grid styling will not work. Available stylesheets: ${Array.from(document.styleSheets).map(e=>e.href||"(inline)").join(", ")}`)}function ot(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function rt(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function nt(e,t){(Math.abs(e.velocityY)>.1||Math.abs(e.velocityX)>.1)&&function(e,t){const i=.95,o=.01,r=()=>{e.velocityY*=i,e.velocityX*=i;const n=16*e.velocityY,s=16*e.velocityX;Math.abs(e.velocityY)>o&&(t.fauxScrollbar.scrollTop+=n),Math.abs(e.velocityX)>o&&t.scrollArea&&(t.scrollArea.scrollLeft+=s),Math.abs(e.velocityY)>o||Math.abs(e.velocityX)>o?e.momentumRaf=requestAnimationFrame(r):e.momentumRaf=0};e.momentumRaf=requestAnimationFrame(r)}(e,t),ot(e)}function st(e,t,i,o){e.addEventListener("pointerdown",i=>{"touch"===i.pointerType&&null===t.activePointerId&&(t.activePointerId=i.pointerId,e.setPointerCapture(i.pointerId),function(e,t,i){rt(i),i.startY=t,i.startX=e,i.lastY=t,i.lastX=e,i.lastTime=performance.now(),i.velocityY=0,i.velocityX=0,i.locked=!1}(i.clientX,i.clientY,t))},{passive:!0,signal:o}),e.addEventListener("pointermove",e=>{if(e.pointerId!==t.activePointerId)return;const o=function(e,t,i,o){if(null===i.lastY||null===i.lastX)return!1;const r=performance.now(),n=i.lastY-t,s=i.lastX-e;if(null!==i.lastTime){const e=r-i.lastTime;e>0&&(i.velocityY=n/e,i.velocityX=s/e)}if(i.lastY=t,i.lastX=e,i.lastTime=r,i.locked)return o.fauxScrollbar.scrollTop+=n,o.scrollArea&&(o.scrollArea.scrollLeft+=s),!0;const l=null!==i.startY?Math.abs(i.startY-t):0,a=null!==i.startX?Math.abs(i.startX-e):0;if(l<3&&a<3)return!1;const d=l>=a,{scrollHeight:c,clientHeight:h}=o.fauxScrollbar,u=c-h>0;let g=!1;if(o.scrollArea){const{scrollWidth:e,clientWidth:t}=o.scrollArea;g=e-t>0}return!!(d&&u||!d&&g)&&(i.locked=!0,o.fauxScrollbar.scrollTop+=n,o.scrollArea&&(o.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,i);o&&e.preventDefault()},{passive:!1,signal:o}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,nt(t,i))},{passive:!0,signal:o}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,ot(t))},{passive:!0,signal:o}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,ot(t))},{passive:!0,signal:o})}const lt=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',isUsed:e=>!0===e||"function"==typeof e},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property'},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property'},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property'},{property:"pinned",pluginName:"pinnedColumns",level:"column",description:'the "pinned" column property',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property (deprecated, use "pinned")',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e}],at=[{property:"rowEditable",pluginName:"editing",level:"config",description:'the "rowEditable" config property',isUsed:e=>"function"==typeof e},{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',isUsed:e=>Array.isArray(e)&&e.length>0}];function dt(e){return`import { ${ct(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function ct(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ht(e,t){return e.some(e=>e.name===t)}function ut(e,t){return e&&"object"==typeof e?"__rowCacheKey"in e?e.__rowCacheKey:"rowId"in e&&null!=e.rowId?`id:${e.rowId}`:t?`id:${t(e)}`:e:e}function gt(e,t,i){const o=ut(t,i);return"string"==typeof o?e.byKey.get(o):o&&"object"==typeof o?e.byRef.get(o):void 0}function ft(e,t,i){if(t<0||t>=e.length)return;const o=e[t],r=i-o.height;if(0!==r){o.height=i,o.measured=!0;for(let i=t+1;i<e.length;i++)e[i].offset+=r}}function pt(e,t){if(0===e.length)return-1;if(t<=0)return 0;let i=0,o=e.length-1;for(;i<=o;){const r=Math.floor((i+o)/2),n=e[r],s=n.offset+n.height;if(t<n.offset)o=r-1;else{if(!(t>=s))return r;i=r+1}}return Math.max(0,Math.min(i,e.length-1))}function wt(e,t){const{positionCache:i,heightCache:o,rows:r,start:n,end:s,getPluginHeight:l,getRowId:a}=e;let d=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const c=parseInt(t,10);if(c<n||c>=s||c>=r.length)return;const h=r[c],u=l?.(h,c);if(void 0!==u){const e=i[c];return void((!e.measured||Math.abs(e.height-u)>1)&&(ft(i,c,u),d=!0))}const g=e.offsetHeight;if(g>0){const e=i[c];(!e.measured||Math.abs(e.height-g)>1)&&(ft(i,c,g),function(e,t,i,o){const r=ut(t,o);"string"==typeof r?e.byKey.set(r,i):r&&"object"==typeof r&&e.byRef.set(r,i)}(o,h,g,a),d=!0)}});const c=d?function(e){let t=0;for(const i of e)i.measured&&t++;return t}(i):0,h=d?function(e,t){let i=0,o=0;for(const r of e)r.measured&&(i+=r.height,o++);return o>0?i/o:t}(i,e.defaultHeight):0;return{hasChanges:d,measuredCount:c,averageHeight:h}}class bt{#e;state;constructor(e,t){this.#e=e,this.state={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null,positionCache:null,heightCache:{byKey:new Map,byRef:new WeakMap},averageHeight:28,measuredCount:0,variableHeights:!1,cachedViewportHeight:0,cachedFauxHeight:0,cachedScrollAreaHeight:0,scrollAreaEl:null,...t}}updateCachedGeometry(){const e=this.state,t=e.container,i=e.viewportEl??t;i&&(e.cachedViewportHeight=i.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const o=e.scrollAreaEl;o&&(e.cachedScrollAreaHeight=o.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const i=this.state;let o,r,n;if(t){const e=i.container??this.#e._hostElement,t=i.viewportEl??e,s=i.scrollAreaEl;o=e?.clientHeight??0,r=t?.clientHeight??0,n=s?s.clientHeight:o,i.cachedFauxHeight=o,i.cachedViewportHeight=r,i.cachedScrollAreaHeight=n}else o=i.cachedFauxHeight,r=i.cachedViewportHeight,n=i.cachedScrollAreaHeight||o;const s=n-r,l=Math.max(0,o-n);let a,d=0;return i.variableHeights&&i.positionCache?a=function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(i.positionCache):(a=e*i.rowHeight,d=this.#e._getPluginExtraHeight()),a+s+d+l}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#e,i=t._rows,o=e.rowHeight||28,r=t.effectiveConfig?.rowHeight,n=t.effectiveConfig?.getRowId,s=n?e=>n(e):void 0;e.positionCache=function(e,t,i,o,r){const n=new Array(e.length);let s=0;for(let l=0;l<e.length;l++){const a=e[l];let d=r?.(a,l),c=void 0!==d;void 0===d&&(d=gt(t,a,o.rowId),c=void 0!==d),void 0===d&&(d=i,c=!1),n[l]={offset:s,height:d,measured:c},s+=d}return n}(i,e.heightCache,o,{rowId:s},(e,i)=>{const o=t._getPluginRowHeight(e,i);if(void 0!==o)return o;if(r){const t=r(e,i);if(void 0!==t&&t>0)return t}});const l=function(e,t,i,o){let r=0,n=0;for(let s=0;s<e.length;s++){const i=e[s];if(i.measured){const e=o?.(t[s],s);void 0===e&&(n+=i.height,r++)}}return{measuredCount:r,averageHeight:r>0?n/r:i}}(e.positionCache,i,o,(e,i)=>t._getPluginRowHeight(e,i));e.measuredCount=l.measuredCount,l.measuredCount>0&&(e.averageHeight=l.averageHeight)}invalidateRowHeight(e,t){const i=this.state;if(!i.variableHeights)return;if(!i.positionCache)return;const o=this.#e._rows;if(e<0||e>=o.length)return;const r=o[e];let n=t;void 0===n&&(n=this.#e._getPluginRowHeight(r,e)),void 0===n&&(n=i.rowHeight);const s=i.positionCache[e];if(s&&!(Math.abs(s.height-n)<1)&&(ft(i.positionCache,e,n),i.totalHeightEl)){const e=this.calculateTotalSpacerHeight(o.length);i.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const i=this.state;if(!i.variableHeights)return;if(!i.positionCache)return;const o=this.#e,r=o._bodyEl;if(!r)return;const n=r.querySelectorAll(".data-grid-row"),s=o.effectiveConfig?.getRowId,l=o._rows,a=wt({positionCache:i.positionCache,heightCache:i.heightCache,rows:l,defaultHeight:i.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>o._getPluginRowHeight(e,t),getRowId:s?e=>s(e):void 0},n);if(a.hasChanges&&(i.measuredCount=a.measuredCount,i.averageHeight=a.averageHeight,i.totalHeightEl)){const e=this.calculateTotalSpacerHeight(l.length);i.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){const i=this.state,o=this.#e,r=o._bodyEl;if(!r)return!1;const n=o._rows.length;if(!i.enabled)return o._renderVisibleRows(0,n),t||o._afterPluginRender(),!0;if(n<=i.bypassThreshold)return i.start=0,i.end=n,e&&(r.style.transform="translateY(0px)"),o._renderVisibleRows(0,n,o.__rowRenderEpoch),e&&i.variableHeights&&this.initializePositionCache(),e&&i.totalHeightEl&&(i.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(n,!0)}px`),o._updateAriaCounts(n,o._visibleColumns.length),t||o._afterPluginRender(),!0;const s=i.container,l=i.viewportEl??s,a=e?i.cachedViewportHeight=l.clientHeight:i.cachedViewportHeight||(i.cachedViewportHeight=l.clientHeight),d=i.rowHeight,c=s.scrollTop;let h;e&&i.variableHeights&&this.initializePositionCache();const u=i.positionCache;if(i.variableHeights&&u&&u.length>0)h=pt(u,c),-1===h&&(h=0);else{h=Math.floor(c/d);let e=0;const t=10;for(;e<t;){const t=o._getPluginExtraHeightBefore(h),i=Math.floor((c-t)/d);if(i>=h||i<0)break;h=i,e++}}h-=h%2,h<0&&(h=0);const g=o._adjustPluginVirtualStart(h,c,d);let f;if(void 0!==g&&g<h&&(h=g,h-=h%2,h<0&&(h=0)),i.variableHeights&&u&&u.length>0){const e=a+3*d;let t=0;for(f=h;f<n&&t<e;)t+=u[f].height,f++;const i=Math.ceil(a/d)+3;f-h<i&&(f=Math.min(h+i,n))}else{f=h+(Math.ceil(a/d)+3)}f>n&&(f=n);const p=i.start,w=i.end;if(!e&&h===p&&f===w)return!1;i.start=h,i.end=f;const b=e?i.cachedFauxHeight=s.clientHeight:i.cachedFauxHeight||(i.cachedFauxHeight=s.clientHeight);if(e){const e=i.scrollAreaEl;e&&(i.cachedScrollAreaHeight=e.clientHeight)}if(0===b&&a>0)return o._requestSchedulerPhase(G.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&i.totalHeightEl){const e=this.calculateTotalSpacerHeight(n);i.totalHeightEl.style.height=`${e}px`}let m;if(i.variableHeights&&u&&u[h])m=u[h].offset;else{m=h*d+o._getPluginExtraHeightBefore(h)}const v=-(c-m);return r.style.transform=`translateY(${v}px)`,o._renderVisibleRows(h,f,o.__rowRenderEpoch),e&&i.variableHeights&&this.measureRenderedRowHeights(h,f),o._updateAriaCounts(n,o._visibleColumns.length),e&&!t&&(o._afterPluginRender(),queueMicrotask(()=>{if(!i.totalHeightEl)return;const e=this.calculateTotalSpacerHeight(n);0===i.cachedFauxHeight&&i.cachedViewportHeight>0||(i.totalHeightEl.style.height=`${e}px`)})),!0}}class mt{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=new Map;cellRenderers=new Map;headerRenderers=new Map;cellEditors=new Map;_hasAfterCellRender=!1;_hasAfterRowRender=!1;eventListeners=new Map;queryHandlers=new Map;static deprecationWarned=new WeakSet;attachAll(e){for(const t of e)this.attach(t)}attach(e){if(function(e,t,i){const o=e.name,r=e.constructor.dependencies??[];for(const n of r){const e=n.name,r=n.required??!0,s=n.reason;if(!t.some(t=>t.name===e)){const t=s??`${ct(o)}Plugin requires ${ct(e)}Plugin`,n=dt(e);r?h("TBW020",`Plugin dependency error:\n\n${t}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${ct(o)}Plugin:\n ${n}\n plugins: [new ${ct(e)}Plugin(), new ${ct(o)}Plugin()]`,i):g("TBW021",`${ct(o)}Plugin: Optional "${e}" plugin not found. Some features may be unavailable.`,i)}}}(e,this.plugins,this.grid.getAttribute("id")??void 0),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);this.registerQueryHandlers(e),this.warnDeprecatedHooks(e),e.attach(this.grid),this.#I();for(const t of this.plugins)t!==e&&t.onPluginAttached&&t.onPluginAttached(e.name,e)}registerQueryHandlers(e){const t=e.constructor.manifest;if(t?.queries)for(const i of t.queries){let t=this.queryHandlers.get(i.type);t||(t=new Set,this.queryHandlers.set(i.type,t)),t.add(e)}}warnDeprecatedHooks(e){const t=e.constructor;if(mt.deprecationWarned.has(t))return;if(!Y())return;const i="function"==typeof e.getExtraHeight||"function"==typeof e.getExtraHeightBefore,o="function"==typeof e.getRowHeight;i&&!o&&(mt.deprecationWarned.add(t),u("TBW023",`"${e.name}" uses getExtraHeight() / getExtraHeightBefore() which are deprecated and will be removed in v2.0.\n → Migrate to getRowHeight(row, index) for better variable row height support.`,this.grid.getAttribute("id")??void 0))}unregisterQueryHandlers(e){for(const[t,i]of this.queryHandlers)i.delete(e),0===i.size&&this.queryHandlers.delete(t)}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--){const t=this.plugins[e];this.unsubscribeAll(t),this.unregisterQueryHandlers(t),t.detach()}this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear(),this.eventListeners.clear(),this.queryHandlers.clear(),this._hasAfterCellRender=!1,this._hasAfterRowRender=!1}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(t=>t.name===e||t.aliases?.includes(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._hasAfterCellRender}afterRowRender(e){for(const t of this.plugins)t.afterRowRender?.(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#I(){this._hasAfterCellRender=this.plugins.some(e=>"function"==typeof e.afterCellRender),this._hasAfterRowRender=this.plugins.some(e=>"function"==typeof e.afterRowRender)}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const t of this.plugins)"function"==typeof t.getExtraHeight&&(e+=t.getExtraHeight());return e}hasExtraHeight(){for(const e of this.plugins)if("function"==typeof e.getExtraHeight&&e.getExtraHeight()>0)return!0;return!1}getExtraHeightBefore(e){let t=0;for(const i of this.plugins)"function"==typeof i.getExtraHeightBefore&&(t+=i.getExtraHeightBefore(e));return t}getRowHeight(e,t){for(const i of this.plugins)if("function"==typeof i.getRowHeight){const o=i.getRowHeight(e,t);if(void 0!==o)return o}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,i){let o=e;for(const r of this.plugins)if("function"==typeof r.adjustVirtualStart){const n=r.adjustVirtualStart(e,t,i);n<o&&(o=n)}return o}renderRow(e,t,i){for(const o of this.plugins)if(o.renderRow?.(e,t,i))return!0;return!1}queryPlugins(e){const t=[],i=this.queryHandlers.get(e.type);if(i&&i.size>0){for(const o of i){const i=o.handleQuery?.(e)??o.onPluginQuery?.(e);void 0!==i&&t.push(i)}return t}for(const o of this.plugins){const i=o.handleQuery?.(e)??o.onPluginQuery?.(e);void 0!==i&&t.push(i)}return t}subscribe(e,t,i){let o=this.eventListeners.get(t);o||(o=new Map,this.eventListeners.set(t,o)),o.set(e,i)}unsubscribe(e,t){const i=this.eventListeners.get(t);i&&(i.delete(e),0===i.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,i]of this.eventListeners)i.delete(e),0===i.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const i=this.eventListeners.get(e);if(i)for(const r of i.values())try{r(t)}catch(o){f("TBW024",`Error in plugin event handler for "${e}": ${o}`,this.grid.getAttribute("id")??void 0)}}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,o=0,r=!1;for(const n of this.plugins){const s=n.getHorizontalScrollOffsets?.(e,t);s&&(i+=s.left,o+=s.right,s.skipScroll&&(r=!0))}return{left:i,right:o,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((e,t)=>(e.panel.order??0)-(t.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((e,t)=>(e.content.order??0)-(t.content.order??0))}}class vt extends HTMLElement{static tagName="tbw-grid";static version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";static#z=0;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","loading"]}get#k(){return this}#N=!1;#o;#r;#q=[];get#p(){return this.#$?.effective??{}}#W=!1;#F=!1;#V={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#U;#B=0;#G=null;#j=!1;#X=!1;#Y=0;#K;#Z={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#Q;#J;#ee;#te;#ie={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#oe;#re;#ne;#se;#le;#ae;get _pluginManager(){return this.#oe}#de=!1;#ce;#he;#_;#$;#ue=function(){return{toolPanels:new Map,headerContents:new Map,toolbarContents:new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:new Set,lightDomToolbarContentIds:new Set,apiToolPanelIds:new Set,apiHeaderContentIds:new Set,isPanelOpen:!1,expandedSections:new Set,headerContentCleanups:new Map,panelCleanups:new Map,toolbarContentCleanups:new Map,lightDomContentMoved:!1}}();#ge;#fe;#pe;#we=!1;#be=new Set;#me=new Map;#ve;#Ce=new Map;_rows=[];#_e=[];get _columns(){return this.#p.columns??[]}set _columns(e){this.#p.columns=e,this.#ye=void 0}#ye;get _visibleColumns(){return this.#ye??=this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#se.state}set _virtualization(e){Object.assign(this.#se.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#$?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#$&&(this.#$.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#$?.originalColumnNodes}set __originalColumnNodes(e){this.#$&&(this.#$.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=this.#q;this.#q=e,t!==e&&this.#Re("rows")}get sourceRows(){return this.#q}set sourceRows(e){this.#q=e}get columns(){return[...this._columns]}set columns(e){const t=this.#$?.getColumns();this.#$?.setColumns(e),t!==e&&this.#Re("columns")}get gridConfig(){return this.#p}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#$?.getGridConfig();this.#$?.setGridConfig(e),t!==e&&(this.#$.clearLightDomCache(),this.#Re("gridConfig"))}get fitMode(){return this.#p.fitMode??"stretch"}set fitMode(e){const t=this.#$?.getFitMode();this.#$?.setFitMode(e),t!==e&&this.#Re("fitMode")}get loading(){return this.#we}set loading(e){const t=this.#we;this.#we=e,e?this.setAttribute("loading",""):this.removeAttribute("loading"),t!==e&&this.#Se()}setRowLoading(e,t){const i=this.#be.has(e);t?this.#be.add(e):this.#be.delete(e),i!==t&&this.#Ee(e,t)}setCellLoading(e,t,i){let o=this.#me.get(e);const r=o?.has(t)??!1;i?(o||(o=new Set,this.#me.set(e,o)),o.add(t)):(o?.delete(t),0===o?.size&&this.#me.delete(e)),r!==i&&this.#xe(e,t,i)}isRowLoading(e){return this.#be.has(e)}isCellLoading(e,t){return this.#me.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#be)this.#Ee(e,!1);this.#be.clear();for(const[e,t]of this.#me)for(const i of t)this.#xe(e,i,!1);this.#me.clear()}get effectiveConfig(){return this.#p}get disconnectSignal(){return this.#Q||(this.#Q=new AbortController),this.#Q.signal}constructor(){super(),this.#Ae(),this.#o=new Promise(e=>this.#r=e),this.#se=new bt(this),this.#le=new Ce(this),this.#ae=new Le(this),this.#U=new j(this),this.#U.setInitialReadyResolver(()=>this.#r?.()),this.#ge=function(e,t){let i=!1;const o={get isInitialized(){return i},setInitialized(e){i=e},get isPanelOpen(){return e.isPanelOpen},get activePanel(){return e.isPanelOpen&&e.expandedSections.size>0?[...e.expandedSections][0]:null},get expandedSections(){return[...e.expandedSections]},openToolPanel(){if(e.isPanelOpen)return;if(0===e.toolPanels.size)return void u("TBW071","No tool panels registered",t.id);if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0){const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}const i=t._renderRoot;je(i,e),Xe(i,e),Ge(i,e,t._accordionIcons),t._emit("tool-panel-open",{sections:o.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolPanels.values())t.onClose?.();e.isPanelOpen=!1;const i=t._renderRoot;je(i,e),Xe(i,e),t._emit("tool-panel-close",{})},toggleToolPanel(){e.isPanelOpen?o.closeToolPanel():o.openToolPanel()},toggleToolPanelSection(i){const o=e.toolPanels.get(i);if(!o)return void u("TBW072",`Tool panel section "${i}" not found`,t.id);if(1===e.toolPanels.size)return;const r=t._renderRoot,n=e.expandedSections.has(i);if(n){const t=e.panelCleanups.get(i);t&&(t(),e.panelCleanups.delete(i)),o.onClose?.(),e.expandedSections.delete(i),Ke(r,i,!1)}else{for(const[t,o]of e.toolPanels)if(t!==i&&e.expandedSections.has(t)){const i=e.panelCleanups.get(t);i&&(i(),e.panelCleanups.delete(t)),o.onClose?.(),e.expandedSections.delete(t),Ke(r,t,!1);const n=r.querySelector(`[data-section="${t}"] .tbw-accordion-content`);n&&(n.innerHTML="")}e.expandedSections.add(i),Ke(r,i,!0),function(e,t,i){const o=t.toolPanels.get(i);if(!o?.render)return;const r=e.querySelector(`[data-section="${i}"] .tbw-accordion-content`);if(!r)return;const n=o.render(r);n&&t.panelCleanups.set(i,n)}(r,e,i)}t._emit("tool-panel-section-toggle",{id:i,expanded:!n})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(o){e.toolPanels.has(o.id)?u("TBW073",`Tool panel "${o.id}" already registered`,t.id):(e.toolPanels.set(o.id,o),i&&t.refreshShellHeader?.())},unregisterToolPanel(o){if(e.expandedSections.has(o)){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),e.expandedSections.delete(o)}e.toolPanels.delete(o),i&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(o){e.headerContents.has(o.id)?u("TBW074",`Header content "${o.id}" already registered`,t.id):(e.headerContents.set(o.id,o),i&&Be(t._renderRoot,e))},unregisterHeaderContent(i){const o=e.headerContentCleanups.get(i);o&&(o(),e.headerContentCleanups.delete(i));const r=e.headerContents.get(i);r?.onDestroy?.(),e.headerContents.delete(i);const n=t._renderRoot.querySelector(`[data-header-content="${i}"]`);n?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(o){e.toolbarContents.has(o.id)?u("TBW075",`Toolbar content "${o.id}" already registered`,t.id):(e.toolbarContents.set(o.id,o),i&&t.refreshShellHeader?.())},unregisterToolbarContent(o){const r=e.toolbarContentCleanups.get(o);r&&(r(),e.toolbarContentCleanups.delete(o));const n=e.toolbarContents.get(o);n?.onDestroy&&n.onDestroy(),e.toolbarContents.delete(o),i&&t.refreshShellHeader?.()}};return o}(this.#ue,this),this.#$=new X(this)}async#Ae(){await it('@layer tbw-base, tbw-plugins, tbw-theme;\n\n@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-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--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-v: var(--tbw-spacing-xs);--tbw-cell-padding-h: var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-cell-padding-v) var(--tbw-cell-padding-h);--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-width: 1px;--tbw-border-style: solid;--tbw-border-input: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-strong);--tbw-border-header: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-header);--tbw-row-divider: var(--tbw-border-width) var(--tbw-border-style) 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-width: 2px;--tbw-focus-outline: var(--tbw-focus-outline-width) var(--tbw-border-style) 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: 2px;--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-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-display: inline-flex;--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)}}\n@layer tbw-base{tbw-grid{color-scheme:inherit;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);font-feature-settings:"tnum","lnum";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 .tbw-grid-root{position:relative;display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root.has-shell{display:flex;flex-direction:column;height:100%}tbw-grid .tbw-grid-root:has(.selected){-webkit-user-select:none;user-select:none}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;touch-action:none}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);touch-action:none}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid .tbw-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}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)}}\n@layer tbw-base{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);text-transform:var(--tbw-header-text-transform);letter-spacing:var(--tbw-header-letter-spacing)}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;color:var(--tbw-sort-indicator-color);display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}tbw-grid .header-row>.cell:hover>span[part~=sort-indicator]{display:inline-flex;visibility:visible}tbw-grid .header-row>.cell[aria-sort=ascending]>span[part~=sort-indicator],tbw-grid .header-row>.cell[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color)}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell:last-child .resize-handle{right:0;width:calc(var(--tbw-resize-hit-area, 18px) / 2)}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 .header-group-row>.header-group-cell.sticky-left,tbw-grid .header-group-row>.header-group-cell.sticky-right{background:var(--tbw-color-header-bg);z-index:35}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-hit-area, 18px) / -2);width:var(--tbw-resize-hit-area, 18px);height:100%;cursor:e-resize;-webkit-user-select:none;user-select:none;touch-action:none;z-index:20;background:transparent}tbw-grid .resize-handle:before{content:"";position:absolute;top:0;left:50%;transform:translate(-50%);width:var(--tbw-resize-handle-width);height:100%;background:var(--tbw-resize-handle-color);border-radius:var(--tbw-resize-handle-border-radius);transition:background .12s ease}tbw-grid .resize-handle:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-handle-width);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:before{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}}\n@layer tbw-base{tbw-grid .data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style}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);align-content:center;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}}\n@layer tbw-base{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;touch-action:none}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}}\n@layer tbw-base{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:var(--tbw-z-layer-toolpanel, 31);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:start;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}}\n@layer tbw-base{.tbw-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:1000;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-spinner{--tbw-spinner-size: 48px;--tbw-spinner-border-width: 3px;--tbw-spinner-color: var(--tbw-color-accent);--tbw-spinner-track-color: var(--tbw-color-border);width:var(--tbw-spinner-size);height:var(--tbw-spinner-size);border:var(--tbw-spinner-border-width) solid var(--tbw-spinner-track-color);border-top-color:var(--tbw-spinner-color);border-radius:50%;animation:tbw-spin .8s linear infinite}.tbw-spinner--large{--tbw-spinner-size: min(48px, calc(100% - 16px) )}.tbw-spinner--small{--tbw-spinner-size: calc(var(--tbw-row-height, 28px) * .6);--tbw-spinner-border-width: 2px}.data-grid-row.tbw-row-loading{position:relative;pointer-events:none}.tbw-row-loading-overlay{position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out;pointer-events:none;display:flex;align-items:center}.tbw-row-loading-spinner{--_spinner-size: calc(var(--tbw-row-height, 28px) * .6);margin-left:var(--tbw-spacing-md);width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite}.cell.tbw-cell-loading{position:relative;pointer-events:none}.cell.tbw-cell-loading:before{content:"";position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out}.cell.tbw-cell-loading:after{--_spinner-size: calc(var(--tbw-row-height, 28px) * .5);content:"";position:absolute;left:var(--tbw-spacing-sm);top:0;bottom:0;margin:auto 0;width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite;z-index:27}}\n@layer tbw-base{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}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}}@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)}}@keyframes tbw-spin{to{transform:rotate(360deg)}}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}\n@layer tbw-base{@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}}}\n')}getPlugin(e){return this.#oe?.getPlugin(e)}getPluginByName(e){return this.#oe?.getPluginByName(e)}requestRender(){this.#U.requestPhase(G.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#U.requestPhase(G.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#U.requestPhase(G.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){C(this)}requestAfterRender(){this.#U.requestPhase(G.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this._virtualization.start=-1,this.refreshVirtualWindow(!1)}#Te(){this.#oe=new mt(this);const e=this.#p?.plugins,t=Array.isArray(e)?e:[],i=this.#p?.features;let o=[];i&&ve&&(o=ve(i));const r=o.length>0?[...o,...t]:t;this.#oe.attachAll(r)}#Pe(){!function(e){let t=!1;for(const{name:i,styles:o}of e)et.has(i)||(et.set(i,o),t=!0);t&&tt()}(this.#oe?.getPluginStyles()??[])}#He(){const e=this.#p?.plugins,t=Array.isArray(e)?e:[],i=this.#p?.features??void 0,o=i!==this.#ne;if((this.#re===t||void 0!==this.#re&&this.#re.length===t.length&&this.#re.every((e,i)=>e===t[i]))&&!o)return void(this.#re=t);this.#oe&&this.#oe.detachAll();for(const n of this.#ue.toolPanels.keys()){const e=this.#ue.lightDomToolPanelIds.has(n),t=this.#ue.apiToolPanelIds.has(n);if(!e&&!t){const e=this.#ue.panelCleanups.get(n);e&&(e(),this.#ue.panelCleanups.delete(n)),this.#ue.toolPanels.delete(n)}}for(const n of this.#ue.headerContents.keys()){if(this.#ue.apiHeaderContentIds.has(n))continue;const e=this.#ue.headerContentCleanups.get(n);e&&(e(),this.#ue.headerContentCleanups.delete(n)),this.#ue.headerContents.delete(n)}this.#Te(),this.#Pe(),this.#re=t,this.#ne=i,this.#Me(),this.#Le();const r=this.#j;if(this.#j=this.#oe?.getAll().some(e=>e.onScroll)??!1,!r&&this.#j){const e=this.#k.querySelector(".tbw-grid-content")??this.#k.querySelector(".tbw-grid-root");this.#Oe(e)}}#De(){this.#oe?.detachAll()}#Le(){if(!this.#oe)return;const e=this.#oe.getToolPanels();for(const{panel:i}of e)this.#ue.toolPanels.has(i.id)||this.#ue.toolPanels.set(i.id,i);const t=this.#oe.getHeaderContents();for(const{content:i}of t)this.#ue.headerContents.has(i.id)||this.#ue.headerContents.set(i.id,i)}#Ie(){const e=vt.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return i=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(i);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(i);if(e)return e}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",vt.version),this.id||(this.id="tbw-grid-"+ ++vt.#z),this._rows=Array.isArray(this.#q)?[...this.#q]:[],this.#Q&&(this.#Q.abort(),this.#de=!1),this.#Q=new AbortController,this.#te&&(ye(this.#te),this.#te=void 0),this.#ze(),this.#$.parseLightDomColumns(this),this.#$.merge(),this.#Te();const e=this.#p?.plugins;var t,i;this.#re=Array.isArray(e)?e:[],this.#ne=this.#p?.features??void 0,this.#Le(),this.#N||(this.#ke(),this.#Pe(),this.#N=!0),this.#Ne(),this.#te=(t=()=>{this.#qe()},i={timeout:100},_e?requestIdleCallback(t,i):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#te&&(ye(this.#te),this.#te=void 0),this.#Y&&(clearTimeout(this.#Y),this.#Y=0),this.#De(),function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const i=e.toolPanels.get(t);i?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#ue),this.#ge.setInitialized(!1),this.#fe?.(),this.#fe=void 0,this.#pe?.(),this.#pe=void 0,rt(this.#Z),this.#Q&&(this.#Q.abort(),this.#Q=void 0),this.#ce?.abort(),this.#ce=void 0,this.#de=!1,this._resizeController&&this._resizeController.dispose(),this.#J&&(this.#J.disconnect(),this.#J=void 0),this.#ee&&(this.#ee.disconnect(),this.#ee=void 0,this.#$e=!1),ce(this),this.#We.clear(),this._virtualization.heightCache?.byKey.clear(),this.#re=void 0,this.#ne=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#W=!1}attributeChangedCallback(e,t,i){if("loading"===e){const e=null!==i&&"false"!==i;return void(this.loading!==e&&(this.loading=e))}if(t!==i&&i&&"null"!==i&&"undefined"!==i)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(i);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{u("TBW130",`Invalid JSON for '${e}' attribute: ${i}`,this.id)}else"fit-mode"===e&&(this.fitMode=i)}#Ne(){const e=this.#k.querySelector(".tbw-grid-content")??this.#k.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.#ge.isInitialized){Be(this.#k,this.#ue),Ue(this.#k,this.#p?.shell,this.#ue);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#ue.toolPanels.has(e)&&(this.openToolPanel(),this.#ue.expandedSections.add(e)),this.#ue.isPanelOpen&&(Xe(this.#k,this.#ue),Ge(this.#k,this.#ue,(this.#p,this.#p)),je(this.#k,this.#ue))}if(this.setAttribute("data-upgraded",""),this.#W=!0,this._resizeController=Se(this),this.#Fe(),this.#Oe(e),this.#de)return;this.#de=!0;const t=this.disconnectSignal;me(this,this,this.#k,t),this.#Me(),queueMicrotask(()=>this.#Ve()),this.#U.requestPhase(G.FULL,"afterConnect")}#Me(){const e=this.#p.rowHeight,t=this.#oe.hasRowHeightPlugin();"function"==typeof e||t?this._virtualization.variableHeights||(this._virtualization.variableHeights=!0,this._virtualization.rowHeight="number"==typeof e&&e>0?e:this._virtualization.rowHeight||28,this.#se.initializePositionCache(),"function"!=typeof e&&(this.#X=!0)):!t&&"function"!=typeof e&&this._virtualization.variableHeights?(this._virtualization.variableHeights=!1,this._virtualization.positionCache=null):"number"==typeof e&&e>0?(this._virtualization.rowHeight=e,this._virtualization.variableHeights=!1):requestAnimationFrame(()=>this.#Ue())}#Ue(){if(this.#oe.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;if(e.style.getPropertyValue("--tbw-row-height"))return;const t=this.#Be(),i=e.querySelectorAll(".cell");let o=0;i.forEach(e=>{const t=e.offsetHeight;t>o&&(o=t)});const r=e.getBoundingClientRect(),n=Math.max(r.height,o),s=this._virtualization.rowHeight,l=t>0&&Math.abs(t-s)>1;(l||n>0&&n-s>1)&&(this._virtualization.rowHeight=l?Math.max(t,n):n,this.#U.requestPhase(G.VIRTUALIZATION,"measureRowHeight"))}#Be(){const e=getComputedStyle(this).getPropertyValue("--tbw-row-height").trim();if(!e)return 0;if(e.endsWith("px"))return parseFloat(e)||0;const t=this._bodyEl?.querySelector('.data-grid-row:not([style*="--tbw-row-height"]) > .cell');if(!t)return 0;const i=parseFloat(getComputedStyle(t).minHeight);return i>0?i:0}#Ge(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let i=0;t.forEach(e=>{const t=e.offsetHeight;t>i&&(i=t)});const o=e.getBoundingClientRect(),r=Math.max(o.height,i);if(r>0){if(Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r),this.#se.initializePositionCache(),this._virtualization.totalHeightEl){const e=this.#se.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#Oe(e){this.#ce?.abort(),this.#ce=new AbortController;const t=this.#ce.signal,i=e?.querySelector(".faux-vscroll"),o=e?.querySelector(".rows");if(this._virtualization.container=i??this,this.#j=this.#oe?.getAll().some(e=>e.onScroll)??!1,i&&o){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#j)return;const e=i.scrollTop,t=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)o.style.transform=`translateY(${-e}px)`;else{const i=this._virtualization.positionCache;let r,n;if(this._virtualization.variableHeights&&i&&i.length>0){r=pt(i,e),-1===r&&(r=0);const o=r-r%2;n=i[o]?.offset??o*t}else{r=Math.floor(e/t);n=(r-r%2)*t}const s=-(e-n);o.style.transform=`translateY(${s}px)`}this.#G=e,this.#B||(this.#B=requestAnimationFrame(()=>{this.#B=0,null!==this.#G&&(this.#je(this.#G),this.#G=null)}))},{passive:!0,signal:t});const e=this.#k.querySelector(".tbw-scroll-area");this.#he=e,this._virtualization.scrollAreaEl=e,e&&this.#j&&e.addEventListener("scroll",()=>{const t=this.#ie;t.scrollTop=i.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=i.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=i.clientHeight,t.clientWidth=e.clientWidth,this.#oe?.onScroll(t)},{passive:!0,signal:t});const r=this.#k.querySelector(".tbw-grid-content"),n=this.#he;r&&(r.addEventListener("wheel",e=>{try{if(r.querySelector("select:open"))return}catch{}const t=e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY);if(t&&n){const t=e.shiftKey?e.deltaY:e.deltaX,{scrollLeft:i,scrollWidth:o,clientWidth:r}=n;(t>0&&i<o-r||t<0&&i>0)&&(e.preventDefault(),n.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:o,clientHeight:r}=i;(e.deltaY>0&&t<o-r||e.deltaY<0&&t>0)&&(e.preventDefault(),i.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),st(r,this.#Z,{fauxScrollbar:i,scrollArea:n},t))}var r,n,s;this._bodyEl&&(r=this,n=this._bodyEl,s=t,n.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");if(!t)return;if(t.classList.contains("editing"))return;const i=e.target;i.draggable||i.closest('[draggable="true"]')||e.preventDefault(),we(r,t)},{signal:s}),n.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&ge(r,e,t),!document.activeElement?.closest(".cell.editing")){const t=e.target.closest("tbw-grid");t&&t.focus({preventScroll:!0})}},{signal:s}),n.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&ge(r,e,t)},{signal:s})),this.#J?.disconnect(),this._virtualization.viewportEl&&(this.#J=new ResizeObserver(()=>{this.#Xe(),this.#U.requestPhase(G.VIRTUALIZATION,"resize-observer")}),this.#J.observe(this._virtualization.viewportEl)),this.#k.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#k.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#k.contains(t)||this.#le.isInExternalFocusContainer(t))||delete this.dataset.hasFocus},{signal:t})}#$e=!1;#Ye(){if(this.#$e)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#$e=!0,this.#ee?.disconnect(),this.#ee=new ResizeObserver(()=>{this.#Ue()}),this.#ee.observe(e))}addEventListener(e,t,i){super.addEventListener(e,t,i)}removeEventListener(e,t,i){super.removeEventListener(e,t,i)}on(e,t){const i=e=>{t(e.detail,e)};return this.addEventListener(e,i),()=>this.removeEventListener(e,i)}#Ke(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#Ke("data-change",{rowCount:this._rows.length,sourceRowCount:this.#q.length})}#Ve(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const i=t===this._focusRow;e.setAttribute("aria-selected",String(i)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(i&&t===this._focusCol))})})}#Re(e){this.#V[e]=!0,this.#F||(this.#F=!0,queueMicrotask(()=>this.#Ze()))}#Ze(){if(!this.#F||!this.#W)return void(this.#F=!1);const e=this.#V;if(this.#F=!1,this.#V={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig)return this.#Qe(),void(e.rows&&this.#Je());e.columns&&this.#et(),e.rows&&this.#Je(),e.fitMode&&this.#tt()}#Je(){this._rows=Array.isArray(this.#q)?[...this.#q]:[],this._rebuildRowIdMap(),this.#U.requestPhase(G.ROWS,"applyRowsUpdate")}_rebuildRowIdMap(){this.#Ce.clear();const e=this.#p.getRowId;this._rows.forEach((t,i)=>{const o=He(t,e);void 0!==o&&this.#Ce.set(o,{row:t,index:i})})}#et(){ce(this),this.#$.merge(),this.#Fe()}#tt(){this.#$.merge();"fixed"===this.#p.fitMode?(this.__didInitialAutoSize=!1,b(this)):(this._columns.forEach(e=>{!e.__userResized&&e.__autoSized&&delete e.width}),C(this))}#Qe(){We(this,this.#ue),Fe(this,this.#ue);const e=!!this.#k.querySelector(".has-shell"),t=!!this.#k.querySelector(".tbw-tool-panel"),i=this.#k.querySelectorAll(".tbw-accordion-section").length,o=this.#k.querySelector(".tbw-tool-panel")?.dataset.position??"right";this.#$.parseLightDomColumns(this),this.#$.merge(),this.#He(),this.#Me(),Ve(this,this.#ue,this.#Ie()),this.#$.markSourcesChanged(),this.#$.merge();const r=$e(this.#p?.shell),n=(this.#p?.shell?.toolPanels?.length??0)>0,s=this.#p?.shell?.toolPanels?.length??0,l=this.#p?.shell?.toolPanel?.position??"right";if(e!==r||!t&&n||t&&s!==i||t&&o!==l)return Ye(this.#ue),this.#ke(),this.#Pe(),this.#Ne(),void this._rebuildRowIdMap();e&&this.#it(),this._rebuildRowIdMap(),this.#U.requestPhase(G.COLUMNS,"applyGridConfigUpdate")}#it(){const e=this.#k.querySelector(".tbw-shell-header");if(!e)return;const t=this.#p.shell?.header?.title??this.#ue.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()}#ot(){if(this.__rowRenderEpoch++,this.#oe){const e=this.#_e.length>0?this.#_e:this._columns,t=e.filter(e=>!e.hidden),i=e.filter(e=>e.hidden),o=this.#oe.processColumns([...t]);if(o!==t){const r=new Set(o.map(e=>e.field));!t.some(e=>r.has(e.field))&&o.length>0?this._columns=[...o,...i]:this._columns=this.#rt(e,o,i)}else this._columns=[...e]}}#rt(e,t,i){if(0===i.length)return t;const o=new Map;for(const l of t)o.set(l.field,l);const r=new Set(e.map(e=>e.field)),n=[];for(const l of t)r.has(l.field)||n.push(l);const s=[];for(const l of e){const e=o.get(l.field);e?s.push(e):l.hidden&&s.push(l)}return s.push(...n),s}#nt(){ce(this);const e=function(e,t){if(!e._sortState)return t;e.__originalOrder=[...t];const i=(e.effectiveConfig?.sortHandler??I)(t,e._sortState,e._columns);return i&&"function"==typeof i.then?t:i}(this,Array.isArray(this.#q)?[...this.#q]:[]),t=this.#oe?.processRows(e)??e;this._rows=t,this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#se.initializePositionCache(),this._emitDataChange()}#st(e){const t={...o,...e.animation},i=t.mode??"reduced-motion";let r=1;!1===i||"off"===i?r=0:!0!==i&&"on"!==i||(r=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(r)),this.dataset.animationMode="boolean"==typeof i?i?"on":"off":i}_renderVisibleRows(e,t,i=this.__rowRenderEpoch){if(this.#K||(this.#K=(e,t,i)=>this.#oe?.renderRow(e,t,i)??!1),function(e,t,i,o,r){const n=Math.max(0,i-t),s=e._bodyEl,l=e._visibleColumns,a=l.length;let d=e.__cachedHeaderRowCount;for(void 0===d&&(d=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=d);e._rowPool.length<n;){const t=de();e._rowPool.push(t)}if(e._rowPool.length>n){for(let t=n;t<e._rowPool.length;t++){const i=e._rowPool[t];i.parentNode===s&&i.remove()}e._rowPool.length=n}const c=r&&!1!==e.__hasRenderRowPlugins,h=e._hasAfterRowRenderHook?.()??!1,g=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let p=0;p<n;p++){const i=t+p,n=e._rows[i],w=e._rowPool[p];if(w.setAttribute("aria-rowindex",String(i+d+1)),c&&r(n,w,i)){w.__epoch=o,w.__rowDataRef=n,w.parentNode!==s&&s.appendChild(w);continue}const b=w.__epoch,m=w.__rowDataRef;let v=w.children.length;v>a&&w.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&v--;const C=b===o&&v===a,_=m!==n,y=!!e._isGridEditMode;let R=!1;if(C&&_)for(let e=0;e<a;e++)if(l[e].externalView&&!w.querySelector(`.cell[data-col="${e}"] [data-external-view]`)){R=!0;break}if(!C||R){const t=re(w),r=y&&!_||e._activeEditRows===i;t&&!r?(w.__isCustomRow&&(w.className="data-grid-row",w.setAttribute("role","row"),w.__isCustomRow=!1),ne(w),ue(e,w,n,i),w.__epoch=o,w.__rowDataRef=n):t&&r?(he(e,w,n,i),w.__rowDataRef=n):(w.__isCustomRow&&(w.className="data-grid-row",w.setAttribute("role","row"),w.__isCustomRow=!1),ue(e,w,n,i),w.__epoch=o,w.__rowDataRef=n)}else if(_){const t=re(w),r=e._activeEditRows===i;t&&!r?(ne(w),ue(e,w,n,i),w.__epoch=o,w.__rowDataRef=n):(he(e,w,n,i),w.__rowDataRef=n)}else{const t=re(w),r=y||e._activeEditRows===i;t&&!r?(ne(w),ue(e,w,n,i),w.__epoch=o,w.__rowDataRef=n):he(e,w,n,i)}let S=!1;const E=e._changedRowIdSet;if(E&&E.size>0)try{const t=e.getRowId?.(n);t&&(S=E.has(t))}catch{}S!==w.classList.contains("changed")&&w.classList.toggle("changed",S);const x=e.effectiveConfig?.rowClass;if(x){const t=w.getAttribute("data-dynamic-classes");t&&t.split(" ").forEach(e=>e&&w.classList.remove(e));try{const e=x(n),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const i of t)i&&"string"==typeof i&&(w.classList.add(i),e+=(e?" ":"")+i);w.setAttribute("data-dynamic-classes",e)}else w.removeAttribute("data-dynamic-classes")}catch(f){u("TBW060",`rowClass callback error: ${f}`,e.id),w.removeAttribute("data-dynamic-classes")}}if(g){const e=g(n,i);void 0!==e&&e>0?w.style.setProperty("--tbw-row-height",`${e}px`):w.style.removeProperty("--tbw-row-height")}h&&e._afterRowRender?.({row:n,rowIndex:i,rowElement:w}),w.parentNode!==s&&s.appendChild(w)}}(this,e,t,i,this.#K),this.#be.size>0)for(const o of this.#be)this.#Ee(o,!0)}#lt={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaDescribedBy:void 0};_updateAriaCounts(e,t){!function(e,t,i,o,r){if(o===e.rowCount&&r===e.colCount)return!1;const n=e.rowCount;e.rowCount=o,e.colCount=r,t&&(t.setAttribute("aria-rowcount",String(o)),t.setAttribute("aria-colcount",String(r))),o!==n&&i&&(o>0?i.setAttribute("role","rowgroup"):i.removeAttribute("role"))}(this.#lt,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#U.requestPhase(e,t)}_getPluginExtraHeight(){return this.#oe?.getExtraHeight()??0}_getPluginRowHeight(e,t){return this.#oe?.getRowHeight?.(e,t)}_getPluginExtraHeightBefore(e){return this.#oe?.getExtraHeightBefore?.(e)??0}_adjustPluginVirtualStart(e,t,i){return this.#oe?.adjustVirtualStart(e,t,i)}_afterPluginRender(){this.#oe?.afterRender()}_emitPluginEvent(e,t){this.#oe?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#$.parseLightDomColumns(this),this.#$.merge(),this.#He(),function(e,t,i){const o=lt,r=at,n=new Map;function s(e,t,i,o,r=!1){n.has(e)||n.set(e,{description:t,importHint:i,fields:[],isConfigProperty:r});const s=n.get(e);s.fields.includes(o)||s.fields.push(o)}for(const a of r){const i=e[a.property];(a.isUsed?a.isUsed(i):void 0!==i)&&!ht(t,a.pluginName)&&s(a.pluginName,a.description,dt(a.pluginName),a.property,!0)}const l=e.columns;if(l&&l.length>0)for(const a of l)for(const e of o){const i=a[e.property];if((e.isUsed?e.isUsed(i):void 0!==i)&&!ht(t,e.pluginName)){const t=a.field||"<unknown>";s(e.pluginName,e.description,dt(e.pluginName),t)}}if(n.size>0){const e=[];for(const[t,{description:i,importHint:o,fields:r,isConfigProperty:s}]of n)if(s)e.push(`Config uses ${i}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${o}\n plugins: [new ${ct(t)}Plugin(), ...]`);else{const n=r.slice(0,3).join(", ")+(r.length>3?`, ... (${r.length} total)`:"");e.push(`Column(s) [${n}] use ${i}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${o}\n plugins: [new ${ct(t)}Plugin(), ...]`)}h([...n.values()].some(e=>e.isConfigProperty)?"TBW002":"TBW001",`Configuration error:\n\n${e.join("\n\n")}\n\nThis validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`,i)}}(this.#p,this.#oe?.getPlugins()??[],this.id),function(e,t){const i=[],o=[];for(const r of e){const e=r.constructor.manifest;if(e?.configRules)for(const t of e.configRules){const e=r.config;if(t.check(e)){const e=`[${ct(r.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?i.push(e):o.push(e)}}}if(o.length>0&&Y())for(const r of o)u("TBW004",r,t);i.length>0&&h("TBW003",`Configuration error:\n\n${i.join("\n\n")}`,t)}(this.#oe?.getPlugins()??[],this.id),function(e,t){if(!Y())return;const i=new Set(e.map(e=>e.name)),o=new Set;for(const r of e){const e=r.constructor.manifest;if(e?.incompatibleWith)for(const n of e.incompatibleWith)if(i.has(n.name)){const e=[r.name,n.name].sort().join("↔");if(o.has(e))continue;o.add(e),u("TBW022",`${ct(r.name)}Plugin and ${ct(n.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${n.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`,t)}}}(this.#oe?.getPlugins()??[],this.id),this.#at(),this.#_e=[...this._columns]}_schedulerProcessColumns(){this.#ot()}_schedulerProcessRows(){this.#nt()}_schedulerRenderHeader(){U(this)}_schedulerUpdateTemplate(){C(this)}_schedulerAfterRender(){this.#oe?.afterRender(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#se.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`});"fixed"!==this.#p.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,b(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,fe(this)),this._virtualization.enabled&&!this.#$e&&this.#Ye(),this.#X&&(this.#X=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#Ge()})})),this.#we&&this.#Se()}get _schedulerIsConnected(){return this.isConnected&&this.#W}get _hostElement(){return this}get _renderRoot(){return this.#k}_emit(e,t){this.#Ke(e,t)}get _accordionIcons(){return{expand:this.#p?.icons?.expand??n.expand,collapse:this.#p?.icons?.collapse??n.collapse}}get _shellState(){return this.#ue}_clearRowPool(){this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++}_setup(){this.#Fe()}_applyAnimationConfig(e){this.#st(e)}#at(){!function(e,t,i,o){if(!t)return!1;let r=!1;const n=function(e,t){const i=e?.gridAriaLabel;return i||(e?.shell?.header?.title??t?.lightDomTitle??void 0)}(i,o);n!==e.ariaLabel&&(e.ariaLabel=n,n?t.setAttribute("aria-label",n):t.removeAttribute("aria-label"),r=!0);const s=i?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),r=!0)}(this.#lt,this.__rowsBodyEl,this.#p,this.#ue)}#Se(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#we?(this.#ve||(this.#ve=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(Re("large",e)),t}(this.#p?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#ve)):(t=this.#ve,t?.remove()))}#Ee(e,t){const i=this.#Ce.get(e);if(!i)return;const o=this.findRenderedRowElement?.(i.index);o&&function(e,t){if(t){if(e.classList.add("tbw-row-loading"),e.setAttribute("aria-busy","true"),!e.querySelector(".tbw-row-loading-overlay")){const t=document.createElement("div");t.className="tbw-row-loading-overlay",t.setAttribute("aria-hidden","true");const i=document.createElement("div");i.className="tbw-row-loading-spinner",t.appendChild(i),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}(o,t)}#xe(e,t,i){const o=this.#Ce.get(e);if(!o)return;const r=this.findRenderedRowElement?.(o.index);if(!r)return;const n=this._visibleColumns.findIndex(e=>e.field===t);if(n<0)return;const s=r.children[n];s&&function(e,t){t?(e.classList.add("tbw-cell-loading"),e.setAttribute("aria-busy","true")):(e.classList.remove("tbw-cell-loading"),e.removeAttribute("aria-busy"))}(s,i)}#Fe(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#$.parseLightDomColumns(this),this.#_){const e=this.#_;this.#_=void 0,this.#$.merge();const t=this.#oe?.getAll()??[];this.#$.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#U.requestPhase(G.FULL,"setup")}}#je(e){let t=0,i=0,o=0,r=0,n=0;if(this.#j){const e=this._virtualization.container,s=this.#he;t=s?.scrollLeft??0,i=e?.scrollHeight??0,o=s?.scrollWidth??0,r=e?.clientHeight??0,n=s?.clientWidth??0}if(this.refreshVirtualWindow(!1)&&this.#oe?.onScrollRender(),this._virtualization.variableHeights&&(this.#Y&&clearTimeout(this.#Y),this.#Y=window.setTimeout(()=>{this.#Y=0,this.#se.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#j){const s=this.#ie;s.scrollTop=e,s.scrollLeft=t,s.scrollHeight=i,s.scrollWidth=o,s.clientHeight=r,s.clientWidth=n,this.#oe?.onScroll(s)}}findHeaderRow(){return this.#k.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,i=e-t.start;return i>=0&&i<this._rowPool.length&&i<t.end-t.start?this._rowPool[i]:null}_dispatchCellClick(e,t,i,o){const r=this._rows[t],n=this._visibleColumns[i];if(!r||!n)return!1;const s=n.field,l=r[s],a=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:i,column:n,field:s,value:l,row:r,cellEl:o,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const d={row:r,rowIndex:t,colIndex:i,column:n,field:s,value:l,cellEl:o,originalEvent:e},c=this.#oe?.onCellClick(d)??!1;return this.#Ke("cell-click",d),c}_dispatchRowClick(e,t,i,o){if(!i)return!1;const r={rowIndex:t,row:i,rowEl:o,originalEvent:e},n=this.#oe?.onRowClick(r)??!1;return this.#Ke("row-click",r),n}_dispatchHeaderClick(e,t,i){if(!t)return!1;const o={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:i,originalEvent:e};return this.#oe?.onHeaderClick(o)??!1}_dispatchKeyDown(e){return this.#oe?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#oe?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}queryPlugins(e){return this.#oe?.queryPlugins(e)??[]}query(e,t){return this.#oe?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#oe?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#oe?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#oe?.onCellMouseUp(e)}_afterCellRender(e){this.#oe?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#oe?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#oe?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#oe?.hasAfterRowRenderHook()??!1}async ready(){return this.#o}async forceLayout(){return this.#U.requestPhase(G.FULL,"forceLayout"),this.#U.whenReady()}async getConfig(){return Object.freeze({...this.#p||{}})}getRowId(e){return Me(e,this.id,this.#p.getRowId)}getRow(e){return this.#ae.getRow(e)}_getRowEntry(e){return this.#Ce.get(e)}updateRow(e,t,i="api"){this.#ae.updateRow(e,t,i)}updateRows(e,t="api"){this.#ae.updateRows(e,t)}animateRow(e,t){return Pe(this,e,t)}animateRows(e,t){return function(e,t,i){return Promise.all(t.map(t=>Pe(e,t,i))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,i){const o=e._rows??[],r=e.getRowId;if(!r)return Promise.resolve(!1);const n=o.findIndex(e=>{if(null==e)return!1;try{return r(e)===t}catch{return!1}});return n<0?Promise.resolve(!1):Pe(e,n,i)}(this,e,t)}async insertRow(e,t,i=!0){return this.#ae.insertRow(e,t,i)}async removeRow(e,t=!0){return this.#ae.removeRow(e,t)}async applyTransaction(e,t=!0){return this.#ae.applyTransaction(e,t)}applyTransactionAsync(e){return this.#ae.applyTransactionAsync(e)}suspendProcessing(){}focusCell(e,t){this.#le.focusCell(e,t)}get focusedCell(){return this.#le.focusedCell}scrollToRow(e,t){this.#le.scrollToRow(e,t)}scrollToRowById(e,t){this.#le.scrollToRowById(e,t)}setColumnVisible(e,t){const i=this.#$.setColumnVisible(e,t);return i&&this.requestStateChange(),i}toggleColumnVisibility(e){const t=this.#$.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#$.isColumnVisible(e)}showAllColumns(){this.#$.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#$.getAllColumns()}setColumnOrder(e){this.#$.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#$.getColumnOrder()}getColumnState(){const e=this.#oe?.getAll()??[];return this.#$.collectState(e)}set columnState(e){e&&(this.#_=e,this.#$.initialColumnState=e,this.#N&&this.#dt(e))}get columnState(){return this.getColumnState()}#dt(e){const t=this.#oe?.getAll()??[];this.#$.applyState(e,t),this.#Fe()}requestStateChange(){const e=this.#oe?.getAll()??[];this.#$.requestStateChange(e)}resetColumnState(){this.#_=void 0,this.__originalOrder=[];const e=this.#oe?.getAll()??[];this.#$.resetState(e),this.#$.merge(),this.#Fe()}get isToolPanelOpen(){return this.#ge.isPanelOpen}get defaultRowHeight(){return this._virtualization.rowHeight}get expandedToolPanelSections(){return this.#ge.expandedSections}openToolPanel(){this.#ge.openToolPanel()}closeToolPanel(){this.#ge.closeToolPanel()}toggleToolPanel(){this.#ge.toggleToolPanel()}toggleToolPanelSection(e){this.#ge.toggleToolPanelSection(e)}getToolPanels(){return this.#ge.getToolPanels()}registerToolPanel(e){this.#ue.apiToolPanelIds.add(e.id),this.#ge.registerToolPanel(e)}unregisterToolPanel(e){this.#ue.apiToolPanelIds.delete(e),this.#ge.unregisterToolPanel(e)}getHeaderContents(){return this.#ge.getHeaderContents()}registerHeaderContent(e){this.#ue.apiHeaderContentIds.add(e.id),this.#ge.registerHeaderContent(e)}unregisterHeaderContent(e){this.#ue.apiHeaderContentIds.delete(e),this.#ge.unregisterHeaderContent(e)}getToolbarContents(){return this.#ge.getToolbarContents()}registerToolbarContent(e){this.#ge.registerToolbarContent(e)}unregisterToolbarContent(e){this.#ge.unregisterToolbarContent(e)}#ct=!1;refreshShellHeader(){this.#ct||(this.#ct=!0,queueMicrotask(()=>{this.#ct=!1,this.isConnected&&(this.#ze(),this.#$.markSourcesChanged(),this.#$.merge(),Ye(this.#ue),this.#ke(),this.#Pe(),this.#ht())}))}#ht(){const e=this.#k.querySelector(".tbw-grid-content")??this.#k.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.#ge.isInitialized){Be(this.#k,this.#ue),Ue(this.#k,this.#p?.shell,this.#ue);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#ue.toolPanels.has(e)&&(this.openToolPanel(),this.#ue.expandedSections.add(e)),this.#ue.isPanelOpen&&(Xe(this.#k,this.#ue),Ge(this.#k,this.#ue,(this.#p,this.#p)),je(this.#k,this.#ue))}this._resizeController=Se(this),this.#Oe(e),this.#U.requestPhase(G.COLUMNS,"shellRefresh")}#We=new Map;registerStyles(e,t){let i=this.#We.get(e);i||(i=new CSSStyleSheet,this.#We.set(e,i)),i.replaceSync(t),this.#ut()}unregisterStyles(e){this.#We.delete(e)&&this.#ut()}getRegisteredStyles(){return Array.from(this.#We.keys())}#ut(){const e=Array.from(this.#We.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#We.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#le.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#le.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#le.containsFocus(e)}#ze(){We(this,this.#ue),Fe(this,this.#ue),Ve(this,this.#ue,this.#Ie())}#gt(){const e=this.#k.querySelector(".tbw-shell-header");if(!e)return;Ye(this.#ue);const t=function(e,t,i="☰"){const o=e?.header?.title??t.lightDomTitle??"",r=!!o,n=qe(i),s=e?.header?.toolbarContents??[],l=[...t.toolbarContents.values()],a=new Set(s.map(e=>e.id)),d=[...s];for(const w of l)a.has(w.id)||d.push(w);const c=d.length>0,h=t.toolPanels.size>0,u=c&&h,g=[...d].sort((e,t)=>(e.order??0)-(t.order??0));let f="";for(const w of g)f+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${w.id}"></div>`;if(u&&(f+='<div class="tbw-toolbar-separator"></div>'),h){const e=t.isPanelOpen;f+=`<button class="${e?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${e}" aria-controls="tbw-tool-panel">${n}</button>`}return`\n <div class="tbw-shell-header" part="shell-header" role="presentation">\n ${r?`<div class="tbw-shell-title">${p=o,p&&"string"==typeof p?p.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}</div>`:""}\n <div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>\n <div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">\n ${f}\n </div>\n </div>\n `;var p}(this.#p.shell,this.#ue,this.#p.icons?.toolPanel),i=document.createElement("div");i.innerHTML=t;const o=i.firstElementChild;o&&(e.replaceWith(o),this.#ft(),Ue(this.#k,this.#p?.shell,this.#ue))}#qe(){const e=()=>{const e=this.#ue.lightDomTitle,t=this.#ue.hasToolButtonsContainer;this.#ze();const i=this.#ue.lightDomTitle,o=this.#ue.hasToolButtonsContainer;(i&&!e||o&&!t)&&(this.#$.markSourcesChanged(),this.#$.merge(),this.#gt())},t=()=>{this.__lightDomColumnsCache=void 0,this.#Fe()};this.#$.registerLightDomHandler("tbw-grid-header",e),this.#$.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#$.registerLightDomHandler("tbw-grid-tool-panel",e),this.#$.registerLightDomHandler("tbw-grid-column",t),this.#$.registerLightDomHandler("tbw-grid-detail",t),this.#$.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,ce(this),this.#$.parseLightDomColumns(this);const e=this.#ue.lightDomTitle,t=this.#ue.hasToolButtonsContainer;this.#ze();const i=this.#ue.lightDomTitle,o=this.#ue.hasToolButtonsContainer;(i&&!e||o&&!t)&&(this.#$.markSourcesChanged(),this.#$.merge(),this.#gt()),this.#U.requestPhase(G.COLUMNS,"refreshColumns")}#Xe(){this.#se.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#se.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#se.invalidateRowHeight(e,t)}#ke(){this.#ze(),this.#$.markSourcesChanged(),this.#$.merge();const e=this.#p?.shell;Ze(this.#k,e,{isPanelOpen:this.#ue.isPanelOpen,expandedSections:this.#ue.expandedSections},this.#p?.icons)&&(this.#ft(),this.#ge.setInitialized(!0))}#ft(){!function(e,t,i,o){const r=e.querySelector(".tbw-shell-toolbar");r&&r.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&o.onPanelToggle()});const n=e.querySelector(".tbw-accordion");n&&n.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),i=e?.getAttribute("data-section");i&&o.onSectionToggle(i)}})}(this.#k,this.#p,this.#ue,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#fe?.(),this.#fe=function(e,t,i){const o=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),n=e.querySelector(".tbw-shell-body");if(!o||!r||!n)return()=>{};const s=t?.toolPanel?.position??"right";let l=0,a=0,d=0,c=!1;const h=e=>{if(!c)return;e.preventDefault();const t="left"===s?e.clientX-l:l-e.clientX,i=Math.min(d,Math.max(200,a+t));o.style.width=`${i}px`},u=()=>{if(!c)return;c=!1,r.classList.remove("resizing"),o.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=o.getBoundingClientRect().width;i(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)},g=e=>{e.preventDefault(),c=!0,l=e.clientX,a=o.getBoundingClientRect().width,d=n.getBoundingClientRect().width-20,r.classList.add("resizing"),o.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)};return r.addEventListener("mousedown",g),()=>{r.removeEventListener("mousedown",g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}}(this.#k,this.#p?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)}),this.#pe?.(),this.#pe=function(e,t,i,o){if(!t?.toolPanel?.closeOnClickOutside)return()=>{};const r=e=>{if(!i.isPanelOpen)return;const t=e.target;t&&(t.closest(".tbw-tool-panel")||t.closest("[data-panel-toggle]")||o())};return e.addEventListener("mousedown",r),()=>e.removeEventListener("mousedown",r)}(this,this.#p?.shell,this.#ue,()=>this.closeToolPanel())}}customElements.get(vt.tagName)||customElements.define(vt.tagName,vt),globalThis.DataGridElement=vt;const Ct={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"},_t={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"},yt={ROOT:`.${Ct.ROOT}`,HEADER:`.${Ct.HEADER}`,HEADER_ROW:`.${Ct.HEADER_ROW}`,HEADER_CELL:`.${Ct.HEADER_CELL}`,ROWS_VIEWPORT:`.${Ct.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${Ct.ROWS_CONTAINER}`,DATA_ROW:`.${Ct.DATA_ROW}`,DATA_CELL:`.${Ct.DATA_CELL}`,GROUP_ROW:`.${Ct.GROUP_ROW}`,ROW_BY_INDEX:e=>`.${Ct.DATA_ROW}[${_t.ROW_INDEX}="${e}"]`,CELL_BY_FIELD:e=>`.${Ct.DATA_CELL}[${_t.FIELD}="${e}"]`,CELL_AT:(e,t)=>`.${Ct.DATA_ROW}[${_t.ROW_INDEX}="${e}"] .${Ct.DATA_CELL}[${_t.COL_INDEX}="${t}"]`,SELECTED_ROWS:`.${Ct.DATA_ROW}.${Ct.SELECTED}`,EDITING_CELL:`.${Ct.DATA_CELL}.${Ct.EDITING}`};const Rt={sum:(e,t)=>e.reduce((e,i)=>e+(Number(i[t])||0),0),avg:(e,t)=>{const i=e.reduce((e,i)=>e+(Number(i[t])||0),0);return e.length?i/e.length:0},count:e=>e.length,min:(e,t)=>e.length?Math.min(...e.map(e=>Number(e[t])||1/0)):0,max:(e,t)=>e.length?Math.max(...e.map(e=>Number(e[t])||-1/0)):0,first:(e,t)=>e[0]?.[t],last:(e,t)=>e[e.length-1]?.[t]},St=new Map,Et={register(e,t){St.set(e,t)},unregister(e){St.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:St.get(e)??Rt[e]},run(e,t,i,o){const r=this.get(e);return r?r(t,i,o):void 0},has:e=>St.has(e)||e in Rt,list:()=>[...Object.keys(Rt),...St.keys()]},xt={sum:e=>e.reduce((e,t)=>e+t,0),avg:e=>e.length?e.reduce((e,t)=>e+t,0)/e.length:0,count:e=>e.length,min:e=>e.length?Math.min(...e):0,max:e=>e.length?Math.max(...e):0,first:e=>e[0]??0,last:e=>e[e.length-1]??0};function At(e){return xt[e]??xt.sum}const Tt=Et.register.bind(Et),Pt=Et.unregister.bind(Et),Ht=Et.get.bind(Et),Mt=Et.run.bind(Et),Lt=Et.list.bind(Et);e.BaseGridPlugin=class{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#pt;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#pt?.abort(),this.#pt=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#pt?.abort(),this.#pt=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}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}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?._hostElement}get disconnectSignal(){return this.#pt?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...n,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!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 void 0!==t?t:this.gridIcons[e]}setIcon(e,t){"string"==typeof t?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e,t){void 0!==t?console.warn(c(e,t,this.gridElement.id,this.name)):console.warn(`${s(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(c(e,t,this.gridElement.id,this.name))}},e.DEFAULT_ANIMATION_CONFIG=o,e.DEFAULT_GRID_ICONS=n,e.DGEvents={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",EDIT_OPEN:"edit-open",EDIT_CLOSE:"edit-close",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",DATA_CHANGE:"data-change"},e.DataGridElement=vt,e.FitModeEnum=i,e.GridCSSVars={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"},e.GridClasses=Ct,e.GridDataAttrs=_t,e.GridElement=vt,e.GridSelectors=yt,e.PLUGIN_QUERIES={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"},e.PluginEvents={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"},e.PluginManager=mt,e.RenderPhase=G,e.aggregatorRegistry=Et,e.builtInSort=I,e.createGrid=function(e){const t=document.createElement("tbw-grid");return e&&(t.gridConfig=e),t},e.defaultComparator=D,e.getAggregator=Ht,e.getValueAggregator=At,e.listAggregators=Lt,e.queryGrid=function(e,t,i){let o=document,r=!1;return"boolean"==typeof t?r=t:t&&(o=t,r=!!i),r?customElements.whenDefined(vt.tagName).then(()=>o.querySelector(e)):o.querySelector(e)},e.registerAggregator=Tt,e.runAggregator=Mt,e.runValueAggregator=function(e,t){return At(e)(t)},e.setFeatureResolver=function(e){ve=e},e.unregisterAggregator=Pt,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=grid.umd.js.map
|