@toolbox-web/grid 3.10.1 → 3.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +2 -1
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/features/registry.js +1 -1
- package/lib/plugins/editing/editing-plugin.d.ts +11 -5
- package/lib/plugins/editing/index.js +2 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/internal/editor-injection.d.ts +9 -2
- package/lib/plugins/hierarchy/hierarchy.d.ts +5 -1
- package/lib/plugins/hierarchy/index.js +1 -1
- package/lib/plugins/hierarchy/index.js.map +1 -1
- package/lib/plugins/shell/index.js +1 -1
- package/lib/plugins/shell/index.js.map +1 -1
- package/lib/plugins/shell/types.d.ts +9 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +1 -1
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -1
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/hierarchy.umd.js +1 -1
- package/umd/plugins/hierarchy.umd.js.map +1 -1
- package/umd/plugins/shell.umd.js +1 -1
- package/umd/plugins/shell.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.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){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t={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`,selectAllRows:()=>"Select all rows",selectRow:e=>`Select row ${e+1}`,columnSelected:e=>`Column ${e} selected`,columnSelectionChanged:e=>`${e} columns selected`,columnSelectionCleared:()=>"Column selection cleared",selectionAxisChanged:e=>"column"===e?"Row selection cleared, column selection active":"Column selection cleared, row selection active",rangeSpanSelected:(e,t)=>1===t?("row"===e?"Row":"Column")+" selected":`${t} ${e}s selected`,editingStarted:e=>`Editing row ${e+1}`,editingCommitted:e=>`Row ${e+1} saved`,dataLoaded:e=>`${e} rows loaded`},r={mode:"reduced-motion",duration:200,easing:"ease-out"},i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function n(e,t){if(!e)return;if(!1===("effectiveConfig"in e?e.effectiveConfig:void 0)?.a11y?.announcements)return;const r=e.querySelector?.(".tbw-sr-only");r&&(r.textContent="","function"==typeof requestAnimationFrame?requestAnimationFrame(()=>{r.textContent=t}):r.textContent=t)}function o(e,r,...i){const n=(e&&"effectiveConfig"in e?e.effectiveConfig:void 0)?.a11y?.messages?.[r];return n?n(...i):t[r](...i)}function s(e){return e.charAt(0).toUpperCase()+e.slice(1)}function a(e){return"id"===e.toLowerCase()?"ID":e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").split(" ").filter(Boolean).map(s).join(" ")}var l=new Set(["string","number","boolean","date","datetime","currency"]);function c(e){const t=e.lastIndexOf(":");if(t>0){const r=e.slice(t+1).toLowerCase();if(l.has(r)){const i=e.slice(0,t);return{field:i,header:a(i),type:r}}}return{field:e,header:a(e)}}function d(e){return e.map(e=>"string"==typeof e?c(e):e)}var u={STRETCH:"stretch",FIXED:"fixed"};function h(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}var g="TBW020",f="TBW021",p="TBW041",w="TBW062";function m(e,t,r,i){return`${h(r,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function b(e,t,r,i){throw new Error(m(e,t,r,i))}function v(e,t,r,i){console.warn(m(e,t,r,i))}function y(e,t,r,i){console.debug(m(e,t,r,i))}function C(e,t,r,i){console.error(m(e,t,r,i))}function _(e,t){const r=new Map;e.forEach((e,t)=>r.set(e.field,t));const i=function(e,t){const r=[];for(const s of e){const e=t.get(s.field);void 0!==e&&r.push({field:s.field,idx:e})}const i=[],n=new Array(r.length).fill(-1);for(let s=0;s<r.length;s++){let e=0,t=i.length;for(;e<t;){const n=e+t>>1;r[i[n]].idx<r[s].idx?e=n+1:t=n}e>0&&(n[s]=i[e-1]),i[e]=s}const o=new Set;for(let s=i.length?i[i.length-1]:-1;-1!==s;s=n[s])o.add(r[s].field);return o}(t,r),n=new Set(t.map(e=>e.field)),o=[],s=new Map;let a;for(const c of e)if(i.has(c.field))a=c.field;else if(c.hidden&&!n.has(c.field))if(void 0===a)o.push(c);else{const e=s.get(a);e?e.push(c):s.set(a,[c])}const l=[];for(const c of t){o.length&&i.has(c.field)&&l.push(...o.splice(0)),l.push(c);const e=s.get(c.field);e&&l.push(...e)}return l.push(...o),l}function R(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const r={},i=t;for(let s=0;s<i.length;s++){const e=i[s],t=r[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.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.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate),e.__element&&!t.__element&&(t.__element=e.__element);const r=e.renderer||e.viewRenderer,i=t.renderer||t.viewRenderer;r&&!i&&(t.viewRenderer=r,e.renderer&&(t.renderer=r)),e.editor&&!t.editor&&(t.editor=e.editor),e.headerRenderer&&!t.headerRenderer&&(t.headerRenderer=e.headerRenderer),e.headerLabelRenderer&&!t.headerLabelRenderer&&(t.headerLabelRenderer=e.headerLabelRenderer)}else r[e.field]={...e}}const n=e.map(e=>{const t=r[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),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.__headerTemplate&&(i.__headerTemplate=t.__headerTemplate),t.__element&&!i.__element&&(i.__element=t.__element);const n=t.renderer||t.viewRenderer,o=i.renderer||i.viewRenderer;return n&&!o&&(i.viewRenderer=n,t.renderer&&(i.renderer=n)),t.editor&&!i.editor&&(i.editor=t.editor),i.headerRenderer||i.headerLabelRenderer||(t.headerRenderer?i.headerRenderer=t.headerRenderer:t.headerLabelRenderer&&(i.headerLabelRenderer=t.headerLabelRenderer)),delete r[e.field],i}),o=Object.keys(r);for(let s=0;s<o.length;s++)n.push(r[o[s]]);return n}function S(e,t){try{e.part?.add?.(t)}catch{}const r=e.getAttribute("part");r?r.split(/\s+/).includes(t)||e.setAttribute("part",r+" "+t):e.setAttribute("part",t)}function E(e){const t=e.effectiveConfig?.fitMode||e.fitMode||u.STRETCH;if(t!==u.STRETCH&&t!==u.FIXED)return;if(e.__didInitialAutoSize)return;if(!e.isConnected)return;const r=Array.from(e._headerRowEl?.children||[]);if(!r.length)return;let i=!1;const n=e._visibleColumns;for(let o=0;o<n.length;o++){const t=n[o];if(t.width)continue;const s=r[o];let a=s?s.scrollWidth:0;for(let r=0;r<e._rowPool.length;r++){const t=e._rowPool[r].children[o];if(t){const e=t.scrollWidth;e>a&&(a=e)}}a>0&&(t.width=a+2,t.__autoSized=!0,i=!0)}i&&M(e),e.__didInitialAutoSize=!0}var A=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function x(e,t){return"number"==typeof e?`${e}px`:(A.test(e)||v("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 M(e){(e.effectiveConfig?.fitMode||e.fitMode||u.STRETCH)===u.STRETCH?e._gridTemplate=e._visibleColumns.map(e=>{if(null!=e.width)return x(e.width,e.field);const t=e.minWidth;return null!=t?`minmax(${t}px, 1fr)`:"1fr"}).join(" ").trim():e._gridTemplate=e._visibleColumns.map(e=>null!=e.width?x(e.width,e.field):"max-content").join(" "),e.style.setProperty("--tbw-column-template",e._gridTemplate)}var H='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])',k={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-grid-row",GROUP_ROW:"group-row",DATA_CELL:"cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},T={FIELD:"data-field",TRUNCATED:"data-tbw-truncated",GROUP_KEY:"data-group-key"},P={ROOT:`.${k.ROOT}`,HEADER:`.${k.HEADER}`,HEADER_ROW:`.${k.HEADER_ROW}`,HEADER_CELL:`.${k.HEADER_CELL}`,ROWS_VIEWPORT:`.${k.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${k.ROWS_CONTAINER}`,DATA_ROW:`.${k.DATA_ROW}`,DATA_CELL:`.${k.DATA_CELL}`,GROUP_ROW:`.${k.GROUP_ROW}`,CELL_BY_FIELD:e=>`.${k.DATA_CELL}[${T.FIELD}="${e}"]`,SELECTED_ROWS:`.${k.DATA_ROW}.${k.SELECTED}`,EDITING_CELL:`.${k.DATA_CELL}.${k.EDITING}`},L=/{{\s*([^}]+)\s*}}/g,D="__DG_EMPTY__",I=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,O="__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("")),z=new RegExp(`__(proto|defineGetter|defineSetter)|${O.slice(3).join("|")}|this\\b`);var N=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|math".split("|")),F=/^on\w+$/i,q=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),$=/^\s*(javascript|vbscript|data|blob):/i;function W(e){const t=document.createElement("template");return e&&"string"==typeof e&&(t.innerHTML=e,function(e){const t=[],r=e.querySelectorAll("*");for(const i of r){const e=i.tagName.toLowerCase();if(N.has(e)){t.push(i);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===i.namespaceURI)&&Array.from(i.attributes).some(e=>F.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(i);continue}const r=[];for(const t of i.attributes){const e=t.name.toLowerCase();F.test(e)?r.push(t.name):"is"!==e?(q.has(e)&&$.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&r.push(t.name):r.push(t.name)}r.forEach(e=>i.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content)),t.content}function V(e,t){t&&"string"==typeof t?-1!==t.indexOf("<")||-1!==t.indexOf("&")?e.replaceChildren(W(t)):e.textContent=t:e.replaceChildren()}function U(e,t){const r=function(e){const t=[];let r=0;for(;r<e.length;){const i=e[r];if(" "!==i){if(i>="0"&&i<="9"||"."===i&&r+1<e.length&&e[r+1]>="0"&&e[r+1]<="9"){const i=r;for(;r<e.length&&(e[r]>="0"&&e[r]<="9"||"."===e[r]);)r++;t.push({type:"num",v:Number(e.slice(i,r))});continue}if("'"===i){let i="";for(r++;r<e.length&&"'"!==e[r];)i+=e[r++];if(r>=e.length)return null;r++,t.push({type:"str",v:i});continue}if(i>="a"&&i<="z"||i>="A"&&i<="Z"||"_"===i||"$"===i){const i=r;for(;r<e.length&&/[\w$.]/.test(e[r]);)r++;t.push({type:"id",v:e.slice(i,r)});continue}if(r+2<e.length){const i=e.slice(r,r+3);if("==="===i||"!=="===i){t.push({type:"op",v:i}),r+=3;continue}}if(r+1<e.length){const i=e.slice(r,r+2);if("=="===i||"!="===i||"<="===i||">="===i||"&&"===i||"||"===i){t.push({type:"op",v:i}),r+=2;continue}}if(!"+-*/%<>!?:(),".includes(i))return null;t.push({type:"op",v:i}),r++}else r++}return t}(e);if(!r)return;const i=r;let n=0;function o(){return i[n]}function s(){return i[n++]}function a(e,t){const r=o();return!!r&&(r.type===e&&(void 0===t||r.v===t))}function l(){const e=function(){let e=c();for(;a("op","||");)s(),e=e||c();return e}();if(a("op","?")){s();const t=l();if(!a("op",":"))return;s();const r=l();return e?t:r}return e}function c(){let e=d();for(;a("op","&&");)s(),e=e&&d();return e}function d(){let e=u();for(;;){const t=o();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=h();for(;;){const t=o();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=g();for(;;){const t=o();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=o();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 a("op","!")?(s(),!f()):p()}function p(){const e=o();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 r=e.slice(4);return t.row?t.row[r]:void 0}if(e.startsWith("typeDefault.")){const r=e.slice(12);return t.typeDefault?t.typeDefault[r]:void 0}return"row"===e?t.row:"typeDefault"===e?t.typeDefault:void 0}(e.v);if("op"===e.type&&"("===e.v){s();const e=l();return a("op",")")&&s(),e}return"op"===e.type&&"-"===e.v?(s(),-p()):void 0}}const w=l();return n<i.length?void 0:w}function B(e,t){if(!e||-1===e.indexOf("{{"))return e;const r=[],i=(n=e.replace(L,(e,i)=>{const n=function(e,t){if(!(e=(e||"").trim()))return D;if(G.test(e))return D;if("value"===e)return null==t.value?D:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const r=e.slice(4),i=t.row?t.row[r]:void 0;return null==i?D:String(i)}if(e.startsWith("typeDefault.")&&!/[()?]/.test(e)&&!e.includes(":")){const r=e.slice(12),i=t.typeDefault?t.typeDefault[r]:void 0;return null==i?D:String(i)}if(e.length>80)return D;if(!I.test(e)||z.test(e))return D;const r=e.match(/\./g);if(r&&r.length>1)return D;try{const r=U(e,t),i=null==r?"":String(r);return G.test(i)?D:i||D}catch{return D}}(i,t);return r.push({expr:i.trim(),result:n}),n===D?n:(o=n)&&"string"==typeof o?o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):"";var o}),n?n.replace(new RegExp(D,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):n);var n;const o=r.length&&r.every(e=>""===e.result||e.result===D);return G.test(e)||o?"":i}var G=/Reflect|Proxy|ownKeys/;function j(e){if(G.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&G.test(t.textContent||"")&&(t.textContent="");G.test(e.textContent||"")&&(e.textContent="")}}function Y(e){if(G.test(e)){const e=()=>"";return e.__blocked=!0,e}const t=t=>B(e,t);return t.__blocked=!1,t}function X(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}var K=new WeakMap;function Z(e){return"__proto__"===e||"constructor"===e||"prototype"===e}var Q=new Map;function J(e){if(-1===e.indexOf("."))return null;let t=Q.get(e);return void 0===t&&(t=Object.freeze(e.split(".")),Q.set(e,t)),t}function ee(e,t){let r=e;for(let i=0;i<t.length;i++){if(null==r||"object"!=typeof r)return;const e=t[i];if(Z(e))return;r=r[e]}return r}function te(e,t,r){if(null==e||"object"!=typeof e)return!1;let i=e;for(let o=0;o<t.length-1;o++){const e=t[o];if(Z(e))return!1;const r=i[e];if(null==r||"object"!=typeof r)return!1;i=r}const n=t[t.length-1];return!Z(n)&&(i[n]=r,!0)}function re(e,t){if(null==e)return;const r=J(t),i=e;return null===r?Z(t)?void 0:i[t]:Object.prototype.hasOwnProperty.call(i,t)?i[t]:ee(i,r)}function ie(e){const t=J(e);return null===t?Z(e)?()=>{}:t=>null==t?void 0:t[e]:r=>{if(null==r)return;const i=r;return Object.prototype.hasOwnProperty.call(i,e)?i[e]:ee(i,t)}}function ne(e){return-1===e.indexOf(".")&&!Z(e)}function oe(e,t,r){if(null==e||"object"!=typeof e)return!1;const i=J(t),n=e;return null===i?!Z(t)&&(n[t]=r,!0):Object.prototype.hasOwnProperty.call(n,t)?(n[t]=r,!0):te(n,i,r)}function se(e,t,r=-1){if(!t.valueAccessor)return re(e,t.field);if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:r});const i=e,n=t.field;let o=K.get(i);if(o){const e=o.get(n);if(void 0!==e)return e.v}else{if(!0===e.__loading)return;o=new Map,K.set(i,o)}const s=t.valueAccessor({row:e,column:t,rowIndex:r});return o.set(n,{v:s}),s}function ae(e,t){e&&(t?K.get(e)?.delete(t):K.delete(e))}function le(e,t,r){const i=[...e];return de(i,t.field,t.direction,r),i}function ce(e,t,r){const i=e.length;if(i<2)return;const n=new Array(i),o=new Uint8Array(i),s=new Array(i);for(let l=0;l<i;l++){const r=e[l];s[l]=l,n[l]=t(r),o[l]=!0===r?.__loading?1:0}s.sort((e,t)=>{const i=o[e];if(i!==o[t])return i?1:-1;const s=n[e],a=n[t];return null==s&&null==a?0:null==s?-r:null==a||s>a?r:s<a?-r:0});const a=new Array(i);for(let l=0;l<i;l++)a[l]=e[s[l]];for(let l=0;l<i;l++)e[l]=a[l]}function de(e,t,r,i){const n=i.find(e=>e.field===t),o=n?.sortComparator;if(o)if(n?.valueAccessor)e.sort((e,t)=>o(se(e,n),se(t,n),e,t)*r);else{const i=ie(t);e.sort((e,t)=>o(i(e),i(t),e,t)*r)}else n?.valueAccessor?function(e,t,r){ce(e,e=>se(e,t),r)}(e,n,r):function(e,t,r){ne(t)?e.sort((e,i)=>{const n=function(e,t){const r=!0===e?.__loading;return r===(!0===t?.__loading)?0:r?1:-1}(e,i);if(0!==n)return n;const o=e[t],s=i[t];return null==o&&null==s?0:null==o?-r:null==s||o>s?r:o<s?-r:0}):ce(e,ie(t),r)}(e,t,r)}function ue(e,t,r,i){e._rows=t,e.__rowRenderEpoch++;for(let n=0;n<e._rowPool.length;n++)e._rowPool[n].__epoch=-1;e._schedulerRenderHeader(),e.refreshVirtualWindow(!0),he(e,r,i)}function he(e,t,r){const i={field:t.field,direction:r};e.dispatchEvent(new CustomEvent("sort-change",{detail:i})),e._pluginManager?.emitPluginEvent?.("sort-change",i),n(e,o(e,0===r?"sortCleared":"sortApplied",t.header??t.field,1===r?"ascending":"descending")),e.requestStateChange?.()}function ge(e){return e._pluginManager?._hasRowStructurePlugins??!1}function fe(e,t){if(e._sortState&&e._sortState.field===t.field)if(1===e._sortState.direction)pe(e,t,-1);else{if(e._sortState=null,ge(e))return e._requestSchedulerPhase(4,"sort-clear"),void he(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=[],e._schedulerRenderHeader();const r=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');if(r)for(let t=0;t<r.length;t++){const i=r[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),he(e,t,0)}else e._sortState||(e.__originalOrder=e._rows.slice()),pe(e,t,1)}function pe(e,t,r){if(e._sortState={field:t.field,direction:r},ge(e))return e._requestSchedulerPhase(4,"sort-apply"),void he(e,t,r);const i={field:t.field,direction:r},n=e._columns,o=e.effectiveConfig?.sortHandler??le;if(o===le)return e._rows=e._rows.slice(),de(e._rows,i.field,r,n),void ue(e,e._rows,t,r);const s=o(e._rows,i,n);s&&"function"==typeof s.then?s.then(i=>{ue(e,i,t,r)}):ue(e,s,t,r)}function we(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function me(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function be(e,t){const r=document.createElement("span");S(r,"sort-indicator"),r.setAttribute("aria-hidden","true");const i=e._sortState?.field===t.field?e._sortState.direction:0,n=1===i?"sortAsc":-1===i?"sortDesc":"sortNone";r.dataset.icon=X(n);const o=e.icons?.[n];return void 0!==o&&function(e,t){"string"==typeof t?V(e,t):t instanceof HTMLElement&&e.replaceChildren(t.cloneNode(!0))}(r,o),r}function ve(e,t,r){const i=document.createElement("div");i.className="resize-handle",i.setAttribute("role","button"),i.setAttribute("tabindex","-1");const n=e._visibleColumns[t];return i.setAttribute("aria-label",`Width of column ${String(n?.header??n?.field??t+1)}`),i.addEventListener("pointerdown",n=>{0!==n.button&&"mouse"===n.pointerType||(n.stopPropagation(),n.preventDefault(),e._resizeController.start(n,t,r,i))}),i.addEventListener("dblclick",r=>{r.stopPropagation(),r.preventDefault(),e._resizeController.resetColumn(t)}),i}function ye(e,t,r,i){i.classList.add(k.SORTABLE),i.tabIndex=0;const n=e._sortState?.field===t.field?e._sortState.direction:0;i.setAttribute("aria-sort",0===n?"none":1===n?"ascending":"descending"),i.addEventListener("click",r=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(r,t,i)||fe(e,t)}),i.addEventListener("keydown",r=>{if("Enter"===r.key||" "===r.key){if(r.preventDefault(),e._dispatchHeaderClick?.(r,t,i))return;fe(e,t)}})}function Ce(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((r,i)=>{const n=document.createElement("div");n.className="cell",S(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",r.field),n.setAttribute("data-col",String(i)),r.type&&n.setAttribute("data-type",r.type);const o=r.header??r.field,s=e._sortState?.field===r.field?e._sortState.direction:0,a=1===s?"asc":-1===s?"desc":null;if(r.headerRenderer){const t={column:r,value:o,sortState:a,filterActive:!1,cellEl:n,renderSortIcon:()=>we(e,r)?be(e,r):null,renderFilterButton:()=>null};!function(e,t){null!=t&&("string"==typeof t?e.appendChild(W(t)):t instanceof Node&&e.appendChild(t))}(n,r.headerRenderer(t)),we(e,r)&&ye(e,r,0,n),me(e,r)&&(n.classList.add("resizable"),n.appendChild(ve(e,i,n)))}else if(r.headerLabelRenderer){const t={column:r,value:o},s=r.headerLabelRenderer(t),a=document.createElement("span");null==s?a.textContent=o:"string"==typeof s?V(a,s):s instanceof Node&&a.appendChild(s),n.appendChild(a),we(e,r)&&(ye(e,r,0,n),n.appendChild(be(e,r))),me(e,r)&&(n.classList.add("resizable"),n.appendChild(ve(e,i,n)))}else if(r.__headerTemplate)Array.from(r.__headerTemplate.childNodes).forEach(e=>n.appendChild(e.cloneNode(!0))),we(e,r)&&(ye(e,r,0,n),n.appendChild(be(e,r))),me(e,r)&&(n.classList.add("resizable"),n.appendChild(ve(e,i,n)));else{const t=document.createElement("span");t.textContent=o,n.appendChild(t),n.setAttribute("aria-label",o),we(e,r)&&(ye(e,r,0,n),n.appendChild(be(e,r))),me(e,r)&&(n.classList.add("resizable"),n.appendChild(ve(e,i,n)))}t.appendChild(n)}),t.querySelectorAll(`.cell.${k.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 _e(e,t){if(t&&t.length){const e={};return t.forEach(t=>{t.type&&(e[t.field]=t.type)}),{columns:t,typeMap:e}}const r=e[0]||{},i=Object.keys(r).map(e=>{const t=r[e],i=null==(n=t)?"string":"number"==typeof n?"number":"boolean"==typeof n?"boolean":n instanceof Date||"string"==typeof n&&/\d{4}-\d{2}-\d{2}/.test(n)&&!isNaN(Date.parse(n))?"date":"string";var n;return{field:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:i}}),n={};return i.forEach(e=>{n[e.field]=e.type||"string"}),{columns:i,typeMap:n}}var Re={STYLE:1,VIRTUALIZATION:2,HEADER:3,ROWS:4,COLUMNS:5,FULL:6},Se=class{#e;#t=0;#r=0;#i=null;#n=null;#o=null;#s=!1;constructor(e){this.#e=e}requestPhase(e,t){e>this.#t&&(this.#t=e),0===this.#r&&(this.#a(),this.#r=requestAnimationFrame(()=>this.#l()))}whenReady(){return this.#i?this.#i:Promise.resolve()}setInitialReadyResolver(e){this.#o=e}cancel(){0!==this.#r&&(cancelAnimationFrame(this.#r),this.#r=0),this.#t=0,this.#n&&(this.#n(),this.#n=null,this.#i=null)}get isPending(){return 0!==this.#t}get pendingPhase(){return this.#t}#a(){this.#i||(this.#i=new Promise(e=>{this.#n=e}))}#l(){if(this.#r=0,!this.#e._schedulerIsConnected)return this.#t=0,void(this.#n&&(this.#n(),this.#n=null,this.#i=null));const e=this.#t;this.#t=0,e>=Re.COLUMNS&&this.#e._schedulerMergeConfig(),e>=Re.ROWS&&this.#e._schedulerProcessRows(),e>=Re.COLUMNS&&(this.#e._schedulerProcessColumns(),this.#e._schedulerUpdateTemplate()),e>=Re.HEADER&&this.#e._schedulerRenderHeader(),e>=Re.VIRTUALIZATION&&this.#e.refreshVirtualWindow(!0,!0),e>=Re.STYLE&&this.#e._schedulerAfterRender();const t=!this.#s;t&&(this.#s=!0,this.#o?.()),this.#n&&(this.#n(),this.#n=null,this.#i=null),0!==e&&this.#c(e,t)}#c(e,t){const r=this.#e._virtualization,i=r?.enabled?{start:r.start,end:r.end}:null,n={phase:e,initial:t,rowCount:this.#e._rows?.length??0,visibleRange:i};this.#e._hostElement.dispatchEvent(new CustomEvent("render",{detail:n,bubbles:!0,composed:!0}))}},Ee="--tbw-row-height",Ae=new Set(["field","header","order","group","hidden","utility"]);var xe=class{#d;#u;#h;#g;#f;#p;#w;#m={};#b={};#v=!0;#y;#C;#_;#R;#e;#S=!1;constructor(e){this.#e=e}get original(){return this.#m}get effective(){return this.#b}get columns(){return this.#b.columns??[]}set columns(e){this.#b.columns=e}get lightDomColumnsCache(){return this.#f}set lightDomColumnsCache(e){this.#f=e}get originalColumnNodes(){return this.#w}set originalColumnNodes(e){this.#w=e}get initialColumnState(){return this.#R}set initialColumnState(e){this.#R=e}markSourcesChanged(){this.#v=!0}setGridConfig(e){this.#d!==e&&(this.#d=e,this.#v=!0,this.#f=void 0)}getGridConfig(){return this.#d}setColumns(e){this.#u=e,this.#v=!0}getColumns(){return this.#u}setFitMode(e){this.#h=e,this.#v=!0}getFitMode(){return this.#h}setColumnInference(e){this.#g!==e&&(this.#g=e,this.#v=!0)}getColumnInference(){return this.#g}merge(){const e=(this.#b.columns?.length??0)>0;if(!this.#v&&e)return;const t=this.#E();this.#v=!1,this.#m=t,Object.freeze(this.#m),this.#m.columns&&Object.freeze(this.#m.columns),this.#b=this.#A(this.#m),this.#x()}#A(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}#x(){const e=this.#b;"number"==typeof e.rowHeight&&e.rowHeight>0?(this.#e._virtualization.rowHeight=e.rowHeight,this.#e.style.setProperty(Ee,`${e.rowHeight}px`),this.#S=!0):this.#S&&(this.#e.style.removeProperty(Ee),this.#S=!1),"fixed"===e.fitMode&&this.columns.forEach(e=>{null==e.width&&(e.width="number"==typeof e.minWidth&&Number.isFinite(e.minWidth)&&e.minWidth>0?e.minWidth:80)}),this.#e._applyAnimationConfig(e)}#E(){const e=this.#d?{...this.#d}:{},t=Array.isArray(e.columns)?[...e.columns]:[],r=(this.#f??[]).map(e=>({...e}));let i=R(t,r);this.#u&&this.#u.length&&(i=R(this.#u,r));const n=this.#e.sourceRows;if("merge"===(this.#g??e.columnInference??"auto")&&n.length){i=function(e,t){if(!t.length)return e;const r=new Map;for(const o of t)r.set(o.field,o);const i=new Set(e.map(e=>e.field)),n=e.map(e=>{const t=r.get(e.field);if(!t)return e;const i={...e};for(const[r,n]of Object.entries(t))void 0!==n&&Object.assign(i,{[r]:n});return i});for(const o of t)i.has(o.field)||n.push(o);return n}(_e(n).columns,i)}else 0===i.length&&n.length&&(i=_e(n).columns);if(this.#p&&Object.keys(this.#p).length>0){const t={...this.#p},r=e.typeDefaults??{};for(const e of Object.keys(r)){const i=r[e],n=t[e];t[e]=n?{...n,...i}:i}e.typeDefaults=t}return i.length&&(!function(e){const t=[],r=[];for(const o of e)"number"==typeof o.order&&Number.isFinite(o.order)&&o.order>=0?t.push({col:o,order:Math.floor(o.order)}):r.push(o);if(0===t.length)return e;t.sort((e,t)=>e.order-t.order);const i=[];let n=0;for(const{col:o,order:s}of t){for(;i.length<s&&n<r.length;)i.push(r[n++]);const e=Math.min(s,i.length);i.splice(e,0,o)}for(;n<r.length;)i.push(r[n++]);e.length=0,e.push(...i)}(i),e.typeDefaults&&function(e,t){for(const r of e){const e=r.type?t[r.type]:void 0;if(e)for(const t of Object.keys(e)){if(Ae.has(t))continue;const i=Reflect.get(e,t);void 0!==i&&null==Reflect.get(r,t)&&("renderer"!==t&&"viewRenderer"!==t||null==r.renderer&&null==r.viewRenderer)&&Reflect.set(r,t,i)}}}(i,e.typeDefaults),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=Y(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=Y(e.__editorTemplate.innerHTML))}),e.columns=i),this.#h&&(e.fitMode=this.#h),e.fitMode||(e.fitMode="stretch"),this.#g&&(e.columnInference=this.#g),this.#e._pluginManager?.processConfig?.(e),e.columnState&&!this.#R&&(this.#R=e.columnState),e}collectState(e){const t=this.columns,r=this.#M();return{columns:t.map((t,i)=>{const n={field:t.field,order:i,visible:!t.hidden},o=t;void 0!==o.__renderedWidth?n.width=o.__renderedWidth:void 0!==t.width&&(n.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=r.get(t.field);s&&(n.sort=s);for(const r of e)if(r.getColumnState){const e=r.getColumnState(t.field);e&&Object.assign(n,e)}return n})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const r=this.columns,i=new Map(e.columns.map(e=>[e.field,e])),n=r.map(e=>{const t=i.get(e.field);if(!t)return e;const r={...e};return void 0!==t.width&&(r.width=t.width,r.__renderedWidth=t.width),void 0!==t.visible&&(r.hidden=!t.visible),r});n.sort((e,t)=>(i.get(e.field)?.order??1/0)-(i.get(t.field)?.order??1/0)),this.columns=n;const o=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(o.length>0){const e=o[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.#R=void 0,this.#e._sortState=null,this.#b=this.#A(this.#m),this.#x();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)}#M(){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.#C&&clearTimeout(this.#C),this.#C=setTimeout(()=>{this.#C=void 0;const t=this.collectState(e);this.#e._emit("column-state-change",t)},100)}setColumnVisible(e,t){const r=this.columns,i=r.find(t=>t.field===e);return!!i&&(!(!t&&i.lockVisible)&&(!(!t&&0===r.filter(t=>!t.hidden&&t.field!==e).length)&&(!!i.hidden!=!t&&(i.hidden=!t,this.#e._emit("column-visibility",{field:e,visible:t,visibleColumns:r.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])),r=[];for(const i of e){const e=t.get(i);e&&(r.push(e),t.delete(i))}for(const i of t.values())r.push(i);this.columns=r,this.#e._invalidateVisibleColumnsCache(),Ce(this.#e),M(this.#e),this.#e._requestSchedulerPhase(Re.COLUMNS,"configManager")}parseLightDomColumns(e){if(this.#f||(this.#w=Array.from(e.querySelectorAll("tbw-grid-column")),this.#f=this.#w.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const r=t.includes(":")?c(t):void 0,i={field:r?.field??t,type:e.getAttribute("type")||r?.type||void 0,header:e.getAttribute("header")||r?.header||void 0,sortable:e.hasAttribute("sortable")&&"false"!==e.getAttribute("sortable"),__element:e},n=e.getAttribute("width");if(n){const e=parseFloat(n);!isNaN(e)&&/^\d+(\.\d+)?$/.test(n.trim())?i.width=e:i.width=n}const o=e.getAttribute("minWidth")||e.getAttribute("min-width");if(o){const e=parseFloat(o);isNaN(e)||(i.minWidth=e)}const s=e.getAttribute("order");if(s){const e=parseInt(s,10);Number.isFinite(e)&&e>=0&&(i.order=e)}e.hasAttribute("resizable")&&(i.resizable="false"!==e.getAttribute("resizable"));const a=e.getAttribute("options");a&&(i.options=a.split(",").map(e=>{const[t,r]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:r?.trim()||t.trim()}}));const l=e.querySelector("tbw-grid-column-view"),d=e.querySelector("tbw-grid-column-editor"),u=e.querySelector("tbw-grid-column-header");l&&(i.__viewTemplate=l),u&&(i.__headerTemplate=u);const h=globalThis.DataGridElement?.getAdapters?.()??[],g=l??e,f=h.find(e=>e.canHandle(g));if(f){const e=f.createRenderer(g);e&&(i.viewRenderer=e)}const p=d??e,w=h.find(e=>e.canHandle(p));if(w){const e=w.createEditor(p);e&&(i.editor=e)}const m=h.find(t=>t.canHandle(e)&&(t.createHeaderRenderer||t.createHeaderLabelRenderer));if(m){const t=m.createHeaderRenderer?.(e);t&&(i.headerRenderer=t);const r=m.createHeaderLabelRenderer?.(e);r&&(i.headerLabelRenderer=r)}return i}).filter(e=>!!e)}(e):[]),!this.#p){const t=function(e){const t=globalThis.DataGridElement?.getAdapters?.()??[];return Array.from(e.children).filter(e=>"tbw-grid-type"===e.tagName.toLowerCase()).map(e=>{const r=e.getAttribute("name")?.trim();if(!r)return null;const i=Array.from(e.children).find(e=>"tbw-grid-column-view"===e.tagName.toLowerCase()),n=i??e,o=t.find(e=>e.canHandle(n))?.createRenderer(n),s={};for(const t of Array.from(e.attributes)){if(!t.name.startsWith("data-"))continue;const e=t.name.slice(5).replace(/-([a-z])/g,(e,t)=>t.toUpperCase()).trim();e&&(s[e]=t.value)}return{name:r,params:s,viewTemplate:i,viewRenderer:o}}).filter(e=>null!==e)}(e),r={};for(const e of t){const t={};let i=!1;if(e.viewRenderer)t.renderer=e.viewRenderer,i=!0;else if(e.viewTemplate){const r=Y(e.viewTemplate.innerHTML);t.renderer=t=>r({row:t.row,value:t.value,field:t.field,column:t.column,typeDefault:e.params}),i=!0}i&&(r[e.name]=t)}this.#p=r}}clearLightDomCache(){this.#f=void 0,this.#p=void 0}#H=new Map;registerLightDomHandler(e,t){this.#H.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#H.delete(e.toLowerCase())}observeLightDOM(e){this.#y&&this.#y.disconnect();const t=new Set,r=()=>{this.#_=void 0;for(const e of t)this.#H.get(e)?.();t.clear()};this.#y=new MutationObserver(e=>{for(const r of e){for(const e of r.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const r=e.tagName.toLowerCase();this.#H.has(r)&&t.add(r)}for(const e of r.removedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const r=e.tagName.toLowerCase();this.#H.has(r)&&t.add(r)}if("attributes"===r.type&&r.target.nodeType===Node.ELEMENT_NODE){const e=r.target.tagName.toLowerCase();this.#H.has(e)&&t.add(e)}}t.size>0&&!this.#_&&(this.#_=setTimeout(r,0))}),this.#y.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order","name","type"]})}dispose(){this.#y?.disconnect(),this.#C&&clearTimeout(this.#C),this.#_&&(clearTimeout(this.#_),this.#_=void 0)}};function Me(e,t){const r=document.createElement("div");return e&&(r.className=e),function(e,t){if(t)for(const r in t){const i=t[r];null!=i&&e.setAttribute(r,i)}}(r,t),r}var He=document.createElement("template");function ke(e){const t=document.createDocumentFragment(),r=Me(e.hasShell?`${k.ROOT} has-shell`:k.ROOT);if(e.hasShell&&e.shellBody)e.shellHeader&&r.appendChild(e.shellHeader),r.appendChild(e.shellBody);else{const e=Me("tbw-grid-content");e.appendChild(He.content.cloneNode(!0)),r.appendChild(e)}return t.appendChild(r),t}He.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';function Te(e){const t=document.createElement("div");return t.className="tbw-empty-message",t.textContent=e.filteredOut?"No matching rows":"No data to display",t}function Pe(e,t){const r=(t??Te)(e);if("string"==typeof r){const e=document.createElement("div");return e.className="tbw-empty-message",V(e,r),e}return r}function Le(e){e?.remove()}function De(e,t,r,i,o,s,a,l){if(!e)return;if(!function(e,t,r){return!(e||t>0||null===r)}(t,r,o))return Le(a.el),a.el=void 0,a.renderer=void 0,a.target=void 0,a.sourceRows=void 0,void(a.filteredOut=void 0);const c=i.length,d=c>0&&0===r;if(a.el&&a.renderer===o&&a.target===s&&a.sourceRows===i&&a.filteredOut===d)return;const u="grid"===s?e:e.querySelector(".rows-container")??e;Le(a.el),a.el=function(e,t,r="rows"){const i=document.createElement("div");return i.className="tbw-empty-overlay",i.setAttribute("role","presentation"),i.setAttribute("data-overlay-target",r),i.appendChild(Pe(e,t)),i}({sourceRowCount:c,filteredOut:d},o??void 0,s),function(e,t){e.appendChild(t)}(u,a.el),a.renderer=o,a.target=s,a.sourceRows=i,a.filteredOut=d;const h=a.el.textContent?.trim();l&&h&&n(l,h)}function Ie(){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 Oe(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"🗹":"☐"}</span>`}function ze(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 Ne(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const r=e.closest(".data-grid-row");if(!r)return-1;const i=r.parentElement;if(!i)return-1;const n=i.querySelectorAll(":scope > .data-grid-row");for(let o=0;o<n.length;o++)if(n[o]===r)return o;return-1}function Fe(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function qe(e){return"rtl"===function(e){try{if("rtl"===getComputedStyle(e).direction)return"rtl"}catch{}try{if("rtl"===e.closest?.("[dir]")?.getAttribute("dir"))return"rtl"}catch{}return"ltr"}(e)}function $e(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 We(e,t,r){const i=$e(t,r);return"string"==typeof i?e.byKey.get(i):i&&"object"==typeof i?e.byRef.get(i):void 0}function Ve(e,t){if(0===e.length)return-1;if(t<=0)return 0;let r=0,i=e.length-1;for(;r<=i;){const n=Math.floor((r+i)/2),o=e[n],s=o.offset+o.height;if(t<o.offset)i=n-1;else{if(!(t>=s))return n;r=n+1}}return Math.max(0,Math.min(r,e.length-1))}function Ue(e,t){const{positionCache:r,heightCache:i,rows:n,start:o,end:s,headerRowCount:a,getPluginHeight:l,getRowId:c}=e;let d=!1;const u=[];t.forEach(e=>{const t=e.getAttribute("aria-rowindex");if(!t)return;const h=parseInt(t,10)-a-1;if(h<o||h>=s||h>=n.length)return;const g=n[h],f=l?.(g,h);if(void 0!==f){const e=r[h];return void((!e.measured||Math.abs(e.height-f)>1)&&(u.push({index:h,height:f}),d=!0))}const p=e.offsetHeight;if(p>0){const e=r[h];(!e.measured||Math.abs(e.height-p)>1)&&(u.push({index:h,height:p}),function(e,t,r,i){const n=$e(t,i);"string"==typeof n?e.byKey.set(n,r):n&&"object"==typeof n&&e.byRef.set(n,r)}(i,g,p,c),d=!0)}}),function(e,t){if(0===t.length||0===e.length)return;let r=t;for(let o=1;o<t.length;o++)if(t[o].index<t[o-1].index){r=[...t].sort((e,t)=>e.index-t.index);break}let i=0;for(;i<r.length&&r[i].index<0;)i++;if(i>=r.length||r[i].index>=e.length)return;let n=0;for(let o=r[i].index;o<e.length;o++){const t=e[o];for(t.offset+=n;i<r.length&&r[i].index===o;){const e=r[i].height,o=e-t.height;t.measured=!0,0!==o&&(t.height=e,n+=o),i++}}}(r,u);const h=d?function(e){let t=0;for(const r of e)r.measured&&t++;return t}(r):0,g=d?function(e,t){let r=0,i=0;for(const n of e)n.measured&&(r+=n.height,i++);return i>0?r/i:t}(r,e.defaultHeight):0;return{hasChanges:d,measuredCount:h,averageHeight:g}}var Be=335e5;function Ge(e,t,r=335e5){return{rawContentHeight:e,spacerHeight:Math.min(e,r),viewportHeight:t,capped:e>r}}function je(e,t){if(!t.capped)return e;const r=t.spacerHeight-t.viewportHeight,i=t.rawContentHeight-t.viewportHeight;if(r<=0||i<=0)return e;const n=e*i/r;return n<0?0:n>i?i:n}function Ye(e,t){if(!t.capped)return e;const r=t.spacerHeight-t.viewportHeight,i=t.rawContentHeight-t.viewportHeight;return r<=0||i<=0?e:e*r/i}function Xe(e){"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit()}function Ke(e){return void 0!==e._activeEditRows&&-1!==e._activeEditRows}function Ze(e,t,r,i){e._focusCol=(qe(e)?!i:i)?Math.min(r,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault()}function Qe(e,t,r){Ke(e)&&Xe(e),e._focusRow=r?t:0}function Je(e,t,r,i){t.ctrlKey||t.metaKey?Qe(e,r,i):(Ke(e)&&Xe(e),e._focusRow=i?Math.min(r,e._focusRow+1):Math.max(0,e._focusRow-1)),t.preventDefault()}function et(e,t,r){const i=e._focusRow,n=e._virtualization,o=n?.viewportEl?.clientHeight??n?.container?.clientHeight??0,s=e._getVerticalScrollOffsets?.(i),a=o-Math.max(0,s?.top??0)-Math.max(0,s?.bottom??0),l=n?.variableHeights?n.positionCache:null;let c;if(a>0&&l?.[i])c=Ve(l,l[i].offset+(r?a:-a)),c===i&&(c=i+(r?1:-1));else{const e=n?.rowHeight??0,t=a>0&&e>0?Math.max(1,Math.floor(a/e)):20;c=i+(r?t:-t)}return Math.max(0,Math.min(t,c))}function tt(e,t,r,i,n){(t.ctrlKey||t.metaKey)&&Qe(e,r,n),e._focusCol=n?i:0,t.preventDefault(),it(e,n?{forceScrollRight:!0}:{forceScrollLeft:!0})}function rt(e,t){if(e._dispatchKeyDown?.(t))return;const r=t.composedPath?.()??[];if(function(e,t,r){if(r&&r!==e&&!r.closest?.(".rows-body"))return!0;if(function(e){if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable}(r))switch(t.key){case"Home":case"End":case"ArrowLeft":case"ArrowRight":case"Enter":case"Escape":return!0;case"ArrowUp":case"ArrowDown":if("INPUT"===r.tagName&&"number"===r.type)return!0}const i=e._visibleColumns[e._focusCol]?.type;return Ke(e)&&"select"===i&&("ArrowDown"===t.key||"ArrowUp"===t.key)}(e,t,r.length?r[0]:t.target))return;const i=e._rows.length-1,n=e._visibleColumns.length-1;switch(t.key){case"Tab":!function(e,t,r,i){if(t.preventDefault(),!t.shiftKey)return e._focusCol<i?void(e._focusCol+=1):(Xe(e),void(e._focusRow<r&&(e._focusRow+=1,e._focusCol=0)));e._focusCol>0?e._focusCol-=1:e._focusRow>0&&(e._activeEditRows===e._focusRow&&Xe(e),e._focusRow-=1,e._focusCol=i)}(e,t,i,n);break;case"ArrowDown":Je(e,t,i,!0);break;case"ArrowUp":Je(e,t,i,!1);break;case"ArrowRight":Ze(e,t,n,!0);break;case"ArrowLeft":Ze(e,t,n,!1);break;case"Home":return void tt(e,t,i,n,!1);case"End":return void tt(e,t,i,n,!0);case"PageDown":e._focusRow=et(e,i,!0),t.preventDefault();break;case"PageUp":e._focusRow=et(e,i,!1),t.preventDefault();break;case"Enter":if(function(e,t){const r=e._focusRow,i=e._focusCol,n=e._visibleColumns[i],o=e._rows[r],s=n?.field??"",a=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:r,colIndex:i,column:n,field:s,value:s&&o?re(o,s):void 0,row:o,cellEl:e.querySelector(`[data-row="${r}"][data-col="${i}"]`),trigger:"keyboard",originalEvent:t}});return e.dispatchEvent(a),a.defaultPrevented}(e,t))return void t.preventDefault();break;default:return}it(e)}function it(e,t){!function(e){if(!e._virtualization?.enabled)return;const{rowHeight:t,container:r,viewportEl:i,scrollMapping:n}=e._virtualization,o=r,s=i?.clientHeight??o?.clientHeight??0;if(!o||s<=0)return;const a=e._getVerticalScrollOffsets?.(e._focusRow)??{top:0,bottom:0};if(a.skipScroll)return;const l=Math.max(0,a.top),c=s-l-Math.max(0,a.bottom);if(c<=0)return;const d=e._focusRow*t,u=n?je(o.scrollTop,n):o.scrollTop;if(d<u+l){const e=Math.max(0,d-l);o.scrollTop=n?Ye(e,n):e}else if(d+t>u+l+c){const e=Math.max(0,d-c+t-l);o.scrollTop=n?Ye(e,n):e}}(e);const r=Ke(e)||!!e._isGridEditMode;r||e.refreshVirtualWindow(!1),Fe(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const i=function(e){const t=e._focusRow,r=e._virtualization.start??0,i=e._virtualization.end??e._rows.length;if(t<r||t>=i)return;const n=e._bodyEl.querySelectorAll(".data-grid-row")[t-r];let o=n?.children[e._focusCol];return o&&o.classList?.contains("cell")||(o=n?.querySelector(`.cell[data-col="${e._focusCol}"]`)??n?.querySelector(".cell[data-col]")),o?{rowEl:n??null,cell:o}:void 0}(e);if(!i)return;const{rowEl:n,cell:o}=i;o.classList.add("cell-focus"),o.setAttribute("aria-selected","true"),r&&!t?.forceHorizontalScroll||function(e,t,r,i){const n=e.querySelector(".tbw-scroll-area");if(!n)return;if(i?.forceScrollLeft)return void(n.scrollLeft=0);if(i?.forceScrollRight)return void(n.scrollLeft=n.scrollWidth-n.clientWidth);const o=e._getHorizontalScrollOffsets?.(t??void 0,r)??{left:0,right:0};if(o.skipScroll)return;const s=r.getBoundingClientRect(),a=n.getBoundingClientRect(),l=s.left-a.left+n.scrollLeft,c=l+s.width,d=n.scrollLeft+o.left,u=n.scrollLeft+n.clientWidth-o.right;l<d?n.scrollLeft=l-o.left:c>u&&(n.scrollLeft=c-n.clientWidth+o.right)}(e,n,o,t),function(e,t,r){if(r&&t.classList.contains(k.EDITING)){const e=t.querySelector(H);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}return}if(r){if(t.contains(document.activeElement))return;t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1");try{t.focus({preventScroll:!0})}catch{}return}const i=document.activeElement;i instanceof HTMLElement&&i!==e&&"function"==typeof e.contains&&e.contains(i)&&!i.classList.contains("cell")&&!i.closest(".cell")||i===e||e.focus({preventScroll:!0})}(e,o,r)}var nt=new WeakMap;function ot(e,t,r,i){const{onMove:n,onEnd:o,onCancel:s,onPromote:a}=r,l=i?.threshold??0,c=i?.longPressDuration??0,d=i?.longPressSlop??8,u=e.pointerId;if(!function(e,t){let r=nt.get(e);return r||(r=new Set,nt.set(e,r)),!r.has(t)&&(r.add(t),!0)}(t,u))return()=>{};const h=e.clientX,g=e.clientY;let f=0===l&&0===c,p=!1,w=null,m=!1;function b(){return f=!0,function(){try{return t.setPointerCapture(u),!0}catch{return m=!0,!1}}()?(a?.(),!0):(y(),!1)}function v(){if(!p){var e,r;p=!0,null!==w&&(clearTimeout(w),w=null),t.removeEventListener("pointermove",C),t.removeEventListener("pointerup",_),t.removeEventListener("pointercancel",R),t.removeEventListener("lostpointercapture",S),document.removeEventListener("keydown",E,!0),e=t,r=u,nt.get(e)?.delete(r);try{t.hasPointerCapture(u)&&t.releasePointerCapture(u)}catch{}}}function y(){p||(v(),s?.())}function C(e){const t=e;if(t.pointerId!==u||p)return;const r=t.clientX-h,i=t.clientY-g,o=Math.sqrt(r*r+i*i);if(!f){if(c>0)return o>d?void y():void 0;if(l>0&&o<l)return;if(!b())return}n(t)}function _(e){const t=e;if(t.pointerId!==u||p)return;const r=f;v(),r?o(t):s?.()}function R(e){e.pointerId!==u||p||y()}function S(e){e.pointerId!==u||p||y()}function E(e){"Escape"!==e.key||p||y()}return t.addEventListener("pointermove",C),t.addEventListener("pointerup",_),t.addEventListener("pointercancel",R),t.addEventListener("lostpointercapture",S),document.addEventListener("keydown",E,!0),f&&(b(),m)?()=>{}:(c>0&&(w=setTimeout(()=>{w=null,p||b()},c)),y)}var st=null,at=new Set;function lt(e){const t=e.matches?"coarse":"fine";at.forEach(e=>e(t))}function ct(){const e=st||("function"!=typeof globalThis.matchMedia?null:("function"==typeof(st=globalThis.matchMedia("(pointer: coarse)")).addEventListener?st.addEventListener("change",lt):"function"==typeof st.addListener&&st.addListener(lt),st));return e?function(e){return e.matches?"coarse":"fine"}(e):"fine"}function dt(e,t){if(t){const r=t({size:e});if("string"==typeof r){const e=document.createElement("div");return V(e,r),e}return r}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 ut(e,t){if(!e.firstElementChild)return;const r=e.querySelector(":scope > .tbw-cell-loading-overlay");r&&(t?.unmount?.(r),r.remove())}function ht(e){if(!e.firstElementChild)return null;const t=e.querySelector(":scope > .tbw-cell-loading-overlay");if(!t)return null;const r=e.parentElement;return r?r.insertBefore(t,e):t.remove(),t}function gt(e,t){if(!e.firstElementChild)return;const r=e.querySelector(":scope > .tbw-row-loading-overlay");r&&(t?.unmount?.(r),r.remove())}function ft(e,t,r,i){if(t){if(e.classList.add("tbw-row-loading"),e.setAttribute("aria-busy","true"),!e.querySelector(":scope > .tbw-row-loading-overlay")){const t=document.createElement("div");if(t.className="tbw-row-loading-overlay",t.setAttribute("aria-hidden","true"),r)t.appendChild(dt("small",r));else{const e=document.createElement("div");e.className="tbw-row-loading-spinner",t.appendChild(e)}e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),gt(e,i)}function pt(e,t,r,i){if(t){e.classList.add("tbw-cell-loading"),e.setAttribute("aria-busy","true");const t=e.parentElement;if(t&&(t.__hasCellLoading=!0),r){if(e.classList.add("tbw-cell-loading-custom"),!e.querySelector(":scope > .tbw-cell-loading-overlay")){const t=document.createElement("div");t.className="tbw-cell-loading-overlay",t.setAttribute("aria-hidden","true"),t.appendChild(dt("small",r)),e.appendChild(t)}}else e.classList.remove("tbw-cell-loading-custom"),ut(e,i)}else e.classList.remove("tbw-cell-loading"),e.classList.remove("tbw-cell-loading-custom"),e.removeAttribute("aria-busy"),ut(e,i)}function wt(e,t){if(!e?.releaseCell&&!e?.unmount)return;gt(t,e);const r=t.children;for(let i=0;i<r.length;i++){const t=r[i];ut(t,e),t.firstElementChild&&e.releaseCell?.(t)}}function mt(e,t){const r=t.renderer||t.viewRenderer;if(r)return r;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const r=i.getTypeDefault(t.type,e._hostElement);if(r?.renderer)return r.renderer}}function bt(e,t){if(t.format)return t.format;if(!t.type)return;const r=e.__frameworkAdapter;if(r?.getTypeDefault){const i=r.getTypeDefault(t.type,e._hostElement);if(i?.format)return i.format}}function vt(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing"),e.querySelectorAll(`.cell.${k.EDITING}`).forEach(e=>e.classList.remove(k.EDITING))}var yt=document.createElement("template");yt.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';var Ct=document.createElement("template");function _t(){return Ct.content.firstElementChild.cloneNode(!0)}function Rt(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function St(e){const t=e.getAttribute("data-dynamic-classes");if(!t)return;const r=t.split(" ");for(let i=0;i<r.length;i++)r[i]&&e.classList.remove(r[i])}function Et(e,t){const r="string"==typeof t?t.split(/\s+/):t;if(!r||0===r.length)return void e.removeAttribute("data-dynamic-classes");let i="";for(let n=0;n<r.length;n++){const t=r[n];t&&"string"==typeof t&&(e.classList.add(t),i+=(i?" ":"")+t)}e.setAttribute("data-dynamic-classes",i)}function At(e,t,r,i,n,o,s,a){e._afterCellRender?.({row:o,rowIndex:s,column:i,colIndex:n,value:a,cellElement:r,rowElement:t})}function xt(e,t,r){const i=e.__frameworkAdapter;i?.beginBatch?.(e);try{for(let e=0;e<r.length;e++){const t=r[e];t.classList.contains("tbw-cell-loading")&&pt(t,!1,void 0,i)}t.__hasCellLoading=!1}finally{i?.endBatch?.(e)}}function Mt(e,t,r){for(let i=0;i<r;i++)if(t[i].externalView&&!e.querySelector(`.cell[data-col="${i}"] [data-external-view]`))return!0;return!1}function Ht(e,t,r,i,n,o,s){const a=function(e){return(e.__editingCellCount??0)>0}(t),l=!!e._isGridEditMode&&!s||e._activeEditRows===i;return o?a&&!l?(vt(t),Ut(e,t,r,i),t.__epoch=n,void(t.__rowDataRef=r)):(Ft(e,t,r,i),void(s&&(t.__rowDataRef=r))):a&&l?(Ft(e,t,r,i),void(t.__rowDataRef=r)):(function(e){e.__isCustomRow&&(e.className="data-grid-row",e.setAttribute("role","row"),e.__isCustomRow=!1)}(t),a&&vt(t),Ut(e,t,r,i),t.__epoch=n,void(t.__rowDataRef=r))}function kt(e,t,r){let i=!1;const n=e._changedRowIdSet;if(n&&n.size>0)try{const t=e.getRowId?.(r);t&&(i=n.has(t))}catch{}i!==t.classList.contains("changed")&&t.classList.toggle("changed",i)}function Tt(e,t,r){const i=e.effectiveConfig?.rowClass;if(i){St(t);try{Et(t,i(r))}catch(n){v("TBW060",`rowClass callback error: ${n}`,e.id),t.removeAttribute("data-dynamic-classes")}}}function Pt(e){return null!=e&&(!0===e.__isGroupRow||!0===e.__loading||!0===e.__pivotIsGrandTotal||void 0!==e.__pivotRowKey)}function Lt(e,t,r,i,n){const o=Math.max(0,r-t),s=e._bodyEl,a=e._visibleColumns,l=a.length,c=function(e){let t=e.__cachedHeaderRowCount;return void 0===t&&(t=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=t),t}(e);!function(e,t,r){for(;e._rowPool.length<t;)e._rowPool.push(_t());if(e._rowPool.length<=t)return;const i=e.__frameworkAdapter;i?.beginBatch?.(e);try{for(let n=t;n<e._rowPool.length;n++){const t=e._rowPool[n];wt(i,t),t.parentNode===r&&t.remove()}e._rowPool.length=t}finally{i?.endBatch?.(e)}}(e,o,s);const d=n&&!1!==e.__hasRenderRowPlugins,u=e._hasAfterRowRenderHook?.()??!1,h=!!e.effectiveConfig?.rowClass,g=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let f=0;f<o;f++){const r=t+f,o=e._rows[r],p=e._rowPool[f],w=r+c+1;p.__ariaRowIndex!==w&&(p.__ariaRowIndex=w,p.setAttribute("aria-rowindex",String(w)));const m=p.__rowDataRef!==o;if(m&&p.__hasCellLoading&&xt(e,p,p.children),d){const t=p.__hasCellLoading?Array.from(p.children):void 0;m&&p.hasAttribute("aria-busy")&&ft(p,!1,void 0,e.__frameworkAdapter);const a=p.hasAttribute("aria-busy")?p.querySelector(":scope > .tbw-row-loading-overlay"):null;if(n(o,p,r)){t&&xt(e,p,t),a&&a.parentNode!==p&&e.__frameworkAdapter?.unmount?.(a),p.__epoch=i,p.__rowDataRef=o,h&&!Pt(o)&&Tt(e,p,o),p.parentNode!==s&&s.appendChild(p);continue}}let b=p.children.length;b>l&&p.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&b--;let v=p.__epoch===i&&b===l&&!p.__isCustomRow;if(v&&m&&Mt(p,a,l)&&(v=!1),Ht(e,p,o,r,i,v,m),kt(e,p,o),Tt(e,p,o),g){const e=!0===o?.__loading?void 0:g(o,r);void 0!==e&&e>0?p.style.setProperty("--tbw-row-height",`${e}px`):p.style.removeProperty("--tbw-row-height")}u&&e._afterRowRender?.({row:o,rowIndex:r,rowElement:p}),p.parentNode!==s&&s.appendChild(p)}}function Dt(e,t){t!==e.classList.contains("cell-focus")&&(e.classList.toggle("cell-focus",t),e.setAttribute("aria-selected",String(t)))}function It(e,t,r,i,n){const o=r.cellClass;if(o){St(t);try{Et(t,o(se(i,r,n),i,r))}catch(s){v("TBW061",`cellClass callback error for column '${r.field}': ${s}`,e.id),t.removeAttribute("data-dynamic-classes")}}}Ct.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';var Ot=/Reflect\.|\bProxy\b|ownKeys\(/;function zt(e,t,r){null!==r?(t.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(t),V(t,r),j(t)):t.textContent=""}function Nt(e,t,r,i,n,o,s,a){const l=mt(e,i);let c;const d=t.__hasCellLoading?ht(r):null;if(l)c=se(o,i,s),function(e,t,r,i,n,o){const s=o({row:i,value:n,field:r.field,column:r,grid:e,cellEl:t});"string"==typeof s?(e.__frameworkAdapter?.releaseCell?.(t),V(t,s)):s instanceof Node?s.parentElement!==t&&(e.__frameworkAdapter?.releaseCell?.(t),t.innerHTML="",t.appendChild(s)):null==s&&(e.__frameworkAdapter?.releaseCell?.(t),t.textContent=null==n?"":String(n))}(e,r,i,o,c,l);else if(i.__compiledView){c=se(o,i,s);const t=i.__compiledView({row:o,value:c,field:i.field,column:i});zt(e,r,i.__compiledView.__blocked?null:t)}else if(i.__viewTemplate){c=se(o,i,s);const t=i.__viewTemplate.innerHTML;zt(e,r,Ot.test(t)?null:B(t,{row:o,value:c}))}else{if(i.externalView)return void(d&&r.appendChild(d));c=se(o,i,s),function(e,t,r,i,n){t.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(t);const o=bt(e,r);if(o){let a;try{const e=o(n,i);a=null==e?"":String(e)}catch(s){v(w,`Format error in column '${r.field}': ${s}`,e.id),a=null==n?"":String(n)}t.textContent=a}else"date"===r.type?t.textContent=ze(n):"boolean"===r.type?t.innerHTML=Oe(!!n):t.textContent=null==n?"":String(n)}(e,r,i,o,c)}d&&r.appendChild(d),a&&At(e,t,r,i,n,o,s,c)}function Ft(e,t,r,i){const n=t.children,o=e._visibleColumns,s=o.length,a=n.length,l=s<a?s:a,c=String(i),d=e._hasAfterCellRenderHook?.()??!1;if(!function(e,t,r){const i=e.__hasSpecialColumns;if(void 0!==i)return i;let n=!1;const o=e.__frameworkAdapter;for(let s=0;s<r;s++){const r=t[s];if(r.__viewTemplate||r.__compiledView||r.renderer||r.viewRenderer||r.externalView||r.format||r.cellClass||"date"===r.type||"boolean"===r.type||r.type&&o?.getTypeDefault?.(r.type,e._hostElement)?.renderer||r.type&&o?.getTypeDefault?.(r.type,e._hostElement)?.format){n=!0;break}}return e.__hasSpecialColumns=n,n}(e,o,s))return void function(e,t,r,i,n,o,s,a,l){const c=e._focusRow,d=e._focusCol,u=!0===t.__hasCellLoading;for(let h=0;h<n;h++){const n=r[h];if(n.classList.contains(k.EDITING))continue;const g=u?ht(n):null;n.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(n);const f=i[h],p=se(o,f,s);n.textContent=null==p?"":String(p),g&&n.appendChild(g),n.getAttribute("data-row")!==a&&n.setAttribute("data-row",a),Dt(n,c===s&&d===h),l&&At(e,t,n,f,h,o,s,p)}}(e,t,n,o,l,r,i,c,d);if(function(e,t,r){for(let i=0;i<r;i++)if(t[i].externalView&&!e[i].querySelector("[data-external-view]"))return!0;return!1}(n,o,l))return void Ut(e,t,r,i);const u=e._focusRow,h=e._focusCol;for(let g=0;g<l;g++){const s=o[g],a=n[g];a.getAttribute("data-row")!==c&&a.setAttribute("data-row",c);const l=a.classList.contains(k.EDITING);l||Dt(a,u===i&&h===g),It(e,a,s,r,i),l||Nt(e,t,a,s,g,r,i,d)}}function qt(e,t,r){const i=yt.content.firstElementChild.cloneNode(!0);return i.setAttribute("aria-colindex",String(t+1)),i.setAttribute("data-col",String(t)),i.setAttribute("data-row",String(r)),i.setAttribute("data-field",e.field),i.setAttribute("data-header",e.header??e.field),e.type&&i.setAttribute("data-type",e.type),i}function $t(e,t,r,i,n,o){const s=mt(e,r);if(s)return function(e,t,r,i,n,o){const s=i({row:o,value:n,field:r.field,column:r,grid:e,cellEl:t});return"string"==typeof s?(V(t,s),!0):(s instanceof Node?s.parentElement!==t&&(t.textContent="",t.appendChild(s)):null==s&&(t.textContent=null==n?"":String(n)),!1)}(e,t,r,s,i,n);if(r.externalView)return function(e,t,r,i,n){const o=r.externalView,s=document.createElement("div");s.setAttribute("data-external-view",""),s.setAttribute("data-field",r.field),t.appendChild(s);const a={row:n,value:i,field:r.field,column:r,grid:e};if(o.mount)try{o.mount({placeholder:s,context:a,spec:o})}catch(l){v("TBW063",`External view mount error for column '${r.field}': ${l}`,e.id)}else queueMicrotask(()=>{try{e.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:s,spec:o,context:a}}))}catch(l){v("TBW064",`External view event dispatch error for column '${r.field}': ${l}`,e.id)}});s.setAttribute("data-mounted","")}(e,t,r,i,n),!1;const a=r.__compiledView;if(a){const e=a({row:n,value:i,field:r.field,column:r});return a.__blocked?(t.textContent="",t.setAttribute("data-blocked-template","")):V(t,e),!0}const l=r.__viewTemplate;if(l){const e=l.innerHTML;return/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(t.textContent="",t.setAttribute("data-blocked-template",""),!1):(V(t,B(e,{row:n,value:i})),!0)}return function(e,t,r,i){i||"date"!==t.type?i||"boolean"!==t.type?e.textContent=null==r?"":String(r):e.innerHTML=Oe(!!r):e.textContent=ze(r)}(t,r,i,o),!1}function Wt(e,t){if(t){j(e);const t=e.textContent||"";/Proxy|Reflect\.ownKeys/.test(t)&&(e.textContent=t.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(e.textContent||"")&&(e.textContent=""))}e.hasAttribute("data-blocked-template")&&(e.textContent||"").trim().length&&(e.textContent="")}function Vt(e,t,r){("function"==typeof t.editable?t.editable(r):t.editable)?e.tabIndex=0:"boolean"===t.type&&(e.hasAttribute("tabindex")||(e.tabIndex=0))}function Ut(e,t,r,i){!function(e,t){t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy");const r=e.__frameworkAdapter;if(r?.releaseCell||r?.unmount){r.beginBatch?.(e);try{gt(t,r);const e=t.children;for(let t=e.length-1;t>=0;t--){const i=e[t];ut(i,r),r.releaseCell?.(i)}t.innerHTML=""}finally{r.endBatch?.(e)}}else t.innerHTML=""}(e,t);const n=e._visibleColumns,o=n.length,s=e._focusRow,a=e._focusCol,l=e._hasAfterCellRenderHook?.()??!1,c=document.createDocumentFragment();for(let u=0;u<o;u++){const o=n[u],h=qt(o,u,i);let g=se(r,o,i);const f=bt(e,o);if(f)try{g=f(g,r)}catch(d){v(w,`Format error in column '${o.field}': ${d}`,e.id)}Wt(h,$t(e,h,o,g,r,!!f)),Vt(h,o,r),s===i&&a===u?(h.classList.add("cell-focus"),h.setAttribute("aria-selected","true")):h.setAttribute("aria-selected","false"),It(e,h,o,r,i),l&&At(e,t,h,o,u,r,i,g),c.appendChild(h)}t.appendChild(c)}function Bt(e,t,r){if(t.target?.closest(".resize-handle"))return;const i=Ne(r.querySelector(".cell[data-row]"));if(i<0)return;const n=e._rows[i];if(!n)return;if(e._dispatchRowClick?.(t,i,n,r))return;const o=t.target?.closest(".cell[data-col]");if(o){const r=Number(o.getAttribute("data-col"));if(!isNaN(r)){if(e._dispatchCellClick?.(t,i,r,o))return;const n=e._focusRow!==i||e._focusCol!==r;if(e._focusRow=i,e._focusCol=r,o.classList.contains(k.EDITING)){n&&(Fe(e._bodyEl??e),o.classList.add("cell-focus"));const r=t.target,i=o.contains(r)&&r.matches('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])')?r:o.querySelector(H);try{i?.focus({preventScroll:!0})}catch{}return}it(e)}}}var Gt=new WeakMap,jt=T.TRUNCATED;function Yt(e,t){const r=Ne(t),i=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(r<0||i<0)return;e._focusRow=r,e._focusCol=i,Fe(e._bodyEl),t.classList.add("cell-focus"),t.setAttribute("aria-selected","true");const n=t.closest("tbw-grid, [data-tbw-grid]");n&&document.activeElement!==n&&n.focus({preventScroll:!0})}function Xt(e,t,r,i){let n=null;const o=r.composedPath?.();if(n=o&&o.length>0?o[0]:r.target,!n||!t.contains(n)||!n.closest?.("[data-col]")){const e=document.elementFromPoint(r.clientX,r.clientY);e&&(n=e)}const s=n?.closest?.("[data-col]"),a=n?.closest?.(".data-grid-row"),l=n?.closest?.(".header-row");let c,d,u,h,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(u=e._rows[c],f=e._visibleColumns[d],h=f?.field,g=u&&h?re(u,h):void 0)),{type:i,row:u,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:h,value:g,column:f,originalEvent:r,cellElement:s??void 0,rowElement:a??void 0,isHeader:!!l,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}var Kt;function Zt(e,t,r){if(0!==r.button&&"mouse"===r.pointerType)return;if(Gt.get(e))return;const i=function(e){return"touch"===e.pointerType||"pen"===e.pointerType||"mouse"!==e.pointerType&&"coarse"===ct()}(r);let n=null;const o=()=>{const i=Xt(e,t,r,"mousedown");return e._dispatchCellMouseDown?.(i)??!1};if(!i){if(!o())return;Gt.set(e,!0)}ot(r,t,{onPromote:()=>{if(i){if(!o())return;Gt.set(e,!0),n=function(e){if(!e)return()=>{};const t=e.style.touchAction;return e.style.touchAction="none",()=>{e.style.touchAction=t}}(e._bodyEl),function(e){const t=e.ownerDocument;if(!t)return;let r=null;const i=t=>{const r=t.target;r&&e.contains(r)&&(t.preventDefault(),t.stopPropagation(),n())},n=()=>{null!==r&&clearTimeout(r),r=null,t.removeEventListener("contextmenu",i,!0)};t.addEventListener("contextmenu",i,!0),r=setTimeout(n,700)}(t)}},onMove:r=>{if(!Gt.get(e))return;const i=Xt(e,t,r,"mousemove");e._dispatchCellMouseMove?.(i)},onEnd:r=>{if(n?.(),n=null,!Gt.get(e))return;const i=Xt(e,t,r,"mouseup");e._dispatchCellMouseUp?.(i),Gt.set(e,!1)},onCancel:()=>{n?.(),n=null,Gt.set(e,!1)}},i?{longPressDuration:400}:{threshold:3})}function Qt(e,t,r,i){t.addEventListener("keydown",t=>rt(e,t),{signal:i}),r.addEventListener("pointerdown",t=>Zt(e,r,t),{signal:i}),r.addEventListener("mouseover",t=>{if(e.getPluginByName?.("tooltip"))return;const r=t.target.closest(".cell");if(!r)return;const i=t.relatedTarget;i&&r.contains(i)||function(e){const t=e.hasAttribute(jt);if(e.title&&!t)return;const r=e.scrollWidth>e.clientWidth?(e.textContent??"").trim():"";r?(e.title=r,e.setAttribute(jt,"")):t&&(e.removeAttribute("title"),e.removeAttribute(jt))}(r)},{signal:i,passive:!0})}var Jt=class{#e;#k=new Set;#T=new Map;#P=null;constructor(e){this.#e=e,this.#L()}focusCell(e,t){const r=this.#e,i=r._rows.length-1;if(i<0)return;let n;if("string"==typeof t){if(n=r._visibleColumns.findIndex(e=>e.field===t),n<0)return}else n=t;const o=r._visibleColumns.length-1;o<0||(r._focusRow=Math.max(0,Math.min(e,i)),r._focusCol=Math.max(0,Math.min(n,o)),it(r))}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 r=this.#e._virtualization;if(!r.enabled)return;const i=r.container;if(!i)return;const n=this.#e._rows.length;if(0===n)return;const o=Math.max(0,Math.min(e,n-1)),s=t?.align??"nearest",a=t?.behavior??"instant";let l,c;const d=r.positionCache;r.variableHeights&&d&&d.length>o?(l=d[o].offset,c=d[o].height):(l=o*r.rowHeight,c=r.rowHeight);const u=r.viewportEl?.clientHeight??i.clientHeight??0;if(u<=0)return;const h=this.#e._getVerticalScrollOffsets?.(o)??{top:0,bottom:0};if(h.skipScroll)return;const g=Math.max(0,h.top),f=u-g-Math.max(0,h.bottom);if(f<=0)return;const p=i.scrollTop,w=l+c,m=p+g,b=p+g+f;let v;switch(s){case"start":v=l-g;break;case"center":v=l-g-f/2+c/2;break;case"end":v=w-f-g;break;default:if(l>=m&&w<=b)return;v=l<m?l-g:w-f-g}v=Math.max(0,v);const y=Ye(v,r.scrollMapping);"smooth"===a&&"0"!==getComputedStyle(this.#e).getPropertyValue("--tbw-animation-enabled").trim()?i.scrollTo({top:y,behavior:"smooth"}):i.scrollTop=y}scrollToRowById(e,t){const r=this.#e._getRowEntry(e);r&&this.scrollToRow(r.index,t)}registerExternalFocusContainer(e){if(this.#k.has(e))return;this.#k.add(e);const t=new AbortController,r=t.signal,i=this.#e;e.addEventListener("focusin",e=>{i.dataset.hasFocus="",this.#D(e.target)},{signal:r}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete i.dataset.hasFocus,null===t&&this.#I()},{signal:r}),this.#T.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#k.delete(e);const t=this.#T.get(e);t&&(t(),this.#T.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.#k)if(t.contains(e))return!0;return!1}#L(){const e=this.#e;e.addEventListener("focusin",e=>this.#D(e.target),{capture:!0}),e.addEventListener("focusout",e=>{null===e.relatedTarget&&this.#I()})}#D(e){if(!(e instanceof HTMLElement))return;if(e===this.#e)return;const t=e.closest?.(".cell");t&&!t.classList.contains("editing")||this.isInExternalFocusContainer(e)||(this.#P=e)}#I(){queueMicrotask(()=>{this.#e.isConnected&&document.activeElement===document.body&&this.restoreLastFocus()})}restoreLastFocus(){const e=this.#P;if(!e)return!1;if(!e.isConnected)return this.#P=null,!1;if(e===document.activeElement)return!0;try{e.focus({preventScroll:!0})}catch{return!1}return document.activeElement===e}get lastFocusedElement(){return this.#P?.isConnected?this.#P:null}};var er="function"==typeof requestIdleCallback;function tr(e){er?cancelIdleCallback(e):clearTimeout(e)}function rr(){return"function"==typeof HTMLElement.prototype?.showPopover}function ir(e,t){const r=document.createElement("button");return r.type="button",r.className="tbw-size-popover-btn",r.setAttribute("aria-label",e),r.textContent=t,r}function nr(e){const t=e.step??16;let r,i=null,n=null,o=null,s=!1,a=!1;const l=new AbortController;function c(){s&&i&&(s=!1,rr()&&i.hidePopover(),i.hidden=!0,o?.removeAttribute("data-tbw-size-open"),o=null)}function d(){n&&(n.value=String(Math.round(e.getSize(r))))}function u(t){Number.isFinite(t)&&(e.setSize(r,t),d())}return document.addEventListener("pointerdown",e=>{s&&i&&!e.composedPath().includes(i)&&c()},{capture:!0,signal:l.signal}),document.addEventListener("keydown",e=>{"Escape"===e.key&&c()},{capture:!0,signal:l.signal}),{get element(){return i},open(h,g){if(a)return;r=h,o?.removeAttribute("data-tbw-size-open"),o=g,g.setAttribute("data-tbw-size-open",""),i||(i=function(){const i=document.createElement("div");i.id=e.id,i.className="tbw-size-popover",i.setAttribute("popover","manual"),i.setAttribute("role","group"),i.hidden=!0;const o=ir("Narrower","−"),s=ir("Wider","+"),a=ir("Reset size","Reset"),h=document.createElement("input");return h.type="number",h.className="tbw-size-popover-input",h.min="0",h.step="any",h.setAttribute("aria-label","Size in pixels"),o.addEventListener("click",()=>u(e.getSize(r)-t),{signal:l.signal}),s.addEventListener("click",()=>u(e.getSize(r)+t),{signal:l.signal}),a.addEventListener("click",()=>{e.reset(r),d()},{signal:l.signal}),h.addEventListener("change",()=>u(h.valueAsNumber),{signal:l.signal}),i.addEventListener("focusout",e=>{const t=e.relatedTarget;t instanceof Node&&!i.contains(t)&&c()},{signal:l.signal}),i.append(o,h,s,a),n=h,i}());const f=e.getHost(h)??document.body;i.parentNode!==f&&f.appendChild(i),i.setAttribute("aria-label",e.getLabel(h)),d(),i.hidden=!1,!s&&rr()&&i.showPopover(),s=!0,function(e){if(!i)return;const t=e.getBoundingClientRect(),r=i.getBoundingClientRect(),n=(e,t)=>Math.max(4,Math.min(e,t-4)),o=n(t.left+t.width/2-r.width/2,window.innerWidth-r.width),s=t.bottom+6,a=t.top-6-r.height,l=t.height>3*r.height;let c;c=!l&&s+r.height<=window.innerHeight?s:!l&&a>=4?a:n(t.top+t.height/2-r.height/2,window.innerHeight-r.height),i.style.left=`${Math.round(o)}px`,i.style.top=`${Math.round(c)}px`}(g),n?.focus()},close:c,dispose(){a=!0,c(),l.abort(),i?.remove(),i=null,n=null}}}function or(e){let t=null,r=null,i=!1,n=null,o=null,s=null,a=null,l=null;const c=()=>{null!==l&&(clearTimeout(l),l=null)},d=t=>{const r=e._visibleColumns[t];return null!=r?.__renderedWidth?r.__renderedWidth:"number"==typeof r?.width?r.width:(t=>(e._headerRowEl??e.findHeaderRow?.())?.querySelectorAll(".cell")[t])(t)?.getBoundingClientRect().width??0},u=(t,r)=>{const i=e._visibleColumns[t];if(!i)return null;const o=Math.max(function(e){return"number"==typeof e?.minWidth&&Number.isFinite(e.minWidth)&&e.minWidth>0?e.minWidth:40}(i),r);return i.width=o,i.__userResized=!0,i.__renderedWidth=o,null==n&&(n=requestAnimationFrame(()=>{n=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:i.field,width:o}})),o},h=e=>{if(!t)return;const r=e.clientX-t.startX;0!==r&&(i=!0),u(t.colIndex,t.startWidth+r)};let g=!1;const f=()=>{g=!0,requestAnimationFrame(()=>{g=!1})},p=r=>{r&&f(),null!==o&&(document.documentElement.style.cursor=o,o=null),null!==s&&(document.body.style.userSelect=s,s=null),t=null,r&&e.requestStateChange&&e.requestStateChange()};function w(t){const r=e._visibleColumns[t];r&&(c(),r.__userResized=!1,r.__renderedWidth=void 0,r.width=r.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:r.field,width:r.width}})))}return{get isResizing(){return null!==t||g},start(n,g,m,b){const v=function(e){return"pointerId"in e?e:new PointerEvent("pointerdown",{pointerId:1,pointerType:"mouse",isPrimary:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons})}(n);n.preventDefault(),r?.(),r=null,c(),i=!1;const y=e._headerRowEl??e.findHeaderRow?.();y&&function(t,r){const i=r.querySelectorAll(".cell");for(let n=0;n<e._visibleColumns.length;n++){if(n===t)continue;const r=e._visibleColumns[n];if(null==r.width&&!r.__userResized){const e=i[n]?.getBoundingClientRect().width;e&&(r.width=Math.round(e),r.__userResized=!0,r.__renderedWidth=r.width)}}}(g,y);const C=e._visibleColumns[g],_="number"==typeof C?.width?C.width:void 0,R=C?.__renderedWidth??_??m.getBoundingClientRect().width;t={startX:v.clientX,colIndex:g,startWidth:R,startConfiguredWidth:C?.width,startRenderedWidth:C?.__renderedWidth,startUserResized:C?.__userResized??!1},null===o&&(o=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",null===s&&(s=document.body.style.userSelect),document.body.style.userSelect="none";const S=b??m;r=ot(v,S,{onMove:h,onEnd:()=>{r=null,i?p(!0):(f(),p(!1),l=setTimeout(()=>{l=null,function(t,r){a??=nr({id:"tbw-column-size-popover",getSize:d,setSize:(t,r)=>{u(t,r),e.requestStateChange?.()},reset:w,getLabel:t=>{const r=e._visibleColumns[t];return`Width of column ${String(r?.header??r?.field??t+1)}`},getHost:()=>e}),a.open(t,r)}(g,S)},300))},onCancel:()=>{r=null,(()=>{const r=t;if(r){const t=e._visibleColumns[r.colIndex];t&&(t.width=r.startConfiguredWidth,t.__renderedWidth=r.startRenderedWidth,t.__userResized=r.startUserResized,e.updateTemplate?.(),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:t.field,width:r.startWidth}}))),f()}p(!1)})()}})},resetColumn:w,setColumnWidth(t,r){null!=u(t,r)&&e.requestStateChange?.()},getColumnWidth:d,dispose(){r?.(),r=null,p(null!==t),c(),a?.dispose(),a=null,null!=n&&(cancelAnimationFrame(n),n=null)}}}var sr="data-animating",ar={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},lr={change:500,insert:300,remove:200};function cr(e,t){const r=ar[t],i=getComputedStyle(e).getPropertyValue(r);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 lr[t]}function dr(e,t,r){if(t<0)return Promise.resolve(!1);const i=e.findRenderedRowElement?.(t);return i?new Promise(e=>{!function(e,t,r){e.removeAttribute(sr),e.offsetWidth,e.setAttribute(sr,t);const i=cr(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(sr),r?.()},i)}(i,r,()=>e(!0))}):Promise.resolve(!1)}function ur(e,t){const r=e;return!0===r?.__loading?null!=r.__index?`__loading:${r.__index}`:null!=r.__groupKey?`__loading:group:${r.__groupKey}`:void 0:t?t(e):"id"in r&&null!=r.id?String(r.id):"_id"in r&&null!=r._id?String(r._id):void 0}var hr=class{#e;constructor(e){this.#e=e}getRow(e){return this.#e._getRowEntry(e)?.row}#O(e,t,r,i,n){const o=this.#e,s=[];for(const[a,l]of Object.entries(i)){if("__proto__"===a||"constructor"===a||"prototype"===a)continue;const c=re(t,a);if(c===l)continue;const d=o.query?.("commitCellValue",{rowIndex:r,rowId:e,row:t,field:a,oldValue:c,newValue:l,source:n});d?.includes(!1)||(d?.includes(!0)||(oe(t,a,l),ae(t)),s.push({field:a,oldValue:c,newValue:l}),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:e,rowIndex:r,field:a,oldValue:c,newValue:l,changes:i,source:n},bubbles:!0,composed:!0})))}return s}updateRow(e,t,r="api"){const i=this.#e,n=i._getSourceRowEntry(e);if(!n)return void("history"!==r&&v(p,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id));const{row:o,index:s}=n;this.#O(e,o,s,t,r).length>0&&(Rt(i),i._requestSchedulerPhase(Re.VIRTUALIZATION,"updateRow"),i._emitDataChange())}updateRows(e,t="api"){const r=this.#e;let i=!1;for(const{id:n,changes:o}of e){const e=r._getSourceRowEntry(n);if(!e){"history"!==t&&v(p,`Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`,r.id);continue}const{row:s,index:a}=e;this.#O(n,s,a,o,t).length>0&&(i=!0)}i&&(Rt(r),r._requestSchedulerPhase(Re.VIRTUALIZATION,"updateRows"),r._emitDataChange())}async insertRow(e,t,r=!0){const i=this.#e,n=Math.max(0,Math.min(e,i._rows.length));i.sourceRows=[...i.sourceRows,t];const o=[...i._rows];o.splice(n,0,t),i._rows=o,i._sortState&&(i.__originalOrder=[...i.__originalOrder,t]),this.#z(),i._emitPluginEvent("row-inserted",{row:t,index:n}),i._emitDataChange(),r&&(await new Promise(e=>requestAnimationFrame(()=>e())),await dr(i,n,"insert"))}async removeRow(e,t=!0){const r=this.#e,i=r._rows[e];if(!i)return;t&&await dr(r,e,"remove");const n=r._rows.indexOf(i);if(n<0)return i;const o=[...r._rows];o.splice(n,1),r._rows=o;const s=r.sourceRows.indexOf(i);if(s>=0){const e=[...r.sourceRows];e.splice(s,1),r.sourceRows=e}if(r._sortState){const e=r.__originalOrder.indexOf(i);if(e>=0){const t=[...r.__originalOrder];t.splice(e,1),r.__originalOrder=t}}return this.#z(),r._emitDataChange(),t&&this.#N(),i}async applyTransaction(e,t=!0){const r={added:[],updated:[],removed:[]};return await this.#F(e,r,t),this.#q(e,r),this.#$(e,r),this.#W(r),t&&await this.#V(r),r}async#F(e,t,r){if(!e.remove?.length)return;const i=this.#e;for(const{id:n}of e.remove){const e=i._getRowEntry(n);if(!e)continue;const{row:o}=e;if(r){const e=i._rows.indexOf(o);e>=0&&await dr(i,e,"remove")}const s=i._rows.indexOf(o);if(s<0){t.removed.push(o);continue}const a=[...i._rows];a.splice(s,1),i._rows=a;const l=i.sourceRows.indexOf(o);if(l>=0){const e=[...i.sourceRows];e.splice(l,1),i.sourceRows=e}if(i._sortState){const e=i.__originalOrder.indexOf(o);if(e>=0){const t=[...i.__originalOrder];t.splice(e,1),i.__originalOrder=t}}t.removed.push(o)}}#q(e,t){if(!e.update?.length)return;const r=this.#e,i=new Set(e.remove?.map(e=>e.id));for(const{id:n,changes:o}of e.update){if(i.has(n))continue;const e=r._getRowEntry(n);if(!e)continue;const{row:s,index:a}=e;let l=!1;for(const[t,i]of Object.entries(o)){const e=re(s,t);e!==i&&(l=!0,oe(s,t,i),ae(s),r.dispatchEvent(new CustomEvent("cell-change",{detail:{row:s,rowId:n,rowIndex:a,field:t,oldValue:e,newValue:i,changes:o,source:"api"},bubbles:!0,composed:!0})))}l&&t.updated.push(s)}}#$(e,t){if(!e.add?.length)return;const r=this.#e;for(const i of e.add)r.sourceRows=[...r.sourceRows,i],r._rows=[...r._rows,i],r._sortState&&(r.__originalOrder=[...r.__originalOrder,i]),t.added.push(i)}#W(e){const t=this.#e,r=e.added.length>0||e.removed.length>0,i=e.updated.length>0;r?this.#z():i&&(Rt(t),t._requestSchedulerPhase(Re.VIRTUALIZATION,"applyTransaction")),(r||i)&&t._emitDataChange()}async#V(e){const t=this.#e;if(e.added.length>0){await new Promise(e=>requestAnimationFrame(()=>e()));for(const r of e.added){const e=t._rows.indexOf(r);e>=0&&await dr(t,e,"insert")}}for(const r of e.updated){const e=t._rows.indexOf(r);e>=0&&await dr(t,e,"change")}e.removed.length>0&&this.#N()}#z(){const e=this.#e;Rt(e),e._rebuildRowIdMap(),e.__rowRenderEpoch++;for(let t=0;t<e._rowPool.length;t++)e._rowPool[t].__epoch=-1;e.refreshVirtualWindow(!0)}#N(){const e=this.#e;requestAnimationFrame(()=>{const t=e.querySelectorAll('[data-animating="remove"]');for(let e=0;e<t.length;e++)t[e].removeAttribute("data-animating")})}#U=null;#B=[];#G=null;applyTransactionAsync(e){return this.#U||(this.#U={add:[],update:[],remove:[]}),e.add&&this.#U.add.push(...e.add),e.update&&this.#U.update.push(...e.update),e.remove&&this.#U.remove.push(...e.remove),new Promise(e=>{this.#B.push(e),null===this.#G&&(this.#G=requestAnimationFrame(()=>{this.#G=null;const e=this.#U,t=this.#B;this.#U=null,this.#B=[],this.applyTransaction(e,!1).then(e=>{for(const r of t)r(e)})}))})}},gr="tbw-grid",fr=gr;function pr(){return fr}var wr="tbw-grid-styles",mr="",br=new Map;function vr(){const e=function(){const e=pr();return"tbw-grid"===e?wr:`${wr}-${e}`}();let t=document.getElementById(e);return t||(t=document.createElement("style"),t.id=e,t.setAttribute("data-tbw-grid","true"),document.head.appendChild(t)),t}function yr(e){const t=pr();return"tbw-grid"===t?e:e.replace(/(?<![-\w])tbw-grid(?![-\w])/g,t)}function Cr(){const e=vr(),t=Array.from(br.values()).join("\n");e.textContent=`${mr}\n\n/* Plugin Styles */\n${t}`}async function _r(e){if(mr)return;if("string"==typeof e&&e.length>0)return mr=yr(e),void Cr();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){v("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(mr=yr(t),Cr()):"undefined"!=typeof process&&"test"===process.env.NODE_ENV||v("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 Rr(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function Sr(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function Er(e,t){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 r=.95,i=1;let n=performance.now();const o=()=>{const s=performance.now(),a=s-n;n=s;const l=a/16,c=Math.pow(r,l);e.velocityY*=c,e.velocityX*=c;const d=16*e.velocityY,u=16*e.velocityX,h=Math.abs(d)>=i,g=Math.abs(u)>=i;h&&(t.fauxScrollbar.scrollTop+=d),g&&t.scrollArea&&(t.scrollArea.scrollLeft+=u),e.momentumRaf=h||g?requestAnimationFrame(o):0};e.momentumRaf=requestAnimationFrame(o)}(e,t),Rr(e)}function Ar(e,t,r,i){e.addEventListener("pointerdown",r=>{"touch"===r.pointerType&&null===t.activePointerId&&(t.activePointerId=r.pointerId,e.setPointerCapture(r.pointerId),function(e,t,r){Sr(r),r.startY=t,r.startX=e,r.lastY=t,r.lastX=e,r.lastTime=performance.now(),r.velocityY=0,r.velocityX=0,r.locked=!1}(r.clientX,r.clientY,t))},{passive:!0,signal:i}),e.addEventListener("pointermove",e=>{e.pointerId===t.activePointerId&&function(e,t,r,i){if(null===r.lastY||null===r.lastX)return!1;const n=performance.now(),o=r.lastY-t,s=r.lastX-e;if(null!==r.lastTime){const e=n-r.lastTime;e>0&&(r.velocityY=o/e,r.velocityX=s/e)}if(r.lastY=t,r.lastX=e,r.lastTime=n,r.locked){const{scrollTop:e,scrollHeight:t,clientHeight:r}=i.fauxScrollbar;if(o>0&&e<t-r||o<0&&e>0?i.fauxScrollbar.scrollTop+=o:0!==o&&window.scrollBy(0,o),i.scrollArea){const{scrollLeft:e,scrollWidth:t,clientWidth:r}=i.scrollArea;s>0&&e<t-r||s<0&&e>0?i.scrollArea.scrollLeft+=s:0!==s&&window.scrollBy(s,0)}return!0}const a=null!==r.startY?Math.abs(r.startY-t):0,l=null!==r.startX?Math.abs(r.startX-e):0;if(a<3&&l<3)return!1;const c=a>=l,{scrollHeight:d,clientHeight:u}=i.fauxScrollbar,h=d-u>0;let g=!1;if(i.scrollArea){const{scrollWidth:e,clientWidth:t}=i.scrollArea;g=e-t>0}return!!(c&&h||!c&&g)&&(r.locked=!0,i.fauxScrollbar.scrollTop+=o,i.scrollArea&&(i.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,r)&&e.preventDefault()},{passive:!1,signal:i}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Er(t,r))},{passive:!0,signal:i}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Rr(t))},{passive:!0,signal:i}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Rr(t))},{passive:!0,signal:i})}var xr=[{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}],Mr=[{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 Hr(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function kr(e){return`import '@toolbox-web/grid/features/${Hr(e)}';`}function Tr(e){return`import { ${Lr(e)}Plugin } from '@toolbox-web/grid/plugins/${Hr(e)}';`}function Pr(e){const t=e?.features;return!!t&&"object"==typeof t&&Object.keys(t).length>0}function Lr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Dr(e,t){return e.some(e=>e.name===t)}var Ir=class{#e;state;#j=0;#Y=0;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,scrollMapping:{rawContentHeight:0,spacerHeight:0,viewportHeight:0,capped:!1},...t}}#X(){const e=this.state,t=e.container??this.#e._hostElement,r=e.viewportEl??t,i=t?.clientHeight??0;return{fauxHeight:i,viewportHeight:r?.clientHeight??0,scrollAreaHeight:e.scrollAreaEl?e.scrollAreaEl.clientHeight:i}}updateCachedGeometry(){const e=this.state,t=e.container,r=e.viewportEl??t;r&&(e.cachedViewportHeight=r.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const i=e.scrollAreaEl;i&&(e.cachedScrollAreaHeight=i.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const r=this.state;let i,n,o;t?(({fauxHeight:i,viewportHeight:n,scrollAreaHeight:o}=this.#X()),r.cachedFauxHeight=i,r.cachedViewportHeight=n,r.cachedScrollAreaHeight=o):(i=r.cachedFauxHeight,n=r.cachedViewportHeight,o=r.cachedScrollAreaHeight||i);const s=o-n,a=Math.max(0,i-o);let l;return l=r.variableHeights&&r.positionCache?function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(r.positionCache):e*r.rowHeight,r.scrollMapping=Ge(l,n),r.scrollMapping.spacerHeight+s+a}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#e,r=t._rows,i=e.rowHeight||28,n=t.effectiveConfig?.getRowId,o=n?e=>n(e):void 0;e.positionCache=function(e,t,r,i,n){const o=new Array(e.length);let s=0;for(let a=0;a<e.length;a++){const l=e[a];let c=n?.(l,a),d=void 0!==c;void 0===c&&(c=We(t,l,i.rowId),d=void 0!==c),void 0===c&&(c=r,d=!1),o[a]={offset:s,height:c,measured:d},s+=c}return o}(r,e.heightCache,i,{rowId:o},this.#K());const s=function(e,t,r,i){let n=0,o=0;for(let s=0;s<e.length;s++){const r=e[s];r.measured&&void 0===i?.(t[s],s)&&(o+=r.height,n++)}return{measuredCount:n,averageHeight:n>0?o/n:r}}(e.positionCache,r,i,(e,r)=>t._getPluginRowHeight(e,r));e.measuredCount=s.measuredCount,s.measuredCount>0&&(e.averageHeight=s.averageHeight)}#K(){const e=this.#e,t=e.effectiveConfig?.rowHeight,r="function"==typeof t?t:void 0,i="number"==typeof t&&t>0?t:void 0;return(t,n)=>{const o=e._getPluginRowHeight(t,n);if(void 0!==o)return o;if(r&&!0!==t?.__loading){const e=r(t,n);if(void 0!==e&&e>0)return e}return i}}invalidateRowHeight(e,t){const r=this.state;if(!r.variableHeights)return;if(!r.positionCache)return;const i=this.#e._rows;if(e<0||e>=i.length)return;const n=i[e];let o=t;void 0===o&&(o=this.#e._getPluginRowHeight(n,e)),void 0===o&&(o=r.rowHeight);const s=r.positionCache[e];if(s&&!(Math.abs(s.height-o)<1)&&(function(e,t,r){if(t<0||t>=e.length)return;const i=e[t],n=r-i.height;if(i.measured=!0,0!==n){i.height=r;for(let r=t+1;r<e.length;r++)e[r].offset+=n}}(r.positionCache,e,o),r.totalHeightEl)){const e=this.calculateTotalSpacerHeight(i.length);r.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const r=this.state;if(!r.variableHeights)return;if(!r.positionCache)return;const i=this.#e,n=i._bodyEl;if(!n)return;const o=n.querySelectorAll(":scope > .data-grid-row"),s=i.effectiveConfig?.getRowId,a=i._rows,l=Ue({positionCache:r.positionCache,heightCache:r.heightCache,rows:a,defaultHeight:r.rowHeight,start:e,end:t,headerRowCount:i.__cachedHeaderRowCount??1,getPluginHeight:this.#K(),getRowId:s?e=>s(e):void 0},o);if(l.hasChanges&&(r.measuredCount=l.measuredCount,r.averageHeight=l.averageHeight,r.totalHeightEl)){const e=this.calculateTotalSpacerHeight(a.length);r.totalHeightEl.style.height=`${e}px`}}#Z(e,t){const r=this.#e;return r._renderVisibleRows(0,e),t||r._afterPluginRender(),!0}#Q(e,t,r,i){const n=this.state,o=this.#e,s=r||0!==n.start||n.end!==t;if(n.start=0,n.end=t,o._renderVisibleRows(0,t,o.__rowRenderEpoch),r){n.variableHeights&&this.initializePositionCache();let r=n.container?.scrollTop??0;if(n.totalHeightEl){const e=this.calculateTotalSpacerHeight(t,!0);n.totalHeightEl.style.height=`${e}px`;const i=e-n.cachedFauxHeight;r>i&&(r=i>0?i:0)}e.style.transform=`translateY(${-r}px)`}return o._updateAriaCounts(t,o._visibleColumns.length),i||o._afterPluginRender(),s}#J(e,t){const r=this.state,i=r.positionCache;let n;r.variableHeights&&i&&i.length>0?(n=Ve(i,e),-1===n&&(n=0)):n=Math.floor(e/r.rowHeight),n-=n%2,n<0&&(n=0),t>0&&n>t-1&&(n=t-1);const o=this.#e._adjustPluginVirtualStart(n,e,r.rowHeight);return void 0!==o&&o<n&&(n=o-o%2,n<0&&(n=0)),n}#ee(e,t,r){const i=this.state,n=i.rowHeight,o=i.positionCache;let s;if(i.variableHeights&&o&&o.length>0){const i=t+3*n;let a=0;for(s=e;s<r&&a<i;)a+=o[s].height,s++;const l=Math.ceil(t/n)+3;s-e<l&&(s=Math.min(e+l,r))}else s=e+Math.ceil(t/n)+3;return s>r?r:s}#te(e){const t=this.state;queueMicrotask(()=>{if(!t.totalHeightEl)return;const r=this.calculateTotalSpacerHeight(e);0===t.cachedFauxHeight&&t.cachedViewportHeight>0||(t.totalHeightEl.style.height=`${r}px`)})}#re(){const e=this.state;this.#j||(this.#j=requestAnimationFrame(()=>{this.#j=0;const t=this.#e;if(!t._schedulerIsConnected||!e.totalHeightEl)return void(this.#Y=0);const{fauxHeight:r,viewportHeight:i,scrollAreaHeight:n}=this.#X();i!==e.cachedViewportHeight||n!==e.cachedScrollAreaHeight||r!==e.cachedFauxHeight?this.#Y>=3?this.#Y=0:(this.#Y++,t._requestSchedulerPhase(Re.VIRTUALIZATION,"geometry-drift")):this.#Y=0}))}refreshVirtualWindow(e=!1,t=!1){const r=this.state,i=this.#e,n=i._bodyEl;if(!n)return!1;const o=i._rows.length;if(!r.enabled)return this.#Z(o,t);if(e&&this.#re(),o<=r.bypassThreshold)return this.#Q(n,o,e,t);const s=r.container,a=r.viewportEl??s,l=e?r.cachedViewportHeight=a.clientHeight:r.cachedViewportHeight||(r.cachedViewportHeight=a.clientHeight),c=je(s.scrollTop,r.scrollMapping);e&&r.variableHeights&&this.initializePositionCache();const d=this.#J(c,o),u=this.#ee(d,l,o);if(!e&&d===r.start&&u===r.end)return!1;r.start=d,r.end=u;const h=e?r.cachedFauxHeight=s.clientHeight:r.cachedFauxHeight||(r.cachedFauxHeight=s.clientHeight);if(e&&r.scrollAreaEl&&(r.cachedScrollAreaHeight=r.scrollAreaEl.clientHeight),0===h&&l>0)return i._requestSchedulerPhase(Re.VIRTUALIZATION,"stale-refs-retry"),!1;e&&r.totalHeightEl&&(r.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(o)}px`);const g=r.positionCache,f=r.variableHeights&&g&&g[d]?g[d].offset:d*r.rowHeight;return n.style.transform=`translateY(${-(c-f)}px)`,i._renderVisibleRows(d,u,i.__rowRenderEpoch),e&&r.variableHeights&&this.measureRenderedRowHeights(d,u),i._updateAriaCounts(o,i._visibleColumns.length),e&&!t&&(i._afterPluginRender(),this.#te(o)),!0}#ie=!1;#ne=null;#oe=0;#se;#ae=!1;#le(){return this.#e._pluginManager?.hasRowHeightPlugin?.()??!1}configureVariableHeights(){const e=this.state,t=this.#e.effectiveConfig?.rowHeight,r=this.#le(),i="number"==typeof t&&t>0?t:null;"function"==typeof t||r?e.variableHeights&&i===this.#ne||(e.variableHeights=!0,e.rowHeight=i??(e.rowHeight||28),this.initializePositionCache(),this.#ie="function"!=typeof t&&null===i):!r&&"function"!=typeof t&&e.variableHeights?(e.variableHeights=!1,e.positionCache=null,this.#ie=!1):null!==i?(e.rowHeight=i,e.variableHeights=!1):requestAnimationFrame(()=>this.#ce()),this.#ne=i}#ce(){const e=this.#e,t=this.state;if(this.#le())return;const r=e.effectiveConfig?.rowHeight;if("number"==typeof r&&r>0)return;const i=e._bodyEl;if(!i?.querySelector(".data-grid-row"))return;const n=this.#de(),o=[];for(const g of i.querySelectorAll(".data-grid-row")){if(g.style.getPropertyValue("--tbw-row-height"))continue;let e=0;g.querySelectorAll(".cell").forEach(t=>{const r=t.offsetHeight;r>e&&(e=r)});const t=Math.max(g.getBoundingClientRect().height,e);t>0&&o.push(t)}if(0===o.length)return;o.sort((e,t)=>e-t);const s=o.length>>1,a=o.length%2==1?o[s]:(o[s-1]+o[s])/2,l=t.rowHeight,c=this.#oe,d=n>0&&c>0&&Math.abs(n-c)>1,u=n>0&&0===c,h=a>0&&a-l>1;if(n>0&&(this.#oe=n),d||u||h){const r=d||u?Math.max(n,a):a;Math.abs(r-l)>1&&(t.rowHeight=r,e._requestSchedulerPhase(Re.VIRTUALIZATION,"measureRowHeight"))}}#de(){const e=this.#e._hostElement;if(!e)return 0;const t=getComputedStyle(e).getPropertyValue("--tbw-row-height").trim();if(!t)return 0;if(t.endsWith("px"))return parseFloat(t)||0;const r=this.#e._bodyEl?.querySelector('.data-grid-row:not([style*="--tbw-row-height"]) > .cell');if(!r)return 0;const i=parseFloat(getComputedStyle(r).minHeight);return i>0?i:0}afterRenderRowHeights(){this.state.enabled&&this.#ue(),this.#ie&&this.#e._bodyEl?.querySelector(".data-grid-row")&&(this.#ie=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#he()||(this.#ie=!0)})}))}#he(){if(null!==this.#ne)return!0;const e=this.#e._bodyEl?.querySelector(".data-grid-row");if(!e)return!1;let t=0;e.querySelectorAll(".cell").forEach(e=>{const r=e.offsetHeight;r>t&&(t=r)});const r=Math.max(e.getBoundingClientRect().height,t);if(r<=0)return!1;const i=this.state;return Math.abs(r-i.rowHeight)>1&&(i.rowHeight=r),this.initializePositionCache(),i.totalHeightEl&&(i.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(this.#e._rows.length)}px`),!0}#ue(){if(this.#ae)return;const e=this.#e._bodyEl?.querySelector(".data-grid-row");e&&(this.#ae=!0,this.#se?.disconnect(),this.#se=new ResizeObserver(()=>this.#ce()),this.#se.observe(e))}disposeRowHeightObserver(){this.#se&&(this.#se.disconnect(),this.#se=void 0,this.#ae=!1,this.#oe=0)}};var Or=class{grid;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;#ge=new Map;eventListeners=new Map;queryHandlers=new Map;constructor(e){this.grid=e}attachAll(e,t=e=>e){const r=this.#fe(function(e,t){const r=new Set(e.map(e=>e.name)),i=[],n=e=>{for(const i of e.constructor.dependencies??[])!i.provide||r.has(i.name)||i.when&&!i.when(e.resolvedConfig)||(r.add(i.name),n(t(i.provide())));i.push(e)};for(const o of e)n(o);return i}(e,t));for(const i of r)this.attach(i)}#fe(e){if(e.length<2)return e;const t=new Map,r=new Map,i=[];for(const n of e){const e=n.constructor,o=t.get(e);if(!o){t.set(e,n),i.push(n);continue}const s=r.get(o)??[];s.push(n),r.set(o,s)}if(0===r.size)return i;for(const[n,o]of r)n.mergeConfigsFrom(o);return i}attach(e){if(function(e,t,r,i){const n=e.name,o=e.constructor.dependencies??[];for(const s of o){if(s.when&&!s.when(e.resolvedConfig))continue;const o=s.name,a=s.required??!0,l=s.reason;if(t.some(e=>e.name===o))continue;const c=s.severity??(a?"error":void 0);if(!c)continue;const d="error"===c?"requires":"recommends",u=l??`${Lr(n)}Plugin ${d} ${Lr(o)}Plugin`;"error"===c?Pr(i)?b(g,`Plugin dependency error:\n\n${u}.\n\n → Enable the required feature in gridConfig.features (pass \`true\` for defaults, or a config object — see the docs):\n ${kr(o)}\n ${kr(n)}\n features: {\n ${o}: true,\n ${n}: true,\n }`,r):b(g,`Plugin dependency error:\n\n${u}.\n\n → Add the required plugin to gridConfig.plugins BEFORE ${Lr(n)}Plugin:\n ${Tr(o)}\n plugins: [new ${Lr(o)}Plugin(), new ${Lr(n)}Plugin()]\n → Tip: the feature-based API is recommended and orders dependencies for you — features: { ${o}: true, ${n}: true }`,r):Ie()&&("warn"===c?v(f,`${u}.`,r):y(f,`${u}.`,r))}}(e,this.plugins,this.grid.getAttribute("id")??void 0,this.grid.effectiveConfig??this.grid.gridConfig),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,r]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,r);if(e.headerRenderers)for(const[t,r]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,r);if(e.cellEditors)for(const[t,r]of Object.entries(e.cellEditors))this.cellEditors.set(t,r);this.registerQueryHandlers(e),e.attach(this.grid),this.#pe();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 r of t.queries){let t=this.queryHandlers.get(r.type);t||(t=new Set,this.queryHandlers.set(r.type,t)),t.add(e)}}unregisterQueryHandlers(e){for(const[t,r]of this.queryHandlers)r.delete(e),0===r.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(),t.__releaseDisconnectSignal()}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.#ge.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 r of this.#we("processRows")){const e=r.processRows(t);e!==t&&(t=e)}return t}orderColumns(e){let t=e;for(const r of this.plugins)r.orderColumns&&(t=r.orderColumns(t));return t}processColumns(e){let t=[...e];for(const r of this.#we("processColumns"))t=r.processColumns(t);return t}processConfig(e){for(const t of this.#we("processConfig"))t.processConfig(e)}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterStructuralRender(){for(const e of this.#we("afterStructuralRender"))e.afterStructuralRender()}beforeStructuralRender(){for(const e of this.plugins)e.beforeStructuralRender?.()}parseLightDom(){for(const e of this.plugins)e.parseLightDom?.()}syncLightDom(){for(const e of this.plugins)e.syncLightDom?.()}needsStructuralRerender(){let e=!1;for(const t of this.plugins)t.needsStructuralRerender?.()&&(e=!0);return e}afterRender(){for(const e of this.#we("afterRender"))e.afterRender()}afterCellRender(e){for(const t of this.#we("afterCellRender"))t.afterCellRender(e)}hasAfterCellRenderHook(){return this._hasAfterCellRender}afterRowRender(e){for(const t of this.#we("afterRowRender"))t.afterRowRender(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#pe(){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.#ge.clear()}#we(e){let t=this.#ge.get(e);if(t)return t;t=this.plugins.filter(t=>e in t&&"function"==typeof t[e]);const r=t=>{const r=t.constructor.manifest?.hookPriority;return r?r[e]??0:0};return t.some(e=>0!==r(e))&&t.sort((e,t)=>r(e)-r(t)),this.#ge.set(e,t),t}onScrollRender(){for(const e of this.#we("onScrollRender"))e.onScrollRender()}getRowHeight(e,t){for(const r of this.plugins)if("function"==typeof r.getRowHeight){const i=r.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,r){let i=e;for(const n of this.plugins)if("function"==typeof n.adjustVirtualStart){const o=n.adjustVirtualStart(e,t,r);o<i&&(i=o)}return i}renderRow(e,t,r){for(const i of this.#we("renderRow"))if(i.renderRow?.(e,t,r))return!0;return!1}queryPlugins(e){const t=[],r=this.queryHandlers.get(e.type);if(r&&r.size>0){for(const i of r){const r=i.handleQuery?.(e);void 0!==r&&t.push(r)}return t}for(const i of this.plugins){const r=i.handleQuery?.(e);void 0!==r&&t.push(r)}return t}subscribe(e,t,r){let i=this.eventListeners.get(t);i||(i=new Map,this.eventListeners.set(t,i)),i.set(e,r)}unsubscribe(e,t){const r=this.eventListeners.get(t);r&&(r.delete(e),0===r.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,r]of this.eventListeners)r.delete(e),0===r.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const r=this.eventListeners.get(e);if(r)for(const n of r.values())try{n(t)}catch(i){C("TBW024",`Error in plugin event handler for "${e}": ${i}`,this.grid.getAttribute("id")??void 0)}}onKeyDown(e){for(const t of this.#we("onKeyDown"))if(t.onKeyDown(e))return!0;return!1}onCellClick(e){for(const t of this.#we("onCellClick"))if(t.onCellClick(e))return!0;return!1}onRowClick(e){for(const t of this.#we("onRowClick"))if(t.onRowClick(e))return!0;return!1}onHeaderClick(e){for(const t of this.#we("onHeaderClick"))if(t.onHeaderClick(e))return!0;return!1}onScroll(e){for(const t of this.#we("onScroll"))t.onScroll(e)}onCellMouseDown(e){for(const t of this.#we("onCellMouseDown"))if(t.onCellMouseDown(e))return!0;return!1}onCellMouseMove(e){for(const t of this.#we("onCellMouseMove"))if(t.onCellMouseMove(e))return!0;return!1}onCellMouseUp(e){for(const t of this.#we("onCellMouseUp"))if(t.onCellMouseUp(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let r=0,i=0,n=!1;for(const o of this.plugins){const s=o.getHorizontalScrollOffsets?.(e,t);s&&(r+=s.left,i+=s.right,s.skipScroll&&(n=!0))}return{left:r,right:i,skipScroll:n}}getVerticalScrollOffsets(e){let t=0,r=0,i=!1;for(const n of this.plugins){const o=n.getVerticalScrollOffsets?.(e);o&&(t+=o.top,r+=o.bottom,o.skipScroll&&(i=!0))}return{top:t,bottom:r,skipScroll:i}}getToolPanels(){const e=[];for(const t of this.plugins){const r=t.getToolPanel?.();r&&e.push({plugin:t,panel:r})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const r=t.getHeaderContent?.();r&&e.push({plugin:t,content:r})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}},zr=class e extends HTMLElement{static tagName=gr;static version="3.10.1";static get activeTag(){return pr()}static set activeTag(e){!function(e){fr=e}(e)}static#me=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","column-inference","loading"]}get#be(){return this}#ve=!1;#i;#n;#ye=[];get#b(){return this.#Ce?.effective??{}}#_e=!1;#Re=!1;#Se={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,columnInference:!1};#Ee;#Ae=0;#xe=null;#Me=0;#He=!1;#ke=0;#Te;#Pe={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#Le;#De;#Ie;#Oe={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#ze;#Ne;#Fe;#qe;#$e;#We;get _pluginManager(){return this.#ze}#Ve=!1;#Ue;#Be;#R;#Ce;#Ge=new Map;#je=!1;#Ye=new Set;#Xe=new Map;#Ke;#Ze={};#Qe=new Map;#Je=!1;#et=[];get _rows(){return this.#et}set _rows(e){this.#et=e,this.#Je=!0}#tt=[];get _columns(){return this.#b.columns??[]}set _columns(e){this.#b.columns=e,this.#rt=void 0}#rt;get _visibleColumns(){return this.#rt??=this._columns.filter(e=>!e.hidden)}_invalidateVisibleColumnsCache(){this.#rt=void 0}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#qe.state}set _virtualization(e){Object.assign(this.#qe.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#Ce?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#Ce&&(this.#Ce.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#Ce?.originalColumnNodes}set __originalColumnNodes(e){this.#Ce&&(this.#Ce.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=Array.isArray(e)?e:[],r=this.#ye;this.#ye=t,r!==t&&this.#it("rows")}get sourceRows(){return this.#ye}set sourceRows(e){this.#ye=Array.isArray(e)?e:[]}get columns(){return[...this._columns]}set columns(e){const t=Array.isArray(e)?d(e):e,r=this.#Ce?.getColumns();this.#Ce?.setColumns(t),r!==t&&this.#it("columns")}get gridConfig(){return this.#b}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#Ce?.getGridConfig();this.#Ce?.setGridConfig(e),t!==e&&(this.#Ce.clearLightDomCache(),this.#it("gridConfig"))}get _sourceConfig(){return this.#Ce?.getGridConfig()}get fitMode(){return this.#b.fitMode??"stretch"}set fitMode(e){const t=this.#Ce?.getFitMode();this.#Ce?.setFitMode(e),t!==e&&this.#it("fitMode")}get columnInference(){return this.#b.columnInference??"auto"}set columnInference(e){const t=this.#Ce?.getColumnInference();this.#Ce?.setColumnInference(e),t!==e&&this.#it("columnInference")}get loading(){return this.#je}set loading(e){const t=this.#je;this.#je=e,t!==e&&(e?(this.setAttribute("loading",""),this.setAttribute("aria-busy","true")):(this.removeAttribute("loading"),this.removeAttribute("aria-busy")),this.#nt(),this.#ot())}setRowLoading(e,t){const r=this.#Ye.has(e);t?this.#Ye.add(e):this.#Ye.delete(e),r!==t&&this.#st(e,t)}setCellLoading(e,t,r){let i=this.#Xe.get(e);const n=i?.has(t)??!1;r?(i||(i=new Set,this.#Xe.set(e,i)),i.add(t)):(i?.delete(t),0===i?.size&&this.#Xe.delete(e)),n!==r&&this.#at(e,t,r)}isRowLoading(e){return this.#Ye.has(e)}isCellLoading(e,t){return this.#Xe.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#Ye)this.#st(e,!1);this.#Ye.clear();for(const[e,t]of this.#Xe)for(const r of t)this.#at(e,r,!1);this.#Xe.clear()}get effectiveConfig(){return this.#b}get disconnectSignal(){return this.#Le||(this.#Le=new AbortController),this.#Le.signal}constructor(){super(),this.#lt(),this.#i=new Promise(e=>this.#n=e),this.#qe=new Ir(this),this.#$e=new Jt(this),this.#We=new hr(this),this.#Ee=new Se(this),this.#Ee.setInitialReadyResolver(()=>this.#n?.()),this.#Ce=new xe(this)}async#lt(){await _r('@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(#eee,#222);--tbw-color-fg:light-dark(#222,#eee);--tbw-color-fg-muted:light-dark(#555,#aaa);--tbw-color-accent:#3b82f6;--tbw-color-accent-fg:light-dark(#fff,#000);--tbw-color-accent-text:light-dark(#1d4ed8,#93c5fd);--tbw-color-success:light-dark(#357937,#4cae4f);--tbw-color-warning:#f59f0a;--tbw-color-error:light-dark(#d33131,#e06c6c);--tbw-color-danger:var(--tbw-color-error);--tbw-color-selection:light-dark(#fff7d6,#333);--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(#777,#666);--tbw-color-border-cell:var(--tbw-color-border);--tbw-color-border-header:var(--tbw-color-border);--tbw-color-shadow:light-dark(#0000001a,#0000004d);--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-column-selection-bg:rgba(from var(--tbw-color-accent) 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-touch-target-min:24px;--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;contain:content;width:100%;height:100%;min-height:0;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);outline:none;display:block;position:relative;overflow:clip}tbw-grid,tbw-grid *{box-sizing:border-box}tbw-grid>tbw-grid-column,tbw-grid>tbw-grid-type{display:none}tbw-grid .tbw-grid-root{flex-direction:column;height:100%;display:flex;position:relative}tbw-grid .tbw-grid-root.has-shell{flex-direction:column;height:100%;display:flex}tbw-grid .tbw-grid-root:has(.selected){-webkit-user-select:none;user-select:none}tbw-grid .tbw-grid-content{touch-action:none;flex-direction:row;flex:1;min-width:0;min-height:0;display:flex;overflow:hidden}tbw-grid .tbw-scroll-area{overflow-anchor:none;flex-direction:column;flex:1;min-width:0;min-height:0;display:flex;overflow:auto hidden}tbw-grid .rows-body-wrapper{flex-direction:row;flex:1;width:100%;min-width:fit-content;min-height:0;display:flex}tbw-grid .rows-body{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex;overflow:visible}tbw-grid .rows-container{flex-direction:row;flex:1;min-height:0;display:flex;position:relative;overflow:visible}tbw-grid .rows-viewport{touch-action:none;flex:1;min-width:0;display:block;position:relative;overflow:clip}tbw-grid .rows-viewport .rows{will-change:transform;min-width:100%;z-index:var(--tbw-z-layer-rows,1);position:absolute;top:0;left:0}tbw-grid .faux-vscroll{width:auto;z-index:var(--tbw-z-layer-header,30);touch-action:none;flex-shrink:0;position:sticky;inset-inline-end:0;overflow:hidden auto}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid .tbw-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}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{z-index:25;position:sticky}tbw-grid .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}tbw-grid .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}.tbw-size-popover{padding:var(--tbw-spacing-xs,.25rem);align-items:center;gap:var(--tbw-spacing-xs,.25rem);background:var(--tbw-color-panel-bg,light-dark(#fff,#232528));color:var(--tbw-color-fg,light-dark(#1a1a1a,#f0f0f0));border:1px solid var(--tbw-color-border,light-dark(#d0d0d4,#454545));border-radius:var(--tbw-border-radius,.25rem);box-shadow:0 4px 12px var(--tbw-color-shadow,#0000004d);font-family:var(--tbw-font-family,system-ui, sans-serif);font-size:var(--tbw-font-size-sm,.9285em);z-index:10001;--tbw-size-popover-radius:min(var(--tbw-border-radius,.25rem), 6px);margin:0;line-height:1;display:flex;position:fixed;inset:auto}.tbw-size-popover[hidden]{display:none}.tbw-size-popover button,.tbw-size-popover input{min-height:var(--tbw-touch-target-min,26px);border-radius:var(--tbw-size-popover-radius);color:inherit;font:inherit;line-height:1}:is(.tbw-size-popover button,.tbw-size-popover input):focus-visible{outline:var(--tbw-focus-outline,2px solid var(--tbw-color-accent,#4a90d9));outline-offset:var(--tbw-focus-outline-offset,1px)}.tbw-size-popover button{min-width:var(--tbw-touch-target-min,26px);padding:0 var(--tbw-spacing-sm,.5rem);cursor:pointer;background:0 0;border:1px solid #0000;justify-content:center;align-items:center;display:inline-flex}.tbw-size-popover button:hover{background:var(--tbw-color-row-hover,light-dark(#f0f0f0,#2a2a2a));border-color:var(--tbw-color-border-strong,light-dark(#777,#666))}.tbw-size-popover button:active{background:var(--tbw-color-accent,#4a90d9);color:var(--tbw-color-accent-fg,#fff)}.tbw-size-popover input{width:5ch;padding:0 var(--tbw-spacing-xs,.25rem);background:var(--tbw-color-bg,light-dark(#fff,#1a1c20));text-align:center;border:1px solid var(--tbw-color-border,light-dark(#d0d0d4,#454545));appearance:textfield}.tbw-size-popover input::-webkit-outer-spin-button{appearance:none;margin:0}.tbw-size-popover input::-webkit-inner-spin-button{appearance:none;margin:0}}\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{vertical-align:middle;display:inline-block;-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}tbw-grid [data-icon=expand]:empty:before{-webkit-mask-image:var(--tbw-icon-expand-mask);-webkit-mask-image:var(--tbw-icon-expand-mask);-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);-webkit-mask-image:var(--tbw-icon-collapse-mask);-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);-webkit-mask-image:var(--tbw-icon-sort-asc-mask);-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);-webkit-mask-image:var(--tbw-icon-sort-desc-mask);-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);-webkit-mask-image:var(--tbw-icon-sort-none-mask);-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);-webkit-mask-image:var(--tbw-icon-submenu-arrow-mask);-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);-webkit-mask-image:var(--tbw-icon-drag-handle-mask);-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);-webkit-mask-image:var(--tbw-icon-tool-panel-mask);-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);-webkit-mask-image:var(--tbw-icon-print-mask);-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);-webkit-mask-image:var(--tbw-icon-filter-mask);-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);-webkit-mask-image:var(--tbw-icon-filter-active-mask);-webkit-mask-image:var(--tbw-icon-filter-active-mask);mask-image:var(--tbw-icon-filter-active-mask)}.tbw-context-menu [data-icon]:empty:before{vertical-align:middle;width:1em;height:1em;display:inline-block}.tbw-context-menu [data-icon=submenu-arrow]:empty:before{content:var(--tbw-icon-submenu-arrow,"▶")}}\n@layer tbw-base{tbw-grid .header{z-index:var(--tbw-z-layer-header,30);background:var(--tbw-color-header-bg);flex-shrink:0;display:block;overflow:visible}tbw-grid .header-group-row{grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header,30);display:grid}tbw-grid .header-group-cell{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:flex-start;align-items:center;justify-content:var(--tbw-align-header-group,var(--tbw-align-header,flex-start));display:flex}tbw-grid .header-group-cell:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row{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);display:grid}tbw-grid .header-row>.cell{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);align-items:center;gap:4px;min-width:0;display:flex;overflow:visible}tbw-grid .header-row>.cell>span:first-child{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-weight:inherit;flex:1;overflow:hidden}tbw-grid .header-row>.cell>span[part~=sort-indicator]{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;flex-shrink:0}tbw-grid .header-row>.cell:hover>span[part~=sort-indicator]{visibility:visible;display:inline-flex}tbw-grid .header-row>.cell[aria-sort=ascending]>span[part~=sort-indicator],tbw-grid .header-row>.cell[aria-sort=descending]>span[part~=sort-indicator]{visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color);display:inline-flex}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell:last-child .resize-handle{width:max(var(--tbw-resize-hit-area,18px), var(--tbw-touch-target-min,24px));right:0}tbw-grid .header-row>.cell:last-child .resize-handle:before{left:auto;right:0;transform:none}tbw-grid .header-row>.cell:last-child.resizable{padding-inline-end:max(var(--tbw-cell-padding-h,.5em), var(--tbw-touch-target-min,24px))}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{padding-inline-end:max(var(--tbw-cell-padding-h,.5em), calc(var(--tbw-touch-target-min,24px) / 2));position:relative}tbw-grid .header-row>.cell.sticky-left,tbw-grid .header-row>.cell.sticky-right,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{top:0;right:calc(max(var(--tbw-resize-hit-area,18px), var(--tbw-touch-target-min,24px)) / -2);width:max(var(--tbw-resize-hit-area,18px), var(--tbw-touch-target-min,24px));cursor:e-resize;-webkit-user-select:none;user-select:none;touch-action:none;z-index:20;background:0 0;height:100%;position:absolute}tbw-grid .resize-handle:before{content:"";width:var(--tbw-resize-handle-width);background:var(--tbw-resize-handle-color);border-radius:var(--tbw-resize-handle-border-radius);height:100%;transition:background .12s;position:absolute;top:0;left:50%;transform:translate(-50%)}tbw-grid .resize-handle:after{content:"";width:var(--tbw-resize-handle-width);background:var(--tbw-resize-indicator-color,var(--tbw-color-accent));opacity:0;pointer-events:none;z-index:1000;height:0;transition:opacity .12s,height 0s .12s;position:absolute;top:100%;left:50%;transform:translate(-50%)}:is(tbw-grid .resize-handle:hover,tbw-grid .resize-handle[data-tbw-size-open]):before{background:var(--tbw-resize-handle-color-hover)}:is(tbw-grid .resize-handle:hover,tbw-grid .resize-handle[data-tbw-size-open]):after{height:100vh;opacity:var(--tbw-resize-indicator-opacity,.6);transition:opacity .12s,height}@media (pointer:coarse){tbw-grid>.cell.sortable>span[part~=sort-indicator]{min-width:var(--tbw-touch-target-min,24px);min-height:var(--tbw-touch-target-min,24px)}}}\n@layer tbw-base{tbw-grid .data-grid-row{grid-template-columns:var(--tbw-column-template);contain:layout style;display:grid}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{padding:var(--tbw-cell-padding,2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);border-right:1px solid var(--tbw-color-border-cell);min-width:0;white-space:var(--tbw-cell-white-space,nowrap);text-overflow:ellipsis;align-content:center;display:block;overflow:hidden}tbw-grid .data-grid-row>.cell>*{text-overflow:ellipsis;white-space:inherit;min-width:0;overflow:hidden}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]{width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle;margin:0}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-loading-overlay{z-index:1000;pointer-events:all;background:light-dark(#ffffffb3,#00000080);justify-content:center;align-items:center;animation:.15s ease-out tbw-fade-in;display:flex;position:absolute;inset:0}.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:.8s linear infinite tbw-spin}.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{pointer-events:none;position:relative}.tbw-row-loading-overlay{z-index:26;pointer-events:none;background:light-dark(#ffffffb3,#00000080);align-items:center;animation:.15s ease-out tbw-fade-in;display:flex;position:absolute;inset:0}.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:.8s linear infinite tbw-spin}.cell.tbw-cell-loading{pointer-events:none;position:relative}.cell.tbw-cell-loading:before{content:"";z-index:26;background:light-dark(#ffffffb3,#00000080);animation:.15s ease-out tbw-fade-in;position:absolute;inset:0}.cell.tbw-cell-loading:after{--_spinner-size:calc(var(--tbw-row-height,28px) * .5);content:"";left:var(--tbw-spacing-sm);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));z-index:27;border-radius:50%;margin:auto 0;animation:.8s linear infinite tbw-spin;position:absolute;top:0;bottom:0}.cell.tbw-cell-loading-custom:after{display:none}.tbw-cell-loading-overlay{z-index:27;pointer-events:none;justify-content:center;align-items:center;animation:.15s ease-out tbw-fade-in;display:flex;position:absolute;inset:0}}\n@layer tbw-base{.tbw-empty-overlay{padding:var(--tbw-spacing-md,12px);text-align:center;color:var(--tbw-color-text-secondary,var(--tbw-color-text));z-index:999;pointer-events:all;background:light-dark(#fff9,#0006);justify-content:center;align-items:center;animation:.15s ease-out tbw-fade-in;display:flex;position:absolute;inset:0}.tbw-empty-message{font-family:var(--tbw-font-family,inherit);font-size:var(--tbw-font-size-md,14px);-webkit-user-select:text;user-select:text;max-width:480px;line-height:1.4}}\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!important;--tbw-animation-duration:0s!important}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:#0000}20%{background-color:var(--tbw-row-change-color)}to{background-color:#0000}}@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;max-height:var(--tbw-row-height,28px);transform:translateY(0)}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-offset:-2px;outline:2px solid highlight!important}tbw-grid .data-grid-row[aria-selected=true]{color:highlighttext!important;background:highlight!important}}@media (prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled:0!important;--tbw-animation-duration:0s!important}tbw-grid[data-animation-mode=reduced-motion] .data-grid-row[data-animating]{animation:none}}}\n')}getPlugin(e){return this.#ze?.getPlugin(e)}getPluginByName(e){return this.#ze?.getPluginByName(e)}requestRender(){this.#Ee.requestPhase(Re.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#Ee.requestPhase(Re.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#Ee.requestPhase(Re.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){M(this)}requestAfterRender(){this.#Ee.requestPhase(Re.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this.#Je=!0,this._virtualization.start=-1,this.refreshVirtualWindow(!1)&&this.#ze?.onScrollRender()}#ct(){this.#ze=new Or(this);const e=this.#b?.plugins,t=Array.isArray(e)?e:[],r=this.#b?.features;let i,n=[];if(r&&Kt&&(n=Kt(r).map(e=>this.#dt(e))),0===n.length)i=t;else if(0===t.length)i=n;else{const e=new Set(t.map(e=>e.name));i=[...n.filter(t=>!e.has(t.name)),...t]}this.#ze.attachAll(i,e=>this.#dt(e))}#dt(e){const t=this.#Ge.get(e.name);return t&&t!==e?(t.refreshUserConfigFrom(e),t):(this.#Ge.set(e.name,e),e)}#ut(){!function(e){let t=!1;for(const{name:r,styles:i}of e)br.has(r)||(br.set(r,yr(i)),t=!0);t&&Cr()}(this.#ze?.getPluginStyles()??[])}#ht(){const e=this.#b?.plugins,t=Array.isArray(e)?e:[],r=this.#b?.features??void 0,i=r!==this.#Fe;if((this.#Ne===t||void 0!==this.#Ne&&this.#Ne.length===t.length&&this.#Ne.every((e,r)=>e===t[r]))&&!i)return void(this.#Ne=t);this.#ze&&this.#ze.detachAll(),this.#ct(),this.#ut(),this.#Ne=t,this.#Fe=r,this.#qe.configureVariableHeights(),this.#Ce.markSourcesChanged(),this.#Ce.merge();const n=this.#He;if(this.#He=this.#ze?.getAll().some(e=>e.onScroll)??!1,!n&&this.#He){const e=this.#be.querySelector(".tbw-grid-content")??this.#be.querySelector(".tbw-grid-root");this.#gt(e)}}#ft(){this.#ze?.detachAll()}#pt(){const t=e.getAdapters();if(0===t.length&&!this.__frameworkAdapter)return;const r=this.__frameworkAdapter;return e=>{if(r?.createToolPanelRenderer){const t=r.createToolPanelRenderer(e);if(t)return t}for(const r of t)if(r.createToolPanelRenderer){const t=r.createToolPanelRenderer(e);if(t)return t}}}_registerLightDomHandler(e,t){this.#Ce.registerLightDomHandler(e,t)}_unregisterLightDomHandler(e){this.#Ce.unregisterLightDomHandler(e)}_requestConfigMerge(){this.#Ce.markSourcesChanged(),this.#Ce.merge()}_getToolPanelRendererFactory(){return this.#pt()}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",e.version),this.hasAttribute("data-tbw-grid")||this.setAttribute("data-tbw-grid",""),this.id||(this.id="tbw-grid-"+ ++e.#me),this._rows=Array.isArray(this.#ye)?[...this.#ye]:[],this.#Le&&(this.#Le.abort(),this.#Ve=!1),this.#Le=new AbortController,this.#Ie&&(tr(this.#Ie),this.#Ie=void 0),this.#wt(),this.#Ce.parseLightDomColumns(this),this.#Ce.merge(),this.#ct();const t=this.#b?.plugins;var r,i;this.#Ne=Array.isArray(t)?t:[],this.#Fe=this.#b?.features??void 0,this.#ve||(this.#mt(),this.#ut(),this.#ve=!0),this.#bt(),this.#Ie=(r=()=>{this.#vt()},i={timeout:100},er?requestIdleCallback(r,i):window.setTimeout(()=>{const e=Date.now();r({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#Ie&&(tr(this.#Ie),this.#Ie=void 0),this.#ke&&(clearTimeout(this.#ke),this.#ke=0),this.#ft(),(this.#ze?.getPluginByName("shell"))?.disposeShellState?.(),Sr(this.#Pe),this.#Le&&(this.#Le.abort(),this.#Le=void 0),this.#Ue?.abort(),this.#Ue=void 0,this.#Ve=!1,this._resizeController&&this._resizeController.dispose(),this.#De&&(this.#De.disconnect(),this.#De=void 0),this.#qe.disposeRowHeightObserver(),Rt(this),this.#yt.clear(),this._virtualization.heightCache?.byKey.clear(),this.#Ne=void 0,this.#Fe=void 0;for(let e=0;e<this._rowPool.length;e++)this._rowPool[e].remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#_e=!1}attributeChangedCallback(e,t,r){if("loading"===e){const e=null!==r&&"false"!==r;return void(this.loading!==e&&(this.loading=e))}if(t!==r&&r&&"null"!==r&&"undefined"!==r)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(r);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{v("TBW130",`Invalid JSON for '${e}' attribute: ${r}`,this.id)}else"fit-mode"===e?this.fitMode=r:"column-inference"===e&&(this.columnInference=r)}#Ct(){const e=this.#be.querySelector(".tbw-grid-content")??this.#be.querySelector(".tbw-grid-root");return 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"),e}#bt(){const e=this.#Ct();if(this.setAttribute("data-upgraded",""),this.#_e=!0,this._resizeController?.dispose(),this._resizeController=or(this),this.#_t(),this.#gt(e),this.#Ve)return;this.#Ve=!0;const t=this.disconnectSignal;Qt(this,this,this.#be,t),this.#qe.configureVariableHeights(),queueMicrotask(()=>this.#Rt()),this.#Ee.requestPhase(Re.FULL,"afterConnect")}#gt(e){this.#Ue?.abort(),this.#Ue=new AbortController;const t=this.#Ue.signal,r=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=r??this,this.#He=this.#ze?.getAll().some(e=>e.onScroll)??!1,r&&i){r.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#He)return;const e=r.scrollTop;i.style.transform=`translateY(${function(e,t,r){if(t<=e.bypassThreshold)return-r;const i=je(r,e.scrollMapping),n=e.positionCache;let o;if(e.variableHeights&&n&&n.length>0){let t=Ve(n,i);-1===t&&(t=0);const r=t-t%2;o=n[r]?.offset??r*e.rowHeight}else{const t=Math.floor(i/e.rowHeight);o=(t-t%2)*e.rowHeight}return-(i-o)}(this._virtualization,this._rows.length,e)}px)`,this.#xe=e,this.#Ae||(this.#Ae=requestAnimationFrame(()=>{this.#Ae=0,null!==this.#xe&&(this.#St(this.#xe),this.#xe=null)}))},{passive:!0,signal:t});const e=this.#be.querySelector(".tbw-scroll-area");this.#Be=e,this._virtualization.scrollAreaEl=e,e&&this.#He&&e.addEventListener("scroll",()=>{this.#Me||(this.#Me=requestAnimationFrame(()=>{this.#Me=0;const t=this.#Oe;t.scrollTop=r.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=r.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=r.clientHeight,t.clientWidth=e.clientWidth,this.#ze?.onScroll(t)}))},{passive:!0,signal:t});const n=this.#be.querySelector(".tbw-grid-content");if(n){const e={fauxScrollbar:r,scrollArea:this.#Be};!function(e,t,r){const{fauxScrollbar:i,scrollArea:n}=t;e.addEventListener("wheel",t=>{try{if(e.querySelector("select:open"))return}catch{}const r=t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY);if(r&&n){const e=t.shiftKey?t.deltaY:t.deltaX,{scrollLeft:r,scrollWidth:i,clientWidth:o}=n;(e>0&&r<i-o||e<0&&r>0)&&(t.preventDefault(),n.scrollLeft+=e)}else if(!r){const{scrollTop:e,scrollHeight:r,clientHeight:n}=i;(t.deltaY>0&&e<r-n||t.deltaY<0&&e>0)&&(t.preventDefault(),i.scrollTop+=t.deltaY)}},{passive:!1,signal:r})}(n,e,t),Ar(n,this.#Pe,e,t)}}var n,o,s;this._bodyEl&&(n=this,o=this._bodyEl,s=t,o.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");if(!t)return;if(t.classList.contains(k.EDITING))return;const r=e.target;r.draggable||r.closest('[draggable="true"]')||e.preventDefault(),Yt(n,t)},{signal:s}),o.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&Bt(n,e,t),!document.activeElement?.closest(`.cell.${k.EDITING}`)){const t=e.target.closest("tbw-grid, [data-tbw-grid]");t&&t.focus({preventScroll:!0})}},{signal:s}),o.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&Bt(n,e,t)},{signal:s})),this.#De?.disconnect(),this._virtualization.viewportEl&&(this.#De=new ResizeObserver(()=>{this.#Et(),this.#Ee.requestPhase(Re.VIRTUALIZATION,"resize-observer")}),this.#De.observe(this._virtualization.viewportEl)),function(e,t,r,i){t.addEventListener("focusin",()=>{e.dataset.hasFocus=""},{signal:i}),t.addEventListener("focusout",i=>{const n=i.relatedTarget;n&&(t.contains(n)||r.isInExternalFocusContainer(n))||delete e.dataset.hasFocus},{signal:i})}(this,this.#be,this.#$e,t)}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}on(e,t){const r=e=>{t(e.detail,e)};return this.addEventListener(e,r),()=>this.removeEventListener(e,r)}#At(e,t){this.#_e&&this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#At("data-change",{rowCount:this._rows.length,sourceRowCount:this.#ye.length}),function(e,t,r){if(r===t.lastAnnouncedSourceCount)return;const i=t.lastAnnouncedSourceCount;t.lastAnnouncedSourceCount=r,0===r&&i<0||n(e,o(e,"dataLoaded",r))}(this,this.#xt,this.#ye.length)}#Rt(){(this._bodyEl?.querySelectorAll(".data-grid-row"))?.forEach((e,t)=>{const r=t===this._focusRow;e.setAttribute("aria-selected",String(r)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(r&&t===this._focusCol))})})}#it(e){this.#Se[e]=!0,this.#Re||(this.#Re=!0,queueMicrotask(()=>this.#Mt()))}#Mt(){if(!this.#Re||!this.#_e)return void(this.#Re=!1);const e=this.#Se;if(this.#Re=!1,this.#Se={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,columnInference:!1},e.gridConfig)return this.#Ht(),void(e.rows&&this.#kt());(e.columns||e.columnInference)&&this.#Tt(),e.rows&&this.#kt(),e.fitMode&&this.#Pt()}#kt(){this._rows=Array.isArray(this.#ye)?[...this.#ye]:[],this.#Je=!0,this.#Ee.requestPhase(Re.ROWS,"applyRowsUpdate")}#Lt(){this.#Je&&this._rebuildRowIdMap()}_rebuildRowIdMap(){this.#Je=!1,this.#Qe.clear();const e=this.#b.getRowId;for(let t=0;t<this._rows.length;t++){const r=ur(this._rows[t],e);void 0!==r&&this.#Qe.set(r,{row:this._rows[t],index:t})}}#Tt(){Rt(this),this.#Ce.merge(),this.#_t()}#Pt(){if(this.#Ce.merge(),"fixed"===this.#b.fitMode)this.__didInitialAutoSize=!1,E(this);else{for(let e=0;e<this._columns.length;e++){const t=this._columns[e];!t.__userResized&&t.__autoSized&&delete t.width}M(this)}}#Ht(){this.#Ce.parseLightDomColumns(this),this.#Ce.merge(),this.#ht(),this.#qe.configureVariableHeights(),this.#Ce.markSourcesChanged(),this.#Ce.merge();const e=this.#Ce.initialColumnState;if(e){this.#Ce.initialColumnState=void 0,this.#R=void 0;const t=this.#ze?.getAll()??[];this.#Ce.applyState(e,t)}if(this.#ze?.needsStructuralRerender())return this.#ze?.beforeStructuralRender(),this.#mt(),this.#ut(),this.#bt(),void this._rebuildRowIdMap();this._rebuildRowIdMap(),this.#Ee.requestPhase(Re.COLUMNS,"applyGridConfigUpdate")}#Dt(){if(this.__rowRenderEpoch++,this.#ze){const e=this.#ze.orderColumns(this.#tt.length>0?this.#tt:this._columns),t=e.filter(e=>!e.hidden),r=e.filter(e=>e.hidden),i=this.#ze.processColumns([...t]);if(i!==t){const n=new Set(i.map(e=>e.field));!t.some(e=>n.has(e.field))&&i.length>0?this._columns=[...i,...r]:0===r.length?this._columns=i:this._columns=_(e,i)}else this._columns=[...e]}}#It(){Rt(this);const e=this.#ye;if(!Array.isArray(e))return this._rows=[],this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#qe.initializePositionCache(),void this._emitDataChange();if(!this._sortState&&this.#b.initialSort){const{field:e,direction:t}=this.#b.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,r=!1){if(!e._sortState)return t;const i=e.effectiveConfig?.sortHandler??le;if(i===le)return r||(e.__originalOrder=t.slice()),de(t,e._sortState.field,e._sortState.direction,e._columns),t;r||(e.__originalOrder=t);const n=i(t,e._sortState,e._columns);return n&&"function"==typeof n.then?t:n}(this,this._sortState?[...e]:e,!0),r=this.#ze?.processRows(t)??t;this._rows=r,this.#Je=!0,this._emitDataChange()}_renderVisibleRows(e,t,r=this.__rowRenderEpoch){if(this.#Te||(this.#Te=(e,t,r)=>this.#ze?.renderRow(e,t,r)??!1),Lt(this,e,t,r,this.#Te),this.#Ye.size>0)for(const i of this.#Ye)this.#st(i,!0);if(this.#Xe.size>0)for(const[i,n]of this.#Xe)for(const e of n)this.#at(i,e,!0)}#xt={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaLabelledBy:void 0,ariaDescribedBy:void 0,ariaRoleDescription:void 0,lastAnnouncedSourceCount:-1};_updateAriaCounts(e,t){!function(e,t,r,i,n){if(i===e.rowCount&&n===e.colCount)return!1;const o=e.rowCount;e.rowCount=i,e.colCount=n,t&&(t.setAttribute("aria-rowcount",String(i)),t.setAttribute("aria-colcount",String(n))),i!==o&&r&&(i>0?r.setAttribute("role","rowgroup"):r.removeAttribute("role"))}(this.#xt,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#Ee.requestPhase(e,t)}_getPluginRowHeight(e,t){return this.#ze?.getRowHeight?.(e,t)}_adjustPluginVirtualStart(e,t,r){return this.#ze?.adjustVirtualStart(e,t,r)}_afterPluginRender(){this.#ze?.afterRender()}_emitPluginEvent(e,t){this.#ze?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#Ce.parseLightDomColumns(this),this.#Ce.merge(),this.#ht(),function(e,t,r){const i=xr,n=Mr,o=new Map;function s(e,t,r,i=!1){o.has(e)||o.set(e,{description:t,fields:[],isConfigProperty:i});const n=o.get(e);n.fields.includes(r)||n.fields.push(r)}const a=e.features;function l(e){return!!a&&!1===a[e]}for(const d of n){const r=e[d.property];if((d.isUsed?d.isUsed(r):void 0!==r)&&!Dr(t,d.pluginName)&&!l(d.pluginName)){const e=d.description||`the "${d.property}" ${d.level} property`;s(d.pluginName,e,d.property,!0)}}const c=e.columns;if(c&&c.length>0)for(const d of c)for(const e of i){const r=d[e.property];if((e.isUsed?e.isUsed(r):void 0!==r)&&!Dr(t,e.pluginName)&&!l(e.pluginName)){const t=d.field||"<unknown>",r=e.description||`the "${e.property}" ${e.level} property`;s(e.pluginName,r,t)}}if(o.size>0){const t=Pr(e),i=[];for(const[e,{description:r,fields:n,isConfigProperty:s}]of o){const o=n.slice(0,3).join(", ")+(n.length>3?`, ... (${n.length} total)`:""),a=s?`Config uses ${r}`:`Column(s) [${o}] use ${r}`;t?i.push(`${a}, but the required feature is not enabled.\n → Enable it in gridConfig.features (pass \`true\` for defaults, or a config object — see the docs):\n ${kr(e)}\n features: { ${e}: true }`):i.push(`${a}, but the required plugin is not loaded.\n → Add it to gridConfig.plugins:\n ${Tr(e)}\n plugins: [new ${Lr(e)}Plugin(), ...]\n → Tip: the feature-based API is recommended — ${kr(e)} then features: { ${e}: true }`)}b([...o.values()].some(e=>e.isConfigProperty)?"TBW002":"TBW001",`Configuration error:\n\n${i.join("\n\n")}\n\nThis validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`,r)}}(this.#b,this.#ze?.getPlugins()??[],this.id),function(e,t){const r=[],i=[];for(const n of e){const e=n.constructor.manifest;if(e?.configRules)for(const t of e.configRules){const e=n.config;if(t.check(e)){const e=`[${Lr(n.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?r.push(e):i.push(e)}}}if(i.length>0&&Ie())for(const n of i)v("TBW004",n,t);r.length>0&&b("TBW003",`Configuration error:\n\n${r.join("\n\n")}`,t)}(this.#ze?.getPlugins()??[],this.id),function(e,t){if(!Ie())return;const r=new Set(e.map(e=>e.name)),i=new Set;for(const n of e){const e=n.constructor.manifest;if(e?.incompatibleWith)for(const o of e.incompatibleWith)if(r.has(o.name)){const e=[n.name,o.name].sort().join("↔");if(i.has(e))continue;i.add(e),v("TBW022",`${Lr(n.name)}Plugin and ${Lr(o.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${o.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`,t)}}}(this.#ze?.getPlugins()??[],this.id),this.#Ot(),this.#tt=[...this._columns]}_schedulerProcessColumns(){this.#Dt()}_schedulerProcessRows(){this.#It()}_schedulerRenderHeader(){Ce(this)}_schedulerUpdateTemplate(){M(this)}_schedulerAfterRender(){this.#ze?.afterRender(),this.#ot(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#qe.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}),"fixed"!==this.#b.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,E(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,it(this)),this.#qe.afterRenderRowHeights(),this.#je&&this.#nt()}get _schedulerIsConnected(){return this.isConnected&&this.#_e}get _hostElement(){return this}get _renderRoot(){return this.#be}_emit(e,t){this.#At(e,t)}get _accordionIcons(){return{expand:this.#b?.icons?.expand??i.expand,collapse:this.#b?.icons?.collapse??i.collapse}}_pluginShellContributions(){return{toolPanels:(this.#ze?.getToolPanels()??[]).map(e=>e.panel),headerContents:(this.#ze?.getHeaderContents()??[]).map(e=>e.content)}}_clearRowPool(){const e=this.__frameworkAdapter;if(e?.releaseCell||e?.unmount){e.beginBatch?.(this);try{for(let t=0;t<this._rowPool.length;t++)wt(e,this._rowPool[t]);this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML="")}finally{e.endBatch?.(this)}}else this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML="");this.__rowRenderEpoch++}_setup(){this.#_t()}_applyAnimationConfig(e){const t={...r,...e.animation},i=t.mode??"reduced-motion";let n=1;!1===i||"off"===i?n=0:!0!==i&&"on"!==i||(n=1),this.style.setProperty("--tbw-animation-duration",`${t.duration}ms`),this.style.setProperty("--tbw-animation-easing",t.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode="boolean"==typeof i?i?"on":"off":i}#Ot(){!function(e,t,r){if(!t)return!1;let i=!1;const n=r?.gridAriaLabelledBy,o=n?void 0:function(e){const t=e?.gridAriaLabel;return t||(e?.shell?.header?.title??void 0)}(r);n!==e.ariaLabelledBy&&(e.ariaLabelledBy=n,n?t.setAttribute("aria-labelledby",n):t.removeAttribute("aria-labelledby"),i=!0),o!==e.ariaLabel&&(e.ariaLabel=o,o?t.setAttribute("aria-label",o):t.removeAttribute("aria-label"),i=!0);const s=r?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),i=!0);const a=r?.gridAriaRoleDescription;a!==e.ariaRoleDescription&&(e.ariaRoleDescription=a,a?t.setAttribute("aria-roledescription",a):t.removeAttribute("aria-roledescription"),i=!0)}(this.#xt,this.__rowsBodyEl,this.#b)}#nt(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#je?(this.#Ke||(this.#Ke=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(dt("large",e)),t}(this.#b?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#Ke)):(t=this.#Ke,t?.remove()))}#ot(){De(this.querySelector(".tbw-grid-root"),this.#je,this._rows.length,this.#ye,this.#b?.emptyRenderer,this.#b?.emptyOverlay??"rows",this.#Ze,this)}#st(e,t){this.#Lt();const r=this.#Qe.get(e);if(!r)return;const i=this.findRenderedRowElement?.(r.index);i&&ft(i,t,this.#b?.loadingRenderer,this.__frameworkAdapter)}#at(e,t,r){this.#Lt();const i=this.#Qe.get(e);if(!i)return;const n=this.findRenderedRowElement?.(i.index);if(!n)return;const o=this._visibleColumns.findIndex(e=>e.field===t);if(o<0)return;const s=n.querySelector(`:scope > .cell[data-col="${o}"]`);s&&pt(s,r,this.#b?.loadingRenderer,this.__frameworkAdapter)}#_t(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#Ce.parseLightDomColumns(this),this.#R){const e=this.#R;this.#R=void 0,this.#Ce.merge();const t=this.#ze?.getAll()??[];this.#Ce.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#Ee.requestPhase(Re.FULL,"setup")}}#St(e){const t=this._virtualization.container,r=this.#Be,i=r?.scrollLeft??0,n=t?.scrollHeight??0,o=r?.scrollWidth??0,s=t?.clientHeight??0,a=r?.clientWidth??0;if(this.refreshVirtualWindow(!1)&&this.#ze?.onScrollRender(),this._virtualization.variableHeights&&(this.#ke&&clearTimeout(this.#ke),this.#ke=window.setTimeout(()=>{this.#ke=0,this.#qe.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#He){const t=this.#Oe;t.scrollTop=e,t.scrollLeft=i,t.scrollHeight=n,t.scrollWidth=o,t.clientHeight=s,t.clientWidth=a,this.#ze?.onScroll(t)}this.#At("tbw-scroll",{scrollTop:e,scrollHeight:n,clientHeight:s,direction:"vertical"})}findHeaderRow(){return this.#be.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,r=e-t.start;return r>=0&&r<this._rowPool.length&&r<t.end-t.start?this._rowPool[r]:null}_dispatchCellClick(e,t,r,i){const n=this._rows[t],o=this._visibleColumns[r];if(!n||!o)return!1;const s=o.field,a=re(n,s),l=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:r,column:o,field:s,value:a,row:n,cellEl:i,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(l),l.defaultPrevented)return!0;const c={row:n,rowIndex:t,colIndex:r,column:o,field:s,value:a,cellEl:i,originalEvent:e},d=this.#ze?.onCellClick(c)??!1;return this.#At("cell-click",c),d}_dispatchRowClick(e,t,r,i){if(!r)return!1;const n={rowIndex:t,row:r,rowEl:i,originalEvent:e},o=this.#ze?.onRowClick(n)??!1;return this.#At("row-click",n),o}_dispatchHeaderClick(e,t,r){if(!t)return!1;const i={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:r,originalEvent:e};return this.#ze?.onHeaderClick(i)??!1}_dispatchKeyDown(e){return this.#ze?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#ze?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}_getVerticalScrollOffsets(e){return this.#ze?.getVerticalScrollOffsets(e)??{top:0,bottom:0}}query(e,t){return this.#ze?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#ze?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#ze?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#ze?.onCellMouseUp(e)}_afterCellRender(e){this.#ze?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#ze?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#ze?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#ze?.hasAfterRowRenderHook()??!1}async ready(){return this.#i}async forceLayout(){return 0===this.#Ee.pendingPhase&&this.#Ee.requestPhase(Re.FULL,"forceLayout"),this.#Ee.whenReady()}async getConfig(){return Object.freeze({...this.#b||{}})}getRowId(e){return function(e,t,r){const i=ur(e,r);return void 0===i&&b("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),i}(e,this.id,this.#b.getRowId)}getRow(e){return this.#We.getRow(e)}_getRowEntry(e){return this.#Lt(),this.#Qe.get(e)}_getSourceRowEntry(e){const t=this._getRowEntry(e);if(t)return t;const r=this.#b.getRowId,i=this.#ye;for(let n=0;n<i.length;n++)if(ur(i[n],r)===e)return{row:i[n],index:-1}}updateRow(e,t,r="api"){this.#We.updateRow(e,t,r)}updateRows(e,t="api"){this.#We.updateRows(e,t)}animateRow(e,t){return dr(this,e,t)}animateRows(e,t){return function(e,t,r){return Promise.all(t.map(t=>dr(e,t,r))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,r){const i=e._rows??[],n=e.getRowId;if(!n)return Promise.resolve(!1);const o=i.findIndex(e=>{if(null==e)return!1;try{return n(e)===t}catch{return!1}});return o<0?Promise.resolve(!1):dr(e,o,r)}(this,e,t)}async insertRow(e,t,r=!0){return this.#We.insertRow(e,t,r)}async removeRow(e,t=!0){return this.#We.removeRow(e,t)}async applyTransaction(e,t=!0){return this.#We.applyTransaction(e,t)}applyTransactionAsync(e){return this.#We.applyTransactionAsync(e)}focusCell(e,t){this.#$e.focusCell(e,t)}get focusedCell(){return this.#$e.focusedCell}scrollToRow(e,t){this.#$e.scrollToRow(e,t)}scrollToRowById(e,t){this.#$e.scrollToRowById(e,t)}setColumnVisible(e,t){const r=this.#Ce.setColumnVisible(e,t);return r&&this.requestStateChange(),r}toggleColumnVisibility(e){const t=this.#Ce.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#Ce.isColumnVisible(e)}showAllColumns(){this.#Ce.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#Ce.getAllColumns()}setColumnOrder(e){this.#Ce.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#Ce.getColumnOrder()}getColumnState(){const e=this.#ze?.getAll()??[];return this.#Ce.collectState(e)}get columnState(){return this.getColumnState()}applyColumnState(e){e&&(this.#ve?this.#zt(e):(this.#R=e,this.#Ce.initialColumnState=e))}#zt(e){const t=this._columns,r=this._sortState,i=this.#ze?.getAll()??[];if(this.#Ce.applyState(e,i),!e.columns.some(e=>void 0!==e.sort)&&this.#Nt(t,r))return this.#rt=void 0,M(this),void this.#Ee.requestPhase(Re.STYLE,"column-width");this.#_t()}#Nt(e,t){const r=this._columns,i=this._sortState;if(t?.field!==i?.field||t?.direction!==i?.direction)return!1;if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++){const t=e[n],i=r[n];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=[],Ce(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 r=this._columns.find(t=>t.field===e);r&&(t?(this._sortState||(this.__originalOrder=this._rows.slice()),pe(this,r,"desc"===t?-1:1)):fe(this,r))}requestStateChange(){const e=this.#ze?.getAll()??[];this.#Ce.requestStateChange(e)}resetColumnState(){this.#R=void 0,this.__originalOrder=[];const e=this.#ze?.getAll()??[];this.#Ce.resetState(e),this.#Ce.merge(),this.#_t()}get defaultRowHeight(){return this._virtualization.rowHeight}#Ft=!1;refreshShellHeader(){this.#Ft||(this.#Ft=!0,queueMicrotask(()=>{this.#Ft=!1,this.isConnected&&(this.#wt(),this.#Ce.markSourcesChanged(),this.#Ce.merge(),this.#ze?.beforeStructuralRender(),this.#ze?.afterStructuralRender(),this.#qt())}))}#qt(){const e=this.#Ct();this._resizeController?.dispose(),this._resizeController=or(this),this.#gt(e),this.#Ee.requestPhase(Re.COLUMNS,"shellRefresh")}#yt=new Map;registerStyles(e,t){let r=this.#yt.get(e);r||(r=new CSSStyleSheet,this.#yt.set(e,r)),r.replaceSync(t),this.#$t()}unregisterStyles(e){this.#yt.delete(e)&&this.#$t()}getRegisteredStyles(){return Array.from(this.#yt.keys())}#$t(){const e=Array.from(this.#yt.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#yt.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#$e.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#$e.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#$e.containsFocus(e)}get lastFocusedElement(){return this.#$e.lastFocusedElement}restoreLastFocus(){return this.#$e.restoreLastFocus()}#wt(){this.#ze?.parseLightDom()}#vt(){const e=()=>{this.#Ce.clearLightDomCache(),this.#_t()};this.#Ce.registerLightDomHandler("tbw-grid-column",e),this.#Ce.registerLightDomHandler("tbw-grid-detail",e),this.#Ce.registerLightDomHandler("tbw-grid-type",e),this.#Ce.observeLightDOM(this)}refreshColumns(){this.#Ce.clearLightDomCache(),Rt(this),this.#Ce.parseLightDomColumns(this),this.#ze?.syncLightDom(),this.#Ee.requestPhase(Re.COLUMNS,"refreshColumns")}#Et(){this.#qe.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#qe.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#qe.invalidateRowHeight(e,t)}#mt(){this.#wt(),this.#Ce.markSourcesChanged(),this.#Ce.merge(),function(e){const t=[];for(let r=e.firstChild;r;r=r.nextSibling)1===r.nodeType&&r.classList.contains(k.ROOT)||t.push(r);e.replaceChildren();for(const r of t)e.appendChild(r);e.appendChild(ke({hasShell:!1}))}(this.#be),this.#ze?.afterStructuralRender()}};!function(){const e=zr.tagName,t=customElements.get(e);if(!t)return customElements.define(e,zr),void(zr.activeTag=e);if(t.version===zr.version)return void(zr.activeTag=e);const r=`${e}-v${zr.version.replace(/[^a-zA-Z0-9]+/g,"-").toLowerCase()}`;customElements.get(r)||customElements.define(r,zr),zr.activeTag=r}(),globalThis.DataGridElement||(globalThis.DataGridElement=zr);function Nr(e,t,r){return r?.valueAccessor?se(e,r):re(e,t)}function Fr(e){return null==e||""===e||"number"==typeof e&&isNaN(e)}var qr={sum:(e,t,r)=>{let i=0;for(let n=0;n<e.length;n++){const o=Nr(e[n],t,r);if(Fr(o))continue;const s=Number(o);isNaN(s)||(i+=s)}return i},avg:(e,t,r)=>{if(!e.length)return 0;let i=0,n=0;for(let o=0;o<e.length;o++){const s=Nr(e[o],t,r);if(Fr(s))continue;const a=Number(s);isNaN(a)||(i+=a,n++)}return n>0?i/n:0},count:e=>e.length,min:(e,t,r)=>{if(!e.length)return 0;let i=1/0;for(let n=0;n<e.length;n++){const o=Nr(e[n],t,r);if(Fr(o))continue;const s=Number(o);isNaN(s)||s<i&&(i=s)}return i===1/0?0:i},max:(e,t,r)=>{if(!e.length)return 0;let i=-1/0;for(let n=0;n<e.length;n++){const o=Nr(e[n],t,r);if(Fr(o))continue;const s=Number(o);isNaN(s)||s>i&&(i=s)}return i===-1/0?0:i},first:(e,t,r)=>e[0]?Nr(e[0],t,r):void 0,last:(e,t,r)=>e.length?Nr(e[e.length-1],t,r):void 0},$r=new Map,Wr={register(e,t){$r.set(e,t)},unregister(e){$r.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:$r.get(e)??qr[e]},run(e,t,r,i){const n=this.get(e);return n?n(t,r,i):void 0},has:e=>$r.has(e)||e in qr,list:()=>[...Object.keys(qr),...$r.keys()]},Vr={sum:e=>{let t=0;for(let r=0;r<e.length;r++)t+=e[r];return t},avg:e=>{if(!e.length)return 0;let t=0;for(let r=0;r<e.length;r++)t+=e[r];return t/e.length},count:e=>e.length,min:e=>{if(!e.length)return 0;let t=e[0];for(let r=1;r<e.length;r++)e[r]<t&&(t=e[r]);return t},max:e=>{if(!e.length)return 0;let t=e[0];for(let r=1;r<e.length;r++)e[r]>t&&(t=e[r]);return t},first:e=>e[0]??0,last:e=>e[e.length-1]??0};function Ur(e){return Vr[e]??Vr.sum}e.BaseGridPlugin=class{static dependencies;static manifest;aliases;version="3.10.1";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#Wt;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#Wt?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},r={};for(const i of Object.keys(t))r[i]=this;for(const i of e){const e=i.userConfig;for(const[n,o]of Object.entries(e)){if(void 0===o)continue;if(!(n in t)){t[n]=o,r[n]=i;continue}if(t[n]===o)continue;const e=r[n]?.constructor.name??this.constructor.name,s=i.constructor.name,a=m("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${n}" supplied by both ${e} and ${s}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig,r={...e.userConfig};for(const i of Object.keys(t))delete t[i];Object.assign(t,r)}attach(e){this.#Wt?.abort(),this.#Wt=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.__releaseDisconnectSignal()}__releaseDisconnectSignal(){this.#Wt?.abort(),this.#Wt=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 r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.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)}queryBoolean(e,t=null){const r=this.grid?.query?.(e,t);return Array.isArray(r)?r.some(Boolean):!!r}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.#Wt?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...i,...e}}t(e,t){return this.grid?.effectiveConfig?.locale?.[e]??t}get translate(){return(e,t)=>this.t(e,t)}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;return!t||"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}setIcon(e,t,r){e.dataset.icon=X(t),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const i=this.#Vt(t,r);void 0!==i?"string"==typeof i?V(e,i):i instanceof HTMLElement&&e.replaceChildren(i.cloneNode(!0)):e.innerHTML=""}#Vt(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const r=document.createElement("span");r.setAttribute("part","sort-indicator"),r.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(r,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(r,"sortNone"));const i=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return i?e.insertBefore(r,i):e.appendChild(r),r}warn(e,t){void 0!==t?console.warn(m(e,t,this.gridElement.id,this.name)):console.warn(`${h(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(m(e,t,this.gridElement.id,this.name))}},e.CORE_CONSUMED_ADAPTER_METHODS=["canHandle","createRenderer","createEditor","processConfig","getTypeDefault","createToolPanelRenderer","parseDetailElement","parseResponsiveCardElement","releaseCell","unmount","beginBatch","endBatch"],e.ColumnInferenceModeEnum={AUTO:"auto",MERGE:"merge"},e.DEFAULT_A11Y_MESSAGES=t,e.DEFAULT_ANIMATION_CONFIG=r,e.DEFAULT_GRID_ICONS=i,e.DataGridElement=zr,e.FitModeEnum=u,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=k,e.GridDataAttrs=T,e.GridElement=zr,e.GridSelectors=P,e.MAX_ELEMENT_HEIGHT_PX=Be,e.PluginManager=Or,e.RenderPhase=Re,e.aggregatorRegistry=Wr,e.applyColumnDefaults=function(e,t){return t?e.map(e=>({...t,...e})):e},e.builtInSort=le,e.computeScrollMapping=Ge,e.createFieldReader=ie,e.createGrid=function(e){const t=document.createElement(zr.activeTag);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.fromVirtualScrollTop=Ye,e.getByPath=ee,e.getPrimaryPointer=ct,e.getValueAggregator=Ur,e.hasColumnShorthands=function(e){return e.some(e=>"string"==typeof e)},e.invalidateAccessorCache=ae,e.isPlainField=ne,e.normalizeColumns=d,e.parseColumnShorthand=c,e.parseFieldPath=J,e.queryGrid=function(e,t,r){let i=document,n=!1;return"boolean"==typeof t?n=t:t&&(i=t,n=!!r),n?customElements.whenDefined(zr.activeTag).then(()=>i.querySelector(e)):i.querySelector(e)},e.readCellField=re,e.resolveCellValue=se,e.runValueAggregator=function(e,t){return Ur(e)(t)},e.setByPath=te,e.setFeatureResolver=function(e){Kt=e},e.startPointerDrag=ot,e.toVirtualScrollTop=je,e.writeCellField=oe});
|
|
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){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t={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`,selectAllRows:()=>"Select all rows",selectRow:e=>`Select row ${e+1}`,columnSelected:e=>`Column ${e} selected`,columnSelectionChanged:e=>`${e} columns selected`,columnSelectionCleared:()=>"Column selection cleared",selectionAxisChanged:e=>"column"===e?"Row selection cleared, column selection active":"Column selection cleared, row selection active",rangeSpanSelected:(e,t)=>1===t?("row"===e?"Row":"Column")+" selected":`${t} ${e}s selected`,editingStarted:e=>`Editing row ${e+1}`,editingCommitted:e=>`Row ${e+1} saved`,dataLoaded:e=>`${e} rows loaded`},r={mode:"reduced-motion",duration:200,easing:"ease-out"},i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:"",filterActive:"",print:"🖨️"};function n(e,t){if(!e)return;if(!1===("effectiveConfig"in e?e.effectiveConfig:void 0)?.a11y?.announcements)return;const r=e.querySelector?.(".tbw-sr-only");r&&(r.textContent="","function"==typeof requestAnimationFrame?requestAnimationFrame(()=>{r.textContent=t}):r.textContent=t)}function o(e,r,...i){const n=(e&&"effectiveConfig"in e?e.effectiveConfig:void 0)?.a11y?.messages?.[r];return n?n(...i):t[r](...i)}function s(e){return e.charAt(0).toUpperCase()+e.slice(1)}function a(e){return"id"===e.toLowerCase()?"ID":e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]/g," ").split(" ").filter(Boolean).map(s).join(" ")}var l=new Set(["string","number","boolean","date","datetime","currency"]);function c(e){const t=e.lastIndexOf(":");if(t>0){const r=e.slice(t+1).toLowerCase();if(l.has(r)){const i=e.slice(0,t);return{field:i,header:a(i),type:r}}}return{field:e,header:a(e)}}function d(e){return e.map(e=>"string"==typeof e?c(e):e)}var u={STRETCH:"stretch",FIXED:"fixed"};function h(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}var g="TBW020",f="TBW021",p="TBW041",w="TBW062";function m(e,t,r,i){return`${h(r,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function b(e,t,r,i){throw new Error(m(e,t,r,i))}function v(e,t,r,i){console.warn(m(e,t,r,i))}function y(e,t,r,i){console.debug(m(e,t,r,i))}function _(e,t,r,i){console.error(m(e,t,r,i))}function C(e,t){const r=new Map;e.forEach((e,t)=>r.set(e.field,t));const i=function(e,t){const r=[];for(const s of e){const e=t.get(s.field);void 0!==e&&r.push({field:s.field,idx:e})}const i=[],n=new Array(r.length).fill(-1);for(let s=0;s<r.length;s++){let e=0,t=i.length;for(;e<t;){const n=e+t>>1;r[i[n]].idx<r[s].idx?e=n+1:t=n}e>0&&(n[s]=i[e-1]),i[e]=s}const o=new Set;for(let s=i.length?i[i.length-1]:-1;-1!==s;s=n[s])o.add(r[s].field);return o}(t,r),n=new Set(t.map(e=>e.field)),o=[],s=new Map;let a;for(const c of e)if(i.has(c.field))a=c.field;else if(c.hidden&&!n.has(c.field))if(void 0===a)o.push(c);else{const e=s.get(a);e?e.push(c):s.set(a,[c])}const l=[];for(const c of t){o.length&&i.has(c.field)&&l.push(...o.splice(0)),l.push(c);const e=s.get(c.field);e&&l.push(...e)}return l.push(...o),l}function R(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const r={},i=t;for(let s=0;s<i.length;s++){const e=i[s],t=r[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.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.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate),e.__element&&!t.__element&&(t.__element=e.__element);const r=e.renderer||e.viewRenderer,i=t.renderer||t.viewRenderer;r&&!i&&(t.viewRenderer=r,e.renderer&&(t.renderer=r)),e.editor&&!t.editor&&(t.editor=e.editor),e.headerRenderer&&!t.headerRenderer&&(t.headerRenderer=e.headerRenderer),e.headerLabelRenderer&&!t.headerLabelRenderer&&(t.headerLabelRenderer=e.headerLabelRenderer)}else r[e.field]={...e}}const n=e.map(e=>{const t=r[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),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.__headerTemplate&&(i.__headerTemplate=t.__headerTemplate),t.__element&&!i.__element&&(i.__element=t.__element);const n=t.renderer||t.viewRenderer,o=i.renderer||i.viewRenderer;return n&&!o&&(i.viewRenderer=n,t.renderer&&(i.renderer=n)),t.editor&&!i.editor&&(i.editor=t.editor),i.headerRenderer||i.headerLabelRenderer||(t.headerRenderer?i.headerRenderer=t.headerRenderer:t.headerLabelRenderer&&(i.headerLabelRenderer=t.headerLabelRenderer)),delete r[e.field],i}),o=Object.keys(r);for(let s=0;s<o.length;s++)n.push(r[o[s]]);return n}function S(e,t){try{e.part?.add?.(t)}catch{}const r=e.getAttribute("part");r?r.split(/\s+/).includes(t)||e.setAttribute("part",r+" "+t):e.setAttribute("part",t)}function E(e){const t=e.effectiveConfig?.fitMode||e.fitMode||u.STRETCH;if(t!==u.STRETCH&&t!==u.FIXED)return;if(e.__didInitialAutoSize)return;if(!e.isConnected)return;const r=Array.from(e._headerRowEl?.children||[]);if(!r.length)return;let i=!1;const n=e._visibleColumns;for(let o=0;o<n.length;o++){const t=n[o];if(t.width)continue;const s=r[o];let a=s?s.scrollWidth:0;for(let r=0;r<e._rowPool.length;r++){const t=e._rowPool[r].children[o];if(t){const e=t.scrollWidth;e>a&&(a=e)}}a>0&&(t.width=a+2,t.__autoSized=!0,i=!0)}i&&M(e),e.__didInitialAutoSize=!0}var A=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function x(e,t){return"number"==typeof e?`${e}px`:(A.test(e)||v("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 M(e){(e.effectiveConfig?.fitMode||e.fitMode||u.STRETCH)===u.STRETCH?e._gridTemplate=e._visibleColumns.map(e=>{if(null!=e.width)return x(e.width,e.field);const t=e.minWidth;return null!=t?`minmax(${t}px, 1fr)`:"1fr"}).join(" ").trim():e._gridTemplate=e._visibleColumns.map(e=>null!=e.width?x(e.width,e.field):"max-content").join(" "),e.style.setProperty("--tbw-column-template",e._gridTemplate)}var H='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])',k={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-grid-row",GROUP_ROW:"group-row",DATA_CELL:"cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},T={FIELD:"data-field",TRUNCATED:"data-tbw-truncated",GROUP_KEY:"data-group-key"},P={ROOT:`.${k.ROOT}`,HEADER:`.${k.HEADER}`,HEADER_ROW:`.${k.HEADER_ROW}`,HEADER_CELL:`.${k.HEADER_CELL}`,ROWS_VIEWPORT:`.${k.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${k.ROWS_CONTAINER}`,DATA_ROW:`.${k.DATA_ROW}`,DATA_CELL:`.${k.DATA_CELL}`,GROUP_ROW:`.${k.GROUP_ROW}`,CELL_BY_FIELD:e=>`.${k.DATA_CELL}[${T.FIELD}="${e}"]`,SELECTED_ROWS:`.${k.DATA_ROW}.${k.SELECTED}`,EDITING_CELL:`.${k.DATA_CELL}.${k.EDITING}`},L=/{{\s*([^}]+)\s*}}/g,D="__DG_EMPTY__",I=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,O="__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("")),z=new RegExp(`__(proto|defineGetter|defineSetter)|${O.slice(3).join("|")}|this\\b`);var N=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|math".split("|")),F=/^on\w+$/i,q=new Set("href|src|action|formaction|data|srcdoc|xlink:href|poster|srcset".split("|")),$=/^\s*(javascript|vbscript|data|blob):/i;function W(e){const t=document.createElement("template");return e&&"string"==typeof e&&(t.innerHTML=e,function(e){const t=[],r=e.querySelectorAll("*");for(const i of r){const e=i.tagName.toLowerCase();if(N.has(e)){t.push(i);continue}if(("svg"===e||"http://www.w3.org/2000/svg"===i.namespaceURI)&&Array.from(i.attributes).some(e=>F.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(i);continue}const r=[];for(const t of i.attributes){const e=t.name.toLowerCase();F.test(e)?r.push(t.name):"is"!==e?(q.has(e)&&$.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&r.push(t.name):r.push(t.name)}r.forEach(e=>i.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content)),t.content}function V(e,t){t&&"string"==typeof t?-1!==t.indexOf("<")||-1!==t.indexOf("&")?e.replaceChildren(W(t)):e.textContent=t:e.replaceChildren()}function U(e,t){const r=function(e){const t=[];let r=0;for(;r<e.length;){const i=e[r];if(" "!==i){if(i>="0"&&i<="9"||"."===i&&r+1<e.length&&e[r+1]>="0"&&e[r+1]<="9"){const i=r;for(;r<e.length&&(e[r]>="0"&&e[r]<="9"||"."===e[r]);)r++;t.push({type:"num",v:Number(e.slice(i,r))});continue}if("'"===i){let i="";for(r++;r<e.length&&"'"!==e[r];)i+=e[r++];if(r>=e.length)return null;r++,t.push({type:"str",v:i});continue}if(i>="a"&&i<="z"||i>="A"&&i<="Z"||"_"===i||"$"===i){const i=r;for(;r<e.length&&/[\w$.]/.test(e[r]);)r++;t.push({type:"id",v:e.slice(i,r)});continue}if(r+2<e.length){const i=e.slice(r,r+3);if("==="===i||"!=="===i){t.push({type:"op",v:i}),r+=3;continue}}if(r+1<e.length){const i=e.slice(r,r+2);if("=="===i||"!="===i||"<="===i||">="===i||"&&"===i||"||"===i){t.push({type:"op",v:i}),r+=2;continue}}if(!"+-*/%<>!?:(),".includes(i))return null;t.push({type:"op",v:i}),r++}else r++}return t}(e);if(!r)return;const i=r;let n=0;function o(){return i[n]}function s(){return i[n++]}function a(e,t){const r=o();return!!r&&(r.type===e&&(void 0===t||r.v===t))}function l(){const e=function(){let e=c();for(;a("op","||");)s(),e=e||c();return e}();if(a("op","?")){s();const t=l();if(!a("op",":"))return;s();const r=l();return e?t:r}return e}function c(){let e=d();for(;a("op","&&");)s(),e=e&&d();return e}function d(){let e=u();for(;;){const t=o();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=h();for(;;){const t=o();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=g();for(;;){const t=o();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=o();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 a("op","!")?(s(),!f()):p()}function p(){const e=o();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 r=e.slice(4);return t.row?t.row[r]:void 0}if(e.startsWith("typeDefault.")){const r=e.slice(12);return t.typeDefault?t.typeDefault[r]:void 0}return"row"===e?t.row:"typeDefault"===e?t.typeDefault:void 0}(e.v);if("op"===e.type&&"("===e.v){s();const e=l();return a("op",")")&&s(),e}return"op"===e.type&&"-"===e.v?(s(),-p()):void 0}}const w=l();return n<i.length?void 0:w}function B(e,t){if(!e||-1===e.indexOf("{{"))return e;const r=[],i=(n=e.replace(L,(e,i)=>{const n=function(e,t){if(!(e=(e||"").trim()))return D;if(G.test(e))return D;if("value"===e)return null==t.value?D:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const r=e.slice(4),i=t.row?t.row[r]:void 0;return null==i?D:String(i)}if(e.startsWith("typeDefault.")&&!/[()?]/.test(e)&&!e.includes(":")){const r=e.slice(12),i=t.typeDefault?t.typeDefault[r]:void 0;return null==i?D:String(i)}if(e.length>80)return D;if(!I.test(e)||z.test(e))return D;const r=e.match(/\./g);if(r&&r.length>1)return D;try{const r=U(e,t),i=null==r?"":String(r);return G.test(i)?D:i||D}catch{return D}}(i,t);return r.push({expr:i.trim(),result:n}),n===D?n:(o=n)&&"string"==typeof o?o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):"";var o}),n?n.replace(new RegExp(D,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):n);var n;const o=r.length&&r.every(e=>""===e.result||e.result===D);return G.test(e)||o?"":i}var G=/Reflect|Proxy|ownKeys/;function j(e){if(G.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&G.test(t.textContent||"")&&(t.textContent="");G.test(e.textContent||"")&&(e.textContent="")}}function Y(e){if(G.test(e)){const e=()=>"";return e.__blocked=!0,e}const t=t=>B(e,t);return t.__blocked=!1,t}function X(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}var K=new WeakMap;function Z(e){return"__proto__"===e||"constructor"===e||"prototype"===e}var Q=new Map;function J(e){if(-1===e.indexOf("."))return null;let t=Q.get(e);return void 0===t&&(t=Object.freeze(e.split(".")),Q.set(e,t)),t}function ee(e,t){let r=e;for(let i=0;i<t.length;i++){if(null==r||"object"!=typeof r)return;const e=t[i];if(Z(e))return;r=r[e]}return r}function te(e,t,r){if(null==e||"object"!=typeof e)return!1;let i=e;for(let o=0;o<t.length-1;o++){const e=t[o];if(Z(e))return!1;const r=i[e];if(null==r||"object"!=typeof r)return!1;i=r}const n=t[t.length-1];return!Z(n)&&(i[n]=r,!0)}function re(e,t){if(null==e)return;const r=J(t),i=e;return null===r?Z(t)?void 0:i[t]:Object.prototype.hasOwnProperty.call(i,t)?i[t]:ee(i,r)}function ie(e){const t=J(e);return null===t?Z(e)?()=>{}:t=>null==t?void 0:t[e]:r=>{if(null==r)return;const i=r;return Object.prototype.hasOwnProperty.call(i,e)?i[e]:ee(i,t)}}function ne(e){return-1===e.indexOf(".")&&!Z(e)}function oe(e,t,r){if(null==e||"object"!=typeof e)return!1;const i=J(t),n=e;return null===i?!Z(t)&&(n[t]=r,!0):Object.prototype.hasOwnProperty.call(n,t)?(n[t]=r,!0):te(n,i,r)}function se(e,t,r=-1){if(!t.valueAccessor)return re(e,t.field);if("object"!=typeof e||null===e)return t.valueAccessor({row:e,column:t,rowIndex:r});const i=e,n=t.field;let o=K.get(i);if(o){const e=o.get(n);if(void 0!==e)return e.v}else{if(!0===e.__loading)return;o=new Map,K.set(i,o)}const s=t.valueAccessor({row:e,column:t,rowIndex:r});return o.set(n,{v:s}),s}function ae(e,t){e&&(t?K.get(e)?.delete(t):K.delete(e))}function le(e,t,r){const i=[...e];return de(i,t.field,t.direction,r),i}function ce(e,t,r){const i=e.length;if(i<2)return;const n=new Array(i),o=new Uint8Array(i),s=new Array(i);for(let l=0;l<i;l++){const r=e[l];s[l]=l,n[l]=t(r),o[l]=!0===r?.__loading?1:0}s.sort((e,t)=>{const i=o[e];if(i!==o[t])return i?1:-1;const s=n[e],a=n[t];return null==s&&null==a?0:null==s?-r:null==a||s>a?r:s<a?-r:0});const a=new Array(i);for(let l=0;l<i;l++)a[l]=e[s[l]];for(let l=0;l<i;l++)e[l]=a[l]}function de(e,t,r,i){const n=i.find(e=>e.field===t),o=n?.sortComparator;if(o)if(n?.valueAccessor)e.sort((e,t)=>o(se(e,n),se(t,n),e,t)*r);else{const i=ie(t);e.sort((e,t)=>o(i(e),i(t),e,t)*r)}else n?.valueAccessor?function(e,t,r){ce(e,e=>se(e,t),r)}(e,n,r):function(e,t,r){ne(t)?e.sort((e,i)=>{const n=function(e,t){const r=!0===e?.__loading;return r===(!0===t?.__loading)?0:r?1:-1}(e,i);if(0!==n)return n;const o=e[t],s=i[t];return null==o&&null==s?0:null==o?-r:null==s||o>s?r:o<s?-r:0}):ce(e,ie(t),r)}(e,t,r)}function ue(e,t,r,i){e._rows=t,e.__rowRenderEpoch++;for(let n=0;n<e._rowPool.length;n++)e._rowPool[n].__epoch=-1;e._schedulerRenderHeader(),e.refreshVirtualWindow(!0),he(e,r,i)}function he(e,t,r){const i={field:t.field,direction:r};e.dispatchEvent(new CustomEvent("sort-change",{detail:i})),e._pluginManager?.emitPluginEvent?.("sort-change",i),n(e,o(e,0===r?"sortCleared":"sortApplied",t.header??t.field,1===r?"ascending":"descending")),e.requestStateChange?.()}function ge(e){return e._pluginManager?._hasRowStructurePlugins??!1}function fe(e,t){if(e._sortState&&e._sortState.field===t.field)if(1===e._sortState.direction)pe(e,t,-1);else{if(e._sortState=null,ge(e))return e._requestSchedulerPhase(4,"sort-clear"),void he(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=[],e._schedulerRenderHeader();const r=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');if(r)for(let t=0;t<r.length;t++){const i=r[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),he(e,t,0)}else e._sortState||(e.__originalOrder=e._rows.slice()),pe(e,t,1)}function pe(e,t,r){if(e._sortState={field:t.field,direction:r},ge(e))return e._requestSchedulerPhase(4,"sort-apply"),void he(e,t,r);const i={field:t.field,direction:r},n=e._columns,o=e.effectiveConfig?.sortHandler??le;if(o===le)return e._rows=e._rows.slice(),de(e._rows,i.field,r,n),void ue(e,e._rows,t,r);const s=o(e._rows,i,n);s&&"function"==typeof s.then?s.then(i=>{ue(e,i,t,r)}):ue(e,s,t,r)}function we(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function me(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function be(e,t){const r=document.createElement("span");S(r,"sort-indicator"),r.setAttribute("aria-hidden","true");const i=e._sortState?.field===t.field?e._sortState.direction:0,n=1===i?"sortAsc":-1===i?"sortDesc":"sortNone";r.dataset.icon=X(n);const o=e.icons?.[n];return void 0!==o&&function(e,t){"string"==typeof t?V(e,t):t instanceof HTMLElement&&e.replaceChildren(t.cloneNode(!0))}(r,o),r}function ve(e,t,r){const i=document.createElement("div");i.className="resize-handle",i.setAttribute("role","button"),i.setAttribute("tabindex","-1");const n=e._visibleColumns[t];return i.setAttribute("aria-label",`Width of column ${String(n?.header??n?.field??t+1)}`),i.addEventListener("pointerdown",n=>{0!==n.button&&"mouse"===n.pointerType||(n.stopPropagation(),n.preventDefault(),e._resizeController.start(n,t,r,i))}),i.addEventListener("dblclick",r=>{r.stopPropagation(),r.preventDefault(),e._resizeController.resetColumn(t)}),i}function ye(e,t,r,i){i.classList.add(k.SORTABLE),i.tabIndex=0;const n=e._sortState?.field===t.field?e._sortState.direction:0;i.setAttribute("aria-sort",0===n?"none":1===n?"ascending":"descending"),i.addEventListener("click",r=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(r,t,i)||fe(e,t)}),i.addEventListener("keydown",r=>{if("Enter"===r.key||" "===r.key){if(r.preventDefault(),e._dispatchHeaderClick?.(r,t,i))return;fe(e,t)}})}function _e(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((r,i)=>{const n=document.createElement("div");n.className="cell",S(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",r.field),n.setAttribute("data-col",String(i)),r.type&&n.setAttribute("data-type",r.type);const o=r.header??r.field,s=e._sortState?.field===r.field?e._sortState.direction:0,a=1===s?"asc":-1===s?"desc":null;if(r.headerRenderer){const t={column:r,value:o,sortState:a,filterActive:!1,cellEl:n,renderSortIcon:()=>we(e,r)?be(e,r):null,renderFilterButton:()=>null};!function(e,t){null!=t&&("string"==typeof t?e.appendChild(W(t)):t instanceof Node&&e.appendChild(t))}(n,r.headerRenderer(t)),we(e,r)&&ye(e,r,0,n),me(e,r)&&(n.classList.add("resizable"),n.appendChild(ve(e,i,n)))}else if(r.headerLabelRenderer){const t={column:r,value:o},s=r.headerLabelRenderer(t),a=document.createElement("span");null==s?a.textContent=o:"string"==typeof s?V(a,s):s instanceof Node&&a.appendChild(s),n.appendChild(a),we(e,r)&&(ye(e,r,0,n),n.appendChild(be(e,r))),me(e,r)&&(n.classList.add("resizable"),n.appendChild(ve(e,i,n)))}else if(r.__headerTemplate)Array.from(r.__headerTemplate.childNodes).forEach(e=>n.appendChild(e.cloneNode(!0))),we(e,r)&&(ye(e,r,0,n),n.appendChild(be(e,r))),me(e,r)&&(n.classList.add("resizable"),n.appendChild(ve(e,i,n)));else{const t=document.createElement("span");t.textContent=o,n.appendChild(t),n.setAttribute("aria-label",o),we(e,r)&&(ye(e,r,0,n),n.appendChild(be(e,r))),me(e,r)&&(n.classList.add("resizable"),n.appendChild(ve(e,i,n)))}t.appendChild(n)}),t.querySelectorAll(`.cell.${k.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 Ce(e,t){if(t&&t.length){const e={};return t.forEach(t=>{t.type&&(e[t.field]=t.type)}),{columns:t,typeMap:e}}const r=e[0]||{},i=Object.keys(r).map(e=>{const t=r[e],i=null==(n=t)?"string":"number"==typeof n?"number":"boolean"==typeof n?"boolean":n instanceof Date||"string"==typeof n&&/\d{4}-\d{2}-\d{2}/.test(n)&&!isNaN(Date.parse(n))?"date":"string";var n;return{field:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:i}}),n={};return i.forEach(e=>{n[e.field]=e.type||"string"}),{columns:i,typeMap:n}}var Re={STYLE:1,VIRTUALIZATION:2,HEADER:3,ROWS:4,COLUMNS:5,FULL:6},Se=class{#e;#t=0;#r=0;#i=null;#n=null;#o=null;#s=!1;constructor(e){this.#e=e}requestPhase(e,t){e>this.#t&&(this.#t=e),0===this.#r&&(this.#a(),this.#r=requestAnimationFrame(()=>this.#l()))}whenReady(){return this.#i?this.#i:Promise.resolve()}setInitialReadyResolver(e){this.#o=e}cancel(){0!==this.#r&&(cancelAnimationFrame(this.#r),this.#r=0),this.#t=0,this.#n&&(this.#n(),this.#n=null,this.#i=null)}get isPending(){return 0!==this.#t}get pendingPhase(){return this.#t}#a(){this.#i||(this.#i=new Promise(e=>{this.#n=e}))}#l(){if(this.#r=0,!this.#e._schedulerIsConnected)return this.#t=0,void(this.#n&&(this.#n(),this.#n=null,this.#i=null));const e=this.#t;this.#t=0,e>=Re.COLUMNS&&this.#e._schedulerMergeConfig(),e>=Re.ROWS&&this.#e._schedulerProcessRows(),e>=Re.COLUMNS&&(this.#e._schedulerProcessColumns(),this.#e._schedulerUpdateTemplate()),e>=Re.HEADER&&this.#e._schedulerRenderHeader(),e>=Re.VIRTUALIZATION&&this.#e.refreshVirtualWindow(!0,!0),e>=Re.STYLE&&this.#e._schedulerAfterRender();const t=!this.#s;t&&(this.#s=!0,this.#o?.()),this.#n&&(this.#n(),this.#n=null,this.#i=null),0!==e&&this.#c(e,t)}#c(e,t){const r=this.#e._virtualization,i=r?.enabled?{start:r.start,end:r.end}:null,n={phase:e,initial:t,rowCount:this.#e._rows?.length??0,visibleRange:i};this.#e._hostElement.dispatchEvent(new CustomEvent("render",{detail:n,bubbles:!0,composed:!0}))}},Ee="--tbw-row-height",Ae=new Set(["field","header","order","group","hidden","utility"]);var xe=class{#d;#u;#h;#g;#f;#p;#w;#m={};#b={};#v=!0;#y;#_;#C;#R;#e;#S=!1;constructor(e){this.#e=e}get original(){return this.#m}get effective(){return this.#b}get columns(){return this.#b.columns??[]}set columns(e){this.#b.columns=e}get lightDomColumnsCache(){return this.#f}set lightDomColumnsCache(e){this.#f=e}get originalColumnNodes(){return this.#w}set originalColumnNodes(e){this.#w=e}get initialColumnState(){return this.#R}set initialColumnState(e){this.#R=e}markSourcesChanged(){this.#v=!0}setGridConfig(e){this.#d!==e&&(this.#d=e,this.#v=!0,this.#f=void 0)}getGridConfig(){return this.#d}setColumns(e){this.#u=e,this.#v=!0}getColumns(){return this.#u}setFitMode(e){this.#h=e,this.#v=!0}getFitMode(){return this.#h}setColumnInference(e){this.#g!==e&&(this.#g=e,this.#v=!0)}getColumnInference(){return this.#g}merge(){const e=(this.#b.columns?.length??0)>0;if(!this.#v&&e)return;const t=this.#E();this.#v=!1,this.#m=t,Object.freeze(this.#m),this.#m.columns&&Object.freeze(this.#m.columns),this.#b=this.#A(this.#m),this.#x()}#A(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}#x(){const e=this.#b;"number"==typeof e.rowHeight&&e.rowHeight>0?(this.#e._virtualization.rowHeight=e.rowHeight,this.#e.style.setProperty(Ee,`${e.rowHeight}px`),this.#S=!0):this.#S&&(this.#e.style.removeProperty(Ee),this.#S=!1),"fixed"===e.fitMode&&this.columns.forEach(e=>{null==e.width&&(e.width="number"==typeof e.minWidth&&Number.isFinite(e.minWidth)&&e.minWidth>0?e.minWidth:80)}),this.#e._applyAnimationConfig(e)}#E(){const e=this.#d?{...this.#d}:{},t=Array.isArray(e.columns)?[...e.columns]:[],r=(this.#f??[]).map(e=>({...e}));let i=R(t,r);this.#u&&this.#u.length&&(i=R(this.#u,r));const n=this.#e.sourceRows;if("merge"===(this.#g??e.columnInference??"auto")&&n.length){i=function(e,t){if(!t.length)return e;const r=new Map;for(const o of t)r.set(o.field,o);const i=new Set(e.map(e=>e.field)),n=e.map(e=>{const t=r.get(e.field);if(!t)return e;const i={...e};for(const[r,n]of Object.entries(t))void 0!==n&&Object.assign(i,{[r]:n});return i});for(const o of t)i.has(o.field)||n.push(o);return n}(Ce(n).columns,i)}else 0===i.length&&n.length&&(i=Ce(n).columns);if(this.#p&&Object.keys(this.#p).length>0){const t={...this.#p},r=e.typeDefaults??{};for(const e of Object.keys(r)){const i=r[e],n=t[e];t[e]=n?{...n,...i}:i}e.typeDefaults=t}return i.length&&(!function(e){const t=[],r=[];for(const o of e)"number"==typeof o.order&&Number.isFinite(o.order)&&o.order>=0?t.push({col:o,order:Math.floor(o.order)}):r.push(o);if(0===t.length)return e;t.sort((e,t)=>e.order-t.order);const i=[];let n=0;for(const{col:o,order:s}of t){for(;i.length<s&&n<r.length;)i.push(r[n++]);const e=Math.min(s,i.length);i.splice(e,0,o)}for(;n<r.length;)i.push(r[n++]);e.length=0,e.push(...i)}(i),e.typeDefaults&&function(e,t){for(const r of e){const e=r.type?t[r.type]:void 0;if(e)for(const t of Object.keys(e)){if(Ae.has(t))continue;const i=Reflect.get(e,t);void 0!==i&&null==Reflect.get(r,t)&&("renderer"!==t&&"viewRenderer"!==t||null==r.renderer&&null==r.viewRenderer)&&Reflect.set(r,t,i)}}}(i,e.typeDefaults),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=Y(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=Y(e.__editorTemplate.innerHTML))}),e.columns=i),this.#h&&(e.fitMode=this.#h),e.fitMode||(e.fitMode="stretch"),this.#g&&(e.columnInference=this.#g),this.#e._pluginManager?.processConfig?.(e),e.columnState&&!this.#R&&(this.#R=e.columnState),e}collectState(e){const t=this.columns,r=this.#M();return{columns:t.map((t,i)=>{const n={field:t.field,order:i,visible:!t.hidden},o=t;void 0!==o.__renderedWidth?n.width=o.__renderedWidth:void 0!==t.width&&(n.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=r.get(t.field);s&&(n.sort=s);for(const r of e)if(r.getColumnState){const e=r.getColumnState(t.field);e&&Object.assign(n,e)}return n})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const r=this.columns,i=new Map(e.columns.map(e=>[e.field,e])),n=r.map(e=>{const t=i.get(e.field);if(!t)return e;const r={...e};return void 0!==t.width&&(r.width=t.width,r.__renderedWidth=t.width),void 0!==t.visible&&(r.hidden=!t.visible),r});n.sort((e,t)=>(i.get(e.field)?.order??1/0)-(i.get(t.field)?.order??1/0)),this.columns=n;const o=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(o.length>0){const e=o[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.#R=void 0,this.#e._sortState=null,this.#b=this.#A(this.#m),this.#x();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)}#M(){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.#_&&clearTimeout(this.#_),this.#_=setTimeout(()=>{this.#_=void 0;const t=this.collectState(e);this.#e._emit("column-state-change",t)},100)}setColumnVisible(e,t){const r=this.columns,i=r.find(t=>t.field===e);return!!i&&(!(!t&&i.lockVisible)&&(!(!t&&0===r.filter(t=>!t.hidden&&t.field!==e).length)&&(!!i.hidden!=!t&&(i.hidden=!t,this.#e._emit("column-visibility",{field:e,visible:t,visibleColumns:r.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])),r=[];for(const i of e){const e=t.get(i);e&&(r.push(e),t.delete(i))}for(const i of t.values())r.push(i);this.columns=r,this.#e._invalidateVisibleColumnsCache(),_e(this.#e),M(this.#e),this.#e._requestSchedulerPhase(Re.COLUMNS,"configManager")}parseLightDomColumns(e){if(this.#f||(this.#w=Array.from(e.querySelectorAll("tbw-grid-column")),this.#f=this.#w.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const r=t.includes(":")?c(t):void 0,i={field:r?.field??t,type:e.getAttribute("type")||r?.type||void 0,header:e.getAttribute("header")||r?.header||void 0,sortable:e.hasAttribute("sortable")&&"false"!==e.getAttribute("sortable"),__element:e},n=e.getAttribute("width");if(n){const e=parseFloat(n);!isNaN(e)&&/^\d+(\.\d+)?$/.test(n.trim())?i.width=e:i.width=n}const o=e.getAttribute("minWidth")||e.getAttribute("min-width");if(o){const e=parseFloat(o);isNaN(e)||(i.minWidth=e)}const s=e.getAttribute("order");if(s){const e=parseInt(s,10);Number.isFinite(e)&&e>=0&&(i.order=e)}e.hasAttribute("resizable")&&(i.resizable="false"!==e.getAttribute("resizable"));const a=e.getAttribute("options");a&&(i.options=a.split(",").map(e=>{const[t,r]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:r?.trim()||t.trim()}}));const l=e.querySelector("tbw-grid-column-view"),d=e.querySelector("tbw-grid-column-editor"),u=e.querySelector("tbw-grid-column-header");l&&(i.__viewTemplate=l),u&&(i.__headerTemplate=u);const h=globalThis.DataGridElement?.getAdapters?.()??[],g=l??e,f=h.find(e=>e.canHandle(g));if(f){const e=f.createRenderer(g);e&&(i.viewRenderer=e)}const p=d??e,w=h.find(e=>e.canHandle(p));if(w){const e=w.createEditor(p);e&&(i.editor=e)}const m=h.find(t=>t.canHandle(e)&&(t.createHeaderRenderer||t.createHeaderLabelRenderer));if(m){const t=m.createHeaderRenderer?.(e);t&&(i.headerRenderer=t);const r=m.createHeaderLabelRenderer?.(e);r&&(i.headerLabelRenderer=r)}return i}).filter(e=>!!e)}(e):[]),!this.#p){const t=function(e){const t=globalThis.DataGridElement?.getAdapters?.()??[];return Array.from(e.children).filter(e=>"tbw-grid-type"===e.tagName.toLowerCase()).map(e=>{const r=e.getAttribute("name")?.trim();if(!r)return null;const i=Array.from(e.children).find(e=>"tbw-grid-column-view"===e.tagName.toLowerCase()),n=i??e,o=t.find(e=>e.canHandle(n))?.createRenderer(n),s={};for(const t of Array.from(e.attributes)){if(!t.name.startsWith("data-"))continue;const e=t.name.slice(5).replace(/-([a-z])/g,(e,t)=>t.toUpperCase()).trim();e&&(s[e]=t.value)}return{name:r,params:s,viewTemplate:i,viewRenderer:o}}).filter(e=>null!==e)}(e),r={};for(const e of t){const t={};let i=!1;if(e.viewRenderer)t.renderer=e.viewRenderer,i=!0;else if(e.viewTemplate){const r=Y(e.viewTemplate.innerHTML);t.renderer=t=>r({row:t.row,value:t.value,field:t.field,column:t.column,typeDefault:e.params}),i=!0}i&&(r[e.name]=t)}this.#p=r}}clearLightDomCache(){this.#f=void 0,this.#p=void 0}#H=new Map;registerLightDomHandler(e,t){this.#H.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#H.delete(e.toLowerCase())}observeLightDOM(e){this.#y&&this.#y.disconnect();const t=new Set,r=()=>{this.#C=void 0;for(const e of t)this.#H.get(e)?.();t.clear()};this.#y=new MutationObserver(e=>{for(const r of e){for(const e of r.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const r=e.tagName.toLowerCase();this.#H.has(r)&&t.add(r)}for(const e of r.removedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const r=e.tagName.toLowerCase();this.#H.has(r)&&t.add(r)}if("attributes"===r.type&&r.target.nodeType===Node.ELEMENT_NODE){const e=r.target.tagName.toLowerCase();this.#H.has(e)&&t.add(e)}}t.size>0&&!this.#C&&(this.#C=setTimeout(r,0))}),this.#y.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order","name","type"]})}dispose(){this.#y?.disconnect(),this.#_&&clearTimeout(this.#_),this.#C&&(clearTimeout(this.#C),this.#C=void 0)}};function Me(e,t){const r=document.createElement("div");return e&&(r.className=e),function(e,t){if(t)for(const r in t){const i=t[r];null!=i&&e.setAttribute(r,i)}}(r,t),r}var He=document.createElement("template");function ke(e){const t=document.createDocumentFragment(),r=Me(e.hasShell?`${k.ROOT} has-shell`:k.ROOT);if(e.hasShell&&e.shellBody)e.shellHeader&&r.appendChild(e.shellHeader),r.appendChild(e.shellBody);else{const e=Me("tbw-grid-content");e.appendChild(He.content.cloneNode(!0)),r.appendChild(e)}return t.appendChild(r),t}He.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';function Te(e){const t=document.createElement("div");return t.className="tbw-empty-message",t.textContent=e.filteredOut?"No matching rows":"No data to display",t}function Pe(e,t){const r=(t??Te)(e);if("string"==typeof r){const e=document.createElement("div");return e.className="tbw-empty-message",V(e,r),e}return r}function Le(e){e?.remove()}function De(e,t,r,i,o,s,a,l){if(!e)return;if(!function(e,t,r){return!(e||t>0||null===r)}(t,r,o))return Le(a.el),a.el=void 0,a.renderer=void 0,a.target=void 0,a.sourceRows=void 0,void(a.filteredOut=void 0);const c=i.length,d=c>0&&0===r;if(a.el&&a.renderer===o&&a.target===s&&a.sourceRows===i&&a.filteredOut===d)return;const u="grid"===s?e:e.querySelector(".rows-container")??e;Le(a.el),a.el=function(e,t,r="rows"){const i=document.createElement("div");return i.className="tbw-empty-overlay",i.setAttribute("role","presentation"),i.setAttribute("data-overlay-target",r),i.appendChild(Pe(e,t)),i}({sourceRowCount:c,filteredOut:d},o??void 0,s),function(e,t){e.appendChild(t)}(u,a.el),a.renderer=o,a.target=s,a.sourceRows=i,a.filteredOut=d;const h=a.el.textContent?.trim();l&&h&&n(l,h)}function Ie(){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 Oe(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"🗹":"☐"}</span>`}function ze(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 Ne(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const r=e.closest(".data-grid-row");if(!r)return-1;const i=r.parentElement;if(!i)return-1;const n=i.querySelectorAll(":scope > .data-grid-row");for(let o=0;o<n.length;o++)if(n[o]===r)return o;return-1}function Fe(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function qe(e){return"rtl"===function(e){try{if("rtl"===getComputedStyle(e).direction)return"rtl"}catch{}try{if("rtl"===e.closest?.("[dir]")?.getAttribute("dir"))return"rtl"}catch{}return"ltr"}(e)}function $e(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 We(e,t,r){const i=$e(t,r);return"string"==typeof i?e.byKey.get(i):i&&"object"==typeof i?e.byRef.get(i):void 0}function Ve(e,t){if(0===e.length)return-1;if(t<=0)return 0;let r=0,i=e.length-1;for(;r<=i;){const n=Math.floor((r+i)/2),o=e[n],s=o.offset+o.height;if(t<o.offset)i=n-1;else{if(!(t>=s))return n;r=n+1}}return Math.max(0,Math.min(r,e.length-1))}function Ue(e,t){const{positionCache:r,heightCache:i,rows:n,start:o,end:s,headerRowCount:a,getPluginHeight:l,getRowId:c}=e;let d=!1;const u=[];t.forEach(e=>{const t=e.getAttribute("aria-rowindex");if(!t)return;const h=parseInt(t,10)-a-1;if(h<o||h>=s||h>=n.length)return;const g=n[h],f=l?.(g,h);if(void 0!==f){const e=r[h];return void((!e.measured||Math.abs(e.height-f)>1)&&(u.push({index:h,height:f}),d=!0))}const p=e.offsetHeight;if(p>0){const e=r[h];(!e.measured||Math.abs(e.height-p)>1)&&(u.push({index:h,height:p}),function(e,t,r,i){const n=$e(t,i);"string"==typeof n?e.byKey.set(n,r):n&&"object"==typeof n&&e.byRef.set(n,r)}(i,g,p,c),d=!0)}}),function(e,t){if(0===t.length||0===e.length)return;let r=t;for(let o=1;o<t.length;o++)if(t[o].index<t[o-1].index){r=[...t].sort((e,t)=>e.index-t.index);break}let i=0;for(;i<r.length&&r[i].index<0;)i++;if(i>=r.length||r[i].index>=e.length)return;let n=0;for(let o=r[i].index;o<e.length;o++){const t=e[o];for(t.offset+=n;i<r.length&&r[i].index===o;){const e=r[i].height,o=e-t.height;t.measured=!0,0!==o&&(t.height=e,n+=o),i++}}}(r,u);const h=d?function(e){let t=0;for(const r of e)r.measured&&t++;return t}(r):0,g=d?function(e,t){let r=0,i=0;for(const n of e)n.measured&&(r+=n.height,i++);return i>0?r/i:t}(r,e.defaultHeight):0;return{hasChanges:d,measuredCount:h,averageHeight:g}}var Be=335e5;function Ge(e,t,r=335e5){return{rawContentHeight:e,spacerHeight:Math.min(e,r),viewportHeight:t,capped:e>r}}function je(e,t){if(!t.capped)return e;const r=t.spacerHeight-t.viewportHeight,i=t.rawContentHeight-t.viewportHeight;if(r<=0||i<=0)return e;const n=e*i/r;return n<0?0:n>i?i:n}function Ye(e,t){if(!t.capped)return e;const r=t.spacerHeight-t.viewportHeight,i=t.rawContentHeight-t.viewportHeight;return r<=0||i<=0?e:e*r/i}function Xe(e){"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit()}function Ke(e){return void 0!==e._activeEditRows&&-1!==e._activeEditRows}function Ze(e,t,r,i){e._focusCol=(qe(e)?!i:i)?Math.min(r,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault()}function Qe(e,t,r){Ke(e)&&Xe(e),e._focusRow=r?t:0}function Je(e,t,r,i){t.ctrlKey||t.metaKey?Qe(e,r,i):(Ke(e)&&Xe(e),e._focusRow=i?Math.min(r,e._focusRow+1):Math.max(0,e._focusRow-1)),t.preventDefault()}function et(e,t,r){const i=e._focusRow,n=e._virtualization,o=n?.viewportEl?.clientHeight??n?.container?.clientHeight??0,s=e._getVerticalScrollOffsets?.(i),a=o-Math.max(0,s?.top??0)-Math.max(0,s?.bottom??0),l=n?.variableHeights?n.positionCache:null;let c;if(a>0&&l?.[i])c=Ve(l,l[i].offset+(r?a:-a)),c===i&&(c=i+(r?1:-1));else{const e=n?.rowHeight??0,t=a>0&&e>0?Math.max(1,Math.floor(a/e)):20;c=i+(r?t:-t)}return Math.max(0,Math.min(t,c))}function tt(e,t,r,i,n){(t.ctrlKey||t.metaKey)&&Qe(e,r,n),e._focusCol=n?i:0,t.preventDefault(),it(e,n?{forceScrollRight:!0}:{forceScrollLeft:!0})}function rt(e,t){if(e._dispatchKeyDown?.(t))return;const r=t.composedPath?.()??[];if(function(e,t,r){if(r&&r!==e&&!r.closest?.(".rows-body"))return!0;if(function(e){if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable}(r))switch(t.key){case"Home":case"End":case"ArrowLeft":case"ArrowRight":case"Enter":case"Escape":return!0;case"ArrowUp":case"ArrowDown":if("INPUT"===r.tagName&&"number"===r.type)return!0}const i=e._visibleColumns[e._focusCol]?.type;return Ke(e)&&"select"===i&&("ArrowDown"===t.key||"ArrowUp"===t.key)}(e,t,r.length?r[0]:t.target))return;const i=e._rows.length-1,n=e._visibleColumns.length-1;switch(t.key){case"Tab":!function(e,t,r,i){if(t.preventDefault(),!t.shiftKey)return e._focusCol<i?void(e._focusCol+=1):(Xe(e),void(e._focusRow<r&&(e._focusRow+=1,e._focusCol=0)));e._focusCol>0?e._focusCol-=1:e._focusRow>0&&(e._activeEditRows===e._focusRow&&Xe(e),e._focusRow-=1,e._focusCol=i)}(e,t,i,n);break;case"ArrowDown":Je(e,t,i,!0);break;case"ArrowUp":Je(e,t,i,!1);break;case"ArrowRight":Ze(e,t,n,!0);break;case"ArrowLeft":Ze(e,t,n,!1);break;case"Home":return void tt(e,t,i,n,!1);case"End":return void tt(e,t,i,n,!0);case"PageDown":e._focusRow=et(e,i,!0),t.preventDefault();break;case"PageUp":e._focusRow=et(e,i,!1),t.preventDefault();break;case"Enter":if(function(e,t){const r=e._focusRow,i=e._focusCol,n=e._visibleColumns[i],o=e._rows[r],s=n?.field??"",a=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:r,colIndex:i,column:n,field:s,value:s&&o?re(o,s):void 0,row:o,cellEl:e.querySelector(`[data-row="${r}"][data-col="${i}"]`),trigger:"keyboard",originalEvent:t}});return e.dispatchEvent(a),a.defaultPrevented}(e,t))return void t.preventDefault();break;default:return}it(e)}function it(e,t){!function(e){if(!e._virtualization?.enabled)return;const{rowHeight:t,container:r,viewportEl:i,scrollMapping:n}=e._virtualization,o=r,s=i?.clientHeight??o?.clientHeight??0;if(!o||s<=0)return;const a=e._getVerticalScrollOffsets?.(e._focusRow)??{top:0,bottom:0};if(a.skipScroll)return;const l=Math.max(0,a.top),c=s-l-Math.max(0,a.bottom);if(c<=0)return;const d=e._focusRow*t,u=n?je(o.scrollTop,n):o.scrollTop;if(d<u+l){const e=Math.max(0,d-l);o.scrollTop=n?Ye(e,n):e}else if(d+t>u+l+c){const e=Math.max(0,d-c+t-l);o.scrollTop=n?Ye(e,n):e}}(e);const r=Ke(e)||!!e._isGridEditMode;r||e.refreshVirtualWindow(!1),Fe(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const i=function(e){const t=e._focusRow,r=e._virtualization.start??0,i=e._virtualization.end??e._rows.length;if(t<r||t>=i)return;const n=e._bodyEl.querySelectorAll(".data-grid-row")[t-r];let o=n?.children[e._focusCol];return o&&o.classList?.contains("cell")||(o=n?.querySelector(`.cell[data-col="${e._focusCol}"]`)??n?.querySelector(".cell[data-col]")),o?{rowEl:n??null,cell:o}:void 0}(e);if(!i)return;const{rowEl:n,cell:o}=i;o.classList.add("cell-focus"),o.setAttribute("aria-selected","true"),r&&!t?.forceHorizontalScroll||function(e,t,r,i){const n=e.querySelector(".tbw-scroll-area");if(!n)return;if(i?.forceScrollLeft)return void(n.scrollLeft=0);if(i?.forceScrollRight)return void(n.scrollLeft=n.scrollWidth-n.clientWidth);const o=e._getHorizontalScrollOffsets?.(t??void 0,r)??{left:0,right:0};if(o.skipScroll)return;const s=r.getBoundingClientRect(),a=n.getBoundingClientRect(),l=s.left-a.left+n.scrollLeft,c=l+s.width,d=n.scrollLeft+o.left,u=n.scrollLeft+n.clientWidth-o.right;l<d?n.scrollLeft=l-o.left:c>u&&(n.scrollLeft=c-n.clientWidth+o.right)}(e,n,o,t),function(e,t,r){if(r&&t.classList.contains(k.EDITING)){const e=t.querySelector(H);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}return}if(r){if(t.contains(document.activeElement))return;t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1");try{t.focus({preventScroll:!0})}catch{}return}const i=document.activeElement;i instanceof HTMLElement&&i!==e&&"function"==typeof e.contains&&e.contains(i)&&!i.classList.contains("cell")&&!i.closest(".cell")||i===e||e.focus({preventScroll:!0})}(e,o,r)}var nt=new WeakMap;function ot(e,t,r,i){const{onMove:n,onEnd:o,onCancel:s,onPromote:a}=r,l=i?.threshold??0,c=i?.longPressDuration??0,d=i?.longPressSlop??8,u=e.pointerId;if(!function(e,t){let r=nt.get(e);return r||(r=new Set,nt.set(e,r)),!r.has(t)&&(r.add(t),!0)}(t,u))return()=>{};const h=e.clientX,g=e.clientY;let f=0===l&&0===c,p=!1,w=null,m=!1;function b(){return f=!0,function(){try{return t.setPointerCapture(u),!0}catch{return m=!0,!1}}()?(a?.(),!0):(y(),!1)}function v(){if(!p){var e,r;p=!0,null!==w&&(clearTimeout(w),w=null),t.removeEventListener("pointermove",_),t.removeEventListener("pointerup",C),t.removeEventListener("pointercancel",R),t.removeEventListener("lostpointercapture",S),document.removeEventListener("keydown",E,!0),e=t,r=u,nt.get(e)?.delete(r);try{t.hasPointerCapture(u)&&t.releasePointerCapture(u)}catch{}}}function y(){p||(v(),s?.())}function _(e){const t=e;if(t.pointerId!==u||p)return;const r=t.clientX-h,i=t.clientY-g,o=Math.sqrt(r*r+i*i);if(!f){if(c>0)return o>d?void y():void 0;if(l>0&&o<l)return;if(!b())return}n(t)}function C(e){const t=e;if(t.pointerId!==u||p)return;const r=f;v(),r?o(t):s?.()}function R(e){e.pointerId!==u||p||y()}function S(e){e.pointerId!==u||p||y()}function E(e){"Escape"!==e.key||p||y()}return t.addEventListener("pointermove",_),t.addEventListener("pointerup",C),t.addEventListener("pointercancel",R),t.addEventListener("lostpointercapture",S),document.addEventListener("keydown",E,!0),f&&(b(),m)?()=>{}:(c>0&&(w=setTimeout(()=>{w=null,p||b()},c)),y)}var st=null,at=new Set;function lt(e){const t=e.matches?"coarse":"fine";at.forEach(e=>e(t))}function ct(){const e=st||("function"!=typeof globalThis.matchMedia?null:("function"==typeof(st=globalThis.matchMedia("(pointer: coarse)")).addEventListener?st.addEventListener("change",lt):"function"==typeof st.addListener&&st.addListener(lt),st));return e?function(e){return e.matches?"coarse":"fine"}(e):"fine"}function dt(e,t){if(t){const r=t({size:e});if("string"==typeof r){const e=document.createElement("div");return V(e,r),e}return r}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 ut(e,t){if(!e.firstElementChild)return;const r=e.querySelector(":scope > .tbw-cell-loading-overlay");r&&(t?.unmount?.(r),r.remove())}function ht(e){if(!e.firstElementChild)return null;const t=e.querySelector(":scope > .tbw-cell-loading-overlay");if(!t)return null;const r=e.parentElement;return r?r.insertBefore(t,e):t.remove(),t}function gt(e,t){if(!e.firstElementChild)return;const r=e.querySelector(":scope > .tbw-row-loading-overlay");r&&(t?.unmount?.(r),r.remove())}function ft(e,t,r,i){if(t){if(e.classList.add("tbw-row-loading"),e.setAttribute("aria-busy","true"),!e.querySelector(":scope > .tbw-row-loading-overlay")){const t=document.createElement("div");if(t.className="tbw-row-loading-overlay",t.setAttribute("aria-hidden","true"),r)t.appendChild(dt("small",r));else{const e=document.createElement("div");e.className="tbw-row-loading-spinner",t.appendChild(e)}e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),gt(e,i)}function pt(e,t,r,i){if(t){e.classList.add("tbw-cell-loading"),e.setAttribute("aria-busy","true");const t=e.parentElement;if(t&&(t.__hasCellLoading=!0),r){if(e.classList.add("tbw-cell-loading-custom"),!e.querySelector(":scope > .tbw-cell-loading-overlay")){const t=document.createElement("div");t.className="tbw-cell-loading-overlay",t.setAttribute("aria-hidden","true"),t.appendChild(dt("small",r)),e.appendChild(t)}}else e.classList.remove("tbw-cell-loading-custom"),ut(e,i)}else e.classList.remove("tbw-cell-loading"),e.classList.remove("tbw-cell-loading-custom"),e.removeAttribute("aria-busy"),ut(e,i)}function wt(e,t){if(!e?.releaseCell&&!e?.unmount)return;gt(t,e);const r=t.children;for(let i=0;i<r.length;i++){const t=r[i];ut(t,e),t.firstElementChild&&e.releaseCell?.(t)}}function mt(e,t){const r=t.renderer||t.viewRenderer;if(r)return r;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const r=i.getTypeDefault(t.type,e._hostElement);if(r?.renderer)return r.renderer}}function bt(e,t){if(t.format)return t.format;if(!t.type)return;const r=e.__frameworkAdapter;if(r?.getTypeDefault){const i=r.getTypeDefault(t.type,e._hostElement);if(i?.format)return i.format}}function vt(e){return(e.__editingCellCount??0)>0}function yt(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing"),e.querySelectorAll(`.cell.${k.EDITING}`).forEach(e=>e.classList.remove(k.EDITING))}var _t=document.createElement("template");_t.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';var Ct=document.createElement("template");function Rt(){return Ct.content.firstElementChild.cloneNode(!0)}function St(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function Et(e){const t=e.getAttribute("data-dynamic-classes");if(!t)return;const r=t.split(" ");for(let i=0;i<r.length;i++)r[i]&&e.classList.remove(r[i])}function At(e,t){const r="string"==typeof t?t.split(/\s+/):t;if(!r||0===r.length)return void e.removeAttribute("data-dynamic-classes");let i="";for(let n=0;n<r.length;n++){const t=r[n];t&&"string"==typeof t&&(e.classList.add(t),i+=(i?" ":"")+t)}e.setAttribute("data-dynamic-classes",i)}function xt(e,t,r,i,n,o,s,a){e._afterCellRender?.({row:o,rowIndex:s,column:i,colIndex:n,value:a,cellElement:r,rowElement:t})}function Mt(e,t,r,i){for(;e._rowPool.length<r;)e._rowPool.push(Rt());if(function(e,t,r,i){if(e._isGridEditMode||(e._activeEditRows??-1)<0||!i)return;const n=e._rowPool,o=e._rows;let s=0;for(;s<n.length&&!vt(n[s]);)s++;if(s===n.length)return;const a=n[s],l=a.__rowDataRef;if(a.parentNode!==i)return;let c=0;for(;c<r&&o[t+c]!==l;)c++;if(c===r)return;e._focusRow===Number(a.firstElementChild?.getAttribute("data-row"))&&(e._focusRow=t+c);if(s===c)return;if(n.splice(s,1),n.splice(c,0,a),s<c)for(let d=s;d<c;d++)i.insertBefore(n[d],a);else{const e=a.nextSibling;for(let t=c+1;t<=s;t++)i.insertBefore(n[t],e)}}(e,t,r,i),e._rowPool.length<=r)return;const n=e.__frameworkAdapter;n?.beginBatch?.(e);try{for(let t=r;t<e._rowPool.length;t++){const r=e._rowPool[t];wt(n,r),r.parentNode===i&&r.remove()}e._rowPool.length=r}finally{n?.endBatch?.(e)}}function Ht(e,t,r){const i=e.__frameworkAdapter;i?.beginBatch?.(e);try{for(let e=0;e<r.length;e++){const t=r[e];t.classList.contains("tbw-cell-loading")&&pt(t,!1,void 0,i)}t.__hasCellLoading=!1}finally{i?.endBatch?.(e)}}function kt(e,t,r){for(let i=0;i<r;i++)if(t[i].externalView&&!e.querySelector(`.cell[data-col="${i}"] [data-external-view]`))return!0;return!1}function Tt(e,t,r,i,n,o,s){const a=vt(t),l=!s&&(!!e._isGridEditMode||(e._activeEditRows??-1)>=0)||e._activeEditRows===i;return o?a&&!l?(yt(t),Bt(e,t,r,i),t.__epoch=n,void(t.__rowDataRef=r)):(qt(e,t,r,i),void(s&&(t.__rowDataRef=r))):a&&l?(qt(e,t,r,i),void(t.__rowDataRef=r)):(function(e){e.__isCustomRow&&(e.className="data-grid-row",e.setAttribute("role","row"),e.__isCustomRow=!1)}(t),a&&yt(t),Bt(e,t,r,i),t.__epoch=n,void(t.__rowDataRef=r))}function Pt(e,t,r){let i=!1;const n=e._changedRowIdSet;if(n&&n.size>0)try{const t=e.getRowId?.(r);t&&(i=n.has(t))}catch{}i!==t.classList.contains("changed")&&t.classList.toggle("changed",i)}function Lt(e,t,r){const i=e.effectiveConfig?.rowClass;if(i){Et(t);try{At(t,i(r))}catch(n){v("TBW060",`rowClass callback error: ${n}`,e.id),t.removeAttribute("data-dynamic-classes")}}}function Dt(e){return null!=e&&(!0===e.__isGroupRow||!0===e.__loading||!0===e.__pivotIsGrandTotal||void 0!==e.__pivotRowKey)}function It(e,t){t!==e.classList.contains("cell-focus")&&(e.classList.toggle("cell-focus",t),e.setAttribute("aria-selected",String(t)))}function Ot(e,t,r,i,n){const o=r.cellClass;if(o){Et(t);try{At(t,o(se(i,r,n),i,r))}catch(s){v("TBW061",`cellClass callback error for column '${r.field}': ${s}`,e.id),t.removeAttribute("data-dynamic-classes")}}}Ct.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';var zt=/Reflect\.|\bProxy\b|ownKeys\(/;function Nt(e,t,r){null!==r?(t.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(t),V(t,r),j(t)):t.textContent=""}function Ft(e,t,r,i,n,o,s,a){const l=mt(e,i);let c;const d=t.__hasCellLoading?ht(r):null;if(l)c=se(o,i,s),function(e,t,r,i,n,o){const s=o({row:i,value:n,field:r.field,column:r,grid:e,cellEl:t});"string"==typeof s?(e.__frameworkAdapter?.releaseCell?.(t),V(t,s)):s instanceof Node?s.parentElement!==t&&(e.__frameworkAdapter?.releaseCell?.(t),t.innerHTML="",t.appendChild(s)):null==s&&(e.__frameworkAdapter?.releaseCell?.(t),t.textContent=null==n?"":String(n))}(e,r,i,o,c,l);else if(i.__compiledView){c=se(o,i,s);const t=i.__compiledView({row:o,value:c,field:i.field,column:i});Nt(e,r,i.__compiledView.__blocked?null:t)}else if(i.__viewTemplate){c=se(o,i,s);const t=i.__viewTemplate.innerHTML;Nt(e,r,zt.test(t)?null:B(t,{row:o,value:c}))}else{if(i.externalView)return void(d&&r.appendChild(d));c=se(o,i,s),function(e,t,r,i,n){t.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(t);const o=bt(e,r);if(o){let a;try{const e=o(n,i);a=null==e?"":String(e)}catch(s){v(w,`Format error in column '${r.field}': ${s}`,e.id),a=null==n?"":String(n)}t.textContent=a}else"date"===r.type?t.textContent=ze(n):"boolean"===r.type?t.innerHTML=Oe(!!n):t.textContent=null==n?"":String(n)}(e,r,i,o,c)}d&&r.appendChild(d),a&&xt(e,t,r,i,n,o,s,c)}function qt(e,t,r,i){const n=t.children,o=e._visibleColumns,s=o.length,a=n.length,l=s<a?s:a,c=String(i),d=e._hasAfterCellRenderHook?.()??!1;if(!function(e,t,r){const i=e.__hasSpecialColumns;if(void 0!==i)return i;let n=!1;const o=e.__frameworkAdapter;for(let s=0;s<r;s++){const r=t[s];if(r.__viewTemplate||r.__compiledView||r.renderer||r.viewRenderer||r.externalView||r.format||r.cellClass||"date"===r.type||"boolean"===r.type||r.type&&o?.getTypeDefault?.(r.type,e._hostElement)?.renderer||r.type&&o?.getTypeDefault?.(r.type,e._hostElement)?.format){n=!0;break}}return e.__hasSpecialColumns=n,n}(e,o,s))return void function(e,t,r,i,n,o,s,a,l){const c=e._focusRow,d=e._focusCol,u=!0===t.__hasCellLoading;for(let h=0;h<n;h++){const n=r[h];if(n.getAttribute("data-row")!==a&&n.setAttribute("data-row",a),n.classList.contains(k.EDITING))continue;const g=u?ht(n):null;n.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(n);const f=i[h],p=se(o,f,s);n.textContent=null==p?"":String(p),g&&n.appendChild(g),It(n,c===s&&d===h),l&&xt(e,t,n,f,h,o,s,p)}}(e,t,n,o,l,r,i,c,d);if(function(e,t,r){for(let i=0;i<r;i++)if(t[i].externalView&&!e[i].querySelector("[data-external-view]"))return!0;return!1}(n,o,l))return void Bt(e,t,r,i);const u=e._focusRow,h=e._focusCol;for(let g=0;g<l;g++){const s=o[g],a=n[g];a.getAttribute("data-row")!==c&&a.setAttribute("data-row",c);const l=a.classList.contains(k.EDITING);l||It(a,u===i&&h===g),Ot(e,a,s,r,i),l||Ft(e,t,a,s,g,r,i,d)}}function $t(e,t,r){const i=_t.content.firstElementChild.cloneNode(!0);return i.setAttribute("aria-colindex",String(t+1)),i.setAttribute("data-col",String(t)),i.setAttribute("data-row",String(r)),i.setAttribute("data-field",e.field),i.setAttribute("data-header",e.header??e.field),e.type&&i.setAttribute("data-type",e.type),i}function Wt(e,t,r,i,n,o){const s=mt(e,r);if(s)return function(e,t,r,i,n,o){const s=i({row:o,value:n,field:r.field,column:r,grid:e,cellEl:t});return"string"==typeof s?(V(t,s),!0):(s instanceof Node?s.parentElement!==t&&(t.textContent="",t.appendChild(s)):null==s&&(t.textContent=null==n?"":String(n)),!1)}(e,t,r,s,i,n);if(r.externalView)return function(e,t,r,i,n){const o=r.externalView,s=document.createElement("div");s.setAttribute("data-external-view",""),s.setAttribute("data-field",r.field),t.appendChild(s);const a={row:n,value:i,field:r.field,column:r,grid:e};if(o.mount)try{o.mount({placeholder:s,context:a,spec:o})}catch(l){v("TBW063",`External view mount error for column '${r.field}': ${l}`,e.id)}else queueMicrotask(()=>{try{e.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:s,spec:o,context:a}}))}catch(l){v("TBW064",`External view event dispatch error for column '${r.field}': ${l}`,e.id)}});s.setAttribute("data-mounted","")}(e,t,r,i,n),!1;const a=r.__compiledView;if(a){const e=a({row:n,value:i,field:r.field,column:r});return a.__blocked?(t.textContent="",t.setAttribute("data-blocked-template","")):V(t,e),!0}const l=r.__viewTemplate;if(l){const e=l.innerHTML;return/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(t.textContent="",t.setAttribute("data-blocked-template",""),!1):(V(t,B(e,{row:n,value:i})),!0)}return function(e,t,r,i){i||"date"!==t.type?i||"boolean"!==t.type?e.textContent=null==r?"":String(r):e.innerHTML=Oe(!!r):e.textContent=ze(r)}(t,r,i,o),!1}function Vt(e,t){if(t){j(e);const t=e.textContent||"";/Proxy|Reflect\.ownKeys/.test(t)&&(e.textContent=t.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(e.textContent||"")&&(e.textContent=""))}e.hasAttribute("data-blocked-template")&&(e.textContent||"").trim().length&&(e.textContent="")}function Ut(e,t,r){("function"==typeof t.editable?t.editable(r):t.editable)?e.tabIndex=0:"boolean"===t.type&&(e.hasAttribute("tabindex")||(e.tabIndex=0))}function Bt(e,t,r,i){!function(e,t){t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy");const r=e.__frameworkAdapter;if(r?.releaseCell||r?.unmount){r.beginBatch?.(e);try{gt(t,r);const e=t.children;for(let t=e.length-1;t>=0;t--){const i=e[t];ut(i,r),r.releaseCell?.(i)}t.innerHTML=""}finally{r.endBatch?.(e)}}else t.innerHTML=""}(e,t);const n=e._visibleColumns,o=n.length,s=e._focusRow,a=e._focusCol,l=e._hasAfterCellRenderHook?.()??!1,c=document.createDocumentFragment();for(let u=0;u<o;u++){const o=n[u],h=$t(o,u,i);let g=se(r,o,i);const f=bt(e,o);if(f)try{g=f(g,r)}catch(d){v(w,`Format error in column '${o.field}': ${d}`,e.id)}Vt(h,Wt(e,h,o,g,r,!!f)),Ut(h,o,r),s===i&&a===u?(h.classList.add("cell-focus"),h.setAttribute("aria-selected","true")):h.setAttribute("aria-selected","false"),Ot(e,h,o,r,i),l&&xt(e,t,h,o,u,r,i,g),c.appendChild(h)}t.appendChild(c)}function Gt(e,t,r){if(t.target?.closest(".resize-handle"))return;const i=Ne(r.querySelector(".cell[data-row]"));if(i<0)return;const n=e._rows[i];if(!n)return;if(e._dispatchRowClick?.(t,i,n,r))return;const o=t.target?.closest(".cell[data-col]");if(o){const r=Number(o.getAttribute("data-col"));if(!isNaN(r)){if(e._dispatchCellClick?.(t,i,r,o))return;const n=e._focusRow!==i||e._focusCol!==r;if(e._focusRow=i,e._focusCol=r,o.classList.contains(k.EDITING)){n&&(Fe(e._bodyEl??e),o.classList.add("cell-focus"));const r=t.target,i=o.contains(r)&&r.matches('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])')?r:o.querySelector(H);try{i?.focus({preventScroll:!0})}catch{}return}it(e)}}}var jt=new WeakMap,Yt=T.TRUNCATED;function Xt(e,t){const r=Ne(t),i=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(r<0||i<0)return;e._focusRow=r,e._focusCol=i,Fe(e._bodyEl),t.classList.add("cell-focus"),t.setAttribute("aria-selected","true");const n=t.closest("tbw-grid, [data-tbw-grid]");n&&document.activeElement!==n&&n.focus({preventScroll:!0})}function Kt(e,t,r,i){let n=null;const o=r.composedPath?.();if(n=o&&o.length>0?o[0]:r.target,!n||!t.contains(n)||!n.closest?.("[data-col]")){const e=document.elementFromPoint(r.clientX,r.clientY);e&&(n=e)}const s=n?.closest?.("[data-col]"),a=n?.closest?.(".data-grid-row"),l=n?.closest?.(".header-row");let c,d,u,h,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(u=e._rows[c],f=e._visibleColumns[d],h=f?.field,g=u&&h?re(u,h):void 0)),{type:i,row:u,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:h,value:g,column:f,originalEvent:r,cellElement:s??void 0,rowElement:a??void 0,isHeader:!!l,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}var Zt;function Qt(e,t,r){if(0!==r.button&&"mouse"===r.pointerType)return;if(jt.get(e))return;const i=function(e){return"touch"===e.pointerType||"pen"===e.pointerType||"mouse"!==e.pointerType&&"coarse"===ct()}(r);let n=null;const o=()=>{const i=Kt(e,t,r,"mousedown");return e._dispatchCellMouseDown?.(i)??!1};if(!i){if(!o())return;jt.set(e,!0)}ot(r,t,{onPromote:()=>{if(i){if(!o())return;jt.set(e,!0),n=function(e){if(!e)return()=>{};const t=e.style.touchAction;return e.style.touchAction="none",()=>{e.style.touchAction=t}}(e._bodyEl),function(e){const t=e.ownerDocument;if(!t)return;let r=null;const i=t=>{const r=t.target;r&&e.contains(r)&&(t.preventDefault(),t.stopPropagation(),n())},n=()=>{null!==r&&clearTimeout(r),r=null,t.removeEventListener("contextmenu",i,!0)};t.addEventListener("contextmenu",i,!0),r=setTimeout(n,700)}(t)}},onMove:r=>{if(!jt.get(e))return;const i=Kt(e,t,r,"mousemove");e._dispatchCellMouseMove?.(i)},onEnd:r=>{if(n?.(),n=null,!jt.get(e))return;const i=Kt(e,t,r,"mouseup");e._dispatchCellMouseUp?.(i),jt.set(e,!1)},onCancel:()=>{n?.(),n=null,jt.set(e,!1)}},i?{longPressDuration:400}:{threshold:3})}function Jt(e,t,r,i){t.addEventListener("keydown",t=>rt(e,t),{signal:i}),r.addEventListener("pointerdown",t=>Qt(e,r,t),{signal:i}),r.addEventListener("mouseover",t=>{if(e.getPluginByName?.("tooltip"))return;const r=t.target.closest(".cell");if(!r)return;const i=t.relatedTarget;i&&r.contains(i)||function(e){const t=e.hasAttribute(Yt);if(e.title&&!t)return;const r=e.scrollWidth>e.clientWidth?(e.textContent??"").trim():"";r?(e.title=r,e.setAttribute(Yt,"")):t&&(e.removeAttribute("title"),e.removeAttribute(Yt))}(r)},{signal:i,passive:!0})}var er=class{#e;#k=new Set;#T=new Map;#P=null;constructor(e){this.#e=e,this.#L()}focusCell(e,t){const r=this.#e,i=r._rows.length-1;if(i<0)return;let n;if("string"==typeof t){if(n=r._visibleColumns.findIndex(e=>e.field===t),n<0)return}else n=t;const o=r._visibleColumns.length-1;o<0||(r._focusRow=Math.max(0,Math.min(e,i)),r._focusCol=Math.max(0,Math.min(n,o)),it(r))}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 r=this.#e._virtualization;if(!r.enabled)return;const i=r.container;if(!i)return;const n=this.#e._rows.length;if(0===n)return;const o=Math.max(0,Math.min(e,n-1)),s=t?.align??"nearest",a=t?.behavior??"instant";let l,c;const d=r.positionCache;r.variableHeights&&d&&d.length>o?(l=d[o].offset,c=d[o].height):(l=o*r.rowHeight,c=r.rowHeight);const u=r.viewportEl?.clientHeight??i.clientHeight??0;if(u<=0)return;const h=this.#e._getVerticalScrollOffsets?.(o)??{top:0,bottom:0};if(h.skipScroll)return;const g=Math.max(0,h.top),f=u-g-Math.max(0,h.bottom);if(f<=0)return;const p=i.scrollTop,w=l+c,m=p+g,b=p+g+f;let v;switch(s){case"start":v=l-g;break;case"center":v=l-g-f/2+c/2;break;case"end":v=w-f-g;break;default:if(l>=m&&w<=b)return;v=l<m?l-g:w-f-g}v=Math.max(0,v);const y=Ye(v,r.scrollMapping);"smooth"===a&&"0"!==getComputedStyle(this.#e).getPropertyValue("--tbw-animation-enabled").trim()?i.scrollTo({top:y,behavior:"smooth"}):i.scrollTop=y}scrollToRowById(e,t){const r=this.#e._getRowEntry(e);r&&this.scrollToRow(r.index,t)}registerExternalFocusContainer(e){if(this.#k.has(e))return;this.#k.add(e);const t=new AbortController,r=t.signal,i=this.#e;e.addEventListener("focusin",e=>{i.dataset.hasFocus="",this.#D(e.target)},{signal:r}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete i.dataset.hasFocus,null===t&&this.#I()},{signal:r}),this.#T.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#k.delete(e);const t=this.#T.get(e);t&&(t(),this.#T.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.#k)if(t.contains(e))return!0;return!1}#L(){const e=this.#e;e.addEventListener("focusin",e=>this.#D(e.target),{capture:!0}),e.addEventListener("focusout",e=>{null===e.relatedTarget&&this.#I()})}#D(e){if(!(e instanceof HTMLElement))return;if(e===this.#e)return;const t=e.closest?.(".cell");t&&!t.classList.contains("editing")||this.isInExternalFocusContainer(e)||(this.#P=e)}#I(){queueMicrotask(()=>{this.#e.isConnected&&document.activeElement===document.body&&this.restoreLastFocus()})}restoreLastFocus(){const e=this.#P;if(!e)return!1;if(!e.isConnected)return this.#P=null,!1;if(e===document.activeElement)return!0;try{e.focus({preventScroll:!0})}catch{return!1}return document.activeElement===e}get lastFocusedElement(){return this.#P?.isConnected?this.#P:null}};var tr="function"==typeof requestIdleCallback;function rr(e){tr?cancelIdleCallback(e):clearTimeout(e)}function ir(){return"function"==typeof HTMLElement.prototype?.showPopover}function nr(e,t){const r=document.createElement("button");return r.type="button",r.className="tbw-size-popover-btn",r.setAttribute("aria-label",e),r.textContent=t,r}function or(e){const t=e.step??16;let r,i=null,n=null,o=null,s=!1,a=!1;const l=new AbortController;function c(){s&&i&&(s=!1,ir()&&i.hidePopover(),i.hidden=!0,o?.removeAttribute("data-tbw-size-open"),o=null)}function d(){n&&(n.value=String(Math.round(e.getSize(r))))}function u(t){Number.isFinite(t)&&(e.setSize(r,t),d())}return document.addEventListener("pointerdown",e=>{s&&i&&!e.composedPath().includes(i)&&c()},{capture:!0,signal:l.signal}),document.addEventListener("keydown",e=>{"Escape"===e.key&&c()},{capture:!0,signal:l.signal}),{get element(){return i},open(h,g){if(a)return;r=h,o?.removeAttribute("data-tbw-size-open"),o=g,g.setAttribute("data-tbw-size-open",""),i||(i=function(){const i=document.createElement("div");i.id=e.id,i.className="tbw-size-popover",i.setAttribute("popover","manual"),i.setAttribute("role","group"),i.hidden=!0;const o=nr("Narrower","−"),s=nr("Wider","+"),a=nr("Reset size","Reset"),h=document.createElement("input");return h.type="number",h.className="tbw-size-popover-input",h.min="0",h.step="any",h.setAttribute("aria-label","Size in pixels"),o.addEventListener("click",()=>u(e.getSize(r)-t),{signal:l.signal}),s.addEventListener("click",()=>u(e.getSize(r)+t),{signal:l.signal}),a.addEventListener("click",()=>{e.reset(r),d()},{signal:l.signal}),h.addEventListener("change",()=>u(h.valueAsNumber),{signal:l.signal}),i.addEventListener("focusout",e=>{const t=e.relatedTarget;t instanceof Node&&!i.contains(t)&&c()},{signal:l.signal}),i.append(o,h,s,a),n=h,i}());const f=e.getHost(h)??document.body;i.parentNode!==f&&f.appendChild(i),i.setAttribute("aria-label",e.getLabel(h)),d(),i.hidden=!1,!s&&ir()&&i.showPopover(),s=!0,function(e){if(!i)return;const t=e.getBoundingClientRect(),r=i.getBoundingClientRect(),n=(e,t)=>Math.max(4,Math.min(e,t-4)),o=n(t.left+t.width/2-r.width/2,window.innerWidth-r.width),s=t.bottom+6,a=t.top-6-r.height,l=t.height>3*r.height;let c;c=!l&&s+r.height<=window.innerHeight?s:!l&&a>=4?a:n(t.top+t.height/2-r.height/2,window.innerHeight-r.height),i.style.left=`${Math.round(o)}px`,i.style.top=`${Math.round(c)}px`}(g),n?.focus()},close:c,dispose(){a=!0,c(),l.abort(),i?.remove(),i=null,n=null}}}function sr(e){let t=null,r=null,i=!1,n=null,o=null,s=null,a=null,l=null;const c=()=>{null!==l&&(clearTimeout(l),l=null)},d=t=>{const r=e._visibleColumns[t];return null!=r?.__renderedWidth?r.__renderedWidth:"number"==typeof r?.width?r.width:(t=>(e._headerRowEl??e.findHeaderRow?.())?.querySelectorAll(".cell")[t])(t)?.getBoundingClientRect().width??0},u=(t,r)=>{const i=e._visibleColumns[t];if(!i)return null;const o=Math.max(function(e){return"number"==typeof e?.minWidth&&Number.isFinite(e.minWidth)&&e.minWidth>0?e.minWidth:40}(i),r);return i.width=o,i.__userResized=!0,i.__renderedWidth=o,null==n&&(n=requestAnimationFrame(()=>{n=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:i.field,width:o}})),o},h=e=>{if(!t)return;const r=e.clientX-t.startX;0!==r&&(i=!0),u(t.colIndex,t.startWidth+r)};let g=!1;const f=()=>{g=!0,requestAnimationFrame(()=>{g=!1})},p=r=>{r&&f(),null!==o&&(document.documentElement.style.cursor=o,o=null),null!==s&&(document.body.style.userSelect=s,s=null),t=null,r&&e.requestStateChange&&e.requestStateChange()};function w(t){const r=e._visibleColumns[t];r&&(c(),r.__userResized=!1,r.__renderedWidth=void 0,r.width=r.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:r.field,width:r.width}})))}return{get isResizing(){return null!==t||g},start(n,g,m,b){const v=function(e){return"pointerId"in e?e:new PointerEvent("pointerdown",{pointerId:1,pointerType:"mouse",isPrimary:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons})}(n);n.preventDefault(),r?.(),r=null,c(),i=!1;const y=e._headerRowEl??e.findHeaderRow?.();y&&function(t,r){const i=r.querySelectorAll(".cell");for(let n=0;n<e._visibleColumns.length;n++){if(n===t)continue;const r=e._visibleColumns[n];if(null==r.width&&!r.__userResized){const e=i[n]?.getBoundingClientRect().width;e&&(r.width=Math.round(e),r.__userResized=!0,r.__renderedWidth=r.width)}}}(g,y);const _=e._visibleColumns[g],C="number"==typeof _?.width?_.width:void 0,R=_?.__renderedWidth??C??m.getBoundingClientRect().width;t={startX:v.clientX,colIndex:g,startWidth:R,startConfiguredWidth:_?.width,startRenderedWidth:_?.__renderedWidth,startUserResized:_?.__userResized??!1},null===o&&(o=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",null===s&&(s=document.body.style.userSelect),document.body.style.userSelect="none";const S=b??m;r=ot(v,S,{onMove:h,onEnd:()=>{r=null,i?p(!0):(f(),p(!1),l=setTimeout(()=>{l=null,function(t,r){a??=or({id:"tbw-column-size-popover",getSize:d,setSize:(t,r)=>{u(t,r),e.requestStateChange?.()},reset:w,getLabel:t=>{const r=e._visibleColumns[t];return`Width of column ${String(r?.header??r?.field??t+1)}`},getHost:()=>e}),a.open(t,r)}(g,S)},300))},onCancel:()=>{r=null,(()=>{const r=t;if(r){const t=e._visibleColumns[r.colIndex];t&&(t.width=r.startConfiguredWidth,t.__renderedWidth=r.startRenderedWidth,t.__userResized=r.startUserResized,e.updateTemplate?.(),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:t.field,width:r.startWidth}}))),f()}p(!1)})()}})},resetColumn:w,setColumnWidth(t,r){null!=u(t,r)&&e.requestStateChange?.()},getColumnWidth:d,dispose(){r?.(),r=null,p(null!==t),c(),a?.dispose(),a=null,null!=n&&(cancelAnimationFrame(n),n=null)}}}var ar="data-animating",lr={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},cr={change:500,insert:300,remove:200};function dr(e,t){const r=lr[t],i=getComputedStyle(e).getPropertyValue(r);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 cr[t]}function ur(e,t,r){if(t<0)return Promise.resolve(!1);const i=e.findRenderedRowElement?.(t);return i?new Promise(e=>{!function(e,t,r){e.removeAttribute(ar),e.offsetWidth,e.setAttribute(ar,t);const i=dr(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(ar),r?.()},i)}(i,r,()=>e(!0))}):Promise.resolve(!1)}function hr(e,t){const r=e;return!0===r?.__loading?null!=r.__index?`__loading:${r.__index}`:null!=r.__groupKey?`__loading:group:${r.__groupKey}`:void 0:t?t(e):"id"in r&&null!=r.id?String(r.id):"_id"in r&&null!=r._id?String(r._id):void 0}var gr=class{#e;constructor(e){this.#e=e}getRow(e){return this.#e._getRowEntry(e)?.row}#O(e,t,r,i,n){const o=this.#e,s=[];for(const[a,l]of Object.entries(i)){if("__proto__"===a||"constructor"===a||"prototype"===a)continue;const c=re(t,a);if(c===l)continue;const d=o.query?.("commitCellValue",{rowIndex:r,rowId:e,row:t,field:a,oldValue:c,newValue:l,source:n});d?.includes(!1)||(d?.includes(!0)||(oe(t,a,l),ae(t)),s.push({field:a,oldValue:c,newValue:l}),o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:t,rowId:e,rowIndex:r,field:a,oldValue:c,newValue:l,changes:i,source:n},bubbles:!0,composed:!0})))}return s}updateRow(e,t,r="api"){const i=this.#e,n=i._getSourceRowEntry(e);if(!n)return void("history"!==r&&v(p,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id));const{row:o,index:s}=n;this.#O(e,o,s,t,r).length>0&&(St(i),i._requestSchedulerPhase(Re.VIRTUALIZATION,"updateRow"),i._emitDataChange())}updateRows(e,t="api"){const r=this.#e;let i=!1;for(const{id:n,changes:o}of e){const e=r._getSourceRowEntry(n);if(!e){"history"!==t&&v(p,`Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`,r.id);continue}const{row:s,index:a}=e;this.#O(n,s,a,o,t).length>0&&(i=!0)}i&&(St(r),r._requestSchedulerPhase(Re.VIRTUALIZATION,"updateRows"),r._emitDataChange())}async insertRow(e,t,r=!0){const i=this.#e,n=Math.max(0,Math.min(e,i._rows.length));i.sourceRows=[...i.sourceRows,t];const o=[...i._rows];o.splice(n,0,t),i._rows=o,i._sortState&&(i.__originalOrder=[...i.__originalOrder,t]),this.#z(),i._emitPluginEvent("row-inserted",{row:t,index:n}),i._emitDataChange(),r&&(await new Promise(e=>requestAnimationFrame(()=>e())),await ur(i,n,"insert"))}async removeRow(e,t=!0){const r=this.#e,i=r._rows[e];if(!i)return;t&&await ur(r,e,"remove");const n=r._rows.indexOf(i);if(n<0)return i;const o=[...r._rows];o.splice(n,1),r._rows=o;const s=r.sourceRows.indexOf(i);if(s>=0){const e=[...r.sourceRows];e.splice(s,1),r.sourceRows=e}if(r._sortState){const e=r.__originalOrder.indexOf(i);if(e>=0){const t=[...r.__originalOrder];t.splice(e,1),r.__originalOrder=t}}return this.#z(),r._emitDataChange(),t&&this.#N(),i}async applyTransaction(e,t=!0){const r={added:[],updated:[],removed:[]};return await this.#F(e,r,t),this.#q(e,r),this.#$(e,r),this.#W(r),t&&await this.#V(r),r}async#F(e,t,r){if(!e.remove?.length)return;const i=this.#e;for(const{id:n}of e.remove){const e=i._getRowEntry(n);if(!e)continue;const{row:o}=e;if(r){const e=i._rows.indexOf(o);e>=0&&await ur(i,e,"remove")}const s=i._rows.indexOf(o);if(s<0){t.removed.push(o);continue}const a=[...i._rows];a.splice(s,1),i._rows=a;const l=i.sourceRows.indexOf(o);if(l>=0){const e=[...i.sourceRows];e.splice(l,1),i.sourceRows=e}if(i._sortState){const e=i.__originalOrder.indexOf(o);if(e>=0){const t=[...i.__originalOrder];t.splice(e,1),i.__originalOrder=t}}t.removed.push(o)}}#q(e,t){if(!e.update?.length)return;const r=this.#e,i=new Set(e.remove?.map(e=>e.id));for(const{id:n,changes:o}of e.update){if(i.has(n))continue;const e=r._getRowEntry(n);if(!e)continue;const{row:s,index:a}=e;let l=!1;for(const[t,i]of Object.entries(o)){const e=re(s,t);e!==i&&(l=!0,oe(s,t,i),ae(s),r.dispatchEvent(new CustomEvent("cell-change",{detail:{row:s,rowId:n,rowIndex:a,field:t,oldValue:e,newValue:i,changes:o,source:"api"},bubbles:!0,composed:!0})))}l&&t.updated.push(s)}}#$(e,t){if(!e.add?.length)return;const r=this.#e;for(const i of e.add)r.sourceRows=[...r.sourceRows,i],r._rows=[...r._rows,i],r._sortState&&(r.__originalOrder=[...r.__originalOrder,i]),t.added.push(i)}#W(e){const t=this.#e,r=e.added.length>0||e.removed.length>0,i=e.updated.length>0;r?this.#z():i&&(St(t),t._requestSchedulerPhase(Re.VIRTUALIZATION,"applyTransaction")),(r||i)&&t._emitDataChange()}async#V(e){const t=this.#e;if(e.added.length>0){await new Promise(e=>requestAnimationFrame(()=>e()));for(const r of e.added){const e=t._rows.indexOf(r);e>=0&&await ur(t,e,"insert")}}for(const r of e.updated){const e=t._rows.indexOf(r);e>=0&&await ur(t,e,"change")}e.removed.length>0&&this.#N()}#z(){const e=this.#e;St(e),e._rebuildRowIdMap(),e.__rowRenderEpoch++;for(let t=0;t<e._rowPool.length;t++)e._rowPool[t].__epoch=-1;e.refreshVirtualWindow(!0)}#N(){const e=this.#e;requestAnimationFrame(()=>{const t=e.querySelectorAll('[data-animating="remove"]');for(let e=0;e<t.length;e++)t[e].removeAttribute("data-animating")})}#U=null;#B=[];#G=null;applyTransactionAsync(e){return this.#U||(this.#U={add:[],update:[],remove:[]}),e.add&&this.#U.add.push(...e.add),e.update&&this.#U.update.push(...e.update),e.remove&&this.#U.remove.push(...e.remove),new Promise(e=>{this.#B.push(e),null===this.#G&&(this.#G=requestAnimationFrame(()=>{this.#G=null;const e=this.#U,t=this.#B;this.#U=null,this.#B=[],this.applyTransaction(e,!1).then(e=>{for(const r of t)r(e)})}))})}},fr="tbw-grid",pr=fr;function wr(){return pr}var mr="tbw-grid-styles",br="",vr=new Map;function yr(){const e=function(){const e=wr();return"tbw-grid"===e?mr:`${mr}-${e}`}();let t=document.getElementById(e);return t||(t=document.createElement("style"),t.id=e,t.setAttribute("data-tbw-grid","true"),document.head.appendChild(t)),t}function _r(e){const t=wr();return"tbw-grid"===t?e:e.replace(/(?<![-\w])tbw-grid(?![-\w])/g,t)}function Cr(){const e=yr(),t=Array.from(vr.values()).join("\n");e.textContent=`${br}\n\n/* Plugin Styles */\n${t}`}async function Rr(e){if(br)return;if("string"==typeof e&&e.length>0)return br=_r(e),void Cr();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){v("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(br=_r(t),Cr()):"undefined"!=typeof process&&"test"===process.env.NODE_ENV||v("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 Sr(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function Er(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function Ar(e,t){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 r=.95,i=1;let n=performance.now();const o=()=>{const s=performance.now(),a=s-n;n=s;const l=a/16,c=Math.pow(r,l);e.velocityY*=c,e.velocityX*=c;const d=16*e.velocityY,u=16*e.velocityX,h=Math.abs(d)>=i,g=Math.abs(u)>=i;h&&(t.fauxScrollbar.scrollTop+=d),g&&t.scrollArea&&(t.scrollArea.scrollLeft+=u),e.momentumRaf=h||g?requestAnimationFrame(o):0};e.momentumRaf=requestAnimationFrame(o)}(e,t),Sr(e)}function xr(e,t,r,i){e.addEventListener("pointerdown",r=>{"touch"===r.pointerType&&null===t.activePointerId&&(t.activePointerId=r.pointerId,e.setPointerCapture(r.pointerId),function(e,t,r){Er(r),r.startY=t,r.startX=e,r.lastY=t,r.lastX=e,r.lastTime=performance.now(),r.velocityY=0,r.velocityX=0,r.locked=!1}(r.clientX,r.clientY,t))},{passive:!0,signal:i}),e.addEventListener("pointermove",e=>{e.pointerId===t.activePointerId&&function(e,t,r,i){if(null===r.lastY||null===r.lastX)return!1;const n=performance.now(),o=r.lastY-t,s=r.lastX-e;if(null!==r.lastTime){const e=n-r.lastTime;e>0&&(r.velocityY=o/e,r.velocityX=s/e)}if(r.lastY=t,r.lastX=e,r.lastTime=n,r.locked){const{scrollTop:e,scrollHeight:t,clientHeight:r}=i.fauxScrollbar;if(o>0&&e<t-r||o<0&&e>0?i.fauxScrollbar.scrollTop+=o:0!==o&&window.scrollBy(0,o),i.scrollArea){const{scrollLeft:e,scrollWidth:t,clientWidth:r}=i.scrollArea;s>0&&e<t-r||s<0&&e>0?i.scrollArea.scrollLeft+=s:0!==s&&window.scrollBy(s,0)}return!0}const a=null!==r.startY?Math.abs(r.startY-t):0,l=null!==r.startX?Math.abs(r.startX-e):0;if(a<3&&l<3)return!1;const c=a>=l,{scrollHeight:d,clientHeight:u}=i.fauxScrollbar,h=d-u>0;let g=!1;if(i.scrollArea){const{scrollWidth:e,clientWidth:t}=i.scrollArea;g=e-t>0}return!!(c&&h||!c&&g)&&(r.locked=!0,i.fauxScrollbar.scrollTop+=o,i.scrollArea&&(i.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,r)&&e.preventDefault()},{passive:!1,signal:i}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Ar(t,r))},{passive:!0,signal:i}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Sr(t))},{passive:!0,signal:i}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,Sr(t))},{passive:!0,signal:i})}var Mr=[{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}],Hr=[{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 kr(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Tr(e){return`import '@toolbox-web/grid/features/${kr(e)}';`}function Pr(e){return`import { ${Dr(e)}Plugin } from '@toolbox-web/grid/plugins/${kr(e)}';`}function Lr(e){const t=e?.features;return!!t&&"object"==typeof t&&Object.keys(t).length>0}function Dr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ir(e,t){return e.some(e=>e.name===t)}var Or=class{#e;state;#j=0;#Y=0;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,scrollMapping:{rawContentHeight:0,spacerHeight:0,viewportHeight:0,capped:!1},...t}}#X(){const e=this.state,t=e.container??this.#e._hostElement,r=e.viewportEl??t,i=t?.clientHeight??0;return{fauxHeight:i,viewportHeight:r?.clientHeight??0,scrollAreaHeight:e.scrollAreaEl?e.scrollAreaEl.clientHeight:i}}updateCachedGeometry(){const e=this.state,t=e.container,r=e.viewportEl??t;r&&(e.cachedViewportHeight=r.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const i=e.scrollAreaEl;i&&(e.cachedScrollAreaHeight=i.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const r=this.state;let i,n,o;t?(({fauxHeight:i,viewportHeight:n,scrollAreaHeight:o}=this.#X()),r.cachedFauxHeight=i,r.cachedViewportHeight=n,r.cachedScrollAreaHeight=o):(i=r.cachedFauxHeight,n=r.cachedViewportHeight,o=r.cachedScrollAreaHeight||i);const s=o-n,a=Math.max(0,i-o);let l;return l=r.variableHeights&&r.positionCache?function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(r.positionCache):e*r.rowHeight,r.scrollMapping=Ge(l,n),r.scrollMapping.spacerHeight+s+a}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#e,r=t._rows,i=e.rowHeight||28,n=t.effectiveConfig?.getRowId,o=n?e=>n(e):void 0;e.positionCache=function(e,t,r,i,n){const o=new Array(e.length);let s=0;for(let a=0;a<e.length;a++){const l=e[a];let c=n?.(l,a),d=void 0!==c;void 0===c&&(c=We(t,l,i.rowId),d=void 0!==c),void 0===c&&(c=r,d=!1),o[a]={offset:s,height:c,measured:d},s+=c}return o}(r,e.heightCache,i,{rowId:o},this.#K());const s=function(e,t,r,i){let n=0,o=0;for(let s=0;s<e.length;s++){const r=e[s];r.measured&&void 0===i?.(t[s],s)&&(o+=r.height,n++)}return{measuredCount:n,averageHeight:n>0?o/n:r}}(e.positionCache,r,i,(e,r)=>t._getPluginRowHeight(e,r));e.measuredCount=s.measuredCount,s.measuredCount>0&&(e.averageHeight=s.averageHeight)}#K(){const e=this.#e,t=e.effectiveConfig?.rowHeight,r="function"==typeof t?t:void 0,i="number"==typeof t&&t>0?t:void 0;return(t,n)=>{const o=e._getPluginRowHeight(t,n);if(void 0!==o)return o;if(r&&!0!==t?.__loading){const e=r(t,n);if(void 0!==e&&e>0)return e}return i}}invalidateRowHeight(e,t){const r=this.state;if(!r.variableHeights)return;if(!r.positionCache)return;const i=this.#e._rows;if(e<0||e>=i.length)return;const n=i[e];let o=t;void 0===o&&(o=this.#e._getPluginRowHeight(n,e)),void 0===o&&(o=r.rowHeight);const s=r.positionCache[e];if(s&&!(Math.abs(s.height-o)<1)&&(function(e,t,r){if(t<0||t>=e.length)return;const i=e[t],n=r-i.height;if(i.measured=!0,0!==n){i.height=r;for(let r=t+1;r<e.length;r++)e[r].offset+=n}}(r.positionCache,e,o),r.totalHeightEl)){const e=this.calculateTotalSpacerHeight(i.length);r.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const r=this.state;if(!r.variableHeights)return;if(!r.positionCache)return;const i=this.#e,n=i._bodyEl;if(!n)return;const o=n.querySelectorAll(":scope > .data-grid-row"),s=i.effectiveConfig?.getRowId,a=i._rows,l=Ue({positionCache:r.positionCache,heightCache:r.heightCache,rows:a,defaultHeight:r.rowHeight,start:e,end:t,headerRowCount:i.__cachedHeaderRowCount??1,getPluginHeight:this.#K(),getRowId:s?e=>s(e):void 0},o);if(l.hasChanges&&(r.measuredCount=l.measuredCount,r.averageHeight=l.averageHeight,r.totalHeightEl)){const e=this.calculateTotalSpacerHeight(a.length);r.totalHeightEl.style.height=`${e}px`}}#Z(e,t){const r=this.#e;return r._renderVisibleRows(0,e),t||r._afterPluginRender(),!0}#Q(e,t,r,i){const n=this.state,o=this.#e,s=r||0!==n.start||n.end!==t;if(n.start=0,n.end=t,o._renderVisibleRows(0,t,o.__rowRenderEpoch),r){n.variableHeights&&this.initializePositionCache();let r=n.container?.scrollTop??0;if(n.totalHeightEl){const e=this.calculateTotalSpacerHeight(t,!0);n.totalHeightEl.style.height=`${e}px`;const i=e-n.cachedFauxHeight;r>i&&(r=i>0?i:0)}e.style.transform=`translateY(${-r}px)`}return o._updateAriaCounts(t,o._visibleColumns.length),i||o._afterPluginRender(),s}#J(e,t){const r=this.state,i=r.positionCache;let n;r.variableHeights&&i&&i.length>0?(n=Ve(i,e),-1===n&&(n=0)):n=Math.floor(e/r.rowHeight),n-=n%2,n<0&&(n=0),t>0&&n>t-1&&(n=t-1);const o=this.#e._adjustPluginVirtualStart(n,e,r.rowHeight);return void 0!==o&&o<n&&(n=o-o%2,n<0&&(n=0)),n}#ee(e,t,r){const i=this.state,n=i.rowHeight,o=i.positionCache;let s;if(i.variableHeights&&o&&o.length>0){const i=t+3*n;let a=0;for(s=e;s<r&&a<i;)a+=o[s].height,s++;const l=Math.ceil(t/n)+3;s-e<l&&(s=Math.min(e+l,r))}else s=e+Math.ceil(t/n)+3;return s>r?r:s}#te(e){const t=this.state;queueMicrotask(()=>{if(!t.totalHeightEl)return;const r=this.calculateTotalSpacerHeight(e);0===t.cachedFauxHeight&&t.cachedViewportHeight>0||(t.totalHeightEl.style.height=`${r}px`)})}#re(){const e=this.state;this.#j||(this.#j=requestAnimationFrame(()=>{this.#j=0;const t=this.#e;if(!t._schedulerIsConnected||!e.totalHeightEl)return void(this.#Y=0);const{fauxHeight:r,viewportHeight:i,scrollAreaHeight:n}=this.#X();i!==e.cachedViewportHeight||n!==e.cachedScrollAreaHeight||r!==e.cachedFauxHeight?this.#Y>=3?this.#Y=0:(this.#Y++,t._requestSchedulerPhase(Re.VIRTUALIZATION,"geometry-drift")):this.#Y=0}))}refreshVirtualWindow(e=!1,t=!1){const r=this.state,i=this.#e,n=i._bodyEl;if(!n)return!1;const o=i._rows.length;if(!r.enabled)return this.#Z(o,t);if(e&&this.#re(),o<=r.bypassThreshold)return this.#Q(n,o,e,t);const s=r.container,a=r.viewportEl??s,l=e?r.cachedViewportHeight=a.clientHeight:r.cachedViewportHeight||(r.cachedViewportHeight=a.clientHeight),c=je(s.scrollTop,r.scrollMapping);e&&r.variableHeights&&this.initializePositionCache();const d=this.#J(c,o),u=this.#ee(d,l,o);if(!e&&d===r.start&&u===r.end)return!1;r.start=d,r.end=u;const h=e?r.cachedFauxHeight=s.clientHeight:r.cachedFauxHeight||(r.cachedFauxHeight=s.clientHeight);if(e&&r.scrollAreaEl&&(r.cachedScrollAreaHeight=r.scrollAreaEl.clientHeight),0===h&&l>0)return i._requestSchedulerPhase(Re.VIRTUALIZATION,"stale-refs-retry"),!1;e&&r.totalHeightEl&&(r.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(o)}px`);const g=r.positionCache,f=r.variableHeights&&g&&g[d]?g[d].offset:d*r.rowHeight;return n.style.transform=`translateY(${-(c-f)}px)`,i._renderVisibleRows(d,u,i.__rowRenderEpoch),e&&r.variableHeights&&this.measureRenderedRowHeights(d,u),i._updateAriaCounts(o,i._visibleColumns.length),e&&!t&&(i._afterPluginRender(),this.#te(o)),!0}#ie=!1;#ne=null;#oe=0;#se;#ae=!1;#le(){return this.#e._pluginManager?.hasRowHeightPlugin?.()??!1}configureVariableHeights(){const e=this.state,t=this.#e.effectiveConfig?.rowHeight,r=this.#le(),i="number"==typeof t&&t>0?t:null;"function"==typeof t||r?e.variableHeights&&i===this.#ne||(e.variableHeights=!0,e.rowHeight=i??(e.rowHeight||28),this.initializePositionCache(),this.#ie="function"!=typeof t&&null===i):!r&&"function"!=typeof t&&e.variableHeights?(e.variableHeights=!1,e.positionCache=null,this.#ie=!1):null!==i?(e.rowHeight=i,e.variableHeights=!1):requestAnimationFrame(()=>this.#ce()),this.#ne=i}#ce(){const e=this.#e,t=this.state;if(this.#le())return;const r=e.effectiveConfig?.rowHeight;if("number"==typeof r&&r>0)return;const i=e._bodyEl;if(!i?.querySelector(".data-grid-row"))return;const n=this.#de(),o=[];for(const g of i.querySelectorAll(".data-grid-row")){if(g.style.getPropertyValue("--tbw-row-height"))continue;let e=0;g.querySelectorAll(".cell").forEach(t=>{const r=t.offsetHeight;r>e&&(e=r)});const t=Math.max(g.getBoundingClientRect().height,e);t>0&&o.push(t)}if(0===o.length)return;o.sort((e,t)=>e-t);const s=o.length>>1,a=o.length%2==1?o[s]:(o[s-1]+o[s])/2,l=t.rowHeight,c=this.#oe,d=n>0&&c>0&&Math.abs(n-c)>1,u=n>0&&0===c,h=a>0&&a-l>1;if(n>0&&(this.#oe=n),d||u||h){const r=d||u?Math.max(n,a):a;Math.abs(r-l)>1&&(t.rowHeight=r,e._requestSchedulerPhase(Re.VIRTUALIZATION,"measureRowHeight"))}}#de(){const e=this.#e._hostElement;if(!e)return 0;const t=getComputedStyle(e).getPropertyValue("--tbw-row-height").trim();if(!t)return 0;if(t.endsWith("px"))return parseFloat(t)||0;const r=this.#e._bodyEl?.querySelector('.data-grid-row:not([style*="--tbw-row-height"]) > .cell');if(!r)return 0;const i=parseFloat(getComputedStyle(r).minHeight);return i>0?i:0}afterRenderRowHeights(){this.state.enabled&&this.#ue(),this.#ie&&this.#e._bodyEl?.querySelector(".data-grid-row")&&(this.#ie=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#he()||(this.#ie=!0)})}))}#he(){if(null!==this.#ne)return!0;const e=this.#e._bodyEl?.querySelector(".data-grid-row");if(!e)return!1;let t=0;e.querySelectorAll(".cell").forEach(e=>{const r=e.offsetHeight;r>t&&(t=r)});const r=Math.max(e.getBoundingClientRect().height,t);if(r<=0)return!1;const i=this.state;return Math.abs(r-i.rowHeight)>1&&(i.rowHeight=r),this.initializePositionCache(),i.totalHeightEl&&(i.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(this.#e._rows.length)}px`),!0}#ue(){if(this.#ae)return;const e=this.#e._bodyEl?.querySelector(".data-grid-row");e&&(this.#ae=!0,this.#se?.disconnect(),this.#se=new ResizeObserver(()=>this.#ce()),this.#se.observe(e))}disposeRowHeightObserver(){this.#se&&(this.#se.disconnect(),this.#se=void 0,this.#ae=!1,this.#oe=0)}};var zr=class{grid;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;#ge=new Map;eventListeners=new Map;queryHandlers=new Map;constructor(e){this.grid=e}attachAll(e,t=e=>e){const r=this.#fe(function(e,t){const r=new Set(e.map(e=>e.name)),i=[],n=e=>{for(const i of e.constructor.dependencies??[])!i.provide||r.has(i.name)||i.when&&!i.when(e.resolvedConfig)||(r.add(i.name),n(t(i.provide())));i.push(e)};for(const o of e)n(o);return i}(e,t));for(const i of r)this.attach(i)}#fe(e){if(e.length<2)return e;const t=new Map,r=new Map,i=[];for(const n of e){const e=n.constructor,o=t.get(e);if(!o){t.set(e,n),i.push(n);continue}const s=r.get(o)??[];s.push(n),r.set(o,s)}if(0===r.size)return i;for(const[n,o]of r)n.mergeConfigsFrom(o);return i}attach(e){if(function(e,t,r,i){const n=e.name,o=e.constructor.dependencies??[];for(const s of o){if(s.when&&!s.when(e.resolvedConfig))continue;const o=s.name,a=s.required??!0,l=s.reason;if(t.some(e=>e.name===o))continue;const c=s.severity??(a?"error":void 0);if(!c)continue;const d="error"===c?"requires":"recommends",u=l??`${Dr(n)}Plugin ${d} ${Dr(o)}Plugin`;"error"===c?Lr(i)?b(g,`Plugin dependency error:\n\n${u}.\n\n → Enable the required feature in gridConfig.features (pass \`true\` for defaults, or a config object — see the docs):\n ${Tr(o)}\n ${Tr(n)}\n features: {\n ${o}: true,\n ${n}: true,\n }`,r):b(g,`Plugin dependency error:\n\n${u}.\n\n → Add the required plugin to gridConfig.plugins BEFORE ${Dr(n)}Plugin:\n ${Pr(o)}\n plugins: [new ${Dr(o)}Plugin(), new ${Dr(n)}Plugin()]\n → Tip: the feature-based API is recommended and orders dependencies for you — features: { ${o}: true, ${n}: true }`,r):Ie()&&("warn"===c?v(f,`${u}.`,r):y(f,`${u}.`,r))}}(e,this.plugins,this.grid.getAttribute("id")??void 0,this.grid.effectiveConfig??this.grid.gridConfig),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,r]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,r);if(e.headerRenderers)for(const[t,r]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,r);if(e.cellEditors)for(const[t,r]of Object.entries(e.cellEditors))this.cellEditors.set(t,r);this.registerQueryHandlers(e),e.attach(this.grid),this.#pe();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 r of t.queries){let t=this.queryHandlers.get(r.type);t||(t=new Set,this.queryHandlers.set(r.type,t)),t.add(e)}}unregisterQueryHandlers(e){for(const[t,r]of this.queryHandlers)r.delete(e),0===r.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(),t.__releaseDisconnectSignal()}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.#ge.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 r of this.#we("processRows")){const e=r.processRows(t);e!==t&&(t=e)}return t}orderColumns(e){let t=e;for(const r of this.plugins)r.orderColumns&&(t=r.orderColumns(t));return t}processColumns(e){let t=[...e];for(const r of this.#we("processColumns"))t=r.processColumns(t);return t}processConfig(e){for(const t of this.#we("processConfig"))t.processConfig(e)}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterStructuralRender(){for(const e of this.#we("afterStructuralRender"))e.afterStructuralRender()}beforeStructuralRender(){for(const e of this.plugins)e.beforeStructuralRender?.()}parseLightDom(){for(const e of this.plugins)e.parseLightDom?.()}syncLightDom(){for(const e of this.plugins)e.syncLightDom?.()}needsStructuralRerender(){let e=!1;for(const t of this.plugins)t.needsStructuralRerender?.()&&(e=!0);return e}afterRender(){for(const e of this.#we("afterRender"))e.afterRender()}afterCellRender(e){for(const t of this.#we("afterCellRender"))t.afterCellRender(e)}hasAfterCellRenderHook(){return this._hasAfterCellRender}afterRowRender(e){for(const t of this.#we("afterRowRender"))t.afterRowRender(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#pe(){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.#ge.clear()}#we(e){let t=this.#ge.get(e);if(t)return t;t=this.plugins.filter(t=>e in t&&"function"==typeof t[e]);const r=t=>{const r=t.constructor.manifest?.hookPriority;return r?r[e]??0:0};return t.some(e=>0!==r(e))&&t.sort((e,t)=>r(e)-r(t)),this.#ge.set(e,t),t}onScrollRender(){for(const e of this.#we("onScrollRender"))e.onScrollRender()}getRowHeight(e,t){for(const r of this.plugins)if("function"==typeof r.getRowHeight){const i=r.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,r){let i=e;for(const n of this.plugins)if("function"==typeof n.adjustVirtualStart){const o=n.adjustVirtualStart(e,t,r);o<i&&(i=o)}return i}renderRow(e,t,r){for(const i of this.#we("renderRow"))if(i.renderRow?.(e,t,r))return!0;return!1}queryPlugins(e){const t=[],r=this.queryHandlers.get(e.type);if(r&&r.size>0){for(const i of r){const r=i.handleQuery?.(e);void 0!==r&&t.push(r)}return t}for(const i of this.plugins){const r=i.handleQuery?.(e);void 0!==r&&t.push(r)}return t}subscribe(e,t,r){let i=this.eventListeners.get(t);i||(i=new Map,this.eventListeners.set(t,i)),i.set(e,r)}unsubscribe(e,t){const r=this.eventListeners.get(t);r&&(r.delete(e),0===r.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,r]of this.eventListeners)r.delete(e),0===r.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const r=this.eventListeners.get(e);if(r)for(const n of r.values())try{n(t)}catch(i){_("TBW024",`Error in plugin event handler for "${e}": ${i}`,this.grid.getAttribute("id")??void 0)}}onKeyDown(e){for(const t of this.#we("onKeyDown"))if(t.onKeyDown(e))return!0;return!1}onCellClick(e){for(const t of this.#we("onCellClick"))if(t.onCellClick(e))return!0;return!1}onRowClick(e){for(const t of this.#we("onRowClick"))if(t.onRowClick(e))return!0;return!1}onHeaderClick(e){for(const t of this.#we("onHeaderClick"))if(t.onHeaderClick(e))return!0;return!1}onScroll(e){for(const t of this.#we("onScroll"))t.onScroll(e)}onCellMouseDown(e){for(const t of this.#we("onCellMouseDown"))if(t.onCellMouseDown(e))return!0;return!1}onCellMouseMove(e){for(const t of this.#we("onCellMouseMove"))if(t.onCellMouseMove(e))return!0;return!1}onCellMouseUp(e){for(const t of this.#we("onCellMouseUp"))if(t.onCellMouseUp(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let r=0,i=0,n=!1;for(const o of this.plugins){const s=o.getHorizontalScrollOffsets?.(e,t);s&&(r+=s.left,i+=s.right,s.skipScroll&&(n=!0))}return{left:r,right:i,skipScroll:n}}getVerticalScrollOffsets(e){let t=0,r=0,i=!1;for(const n of this.plugins){const o=n.getVerticalScrollOffsets?.(e);o&&(t+=o.top,r+=o.bottom,o.skipScroll&&(i=!0))}return{top:t,bottom:r,skipScroll:i}}getToolPanels(){const e=[];for(const t of this.plugins){const r=t.getToolPanel?.();r&&e.push({plugin:t,panel:r})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const r=t.getHeaderContent?.();r&&e.push({plugin:t,content:r})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}},Nr=class e extends HTMLElement{static tagName=fr;static version="3.10.3";static get activeTag(){return wr()}static set activeTag(e){!function(e){pr=e}(e)}static#me=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","column-inference","loading"]}get#be(){return this}#ve=!1;#i;#n;#ye=[];get#b(){return this.#_e?.effective??{}}#Ce=!1;#Re=!1;#Se={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,columnInference:!1};#Ee;#Ae=0;#xe=null;#Me=0;#He=!1;#ke=0;#Te;#Pe={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#Le;#De;#Ie;#Oe={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#ze;#Ne;#Fe;#qe;#$e;#We;get _pluginManager(){return this.#ze}#Ve=!1;#Ue;#Be;#R;#_e;#Ge=new Map;#je=!1;#Ye=new Set;#Xe=new Map;#Ke;#Ze={};#Qe=new Map;#Je=!1;#et=[];get _rows(){return this.#et}set _rows(e){this.#et=e,this.#Je=!0}#tt=[];get _columns(){return this.#b.columns??[]}set _columns(e){this.#b.columns=e,this.#rt=void 0}#rt;get _visibleColumns(){return this.#rt??=this._columns.filter(e=>!e.hidden)}_invalidateVisibleColumnsCache(){this.#rt=void 0}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#qe.state}set _virtualization(e){Object.assign(this.#qe.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#_e?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#_e&&(this.#_e.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#_e?.originalColumnNodes}set __originalColumnNodes(e){this.#_e&&(this.#_e.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=Array.isArray(e)?e:[],r=this.#ye;this.#ye=t,r!==t&&this.#it("rows")}get sourceRows(){return this.#ye}set sourceRows(e){this.#ye=Array.isArray(e)?e:[]}get columns(){return[...this._columns]}set columns(e){const t=Array.isArray(e)?d(e):e,r=this.#_e?.getColumns();this.#_e?.setColumns(t),r!==t&&this.#it("columns")}get gridConfig(){return this.#b}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#_e?.getGridConfig();this.#_e?.setGridConfig(e),t!==e&&(this.#_e.clearLightDomCache(),this.#it("gridConfig"))}get _sourceConfig(){return this.#_e?.getGridConfig()}get fitMode(){return this.#b.fitMode??"stretch"}set fitMode(e){const t=this.#_e?.getFitMode();this.#_e?.setFitMode(e),t!==e&&this.#it("fitMode")}get columnInference(){return this.#b.columnInference??"auto"}set columnInference(e){const t=this.#_e?.getColumnInference();this.#_e?.setColumnInference(e),t!==e&&this.#it("columnInference")}get loading(){return this.#je}set loading(e){const t=this.#je;this.#je=e,t!==e&&(e?(this.setAttribute("loading",""),this.setAttribute("aria-busy","true")):(this.removeAttribute("loading"),this.removeAttribute("aria-busy")),this.#nt(),this.#ot())}setRowLoading(e,t){const r=this.#Ye.has(e);t?this.#Ye.add(e):this.#Ye.delete(e),r!==t&&this.#st(e,t)}setCellLoading(e,t,r){let i=this.#Xe.get(e);const n=i?.has(t)??!1;r?(i||(i=new Set,this.#Xe.set(e,i)),i.add(t)):(i?.delete(t),0===i?.size&&this.#Xe.delete(e)),n!==r&&this.#at(e,t,r)}isRowLoading(e){return this.#Ye.has(e)}isCellLoading(e,t){return this.#Xe.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#Ye)this.#st(e,!1);this.#Ye.clear();for(const[e,t]of this.#Xe)for(const r of t)this.#at(e,r,!1);this.#Xe.clear()}get effectiveConfig(){return this.#b}get disconnectSignal(){return this.#Le||(this.#Le=new AbortController),this.#Le.signal}constructor(){super(),this.#lt(),this.#i=new Promise(e=>this.#n=e),this.#qe=new Or(this),this.#$e=new er(this),this.#We=new gr(this),this.#Ee=new Se(this),this.#Ee.setInitialReadyResolver(()=>this.#n?.()),this.#_e=new xe(this)}async#lt(){await Rr('@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(#eee,#222);--tbw-color-fg:light-dark(#222,#eee);--tbw-color-fg-muted:light-dark(#555,#aaa);--tbw-color-accent:#3b82f6;--tbw-color-accent-fg:light-dark(#fff,#000);--tbw-color-accent-text:light-dark(#1d4ed8,#93c5fd);--tbw-color-success:light-dark(#357937,#4cae4f);--tbw-color-warning:#f59f0a;--tbw-color-error:light-dark(#d33131,#e06c6c);--tbw-color-danger:var(--tbw-color-error);--tbw-color-selection:light-dark(#fff7d6,#333);--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(#777,#666);--tbw-color-border-cell:var(--tbw-color-border);--tbw-color-border-header:var(--tbw-color-border);--tbw-color-shadow:light-dark(#0000001a,#0000004d);--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-column-selection-bg:rgba(from var(--tbw-color-accent) 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-touch-target-min:24px;--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;contain:content;width:100%;height:100%;min-height:0;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);outline:none;display:block;position:relative;overflow:clip}tbw-grid,tbw-grid *{box-sizing:border-box}tbw-grid>tbw-grid-column,tbw-grid>tbw-grid-type{display:none}tbw-grid .tbw-grid-root{flex-direction:column;height:100%;display:flex;position:relative}tbw-grid .tbw-grid-root.has-shell{flex-direction:column;height:100%;display:flex}tbw-grid .tbw-grid-root:has(.selected){-webkit-user-select:none;user-select:none}tbw-grid .tbw-grid-content{touch-action:none;flex-direction:row;flex:1;min-width:0;min-height:0;display:flex;overflow:hidden}tbw-grid .tbw-scroll-area{overflow-anchor:none;flex-direction:column;flex:1;min-width:0;min-height:0;display:flex;overflow:auto hidden}tbw-grid .rows-body-wrapper{flex-direction:row;flex:1;width:100%;min-width:fit-content;min-height:0;display:flex}tbw-grid .rows-body{flex-direction:column;flex:1;min-width:0;min-height:0;display:flex;overflow:visible}tbw-grid .rows-container{flex-direction:row;flex:1;min-height:0;display:flex;position:relative;overflow:visible}tbw-grid .rows-viewport{touch-action:none;flex:1;min-width:0;display:block;position:relative;overflow:clip}tbw-grid .rows-viewport .rows{will-change:transform;min-width:100%;z-index:var(--tbw-z-layer-rows,1);position:absolute;top:0;left:0}tbw-grid .faux-vscroll{width:auto;z-index:var(--tbw-z-layer-header,30);touch-action:none;flex-shrink:0;position:sticky;inset-inline-end:0;overflow:hidden auto}tbw-grid .faux-vscroll-spacer{width:1px}tbw-grid .tbw-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}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{z-index:25;position:sticky}tbw-grid .sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}tbw-grid .sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}.tbw-size-popover{padding:var(--tbw-spacing-xs,.25rem);align-items:center;gap:var(--tbw-spacing-xs,.25rem);background:var(--tbw-color-panel-bg,light-dark(#fff,#232528));color:var(--tbw-color-fg,light-dark(#1a1a1a,#f0f0f0));border:1px solid var(--tbw-color-border,light-dark(#d0d0d4,#454545));border-radius:var(--tbw-border-radius,.25rem);box-shadow:0 4px 12px var(--tbw-color-shadow,#0000004d);font-family:var(--tbw-font-family,system-ui, sans-serif);font-size:var(--tbw-font-size-sm,.9285em);z-index:10001;--tbw-size-popover-radius:min(var(--tbw-border-radius,.25rem), 6px);margin:0;line-height:1;display:flex;position:fixed;inset:auto}.tbw-size-popover[hidden]{display:none}.tbw-size-popover button,.tbw-size-popover input{min-height:var(--tbw-touch-target-min,26px);border-radius:var(--tbw-size-popover-radius);color:inherit;font:inherit;line-height:1}:is(.tbw-size-popover button,.tbw-size-popover input):focus-visible{outline:var(--tbw-focus-outline,2px solid var(--tbw-color-accent,#4a90d9));outline-offset:var(--tbw-focus-outline-offset,1px)}.tbw-size-popover button{min-width:var(--tbw-touch-target-min,26px);padding:0 var(--tbw-spacing-sm,.5rem);cursor:pointer;background:0 0;border:1px solid #0000;justify-content:center;align-items:center;display:inline-flex}.tbw-size-popover button:hover{background:var(--tbw-color-row-hover,light-dark(#f0f0f0,#2a2a2a));border-color:var(--tbw-color-border-strong,light-dark(#777,#666))}.tbw-size-popover button:active{background:var(--tbw-color-accent,#4a90d9);color:var(--tbw-color-accent-fg,#fff)}.tbw-size-popover input{width:5ch;padding:0 var(--tbw-spacing-xs,.25rem);background:var(--tbw-color-bg,light-dark(#fff,#1a1c20));text-align:center;border:1px solid var(--tbw-color-border,light-dark(#d0d0d4,#454545));appearance:textfield}.tbw-size-popover input::-webkit-outer-spin-button{appearance:none;margin:0}.tbw-size-popover input::-webkit-inner-spin-button{appearance:none;margin:0}}\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{vertical-align:middle;display:inline-block;-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}tbw-grid [data-icon=expand]:empty:before{-webkit-mask-image:var(--tbw-icon-expand-mask);-webkit-mask-image:var(--tbw-icon-expand-mask);-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);-webkit-mask-image:var(--tbw-icon-collapse-mask);-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);-webkit-mask-image:var(--tbw-icon-sort-asc-mask);-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);-webkit-mask-image:var(--tbw-icon-sort-desc-mask);-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);-webkit-mask-image:var(--tbw-icon-sort-none-mask);-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);-webkit-mask-image:var(--tbw-icon-submenu-arrow-mask);-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);-webkit-mask-image:var(--tbw-icon-drag-handle-mask);-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);-webkit-mask-image:var(--tbw-icon-tool-panel-mask);-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);-webkit-mask-image:var(--tbw-icon-print-mask);-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);-webkit-mask-image:var(--tbw-icon-filter-mask);-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);-webkit-mask-image:var(--tbw-icon-filter-active-mask);-webkit-mask-image:var(--tbw-icon-filter-active-mask);mask-image:var(--tbw-icon-filter-active-mask)}.tbw-context-menu [data-icon]:empty:before{vertical-align:middle;width:1em;height:1em;display:inline-block}.tbw-context-menu [data-icon=submenu-arrow]:empty:before{content:var(--tbw-icon-submenu-arrow,"▶")}}\n@layer tbw-base{tbw-grid .header{z-index:var(--tbw-z-layer-header,30);background:var(--tbw-color-header-bg);flex-shrink:0;display:block;overflow:visible}tbw-grid .header-group-row{grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header,30);display:grid}tbw-grid .header-group-cell{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:flex-start;align-items:center;justify-content:var(--tbw-align-header-group,var(--tbw-align-header,flex-start));display:flex}tbw-grid .header-group-cell:not(:last-child){border-right:2px solid var(--tbw-color-border)}tbw-grid .header-row{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);display:grid}tbw-grid .header-row>.cell{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);align-items:center;gap:4px;min-width:0;display:flex;overflow:visible}tbw-grid .header-row>.cell>span:first-child{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-weight:inherit;flex:1;overflow:hidden}tbw-grid .header-row>.cell>span[part~=sort-indicator]{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;flex-shrink:0}tbw-grid .header-row>.cell:hover>span[part~=sort-indicator]{visibility:visible;display:inline-flex}tbw-grid .header-row>.cell[aria-sort=ascending]>span[part~=sort-indicator],tbw-grid .header-row>.cell[aria-sort=descending]>span[part~=sort-indicator]{visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color);display:inline-flex}tbw-grid .header-row>.cell:last-child{border-right:0}tbw-grid .header-row>.cell:last-child .resize-handle{width:max(var(--tbw-resize-hit-area,18px), var(--tbw-touch-target-min,24px));right:0}tbw-grid .header-row>.cell:last-child .resize-handle:before{left:auto;right:0;transform:none}tbw-grid .header-row>.cell:last-child.resizable{padding-inline-end:max(var(--tbw-cell-padding-h,.5em), var(--tbw-touch-target-min,24px))}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{padding-inline-end:max(var(--tbw-cell-padding-h,.5em), calc(var(--tbw-touch-target-min,24px) / 2));position:relative}tbw-grid .header-row>.cell.sticky-left,tbw-grid .header-row>.cell.sticky-right,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{top:0;right:calc(max(var(--tbw-resize-hit-area,18px), var(--tbw-touch-target-min,24px)) / -2);width:max(var(--tbw-resize-hit-area,18px), var(--tbw-touch-target-min,24px));cursor:e-resize;-webkit-user-select:none;user-select:none;touch-action:none;z-index:20;background:0 0;height:100%;position:absolute}tbw-grid .resize-handle:before{content:"";width:var(--tbw-resize-handle-width);background:var(--tbw-resize-handle-color);border-radius:var(--tbw-resize-handle-border-radius);height:100%;transition:background .12s;position:absolute;top:0;left:50%;transform:translate(-50%)}tbw-grid .resize-handle:after{content:"";width:var(--tbw-resize-handle-width);background:var(--tbw-resize-indicator-color,var(--tbw-color-accent));opacity:0;pointer-events:none;z-index:1000;height:0;transition:opacity .12s,height 0s .12s;position:absolute;top:100%;left:50%;transform:translate(-50%)}:is(tbw-grid .resize-handle:hover,tbw-grid .resize-handle[data-tbw-size-open]):before{background:var(--tbw-resize-handle-color-hover)}:is(tbw-grid .resize-handle:hover,tbw-grid .resize-handle[data-tbw-size-open]):after{height:100vh;opacity:var(--tbw-resize-indicator-opacity,.6);transition:opacity .12s,height}@media (pointer:coarse){tbw-grid>.cell.sortable>span[part~=sort-indicator]{min-width:var(--tbw-touch-target-min,24px);min-height:var(--tbw-touch-target-min,24px)}}}\n@layer tbw-base{tbw-grid .data-grid-row{grid-template-columns:var(--tbw-column-template);contain:layout style;display:grid}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{padding:var(--tbw-cell-padding,2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);border-right:1px solid var(--tbw-color-border-cell);min-width:0;white-space:var(--tbw-cell-white-space,nowrap);text-overflow:ellipsis;align-content:center;display:block;overflow:hidden}tbw-grid .data-grid-row>.cell>*{text-overflow:ellipsis;white-space:inherit;min-width:0;overflow:hidden}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]{width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle;margin:0}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-loading-overlay{z-index:1000;pointer-events:all;background:light-dark(#ffffffb3,#00000080);justify-content:center;align-items:center;animation:.15s ease-out tbw-fade-in;display:flex;position:absolute;inset:0}.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:.8s linear infinite tbw-spin}.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{pointer-events:none;position:relative}.tbw-row-loading-overlay{z-index:26;pointer-events:none;background:light-dark(#ffffffb3,#00000080);align-items:center;animation:.15s ease-out tbw-fade-in;display:flex;position:absolute;inset:0}.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:.8s linear infinite tbw-spin}.cell.tbw-cell-loading{pointer-events:none;position:relative}.cell.tbw-cell-loading:before{content:"";z-index:26;background:light-dark(#ffffffb3,#00000080);animation:.15s ease-out tbw-fade-in;position:absolute;inset:0}.cell.tbw-cell-loading:after{--_spinner-size:calc(var(--tbw-row-height,28px) * .5);content:"";left:var(--tbw-spacing-sm);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));z-index:27;border-radius:50%;margin:auto 0;animation:.8s linear infinite tbw-spin;position:absolute;top:0;bottom:0}.cell.tbw-cell-loading-custom:after{display:none}.tbw-cell-loading-overlay{z-index:27;pointer-events:none;justify-content:center;align-items:center;animation:.15s ease-out tbw-fade-in;display:flex;position:absolute;inset:0}}\n@layer tbw-base{.tbw-empty-overlay{padding:var(--tbw-spacing-md,12px);text-align:center;color:var(--tbw-color-text-secondary,var(--tbw-color-text));z-index:999;pointer-events:all;background:light-dark(#fff9,#0006);justify-content:center;align-items:center;animation:.15s ease-out tbw-fade-in;display:flex;position:absolute;inset:0}.tbw-empty-message{font-family:var(--tbw-font-family,inherit);font-size:var(--tbw-font-size-md,14px);-webkit-user-select:text;user-select:text;max-width:480px;line-height:1.4}}\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!important;--tbw-animation-duration:0s!important}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:#0000}20%{background-color:var(--tbw-row-change-color)}to{background-color:#0000}}@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;max-height:var(--tbw-row-height,28px);transform:translateY(0)}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-offset:-2px;outline:2px solid highlight!important}tbw-grid .data-grid-row[aria-selected=true]{color:highlighttext!important;background:highlight!important}}@media (prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled:0!important;--tbw-animation-duration:0s!important}tbw-grid[data-animation-mode=reduced-motion] .data-grid-row[data-animating]{animation:none}}}\n')}getPlugin(e){return this.#ze?.getPlugin(e)}getPluginByName(e){return this.#ze?.getPluginByName(e)}requestRender(){this.#Ee.requestPhase(Re.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#Ee.requestPhase(Re.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#Ee.requestPhase(Re.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){M(this)}requestAfterRender(){this.#Ee.requestPhase(Re.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this.#Je=!0,this._virtualization.start=-1,this.refreshVirtualWindow(!1)&&this.#ze?.onScrollRender()}#ct(){this.#ze=new zr(this);const e=this.#b?.plugins,t=Array.isArray(e)?e:[],r=this.#b?.features;let i,n=[];if(r&&Zt&&(n=Zt(r).map(e=>this.#dt(e))),0===n.length)i=t;else if(0===t.length)i=n;else{const e=new Set(t.map(e=>e.name));i=[...n.filter(t=>!e.has(t.name)),...t]}this.#ze.attachAll(i,e=>this.#dt(e))}#dt(e){const t=this.#Ge.get(e.name);return t&&t!==e?(t.refreshUserConfigFrom(e),t):(this.#Ge.set(e.name,e),e)}#ut(){!function(e){let t=!1;for(const{name:r,styles:i}of e)vr.has(r)||(vr.set(r,_r(i)),t=!0);t&&Cr()}(this.#ze?.getPluginStyles()??[])}#ht(){const e=this.#b?.plugins,t=Array.isArray(e)?e:[],r=this.#b?.features??void 0,i=r!==this.#Fe;if((this.#Ne===t||void 0!==this.#Ne&&this.#Ne.length===t.length&&this.#Ne.every((e,r)=>e===t[r]))&&!i)return void(this.#Ne=t);this.#ze&&this.#ze.detachAll(),this.#ct(),this.#ut(),this.#Ne=t,this.#Fe=r,this.#qe.configureVariableHeights(),this.#_e.markSourcesChanged(),this.#_e.merge();const n=this.#He;if(this.#He=this.#ze?.getAll().some(e=>e.onScroll)??!1,!n&&this.#He){const e=this.#be.querySelector(".tbw-grid-content")??this.#be.querySelector(".tbw-grid-root");this.#gt(e)}}#ft(){this.#ze?.detachAll()}#pt(){const t=e.getAdapters();if(0===t.length&&!this.__frameworkAdapter)return;const r=this.__frameworkAdapter;return e=>{if(r?.createToolPanelRenderer){const t=r.createToolPanelRenderer(e);if(t)return t}for(const r of t)if(r.createToolPanelRenderer){const t=r.createToolPanelRenderer(e);if(t)return t}}}_registerLightDomHandler(e,t){this.#_e.registerLightDomHandler(e,t)}_unregisterLightDomHandler(e){this.#_e.unregisterLightDomHandler(e)}_requestConfigMerge(){this.#_e.markSourcesChanged(),this.#_e.merge()}_getToolPanelRendererFactory(){return this.#pt()}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",e.version),this.hasAttribute("data-tbw-grid")||this.setAttribute("data-tbw-grid",""),this.id||(this.id="tbw-grid-"+ ++e.#me),this._rows=Array.isArray(this.#ye)?[...this.#ye]:[],this.#Le&&(this.#Le.abort(),this.#Ve=!1),this.#Le=new AbortController,this.#Ie&&(rr(this.#Ie),this.#Ie=void 0),this.#wt(),this.#_e.parseLightDomColumns(this),this.#_e.merge(),this.#ct();const t=this.#b?.plugins;var r,i;this.#Ne=Array.isArray(t)?t:[],this.#Fe=this.#b?.features??void 0,this.#ve||(this.#mt(),this.#ut(),this.#ve=!0),this.#bt(),this.#Ie=(r=()=>{this.#vt()},i={timeout:100},tr?requestIdleCallback(r,i):window.setTimeout(()=>{const e=Date.now();r({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#Ie&&(rr(this.#Ie),this.#Ie=void 0),this.#ke&&(clearTimeout(this.#ke),this.#ke=0),this.#ft(),(this.#ze?.getPluginByName("shell"))?.disposeShellState?.(),Er(this.#Pe),this.#Le&&(this.#Le.abort(),this.#Le=void 0),this.#Ue?.abort(),this.#Ue=void 0,this.#Ve=!1,this._resizeController&&this._resizeController.dispose(),this.#De&&(this.#De.disconnect(),this.#De=void 0),this.#qe.disposeRowHeightObserver(),St(this),this.#yt.clear(),this._virtualization.heightCache?.byKey.clear(),this.#Ne=void 0,this.#Fe=void 0;for(let e=0;e<this._rowPool.length;e++)this._rowPool[e].remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#Ce=!1}attributeChangedCallback(e,t,r){if("loading"===e){const e=null!==r&&"false"!==r;return void(this.loading!==e&&(this.loading=e))}if(t!==r&&r&&"null"!==r&&"undefined"!==r)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(r);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{v("TBW130",`Invalid JSON for '${e}' attribute: ${r}`,this.id)}else"fit-mode"===e?this.fitMode=r:"column-inference"===e&&(this.columnInference=r)}#_t(){const e=this.#be.querySelector(".tbw-grid-content")??this.#be.querySelector(".tbw-grid-root");return 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"),e}#bt(){const e=this.#_t();if(this.setAttribute("data-upgraded",""),this.#Ce=!0,this._resizeController?.dispose(),this._resizeController=sr(this),this.#Ct(),this.#gt(e),this.#Ve)return;this.#Ve=!0;const t=this.disconnectSignal;Jt(this,this,this.#be,t),this.#qe.configureVariableHeights(),queueMicrotask(()=>this.#Rt()),this.#Ee.requestPhase(Re.FULL,"afterConnect")}#gt(e){this.#Ue?.abort(),this.#Ue=new AbortController;const t=this.#Ue.signal,r=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=r??this,this.#He=this.#ze?.getAll().some(e=>e.onScroll)??!1,r&&i){r.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#He)return;const e=r.scrollTop;i.style.transform=`translateY(${function(e,t,r){if(t<=e.bypassThreshold)return-r;const i=je(r,e.scrollMapping),n=e.positionCache;let o;if(e.variableHeights&&n&&n.length>0){let t=Ve(n,i);-1===t&&(t=0);const r=t-t%2;o=n[r]?.offset??r*e.rowHeight}else{const t=Math.floor(i/e.rowHeight);o=(t-t%2)*e.rowHeight}return-(i-o)}(this._virtualization,this._rows.length,e)}px)`,this.#xe=e,this.#Ae||(this.#Ae=requestAnimationFrame(()=>{this.#Ae=0,null!==this.#xe&&(this.#St(this.#xe),this.#xe=null)}))},{passive:!0,signal:t});const e=this.#be.querySelector(".tbw-scroll-area");this.#Be=e,this._virtualization.scrollAreaEl=e,e&&this.#He&&e.addEventListener("scroll",()=>{this.#Me||(this.#Me=requestAnimationFrame(()=>{this.#Me=0;const t=this.#Oe;t.scrollTop=r.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=r.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=r.clientHeight,t.clientWidth=e.clientWidth,this.#ze?.onScroll(t)}))},{passive:!0,signal:t});const n=this.#be.querySelector(".tbw-grid-content");if(n){const e={fauxScrollbar:r,scrollArea:this.#Be};!function(e,t,r){const{fauxScrollbar:i,scrollArea:n}=t;e.addEventListener("wheel",t=>{try{if(e.querySelector("select:open"))return}catch{}const r=t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY);if(r&&n){const e=t.shiftKey?t.deltaY:t.deltaX,{scrollLeft:r,scrollWidth:i,clientWidth:o}=n;(e>0&&r<i-o||e<0&&r>0)&&(t.preventDefault(),n.scrollLeft+=e)}else if(!r){const{scrollTop:e,scrollHeight:r,clientHeight:n}=i;(t.deltaY>0&&e<r-n||t.deltaY<0&&e>0)&&(t.preventDefault(),i.scrollTop+=t.deltaY)}},{passive:!1,signal:r})}(n,e,t),xr(n,this.#Pe,e,t)}}var n,o,s;this._bodyEl&&(n=this,o=this._bodyEl,s=t,o.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");if(!t)return;if(t.classList.contains(k.EDITING))return;const r=e.target;r.draggable||r.closest('[draggable="true"]')||e.preventDefault(),Xt(n,t)},{signal:s}),o.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&Gt(n,e,t),!document.activeElement?.closest(`.cell.${k.EDITING}`)){const t=e.target.closest("tbw-grid, [data-tbw-grid]");t&&t.focus({preventScroll:!0})}},{signal:s}),o.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&Gt(n,e,t)},{signal:s})),this.#De?.disconnect(),this._virtualization.viewportEl&&(this.#De=new ResizeObserver(()=>{this.#Et(),this.#Ee.requestPhase(Re.VIRTUALIZATION,"resize-observer")}),this.#De.observe(this._virtualization.viewportEl)),function(e,t,r,i){t.addEventListener("focusin",()=>{e.dataset.hasFocus=""},{signal:i}),t.addEventListener("focusout",i=>{const n=i.relatedTarget;n&&(t.contains(n)||r.isInExternalFocusContainer(n))||delete e.dataset.hasFocus},{signal:i})}(this,this.#be,this.#$e,t)}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}on(e,t){const r=e=>{t(e.detail,e)};return this.addEventListener(e,r),()=>this.removeEventListener(e,r)}#At(e,t){this.#Ce&&this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#At("data-change",{rowCount:this._rows.length,sourceRowCount:this.#ye.length}),function(e,t,r){if(r===t.lastAnnouncedSourceCount)return;const i=t.lastAnnouncedSourceCount;t.lastAnnouncedSourceCount=r,0===r&&i<0||n(e,o(e,"dataLoaded",r))}(this,this.#xt,this.#ye.length)}#Rt(){(this._bodyEl?.querySelectorAll(".data-grid-row"))?.forEach((e,t)=>{const r=t===this._focusRow;e.setAttribute("aria-selected",String(r)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(r&&t===this._focusCol))})})}#it(e){this.#Se[e]=!0,this.#Re||(this.#Re=!0,queueMicrotask(()=>this.#Mt()))}#Mt(){if(!this.#Re||!this.#Ce)return void(this.#Re=!1);const e=this.#Se;if(this.#Re=!1,this.#Se={rows:!1,columns:!1,gridConfig:!1,fitMode:!1,columnInference:!1},e.gridConfig)return this.#Ht(),void(e.rows&&this.#kt());(e.columns||e.columnInference)&&this.#Tt(),e.rows&&this.#kt(),e.fitMode&&this.#Pt()}#kt(){this._rows=Array.isArray(this.#ye)?[...this.#ye]:[],this.#Je=!0,this.#Ee.requestPhase(Re.ROWS,"applyRowsUpdate")}#Lt(){this.#Je&&this._rebuildRowIdMap()}_rebuildRowIdMap(){this.#Je=!1,this.#Qe.clear();const e=this.#b.getRowId;for(let t=0;t<this._rows.length;t++){const r=hr(this._rows[t],e);void 0!==r&&this.#Qe.set(r,{row:this._rows[t],index:t})}}#Tt(){St(this),this.#_e.merge(),this.#Ct()}#Pt(){if(this.#_e.merge(),"fixed"===this.#b.fitMode)this.__didInitialAutoSize=!1,E(this);else{for(let e=0;e<this._columns.length;e++){const t=this._columns[e];!t.__userResized&&t.__autoSized&&delete t.width}M(this)}}#Ht(){this.#_e.parseLightDomColumns(this),this.#_e.merge(),this.#ht(),this.#qe.configureVariableHeights(),this.#_e.markSourcesChanged(),this.#_e.merge();const e=this.#_e.initialColumnState;if(e){this.#_e.initialColumnState=void 0,this.#R=void 0;const t=this.#ze?.getAll()??[];this.#_e.applyState(e,t)}if(this.#ze?.needsStructuralRerender())return this.#ze?.beforeStructuralRender(),this.#mt(),this.#ut(),this.#bt(),void this._rebuildRowIdMap();this._rebuildRowIdMap(),this.#Ee.requestPhase(Re.COLUMNS,"applyGridConfigUpdate")}#Dt(){if(this.__rowRenderEpoch++,this.#ze){const e=this.#ze.orderColumns(this.#tt.length>0?this.#tt:this._columns),t=e.filter(e=>!e.hidden),r=e.filter(e=>e.hidden),i=this.#ze.processColumns([...t]);if(i!==t){const n=new Set(i.map(e=>e.field));!t.some(e=>n.has(e.field))&&i.length>0?this._columns=[...i,...r]:0===r.length?this._columns=i:this._columns=C(e,i)}else this._columns=[...e]}}#It(){St(this);const e=this.#ye;if(!Array.isArray(e))return this._rows=[],this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#qe.initializePositionCache(),void this._emitDataChange();if(!this._sortState&&this.#b.initialSort){const{field:e,direction:t}=this.#b.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,r=!1){if(!e._sortState)return t;const i=e.effectiveConfig?.sortHandler??le;if(i===le)return r||(e.__originalOrder=t.slice()),de(t,e._sortState.field,e._sortState.direction,e._columns),t;r||(e.__originalOrder=t);const n=i(t,e._sortState,e._columns);return n&&"function"==typeof n.then?t:n}(this,this._sortState?[...e]:e,!0),r=this.#ze?.processRows(t)??t;this._rows=r,this.#Je=!0,this._emitDataChange()}_renderVisibleRows(e,t,r=this.__rowRenderEpoch){if(this.#Te||(this.#Te=(e,t,r)=>this.#ze?.renderRow(e,t,r)??!1),function(e,t,r,i,n){const o=Math.max(0,r-t),s=e._bodyEl,a=e._visibleColumns,l=a.length,c=function(e){let t=e.__cachedHeaderRowCount;return void 0===t&&(t=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=t),t}(e);Mt(e,t,o,s);const d=n&&!1!==e.__hasRenderRowPlugins,u=e._hasAfterRowRenderHook?.()??!1,h=!!e.effectiveConfig?.rowClass,g=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let f=0;f<o;f++){const r=t+f,o=e._rows[r],p=e._rowPool[f],w=r+c+1;p.__ariaRowIndex!==w&&(p.__ariaRowIndex=w,p.setAttribute("aria-rowindex",String(w)));const m=p.__rowDataRef!==o;if(m&&p.__hasCellLoading&&Ht(e,p,p.children),d){const t=p.__hasCellLoading?Array.from(p.children):void 0;m&&p.hasAttribute("aria-busy")&&ft(p,!1,void 0,e.__frameworkAdapter);const a=p.hasAttribute("aria-busy")?p.querySelector(":scope > .tbw-row-loading-overlay"):null;if(n(o,p,r)){t&&Ht(e,p,t),a&&a.parentNode!==p&&e.__frameworkAdapter?.unmount?.(a),p.__epoch=i,p.__rowDataRef=o,h&&!Dt(o)&&Lt(e,p,o),p.parentNode!==s&&s.appendChild(p);continue}}let b=p.children.length;b>l&&p.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&b--;let v=p.__epoch===i&&b===l&&!p.__isCustomRow;if(v&&m&&kt(p,a,l)&&(v=!1),Tt(e,p,o,r,i,v,m),Pt(e,p,o),Lt(e,p,o),g){const e=!0===o?.__loading?void 0:g(o,r);void 0!==e&&e>0?p.style.setProperty("--tbw-row-height",`${e}px`):p.style.removeProperty("--tbw-row-height")}u&&e._afterRowRender?.({row:o,rowIndex:r,rowElement:p}),p.parentNode!==s&&s.appendChild(p)}}(this,e,t,r,this.#Te),this.#Ye.size>0)for(const i of this.#Ye)this.#st(i,!0);if(this.#Xe.size>0)for(const[i,n]of this.#Xe)for(const e of n)this.#at(i,e,!0)}#xt={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaLabelledBy:void 0,ariaDescribedBy:void 0,ariaRoleDescription:void 0,lastAnnouncedSourceCount:-1};_updateAriaCounts(e,t){!function(e,t,r,i,n){if(i===e.rowCount&&n===e.colCount)return!1;const o=e.rowCount;e.rowCount=i,e.colCount=n,t&&(t.setAttribute("aria-rowcount",String(i)),t.setAttribute("aria-colcount",String(n))),i!==o&&r&&(i>0?r.setAttribute("role","rowgroup"):r.removeAttribute("role"))}(this.#xt,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#Ee.requestPhase(e,t)}_getPluginRowHeight(e,t){return this.#ze?.getRowHeight?.(e,t)}_adjustPluginVirtualStart(e,t,r){return this.#ze?.adjustVirtualStart(e,t,r)}_afterPluginRender(){this.#ze?.afterRender()}_emitPluginEvent(e,t){this.#ze?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#_e.parseLightDomColumns(this),this.#_e.merge(),this.#ht(),function(e,t,r){const i=Mr,n=Hr,o=new Map;function s(e,t,r,i=!1){o.has(e)||o.set(e,{description:t,fields:[],isConfigProperty:i});const n=o.get(e);n.fields.includes(r)||n.fields.push(r)}const a=e.features;function l(e){return!!a&&!1===a[e]}for(const d of n){const r=e[d.property];if((d.isUsed?d.isUsed(r):void 0!==r)&&!Ir(t,d.pluginName)&&!l(d.pluginName)){const e=d.description||`the "${d.property}" ${d.level} property`;s(d.pluginName,e,d.property,!0)}}const c=e.columns;if(c&&c.length>0)for(const d of c)for(const e of i){const r=d[e.property];if((e.isUsed?e.isUsed(r):void 0!==r)&&!Ir(t,e.pluginName)&&!l(e.pluginName)){const t=d.field||"<unknown>",r=e.description||`the "${e.property}" ${e.level} property`;s(e.pluginName,r,t)}}if(o.size>0){const t=Lr(e),i=[];for(const[e,{description:r,fields:n,isConfigProperty:s}]of o){const o=n.slice(0,3).join(", ")+(n.length>3?`, ... (${n.length} total)`:""),a=s?`Config uses ${r}`:`Column(s) [${o}] use ${r}`;t?i.push(`${a}, but the required feature is not enabled.\n → Enable it in gridConfig.features (pass \`true\` for defaults, or a config object — see the docs):\n ${Tr(e)}\n features: { ${e}: true }`):i.push(`${a}, but the required plugin is not loaded.\n → Add it to gridConfig.plugins:\n ${Pr(e)}\n plugins: [new ${Dr(e)}Plugin(), ...]\n → Tip: the feature-based API is recommended — ${Tr(e)} then features: { ${e}: true }`)}b([...o.values()].some(e=>e.isConfigProperty)?"TBW002":"TBW001",`Configuration error:\n\n${i.join("\n\n")}\n\nThis validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`,r)}}(this.#b,this.#ze?.getPlugins()??[],this.id),function(e,t){const r=[],i=[];for(const n of e){const e=n.constructor.manifest;if(e?.configRules)for(const t of e.configRules){const e=n.config;if(t.check(e)){const e=`[${Dr(n.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?r.push(e):i.push(e)}}}if(i.length>0&&Ie())for(const n of i)v("TBW004",n,t);r.length>0&&b("TBW003",`Configuration error:\n\n${r.join("\n\n")}`,t)}(this.#ze?.getPlugins()??[],this.id),function(e,t){if(!Ie())return;const r=new Set(e.map(e=>e.name)),i=new Set;for(const n of e){const e=n.constructor.manifest;if(e?.incompatibleWith)for(const o of e.incompatibleWith)if(r.has(o.name)){const e=[n.name,o.name].sort().join("↔");if(i.has(e))continue;i.add(e),v("TBW022",`${Dr(n.name)}Plugin and ${Dr(o.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${o.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`,t)}}}(this.#ze?.getPlugins()??[],this.id),this.#Ot(),this.#tt=[...this._columns]}_schedulerProcessColumns(){this.#Dt()}_schedulerProcessRows(){this.#It()}_schedulerRenderHeader(){_e(this)}_schedulerUpdateTemplate(){M(this)}_schedulerAfterRender(){this.#ze?.afterRender(),this.#ot(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#qe.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}),"fixed"!==this.#b.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,E(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,it(this)),this.#qe.afterRenderRowHeights(),this.#je&&this.#nt()}get _schedulerIsConnected(){return this.isConnected&&this.#Ce}get _hostElement(){return this}get _renderRoot(){return this.#be}_emit(e,t){this.#At(e,t)}get _accordionIcons(){return{expand:this.#b?.icons?.expand??i.expand,collapse:this.#b?.icons?.collapse??i.collapse}}_pluginShellContributions(){return{toolPanels:(this.#ze?.getToolPanels()??[]).map(e=>e.panel),headerContents:(this.#ze?.getHeaderContents()??[]).map(e=>e.content)}}_clearRowPool(){const e=this.__frameworkAdapter;if(e?.releaseCell||e?.unmount){e.beginBatch?.(this);try{for(let t=0;t<this._rowPool.length;t++)wt(e,this._rowPool[t]);this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML="")}finally{e.endBatch?.(this)}}else this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML="");this.__rowRenderEpoch++}_setup(){this.#Ct()}_applyAnimationConfig(e){const t={...r,...e.animation},i=t.mode??"reduced-motion";let n=1;!1===i||"off"===i?n=0:!0!==i&&"on"!==i||(n=1),this.style.setProperty("--tbw-animation-duration",`${t.duration}ms`),this.style.setProperty("--tbw-animation-easing",t.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode="boolean"==typeof i?i?"on":"off":i}#Ot(){!function(e,t,r){if(!t)return!1;let i=!1;const n=r?.gridAriaLabelledBy,o=n?void 0:function(e){const t=e?.gridAriaLabel;return t||(e?.shell?.header?.title??void 0)}(r);n!==e.ariaLabelledBy&&(e.ariaLabelledBy=n,n?t.setAttribute("aria-labelledby",n):t.removeAttribute("aria-labelledby"),i=!0),o!==e.ariaLabel&&(e.ariaLabel=o,o?t.setAttribute("aria-label",o):t.removeAttribute("aria-label"),i=!0);const s=r?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),i=!0);const a=r?.gridAriaRoleDescription;a!==e.ariaRoleDescription&&(e.ariaRoleDescription=a,a?t.setAttribute("aria-roledescription",a):t.removeAttribute("aria-roledescription"),i=!0)}(this.#xt,this.__rowsBodyEl,this.#b)}#nt(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#je?(this.#Ke||(this.#Ke=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(dt("large",e)),t}(this.#b?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#Ke)):(t=this.#Ke,t?.remove()))}#ot(){De(this.querySelector(".tbw-grid-root"),this.#je,this._rows.length,this.#ye,this.#b?.emptyRenderer,this.#b?.emptyOverlay??"rows",this.#Ze,this)}#st(e,t){this.#Lt();const r=this.#Qe.get(e);if(!r)return;const i=this.findRenderedRowElement?.(r.index);i&&ft(i,t,this.#b?.loadingRenderer,this.__frameworkAdapter)}#at(e,t,r){this.#Lt();const i=this.#Qe.get(e);if(!i)return;const n=this.findRenderedRowElement?.(i.index);if(!n)return;const o=this._visibleColumns.findIndex(e=>e.field===t);if(o<0)return;const s=n.querySelector(`:scope > .cell[data-col="${o}"]`);s&&pt(s,r,this.#b?.loadingRenderer,this.__frameworkAdapter)}#Ct(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#_e.parseLightDomColumns(this),this.#R){const e=this.#R;this.#R=void 0,this.#_e.merge();const t=this.#ze?.getAll()??[];this.#_e.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#Ee.requestPhase(Re.FULL,"setup")}}#St(e){const t=this._virtualization.container,r=this.#Be,i=r?.scrollLeft??0,n=t?.scrollHeight??0,o=r?.scrollWidth??0,s=t?.clientHeight??0,a=r?.clientWidth??0;if(this.refreshVirtualWindow(!1)&&this.#ze?.onScrollRender(),this._virtualization.variableHeights&&(this.#ke&&clearTimeout(this.#ke),this.#ke=window.setTimeout(()=>{this.#ke=0,this.#qe.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#He){const t=this.#Oe;t.scrollTop=e,t.scrollLeft=i,t.scrollHeight=n,t.scrollWidth=o,t.clientHeight=s,t.clientWidth=a,this.#ze?.onScroll(t)}this.#At("tbw-scroll",{scrollTop:e,scrollHeight:n,clientHeight:s,direction:"vertical"})}findHeaderRow(){return this.#be.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,r=e-t.start;return r>=0&&r<this._rowPool.length&&r<t.end-t.start?this._rowPool[r]:null}_dispatchCellClick(e,t,r,i){const n=this._rows[t],o=this._visibleColumns[r];if(!n||!o)return!1;const s=o.field,a=re(n,s),l=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:r,column:o,field:s,value:a,row:n,cellEl:i,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(l),l.defaultPrevented)return!0;const c={row:n,rowIndex:t,colIndex:r,column:o,field:s,value:a,cellEl:i,originalEvent:e},d=this.#ze?.onCellClick(c)??!1;return this.#At("cell-click",c),d}_dispatchRowClick(e,t,r,i){if(!r)return!1;const n={rowIndex:t,row:r,rowEl:i,originalEvent:e},o=this.#ze?.onRowClick(n)??!1;return this.#At("row-click",n),o}_dispatchHeaderClick(e,t,r){if(!t)return!1;const i={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:r,originalEvent:e};return this.#ze?.onHeaderClick(i)??!1}_dispatchKeyDown(e){return this.#ze?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#ze?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}_getVerticalScrollOffsets(e){return this.#ze?.getVerticalScrollOffsets(e)??{top:0,bottom:0}}query(e,t){return this.#ze?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#ze?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#ze?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#ze?.onCellMouseUp(e)}_afterCellRender(e){this.#ze?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#ze?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#ze?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#ze?.hasAfterRowRenderHook()??!1}async ready(){return this.#i}async forceLayout(){return 0===this.#Ee.pendingPhase&&this.#Ee.requestPhase(Re.FULL,"forceLayout"),this.#Ee.whenReady()}async getConfig(){return Object.freeze({...this.#b||{}})}getRowId(e){return function(e,t,r){const i=hr(e,r);return void 0===i&&b("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),i}(e,this.id,this.#b.getRowId)}getRow(e){return this.#We.getRow(e)}_getRowEntry(e){return this.#Lt(),this.#Qe.get(e)}_getSourceRowEntry(e){const t=this._getRowEntry(e);if(t)return t;const r=this.#b.getRowId,i=this.#ye;for(let n=0;n<i.length;n++)if(hr(i[n],r)===e)return{row:i[n],index:-1}}updateRow(e,t,r="api"){this.#We.updateRow(e,t,r)}updateRows(e,t="api"){this.#We.updateRows(e,t)}animateRow(e,t){return ur(this,e,t)}animateRows(e,t){return function(e,t,r){return Promise.all(t.map(t=>ur(e,t,r))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,r){const i=e._rows??[],n=e.getRowId;if(!n)return Promise.resolve(!1);const o=i.findIndex(e=>{if(null==e)return!1;try{return n(e)===t}catch{return!1}});return o<0?Promise.resolve(!1):ur(e,o,r)}(this,e,t)}async insertRow(e,t,r=!0){return this.#We.insertRow(e,t,r)}async removeRow(e,t=!0){return this.#We.removeRow(e,t)}async applyTransaction(e,t=!0){return this.#We.applyTransaction(e,t)}applyTransactionAsync(e){return this.#We.applyTransactionAsync(e)}focusCell(e,t){this.#$e.focusCell(e,t)}get focusedCell(){return this.#$e.focusedCell}scrollToRow(e,t){this.#$e.scrollToRow(e,t)}scrollToRowById(e,t){this.#$e.scrollToRowById(e,t)}setColumnVisible(e,t){const r=this.#_e.setColumnVisible(e,t);return r&&this.requestStateChange(),r}toggleColumnVisibility(e){const t=this.#_e.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#_e.isColumnVisible(e)}showAllColumns(){this.#_e.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#_e.getAllColumns()}setColumnOrder(e){this.#_e.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#_e.getColumnOrder()}getColumnState(){const e=this.#ze?.getAll()??[];return this.#_e.collectState(e)}get columnState(){return this.getColumnState()}applyColumnState(e){e&&(this.#ve?this.#zt(e):(this.#R=e,this.#_e.initialColumnState=e))}#zt(e){const t=this._columns,r=this._sortState,i=this.#ze?.getAll()??[];if(this.#_e.applyState(e,i),!e.columns.some(e=>void 0!==e.sort)&&this.#Nt(t,r))return this.#rt=void 0,M(this),void this.#Ee.requestPhase(Re.STYLE,"column-width");this.#Ct()}#Nt(e,t){const r=this._columns,i=this._sortState;if(t?.field!==i?.field||t?.direction!==i?.direction)return!1;if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++){const t=e[n],i=r[n];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=[],_e(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 r=this._columns.find(t=>t.field===e);r&&(t?(this._sortState||(this.__originalOrder=this._rows.slice()),pe(this,r,"desc"===t?-1:1)):fe(this,r))}requestStateChange(){const e=this.#ze?.getAll()??[];this.#_e.requestStateChange(e)}resetColumnState(){this.#R=void 0,this.__originalOrder=[];const e=this.#ze?.getAll()??[];this.#_e.resetState(e),this.#_e.merge(),this.#Ct()}get defaultRowHeight(){return this._virtualization.rowHeight}#Ft=!1;refreshShellHeader(){this.#Ft||(this.#Ft=!0,queueMicrotask(()=>{this.#Ft=!1,this.isConnected&&(this.#wt(),this.#_e.markSourcesChanged(),this.#_e.merge(),this.#ze?.beforeStructuralRender(),this.#ze?.afterStructuralRender(),this.#qt())}))}#qt(){const e=this.#_t();this._resizeController?.dispose(),this._resizeController=sr(this),this.#gt(e),this.#Ee.requestPhase(Re.COLUMNS,"shellRefresh")}#yt=new Map;registerStyles(e,t){let r=this.#yt.get(e);r||(r=new CSSStyleSheet,this.#yt.set(e,r)),r.replaceSync(t),this.#$t()}unregisterStyles(e){this.#yt.delete(e)&&this.#$t()}getRegisteredStyles(){return Array.from(this.#yt.keys())}#$t(){const e=Array.from(this.#yt.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#yt.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#$e.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#$e.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#$e.containsFocus(e)}get lastFocusedElement(){return this.#$e.lastFocusedElement}restoreLastFocus(){return this.#$e.restoreLastFocus()}#wt(){this.#ze?.parseLightDom()}#vt(){const e=()=>{this.#_e.clearLightDomCache(),this.#Ct()};this.#_e.registerLightDomHandler("tbw-grid-column",e),this.#_e.registerLightDomHandler("tbw-grid-detail",e),this.#_e.registerLightDomHandler("tbw-grid-type",e),this.#_e.observeLightDOM(this)}refreshColumns(){this.#_e.clearLightDomCache(),St(this),this.#_e.parseLightDomColumns(this),this.#ze?.syncLightDom(),this.#Ee.requestPhase(Re.COLUMNS,"refreshColumns")}#Et(){this.#qe.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#qe.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#qe.invalidateRowHeight(e,t)}#mt(){this.#wt(),this.#_e.markSourcesChanged(),this.#_e.merge(),function(e){const t=[];for(let r=e.firstChild;r;r=r.nextSibling)1===r.nodeType&&r.classList.contains(k.ROOT)||t.push(r);e.replaceChildren();for(const r of t)e.appendChild(r);e.appendChild(ke({hasShell:!1}))}(this.#be),this.#ze?.afterStructuralRender()}};!function(){const e=Nr.tagName,t=customElements.get(e);if(!t)return customElements.define(e,Nr),void(Nr.activeTag=e);if(t.version===Nr.version)return void(Nr.activeTag=e);const r=`${e}-v${Nr.version.replace(/[^a-zA-Z0-9]+/g,"-").toLowerCase()}`;customElements.get(r)||customElements.define(r,Nr),Nr.activeTag=r}(),globalThis.DataGridElement||(globalThis.DataGridElement=Nr);function Fr(e,t,r){return r?.valueAccessor?se(e,r):re(e,t)}function qr(e){return null==e||""===e||"number"==typeof e&&isNaN(e)}var $r={sum:(e,t,r)=>{let i=0;for(let n=0;n<e.length;n++){const o=Fr(e[n],t,r);if(qr(o))continue;const s=Number(o);isNaN(s)||(i+=s)}return i},avg:(e,t,r)=>{if(!e.length)return 0;let i=0,n=0;for(let o=0;o<e.length;o++){const s=Fr(e[o],t,r);if(qr(s))continue;const a=Number(s);isNaN(a)||(i+=a,n++)}return n>0?i/n:0},count:e=>e.length,min:(e,t,r)=>{if(!e.length)return 0;let i=1/0;for(let n=0;n<e.length;n++){const o=Fr(e[n],t,r);if(qr(o))continue;const s=Number(o);isNaN(s)||s<i&&(i=s)}return i===1/0?0:i},max:(e,t,r)=>{if(!e.length)return 0;let i=-1/0;for(let n=0;n<e.length;n++){const o=Fr(e[n],t,r);if(qr(o))continue;const s=Number(o);isNaN(s)||s>i&&(i=s)}return i===-1/0?0:i},first:(e,t,r)=>e[0]?Fr(e[0],t,r):void 0,last:(e,t,r)=>e.length?Fr(e[e.length-1],t,r):void 0},Wr=new Map,Vr={register(e,t){Wr.set(e,t)},unregister(e){Wr.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:Wr.get(e)??$r[e]},run(e,t,r,i){const n=this.get(e);return n?n(t,r,i):void 0},has:e=>Wr.has(e)||e in $r,list:()=>[...Object.keys($r),...Wr.keys()]},Ur={sum:e=>{let t=0;for(let r=0;r<e.length;r++)t+=e[r];return t},avg:e=>{if(!e.length)return 0;let t=0;for(let r=0;r<e.length;r++)t+=e[r];return t/e.length},count:e=>e.length,min:e=>{if(!e.length)return 0;let t=e[0];for(let r=1;r<e.length;r++)e[r]<t&&(t=e[r]);return t},max:e=>{if(!e.length)return 0;let t=e[0];for(let r=1;r<e.length;r++)e[r]>t&&(t=e[r]);return t},first:e=>e[0]??0,last:e=>e[e.length-1]??0};function Br(e){return Ur[e]??Ur.sum}e.BaseGridPlugin=class{static dependencies;static manifest;aliases;version="3.10.3";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#Wt;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}get resolvedConfig(){return this.#Wt?this.config:{...this.defaultConfig,...this.userConfig}}mergeConfigsFrom(e){if(0===e.length)return;const t={...this.userConfig},r={};for(const i of Object.keys(t))r[i]=this;for(const i of e){const e=i.userConfig;for(const[n,o]of Object.entries(e)){if(void 0===o)continue;if(!(n in t)){t[n]=o,r[n]=i;continue}if(t[n]===o)continue;const e=r[n]?.constructor.name??this.constructor.name,s=i.constructor.name,a=m("TBW025",`Cannot merge plugin configs for "${this.name}": conflicting value for "${n}" supplied by both ${e} and ${s}. Pass the option on a single instance, or remove the duplicate.`,void 0,this.name);throw new Error(a)}}Object.assign(this.userConfig,t)}refreshUserConfigFrom(e){const t=this.userConfig,r={...e.userConfig};for(const i of Object.keys(t))delete t[i];Object.assign(t,r)}attach(e){this.#Wt?.abort(),this.#Wt=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.__releaseDisconnectSignal()}__releaseDisconnectSignal(){this.#Wt?.abort(),this.#Wt=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 r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.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)}queryBoolean(e,t=null){const r=this.grid?.query?.(e,t);return Array.isArray(r)?r.some(Boolean):!!r}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.#Wt?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...i,...e}}t(e,t){return this.grid?.effectiveConfig?.locale?.[e]??t}get translate(){return(e,t)=>this.t(e,t)}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;return!t||"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}setIcon(e,t,r){e.dataset.icon=X(t),"collapse"===t?e.dataset.expanded="":"expand"===t&&delete e.dataset.expanded;const i=this.#Vt(t,r);void 0!==i?"string"==typeof i?V(e,i):i instanceof HTMLElement&&e.replaceChildren(i.cloneNode(!0)):e.innerHTML=""}#Vt(e,t){return void 0!==t?t:this.grid?.gridConfig?.icons?.[e]}updateSortIndicator(e,t){e.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove();const r=document.createElement("span");r.setAttribute("part","sort-indicator"),r.className="sort-indicator",t?(e.setAttribute("aria-sort","asc"===t?"ascending":"descending"),e.setAttribute("data-sort",t),this.setIcon(r,"asc"===t?"sortAsc":"sortDesc")):(e.setAttribute("aria-sort","none"),e.removeAttribute("data-sort"),this.setIcon(r,"sortNone"));const i=e.querySelector(".tbw-filter-btn")??e.querySelector(".resize-handle");return i?e.insertBefore(r,i):e.appendChild(r),r}warn(e,t){void 0!==t?console.warn(m(e,t,this.gridElement.id,this.name)):console.warn(`${h(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(m(e,t,this.gridElement.id,this.name))}},e.CORE_CONSUMED_ADAPTER_METHODS=["canHandle","createRenderer","createEditor","processConfig","getTypeDefault","createToolPanelRenderer","parseDetailElement","parseResponsiveCardElement","releaseCell","unmount","beginBatch","endBatch"],e.ColumnInferenceModeEnum={AUTO:"auto",MERGE:"merge"},e.DEFAULT_A11Y_MESSAGES=t,e.DEFAULT_ANIMATION_CONFIG=r,e.DEFAULT_GRID_ICONS=i,e.DataGridElement=Nr,e.FitModeEnum=u,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=k,e.GridDataAttrs=T,e.GridElement=Nr,e.GridSelectors=P,e.MAX_ELEMENT_HEIGHT_PX=Be,e.PluginManager=zr,e.RenderPhase=Re,e.aggregatorRegistry=Vr,e.applyColumnDefaults=function(e,t){return t?e.map(e=>({...t,...e})):e},e.builtInSort=le,e.computeScrollMapping=Ge,e.createFieldReader=ie,e.createGrid=function(e){const t=document.createElement(Nr.activeTag);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.fromVirtualScrollTop=Ye,e.getByPath=ee,e.getPrimaryPointer=ct,e.getValueAggregator=Br,e.hasColumnShorthands=function(e){return e.some(e=>"string"==typeof e)},e.invalidateAccessorCache=ae,e.isPlainField=ne,e.normalizeColumns=d,e.parseColumnShorthand=c,e.parseFieldPath=J,e.queryGrid=function(e,t,r){let i=document,n=!1;return"boolean"==typeof t?n=t:t&&(i=t,n=!!r),n?customElements.whenDefined(Nr.activeTag).then(()=>i.querySelector(e)):i.querySelector(e)},e.readCellField=re,e.resolveCellValue=se,e.runValueAggregator=function(e,t){return Br(e)(t)},e.setByPath=te,e.setFeatureResolver=function(e){Zt=e},e.startPointerDrag=ot,e.toVirtualScrollTop=je,e.writeCellField=oe});
|
|
2
2
|
//# sourceMappingURL=grid.umd.js.map
|