@toolbox-web/grid 1.26.0 → 1.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +1 -1
- package/all.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/lib/plugins/editing/index.js +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/internal/editor-injection.d.ts +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/reorder-columns/index.js.map +1 -1
- package/lib/plugins/reorder-rows/index.js.map +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -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/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t){const o=e.querySelector?.(".tbw-sr-only");o&&(o.textContent="",requestAnimationFrame(()=>{o.textContent=t}))}const t={STRETCH:"stretch",FIXED:"fixed"},o={mode:"reduced-motion",duration:200,easing:"ease-out"},i='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',n={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:i,filterActive:i,print:"🖨️"};function r(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const s="TBW041",l="TBW061",a="TBW062",c="TBW080",d="TBW090",h="TBW091",u="TBW092",g="TBW093",f="TBW100",p="TBW110",w="TBW111",b="TBW112",m="TBW113",v="TBW114";function C(e,t,o,i){return`${r(o,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function y(e,t,o,i){throw new Error(C(e,t,o,i))}function _(e,t,o,i){console.warn(C(e,t,o,i))}function R(e,t,o,i){console.info(C(e,t,o,i))}function S(e,t,o,i){console.error(C(e,t,o,i))}function E(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const o={};t.forEach(e=>{const t=o[e.field];if(t){e.header&&!t.header&&(t.header=e.header),e.type&&!t.type&&(t.type=e.type),e.sortable&&(t.sortable=!0),e.editable&&(t.editable=!0),e.resizable&&(t.resizable=!0),null!=e.width&&null==t.width&&(t.width=e.width),null!=e.minWidth&&null==t.minWidth&&(t.minWidth=e.minWidth),e.__viewTemplate&&(t.__viewTemplate=e.__viewTemplate),e.__editorTemplate&&(t.__editorTemplate=e.__editorTemplate),e.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate);const o=e.renderer||e.viewRenderer,i=t.renderer||t.viewRenderer;o&&!i&&(t.viewRenderer=o,e.renderer&&(t.renderer=o)),e.editor&&!t.editor&&(t.editor=e.editor)}else o[e.field]={...e}});const i=e.map(e=>{const t=o[e.field];if(!t)return e;const i={...e};t.header&&!i.header&&(i.header=t.header),t.type&&!i.type&&(i.type=t.type),i.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(i.resizable=!0),i.editable=e.editable||t.editable,null!=t.width&&null==i.width&&(i.width=t.width),null!=t.minWidth&&null==i.minWidth&&(i.minWidth=t.minWidth),t.__viewTemplate&&(i.__viewTemplate=t.__viewTemplate),t.__editorTemplate&&(i.__editorTemplate=t.__editorTemplate),t.__headerTemplate&&(i.__headerTemplate=t.__headerTemplate);const n=t.renderer||t.viewRenderer,r=i.renderer||i.viewRenderer;return n&&!r&&(i.viewRenderer=n,t.renderer&&(i.renderer=n)),t.editor&&!i.editor&&(i.editor=t.editor),delete o[e.field],i});return Object.keys(o).forEach(e=>i.push(o[e])),i}function x(e,t){try{e.part?.add?.(t)}catch{}const o=e.getAttribute("part");o?o.split(/\s+/).includes(t)||e.setAttribute("part",o+" "+t):e.setAttribute("part",t)}function A(e){const o=e.effectiveConfig?.fitMode||e.fitMode||t.STRETCH;if(o!==t.STRETCH&&o!==t.FIXED)return;if(e.__didInitialAutoSize)return;if(!e.isConnected)return;const i=Array.from(e._headerRowEl?.children||[]);if(!i.length)return;let n=!1;e._visibleColumns.forEach((t,o)=>{if(t.width)return;const r=i[o];let s=r?r.scrollWidth:0;for(const i of e._rowPool){const e=i.children[o];if(e){const t=e.scrollWidth;t>s&&(s=t)}}s>0&&(t.width=s+2,t.__autoSized=!0,n=!0)}),n&&P(e),e.__didInitialAutoSize=!0}const T=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function H(e,t){return"number"==typeof e?`${e}px`:(T.test(e)||_("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 P(e){const o=e.effectiveConfig?.fitMode||e.fitMode||t.STRETCH;e._gridTemplate=o===t.STRETCH?e._visibleColumns.map(e=>{if(null!=e.width)return H(e.width,e.field);const t=e.minWidth;return null!=t?`minmax(${t}px, 1fr)`:"1fr"}).join(" ").trim():e._visibleColumns.map(e=>null!=e.width?H(e.width,e.field):"max-content").join(" "),e.style.setProperty("--tbw-column-template",e._gridTemplate)}const M=/{{\s*([^}]+)\s*}}/g,L="__DG_EMPTY__",D=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,O=/__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/;const k=/* @__PURE__ */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"]),z=/^on\w+$/i,I=/* @__PURE__ */new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),N=/^\s*(javascript|vbscript|data|blob):/i;function q(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],o=e.querySelectorAll("*");for(const i of o){const e=i.tagName.toLowerCase();if(k.has(e)){t.push(i);continue}if("svg"===e||"http://www.w3.org/2000/svg"===i.namespaceURI){if(Array.from(i.attributes).some(e=>z.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(i);continue}}const o=[];for(const t of i.attributes){const e=t.name.toLowerCase();z.test(e)?o.push(t.name):(I.has(e)&&N.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>i.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function W(e,t){if(!e||-1===e.indexOf("{{"))return e;const o=[],i=e.replace(M,(e,i)=>{const n=function(e,t){if(e=(e||"").trim(),!e)return L;if($.test(e))return L;if("value"===e)return null==t.value?L:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const o=e.slice(4),i=t.row?t.row[o]:void 0;return null==i?L:String(i)}if(e.length>80)return L;if(!D.test(e)||O.test(e))return L;const o=e.match(/\./g);if(o&&o.length>1)return L;try{const o=new Function("value","row",`return (${e});`)(t.value,t.row),i=null==o?"":String(o);return $.test(i)?L:i||L}catch{return L}}(i,t);return o.push({expr:i.trim(),result:n}),n}),n=(r=i)?r.replace(new RegExp(L,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):r;var r;const s=o.length&&o.every(e=>""===e.result||e.result===L);return $.test(e)||s?"":n}const $=/Reflect|Proxy|ownKeys/;function F(e){if($.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&$.test(t.textContent||"")&&(t.textContent="");$.test(e.textContent||"")&&(e.textContent="")}}function B(e){const t=$.test(e),o=o=>{if(t)return"";return W(e,o)};return o.__blocked=t,o}function U(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0}function V(e,t,o){const i=o.find(e=>e.field===t.field),n=i?.sortComparator??U,{field:r,direction:s}=t;return[...e].sort((e,t)=>n(e[r],t[r],e,t)*s)}function G(t,o,i,n){t._rows=o,t.__rowRenderEpoch++,t._rowPool.forEach(e=>e.__epoch=-1),ee(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:i.field,direction:n}})),e(t,`Sorted by ${i.header??i.field}, ${1===n?"ascending":"descending"}`),t.requestStateChange?.()}function X(t,o){if(t._sortState&&t._sortState.field===o.field)if(1===t._sortState.direction)Y(t,o,-1);else{t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(e=>e.__epoch=-1),t._rows=t.__originalOrder.slice(),ee(t);const i=t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');i?.forEach(e=>{e.getAttribute("aria-sort")&&("ascending"!==e.getAttribute("aria-sort")&&"descending"!==e.getAttribute("aria-sort")||t._sortState)||e.setAttribute("aria-sort","none")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:0}})),e(t,"Sort cleared"),t.requestStateChange?.()}else t._sortState||(t.__originalOrder=t._rows.slice()),Y(t,o,1)}function Y(e,t,o){e._sortState={field:t.field,direction:o};const i={field:t.field,direction:o},n=e._columns,r=(e.effectiveConfig?.sortHandler??V)(e._rows,i,n);r&&"function"==typeof r.then?r.then(i=>{G(e,i,t,o)}):G(e,r,t,o)}function j(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function K(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function Z(e,t){const o=document.createElement("span");x(o,"sort-indicator");const i=e._sortState?.field===t.field?e._sortState.direction:0,r={...n,...e.icons};return function(e,t){"string"==typeof t?e.textContent=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(o,1===i?r.sortAsc:-1===i?r.sortDesc:r.sortNone),o}function Q(e,t,o){const i=document.createElement("div");return i.className="resize-handle",i.setAttribute("aria-hidden","true"),i.addEventListener("mousedown",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.start(i,t,o)}),i.addEventListener("dblclick",o=>{o.stopPropagation(),o.preventDefault(),e._resizeController.resetColumn(t)}),i}function J(e,t,o,i){i.classList.add("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",o=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(o,t,i)||X(e,t)}),i.addEventListener("keydown",o=>{if("Enter"===o.key||" "===o.key){if(o.preventDefault(),e._dispatchHeaderClick?.(o,t,i))return;X(e,t)}})}function ee(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((o,i)=>{const n=document.createElement("div");n.className="cell",x(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",o.field),n.setAttribute("data-col",String(i)),o.type&&n.setAttribute("data-type",o.type);const r=o.header??o.field,s=e._sortState?.field===o.field?e._sortState.direction:0,l=1===s?"asc":-1===s?"desc":null;if(o.headerRenderer){const t={column:o,value:r,sortState:l,filterActive:!1,cellEl:n,renderSortIcon:()=>j(e,o)?Z(e,o):null,renderFilterButton:()=>null},s=o.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const o=document.createElement("span");for(o.innerHTML=q(t);o.firstChild;)e.appendChild(o.firstChild)}else t instanceof Node&&e.appendChild(t)}(n,s),j(e,o)&&J(e,o,0,n),K(e,o)&&(n.classList.add("resizable"),n.appendChild(Q(e,i,n)))}else if(o.headerLabelRenderer){const t={column:o,value:r},s=o.headerLabelRenderer(t),l=document.createElement("span");null==s?l.textContent=r:"string"==typeof s?l.innerHTML=q(s):s instanceof Node&&l.appendChild(s),n.appendChild(l),j(e,o)&&(J(e,o,0,n),n.appendChild(Z(e,o))),K(e,o)&&(n.classList.add("resizable"),n.appendChild(Q(e,i,n)))}else if(o.__headerTemplate)Array.from(o.__headerTemplate.childNodes).forEach(e=>n.appendChild(e.cloneNode(!0))),j(e,o)&&(J(e,o,0,n),n.appendChild(Z(e,o))),K(e,o)&&(n.classList.add("resizable"),n.appendChild(Q(e,i,n)));else{const t=document.createElement("span");t.textContent=r,n.appendChild(t),j(e,o)&&(J(e,o,0,n),n.appendChild(Z(e,o))),K(e,o)&&(n.classList.add("resizable"),n.appendChild(Q(e,i,n)))}t.appendChild(n)}),t.querySelectorAll(".cell.sortable").forEach(e=>{e.getAttribute("aria-sort")||e.setAttribute("aria-sort","none")}),t.children.length>0?(t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1")):(t.removeAttribute("role"),t.removeAttribute("aria-rowindex")))}function te(e,t){const o=e[0]||{},i=Object.keys(o).map(e=>{const t=o[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 oe,ie=((oe=ie||{})[oe.STYLE=1]="STYLE",oe[oe.VIRTUALIZATION=2]="VIRTUALIZATION",oe[oe.HEADER=3]="HEADER",oe[oe.ROWS=4]="ROWS",oe[oe.COLUMNS=5]="COLUMNS",oe[oe.FULL=6]="FULL",oe);class ne{#e;#t=0;#o=0;#i=null;#n=null;#r=null;#s=!1;constructor(e){this.#e=e}requestPhase(e,t){e>this.#t&&(this.#t=e),0===this.#o&&(this.#l(),this.#o=requestAnimationFrame(()=>this.#a()))}whenReady(){return this.#i?this.#i:Promise.resolve()}setInitialReadyResolver(e){this.#r=e}cancel(){0!==this.#o&&(cancelAnimationFrame(this.#o),this.#o=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}#l(){this.#i||(this.#i=new Promise(e=>{this.#n=e}))}#a(){if(this.#o=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>=5&&this.#e._schedulerMergeConfig(),e>=4&&this.#e._schedulerProcessRows(),e>=5&&(this.#e._schedulerProcessColumns(),this.#e._schedulerUpdateTemplate()),e>=3&&this.#e._schedulerRenderHeader(),e>=2&&this.#e.refreshVirtualWindow(!0,!0),e>=1&&this.#e._schedulerAfterRender(),!this.#s&&this.#r&&(this.#s=!0,this.#r()),this.#n&&(this.#n(),this.#n=null,this.#i=null)}}class re{#c;#d;#h;#u;#g;#f={};#p={};#w=!0;#b=[];#m;#v;#C;#y;#e;#_;constructor(e){this.#e=e}get original(){return this.#f}get effective(){return this.#p}get columns(){return this.#p.columns??[]}set columns(e){this.#p.columns=e}get lightDomColumnsCache(){return this.#u}set lightDomColumnsCache(e){this.#u=e}get originalColumnNodes(){return this.#g}set originalColumnNodes(e){this.#g=e}get lightDomTitle(){return this.#_}set lightDomTitle(e){this.#_=e}get initialColumnState(){return this.#y}set initialColumnState(e){this.#y=e}get sourcesChanged(){return this.#w}markSourcesChanged(){this.#w=!0}setGridConfig(e){this.#c=e,this.#w=!0,this.#u=void 0}getGridConfig(){return this.#c}setColumns(e){this.#d=e,this.#w=!0}getColumns(){return this.#d}setFitMode(e){this.#h=e,this.#w=!0}getFitMode(){return this.#h}merge(){const e=(this.#p.columns?.length??0)>0;if(!this.#w&&e)return;const t=this.#R();this.#w=!1,this.#f=t,Object.freeze(this.#f),this.#f.columns&&Object.freeze(this.#f.columns),this.#p=this.#S(this.#f),this.#E()}#S(e){const t={...e};return e.columns&&(t.columns=e.columns.map(e=>({...e}))),e.shell&&(t.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(e=>({...e})),headerContents:e.shell.headerContents?.map(e=>({...e}))}),t}#E(){const e=this.#p;if(this.#x(),"number"==typeof e.rowHeight&&e.rowHeight>0&&(this.#e._virtualization.rowHeight=e.rowHeight),"fixed"===e.fitMode){this.columns.forEach(e=>{null==e.width&&(e.width=80)})}this.#e._applyAnimationConfig(e)}#x(){const e=this.#p.typeDefaults;if(!e)return;const t=this.columns;for(const o of t){if(!o.type)continue;const t=e[o.type];t&&(o.renderer||o.viewRenderer||!t.renderer||(o.renderer=t.renderer),!o.format&&t.format&&(o.format=t.format),!o.editor&&t.editor&&(o.editor=t.editor),!o.editorParams&&t.editorParams&&(o.editorParams=t.editorParams))}}#R(){const e=this.#c?{...this.#c}:{},t=Array.isArray(e.columns)?[...e.columns]:[],o=(this.#u??[]).map(e=>({...e}));let i=E(t,o);this.#d&&this.#d.length&&(i=E(this.#d,o));const n=this.#e.sourceRows;if(0===i.length&&n.length){i=te(n).columns}return i.length&&(i.forEach(e=>{void 0===e.sortable&&(e.sortable=!0),void 0===e.resizable&&(e.resizable=!0),void 0===e.__originalWidth&&"number"==typeof e.width&&(e.__originalWidth=e.width)}),i.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=B(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=B(e.__editorTemplate.innerHTML))}),e.columns=i),this.#h&&(e.fitMode=this.#h),e.fitMode||(e.fitMode="stretch"),this.#A(e),e.columnState&&!this.#y&&(this.#y=e.columnState),e}#A(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const t=this.#e._shellState.lightDomTitle;t&&(this.#_=t),this.#_&&!e.shell.header.title&&(e.shell.header.title=this.#_);const o=this.#e._shellState.lightDomHeaderContent;o?.length>0&&(e.shell.header.lightDomContent=o),this.#e._shellState.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0);const i=this.#e._shellState.toolPanels;if(i.size>0){const t=Array.from(i.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=t}const n=this.#e._shellState.headerContents;if(n.size>0){const t=Array.from(n.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=t}const r=this.#e._shellState.toolbarContents,s=Array.from(r.values()),l=this.#c?.shell?.header?.toolbarContents??[],a=new Set(l.map(e=>e.id)),c=[...l];for(const d of s)a.has(d.id)||c.push(d);c.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=c}collectState(e){const t=this.columns,o=this.#T();return{columns:t.map((t,i)=>{const n={field:t.field,order:i,visible:!t.hidden},r=t;void 0!==r.__renderedWidth?n.width=r.__renderedWidth:void 0!==t.width&&(n.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=o.get(t.field);s&&(n.sort=s);for(const o of e)if(o.getColumnState){const e=o.getColumnState(t.field);e&&Object.assign(n,e)}return n})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const o=this.columns,i=new Map(e.columns.map(e=>[e.field,e])),n=o.map(e=>{const t=i.get(e.field);if(!t)return e;const o={...e};return void 0!==t.width&&(o.width=t.width,o.__renderedWidth=t.width),void 0!==t.visible&&(o.hidden=!t.visible),o});n.sort((e,t)=>(i.get(e.field)?.order??1/0)-(i.get(t.field)?.order??1/0)),this.columns=n;const r=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(r.length>0){const e=r[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.#y=void 0,this.#e._sortState=null,this.#p=this.#S(this.#f),this.#E();for(const t of e)if(t.applyColumnState)for(const e of this.columns)t.applyColumnState(e.field,{field:e.field,order:0,visible:!0});this.requestStateChange(e)}#T(){const e=/* @__PURE__ */new Map,t=this.#e._sortState;return t&&e.set(t.field,{direction:1===t.direction?"asc":"desc",priority:0}),e}requestStateChange(e){this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=void 0;const t=this.collectState(e);this.#e._emit("column-state-change",t)},100)}setColumnVisible(e,t){const o=this.columns,i=o.find(t=>t.field===e);if(!i)return!1;if(!t&&i.lockVisible)return!1;if(!t){if(0===o.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!i.hidden!=!t&&(i.hidden=!t,this.#e._emit("column-visibility",{field:e,visible:t,visibleColumns:o.filter(e=>!e.hidden).map(e=>e.field)}),this.#e._clearRowPool(),this.#e._setup(),!0)}toggleColumnVisibility(e){const t=this.columns.find(t=>t.field===e);return!!t&&this.setColumnVisible(e,!!t.hidden)}isColumnVisible(e){const t=this.columns.find(t=>t.field===e);return!!t&&!t.hidden}showAllColumns(){const e=this.columns;e.some(e=>e.hidden)&&(e.forEach(e=>e.hidden=!1),this.#e._emit("column-visibility",{visibleColumns:e.map(e=>e.field)}),this.#e._clearRowPool(),this.#e._setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:!0===e.meta?.utility}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const t=new Map(this.columns.map(e=>[e.field,e])),o=[];for(const i of e){const e=t.get(i);e&&(o.push(e),t.delete(i))}for(const i of t.values())o.push(i);this.columns=o,ee(this.#e),P(this.#e),this.#e._requestSchedulerPhase(ie.VIRTUALIZATION,"configManager")}parseLightDomColumns(e){this.#u||(this.#g=Array.from(e.querySelectorAll("tbw-grid-column")),this.#u=this.#g.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const o=e.getAttribute("type")||void 0,i={field:t,type:o&&/* @__PURE__ */new Set(["number","string","date","boolean","select"]).has(o)?o:void 0,header:e.getAttribute("header")||void 0,sortable:e.hasAttribute("sortable"),editable:e.hasAttribute("editable")},n=e.getAttribute("width");if(n){const e=parseFloat(n);!isNaN(e)&&/^\d+(\.\d+)?$/.test(n.trim())?i.width=e:i.width=n}const r=e.getAttribute("minWidth")||e.getAttribute("min-width");if(r){const e=parseFloat(r);isNaN(e)||(i.minWidth=e)}e.hasAttribute("resizable")&&(i.resizable=!0),e.hasAttribute("sizable")&&(i.resizable=!0);const s=e.getAttribute("editor"),l=e.getAttribute("renderer");s&&(i.__editorName=s),l&&(i.__rendererName=l);const a=e.getAttribute("options");a&&(i.options=a.split(",").map(e=>{const[t,o]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:o?.trim()||t.trim()}}));const c=e.querySelector("tbw-grid-column-view"),d=e.querySelector("tbw-grid-column-editor"),h=e.querySelector("tbw-grid-column-header");c&&(i.__viewTemplate=c),d&&(i.__editorTemplate=d),h&&(i.__headerTemplate=h);const u=globalThis.DataGridElement,g=u?.getAdapters?.()??[],f=c??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(i.viewRenderer=e)}const w=d??e,b=g.find(e=>e.canHandle(w));if(b){const e=b.createEditor(w);e&&(i.editor=e)}return i}).filter(e=>!!e)}(e):[])}clearLightDomCache(){this.#u=void 0}#H=/* @__PURE__ */new Map;registerLightDomHandler(e,t){this.#H.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#H.delete(e.toLowerCase())}observeLightDOM(e){this.#m&&this.#m.disconnect();const t=/* @__PURE__ */new Set,o=()=>{this.#C=void 0;for(const e of t){const t=this.#H.get(e);t?.()}t.clear()};this.#m=new MutationObserver(e=>{for(const o of e){for(const e of o.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const o=e.tagName.toLowerCase();this.#H.has(o)&&t.add(o)}if("attributes"===o.type&&o.target.nodeType===Node.ELEMENT_NODE){const e=o.target.tagName.toLowerCase();this.#H.has(e)&&t.add(e)}}t.size>0&&!this.#C&&(this.#C=setTimeout(o,0))}),this.#m.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#b.push(e)}notifyChange(){for(const e of this.#b)e()}dispose(){this.#m?.disconnect(),this.#b=[],this.#v&&clearTimeout(this.#v),this.#C&&(clearTimeout(this.#C),this.#C=void 0)}}function se(){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 le(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"🗹":"☐"}</span>`}function ae(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 ce(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const o=e.closest(".data-grid-row");if(!o)return-1;const i=o.parentElement;if(!i)return-1;const n=i.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===o)return r;return-1}function de(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function he(e){try{if("rtl"===getComputedStyle(e).direction)return"rtl"}catch{}try{const t=e.closest?.("[dir]")?.getAttribute("dir");if("rtl"===t)return"rtl"}catch{}return"ltr"}function ue(e){return"rtl"===he(e)}function ge(e,t){return"left"===e||"right"===e?e:"rtl"===t?"start"===e?"right":"left":"start"===e?"left":"right"}function fe(e,t){const o=t.renderer||t.viewRenderer;if(o)return o;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const e=i.getTypeDefault(t.type);if(e?.renderer)return e.renderer}}function pe(e,t){if(t.format)return t.format;if(!t.type)return;const o=e.__frameworkAdapter;if(o?.getTypeDefault){const e=o.getTypeDefault(t.type);if(e?.format)return e.format}}const we='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function be(e){return(e.__editingCellCount??0)>0}function me(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(".cell.editing").forEach(e=>e.classList.remove("editing"))}const ve=document.createElement("template");ve.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const Ce=document.createElement("template");function ye(){return ve.content.firstElementChild.cloneNode(!0)}function _e(){return Ce.content.firstElementChild.cloneNode(!0)}function Re(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function Se(e,t,o,i){const n=t.children,r=e._visibleColumns,s=r.length,c=n.length,d=s<c?s:c,h=e._focusRow,u=e._focusCol,g=e._hasAfterCellRenderHook?.()??!1;let f=e.__hasSpecialColumns;if(void 0===f){f=!1;const t=e.__frameworkAdapter;for(let e=0;e<s;e++){const o=r[e];if(o.__viewTemplate||o.__compiledView||o.renderer||o.viewRenderer||o.externalView||o.format||o.cellClass||"date"===o.type||"boolean"===o.type||o.type&&t?.getTypeDefault?.(o.type)?.renderer||o.type&&t?.getTypeDefault?.(o.type)?.format){f=!0;break}}e.__hasSpecialColumns=f}const p=String(i);if(f){for(let s=0;s<d;s++){if(r[s].externalView){if(!n[s].querySelector("[data-external-view]"))return void Ee(e,t,o,i)}}for(let s=0;s<d;s++){const c=r[s],d=n[s];d.getAttribute("data-row")!==p&&d.setAttribute("data-row",p);const f=d.classList.contains("editing");if(!f){const e=h===i&&u===s;e!==d.classList.contains("cell-focus")&&(d.classList.toggle("cell-focus",e),d.setAttribute("aria-selected",String(e)))}const b=c.cellClass;if(b){const t=d.getAttribute("data-dynamic-classes");t&&t.split(" ").forEach(e=>e&&d.classList.remove(e));try{const e=b(o[c.field],o,c),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){const e=t.filter(e=>e&&"string"==typeof e);e.forEach(e=>d.classList.add(e)),d.setAttribute("data-dynamic-classes",e.join(" "))}else d.removeAttribute("data-dynamic-classes")}catch(w){_(l,`cellClass callback error for column '${c.field}': ${w}`,e.id),d.removeAttribute("data-dynamic-classes")}}if(f)continue;const m=fe(e,c);if(m){const n=o[c.field],r=m({row:o,value:n,field:c.field,column:c,cellEl:d});"string"==typeof r?(e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=q(r)):r instanceof Node?r.parentElement!==d&&(e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML="",d.appendChild(r)):null==r&&(e.__frameworkAdapter?.releaseCell?.(d),d.textContent=null==n?"":String(n)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:c,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(c.__compiledView){const n=o[c.field],r=c.__compiledView({row:o,value:n,field:c.field,column:c});c.__compiledView.__blocked?d.textContent="":(d.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=q(r),F(d)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:c,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(c.__viewTemplate){const n=o[c.field],r=c.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(r)?d.textContent="":(d.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=q(W(r,{row:o,value:n})),F(d)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:c,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(c.externalView)continue;const v=o[c.field];let C;const y=pe(e,c);if(y){try{const e=y(v,o);C=null==e?"":String(e)}catch(w){_(a,`Format error in column '${c.field}': ${w}`,e.id),C=null==v?"":String(v)}d.textContent=C}else"date"===c.type?(C=ae(v),d.textContent=C):"boolean"===c.type?d.innerHTML=le(!!v):(C=null==v?"":String(v),d.textContent=C);g&&e._afterCellRender?.({row:o,rowIndex:i,column:c,colIndex:s,value:v,cellElement:d,rowElement:t})}}else for(let l=0;l<d;l++){const s=n[l];if(s.classList.contains("editing"))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const a=r[l],c=o[a.field];s.textContent=null==c?"":String(c),s.getAttribute("data-row")!==p&&s.setAttribute("data-row",p);const d=h===i&&u===l;d!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",d),s.setAttribute("aria-selected",String(d))),g&&e._afterCellRender?.({row:o,rowIndex:i,column:a,colIndex:l,value:c,cellElement:s,rowElement:t})}}function Ee(e,t,o,i){t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy");const n=e.__frameworkAdapter;if(n?.releaseCell){const e=t.children;for(let t=e.length-1;t>=0;t--)n.releaseCell(e[t])}t.innerHTML="";const r=e._visibleColumns,s=r.length,c=e._focusRow,d=e._focusCol,h=e._hasAfterCellRenderHook?.()??!1,u=document.createDocumentFragment();for(let f=0;f<s;f++){const n=r[f],s=ye();s.setAttribute("aria-colindex",String(f+1)),s.setAttribute("data-col",String(f)),s.setAttribute("data-row",String(i)),s.setAttribute("data-field",n.field),s.setAttribute("data-header",n.header??n.field),n.type&&s.setAttribute("data-type",n.type);let p=o[n.field];const w=pe(e,n);if(w)try{p=w(p,o)}catch(g){_(a,`Format error in column '${n.field}': ${g}`,e.id)}const b=n.__compiledView,m=n.__viewTemplate,v=fe(e,n),C=n.externalView;let y=!1;if(v){const e=v({row:o,value:p,field:n.field,column:n,cellEl:s});"string"==typeof e?(s.innerHTML=q(e),y=!0):e instanceof Node?e.parentElement!==s&&(s.textContent="",s.appendChild(e)):null==e&&(s.textContent=null==p?"":String(p))}else if(C){const t=C,i=document.createElement("div");i.setAttribute("data-external-view",""),i.setAttribute("data-field",n.field),s.appendChild(i);const r={row:o,value:p,field:n.field,column:n};if(t.mount)try{t.mount({placeholder:i,context:r,spec:t})}catch(g){_("TBW063",`External view mount error for column '${n.field}': ${g}`,e.id)}else queueMicrotask(()=>{try{e.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:i,spec:t,context:r}}))}catch(g){_("TBW064",`External view event dispatch error for column '${n.field}': ${g}`,e.id)}});i.setAttribute("data-mounted","")}else if(b){const e=b({row:o,value:p,field:n.field,column:n}),t=b.__blocked;s.innerHTML=t?"":q(e),y=!0,t&&(s.textContent="",s.setAttribute("data-blocked-template",""))}else if(m){const e=m.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(s.textContent="",s.setAttribute("data-blocked-template","")):(s.innerHTML=q(W(e,{row:o,value:p})),y=!0)}else w?s.textContent=null==p?"":String(p):"date"===n.type?s.textContent=ae(p):"boolean"===n.type?s.innerHTML=le(!!p):s.textContent=null==p?"":String(p);if(y){F(s);const e=s.textContent||"";/Proxy|Reflect\.ownKeys/.test(e)&&(s.textContent=e.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(s.textContent||"")&&(s.textContent=""))}s.hasAttribute("data-blocked-template")&&(s.textContent||"").trim().length&&(s.textContent="");("function"==typeof n.editable?n.editable(o):n.editable)?s.tabIndex=0:"boolean"===n.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),c===i&&d===f?(s.classList.add("cell-focus"),s.setAttribute("aria-selected","true")):s.setAttribute("aria-selected","false");const R=n.cellClass;if(R)try{const e=R(o[n.field],o,n),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const o of t)o&&"string"==typeof o&&(s.classList.add(o),e+=(e?" ":"")+o);s.setAttribute("data-dynamic-classes",e)}}catch(g){_(l,`cellClass callback error for column '${n.field}': ${g}`,e.id)}h&&e._afterCellRender?.({row:o,rowIndex:i,column:n,colIndex:f,value:p,cellElement:s,rowElement:t}),u.appendChild(s)}t.appendChild(u)}function xe(e,t,o){if(t.target?.closest(".resize-handle"))return;const i=ce(o.querySelector(".cell[data-row]"));if(i<0)return;const n=e._rows[i];if(!n)return;if(e._dispatchRowClick?.(t,i,n,o))return;const r=t.target?.closest(".cell[data-col]");if(r){const o=Number(r.getAttribute("data-col"));if(!isNaN(o)){if(e._dispatchCellClick?.(t,i,o,r))return;const n=e._focusRow!==i||e._focusCol!==o;if(e._focusRow=i,e._focusCol=o,r.classList.contains("editing")){n&&(de(e._bodyEl??e),r.classList.add("cell-focus"));const t=r.querySelector(we);try{t?.focus({preventScroll:!0})}catch{}return}Ae(e)}}}function Ae(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:o,viewportEl:i}=e._virtualization,n=o,r=i?.clientHeight??n?.clientHeight??0;if(n&&r>0){const o=e._focusRow*t;o<n.scrollTop?n.scrollTop=o:o+t>n.scrollTop+r&&(n.scrollTop=o-r+t)}}const o=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;o||e.refreshVirtualWindow(!1),de(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const i=e._focusRow,n=e._virtualization.start??0,r=e._virtualization.end??e._rows.length;if(i>=n&&i<r){const r=e._bodyEl.querySelectorAll(".data-grid-row")[i-n];let s=r?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=r?.querySelector(`.cell[data-col="${e._focusCol}"]`)??r?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const i=e.querySelector(".tbw-scroll-area");if(i&&s&&(!o||t?.forceHorizontalScroll))if(t?.forceScrollLeft)i.scrollLeft=0;else if(t?.forceScrollRight)i.scrollLeft=i.scrollWidth-i.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(r??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),o=i.getBoundingClientRect(),n=e.left-o.left+i.scrollLeft,r=n+e.width,l=i.scrollLeft+t.left,a=i.scrollLeft+i.clientWidth-t.right;n<l?i.scrollLeft=n-t.left:r>a&&(i.scrollLeft=r-i.clientWidth+t.right)}}if(o&&s.classList.contains("editing")){const e=s.querySelector(we);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(o&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else o||document.activeElement!==e&&e.focus({preventScroll:!0})}}}Ce.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const Te=/* @__PURE__ */new WeakMap;function He(e,t){const o=ce(t),i=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(o<0||i<0)return;e._focusRow=o,e._focusCol=i,de(e._bodyEl),t.classList.add("cell-focus"),t.setAttribute("aria-selected","true");const n=t.closest("tbw-grid");n&&document.activeElement!==n&&n.focus({preventScroll:!0})}function Pe(e,t,o,i){let n=null;const r=o.composedPath?.();if(n=r&&r.length>0?r[0]:o.target,n&&!t.contains(n)){const e=document.elementFromPoint(o.clientX,o.clientY);e&&(n=e)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,h,u,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(h=e._rows[c],f=e._visibleColumns[d],u=f?.field,g=h&&u?h[u]:void 0)),{type:i,row:h,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:u,value:g,column:f,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}function Me(e,t,o,i){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const o=e._rows.length-1,i=e._visibleColumns.length-1,n=void 0!==e._activeEditRows&&-1!==e._activeEditRows,r=e._visibleColumns[e._focusCol],s=r?.type,l=t.composedPath?.()??[],a=l.length?l[0]:t.target,c=e=>{if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable};if((!c(a)||"Home"!==t.key&&"End"!==t.key)&&!(c(a)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===a.tagName&&"number"===a.type||c(a)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||c(a)&&("Enter"===t.key||"Escape"===t.key)||n&&"select"===s&&("ArrowDown"===t.key||"ArrowUp"===t.key))){switch(t.key){case"Tab":return t.preventDefault(),t.shiftKey?e._focusCol>0?e._focusCol-=1:e._focusRow>0&&("function"==typeof e.commitActiveRowEdit&&e._activeEditRows===e._focusRow&&e.commitActiveRowEdit(),e._focusRow-=1,e._focusCol=i):e._focusCol<i?e._focusCol+=1:("function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow<o&&(e._focusRow+=1,e._focusCol=0)),void Ae(e);case"ArrowDown":n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=Math.min(o,e._focusRow+1),t.preventDefault();break;case"ArrowUp":n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const o=ue(e);e._focusCol=o?Math.max(0,e._focusCol-1):Math.min(i,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const o=ue(e);e._focusCol=o?Math.min(i,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void Ae(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=o,e._focusCol=i):e._focusCol=i,t.preventDefault(),void Ae(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(o,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const o=e._focusRow,i=e._focusCol,n=e._visibleColumns[i],r=e._rows[o],s=n?.field??"",l=s&&r?r[s]:void 0,a=e.querySelector(`[data-row="${o}"][data-col="${i}"]`),c=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:o,colIndex:i,column:n,field:s,value:l,row:r,cellEl:a,trigger:"keyboard",originalEvent:t}});e.dispatchEvent(c);const d=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:o,col:i}});if(e.dispatchEvent(d),c.defaultPrevented||d.defaultPrevented)return void t.preventDefault();break}default:return}Ae(e)}}(e,t),{signal:i}),o.addEventListener("mousedown",t=>function(e,t,o){const i=Pe(e,t,o,"mousedown");e._dispatchCellMouseDown?.(i)&&Te.set(e,!0)}(e,o,t),{signal:i}),document.addEventListener("mousemove",t=>function(e,t,o){if(!Te.get(e))return;const i=Pe(e,t,o,"mousemove");e._dispatchCellMouseMove?.(i)}(e,o,t),{signal:i}),document.addEventListener("mouseup",t=>function(e,t,o){if(!Te.get(e))return;const i=Pe(e,t,o,"mouseup");e._dispatchCellMouseUp?.(i),Te.set(e,!1)}(e,o,t),{signal:i})}let Le;function De(e){Le=e}class Oe{#e;#P=/* @__PURE__ */new Set;#M=/* @__PURE__ */new Map;constructor(e){this.#e=e}focusCell(e,t){const o=this.#e,i=o._rows.length-1;if(i<0)return;let n;if("string"==typeof t){if(n=o._visibleColumns.findIndex(e=>e.field===t),n<0)return}else n=t;const r=o._visibleColumns.length-1;r<0||(o._focusRow=Math.max(0,Math.min(e,i)),o._focusCol=Math.max(0,Math.min(n,r)),Ae(o))}get focusedCell(){const e=this.#e;if(0===e._rows.length||0===e._visibleColumns.length)return null;const t=e._visibleColumns[e._focusCol];return{rowIndex:e._focusRow,colIndex:e._focusCol,field:t?.field??""}}scrollToRow(e,t){const o=this.#e._virtualization;if(!o.enabled)return;const i=o.container;if(!i)return;const n=this.#e._rows.length;if(0===n)return;const r=Math.max(0,Math.min(e,n-1)),s=t?.align??"nearest",l=t?.behavior??"instant";let a,c;const d=o.positionCache;o.variableHeights&&d&&d.length>r?(a=d[r].offset,c=d[r].height):(a=r*o.rowHeight,c=o.rowHeight);const h=o.viewportEl?.clientHeight??i.clientHeight??0;if(h<=0)return;const u=i.scrollTop,g=a+c,f=u+h;let p;switch(s){case"start":p=a;break;case"center":p=a-h/2+c/2;break;case"end":p=g-h;break;default:if(a>=u&&g<=f)return;p=a<u?a:g-h}p=Math.max(0,p),"smooth"===l?i.scrollTo({top:p,behavior:"smooth"}):i.scrollTop=p}scrollToRowById(e,t){const o=this.#e._getRowEntry(e);o&&this.scrollToRow(o.index,t)}registerExternalFocusContainer(e){if(this.#P.has(e))return;this.#P.add(e);const t=new AbortController,o=t.signal,i=this.#e;e.addEventListener("focusin",()=>{i.dataset.hasFocus=""},{signal:o}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete i.dataset.hasFocus},{signal:o}),this.#M.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#P.delete(e);const t=this.#M.get(e);t&&(t(),this.#M.delete(e))}containsFocus(e){const t=e??document.activeElement;return!!t&&(!!this.#e.contains(t)||this.isInExternalFocusContainer(t))}isInExternalFocusContainer(e){for(const t of this.#P)if(t.contains(e))return!0;return!1}destroy(){for(const e of this.#M.values())e();this.#M.clear(),this.#P.clear()}}const ke="function"==typeof requestIdleCallback;function ze(e){ke?cancelIdleCallback(e):clearTimeout(e)}function Ie(e,t){if(t){const o=t({size:e});if("string"==typeof o){const e=document.createElement("div");return e.innerHTML=o,e}return o}return function(e){const t=document.createElement("div");return t.className=`tbw-spinner tbw-spinner--${e}`,t.setAttribute("role","progressbar"),t.setAttribute("aria-label","Loading"),t}(e)}function Ne(e){let t=null,o=null,i=null,n=null;const r=i=>{if(!t)return;const n=i.clientX-t.startX,r=Math.max(40,t.startWidth+n),s=e._visibleColumns[t.colIndex];s.width=r,s.__userResized=!0,s.__renderedWidth=r,null==o&&(o=requestAnimationFrame(()=>{o=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:s.field,width:r}}))};let s=!1;const l=()=>{const o=null!==t;o&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),null!==i&&(document.documentElement.style.cursor=i,i=null),null!==n&&(document.body.style.userSelect=n,n=null),t=null,o&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(o,s,a){o.preventDefault();const c=e._visibleColumns[s],d="number"==typeof c?.width?c.width:void 0,h=c?.__renderedWidth??d??a.getBoundingClientRect().width;t={startX:o.clientX,colIndex:s,startWidth:h},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),null===i&&(i=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",null===n&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(t){const o=e._visibleColumns[t];o&&(o.__userResized=!1,o.__renderedWidth=void 0,o.width=o.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:o.field,width:o.width}})))},dispose(){l()}}}const qe="data-animating",We={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},$e={change:500,insert:300,remove:200};function Fe(e,t){const o=We[t],i=getComputedStyle(e).getPropertyValue(o);if(i){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(i);if(!isNaN(e)&&e>0)return e}return $e[t]}function Be(e,t,o){if(t<0)return Promise.resolve(!1);const i=e.findRenderedRowElement?.(t);return i?new Promise(e=>{!function(e,t,o){e.removeAttribute(qe),e.offsetWidth,e.setAttribute(qe,t);const i=Fe(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(qe),o?.()},i)}(i,o,()=>e(!0))}):Promise.resolve(!1)}function Ue(e,t){if(t)return t(e);const o=e;return"id"in o&&null!=o.id?String(o.id):"_id"in o&&null!=o._id?String(o._id):void 0}function Ve(e,t,o){const i=Ue(e,o);return void 0===i&&y("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),i}class Ge{#e;constructor(e){this.#e=e}resolveRowId(e){return Ve(e,this.#e.id,this.#e.effectiveConfig?.getRowId)}getRow(e){return this.#e._getRowEntry(e)?.row}getRowEntry(e){return this.#e._getRowEntry(e)}updateRow(e,t,o="api"){const i=this.#e,n=i._getRowEntry(e);n||y(s,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id);const{row:r,index:l}=n,a=[];for(const[s,c]of Object.entries(t)){const e=r[s];e!==c&&(a.push({field:s,oldValue:e,newValue:c}),r[s]=c)}for(const{field:s,oldValue:c,newValue:d}of a)i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:r,rowId:e,rowIndex:l,field:s,oldValue:c,newValue:d,changes:t,source:o},bubbles:!0,composed:!0}));a.length>0&&(Re(i),i._requestSchedulerPhase(ie.VIRTUALIZATION,"updateRow"),i._emitDataChange())}updateRows(e,t="api"){const o=this.#e;let i=!1;for(const{id:n,changes:r}of e){const e=o._getRowEntry(n);e||y(s,`Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`,o.id);const{row:l,index:a}=e;for(const[s,c]of Object.entries(r)){const e=l[s];e!==c&&(i=!0,l[s]=c,o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:l,rowId:n,rowIndex:a,field:s,oldValue:e,newValue:c,changes:r,source:t},bubbles:!0,composed:!0})))}}i&&(Re(o),o._requestSchedulerPhase(ie.VIRTUALIZATION,"updateRows"),o._emitDataChange())}async insertRow(e,t,o=!0){const i=this.#e,n=Math.max(0,Math.min(e,i._rows.length));i.sourceRows=[...i.sourceRows,t];const r=[...i._rows];r.splice(n,0,t),i._rows=r,i._sortState&&(i.__originalOrder=[...i.__originalOrder,t]),Re(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(const s of i._rowPool)s.__epoch=-1;i.refreshVirtualWindow(!0),i._emitPluginEvent("row-inserted",{row:t,index:n}),i._emitDataChange(),o&&(await new Promise(e=>requestAnimationFrame(()=>e())),await Be(i,n,"insert"))}async removeRow(e,t=!0){const o=this.#e,i=o._rows[e];if(!i)return;t&&await Be(o,e,"remove");const n=o._rows.indexOf(i);if(n<0)return i;const r=[...o._rows];r.splice(n,1),o._rows=r;const s=o.sourceRows.indexOf(i);if(s>=0){const e=[...o.sourceRows];e.splice(s,1),o.sourceRows=e}if(o._sortState){const e=o.__originalOrder.indexOf(i);if(e>=0){const t=[...o.__originalOrder];t.splice(e,1),o.__originalOrder=t}}Re(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(const l of o._rowPool)l.__epoch=-1;return o.refreshVirtualWindow(!0),o._emitDataChange(),t&&requestAnimationFrame(()=>{o.querySelectorAll('[data-animating="remove"]').forEach(e=>{e.removeAttribute("data-animating")})}),i}}function Xe(e,t,o){const i=document.createElement(e);if(t)for(const n in t){const e=t[n];null!=e&&i.setAttribute(n,e)}return i}function Ye(e,t){const o=document.createElement("div");if(e&&(o.className=e),t)for(const i in t){const e=t[i];null!=e&&o.setAttribute(i,e)}return o}function je(e,t,o){const i=document.createElement("button");if(e&&(i.className=e),t)for(const n in t){const e=t[n];null!=e&&i.setAttribute(n,e)}return i}const Ke=document.createElement("template");function Ze(){return Ke.content.cloneNode(!0)}function Qe(e){const t=document.createDocumentFragment(),o=Ye(e.hasShell?"tbw-grid-root has-shell":"tbw-grid-root");if(e.hasShell&&e.shellHeader&&e.shellBody)o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=Ye("tbw-grid-content");e.appendChild(Ze()),o.appendChild(e)}return t.appendChild(o),t}function Je(e){return e?"string"==typeof e?e:e.outerHTML:""}function et(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function tt(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const i=o.querySelectorAll("tbw-grid-header-content");i.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(i)),o.style.display="none"}function ot(e,t,o){const i=e.querySelector(":scope > tbw-grid-tool-buttons");if(!i)return;t.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:e=>{for(;i.firstChild;)e.appendChild(i.firstChild);return()=>{for(;e.firstChild;)i.appendChild(e.firstChild)}}};t.toolbarContents.set(n,r),t.lightDomToolbarContentIds.add(n),i.style.display="none"}function it(e,t,o){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const i=e,n=i.getAttribute("id"),r=i.getAttribute("title");if(!n||!r)return void _("TBW070",`Tool panel missing required id or title attribute: id="${n??""}", title="${r??""}"`);const s=i.getAttribute("icon")??void 0,l=i.getAttribute("tooltip")??void 0,a=parseInt(i.getAttribute("order")??"100",10);let c;const d=o?.(i);if(d)c=d;else{const e=i.innerHTML.trim();c=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const h=t.toolPanels.get(n);if(h){if(d){h.render=c,h.order=a,h.icon=s,h.tooltip=l;const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n))}return}const u={id:n,title:r,icon:s,tooltip:l,order:a,render:c};t.toolPanels.set(n,u),t.lightDomToolPanelIds.add(n),i.style.display="none"})}function nt(e,t,o){const i=t?.header?.toolbarContents??[],n=[...o.toolbarContents.values()],r=new Set(i.map(e=>e.id)),s=[...i];for(const l of n)r.has(l.id)||s.push(l);for(const l of s){if(o.toolbarContentCleanups.has(l.id))continue;if(!l.render)continue;const t=e.querySelector(`[data-toolbar-content="${l.id}"]`);if(!t)continue;const i=l.render(t);i&&o.toolbarContentCleanups.set(l.id,i)}}function rt(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,i=t.headerContents.size>0;if(!o&&!i)return;const n=e.querySelector(".tbw-shell-content");if(!n)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",n.appendChild(e);t.lightDomContentMoved=!0}const r=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of r){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let o=n.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),n.appendChild(o));const i=s.render(o);i&&t.headerContentCleanups.set(s.id,i)}}function st(e,t,o){if(t.isPanelOpen)for(const[i,n]of t.toolPanels){const o=t.expandedSections.has(i),r=e.querySelector(`[data-section="${i}"]`),s=r?.querySelector(".tbw-accordion-content");if(!r||!s)continue;r.classList.toggle("expanded",o);const l=r.querySelector(".tbw-accordion-header");if(l&&l.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=n.render(s);e&&t.panelCleanups.set(i,e)}}else{const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i)),s.innerHTML=""}}}function lt(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function at(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}function ct(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear(),e.lightDomContentMoved=!1}function dt(e,t,o){const i=e.querySelector(`[data-section="${t}"]`);i&&i.classList.toggle("expanded",o)}function ht(e,t,o,i){const r=et(t),s=[],l=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const n of l){e.querySelectorAll(`:scope > ${n}`).forEach(e=>s.push(e))}e.replaceChildren();for(const n of s)e.appendChild(n);if(r){const r=Je(i?.toolPanel??n.toolPanel),s=Je(i?.expand??n.expand);Je(i?.collapse??n.collapse);const l=[...t?.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),a=[...t?.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100)),c={title:t?.header?.title??void 0,hasPanels:a.length>0,isPanelOpen:o.isPanelOpen,toolPanelIcon:r,configButtons:l.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},d={position:t?.toolPanel?.position??"right",isPanelOpen:o.isPanelOpen,expandIcon:s,panels:a.map(e=>({id:e.id,title:e.title,icon:Je(e.icon),isExpanded:o.expandedSections.has(e.id)}))},h=Qe({hasShell:!0,shellHeader:function(e){const t=Ye("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=Ye("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=Ye("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const i=Ye("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const n of e.configButtons)n.hasRender&&i.appendChild(Ye("tbw-toolbar-content-slot",{"data-toolbar-content":n.id}));for(const n of e.apiButtons)n.hasRender&&i.appendChild(Ye("tbw-toolbar-content-slot",{"data-toolbar-content":n.id}));if((e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender))&&e.hasPanels&&i.appendChild(Ye("tbw-toolbar-separator")),e.hasPanels){const t=je(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.innerHTML=e.toolPanelIcon,i.appendChild(t)}return t.appendChild(i),t}(c),shellBody:function(e){const t=Ye("tbw-shell-body"),o=e.panels.length>0,i=1===e.panels.length,n=Ye("tbw-grid-content");n.appendChild(Ze());let r=null;if(o){r=Xe("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel"});const t="left"===e.position?"right":"left";r.appendChild(Ye("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":t,"aria-hidden":"true"}));const o=Ye("tbw-tool-panel-content",{role:"presentation"}),n=Ye("tbw-accordion");for(const r of e.panels){const t=Ye(`tbw-accordion-section${r.isExpanded?" expanded":""}${i?" single":""}`,{"data-section":r.id}),o=je("tbw-accordion-header",{"aria-expanded":String(r.isExpanded),"aria-controls":`tbw-section-${r.id}`});if(i&&o.setAttribute("aria-disabled","true"),r.icon){const e=Xe("span",{class:"tbw-accordion-icon"});e.innerHTML=r.icon,o.appendChild(e)}const s=Xe("span",{class:"tbw-accordion-title"});if(s.textContent=r.title,o.appendChild(s),!i){const t=Xe("span",{class:"tbw-accordion-chevron"});t.innerHTML=e.expandIcon,o.appendChild(t)}t.appendChild(o),t.appendChild(Ye("tbw-accordion-content",{id:`tbw-section-${r.id}`,role:"presentation"})),n.appendChild(t)}o.appendChild(n),r.appendChild(o)}return"left"===e.position&&r?(t.appendChild(r),t.appendChild(n)):(t.appendChild(n),r&&t.appendChild(r)),t}(d)});e.appendChild(h)}else{const t=Qe({hasShell:!1});e.appendChild(t)}return r}Ke.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n <div class="tbw-sr-only" aria-live="polite" aria-atomic="true"></div>\n';const ut="tbw-grid-styles";let gt="";const ft=/* @__PURE__ */new Map;function pt(){const e=function(){let e=document.getElementById(ut);return e||(e=document.createElement("style"),e.id=ut,e.setAttribute("data-tbw-grid","true"),document.head.appendChild(e)),e}(),t=Array.from(ft.values()).join("\n");e.textContent=`${gt}\n\n/* Plugin Styles */\n${t}`}async function wt(e){if(gt)return;if("string"==typeof e&&e.length>0)return gt=e,void pt();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){_("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(gt=t,pt()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||_("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 bt(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function mt(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function vt(e,t){(Math.abs(e.velocityY)>.1||Math.abs(e.velocityX)>.1)&&function(e,t){const o=.95,i=.01,n=()=>{e.velocityY*=o,e.velocityX*=o;const r=16*e.velocityY,s=16*e.velocityX;Math.abs(e.velocityY)>i&&(t.fauxScrollbar.scrollTop+=r),Math.abs(e.velocityX)>i&&t.scrollArea&&(t.scrollArea.scrollLeft+=s),Math.abs(e.velocityY)>i||Math.abs(e.velocityX)>i?e.momentumRaf=requestAnimationFrame(n):e.momentumRaf=0};e.momentumRaf=requestAnimationFrame(n)}(e,t),bt(e)}function Ct(e,t,o,i){e.addEventListener("pointerdown",o=>{"touch"===o.pointerType&&null===t.activePointerId&&(t.activePointerId=o.pointerId,e.setPointerCapture(o.pointerId),function(e,t,o){mt(o),o.startY=t,o.startX=e,o.lastY=t,o.lastX=e,o.lastTime=performance.now(),o.velocityY=0,o.velocityX=0,o.locked=!1}(o.clientX,o.clientY,t))},{passive:!0,signal:i}),e.addEventListener("pointermove",e=>{if(e.pointerId!==t.activePointerId)return;const i=function(e,t,o,i){if(null===o.lastY||null===o.lastX)return!1;const n=performance.now(),r=o.lastY-t,s=o.lastX-e;if(null!==o.lastTime){const e=n-o.lastTime;e>0&&(o.velocityY=r/e,o.velocityX=s/e)}if(o.lastY=t,o.lastX=e,o.lastTime=n,o.locked)return i.fauxScrollbar.scrollTop+=r,i.scrollArea&&(i.scrollArea.scrollLeft+=s),!0;const l=null!==o.startY?Math.abs(o.startY-t):0,a=null!==o.startX?Math.abs(o.startX-e):0;if(l<3&&a<3)return!1;const c=l>=a,{scrollHeight:d,clientHeight:h}=i.fauxScrollbar,u=d-h>0;let g=!1;if(i.scrollArea){const{scrollWidth:e,clientWidth:t}=i.scrollArea;g=e-t>0}return!!(c&&u||!c&&g)&&(o.locked=!0,i.fauxScrollbar.scrollTop+=r,i.scrollArea&&(i.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,o);i&&e.preventDefault()},{passive:!1,signal:i}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,vt(t,o))},{passive:!0,signal:i}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,bt(t))},{passive:!0,signal:i}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,bt(t))},{passive:!0,signal:i})}const yt=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',isUsed:e=>!0===e||"function"==typeof e},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property'},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property'},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property'},{property:"pinned",pluginName:"pinnedColumns",level:"column",description:'the "pinned" column property',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property (deprecated, use "pinned")',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e}],_t=[{property:"rowEditable",pluginName:"editing",level:"config",description:'the "rowEditable" config property',isUsed:e=>"function"==typeof e},{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',isUsed:e=>Array.isArray(e)&&e.length>0}];function Rt(e){return`import { ${St(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function St(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Et(e,t){return e.some(e=>e.name===t)}function xt(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 At(e,t,o){const i=xt(t,o);return"string"==typeof i?e.byKey.get(i):i&&"object"==typeof i?e.byRef.get(i):void 0}function Tt(e,t,o){if(t<0||t>=e.length)return;const i=e[t],n=o-i.height;if(0!==n){i.height=o,i.measured=!0;for(let o=t+1;o<e.length;o++)e[o].offset+=n}}function Ht(e,t){if(0===e.length)return-1;if(t<=0)return 0;let o=0,i=e.length-1;for(;o<=i;){const n=Math.floor((o+i)/2),r=e[n],s=r.offset+r.height;if(t<r.offset)i=n-1;else{if(!(t>=s))return n;o=n+1}}return Math.max(0,Math.min(o,e.length-1))}function Pt(e,t){const{positionCache:o,heightCache:i,rows:n,start:r,end:s,getPluginHeight:l,getRowId:a}=e;let c=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const d=parseInt(t,10);if(d<r||d>=s||d>=n.length)return;const h=n[d],u=l?.(h,d);if(void 0!==u){const e=o[d];return void((!e.measured||Math.abs(e.height-u)>1)&&(Tt(o,d,u),c=!0))}const g=e.offsetHeight;if(g>0){const e=o[d];(!e.measured||Math.abs(e.height-g)>1)&&(Tt(o,d,g),function(e,t,o,i){const n=xt(t,i);"string"==typeof n?e.byKey.set(n,o):n&&"object"==typeof n&&e.byRef.set(n,o)}(i,h,g,a),c=!0)}});const d=c?function(e){let t=0;for(const o of e)o.measured&&t++;return t}(o):0,h=c?function(e,t){let o=0,i=0;for(const n of e)n.measured&&(o+=n.height,i++);return i>0?o/i:t}(o,e.defaultHeight):0;return{hasChanges:c,measuredCount:d,averageHeight:h}}function Mt(e){const{totalRows:t,viewportHeight:o,scrollTop:i,rowHeight:n,overscan:r}=e,s=Math.ceil(o/n);let l=Math.floor(i/n)-r;l<0&&(l=0);let a=l+s+2*r;return a>t&&(a=t),a===t&&l>0&&(l=Math.max(0,a-s-2*r)),{start:l,end:a,offsetY:l*n,totalHeight:t*n}}function Lt(e,t){return e<=t}class Dt{#e;state;constructor(e,t){this.#e=e,this.state={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null,positionCache:null,heightCache:{byKey:/* @__PURE__ */new Map,byRef:/* @__PURE__ */new WeakMap},averageHeight:28,measuredCount:0,variableHeights:!1,cachedViewportHeight:0,cachedFauxHeight:0,cachedScrollAreaHeight:0,scrollAreaEl:null,...t}}updateCachedGeometry(){const e=this.state,t=e.container,o=e.viewportEl??t;o&&(e.cachedViewportHeight=o.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const i=e.scrollAreaEl;i&&(e.cachedScrollAreaHeight=i.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const o=this.state;let i,n,r;if(t){const e=o.container??this.#e._hostElement,t=o.viewportEl??e,s=o.scrollAreaEl;i=e?.clientHeight??0,n=t?.clientHeight??0,r=s?s.clientHeight:i,o.cachedFauxHeight=i,o.cachedViewportHeight=n,o.cachedScrollAreaHeight=r}else i=o.cachedFauxHeight,n=o.cachedViewportHeight,r=o.cachedScrollAreaHeight||i;const s=r-n,l=Math.max(0,i-r);let a,c=0;return o.variableHeights&&o.positionCache?a=function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(o.positionCache):(a=e*o.rowHeight,c=this.#e._getPluginExtraHeight()),a+s+c+l}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#e,o=t._rows,i=e.rowHeight||28,n=t.effectiveConfig?.rowHeight,r=t.effectiveConfig?.getRowId,s=r?e=>r(e):void 0;e.positionCache=function(e,t,o,i,n){const r=new Array(e.length);let s=0;for(let l=0;l<e.length;l++){const a=e[l];let c=n?.(a,l),d=void 0!==c;void 0===c&&(c=At(t,a,i.rowId),d=void 0!==c),void 0===c&&(c=o,d=!1),r[l]={offset:s,height:c,measured:d},s+=c}return r}(o,e.heightCache,i,{rowId:s},(e,o)=>{const i=t._getPluginRowHeight(e,o);if(void 0!==i)return i;if(n){const t=n(e,o);if(void 0!==t&&t>0)return t}});const l=function(e,t,o,i){let n=0,r=0;for(let s=0;s<e.length;s++){const o=e[s];if(o.measured){const e=i?.(t[s],s);void 0===e&&(r+=o.height,n++)}}return{measuredCount:n,averageHeight:n>0?r/n:o}}(e.positionCache,o,i,(e,o)=>t._getPluginRowHeight(e,o));e.measuredCount=l.measuredCount,l.measuredCount>0&&(e.averageHeight=l.averageHeight)}invalidateRowHeight(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#e._rows;if(e<0||e>=i.length)return;const n=i[e];let r=t;void 0===r&&(r=this.#e._getPluginRowHeight(n,e)),void 0===r&&(r=o.rowHeight);const s=o.positionCache[e];if(s&&!(Math.abs(s.height-r)<1)&&(Tt(o.positionCache,e,r),o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(i.length);o.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#e,n=i._bodyEl;if(!n)return;const r=n.querySelectorAll(".data-grid-row"),s=i.effectiveConfig?.getRowId,l=i._rows,a=Pt({positionCache:o.positionCache,heightCache:o.heightCache,rows:l,defaultHeight:o.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>i._getPluginRowHeight(e,t),getRowId:s?e=>s(e):void 0},r);if(a.hasChanges&&(o.measuredCount=a.measuredCount,o.averageHeight=a.averageHeight,o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(l.length);o.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){const o=this.state,i=this.#e,n=i._bodyEl;if(!n)return!1;const r=i._rows.length;if(!o.enabled)return i._renderVisibleRows(0,r),t||i._afterPluginRender(),!0;if(r<=o.bypassThreshold)return o.start=0,o.end=r,e&&(n.style.transform="translateY(0px)"),i._renderVisibleRows(0,r,i.__rowRenderEpoch),e&&o.totalHeightEl&&(o.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(r,!0)}px`),i._updateAriaCounts(r,i._visibleColumns.length),t||i._afterPluginRender(),!0;const s=o.container,l=o.viewportEl??s,a=e?o.cachedViewportHeight=l.clientHeight:o.cachedViewportHeight||(o.cachedViewportHeight=l.clientHeight),c=o.rowHeight,d=s.scrollTop;let h;e&&o.variableHeights&&this.initializePositionCache();const u=o.positionCache;if(o.variableHeights&&u&&u.length>0)h=Ht(u,d),-1===h&&(h=0);else{h=Math.floor(d/c);let e=0;const t=10;for(;e<t;){const t=i._getPluginExtraHeightBefore(h),o=Math.floor((d-t)/c);if(o>=h||o<0)break;h=o,e++}}h-=h%2,h<0&&(h=0);const g=i._adjustPluginVirtualStart(h,d,c);let f;if(void 0!==g&&g<h&&(h=g,h-=h%2,h<0&&(h=0)),o.variableHeights&&u&&u.length>0){const e=a+3*c;let t=0;for(f=h;f<r&&t<e;)t+=u[f].height,f++;const o=Math.ceil(a/c)+3;f-h<o&&(f=Math.min(h+o,r))}else{f=h+(Math.ceil(a/c)+3)}f>r&&(f=r);const p=o.start,w=o.end;if(!e&&h===p&&f===w)return!1;o.start=h,o.end=f;const b=e?o.cachedFauxHeight=s.clientHeight:o.cachedFauxHeight||(o.cachedFauxHeight=s.clientHeight);if(e){const e=o.scrollAreaEl;e&&(o.cachedScrollAreaHeight=e.clientHeight)}if(0===b&&a>0)return i._requestSchedulerPhase(ie.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&o.totalHeightEl){const e=this.calculateTotalSpacerHeight(r);o.totalHeightEl.style.height=`${e}px`}let m;if(o.variableHeights&&u&&u[h])m=u[h].offset;else{m=h*c+i._getPluginExtraHeightBefore(h)}const v=-(d-m);return n.style.transform=`translateY(${v}px)`,i._renderVisibleRows(h,f,i.__rowRenderEpoch),e&&o.variableHeights&&this.measureRenderedRowHeights(h,f),i._updateAriaCounts(r,i._visibleColumns.length),e&&!t&&(i._afterPluginRender(),queueMicrotask(()=>{if(!o.totalHeightEl)return;const e=this.calculateTotalSpacerHeight(r);0===o.cachedFauxHeight&&o.cachedViewportHeight>0||(o.totalHeightEl.style.height=`${e}px`)})),!0}}class Ot{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=/* @__PURE__ */new Map;cellRenderers=/* @__PURE__ */new Map;headerRenderers=/* @__PURE__ */new Map;cellEditors=/* @__PURE__ */new Map;_hasAfterCellRender=!1;_hasAfterRowRender=!1;eventListeners=/* @__PURE__ */new Map;queryHandlers=/* @__PURE__ */new Map;static deprecationWarned=/* @__PURE__ */new WeakSet;attachAll(e){for(const t of e)this.attach(t)}attach(e){if(function(e,t,o){const i=e.name,n=e.constructor.dependencies??[];for(const r of n){const e=r.name,n=r.required??!0,s=r.reason;if(!t.some(t=>t.name===e)){const t=s??`${St(i)}Plugin requires ${St(e)}Plugin`,r=Rt(e);n?y("TBW020",`Plugin dependency error:\n\n${t}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${St(i)}Plugin:\n ${r}\n plugins: [new ${St(e)}Plugin(), new ${St(i)}Plugin()]`,o):R("TBW021",`${St(i)}Plugin: Optional "${e}" plugin not found. Some features may be unavailable.`,o)}}}(e,this.plugins,this.grid.getAttribute("id")??void 0),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,o]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,o);if(e.headerRenderers)for(const[t,o]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,o);if(e.cellEditors)for(const[t,o]of Object.entries(e.cellEditors))this.cellEditors.set(t,o);this.registerQueryHandlers(e),this.warnDeprecatedHooks(e),e.attach(this.grid),this.#L();for(const t of this.plugins)t!==e&&t.onPluginAttached&&t.onPluginAttached(e.name,e)}registerQueryHandlers(e){const t=e.constructor.manifest;if(t?.queries)for(const o of t.queries){let t=this.queryHandlers.get(o.type);t||(t=/* @__PURE__ */new Set,this.queryHandlers.set(o.type,t)),t.add(e)}}warnDeprecatedHooks(e){const t=e.constructor;if(Ot.deprecationWarned.has(t))return;if(!se())return;const o="function"==typeof e.getExtraHeight||"function"==typeof e.getExtraHeightBefore,i="function"==typeof e.getRowHeight;o&&!i&&(Ot.deprecationWarned.add(t),_("TBW023",`"${e.name}" uses getExtraHeight() / getExtraHeightBefore() which are deprecated and will be removed in v2.0.\n → Migrate to getRowHeight(row, index) for better variable row height support.`,this.grid.getAttribute("id")??void 0))}unregisterQueryHandlers(e){for(const[t,o]of this.queryHandlers)o.delete(e),0===o.size&&this.queryHandlers.delete(t)}detachAll(){for(const e of this.plugins)for(const t of this.plugins)t!==e&&t.onPluginDetached&&t.onPluginDetached(e.name);for(let e=this.plugins.length-1;e>=0;e--){const t=this.plugins[e];this.unsubscribeAll(t),this.unregisterQueryHandlers(t),t.detach()}this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear(),this.eventListeners.clear(),this.queryHandlers.clear(),this._hasAfterCellRender=!1,this._hasAfterRowRender=!1}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(t=>t.name===e||t.aliases?.includes(e))}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getRegisteredPluginNames(){return this.plugins.map(e=>e.name)}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getPluginStyles(){return this.plugins.filter(e=>e.styles).map(e=>({name:e.name,styles:e.styles}))}processRows(e){let t=[...e];for(const o of this.plugins)o.processRows&&(t=o.processRows(t));return t}processColumns(e){let t=[...e];for(const o of this.plugins)o.processColumns&&(t=o.processColumns(t));return t}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.plugins)e.afterRender?.()}afterCellRender(e){for(const t of this.plugins)t.afterCellRender?.(e)}hasAfterCellRenderHook(){return this._hasAfterCellRender}afterRowRender(e){for(const t of this.plugins)t.afterRowRender?.(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#L(){this._hasAfterCellRender=this.plugins.some(e=>"function"==typeof e.afterCellRender),this._hasAfterRowRender=this.plugins.some(e=>"function"==typeof e.afterRowRender)}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const t of this.plugins)"function"==typeof t.getExtraHeight&&(e+=t.getExtraHeight());return e}hasExtraHeight(){for(const e of this.plugins)if("function"==typeof e.getExtraHeight&&e.getExtraHeight()>0)return!0;return!1}getExtraHeightBefore(e){let t=0;for(const o of this.plugins)"function"==typeof o.getExtraHeightBefore&&(t+=o.getExtraHeightBefore(e));return t}getRowHeight(e,t){for(const o of this.plugins)if("function"==typeof o.getRowHeight){const i=o.getRowHeight(e,t);if(void 0!==i)return i}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,o){let i=e;for(const n of this.plugins)if("function"==typeof n.adjustVirtualStart){const r=n.adjustVirtualStart(e,t,o);r<i&&(i=r)}return i}renderRow(e,t,o){for(const i of this.plugins)if(i.renderRow?.(e,t,o))return!0;return!1}queryPlugins(e){const t=[],o=this.queryHandlers.get(e.type);if(o&&o.size>0){for(const i of o){const o=i.handleQuery?.(e)??i.onPluginQuery?.(e);void 0!==o&&t.push(o)}return t}for(const i of this.plugins){const o=i.handleQuery?.(e)??i.onPluginQuery?.(e);void 0!==o&&t.push(o)}return t}subscribe(e,t,o){let i=this.eventListeners.get(t);i||(i=/* @__PURE__ */new Map,this.eventListeners.set(t,i)),i.set(e,o)}unsubscribe(e,t){const o=this.eventListeners.get(t);o&&(o.delete(e),0===o.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,o]of this.eventListeners)o.delete(e),0===o.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const o=this.eventListeners.get(e);if(o)for(const n of o.values())try{n(t)}catch(i){S("TBW024",`Error in plugin event handler for "${e}": ${i}`,this.grid.getAttribute("id")??void 0)}}onKeyDown(e){for(const t of this.plugins)if(t.onKeyDown?.(e))return!0;return!1}onCellClick(e){for(const t of this.plugins)if(t.onCellClick?.(e))return!0;return!1}onRowClick(e){for(const t of this.plugins)if(t.onRowClick?.(e))return!0;return!1}onHeaderClick(e){for(const t of this.plugins)if(t.onHeaderClick?.(e))return!0;return!1}onScroll(e){for(const t of this.plugins)t.onScroll?.(e)}onCellMouseDown(e){for(const t of this.plugins)if(t.onCellMouseDown?.(e))return!0;return!1}onCellMouseMove(e){for(const t of this.plugins)if(t.onCellMouseMove?.(e))return!0;return!1}onCellMouseUp(e){for(const t of this.plugins)if(t.onCellMouseUp?.(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let o=0,i=0,n=!1;for(const r of this.plugins){const s=r.getHorizontalScrollOffsets?.(e,t);s&&(o+=s.left,i+=s.right,s.skipScroll&&(n=!0))}return{left:o,right:i,skipScroll:n}}getToolPanels(){const e=[];for(const t of this.plugins){const o=t.getToolPanel?.();o&&e.push({plugin:t,panel:o})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const o=t.getHeaderContent?.();o&&e.push({plugin:t,content:o})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}}class kt extends HTMLElement{static tagName="tbw-grid";static version="1.26.0";static#D=0;static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode","loading"]}get#O(){return this}#k=!1;#i;#n;#z=[];get#p(){return this.#I?.effective??{}}#N=!1;#q=!1;#W={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#$;#F=0;#B=null;#U=!1;#V=!1;#G=0;#X;#Y={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#j;#K;#Z;#Q;#J={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#ee;#te;#oe;#ie;#ne;#re;get _pluginManager(){return this.#ee}#se=!1;#le;#ae;#y;#I;#ce=function(){return{toolPanels:/* @__PURE__ */new Map,headerContents:/* @__PURE__ */new Map,toolbarContents:/* @__PURE__ */new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:/* @__PURE__ */new Set,lightDomToolbarContentIds:/* @__PURE__ */new Set,apiToolPanelIds:/* @__PURE__ */new Set,apiHeaderContentIds:/* @__PURE__ */new Set,isPanelOpen:!1,expandedSections:/* @__PURE__ */new Set,headerContentCleanups:/* @__PURE__ */new Map,panelCleanups:/* @__PURE__ */new Map,toolbarContentCleanups:/* @__PURE__ */new Map,lightDomContentMoved:!1}}();#de;#he;#ue;#ge=!1;#fe=/* @__PURE__ */new Set;#pe=/* @__PURE__ */new Map;#we;#be=/* @__PURE__ */new Map;_rows=[];#me=[];get _columns(){return this.#p.columns??[]}set _columns(e){this.#p.columns=e,this.#ve=void 0}#ve;get _visibleColumns(){return this.#ve??=this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#ie.state}set _virtualization(e){Object.assign(this.#ie.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#I?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#I&&(this.#I.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#I?.originalColumnNodes}set __originalColumnNodes(e){this.#I&&(this.#I.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=this.#z;this.#z=e,t!==e&&this.#Ce("rows")}get sourceRows(){return this.#z}set sourceRows(e){this.#z=e}get columns(){return[...this._columns]}set columns(e){const t=this.#I?.getColumns();this.#I?.setColumns(e),t!==e&&this.#Ce("columns")}get gridConfig(){return this.#p}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#I?.getGridConfig();this.#I?.setGridConfig(e),t!==e&&(this.#I.clearLightDomCache(),this.#Ce("gridConfig"))}get fitMode(){return this.#p.fitMode??"stretch"}set fitMode(e){const t=this.#I?.getFitMode();this.#I?.setFitMode(e),t!==e&&this.#Ce("fitMode")}get loading(){return this.#ge}set loading(e){const t=this.#ge;this.#ge=e,e?this.setAttribute("loading",""):this.removeAttribute("loading"),t!==e&&this.#ye()}setRowLoading(e,t){const o=this.#fe.has(e);t?this.#fe.add(e):this.#fe.delete(e),o!==t&&this.#_e(e,t)}setCellLoading(e,t,o){let i=this.#pe.get(e);const n=i?.has(t)??!1;o?(i||(i=/* @__PURE__ */new Set,this.#pe.set(e,i)),i.add(t)):(i?.delete(t),0===i?.size&&this.#pe.delete(e)),n!==o&&this.#Re(e,t,o)}isRowLoading(e){return this.#fe.has(e)}isCellLoading(e,t){return this.#pe.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#fe)this.#_e(e,!1);this.#fe.clear();for(const[e,t]of this.#pe)for(const o of t)this.#Re(e,o,!1);this.#pe.clear()}get effectiveConfig(){return this.#p}get disconnectSignal(){return this.#j||(this.#j=new AbortController),this.#j.signal}constructor(){super(),this.#Se(),this.#i=new Promise(e=>this.#n=e),this.#ie=new Dt(this),this.#ne=new Oe(this),this.#re=new Ge(this),this.#$=new ne(this),this.#$.setInitialReadyResolver(()=>this.#n?.()),this.#de=function(e,t){let o=!1;const i={get isInitialized(){return o},setInitialized(e){o=e},get isPanelOpen(){return e.isPanelOpen},get activePanel(){return e.isPanelOpen&&e.expandedSections.size>0?[...e.expandedSections][0]:null},get expandedSections(){return[...e.expandedSections]},openToolPanel(){if(e.isPanelOpen)return;if(0===e.toolPanels.size)return void _("TBW071","No tool panels registered",t.id);if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0){const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}const o=t._renderRoot;lt(o,e),at(o,e),st(o,e,t._accordionIcons),t._emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolPanels.values())t.onClose?.();e.isPanelOpen=!1;const o=t._renderRoot;lt(o,e),at(o,e),t._emit("tool-panel-close",{})},toggleToolPanel(){e.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(o){const i=e.toolPanels.get(o);if(!i)return void _("TBW072",`Tool panel section "${o}" not found`,t.id);if(1===e.toolPanels.size)return;const n=t._renderRoot,r=e.expandedSections.has(o);if(r){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),i.onClose?.(),e.expandedSections.delete(o),dt(n,o,!1)}else{for(const[t,i]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),i.onClose?.(),e.expandedSections.delete(t),dt(n,t,!1);const r=n.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),dt(n,o,!0),function(e,t,o){const i=t.toolPanels.get(o);if(!i?.render)return;const n=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!n)return;const r=i.render(n);r&&t.panelCleanups.set(o,r)}(n,e,o)}t._emit("tool-panel-section-toggle",{id:o,expanded:!r})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(i){e.toolPanels.has(i.id)?_("TBW073",`Tool panel "${i.id}" already registered`,t.id):(e.toolPanels.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolPanel(i){if(e.expandedSections.has(i)){const t=e.panelCleanups.get(i);t&&(t(),e.panelCleanups.delete(i)),e.expandedSections.delete(i)}e.toolPanels.delete(i),o&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(i){e.headerContents.has(i.id)?_("TBW074",`Header content "${i.id}" already registered`,t.id):(e.headerContents.set(i.id,i),o&&rt(t._renderRoot,e))},unregisterHeaderContent(o){const i=e.headerContentCleanups.get(o);i&&(i(),e.headerContentCleanups.delete(o));const n=e.headerContents.get(o);n?.onDestroy?.(),e.headerContents.delete(o);const r=t._renderRoot.querySelector(`[data-header-content="${o}"]`);r?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(i){e.toolbarContents.has(i.id)?_("TBW075",`Toolbar content "${i.id}" already registered`,t.id):(e.toolbarContents.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolbarContent(i){const n=e.toolbarContentCleanups.get(i);n&&(n(),e.toolbarContentCleanups.delete(i));const r=e.toolbarContents.get(i);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(i),o&&t.refreshShellHeader?.()}};return i}(this.#ce,this),this.#I=new re(this)}async#Se(){await wt('@layer tbw-base, tbw-plugins, tbw-theme;\n\n@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #666666);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-v: var(--tbw-spacing-xs);--tbw-cell-padding-h: var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-cell-padding-v) var(--tbw-cell-padding-h);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-width: 1px;--tbw-border-style: solid;--tbw-border-input: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-strong);--tbw-border-header: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-header);--tbw-row-divider: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline-width: 2px;--tbw-focus-outline: var(--tbw-focus-outline-width) var(--tbw-border-style) var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-display: inline-flex;--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm)}}\n@layer tbw-base{tbw-grid{color-scheme:inherit;position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);font-feature-settings:"tnum","lnum";background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none;&,*{box-sizing:border-box}.tbw-grid-root{position:relative;display:flex;flex-direction:column;height:100%;&.has-shell{display:flex;flex-direction:column;height:100%}&:has(.selected){user-select:none}}.rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}.rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}.rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}.rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip;touch-action:none;.rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}}.faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30);touch-action:none}.faux-vscroll-spacer{width:1px}.tbw-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}&[data-has-focus]{.cell-focus,.row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}}.sticky-left,.sticky-right{position:sticky;z-index:25}.sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}.sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}}}\n@layer tbw-base{tbw-grid{.header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}.header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}.header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start));&:not(:last-child){border-right:2px solid var(--tbw-color-border)}}.header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30);text-transform:var(--tbw-header-text-transform);letter-spacing:var(--tbw-header-letter-spacing);>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:visible;min-width:0;>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;color:var(--tbw-sort-indicator-color);display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}&:hover>span[part~=sort-indicator]{display:inline-flex;visibility:visible}&[aria-sort=ascending]>span[part~=sort-indicator],&[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color)}&:last-child{border-right:0;.resize-handle{right:0;width:calc(var(--tbw-resize-handle-width) / 2)}}&.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}&.resizable{position:relative}&.sticky-left,&.sticky-right{background:var(--tbw-color-header-bg);z-index:35}}}.sortable{cursor:pointer;user-select:none}.resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius);&:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}&:hover{background:var(--tbw-resize-handle-color-hover);&:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}}}}}\n@layer tbw-base{tbw-grid{.data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style;&:nth-child(2n){background:var(--tbw-color-row-alt)}&:hover{background:var(--tbw-color-row-hover)}>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);align-content:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis;>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}&:last-child{border-right:0}&[data-type=boolean]{text-align:center;input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}}&.selected:focus-visible,&:focus-visible:not(.cell-focus){outline:none}&.sticky-left,&.sticky-right{background:var(--tbw-color-panel-bg)}}}.selecting .data-grid-row>.cell{user-select:none}}}\n@layer tbw-base{tbw-grid{.tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}.tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}.tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}.tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease);&:hover{background:var(--tbw-color-row-hover)}&:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}&.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}&:disabled{opacity:.5;cursor:not-allowed}}.tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}.tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}.tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden;touch-action:none}.tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}}}\n@layer tbw-base{tbw-grid{.tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:var(--tbw-z-layer-toolpanel, 31);box-shadow:-2px 0 8px var(--tbw-color-shadow);&[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}&.open{width:var(--tbw-tool-panel-width)}}.tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease);&[data-handle-position=left]{left:0}&[data-handle-position=right]{right:0}&:hover,&.resizing{background:var(--tbw-color-accent)}}.tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}.tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px;&:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}}.tbw-tool-panel-content{flex:1;overflow:auto}.tbw-accordion{display:flex;flex-direction:column;gap:0}.tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border);&:last-child{border-bottom:none}&.single .tbw-accordion-header{cursor:default;&:hover{background:transparent}}&.expanded{.tbw-accordion-chevron{transform:rotate(90deg)}.tbw-accordion-content{display:block}}}.tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;user-select:none;&:hover{background:var(--tbw-color-row-hover)}}.tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}.tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}.tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tbw-accordion-content{display:none}}}\n@layer tbw-base{.tbw-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:1000;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-spinner{--tbw-spinner-size: 48px;--tbw-spinner-border-width: 3px;--tbw-spinner-color: var(--tbw-color-accent);--tbw-spinner-track-color: var(--tbw-color-border);width:var(--tbw-spinner-size);height:var(--tbw-spinner-size);border:var(--tbw-spinner-border-width) solid var(--tbw-spinner-track-color);border-top-color:var(--tbw-spinner-color);border-radius:50%;animation:tbw-spin .8s linear infinite}.tbw-spinner--large{--tbw-spinner-size: min(48px, calc(100% - 16px) )}.tbw-spinner--small{--tbw-spinner-size: calc(var(--tbw-row-height, 28px) * .6);--tbw-spinner-border-width: 2px}.data-grid-row.tbw-row-loading{position:relative;pointer-events:none}.tbw-row-loading-overlay{position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out;pointer-events:none;display:flex;align-items:center}.tbw-row-loading-spinner{--_spinner-size: calc(var(--tbw-row-height, 28px) * .6);margin-left:var(--tbw-spacing-md);width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite}.cell.tbw-cell-loading{position:relative;pointer-events:none;&:before{content:"";position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out}&:after{--_spinner-size: calc(var(--tbw-row-height, 28px) * .5);content:"";position:absolute;left:var(--tbw-spacing-sm);top:0;bottom:0;margin:auto 0;width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite;z-index:27}}}\n@layer tbw-base{tbw-grid{.tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}.tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}&[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}tbw-grid .data-grid-row[data-animating=change]{animation:tbw-row-change var(--tbw-row-change-duration) ease-out}tbw-grid .data-grid-row[data-animating=insert]{animation:tbw-row-insert var(--tbw-row-insert-duration) ease-out;will-change:max-height,opacity}tbw-grid .data-grid-row[data-animating=remove]{animation:tbw-row-remove var(--tbw-row-remove-duration) ease-out forwards;will-change:max-height,opacity,transform;pointer-events:none}}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-row-change{0%{background-color:transparent}20%{background-color:var(--tbw-row-change-color)}to{background-color:transparent}}@keyframes tbw-row-insert{0%{opacity:0;max-height:0;overflow:hidden}to{opacity:1;max-height:var(--tbw-row-height, 28px);overflow:hidden}}@keyframes tbw-row-remove{0%{opacity:1;transform:translateY(0);max-height:var(--tbw-row-height, 28px)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-spin{to{transform:rotate(360deg)}}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}\n@layer tbw-base{@media(forced-colors:active){tbw-grid{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight;.cell:focus,.cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}.data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}}\n')}getPlugin(e){return this.#ee?.getPlugin(e)}getPluginByName(e){return this.#ee?.getPluginByName(e)}requestRender(){this.#$.requestPhase(ie.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#$.requestPhase(ie.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#$.requestPhase(ie.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){P(this)}requestAfterRender(){this.#$.requestPhase(ie.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this._virtualization.start=-1,this.refreshVirtualWindow(!1)}#Ee(){this.#ee=new Ot(this);const e=this.#p?.plugins,t=Array.isArray(e)?e:[],o=this.#p?.features;let i=[];o&&Le&&(i=Le(o));const n=i.length>0?[...i,...t]:t;this.#ee.attachAll(n)}#xe(){!function(e){let t=!1;for(const{name:o,styles:i}of e)ft.has(o)||(ft.set(o,i),t=!0);t&&pt()}(this.#ee?.getPluginStyles()??[])}#Ae(){const e=this.#p?.plugins,t=Array.isArray(e)?e:[],o=this.#p?.features??void 0,i=o!==this.#oe;if((this.#te===t||void 0!==this.#te&&this.#te.length===t.length&&this.#te.every((e,o)=>e===t[o]))&&!i)return void(this.#te=t);this.#ee&&this.#ee.detachAll();for(const r of this.#ce.toolPanels.keys()){const e=this.#ce.lightDomToolPanelIds.has(r),t=this.#ce.apiToolPanelIds.has(r);if(!e&&!t){const e=this.#ce.panelCleanups.get(r);e&&(e(),this.#ce.panelCleanups.delete(r)),this.#ce.toolPanels.delete(r)}}for(const r of this.#ce.headerContents.keys()){if(this.#ce.apiHeaderContentIds.has(r))continue;const e=this.#ce.headerContentCleanups.get(r);e&&(e(),this.#ce.headerContentCleanups.delete(r)),this.#ce.headerContents.delete(r)}this.#Ee(),this.#xe(),this.#te=t,this.#oe=o,this.#Te(),this.#He();const n=this.#U;if(this.#U=this.#ee?.getAll().some(e=>e.onScroll)??!1,!n&&this.#U){const e=this.#O.querySelector(".tbw-grid-content")??this.#O.querySelector(".tbw-grid-root");this.#Pe(e)}}#Me(){this.#ee?.detachAll()}#He(){if(!this.#ee)return;const e=this.#ee.getToolPanels();for(const{panel:o}of e)this.#ce.toolPanels.has(o.id)||this.#ce.toolPanels.set(o.id,o);const t=this.#ee.getHeaderContents();for(const{content:o}of t)this.#ce.headerContents.has(o.id)||this.#ce.headerContents.set(o.id,o)}#Le(){const e=kt.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return o=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",kt.version),this.id||(this.id="tbw-grid-"+ ++kt.#D),this._rows=Array.isArray(this.#z)?[...this.#z]:[],this.#j&&(this.#j.abort(),this.#se=!1),this.#j=new AbortController,this.#Q&&(ze(this.#Q),this.#Q=void 0),this.#De(),this.#I.parseLightDomColumns(this),this.#I.merge(),this.#Ee();const e=this.#p?.plugins;var t,o;this.#te=Array.isArray(e)?e:[],this.#oe=this.#p?.features??void 0,this.#He(),this.#k||(this.#Oe(),this.#xe(),this.#k=!0),this.#ke(),this.#Q=(t=()=>{this.#ze()},o={timeout:100},ke?requestIdleCallback(t,o):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#Q&&(ze(this.#Q),this.#Q=void 0),this.#G&&(clearTimeout(this.#G),this.#G=0),this.#Me(),function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const o=e.toolPanels.get(t);o?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#ce),this.#de.setInitialized(!1),this.#he?.(),this.#he=void 0,this.#ue?.(),this.#ue=void 0,mt(this.#Y),this.#j&&(this.#j.abort(),this.#j=void 0),this.#le?.abort(),this.#le=void 0,this.#se=!1,this._resizeController&&this._resizeController.dispose(),this.#K&&(this.#K.disconnect(),this.#K=void 0),this.#Z&&(this.#Z.disconnect(),this.#Z=void 0,this.#Ie=!1),Re(this),this.#Ne.clear(),this._virtualization.heightCache?.byKey.clear(),this.#te=void 0,this.#oe=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#N=!1}attributeChangedCallback(e,t,o){if("loading"===e){const e=null!==o&&"false"!==o;return void(this.loading!==e&&(this.loading=e))}if(t!==o&&o&&"null"!==o&&"undefined"!==o)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(o);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{_("TBW130",`Invalid JSON for '${e}' attribute: ${o}`,this.id)}else"fit-mode"===e&&(this.fitMode=o)}#ke(){const e=this.#O.querySelector(".tbw-grid-content")??this.#O.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.#de.isInitialized){rt(this.#O,this.#ce),nt(this.#O,this.#p?.shell,this.#ce);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#ce.toolPanels.has(e)&&(this.openToolPanel(),this.#ce.expandedSections.add(e)),this.#ce.isPanelOpen&&(at(this.#O,this.#ce),st(this.#O,this.#ce,(this.#p,this.#p)),lt(this.#O,this.#ce))}if(this.setAttribute("data-upgraded",""),this.#N=!0,this._resizeController=Ne(this),this.#qe(),this.#Pe(e),this.#se)return;this.#se=!0;const t=this.disconnectSignal;Me(this,this,this.#O,t),this.#Te(),queueMicrotask(()=>this.#We()),this.#$.requestPhase(ie.FULL,"afterConnect")}#Te(){const e=this.#p.rowHeight,t=this.#ee.hasRowHeightPlugin();"function"==typeof e||t?this._virtualization.variableHeights||(this._virtualization.variableHeights=!0,this._virtualization.rowHeight="number"==typeof e&&e>0?e:this._virtualization.rowHeight||28,this.#ie.initializePositionCache(),"function"!=typeof e&&(this.#V=!0)):!t&&"function"!=typeof e&&this._virtualization.variableHeights?(this._virtualization.variableHeights=!1,this._virtualization.positionCache=null):"number"==typeof e&&e>0?(this._virtualization.rowHeight=e,this._virtualization.variableHeights=!1):requestAnimationFrame(()=>this.#$e())}#$e(){if(this.#ee.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let o=0;t.forEach(e=>{const t=e.offsetHeight;t>o&&(o=t)});const i=e.getBoundingClientRect(),n=Math.max(i.height,o);n>0&&n-this._virtualization.rowHeight>1&&(this._virtualization.rowHeight=n,this.#$.requestPhase(ie.VIRTUALIZATION,"measureRowHeight"))}#Fe(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let o=0;t.forEach(e=>{const t=e.offsetHeight;t>o&&(o=t)});const i=e.getBoundingClientRect(),n=Math.max(i.height,o);if(n>0){if(Math.abs(n-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=n),this.#ie.initializePositionCache(),this._virtualization.totalHeightEl){const e=this.#ie.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#Pe(e){this.#le?.abort(),this.#le=new AbortController;const t=this.#le.signal,o=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=o??this,this.#U=this.#ee?.getAll().some(e=>e.onScroll)??!1,o&&i){o.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#U)return;const e=o.scrollTop,t=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)i.style.transform=`translateY(${-e}px)`;else{const o=this._virtualization.positionCache;let n,r;if(this._virtualization.variableHeights&&o&&o.length>0){n=Ht(o,e),-1===n&&(n=0);const i=n-n%2;r=o[i]?.offset??i*t}else{n=Math.floor(e/t);r=(n-n%2)*t}const s=-(e-r);i.style.transform=`translateY(${s}px)`}this.#B=e,this.#F||(this.#F=requestAnimationFrame(()=>{this.#F=0,null!==this.#B&&(this.#Be(this.#B),this.#B=null)}))},{passive:!0,signal:t});const e=this.#O.querySelector(".tbw-scroll-area");this.#ae=e,this._virtualization.scrollAreaEl=e,e&&this.#U&&e.addEventListener("scroll",()=>{const t=this.#J;t.scrollTop=o.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=o.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=o.clientHeight,t.clientWidth=e.clientWidth,this.#ee?.onScroll(t)},{passive:!0,signal:t});const n=this.#O.querySelector(".tbw-grid-content"),r=this.#ae;n&&(n.addEventListener("wheel",e=>{const t=e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY);if(t&&r){const t=e.shiftKey?e.deltaY:e.deltaX,{scrollLeft:o,scrollWidth:i,clientWidth:n}=r;(t>0&&o<i-n||t<0&&o>0)&&(e.preventDefault(),r.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:i,clientHeight:n}=o;(e.deltaY>0&&t<i-n||e.deltaY<0&&t>0)&&(e.preventDefault(),o.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),Ct(n,this.#Y,{fauxScrollbar:o,scrollArea:r},t))}var n,r,s;this._bodyEl&&(n=this,r=this._bodyEl,s=t,r.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");if(!t)return;if(t.classList.contains("editing"))return;const o=e.target;o.draggable||o.closest('[draggable="true"]')||e.preventDefault(),He(n,t)},{signal:s}),r.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&xe(n,e,t),!document.activeElement?.closest(".cell.editing")){const t=e.target.closest("tbw-grid");t&&t.focus({preventScroll:!0})}},{signal:s}),r.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&xe(n,e,t)},{signal:s})),this.#K?.disconnect(),this._virtualization.viewportEl&&(this.#K=new ResizeObserver(()=>{this.#Ue(),this.#$.requestPhase(ie.VIRTUALIZATION,"resize-observer")}),this.#K.observe(this._virtualization.viewportEl)),this.#O.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#O.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#O.contains(t)||this.#ne.isInExternalFocusContainer(t))||delete this.dataset.hasFocus},{signal:t})}#Ie=!1;#Ve(){if(this.#Ie)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#Ie=!0,this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#$e()}),this.#Z.observe(e))}addEventListener(e,t,o){super.addEventListener(e,t,o)}removeEventListener(e,t,o){super.removeEventListener(e,t,o)}on(e,t){const o=e=>{t(e.detail,e)};return this.addEventListener(e,o),()=>this.removeEventListener(e,o)}#Ge(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#Ge("data-change",{rowCount:this._rows.length,sourceRowCount:this.#z.length})}#We(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const o=t===this._focusRow;e.setAttribute("aria-selected",String(o)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(o&&t===this._focusCol))})})}#Ce(e){this.#W[e]=!0,this.#q||(this.#q=!0,queueMicrotask(()=>this.#Xe()))}#Xe(){if(!this.#q||!this.#N)return void(this.#q=!1);const e=this.#W;if(this.#q=!1,this.#W={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig)return this.#Ye(),void(e.rows&&this.#je());e.columns&&this.#Ke(),e.rows&&this.#je(),e.fitMode&&this.#Ze()}#je(){this._rows=Array.isArray(this.#z)?[...this.#z]:[],this._rebuildRowIdMap(),this.#$.requestPhase(ie.ROWS,"applyRowsUpdate")}_rebuildRowIdMap(){this.#be.clear();const e=this.#p.getRowId;this._rows.forEach((t,o)=>{const i=Ue(t,e);void 0!==i&&this.#be.set(i,{row:t,index:o})})}#Ke(){Re(this),this.#I.merge(),this.#qe()}#Ze(){this.#I.merge();"fixed"===this.#p.fitMode?(this.__didInitialAutoSize=!1,A(this)):(this._columns.forEach(e=>{!e.__userResized&&e.__autoSized&&delete e.width}),P(this))}#Ye(){tt(this,this.#ce),ot(this,this.#ce);const e=!!this.#O.querySelector(".has-shell"),t=!!this.#O.querySelector(".tbw-tool-panel"),o=this.#O.querySelectorAll(".tbw-accordion-section").length,i=this.#O.querySelector(".tbw-tool-panel")?.dataset.position??"right";this.#I.parseLightDomColumns(this),this.#I.merge(),this.#Ae(),it(this,this.#ce,this.#Le()),this.#I.markSourcesChanged(),this.#I.merge();const n=et(this.#p?.shell),r=(this.#p?.shell?.toolPanels?.length??0)>0,s=this.#p?.shell?.toolPanels?.length??0,l=this.#p?.shell?.toolPanel?.position??"right";if(e!==n||!t&&r||t&&s!==o||t&&i!==l)return ct(this.#ce),this.#Oe(),this.#xe(),this.#ke(),void this._rebuildRowIdMap();e&&this.#Qe(),this._rebuildRowIdMap(),this.#$.requestPhase(ie.COLUMNS,"applyGridConfigUpdate")}#Qe(){const e=this.#O.querySelector(".tbw-shell-header");if(!e)return;const t=this.#p.shell?.header?.title??this.#ce.lightDomTitle;let o=e.querySelector(".tbw-shell-title");t?(o||(o=document.createElement("h2"),o.className="tbw-shell-title",o.setAttribute("part","shell-title"),e.insertBefore(o,e.firstChild)),o.textContent=t):o&&o.remove()}#Je(){if(this.__rowRenderEpoch++,this.#ee){const e=this.#me.length>0?this.#me:this._columns,t=e.filter(e=>!e.hidden),o=e.filter(e=>e.hidden),i=this.#ee.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,...o]:this._columns=this.#et(e,i,o)}else this._columns=[...e]}}#et(e,t,o){if(0===o.length)return t;const i=/* @__PURE__ */new Map;for(const l of t)i.set(l.field,l);const n=new Set(e.map(e=>e.field)),r=[];for(const l of t)n.has(l.field)||r.push(l);const s=[];for(const l of e){const e=i.get(l.field);e?s.push(e):l.hidden&&s.push(l)}return s.push(...r),s}#tt(){Re(this);const e=function(e,t){if(!e._sortState)return t;e.__originalOrder=[...t];const o=(e.effectiveConfig?.sortHandler??V)(t,e._sortState,e._columns);return o&&"function"==typeof o.then?t:o}(this,Array.isArray(this.#z)?[...this.#z]:[]),t=this.#ee?.processRows(e)??e;this._rows=t,this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#ie.initializePositionCache(),this._emitDataChange()}#ot(e){const t={...o,...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}_renderVisibleRows(e,t,o=this.__rowRenderEpoch){if(this.#X||(this.#X=(e,t,o)=>this.#ee?.renderRow(e,t,o)??!1),function(e,t,o,i,n){const r=Math.max(0,o-t),s=e._bodyEl,l=e._visibleColumns,a=l.length;let c=e.__cachedHeaderRowCount;for(void 0===c&&(c=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=c);e._rowPool.length<r;){const t=_e();e._rowPool.push(t)}if(e._rowPool.length>r){for(let t=r;t<e._rowPool.length;t++){const o=e._rowPool[t];o.parentNode===s&&o.remove()}e._rowPool.length=r}const d=n&&!1!==e.__hasRenderRowPlugins,h=e._hasAfterRowRenderHook?.()??!1;for(let g=0;g<r;g++){const o=t+g,r=e._rows[o],f=e._rowPool[g];if(f.setAttribute("aria-rowindex",String(o+c+1)),d&&n(r,f,o)){f.__epoch=i,f.__rowDataRef=r,f.parentNode!==s&&s.appendChild(f);continue}const p=f.__epoch,w=f.__rowDataRef;let b=f.children.length;b>a&&f.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&b--;const m=p===i&&b===a,v=w!==r,C=!!e._isGridEditMode;let y=!1;if(m&&v)for(let e=0;e<a;e++)if(l[e].externalView&&!f.querySelector(`.cell[data-col="${e}"] [data-external-view]`)){y=!0;break}if(!m||y){const t=be(f),n=C||e._activeEditRows===o;t&&!n?(f.__isCustomRow&&(f.className="data-grid-row",f.setAttribute("role","row"),f.__isCustomRow=!1),me(f),Ee(e,f,r,o),f.__epoch=i,f.__rowDataRef=r):t&&n?(Se(e,f,r,o),f.__rowDataRef=r):(f.__isCustomRow&&(f.className="data-grid-row",f.setAttribute("role","row"),f.__isCustomRow=!1),Ee(e,f,r,o),f.__epoch=i,f.__rowDataRef=r)}else if(v){const t=be(f),n=C||e._activeEditRows===o;t&&!n?(me(f),Ee(e,f,r,o),f.__epoch=i,f.__rowDataRef=r):(Se(e,f,r,o),f.__rowDataRef=r)}else{const t=be(f),n=C||e._activeEditRows===o;t&&!n?(me(f),Ee(e,f,r,o),f.__epoch=i,f.__rowDataRef=r):Se(e,f,r,o)}let R=!1;const S=e._changedRowIdSet;if(S&&S.size>0)try{const t=e.getRowId?.(r);t&&(R=S.has(t))}catch{}R!==f.classList.contains("changed")&&f.classList.toggle("changed",R);const E=e.effectiveConfig?.rowClass;if(E){const t=f.getAttribute("data-dynamic-classes");t&&t.split(" ").forEach(e=>e&&f.classList.remove(e));try{const e=E(r),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const o of t)o&&"string"==typeof o&&(f.classList.add(o),e+=(e?" ":"")+o);f.setAttribute("data-dynamic-classes",e)}else f.removeAttribute("data-dynamic-classes")}catch(u){_("TBW060",`rowClass callback error: ${u}`,e.id),f.removeAttribute("data-dynamic-classes")}}h&&e._afterRowRender?.({row:r,rowIndex:o,rowElement:f}),f.parentNode!==s&&s.appendChild(f)}}(this,e,t,o,this.#X),this.#fe.size>0)for(const i of this.#fe)this.#_e(i,!0)}#it={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaDescribedBy:void 0};_updateAriaCounts(e,t){!function(e,t,o,i,n){if(i===e.rowCount&&n===e.colCount)return!1;const r=e.rowCount;e.rowCount=i,e.colCount=n,t&&(t.setAttribute("aria-rowcount",String(i)),t.setAttribute("aria-colcount",String(n))),i!==r&&o&&(i>0?o.setAttribute("role","rowgroup"):o.removeAttribute("role"))}(this.#it,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#$.requestPhase(e,t)}_getPluginExtraHeight(){return this.#ee?.getExtraHeight()??0}_getPluginRowHeight(e,t){return this.#ee?.getRowHeight?.(e,t)}_getPluginExtraHeightBefore(e){return this.#ee?.getExtraHeightBefore?.(e)??0}_adjustPluginVirtualStart(e,t,o){return this.#ee?.adjustVirtualStart(e,t,o)}_afterPluginRender(){this.#ee?.afterRender()}_emitPluginEvent(e,t){this.#ee?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#I.parseLightDomColumns(this),this.#I.merge(),this.#Ae(),function(e,t,o){const i=yt,n=_t,r=/* @__PURE__ */new Map;function s(e,t,o,i,n=!1){r.has(e)||r.set(e,{description:t,importHint:o,fields:[],isConfigProperty:n});const s=r.get(e);s.fields.includes(i)||s.fields.push(i)}for(const a of n){const o=e[a.property];(a.isUsed?a.isUsed(o):void 0!==o)&&!Et(t,a.pluginName)&&s(a.pluginName,a.description,Rt(a.pluginName),a.property,!0)}const l=e.columns;if(l&&l.length>0)for(const a of l)for(const e of i){const o=a[e.property];if((e.isUsed?e.isUsed(o):void 0!==o)&&!Et(t,e.pluginName)){const t=a.field||"<unknown>";s(e.pluginName,e.description,Rt(e.pluginName),t)}}if(r.size>0){const e=[];for(const[t,{description:o,importHint:i,fields:n,isConfigProperty:s}]of r)if(s)e.push(`Config uses ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${St(t)}Plugin(), ...]`);else{const r=n.slice(0,3).join(", ")+(n.length>3?`, ... (${n.length} total)`:"");e.push(`Column(s) [${r}] use ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${St(t)}Plugin(), ...]`)}y([...r.values()].some(e=>e.isConfigProperty)?"TBW002":"TBW001",`Configuration error:\n\n${e.join("\n\n")}\n\nThis validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`,o)}}(this.#p,this.#ee?.getPlugins()??[],this.id),function(e,t){const o=[],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=`[${St(n.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?o.push(e):i.push(e)}}}if(i.length>0&&se())for(const n of i)_("TBW004",n,t);o.length>0&&y("TBW003",`Configuration error:\n\n${o.join("\n\n")}`,t)}(this.#ee?.getPlugins()??[],this.id),function(e,t){if(!se())return;const o=new Set(e.map(e=>e.name)),i=/* @__PURE__ */new Set;for(const n of e){const e=n.constructor.manifest;if(e?.incompatibleWith)for(const r of e.incompatibleWith)if(o.has(r.name)){const e=[n.name,r.name].sort().join("↔");if(i.has(e))continue;i.add(e),_("TBW022",`${St(n.name)}Plugin and ${St(r.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${r.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`,t)}}}(this.#ee?.getPlugins()??[],this.id),this.#nt(),this.#me=[...this._columns]}_schedulerProcessColumns(){this.#Je()}_schedulerProcessRows(){this.#tt()}_schedulerRenderHeader(){ee(this)}_schedulerUpdateTemplate(){P(this)}_schedulerAfterRender(){this.#ee?.afterRender(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#ie.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`});"fixed"!==this.#p.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,A(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,Ae(this)),this._virtualization.enabled&&!this.#Ie&&this.#Ve(),this.#V&&(this.#V=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#Fe()})})),this.#ge&&this.#ye()}get _schedulerIsConnected(){return this.isConnected&&this.#N}get _hostElement(){return this}get _renderRoot(){return this.#O}_emit(e,t){this.#Ge(e,t)}get _accordionIcons(){return{expand:this.#p?.icons?.expand??n.expand,collapse:this.#p?.icons?.collapse??n.collapse}}get _shellState(){return this.#ce}_clearRowPool(){this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++}_setup(){this.#qe()}_applyAnimationConfig(e){this.#ot(e)}#nt(){!function(e,t,o,i){if(!t)return!1;let n=!1;const r=function(e,t){const o=e?.gridAriaLabel;return o||(e?.shell?.header?.title??t?.lightDomTitle??void 0)}(o,i);r!==e.ariaLabel&&(e.ariaLabel=r,r?t.setAttribute("aria-label",r):t.removeAttribute("aria-label"),n=!0);const s=o?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),n=!0)}(this.#it,this.__rowsBodyEl,this.#p,this.#ce)}#ye(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#ge?(this.#we||(this.#we=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(Ie("large",e)),t}(this.#p?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#we)):(t=this.#we,t?.remove()))}#_e(e,t){const o=this.#be.get(e);if(!o)return;const i=this.findRenderedRowElement?.(o.index);i&&function(e,t){if(t){if(e.classList.add("tbw-row-loading"),e.setAttribute("aria-busy","true"),!e.querySelector(".tbw-row-loading-overlay")){const t=document.createElement("div");t.className="tbw-row-loading-overlay",t.setAttribute("aria-hidden","true");const o=document.createElement("div");o.className="tbw-row-loading-spinner",t.appendChild(o),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}(i,t)}#Re(e,t,o){const i=this.#be.get(e);if(!i)return;const n=this.findRenderedRowElement?.(i.index);if(!n)return;const r=this._visibleColumns.findIndex(e=>e.field===t);if(r<0)return;const s=n.children[r];s&&function(e,t){t?(e.classList.add("tbw-cell-loading"),e.setAttribute("aria-busy","true")):(e.classList.remove("tbw-cell-loading"),e.removeAttribute("aria-busy"))}(s,o)}#qe(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#I.parseLightDomColumns(this),this.#y){const e=this.#y;this.#y=void 0,this.#I.merge();const t=this.#ee?.getAll()??[];this.#I.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#$.requestPhase(ie.FULL,"setup")}}#Be(e){let t=0,o=0,i=0,n=0,r=0;if(this.#U){const e=this._virtualization.container,s=this.#ae;t=s?.scrollLeft??0,o=e?.scrollHeight??0,i=s?.scrollWidth??0,n=e?.clientHeight??0,r=s?.clientWidth??0}if(this.refreshVirtualWindow(!1)&&this.#ee?.onScrollRender(),this._virtualization.variableHeights&&(this.#G&&clearTimeout(this.#G),this.#G=window.setTimeout(()=>{this.#G=0,this.#ie.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#U){const s=this.#J;s.scrollTop=e,s.scrollLeft=t,s.scrollHeight=o,s.scrollWidth=i,s.clientHeight=n,s.clientWidth=r,this.#ee?.onScroll(s)}}findHeaderRow(){return this.#O.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,o=e-t.start;return o>=0&&o<this._rowPool.length&&o<t.end-t.start?this._rowPool[o]:null}_dispatchCellClick(e,t,o,i){const n=this._rows[t],r=this._visibleColumns[o];if(!n||!r)return!1;const s=r.field,l=n[s],a=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:o,column:r,field:s,value:l,row:n,cellEl:i,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const c={row:n,rowIndex:t,colIndex:o,column:r,field:s,value:l,cellEl:i,originalEvent:e},d=this.#ee?.onCellClick(c)??!1;return this.#Ge("cell-click",c),d}_dispatchRowClick(e,t,o,i){if(!o)return!1;const n={rowIndex:t,row:o,rowEl:i,originalEvent:e},r=this.#ee?.onRowClick(n)??!1;return this.#Ge("row-click",n),r}_dispatchHeaderClick(e,t,o){if(!t)return!1;const i={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:o,originalEvent:e};return this.#ee?.onHeaderClick(i)??!1}_dispatchKeyDown(e){return this.#ee?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#ee?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}queryPlugins(e){return this.#ee?.queryPlugins(e)??[]}query(e,t){return this.#ee?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#ee?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#ee?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#ee?.onCellMouseUp(e)}_afterCellRender(e){this.#ee?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#ee?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#ee?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#ee?.hasAfterRowRenderHook()??!1}async ready(){return this.#i}async forceLayout(){return this.#$.requestPhase(ie.FULL,"forceLayout"),this.#$.whenReady()}async getConfig(){return Object.freeze({...this.#p||{}})}getRowId(e){return Ve(e,this.id,this.#p.getRowId)}getRow(e){return this.#re.getRow(e)}_getRowEntry(e){return this.#be.get(e)}updateRow(e,t,o="api"){this.#re.updateRow(e,t,o)}updateRows(e,t="api"){this.#re.updateRows(e,t)}animateRow(e,t){return Be(this,e,t)}animateRows(e,t){return function(e,t,o){return Promise.all(t.map(t=>Be(e,t,o))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,o){const i=e._rows??[],n=e.getRowId;if(!n)return Promise.resolve(!1);const r=i.findIndex(e=>{if(null==e)return!1;try{return n(e)===t}catch{return!1}});return r<0?Promise.resolve(!1):Be(e,r,o)}(this,e,t)}async insertRow(e,t,o=!0){return this.#re.insertRow(e,t,o)}async removeRow(e,t=!0){return this.#re.removeRow(e,t)}suspendProcessing(){}focusCell(e,t){this.#ne.focusCell(e,t)}get focusedCell(){return this.#ne.focusedCell}scrollToRow(e,t){this.#ne.scrollToRow(e,t)}scrollToRowById(e,t){this.#ne.scrollToRowById(e,t)}setColumnVisible(e,t){const o=this.#I.setColumnVisible(e,t);return o&&this.requestStateChange(),o}toggleColumnVisibility(e){const t=this.#I.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#I.isColumnVisible(e)}showAllColumns(){this.#I.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#I.getAllColumns()}setColumnOrder(e){this.#I.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#I.getColumnOrder()}getColumnState(){const e=this.#ee?.getAll()??[];return this.#I.collectState(e)}set columnState(e){e&&(this.#y=e,this.#I.initialColumnState=e,this.#k&&this.#rt(e))}get columnState(){return this.getColumnState()}#rt(e){const t=this.#ee?.getAll()??[];this.#I.applyState(e,t),this.#qe()}requestStateChange(){const e=this.#ee?.getAll()??[];this.#I.requestStateChange(e)}resetColumnState(){this.#y=void 0,this.__originalOrder=[];const e=this.#ee?.getAll()??[];this.#I.resetState(e),this.#I.merge(),this.#qe()}get isToolPanelOpen(){return this.#de.isPanelOpen}get defaultRowHeight(){return this._virtualization.rowHeight}get expandedToolPanelSections(){return this.#de.expandedSections}openToolPanel(){this.#de.openToolPanel()}closeToolPanel(){this.#de.closeToolPanel()}toggleToolPanel(){this.#de.toggleToolPanel()}toggleToolPanelSection(e){this.#de.toggleToolPanelSection(e)}getToolPanels(){return this.#de.getToolPanels()}registerToolPanel(e){this.#ce.apiToolPanelIds.add(e.id),this.#de.registerToolPanel(e)}unregisterToolPanel(e){this.#ce.apiToolPanelIds.delete(e),this.#de.unregisterToolPanel(e)}getHeaderContents(){return this.#de.getHeaderContents()}registerHeaderContent(e){this.#ce.apiHeaderContentIds.add(e.id),this.#de.registerHeaderContent(e)}unregisterHeaderContent(e){this.#ce.apiHeaderContentIds.delete(e),this.#de.unregisterHeaderContent(e)}getToolbarContents(){return this.#de.getToolbarContents()}registerToolbarContent(e){this.#de.registerToolbarContent(e)}unregisterToolbarContent(e){this.#de.unregisterToolbarContent(e)}#st=!1;refreshShellHeader(){this.#st||(this.#st=!0,queueMicrotask(()=>{this.#st=!1,this.isConnected&&(this.#De(),this.#I.markSourcesChanged(),this.#I.merge(),ct(this.#ce),this.#Oe(),this.#xe(),this.#lt())}))}#lt(){const e=this.#O.querySelector(".tbw-grid-content")??this.#O.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.#de.isInitialized){rt(this.#O,this.#ce),nt(this.#O,this.#p?.shell,this.#ce);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#ce.toolPanels.has(e)&&(this.openToolPanel(),this.#ce.expandedSections.add(e)),this.#ce.isPanelOpen&&(at(this.#O,this.#ce),st(this.#O,this.#ce,(this.#p,this.#p)),lt(this.#O,this.#ce))}this._resizeController=Ne(this),this.#Pe(e),this.#$.requestPhase(ie.COLUMNS,"shellRefresh")}#Ne=/* @__PURE__ */new Map;registerStyles(e,t){let o=this.#Ne.get(e);o||(o=new CSSStyleSheet,this.#Ne.set(e,o)),o.replaceSync(t),this.#at()}unregisterStyles(e){this.#Ne.delete(e)&&this.#at()}getRegisteredStyles(){return Array.from(this.#Ne.keys())}#at(){const e=Array.from(this.#Ne.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#Ne.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#ne.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#ne.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#ne.containsFocus(e)}#De(){tt(this,this.#ce),ot(this,this.#ce),it(this,this.#ce,this.#Le())}#ct(){const e=this.#O.querySelector(".tbw-shell-header");if(!e)return;ct(this.#ce);const t=function(e,t,o="☰"){const i=e?.header?.title??t.lightDomTitle??"",n=!!i,r=Je(o),s=e?.header?.toolbarContents??[],l=[...t.toolbarContents.values()],a=new Set(s.map(e=>e.id)),c=[...s];for(const w of l)a.has(w.id)||c.push(w);const d=c.length>0,h=t.toolPanels.size>0,u=d&&h,g=[...c].sort((e,t)=>(e.order??0)-(t.order??0));let f="";for(const w of g)f+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${w.id}"></div>`;if(u&&(f+='<div class="tbw-toolbar-separator"></div>'),h){const e=t.isPanelOpen;f+=`<button class="${e?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${e}" aria-controls="tbw-tool-panel">${r}</button>`}return`\n <div class="tbw-shell-header" part="shell-header" role="presentation">\n ${n?`<div class="tbw-shell-title">${p=i,p&&"string"==typeof p?p.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}</div>`:""}\n <div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>\n <div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">\n ${f}\n </div>\n </div>\n `;var p}(this.#p.shell,this.#ce,this.#p.icons?.toolPanel),o=document.createElement("div");o.innerHTML=t;const i=o.firstElementChild;i&&(e.replaceWith(i),this.#dt(),nt(this.#O,this.#p?.shell,this.#ce))}#ze(){const e=()=>{const e=this.#ce.lightDomTitle,t=this.#ce.hasToolButtonsContainer;this.#De();const o=this.#ce.lightDomTitle,i=this.#ce.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#I.markSourcesChanged(),this.#I.merge(),this.#ct())},t=()=>{this.__lightDomColumnsCache=void 0,this.#qe()};this.#I.registerLightDomHandler("tbw-grid-header",e),this.#I.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#I.registerLightDomHandler("tbw-grid-tool-panel",e),this.#I.registerLightDomHandler("tbw-grid-column",t),this.#I.registerLightDomHandler("tbw-grid-detail",t),this.#I.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,Re(this),this.#I.parseLightDomColumns(this);const e=this.#ce.lightDomTitle,t=this.#ce.hasToolButtonsContainer;this.#De();const o=this.#ce.lightDomTitle,i=this.#ce.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#I.markSourcesChanged(),this.#I.merge(),this.#ct()),this.#$.requestPhase(ie.COLUMNS,"refreshColumns")}#Ue(){this.#ie.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#ie.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#ie.invalidateRowHeight(e,t)}#Oe(){this.#De(),this.#I.markSourcesChanged(),this.#I.merge();const e=this.#p?.shell;ht(this.#O,e,{isPanelOpen:this.#ce.isPanelOpen,expandedSections:this.#ce.expandedSections},this.#p?.icons)&&(this.#dt(),this.#de.setInitialized(!0))}#dt(){!function(e,t,o,i){const n=e.querySelector(".tbw-shell-toolbar");n&&n.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&i.onPanelToggle()});const r=e.querySelector(".tbw-accordion");r&&r.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),o=e?.getAttribute("data-section");o&&i.onSectionToggle(o)}})}(this.#O,this.#p,this.#ce,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#he?.(),this.#he=function(e,t,o){const i=e.querySelector(".tbw-tool-panel"),n=e.querySelector("[data-resize-handle]"),r=e.querySelector(".tbw-shell-body");if(!i||!n||!r)return()=>{};const s=t?.toolPanel?.position??"right";let l=0,a=0,c=0,d=!1;const h=e=>{if(!d)return;e.preventDefault();const t="left"===s?e.clientX-l:l-e.clientX,o=Math.min(c,Math.max(200,a+t));i.style.width=`${o}px`},u=()=>{if(!d)return;d=!1,n.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=i.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)},g=e=>{e.preventDefault(),d=!0,l=e.clientX,a=i.getBoundingClientRect().width,c=r.getBoundingClientRect().width-20,n.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)};return n.addEventListener("mousedown",g),()=>{n.removeEventListener("mousedown",g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}}(this.#O,this.#p?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)}),this.#ue?.(),this.#ue=function(e,t,o,i){if(!t?.toolPanel?.closeOnClickOutside)return()=>{};const n=e=>{if(!o.isPanelOpen)return;const t=e.target;t&&(t.closest(".tbw-tool-panel")||t.closest("[data-panel-toggle]")||i())};return e.addEventListener("mousedown",n),()=>e.removeEventListener("mousedown",n)}(this,this.#p?.shell,this.#ce,()=>this.closeToolPanel())}}customElements.get(kt.tagName)||customElements.define(kt.tagName,kt),globalThis.DataGridElement=kt;const zt={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class It{static dependencies;static manifest;aliases;version="1.26.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#ht;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#ht?.abort(),this.#ht=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#ht?.abort(),this.#ht=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const o=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#ht?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...n,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(t,10);if(!isNaN(o))return o}return 200}resolveIcon(e,t){return void 0!==t?t:this.gridIcons[e]}setIcon(e,t){"string"==typeof t?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e,t){void 0!==t?console.warn(C(e,t,this.gridElement.id,this.name)):console.warn(`${r(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(C(e,t,this.gridElement.id,this.name))}}const Nt={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},qt={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},Wt={ROOT:`.${Nt.ROOT}`,HEADER:`.${Nt.HEADER}`,HEADER_ROW:`.${Nt.HEADER_ROW}`,HEADER_CELL:`.${Nt.HEADER_CELL}`,ROWS_VIEWPORT:`.${Nt.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${Nt.ROWS_CONTAINER}`,DATA_ROW:`.${Nt.DATA_ROW}`,DATA_CELL:`.${Nt.DATA_CELL}`,GROUP_ROW:`.${Nt.GROUP_ROW}`,ROW_BY_INDEX:e=>`.${Nt.DATA_ROW}[${qt.ROW_INDEX}="${e}"]`,CELL_BY_FIELD:e=>`.${Nt.DATA_CELL}[${qt.FIELD}="${e}"]`,CELL_AT:(e,t)=>`.${Nt.DATA_ROW}[${qt.ROW_INDEX}="${e}"] .${Nt.DATA_CELL}[${qt.COL_INDEX}="${t}"]`,SELECTED_ROWS:`.${Nt.DATA_ROW}.${Nt.SELECTED}`,EDITING_CELL:`.${Nt.DATA_CELL}.${Nt.EDITING}`},$t={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"};function Ft(e){const t=document.createElement("tbw-grid");return e&&(t.gridConfig=e),t}function Bt(e,t,o){let i=document,n=!1;return"boolean"==typeof t?n=t:t&&(i=t,n=!!o),n?customElements.whenDefined(kt.tagName).then(()=>i.querySelector(e)):i.querySelector(e)}const Ut={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",EDIT_OPEN:"edit-open",EDIT_CLOSE:"edit-close",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change",DATA_CHANGE:"data-change"},Vt={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},Gt={sum:(e,t)=>e.reduce((e,o)=>e+(Number(o[t])||0),0),avg:(e,t)=>{const o=e.reduce((e,o)=>e+(Number(o[t])||0),0);return e.length?o/e.length:0},count:e=>e.length,min:(e,t)=>e.length?Math.min(...e.map(e=>Number(e[t])||1/0)):0,max:(e,t)=>e.length?Math.max(...e.map(e=>Number(e[t])||-1/0)):0,first:(e,t)=>e[0]?.[t],last:(e,t)=>e[e.length-1]?.[t]},Xt=/* @__PURE__ */new Map,Yt={register(e,t){Xt.set(e,t)},unregister(e){Xt.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:Xt.get(e)??Gt[e]},run(e,t,o,i){const n=this.get(e);return n?n(t,o,i):void 0},has:e=>Xt.has(e)||e in Gt,list:()=>[...Object.keys(Gt),...Xt.keys()]},jt={sum:e=>e.reduce((e,t)=>e+t,0),avg:e=>e.length?e.reduce((e,t)=>e+t,0)/e.length:0,count:e=>e.length,min:e=>e.length?Math.min(...e):0,max:e=>e.length?Math.max(...e):0,first:e=>e[0]??0,last:e=>e[e.length-1]??0};function Kt(e){return jt[e]??jt.sum}function Zt(e,t){return Kt(e)(t)}const Qt=Yt.register.bind(Yt),Jt=Yt.unregister.bind(Yt),eo=Yt.get.bind(Yt),to=Yt.run.bind(Yt),oo=Yt.list.bind(Yt);export{It as BaseGridPlugin,f as C,o as DEFAULT_ANIMATION_CONFIG,n as DEFAULT_GRID_ICONS,Ut as DGEvents,kt as DataGridElement,c as E,we as F,t as FitModeEnum,$t as GridCSSVars,Nt as GridClasses,qt as GridDataAttrs,kt as GridElement,Wt as GridSelectors,p as M,b as N,g as P,zt as PLUGIN_QUERIES,Vt as PluginEvents,Ot as PluginManager,ie as RenderPhase,w as T,e as a,Yt as aggregatorRegistry,m as b,V as builtInSort,Mt as c,Ft as createGrid,v as d,U as defaultComparator,Ae as e,W as f,q as g,eo as getAggregator,Kt as getValueAggregator,he as h,d as i,h as j,S as k,u as l,oo as listAggregators,ce as m,de as n,Bt as queryGrid,ge as r,Qt as registerAggregator,to as runAggregator,Zt as runValueAggregator,Lt as s,De as setFeatureResolver,y as t,Jt as unregisterAggregator,_ as w};//# sourceMappingURL=index.js.map
|
|
1
|
+
function e(e,t){const o=e.querySelector?.(".tbw-sr-only");o&&(o.textContent="",requestAnimationFrame(()=>{o.textContent=t}))}const t={STRETCH:"stretch",FIXED:"fixed"},o={mode:"reduced-motion",duration:200,easing:"ease-out"},i='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',n={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:i,filterActive:i,print:"🖨️"};function r(e,t){return`[tbw-grid${e?`#${e}`:""}${t?`:${t}`:""}]`}const s="TBW041",l="TBW061",a="TBW062",c="TBW080",d="TBW090",h="TBW091",u="TBW092",g="TBW093",f="TBW100",p="TBW110",w="TBW111",b="TBW112",m="TBW113",v="TBW114";function C(e,t,o,i){return`${r(o,i)} ${e}: ${t}\n\n → More info: ${function(e){return`https://toolboxjs.com/grid/errors#${e.toLowerCase()}`}(e)}`}function y(e,t,o,i){throw new Error(C(e,t,o,i))}function _(e,t,o,i){console.warn(C(e,t,o,i))}function R(e,t,o,i){console.info(C(e,t,o,i))}function S(e,t,o,i){console.error(C(e,t,o,i))}function E(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const o={};t.forEach(e=>{const t=o[e.field];if(t){e.header&&!t.header&&(t.header=e.header),e.type&&!t.type&&(t.type=e.type),e.sortable&&(t.sortable=!0),e.editable&&(t.editable=!0),e.resizable&&(t.resizable=!0),null!=e.width&&null==t.width&&(t.width=e.width),null!=e.minWidth&&null==t.minWidth&&(t.minWidth=e.minWidth),e.__viewTemplate&&(t.__viewTemplate=e.__viewTemplate),e.__editorTemplate&&(t.__editorTemplate=e.__editorTemplate),e.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate);const o=e.renderer||e.viewRenderer,i=t.renderer||t.viewRenderer;o&&!i&&(t.viewRenderer=o,e.renderer&&(t.renderer=o)),e.editor&&!t.editor&&(t.editor=e.editor)}else o[e.field]={...e}});const i=e.map(e=>{const t=o[e.field];if(!t)return e;const i={...e};t.header&&!i.header&&(i.header=t.header),t.type&&!i.type&&(i.type=t.type),i.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(i.resizable=!0),i.editable=e.editable||t.editable,null!=t.width&&null==i.width&&(i.width=t.width),null!=t.minWidth&&null==i.minWidth&&(i.minWidth=t.minWidth),t.__viewTemplate&&(i.__viewTemplate=t.__viewTemplate),t.__editorTemplate&&(i.__editorTemplate=t.__editorTemplate),t.__headerTemplate&&(i.__headerTemplate=t.__headerTemplate);const n=t.renderer||t.viewRenderer,r=i.renderer||i.viewRenderer;return n&&!r&&(i.viewRenderer=n,t.renderer&&(i.renderer=n)),t.editor&&!i.editor&&(i.editor=t.editor),delete o[e.field],i});return Object.keys(o).forEach(e=>i.push(o[e])),i}function x(e,t){try{e.part?.add?.(t)}catch{}const o=e.getAttribute("part");o?o.split(/\s+/).includes(t)||e.setAttribute("part",o+" "+t):e.setAttribute("part",t)}function A(e){const o=e.effectiveConfig?.fitMode||e.fitMode||t.STRETCH;if(o!==t.STRETCH&&o!==t.FIXED)return;if(e.__didInitialAutoSize)return;if(!e.isConnected)return;const i=Array.from(e._headerRowEl?.children||[]);if(!i.length)return;let n=!1;e._visibleColumns.forEach((t,o)=>{if(t.width)return;const r=i[o];let s=r?r.scrollWidth:0;for(const i of e._rowPool){const e=i.children[o];if(e){const t=e.scrollWidth;t>s&&(s=t)}}s>0&&(t.width=s+2,t.__autoSized=!0,n=!0)}),n&&P(e),e.__didInitialAutoSize=!0}const T=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function H(e,t){return"number"==typeof e?`${e}px`:(T.test(e)||_("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 P(e){const o=e.effectiveConfig?.fitMode||e.fitMode||t.STRETCH;e._gridTemplate=o===t.STRETCH?e._visibleColumns.map(e=>{if(null!=e.width)return H(e.width,e.field);const t=e.minWidth;return null!=t?`minmax(${t}px, 1fr)`:"1fr"}).join(" ").trim():e._visibleColumns.map(e=>null!=e.width?H(e.width,e.field):"max-content").join(" "),e.style.setProperty("--tbw-column-template",e._gridTemplate)}const M=/{{\s*([^}]+)\s*}}/g,L="__DG_EMPTY__",D=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,O=/__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/;const k=/* @__PURE__ */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"]),z=/^on\w+$/i,I=/* @__PURE__ */new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),N=/^\s*(javascript|vbscript|data|blob):/i;function q(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],o=e.querySelectorAll("*");for(const i of o){const e=i.tagName.toLowerCase();if(k.has(e)){t.push(i);continue}if("svg"===e||"http://www.w3.org/2000/svg"===i.namespaceURI){if(Array.from(i.attributes).some(e=>z.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(i);continue}}const o=[];for(const t of i.attributes){const e=t.name.toLowerCase();z.test(e)?o.push(t.name):(I.has(e)&&N.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&o.push(t.name)}o.forEach(e=>i.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function W(e,t){if(!e||-1===e.indexOf("{{"))return e;const o=[],i=e.replace(M,(e,i)=>{const n=function(e,t){if(e=(e||"").trim(),!e)return L;if($.test(e))return L;if("value"===e)return null==t.value?L:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const o=e.slice(4),i=t.row?t.row[o]:void 0;return null==i?L:String(i)}if(e.length>80)return L;if(!D.test(e)||O.test(e))return L;const o=e.match(/\./g);if(o&&o.length>1)return L;try{const o=new Function("value","row",`return (${e});`)(t.value,t.row),i=null==o?"":String(o);return $.test(i)?L:i||L}catch{return L}}(i,t);return o.push({expr:i.trim(),result:n}),n}),n=(r=i)?r.replace(new RegExp(L,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):r;var r;const s=o.length&&o.every(e=>""===e.result||e.result===L);return $.test(e)||s?"":n}const $=/Reflect|Proxy|ownKeys/;function F(e){if($.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&$.test(t.textContent||"")&&(t.textContent="");$.test(e.textContent||"")&&(e.textContent="")}}function B(e){const t=$.test(e),o=o=>{if(t)return"";return W(e,o)};return o.__blocked=t,o}function U(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0}function V(e,t,o){const i=o.find(e=>e.field===t.field),n=i?.sortComparator??U,{field:r,direction:s}=t;return[...e].sort((e,t)=>n(e[r],t[r],e,t)*s)}function G(t,o,i,n){t._rows=o,t.__rowRenderEpoch++,t._rowPool.forEach(e=>e.__epoch=-1),ee(t),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:i.field,direction:n}})),e(t,`Sorted by ${i.header??i.field}, ${1===n?"ascending":"descending"}`),t.requestStateChange?.()}function X(t,o){if(t._sortState&&t._sortState.field===o.field)if(1===t._sortState.direction)Y(t,o,-1);else{t._sortState=null,t.__rowRenderEpoch++,t._rowPool.forEach(e=>e.__epoch=-1),t._rows=t.__originalOrder.slice(),ee(t);const i=t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');i?.forEach(e=>{e.getAttribute("aria-sort")&&("ascending"!==e.getAttribute("aria-sort")&&"descending"!==e.getAttribute("aria-sort")||t._sortState)||e.setAttribute("aria-sort","none")}),t.refreshVirtualWindow(!0),t.dispatchEvent(new CustomEvent("sort-change",{detail:{field:o.field,direction:0}})),e(t,"Sort cleared"),t.requestStateChange?.()}else t._sortState||(t.__originalOrder=t._rows.slice()),Y(t,o,1)}function Y(e,t,o){e._sortState={field:t.field,direction:o};const i={field:t.field,direction:o},n=e._columns,r=(e.effectiveConfig?.sortHandler??V)(e._rows,i,n);r&&"function"==typeof r.then?r.then(i=>{G(e,i,t,o)}):G(e,r,t,o)}function j(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function K(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function Z(e,t){const o=document.createElement("span");x(o,"sort-indicator");const i=e._sortState?.field===t.field?e._sortState.direction:0,r={...n,...e.icons};return function(e,t){"string"==typeof t?e.textContent=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(o,1===i?r.sortAsc:-1===i?r.sortDesc:r.sortNone),o}function Q(e,t,o){const i=document.createElement("div");return i.className="resize-handle",i.setAttribute("aria-hidden","true"),i.addEventListener("mousedown",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.start(i,t,o)}),i.addEventListener("dblclick",o=>{o.stopPropagation(),o.preventDefault(),e._resizeController.resetColumn(t)}),i}function J(e,t,o,i){i.classList.add("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",o=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(o,t,i)||X(e,t)}),i.addEventListener("keydown",o=>{if("Enter"===o.key||" "===o.key){if(o.preventDefault(),e._dispatchHeaderClick?.(o,t,i))return;X(e,t)}})}function ee(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((o,i)=>{const n=document.createElement("div");n.className="cell",x(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(i+1)),n.setAttribute("data-field",o.field),n.setAttribute("data-col",String(i)),o.type&&n.setAttribute("data-type",o.type);const r=o.header??o.field,s=e._sortState?.field===o.field?e._sortState.direction:0,l=1===s?"asc":-1===s?"desc":null;if(o.headerRenderer){const t={column:o,value:r,sortState:l,filterActive:!1,cellEl:n,renderSortIcon:()=>j(e,o)?Z(e,o):null,renderFilterButton:()=>null},s=o.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const o=document.createElement("span");for(o.innerHTML=q(t);o.firstChild;)e.appendChild(o.firstChild)}else t instanceof Node&&e.appendChild(t)}(n,s),j(e,o)&&J(e,o,0,n),K(e,o)&&(n.classList.add("resizable"),n.appendChild(Q(e,i,n)))}else if(o.headerLabelRenderer){const t={column:o,value:r},s=o.headerLabelRenderer(t),l=document.createElement("span");null==s?l.textContent=r:"string"==typeof s?l.innerHTML=q(s):s instanceof Node&&l.appendChild(s),n.appendChild(l),j(e,o)&&(J(e,o,0,n),n.appendChild(Z(e,o))),K(e,o)&&(n.classList.add("resizable"),n.appendChild(Q(e,i,n)))}else if(o.__headerTemplate)Array.from(o.__headerTemplate.childNodes).forEach(e=>n.appendChild(e.cloneNode(!0))),j(e,o)&&(J(e,o,0,n),n.appendChild(Z(e,o))),K(e,o)&&(n.classList.add("resizable"),n.appendChild(Q(e,i,n)));else{const t=document.createElement("span");t.textContent=r,n.appendChild(t),j(e,o)&&(J(e,o,0,n),n.appendChild(Z(e,o))),K(e,o)&&(n.classList.add("resizable"),n.appendChild(Q(e,i,n)))}t.appendChild(n)}),t.querySelectorAll(".cell.sortable").forEach(e=>{e.getAttribute("aria-sort")||e.setAttribute("aria-sort","none")}),t.children.length>0?(t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1")):(t.removeAttribute("role"),t.removeAttribute("aria-rowindex")))}function te(e,t){const o=e[0]||{},i=Object.keys(o).map(e=>{const t=o[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 oe,ie=((oe=ie||{})[oe.STYLE=1]="STYLE",oe[oe.VIRTUALIZATION=2]="VIRTUALIZATION",oe[oe.HEADER=3]="HEADER",oe[oe.ROWS=4]="ROWS",oe[oe.COLUMNS=5]="COLUMNS",oe[oe.FULL=6]="FULL",oe);class ne{#e;#t=0;#o=0;#i=null;#n=null;#r=null;#s=!1;constructor(e){this.#e=e}requestPhase(e,t){e>this.#t&&(this.#t=e),0===this.#o&&(this.#l(),this.#o=requestAnimationFrame(()=>this.#a()))}whenReady(){return this.#i?this.#i:Promise.resolve()}setInitialReadyResolver(e){this.#r=e}cancel(){0!==this.#o&&(cancelAnimationFrame(this.#o),this.#o=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}#l(){this.#i||(this.#i=new Promise(e=>{this.#n=e}))}#a(){if(this.#o=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>=5&&this.#e._schedulerMergeConfig(),e>=4&&this.#e._schedulerProcessRows(),e>=5&&(this.#e._schedulerProcessColumns(),this.#e._schedulerUpdateTemplate()),e>=3&&this.#e._schedulerRenderHeader(),e>=2&&this.#e.refreshVirtualWindow(!0,!0),e>=1&&this.#e._schedulerAfterRender(),!this.#s&&this.#r&&(this.#s=!0,this.#r()),this.#n&&(this.#n(),this.#n=null,this.#i=null)}}class re{#c;#d;#h;#u;#g;#f={};#p={};#w=!0;#b=[];#m;#v;#C;#y;#e;#_;constructor(e){this.#e=e}get original(){return this.#f}get effective(){return this.#p}get columns(){return this.#p.columns??[]}set columns(e){this.#p.columns=e}get lightDomColumnsCache(){return this.#u}set lightDomColumnsCache(e){this.#u=e}get originalColumnNodes(){return this.#g}set originalColumnNodes(e){this.#g=e}get lightDomTitle(){return this.#_}set lightDomTitle(e){this.#_=e}get initialColumnState(){return this.#y}set initialColumnState(e){this.#y=e}get sourcesChanged(){return this.#w}markSourcesChanged(){this.#w=!0}setGridConfig(e){this.#c=e,this.#w=!0,this.#u=void 0}getGridConfig(){return this.#c}setColumns(e){this.#d=e,this.#w=!0}getColumns(){return this.#d}setFitMode(e){this.#h=e,this.#w=!0}getFitMode(){return this.#h}merge(){const e=(this.#p.columns?.length??0)>0;if(!this.#w&&e)return;const t=this.#R();this.#w=!1,this.#f=t,Object.freeze(this.#f),this.#f.columns&&Object.freeze(this.#f.columns),this.#p=this.#S(this.#f),this.#E()}#S(e){const t={...e};return e.columns&&(t.columns=e.columns.map(e=>({...e}))),e.shell&&(t.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(e=>({...e})),headerContents:e.shell.headerContents?.map(e=>({...e}))}),t}#E(){const e=this.#p;if(this.#x(),"number"==typeof e.rowHeight&&e.rowHeight>0&&(this.#e._virtualization.rowHeight=e.rowHeight),"fixed"===e.fitMode){this.columns.forEach(e=>{null==e.width&&(e.width=80)})}this.#e._applyAnimationConfig(e)}#x(){const e=this.#p.typeDefaults;if(!e)return;const t=this.columns;for(const o of t){if(!o.type)continue;const t=e[o.type];t&&(o.renderer||o.viewRenderer||!t.renderer||(o.renderer=t.renderer),!o.format&&t.format&&(o.format=t.format),!o.editor&&t.editor&&(o.editor=t.editor),!o.editorParams&&t.editorParams&&(o.editorParams=t.editorParams))}}#R(){const e=this.#c?{...this.#c}:{},t=Array.isArray(e.columns)?[...e.columns]:[],o=(this.#u??[]).map(e=>({...e}));let i=E(t,o);this.#d&&this.#d.length&&(i=E(this.#d,o));const n=this.#e.sourceRows;if(0===i.length&&n.length){i=te(n).columns}return i.length&&(i.forEach(e=>{void 0===e.sortable&&(e.sortable=!0),void 0===e.resizable&&(e.resizable=!0),void 0===e.__originalWidth&&"number"==typeof e.width&&(e.__originalWidth=e.width)}),i.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=B(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=B(e.__editorTemplate.innerHTML))}),e.columns=i),this.#h&&(e.fitMode=this.#h),e.fitMode||(e.fitMode="stretch"),this.#A(e),e.columnState&&!this.#y&&(this.#y=e.columnState),e}#A(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const t=this.#e._shellState.lightDomTitle;t&&(this.#_=t),this.#_&&!e.shell.header.title&&(e.shell.header.title=this.#_);const o=this.#e._shellState.lightDomHeaderContent;o?.length>0&&(e.shell.header.lightDomContent=o),this.#e._shellState.hasToolButtonsContainer&&(e.shell.header.hasToolButtonsContainer=!0);const i=this.#e._shellState.toolPanels;if(i.size>0){const t=Array.from(i.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=t}const n=this.#e._shellState.headerContents;if(n.size>0){const t=Array.from(n.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=t}const r=this.#e._shellState.toolbarContents,s=Array.from(r.values()),l=this.#c?.shell?.header?.toolbarContents??[],a=new Set(l.map(e=>e.id)),c=[...l];for(const d of s)a.has(d.id)||c.push(d);c.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=c}collectState(e){const t=this.columns,o=this.#T();return{columns:t.map((t,i)=>{const n={field:t.field,order:i,visible:!t.hidden},r=t;void 0!==r.__renderedWidth?n.width=r.__renderedWidth:void 0!==t.width&&(n.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=o.get(t.field);s&&(n.sort=s);for(const o of e)if(o.getColumnState){const e=o.getColumnState(t.field);e&&Object.assign(n,e)}return n})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const o=this.columns,i=new Map(e.columns.map(e=>[e.field,e])),n=o.map(e=>{const t=i.get(e.field);if(!t)return e;const o={...e};return void 0!==t.width&&(o.width=t.width,o.__renderedWidth=t.width),void 0!==t.visible&&(o.hidden=!t.visible),o});n.sort((e,t)=>(i.get(e.field)?.order??1/0)-(i.get(t.field)?.order??1/0)),this.columns=n;const r=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(r.length>0){const e=r[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.#y=void 0,this.#e._sortState=null,this.#p=this.#S(this.#f),this.#E();for(const t of e)if(t.applyColumnState)for(const e of this.columns)t.applyColumnState(e.field,{field:e.field,order:0,visible:!0});this.requestStateChange(e)}#T(){const e=/* @__PURE__ */new Map,t=this.#e._sortState;return t&&e.set(t.field,{direction:1===t.direction?"asc":"desc",priority:0}),e}requestStateChange(e){this.#v&&clearTimeout(this.#v),this.#v=setTimeout(()=>{this.#v=void 0;const t=this.collectState(e);this.#e._emit("column-state-change",t)},100)}setColumnVisible(e,t){const o=this.columns,i=o.find(t=>t.field===e);if(!i)return!1;if(!t&&i.lockVisible)return!1;if(!t){if(0===o.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!i.hidden!=!t&&(i.hidden=!t,this.#e._emit("column-visibility",{field:e,visible:t,visibleColumns:o.filter(e=>!e.hidden).map(e=>e.field)}),this.#e._clearRowPool(),this.#e._setup(),!0)}toggleColumnVisibility(e){const t=this.columns.find(t=>t.field===e);return!!t&&this.setColumnVisible(e,!!t.hidden)}isColumnVisible(e){const t=this.columns.find(t=>t.field===e);return!!t&&!t.hidden}showAllColumns(){const e=this.columns;e.some(e=>e.hidden)&&(e.forEach(e=>e.hidden=!1),this.#e._emit("column-visibility",{visibleColumns:e.map(e=>e.field)}),this.#e._clearRowPool(),this.#e._setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:!0===e.meta?.utility}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const t=new Map(this.columns.map(e=>[e.field,e])),o=[];for(const i of e){const e=t.get(i);e&&(o.push(e),t.delete(i))}for(const i of t.values())o.push(i);this.columns=o,ee(this.#e),P(this.#e),this.#e._requestSchedulerPhase(ie.VIRTUALIZATION,"configManager")}parseLightDomColumns(e){this.#u||(this.#g=Array.from(e.querySelectorAll("tbw-grid-column")),this.#u=this.#g.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const o=e.getAttribute("type")||void 0,i={field:t,type:o&&/* @__PURE__ */new Set(["number","string","date","boolean","select"]).has(o)?o:void 0,header:e.getAttribute("header")||void 0,sortable:e.hasAttribute("sortable"),editable:e.hasAttribute("editable")},n=e.getAttribute("width");if(n){const e=parseFloat(n);!isNaN(e)&&/^\d+(\.\d+)?$/.test(n.trim())?i.width=e:i.width=n}const r=e.getAttribute("minWidth")||e.getAttribute("min-width");if(r){const e=parseFloat(r);isNaN(e)||(i.minWidth=e)}e.hasAttribute("resizable")&&(i.resizable=!0),e.hasAttribute("sizable")&&(i.resizable=!0);const s=e.getAttribute("editor"),l=e.getAttribute("renderer");s&&(i.__editorName=s),l&&(i.__rendererName=l);const a=e.getAttribute("options");a&&(i.options=a.split(",").map(e=>{const[t,o]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:o?.trim()||t.trim()}}));const c=e.querySelector("tbw-grid-column-view"),d=e.querySelector("tbw-grid-column-editor"),h=e.querySelector("tbw-grid-column-header");c&&(i.__viewTemplate=c),d&&(i.__editorTemplate=d),h&&(i.__headerTemplate=h);const u=globalThis.DataGridElement,g=u?.getAdapters?.()??[],f=c??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(i.viewRenderer=e)}const w=d??e,b=g.find(e=>e.canHandle(w));if(b){const e=b.createEditor(w);e&&(i.editor=e)}return i}).filter(e=>!!e)}(e):[])}clearLightDomCache(){this.#u=void 0}#H=/* @__PURE__ */new Map;registerLightDomHandler(e,t){this.#H.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#H.delete(e.toLowerCase())}observeLightDOM(e){this.#m&&this.#m.disconnect();const t=/* @__PURE__ */new Set,o=()=>{this.#C=void 0;for(const e of t){const t=this.#H.get(e);t?.()}t.clear()};this.#m=new MutationObserver(e=>{for(const o of e){for(const e of o.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const o=e.tagName.toLowerCase();this.#H.has(o)&&t.add(o)}if("attributes"===o.type&&o.target.nodeType===Node.ELEMENT_NODE){const e=o.target.tagName.toLowerCase();this.#H.has(e)&&t.add(e)}}t.size>0&&!this.#C&&(this.#C=setTimeout(o,0))}),this.#m.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#b.push(e)}notifyChange(){for(const e of this.#b)e()}dispose(){this.#m?.disconnect(),this.#b=[],this.#v&&clearTimeout(this.#v),this.#C&&(clearTimeout(this.#C),this.#C=void 0)}}function se(){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 le(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"🗹":"☐"}</span>`}function ae(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 ce(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const o=e.closest(".data-grid-row");if(!o)return-1;const i=o.parentElement;if(!i)return-1;const n=i.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===o)return r;return-1}function de(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function he(e){try{if("rtl"===getComputedStyle(e).direction)return"rtl"}catch{}try{const t=e.closest?.("[dir]")?.getAttribute("dir");if("rtl"===t)return"rtl"}catch{}return"ltr"}function ue(e){return"rtl"===he(e)}function ge(e,t){return"left"===e||"right"===e?e:"rtl"===t?"start"===e?"right":"left":"start"===e?"left":"right"}function fe(e,t){const o=t.renderer||t.viewRenderer;if(o)return o;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const e=i.getTypeDefault(t.type);if(e?.renderer)return e.renderer}}function pe(e,t){if(t.format)return t.format;if(!t.type)return;const o=e.__frameworkAdapter;if(o?.getTypeDefault){const e=o.getTypeDefault(t.type);if(e?.format)return e.format}}const we='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function be(e){return(e.__editingCellCount??0)>0}function me(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(".cell.editing").forEach(e=>e.classList.remove("editing"))}const ve=document.createElement("template");ve.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const Ce=document.createElement("template");function ye(){return ve.content.firstElementChild.cloneNode(!0)}function _e(){return Ce.content.firstElementChild.cloneNode(!0)}function Re(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function Se(e,t,o,i){const n=t.children,r=e._visibleColumns,s=r.length,c=n.length,d=s<c?s:c,h=e._focusRow,u=e._focusCol,g=e._hasAfterCellRenderHook?.()??!1;let f=e.__hasSpecialColumns;if(void 0===f){f=!1;const t=e.__frameworkAdapter;for(let e=0;e<s;e++){const o=r[e];if(o.__viewTemplate||o.__compiledView||o.renderer||o.viewRenderer||o.externalView||o.format||o.cellClass||"date"===o.type||"boolean"===o.type||o.type&&t?.getTypeDefault?.(o.type)?.renderer||o.type&&t?.getTypeDefault?.(o.type)?.format){f=!0;break}}e.__hasSpecialColumns=f}const p=String(i);if(f){for(let s=0;s<d;s++){if(r[s].externalView){if(!n[s].querySelector("[data-external-view]"))return void Ee(e,t,o,i)}}for(let s=0;s<d;s++){const c=r[s],d=n[s];d.getAttribute("data-row")!==p&&d.setAttribute("data-row",p);const f=d.classList.contains("editing");if(!f){const e=h===i&&u===s;e!==d.classList.contains("cell-focus")&&(d.classList.toggle("cell-focus",e),d.setAttribute("aria-selected",String(e)))}const b=c.cellClass;if(b){const t=d.getAttribute("data-dynamic-classes");t&&t.split(" ").forEach(e=>e&&d.classList.remove(e));try{const e=b(o[c.field],o,c),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){const e=t.filter(e=>e&&"string"==typeof e);e.forEach(e=>d.classList.add(e)),d.setAttribute("data-dynamic-classes",e.join(" "))}else d.removeAttribute("data-dynamic-classes")}catch(w){_(l,`cellClass callback error for column '${c.field}': ${w}`,e.id),d.removeAttribute("data-dynamic-classes")}}if(f)continue;const m=fe(e,c);if(m){const n=o[c.field],r=m({row:o,value:n,field:c.field,column:c,cellEl:d});"string"==typeof r?(e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=q(r)):r instanceof Node?r.parentElement!==d&&(e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML="",d.appendChild(r)):null==r&&(e.__frameworkAdapter?.releaseCell?.(d),d.textContent=null==n?"":String(n)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:c,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(c.__compiledView){const n=o[c.field],r=c.__compiledView({row:o,value:n,field:c.field,column:c});c.__compiledView.__blocked?d.textContent="":(d.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=q(r),F(d)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:c,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(c.__viewTemplate){const n=o[c.field],r=c.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(r)?d.textContent="":(d.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(d),d.innerHTML=q(W(r,{row:o,value:n})),F(d)),g&&e._afterCellRender?.({row:o,rowIndex:i,column:c,colIndex:s,value:n,cellElement:d,rowElement:t});continue}if(c.externalView)continue;const v=o[c.field];let C;const y=pe(e,c);if(y){try{const e=y(v,o);C=null==e?"":String(e)}catch(w){_(a,`Format error in column '${c.field}': ${w}`,e.id),C=null==v?"":String(v)}d.textContent=C}else"date"===c.type?(C=ae(v),d.textContent=C):"boolean"===c.type?d.innerHTML=le(!!v):(C=null==v?"":String(v),d.textContent=C);g&&e._afterCellRender?.({row:o,rowIndex:i,column:c,colIndex:s,value:v,cellElement:d,rowElement:t})}}else for(let l=0;l<d;l++){const s=n[l];if(s.classList.contains("editing"))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const a=r[l],c=o[a.field];s.textContent=null==c?"":String(c),s.getAttribute("data-row")!==p&&s.setAttribute("data-row",p);const d=h===i&&u===l;d!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",d),s.setAttribute("aria-selected",String(d))),g&&e._afterCellRender?.({row:o,rowIndex:i,column:a,colIndex:l,value:c,cellElement:s,rowElement:t})}}function Ee(e,t,o,i){t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy");const n=e.__frameworkAdapter;if(n?.releaseCell){const e=t.children;for(let t=e.length-1;t>=0;t--)n.releaseCell(e[t])}t.innerHTML="";const r=e._visibleColumns,s=r.length,c=e._focusRow,d=e._focusCol,h=e._hasAfterCellRenderHook?.()??!1,u=document.createDocumentFragment();for(let f=0;f<s;f++){const n=r[f],s=ye();s.setAttribute("aria-colindex",String(f+1)),s.setAttribute("data-col",String(f)),s.setAttribute("data-row",String(i)),s.setAttribute("data-field",n.field),s.setAttribute("data-header",n.header??n.field),n.type&&s.setAttribute("data-type",n.type);let p=o[n.field];const w=pe(e,n);if(w)try{p=w(p,o)}catch(g){_(a,`Format error in column '${n.field}': ${g}`,e.id)}const b=n.__compiledView,m=n.__viewTemplate,v=fe(e,n),C=n.externalView;let y=!1;if(v){const e=v({row:o,value:p,field:n.field,column:n,cellEl:s});"string"==typeof e?(s.innerHTML=q(e),y=!0):e instanceof Node?e.parentElement!==s&&(s.textContent="",s.appendChild(e)):null==e&&(s.textContent=null==p?"":String(p))}else if(C){const t=C,i=document.createElement("div");i.setAttribute("data-external-view",""),i.setAttribute("data-field",n.field),s.appendChild(i);const r={row:o,value:p,field:n.field,column:n};if(t.mount)try{t.mount({placeholder:i,context:r,spec:t})}catch(g){_("TBW063",`External view mount error for column '${n.field}': ${g}`,e.id)}else queueMicrotask(()=>{try{e.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:i,spec:t,context:r}}))}catch(g){_("TBW064",`External view event dispatch error for column '${n.field}': ${g}`,e.id)}});i.setAttribute("data-mounted","")}else if(b){const e=b({row:o,value:p,field:n.field,column:n}),t=b.__blocked;s.innerHTML=t?"":q(e),y=!0,t&&(s.textContent="",s.setAttribute("data-blocked-template",""))}else if(m){const e=m.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(s.textContent="",s.setAttribute("data-blocked-template","")):(s.innerHTML=q(W(e,{row:o,value:p})),y=!0)}else w?s.textContent=null==p?"":String(p):"date"===n.type?s.textContent=ae(p):"boolean"===n.type?s.innerHTML=le(!!p):s.textContent=null==p?"":String(p);if(y){F(s);const e=s.textContent||"";/Proxy|Reflect\.ownKeys/.test(e)&&(s.textContent=e.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(s.textContent||"")&&(s.textContent=""))}s.hasAttribute("data-blocked-template")&&(s.textContent||"").trim().length&&(s.textContent="");("function"==typeof n.editable?n.editable(o):n.editable)?s.tabIndex=0:"boolean"===n.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),c===i&&d===f?(s.classList.add("cell-focus"),s.setAttribute("aria-selected","true")):s.setAttribute("aria-selected","false");const R=n.cellClass;if(R)try{const e=R(o[n.field],o,n),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const o of t)o&&"string"==typeof o&&(s.classList.add(o),e+=(e?" ":"")+o);s.setAttribute("data-dynamic-classes",e)}}catch(g){_(l,`cellClass callback error for column '${n.field}': ${g}`,e.id)}h&&e._afterCellRender?.({row:o,rowIndex:i,column:n,colIndex:f,value:p,cellElement:s,rowElement:t}),u.appendChild(s)}t.appendChild(u)}function xe(e,t,o){if(t.target?.closest(".resize-handle"))return;const i=ce(o.querySelector(".cell[data-row]"));if(i<0)return;const n=e._rows[i];if(!n)return;if(e._dispatchRowClick?.(t,i,n,o))return;const r=t.target?.closest(".cell[data-col]");if(r){const o=Number(r.getAttribute("data-col"));if(!isNaN(o)){if(e._dispatchCellClick?.(t,i,o,r))return;const n=e._focusRow!==i||e._focusCol!==o;if(e._focusRow=i,e._focusCol=o,r.classList.contains("editing")){n&&(de(e._bodyEl??e),r.classList.add("cell-focus"));const o=t.target,i=r.contains(o)&&o.matches(we)?o:r.querySelector(we);try{i?.focus({preventScroll:!0})}catch{}return}Ae(e)}}}function Ae(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:o,viewportEl:i}=e._virtualization,n=o,r=i?.clientHeight??n?.clientHeight??0;if(n&&r>0){const o=e._focusRow*t;o<n.scrollTop?n.scrollTop=o:o+t>n.scrollTop+r&&(n.scrollTop=o-r+t)}}const o=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;o||e.refreshVirtualWindow(!1),de(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const i=e._focusRow,n=e._virtualization.start??0,r=e._virtualization.end??e._rows.length;if(i>=n&&i<r){const r=e._bodyEl.querySelectorAll(".data-grid-row")[i-n];let s=r?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=r?.querySelector(`.cell[data-col="${e._focusCol}"]`)??r?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const i=e.querySelector(".tbw-scroll-area");if(i&&s&&(!o||t?.forceHorizontalScroll))if(t?.forceScrollLeft)i.scrollLeft=0;else if(t?.forceScrollRight)i.scrollLeft=i.scrollWidth-i.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(r??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),o=i.getBoundingClientRect(),n=e.left-o.left+i.scrollLeft,r=n+e.width,l=i.scrollLeft+t.left,a=i.scrollLeft+i.clientWidth-t.right;n<l?i.scrollLeft=n-t.left:r>a&&(i.scrollLeft=r-i.clientWidth+t.right)}}if(o&&s.classList.contains("editing")){const e=s.querySelector(we);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(o&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else o||document.activeElement!==e&&e.focus({preventScroll:!0})}}}Ce.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const Te=/* @__PURE__ */new WeakMap;function He(e,t){const o=ce(t),i=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(o<0||i<0)return;e._focusRow=o,e._focusCol=i,de(e._bodyEl),t.classList.add("cell-focus"),t.setAttribute("aria-selected","true");const n=t.closest("tbw-grid");n&&document.activeElement!==n&&n.focus({preventScroll:!0})}function Pe(e,t,o,i){let n=null;const r=o.composedPath?.();if(n=r&&r.length>0?r[0]:o.target,n&&!t.contains(n)){const e=document.elementFromPoint(o.clientX,o.clientY);e&&(n=e)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,h,u,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(h=e._rows[c],f=e._visibleColumns[d],u=f?.field,g=h&&u?h[u]:void 0)),{type:i,row:h,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:u,value:g,column:f,originalEvent:o,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}function Me(e,t,o,i){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const o=e._rows.length-1,i=e._visibleColumns.length-1,n=void 0!==e._activeEditRows&&-1!==e._activeEditRows,r=e._visibleColumns[e._focusCol],s=r?.type,l=t.composedPath?.()??[],a=l.length?l[0]:t.target,c=e=>{if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable};if((!c(a)||"Home"!==t.key&&"End"!==t.key)&&!(c(a)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===a.tagName&&"number"===a.type||c(a)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||c(a)&&("Enter"===t.key||"Escape"===t.key)||n&&"select"===s&&("ArrowDown"===t.key||"ArrowUp"===t.key))){switch(t.key){case"Tab":return t.preventDefault(),t.shiftKey?e._focusCol>0?e._focusCol-=1:e._focusRow>0&&("function"==typeof e.commitActiveRowEdit&&e._activeEditRows===e._focusRow&&e.commitActiveRowEdit(),e._focusRow-=1,e._focusCol=i):e._focusCol<i?e._focusCol+=1:("function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow<o&&(e._focusRow+=1,e._focusCol=0)),void Ae(e);case"ArrowDown":n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=Math.min(o,e._focusRow+1),t.preventDefault();break;case"ArrowUp":n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const o=ue(e);e._focusCol=o?Math.max(0,e._focusCol-1):Math.min(i,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const o=ue(e);e._focusCol=o?Math.min(i,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void Ae(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=o,e._focusCol=i):e._focusCol=i,t.preventDefault(),void Ae(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(o,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const o=e._focusRow,i=e._focusCol,n=e._visibleColumns[i],r=e._rows[o],s=n?.field??"",l=s&&r?r[s]:void 0,a=e.querySelector(`[data-row="${o}"][data-col="${i}"]`),c=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:o,colIndex:i,column:n,field:s,value:l,row:r,cellEl:a,trigger:"keyboard",originalEvent:t}});e.dispatchEvent(c);const d=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:o,col:i}});if(e.dispatchEvent(d),c.defaultPrevented||d.defaultPrevented)return void t.preventDefault();break}default:return}Ae(e)}}(e,t),{signal:i}),o.addEventListener("mousedown",t=>function(e,t,o){const i=Pe(e,t,o,"mousedown");e._dispatchCellMouseDown?.(i)&&Te.set(e,!0)}(e,o,t),{signal:i}),document.addEventListener("mousemove",t=>function(e,t,o){if(!Te.get(e))return;const i=Pe(e,t,o,"mousemove");e._dispatchCellMouseMove?.(i)}(e,o,t),{signal:i}),document.addEventListener("mouseup",t=>function(e,t,o){if(!Te.get(e))return;const i=Pe(e,t,o,"mouseup");e._dispatchCellMouseUp?.(i),Te.set(e,!1)}(e,o,t),{signal:i})}let Le;function De(e){Le=e}class Oe{#e;#P=/* @__PURE__ */new Set;#M=/* @__PURE__ */new Map;constructor(e){this.#e=e}focusCell(e,t){const o=this.#e,i=o._rows.length-1;if(i<0)return;let n;if("string"==typeof t){if(n=o._visibleColumns.findIndex(e=>e.field===t),n<0)return}else n=t;const r=o._visibleColumns.length-1;r<0||(o._focusRow=Math.max(0,Math.min(e,i)),o._focusCol=Math.max(0,Math.min(n,r)),Ae(o))}get focusedCell(){const e=this.#e;if(0===e._rows.length||0===e._visibleColumns.length)return null;const t=e._visibleColumns[e._focusCol];return{rowIndex:e._focusRow,colIndex:e._focusCol,field:t?.field??""}}scrollToRow(e,t){const o=this.#e._virtualization;if(!o.enabled)return;const i=o.container;if(!i)return;const n=this.#e._rows.length;if(0===n)return;const r=Math.max(0,Math.min(e,n-1)),s=t?.align??"nearest",l=t?.behavior??"instant";let a,c;const d=o.positionCache;o.variableHeights&&d&&d.length>r?(a=d[r].offset,c=d[r].height):(a=r*o.rowHeight,c=o.rowHeight);const h=o.viewportEl?.clientHeight??i.clientHeight??0;if(h<=0)return;const u=i.scrollTop,g=a+c,f=u+h;let p;switch(s){case"start":p=a;break;case"center":p=a-h/2+c/2;break;case"end":p=g-h;break;default:if(a>=u&&g<=f)return;p=a<u?a:g-h}p=Math.max(0,p),"smooth"===l?i.scrollTo({top:p,behavior:"smooth"}):i.scrollTop=p}scrollToRowById(e,t){const o=this.#e._getRowEntry(e);o&&this.scrollToRow(o.index,t)}registerExternalFocusContainer(e){if(this.#P.has(e))return;this.#P.add(e);const t=new AbortController,o=t.signal,i=this.#e;e.addEventListener("focusin",()=>{i.dataset.hasFocus=""},{signal:o}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete i.dataset.hasFocus},{signal:o}),this.#M.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#P.delete(e);const t=this.#M.get(e);t&&(t(),this.#M.delete(e))}containsFocus(e){const t=e??document.activeElement;return!!t&&(!!this.#e.contains(t)||this.isInExternalFocusContainer(t))}isInExternalFocusContainer(e){for(const t of this.#P)if(t.contains(e))return!0;return!1}destroy(){for(const e of this.#M.values())e();this.#M.clear(),this.#P.clear()}}const ke="function"==typeof requestIdleCallback;function ze(e){ke?cancelIdleCallback(e):clearTimeout(e)}function Ie(e,t){if(t){const o=t({size:e});if("string"==typeof o){const e=document.createElement("div");return e.innerHTML=o,e}return o}return function(e){const t=document.createElement("div");return t.className=`tbw-spinner tbw-spinner--${e}`,t.setAttribute("role","progressbar"),t.setAttribute("aria-label","Loading"),t}(e)}function Ne(e){let t=null,o=null,i=null,n=null;const r=i=>{if(!t)return;const n=i.clientX-t.startX,r=Math.max(40,t.startWidth+n),s=e._visibleColumns[t.colIndex];s.width=r,s.__userResized=!0,s.__renderedWidth=r,null==o&&(o=requestAnimationFrame(()=>{o=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:s.field,width:r}}))};let s=!1;const l=()=>{const o=null!==t;o&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),null!==i&&(document.documentElement.style.cursor=i,i=null),null!==n&&(document.body.style.userSelect=n,n=null),t=null,o&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(o,s,a){o.preventDefault();const c=e._visibleColumns[s],d="number"==typeof c?.width?c.width:void 0,h=c?.__renderedWidth??d??a.getBoundingClientRect().width;t={startX:o.clientX,colIndex:s,startWidth:h},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),null===i&&(i=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",null===n&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(t){const o=e._visibleColumns[t];o&&(o.__userResized=!1,o.__renderedWidth=void 0,o.width=o.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:o.field,width:o.width}})))},dispose(){l()}}}const qe="data-animating",We={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},$e={change:500,insert:300,remove:200};function Fe(e,t){const o=We[t],i=getComputedStyle(e).getPropertyValue(o);if(i){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(i);if(!isNaN(e)&&e>0)return e}return $e[t]}function Be(e,t,o){if(t<0)return Promise.resolve(!1);const i=e.findRenderedRowElement?.(t);return i?new Promise(e=>{!function(e,t,o){e.removeAttribute(qe),e.offsetWidth,e.setAttribute(qe,t);const i=Fe(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(qe),o?.()},i)}(i,o,()=>e(!0))}):Promise.resolve(!1)}function Ue(e,t){if(t)return t(e);const o=e;return"id"in o&&null!=o.id?String(o.id):"_id"in o&&null!=o._id?String(o._id):void 0}function Ve(e,t,o){const i=Ue(e,o);return void 0===i&&y("TBW040",'Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.',t),i}class Ge{#e;constructor(e){this.#e=e}resolveRowId(e){return Ve(e,this.#e.id,this.#e.effectiveConfig?.getRowId)}getRow(e){return this.#e._getRowEntry(e)?.row}getRowEntry(e){return this.#e._getRowEntry(e)}updateRow(e,t,o="api"){const i=this.#e,n=i._getRowEntry(e);n||y(s,`Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`,i.id);const{row:r,index:l}=n,a=[];for(const[s,c]of Object.entries(t)){const e=r[s];e!==c&&(a.push({field:s,oldValue:e,newValue:c}),r[s]=c)}for(const{field:s,oldValue:c,newValue:d}of a)i.dispatchEvent(new CustomEvent("cell-change",{detail:{row:r,rowId:e,rowIndex:l,field:s,oldValue:c,newValue:d,changes:t,source:o},bubbles:!0,composed:!0}));a.length>0&&(Re(i),i._requestSchedulerPhase(ie.VIRTUALIZATION,"updateRow"),i._emitDataChange())}updateRows(e,t="api"){const o=this.#e;let i=!1;for(const{id:n,changes:r}of e){const e=o._getRowEntry(n);e||y(s,`Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`,o.id);const{row:l,index:a}=e;for(const[s,c]of Object.entries(r)){const e=l[s];e!==c&&(i=!0,l[s]=c,o.dispatchEvent(new CustomEvent("cell-change",{detail:{row:l,rowId:n,rowIndex:a,field:s,oldValue:e,newValue:c,changes:r,source:t},bubbles:!0,composed:!0})))}}i&&(Re(o),o._requestSchedulerPhase(ie.VIRTUALIZATION,"updateRows"),o._emitDataChange())}async insertRow(e,t,o=!0){const i=this.#e,n=Math.max(0,Math.min(e,i._rows.length));i.sourceRows=[...i.sourceRows,t];const r=[...i._rows];r.splice(n,0,t),i._rows=r,i._sortState&&(i.__originalOrder=[...i.__originalOrder,t]),Re(i),i._rebuildRowIdMap(),i.__rowRenderEpoch++;for(const s of i._rowPool)s.__epoch=-1;i.refreshVirtualWindow(!0),i._emitPluginEvent("row-inserted",{row:t,index:n}),i._emitDataChange(),o&&(await new Promise(e=>requestAnimationFrame(()=>e())),await Be(i,n,"insert"))}async removeRow(e,t=!0){const o=this.#e,i=o._rows[e];if(!i)return;t&&await Be(o,e,"remove");const n=o._rows.indexOf(i);if(n<0)return i;const r=[...o._rows];r.splice(n,1),o._rows=r;const s=o.sourceRows.indexOf(i);if(s>=0){const e=[...o.sourceRows];e.splice(s,1),o.sourceRows=e}if(o._sortState){const e=o.__originalOrder.indexOf(i);if(e>=0){const t=[...o.__originalOrder];t.splice(e,1),o.__originalOrder=t}}Re(o),o._rebuildRowIdMap(),o.__rowRenderEpoch++;for(const l of o._rowPool)l.__epoch=-1;return o.refreshVirtualWindow(!0),o._emitDataChange(),t&&requestAnimationFrame(()=>{o.querySelectorAll('[data-animating="remove"]').forEach(e=>{e.removeAttribute("data-animating")})}),i}}function Xe(e,t,o){const i=document.createElement(e);if(t)for(const n in t){const e=t[n];null!=e&&i.setAttribute(n,e)}return i}function Ye(e,t){const o=document.createElement("div");if(e&&(o.className=e),t)for(const i in t){const e=t[i];null!=e&&o.setAttribute(i,e)}return o}function je(e,t,o){const i=document.createElement("button");if(e&&(i.className=e),t)for(const n in t){const e=t[n];null!=e&&i.setAttribute(n,e)}return i}const Ke=document.createElement("template");function Ze(){return Ke.content.cloneNode(!0)}function Qe(e){const t=document.createDocumentFragment(),o=Ye(e.hasShell?"tbw-grid-root has-shell":"tbw-grid-root");if(e.hasShell&&e.shellHeader&&e.shellBody)o.appendChild(e.shellHeader),o.appendChild(e.shellBody);else{const e=Ye("tbw-grid-content");e.appendChild(Ze()),o.appendChild(e)}return t.appendChild(o),t}function Je(e){return e?"string"==typeof e?e:e.outerHTML:""}function et(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function tt(e,t){const o=e.querySelector("tbw-grid-header");if(!o)return;if(!t.lightDomTitle){const e=o.getAttribute("title");e&&(t.lightDomTitle=e)}const i=o.querySelectorAll("tbw-grid-header-content");i.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(i)),o.style.display="none"}function ot(e,t,o){const i=e.querySelector(":scope > tbw-grid-tool-buttons");if(!i)return;t.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:e=>{for(;i.firstChild;)e.appendChild(i.firstChild);return()=>{for(;e.firstChild;)i.appendChild(e.firstChild)}}};t.toolbarContents.set(n,r),t.lightDomToolbarContentIds.add(n),i.style.display="none"}function it(e,t,o){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const i=e,n=i.getAttribute("id"),r=i.getAttribute("title");if(!n||!r)return void _("TBW070",`Tool panel missing required id or title attribute: id="${n??""}", title="${r??""}"`);const s=i.getAttribute("icon")??void 0,l=i.getAttribute("tooltip")??void 0,a=parseInt(i.getAttribute("order")??"100",10);let c;const d=o?.(i);if(d)c=d;else{const e=i.innerHTML.trim();c=t=>{const o=document.createElement("div");return o.innerHTML=e,t.appendChild(o),()=>o.remove()}}const h=t.toolPanels.get(n);if(h){if(d){h.render=c,h.order=a,h.icon=s,h.tooltip=l;const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n))}return}const u={id:n,title:r,icon:s,tooltip:l,order:a,render:c};t.toolPanels.set(n,u),t.lightDomToolPanelIds.add(n),i.style.display="none"})}function nt(e,t,o){const i=t?.header?.toolbarContents??[],n=[...o.toolbarContents.values()],r=new Set(i.map(e=>e.id)),s=[...i];for(const l of n)r.has(l.id)||s.push(l);for(const l of s){if(o.toolbarContentCleanups.has(l.id))continue;if(!l.render)continue;const t=e.querySelector(`[data-toolbar-content="${l.id}"]`);if(!t)continue;const i=l.render(t);i&&o.toolbarContentCleanups.set(l.id,i)}}function rt(e,t){const o=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,i=t.headerContents.size>0;if(!o&&!i)return;const n=e.querySelector(".tbw-shell-content");if(!n)return;if(o){for(const e of t.lightDomHeaderContent)e.style.display="",n.appendChild(e);t.lightDomContentMoved=!0}const r=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of r){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let o=n.querySelector(`[data-header-content="${s.id}"]`);o||(o=document.createElement("div"),o.setAttribute("data-header-content",s.id),n.appendChild(o));const i=s.render(o);i&&t.headerContentCleanups.set(s.id,i)}}function st(e,t,o){if(t.isPanelOpen)for(const[i,n]of t.toolPanels){const o=t.expandedSections.has(i),r=e.querySelector(`[data-section="${i}"]`),s=r?.querySelector(".tbw-accordion-content");if(!r||!s)continue;r.classList.toggle("expanded",o);const l=r.querySelector(".tbw-accordion-header");if(l&&l.setAttribute("aria-expanded",String(o)),o){if(0===s.children.length){const e=n.render(s);e&&t.panelCleanups.set(i,e)}}else{const e=t.panelCleanups.get(i);e&&(e(),t.panelCleanups.delete(i)),s.innerHTML=""}}}function lt(e,t){const o=e.querySelector("[data-panel-toggle]");o&&(o.classList.toggle("active",t.isPanelOpen),o.setAttribute("aria-pressed",String(t.isPanelOpen)))}function at(e,t){const o=e.querySelector(".tbw-tool-panel");o&&(o.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(o.style.width=""))}function ct(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear(),e.lightDomContentMoved=!1}function dt(e,t,o){const i=e.querySelector(`[data-section="${t}"]`);i&&i.classList.toggle("expanded",o)}function ht(e,t,o,i){const r=et(t),s=[],l=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const n of l){e.querySelectorAll(`:scope > ${n}`).forEach(e=>s.push(e))}e.replaceChildren();for(const n of s)e.appendChild(n);if(r){const r=Je(i?.toolPanel??n.toolPanel),s=Je(i?.expand??n.expand);Je(i?.collapse??n.collapse);const l=[...t?.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),a=[...t?.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100)),c={title:t?.header?.title??void 0,hasPanels:a.length>0,isPanelOpen:o.isPanelOpen,toolPanelIcon:r,configButtons:l.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},d={position:t?.toolPanel?.position??"right",isPanelOpen:o.isPanelOpen,expandIcon:s,panels:a.map(e=>({id:e.id,title:e.title,icon:Je(e.icon),isExpanded:o.expandedSections.has(e.id)}))},h=Qe({hasShell:!0,shellHeader:function(e){const t=Ye("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const o=Ye("tbw-shell-title");o.textContent=e.title,t.appendChild(o)}const o=Ye("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(o);const i=Ye("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const n of e.configButtons)n.hasRender&&i.appendChild(Ye("tbw-toolbar-content-slot",{"data-toolbar-content":n.id}));for(const n of e.apiButtons)n.hasRender&&i.appendChild(Ye("tbw-toolbar-content-slot",{"data-toolbar-content":n.id}));if((e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender))&&e.hasPanels&&i.appendChild(Ye("tbw-toolbar-separator")),e.hasPanels){const t=je(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.innerHTML=e.toolPanelIcon,i.appendChild(t)}return t.appendChild(i),t}(c),shellBody:function(e){const t=Ye("tbw-shell-body"),o=e.panels.length>0,i=1===e.panels.length,n=Ye("tbw-grid-content");n.appendChild(Ze());let r=null;if(o){r=Xe("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel"});const t="left"===e.position?"right":"left";r.appendChild(Ye("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":t,"aria-hidden":"true"}));const o=Ye("tbw-tool-panel-content",{role:"presentation"}),n=Ye("tbw-accordion");for(const r of e.panels){const t=Ye(`tbw-accordion-section${r.isExpanded?" expanded":""}${i?" single":""}`,{"data-section":r.id}),o=je("tbw-accordion-header",{"aria-expanded":String(r.isExpanded),"aria-controls":`tbw-section-${r.id}`});if(i&&o.setAttribute("aria-disabled","true"),r.icon){const e=Xe("span",{class:"tbw-accordion-icon"});e.innerHTML=r.icon,o.appendChild(e)}const s=Xe("span",{class:"tbw-accordion-title"});if(s.textContent=r.title,o.appendChild(s),!i){const t=Xe("span",{class:"tbw-accordion-chevron"});t.innerHTML=e.expandIcon,o.appendChild(t)}t.appendChild(o),t.appendChild(Ye("tbw-accordion-content",{id:`tbw-section-${r.id}`,role:"presentation"})),n.appendChild(t)}o.appendChild(n),r.appendChild(o)}return"left"===e.position&&r?(t.appendChild(r),t.appendChild(n)):(t.appendChild(n),r&&t.appendChild(r)),t}(d)});e.appendChild(h)}else{const t=Qe({hasShell:!1});e.appendChild(t)}return r}Ke.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n <div class="tbw-sr-only" aria-live="polite" aria-atomic="true"></div>\n';const ut="tbw-grid-styles";let gt="";const ft=/* @__PURE__ */new Map;function pt(){const e=function(){let e=document.getElementById(ut);return e||(e=document.createElement("style"),e.id=ut,e.setAttribute("data-tbw-grid","true"),document.head.appendChild(e)),e}(),t=Array.from(ft.values()).join("\n");e.textContent=`${gt}\n\n/* Plugin Styles */\n${t}`}async function wt(e){if(gt)return;if("string"==typeof e&&e.length>0)return gt=e,void pt();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){_("TBW120",`Failed to extract grid.css from document stylesheets: ${e}`)}return null}();t?(gt=t,pt()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||_("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 bt(e){e.startY=null,e.startX=null,e.lastY=null,e.lastX=null,e.lastTime=null,e.locked=!1}function mt(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function vt(e,t){(Math.abs(e.velocityY)>.1||Math.abs(e.velocityX)>.1)&&function(e,t){const o=.95,i=.01,n=()=>{e.velocityY*=o,e.velocityX*=o;const r=16*e.velocityY,s=16*e.velocityX;Math.abs(e.velocityY)>i&&(t.fauxScrollbar.scrollTop+=r),Math.abs(e.velocityX)>i&&t.scrollArea&&(t.scrollArea.scrollLeft+=s),Math.abs(e.velocityY)>i||Math.abs(e.velocityX)>i?e.momentumRaf=requestAnimationFrame(n):e.momentumRaf=0};e.momentumRaf=requestAnimationFrame(n)}(e,t),bt(e)}function Ct(e,t,o,i){e.addEventListener("pointerdown",o=>{"touch"===o.pointerType&&null===t.activePointerId&&(t.activePointerId=o.pointerId,e.setPointerCapture(o.pointerId),function(e,t,o){mt(o),o.startY=t,o.startX=e,o.lastY=t,o.lastX=e,o.lastTime=performance.now(),o.velocityY=0,o.velocityX=0,o.locked=!1}(o.clientX,o.clientY,t))},{passive:!0,signal:i}),e.addEventListener("pointermove",e=>{if(e.pointerId!==t.activePointerId)return;const i=function(e,t,o,i){if(null===o.lastY||null===o.lastX)return!1;const n=performance.now(),r=o.lastY-t,s=o.lastX-e;if(null!==o.lastTime){const e=n-o.lastTime;e>0&&(o.velocityY=r/e,o.velocityX=s/e)}if(o.lastY=t,o.lastX=e,o.lastTime=n,o.locked)return i.fauxScrollbar.scrollTop+=r,i.scrollArea&&(i.scrollArea.scrollLeft+=s),!0;const l=null!==o.startY?Math.abs(o.startY-t):0,a=null!==o.startX?Math.abs(o.startX-e):0;if(l<3&&a<3)return!1;const c=l>=a,{scrollHeight:d,clientHeight:h}=i.fauxScrollbar,u=d-h>0;let g=!1;if(i.scrollArea){const{scrollWidth:e,clientWidth:t}=i.scrollArea;g=e-t>0}return!!(c&&u||!c&&g)&&(o.locked=!0,i.fauxScrollbar.scrollTop+=r,i.scrollArea&&(i.scrollArea.scrollLeft+=s),!0)}(e.clientX,e.clientY,t,o);i&&e.preventDefault()},{passive:!1,signal:i}),e.addEventListener("pointerup",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,vt(t,o))},{passive:!0,signal:i}),e.addEventListener("pointercancel",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,bt(t))},{passive:!0,signal:i}),e.addEventListener("lostpointercapture",e=>{e.pointerId===t.activePointerId&&(t.activePointerId=null,bt(t))},{passive:!0,signal:i})}const yt=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',isUsed:e=>!0===e||"function"==typeof e},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property'},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property'},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property'},{property:"pinned",pluginName:"pinnedColumns",level:"column",description:'the "pinned" column property',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property (deprecated, use "pinned")',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e}],_t=[{property:"rowEditable",pluginName:"editing",level:"config",description:'the "rowEditable" config property',isUsed:e=>"function"==typeof e},{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',isUsed:e=>Array.isArray(e)&&e.length>0}];function Rt(e){return`import { ${St(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function St(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Et(e,t){return e.some(e=>e.name===t)}function xt(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 At(e,t,o){const i=xt(t,o);return"string"==typeof i?e.byKey.get(i):i&&"object"==typeof i?e.byRef.get(i):void 0}function Tt(e,t,o){if(t<0||t>=e.length)return;const i=e[t],n=o-i.height;if(0!==n){i.height=o,i.measured=!0;for(let o=t+1;o<e.length;o++)e[o].offset+=n}}function Ht(e,t){if(0===e.length)return-1;if(t<=0)return 0;let o=0,i=e.length-1;for(;o<=i;){const n=Math.floor((o+i)/2),r=e[n],s=r.offset+r.height;if(t<r.offset)i=n-1;else{if(!(t>=s))return n;o=n+1}}return Math.max(0,Math.min(o,e.length-1))}function Pt(e,t){const{positionCache:o,heightCache:i,rows:n,start:r,end:s,getPluginHeight:l,getRowId:a}=e;let c=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const d=parseInt(t,10);if(d<r||d>=s||d>=n.length)return;const h=n[d],u=l?.(h,d);if(void 0!==u){const e=o[d];return void((!e.measured||Math.abs(e.height-u)>1)&&(Tt(o,d,u),c=!0))}const g=e.offsetHeight;if(g>0){const e=o[d];(!e.measured||Math.abs(e.height-g)>1)&&(Tt(o,d,g),function(e,t,o,i){const n=xt(t,i);"string"==typeof n?e.byKey.set(n,o):n&&"object"==typeof n&&e.byRef.set(n,o)}(i,h,g,a),c=!0)}});const d=c?function(e){let t=0;for(const o of e)o.measured&&t++;return t}(o):0,h=c?function(e,t){let o=0,i=0;for(const n of e)n.measured&&(o+=n.height,i++);return i>0?o/i:t}(o,e.defaultHeight):0;return{hasChanges:c,measuredCount:d,averageHeight:h}}function Mt(e){const{totalRows:t,viewportHeight:o,scrollTop:i,rowHeight:n,overscan:r}=e,s=Math.ceil(o/n);let l=Math.floor(i/n)-r;l<0&&(l=0);let a=l+s+2*r;return a>t&&(a=t),a===t&&l>0&&(l=Math.max(0,a-s-2*r)),{start:l,end:a,offsetY:l*n,totalHeight:t*n}}function Lt(e,t){return e<=t}class Dt{#e;state;constructor(e,t){this.#e=e,this.state={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null,positionCache:null,heightCache:{byKey:/* @__PURE__ */new Map,byRef:/* @__PURE__ */new WeakMap},averageHeight:28,measuredCount:0,variableHeights:!1,cachedViewportHeight:0,cachedFauxHeight:0,cachedScrollAreaHeight:0,scrollAreaEl:null,...t}}updateCachedGeometry(){const e=this.state,t=e.container,o=e.viewportEl??t;o&&(e.cachedViewportHeight=o.clientHeight),t&&(e.cachedFauxHeight=t.clientHeight);const i=e.scrollAreaEl;i&&(e.cachedScrollAreaHeight=i.clientHeight)}calculateTotalSpacerHeight(e,t=!1){const o=this.state;let i,n,r;if(t){const e=o.container??this.#e._hostElement,t=o.viewportEl??e,s=o.scrollAreaEl;i=e?.clientHeight??0,n=t?.clientHeight??0,r=s?s.clientHeight:i,o.cachedFauxHeight=i,o.cachedViewportHeight=n,o.cachedScrollAreaHeight=r}else i=o.cachedFauxHeight,n=o.cachedViewportHeight,r=o.cachedScrollAreaHeight||i;const s=r-n,l=Math.max(0,i-r);let a,c=0;return o.variableHeights&&o.positionCache?a=function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(o.positionCache):(a=e*o.rowHeight,c=this.#e._getPluginExtraHeight()),a+s+c+l}initializePositionCache(){const e=this.state;if(!e.variableHeights)return;const t=this.#e,o=t._rows,i=e.rowHeight||28,n=t.effectiveConfig?.rowHeight,r=t.effectiveConfig?.getRowId,s=r?e=>r(e):void 0;e.positionCache=function(e,t,o,i,n){const r=new Array(e.length);let s=0;for(let l=0;l<e.length;l++){const a=e[l];let c=n?.(a,l),d=void 0!==c;void 0===c&&(c=At(t,a,i.rowId),d=void 0!==c),void 0===c&&(c=o,d=!1),r[l]={offset:s,height:c,measured:d},s+=c}return r}(o,e.heightCache,i,{rowId:s},(e,o)=>{const i=t._getPluginRowHeight(e,o);if(void 0!==i)return i;if(n){const t=n(e,o);if(void 0!==t&&t>0)return t}});const l=function(e,t,o,i){let n=0,r=0;for(let s=0;s<e.length;s++){const o=e[s];if(o.measured){const e=i?.(t[s],s);void 0===e&&(r+=o.height,n++)}}return{measuredCount:n,averageHeight:n>0?r/n:o}}(e.positionCache,o,i,(e,o)=>t._getPluginRowHeight(e,o));e.measuredCount=l.measuredCount,l.measuredCount>0&&(e.averageHeight=l.averageHeight)}invalidateRowHeight(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#e._rows;if(e<0||e>=i.length)return;const n=i[e];let r=t;void 0===r&&(r=this.#e._getPluginRowHeight(n,e)),void 0===r&&(r=o.rowHeight);const s=o.positionCache[e];if(s&&!(Math.abs(s.height-r)<1)&&(Tt(o.positionCache,e,r),o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(i.length);o.totalHeightEl.style.height=`${e}px`}}measureRenderedRowHeights(e,t){const o=this.state;if(!o.variableHeights)return;if(!o.positionCache)return;const i=this.#e,n=i._bodyEl;if(!n)return;const r=n.querySelectorAll(".data-grid-row"),s=i.effectiveConfig?.getRowId,l=i._rows,a=Pt({positionCache:o.positionCache,heightCache:o.heightCache,rows:l,defaultHeight:o.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>i._getPluginRowHeight(e,t),getRowId:s?e=>s(e):void 0},r);if(a.hasChanges&&(o.measuredCount=a.measuredCount,o.averageHeight=a.averageHeight,o.totalHeightEl)){const e=this.calculateTotalSpacerHeight(l.length);o.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){const o=this.state,i=this.#e,n=i._bodyEl;if(!n)return!1;const r=i._rows.length;if(!o.enabled)return i._renderVisibleRows(0,r),t||i._afterPluginRender(),!0;if(r<=o.bypassThreshold)return o.start=0,o.end=r,e&&(n.style.transform="translateY(0px)"),i._renderVisibleRows(0,r,i.__rowRenderEpoch),e&&o.totalHeightEl&&(o.totalHeightEl.style.height=`${this.calculateTotalSpacerHeight(r,!0)}px`),i._updateAriaCounts(r,i._visibleColumns.length),t||i._afterPluginRender(),!0;const s=o.container,l=o.viewportEl??s,a=e?o.cachedViewportHeight=l.clientHeight:o.cachedViewportHeight||(o.cachedViewportHeight=l.clientHeight),c=o.rowHeight,d=s.scrollTop;let h;e&&o.variableHeights&&this.initializePositionCache();const u=o.positionCache;if(o.variableHeights&&u&&u.length>0)h=Ht(u,d),-1===h&&(h=0);else{h=Math.floor(d/c);let e=0;const t=10;for(;e<t;){const t=i._getPluginExtraHeightBefore(h),o=Math.floor((d-t)/c);if(o>=h||o<0)break;h=o,e++}}h-=h%2,h<0&&(h=0);const g=i._adjustPluginVirtualStart(h,d,c);let f;if(void 0!==g&&g<h&&(h=g,h-=h%2,h<0&&(h=0)),o.variableHeights&&u&&u.length>0){const e=a+3*c;let t=0;for(f=h;f<r&&t<e;)t+=u[f].height,f++;const o=Math.ceil(a/c)+3;f-h<o&&(f=Math.min(h+o,r))}else{f=h+(Math.ceil(a/c)+3)}f>r&&(f=r);const p=o.start,w=o.end;if(!e&&h===p&&f===w)return!1;o.start=h,o.end=f;const b=e?o.cachedFauxHeight=s.clientHeight:o.cachedFauxHeight||(o.cachedFauxHeight=s.clientHeight);if(e){const e=o.scrollAreaEl;e&&(o.cachedScrollAreaHeight=e.clientHeight)}if(0===b&&a>0)return i._requestSchedulerPhase(ie.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&o.totalHeightEl){const e=this.calculateTotalSpacerHeight(r);o.totalHeightEl.style.height=`${e}px`}let m;if(o.variableHeights&&u&&u[h])m=u[h].offset;else{m=h*c+i._getPluginExtraHeightBefore(h)}const v=-(d-m);return n.style.transform=`translateY(${v}px)`,i._renderVisibleRows(h,f,i.__rowRenderEpoch),e&&o.variableHeights&&this.measureRenderedRowHeights(h,f),i._updateAriaCounts(r,i._visibleColumns.length),e&&!t&&(i._afterPluginRender(),queueMicrotask(()=>{if(!o.totalHeightEl)return;const e=this.calculateTotalSpacerHeight(r);0===o.cachedFauxHeight&&o.cachedViewportHeight>0||(o.totalHeightEl.style.height=`${e}px`)})),!0}}class Ot{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=/* @__PURE__ */new Map;cellRenderers=/* @__PURE__ */new Map;headerRenderers=/* @__PURE__ */new Map;cellEditors=/* @__PURE__ */new Map;_hasAfterCellRender=!1;_hasAfterRowRender=!1;eventListeners=/* @__PURE__ */new Map;queryHandlers=/* @__PURE__ */new Map;static deprecationWarned=/* @__PURE__ */new WeakSet;attachAll(e){for(const t of e)this.attach(t)}attach(e){if(function(e,t,o){const i=e.name,n=e.constructor.dependencies??[];for(const r of n){const e=r.name,n=r.required??!0,s=r.reason;if(!t.some(t=>t.name===e)){const t=s??`${St(i)}Plugin requires ${St(e)}Plugin`,r=Rt(e);n?y("TBW020",`Plugin dependency error:\n\n${t}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${St(i)}Plugin:\n ${r}\n plugins: [new ${St(e)}Plugin(), new ${St(i)}Plugin()]`,o):R("TBW021",`${St(i)}Plugin: Optional "${e}" plugin not found. Some features may be unavailable.`,o)}}}(e,this.plugins,this.grid.getAttribute("id")??void 0),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,o]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,o);if(e.headerRenderers)for(const[t,o]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,o);if(e.cellEditors)for(const[t,o]of Object.entries(e.cellEditors))this.cellEditors.set(t,o);this.registerQueryHandlers(e),this.warnDeprecatedHooks(e),e.attach(this.grid),this.#L();for(const t of this.plugins)t!==e&&t.onPluginAttached&&t.onPluginAttached(e.name,e)}registerQueryHandlers(e){const t=e.constructor.manifest;if(t?.queries)for(const o of t.queries){let t=this.queryHandlers.get(o.type);t||(t=/* @__PURE__ */new Set,this.queryHandlers.set(o.type,t)),t.add(e)}}warnDeprecatedHooks(e){const t=e.constructor;if(Ot.deprecationWarned.has(t))return;if(!se())return;const o="function"==typeof e.getExtraHeight||"function"==typeof e.getExtraHeightBefore,i="function"==typeof e.getRowHeight;o&&!i&&(Ot.deprecationWarned.add(t),_("TBW023",`"${e.name}" uses getExtraHeight() / getExtraHeightBefore() which are deprecated and will be removed in v2.0.\n → Migrate to getRowHeight(row, index) for better variable row height support.`,this.grid.getAttribute("id")??void 0))}unregisterQueryHandlers(e){for(const[t,o]of this.queryHandlers)o.delete(e),0===o.size&&this.queryHandlers.delete(t)}detachAll(){for(const e of this.plugins)for(const t of this.plugins)t!==e&&t.onPluginDetached&&t.onPluginDetached(e.name);for(let e=this.plugins.length-1;e>=0;e--){const t=this.plugins[e];this.unsubscribeAll(t),this.unregisterQueryHandlers(t),t.detach()}this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear(),this.eventListeners.clear(),this.queryHandlers.clear(),this._hasAfterCellRender=!1,this._hasAfterRowRender=!1}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(t=>t.name===e||t.aliases?.includes(e))}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getRegisteredPluginNames(){return this.plugins.map(e=>e.name)}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getPluginStyles(){return this.plugins.filter(e=>e.styles).map(e=>({name:e.name,styles:e.styles}))}processRows(e){let t=[...e];for(const o of this.plugins)o.processRows&&(t=o.processRows(t));return t}processColumns(e){let t=[...e];for(const o of this.plugins)o.processColumns&&(t=o.processColumns(t));return t}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.plugins)e.afterRender?.()}afterCellRender(e){for(const t of this.plugins)t.afterCellRender?.(e)}hasAfterCellRenderHook(){return this._hasAfterCellRender}afterRowRender(e){for(const t of this.plugins)t.afterRowRender?.(e)}hasAfterRowRenderHook(){return this._hasAfterRowRender}#L(){this._hasAfterCellRender=this.plugins.some(e=>"function"==typeof e.afterCellRender),this._hasAfterRowRender=this.plugins.some(e=>"function"==typeof e.afterRowRender)}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const t of this.plugins)"function"==typeof t.getExtraHeight&&(e+=t.getExtraHeight());return e}hasExtraHeight(){for(const e of this.plugins)if("function"==typeof e.getExtraHeight&&e.getExtraHeight()>0)return!0;return!1}getExtraHeightBefore(e){let t=0;for(const o of this.plugins)"function"==typeof o.getExtraHeightBefore&&(t+=o.getExtraHeightBefore(e));return t}getRowHeight(e,t){for(const o of this.plugins)if("function"==typeof o.getRowHeight){const i=o.getRowHeight(e,t);if(void 0!==i)return i}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,o){let i=e;for(const n of this.plugins)if("function"==typeof n.adjustVirtualStart){const r=n.adjustVirtualStart(e,t,o);r<i&&(i=r)}return i}renderRow(e,t,o){for(const i of this.plugins)if(i.renderRow?.(e,t,o))return!0;return!1}queryPlugins(e){const t=[],o=this.queryHandlers.get(e.type);if(o&&o.size>0){for(const i of o){const o=i.handleQuery?.(e)??i.onPluginQuery?.(e);void 0!==o&&t.push(o)}return t}for(const i of this.plugins){const o=i.handleQuery?.(e)??i.onPluginQuery?.(e);void 0!==o&&t.push(o)}return t}subscribe(e,t,o){let i=this.eventListeners.get(t);i||(i=/* @__PURE__ */new Map,this.eventListeners.set(t,i)),i.set(e,o)}unsubscribe(e,t){const o=this.eventListeners.get(t);o&&(o.delete(e),0===o.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,o]of this.eventListeners)o.delete(e),0===o.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const o=this.eventListeners.get(e);if(o)for(const n of o.values())try{n(t)}catch(i){S("TBW024",`Error in plugin event handler for "${e}": ${i}`,this.grid.getAttribute("id")??void 0)}}onKeyDown(e){for(const t of this.plugins)if(t.onKeyDown?.(e))return!0;return!1}onCellClick(e){for(const t of this.plugins)if(t.onCellClick?.(e))return!0;return!1}onRowClick(e){for(const t of this.plugins)if(t.onRowClick?.(e))return!0;return!1}onHeaderClick(e){for(const t of this.plugins)if(t.onHeaderClick?.(e))return!0;return!1}onScroll(e){for(const t of this.plugins)t.onScroll?.(e)}onCellMouseDown(e){for(const t of this.plugins)if(t.onCellMouseDown?.(e))return!0;return!1}onCellMouseMove(e){for(const t of this.plugins)if(t.onCellMouseMove?.(e))return!0;return!1}onCellMouseUp(e){for(const t of this.plugins)if(t.onCellMouseUp?.(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let o=0,i=0,n=!1;for(const r of this.plugins){const s=r.getHorizontalScrollOffsets?.(e,t);s&&(o+=s.left,i+=s.right,s.skipScroll&&(n=!0))}return{left:o,right:i,skipScroll:n}}getToolPanels(){const e=[];for(const t of this.plugins){const o=t.getToolPanel?.();o&&e.push({plugin:t,panel:o})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const o=t.getHeaderContent?.();o&&e.push({plugin:t,content:o})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}}class kt extends HTMLElement{static tagName="tbw-grid";static version="1.26.1";static#D=0;static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode","loading"]}get#O(){return this}#k=!1;#i;#n;#z=[];get#p(){return this.#I?.effective??{}}#N=!1;#q=!1;#W={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#$;#F=0;#B=null;#U=!1;#V=!1;#G=0;#X;#Y={startY:null,startX:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0,locked:!1,activePointerId:null};#j;#K;#Z;#Q;#J={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#ee;#te;#oe;#ie;#ne;#re;get _pluginManager(){return this.#ee}#se=!1;#le;#ae;#y;#I;#ce=function(){return{toolPanels:/* @__PURE__ */new Map,headerContents:/* @__PURE__ */new Map,toolbarContents:/* @__PURE__ */new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:/* @__PURE__ */new Set,lightDomToolbarContentIds:/* @__PURE__ */new Set,apiToolPanelIds:/* @__PURE__ */new Set,apiHeaderContentIds:/* @__PURE__ */new Set,isPanelOpen:!1,expandedSections:/* @__PURE__ */new Set,headerContentCleanups:/* @__PURE__ */new Map,panelCleanups:/* @__PURE__ */new Map,toolbarContentCleanups:/* @__PURE__ */new Map,lightDomContentMoved:!1}}();#de;#he;#ue;#ge=!1;#fe=/* @__PURE__ */new Set;#pe=/* @__PURE__ */new Map;#we;#be=/* @__PURE__ */new Map;_rows=[];#me=[];get _columns(){return this.#p.columns??[]}set _columns(e){this.#p.columns=e,this.#ve=void 0}#ve;get _visibleColumns(){return this.#ve??=this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;get _virtualization(){return this.#ie.state}set _virtualization(e){Object.assign(this.#ie.state,e)}_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#I?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#I&&(this.#I.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#I?.originalColumnNodes}set __originalColumnNodes(e){this.#I&&(this.#I.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=this.#z;this.#z=e,t!==e&&this.#Ce("rows")}get sourceRows(){return this.#z}set sourceRows(e){this.#z=e}get columns(){return[...this._columns]}set columns(e){const t=this.#I?.getColumns();this.#I?.setColumns(e),t!==e&&this.#Ce("columns")}get gridConfig(){return this.#p}set gridConfig(e){e&&this.__frameworkAdapter?.processConfig&&(e=this.__frameworkAdapter.processConfig(e));const t=this.#I?.getGridConfig();this.#I?.setGridConfig(e),t!==e&&(this.#I.clearLightDomCache(),this.#Ce("gridConfig"))}get fitMode(){return this.#p.fitMode??"stretch"}set fitMode(e){const t=this.#I?.getFitMode();this.#I?.setFitMode(e),t!==e&&this.#Ce("fitMode")}get loading(){return this.#ge}set loading(e){const t=this.#ge;this.#ge=e,e?this.setAttribute("loading",""):this.removeAttribute("loading"),t!==e&&this.#ye()}setRowLoading(e,t){const o=this.#fe.has(e);t?this.#fe.add(e):this.#fe.delete(e),o!==t&&this.#_e(e,t)}setCellLoading(e,t,o){let i=this.#pe.get(e);const n=i?.has(t)??!1;o?(i||(i=/* @__PURE__ */new Set,this.#pe.set(e,i)),i.add(t)):(i?.delete(t),0===i?.size&&this.#pe.delete(e)),n!==o&&this.#Re(e,t,o)}isRowLoading(e){return this.#fe.has(e)}isCellLoading(e,t){return this.#pe.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#fe)this.#_e(e,!1);this.#fe.clear();for(const[e,t]of this.#pe)for(const o of t)this.#Re(e,o,!1);this.#pe.clear()}get effectiveConfig(){return this.#p}get disconnectSignal(){return this.#j||(this.#j=new AbortController),this.#j.signal}constructor(){super(),this.#Se(),this.#i=new Promise(e=>this.#n=e),this.#ie=new Dt(this),this.#ne=new Oe(this),this.#re=new Ge(this),this.#$=new ne(this),this.#$.setInitialReadyResolver(()=>this.#n?.()),this.#de=function(e,t){let o=!1;const i={get isInitialized(){return o},setInitialized(e){o=e},get isPanelOpen(){return e.isPanelOpen},get activePanel(){return e.isPanelOpen&&e.expandedSections.size>0?[...e.expandedSections][0]:null},get expandedSections(){return[...e.expandedSections]},openToolPanel(){if(e.isPanelOpen)return;if(0===e.toolPanels.size)return void _("TBW071","No tool panels registered",t.id);if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0){const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}const o=t._renderRoot;lt(o,e),at(o,e),st(o,e,t._accordionIcons),t._emit("tool-panel-open",{sections:i.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolPanels.values())t.onClose?.();e.isPanelOpen=!1;const o=t._renderRoot;lt(o,e),at(o,e),t._emit("tool-panel-close",{})},toggleToolPanel(){e.isPanelOpen?i.closeToolPanel():i.openToolPanel()},toggleToolPanelSection(o){const i=e.toolPanels.get(o);if(!i)return void _("TBW072",`Tool panel section "${o}" not found`,t.id);if(1===e.toolPanels.size)return;const n=t._renderRoot,r=e.expandedSections.has(o);if(r){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),i.onClose?.(),e.expandedSections.delete(o),dt(n,o,!1)}else{for(const[t,i]of e.toolPanels)if(t!==o&&e.expandedSections.has(t)){const o=e.panelCleanups.get(t);o&&(o(),e.panelCleanups.delete(t)),i.onClose?.(),e.expandedSections.delete(t),dt(n,t,!1);const r=n.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(o),dt(n,o,!0),function(e,t,o){const i=t.toolPanels.get(o);if(!i?.render)return;const n=e.querySelector(`[data-section="${o}"] .tbw-accordion-content`);if(!n)return;const r=i.render(n);r&&t.panelCleanups.set(o,r)}(n,e,o)}t._emit("tool-panel-section-toggle",{id:o,expanded:!r})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(i){e.toolPanels.has(i.id)?_("TBW073",`Tool panel "${i.id}" already registered`,t.id):(e.toolPanels.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolPanel(i){if(e.expandedSections.has(i)){const t=e.panelCleanups.get(i);t&&(t(),e.panelCleanups.delete(i)),e.expandedSections.delete(i)}e.toolPanels.delete(i),o&&t.refreshShellHeader?.()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(i){e.headerContents.has(i.id)?_("TBW074",`Header content "${i.id}" already registered`,t.id):(e.headerContents.set(i.id,i),o&&rt(t._renderRoot,e))},unregisterHeaderContent(o){const i=e.headerContentCleanups.get(o);i&&(i(),e.headerContentCleanups.delete(o));const n=e.headerContents.get(o);n?.onDestroy?.(),e.headerContents.delete(o);const r=t._renderRoot.querySelector(`[data-header-content="${o}"]`);r?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(i){e.toolbarContents.has(i.id)?_("TBW075",`Toolbar content "${i.id}" already registered`,t.id):(e.toolbarContents.set(i.id,i),o&&t.refreshShellHeader?.())},unregisterToolbarContent(i){const n=e.toolbarContentCleanups.get(i);n&&(n(),e.toolbarContentCleanups.delete(i));const r=e.toolbarContents.get(i);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(i),o&&t.refreshShellHeader?.()}};return i}(this.#ce,this),this.#I=new re(this)}async#Se(){await wt('@layer tbw-base, tbw-plugins, tbw-theme;\n\n@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #666666);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-v: var(--tbw-spacing-xs);--tbw-cell-padding-h: var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-cell-padding-v) var(--tbw-cell-padding-h);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-width: 1px;--tbw-border-style: solid;--tbw-border-input: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-strong);--tbw-border-header: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-header);--tbw-row-divider: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline-width: 2px;--tbw-focus-outline: var(--tbw-focus-outline-width) var(--tbw-border-style) var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-display: inline-flex;--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm)}}\n@layer tbw-base{tbw-grid{color-scheme:inherit;position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);font-feature-settings:"tnum","lnum";background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none;&,*{box-sizing:border-box}.tbw-grid-root{position:relative;display:flex;flex-direction:column;height:100%;&.has-shell{display:flex;flex-direction:column;height:100%}&:has(.selected){user-select:none}}.rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}.rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}.rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}.rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip;touch-action:none;.rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}}.faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30);touch-action:none}.faux-vscroll-spacer{width:1px}.tbw-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}&[data-has-focus]{.cell-focus,.row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}}.sticky-left,.sticky-right{position:sticky;z-index:25}.sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}.sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}}}\n@layer tbw-base{tbw-grid{.header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}.header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}.header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start));&:not(:last-child){border-right:2px solid var(--tbw-color-border)}}.header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30);text-transform:var(--tbw-header-text-transform);letter-spacing:var(--tbw-header-letter-spacing);>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:visible;min-width:0;>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;color:var(--tbw-sort-indicator-color);display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}&:hover>span[part~=sort-indicator]{display:inline-flex;visibility:visible}&[aria-sort=ascending]>span[part~=sort-indicator],&[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color)}&:last-child{border-right:0;.resize-handle{right:0;width:calc(var(--tbw-resize-handle-width) / 2)}}&.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}&.resizable{position:relative}&.sticky-left,&.sticky-right{background:var(--tbw-color-header-bg);z-index:35}}}.sortable{cursor:pointer;user-select:none}.resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius);&:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}&:hover{background:var(--tbw-resize-handle-color-hover);&:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}}}}}\n@layer tbw-base{tbw-grid{.data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style;&:nth-child(2n){background:var(--tbw-color-row-alt)}&:hover{background:var(--tbw-color-row-hover)}>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);align-content:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis;>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}&:last-child{border-right:0}&[data-type=boolean]{text-align:center;input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}}&.selected:focus-visible,&:focus-visible:not(.cell-focus){outline:none}&.sticky-left,&.sticky-right{background:var(--tbw-color-panel-bg)}}}.selecting .data-grid-row>.cell{user-select:none}}}\n@layer tbw-base{tbw-grid{.tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}.tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}.tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}.tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease);&:hover{background:var(--tbw-color-row-hover)}&:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}&.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}&:disabled{opacity:.5;cursor:not-allowed}}.tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}.tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}.tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden;touch-action:none}.tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}}}\n@layer tbw-base{tbw-grid{.tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:var(--tbw-z-layer-toolpanel, 31);box-shadow:-2px 0 8px var(--tbw-color-shadow);&[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}&.open{width:var(--tbw-tool-panel-width)}}.tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease);&[data-handle-position=left]{left:0}&[data-handle-position=right]{right:0}&:hover,&.resizing{background:var(--tbw-color-accent)}}.tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}.tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px;&:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}}.tbw-tool-panel-content{flex:1;overflow:auto}.tbw-accordion{display:flex;flex-direction:column;gap:0}.tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border);&:last-child{border-bottom:none}&.single .tbw-accordion-header{cursor:default;&:hover{background:transparent}}&.expanded{.tbw-accordion-chevron{transform:rotate(90deg)}.tbw-accordion-content{display:block}}}.tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;user-select:none;&:hover{background:var(--tbw-color-row-hover)}}.tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}.tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}.tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tbw-accordion-content{display:none}}}\n@layer tbw-base{.tbw-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:1000;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-spinner{--tbw-spinner-size: 48px;--tbw-spinner-border-width: 3px;--tbw-spinner-color: var(--tbw-color-accent);--tbw-spinner-track-color: var(--tbw-color-border);width:var(--tbw-spinner-size);height:var(--tbw-spinner-size);border:var(--tbw-spinner-border-width) solid var(--tbw-spinner-track-color);border-top-color:var(--tbw-spinner-color);border-radius:50%;animation:tbw-spin .8s linear infinite}.tbw-spinner--large{--tbw-spinner-size: min(48px, calc(100% - 16px) )}.tbw-spinner--small{--tbw-spinner-size: calc(var(--tbw-row-height, 28px) * .6);--tbw-spinner-border-width: 2px}.data-grid-row.tbw-row-loading{position:relative;pointer-events:none}.tbw-row-loading-overlay{position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out;pointer-events:none;display:flex;align-items:center}.tbw-row-loading-spinner{--_spinner-size: calc(var(--tbw-row-height, 28px) * .6);margin-left:var(--tbw-spacing-md);width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite}.cell.tbw-cell-loading{position:relative;pointer-events:none;&:before{content:"";position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out}&:after{--_spinner-size: calc(var(--tbw-row-height, 28px) * .5);content:"";position:absolute;left:var(--tbw-spacing-sm);top:0;bottom:0;margin:auto 0;width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite;z-index:27}}}\n@layer tbw-base{tbw-grid{.tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}.tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}&[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}tbw-grid .data-grid-row[data-animating=change]{animation:tbw-row-change var(--tbw-row-change-duration) ease-out}tbw-grid .data-grid-row[data-animating=insert]{animation:tbw-row-insert var(--tbw-row-insert-duration) ease-out;will-change:max-height,opacity}tbw-grid .data-grid-row[data-animating=remove]{animation:tbw-row-remove var(--tbw-row-remove-duration) ease-out forwards;will-change:max-height,opacity,transform;pointer-events:none}}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-row-change{0%{background-color:transparent}20%{background-color:var(--tbw-row-change-color)}to{background-color:transparent}}@keyframes tbw-row-insert{0%{opacity:0;max-height:0;overflow:hidden}to{opacity:1;max-height:var(--tbw-row-height, 28px);overflow:hidden}}@keyframes tbw-row-remove{0%{opacity:1;transform:translateY(0);max-height:var(--tbw-row-height, 28px)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-spin{to{transform:rotate(360deg)}}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}\n@layer tbw-base{@media(forced-colors:active){tbw-grid{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight;.cell:focus,.cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}.data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}}\n')}getPlugin(e){return this.#ee?.getPlugin(e)}getPluginByName(e){return this.#ee?.getPluginByName(e)}requestRender(){this.#$.requestPhase(ie.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#$.requestPhase(ie.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#$.requestPhase(ie.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){P(this)}requestAfterRender(){this.#$.requestPhase(ie.STYLE,"plugin:requestAfterRender")}requestVirtualRefresh(){this._virtualization.start=-1,this.refreshVirtualWindow(!1)}#Ee(){this.#ee=new Ot(this);const e=this.#p?.plugins,t=Array.isArray(e)?e:[],o=this.#p?.features;let i=[];o&&Le&&(i=Le(o));const n=i.length>0?[...i,...t]:t;this.#ee.attachAll(n)}#xe(){!function(e){let t=!1;for(const{name:o,styles:i}of e)ft.has(o)||(ft.set(o,i),t=!0);t&&pt()}(this.#ee?.getPluginStyles()??[])}#Ae(){const e=this.#p?.plugins,t=Array.isArray(e)?e:[],o=this.#p?.features??void 0,i=o!==this.#oe;if((this.#te===t||void 0!==this.#te&&this.#te.length===t.length&&this.#te.every((e,o)=>e===t[o]))&&!i)return void(this.#te=t);this.#ee&&this.#ee.detachAll();for(const r of this.#ce.toolPanels.keys()){const e=this.#ce.lightDomToolPanelIds.has(r),t=this.#ce.apiToolPanelIds.has(r);if(!e&&!t){const e=this.#ce.panelCleanups.get(r);e&&(e(),this.#ce.panelCleanups.delete(r)),this.#ce.toolPanels.delete(r)}}for(const r of this.#ce.headerContents.keys()){if(this.#ce.apiHeaderContentIds.has(r))continue;const e=this.#ce.headerContentCleanups.get(r);e&&(e(),this.#ce.headerContentCleanups.delete(r)),this.#ce.headerContents.delete(r)}this.#Ee(),this.#xe(),this.#te=t,this.#oe=o,this.#Te(),this.#He();const n=this.#U;if(this.#U=this.#ee?.getAll().some(e=>e.onScroll)??!1,!n&&this.#U){const e=this.#O.querySelector(".tbw-grid-content")??this.#O.querySelector(".tbw-grid-root");this.#Pe(e)}}#Me(){this.#ee?.detachAll()}#He(){if(!this.#ee)return;const e=this.#ee.getToolPanels();for(const{panel:o}of e)this.#ce.toolPanels.has(o.id)||this.#ce.toolPanels.set(o.id,o);const t=this.#ee.getHeaderContents();for(const{content:o}of t)this.#ce.headerContents.has(o.id)||this.#ce.headerContents.set(o.id,o)}#Le(){const e=kt.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return o=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(o);if(e)return e}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",kt.version),this.id||(this.id="tbw-grid-"+ ++kt.#D),this._rows=Array.isArray(this.#z)?[...this.#z]:[],this.#j&&(this.#j.abort(),this.#se=!1),this.#j=new AbortController,this.#Q&&(ze(this.#Q),this.#Q=void 0),this.#De(),this.#I.parseLightDomColumns(this),this.#I.merge(),this.#Ee();const e=this.#p?.plugins;var t,o;this.#te=Array.isArray(e)?e:[],this.#oe=this.#p?.features??void 0,this.#He(),this.#k||(this.#Oe(),this.#xe(),this.#k=!0),this.#ke(),this.#Q=(t=()=>{this.#ze()},o={timeout:100},ke?requestIdleCallback(t,o):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#Q&&(ze(this.#Q),this.#Q=void 0),this.#G&&(clearTimeout(this.#G),this.#G=0),this.#Me(),function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const o=e.toolPanels.get(t);o?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#ce),this.#de.setInitialized(!1),this.#he?.(),this.#he=void 0,this.#ue?.(),this.#ue=void 0,mt(this.#Y),this.#j&&(this.#j.abort(),this.#j=void 0),this.#le?.abort(),this.#le=void 0,this.#se=!1,this._resizeController&&this._resizeController.dispose(),this.#K&&(this.#K.disconnect(),this.#K=void 0),this.#Z&&(this.#Z.disconnect(),this.#Z=void 0,this.#Ie=!1),Re(this),this.#Ne.clear(),this._virtualization.heightCache?.byKey.clear(),this.#te=void 0,this.#oe=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#N=!1}attributeChangedCallback(e,t,o){if("loading"===e){const e=null!==o&&"false"!==o;return void(this.loading!==e&&(this.loading=e))}if(t!==o&&o&&"null"!==o&&"undefined"!==o)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(o);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{_("TBW130",`Invalid JSON for '${e}' attribute: ${o}`,this.id)}else"fit-mode"===e&&(this.fitMode=o)}#ke(){const e=this.#O.querySelector(".tbw-grid-content")??this.#O.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.#de.isInitialized){rt(this.#O,this.#ce),nt(this.#O,this.#p?.shell,this.#ce);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#ce.toolPanels.has(e)&&(this.openToolPanel(),this.#ce.expandedSections.add(e)),this.#ce.isPanelOpen&&(at(this.#O,this.#ce),st(this.#O,this.#ce,(this.#p,this.#p)),lt(this.#O,this.#ce))}if(this.setAttribute("data-upgraded",""),this.#N=!0,this._resizeController=Ne(this),this.#qe(),this.#Pe(e),this.#se)return;this.#se=!0;const t=this.disconnectSignal;Me(this,this,this.#O,t),this.#Te(),queueMicrotask(()=>this.#We()),this.#$.requestPhase(ie.FULL,"afterConnect")}#Te(){const e=this.#p.rowHeight,t=this.#ee.hasRowHeightPlugin();"function"==typeof e||t?this._virtualization.variableHeights||(this._virtualization.variableHeights=!0,this._virtualization.rowHeight="number"==typeof e&&e>0?e:this._virtualization.rowHeight||28,this.#ie.initializePositionCache(),"function"!=typeof e&&(this.#V=!0)):!t&&"function"!=typeof e&&this._virtualization.variableHeights?(this._virtualization.variableHeights=!1,this._virtualization.positionCache=null):"number"==typeof e&&e>0?(this._virtualization.rowHeight=e,this._virtualization.variableHeights=!1):requestAnimationFrame(()=>this.#$e())}#$e(){if(this.#ee.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;if(e.style.getPropertyValue("--tbw-row-height"))return;const t=e.querySelectorAll(".cell");let o=0;t.forEach(e=>{const t=e.offsetHeight;t>o&&(o=t)});const i=e.getBoundingClientRect(),n=Math.max(i.height,o);n>0&&n-this._virtualization.rowHeight>1&&(this._virtualization.rowHeight=n,this.#$.requestPhase(ie.VIRTUALIZATION,"measureRowHeight"))}#Fe(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let o=0;t.forEach(e=>{const t=e.offsetHeight;t>o&&(o=t)});const i=e.getBoundingClientRect(),n=Math.max(i.height,o);if(n>0){if(Math.abs(n-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=n),this.#ie.initializePositionCache(),this._virtualization.totalHeightEl){const e=this.#ie.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#Pe(e){this.#le?.abort(),this.#le=new AbortController;const t=this.#le.signal,o=e?.querySelector(".faux-vscroll"),i=e?.querySelector(".rows");if(this._virtualization.container=o??this,this.#U=this.#ee?.getAll().some(e=>e.onScroll)??!1,o&&i){o.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#U)return;const e=o.scrollTop,t=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)i.style.transform=`translateY(${-e}px)`;else{const o=this._virtualization.positionCache;let n,r;if(this._virtualization.variableHeights&&o&&o.length>0){n=Ht(o,e),-1===n&&(n=0);const i=n-n%2;r=o[i]?.offset??i*t}else{n=Math.floor(e/t);r=(n-n%2)*t}const s=-(e-r);i.style.transform=`translateY(${s}px)`}this.#B=e,this.#F||(this.#F=requestAnimationFrame(()=>{this.#F=0,null!==this.#B&&(this.#Be(this.#B),this.#B=null)}))},{passive:!0,signal:t});const e=this.#O.querySelector(".tbw-scroll-area");this.#ae=e,this._virtualization.scrollAreaEl=e,e&&this.#U&&e.addEventListener("scroll",()=>{const t=this.#J;t.scrollTop=o.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=o.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=o.clientHeight,t.clientWidth=e.clientWidth,this.#ee?.onScroll(t)},{passive:!0,signal:t});const n=this.#O.querySelector(".tbw-grid-content"),r=this.#ae;n&&(n.addEventListener("wheel",e=>{try{if(n.querySelector("select:open"))return}catch{}const t=e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY);if(t&&r){const t=e.shiftKey?e.deltaY:e.deltaX,{scrollLeft:o,scrollWidth:i,clientWidth:n}=r;(t>0&&o<i-n||t<0&&o>0)&&(e.preventDefault(),r.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:i,clientHeight:n}=o;(e.deltaY>0&&t<i-n||e.deltaY<0&&t>0)&&(e.preventDefault(),o.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),Ct(n,this.#Y,{fauxScrollbar:o,scrollArea:r},t))}var n,r,s;this._bodyEl&&(n=this,r=this._bodyEl,s=t,r.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");if(!t)return;if(t.classList.contains("editing"))return;const o=e.target;o.draggable||o.closest('[draggable="true"]')||e.preventDefault(),He(n,t)},{signal:s}),r.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&xe(n,e,t),!document.activeElement?.closest(".cell.editing")){const t=e.target.closest("tbw-grid");t&&t.focus({preventScroll:!0})}},{signal:s}),r.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&xe(n,e,t)},{signal:s})),this.#K?.disconnect(),this._virtualization.viewportEl&&(this.#K=new ResizeObserver(()=>{this.#Ue(),this.#$.requestPhase(ie.VIRTUALIZATION,"resize-observer")}),this.#K.observe(this._virtualization.viewportEl)),this.#O.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#O.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#O.contains(t)||this.#ne.isInExternalFocusContainer(t))||delete this.dataset.hasFocus},{signal:t})}#Ie=!1;#Ve(){if(this.#Ie)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#Ie=!0,this.#Z?.disconnect(),this.#Z=new ResizeObserver(()=>{this.#$e()}),this.#Z.observe(e))}addEventListener(e,t,o){super.addEventListener(e,t,o)}removeEventListener(e,t,o){super.removeEventListener(e,t,o)}on(e,t){const o=e=>{t(e.detail,e)};return this.addEventListener(e,o),()=>this.removeEventListener(e,o)}#Ge(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_emitDataChange(){this.#Ge("data-change",{rowCount:this._rows.length,sourceRowCount:this.#z.length})}#We(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const o=t===this._focusRow;e.setAttribute("aria-selected",String(o)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(o&&t===this._focusCol))})})}#Ce(e){this.#W[e]=!0,this.#q||(this.#q=!0,queueMicrotask(()=>this.#Xe()))}#Xe(){if(!this.#q||!this.#N)return void(this.#q=!1);const e=this.#W;if(this.#q=!1,this.#W={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig)return this.#Ye(),void(e.rows&&this.#je());e.columns&&this.#Ke(),e.rows&&this.#je(),e.fitMode&&this.#Ze()}#je(){this._rows=Array.isArray(this.#z)?[...this.#z]:[],this._rebuildRowIdMap(),this.#$.requestPhase(ie.ROWS,"applyRowsUpdate")}_rebuildRowIdMap(){this.#be.clear();const e=this.#p.getRowId;this._rows.forEach((t,o)=>{const i=Ue(t,e);void 0!==i&&this.#be.set(i,{row:t,index:o})})}#Ke(){Re(this),this.#I.merge(),this.#qe()}#Ze(){this.#I.merge();"fixed"===this.#p.fitMode?(this.__didInitialAutoSize=!1,A(this)):(this._columns.forEach(e=>{!e.__userResized&&e.__autoSized&&delete e.width}),P(this))}#Ye(){tt(this,this.#ce),ot(this,this.#ce);const e=!!this.#O.querySelector(".has-shell"),t=!!this.#O.querySelector(".tbw-tool-panel"),o=this.#O.querySelectorAll(".tbw-accordion-section").length,i=this.#O.querySelector(".tbw-tool-panel")?.dataset.position??"right";this.#I.parseLightDomColumns(this),this.#I.merge(),this.#Ae(),this.#Te(),it(this,this.#ce,this.#Le()),this.#I.markSourcesChanged(),this.#I.merge();const n=et(this.#p?.shell),r=(this.#p?.shell?.toolPanels?.length??0)>0,s=this.#p?.shell?.toolPanels?.length??0,l=this.#p?.shell?.toolPanel?.position??"right";if(e!==n||!t&&r||t&&s!==o||t&&i!==l)return ct(this.#ce),this.#Oe(),this.#xe(),this.#ke(),void this._rebuildRowIdMap();e&&this.#Qe(),this._rebuildRowIdMap(),this.#$.requestPhase(ie.COLUMNS,"applyGridConfigUpdate")}#Qe(){const e=this.#O.querySelector(".tbw-shell-header");if(!e)return;const t=this.#p.shell?.header?.title??this.#ce.lightDomTitle;let o=e.querySelector(".tbw-shell-title");t?(o||(o=document.createElement("h2"),o.className="tbw-shell-title",o.setAttribute("part","shell-title"),e.insertBefore(o,e.firstChild)),o.textContent=t):o&&o.remove()}#Je(){if(this.__rowRenderEpoch++,this.#ee){const e=this.#me.length>0?this.#me:this._columns,t=e.filter(e=>!e.hidden),o=e.filter(e=>e.hidden),i=this.#ee.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,...o]:this._columns=this.#et(e,i,o)}else this._columns=[...e]}}#et(e,t,o){if(0===o.length)return t;const i=/* @__PURE__ */new Map;for(const l of t)i.set(l.field,l);const n=new Set(e.map(e=>e.field)),r=[];for(const l of t)n.has(l.field)||r.push(l);const s=[];for(const l of e){const e=i.get(l.field);e?s.push(e):l.hidden&&s.push(l)}return s.push(...r),s}#tt(){Re(this);const e=function(e,t){if(!e._sortState)return t;e.__originalOrder=[...t];const o=(e.effectiveConfig?.sortHandler??V)(t,e._sortState,e._columns);return o&&"function"==typeof o.then?t:o}(this,Array.isArray(this.#z)?[...this.#z]:[]),t=this.#ee?.processRows(e)??e;this._rows=t,this._rebuildRowIdMap(),this._virtualization.variableHeights&&this.#ie.initializePositionCache(),this._emitDataChange()}#ot(e){const t={...o,...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}_renderVisibleRows(e,t,o=this.__rowRenderEpoch){if(this.#X||(this.#X=(e,t,o)=>this.#ee?.renderRow(e,t,o)??!1),function(e,t,o,i,n){const r=Math.max(0,o-t),s=e._bodyEl,l=e._visibleColumns,a=l.length;let c=e.__cachedHeaderRowCount;for(void 0===c&&(c=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=c);e._rowPool.length<r;){const t=_e();e._rowPool.push(t)}if(e._rowPool.length>r){for(let t=r;t<e._rowPool.length;t++){const o=e._rowPool[t];o.parentNode===s&&o.remove()}e._rowPool.length=r}const d=n&&!1!==e.__hasRenderRowPlugins,h=e._hasAfterRowRenderHook?.()??!1,u=e._virtualization?.variableHeights&&"function"==typeof e.effectiveConfig?.rowHeight?e.effectiveConfig.rowHeight:null;for(let f=0;f<r;f++){const o=t+f,r=e._rows[o],p=e._rowPool[f];if(p.setAttribute("aria-rowindex",String(o+c+1)),d&&n(r,p,o)){p.__epoch=i,p.__rowDataRef=r,p.parentNode!==s&&s.appendChild(p);continue}const w=p.__epoch,b=p.__rowDataRef;let m=p.children.length;m>a&&p.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&m--;const v=w===i&&m===a,C=b!==r,y=!!e._isGridEditMode;let R=!1;if(v&&C)for(let e=0;e<a;e++)if(l[e].externalView&&!p.querySelector(`.cell[data-col="${e}"] [data-external-view]`)){R=!0;break}if(!v||R){const t=be(p),n=y&&!C||e._activeEditRows===o;t&&!n?(p.__isCustomRow&&(p.className="data-grid-row",p.setAttribute("role","row"),p.__isCustomRow=!1),me(p),Ee(e,p,r,o),p.__epoch=i,p.__rowDataRef=r):t&&n?(Se(e,p,r,o),p.__rowDataRef=r):(p.__isCustomRow&&(p.className="data-grid-row",p.setAttribute("role","row"),p.__isCustomRow=!1),Ee(e,p,r,o),p.__epoch=i,p.__rowDataRef=r)}else if(C){const t=be(p),n=e._activeEditRows===o;t&&!n?(me(p),Ee(e,p,r,o),p.__epoch=i,p.__rowDataRef=r):(Se(e,p,r,o),p.__rowDataRef=r)}else{const t=be(p),n=y||e._activeEditRows===o;t&&!n?(me(p),Ee(e,p,r,o),p.__epoch=i,p.__rowDataRef=r):Se(e,p,r,o)}let S=!1;const E=e._changedRowIdSet;if(E&&E.size>0)try{const t=e.getRowId?.(r);t&&(S=E.has(t))}catch{}S!==p.classList.contains("changed")&&p.classList.toggle("changed",S);const x=e.effectiveConfig?.rowClass;if(x){const t=p.getAttribute("data-dynamic-classes");t&&t.split(" ").forEach(e=>e&&p.classList.remove(e));try{const e=x(r),t="string"==typeof e?e.split(/\s+/):e;if(t&&t.length>0){let e="";for(const o of t)o&&"string"==typeof o&&(p.classList.add(o),e+=(e?" ":"")+o);p.setAttribute("data-dynamic-classes",e)}else p.removeAttribute("data-dynamic-classes")}catch(g){_("TBW060",`rowClass callback error: ${g}`,e.id),p.removeAttribute("data-dynamic-classes")}}if(u){const e=u(r,o);void 0!==e&&e>0?p.style.setProperty("--tbw-row-height",`${e}px`):p.style.removeProperty("--tbw-row-height")}h&&e._afterRowRender?.({row:r,rowIndex:o,rowElement:p}),p.parentNode!==s&&s.appendChild(p)}}(this,e,t,o,this.#X),this.#fe.size>0)for(const i of this.#fe)this.#_e(i,!0)}#it={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaDescribedBy:void 0};_updateAriaCounts(e,t){!function(e,t,o,i,n){if(i===e.rowCount&&n===e.colCount)return!1;const r=e.rowCount;e.rowCount=i,e.colCount=n,t&&(t.setAttribute("aria-rowcount",String(i)),t.setAttribute("aria-colcount",String(n))),i!==r&&o&&(i>0?o.setAttribute("role","rowgroup"):o.removeAttribute("role"))}(this.#it,this.__rowsBodyEl,this._bodyEl,e,t)}_requestSchedulerPhase(e,t){this.#$.requestPhase(e,t)}_getPluginExtraHeight(){return this.#ee?.getExtraHeight()??0}_getPluginRowHeight(e,t){return this.#ee?.getRowHeight?.(e,t)}_getPluginExtraHeightBefore(e){return this.#ee?.getExtraHeightBefore?.(e)??0}_adjustPluginVirtualStart(e,t,o){return this.#ee?.adjustVirtualStart(e,t,o)}_afterPluginRender(){this.#ee?.afterRender()}_emitPluginEvent(e,t){this.#ee?.emitPluginEvent(e,t)}_schedulerMergeConfig(){this.#I.parseLightDomColumns(this),this.#I.merge(),this.#Ae(),function(e,t,o){const i=yt,n=_t,r=/* @__PURE__ */new Map;function s(e,t,o,i,n=!1){r.has(e)||r.set(e,{description:t,importHint:o,fields:[],isConfigProperty:n});const s=r.get(e);s.fields.includes(i)||s.fields.push(i)}for(const a of n){const o=e[a.property];(a.isUsed?a.isUsed(o):void 0!==o)&&!Et(t,a.pluginName)&&s(a.pluginName,a.description,Rt(a.pluginName),a.property,!0)}const l=e.columns;if(l&&l.length>0)for(const a of l)for(const e of i){const o=a[e.property];if((e.isUsed?e.isUsed(o):void 0!==o)&&!Et(t,e.pluginName)){const t=a.field||"<unknown>";s(e.pluginName,e.description,Rt(e.pluginName),t)}}if(r.size>0){const e=[];for(const[t,{description:o,importHint:i,fields:n,isConfigProperty:s}]of r)if(s)e.push(`Config uses ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${St(t)}Plugin(), ...]`);else{const r=n.slice(0,3).join(", ")+(n.length>3?`, ... (${n.length} total)`:"");e.push(`Column(s) [${r}] use ${o}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${i}\n plugins: [new ${St(t)}Plugin(), ...]`)}y([...r.values()].some(e=>e.isConfigProperty)?"TBW002":"TBW001",`Configuration error:\n\n${e.join("\n\n")}\n\nThis validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`,o)}}(this.#p,this.#ee?.getPlugins()??[],this.id),function(e,t){const o=[],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=`[${St(n.name)}Plugin] Configuration warning: ${t.message}`;"error"===t.severity?o.push(e):i.push(e)}}}if(i.length>0&&se())for(const n of i)_("TBW004",n,t);o.length>0&&y("TBW003",`Configuration error:\n\n${o.join("\n\n")}`,t)}(this.#ee?.getPlugins()??[],this.id),function(e,t){if(!se())return;const o=new Set(e.map(e=>e.name)),i=/* @__PURE__ */new Set;for(const n of e){const e=n.constructor.manifest;if(e?.incompatibleWith)for(const r of e.incompatibleWith)if(o.has(r.name)){const e=[n.name,r.name].sort().join("↔");if(i.has(e))continue;i.add(e),_("TBW022",`${St(n.name)}Plugin and ${St(r.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${r.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`,t)}}}(this.#ee?.getPlugins()??[],this.id),this.#nt(),this.#me=[...this._columns]}_schedulerProcessColumns(){this.#Je()}_schedulerProcessRows(){this.#tt()}_schedulerRenderHeader(){ee(this)}_schedulerUpdateTemplate(){P(this)}_schedulerAfterRender(){this.#ee?.afterRender(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#ie.calculateTotalSpacerHeight(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`});"fixed"!==this.#p.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,A(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,Ae(this)),this._virtualization.enabled&&!this.#Ie&&this.#Ve(),this.#V&&(this.#V=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#Fe()})})),this.#ge&&this.#ye()}get _schedulerIsConnected(){return this.isConnected&&this.#N}get _hostElement(){return this}get _renderRoot(){return this.#O}_emit(e,t){this.#Ge(e,t)}get _accordionIcons(){return{expand:this.#p?.icons?.expand??n.expand,collapse:this.#p?.icons?.collapse??n.collapse}}get _shellState(){return this.#ce}_clearRowPool(){this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++}_setup(){this.#qe()}_applyAnimationConfig(e){this.#ot(e)}#nt(){!function(e,t,o,i){if(!t)return!1;let n=!1;const r=function(e,t){const o=e?.gridAriaLabel;return o||(e?.shell?.header?.title??t?.lightDomTitle??void 0)}(o,i);r!==e.ariaLabel&&(e.ariaLabel=r,r?t.setAttribute("aria-label",r):t.removeAttribute("aria-label"),n=!0);const s=o?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),n=!0)}(this.#it,this.__rowsBodyEl,this.#p,this.#ce)}#ye(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#ge?(this.#we||(this.#we=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(Ie("large",e)),t}(this.#p?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#we)):(t=this.#we,t?.remove()))}#_e(e,t){const o=this.#be.get(e);if(!o)return;const i=this.findRenderedRowElement?.(o.index);i&&function(e,t){if(t){if(e.classList.add("tbw-row-loading"),e.setAttribute("aria-busy","true"),!e.querySelector(".tbw-row-loading-overlay")){const t=document.createElement("div");t.className="tbw-row-loading-overlay",t.setAttribute("aria-hidden","true");const o=document.createElement("div");o.className="tbw-row-loading-spinner",t.appendChild(o),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}(i,t)}#Re(e,t,o){const i=this.#be.get(e);if(!i)return;const n=this.findRenderedRowElement?.(i.index);if(!n)return;const r=this._visibleColumns.findIndex(e=>e.field===t);if(r<0)return;const s=n.children[r];s&&function(e,t){t?(e.classList.add("tbw-cell-loading"),e.setAttribute("aria-busy","true")):(e.classList.remove("tbw-cell-loading"),e.removeAttribute("aria-busy"))}(s,o)}#qe(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#I.parseLightDomColumns(this),this.#y){const e=this.#y;this.#y=void 0,this.#I.merge();const t=this.#ee?.getAll()??[];this.#I.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#$.requestPhase(ie.FULL,"setup")}}#Be(e){let t=0,o=0,i=0,n=0,r=0;if(this.#U){const e=this._virtualization.container,s=this.#ae;t=s?.scrollLeft??0,o=e?.scrollHeight??0,i=s?.scrollWidth??0,n=e?.clientHeight??0,r=s?.clientWidth??0}if(this.refreshVirtualWindow(!1)&&this.#ee?.onScrollRender(),this._virtualization.variableHeights&&(this.#G&&clearTimeout(this.#G),this.#G=window.setTimeout(()=>{this.#G=0,this.#ie.measureRenderedRowHeights(this._virtualization.start,this._virtualization.end)},100)),this.#U){const s=this.#J;s.scrollTop=e,s.scrollLeft=t,s.scrollHeight=o,s.scrollWidth=i,s.clientHeight=n,s.clientWidth=r,this.#ee?.onScroll(s)}}findHeaderRow(){return this.#O.querySelector(".header-row")}findRenderedRowElement(e){const t=this._virtualization,o=e-t.start;return o>=0&&o<this._rowPool.length&&o<t.end-t.start?this._rowPool[o]:null}_dispatchCellClick(e,t,o,i){const n=this._rows[t],r=this._visibleColumns[o];if(!n||!r)return!1;const s=r.field,l=n[s],a=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:o,column:r,field:s,value:l,row:n,cellEl:i,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const c={row:n,rowIndex:t,colIndex:o,column:r,field:s,value:l,cellEl:i,originalEvent:e},d=this.#ee?.onCellClick(c)??!1;return this.#Ge("cell-click",c),d}_dispatchRowClick(e,t,o,i){if(!o)return!1;const n={rowIndex:t,row:o,rowEl:i,originalEvent:e},r=this.#ee?.onRowClick(n)??!1;return this.#Ge("row-click",n),r}_dispatchHeaderClick(e,t,o){if(!t)return!1;const i={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:o,originalEvent:e};return this.#ee?.onHeaderClick(i)??!1}_dispatchKeyDown(e){return this.#ee?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#ee?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}queryPlugins(e){return this.#ee?.queryPlugins(e)??[]}query(e,t){return this.#ee?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#ee?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#ee?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#ee?.onCellMouseUp(e)}_afterCellRender(e){this.#ee?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#ee?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#ee?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#ee?.hasAfterRowRenderHook()??!1}async ready(){return this.#i}async forceLayout(){return this.#$.requestPhase(ie.FULL,"forceLayout"),this.#$.whenReady()}async getConfig(){return Object.freeze({...this.#p||{}})}getRowId(e){return Ve(e,this.id,this.#p.getRowId)}getRow(e){return this.#re.getRow(e)}_getRowEntry(e){return this.#be.get(e)}updateRow(e,t,o="api"){this.#re.updateRow(e,t,o)}updateRows(e,t="api"){this.#re.updateRows(e,t)}animateRow(e,t){return Be(this,e,t)}animateRows(e,t){return function(e,t,o){return Promise.all(t.map(t=>Be(e,t,o))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,o){const i=e._rows??[],n=e.getRowId;if(!n)return Promise.resolve(!1);const r=i.findIndex(e=>{if(null==e)return!1;try{return n(e)===t}catch{return!1}});return r<0?Promise.resolve(!1):Be(e,r,o)}(this,e,t)}async insertRow(e,t,o=!0){return this.#re.insertRow(e,t,o)}async removeRow(e,t=!0){return this.#re.removeRow(e,t)}suspendProcessing(){}focusCell(e,t){this.#ne.focusCell(e,t)}get focusedCell(){return this.#ne.focusedCell}scrollToRow(e,t){this.#ne.scrollToRow(e,t)}scrollToRowById(e,t){this.#ne.scrollToRowById(e,t)}setColumnVisible(e,t){const o=this.#I.setColumnVisible(e,t);return o&&this.requestStateChange(),o}toggleColumnVisibility(e){const t=this.#I.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#I.isColumnVisible(e)}showAllColumns(){this.#I.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#I.getAllColumns()}setColumnOrder(e){this.#I.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#I.getColumnOrder()}getColumnState(){const e=this.#ee?.getAll()??[];return this.#I.collectState(e)}set columnState(e){e&&(this.#y=e,this.#I.initialColumnState=e,this.#k&&this.#rt(e))}get columnState(){return this.getColumnState()}#rt(e){const t=this.#ee?.getAll()??[];this.#I.applyState(e,t),this.#qe()}requestStateChange(){const e=this.#ee?.getAll()??[];this.#I.requestStateChange(e)}resetColumnState(){this.#y=void 0,this.__originalOrder=[];const e=this.#ee?.getAll()??[];this.#I.resetState(e),this.#I.merge(),this.#qe()}get isToolPanelOpen(){return this.#de.isPanelOpen}get defaultRowHeight(){return this._virtualization.rowHeight}get expandedToolPanelSections(){return this.#de.expandedSections}openToolPanel(){this.#de.openToolPanel()}closeToolPanel(){this.#de.closeToolPanel()}toggleToolPanel(){this.#de.toggleToolPanel()}toggleToolPanelSection(e){this.#de.toggleToolPanelSection(e)}getToolPanels(){return this.#de.getToolPanels()}registerToolPanel(e){this.#ce.apiToolPanelIds.add(e.id),this.#de.registerToolPanel(e)}unregisterToolPanel(e){this.#ce.apiToolPanelIds.delete(e),this.#de.unregisterToolPanel(e)}getHeaderContents(){return this.#de.getHeaderContents()}registerHeaderContent(e){this.#ce.apiHeaderContentIds.add(e.id),this.#de.registerHeaderContent(e)}unregisterHeaderContent(e){this.#ce.apiHeaderContentIds.delete(e),this.#de.unregisterHeaderContent(e)}getToolbarContents(){return this.#de.getToolbarContents()}registerToolbarContent(e){this.#de.registerToolbarContent(e)}unregisterToolbarContent(e){this.#de.unregisterToolbarContent(e)}#st=!1;refreshShellHeader(){this.#st||(this.#st=!0,queueMicrotask(()=>{this.#st=!1,this.isConnected&&(this.#De(),this.#I.markSourcesChanged(),this.#I.merge(),ct(this.#ce),this.#Oe(),this.#xe(),this.#lt())}))}#lt(){const e=this.#O.querySelector(".tbw-grid-content")??this.#O.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.#de.isInitialized){rt(this.#O,this.#ce),nt(this.#O,this.#p?.shell,this.#ce);const e=this.#p?.shell?.toolPanel?.defaultOpen;e&&this.#ce.toolPanels.has(e)&&(this.openToolPanel(),this.#ce.expandedSections.add(e)),this.#ce.isPanelOpen&&(at(this.#O,this.#ce),st(this.#O,this.#ce,(this.#p,this.#p)),lt(this.#O,this.#ce))}this._resizeController=Ne(this),this.#Pe(e),this.#$.requestPhase(ie.COLUMNS,"shellRefresh")}#Ne=/* @__PURE__ */new Map;registerStyles(e,t){let o=this.#Ne.get(e);o||(o=new CSSStyleSheet,this.#Ne.set(e,o)),o.replaceSync(t),this.#at()}unregisterStyles(e){this.#Ne.delete(e)&&this.#at()}getRegisteredStyles(){return Array.from(this.#Ne.keys())}#at(){const e=Array.from(this.#Ne.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#Ne.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}registerExternalFocusContainer(e){this.#ne.registerExternalFocusContainer(e)}unregisterExternalFocusContainer(e){this.#ne.unregisterExternalFocusContainer(e)}containsFocus(e){return this.#ne.containsFocus(e)}#De(){tt(this,this.#ce),ot(this,this.#ce),it(this,this.#ce,this.#Le())}#ct(){const e=this.#O.querySelector(".tbw-shell-header");if(!e)return;ct(this.#ce);const t=function(e,t,o="☰"){const i=e?.header?.title??t.lightDomTitle??"",n=!!i,r=Je(o),s=e?.header?.toolbarContents??[],l=[...t.toolbarContents.values()],a=new Set(s.map(e=>e.id)),c=[...s];for(const w of l)a.has(w.id)||c.push(w);const d=c.length>0,h=t.toolPanels.size>0,u=d&&h,g=[...c].sort((e,t)=>(e.order??0)-(t.order??0));let f="";for(const w of g)f+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${w.id}"></div>`;if(u&&(f+='<div class="tbw-toolbar-separator"></div>'),h){const e=t.isPanelOpen;f+=`<button class="${e?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${e}" aria-controls="tbw-tool-panel">${r}</button>`}return`\n <div class="tbw-shell-header" part="shell-header" role="presentation">\n ${n?`<div class="tbw-shell-title">${p=i,p&&"string"==typeof p?p.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}</div>`:""}\n <div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>\n <div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">\n ${f}\n </div>\n </div>\n `;var p}(this.#p.shell,this.#ce,this.#p.icons?.toolPanel),o=document.createElement("div");o.innerHTML=t;const i=o.firstElementChild;i&&(e.replaceWith(i),this.#dt(),nt(this.#O,this.#p?.shell,this.#ce))}#ze(){const e=()=>{const e=this.#ce.lightDomTitle,t=this.#ce.hasToolButtonsContainer;this.#De();const o=this.#ce.lightDomTitle,i=this.#ce.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#I.markSourcesChanged(),this.#I.merge(),this.#ct())},t=()=>{this.__lightDomColumnsCache=void 0,this.#qe()};this.#I.registerLightDomHandler("tbw-grid-header",e),this.#I.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#I.registerLightDomHandler("tbw-grid-tool-panel",e),this.#I.registerLightDomHandler("tbw-grid-column",t),this.#I.registerLightDomHandler("tbw-grid-detail",t),this.#I.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,Re(this),this.#I.parseLightDomColumns(this);const e=this.#ce.lightDomTitle,t=this.#ce.hasToolButtonsContainer;this.#De();const o=this.#ce.lightDomTitle,i=this.#ce.hasToolButtonsContainer;(o&&!e||i&&!t)&&(this.#I.markSourcesChanged(),this.#I.merge(),this.#ct()),this.#$.requestPhase(ie.COLUMNS,"refreshColumns")}#Ue(){this.#ie.updateCachedGeometry()}refreshVirtualWindow(e=!1,t=!1){return this.#ie.refreshVirtualWindow(e,t)}invalidateRowHeight(e,t){this.#ie.invalidateRowHeight(e,t)}#Oe(){this.#De(),this.#I.markSourcesChanged(),this.#I.merge();const e=this.#p?.shell;ht(this.#O,e,{isPanelOpen:this.#ce.isPanelOpen,expandedSections:this.#ce.expandedSections},this.#p?.icons)&&(this.#dt(),this.#de.setInitialized(!0))}#dt(){!function(e,t,o,i){const n=e.querySelector(".tbw-shell-toolbar");n&&n.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&i.onPanelToggle()});const r=e.querySelector(".tbw-accordion");r&&r.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),o=e?.getAttribute("data-section");o&&i.onSectionToggle(o)}})}(this.#O,this.#p,this.#ce,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#he?.(),this.#he=function(e,t,o){const i=e.querySelector(".tbw-tool-panel"),n=e.querySelector("[data-resize-handle]"),r=e.querySelector(".tbw-shell-body");if(!i||!n||!r)return()=>{};const s=t?.toolPanel?.position??"right";let l=0,a=0,c=0,d=!1;const h=e=>{if(!d)return;e.preventDefault();const t="left"===s?e.clientX-l:l-e.clientX,o=Math.min(c,Math.max(200,a+t));i.style.width=`${o}px`},u=()=>{if(!d)return;d=!1,n.classList.remove("resizing"),i.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=i.getBoundingClientRect().width;o(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)},g=e=>{e.preventDefault(),d=!0,l=e.clientX,a=i.getBoundingClientRect().width,c=r.getBoundingClientRect().width-20,n.classList.add("resizing"),i.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)};return n.addEventListener("mousedown",g),()=>{n.removeEventListener("mousedown",g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}}(this.#O,this.#p?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)}),this.#ue?.(),this.#ue=function(e,t,o,i){if(!t?.toolPanel?.closeOnClickOutside)return()=>{};const n=e=>{if(!o.isPanelOpen)return;const t=e.target;t&&(t.closest(".tbw-tool-panel")||t.closest("[data-panel-toggle]")||i())};return e.addEventListener("mousedown",n),()=>e.removeEventListener("mousedown",n)}(this,this.#p?.shell,this.#ce,()=>this.closeToolPanel())}}customElements.get(kt.tagName)||customElements.define(kt.tagName,kt),globalThis.DataGridElement=kt;const zt={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class It{static dependencies;static manifest;aliases;version="1.26.1";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#ht;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#ht?.abort(),this.#ht=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#ht?.abort(),this.#ht=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const o=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(o),o.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}requestVirtualRefresh(){this.grid?.requestVirtualRefresh?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid?._hostElement}get disconnectSignal(){return this.#ht?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...n,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),o=parseInt(t,10);if(!isNaN(o))return o}return 200}resolveIcon(e,t){return void 0!==t?t:this.gridIcons[e]}setIcon(e,t){"string"==typeof t?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e,t){void 0!==t?console.warn(C(e,t,this.gridElement.id,this.name)):console.warn(`${r(this.gridElement.id,this.name)} ${e}`)}throwDiagnostic(e,t){throw new Error(C(e,t,this.gridElement.id,this.name))}}const Nt={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},qt={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},Wt={ROOT:`.${Nt.ROOT}`,HEADER:`.${Nt.HEADER}`,HEADER_ROW:`.${Nt.HEADER_ROW}`,HEADER_CELL:`.${Nt.HEADER_CELL}`,ROWS_VIEWPORT:`.${Nt.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${Nt.ROWS_CONTAINER}`,DATA_ROW:`.${Nt.DATA_ROW}`,DATA_CELL:`.${Nt.DATA_CELL}`,GROUP_ROW:`.${Nt.GROUP_ROW}`,ROW_BY_INDEX:e=>`.${Nt.DATA_ROW}[${qt.ROW_INDEX}="${e}"]`,CELL_BY_FIELD:e=>`.${Nt.DATA_CELL}[${qt.FIELD}="${e}"]`,CELL_AT:(e,t)=>`.${Nt.DATA_ROW}[${qt.ROW_INDEX}="${e}"] .${Nt.DATA_CELL}[${qt.COL_INDEX}="${t}"]`,SELECTED_ROWS:`.${Nt.DATA_ROW}.${Nt.SELECTED}`,EDITING_CELL:`.${Nt.DATA_CELL}.${Nt.EDITING}`},$t={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"};function Ft(e){const t=document.createElement("tbw-grid");return e&&(t.gridConfig=e),t}function Bt(e,t,o){let i=document,n=!1;return"boolean"==typeof t?n=t:t&&(i=t,n=!!o),n?customElements.whenDefined(kt.tagName).then(()=>i.querySelector(e)):i.querySelector(e)}const Ut={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",EDIT_OPEN:"edit-open",EDIT_CLOSE:"edit-close",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change",DATA_CHANGE:"data-change"},Vt={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},Gt={sum:(e,t)=>e.reduce((e,o)=>e+(Number(o[t])||0),0),avg:(e,t)=>{const o=e.reduce((e,o)=>e+(Number(o[t])||0),0);return e.length?o/e.length:0},count:e=>e.length,min:(e,t)=>e.length?Math.min(...e.map(e=>Number(e[t])||1/0)):0,max:(e,t)=>e.length?Math.max(...e.map(e=>Number(e[t])||-1/0)):0,first:(e,t)=>e[0]?.[t],last:(e,t)=>e[e.length-1]?.[t]},Xt=/* @__PURE__ */new Map,Yt={register(e,t){Xt.set(e,t)},unregister(e){Xt.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:Xt.get(e)??Gt[e]},run(e,t,o,i){const n=this.get(e);return n?n(t,o,i):void 0},has:e=>Xt.has(e)||e in Gt,list:()=>[...Object.keys(Gt),...Xt.keys()]},jt={sum:e=>e.reduce((e,t)=>e+t,0),avg:e=>e.length?e.reduce((e,t)=>e+t,0)/e.length:0,count:e=>e.length,min:e=>e.length?Math.min(...e):0,max:e=>e.length?Math.max(...e):0,first:e=>e[0]??0,last:e=>e[e.length-1]??0};function Kt(e){return jt[e]??jt.sum}function Zt(e,t){return Kt(e)(t)}const Qt=Yt.register.bind(Yt),Jt=Yt.unregister.bind(Yt),eo=Yt.get.bind(Yt),to=Yt.run.bind(Yt),oo=Yt.list.bind(Yt);export{It as BaseGridPlugin,f as C,o as DEFAULT_ANIMATION_CONFIG,n as DEFAULT_GRID_ICONS,Ut as DGEvents,kt as DataGridElement,c as E,we as F,t as FitModeEnum,$t as GridCSSVars,Nt as GridClasses,qt as GridDataAttrs,kt as GridElement,Wt as GridSelectors,p as M,b as N,g as P,zt as PLUGIN_QUERIES,Vt as PluginEvents,Ot as PluginManager,ie as RenderPhase,w as T,e as a,Yt as aggregatorRegistry,m as b,V as builtInSort,Mt as c,Ft as createGrid,v as d,U as defaultComparator,Ae as e,W as f,q as g,eo as getAggregator,Kt as getValueAggregator,he as h,d as i,h as j,S as k,u as l,oo as listAggregators,ce as m,de as n,Bt as queryGrid,ge as r,Qt as registerAggregator,to as runAggregator,Zt as runValueAggregator,Lt as s,De as setFeatureResolver,y as t,Jt as unregisterAggregator,_ as w};//# sourceMappingURL=index.js.map
|