@toolbox-web/grid 2.4.1 → 2.5.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.
Files changed (38) hide show
  1. package/all.js +1 -1
  2. package/all.js.map +1 -1
  3. package/index.js +1 -1
  4. package/index.js.map +1 -1
  5. package/lib/core/types.d.ts +26 -0
  6. package/lib/plugins/clipboard/index.js.map +1 -1
  7. package/lib/plugins/column-virtualization/index.js.map +1 -1
  8. package/lib/plugins/context-menu/index.js.map +1 -1
  9. package/lib/plugins/editing/index.js +1 -1
  10. package/lib/plugins/editing/index.js.map +1 -1
  11. package/lib/plugins/editing/internal/helpers.d.ts +17 -0
  12. package/lib/plugins/export/index.js.map +1 -1
  13. package/lib/plugins/filtering/index.js.map +1 -1
  14. package/lib/plugins/grouping-columns/index.js.map +1 -1
  15. package/lib/plugins/grouping-rows/index.js.map +1 -1
  16. package/lib/plugins/master-detail/index.js.map +1 -1
  17. package/lib/plugins/multi-sort/index.js.map +1 -1
  18. package/lib/plugins/pinned-columns/index.js.map +1 -1
  19. package/lib/plugins/pinned-rows/index.js.map +1 -1
  20. package/lib/plugins/pivot/index.js.map +1 -1
  21. package/lib/plugins/print/index.js.map +1 -1
  22. package/lib/plugins/reorder-columns/index.js.map +1 -1
  23. package/lib/plugins/reorder-rows/index.js.map +1 -1
  24. package/lib/plugins/responsive/index.js.map +1 -1
  25. package/lib/plugins/row-drag-drop/index.js.map +1 -1
  26. package/lib/plugins/selection/index.js.map +1 -1
  27. package/lib/plugins/server-side/index.js.map +1 -1
  28. package/lib/plugins/tooltip/index.js.map +1 -1
  29. package/lib/plugins/tree/index.js.map +1 -1
  30. package/lib/plugins/undo-redo/index.js.map +1 -1
  31. package/lib/plugins/visibility/index.js.map +1 -1
  32. package/package.json +1 -1
  33. package/umd/grid.all.umd.js +1 -1
  34. package/umd/grid.all.umd.js.map +1 -1
  35. package/umd/grid.umd.js +1 -1
  36. package/umd/grid.umd.js.map +1 -1
  37. package/umd/plugins/editing.umd.js +1 -1
  38. package/umd/plugins/editing.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";const t={STRETCH:"stretch",FIXED:"fixed"},o={sortApplied:(e,t)=>`Sorted by ${e}, ${t}`,sortCleared:()=>"Sort cleared",filterApplied:e=>`Filter applied on ${e}`,filterCleared:e=>`Filter cleared from ${e}`,allFiltersCleared:()=>"All filters cleared",groupExpanded:(e,t)=>`Group ${e} expanded, ${t} rows`,groupCollapsed:e=>`Group ${e} collapsed`,selectionChanged:e=>`${e} rows selected`,editingStarted:e=>`Editing row ${e+1}`,editingCommitted:e=>`Row ${e+1} saved`,dataLoaded:e=>`${e} rows loaded`},i={mode:"reduced-motion",duration:200,easing:"ease-out"},r={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function n(e,t){if(!e)return;const o="effectiveConfig"in e?e.effectiveConfig:void 0;if(!1===o?.a11y?.announcements)return;const i=e.querySelector?.(".tbw-sr-only");i&&(i.textContent="",requestAnimationFrame(()=>{i.textContent=t}))}function s(e,t,...i){const r=e&&"effectiveConfig"in e?e.effectiveConfig:void 0,n=r?.a11y?.messages?.[t];return n?n(...i):o[t](...i)}function l(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const a="TBW041",c="TBW061",d="TBW062";function h(e,t,o,i){return`${l(o,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function u(e,t,o,i){throw new Error(h(e,t,o,i))}function g(e,t,o,i){console.warn(h(e,t,o,i))}function f(e,t,o,i){console.error(h(e,t,o,i))}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 o={},i=t;for(let s=0;s<i.length;s++){const e=i[s],t=o[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 o=e.renderer||e.viewRenderer,i=t.renderer||t.viewRenderer;o&&!i&&(t.viewRenderer=o,e.renderer&&(t.renderer=o)),e.editor&&!t.editor&&(t.editor=e.editor)}else o[e.field]={...e}}const r=e.map(e=>{const t=o[e.field];if(!t)return e;const i={...e};t.header&&!i.header&&(i.header=t.header),t.type&&!i.type&&(i.type=t.type),i.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(i.resizable=!0),i.editable=e.editable||t.editable,null!=t.width&&null==i.width&&(i.width=t.width),null!=t.minWidth&&null==i.minWidth&&(i.minWidth=t.minWidth),t.__viewTemplate&&(i.__viewTemplate=t.__viewTemplate),t.__editorTemplate&&(i.__editorTemplate=t.__editorTemplate),t.__headerTemplate&&(i.__headerTemplate=t.__headerTemplate);const r=t.renderer||t.viewRenderer,n=i.renderer||i.viewRenderer;return r&&!n&&(i.viewRenderer=r,t.renderer&&(i.renderer=r)),t.editor&&!i.editor&&(i.editor=t.editor),delete o[e.field],i}),n=Object.keys(o);for(let s=0;s<n.length;s++)r.push(o[n[s]]);return r}function w(e,t){try{e.part?.add?.(t)}catch{}const o=e.getAttribute("part");o?o.split(/\s+/).includes(t)||e.setAttribute("part",o+" "+t):e.setAttribute("part",t)}function b(e){const o=e.effectiveConfig?.fitMode||e.fitMode||t.STRETCH;if(o!==t.STRETCH&&o!==t.FIXED)return;if(e.__didInitialAutoSize)return;if(!e.isConnected)return;const i=Array.from(e._headerRowEl?.children||[]);if(!i.length)return;let r=!1;const n=e._visibleColumns;for(let t=0;t<n.length;t++){const o=n[t];if(o.width)continue;const s=i[t];let l=s?s.scrollWidth:0;for(let i=0;i<e._rowPool.length;i++){const o=e._rowPool[i].children[t];if(o){const e=o.scrollWidth;e>l&&(l=e)}}l>0&&(o.width=l+2,o.__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)||g("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 o=e.effectiveConfig?.fitMode||e.fitMode||t.STRETCH;e._gridTemplate=o===t.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 _={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"},y={FIELD:"data-field",GROUP_KEY:"data-group-key"},R={ROOT:`.${_.ROOT}`,HEADER:`.${_.HEADER}`,HEADER_ROW:`.${_.HEADER_ROW}`,HEADER_CELL:`.${_.HEADER_CELL}`,ROWS_VIEWPORT:`.${_.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${_.ROWS_CONTAINER}`,DATA_ROW:`.${_.DATA_ROW}`,DATA_CELL:`.${_.DATA_CELL}`,GROUP_ROW:`.${_.GROUP_ROW}`,CELL_BY_FIELD:e=>`.${_.DATA_CELL}[${y.FIELD}="${e}"]`,SELECTED_ROWS:`.${_.DATA_ROW}.${_.SELECTED}`,EDITING_CELL:`.${_.DATA_CELL}.${_.EDITING}`},S=/{{\s*([^}]+)\s*}}/g,E="__DG_EMPTY__",A=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,x="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join("")),T=new RegExp(`__(proto|defineGetter|defineSetter)|${x.slice(3).join("|")}|this\\b`);const P=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".split("|")),M=/^on\w+$/i,H=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),k=/^\s*(javascript|vbscript|data|blob):/i;function L(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=[],o=e.querySelectorAll("*");for(const i of o){const e=i.tagName.toLowerCase();if(P.has(e)){t.push(i);continue}if("svg"===e||"http://www.w3.org/2000/svg"===i.namespaceURI){if(Array.from(i.attributes).some(e=>M.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(i);continue}}const o=[];for(const t of i.attributes){const e=t.name.toLowerCase();M.test(e)?o.push(t.name):(H.has(e)&&k.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>i.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function O(e,t){const o=function(e){const t=[];let o=0;for(;o<e.length;){const i=e[o];if(" "!==i){if(i>="0"&&i<="9"||"."===i&&o+1<e.length&&e[o+1]>="0"&&e[o+1]<="9"){const i=o;for(;o<e.length&&(e[o]>="0"&&e[o]<="9"||"."===e[o]);)o++;t.push({type:"num",v:Number(e.slice(i,o))});continue}if("'"===i){let i="";for(o++;o<e.length&&"'"!==e[o];)i+=e[o++];if(o>=e.length)return null;o++,t.push({type:"str",v:i});continue}if(i>="a"&&i<="z"||i>="A"&&i<="Z"||"_"===i||"$"===i){const i=o;for(;o<e.length&&/[\w$.]/.test(e[o]);)o++;t.push({type:"id",v:e.slice(i,o)});continue}if(o+2<e.length){const i=e.slice(o,o+3);if("==="===i||"!=="===i){t.push({type:"op",v:i}),o+=3;continue}}if(o+1<e.length){const i=e.slice(o,o+2);if("=="===i||"!="===i||"<="===i||">="===i||"&&"===i||"||"===i){t.push({type:"op",v:i}),o+=2;continue}}if(!"+-*/%<>!?:(),".includes(i))return null;t.push({type:"op",v:i}),o++}else o++}return t}(e);if(!o)return;const i=o;let r=0;function n(){return i[r]}function s(){return i[r++]}function l(e,t){const o=n();return!!o&&(o.type===e&&(void 0===t||o.v===t))}function a(){const e=function(){let e=c();for(;l("op","||");)s(),e=e||c();return e}();if(l("op","?")){s();const t=a();if(!l("op",":"))return;s();const o=a();return e?t:o}return e}function c(){let e=d();for(;l("op","&&");)s(),e=e&&d();return e}function d(){let e=h();for(;;){const t=n();if(!t||"op"!==t.type)break;if("==="===t.v)s(),e=e===h();else if("!=="===t.v)s(),e=e!==h();else if("=="===t.v)s(),e=e==h();else{if("!="!==t.v)break;s(),e=e!=h()}}return e}function h(){let e=u();for(;;){const t=n();if(!t||"op"!==t.type)break;if("<"===t.v)s(),e=e<u();else if(">"===t.v)s(),e=e>u();else if("<="===t.v)s(),e=e<=u();else{if(">="!==t.v)break;s(),e=e>=u()}}return e}function u(){let e=g();for(;;){const t=n();if(!t||"op"!==t.type)break;if("+"===t.v)s(),e+=g();else{if("-"!==t.v)break;s(),e-=g()}}return e}function g(){let e=f();for(;;){const t=n();if(!t||"op"!==t.type)break;if("*"===t.v)s(),e*=f();else if("/"===t.v)s(),e/=f();else{if("%"!==t.v)break;s(),e%=f()}}return e}function f(){return l("op","!")?(s(),!f()):p()}function p(){const e=n();if(e){if("num"===e.type)return s(),e.v;if("str"===e.type)return s(),e.v;if("id"===e.type)return s(),function(e){if("value"===e)return t.value;if(e.startsWith("row.")){const o=e.slice(4);return t.row?t.row[o]:void 0}return"row"===e?t.row:void 0}(e.v);if("op"===e.type&&"("===e.v){s();const e=a();return l("op",")")&&s(),e}return"op"===e.type&&"-"===e.v?(s(),-p()):void 0}}const w=a();return r<i.length?void 0:w}function D(e,t){if(!e||-1===e.indexOf("{{"))return e;const o=[],i=e.replace(S,(e,i)=>{const r=function(e,t){if(e=(e||"").trim(),!e)return E;if(I.test(e))return E;if("value"===e)return null==t.value?E:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const o=e.slice(4),i=t.row?t.row[o]:void 0;return null==i?E:String(i)}if(e.length>80)return E;if(!A.test(e)||T.test(e))return E;const o=e.match(/\./g);if(o&&o.length>1)return E;try{const o=O(e,t),i=null==o?"":String(o);return I.test(i)?E:i||E}catch{return E}}(i,t);return o.push({expr:i.trim(),result:r}),r}),r=(n=i)?n.replace(new RegExp(E,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):n;var n;const s=o.length&&o.every(e=>""===e.result||e.result===E);return I.test(e)||s?"":r}const I=/Reflect|Proxy|ownKeys/;function z(e){if(I.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&I.test(t.textContent||"")&&(t.textContent="");I.test(e.textContent||"")&&(e.textContent="")}}function N(e){if(I.test(e)){const e=()=>"";return e.__blocked=!0,e}const t=t=>D(e,t);return t.__blocked=!1,t}function q(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}const $=new WeakMap;function F(e,t,o=-1){if(!t.valueAccessor)return e?.[t.field];if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:o});const i=t.field;let r=$.get(e);if(r){if(r.has(i))return r.get(i)}else r=new Map,$.set(e,r);const n=t.valueAccessor({row:e,column:t,rowIndex:o});return r.set(i,n),n}function W(e,t){e&&(t?$.get(e)?.delete(t):$.delete(e))}function V(e,t,o){const i=o.find(e=>e.field===t.field),r=i?.sortComparator,{field:n,direction:s}=t,l=[...e];return r?i?.valueAccessor?l.sort((e,t)=>r(F(e,i),F(t,i),e,t)*s):l.sort((e,t)=>r(e[n],t[n],e,t)*s):i?.valueAccessor?U(l,i,s):B(l,n,s),l}function B(e,t,o){e.sort((e,i)=>{const r=G(e,i);if(0!==r)return r;const n=e[t],s=i[t];return null==n&&null==s?0:null==n?-o:null==s||n>s?o:n<s?-o:0})}function U(e,t,o){e.sort((e,i)=>{const r=G(e,i);if(0!==r)return r;const n=F(e,t),s=F(i,t);return null==n&&null==s?0:null==n?-o:null==s||n>s?o:n<s?-o:0})}function G(e,t){const o=!0===e?.__loading;return o===(!0===t?.__loading)?0:o?1:-1}function j(e,t,o,i){const r=i.find(e=>e.field===t),n=r?.sortComparator;n?r?.valueAccessor?e.sort((e,t)=>n(F(e,r),F(t,r),e,t)*o):e.sort((e,i)=>n(e[t],i[t],e,i)*o):r?.valueAccessor?U(e,r,o):B(e,t,o)}function Y(e,t,o,i){e._rows=t,e.__rowRenderEpoch++;for(let r=0;r<e._rowPool.length;r++)e._rowPool[r].__epoch=-1;re(e),e.refreshVirtualWindow(!0),X(e,o,i)}function X(e,t,o){const i={field:t.field,direction:o};e.dispatchEvent(new CustomEvent("sort-change",{detail:i})),e._pluginManager?.emitPluginEvent?.("sort-change",i),n(e,s(e,0===o?"sortCleared":"sortApplied",t.header??t.field,1===o?"ascending":"descending")),e.requestStateChange?.()}function K(e){return e._pluginManager?._hasRowStructurePlugins??!1}function Z(e,t){if(e._sortState&&e._sortState.field===t.field)if(1===e._sortState.direction)Q(e,t,-1);else{if(e._sortState=null,K(e))return e._requestSchedulerPhase(4,"sort-clear"),void X(e,t,0);e.__rowRenderEpoch++;for(let t=0;t<e._rowPool.length;t++)e._rowPool[t].__epoch=-1;e._rows=e.__originalOrder.slice(),e.__originalOrder=[],re(e);const o=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');if(o)for(let t=0;t<o.length;t++){const i=o[t];i.getAttribute("aria-sort")&&("ascending"!==i.getAttribute("aria-sort")&&"descending"!==i.getAttribute("aria-sort")||e._sortState)||i.setAttribute("aria-sort","none")}e.refreshVirtualWindow(!0),X(e,t,0)}else e._sortState||(e.__originalOrder=e._rows.slice()),Q(e,t,1)}function Q(e,t,o){if(e._sortState={field:t.field,direction:o},K(e))return e._requestSchedulerPhase(4,"sort-apply"),void X(e,t,o);const i={field:t.field,direction:o},r=e._columns,n=e.effectiveConfig?.sortHandler??V;if(n===V)return j(e._rows,i.field,o,r),void Y(e,e._rows,t,o);const s=n(e._rows,i,r);s&&"function"==typeof s.then?s.then(i=>{Y(e,i,t,o)}):Y(e,s,t,o)}function J(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function ee(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function te(e,t){const o=document.createElement("span");w(o,"sort-indicator");const i=e._sortState?.field===t.field?e._sortState.direction:0,r=1===i?"sortAsc":-1===i?"sortDesc":"sortNone";o.dataset.icon=q(r);const n=e.icons?.[r];return void 0!==n&&function(e,t){"string"==typeof t?e.innerHTML=L(t):t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(o,n),o}function oe(e,t,o){const i=document.createElement("div");return i.className="resize-handle",i.setAttribute("aria-hidden","true"),i.addEventListener("mousedown",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.start(i,t,o)}),i.addEventListener("dblclick",o=>{o.stopPropagation(),o.preventDefault(),e._resizeController.resetColumn(t)}),i}function ie(e,t,o,i){i.classList.add(_.SORTABLE),i.tabIndex=0;const r=e._sortState?.field===t.field?e._sortState.direction:0;i.setAttribute("aria-sort",0===r?"none":1===r?"ascending":"descending"),i.addEventListener("click",o=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(o,t,i)||Z(e,t)}),i.addEventListener("keydown",o=>{if("Enter"===o.key||" "===o.key){if(o.preventDefault(),e._dispatchHeaderClick?.(o,t,i))return;Z(e,t)}})}function re(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((o,i)=>{const r=document.createElement("div");r.className="cell",w(r,"header-cell"),r.setAttribute("role","columnheader"),r.setAttribute("aria-colindex",String(i+1)),r.setAttribute("data-field",o.field),r.setAttribute("data-col",String(i)),o.type&&r.setAttribute("data-type",o.type);const n=o.header??o.field,s=e._sortState?.field===o.field?e._sortState.direction:0,l=1===s?"asc":-1===s?"desc":null;if(o.headerRenderer){const t={column:o,value:n,sortState:l,filterActive:!1,cellEl:r,renderSortIcon:()=>J(e,o)?te(e,o):null,renderFilterButton:()=>null},s=o.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const o=document.createElement("span");for(o.innerHTML=L(t);o.firstChild;)e.appendChild(o.firstChild)}else t instanceof Node&&e.appendChild(t)}(r,s),J(e,o)&&ie(e,o,0,r),ee(e,o)&&(r.classList.add("resizable"),r.appendChild(oe(e,i,r)))}else if(o.headerLabelRenderer){const t={column:o,value:n},s=o.headerLabelRenderer(t),l=document.createElement("span");null==s?l.textContent=n:"string"==typeof s?l.innerHTML=L(s):s instanceof Node&&l.appendChild(s),r.appendChild(l),J(e,o)&&(ie(e,o,0,r),r.appendChild(te(e,o))),ee(e,o)&&(r.classList.add("resizable"),r.appendChild(oe(e,i,r)))}else if(o.__headerTemplate)Array.from(o.__headerTemplate.childNodes).forEach(e=>r.appendChild(e.cloneNode(!0))),J(e,o)&&(ie(e,o,0,r),r.appendChild(te(e,o))),ee(e,o)&&(r.classList.add("resizable"),r.appendChild(oe(e,i,r)));else{const t=document.createElement("span");t.textContent=n,r.appendChild(t),J(e,o)&&(ie(e,o,0,r),r.appendChild(te(e,o))),ee(e,o)&&(r.classList.add("resizable"),r.appendChild(oe(e,i,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 ne(e,t){const o=e[0]||{},i=Object.keys(o).map(e=>{const t=o[e],i=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:i}}),r={};return i.forEach(e=>{r[e.field]=e.type||"string"}),{columns:i,typeMap:r}}const se={STYLE:1,VIRTUALIZATION:2,HEADER:3,ROWS:4,COLUMNS:5,FULL:6};class le{#e;#t=0;#o=0;#i=null;#r=null;#n=null;#s=!1;constructor(e){this.#e=e}requestPhase(e,t){e>this.#t&&(this.#t=e),0===this.#o&&(this.#l(),this.#o=requestAnimationFrame(()=>this.#a()))}whenReady(){return this.#i?this.#i:Promise.resolve()}setInitialReadyResolver(e){this.#n=e}cancel(){0!==this.#o&&(cancelAnimationFrame(this.#o),this.#o=0),this.#t=0,this.#r&&(this.#r(),this.#r=null,this.#i=null)}get isPending(){return 0!==this.#t}get pendingPhase(){return this.#t}#l(){this.#i||(this.#i=new Promise(e=>{this.#r=e}))}#a(){if(this.#o=0,!this.#e._schedulerIsConnected)return this.#t=0,void(this.#r&&(this.#r(),this.#r=null,this.#i=null));const e=this.#t;this.#t=0,e>=se.COLUMNS&&this.#e._schedulerMergeConfig(),e>=se.ROWS&&this.#e._schedulerProcessRows(),e>=se.COLUMNS&&(this.#e._schedulerProcessColumns(),this.#e._schedulerUpdateTemplate()),e>=se.HEADER&&this.#e._schedulerRenderHeader(),e>=se.VIRTUALIZATION&&this.#e.refreshVirtualWindow(!0,!0),e>=se.STYLE&&this.#e._schedulerAfterRender(),!this.#s&&this.#n&&(this.#s=!0,this.#n()),this.#r&&(this.#r(),this.#r=null,this.#i=null)}}class ae{#c;#d;#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.#c=e,this.#w=!0,this.#u=void 0}getGridConfig(){return this.#c}setColumns(e){this.#d=e,this.#w=!0}getColumns(){return this.#d}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.#A(),"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)}#A(){const e=this.#p.typeDefaults;if(!e)return;const t=this.columns;for(const o of t){if(!o.type)continue;const t=e[o.type];t&&(o.renderer||o.viewRenderer||!t.renderer||(o.renderer=t.renderer),!o.format&&t.format&&(o.format=t.format),!o.editor&&t.editor&&(o.editor=t.editor),!o.editorParams&&t.editorParams&&(o.editorParams=t.editorParams))}}#R(){const e=this.#c?{...this.#c}:{},t=Array.isArray(e.columns)?[...e.columns]:[],o=(this.#u??[]).map(e=>({...e}));let i=p(t,o);this.#d&&this.#d.length&&(i=p(this.#d,o));const r=this.#e.sourceRows;if(0===i.length&&r.length){i=ne(r).columns}return i.length&&(i.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)}),i.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=N(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=N(e.__editorTemplate.innerHTML))}),e.columns=i),this.#h&&(e.fitMode=this.#h),e.fitMode||(e.fitMode="stretch"),this.#x(e),e.columnState&&!this.#_&&(this.#_=e.columnState),e}#x(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 o=this.#e._shellState.lightDomHeaderContent;o?.length>0&&(e.shell.header.lightDomContent=o),this.#e._shellState.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0);const i=this.#e._shellState.toolPanels;if(i.size>0){const t=Array.from(i.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.#c?.shell?.header?.toolbarContents??[],a=new Set(l.map(e=>e.id)),c=[...l];for(const d of s)a.has(d.id)||c.push(d);c.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=c}collectState(e){const t=this.columns,o=this.#T();return{columns:t.map((t,i)=>{const r={field:t.field,order:i,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=o.get(t.field);s&&(r.sort=s);for(const o of e)if(o.getColumnState){const e=o.getColumnState(t.field);e&&Object.assign(r,e)}return r})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const o=this.columns,i=new Map(e.columns.map(e=>[e.field,e])),r=o.map(e=>{const t=i.get(e.field);if(!t)return e;const o={...e};return void 0!==t.width&&(o.width=t.width,o.__renderedWidth=t.width),void 0!==t.visible&&(o.hidden=!t.visible),o});r.sort((e,t)=>(i.get(e.field)?.order??1/0)-(i.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 o=this.columns,i=o.find(t=>t.field===e);if(!i)return!1;if(!t&&i.lockVisible)return!1;if(!t){if(0===o.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!i.hidden!=!t&&(i.hidden=!t,this.#e._emit("column-visibility",{field:e,visible:t,visibleColumns:o.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.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])),o=[];for(const i of e){const e=t.get(i);e&&(o.push(e),t.delete(i))}for(const i of t.values())o.push(i);this.columns=o,this.#e._invalidateVisibleColumnsCache(),re(this.#e),C(this.#e),this.#e._requestSchedulerPhase(se.COLUMNS,"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 o=e.getAttribute("type")||void 0,i={field:t,type:o&&new Set(["number","string","date","boolean","select"]).has(o)?o: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())?i.width=e:i.width=r}const n=e.getAttribute("minWidth")||e.getAttribute("min-width");if(n){const e=parseFloat(n);isNaN(e)||(i.minWidth=e)}e.hasAttribute("resizable")&&(i.resizable=!0);const s=e.getAttribute("editor"),l=e.getAttribute("renderer");s&&(i.__editorName=s),l&&(i.__rendererName=l);const a=e.getAttribute("options");a&&(i.options=a.split(",").map(e=>{const[t,o]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:o?.trim()||t.trim()}}));const c=e.querySelector("tbw-grid-column-view"),d=e.querySelector("tbw-grid-column-editor"),h=e.querySelector("tbw-grid-column-header");c&&(i.__viewTemplate=c),d&&(i.__editorTemplate=d),h&&(i.__headerTemplate=h);const u=globalThis.DataGridElement,g=u?.getAdapters?.()??[],f=c??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(i.viewRenderer=e)}const w=d??e,b=g.find(e=>e.canHandle(w));if(b){const e=b.createEditor(w);e&&(i.editor=e)}return i}).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,o=()=>{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 o of e){for(const e of o.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const o=e.tagName.toLowerCase();this.#P.has(o)&&t.add(o)}if("attributes"===o.type&&o.target.nodeType===Node.ELEMENT_NODE){const e=o.target.tagName.toLowerCase();this.#P.has(e)&&t.add(e)}}t.size>0&&!this.#C&&(this.#C=setTimeout(o,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 ce(){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 de(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"&#x1F5F9;":"&#9744;"}</span>`}function he(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 ue(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const o=e.closest(".data-grid-row");if(!o)return-1;const i=o.parentElement;if(!i)return-1;const r=i.querySelectorAll(":scope > .data-grid-row");for(let n=0;n<r.length;n++)if(r[n]===o)return n;return-1}function ge(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function fe(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 pe(e,t){const o=t.renderer||t.viewRenderer;if(o)return o;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const o=i.getTypeDefault(t.type,e._hostElement);if(o?.renderer)return o.renderer}}function we(e,t){if(t.format)return t.format;if(!t.type)return;const o=e.__frameworkAdapter;if(o?.getTypeDefault){const i=o.getTypeDefault(t.type,e._hostElement);if(i?.format)return i.format}}const be='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function me(e){return(e.__editingCellCount??0)>0}function ve(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(`.cell.${_.EDITING}`).forEach(e=>e.classList.remove(_.EDITING))}const Ce=document.createElement("template");Ce.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const _e=document.createElement("template");function ye(){return Ce.content.firstElementChild.cloneNode(!0)}function Re(){return _e.content.firstElementChild.cloneNode(!0)}function Se(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function Ee(e,t,o,i){const r=t.children,n=e._visibleColumns,s=n.length,l=r.length,a=s<l?s:l,h=e._focusRow,u=e._focusCol,f=e._hasAfterCellRenderHook?.()??!1;let p=e.__hasSpecialColumns;if(void 0===p){p=!1;const t=e.__frameworkAdapter;for(let o=0;o<s;o++){const i=n[o];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,e._hostElement)?.renderer||i.type&&t?.getTypeDefault?.(i.type,e._hostElement)?.format){p=!0;break}}e.__hasSpecialColumns=p}const w=String(i);if(p){for(let s=0;s<a;s++){if(n[s].externalView){if(!r[s].querySelector("[data-external-view]"))return void Ae(e,t,o,i)}}for(let s=0;s<a;s++){const l=n[s],a=r[s];a.getAttribute("data-row")!==w&&a.setAttribute("data-row",w);const p=a.classList.contains(_.EDITING);if(!p){const e=h===i&&u===s;e!==a.classList.contains("cell-focus")&&(a.classList.toggle("cell-focus",e),a.setAttribute("aria-selected",String(e)))}const m=l.cellClass;if(m){const t=a.getAttribute("data-dynamic-classes");if(t){const e=t.split(" ");for(let t=0;t<e.length;t++)e[t]&&a.classList.remove(e[t])}try{const e=m(F(o,l,i),o,l),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let o=0;o<t.length;o++){const i=t[o];i&&"string"==typeof i&&(a.classList.add(i),e+=(e?" ":"")+i)}a.setAttribute("data-dynamic-classes",e)}else a.removeAttribute("data-dynamic-classes")}catch(b){g(c,`cellClass callback error for column '${l.field}': ${b}`,e.id),a.removeAttribute("data-dynamic-classes")}}if(p)continue;const v=pe(e,l);if(v){const r=F(o,l,i),n=v({row:o,value:r,field:l.field,column:l,grid:e,cellEl:a});"string"==typeof n?(e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML=L(n)):n instanceof Node?n.parentElement!==a&&(e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML="",a.appendChild(n)):null==n&&(e.__frameworkAdapter?.releaseCell?.(a),a.textContent=null==r?"":String(r)),f&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:r,cellElement:a,rowElement:t});continue}if(l.__compiledView){const r=F(o,l,i),n=l.__compiledView({row:o,value:r,field:l.field,column:l});l.__compiledView.__blocked?a.textContent="":(a.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML=L(n),z(a)),f&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:r,cellElement:a,rowElement:t});continue}if(l.__viewTemplate){const r=F(o,l,i),n=l.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(n)?a.textContent="":(a.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML=L(D(n,{row:o,value:r})),z(a)),f&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:r,cellElement:a,rowElement:t});continue}if(l.externalView)continue;const C=F(o,l,i);let y;a.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(a);const R=we(e,l);if(R){try{const e=R(C,o);y=null==e?"":String(e)}catch(b){g(d,`Format error in column '${l.field}': ${b}`,e.id),y=null==C?"":String(C)}a.textContent=y}else"date"===l.type?(y=he(C),a.textContent=y):"boolean"===l.type?a.innerHTML=de(!!C):(y=null==C?"":String(C),a.textContent=y);f&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:C,cellElement:a,rowElement:t})}}else for(let c=0;c<a;c++){const s=r[c];if(s.classList.contains(_.EDITING))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const l=n[c],a=F(o,l,i);s.textContent=null==a?"":String(a),s.getAttribute("data-row")!==w&&s.setAttribute("data-row",w);const d=h===i&&u===c;d!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",d),s.setAttribute("aria-selected",String(d))),f&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:c,value:a,cellElement:s,rowElement:t})}}function Ae(e,t,o,i){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,a=e._focusCol,h=e._hasAfterCellRenderHook?.()??!1,u=document.createDocumentFragment();for(let p=0;p<s;p++){const r=n[p],s=ye();s.setAttribute("aria-colindex",String(p+1)),s.setAttribute("data-col",String(p)),s.setAttribute("data-row",String(i)),s.setAttribute("data-field",r.field),s.setAttribute("data-header",r.header??r.field),r.type&&s.setAttribute("data-type",r.type);let w=F(o,r,i);const b=we(e,r);if(b)try{w=b(w,o)}catch(f){g(d,`Format error in column '${r.field}': ${f}`,e.id)}const m=r.__compiledView,v=r.__viewTemplate,C=pe(e,r),_=r.externalView;let y=!1;if(C){const t=C({row:o,value:w,field:r.field,column:r,grid:e,cellEl:s});"string"==typeof t?(s.innerHTML=L(t),y=!0):t instanceof Node?t.parentElement!==s&&(s.textContent="",s.appendChild(t)):null==t&&(s.textContent=null==w?"":String(w))}else if(_){const t=_,i=document.createElement("div");i.setAttribute("data-external-view",""),i.setAttribute("data-field",r.field),s.appendChild(i);const n={row:o,value:w,field:r.field,column:r,grid:e};if(t.mount)try{t.mount({placeholder:i,context:n,spec:t})}catch(f){g("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:i,spec:t,context:n}}))}catch(f){g("TBW064",`External view event dispatch error for column '${r.field}': ${f}`,e.id)}});i.setAttribute("data-mounted","")}else if(m){const e=m({row:o,value:w,field:r.field,column:r}),t=m.__blocked;s.innerHTML=t?"":L(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=L(D(e,{row:o,value:w})),y=!0)}else b?s.textContent=null==w?"":String(w):"date"===r.type?s.textContent=he(w):"boolean"===r.type?s.innerHTML=de(!!w):s.textContent=null==w?"":String(w);if(y){z(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(o):r.editable)?s.tabIndex=0:"boolean"===r.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),l===i&&a===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(F(o,r,i),o,r),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const o of t)o&&"string"==typeof o&&(s.classList.add(o),e+=(e?" ":"")+o);s.setAttribute("data-dynamic-classes",e)}}catch(f){g(c,`cellClass callback error for column '${r.field}': ${f}`,e.id)}h&&e._afterCellRender?.({row:o,rowIndex:i,column:r,colIndex:p,value:w,cellElement:s,rowElement:t}),u.appendChild(s)}t.appendChild(u)}function xe(e,t,o){if(t.target?.closest(".resize-handle"))return;const i=ue(o.querySelector(".cell[data-row]"));if(i<0)return;const r=e._rows[i];if(!r)return;if(e._dispatchRowClick?.(t,i,r,o))return;const n=t.target?.closest(".cell[data-col]");if(n){const o=Number(n.getAttribute("data-col"));if(!isNaN(o)){if(e._dispatchCellClick?.(t,i,o,n))return;const r=e._focusRow!==i||e._focusCol!==o;if(e._focusRow=i,e._focusCol=o,n.classList.contains(_.EDITING)){r&&(ge(e._bodyEl??e),n.classList.add("cell-focus"));const o=t.target,i=n.contains(o)&&o.matches(be)?o:n.querySelector(be);try{i?.focus({preventScroll:!0})}catch{}return}Me(e)}}}function Te(e){"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit()}function Pe(e){if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable}function Me(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:o,viewportEl:i}=e._virtualization,r=o,n=i?.clientHeight??r?.clientHeight??0;if(r&&n>0){const o=e._focusRow*t;o<r.scrollTop?r.scrollTop=o:o+t>r.scrollTop+n&&(r.scrollTop=o-n+t)}}const o=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;o||e.refreshVirtualWindow(!1),ge(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const i=e._focusRow,r=e._virtualization.start??0,n=e._virtualization.end??e._rows.length;if(i>=r&&i<n){const n=e._bodyEl.querySelectorAll(".data-grid-row")[i-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 i=e.querySelector(".tbw-scroll-area");if(i&&s&&(!o||t?.forceHorizontalScroll))if(t?.forceScrollLeft)i.scrollLeft=0;else if(t?.forceScrollRight)i.scrollLeft=i.scrollWidth-i.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(n??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),o=i.getBoundingClientRect(),r=e.left-o.left+i.scrollLeft,n=r+e.width,l=i.scrollLeft+t.left,a=i.scrollLeft+i.clientWidth-t.right;r<l?i.scrollLeft=r-t.left:n>a&&(i.scrollLeft=n-i.clientWidth+t.right)}}if(o&&s.classList.contains(_.EDITING)){const e=s.querySelector(be);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(o&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else o||document.activeElement!==e&&e.focus({preventScroll:!0})}}}_e.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const He=new WeakMap;function ke(e,t){const o=ue(t),i=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(o<0||i<0)return;e._focusRow=o,e._focusCol=i,ge(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 Le(e,t,o,i){let r=null;const n=o.composedPath?.();if(r=n&&n.length>0?n[0]:o.target,r&&!t.contains(r)){const e=document.elementFromPoint(o.clientX,o.clientY);e&&(r=e)}const s=r?.closest?.("[data-col]"),l=r?.closest?.(".data-grid-row"),a=r?.closest?.(".header-row");let c,d,h,u,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(h=e._rows[c],f=e._visibleColumns[d],u=f?.field,g=h&&u?h[u]:void 0)),{type:i,row:h,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:u,value:g,column:f,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}function Oe(e,t,o,i){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const o=e._rows.length-1,i=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;if((!Pe(a)||"Home"!==t.key&&"End"!==t.key)&&!(Pe(a)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===a.tagName&&"number"===a.type||Pe(a)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||Pe(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&&(e._activeEditRows===e._focusRow&&Te(e),e._focusRow-=1,e._focusCol=i):e._focusCol<i?e._focusCol+=1:(Te(e),e._focusRow<o&&(e._focusRow+=1,e._focusCol=0)),void Me(e);case"ArrowDown":r&&Te(e),e._focusRow=Math.min(o,e._focusRow+1),t.preventDefault();break;case"ArrowUp":r&&Te(e),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const o=fe(e);e._focusCol=o?Math.max(0,e._focusCol-1):Math.min(i,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const o=fe(e);e._focusCol=o?Math.min(i,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(r&&Te(e),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void Me(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(r&&Te(e),e._focusRow=o,e._focusCol=i):e._focusCol=i,t.preventDefault(),void Me(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(o,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const o=e._focusRow,i=e._focusCol,r=e._visibleColumns[i],n=e._rows[o],s=r?.field??"",l=s&&n?n[s]:void 0,a=e.querySelector(`[data-row="${o}"][data-col="${i}"]`),c=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:o,colIndex:i,column:r,field:s,value:l,row:n,cellEl:a,trigger:"keyboard",originalEvent:t}});if(e.dispatchEvent(c),c.defaultPrevented)return void t.preventDefault();break}default:return}Me(e)}}(e,t),{signal:i}),o.addEventListener("mousedown",t=>function(e,t,o){const i=Le(e,t,o,"mousedown");e._dispatchCellMouseDown?.(i)&&He.set(e,!0)}(e,o,t),{signal:i}),document.addEventListener("mousemove",t=>function(e,t,o){if(!He.get(e))return;const i=Le(e,t,o,"mousemove");e._dispatchCellMouseMove?.(i)}(e,o,t),{signal:i}),document.addEventListener("mouseup",t=>function(e,t,o){if(!He.get(e))return;const i=Le(e,t,o,"mouseup");e._dispatchCellMouseUp?.(i),He.set(e,!1)}(e,o,t),{signal:i})}let De;class Ie{#e;#M=new Set;#H=new Map;constructor(e){this.#e=e}focusCell(e,t){const o=this.#e,i=o._rows.length-1;if(i<0)return;let r;if("string"==typeof t){if(r=o._visibleColumns.findIndex(e=>e.field===t),r<0)return}else r=t;const n=o._visibleColumns.length-1;n<0||(o._focusRow=Math.max(0,Math.min(e,i)),o._focusCol=Math.max(0,Math.min(r,n)),Me(o))}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 o=this.#e._virtualization;if(!o.enabled)return;const i=o.container;if(!i)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,c;const d=o.positionCache;o.variableHeights&&d&&d.length>n?(a=d[n].offset,c=d[n].height):(a=n*o.rowHeight,c=o.rowHeight);const h=o.viewportEl?.clientHeight??i.clientHeight??0;if(h<=0)return;const u=i.scrollTop,g=a+c,f=u+h;let p;switch(s){case"start":p=a;break;case"center":p=a-h/2+c/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?i.scrollTo({top:p,behavior:"smooth"}):i.scrollTop=p}scrollToRowById(e,t){const o=this.#e._getRowEntry(e);o&&this.scrollToRow(o.index,t)}registerExternalFocusContainer(e){if(this.#M.has(e))return;this.#M.add(e);const t=new AbortController,o=t.signal,i=this.#e;e.addEventListener("focusin",()=>{i.dataset.hasFocus=""},{signal:o}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete i.dataset.hasFocus},{signal:o}),this.#H.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#M.delete(e);const t=this.#H.get(e);t&&(t(),this.#H.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.#M)if(t.contains(e))return!0;return!1}destroy(){for(const e of this.#H.values())e();this.#H.clear(),this.#M.clear()}}const ze="function"==typeof requestIdleCallback;function Ne(e){ze?cancelIdleCallback(e):clearTimeout(e)}function qe(e,t){if(t){const o=t({size:e});if("string"==typeof o){const e=document.createElement("div");return e.innerHTML=o,e}return o}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 $e(e){let t=null,o=null,i=null,r=null;const n=i=>{if(!t)return;const r=i.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==o&&(o=requestAnimationFrame(()=>{o=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:s.field,width:n}}))};let s=!1;const l=()=>{const o=null!==t;o&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",l),null!==i&&(document.documentElement.style.cursor=i,i=null),null!==r&&(document.body.style.userSelect=r,r=null),t=null,o&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(o,s,a){o.preventDefault();const c=e._headerRowEl??e.findHeaderRow?.();c&&function(t,o){const i=o.querySelectorAll(".cell");for(let r=0;r<e._visibleColumns.length;r++){if(r===t)continue;const o=e._visibleColumns[r];if(null==o.width&&!o.__userResized){const e=i[r],t=e?.getBoundingClientRect().width;t&&(o.width=Math.round(t),o.__userResized=!0,o.__renderedWidth=o.width)}}}(s,c);const d=e._visibleColumns[s],h="number"==typeof d?.width?d.width:void 0,u=d?.__renderedWidth??h??a.getBoundingClientRect().width;t={startX:o.clientX,colIndex:s,startWidth:u},window.addEventListener("mousemove",n),window.addEventListener("mouseup",l),null===i&&(i=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 o=e._visibleColumns[t];o&&(o.__userResized=!1,o.__renderedWidth=void 0,o.width=o.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:o.field,width:o.width}})))},dispose(){l()}}}const Fe="data-animating",We={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},Ve={change:500,insert:300,remove:200};function Be(e,t){const o=We[t],i=getComputedStyle(e).getPropertyValue(o);if(i){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(i);if(!isNaN(e)&&e>0)return e}return Ve[t]}function Ue(e,t,o){if(t<0)return Promise.resolve(!1);const i=e.findRenderedRowElement?.(t);return i?new Promise(e=>{!function(e,t,o){e.removeAttribute(Fe),e.offsetWidth,e.setAttribute(Fe,t);const i=Be(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(Fe),o?.()},i)}(i,o,()=>e(!0))}):Promise.resolve(!1)}function Ge(e,t){if(t)return t(e);const o=e;return"id"in o&&null!=o.id?String(o.id):"_id"in o&&null!=o._id?String(o._id):void 0}function je(e,t,o){const i=Ge(e,o);return void 0===i&&u("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),i}class Ye{#e;constructor(e){this.#e=e}resolveRowId(e){return je(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,o="api"){const i=this.#e,r=i._getRowEntry(e);r||u(a,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id);const{row:n,index:s}=r,l=[];for(const[a,c]of Object.entries(t)){const e=n[a];e!==c&&(l.push({field:a,oldValue:e,newValue:c}),n[a]=c,W(n,a))}for(const{field:a,oldValue:c,newValue:d}of l)i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:n,rowId:e,rowIndex:s,field:a,oldValue:c,newValue:d,changes:t,source:o},bubbles:!0,composed:!0}));l.length>0&&(Se(i),i._requestSchedulerPhase(se.VIRTUALIZATION,"updateRow"),i._emitDataChange())}updateRows(e,t="api"){const o=this.#e;let i=!1;for(const{id:r,changes:n}of e){const e=o._getRowEntry(r);e||u(a,`Row with ID "${r}" not found. Ensure the row exists and getRowId is correctly configured.`,o.id);const{row:s,index:l}=e;for(const[a,c]of Object.entries(n)){const e=s[a];e!==c&&(i=!0,s[a]=c,W(s,a),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:s,rowId:r,rowIndex:l,field:a,oldValue:e,newValue:c,changes:n,source:t},bubbles:!0,composed:!0})))}}i&&(Se(o),o._requestSchedulerPhase(se.VIRTUALIZATION,"updateRows"),o._emitDataChange())}async insertRow(e,t,o=!0){const i=this.#e,r=Math.max(0,Math.min(e,i._rows.length));i.sourceRows=[...i.sourceRows,t];const n=[...i._rows];n.splice(r,0,t),i._rows=n,i._sortState&&(i.__originalOrder=[...i.__originalOrder,t]),Se(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(let s=0;s<i._rowPool.length;s++)i._rowPool[s].__epoch=-1;i.refreshVirtualWindow(!0),i._emitPluginEvent("row-inserted",{row:t,index:r}),i._emitDataChange(),o&&(await new Promise(e=>requestAnimationFrame(()=>e())),await Ue(i,r,"insert"))}async removeRow(e,t=!0){const o=this.#e,i=o._rows[e];if(!i)return;t&&await Ue(o,e,"remove");const r=o._rows.indexOf(i);if(r<0)return i;const n=[...o._rows];n.splice(r,1),o._rows=n;const s=o.sourceRows.indexOf(i);if(s>=0){const e=[...o.sourceRows];e.splice(s,1),o.sourceRows=e}if(o._sortState){const e=o.__originalOrder.indexOf(i);if(e>=0){const t=[...o.__originalOrder];t.splice(e,1),o.__originalOrder=t}}Se(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(let l=0;l<o._rowPool.length;l++)o._rowPool[l].__epoch=-1;return o.refreshVirtualWindow(!0),o._emitDataChange(),t&&requestAnimationFrame(()=>{const e=o.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),i}async applyTransaction(e,t=!0){const o=this.#e,i={added:[],updated:[],removed:[]};if(e.remove?.length)for(const{id:l}of e.remove){const e=o._getRowEntry(l);if(!e)continue;const{row:r}=e;if(t){const e=o._rows.indexOf(r);e>=0&&await Ue(o,e,"remove")}const n=o._rows.indexOf(r);if(n<0){i.removed.push(r);continue}const s=[...o._rows];s.splice(n,1),o._rows=s;const a=o.sourceRows.indexOf(r);if(a>=0){const e=[...o.sourceRows];e.splice(a,1),o.sourceRows=e}if(o._sortState){const e=o.__originalOrder.indexOf(r);if(e>=0){const t=[...o.__originalOrder];t.splice(e,1),o.__originalOrder=t}}i.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=o._getRowEntry(l);if(!e)continue;const{row:t,index:n}=e;let s=!1;for(const[i,r]of Object.entries(a)){const e=t[i];e!==r&&(s=!0,t[i]=r,W(t,i),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:l,rowIndex:n,field:i,oldValue:e,newValue:r,changes:a,source:"api"},bubbles:!0,composed:!0})))}s&&i.updated.push(t)}if(e.add?.length)for(const l of e.add){o.sourceRows=[...o.sourceRows,l];const e=[...o._rows];e.push(l),o._rows=e,o._sortState&&(o.__originalOrder=[...o.__originalOrder,l]),i.added.push(l)}const n=i.added.length>0||i.removed.length>0,s=i.updated.length>0;if(n){Se(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(let e=0;e<o._rowPool.length;e++)o._rowPool[e].__epoch=-1;o.refreshVirtualWindow(!0)}else s&&(Se(o),o._requestSchedulerPhase(se.VIRTUALIZATION,"applyTransaction"));if((n||s)&&o._emitDataChange(),t&&i.added.length>0){await new Promise(e=>requestAnimationFrame(()=>e()));for(const e of i.added){const t=o._rows.indexOf(e);t>=0&&await Ue(o,t,"insert")}}if(t&&i.updated.length>0)for(const l of i.updated){const e=o._rows.indexOf(l);e>=0&&await Ue(o,e,"change")}return t&&i.removed.length>0&&requestAnimationFrame(()=>{const e=o.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),i}#k=null;#L=[];#O=null;applyTransactionAsync(e){return this.#k||(this.#k={add:[],update:[],remove:[]}),e.add&&this.#k.add.push(...e.add),e.update&&this.#k.update.push(...e.update),e.remove&&this.#k.remove.push(...e.remove),new Promise(e=>{this.#L.push(e),null===this.#O&&(this.#O=requestAnimationFrame(()=>{this.#O=null;const e=this.#k,t=this.#L;this.#k=null,this.#L=[],this.applyTransaction(e,!1).then(e=>{for(const o of t)o(e)})}))})}}function Xe(e,t){if(t)for(const o in t){const i=t[o];null!=i&&e.setAttribute(o,i)}}function Ke(e,t,o){const i=document.createElement(e);return Xe(i,t),i}function Ze(e,t){const o=document.createElement("div");return e&&(o.className=e),Xe(o,t),o}function Qe(e,t,o){const i=document.createElement("button");return e&&(i.className=e),Xe(i,t),i}const Je=document.createElement("template");function et(){return Je.content.cloneNode(!0)}function tt(e){const t=document.createDocumentFragment(),o=Ze(e.hasShell?`${_.ROOT} has-shell`:_.ROOT);if(e.hasShell&&e.shellHeader&&e.shellBody)o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=Ze("tbw-grid-content");e.appendChild(et()),o.appendChild(e)}return t.appendChild(o),t}function ot(e){const t=Ze("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=Ze("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=Ze("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const i=Ze("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const r of e.configButtons)r.hasRender&&i.appendChild(Ze("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));for(const r of e.apiButtons)r.hasRender&&i.appendChild(Ze("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));if((e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender))&&e.hasPanels&&i.appendChild(Ze("tbw-toolbar-separator")),e.hasPanels){const t=Qe(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.dataset.icon="tool-panel",void 0!==e.toolPanelIcon&&(t.innerHTML=L(e.toolPanelIcon)),i.appendChild(t)}return t.appendChild(i),t}function it(e){const t=Ze("tbw-shell-body"),o=e.panels.length>0,i=1===e.panels.length,r=Ze("tbw-grid-content");r.appendChild(et());let n=null;if(o){n=Ke("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(Ze("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":t,"aria-hidden":"true"}));const o=Ze("tbw-tool-panel-content",{role:"presentation"}),r=Ze("tbw-accordion");for(const n of e.panels){const t=Ze(`tbw-accordion-section${n.isExpanded?" expanded":""}${i?" single":""}`,{"data-section":n.id}),o=Qe("tbw-accordion-header",{"aria-expanded":String(n.isExpanded),"aria-controls":`tbw-section-${n.id}`});if(i&&o.setAttribute("aria-disabled","true"),n.icon){const e=Ke("span",{class:"tbw-accordion-icon"});e.innerHTML=L(n.icon),o.appendChild(e)}const s=Ke("span",{class:"tbw-accordion-title"});if(s.textContent=n.title,o.appendChild(s),!i){const t=Ke("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=L(e.expandIcon)),o.appendChild(t)}t.appendChild(o),t.appendChild(Ze("tbw-accordion-content",{id:`tbw-section-${n.id}`,role:"presentation"})),r.appendChild(t)}o.appendChild(r),n.appendChild(o)}return"left"===e.position&&n?(t.appendChild(n),t.appendChild(r)):(t.appendChild(r),n&&t.appendChild(n)),t}function rt(e){return e?"string"==typeof e?L(e):e.outerHTML:""}function nt(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function st(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const i=o.querySelectorAll("tbw-grid-header-content");i.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(i)),o.style.display="none"}function lt(e,t,o){const i=e.querySelector(":scope > tbw-grid-tool-buttons");if(!i)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(;i.firstChild;)e.appendChild(i.firstChild);return()=>{for(;e.firstChild;)i.appendChild(e.firstChild)}}};t.toolbarContents.set(r,n),t.lightDomToolbarContentIds.add(r),i.style.display="none"}function at(e,t,o){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const i=e,r=i.getAttribute("id"),n=i.getAttribute("title");if(!r||!n)return void g("TBW070",`Tool panel missing required id or title attribute: id="${r??""}", title="${n??""}"`);const s=i.getAttribute("icon")??void 0,l=i.getAttribute("tooltip")??void 0,a=parseInt(i.getAttribute("order")??"100",10);let c;const d=o?.(i);if(d)c=d;else{const e=L(i.innerHTML.trim());c=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const h=t.toolPanels.get(r);if(h){if(d){h.render=c,h.order=a,h.icon=s,h.tooltip=l;const e=t.panelCleanups.get(r);e&&(e(),t.panelCleanups.delete(r))}return}const u={id:r,title:n,icon:s,tooltip:l,order:a,render:c};t.toolPanels.set(r,u),t.lightDomToolPanelIds.add(r),i.style.display="none"})}function ct(e,t,o){const i=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],n=new Set(i.map(e=>e.id)),s=[...i];for(const l of r)n.has(l.id)||s.push(l);for(const l of s){if(o.toolbarContentCleanups.has(l.id))continue;if(!l.render)continue;const t=e.querySelector(`[data-toolbar-content="${l.id}"]`);if(!t)continue;const i=l.render(t);i&&o.toolbarContentCleanups.set(l.id,i)}}function dt(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,i=t.headerContents.size>0;if(!o&&!i)return;const r=e.querySelector(".tbw-shell-content");if(!r)return;if(o){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 o=r.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),r.appendChild(o));const i=s.render(o);i&&t.headerContentCleanups.set(s.id,i)}}function ht(e,t,o){if(t.isPanelOpen)for(const[i,r]of t.toolPanels){const o=t.expandedSections.has(i),n=e.querySelector(`[data-section="${i}"]`),s=n?.querySelector(".tbw-accordion-content");if(!n||!s)continue;n.classList.toggle("expanded",o);const l=n.querySelector(".tbw-accordion-header");if(l&&l.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=r.render(s);e&&t.panelCleanups.set(i,e)}}else{const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i)),s.innerHTML=""}}}function ut(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function gt(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}function ft(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 pt(e,t,o){const i=void 0!==o?.toolPanel?rt(o.toolPanel):void 0,r=void 0!==o?.expand?rt(o.expand):void 0,n=void 0!==o?.collapse?rt(o.collapse):void 0,s=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),l=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:l.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:i,configButtons:s.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},bodyOptions:{position:e.toolPanel?.position??"right",isPanelOpen:t.isPanelOpen,expandIcon:r,collapseIcon:n,panels:l.map(e=>({id:e.id,title:e.title,icon:rt(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function wt(e,t,o,i){const r=nt(t),n=[],s=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const l of s){e.querySelectorAll(`:scope > ${l}`).forEach(e=>n.push(e))}e.replaceChildren();for(const l of n)e.appendChild(l);if(r){const{headerOptions:r,bodyOptions:n}=pt(t,o,i),s=tt({hasShell:!0,shellHeader:ot(r),shellBody:it(n)});e.appendChild(s)}else{const t=tt({hasShell:!1});e.appendChild(t)}return r}function bt(e,t,o){const i=e.querySelector(`[data-section="${t}"]`);i&&i.classList.toggle("expanded",o)}Je.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 mt="tbw-grid-styles";let vt="";const Ct=new Map;function _t(){const e=function(){let e=document.getElementById(mt);return e||(e=document.createElement("style"),e.id=mt,e.setAttribute("data-tbw-grid","true"),document.head.appendChild(e)),e}(),t=Array.from(Ct.values()).join("\n");e.textContent=`${vt}\n\n/* Plugin Styles */\n${t}`}async function yt(e){if(vt)return;if("string"==typeof e&&e.length>0)return vt=e,void _t();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){g("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(vt=t,_t()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||g("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 Rt(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function St(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function Et(e,t){if(null!==e.lastTime){performance.now()-e.lastTime>60&&(e.velocityY=0,e.velocityX=0)}(Math.abs(e.velocityY)>.1||Math.abs(e.velocityX)>.1)&&function(e,t){const o=.95,i=1;let r=performance.now();const n=()=>{const s=performance.now(),l=s-r;r=s;const a=l/16,c=Math.pow(o,a);e.velocityY*=c,e.velocityX*=c;const d=16*e.velocityY,h=16*e.velocityX,u=Math.abs(d)>=i,g=Math.abs(h)>=i;u&&(t.fauxScrollbar.scrollTop+=d),g&&t.scrollArea&&(t.scrollArea.scrollLeft+=h),e.momentumRaf=u||g?requestAnimationFrame(n):0};e.momentumRaf=requestAnimationFrame(n)}(e,t),Rt(e)}function At(e,t,o,i){e.addEventListener("pointerdown",o=>{"touch"===o.pointerType&&null===t.activePointerId&&(t.activePointerId=o.pointerId,e.setPointerCapture(o.pointerId),function(e,t,o){St(o),o.startY=t,o.startX=e,o.lastY=t,o.lastX=e,o.lastTime=performance.now(),o.velocityY=0,o.velocityX=0,o.locked=!1}(o.clientX,o.clientY,t))},{passive:!0,signal:i}),e.addEventListener("pointermove",e=>{if(e.pointerId!==t.activePointerId)return;const i=function(e,t,o,i){if(null===o.lastY||null===o.lastX)return!1;const r=performance.now(),n=o.lastY-t,s=o.lastX-e;if(null!==o.lastTime){const e=r-o.lastTime;e>0&&(o.velocityY=n/e,o.velocityX=s/e)}if(o.lastY=t,o.lastX=e,o.lastTime=r,o.locked){const{scrollTop:e,scrollHeight:t,clientHeight:o}=i.fauxScrollbar;if(n>0&&e<t-o||n<0&&e>0?i.fauxScrollbar.scrollTop+=n:0!==n&&window.scrollBy(0,n),i.scrollArea){const{scrollLeft:e,scrollWidth:t,clientWidth:o}=i.scrollArea;s>0&&e<t-o||s<0&&e>0?i.scrollArea.scrollLeft+=s:0!==s&&window.scrollBy(s,0)}return!0}const l=null!==o.startY?Math.abs(o.startY-t):0,a=null!==o.startX?Math.abs(o.startX-e):0;if(l<3&&a<3)return!1;const c=l>=a,{scrollHeight:d,clientHeight:h}=i.fauxScrollbar,u=d-h>0;let g=!1;if(i.scrollArea){const{scrollWidth:e,clientWidth:t}=i.scrollArea;g=e-t>0}return!!(c&&u||!c&&g)&&(o.locked=!0,i.fauxScrollbar.scrollTop+=n,i.scrollArea&&(i.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,o);i&&e.preventDefault()},{passive:!1,signal:i}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Et(t,o))},{passive:!0,signal:i}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Rt(t))},{passive:!0,signal:i}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Rt(t))},{passive:!0,signal:i})}const xt=[{property:"editable",pluginName:"editing",level:"column",description:"",isUsed:e=>!0===e||"function"==typeof e},{property:"editor",pluginName:"editing",level:"column",description:""},{property:"editorParams",pluginName:"editing",level:"column",description:""},{property:"group",pluginName:"groupingColumns",level:"column",description:""},{property:"pinned",pluginName:"pinnedColumns",level:"column",description:"",isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e}],Tt=[{property:"rowEditable",pluginName:"editing",level:"config",description:"",isUsed:e=>"function"==typeof e},{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:"",isUsed:e=>Array.isArray(e)&&e.length>0}];function Pt(e){return`import { ${Mt(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function Mt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ht(e,t){return e.some(e=>e.name===t)}function kt(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 Lt(e,t,o){const i=kt(t,o);return"string"==typeof i?e.byKey.get(i):i&&"object"==typeof i?e.byRef.get(i):void 0}function Ot(e,t,o){if(t<0||t>=e.length)return;const i=e[t],r=o-i.height;if(0!==r){i.height=o,i.measured=!0;for(let o=t+1;o<e.length;o++)e[o].offset+=r}}function Dt(e,t){if(0===e.length)return-1;if(t<=0)return 0;let o=0,i=e.length-1;for(;o<=i;){const r=Math.floor((o+i)/2),n=e[r],s=n.offset+n.height;if(t<n.offset)i=r-1;else{if(!(t>=s))return r;o=r+1}}return Math.max(0,Math.min(o,e.length-1))}function It(e,t){const{positionCache:o,heightCache:i,rows:r,start:n,end:s,getPluginHeight:l,getRowId:a}=e;let c=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const d=parseInt(t,10);if(d<n||d>=s||d>=r.length)return;const h=r[d],u=l?.(h,d);if(void 0!==u){const e=o[d];return void((!e.measured||Math.abs(e.height-u)>1)&&(Ot(o,d,u),c=!0))}const g=e.offsetHeight;if(g>0){const e=o[d];(!e.measured||Math.abs(e.height-g)>1)&&(Ot(o,d,g),function(e,t,o,i){const r=kt(t,i);"string"==typeof r?e.byKey.set(r,o):r&&"object"==typeof r&&e.byRef.set(r,o)}(i,h,g,a),c=!0)}});const d=c?function(e){let t=0;for(const o of e)o.measured&&t++;return t}(o):0,h=c?function(e,t){let o=0,i=0;for(const r of e)r.measured&&(o+=r.height,i++);return i>0?o/i:t}(o,e.defaultHeight):0;return{hasChanges:c,measuredCount:d,averageHeight:h}}class zt{#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,o=e.viewportEl??t;o&&(e.cachedViewportHeight=o.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const i=e.scrollAreaEl;i&&(e.cachedScrollAreaHeight=i.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const o=this.state;let i,r,n;if(t){const e=o.container??this.#e._hostElement,t=o.viewportEl??e,s=o.scrollAreaEl;i=e?.clientHeight??0,r=t?.clientHeight??0,n=s?s.clientHeight:i,o.cachedFauxHeight=i,o.cachedViewportHeight=r,o.cachedScrollAreaHeight=n}else i=o.cachedFauxHeight,r=o.cachedViewportHeight,n=o.cachedScrollAreaHeight||i;const s=n-r,l=Math.max(0,i-n);let a;return a=o.variableHeights&&o.positionCache?function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(o.positionCache):e*o.rowHeight,a+s+l}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#e,o=t._rows,i=e.rowHeight||28,r=t.effectiveConfig?.rowHeight,n=t.effectiveConfig?.getRowId,s=n?e=>n(e):void 0;e.positionCache=function(e,t,o,i,r){const n=new Array(e.length);let s=0;for(let l=0;l<e.length;l++){const a=e[l];let c=r?.(a,l),d=void 0!==c;void 0===c&&(c=Lt(t,a,i.rowId),d=void 0!==c),void 0===c&&(c=o,d=!1),n[l]={offset:s,height:c,measured:d},s+=c}return n}(o,e.heightCache,i,{rowId:s},(e,o)=>{const i=t._getPluginRowHeight(e,o);if(void 0!==i)return i;if(r){const t=r(e,o);if(void 0!==t&&t>0)return t}});const l=function(e,t,o,i){let r=0,n=0;for(let s=0;s<e.length;s++){const o=e[s];if(o.measured){const e=i?.(t[s],s);void 0===e&&(n+=o.height,r++)}}return{measuredCount:r,averageHeight:r>0?n/r:o}}(e.positionCache,o,i,(e,o)=>t._getPluginRowHeight(e,o));e.measuredCount=l.measuredCount,l.measuredCount>0&&(e.averageHeight=l.averageHeight)}invalidateRowHeight(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#e._rows;if(e<0||e>=i.length)return;const r=i[e];let n=t;void 0===n&&(n=this.#e._getPluginRowHeight(r,e)),void 0===n&&(n=o.rowHeight);const s=o.positionCache[e];if(s&&!(Math.abs(s.height-n)<1)&&(Ot(o.positionCache,e,n),o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(i.length);o.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#e,r=i._bodyEl;if(!r)return;const n=r.querySelectorAll(".data-grid-row"),s=i.effectiveConfig?.getRowId,l=i._rows,a=It({positionCache:o.positionCache,heightCache:o.heightCache,rows:l,defaultHeight:o.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>i._getPluginRowHeight(e,t),getRowId:s?e=>s(e):void 0},n);if(a.hasChanges&&(o.measuredCount=a.measuredCount,o.averageHeight=a.averageHeight,o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(l.length);o.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){const o=this.state,i=this.#e,r=i._bodyEl;if(!r)return!1;const n=i._rows.length;if(!o.enabled)return i._renderVisibleRows(0,n),t||i._afterPluginRender(),!0;if(n<=o.bypassThreshold)return o.start=0,o.end=n,e&&(r.style.transform="translateY(0px)"),i._renderVisibleRows(0,n,i.__rowRenderEpoch),e&&o.variableHeights&&this.initializePositionCache(),e&&o.totalHeightEl&&(o.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(n,!0)}px`),i._updateAriaCounts(n,i._visibleColumns.length),t||i._afterPluginRender(),!0;const s=o.container,l=o.viewportEl??s,a=e?o.cachedViewportHeight=l.clientHeight:o.cachedViewportHeight||(o.cachedViewportHeight=l.clientHeight),c=o.rowHeight,d=s.scrollTop;let h;e&&o.variableHeights&&this.initializePositionCache();const u=o.positionCache;o.variableHeights&&u&&u.length>0?(h=Dt(u,d),-1===h&&(h=0)):h=Math.floor(d/c),h-=h%2,h<0&&(h=0);const g=i._adjustPluginVirtualStart(h,d,c);let f;if(void 0!==g&&g<h&&(h=g,h-=h%2,h<0&&(h=0)),o.variableHeights&&u&&u.length>0){const e=a+3*c;let t=0;for(f=h;f<n&&t<e;)t+=u[f].height,f++;const o=Math.ceil(a/c)+3;f-h<o&&(f=Math.min(h+o,n))}else{f=h+(Math.ceil(a/c)+3)}f>n&&(f=n);const p=o.start,w=o.end;if(!e&&h===p&&f===w)return!1;o.start=h,o.end=f;const b=e?o.cachedFauxHeight=s.clientHeight:o.cachedFauxHeight||(o.cachedFauxHeight=s.clientHeight);if(e){const e=o.scrollAreaEl;e&&(o.cachedScrollAreaHeight=e.clientHeight)}if(0===b&&a>0)return i._requestSchedulerPhase(se.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&o.totalHeightEl){const e=this.calculateTotalSpacerHeight(n);o.totalHeightEl.style.height=`${e}px`}let m;m=o.variableHeights&&u&&u[h]?u[h].offset:h*c;const v=-(d-m);return r.style.transform=`translateY(${v}px)`,i._renderVisibleRows(h,f,i.__rowRenderEpoch),e&&o.variableHeights&&this.measureRenderedRowHeights(h,f),i._updateAriaCounts(n,i._visibleColumns.length),e&&!t&&(i._afterPluginRender(),queueMicrotask(()=>{if(!o.totalHeightEl)return;const e=this.calculateTotalSpacerHeight(n);0===o.cachedFauxHeight&&o.cachedViewportHeight>0||(o.totalHeightEl.style.height=`${e}px`)})),!0}}class Nt{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;_hasProcessRows=!1;_hasRowStructurePlugins=!1;#D=new Map;eventListeners=new Map;queryHandlers=new Map;attachAll(e){const t=this.#I(e);for(const o of t)this.attach(o)}#I(e){if(e.length<2)return e;const t=new Map,o=new Map,i=[];for(const r of e){const e=r.constructor,n=t.get(e);if(!n){t.set(e,r),i.push(r);continue}const s=o.get(n)??[];s.push(r),o.set(n,s)}if(0===o.size)return i;for(const[r,n]of o)r.mergeConfigsFrom(n);return i}attach(e){if(function(e,t,o){const i=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??`${Mt(i)}Plugin requires ${Mt(e)}Plugin`,n=Pt(e);r&&u("TBW020",`Plugin dependency error:\n\n${t}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${Mt(i)}Plugin:\n ${n}\n plugins: [new ${Mt(e)}Plugin(), new ${Mt(i)}Plugin()]`,o)}}}(e,this.plugins,this.grid.getAttribute("id")??void 0),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,o]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,o);if(e.headerRenderers)for(const[t,o]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,o);if(e.cellEditors)for(const[t,o]of Object.entries(e.cellEditors))this.cellEditors.set(t,o);this.registerQueryHandlers(e),e.attach(this.grid),this.#z();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 o of t.queries){let t=this.queryHandlers.get(o.type);t||(t=new Set,this.queryHandlers.set(o.type,t)),t.add(e)}}unregisterQueryHandlers(e){for(const[t,o]of this.queryHandlers)o.delete(e),0===o.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,this._hasProcessRows=!1,this.#D.clear()}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){if(!this._hasProcessRows)return e;let t=e;for(const o of this.#N("processRows")){const e=o.processRows(t);e!==t&&(t=e)}return t}processColumns(e){let t=[...e];for(const o of this.#N("processColumns"))t=o.processColumns(t);return t}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.#N("afterRender"))e.afterRender()}afterCellRender(e){for(const t of this.#N("afterCellRender"))t.afterCellRender(e)}hasAfterCellRenderHook(){return this._hasAfterCellRender}afterRowRender(e){for(const t of this.#N("afterRowRender"))t.afterRowRender(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#z(){this._hasAfterCellRender=this.plugins.some(e=>"function"==typeof e.afterCellRender),this._hasAfterRowRender=this.plugins.some(e=>"function"==typeof e.afterRowRender),this._hasProcessRows=this.plugins.some(e=>"function"==typeof e.processRows),this._hasRowStructurePlugins=this.plugins.some(e=>!0===e.constructor.manifest?.modifiesRowStructure),this.#D.clear()}#N(e){let t=this.#D.get(e);if(t)return t;t=this.plugins.filter(t=>e in t&&"function"==typeof t[e]);const o=t=>{const o=t.constructor.manifest?.hookPriority;if(!o)return 0;return o[e]??0};return t.some(e=>0!==o(e))&&t.sort((e,t)=>o(e)-o(t)),this.#D.set(e,t),t}onScrollRender(){for(const e of this.#N("onScrollRender"))e.onScrollRender()}getRowHeight(e,t){for(const o of this.plugins)if("function"==typeof o.getRowHeight){const i=o.getRowHeight(e,t);if(void 0!==i)return i}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,o){let i=e;for(const r of this.plugins)if("function"==typeof r.adjustVirtualStart){const n=r.adjustVirtualStart(e,t,o);n<i&&(i=n)}return i}renderRow(e,t,o){for(const i of this.plugins)if(i.renderRow?.(e,t,o))return!0;return!1}queryPlugins(e){const t=[],o=this.queryHandlers.get(e.type);if(o&&o.size>0){for(const i of o){const o=i.handleQuery?.(e);void 0!==o&&t.push(o)}return t}for(const i of this.plugins){const o=i.handleQuery?.(e);void 0!==o&&t.push(o)}return t}subscribe(e,t,o){let i=this.eventListeners.get(t);i||(i=new Map,this.eventListeners.set(t,i)),i.set(e,o)}unsubscribe(e,t){const o=this.eventListeners.get(t);o&&(o.delete(e),0===o.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,o]of this.eventListeners)o.delete(e),0===o.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const o=this.eventListeners.get(e);if(o)for(const r of o.values())try{r(t)}catch(i){f("TBW024",`Error in plugin event handler for "${e}": ${i}`,this.grid.getAttribute("id")??void 0)}}onKeyDown(e){for(const t of this.#N("onKeyDown"))if(t.onKeyDown(e))return!0;return!1}onCellClick(e){for(const t of this.#N("onCellClick"))if(t.onCellClick(e))return!0;return!1}onRowClick(e){for(const t of this.#N("onRowClick"))if(t.onRowClick(e))return!0;return!1}onHeaderClick(e){for(const t of this.#N("onHeaderClick"))if(t.onHeaderClick(e))return!0;return!1}onScroll(e){for(const t of this.#N("onScroll"))t.onScroll(e)}onCellMouseDown(e){for(const t of this.#N("onCellMouseDown"))if(t.onCellMouseDown(e))return!0;return!1}onCellMouseMove(e){for(const t of this.#N("onCellMouseMove"))if(t.onCellMouseMove(e))return!0;return!1}onCellMouseUp(e){for(const t of this.#N("onCellMouseUp"))if(t.onCellMouseUp(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let o=0,i=0,r=!1;for(const n of this.plugins){const s=n.getHorizontalScrollOffsets?.(e,t);s&&(o+=s.left,i+=s.right,s.skipScroll&&(r=!0))}return{left:o,right:i,skipScroll:r}}getToolPanels(){const e=[];for(const t of this.plugins){const o=t.getToolPanel?.();o&&e.push({plugin:t,panel:o})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const o=t.getHeaderContent?.();o&&e.push({plugin:t,content:o})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}}class qt extends HTMLElement{static tagName="tbw-grid";static version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";static#q=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#$(){return this}#F=!1;#i;#r;#W=[];get#p(){return this.#V?.effective??{}}#B=!1;#U=!1;#G={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#j;#Y=0;#X=null;#K=!1;#Z=!1;#Q=0;#J;#ee={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#te;#oe;#ie;#re;#ne={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#se;#le;#ae;#ce;#de;#he;get _pluginManager(){return this.#se}#ue=!1;#ge;#fe;#_;#V;#pe=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}}();#we;#be;#me;#ve=!1;#Ce=new Set;#_e=new Map;#ye;#Re=new Map;#Se=!1;_rows=[];#Ee=[];get _columns(){return this.#p.columns??[]}set _columns(e){this.#p.columns=e,this.#Ae=void 0}#Ae;get _visibleColumns(){return this.#Ae??=this._columns.filter(e=>!e.hidden)}_invalidateVisibleColumnsCache(){this.#Ae=void 0}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#ce.state}set _virtualization(e){Object.assign(this.#ce.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#V?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#V&&(this.#V.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#V?.originalColumnNodes}set __originalColumnNodes(e){this.#V&&(this.#V.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=Array.isArray(e)?e:[],o=this.#W;this.#W=t,o!==t&&this.#xe("rows")}get sourceRows(){return this.#W}set sourceRows(e){this.#W=Array.isArray(e)?e:[]}get columns(){return[...this._columns]}set columns(e){const t=this.#V?.getColumns();this.#V?.setColumns(e),t!==e&&this.#xe("columns")}get gridConfig(){return this.#p}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#V?.getGridConfig();this.#V?.setGridConfig(e),t!==e&&(this.#V.clearLightDomCache(),this.#xe("gridConfig"))}get fitMode(){return this.#p.fitMode??"stretch"}set fitMode(e){const t=this.#V?.getFitMode();this.#V?.setFitMode(e),t!==e&&this.#xe("fitMode")}get loading(){return this.#ve}set loading(e){const t=this.#ve;this.#ve=e,t!==e&&(e?(this.setAttribute("loading",""),this.setAttribute("aria-busy","true")):(this.removeAttribute("loading"),this.removeAttribute("aria-busy")),this.#Te())}setRowLoading(e,t){const o=this.#Ce.has(e);t?this.#Ce.add(e):this.#Ce.delete(e),o!==t&&this.#Pe(e,t)}setCellLoading(e,t,o){let i=this.#_e.get(e);const r=i?.has(t)??!1;o?(i||(i=new Set,this.#_e.set(e,i)),i.add(t)):(i?.delete(t),0===i?.size&&this.#_e.delete(e)),r!==o&&this.#Me(e,t,o)}isRowLoading(e){return this.#Ce.has(e)}isCellLoading(e,t){return this.#_e.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#Ce)this.#Pe(e,!1);this.#Ce.clear();for(const[e,t]of this.#_e)for(const o of t)this.#Me(e,o,!1);this.#_e.clear()}get effectiveConfig(){return this.#p}get disconnectSignal(){return this.#te||(this.#te=new AbortController),this.#te.signal}constructor(){super(),this.#He(),this.#i=new Promise(e=>this.#r=e),this.#ce=new zt(this),this.#de=new Ie(this),this.#he=new Ye(this),this.#j=new le(this),this.#j.setInitialReadyResolver(()=>this.#r?.()),this.#we=function(e,t){let o=!1;const i={get isInitialized(){return o},setInitialized(e){o=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(){if(e.isPanelOpen)return;if(0===e.toolPanels.size)return void g("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 o=t._renderRoot;ut(o,e),gt(o,e),ht(o,e,t._accordionIcons),t._emit("tool-panel-open",{sections:i.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 o=t._renderRoot;ut(o,e),gt(o,e),t._emit("tool-panel-close",{})},toggleToolPanel(){e.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(o){const i=e.toolPanels.get(o);if(!i)return void g("TBW072",`Tool panel section "${o}" not found`,t.id);if(1===e.toolPanels.size)return;const r=t._renderRoot,n=e.expandedSections.has(o);if(n){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),i.onClose?.(),e.expandedSections.delete(o),bt(r,o,!1)}else{for(const[t,i]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),i.onClose?.(),e.expandedSections.delete(t),bt(r,t,!1);const n=r.querySelector(`[data-section="${t}"] .tbw-accordion-content`);n&&(n.innerHTML="")}e.expandedSections.add(o),bt(r,o,!0),function(e,t,o){const i=t.toolPanels.get(o);if(!i?.render)return;const r=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!r)return;const n=i.render(r);n&&t.panelCleanups.set(o,n)}(r,e,o)}t._emit("tool-panel-section-toggle",{id:o,expanded:!n})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(i){e.toolPanels.has(i.id)?g("TBW073",`Tool panel "${i.id}" already registered`,t.id):(e.toolPanels.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolPanel(i){if(e.expandedSections.has(i)){const t=e.panelCleanups.get(i);t&&(t(),e.panelCleanups.delete(i)),e.expandedSections.delete(i)}e.toolPanels.delete(i),o&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(i){e.headerContents.has(i.id)?g("TBW074",`Header content "${i.id}" already registered`,t.id):(e.headerContents.set(i.id,i),o&&dt(t._renderRoot,e))},unregisterHeaderContent(o){const i=e.headerContentCleanups.get(o);i&&(i(),e.headerContentCleanups.delete(o));const r=e.headerContents.get(o);r?.onDestroy?.(),e.headerContents.delete(o);const n=t._renderRoot.querySelector(`[data-header-content="${o}"]`);n?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(i){e.toolbarContents.has(i.id)?g("TBW075",`Toolbar content "${i.id}" already registered`,t.id):(e.toolbarContents.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolbarContent(i){const r=e.toolbarContentCleanups.get(i);r&&(r(),e.toolbarContentCleanups.delete(i));const n=e.toolbarContents.get(i);n?.onDestroy&&n.onDestroy(),e.toolbarContents.delete(i),o&&t.refreshShellHeader?.()}};return i}(this.#pe,this),this.#V=new ae(this)}async#He(){await yt('@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);--tbw-icon-expand: "▶";--tbw-icon-collapse: "▼";--tbw-icon-sort-asc: "▲";--tbw-icon-sort-desc: "▼";--tbw-icon-sort-none: "⇅";--tbw-icon-submenu-arrow: "▶";--tbw-icon-drag-handle: "⋮⋮";--tbw-icon-tool-panel: "☰";--tbw-icon-filter: "";--tbw-icon-filter-active: "";--tbw-icon-print: "🖨️";--tbw-icon-expand-mask: none;--tbw-icon-collapse-mask: none;--tbw-icon-sort-asc-mask: none;--tbw-icon-sort-desc-mask: none;--tbw-icon-sort-none-mask: none;--tbw-icon-submenu-arrow-mask: none;--tbw-icon-drag-handle-mask: none;--tbw-icon-tool-panel-mask: none;--tbw-icon-filter-mask: url("data:image/svg+xml,%3Csvg viewBox=\'0 0 16 16\' width=\'12\' height=\'12\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath 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\'/%3E%3C/svg%3E");--tbw-icon-filter-active-mask: var(--tbw-icon-filter-mask);--tbw-icon-print-mask: none}}\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 [data-icon=expand]:empty:before{content:var(--tbw-icon-expand)}tbw-grid [data-icon=collapse]:empty:before{content:var(--tbw-icon-collapse)}tbw-grid [data-icon=sort-asc]:empty:before{content:var(--tbw-icon-sort-asc)}tbw-grid [data-icon=sort-desc]:empty:before{content:var(--tbw-icon-sort-desc)}tbw-grid [data-icon=sort-none]:empty:before{content:var(--tbw-icon-sort-none)}tbw-grid [data-icon=submenu-arrow]:empty:before{content:var(--tbw-icon-submenu-arrow)}tbw-grid [data-icon=drag-handle]:empty:before{content:var(--tbw-icon-drag-handle)}tbw-grid [data-icon=tool-panel]:empty:before{content:var(--tbw-icon-tool-panel)}tbw-grid [data-icon=print]:empty:before{content:var(--tbw-icon-print)}tbw-grid [data-icon=filter]:empty:before{content:var(--tbw-icon-filter)}tbw-grid [data-icon=filter-active]:empty:before{content:var(--tbw-icon-filter-active)}tbw-grid [data-icon]:empty:before{display:inline-block;vertical-align:middle;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center}tbw-grid [data-icon=expand]:empty:before{-webkit-mask-image:var(--tbw-icon-expand-mask);mask-image:var(--tbw-icon-expand-mask)}tbw-grid [data-icon=collapse]:empty:before{-webkit-mask-image:var(--tbw-icon-collapse-mask);mask-image:var(--tbw-icon-collapse-mask)}tbw-grid [data-icon=sort-asc]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-asc-mask);mask-image:var(--tbw-icon-sort-asc-mask)}tbw-grid [data-icon=sort-desc]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-desc-mask);mask-image:var(--tbw-icon-sort-desc-mask)}tbw-grid [data-icon=sort-none]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-none-mask);mask-image:var(--tbw-icon-sort-none-mask)}tbw-grid [data-icon=submenu-arrow]:empty:before{-webkit-mask-image:var(--tbw-icon-submenu-arrow-mask);mask-image:var(--tbw-icon-submenu-arrow-mask)}tbw-grid [data-icon=drag-handle]:empty:before{-webkit-mask-image:var(--tbw-icon-drag-handle-mask);mask-image:var(--tbw-icon-drag-handle-mask)}tbw-grid [data-icon=tool-panel]:empty:before{-webkit-mask-image:var(--tbw-icon-tool-panel-mask);mask-image:var(--tbw-icon-tool-panel-mask)}tbw-grid [data-icon=print]:empty:before{-webkit-mask-image:var(--tbw-icon-print-mask);mask-image:var(--tbw-icon-print-mask)}tbw-grid [data-icon=filter]:empty:before,tbw-grid [data-icon=filter-active]:empty:before{width:var(--tbw-icon-size, 1em);height:var(--tbw-icon-size, 1em);background:currentColor}tbw-grid [data-icon=filter]:empty:before{-webkit-mask-image:var(--tbw-icon-filter-mask);mask-image:var(--tbw-icon-filter-mask)}tbw-grid [data-icon=filter-active]:empty:before{-webkit-mask-image:var(--tbw-icon-filter-active-mask);mask-image:var(--tbw-icon-filter-active-mask)}.tbw-context-menu [data-icon]:empty:before{display:inline-block;width:1em;height:1em;vertical-align:middle}.tbw-context-menu [data-icon=submenu-arrow]:empty:before{content:var(--tbw-icon-submenu-arrow, "▶")}}\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)}@media(hover:hover){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.#se?.getPlugin(e)}getPluginByName(e){return this.#se?.getPluginByName(e)}requestRender(){this.#j.requestPhase(se.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#j.requestPhase(se.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#j.requestPhase(se.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){C(this)}requestAfterRender(){this.#j.requestPhase(se.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this._virtualization.start=-1,this.refreshVirtualWindow(!1)}#ke(){this.#se=new Nt(this);const e=this.#p?.plugins,t=Array.isArray(e)?e:[],o=this.#p?.features;let i=[];o&&De&&(i=De(o));const r=i.length>0?[...i,...t]:t;this.#se.attachAll(r)}#Le(){!function(e){let t=!1;for(const{name:o,styles:i}of e)Ct.has(o)||(Ct.set(o,i),t=!0);t&&_t()}(this.#se?.getPluginStyles()??[])}#Oe(){const e=this.#p?.plugins,t=Array.isArray(e)?e:[],o=this.#p?.features??void 0,i=o!==this.#ae;if((this.#le===t||void 0!==this.#le&&this.#le.length===t.length&&this.#le.every((e,o)=>e===t[o]))&&!i)return void(this.#le=t);this.#se&&this.#se.detachAll();for(const n of this.#pe.toolPanels.keys()){const e=this.#pe.lightDomToolPanelIds.has(n),t=this.#pe.apiToolPanelIds.has(n);if(!e&&!t){const e=this.#pe.panelCleanups.get(n);e&&(e(),this.#pe.panelCleanups.delete(n)),this.#pe.toolPanels.delete(n)}}for(const n of this.#pe.headerContents.keys()){if(this.#pe.apiHeaderContentIds.has(n))continue;const e=this.#pe.headerContentCleanups.get(n);e&&(e(),this.#pe.headerContentCleanups.delete(n)),this.#pe.headerContents.delete(n)}this.#ke(),this.#Le(),this.#le=t,this.#ae=o,this.#De(),this.#Ie();const r=this.#K;if(this.#K=this.#se?.getAll().some(e=>e.onScroll)??!1,!r&&this.#K){const e=this.#$.querySelector(".tbw-grid-content")??this.#$.querySelector(".tbw-grid-root");this.#ze(e)}}#Ne(){this.#se?.detachAll()}#Ie(){if(!this.#se)return;const e=this.#se.getToolPanels();for(const{panel:o}of e)this.#pe.toolPanels.has(o.id)||this.#pe.toolPanels.set(o.id,o);const t=this.#se.getHeaderContents();for(const{content:o}of t)this.#pe.headerContents.has(o.id)||this.#pe.headerContents.set(o.id,o)}#qe(){const e=qt.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return o=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",qt.version),this.id||(this.id="tbw-grid-"+ ++qt.#q),this._rows=Array.isArray(this.#W)?[...this.#W]:[],this.#te&&(this.#te.abort(),this.#ue=!1),this.#te=new AbortController,this.#re&&(Ne(this.#re),this.#re=void 0),this.#$e(),this.#V.parseLightDomColumns(this),this.#V.merge(),this.#ke();const e=this.#p?.plugins;var t,o;this.#le=Array.isArray(e)?e:[],this.#ae=this.#p?.features??void 0,this.#Ie(),this.#F||(this.#Fe(),this.#Le(),this.#F=!0),this.#We(),this.#re=(t=()=>{this.#Ve()},o={timeout:100},ze?requestIdleCallback(t,o):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#re&&(Ne(this.#re),this.#re=void 0),this.#Q&&(clearTimeout(this.#Q),this.#Q=0),this.#Ne(),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 o=e.toolPanels.get(t);o?.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.#pe),this.#we.setInitialized(!1),this.#be?.(),this.#be=void 0,this.#me?.(),this.#me=void 0,St(this.#ee),this.#te&&(this.#te.abort(),this.#te=void 0),this.#ge?.abort(),this.#ge=void 0,this.#ue=!1,this._resizeController&&this._resizeController.dispose(),this.#oe&&(this.#oe.disconnect(),this.#oe=void 0),this.#ie&&(this.#ie.disconnect(),this.#ie=void 0,this.#Be=!1),Se(this),this.#Ue.clear(),this._virtualization.heightCache?.byKey.clear(),this.#le=void 0,this.#ae=void 0;for(let e=0;e<this._rowPool.length;e++)this._rowPool[e].remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#B=!1}attributeChangedCallback(e,t,o){if("loading"===e){const e=null!==o&&"false"!==o;return void(this.loading!==e&&(this.loading=e))}if(t!==o&&o&&"null"!==o&&"undefined"!==o)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(o);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{g("TBW130",`Invalid JSON for '${e}' attribute: ${o}`,this.id)}else"fit-mode"===e&&(this.fitMode=o)}#We(){const e=this.#$.querySelector(".tbw-grid-content")??this.#$.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.#we.isInitialized){dt(this.#$,this.#pe),ct(this.#$,this.#p?.shell,this.#pe);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#pe.toolPanels.has(e)&&(this.openToolPanel(),this.#pe.expandedSections.add(e)),this.#pe.isPanelOpen&&(gt(this.#$,this.#pe),ht(this.#$,this.#pe,(this.#p,this.#p)),ut(this.#$,this.#pe))}if(this.setAttribute("data-upgraded",""),this.#B=!0,this._resizeController=$e(this),this.#Ge(),this.#ze(e),this.#ue)return;this.#ue=!0;const t=this.disconnectSignal;Oe(this,this,this.#$,t),this.#De(),queueMicrotask(()=>this.#je()),this.#j.requestPhase(se.FULL,"afterConnect")}#De(){const e=this.#p.rowHeight,t=this.#se.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.#ce.initializePositionCache(),"function"!=typeof e&&(this.#Z=!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.#Ye())}#Ye(){if(this.#se.hasRowHeightPlugin())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;if(e.style.getPropertyValue("--tbw-row-height"))return;const t=this.#Xe(),o=e.querySelectorAll(".cell");let i=0;o.forEach(e=>{const t=e.offsetHeight;t>i&&(i=t)});const r=e.getBoundingClientRect(),n=Math.max(r.height,i),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.#j.requestPhase(se.VIRTUALIZATION,"measureRowHeight"))}#Xe(){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 o=parseFloat(getComputedStyle(t).minHeight);return o>0?o:0}#Ke(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let o=0;t.forEach(e=>{const t=e.offsetHeight;t>o&&(o=t)});const i=e.getBoundingClientRect(),r=Math.max(i.height,o);if(r>0){if(Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r),this.#ce.initializePositionCache(),this._virtualization.totalHeightEl){const e=this.#ce.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#ze(e){this.#ge?.abort(),this.#ge=new AbortController;const t=this.#ge.signal,o=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=o??this,this.#K=this.#se?.getAll().some(e=>e.onScroll)??!1,o&&i){o.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#K)return;const e=o.scrollTop,t=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)i.style.transform=`translateY(${-e}px)`;else{const o=this._virtualization.positionCache;let r,n;if(this._virtualization.variableHeights&&o&&o.length>0){r=Dt(o,e),-1===r&&(r=0);const i=r-r%2;n=o[i]?.offset??i*t}else{r=Math.floor(e/t);n=(r-r%2)*t}const s=-(e-n);i.style.transform=`translateY(${s}px)`}this.#X=e,this.#Y||(this.#Y=requestAnimationFrame(()=>{this.#Y=0,null!==this.#X&&(this.#Ze(this.#X),this.#X=null)}))},{passive:!0,signal:t});const e=this.#$.querySelector(".tbw-scroll-area");this.#fe=e,this._virtualization.scrollAreaEl=e,e&&this.#K&&e.addEventListener("scroll",()=>{const t=this.#ne;t.scrollTop=o.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=o.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=o.clientHeight,t.clientWidth=e.clientWidth,this.#se?.onScroll(t)},{passive:!0,signal:t});const r=this.#$.querySelector(".tbw-grid-content"),n=this.#fe;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:o,scrollWidth:i,clientWidth:r}=n;(t>0&&o<i-r||t<0&&o>0)&&(e.preventDefault(),n.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:i,clientHeight:r}=o;(e.deltaY>0&&t<i-r||e.deltaY<0&&t>0)&&(e.preventDefault(),o.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),At(r,this.#ee,{fauxScrollbar:o,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 o=e.target;o.draggable||o.closest('[draggable="true"]')||e.preventDefault(),ke(r,t)},{signal:s}),n.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&xe(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&&xe(r,e,t)},{signal:s})),this.#oe?.disconnect(),this._virtualization.viewportEl&&(this.#oe=new ResizeObserver(()=>{this.#Qe(),this.#j.requestPhase(se.VIRTUALIZATION,"resize-observer")}),this.#oe.observe(this._virtualization.viewportEl)),this.#$.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#$.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#$.contains(t)||this.#de.isInExternalFocusContainer(t))||delete this.dataset.hasFocus},{signal:t})}#Be=!1;#Je(){if(this.#Be)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#Be=!0,this.#ie?.disconnect(),this.#ie=new ResizeObserver(()=>{this.#Ye()}),this.#ie.observe(e))}addEventListener(e,t,o){super.addEventListener(e,t,o)}removeEventListener(e,t,o){super.removeEventListener(e,t,o)}on(e,t){const o=e=>{t(e.detail,e)};return this.addEventListener(e,o),()=>this.removeEventListener(e,o)}#et(e,t){this.#B&&this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#et("data-change",{rowCount:this._rows.length,sourceRowCount:this.#W.length}),function(e,t,o){if(o===t.lastAnnouncedSourceCount)return;const i=t.lastAnnouncedSourceCount;t.lastAnnouncedSourceCount=o,0===o&&i<0||n(e,s(e,"dataLoaded",o))}(this,this.#tt,this.#W.length)}#je(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const o=t===this._focusRow;e.setAttribute("aria-selected",String(o)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(o&&t===this._focusCol))})})}#xe(e){this.#G[e]=!0,this.#U||(this.#U=!0,queueMicrotask(()=>this.#ot()))}#ot(){if(!this.#U||!this.#B)return void(this.#U=!1);const e=this.#G;if(this.#U=!1,this.#G={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig)return this.#it(),void(e.rows&&this.#rt());e.columns&&this.#nt(),e.rows&&this.#rt(),e.fitMode&&this.#st()}#rt(){this._rows=Array.isArray(this.#W)?[...this.#W]:[],this.#Se=!0,this.#j.requestPhase(se.ROWS,"applyRowsUpdate")}#lt(){this.#Se&&this._rebuildRowIdMap()}_rebuildRowIdMap(){this.#Se=!1,this.#Re.clear();const e=this.#p.getRowId;for(let t=0;t<this._rows.length;t++){const o=Ge(this._rows[t],e);void 0!==o&&this.#Re.set(o,{row:this._rows[t],index:t})}}#nt(){Se(this),this.#V.merge(),this.#Ge()}#st(){this.#V.merge();if("fixed"===this.#p.fitMode)this.__didInitialAutoSize=!1,b(this);else{for(let e=0;e<this._columns.length;e++){const t=this._columns[e];!t.__userResized&&t.__autoSized&&delete t.width}C(this)}}#it(){st(this,this.#pe),lt(this,this.#pe);const e=!!this.#$.querySelector(".has-shell"),t=!!this.#$.querySelector(".tbw-tool-panel"),o=this.#$.querySelectorAll(".tbw-accordion-section").length,i=this.#$.querySelector(".tbw-tool-panel")?.dataset.position??"right";this.#V.parseLightDomColumns(this),this.#V.merge(),this.#Oe(),this.#De(),at(this,this.#pe,this.#qe()),this.#V.markSourcesChanged(),this.#V.merge();const r=nt(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!==o||t&&i!==l)return ft(this.#pe),this.#Fe(),this.#Le(),this.#We(),void this._rebuildRowIdMap();e&&this.#at(),this.#pe.isPanelOpen&&ht(this.#$,this.#pe,(this.#p,this.#p)),this._rebuildRowIdMap(),this.#j.requestPhase(se.COLUMNS,"applyGridConfigUpdate")}#at(){const e=this.#$.querySelector(".tbw-shell-header");if(!e)return;const t=this.#p.shell?.header?.title??this.#pe.lightDomTitle;let o=e.querySelector(".tbw-shell-title");t?(o||(o=document.createElement("h2"),o.className="tbw-shell-title",o.setAttribute("part","shell-title"),e.insertBefore(o,e.firstChild)),o.textContent=t):o&&o.remove()}#ct(){if(this.__rowRenderEpoch++,this.#se){const e=this.#Ee.length>0?this.#Ee:this._columns,t=e.filter(e=>!e.hidden),o=e.filter(e=>e.hidden),i=this.#se.processColumns([...t]);if(i!==t){const r=new Set(i.map(e=>e.field));!t.some(e=>r.has(e.field))&&i.length>0?this._columns=[...i,...o]:this._columns=this.#dt(e,i,o)}else this._columns=[...e]}}#dt(e,t,o){if(0===o.length)return t;const i=new Map;for(const l of t)i.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=i.get(l.field);e?s.push(e):l.hidden&&s.push(l)}return s.push(...n),s}#ht(){Se(this);const e=this.#W;if(!Array.isArray(e))return this._rows=[],this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#ce.initializePositionCache(),void this._emitDataChange();if(!this._sortState&&this.#p.initialSort){const{field:e,direction:t}=this.#p.initialSort;this._columns.find(t=>t.field===e)&&(this._sortState={field:e,direction:"desc"===t?-1:1})}this._sortState&&(this.__originalOrder=this._rows);const t=function(e,t,o=!1){if(!e._sortState)return t;const i=e.effectiveConfig?.sortHandler??V;if(i===V)return o||(e.__originalOrder=t.slice()),j(t,e._sortState.field,e._sortState.direction,e._columns),t;o||(e.__originalOrder=t);const r=i(t,e._sortState,e._columns);return r&&"function"==typeof r.then?t:r}(this,this._sortState?[...e]:e,!0),o=this.#se?.processRows(t)??t;this._rows=o,this._rebuildRowIdMap(),this._emitDataChange()}#ut(e){const t={...i,...e.animation},o=t.mode??"reduced-motion";let r=1;!1===o||"off"===o?r=0:!0!==o&&"on"!==o||(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 o?o?"on":"off":o}_renderVisibleRows(e,t,o=this.__rowRenderEpoch){if(this.#J||(this.#J=(e,t,o)=>this.#se?.renderRow(e,t,o)??!1),function(e,t,o,i,r){const n=Math.max(0,o-t),s=e._bodyEl,l=e._visibleColumns,a=l.length;let c=e.__cachedHeaderRowCount;for(void 0===c&&(c=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=c);e._rowPool.length<n;){const t=Re();e._rowPool.push(t)}if(e._rowPool.length>n){for(let t=n;t<e._rowPool.length;t++){const o=e._rowPool[t];o.parentNode===s&&o.remove()}e._rowPool.length=n}const d=r&&!1!==e.__hasRenderRowPlugins,h=e._hasAfterRowRenderHook?.()??!1,u=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let p=0;p<n;p++){const o=t+p,n=e._rows[o],w=e._rowPool[p];if(w.setAttribute("aria-rowindex",String(o+c+1)),d&&r(n,w,o)){w.__epoch=i,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===i&&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=me(w),r=y&&!_||e._activeEditRows===o;t&&!r?(w.__isCustomRow&&(w.className="data-grid-row",w.setAttribute("role","row"),w.__isCustomRow=!1),ve(w),Ae(e,w,n,o),w.__epoch=i,w.__rowDataRef=n):t&&r?(Ee(e,w,n,o),w.__rowDataRef=n):(w.__isCustomRow&&(w.className="data-grid-row",w.setAttribute("role","row"),w.__isCustomRow=!1),Ae(e,w,n,o),w.__epoch=i,w.__rowDataRef=n)}else if(_){const t=me(w),r=e._activeEditRows===o;t&&!r?(ve(w),Ae(e,w,n,o),w.__epoch=i,w.__rowDataRef=n):(Ee(e,w,n,o),w.__rowDataRef=n)}else{const t=me(w),r=y||e._activeEditRows===o;t&&!r?(ve(w),Ae(e,w,n,o),w.__epoch=i,w.__rowDataRef=n):Ee(e,w,n,o)}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 A=e.effectiveConfig?.rowClass;if(A){const t=w.getAttribute("data-dynamic-classes");if(t){const e=t.split(" ");for(let t=0;t<e.length;t++)e[t]&&w.classList.remove(e[t])}try{const e=A(n),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let o=0;o<t.length;o++){const i=t[o];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){g("TBW060",`rowClass callback error: ${f}`,e.id),w.removeAttribute("data-dynamic-classes")}}if(u){const e=u(n,o);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:o,rowElement:w}),w.parentNode!==s&&s.appendChild(w)}}(this,e,t,o,this.#J),this.#Ce.size>0)for(const i of this.#Ce)this.#Pe(i,!0)}#tt={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaDescribedBy:void 0,lastAnnouncedSourceCount:-1};_updateAriaCounts(e,t){!function(e,t,o,i,r){if(i===e.rowCount&&r===e.colCount)return!1;const n=e.rowCount;e.rowCount=i,e.colCount=r,t&&(t.setAttribute("aria-rowcount",String(i)),t.setAttribute("aria-colcount",String(r))),i!==n&&o&&(i>0?o.setAttribute("role","rowgroup"):o.removeAttribute("role"))}(this.#tt,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#j.requestPhase(e,t)}_getPluginRowHeight(e,t){return this.#se?.getRowHeight?.(e,t)}_adjustPluginVirtualStart(e,t,o){return this.#se?.adjustVirtualStart(e,t,o)}_afterPluginRender(){this.#se?.afterRender()}_emitPluginEvent(e,t){this.#se?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#V.parseLightDomColumns(this),this.#V.merge(),this.#Oe(),function(e,t,o){const i=xt,r=Tt,n=new Map;function s(e,t,o,i,r=!1){n.has(e)||n.set(e,{description:t,importHint:o,fields:[],isConfigProperty:r});const s=n.get(e);s.fields.includes(i)||s.fields.push(i)}for(const a of r){const o=e[a.property];if((a.isUsed?a.isUsed(o):void 0!==o)&&!Ht(t,a.pluginName)){const e=a.description||`the "${a.property}" ${a.level} property`;s(a.pluginName,e,Pt(a.pluginName),a.property,!0)}}const l=e.columns;if(l&&l.length>0)for(const a of l)for(const e of i){const o=a[e.property];if((e.isUsed?e.isUsed(o):void 0!==o)&&!Ht(t,e.pluginName)){const t=a.field||"<unknown>",o=e.description||`the "${e.property}" ${e.level} property`;s(e.pluginName,o,Pt(e.pluginName),t)}}if(n.size>0){const e=[];for(const[t,{description:o,importHint:i,fields:r,isConfigProperty:s}]of n)if(s)e.push(`Config uses ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${Mt(t)}Plugin(), ...]`);else{const n=r.slice(0,3).join(", ")+(r.length>3?`, ... (${r.length} total)`:"");e.push(`Column(s) [${n}] use ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${Mt(t)}Plugin(), ...]`)}u([...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.`,o)}}(this.#p,this.#se?.getPlugins()??[],this.id),function(e,t){const o=[],i=[];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=`[${Mt(r.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?o.push(e):i.push(e)}}}if(i.length>0&&ce())for(const r of i)g("TBW004",r,t);o.length>0&&u("TBW003",`Configuration error:\n\n${o.join("\n\n")}`,t)}(this.#se?.getPlugins()??[],this.id),function(e,t){if(!ce())return;const o=new Set(e.map(e=>e.name)),i=new Set;for(const r of e){const e=r.constructor.manifest;if(e?.incompatibleWith)for(const n of e.incompatibleWith)if(o.has(n.name)){const e=[r.name,n.name].sort().join("↔");if(i.has(e))continue;i.add(e),g("TBW022",`${Mt(r.name)}Plugin and ${Mt(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.#se?.getPlugins()??[],this.id),this.#gt(),this.#Ee=[...this._columns]}_schedulerProcessColumns(){this.#ct()}_schedulerProcessRows(){this.#ht()}_schedulerRenderHeader(){re(this)}_schedulerUpdateTemplate(){C(this)}_schedulerAfterRender(){this.#se?.afterRender(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#ce.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,Me(this)),this._virtualization.enabled&&!this.#Be&&this.#Je(),this.#Z&&(this.#Z=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#Ke()})})),this.#ve&&this.#Te()}get _schedulerIsConnected(){return this.isConnected&&this.#B}get _hostElement(){return this}get _renderRoot(){return this.#$}_emit(e,t){this.#et(e,t)}get _accordionIcons(){return{expand:this.#p?.icons?.expand??r.expand,collapse:this.#p?.icons?.collapse??r.collapse}}get _shellState(){return this.#pe}_clearRowPool(){this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++}_setup(){this.#Ge()}_applyAnimationConfig(e){this.#ut(e)}#gt(){!function(e,t,o,i){if(!t)return!1;let r=!1;const n=function(e,t){const o=e?.gridAriaLabel;return o||(e?.shell?.header?.title??t?.lightDomTitle??void 0)}(o,i);n!==e.ariaLabel&&(e.ariaLabel=n,n?t.setAttribute("aria-label",n):t.removeAttribute("aria-label"),r=!0);const s=o?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),r=!0)}(this.#tt,this.__rowsBodyEl,this.#p,this.#pe)}#Te(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#ve?(this.#ye||(this.#ye=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(qe("large",e)),t}(this.#p?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#ye)):(t=this.#ye,t?.remove()))}#Pe(e,t){this.#lt();const o=this.#Re.get(e);if(!o)return;const i=this.findRenderedRowElement?.(o.index);i&&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 o=document.createElement("div");o.className="tbw-row-loading-spinner",t.appendChild(o),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}(i,t)}#Me(e,t,o){this.#lt();const i=this.#Re.get(e);if(!i)return;const r=this.findRenderedRowElement?.(i.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,o)}#Ge(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#V.parseLightDomColumns(this),this.#_){const e=this.#_;this.#_=void 0,this.#V.merge();const t=this.#se?.getAll()??[];this.#V.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#j.requestPhase(se.FULL,"setup")}}#Ze(e){const t=this._virtualization.container,o=this.#fe,i=o?.scrollLeft??0,r=t?.scrollHeight??0,n=o?.scrollWidth??0,s=t?.clientHeight??0,l=o?.clientWidth??0;if(this.refreshVirtualWindow(!1)&&this.#se?.onScrollRender(),this._virtualization.variableHeights&&(this.#Q&&clearTimeout(this.#Q),this.#Q=window.setTimeout(()=>{this.#Q=0,this.#ce.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#K){const t=this.#ne;t.scrollTop=e,t.scrollLeft=i,t.scrollHeight=r,t.scrollWidth=n,t.clientHeight=s,t.clientWidth=l,this.#se?.onScroll(t)}this.#et("tbw-scroll",{scrollTop:e,scrollHeight:r,clientHeight:s,direction:"vertical"})}findHeaderRow(){return this.#$.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,o=e-t.start;return o>=0&&o<this._rowPool.length&&o<t.end-t.start?this._rowPool[o]:null}_dispatchCellClick(e,t,o,i){const r=this._rows[t],n=this._visibleColumns[o];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:o,column:n,field:s,value:l,row:r,cellEl:i,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const c={row:r,rowIndex:t,colIndex:o,column:n,field:s,value:l,cellEl:i,originalEvent:e},d=this.#se?.onCellClick(c)??!1;return this.#et("cell-click",c),d}_dispatchRowClick(e,t,o,i){if(!o)return!1;const r={rowIndex:t,row:o,rowEl:i,originalEvent:e},n=this.#se?.onRowClick(r)??!1;return this.#et("row-click",r),n}_dispatchHeaderClick(e,t,o){if(!t)return!1;const i={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:o,originalEvent:e};return this.#se?.onHeaderClick(i)??!1}_dispatchKeyDown(e){return this.#se?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#se?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}query(e,t){return this.#se?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#se?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#se?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#se?.onCellMouseUp(e)}_afterCellRender(e){this.#se?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#se?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#se?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#se?.hasAfterRowRenderHook()??!1}async ready(){return this.#i}async forceLayout(){return 0===this.#j.pendingPhase&&this.#j.requestPhase(se.FULL,"forceLayout"),this.#j.whenReady()}async getConfig(){return Object.freeze({...this.#p||{}})}getRowId(e){return je(e,this.id,this.#p.getRowId)}getRow(e){return this.#he.getRow(e)}_getRowEntry(e){return this.#lt(),this.#Re.get(e)}updateRow(e,t,o="api"){this.#he.updateRow(e,t,o)}updateRows(e,t="api"){this.#he.updateRows(e,t)}animateRow(e,t){return Ue(this,e,t)}animateRows(e,t){return function(e,t,o){return Promise.all(t.map(t=>Ue(e,t,o))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,o){const i=e._rows??[],r=e.getRowId;if(!r)return Promise.resolve(!1);const n=i.findIndex(e=>{if(null==e)return!1;try{return r(e)===t}catch{return!1}});return n<0?Promise.resolve(!1):Ue(e,n,o)}(this,e,t)}async insertRow(e,t,o=!0){return this.#he.insertRow(e,t,o)}async removeRow(e,t=!0){return this.#he.removeRow(e,t)}async applyTransaction(e,t=!0){return this.#he.applyTransaction(e,t)}applyTransactionAsync(e){return this.#he.applyTransactionAsync(e)}focusCell(e,t){this.#de.focusCell(e,t)}get focusedCell(){return this.#de.focusedCell}scrollToRow(e,t){this.#de.scrollToRow(e,t)}scrollToRowById(e,t){this.#de.scrollToRowById(e,t)}setColumnVisible(e,t){const o=this.#V.setColumnVisible(e,t);return o&&this.requestStateChange(),o}toggleColumnVisibility(e){const t=this.#V.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#V.isColumnVisible(e)}showAllColumns(){this.#V.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#V.getAllColumns()}setColumnOrder(e){this.#V.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#V.getColumnOrder()}getColumnState(){const e=this.#se?.getAll()??[];return this.#V.collectState(e)}get columnState(){return this.getColumnState()}applyColumnState(e){e&&(this.#F?this.#ft(e):(this.#_=e,this.#V.initialColumnState=e))}#ft(e){const t=this._columns,o=this._sortState,i=this.#se?.getAll()??[];this.#V.applyState(e,i);if(!e.columns.some(e=>void 0!==e.sort)&&this.#pt(t,o))return this.#Ae=void 0,C(this),void this.#j.requestPhase(se.STYLE,"column-width");this.#Ge()}#pt(e,t){const o=this._columns,i=this._sortState;if(t?.field!==i?.field||t?.direction!==i?.direction)return!1;if(e.length!==o.length)return!1;for(let r=0;r<e.length;r++){const t=e[r],i=o[r];if(t.field!==i.field)return!1;if(!!t.hidden!=!!i.hidden)return!1}return!0}get sortModel(){return this._sortState?{field:this._sortState.field,direction:1===this._sortState.direction?"asc":"desc"}:null}sort(e,t){if(null===e){if(!this._sortState)return;const e=this._sortState.field;this._sortState=null,this.__rowRenderEpoch++;for(let t=0;t<this._rowPool.length;t++)this._rowPool[t].__epoch=-1;return this._rows=this.__originalOrder.slice(),this.__originalOrder=[],re(this),this.refreshVirtualWindow(!0),this.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e,direction:0}})),this._pluginManager?.emitPluginEvent?.("sort-change",{field:e,direction:0}),void this.requestStateChange?.()}const o=this._columns.find(t=>t.field===e);o&&(t?(this._sortState||(this.__originalOrder=this._rows.slice()),Q(this,o,"desc"===t?-1:1)):Z(this,o))}requestStateChange(){const e=this.#se?.getAll()??[];this.#V.requestStateChange(e)}resetColumnState(){this.#_=void 0,this.__originalOrder=[];const e=this.#se?.getAll()??[];this.#V.resetState(e),this.#V.merge(),this.#Ge()}get isToolPanelOpen(){return this.#we.isPanelOpen}get defaultRowHeight(){return this._virtualization.rowHeight}get expandedToolPanelSections(){return this.#we.expandedSections}openToolPanel(){this.#we.openToolPanel()}closeToolPanel(){this.#we.closeToolPanel()}toggleToolPanel(){this.#we.toggleToolPanel()}toggleToolPanelSection(e){this.#we.toggleToolPanelSection(e)}getToolPanels(){return this.#we.getToolPanels()}registerToolPanel(e){this.#pe.apiToolPanelIds.add(e.id),this.#we.registerToolPanel(e)}unregisterToolPanel(e){this.#pe.apiToolPanelIds.delete(e),this.#we.unregisterToolPanel(e)}getHeaderContents(){return this.#we.getHeaderContents()}registerHeaderContent(e){this.#pe.apiHeaderContentIds.add(e.id),this.#we.registerHeaderContent(e)}unregisterHeaderContent(e){this.#pe.apiHeaderContentIds.delete(e),this.#we.unregisterHeaderContent(e)}getToolbarContents(){return this.#we.getToolbarContents()}registerToolbarContent(e){this.#we.registerToolbarContent(e)}unregisterToolbarContent(e){this.#we.unregisterToolbarContent(e)}#wt=!1;refreshShellHeader(){this.#wt||(this.#wt=!0,queueMicrotask(()=>{if(this.#wt=!1,!this.isConnected)return;this.#$e(),this.#V.markSourcesChanged(),this.#V.merge(),ft(this.#pe);(function(e,t,o,i){const r=e.querySelector(`.${_.ROOT}`),n=r?.querySelector(".tbw-grid-content");if(!r||!n)return wt(e,t,o,i);n.remove();const s=nt(t);if(r.replaceChildren(),s){r.className=`${_.ROOT} has-shell`;const{headerOptions:e,bodyOptions:s}=pt(t,o,i),l=ot(e),a=it(s),c=a.querySelector(".tbw-grid-content");c&&c.replaceWith(n),r.appendChild(l),r.appendChild(a)}else r.className=_.ROOT,r.appendChild(n);return s})(this.#$,this.#p?.shell,{isPanelOpen:this.#pe.isPanelOpen,expandedSections:this.#pe.expandedSections},this.#p?.icons)&&(this.#bt(),this.#we.setInitialized(!0)),this.#mt()}))}#mt(){const e=this.#$.querySelector(".tbw-grid-content")??this.#$.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.#we.isInitialized){dt(this.#$,this.#pe),ct(this.#$,this.#p?.shell,this.#pe);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#pe.toolPanels.has(e)&&(this.openToolPanel(),this.#pe.expandedSections.add(e)),this.#pe.isPanelOpen&&(gt(this.#$,this.#pe),ht(this.#$,this.#pe,(this.#p,this.#p)),ut(this.#$,this.#pe))}this._resizeController=$e(this),this.#ze(e),this.#j.requestPhase(se.COLUMNS,"shellRefresh")}#Ue=new Map;registerStyles(e,t){let o=this.#Ue.get(e);o||(o=new CSSStyleSheet,this.#Ue.set(e,o)),o.replaceSync(t),this.#vt()}unregisterStyles(e){this.#Ue.delete(e)&&this.#vt()}getRegisteredStyles(){return Array.from(this.#Ue.keys())}#vt(){const e=Array.from(this.#Ue.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#Ue.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#de.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#de.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#de.containsFocus(e)}#$e(){st(this,this.#pe),lt(this,this.#pe),at(this,this.#pe,this.#qe())}#Ct(){const e=this.#$.querySelector(".tbw-shell-header");if(!e)return;ft(this.#pe);const t=function(e,t,o){const i=e?.header?.title??t.lightDomTitle??"",r=!!i;let n="";void 0!==o&&(n="string"==typeof o?L(o):o.outerHTML);const s=e?.header?.toolbarContents??[],l=[...t.toolbarContents.values()],a=new Set(s.map(e=>e.id)),c=[...s];for(const w of l)a.has(w.id)||c.push(w);const d=c.length>0,h=t.toolPanels.size>0,u=d&&h,g=[...c].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 data-icon="tool-panel" 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=i,p&&"string"==typeof p?p.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):""}</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.#pe,this.#p.icons?.toolPanel),o=document.createElement("div");o.innerHTML=t;const i=o.firstElementChild;i&&(e.replaceWith(i),this.#bt(),ct(this.#$,this.#p?.shell,this.#pe))}#Ve(){const e=()=>{const e=this.#pe.lightDomTitle,t=this.#pe.hasToolButtonsContainer;this.#$e();const o=this.#pe.lightDomTitle,i=this.#pe.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#V.markSourcesChanged(),this.#V.merge(),this.#Ct())},t=()=>{this.__lightDomColumnsCache=void 0,this.#Ge()};this.#V.registerLightDomHandler("tbw-grid-header",e),this.#V.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#V.registerLightDomHandler("tbw-grid-tool-panel",e),this.#V.registerLightDomHandler("tbw-grid-column",t),this.#V.registerLightDomHandler("tbw-grid-detail",t),this.#V.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,Se(this),this.#V.parseLightDomColumns(this);const e=this.#pe.lightDomTitle,t=this.#pe.hasToolButtonsContainer;this.#$e();const o=this.#pe.lightDomTitle,i=this.#pe.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#V.markSourcesChanged(),this.#V.merge(),this.#Ct()),this.#j.requestPhase(se.COLUMNS,"refreshColumns")}#Qe(){this.#ce.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#ce.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#ce.invalidateRowHeight(e,t)}#Fe(){this.#$e(),this.#V.markSourcesChanged(),this.#V.merge();const e=this.#p?.shell;wt(this.#$,e,{isPanelOpen:this.#pe.isPanelOpen,expandedSections:this.#pe.expandedSections},this.#p?.icons)&&(this.#bt(),this.#we.setInitialized(!0))}#bt(){!function(e,t,o,i){const r=e.querySelector(".tbw-shell-toolbar");r&&r.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&i.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]"),o=e?.getAttribute("data-section");o&&i.onSectionToggle(o)}})}(this.#$,this.#p,this.#pe,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#be?.(),this.#be=function(e,t,o){const i=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),n=e.querySelector(".tbw-shell-body");if(!i||!r||!n)return()=>{};const s=t?.toolPanel?.position??"right";let l=0,a=0,c=0,d=!1;const h=e=>{if(!d)return;e.preventDefault();const t="left"===s?e.clientX-l:l-e.clientX,o=Math.min(c,Math.max(200,a+t));i.style.width=`${o}px`},u=()=>{if(!d)return;d=!1,r.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=i.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)},g=e=>{e.preventDefault(),d=!0,l=e.clientX,a=i.getBoundingClientRect().width,c=n.getBoundingClientRect().width-20,r.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)};return r.addEventListener("mousedown",g),()=>{r.removeEventListener("mousedown",g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}}(this.#$,this.#p?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)}),this.#me?.(),this.#me=function(e,t,o,i){if(!t?.toolPanel?.closeOnClickOutside)return()=>{};const r=e=>{if(!o.isPanelOpen)return;const t=e.target;t&&(t.closest(".tbw-tool-panel")||t.closest("[data-panel-toggle]")||i())};return e.addEventListener("mousedown",r),()=>e.removeEventListener("mousedown",r)}(this,this.#p?.shell,this.#pe,()=>this.closeToolPanel())}}customElements.get(qt.tagName)||customElements.define(qt.tagName,qt),globalThis.DataGridElement=qt;function $t(e,t,o){return o?.valueAccessor?F(e,o):e?.[t]}function Ft(e){return null==e||""===e||"number"==typeof e&&isNaN(e)}const Wt={sum:(e,t,o)=>{let i=0;for(let r=0;r<e.length;r++){const n=$t(e[r],t,o);if(Ft(n))continue;const s=Number(n);isNaN(s)||(i+=s)}return i},avg:(e,t,o)=>{if(!e.length)return 0;let i=0,r=0;for(let n=0;n<e.length;n++){const s=$t(e[n],t,o);if(Ft(s))continue;const l=Number(s);isNaN(l)||(i+=l,r++)}return r>0?i/r:0},count:e=>e.length,min:(e,t,o)=>{if(!e.length)return 0;let i=1/0;for(let r=0;r<e.length;r++){const n=$t(e[r],t,o);if(Ft(n))continue;const s=Number(n);isNaN(s)||s<i&&(i=s)}return i===1/0?0:i},max:(e,t,o)=>{if(!e.length)return 0;let i=-1/0;for(let r=0;r<e.length;r++){const n=$t(e[r],t,o);if(Ft(n))continue;const s=Number(n);isNaN(s)||s>i&&(i=s)}return i===-1/0?0:i},first:(e,t,o)=>e[0]?$t(e[0],t,o):void 0,last:(e,t,o)=>e.length?$t(e[e.length-1],t,o):void 0},Vt=new Map,Bt={register(e,t){Vt.set(e,t)},unregister(e){Vt.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:Vt.get(e)??Wt[e]},run(e,t,o,i){const r=this.get(e);return r?r(t,o,i):void 0},has:e=>Vt.has(e)||e in Wt,list:()=>[...Object.keys(Wt),...Vt.keys()]},Ut={sum:e=>{let t=0;for(let o=0;o<e.length;o++)t+=e[o];return t},avg:e=>{if(!e.length)return 0;let t=0;for(let o=0;o<e.length;o++)t+=e[o];return t/e.length},count:e=>e.length,min:e=>{if(!e.length)return 0;let t=e[0];for(let o=1;o<e.length;o++)e[o]<t&&(t=e[o]);return t},max:e=>{if(!e.length)return 0;let t=e[0];for(let o=1;o<e.length;o++)e[o]>t&&(t=e[o]);return t},first:e=>e[0]??0,last:e=>e[e.length-1]??0};function Gt(e){return Ut[e]??Ut.sum}e.BaseGridPlugin=class{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#_t;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},o={};for(const i of Object.keys(t))o[i]=this;for(const i of e){const e=i.userConfig;for(const[r,n]of Object.entries(e)){if(void 0===n)continue;if(!(r in t)){t[r]=n,o[r]=i;continue}if(t[r]===n)continue;const e=o[r]?.constructor.name??this.constructor.name,s=i.constructor.name,l=h("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${r}" supplied by both ${e} and ${s}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(l)}}Object.assign(this.userConfig,t)}attach(e){this.#_t?.abort(),this.#_t=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#_t?.abort(),this.#_t=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 o=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.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)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(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.#_t?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...r,...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(),o=parseInt(t,10);if(!isNaN(o))return o}return 200}setIcon(e,t,o){e.dataset.icon=q(t),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const i=this.#yt(t,o);void 0!==i?"string"==typeof i?e.innerHTML=L(i):i instanceof HTMLElement&&(e.innerHTML="",e.appendChild(i.cloneNode(!0))):e.innerHTML=""}#yt(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(o,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const i=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return i?e.insertBefore(o,i):e.appendChild(o),o}warn(e,t){void 0!==t?console.warn(h(e,t,this.gridElement.id,this.name)):console.warn(`${l(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(h(e,t,this.gridElement.id,this.name))}},e.CORE_CONSUMED_ADAPTER_METHODS=["canHandle","createRenderer","createEditor","processConfig","getTypeDefault","createToolPanelRenderer","parseDetailElement","parseResponsiveCardElement","releaseCell","unmount"],e.DEFAULT_A11Y_MESSAGES=o,e.DEFAULT_ANIMATION_CONFIG=i,e.DEFAULT_GRID_ICONS=r,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",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change",DATA_CHANGE:"data-change",TBW_SCROLL:"tbw-scroll"},e.DataGridElement=qt,e.FitModeEnum=t,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=_,e.GridDataAttrs=y,e.GridElement=qt,e.GridSelectors=R,e.PluginEvents={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",TREE_LOAD_START:"tree-load-start",TREE_LOAD_END:"tree-load-end",TREE_LOAD_ERROR:"tree-load-error",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=Nt,e.RenderPhase=se,e.aggregatorRegistry=Bt,e.builtInSort=V,e.createGrid=function(e){const t=document.createElement("tbw-grid");return e&&(t.gridConfig=e),t},e.defaultComparator=function(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0},e.getValueAggregator=Gt,e.invalidateAccessorCache=W,e.queryGrid=function(e,t,o){let i=document,r=!1;return"boolean"==typeof t?r=t:t&&(i=t,r=!!o),r?customElements.whenDefined(qt.tagName).then(()=>i.querySelector(e)):i.querySelector(e)},e.resolveCellValue=F,e.runValueAggregator=function(e,t){return Gt(e)(t)},e.setFeatureResolver=function(e){De=e},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";const t={STRETCH:"stretch",FIXED:"fixed"},o={sortApplied:(e,t)=>`Sorted by ${e}, ${t}`,sortCleared:()=>"Sort cleared",filterApplied:e=>`Filter applied on ${e}`,filterCleared:e=>`Filter cleared from ${e}`,allFiltersCleared:()=>"All filters cleared",groupExpanded:(e,t)=>`Group ${e} expanded, ${t} rows`,groupCollapsed:e=>`Group ${e} collapsed`,selectionChanged:e=>`${e} rows selected`,editingStarted:e=>`Editing row ${e+1}`,editingCommitted:e=>`Row ${e+1} saved`,dataLoaded:e=>`${e} rows loaded`},i={mode:"reduced-motion",duration:200,easing:"ease-out"},r={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function n(e,t){if(!e)return;const o="effectiveConfig"in e?e.effectiveConfig:void 0;if(!1===o?.a11y?.announcements)return;const i=e.querySelector?.(".tbw-sr-only");i&&(i.textContent="",requestAnimationFrame(()=>{i.textContent=t}))}function s(e,t,...i){const r=e&&"effectiveConfig"in e?e.effectiveConfig:void 0,n=r?.a11y?.messages?.[t];return n?n(...i):o[t](...i)}function l(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const a="TBW041",c="TBW061",d="TBW062";function h(e,t,o,i){return`${l(o,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function u(e,t,o,i){throw new Error(h(e,t,o,i))}function g(e,t,o,i){console.warn(h(e,t,o,i))}function f(e,t,o,i){console.error(h(e,t,o,i))}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 o={},i=t;for(let s=0;s<i.length;s++){const e=i[s],t=o[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 o=e.renderer||e.viewRenderer,i=t.renderer||t.viewRenderer;o&&!i&&(t.viewRenderer=o,e.renderer&&(t.renderer=o)),e.editor&&!t.editor&&(t.editor=e.editor)}else o[e.field]={...e}}const r=e.map(e=>{const t=o[e.field];if(!t)return e;const i={...e};t.header&&!i.header&&(i.header=t.header),t.type&&!i.type&&(i.type=t.type),i.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(i.resizable=!0),i.editable=e.editable||t.editable,null!=t.width&&null==i.width&&(i.width=t.width),null!=t.minWidth&&null==i.minWidth&&(i.minWidth=t.minWidth),t.__viewTemplate&&(i.__viewTemplate=t.__viewTemplate),t.__editorTemplate&&(i.__editorTemplate=t.__editorTemplate),t.__headerTemplate&&(i.__headerTemplate=t.__headerTemplate);const r=t.renderer||t.viewRenderer,n=i.renderer||i.viewRenderer;return r&&!n&&(i.viewRenderer=r,t.renderer&&(i.renderer=r)),t.editor&&!i.editor&&(i.editor=t.editor),delete o[e.field],i}),n=Object.keys(o);for(let s=0;s<n.length;s++)r.push(o[n[s]]);return r}function w(e,t){try{e.part?.add?.(t)}catch{}const o=e.getAttribute("part");o?o.split(/\s+/).includes(t)||e.setAttribute("part",o+" "+t):e.setAttribute("part",t)}function b(e){const o=e.effectiveConfig?.fitMode||e.fitMode||t.STRETCH;if(o!==t.STRETCH&&o!==t.FIXED)return;if(e.__didInitialAutoSize)return;if(!e.isConnected)return;const i=Array.from(e._headerRowEl?.children||[]);if(!i.length)return;let r=!1;const n=e._visibleColumns;for(let t=0;t<n.length;t++){const o=n[t];if(o.width)continue;const s=i[t];let l=s?s.scrollWidth:0;for(let i=0;i<e._rowPool.length;i++){const o=e._rowPool[i].children[t];if(o){const e=o.scrollWidth;e>l&&(l=e)}}l>0&&(o.width=l+2,o.__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)||g("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 o=e.effectiveConfig?.fitMode||e.fitMode||t.STRETCH;e._gridTemplate=o===t.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 _={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"},y={FIELD:"data-field",GROUP_KEY:"data-group-key"},R={ROOT:`.${_.ROOT}`,HEADER:`.${_.HEADER}`,HEADER_ROW:`.${_.HEADER_ROW}`,HEADER_CELL:`.${_.HEADER_CELL}`,ROWS_VIEWPORT:`.${_.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${_.ROWS_CONTAINER}`,DATA_ROW:`.${_.DATA_ROW}`,DATA_CELL:`.${_.DATA_CELL}`,GROUP_ROW:`.${_.GROUP_ROW}`,CELL_BY_FIELD:e=>`.${_.DATA_CELL}[${y.FIELD}="${e}"]`,SELECTED_ROWS:`.${_.DATA_ROW}.${_.SELECTED}`,EDITING_CELL:`.${_.DATA_CELL}.${_.EDITING}`},S=/{{\s*([^}]+)\s*}}/g,E="__DG_EMPTY__",A=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,x="__otorp__|__retteGenifed__|__retteSenifed__|rotcurtsnoc|wodniw|sihTlabolg|labolg|ssecorp|noitcnuF|tropmi|lave|tcelfeR|yxorP|rorrE|stnemugra|tnemucod|noitacol|eikooc|egarotSlacol|egarotSnoisses|BDdexedni|hctef|tseuqeRpttHLMX|tekcoSbeW|rekroW|rekroWderahS|rekroWecivreS|renepo|tnerap|pot|semarf|fles".split("|").map(e=>e.split("").reverse().join("")),T=new RegExp(`__(proto|defineGetter|defineSetter)|${x.slice(3).join("|")}|this\\b`);const P=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".split("|")),M=/^on\w+$/i,H=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),k=/^\s*(javascript|vbscript|data|blob):/i;function L(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=[],o=e.querySelectorAll("*");for(const i of o){const e=i.tagName.toLowerCase();if(P.has(e)){t.push(i);continue}if("svg"===e||"http://www.w3.org/2000/svg"===i.namespaceURI){if(Array.from(i.attributes).some(e=>M.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(i);continue}}const o=[];for(const t of i.attributes){const e=t.name.toLowerCase();M.test(e)?o.push(t.name):(H.has(e)&&k.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>i.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function O(e,t){const o=function(e){const t=[];let o=0;for(;o<e.length;){const i=e[o];if(" "!==i){if(i>="0"&&i<="9"||"."===i&&o+1<e.length&&e[o+1]>="0"&&e[o+1]<="9"){const i=o;for(;o<e.length&&(e[o]>="0"&&e[o]<="9"||"."===e[o]);)o++;t.push({type:"num",v:Number(e.slice(i,o))});continue}if("'"===i){let i="";for(o++;o<e.length&&"'"!==e[o];)i+=e[o++];if(o>=e.length)return null;o++,t.push({type:"str",v:i});continue}if(i>="a"&&i<="z"||i>="A"&&i<="Z"||"_"===i||"$"===i){const i=o;for(;o<e.length&&/[\w$.]/.test(e[o]);)o++;t.push({type:"id",v:e.slice(i,o)});continue}if(o+2<e.length){const i=e.slice(o,o+3);if("==="===i||"!=="===i){t.push({type:"op",v:i}),o+=3;continue}}if(o+1<e.length){const i=e.slice(o,o+2);if("=="===i||"!="===i||"<="===i||">="===i||"&&"===i||"||"===i){t.push({type:"op",v:i}),o+=2;continue}}if(!"+-*/%<>!?:(),".includes(i))return null;t.push({type:"op",v:i}),o++}else o++}return t}(e);if(!o)return;const i=o;let r=0;function n(){return i[r]}function s(){return i[r++]}function l(e,t){const o=n();return!!o&&(o.type===e&&(void 0===t||o.v===t))}function a(){const e=function(){let e=c();for(;l("op","||");)s(),e=e||c();return e}();if(l("op","?")){s();const t=a();if(!l("op",":"))return;s();const o=a();return e?t:o}return e}function c(){let e=d();for(;l("op","&&");)s(),e=e&&d();return e}function d(){let e=h();for(;;){const t=n();if(!t||"op"!==t.type)break;if("==="===t.v)s(),e=e===h();else if("!=="===t.v)s(),e=e!==h();else if("=="===t.v)s(),e=e==h();else{if("!="!==t.v)break;s(),e=e!=h()}}return e}function h(){let e=u();for(;;){const t=n();if(!t||"op"!==t.type)break;if("<"===t.v)s(),e=e<u();else if(">"===t.v)s(),e=e>u();else if("<="===t.v)s(),e=e<=u();else{if(">="!==t.v)break;s(),e=e>=u()}}return e}function u(){let e=g();for(;;){const t=n();if(!t||"op"!==t.type)break;if("+"===t.v)s(),e+=g();else{if("-"!==t.v)break;s(),e-=g()}}return e}function g(){let e=f();for(;;){const t=n();if(!t||"op"!==t.type)break;if("*"===t.v)s(),e*=f();else if("/"===t.v)s(),e/=f();else{if("%"!==t.v)break;s(),e%=f()}}return e}function f(){return l("op","!")?(s(),!f()):p()}function p(){const e=n();if(e){if("num"===e.type)return s(),e.v;if("str"===e.type)return s(),e.v;if("id"===e.type)return s(),function(e){if("value"===e)return t.value;if(e.startsWith("row.")){const o=e.slice(4);return t.row?t.row[o]:void 0}return"row"===e?t.row:void 0}(e.v);if("op"===e.type&&"("===e.v){s();const e=a();return l("op",")")&&s(),e}return"op"===e.type&&"-"===e.v?(s(),-p()):void 0}}const w=a();return r<i.length?void 0:w}function D(e,t){if(!e||-1===e.indexOf("{{"))return e;const o=[],i=e.replace(S,(e,i)=>{const r=function(e,t){if(e=(e||"").trim(),!e)return E;if(I.test(e))return E;if("value"===e)return null==t.value?E:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const o=e.slice(4),i=t.row?t.row[o]:void 0;return null==i?E:String(i)}if(e.length>80)return E;if(!A.test(e)||T.test(e))return E;const o=e.match(/\./g);if(o&&o.length>1)return E;try{const o=O(e,t),i=null==o?"":String(o);return I.test(i)?E:i||E}catch{return E}}(i,t);return o.push({expr:i.trim(),result:r}),r}),r=(n=i)?n.replace(new RegExp(E,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):n;var n;const s=o.length&&o.every(e=>""===e.result||e.result===E);return I.test(e)||s?"":r}const I=/Reflect|Proxy|ownKeys/;function z(e){if(I.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&I.test(t.textContent||"")&&(t.textContent="");I.test(e.textContent||"")&&(e.textContent="")}}function N(e){if(I.test(e)){const e=()=>"";return e.__blocked=!0,e}const t=t=>D(e,t);return t.__blocked=!1,t}function q(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}const $=new WeakMap;function F(e,t,o=-1){if(!t.valueAccessor)return e?.[t.field];if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:o});const i=t.field;let r=$.get(e);if(r){if(r.has(i))return r.get(i)}else r=new Map,$.set(e,r);const n=t.valueAccessor({row:e,column:t,rowIndex:o});return r.set(i,n),n}function W(e,t){e&&(t?$.get(e)?.delete(t):$.delete(e))}function V(e,t,o){const i=o.find(e=>e.field===t.field),r=i?.sortComparator,{field:n,direction:s}=t,l=[...e];return r?i?.valueAccessor?l.sort((e,t)=>r(F(e,i),F(t,i),e,t)*s):l.sort((e,t)=>r(e[n],t[n],e,t)*s):i?.valueAccessor?U(l,i,s):B(l,n,s),l}function B(e,t,o){e.sort((e,i)=>{const r=G(e,i);if(0!==r)return r;const n=e[t],s=i[t];return null==n&&null==s?0:null==n?-o:null==s||n>s?o:n<s?-o:0})}function U(e,t,o){e.sort((e,i)=>{const r=G(e,i);if(0!==r)return r;const n=F(e,t),s=F(i,t);return null==n&&null==s?0:null==n?-o:null==s||n>s?o:n<s?-o:0})}function G(e,t){const o=!0===e?.__loading;return o===(!0===t?.__loading)?0:o?1:-1}function j(e,t,o,i){const r=i.find(e=>e.field===t),n=r?.sortComparator;n?r?.valueAccessor?e.sort((e,t)=>n(F(e,r),F(t,r),e,t)*o):e.sort((e,i)=>n(e[t],i[t],e,i)*o):r?.valueAccessor?U(e,r,o):B(e,t,o)}function Y(e,t,o,i){e._rows=t,e.__rowRenderEpoch++;for(let r=0;r<e._rowPool.length;r++)e._rowPool[r].__epoch=-1;re(e),e.refreshVirtualWindow(!0),X(e,o,i)}function X(e,t,o){const i={field:t.field,direction:o};e.dispatchEvent(new CustomEvent("sort-change",{detail:i})),e._pluginManager?.emitPluginEvent?.("sort-change",i),n(e,s(e,0===o?"sortCleared":"sortApplied",t.header??t.field,1===o?"ascending":"descending")),e.requestStateChange?.()}function K(e){return e._pluginManager?._hasRowStructurePlugins??!1}function Z(e,t){if(e._sortState&&e._sortState.field===t.field)if(1===e._sortState.direction)Q(e,t,-1);else{if(e._sortState=null,K(e))return e._requestSchedulerPhase(4,"sort-clear"),void X(e,t,0);e.__rowRenderEpoch++;for(let t=0;t<e._rowPool.length;t++)e._rowPool[t].__epoch=-1;e._rows=e.__originalOrder.slice(),e.__originalOrder=[],re(e);const o=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');if(o)for(let t=0;t<o.length;t++){const i=o[t];i.getAttribute("aria-sort")&&("ascending"!==i.getAttribute("aria-sort")&&"descending"!==i.getAttribute("aria-sort")||e._sortState)||i.setAttribute("aria-sort","none")}e.refreshVirtualWindow(!0),X(e,t,0)}else e._sortState||(e.__originalOrder=e._rows.slice()),Q(e,t,1)}function Q(e,t,o){if(e._sortState={field:t.field,direction:o},K(e))return e._requestSchedulerPhase(4,"sort-apply"),void X(e,t,o);const i={field:t.field,direction:o},r=e._columns,n=e.effectiveConfig?.sortHandler??V;if(n===V)return j(e._rows,i.field,o,r),void Y(e,e._rows,t,o);const s=n(e._rows,i,r);s&&"function"==typeof s.then?s.then(i=>{Y(e,i,t,o)}):Y(e,s,t,o)}function J(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function ee(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function te(e,t){const o=document.createElement("span");w(o,"sort-indicator");const i=e._sortState?.field===t.field?e._sortState.direction:0,r=1===i?"sortAsc":-1===i?"sortDesc":"sortNone";o.dataset.icon=q(r);const n=e.icons?.[r];return void 0!==n&&function(e,t){"string"==typeof t?e.innerHTML=L(t):t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(o,n),o}function oe(e,t,o){const i=document.createElement("div");return i.className="resize-handle",i.setAttribute("aria-hidden","true"),i.addEventListener("mousedown",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.start(i,t,o)}),i.addEventListener("dblclick",o=>{o.stopPropagation(),o.preventDefault(),e._resizeController.resetColumn(t)}),i}function ie(e,t,o,i){i.classList.add(_.SORTABLE),i.tabIndex=0;const r=e._sortState?.field===t.field?e._sortState.direction:0;i.setAttribute("aria-sort",0===r?"none":1===r?"ascending":"descending"),i.addEventListener("click",o=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(o,t,i)||Z(e,t)}),i.addEventListener("keydown",o=>{if("Enter"===o.key||" "===o.key){if(o.preventDefault(),e._dispatchHeaderClick?.(o,t,i))return;Z(e,t)}})}function re(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((o,i)=>{const r=document.createElement("div");r.className="cell",w(r,"header-cell"),r.setAttribute("role","columnheader"),r.setAttribute("aria-colindex",String(i+1)),r.setAttribute("data-field",o.field),r.setAttribute("data-col",String(i)),o.type&&r.setAttribute("data-type",o.type);const n=o.header??o.field,s=e._sortState?.field===o.field?e._sortState.direction:0,l=1===s?"asc":-1===s?"desc":null;if(o.headerRenderer){const t={column:o,value:n,sortState:l,filterActive:!1,cellEl:r,renderSortIcon:()=>J(e,o)?te(e,o):null,renderFilterButton:()=>null},s=o.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const o=document.createElement("span");for(o.innerHTML=L(t);o.firstChild;)e.appendChild(o.firstChild)}else t instanceof Node&&e.appendChild(t)}(r,s),J(e,o)&&ie(e,o,0,r),ee(e,o)&&(r.classList.add("resizable"),r.appendChild(oe(e,i,r)))}else if(o.headerLabelRenderer){const t={column:o,value:n},s=o.headerLabelRenderer(t),l=document.createElement("span");null==s?l.textContent=n:"string"==typeof s?l.innerHTML=L(s):s instanceof Node&&l.appendChild(s),r.appendChild(l),J(e,o)&&(ie(e,o,0,r),r.appendChild(te(e,o))),ee(e,o)&&(r.classList.add("resizable"),r.appendChild(oe(e,i,r)))}else if(o.__headerTemplate)Array.from(o.__headerTemplate.childNodes).forEach(e=>r.appendChild(e.cloneNode(!0))),J(e,o)&&(ie(e,o,0,r),r.appendChild(te(e,o))),ee(e,o)&&(r.classList.add("resizable"),r.appendChild(oe(e,i,r)));else{const t=document.createElement("span");t.textContent=n,r.appendChild(t),J(e,o)&&(ie(e,o,0,r),r.appendChild(te(e,o))),ee(e,o)&&(r.classList.add("resizable"),r.appendChild(oe(e,i,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 ne(e,t){const o=e[0]||{},i=Object.keys(o).map(e=>{const t=o[e],i=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:i}}),r={};return i.forEach(e=>{r[e.field]=e.type||"string"}),{columns:i,typeMap:r}}const se={STYLE:1,VIRTUALIZATION:2,HEADER:3,ROWS:4,COLUMNS:5,FULL:6};class le{#e;#t=0;#o=0;#i=null;#r=null;#n=null;#s=!1;constructor(e){this.#e=e}requestPhase(e,t){e>this.#t&&(this.#t=e),0===this.#o&&(this.#l(),this.#o=requestAnimationFrame(()=>this.#a()))}whenReady(){return this.#i?this.#i:Promise.resolve()}setInitialReadyResolver(e){this.#n=e}cancel(){0!==this.#o&&(cancelAnimationFrame(this.#o),this.#o=0),this.#t=0,this.#r&&(this.#r(),this.#r=null,this.#i=null)}get isPending(){return 0!==this.#t}get pendingPhase(){return this.#t}#l(){this.#i||(this.#i=new Promise(e=>{this.#r=e}))}#a(){if(this.#o=0,!this.#e._schedulerIsConnected)return this.#t=0,void(this.#r&&(this.#r(),this.#r=null,this.#i=null));const e=this.#t;this.#t=0,e>=se.COLUMNS&&this.#e._schedulerMergeConfig(),e>=se.ROWS&&this.#e._schedulerProcessRows(),e>=se.COLUMNS&&(this.#e._schedulerProcessColumns(),this.#e._schedulerUpdateTemplate()),e>=se.HEADER&&this.#e._schedulerRenderHeader(),e>=se.VIRTUALIZATION&&this.#e.refreshVirtualWindow(!0,!0),e>=se.STYLE&&this.#e._schedulerAfterRender(),!this.#s&&this.#n&&(this.#s=!0,this.#n()),this.#r&&(this.#r(),this.#r=null,this.#i=null)}}class ae{#c;#d;#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.#c=e,this.#w=!0,this.#u=void 0}getGridConfig(){return this.#c}setColumns(e){this.#d=e,this.#w=!0}getColumns(){return this.#d}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.#A(),"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)}#A(){const e=this.#p.typeDefaults;if(!e)return;const t=this.columns;for(const o of t){if(!o.type)continue;const t=e[o.type];t&&(o.renderer||o.viewRenderer||!t.renderer||(o.renderer=t.renderer),!o.format&&t.format&&(o.format=t.format),!o.editor&&t.editor&&(o.editor=t.editor),!o.editorParams&&t.editorParams&&(o.editorParams=t.editorParams))}}#R(){const e=this.#c?{...this.#c}:{},t=Array.isArray(e.columns)?[...e.columns]:[],o=(this.#u??[]).map(e=>({...e}));let i=p(t,o);this.#d&&this.#d.length&&(i=p(this.#d,o));const r=this.#e.sourceRows;if(0===i.length&&r.length){i=ne(r).columns}return i.length&&(i.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)}),i.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=N(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=N(e.__editorTemplate.innerHTML))}),e.columns=i),this.#h&&(e.fitMode=this.#h),e.fitMode||(e.fitMode="stretch"),this.#x(e),e.columnState&&!this.#_&&(this.#_=e.columnState),e}#x(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 o=this.#e._shellState.lightDomHeaderContent;o?.length>0&&(e.shell.header.lightDomContent=o),this.#e._shellState.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0);const i=this.#e._shellState.toolPanels;if(i.size>0){const t=Array.from(i.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.#c?.shell?.header?.toolbarContents??[],a=new Set(l.map(e=>e.id)),c=[...l];for(const d of s)a.has(d.id)||c.push(d);c.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=c}collectState(e){const t=this.columns,o=this.#T();return{columns:t.map((t,i)=>{const r={field:t.field,order:i,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=o.get(t.field);s&&(r.sort=s);for(const o of e)if(o.getColumnState){const e=o.getColumnState(t.field);e&&Object.assign(r,e)}return r})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const o=this.columns,i=new Map(e.columns.map(e=>[e.field,e])),r=o.map(e=>{const t=i.get(e.field);if(!t)return e;const o={...e};return void 0!==t.width&&(o.width=t.width,o.__renderedWidth=t.width),void 0!==t.visible&&(o.hidden=!t.visible),o});r.sort((e,t)=>(i.get(e.field)?.order??1/0)-(i.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 o=this.columns,i=o.find(t=>t.field===e);if(!i)return!1;if(!t&&i.lockVisible)return!1;if(!t){if(0===o.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!i.hidden!=!t&&(i.hidden=!t,this.#e._emit("column-visibility",{field:e,visible:t,visibleColumns:o.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.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])),o=[];for(const i of e){const e=t.get(i);e&&(o.push(e),t.delete(i))}for(const i of t.values())o.push(i);this.columns=o,this.#e._invalidateVisibleColumnsCache(),re(this.#e),C(this.#e),this.#e._requestSchedulerPhase(se.COLUMNS,"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 o=e.getAttribute("type")||void 0,i={field:t,type:o&&new Set(["number","string","date","boolean","select"]).has(o)?o: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())?i.width=e:i.width=r}const n=e.getAttribute("minWidth")||e.getAttribute("min-width");if(n){const e=parseFloat(n);isNaN(e)||(i.minWidth=e)}e.hasAttribute("resizable")&&(i.resizable=!0);const s=e.getAttribute("editor"),l=e.getAttribute("renderer");s&&(i.__editorName=s),l&&(i.__rendererName=l);const a=e.getAttribute("options");a&&(i.options=a.split(",").map(e=>{const[t,o]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:o?.trim()||t.trim()}}));const c=e.querySelector("tbw-grid-column-view"),d=e.querySelector("tbw-grid-column-editor"),h=e.querySelector("tbw-grid-column-header");c&&(i.__viewTemplate=c),d&&(i.__editorTemplate=d),h&&(i.__headerTemplate=h);const u=globalThis.DataGridElement,g=u?.getAdapters?.()??[],f=c??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(i.viewRenderer=e)}const w=d??e,b=g.find(e=>e.canHandle(w));if(b){const e=b.createEditor(w);e&&(i.editor=e)}return i}).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,o=()=>{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 o of e){for(const e of o.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const o=e.tagName.toLowerCase();this.#P.has(o)&&t.add(o)}if("attributes"===o.type&&o.target.nodeType===Node.ELEMENT_NODE){const e=o.target.tagName.toLowerCase();this.#P.has(e)&&t.add(e)}}t.size>0&&!this.#C&&(this.#C=setTimeout(o,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 ce(){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 de(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"&#x1F5F9;":"&#9744;"}</span>`}function he(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 ue(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const o=e.closest(".data-grid-row");if(!o)return-1;const i=o.parentElement;if(!i)return-1;const r=i.querySelectorAll(":scope > .data-grid-row");for(let n=0;n<r.length;n++)if(r[n]===o)return n;return-1}function ge(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function fe(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 pe(e,t){const o=t.renderer||t.viewRenderer;if(o)return o;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const o=i.getTypeDefault(t.type,e._hostElement);if(o?.renderer)return o.renderer}}function we(e,t){if(t.format)return t.format;if(!t.type)return;const o=e.__frameworkAdapter;if(o?.getTypeDefault){const i=o.getTypeDefault(t.type,e._hostElement);if(i?.format)return i.format}}const be='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function me(e){return(e.__editingCellCount??0)>0}function ve(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(`.cell.${_.EDITING}`).forEach(e=>e.classList.remove(_.EDITING))}const Ce=document.createElement("template");Ce.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const _e=document.createElement("template");function ye(){return Ce.content.firstElementChild.cloneNode(!0)}function Re(){return _e.content.firstElementChild.cloneNode(!0)}function Se(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function Ee(e,t,o,i){const r=t.children,n=e._visibleColumns,s=n.length,l=r.length,a=s<l?s:l,h=e._focusRow,u=e._focusCol,f=e._hasAfterCellRenderHook?.()??!1;let p=e.__hasSpecialColumns;if(void 0===p){p=!1;const t=e.__frameworkAdapter;for(let o=0;o<s;o++){const i=n[o];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,e._hostElement)?.renderer||i.type&&t?.getTypeDefault?.(i.type,e._hostElement)?.format){p=!0;break}}e.__hasSpecialColumns=p}const w=String(i);if(p){for(let s=0;s<a;s++){if(n[s].externalView){if(!r[s].querySelector("[data-external-view]"))return void Ae(e,t,o,i)}}for(let s=0;s<a;s++){const l=n[s],a=r[s];a.getAttribute("data-row")!==w&&a.setAttribute("data-row",w);const p=a.classList.contains(_.EDITING);if(!p){const e=h===i&&u===s;e!==a.classList.contains("cell-focus")&&(a.classList.toggle("cell-focus",e),a.setAttribute("aria-selected",String(e)))}const m=l.cellClass;if(m){const t=a.getAttribute("data-dynamic-classes");if(t){const e=t.split(" ");for(let t=0;t<e.length;t++)e[t]&&a.classList.remove(e[t])}try{const e=m(F(o,l,i),o,l),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let o=0;o<t.length;o++){const i=t[o];i&&"string"==typeof i&&(a.classList.add(i),e+=(e?" ":"")+i)}a.setAttribute("data-dynamic-classes",e)}else a.removeAttribute("data-dynamic-classes")}catch(b){g(c,`cellClass callback error for column '${l.field}': ${b}`,e.id),a.removeAttribute("data-dynamic-classes")}}if(p)continue;const v=pe(e,l);if(v){const r=F(o,l,i),n=v({row:o,value:r,field:l.field,column:l,grid:e,cellEl:a});"string"==typeof n?(e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML=L(n)):n instanceof Node?n.parentElement!==a&&(e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML="",a.appendChild(n)):null==n&&(e.__frameworkAdapter?.releaseCell?.(a),a.textContent=null==r?"":String(r)),f&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:r,cellElement:a,rowElement:t});continue}if(l.__compiledView){const r=F(o,l,i),n=l.__compiledView({row:o,value:r,field:l.field,column:l});l.__compiledView.__blocked?a.textContent="":(a.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML=L(n),z(a)),f&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:r,cellElement:a,rowElement:t});continue}if(l.__viewTemplate){const r=F(o,l,i),n=l.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(n)?a.textContent="":(a.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML=L(D(n,{row:o,value:r})),z(a)),f&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:r,cellElement:a,rowElement:t});continue}if(l.externalView)continue;const C=F(o,l,i);let y;a.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(a);const R=we(e,l);if(R){try{const e=R(C,o);y=null==e?"":String(e)}catch(b){g(d,`Format error in column '${l.field}': ${b}`,e.id),y=null==C?"":String(C)}a.textContent=y}else"date"===l.type?(y=he(C),a.textContent=y):"boolean"===l.type?a.innerHTML=de(!!C):(y=null==C?"":String(C),a.textContent=y);f&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:s,value:C,cellElement:a,rowElement:t})}}else for(let c=0;c<a;c++){const s=r[c];if(s.classList.contains(_.EDITING))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const l=n[c],a=F(o,l,i);s.textContent=null==a?"":String(a),s.getAttribute("data-row")!==w&&s.setAttribute("data-row",w);const d=h===i&&u===c;d!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",d),s.setAttribute("aria-selected",String(d))),f&&e._afterCellRender?.({row:o,rowIndex:i,column:l,colIndex:c,value:a,cellElement:s,rowElement:t})}}function Ae(e,t,o,i){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,a=e._focusCol,h=e._hasAfterCellRenderHook?.()??!1,u=document.createDocumentFragment();for(let p=0;p<s;p++){const r=n[p],s=ye();s.setAttribute("aria-colindex",String(p+1)),s.setAttribute("data-col",String(p)),s.setAttribute("data-row",String(i)),s.setAttribute("data-field",r.field),s.setAttribute("data-header",r.header??r.field),r.type&&s.setAttribute("data-type",r.type);let w=F(o,r,i);const b=we(e,r);if(b)try{w=b(w,o)}catch(f){g(d,`Format error in column '${r.field}': ${f}`,e.id)}const m=r.__compiledView,v=r.__viewTemplate,C=pe(e,r),_=r.externalView;let y=!1;if(C){const t=C({row:o,value:w,field:r.field,column:r,grid:e,cellEl:s});"string"==typeof t?(s.innerHTML=L(t),y=!0):t instanceof Node?t.parentElement!==s&&(s.textContent="",s.appendChild(t)):null==t&&(s.textContent=null==w?"":String(w))}else if(_){const t=_,i=document.createElement("div");i.setAttribute("data-external-view",""),i.setAttribute("data-field",r.field),s.appendChild(i);const n={row:o,value:w,field:r.field,column:r,grid:e};if(t.mount)try{t.mount({placeholder:i,context:n,spec:t})}catch(f){g("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:i,spec:t,context:n}}))}catch(f){g("TBW064",`External view event dispatch error for column '${r.field}': ${f}`,e.id)}});i.setAttribute("data-mounted","")}else if(m){const e=m({row:o,value:w,field:r.field,column:r}),t=m.__blocked;s.innerHTML=t?"":L(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=L(D(e,{row:o,value:w})),y=!0)}else b?s.textContent=null==w?"":String(w):"date"===r.type?s.textContent=he(w):"boolean"===r.type?s.innerHTML=de(!!w):s.textContent=null==w?"":String(w);if(y){z(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(o):r.editable)?s.tabIndex=0:"boolean"===r.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),l===i&&a===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(F(o,r,i),o,r),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const o of t)o&&"string"==typeof o&&(s.classList.add(o),e+=(e?" ":"")+o);s.setAttribute("data-dynamic-classes",e)}}catch(f){g(c,`cellClass callback error for column '${r.field}': ${f}`,e.id)}h&&e._afterCellRender?.({row:o,rowIndex:i,column:r,colIndex:p,value:w,cellElement:s,rowElement:t}),u.appendChild(s)}t.appendChild(u)}function xe(e,t,o){if(t.target?.closest(".resize-handle"))return;const i=ue(o.querySelector(".cell[data-row]"));if(i<0)return;const r=e._rows[i];if(!r)return;if(e._dispatchRowClick?.(t,i,r,o))return;const n=t.target?.closest(".cell[data-col]");if(n){const o=Number(n.getAttribute("data-col"));if(!isNaN(o)){if(e._dispatchCellClick?.(t,i,o,n))return;const r=e._focusRow!==i||e._focusCol!==o;if(e._focusRow=i,e._focusCol=o,n.classList.contains(_.EDITING)){r&&(ge(e._bodyEl??e),n.classList.add("cell-focus"));const o=t.target,i=n.contains(o)&&o.matches(be)?o:n.querySelector(be);try{i?.focus({preventScroll:!0})}catch{}return}Me(e)}}}function Te(e){"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit()}function Pe(e){if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable}function Me(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:o,viewportEl:i}=e._virtualization,r=o,n=i?.clientHeight??r?.clientHeight??0;if(r&&n>0){const o=e._focusRow*t;o<r.scrollTop?r.scrollTop=o:o+t>r.scrollTop+n&&(r.scrollTop=o-n+t)}}const o=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;o||e.refreshVirtualWindow(!1),ge(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const i=e._focusRow,r=e._virtualization.start??0,n=e._virtualization.end??e._rows.length;if(i>=r&&i<n){const n=e._bodyEl.querySelectorAll(".data-grid-row")[i-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 i=e.querySelector(".tbw-scroll-area");if(i&&s&&(!o||t?.forceHorizontalScroll))if(t?.forceScrollLeft)i.scrollLeft=0;else if(t?.forceScrollRight)i.scrollLeft=i.scrollWidth-i.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(n??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),o=i.getBoundingClientRect(),r=e.left-o.left+i.scrollLeft,n=r+e.width,l=i.scrollLeft+t.left,a=i.scrollLeft+i.clientWidth-t.right;r<l?i.scrollLeft=r-t.left:n>a&&(i.scrollLeft=n-i.clientWidth+t.right)}}if(o&&s.classList.contains(_.EDITING)){const e=s.querySelector(be);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(o&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else o||document.activeElement!==e&&e.focus({preventScroll:!0})}}}_e.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const He=new WeakMap;function ke(e,t){const o=ue(t),i=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(o<0||i<0)return;e._focusRow=o,e._focusCol=i,ge(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 Le(e,t,o,i){let r=null;const n=o.composedPath?.();if(r=n&&n.length>0?n[0]:o.target,r&&!t.contains(r)){const e=document.elementFromPoint(o.clientX,o.clientY);e&&(r=e)}const s=r?.closest?.("[data-col]"),l=r?.closest?.(".data-grid-row"),a=r?.closest?.(".header-row");let c,d,h,u,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(h=e._rows[c],f=e._visibleColumns[d],u=f?.field,g=h&&u?h[u]:void 0)),{type:i,row:h,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:u,value:g,column:f,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}function Oe(e,t,o,i){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const o=e._rows.length-1,i=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;if((!Pe(a)||"Home"!==t.key&&"End"!==t.key)&&!(Pe(a)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===a.tagName&&"number"===a.type||Pe(a)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||Pe(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&&(e._activeEditRows===e._focusRow&&Te(e),e._focusRow-=1,e._focusCol=i):e._focusCol<i?e._focusCol+=1:(Te(e),e._focusRow<o&&(e._focusRow+=1,e._focusCol=0)),void Me(e);case"ArrowDown":r&&Te(e),e._focusRow=Math.min(o,e._focusRow+1),t.preventDefault();break;case"ArrowUp":r&&Te(e),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const o=fe(e);e._focusCol=o?Math.max(0,e._focusCol-1):Math.min(i,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const o=fe(e);e._focusCol=o?Math.min(i,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(r&&Te(e),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void Me(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(r&&Te(e),e._focusRow=o,e._focusCol=i):e._focusCol=i,t.preventDefault(),void Me(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(o,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const o=e._focusRow,i=e._focusCol,r=e._visibleColumns[i],n=e._rows[o],s=r?.field??"",l=s&&n?n[s]:void 0,a=e.querySelector(`[data-row="${o}"][data-col="${i}"]`),c=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:o,colIndex:i,column:r,field:s,value:l,row:n,cellEl:a,trigger:"keyboard",originalEvent:t}});if(e.dispatchEvent(c),c.defaultPrevented)return void t.preventDefault();break}default:return}Me(e)}}(e,t),{signal:i}),o.addEventListener("mousedown",t=>function(e,t,o){const i=Le(e,t,o,"mousedown");e._dispatchCellMouseDown?.(i)&&He.set(e,!0)}(e,o,t),{signal:i}),document.addEventListener("mousemove",t=>function(e,t,o){if(!He.get(e))return;const i=Le(e,t,o,"mousemove");e._dispatchCellMouseMove?.(i)}(e,o,t),{signal:i}),document.addEventListener("mouseup",t=>function(e,t,o){if(!He.get(e))return;const i=Le(e,t,o,"mouseup");e._dispatchCellMouseUp?.(i),He.set(e,!1)}(e,o,t),{signal:i})}let De;class Ie{#e;#M=new Set;#H=new Map;constructor(e){this.#e=e}focusCell(e,t){const o=this.#e,i=o._rows.length-1;if(i<0)return;let r;if("string"==typeof t){if(r=o._visibleColumns.findIndex(e=>e.field===t),r<0)return}else r=t;const n=o._visibleColumns.length-1;n<0||(o._focusRow=Math.max(0,Math.min(e,i)),o._focusCol=Math.max(0,Math.min(r,n)),Me(o))}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 o=this.#e._virtualization;if(!o.enabled)return;const i=o.container;if(!i)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,c;const d=o.positionCache;o.variableHeights&&d&&d.length>n?(a=d[n].offset,c=d[n].height):(a=n*o.rowHeight,c=o.rowHeight);const h=o.viewportEl?.clientHeight??i.clientHeight??0;if(h<=0)return;const u=i.scrollTop,g=a+c,f=u+h;let p;switch(s){case"start":p=a;break;case"center":p=a-h/2+c/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?i.scrollTo({top:p,behavior:"smooth"}):i.scrollTop=p}scrollToRowById(e,t){const o=this.#e._getRowEntry(e);o&&this.scrollToRow(o.index,t)}registerExternalFocusContainer(e){if(this.#M.has(e))return;this.#M.add(e);const t=new AbortController,o=t.signal,i=this.#e;e.addEventListener("focusin",()=>{i.dataset.hasFocus=""},{signal:o}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete i.dataset.hasFocus},{signal:o}),this.#H.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#M.delete(e);const t=this.#H.get(e);t&&(t(),this.#H.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.#M)if(t.contains(e))return!0;return!1}destroy(){for(const e of this.#H.values())e();this.#H.clear(),this.#M.clear()}}const ze="function"==typeof requestIdleCallback;function Ne(e){ze?cancelIdleCallback(e):clearTimeout(e)}function qe(e,t){if(t){const o=t({size:e});if("string"==typeof o){const e=document.createElement("div");return e.innerHTML=o,e}return o}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 $e(e){let t=null,o=null,i=null,r=null;const n=i=>{if(!t)return;const r=i.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==o&&(o=requestAnimationFrame(()=>{o=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:s.field,width:n}}))};let s=!1;const l=()=>{const o=null!==t;o&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",l),null!==i&&(document.documentElement.style.cursor=i,i=null),null!==r&&(document.body.style.userSelect=r,r=null),t=null,o&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(o,s,a){o.preventDefault();const c=e._headerRowEl??e.findHeaderRow?.();c&&function(t,o){const i=o.querySelectorAll(".cell");for(let r=0;r<e._visibleColumns.length;r++){if(r===t)continue;const o=e._visibleColumns[r];if(null==o.width&&!o.__userResized){const e=i[r],t=e?.getBoundingClientRect().width;t&&(o.width=Math.round(t),o.__userResized=!0,o.__renderedWidth=o.width)}}}(s,c);const d=e._visibleColumns[s],h="number"==typeof d?.width?d.width:void 0,u=d?.__renderedWidth??h??a.getBoundingClientRect().width;t={startX:o.clientX,colIndex:s,startWidth:u},window.addEventListener("mousemove",n),window.addEventListener("mouseup",l),null===i&&(i=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 o=e._visibleColumns[t];o&&(o.__userResized=!1,o.__renderedWidth=void 0,o.width=o.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:o.field,width:o.width}})))},dispose(){l()}}}const Fe="data-animating",We={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},Ve={change:500,insert:300,remove:200};function Be(e,t){const o=We[t],i=getComputedStyle(e).getPropertyValue(o);if(i){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(i);if(!isNaN(e)&&e>0)return e}return Ve[t]}function Ue(e,t,o){if(t<0)return Promise.resolve(!1);const i=e.findRenderedRowElement?.(t);return i?new Promise(e=>{!function(e,t,o){e.removeAttribute(Fe),e.offsetWidth,e.setAttribute(Fe,t);const i=Be(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(Fe),o?.()},i)}(i,o,()=>e(!0))}):Promise.resolve(!1)}function Ge(e,t){if(t)return t(e);const o=e;return"id"in o&&null!=o.id?String(o.id):"_id"in o&&null!=o._id?String(o._id):void 0}function je(e,t,o){const i=Ge(e,o);return void 0===i&&u("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),i}class Ye{#e;constructor(e){this.#e=e}resolveRowId(e){return je(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,o="api"){const i=this.#e,r=i._getRowEntry(e);r||u(a,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id);const{row:n,index:s}=r,l=[];for(const[a,c]of Object.entries(t)){const e=n[a];e!==c&&(l.push({field:a,oldValue:e,newValue:c}),n[a]=c,W(n,a))}for(const{field:a,oldValue:c,newValue:d}of l)i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:n,rowId:e,rowIndex:s,field:a,oldValue:c,newValue:d,changes:t,source:o},bubbles:!0,composed:!0}));l.length>0&&(Se(i),i._requestSchedulerPhase(se.VIRTUALIZATION,"updateRow"),i._emitDataChange())}updateRows(e,t="api"){const o=this.#e;let i=!1;for(const{id:r,changes:n}of e){const e=o._getRowEntry(r);e||u(a,`Row with ID "${r}" not found. Ensure the row exists and getRowId is correctly configured.`,o.id);const{row:s,index:l}=e;for(const[a,c]of Object.entries(n)){const e=s[a];e!==c&&(i=!0,s[a]=c,W(s,a),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:s,rowId:r,rowIndex:l,field:a,oldValue:e,newValue:c,changes:n,source:t},bubbles:!0,composed:!0})))}}i&&(Se(o),o._requestSchedulerPhase(se.VIRTUALIZATION,"updateRows"),o._emitDataChange())}async insertRow(e,t,o=!0){const i=this.#e,r=Math.max(0,Math.min(e,i._rows.length));i.sourceRows=[...i.sourceRows,t];const n=[...i._rows];n.splice(r,0,t),i._rows=n,i._sortState&&(i.__originalOrder=[...i.__originalOrder,t]),Se(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(let s=0;s<i._rowPool.length;s++)i._rowPool[s].__epoch=-1;i.refreshVirtualWindow(!0),i._emitPluginEvent("row-inserted",{row:t,index:r}),i._emitDataChange(),o&&(await new Promise(e=>requestAnimationFrame(()=>e())),await Ue(i,r,"insert"))}async removeRow(e,t=!0){const o=this.#e,i=o._rows[e];if(!i)return;t&&await Ue(o,e,"remove");const r=o._rows.indexOf(i);if(r<0)return i;const n=[...o._rows];n.splice(r,1),o._rows=n;const s=o.sourceRows.indexOf(i);if(s>=0){const e=[...o.sourceRows];e.splice(s,1),o.sourceRows=e}if(o._sortState){const e=o.__originalOrder.indexOf(i);if(e>=0){const t=[...o.__originalOrder];t.splice(e,1),o.__originalOrder=t}}Se(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(let l=0;l<o._rowPool.length;l++)o._rowPool[l].__epoch=-1;return o.refreshVirtualWindow(!0),o._emitDataChange(),t&&requestAnimationFrame(()=>{const e=o.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),i}async applyTransaction(e,t=!0){const o=this.#e,i={added:[],updated:[],removed:[]};if(e.remove?.length)for(const{id:l}of e.remove){const e=o._getRowEntry(l);if(!e)continue;const{row:r}=e;if(t){const e=o._rows.indexOf(r);e>=0&&await Ue(o,e,"remove")}const n=o._rows.indexOf(r);if(n<0){i.removed.push(r);continue}const s=[...o._rows];s.splice(n,1),o._rows=s;const a=o.sourceRows.indexOf(r);if(a>=0){const e=[...o.sourceRows];e.splice(a,1),o.sourceRows=e}if(o._sortState){const e=o.__originalOrder.indexOf(r);if(e>=0){const t=[...o.__originalOrder];t.splice(e,1),o.__originalOrder=t}}i.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=o._getRowEntry(l);if(!e)continue;const{row:t,index:n}=e;let s=!1;for(const[i,r]of Object.entries(a)){const e=t[i];e!==r&&(s=!0,t[i]=r,W(t,i),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:l,rowIndex:n,field:i,oldValue:e,newValue:r,changes:a,source:"api"},bubbles:!0,composed:!0})))}s&&i.updated.push(t)}if(e.add?.length)for(const l of e.add){o.sourceRows=[...o.sourceRows,l];const e=[...o._rows];e.push(l),o._rows=e,o._sortState&&(o.__originalOrder=[...o.__originalOrder,l]),i.added.push(l)}const n=i.added.length>0||i.removed.length>0,s=i.updated.length>0;if(n){Se(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(let e=0;e<o._rowPool.length;e++)o._rowPool[e].__epoch=-1;o.refreshVirtualWindow(!0)}else s&&(Se(o),o._requestSchedulerPhase(se.VIRTUALIZATION,"applyTransaction"));if((n||s)&&o._emitDataChange(),t&&i.added.length>0){await new Promise(e=>requestAnimationFrame(()=>e()));for(const e of i.added){const t=o._rows.indexOf(e);t>=0&&await Ue(o,t,"insert")}}if(t&&i.updated.length>0)for(const l of i.updated){const e=o._rows.indexOf(l);e>=0&&await Ue(o,e,"change")}return t&&i.removed.length>0&&requestAnimationFrame(()=>{const e=o.querySelectorAll('[data-animating="remove"]');for(let t=0;t<e.length;t++)e[t].removeAttribute("data-animating")}),i}#k=null;#L=[];#O=null;applyTransactionAsync(e){return this.#k||(this.#k={add:[],update:[],remove:[]}),e.add&&this.#k.add.push(...e.add),e.update&&this.#k.update.push(...e.update),e.remove&&this.#k.remove.push(...e.remove),new Promise(e=>{this.#L.push(e),null===this.#O&&(this.#O=requestAnimationFrame(()=>{this.#O=null;const e=this.#k,t=this.#L;this.#k=null,this.#L=[],this.applyTransaction(e,!1).then(e=>{for(const o of t)o(e)})}))})}}function Xe(e,t){if(t)for(const o in t){const i=t[o];null!=i&&e.setAttribute(o,i)}}function Ke(e,t,o){const i=document.createElement(e);return Xe(i,t),i}function Ze(e,t){const o=document.createElement("div");return e&&(o.className=e),Xe(o,t),o}function Qe(e,t,o){const i=document.createElement("button");return e&&(i.className=e),Xe(i,t),i}const Je=document.createElement("template");function et(){return Je.content.cloneNode(!0)}function tt(e){const t=document.createDocumentFragment(),o=Ze(e.hasShell?`${_.ROOT} has-shell`:_.ROOT);if(e.hasShell&&e.shellHeader&&e.shellBody)o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=Ze("tbw-grid-content");e.appendChild(et()),o.appendChild(e)}return t.appendChild(o),t}function ot(e){const t=Ze("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=Ze("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=Ze("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const i=Ze("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const r of e.configButtons)r.hasRender&&i.appendChild(Ze("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));for(const r of e.apiButtons)r.hasRender&&i.appendChild(Ze("tbw-toolbar-content-slot",{"data-toolbar-content":r.id}));if((e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender))&&e.hasPanels&&i.appendChild(Ze("tbw-toolbar-separator")),e.hasPanels){const t=Qe(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.dataset.icon="tool-panel",void 0!==e.toolPanelIcon&&(t.innerHTML=L(e.toolPanelIcon)),i.appendChild(t)}return t.appendChild(i),t}function it(e){const t=Ze("tbw-shell-body"),o=e.panels.length>0,i=1===e.panels.length,r=Ze("tbw-grid-content");r.appendChild(et());let n=null;if(o){n=Ke("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(Ze("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":t,"aria-hidden":"true"}));const o=Ze("tbw-tool-panel-content",{role:"presentation"}),r=Ze("tbw-accordion");for(const n of e.panels){const t=Ze(`tbw-accordion-section${n.isExpanded?" expanded":""}${i?" single":""}`,{"data-section":n.id}),o=Qe("tbw-accordion-header",{"aria-expanded":String(n.isExpanded),"aria-controls":`tbw-section-${n.id}`});if(i&&o.setAttribute("aria-disabled","true"),n.icon){const e=Ke("span",{class:"tbw-accordion-icon"});e.innerHTML=L(n.icon),o.appendChild(e)}const s=Ke("span",{class:"tbw-accordion-title"});if(s.textContent=n.title,o.appendChild(s),!i){const t=Ke("span",{class:"tbw-accordion-chevron","data-icon":"expand"});void 0!==e.expandIcon&&(t.innerHTML=L(e.expandIcon)),o.appendChild(t)}t.appendChild(o),t.appendChild(Ze("tbw-accordion-content",{id:`tbw-section-${n.id}`,role:"presentation"})),r.appendChild(t)}o.appendChild(r),n.appendChild(o)}return"left"===e.position&&n?(t.appendChild(n),t.appendChild(r)):(t.appendChild(r),n&&t.appendChild(n)),t}function rt(e){return e?"string"==typeof e?L(e):e.outerHTML:""}function nt(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function st(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const i=o.querySelectorAll("tbw-grid-header-content");i.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(i)),o.style.display="none"}function lt(e,t,o){const i=e.querySelector(":scope > tbw-grid-tool-buttons");if(!i)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(;i.firstChild;)e.appendChild(i.firstChild);return()=>{for(;e.firstChild;)i.appendChild(e.firstChild)}}};t.toolbarContents.set(r,n),t.lightDomToolbarContentIds.add(r),i.style.display="none"}function at(e,t,o){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const i=e,r=i.getAttribute("id"),n=i.getAttribute("title");if(!r||!n)return void g("TBW070",`Tool panel missing required id or title attribute: id="${r??""}", title="${n??""}"`);const s=i.getAttribute("icon")??void 0,l=i.getAttribute("tooltip")??void 0,a=parseInt(i.getAttribute("order")??"100",10);let c;const d=o?.(i);if(d)c=d;else{const e=L(i.innerHTML.trim());c=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const h=t.toolPanels.get(r);if(h){if(d){h.render=c,h.order=a,h.icon=s,h.tooltip=l;const e=t.panelCleanups.get(r);e&&(e(),t.panelCleanups.delete(r))}return}const u={id:r,title:n,icon:s,tooltip:l,order:a,render:c};t.toolPanels.set(r,u),t.lightDomToolPanelIds.add(r),i.style.display="none"})}function ct(e,t,o){const i=t?.header?.toolbarContents??[],r=[...o.toolbarContents.values()],n=new Set(i.map(e=>e.id)),s=[...i];for(const l of r)n.has(l.id)||s.push(l);for(const l of s){if(o.toolbarContentCleanups.has(l.id))continue;if(!l.render)continue;const t=e.querySelector(`[data-toolbar-content="${l.id}"]`);if(!t)continue;const i=l.render(t);i&&o.toolbarContentCleanups.set(l.id,i)}}function dt(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,i=t.headerContents.size>0;if(!o&&!i)return;const r=e.querySelector(".tbw-shell-content");if(!r)return;if(o){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 o=r.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),r.appendChild(o));const i=s.render(o);i&&t.headerContentCleanups.set(s.id,i)}}function ht(e,t,o){if(t.isPanelOpen)for(const[i,r]of t.toolPanels){const o=t.expandedSections.has(i),n=e.querySelector(`[data-section="${i}"]`),s=n?.querySelector(".tbw-accordion-content");if(!n||!s)continue;n.classList.toggle("expanded",o);const l=n.querySelector(".tbw-accordion-header");if(l&&l.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=r.render(s);e&&t.panelCleanups.set(i,e)}}else{const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i)),s.innerHTML=""}}}function ut(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function gt(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}function ft(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 pt(e,t,o){const i=void 0!==o?.toolPanel?rt(o.toolPanel):void 0,r=void 0!==o?.expand?rt(o.expand):void 0,n=void 0!==o?.collapse?rt(o.collapse):void 0,s=[...e.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),l=[...e.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100));return{headerOptions:{title:e.header?.title??void 0,hasPanels:l.length>0,isPanelOpen:t.isPanelOpen,toolPanelIcon:i,configButtons:s.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},bodyOptions:{position:e.toolPanel?.position??"right",isPanelOpen:t.isPanelOpen,expandIcon:r,collapseIcon:n,panels:l.map(e=>({id:e.id,title:e.title,icon:rt(e.icon),isExpanded:t.expandedSections.has(e.id)}))}}}function wt(e,t,o,i){const r=nt(t),n=[],s=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const l of s){e.querySelectorAll(`:scope > ${l}`).forEach(e=>n.push(e))}e.replaceChildren();for(const l of n)e.appendChild(l);if(r){const{headerOptions:r,bodyOptions:n}=pt(t,o,i),s=tt({hasShell:!0,shellHeader:ot(r),shellBody:it(n)});e.appendChild(s)}else{const t=tt({hasShell:!1});e.appendChild(t)}return r}function bt(e,t,o){const i=e.querySelector(`[data-section="${t}"]`);i&&i.classList.toggle("expanded",o)}Je.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 mt="tbw-grid-styles";let vt="";const Ct=new Map;function _t(){const e=function(){let e=document.getElementById(mt);return e||(e=document.createElement("style"),e.id=mt,e.setAttribute("data-tbw-grid","true"),document.head.appendChild(e)),e}(),t=Array.from(Ct.values()).join("\n");e.textContent=`${vt}\n\n/* Plugin Styles */\n${t}`}async function yt(e){if(vt)return;if("string"==typeof e&&e.length>0)return vt=e,void _t();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){g("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(vt=t,_t()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||g("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 Rt(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function St(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function Et(e,t){if(null!==e.lastTime){performance.now()-e.lastTime>60&&(e.velocityY=0,e.velocityX=0)}(Math.abs(e.velocityY)>.1||Math.abs(e.velocityX)>.1)&&function(e,t){const o=.95,i=1;let r=performance.now();const n=()=>{const s=performance.now(),l=s-r;r=s;const a=l/16,c=Math.pow(o,a);e.velocityY*=c,e.velocityX*=c;const d=16*e.velocityY,h=16*e.velocityX,u=Math.abs(d)>=i,g=Math.abs(h)>=i;u&&(t.fauxScrollbar.scrollTop+=d),g&&t.scrollArea&&(t.scrollArea.scrollLeft+=h),e.momentumRaf=u||g?requestAnimationFrame(n):0};e.momentumRaf=requestAnimationFrame(n)}(e,t),Rt(e)}function At(e,t,o,i){e.addEventListener("pointerdown",o=>{"touch"===o.pointerType&&null===t.activePointerId&&(t.activePointerId=o.pointerId,e.setPointerCapture(o.pointerId),function(e,t,o){St(o),o.startY=t,o.startX=e,o.lastY=t,o.lastX=e,o.lastTime=performance.now(),o.velocityY=0,o.velocityX=0,o.locked=!1}(o.clientX,o.clientY,t))},{passive:!0,signal:i}),e.addEventListener("pointermove",e=>{if(e.pointerId!==t.activePointerId)return;const i=function(e,t,o,i){if(null===o.lastY||null===o.lastX)return!1;const r=performance.now(),n=o.lastY-t,s=o.lastX-e;if(null!==o.lastTime){const e=r-o.lastTime;e>0&&(o.velocityY=n/e,o.velocityX=s/e)}if(o.lastY=t,o.lastX=e,o.lastTime=r,o.locked){const{scrollTop:e,scrollHeight:t,clientHeight:o}=i.fauxScrollbar;if(n>0&&e<t-o||n<0&&e>0?i.fauxScrollbar.scrollTop+=n:0!==n&&window.scrollBy(0,n),i.scrollArea){const{scrollLeft:e,scrollWidth:t,clientWidth:o}=i.scrollArea;s>0&&e<t-o||s<0&&e>0?i.scrollArea.scrollLeft+=s:0!==s&&window.scrollBy(s,0)}return!0}const l=null!==o.startY?Math.abs(o.startY-t):0,a=null!==o.startX?Math.abs(o.startX-e):0;if(l<3&&a<3)return!1;const c=l>=a,{scrollHeight:d,clientHeight:h}=i.fauxScrollbar,u=d-h>0;let g=!1;if(i.scrollArea){const{scrollWidth:e,clientWidth:t}=i.scrollArea;g=e-t>0}return!!(c&&u||!c&&g)&&(o.locked=!0,i.fauxScrollbar.scrollTop+=n,i.scrollArea&&(i.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,o);i&&e.preventDefault()},{passive:!1,signal:i}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Et(t,o))},{passive:!0,signal:i}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Rt(t))},{passive:!0,signal:i}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Rt(t))},{passive:!0,signal:i})}const xt=[{property:"editable",pluginName:"editing",level:"column",description:"",isUsed:e=>!0===e||"function"==typeof e},{property:"editor",pluginName:"editing",level:"column",description:""},{property:"editorParams",pluginName:"editing",level:"column",description:""},{property:"group",pluginName:"groupingColumns",level:"column",description:""},{property:"pinned",pluginName:"pinnedColumns",level:"column",description:"",isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e}],Tt=[{property:"rowEditable",pluginName:"editing",level:"config",description:"",isUsed:e=>"function"==typeof e},{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:"",isUsed:e=>Array.isArray(e)&&e.length>0}];function Pt(e){return`import { ${Mt(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function Mt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ht(e,t){return e.some(e=>e.name===t)}function kt(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 Lt(e,t,o){const i=kt(t,o);return"string"==typeof i?e.byKey.get(i):i&&"object"==typeof i?e.byRef.get(i):void 0}function Ot(e,t,o){if(t<0||t>=e.length)return;const i=e[t],r=o-i.height;if(0!==r){i.height=o,i.measured=!0;for(let o=t+1;o<e.length;o++)e[o].offset+=r}}function Dt(e,t){if(0===e.length)return-1;if(t<=0)return 0;let o=0,i=e.length-1;for(;o<=i;){const r=Math.floor((o+i)/2),n=e[r],s=n.offset+n.height;if(t<n.offset)i=r-1;else{if(!(t>=s))return r;o=r+1}}return Math.max(0,Math.min(o,e.length-1))}function It(e,t){const{positionCache:o,heightCache:i,rows:r,start:n,end:s,getPluginHeight:l,getRowId:a}=e;let c=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const d=parseInt(t,10);if(d<n||d>=s||d>=r.length)return;const h=r[d],u=l?.(h,d);if(void 0!==u){const e=o[d];return void((!e.measured||Math.abs(e.height-u)>1)&&(Ot(o,d,u),c=!0))}const g=e.offsetHeight;if(g>0){const e=o[d];(!e.measured||Math.abs(e.height-g)>1)&&(Ot(o,d,g),function(e,t,o,i){const r=kt(t,i);"string"==typeof r?e.byKey.set(r,o):r&&"object"==typeof r&&e.byRef.set(r,o)}(i,h,g,a),c=!0)}});const d=c?function(e){let t=0;for(const o of e)o.measured&&t++;return t}(o):0,h=c?function(e,t){let o=0,i=0;for(const r of e)r.measured&&(o+=r.height,i++);return i>0?o/i:t}(o,e.defaultHeight):0;return{hasChanges:c,measuredCount:d,averageHeight:h}}class zt{#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,o=e.viewportEl??t;o&&(e.cachedViewportHeight=o.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const i=e.scrollAreaEl;i&&(e.cachedScrollAreaHeight=i.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const o=this.state;let i,r,n;if(t){const e=o.container??this.#e._hostElement,t=o.viewportEl??e,s=o.scrollAreaEl;i=e?.clientHeight??0,r=t?.clientHeight??0,n=s?s.clientHeight:i,o.cachedFauxHeight=i,o.cachedViewportHeight=r,o.cachedScrollAreaHeight=n}else i=o.cachedFauxHeight,r=o.cachedViewportHeight,n=o.cachedScrollAreaHeight||i;const s=n-r,l=Math.max(0,i-n);let a;return a=o.variableHeights&&o.positionCache?function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(o.positionCache):e*o.rowHeight,a+s+l}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#e,o=t._rows,i=e.rowHeight||28,r=t.effectiveConfig?.rowHeight,n=t.effectiveConfig?.getRowId,s=n?e=>n(e):void 0;e.positionCache=function(e,t,o,i,r){const n=new Array(e.length);let s=0;for(let l=0;l<e.length;l++){const a=e[l];let c=r?.(a,l),d=void 0!==c;void 0===c&&(c=Lt(t,a,i.rowId),d=void 0!==c),void 0===c&&(c=o,d=!1),n[l]={offset:s,height:c,measured:d},s+=c}return n}(o,e.heightCache,i,{rowId:s},(e,o)=>{const i=t._getPluginRowHeight(e,o);if(void 0!==i)return i;if(r){const t=r(e,o);if(void 0!==t&&t>0)return t}});const l=function(e,t,o,i){let r=0,n=0;for(let s=0;s<e.length;s++){const o=e[s];if(o.measured){const e=i?.(t[s],s);void 0===e&&(n+=o.height,r++)}}return{measuredCount:r,averageHeight:r>0?n/r:o}}(e.positionCache,o,i,(e,o)=>t._getPluginRowHeight(e,o));e.measuredCount=l.measuredCount,l.measuredCount>0&&(e.averageHeight=l.averageHeight)}invalidateRowHeight(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#e._rows;if(e<0||e>=i.length)return;const r=i[e];let n=t;void 0===n&&(n=this.#e._getPluginRowHeight(r,e)),void 0===n&&(n=o.rowHeight);const s=o.positionCache[e];if(s&&!(Math.abs(s.height-n)<1)&&(Ot(o.positionCache,e,n),o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(i.length);o.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#e,r=i._bodyEl;if(!r)return;const n=r.querySelectorAll(".data-grid-row"),s=i.effectiveConfig?.getRowId,l=i._rows,a=It({positionCache:o.positionCache,heightCache:o.heightCache,rows:l,defaultHeight:o.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>i._getPluginRowHeight(e,t),getRowId:s?e=>s(e):void 0},n);if(a.hasChanges&&(o.measuredCount=a.measuredCount,o.averageHeight=a.averageHeight,o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(l.length);o.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){const o=this.state,i=this.#e,r=i._bodyEl;if(!r)return!1;const n=i._rows.length;if(!o.enabled)return i._renderVisibleRows(0,n),t||i._afterPluginRender(),!0;if(n<=o.bypassThreshold)return o.start=0,o.end=n,e&&(r.style.transform="translateY(0px)"),i._renderVisibleRows(0,n,i.__rowRenderEpoch),e&&o.variableHeights&&this.initializePositionCache(),e&&o.totalHeightEl&&(o.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(n,!0)}px`),i._updateAriaCounts(n,i._visibleColumns.length),t||i._afterPluginRender(),!0;const s=o.container,l=o.viewportEl??s,a=e?o.cachedViewportHeight=l.clientHeight:o.cachedViewportHeight||(o.cachedViewportHeight=l.clientHeight),c=o.rowHeight,d=s.scrollTop;let h;e&&o.variableHeights&&this.initializePositionCache();const u=o.positionCache;o.variableHeights&&u&&u.length>0?(h=Dt(u,d),-1===h&&(h=0)):h=Math.floor(d/c),h-=h%2,h<0&&(h=0);const g=i._adjustPluginVirtualStart(h,d,c);let f;if(void 0!==g&&g<h&&(h=g,h-=h%2,h<0&&(h=0)),o.variableHeights&&u&&u.length>0){const e=a+3*c;let t=0;for(f=h;f<n&&t<e;)t+=u[f].height,f++;const o=Math.ceil(a/c)+3;f-h<o&&(f=Math.min(h+o,n))}else{f=h+(Math.ceil(a/c)+3)}f>n&&(f=n);const p=o.start,w=o.end;if(!e&&h===p&&f===w)return!1;o.start=h,o.end=f;const b=e?o.cachedFauxHeight=s.clientHeight:o.cachedFauxHeight||(o.cachedFauxHeight=s.clientHeight);if(e){const e=o.scrollAreaEl;e&&(o.cachedScrollAreaHeight=e.clientHeight)}if(0===b&&a>0)return i._requestSchedulerPhase(se.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&o.totalHeightEl){const e=this.calculateTotalSpacerHeight(n);o.totalHeightEl.style.height=`${e}px`}let m;m=o.variableHeights&&u&&u[h]?u[h].offset:h*c;const v=-(d-m);return r.style.transform=`translateY(${v}px)`,i._renderVisibleRows(h,f,i.__rowRenderEpoch),e&&o.variableHeights&&this.measureRenderedRowHeights(h,f),i._updateAriaCounts(n,i._visibleColumns.length),e&&!t&&(i._afterPluginRender(),queueMicrotask(()=>{if(!o.totalHeightEl)return;const e=this.calculateTotalSpacerHeight(n);0===o.cachedFauxHeight&&o.cachedViewportHeight>0||(o.totalHeightEl.style.height=`${e}px`)})),!0}}class Nt{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;_hasProcessRows=!1;_hasRowStructurePlugins=!1;#D=new Map;eventListeners=new Map;queryHandlers=new Map;attachAll(e){const t=this.#I(e);for(const o of t)this.attach(o)}#I(e){if(e.length<2)return e;const t=new Map,o=new Map,i=[];for(const r of e){const e=r.constructor,n=t.get(e);if(!n){t.set(e,r),i.push(r);continue}const s=o.get(n)??[];s.push(r),o.set(n,s)}if(0===o.size)return i;for(const[r,n]of o)r.mergeConfigsFrom(n);return i}attach(e){if(function(e,t,o){const i=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??`${Mt(i)}Plugin requires ${Mt(e)}Plugin`,n=Pt(e);r&&u("TBW020",`Plugin dependency error:\n\n${t}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${Mt(i)}Plugin:\n ${n}\n plugins: [new ${Mt(e)}Plugin(), new ${Mt(i)}Plugin()]`,o)}}}(e,this.plugins,this.grid.getAttribute("id")??void 0),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,o]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,o);if(e.headerRenderers)for(const[t,o]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,o);if(e.cellEditors)for(const[t,o]of Object.entries(e.cellEditors))this.cellEditors.set(t,o);this.registerQueryHandlers(e),e.attach(this.grid),this.#z();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 o of t.queries){let t=this.queryHandlers.get(o.type);t||(t=new Set,this.queryHandlers.set(o.type,t)),t.add(e)}}unregisterQueryHandlers(e){for(const[t,o]of this.queryHandlers)o.delete(e),0===o.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,this._hasProcessRows=!1,this.#D.clear()}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){if(!this._hasProcessRows)return e;let t=e;for(const o of this.#N("processRows")){const e=o.processRows(t);e!==t&&(t=e)}return t}processColumns(e){let t=[...e];for(const o of this.#N("processColumns"))t=o.processColumns(t);return t}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.#N("afterRender"))e.afterRender()}afterCellRender(e){for(const t of this.#N("afterCellRender"))t.afterCellRender(e)}hasAfterCellRenderHook(){return this._hasAfterCellRender}afterRowRender(e){for(const t of this.#N("afterRowRender"))t.afterRowRender(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#z(){this._hasAfterCellRender=this.plugins.some(e=>"function"==typeof e.afterCellRender),this._hasAfterRowRender=this.plugins.some(e=>"function"==typeof e.afterRowRender),this._hasProcessRows=this.plugins.some(e=>"function"==typeof e.processRows),this._hasRowStructurePlugins=this.plugins.some(e=>!0===e.constructor.manifest?.modifiesRowStructure),this.#D.clear()}#N(e){let t=this.#D.get(e);if(t)return t;t=this.plugins.filter(t=>e in t&&"function"==typeof t[e]);const o=t=>{const o=t.constructor.manifest?.hookPriority;if(!o)return 0;return o[e]??0};return t.some(e=>0!==o(e))&&t.sort((e,t)=>o(e)-o(t)),this.#D.set(e,t),t}onScrollRender(){for(const e of this.#N("onScrollRender"))e.onScrollRender()}getRowHeight(e,t){for(const o of this.plugins)if("function"==typeof o.getRowHeight){const i=o.getRowHeight(e,t);if(void 0!==i)return i}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,o){let i=e;for(const r of this.plugins)if("function"==typeof r.adjustVirtualStart){const n=r.adjustVirtualStart(e,t,o);n<i&&(i=n)}return i}renderRow(e,t,o){for(const i of this.plugins)if(i.renderRow?.(e,t,o))return!0;return!1}queryPlugins(e){const t=[],o=this.queryHandlers.get(e.type);if(o&&o.size>0){for(const i of o){const o=i.handleQuery?.(e);void 0!==o&&t.push(o)}return t}for(const i of this.plugins){const o=i.handleQuery?.(e);void 0!==o&&t.push(o)}return t}subscribe(e,t,o){let i=this.eventListeners.get(t);i||(i=new Map,this.eventListeners.set(t,i)),i.set(e,o)}unsubscribe(e,t){const o=this.eventListeners.get(t);o&&(o.delete(e),0===o.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,o]of this.eventListeners)o.delete(e),0===o.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const o=this.eventListeners.get(e);if(o)for(const r of o.values())try{r(t)}catch(i){f("TBW024",`Error in plugin event handler for "${e}": ${i}`,this.grid.getAttribute("id")??void 0)}}onKeyDown(e){for(const t of this.#N("onKeyDown"))if(t.onKeyDown(e))return!0;return!1}onCellClick(e){for(const t of this.#N("onCellClick"))if(t.onCellClick(e))return!0;return!1}onRowClick(e){for(const t of this.#N("onRowClick"))if(t.onRowClick(e))return!0;return!1}onHeaderClick(e){for(const t of this.#N("onHeaderClick"))if(t.onHeaderClick(e))return!0;return!1}onScroll(e){for(const t of this.#N("onScroll"))t.onScroll(e)}onCellMouseDown(e){for(const t of this.#N("onCellMouseDown"))if(t.onCellMouseDown(e))return!0;return!1}onCellMouseMove(e){for(const t of this.#N("onCellMouseMove"))if(t.onCellMouseMove(e))return!0;return!1}onCellMouseUp(e){for(const t of this.#N("onCellMouseUp"))if(t.onCellMouseUp(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let o=0,i=0,r=!1;for(const n of this.plugins){const s=n.getHorizontalScrollOffsets?.(e,t);s&&(o+=s.left,i+=s.right,s.skipScroll&&(r=!0))}return{left:o,right:i,skipScroll:r}}getToolPanels(){const e=[];for(const t of this.plugins){const o=t.getToolPanel?.();o&&e.push({plugin:t,panel:o})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const o=t.getHeaderContent?.();o&&e.push({plugin:t,content:o})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}}class qt extends HTMLElement{static tagName="tbw-grid";static version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";static#q=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#$(){return this}#F=!1;#i;#r;#W=[];get#p(){return this.#V?.effective??{}}#B=!1;#U=!1;#G={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#j;#Y=0;#X=null;#K=!1;#Z=!1;#Q=0;#J;#ee={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#te;#oe;#ie;#re;#ne={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#se;#le;#ae;#ce;#de;#he;get _pluginManager(){return this.#se}#ue=!1;#ge;#fe;#_;#V;#pe=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}}();#we;#be;#me;#ve=!1;#Ce=new Set;#_e=new Map;#ye;#Re=new Map;#Se=!1;_rows=[];#Ee=[];get _columns(){return this.#p.columns??[]}set _columns(e){this.#p.columns=e,this.#Ae=void 0}#Ae;get _visibleColumns(){return this.#Ae??=this._columns.filter(e=>!e.hidden)}_invalidateVisibleColumnsCache(){this.#Ae=void 0}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#ce.state}set _virtualization(e){Object.assign(this.#ce.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#V?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#V&&(this.#V.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#V?.originalColumnNodes}set __originalColumnNodes(e){this.#V&&(this.#V.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=Array.isArray(e)?e:[],o=this.#W;this.#W=t,o!==t&&this.#xe("rows")}get sourceRows(){return this.#W}set sourceRows(e){this.#W=Array.isArray(e)?e:[]}get columns(){return[...this._columns]}set columns(e){const t=this.#V?.getColumns();this.#V?.setColumns(e),t!==e&&this.#xe("columns")}get gridConfig(){return this.#p}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#V?.getGridConfig();this.#V?.setGridConfig(e),t!==e&&(this.#V.clearLightDomCache(),this.#xe("gridConfig"))}get fitMode(){return this.#p.fitMode??"stretch"}set fitMode(e){const t=this.#V?.getFitMode();this.#V?.setFitMode(e),t!==e&&this.#xe("fitMode")}get loading(){return this.#ve}set loading(e){const t=this.#ve;this.#ve=e,t!==e&&(e?(this.setAttribute("loading",""),this.setAttribute("aria-busy","true")):(this.removeAttribute("loading"),this.removeAttribute("aria-busy")),this.#Te())}setRowLoading(e,t){const o=this.#Ce.has(e);t?this.#Ce.add(e):this.#Ce.delete(e),o!==t&&this.#Pe(e,t)}setCellLoading(e,t,o){let i=this.#_e.get(e);const r=i?.has(t)??!1;o?(i||(i=new Set,this.#_e.set(e,i)),i.add(t)):(i?.delete(t),0===i?.size&&this.#_e.delete(e)),r!==o&&this.#Me(e,t,o)}isRowLoading(e){return this.#Ce.has(e)}isCellLoading(e,t){return this.#_e.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#Ce)this.#Pe(e,!1);this.#Ce.clear();for(const[e,t]of this.#_e)for(const o of t)this.#Me(e,o,!1);this.#_e.clear()}get effectiveConfig(){return this.#p}get disconnectSignal(){return this.#te||(this.#te=new AbortController),this.#te.signal}constructor(){super(),this.#He(),this.#i=new Promise(e=>this.#r=e),this.#ce=new zt(this),this.#de=new Ie(this),this.#he=new Ye(this),this.#j=new le(this),this.#j.setInitialReadyResolver(()=>this.#r?.()),this.#we=function(e,t){let o=!1;const i={get isInitialized(){return o},setInitialized(e){o=e},get isPanelOpen(){return e.isPanelOpen},get expandedSections(){return[...e.expandedSections]},openToolPanel(){if(e.isPanelOpen)return;if(0===e.toolPanels.size)return void g("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 o=t._renderRoot;ut(o,e),gt(o,e),ht(o,e,t._accordionIcons),t._emit("tool-panel-open",{sections:i.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 o=t._renderRoot;ut(o,e),gt(o,e),t._emit("tool-panel-close",{})},toggleToolPanel(){e.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(o){const i=e.toolPanels.get(o);if(!i)return void g("TBW072",`Tool panel section "${o}" not found`,t.id);if(1===e.toolPanels.size)return;const r=t._renderRoot,n=e.expandedSections.has(o);if(n){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),i.onClose?.(),e.expandedSections.delete(o),bt(r,o,!1)}else{for(const[t,i]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),i.onClose?.(),e.expandedSections.delete(t),bt(r,t,!1);const n=r.querySelector(`[data-section="${t}"] .tbw-accordion-content`);n&&(n.innerHTML="")}e.expandedSections.add(o),bt(r,o,!0),function(e,t,o){const i=t.toolPanels.get(o);if(!i?.render)return;const r=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!r)return;const n=i.render(r);n&&t.panelCleanups.set(o,n)}(r,e,o)}t._emit("tool-panel-section-toggle",{id:o,expanded:!n})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(i){e.toolPanels.has(i.id)?g("TBW073",`Tool panel "${i.id}" already registered`,t.id):(e.toolPanels.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolPanel(i){if(e.expandedSections.has(i)){const t=e.panelCleanups.get(i);t&&(t(),e.panelCleanups.delete(i)),e.expandedSections.delete(i)}e.toolPanels.delete(i),o&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(i){e.headerContents.has(i.id)?g("TBW074",`Header content "${i.id}" already registered`,t.id):(e.headerContents.set(i.id,i),o&&dt(t._renderRoot,e))},unregisterHeaderContent(o){const i=e.headerContentCleanups.get(o);i&&(i(),e.headerContentCleanups.delete(o));const r=e.headerContents.get(o);r?.onDestroy?.(),e.headerContents.delete(o);const n=t._renderRoot.querySelector(`[data-header-content="${o}"]`);n?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(i){e.toolbarContents.has(i.id)?g("TBW075",`Toolbar content "${i.id}" already registered`,t.id):(e.toolbarContents.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolbarContent(i){const r=e.toolbarContentCleanups.get(i);r&&(r(),e.toolbarContentCleanups.delete(i));const n=e.toolbarContents.get(i);n?.onDestroy&&n.onDestroy(),e.toolbarContents.delete(i),o&&t.refreshShellHeader?.()}};return i}(this.#pe,this),this.#V=new ae(this)}async#He(){await yt('@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);--tbw-icon-expand: "▶";--tbw-icon-collapse: "▼";--tbw-icon-sort-asc: "▲";--tbw-icon-sort-desc: "▼";--tbw-icon-sort-none: "⇅";--tbw-icon-submenu-arrow: "▶";--tbw-icon-drag-handle: "⋮⋮";--tbw-icon-tool-panel: "☰";--tbw-icon-filter: "";--tbw-icon-filter-active: "";--tbw-icon-print: "🖨️";--tbw-icon-expand-mask: none;--tbw-icon-collapse-mask: none;--tbw-icon-sort-asc-mask: none;--tbw-icon-sort-desc-mask: none;--tbw-icon-sort-none-mask: none;--tbw-icon-submenu-arrow-mask: none;--tbw-icon-drag-handle-mask: none;--tbw-icon-tool-panel-mask: none;--tbw-icon-filter-mask: url("data:image/svg+xml,%3Csvg viewBox=\'0 0 16 16\' width=\'12\' height=\'12\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath 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\'/%3E%3C/svg%3E");--tbw-icon-filter-active-mask: var(--tbw-icon-filter-mask);--tbw-icon-print-mask: none}}\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 [data-icon=expand]:empty:before{content:var(--tbw-icon-expand)}tbw-grid [data-icon=collapse]:empty:before{content:var(--tbw-icon-collapse)}tbw-grid [data-icon=sort-asc]:empty:before{content:var(--tbw-icon-sort-asc)}tbw-grid [data-icon=sort-desc]:empty:before{content:var(--tbw-icon-sort-desc)}tbw-grid [data-icon=sort-none]:empty:before{content:var(--tbw-icon-sort-none)}tbw-grid [data-icon=submenu-arrow]:empty:before{content:var(--tbw-icon-submenu-arrow)}tbw-grid [data-icon=drag-handle]:empty:before{content:var(--tbw-icon-drag-handle)}tbw-grid [data-icon=tool-panel]:empty:before{content:var(--tbw-icon-tool-panel)}tbw-grid [data-icon=print]:empty:before{content:var(--tbw-icon-print)}tbw-grid [data-icon=filter]:empty:before{content:var(--tbw-icon-filter)}tbw-grid [data-icon=filter-active]:empty:before{content:var(--tbw-icon-filter-active)}tbw-grid [data-icon]:empty:before{display:inline-block;vertical-align:middle;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-position:center;mask-position:center}tbw-grid [data-icon=expand]:empty:before{-webkit-mask-image:var(--tbw-icon-expand-mask);mask-image:var(--tbw-icon-expand-mask)}tbw-grid [data-icon=collapse]:empty:before{-webkit-mask-image:var(--tbw-icon-collapse-mask);mask-image:var(--tbw-icon-collapse-mask)}tbw-grid [data-icon=sort-asc]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-asc-mask);mask-image:var(--tbw-icon-sort-asc-mask)}tbw-grid [data-icon=sort-desc]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-desc-mask);mask-image:var(--tbw-icon-sort-desc-mask)}tbw-grid [data-icon=sort-none]:empty:before{-webkit-mask-image:var(--tbw-icon-sort-none-mask);mask-image:var(--tbw-icon-sort-none-mask)}tbw-grid [data-icon=submenu-arrow]:empty:before{-webkit-mask-image:var(--tbw-icon-submenu-arrow-mask);mask-image:var(--tbw-icon-submenu-arrow-mask)}tbw-grid [data-icon=drag-handle]:empty:before{-webkit-mask-image:var(--tbw-icon-drag-handle-mask);mask-image:var(--tbw-icon-drag-handle-mask)}tbw-grid [data-icon=tool-panel]:empty:before{-webkit-mask-image:var(--tbw-icon-tool-panel-mask);mask-image:var(--tbw-icon-tool-panel-mask)}tbw-grid [data-icon=print]:empty:before{-webkit-mask-image:var(--tbw-icon-print-mask);mask-image:var(--tbw-icon-print-mask)}tbw-grid [data-icon=filter]:empty:before,tbw-grid [data-icon=filter-active]:empty:before{width:var(--tbw-icon-size, 1em);height:var(--tbw-icon-size, 1em);background:currentColor}tbw-grid [data-icon=filter]:empty:before{-webkit-mask-image:var(--tbw-icon-filter-mask);mask-image:var(--tbw-icon-filter-mask)}tbw-grid [data-icon=filter-active]:empty:before{-webkit-mask-image:var(--tbw-icon-filter-active-mask);mask-image:var(--tbw-icon-filter-active-mask)}.tbw-context-menu [data-icon]:empty:before{display:inline-block;width:1em;height:1em;vertical-align:middle}.tbw-context-menu [data-icon=submenu-arrow]:empty:before{content:var(--tbw-icon-submenu-arrow, "▶")}}\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)}@media(hover:hover){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.#se?.getPlugin(e)}getPluginByName(e){return this.#se?.getPluginByName(e)}requestRender(){this.#j.requestPhase(se.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#j.requestPhase(se.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#j.requestPhase(se.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){C(this)}requestAfterRender(){this.#j.requestPhase(se.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this._virtualization.start=-1,this.refreshVirtualWindow(!1)}#ke(){this.#se=new Nt(this);const e=this.#p?.plugins,t=Array.isArray(e)?e:[],o=this.#p?.features;let i=[];o&&De&&(i=De(o));const r=i.length>0?[...i,...t]:t;this.#se.attachAll(r)}#Le(){!function(e){let t=!1;for(const{name:o,styles:i}of e)Ct.has(o)||(Ct.set(o,i),t=!0);t&&_t()}(this.#se?.getPluginStyles()??[])}#Oe(){const e=this.#p?.plugins,t=Array.isArray(e)?e:[],o=this.#p?.features??void 0,i=o!==this.#ae;if((this.#le===t||void 0!==this.#le&&this.#le.length===t.length&&this.#le.every((e,o)=>e===t[o]))&&!i)return void(this.#le=t);this.#se&&this.#se.detachAll();for(const n of this.#pe.toolPanels.keys()){const e=this.#pe.lightDomToolPanelIds.has(n),t=this.#pe.apiToolPanelIds.has(n);if(!e&&!t){const e=this.#pe.panelCleanups.get(n);e&&(e(),this.#pe.panelCleanups.delete(n)),this.#pe.toolPanels.delete(n)}}for(const n of this.#pe.headerContents.keys()){if(this.#pe.apiHeaderContentIds.has(n))continue;const e=this.#pe.headerContentCleanups.get(n);e&&(e(),this.#pe.headerContentCleanups.delete(n)),this.#pe.headerContents.delete(n)}this.#ke(),this.#Le(),this.#le=t,this.#ae=o,this.#De(),this.#Ie();const r=this.#K;if(this.#K=this.#se?.getAll().some(e=>e.onScroll)??!1,!r&&this.#K){const e=this.#$.querySelector(".tbw-grid-content")??this.#$.querySelector(".tbw-grid-root");this.#ze(e)}}#Ne(){this.#se?.detachAll()}#Ie(){if(!this.#se)return;const e=this.#se.getToolPanels();for(const{panel:o}of e)this.#pe.toolPanels.has(o.id)||this.#pe.toolPanels.set(o.id,o);const t=this.#se.getHeaderContents();for(const{content:o}of t)this.#pe.headerContents.has(o.id)||this.#pe.headerContents.set(o.id,o)}#qe(){const e=qt.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return o=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",qt.version),this.id||(this.id="tbw-grid-"+ ++qt.#q),this._rows=Array.isArray(this.#W)?[...this.#W]:[],this.#te&&(this.#te.abort(),this.#ue=!1),this.#te=new AbortController,this.#re&&(Ne(this.#re),this.#re=void 0),this.#$e(),this.#V.parseLightDomColumns(this),this.#V.merge(),this.#ke();const e=this.#p?.plugins;var t,o;this.#le=Array.isArray(e)?e:[],this.#ae=this.#p?.features??void 0,this.#Ie(),this.#F||(this.#Fe(),this.#Le(),this.#F=!0),this.#We(),this.#re=(t=()=>{this.#Ve()},o={timeout:100},ze?requestIdleCallback(t,o):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#re&&(Ne(this.#re),this.#re=void 0),this.#Q&&(clearTimeout(this.#Q),this.#Q=0),this.#Ne(),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 o=e.toolPanels.get(t);o?.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.#pe),this.#we.setInitialized(!1),this.#be?.(),this.#be=void 0,this.#me?.(),this.#me=void 0,St(this.#ee),this.#te&&(this.#te.abort(),this.#te=void 0),this.#ge?.abort(),this.#ge=void 0,this.#ue=!1,this._resizeController&&this._resizeController.dispose(),this.#oe&&(this.#oe.disconnect(),this.#oe=void 0),this.#ie&&(this.#ie.disconnect(),this.#ie=void 0,this.#Be=!1),Se(this),this.#Ue.clear(),this._virtualization.heightCache?.byKey.clear(),this.#le=void 0,this.#ae=void 0;for(let e=0;e<this._rowPool.length;e++)this._rowPool[e].remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#B=!1}attributeChangedCallback(e,t,o){if("loading"===e){const e=null!==o&&"false"!==o;return void(this.loading!==e&&(this.loading=e))}if(t!==o&&o&&"null"!==o&&"undefined"!==o)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(o);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{g("TBW130",`Invalid JSON for '${e}' attribute: ${o}`,this.id)}else"fit-mode"===e&&(this.fitMode=o)}#We(){const e=this.#$.querySelector(".tbw-grid-content")??this.#$.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.#we.isInitialized){dt(this.#$,this.#pe),ct(this.#$,this.#p?.shell,this.#pe);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#pe.toolPanels.has(e)&&(this.openToolPanel(),this.#pe.expandedSections.add(e)),this.#pe.isPanelOpen&&(gt(this.#$,this.#pe),ht(this.#$,this.#pe,(this.#p,this.#p)),ut(this.#$,this.#pe))}if(this.setAttribute("data-upgraded",""),this.#B=!0,this._resizeController=$e(this),this.#Ge(),this.#ze(e),this.#ue)return;this.#ue=!0;const t=this.disconnectSignal;Oe(this,this,this.#$,t),this.#De(),queueMicrotask(()=>this.#je()),this.#j.requestPhase(se.FULL,"afterConnect")}#De(){const e=this.#p.rowHeight,t=this.#se.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.#ce.initializePositionCache(),"function"!=typeof e&&(this.#Z=!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.#Ye())}#Ye(){if(this.#se.hasRowHeightPlugin())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;if(e.style.getPropertyValue("--tbw-row-height"))return;const t=this.#Xe(),o=e.querySelectorAll(".cell");let i=0;o.forEach(e=>{const t=e.offsetHeight;t>i&&(i=t)});const r=e.getBoundingClientRect(),n=Math.max(r.height,i),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.#j.requestPhase(se.VIRTUALIZATION,"measureRowHeight"))}#Xe(){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 o=parseFloat(getComputedStyle(t).minHeight);return o>0?o:0}#Ke(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let o=0;t.forEach(e=>{const t=e.offsetHeight;t>o&&(o=t)});const i=e.getBoundingClientRect(),r=Math.max(i.height,o);if(r>0){if(Math.abs(r-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=r),this.#ce.initializePositionCache(),this._virtualization.totalHeightEl){const e=this.#ce.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#ze(e){this.#ge?.abort(),this.#ge=new AbortController;const t=this.#ge.signal,o=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=o??this,this.#K=this.#se?.getAll().some(e=>e.onScroll)??!1,o&&i){o.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#K)return;const e=o.scrollTop,t=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)i.style.transform=`translateY(${-e}px)`;else{const o=this._virtualization.positionCache;let r,n;if(this._virtualization.variableHeights&&o&&o.length>0){r=Dt(o,e),-1===r&&(r=0);const i=r-r%2;n=o[i]?.offset??i*t}else{r=Math.floor(e/t);n=(r-r%2)*t}const s=-(e-n);i.style.transform=`translateY(${s}px)`}this.#X=e,this.#Y||(this.#Y=requestAnimationFrame(()=>{this.#Y=0,null!==this.#X&&(this.#Ze(this.#X),this.#X=null)}))},{passive:!0,signal:t});const e=this.#$.querySelector(".tbw-scroll-area");this.#fe=e,this._virtualization.scrollAreaEl=e,e&&this.#K&&e.addEventListener("scroll",()=>{const t=this.#ne;t.scrollTop=o.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=o.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=o.clientHeight,t.clientWidth=e.clientWidth,this.#se?.onScroll(t)},{passive:!0,signal:t});const r=this.#$.querySelector(".tbw-grid-content"),n=this.#fe;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:o,scrollWidth:i,clientWidth:r}=n;(t>0&&o<i-r||t<0&&o>0)&&(e.preventDefault(),n.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:i,clientHeight:r}=o;(e.deltaY>0&&t<i-r||e.deltaY<0&&t>0)&&(e.preventDefault(),o.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),At(r,this.#ee,{fauxScrollbar:o,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 o=e.target;o.draggable||o.closest('[draggable="true"]')||e.preventDefault(),ke(r,t)},{signal:s}),n.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&xe(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&&xe(r,e,t)},{signal:s})),this.#oe?.disconnect(),this._virtualization.viewportEl&&(this.#oe=new ResizeObserver(()=>{this.#Qe(),this.#j.requestPhase(se.VIRTUALIZATION,"resize-observer")}),this.#oe.observe(this._virtualization.viewportEl)),this.#$.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#$.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#$.contains(t)||this.#de.isInExternalFocusContainer(t))||delete this.dataset.hasFocus},{signal:t})}#Be=!1;#Je(){if(this.#Be)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#Be=!0,this.#ie?.disconnect(),this.#ie=new ResizeObserver(()=>{this.#Ye()}),this.#ie.observe(e))}addEventListener(e,t,o){super.addEventListener(e,t,o)}removeEventListener(e,t,o){super.removeEventListener(e,t,o)}on(e,t){const o=e=>{t(e.detail,e)};return this.addEventListener(e,o),()=>this.removeEventListener(e,o)}#et(e,t){this.#B&&this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#et("data-change",{rowCount:this._rows.length,sourceRowCount:this.#W.length}),function(e,t,o){if(o===t.lastAnnouncedSourceCount)return;const i=t.lastAnnouncedSourceCount;t.lastAnnouncedSourceCount=o,0===o&&i<0||n(e,s(e,"dataLoaded",o))}(this,this.#tt,this.#W.length)}#je(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const o=t===this._focusRow;e.setAttribute("aria-selected",String(o)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(o&&t===this._focusCol))})})}#xe(e){this.#G[e]=!0,this.#U||(this.#U=!0,queueMicrotask(()=>this.#ot()))}#ot(){if(!this.#U||!this.#B)return void(this.#U=!1);const e=this.#G;if(this.#U=!1,this.#G={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig)return this.#it(),void(e.rows&&this.#rt());e.columns&&this.#nt(),e.rows&&this.#rt(),e.fitMode&&this.#st()}#rt(){this._rows=Array.isArray(this.#W)?[...this.#W]:[],this.#Se=!0,this.#j.requestPhase(se.ROWS,"applyRowsUpdate")}#lt(){this.#Se&&this._rebuildRowIdMap()}_rebuildRowIdMap(){this.#Se=!1,this.#Re.clear();const e=this.#p.getRowId;for(let t=0;t<this._rows.length;t++){const o=Ge(this._rows[t],e);void 0!==o&&this.#Re.set(o,{row:this._rows[t],index:t})}}#nt(){Se(this),this.#V.merge(),this.#Ge()}#st(){this.#V.merge();if("fixed"===this.#p.fitMode)this.__didInitialAutoSize=!1,b(this);else{for(let e=0;e<this._columns.length;e++){const t=this._columns[e];!t.__userResized&&t.__autoSized&&delete t.width}C(this)}}#it(){st(this,this.#pe),lt(this,this.#pe);const e=!!this.#$.querySelector(".has-shell"),t=!!this.#$.querySelector(".tbw-tool-panel"),o=this.#$.querySelectorAll(".tbw-accordion-section").length,i=this.#$.querySelector(".tbw-tool-panel")?.dataset.position??"right";this.#V.parseLightDomColumns(this),this.#V.merge(),this.#Oe(),this.#De(),at(this,this.#pe,this.#qe()),this.#V.markSourcesChanged(),this.#V.merge();const r=nt(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!==o||t&&i!==l)return ft(this.#pe),this.#Fe(),this.#Le(),this.#We(),void this._rebuildRowIdMap();e&&this.#at(),this.#pe.isPanelOpen&&ht(this.#$,this.#pe,(this.#p,this.#p)),this._rebuildRowIdMap(),this.#j.requestPhase(se.COLUMNS,"applyGridConfigUpdate")}#at(){const e=this.#$.querySelector(".tbw-shell-header");if(!e)return;const t=this.#p.shell?.header?.title??this.#pe.lightDomTitle;let o=e.querySelector(".tbw-shell-title");t?(o||(o=document.createElement("h2"),o.className="tbw-shell-title",o.setAttribute("part","shell-title"),e.insertBefore(o,e.firstChild)),o.textContent=t):o&&o.remove()}#ct(){if(this.__rowRenderEpoch++,this.#se){const e=this.#Ee.length>0?this.#Ee:this._columns,t=e.filter(e=>!e.hidden),o=e.filter(e=>e.hidden),i=this.#se.processColumns([...t]);if(i!==t){const r=new Set(i.map(e=>e.field));!t.some(e=>r.has(e.field))&&i.length>0?this._columns=[...i,...o]:this._columns=this.#dt(e,i,o)}else this._columns=[...e]}}#dt(e,t,o){if(0===o.length)return t;const i=new Map;for(const l of t)i.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=i.get(l.field);e?s.push(e):l.hidden&&s.push(l)}return s.push(...n),s}#ht(){Se(this);const e=this.#W;if(!Array.isArray(e))return this._rows=[],this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#ce.initializePositionCache(),void this._emitDataChange();if(!this._sortState&&this.#p.initialSort){const{field:e,direction:t}=this.#p.initialSort;this._columns.find(t=>t.field===e)&&(this._sortState={field:e,direction:"desc"===t?-1:1})}this._sortState&&(this.__originalOrder=this._rows);const t=function(e,t,o=!1){if(!e._sortState)return t;const i=e.effectiveConfig?.sortHandler??V;if(i===V)return o||(e.__originalOrder=t.slice()),j(t,e._sortState.field,e._sortState.direction,e._columns),t;o||(e.__originalOrder=t);const r=i(t,e._sortState,e._columns);return r&&"function"==typeof r.then?t:r}(this,this._sortState?[...e]:e,!0),o=this.#se?.processRows(t)??t;this._rows=o,this._rebuildRowIdMap(),this._emitDataChange()}#ut(e){const t={...i,...e.animation},o=t.mode??"reduced-motion";let r=1;!1===o||"off"===o?r=0:!0!==o&&"on"!==o||(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 o?o?"on":"off":o}_renderVisibleRows(e,t,o=this.__rowRenderEpoch){if(this.#J||(this.#J=(e,t,o)=>this.#se?.renderRow(e,t,o)??!1),function(e,t,o,i,r){const n=Math.max(0,o-t),s=e._bodyEl,l=e._visibleColumns,a=l.length;let c=e.__cachedHeaderRowCount;for(void 0===c&&(c=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=c);e._rowPool.length<n;){const t=Re();e._rowPool.push(t)}if(e._rowPool.length>n){const t=e.__frameworkAdapter,o=t?.releaseCell;for(let i=n;i<e._rowPool.length;i++){const r=e._rowPool[i];if(o){const e=r.children;for(let i=0;i<e.length;i++){const r=e[i];r.firstElementChild&&o.call(t,r)}}r.parentNode===s&&r.remove()}e._rowPool.length=n}const d=r&&!1!==e.__hasRenderRowPlugins,h=e._hasAfterRowRenderHook?.()??!1,u=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let p=0;p<n;p++){const o=t+p,n=e._rows[o],w=e._rowPool[p];if(w.setAttribute("aria-rowindex",String(o+c+1)),d&&r(n,w,o)){w.__epoch=i,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===i&&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=me(w),r=y&&!_||e._activeEditRows===o;t&&!r?(w.__isCustomRow&&(w.className="data-grid-row",w.setAttribute("role","row"),w.__isCustomRow=!1),ve(w),Ae(e,w,n,o),w.__epoch=i,w.__rowDataRef=n):t&&r?(Ee(e,w,n,o),w.__rowDataRef=n):(w.__isCustomRow&&(w.className="data-grid-row",w.setAttribute("role","row"),w.__isCustomRow=!1),Ae(e,w,n,o),w.__epoch=i,w.__rowDataRef=n)}else if(_){const t=me(w),r=e._activeEditRows===o;t&&!r?(ve(w),Ae(e,w,n,o),w.__epoch=i,w.__rowDataRef=n):(Ee(e,w,n,o),w.__rowDataRef=n)}else{const t=me(w),r=y||e._activeEditRows===o;t&&!r?(ve(w),Ae(e,w,n,o),w.__epoch=i,w.__rowDataRef=n):Ee(e,w,n,o)}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 A=e.effectiveConfig?.rowClass;if(A){const t=w.getAttribute("data-dynamic-classes");if(t){const e=t.split(" ");for(let t=0;t<e.length;t++)e[t]&&w.classList.remove(e[t])}try{const e=A(n),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(let o=0;o<t.length;o++){const i=t[o];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){g("TBW060",`rowClass callback error: ${f}`,e.id),w.removeAttribute("data-dynamic-classes")}}if(u){const e=u(n,o);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:o,rowElement:w}),w.parentNode!==s&&s.appendChild(w)}}(this,e,t,o,this.#J),this.#Ce.size>0)for(const i of this.#Ce)this.#Pe(i,!0)}#tt={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaDescribedBy:void 0,lastAnnouncedSourceCount:-1};_updateAriaCounts(e,t){!function(e,t,o,i,r){if(i===e.rowCount&&r===e.colCount)return!1;const n=e.rowCount;e.rowCount=i,e.colCount=r,t&&(t.setAttribute("aria-rowcount",String(i)),t.setAttribute("aria-colcount",String(r))),i!==n&&o&&(i>0?o.setAttribute("role","rowgroup"):o.removeAttribute("role"))}(this.#tt,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#j.requestPhase(e,t)}_getPluginRowHeight(e,t){return this.#se?.getRowHeight?.(e,t)}_adjustPluginVirtualStart(e,t,o){return this.#se?.adjustVirtualStart(e,t,o)}_afterPluginRender(){this.#se?.afterRender()}_emitPluginEvent(e,t){this.#se?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#V.parseLightDomColumns(this),this.#V.merge(),this.#Oe(),function(e,t,o){const i=xt,r=Tt,n=new Map;function s(e,t,o,i,r=!1){n.has(e)||n.set(e,{description:t,importHint:o,fields:[],isConfigProperty:r});const s=n.get(e);s.fields.includes(i)||s.fields.push(i)}for(const a of r){const o=e[a.property];if((a.isUsed?a.isUsed(o):void 0!==o)&&!Ht(t,a.pluginName)){const e=a.description||`the "${a.property}" ${a.level} property`;s(a.pluginName,e,Pt(a.pluginName),a.property,!0)}}const l=e.columns;if(l&&l.length>0)for(const a of l)for(const e of i){const o=a[e.property];if((e.isUsed?e.isUsed(o):void 0!==o)&&!Ht(t,e.pluginName)){const t=a.field||"<unknown>",o=e.description||`the "${e.property}" ${e.level} property`;s(e.pluginName,o,Pt(e.pluginName),t)}}if(n.size>0){const e=[];for(const[t,{description:o,importHint:i,fields:r,isConfigProperty:s}]of n)if(s)e.push(`Config uses ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${Mt(t)}Plugin(), ...]`);else{const n=r.slice(0,3).join(", ")+(r.length>3?`, ... (${r.length} total)`:"");e.push(`Column(s) [${n}] use ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${Mt(t)}Plugin(), ...]`)}u([...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.`,o)}}(this.#p,this.#se?.getPlugins()??[],this.id),function(e,t){const o=[],i=[];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=`[${Mt(r.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?o.push(e):i.push(e)}}}if(i.length>0&&ce())for(const r of i)g("TBW004",r,t);o.length>0&&u("TBW003",`Configuration error:\n\n${o.join("\n\n")}`,t)}(this.#se?.getPlugins()??[],this.id),function(e,t){if(!ce())return;const o=new Set(e.map(e=>e.name)),i=new Set;for(const r of e){const e=r.constructor.manifest;if(e?.incompatibleWith)for(const n of e.incompatibleWith)if(o.has(n.name)){const e=[r.name,n.name].sort().join("↔");if(i.has(e))continue;i.add(e),g("TBW022",`${Mt(r.name)}Plugin and ${Mt(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.#se?.getPlugins()??[],this.id),this.#gt(),this.#Ee=[...this._columns]}_schedulerProcessColumns(){this.#ct()}_schedulerProcessRows(){this.#ht()}_schedulerRenderHeader(){re(this)}_schedulerUpdateTemplate(){C(this)}_schedulerAfterRender(){this.#se?.afterRender(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#ce.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,Me(this)),this._virtualization.enabled&&!this.#Be&&this.#Je(),this.#Z&&(this.#Z=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#Ke()})})),this.#ve&&this.#Te()}get _schedulerIsConnected(){return this.isConnected&&this.#B}get _hostElement(){return this}get _renderRoot(){return this.#$}_emit(e,t){this.#et(e,t)}get _accordionIcons(){return{expand:this.#p?.icons?.expand??r.expand,collapse:this.#p?.icons?.collapse??r.collapse}}get _shellState(){return this.#pe}_clearRowPool(){const e=this.__frameworkAdapter,t=e?.releaseCell;if(t)for(let o=0;o<this._rowPool.length;o++){const i=this._rowPool[o].children;for(let o=0;o<i.length;o++){const r=i[o];r.firstElementChild&&t.call(e,r)}}this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++}_setup(){this.#Ge()}_applyAnimationConfig(e){this.#ut(e)}#gt(){!function(e,t,o,i){if(!t)return!1;let r=!1;const n=function(e,t){const o=e?.gridAriaLabel;return o||(e?.shell?.header?.title??t?.lightDomTitle??void 0)}(o,i);n!==e.ariaLabel&&(e.ariaLabel=n,n?t.setAttribute("aria-label",n):t.removeAttribute("aria-label"),r=!0);const s=o?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),r=!0)}(this.#tt,this.__rowsBodyEl,this.#p,this.#pe)}#Te(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#ve?(this.#ye||(this.#ye=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(qe("large",e)),t}(this.#p?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#ye)):(t=this.#ye,t?.remove()))}#Pe(e,t){this.#lt();const o=this.#Re.get(e);if(!o)return;const i=this.findRenderedRowElement?.(o.index);i&&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 o=document.createElement("div");o.className="tbw-row-loading-spinner",t.appendChild(o),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}(i,t)}#Me(e,t,o){this.#lt();const i=this.#Re.get(e);if(!i)return;const r=this.findRenderedRowElement?.(i.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,o)}#Ge(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#V.parseLightDomColumns(this),this.#_){const e=this.#_;this.#_=void 0,this.#V.merge();const t=this.#se?.getAll()??[];this.#V.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#j.requestPhase(se.FULL,"setup")}}#Ze(e){const t=this._virtualization.container,o=this.#fe,i=o?.scrollLeft??0,r=t?.scrollHeight??0,n=o?.scrollWidth??0,s=t?.clientHeight??0,l=o?.clientWidth??0;if(this.refreshVirtualWindow(!1)&&this.#se?.onScrollRender(),this._virtualization.variableHeights&&(this.#Q&&clearTimeout(this.#Q),this.#Q=window.setTimeout(()=>{this.#Q=0,this.#ce.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#K){const t=this.#ne;t.scrollTop=e,t.scrollLeft=i,t.scrollHeight=r,t.scrollWidth=n,t.clientHeight=s,t.clientWidth=l,this.#se?.onScroll(t)}this.#et("tbw-scroll",{scrollTop:e,scrollHeight:r,clientHeight:s,direction:"vertical"})}findHeaderRow(){return this.#$.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,o=e-t.start;return o>=0&&o<this._rowPool.length&&o<t.end-t.start?this._rowPool[o]:null}_dispatchCellClick(e,t,o,i){const r=this._rows[t],n=this._visibleColumns[o];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:o,column:n,field:s,value:l,row:r,cellEl:i,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const c={row:r,rowIndex:t,colIndex:o,column:n,field:s,value:l,cellEl:i,originalEvent:e},d=this.#se?.onCellClick(c)??!1;return this.#et("cell-click",c),d}_dispatchRowClick(e,t,o,i){if(!o)return!1;const r={rowIndex:t,row:o,rowEl:i,originalEvent:e},n=this.#se?.onRowClick(r)??!1;return this.#et("row-click",r),n}_dispatchHeaderClick(e,t,o){if(!t)return!1;const i={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:o,originalEvent:e};return this.#se?.onHeaderClick(i)??!1}_dispatchKeyDown(e){return this.#se?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#se?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}query(e,t){return this.#se?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#se?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#se?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#se?.onCellMouseUp(e)}_afterCellRender(e){this.#se?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#se?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#se?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#se?.hasAfterRowRenderHook()??!1}async ready(){return this.#i}async forceLayout(){return 0===this.#j.pendingPhase&&this.#j.requestPhase(se.FULL,"forceLayout"),this.#j.whenReady()}async getConfig(){return Object.freeze({...this.#p||{}})}getRowId(e){return je(e,this.id,this.#p.getRowId)}getRow(e){return this.#he.getRow(e)}_getRowEntry(e){return this.#lt(),this.#Re.get(e)}updateRow(e,t,o="api"){this.#he.updateRow(e,t,o)}updateRows(e,t="api"){this.#he.updateRows(e,t)}animateRow(e,t){return Ue(this,e,t)}animateRows(e,t){return function(e,t,o){return Promise.all(t.map(t=>Ue(e,t,o))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,o){const i=e._rows??[],r=e.getRowId;if(!r)return Promise.resolve(!1);const n=i.findIndex(e=>{if(null==e)return!1;try{return r(e)===t}catch{return!1}});return n<0?Promise.resolve(!1):Ue(e,n,o)}(this,e,t)}async insertRow(e,t,o=!0){return this.#he.insertRow(e,t,o)}async removeRow(e,t=!0){return this.#he.removeRow(e,t)}async applyTransaction(e,t=!0){return this.#he.applyTransaction(e,t)}applyTransactionAsync(e){return this.#he.applyTransactionAsync(e)}focusCell(e,t){this.#de.focusCell(e,t)}get focusedCell(){return this.#de.focusedCell}scrollToRow(e,t){this.#de.scrollToRow(e,t)}scrollToRowById(e,t){this.#de.scrollToRowById(e,t)}setColumnVisible(e,t){const o=this.#V.setColumnVisible(e,t);return o&&this.requestStateChange(),o}toggleColumnVisibility(e){const t=this.#V.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#V.isColumnVisible(e)}showAllColumns(){this.#V.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#V.getAllColumns()}setColumnOrder(e){this.#V.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#V.getColumnOrder()}getColumnState(){const e=this.#se?.getAll()??[];return this.#V.collectState(e)}get columnState(){return this.getColumnState()}applyColumnState(e){e&&(this.#F?this.#ft(e):(this.#_=e,this.#V.initialColumnState=e))}#ft(e){const t=this._columns,o=this._sortState,i=this.#se?.getAll()??[];this.#V.applyState(e,i);if(!e.columns.some(e=>void 0!==e.sort)&&this.#pt(t,o))return this.#Ae=void 0,C(this),void this.#j.requestPhase(se.STYLE,"column-width");this.#Ge()}#pt(e,t){const o=this._columns,i=this._sortState;if(t?.field!==i?.field||t?.direction!==i?.direction)return!1;if(e.length!==o.length)return!1;for(let r=0;r<e.length;r++){const t=e[r],i=o[r];if(t.field!==i.field)return!1;if(!!t.hidden!=!!i.hidden)return!1}return!0}get sortModel(){return this._sortState?{field:this._sortState.field,direction:1===this._sortState.direction?"asc":"desc"}:null}sort(e,t){if(null===e){if(!this._sortState)return;const e=this._sortState.field;this._sortState=null,this.__rowRenderEpoch++;for(let t=0;t<this._rowPool.length;t++)this._rowPool[t].__epoch=-1;return this._rows=this.__originalOrder.slice(),this.__originalOrder=[],re(this),this.refreshVirtualWindow(!0),this.dispatchEvent(new CustomEvent("sort-change",{detail:{field:e,direction:0}})),this._pluginManager?.emitPluginEvent?.("sort-change",{field:e,direction:0}),void this.requestStateChange?.()}const o=this._columns.find(t=>t.field===e);o&&(t?(this._sortState||(this.__originalOrder=this._rows.slice()),Q(this,o,"desc"===t?-1:1)):Z(this,o))}requestStateChange(){const e=this.#se?.getAll()??[];this.#V.requestStateChange(e)}resetColumnState(){this.#_=void 0,this.__originalOrder=[];const e=this.#se?.getAll()??[];this.#V.resetState(e),this.#V.merge(),this.#Ge()}get isToolPanelOpen(){return this.#we.isPanelOpen}get defaultRowHeight(){return this._virtualization.rowHeight}get expandedToolPanelSections(){return this.#we.expandedSections}openToolPanel(){this.#we.openToolPanel()}closeToolPanel(){this.#we.closeToolPanel()}toggleToolPanel(){this.#we.toggleToolPanel()}toggleToolPanelSection(e){this.#we.toggleToolPanelSection(e)}getToolPanels(){return this.#we.getToolPanels()}registerToolPanel(e){this.#pe.apiToolPanelIds.add(e.id),this.#we.registerToolPanel(e)}unregisterToolPanel(e){this.#pe.apiToolPanelIds.delete(e),this.#we.unregisterToolPanel(e)}getHeaderContents(){return this.#we.getHeaderContents()}registerHeaderContent(e){this.#pe.apiHeaderContentIds.add(e.id),this.#we.registerHeaderContent(e)}unregisterHeaderContent(e){this.#pe.apiHeaderContentIds.delete(e),this.#we.unregisterHeaderContent(e)}getToolbarContents(){return this.#we.getToolbarContents()}registerToolbarContent(e){this.#we.registerToolbarContent(e)}unregisterToolbarContent(e){this.#we.unregisterToolbarContent(e)}#wt=!1;refreshShellHeader(){this.#wt||(this.#wt=!0,queueMicrotask(()=>{if(this.#wt=!1,!this.isConnected)return;this.#$e(),this.#V.markSourcesChanged(),this.#V.merge(),ft(this.#pe);(function(e,t,o,i){const r=e.querySelector(`.${_.ROOT}`),n=r?.querySelector(".tbw-grid-content");if(!r||!n)return wt(e,t,o,i);n.remove();const s=nt(t);if(r.replaceChildren(),s){r.className=`${_.ROOT} has-shell`;const{headerOptions:e,bodyOptions:s}=pt(t,o,i),l=ot(e),a=it(s),c=a.querySelector(".tbw-grid-content");c&&c.replaceWith(n),r.appendChild(l),r.appendChild(a)}else r.className=_.ROOT,r.appendChild(n);return s})(this.#$,this.#p?.shell,{isPanelOpen:this.#pe.isPanelOpen,expandedSections:this.#pe.expandedSections},this.#p?.icons)&&(this.#bt(),this.#we.setInitialized(!0)),this.#mt()}))}#mt(){const e=this.#$.querySelector(".tbw-grid-content")??this.#$.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.#we.isInitialized){dt(this.#$,this.#pe),ct(this.#$,this.#p?.shell,this.#pe);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#pe.toolPanels.has(e)&&(this.openToolPanel(),this.#pe.expandedSections.add(e)),this.#pe.isPanelOpen&&(gt(this.#$,this.#pe),ht(this.#$,this.#pe,(this.#p,this.#p)),ut(this.#$,this.#pe))}this._resizeController=$e(this),this.#ze(e),this.#j.requestPhase(se.COLUMNS,"shellRefresh")}#Ue=new Map;registerStyles(e,t){let o=this.#Ue.get(e);o||(o=new CSSStyleSheet,this.#Ue.set(e,o)),o.replaceSync(t),this.#vt()}unregisterStyles(e){this.#Ue.delete(e)&&this.#vt()}getRegisteredStyles(){return Array.from(this.#Ue.keys())}#vt(){const e=Array.from(this.#Ue.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#Ue.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#de.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#de.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#de.containsFocus(e)}#$e(){st(this,this.#pe),lt(this,this.#pe),at(this,this.#pe,this.#qe())}#Ct(){const e=this.#$.querySelector(".tbw-shell-header");if(!e)return;ft(this.#pe);const t=function(e,t,o){const i=e?.header?.title??t.lightDomTitle??"",r=!!i;let n="";void 0!==o&&(n="string"==typeof o?L(o):o.outerHTML);const s=e?.header?.toolbarContents??[],l=[...t.toolbarContents.values()],a=new Set(s.map(e=>e.id)),c=[...s];for(const w of l)a.has(w.id)||c.push(w);const d=c.length>0,h=t.toolPanels.size>0,u=d&&h,g=[...c].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 data-icon="tool-panel" 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=i,p&&"string"==typeof p?p.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):""}</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.#pe,this.#p.icons?.toolPanel),o=document.createElement("div");o.innerHTML=t;const i=o.firstElementChild;i&&(e.replaceWith(i),this.#bt(),ct(this.#$,this.#p?.shell,this.#pe))}#Ve(){const e=()=>{const e=this.#pe.lightDomTitle,t=this.#pe.hasToolButtonsContainer;this.#$e();const o=this.#pe.lightDomTitle,i=this.#pe.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#V.markSourcesChanged(),this.#V.merge(),this.#Ct())},t=()=>{this.__lightDomColumnsCache=void 0,this.#Ge()};this.#V.registerLightDomHandler("tbw-grid-header",e),this.#V.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#V.registerLightDomHandler("tbw-grid-tool-panel",e),this.#V.registerLightDomHandler("tbw-grid-column",t),this.#V.registerLightDomHandler("tbw-grid-detail",t),this.#V.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,Se(this),this.#V.parseLightDomColumns(this);const e=this.#pe.lightDomTitle,t=this.#pe.hasToolButtonsContainer;this.#$e();const o=this.#pe.lightDomTitle,i=this.#pe.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#V.markSourcesChanged(),this.#V.merge(),this.#Ct()),this.#j.requestPhase(se.COLUMNS,"refreshColumns")}#Qe(){this.#ce.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#ce.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#ce.invalidateRowHeight(e,t)}#Fe(){this.#$e(),this.#V.markSourcesChanged(),this.#V.merge();const e=this.#p?.shell;wt(this.#$,e,{isPanelOpen:this.#pe.isPanelOpen,expandedSections:this.#pe.expandedSections},this.#p?.icons)&&(this.#bt(),this.#we.setInitialized(!0))}#bt(){!function(e,t,o,i){const r=e.querySelector(".tbw-shell-toolbar");r&&r.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&i.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]"),o=e?.getAttribute("data-section");o&&i.onSectionToggle(o)}})}(this.#$,this.#p,this.#pe,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#be?.(),this.#be=function(e,t,o){const i=e.querySelector(".tbw-tool-panel"),r=e.querySelector("[data-resize-handle]"),n=e.querySelector(".tbw-shell-body");if(!i||!r||!n)return()=>{};const s=t?.toolPanel?.position??"right";let l=0,a=0,c=0,d=!1;const h=e=>{if(!d)return;e.preventDefault();const t="left"===s?e.clientX-l:l-e.clientX,o=Math.min(c,Math.max(200,a+t));i.style.width=`${o}px`},u=()=>{if(!d)return;d=!1,r.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=i.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)},g=e=>{e.preventDefault(),d=!0,l=e.clientX,a=i.getBoundingClientRect().width,c=n.getBoundingClientRect().width-20,r.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)};return r.addEventListener("mousedown",g),()=>{r.removeEventListener("mousedown",g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}}(this.#$,this.#p?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)}),this.#me?.(),this.#me=function(e,t,o,i){if(!t?.toolPanel?.closeOnClickOutside)return()=>{};const r=e=>{if(!o.isPanelOpen)return;const t=e.target;t&&(t.closest(".tbw-tool-panel")||t.closest("[data-panel-toggle]")||i())};return e.addEventListener("mousedown",r),()=>e.removeEventListener("mousedown",r)}(this,this.#p?.shell,this.#pe,()=>this.closeToolPanel())}}customElements.get(qt.tagName)||customElements.define(qt.tagName,qt),globalThis.DataGridElement=qt;function $t(e,t,o){return o?.valueAccessor?F(e,o):e?.[t]}function Ft(e){return null==e||""===e||"number"==typeof e&&isNaN(e)}const Wt={sum:(e,t,o)=>{let i=0;for(let r=0;r<e.length;r++){const n=$t(e[r],t,o);if(Ft(n))continue;const s=Number(n);isNaN(s)||(i+=s)}return i},avg:(e,t,o)=>{if(!e.length)return 0;let i=0,r=0;for(let n=0;n<e.length;n++){const s=$t(e[n],t,o);if(Ft(s))continue;const l=Number(s);isNaN(l)||(i+=l,r++)}return r>0?i/r:0},count:e=>e.length,min:(e,t,o)=>{if(!e.length)return 0;let i=1/0;for(let r=0;r<e.length;r++){const n=$t(e[r],t,o);if(Ft(n))continue;const s=Number(n);isNaN(s)||s<i&&(i=s)}return i===1/0?0:i},max:(e,t,o)=>{if(!e.length)return 0;let i=-1/0;for(let r=0;r<e.length;r++){const n=$t(e[r],t,o);if(Ft(n))continue;const s=Number(n);isNaN(s)||s>i&&(i=s)}return i===-1/0?0:i},first:(e,t,o)=>e[0]?$t(e[0],t,o):void 0,last:(e,t,o)=>e.length?$t(e[e.length-1],t,o):void 0},Vt=new Map,Bt={register(e,t){Vt.set(e,t)},unregister(e){Vt.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:Vt.get(e)??Wt[e]},run(e,t,o,i){const r=this.get(e);return r?r(t,o,i):void 0},has:e=>Vt.has(e)||e in Wt,list:()=>[...Object.keys(Wt),...Vt.keys()]},Ut={sum:e=>{let t=0;for(let o=0;o<e.length;o++)t+=e[o];return t},avg:e=>{if(!e.length)return 0;let t=0;for(let o=0;o<e.length;o++)t+=e[o];return t/e.length},count:e=>e.length,min:e=>{if(!e.length)return 0;let t=e[0];for(let o=1;o<e.length;o++)e[o]<t&&(t=e[o]);return t},max:e=>{if(!e.length)return 0;let t=e[0];for(let o=1;o<e.length;o++)e[o]>t&&(t=e[o]);return t},first:e=>e[0]??0,last:e=>e[e.length-1]??0};function Gt(e){return Ut[e]??Ut.sum}e.BaseGridPlugin=class{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#_t;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},o={};for(const i of Object.keys(t))o[i]=this;for(const i of e){const e=i.userConfig;for(const[r,n]of Object.entries(e)){if(void 0===n)continue;if(!(r in t)){t[r]=n,o[r]=i;continue}if(t[r]===n)continue;const e=o[r]?.constructor.name??this.constructor.name,s=i.constructor.name,l=h("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${r}" supplied by both ${e} and ${s}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(l)}}Object.assign(this.userConfig,t)}attach(e){this.#_t?.abort(),this.#_t=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#_t?.abort(),this.#_t=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 o=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.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)}broadcast(e,t){this.emitPluginEvent(e,t),this.emit(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.#_t?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...r,...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(),o=parseInt(t,10);if(!isNaN(o))return o}return 200}setIcon(e,t,o){e.dataset.icon=q(t),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const i=this.#yt(t,o);void 0!==i?"string"==typeof i?e.innerHTML=L(i):i instanceof HTMLElement&&(e.innerHTML="",e.appendChild(i.cloneNode(!0))):e.innerHTML=""}#yt(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const o=document.createElement("span");o.setAttribute("part","sort-indicator"),o.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(o,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(o,"sortNone"));const i=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return i?e.insertBefore(o,i):e.appendChild(o),o}warn(e,t){void 0!==t?console.warn(h(e,t,this.gridElement.id,this.name)):console.warn(`${l(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(h(e,t,this.gridElement.id,this.name))}},e.CORE_CONSUMED_ADAPTER_METHODS=["canHandle","createRenderer","createEditor","processConfig","getTypeDefault","createToolPanelRenderer","parseDetailElement","parseResponsiveCardElement","releaseCell","unmount"],e.DEFAULT_A11Y_MESSAGES=o,e.DEFAULT_ANIMATION_CONFIG=i,e.DEFAULT_GRID_ICONS=r,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",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change",DATA_CHANGE:"data-change",TBW_SCROLL:"tbw-scroll"},e.DataGridElement=qt,e.FitModeEnum=t,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=_,e.GridDataAttrs=y,e.GridElement=qt,e.GridSelectors=R,e.PluginEvents={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",TREE_LOAD_START:"tree-load-start",TREE_LOAD_END:"tree-load-end",TREE_LOAD_ERROR:"tree-load-error",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=Nt,e.RenderPhase=se,e.aggregatorRegistry=Bt,e.builtInSort=V,e.createGrid=function(e){const t=document.createElement("tbw-grid");return e&&(t.gridConfig=e),t},e.defaultComparator=function(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0},e.getValueAggregator=Gt,e.invalidateAccessorCache=W,e.queryGrid=function(e,t,o){let i=document,r=!1;return"boolean"==typeof t?r=t:t&&(i=t,r=!!o),r?customElements.whenDefined(qt.tagName).then(()=>i.querySelector(e)):i.querySelector(e)},e.resolveCellValue=F,e.runValueAggregator=function(e,t){return Gt(e)(t)},e.setFeatureResolver=function(e){De=e},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=grid.umd.js.map