@guiexpert/react-table 1.0.3 → 1.0.5

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/index.js CHANGED
@@ -1,20 +1,1872 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("react/jsx-runtime"),k=require("react"),X=require("react-dom");class P{constructor(e=-1,t=-1,i=-1,s=-1,o,r,n,l=0,a=0,d=0,S=""){this.rowIndex=e,this.rowTop=t,this.columnIndex=i,this.columnLeft=s,this.areaIdent=o,this.sideIdent=r,this.originalEvent=n,this.clickCount=l,this.draggingX=a,this.draggingY=d,this.action=S}clone(){return new P(this.rowIndex,this.rowTop,this.columnIndex,this.columnLeft,this.areaIdent,this.sideIdent,this.originalEvent,this.clickCount,this.draggingX,this.draggingY,this.action)}}class I{constructor(e=">",t="",i=[]){this.content=e,this.style=t,this.classes=i}}class N{constructor(e=new I(">","transform: rotate(90deg) translate(66%, -66%); transform-origin: 0 0;",["gt-table-tree-arrow-expanded"]),t=new I(">","",["ge-table-tree-arrow-collapsed"]),i=new I(">","color:transparent;",["gt-table-tree-arrow-hidden"]),s=new I("↕","",["gt-table-tree-arrow-expanded-all"])){this.arrowExpanded=e,this.arrowCollapsed=t,this.arrowPlaceholder=i,this.arrowExpandCollapseAll=s}}class j{constructor(e=new I("↑","",["ge-header-sorted-asc"]),t=new I("↓","",["ge-header-sorted-desc"]),i=new I("↑","color:transparent;",[])){this.iconAsc=e,this.iconDesc=t,this.iconPlaceholder=i}}class K{constructor(e){this.domService=e}setStyle(e,t,i){return this.domService.setStyle(e,t,i),e}applyStyle(e,t){for(const i in t)this.domService.setStyle(e,i,t[i]);return e}applyDisplayNoneStyle(e){return this.domService.setStyle(e,"display","none"),e}applyDisplayBlockStyle(e){return this.domService.setStyle(e,"display","block"),e}applyStyleInPx(e,t){return Object.entries(t).forEach(([i,s])=>this.domService.setStyle(e,i,s+"px")),e}applyStylePosistionRelative(e){return this.domService.setStyle(e,"position","relative"),this.domService.setStyle(e,"overflow","clip"),e}applyStylePosistionAbsolute(e){return this.domService.setStyle(e,"position","absolute"),e}applyStyleFullSize(e){return this.domService.setStyle(e,"width","100%"),this.domService.setStyle(e,"height","100%"),e}applyStyleOverflowAuto(e="auto",t="auto",i){return this.domService.setStyle(i,"overflow-x",e),this.domService.setStyle(i,"overflow-y",t),i}applyStyleNoPadding(e){return this.domService.setStyle(e,"padding","0"),this.domService.setStyle(e,"margin","0"),this.domService.setStyle(e,"border","0"),e}appendRelativeChildDiv(e){const t=this.applyStylePosistionRelative(this.applyStyleFullSize(this.applyStyleNoPadding(this.domService.createElement("div"))));return this.domService.appendChild(e,t),this.applyStylePosistionAbsolute(e),{parent:e,child:t,cache:{}}}appendText(e,t){const i=this.domService.createText(t);return this.domService.appendChild(e,i),i}addClass(e,t){return e.includes(" ")?e.split(" ").forEach(i=>this.domService.addClass(t,i)):this.domService.addClass(t,e),t}addClasses(e,t){if(e)for(const i of e)this.domService.addClass(t,i);return t}setAttribute(e,t,i){return t&&i&&this.domService.setAttribute(e,t,i),e}createAreaDivWithClass(e,t,i,s){const o=this.domService.createElement("div");return this.addClass(e,o),this.domService.setAttribute(o,"data-area",i),this.domService.setAttribute(o,"data-side",s),this.domService.appendChild(t,o),o}createDivWithClass(e,t){const i=this.domService.createElement("div");return this.addClass(e,i),this.domService.appendChild(t,i),i}addRowDiv(e,t,i=-1,s,o,r=""){const n=t.index??-1,l=this.getDivOrCreateDiv(n,e);if(this.domService.addClass(l,"ge-table-row-div"),this.domService.addClass(l,`ge-table-row-div-${t.index}`),s==="body"&&o==="center"){const a=((t==null?void 0:t.index)??0)%2===0?"even":"odd";this.domService.addClass(l,`ge-table-row-${a}`)}if(this.domService.setStyle(l,"display","clip"),this.domService.setStyle(l,"position","absolute"),this.domService.setStyle(l,"left",`${t.left}px`),this.domService.setStyle(l,"top",`${t.top}px`),this.domService.setStyle(l,"width",`${t.width}px`),this.domService.setStyle(l,"height",`${t.height}px`),this.domService.setAttribute(l,"data-row-index",`${i}`),this.domService.setAttribute(l,"data-area",`${s}`),r){const a=this.domService.createText(r);this.domService.appendChild(l,a)}return this.domService.appendChild(e.child,l),l}addColumnDiv(e,t,i=-1,s=-1,o,r,n="",l,a,d=void 0,S){const g=a==null?void 0:a.treeOptions,f=a==null?void 0:a.showCheckboxWihoutExtraColumn,c=this.domService.createElement("div");this.domService.addClass(c,"ge-table-col-div"),this.domService.addClass(c,`ge-table-col-div-${t.index}`),this.domService.setAttribute(c,"data-col-index",`${t.index}`),this.domService.setAttribute(c,"data-row-index",`${i}`),this.domService.setAttribute(c,"data-area",`${o}`);const b=((t==null?void 0:t.index)??0)%2===0?"even":"odd";if(o==="body"&&r==="center"&&this.domService.addClass(c,`ge-table-column-${b}`),this.domService.setStyle(c,"display","clip"),this.domService.setStyle(c,"position","absolute"),this.domService.setStyle(c,"left",`${t.left}px`),this.domService.setStyle(c,"top",`${t.top}px`),this.domService.setStyle(c,"width",`${t.width}px`),this.domService.setStyle(c,"height",`${t.height}px`),l&&l!=="none"&&(this.domService.addClass(c,"ge-table-col-tree"),this.addArrowDiv(c,l,g,i,s,o)),f&&s===0&&d&&this.addCheckboxToDiv(c,d,o,i),n){const h=l!=="none"&&s===0;this.addLabelDiv(c,n,h,i,s,o)}return S&&this.addSortedIcon(c,S,a==null?void 0:a.sortedOptions,s),this.domService.appendChild(e,c),c}addCheckboxToDiv(e,t,i,s){const o=this.domService.createElement("div"),r=t==="full"?"checked":"";return o.innerHTML=`
1
+ import { jsx as Y } from "react/jsx-runtime";
2
+ import { useRef as q, useEffect as U } from "react";
3
+ import J from "react-dom";
4
+ function O(p) {
5
+ return p && p.type === "TreeRow";
6
+ }
7
+ function $(p) {
8
+ return p && p.type === "AreaModelTree";
9
+ }
10
+ class W {
11
+ constructor(e = -1, t = -1, s = -1, i = -1, o, r, n, l = 0, a = 0, d = 0, u = "") {
12
+ this.rowIndex = e, this.rowTop = t, this.columnIndex = s, this.columnLeft = i, this.areaIdent = o, this.sideIdent = r, this.originalEvent = n, this.clickCount = l, this.draggingX = a, this.draggingY = d, this.action = u;
13
+ }
14
+ clone() {
15
+ return new W(
16
+ this.rowIndex,
17
+ this.rowTop,
18
+ this.columnIndex,
19
+ this.columnLeft,
20
+ this.areaIdent,
21
+ this.sideIdent,
22
+ this.originalEvent,
23
+ this.clickCount,
24
+ this.draggingX,
25
+ this.draggingY,
26
+ this.action
27
+ );
28
+ }
29
+ }
30
+ class D {
31
+ constructor(e = ">", t = "", s = []) {
32
+ this.content = e, this.style = t, this.classes = s;
33
+ }
34
+ }
35
+ class j {
36
+ constructor(e = new D(
37
+ ">",
38
+ "transform: rotate(90deg) translate(66%, -66%); transform-origin: 0 0;",
39
+ ["gt-table-tree-arrow-expanded"]
40
+ ), t = new D(
41
+ ">",
42
+ "",
43
+ ["ge-table-tree-arrow-collapsed"]
44
+ ), s = new D(
45
+ ">",
46
+ "color:transparent;",
47
+ ["gt-table-tree-arrow-hidden"]
48
+ ), i = new D(
49
+ "↕",
50
+ "",
51
+ ["gt-table-tree-arrow-expanded-all"]
52
+ )) {
53
+ this.arrowExpanded = e, this.arrowCollapsed = t, this.arrowPlaceholder = s, this.arrowExpandCollapseAll = i;
54
+ }
55
+ }
56
+ class X {
57
+ constructor(e = new D("↑", "", ["ge-header-sorted-asc"]), t = new D("↓", "", ["ge-header-sorted-desc"]), s = new D("↑", "color:transparent;", [])) {
58
+ this.iconAsc = e, this.iconDesc = t, this.iconPlaceholder = s;
59
+ }
60
+ }
61
+ class Q {
62
+ constructor(e) {
63
+ this.domService = e;
64
+ }
65
+ setStyle(e, t, s) {
66
+ return this.domService.setStyle(e, t, s), e;
67
+ }
68
+ applyStyle(e, t) {
69
+ for (const s in t)
70
+ this.domService.setStyle(e, s, t[s]);
71
+ return e;
72
+ }
73
+ applyDisplayNoneStyle(e) {
74
+ return this.domService.setStyle(e, "display", "none"), e;
75
+ }
76
+ applyDisplayBlockStyle(e) {
77
+ return this.domService.setStyle(e, "display", "block"), e;
78
+ }
79
+ applyStyleInPx(e, t) {
80
+ return Object.entries(t).forEach(([s, i]) => this.domService.setStyle(e, s, i + "px")), e;
81
+ }
82
+ applyStylePosistionRelative(e) {
83
+ return this.domService.setStyle(e, "position", "relative"), this.domService.setStyle(e, "overflow", "clip"), e;
84
+ }
85
+ applyStylePosistionAbsolute(e) {
86
+ return this.domService.setStyle(e, "position", "absolute"), e;
87
+ }
88
+ applyStyleFullSize(e) {
89
+ return this.domService.setStyle(e, "width", "100%"), this.domService.setStyle(e, "height", "100%"), e;
90
+ }
91
+ applyStyleOverflowAuto(e = "auto", t = "auto", s) {
92
+ return this.domService.setStyle(s, "overflow-x", e), this.domService.setStyle(s, "overflow-y", t), s;
93
+ }
94
+ applyStyleNoPadding(e) {
95
+ return this.domService.setStyle(e, "padding", "0"), this.domService.setStyle(e, "margin", "0"), this.domService.setStyle(e, "border", "0"), e;
96
+ }
97
+ appendRelativeChildDiv(e) {
98
+ const t = this.applyStylePosistionRelative(
99
+ this.applyStyleFullSize(
100
+ this.applyStyleNoPadding(
101
+ this.domService.createElement("div")
102
+ )
103
+ )
104
+ );
105
+ return this.domService.appendChild(e, t), this.applyStylePosistionAbsolute(e), { parent: e, child: t, cache: {} };
106
+ }
107
+ appendText(e, t) {
108
+ const s = this.domService.createText(t);
109
+ return this.domService.appendChild(e, s), s;
110
+ }
111
+ addClass(e, t) {
112
+ return e.includes(" ") ? e.split(" ").forEach((s) => this.domService.addClass(t, s)) : this.domService.addClass(t, e), t;
113
+ }
114
+ removeClass(e, t) {
115
+ return e.includes(" ") ? e.split(" ").forEach((s) => this.domService.removeClass(t, s)) : this.domService.removeClass(t, e), t;
116
+ }
117
+ addClasses(e, t) {
118
+ if (e)
119
+ for (const s of e)
120
+ this.domService.addClass(t, s);
121
+ return t;
122
+ }
123
+ setAttribute(e, t, s) {
124
+ return t && s && this.domService.setAttribute(e, t, s), e;
125
+ }
126
+ createAreaDivWithClass(e, t, s, i) {
127
+ const o = this.domService.createElement("div");
128
+ return this.addClass(e, o), this.domService.setAttribute(o, "data-area", s), this.domService.setAttribute(o, "data-side", i), this.domService.appendChild(t, o), o;
129
+ }
130
+ createDivWithClass(e, t) {
131
+ const s = this.domService.createElement("div");
132
+ return this.addClass(e, s), this.domService.appendChild(t, s), s;
133
+ }
134
+ addRowDiv(e, t, s = -1, i, o, r = "") {
135
+ const n = t.index ?? -1, l = this.getDivOrCreateDiv(n, e);
136
+ if (this.domService.addClass(l, "ge-table-row-div"), this.domService.addClass(l, `ge-table-row-div-${t.index}`), i === "body" && o === "center") {
137
+ const a = ((t == null ? void 0 : t.index) ?? 0) % 2 === 0 ? "even" : "odd";
138
+ this.domService.addClass(l, `ge-table-row-${a}`);
139
+ }
140
+ if (this.domService.setStyle(l, "display", "clip"), this.domService.setStyle(l, "position", "absolute"), this.domService.setStyle(l, "left", `${t.left}px`), this.domService.setStyle(l, "top", `${t.top}px`), this.domService.setStyle(l, "width", `${t.width}px`), this.domService.setStyle(l, "height", `${t.height}px`), this.domService.setAttribute(l, "data-row-index", `${s}`), this.domService.setAttribute(l, "data-area", `${i}`), r) {
141
+ const a = this.domService.createText(r);
142
+ this.domService.appendChild(l, a);
143
+ }
144
+ return this.domService.appendChild(e.child, l), l;
145
+ }
146
+ addColumnDiv(e, t, s = -1, i = -1, o, r, n = "", l, a, d = void 0, u) {
147
+ const g = a == null ? void 0 : a.treeOptions, m = a == null ? void 0 : a.showCheckboxWihoutExtraColumn, c = this.domService.createElement("div");
148
+ this.domService.addClass(c, "ge-table-col-div"), this.domService.addClass(c, `ge-table-col-div-${t.index}`), this.domService.setAttribute(c, "data-col-index", `${t.index}`), this.domService.setAttribute(c, "data-row-index", `${s}`), this.domService.setAttribute(c, "data-area", `${o}`);
149
+ const b = ((t == null ? void 0 : t.index) ?? 0) % 2 === 0 ? "even" : "odd";
150
+ if (o === "body" && r === "center" && this.domService.addClass(c, `ge-table-column-${b}`), this.domService.setStyle(c, "display", "clip"), this.domService.setStyle(c, "position", "absolute"), this.domService.setStyle(c, "left", `${t.left}px`), this.domService.setStyle(c, "top", `${t.top}px`), this.domService.setStyle(c, "width", `${t.width}px`), this.domService.setStyle(c, "height", `${t.height}px`), l && l !== "none" && (this.domService.addClass(c, "ge-table-col-tree"), this.addArrowDiv(c, l, g, s, i, o)), m && i === 0 && d && this.addCheckboxToDiv(c, d, o, s), n) {
151
+ const h = l !== "none" && i === 0;
152
+ this.addLabelDiv(c, n, h, s, i, o);
153
+ }
154
+ return u && this.addSortedIcon(c, u, a == null ? void 0 : a.sortedOptions, i), this.domService.appendChild(e, c), c;
155
+ }
156
+ addCheckboxToDiv(e, t, s, i) {
157
+ const o = this.domService.createElement("div"), r = t === "full" ? "checked" : "";
158
+ return o.innerHTML = `
2
159
  <input
3
160
  type="checkbox"
4
- data-area="${i}"
5
- data-row-index="${s}"
161
+ data-area="${s}"
162
+ data-row-index="${i}"
6
163
  data-input-type="checkbox"
7
164
  ${r}
8
- class="ge-table-row-checkbox"> `,this.domService.setStyle(o,"display","inline"),this.domService.setStyle(o,"width","inherit"),this.domService.setAttribute(o,"data-row-index",`${s}`),this.domService.appendChild(e,o),o}addLabelDiv(e,t="",i=!1,s=-1,o=-1,r="body"){const n=this.domService.createElement("div");if(this.domService.addClass(n,"ge-table-label-div"),this.domService.setStyle(n,"position","relative"),this.domService.setStyle(n,"background","transparent"),this.domService.setStyle(n,"width","100%"),this.domService.setStyle(n,"height","100%"),this.domService.setAttribute(n,"data-row-index",`${s}`),this.domService.setAttribute(n,"data-col-index",`${o}`),this.domService.setAttribute(n,"data-area",`${r}`),t)if(i){const l=this.domService.createText(t);this.domService.appendChild(n,l)}else{const l=this.domService.createElement("div");this.domService.appendChild(n,l);const a=this.domService.createText(t);this.domService.addClass(l,"ge-table-label"),this.domService.appendChild(l,a),this.domService.setAttribute(l,"data-row-index",`${s}`),this.domService.setAttribute(l,"data-col-index",`${o}`),this.domService.setAttribute(l,"data-area",`${r}`)}return this.domService.appendChild(e,n),n}addSortedIcon(e,t="",i=new j,s=-1){const o=this.domService.createElement("div");this.domService.addClass(o,"ge-table-sorted-icon-div"),this.domService.setStyle(o,"position","absolute"),this.domService.setStyle(o,"top","0"),this.domService.setStyle(o,"right","0"),this.domService.setStyle(o,"width","20px"),this.domService.setStyle(o,"background","transparent"),this.domService.setStyle(o,"cursor","pointer"),this.domService.setAttribute(o,"data-col-index",`${s}`),this.domService.setAttribute(o,"data-area","header");let r;t==="asc"?r=i.iconAsc:t==="desc"?r=i.iconDesc:r=i.iconPlaceholder;const n=r.content,l=this.domService.createText(n);this.domService.appendChild(o,l),r.style&&this.applyStyleString(o,r.style);for(const a of r.classes)this.domService.addClass(o,a);return this.domService.appendChild(e,o),o}addArrowDiv(e,t="none",i=new N,s=-1,o=-1,r="body"){const n=this.domService.createElement("div");this.domService.addClass(n,"ge-table-tree-arrow-div"),this.domService.setStyle(n,"display","inline-block"),this.domService.setStyle(n,"position",""),this.domService.setStyle(n,"width","20px"),this.domService.setStyle(n,"background","transparent"),this.domService.setStyle(n,"cursor","pointer"),this.domService.setAttribute(n,"data-row-index",`${s}`),this.domService.setAttribute(n,"data-col-index",`${o}`),this.domService.setAttribute(n,"data-area",`${r}`);let l;t==="expanded"?l=i.arrowExpanded:t==="collapsed"?l=i.arrowCollapsed:l=i.arrowPlaceholder;const a=l.content,d=this.domService.createText(a);this.domService.appendChild(n,d),l.style&&this.applyStyleString(n,l.style);for(const S of l.classes)this.domService.addClass(n,S);return this.domService.appendChild(e,n),n}addColumnBorderDivs(e,t,i,s,o){if(e.verticalBorderVisible){const r=`ge-table-${s}-${o}-vertical-border`;this.addVerticalBorder(i,t,r)}if(e.horizontalBorderVisible){const r=`ge-table-${s}-${o}-horizontal-border`;this.addHorizontalBorder(i,t,r)}return t}addHorizontalBorder(e,t,i="ge-table-body-center-horizontal-border"){const s=this.domService.createElement("div");return this.domService.addClass(s,i),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${e.left}px`),this.domService.setStyle(s,"top",`${e.top}px`),this.domService.setStyle(s,"width",`${e.width}px`),this.domService.setStyle(s,"height","1px"),this.domService.appendChild(t,s),s}addFocusBorderDivs(e,t,i){let s=this.domService.createElement("div");return this.domService.addClass(s,"ge-table-focus-border"),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${t.left}px`),this.domService.setStyle(s,"top",`${t.top}px`),this.domService.setStyle(s,"width","1px"),this.domService.setStyle(s,"height",`${t.height}px`),this.applyStyle(s,i),this.domService.appendChild(e,s),s=this.domService.createElement("div"),this.domService.addClass(s,"ge-table-focus-border"),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${t.left+t.width-1}px`),this.domService.setStyle(s,"top",`${t.top}px`),this.domService.setStyle(s,"width","1px"),this.domService.setStyle(s,"height",`${t.height}px`),this.applyStyle(s,i),this.domService.appendChild(e,s),s=this.domService.createElement("div"),this.domService.addClass(s,"ge-table-focus-border"),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${t.left}px`),this.domService.setStyle(s,"top",`${t.top}px`),this.domService.setStyle(s,"width",`${t.width}px`),this.domService.setStyle(s,"height","1px"),this.applyStyle(s,i),this.domService.appendChild(e,s),s=this.domService.createElement("div"),this.domService.addClass(s,"ge-table-focus-border"),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${t.left}px`),this.domService.setStyle(s,"top",`${t.top+t.height-1}px`),this.domService.setStyle(s,"width",`${t.width}px`),this.domService.setStyle(s,"height","1px"),this.applyStyle(s,i),this.domService.appendChild(e,s),e}addVerticalBorder(e,t,i="ge-table-body-center-vertical-border"){const s=this.domService.createElement("div");return this.domService.addClass(s,i),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${e.left}px`),this.domService.setStyle(s,"top",`${e.top}px`),this.domService.setStyle(s,"width","1px"),this.domService.setStyle(s,"height",`${e.height}px`),this.domService.appendChild(t,s),s}addDiv(e,t,i=""){const s=this.domService.createElement("div");return i&&this.domService.addClass(s,i),this.domService.setStyle(s,"display","clip"),this.domService.setStyle(s,"position","absolute"),this.domService.setStyle(s,"left",`${t.left}px`),this.domService.setStyle(s,"top",`${t.top}px`),this.domService.setStyle(s,"width",`${t.width}px`),this.domService.setStyle(s,"height",`${t.height}px`),this.domService.appendChild(e,s),s}applyStyleString(e,t){const i=t.split(";").map(s=>s.trim()).filter(s=>s);for(const s of i){const[o,r]=s.split(":");this.domService.setStyle(e,o.trim(),r.trim())}}getDivOrCreateDiv(e,t){let i=t.cache[e];return i?(i.innerText="",i):(i=this.domService.createElement("div"),t.cache[e]=i,i)}}class L{constructor(e,t=!0,i,s,o=0,r=!1,n=!1){this.data=e,this.expanded=t,this.children=i,this.parent=s,this.deep=o,this.checked=r,this.keep=n}}const V=p=>p==="header"?"header":p==="footer"?"footer":"body";class Y{constructor(e,t){if(this.rowIdx=-1,this.colIdx=-1,this.action=null,this.inputType=null,this.className="",e!==null&&(e instanceof HTMLDivElement||e instanceof HTMLSpanElement||e instanceof HTMLInputElement)){this.className=e.className,this.action=e.getAttribute("data-ge-action"),this.inputType=e.getAttribute("data-input-type"),this.rowIdx=Number(e.getAttribute("data-row-index")),this.colIdx=Number(e.getAttribute("data-col-index"));const i=e.getAttribute("data-area");if(i&&(this.areaIdent=V(i),this.areaModel=t.tableModel.getAreaModel(this.areaIdent),this.row=this.areaModel.getRowByIndex(this.rowIdx)),e instanceof HTMLInputElement){const s=e;this.value=s.value}}}}class q{constructor(e){this.tableScope=e,this.expandedAll=!0,this.mouseDown=!1,this.dragging=!1,this.tableScope.hostElement.addEventListener("click",this.onHostElementClicked.bind(this)),this.tableScope.hostElement.addEventListener("dblclick",this.onHostElementDblClicked.bind(this)),this.tableScope.hostElement.addEventListener("mousedown",this.onMouseDown.bind(this)),this.tableScope.hostElement.addEventListener("mousemove",this.onMouseMove.bind(this)),this.tableScope.hostElement.addEventListener("mouseup",this.onMouseUp.bind(this)),this.tableScope.hostElement.addEventListener("contextmenu",this.onContextmenu.bind(this)),this.tableScope.hostElement._MouseHandler="true",this.tableScope.scrollViewport.addEventListener("scroll",this.tableScope.adjustAfterScrolling.bind(this.tableScope)),[window,this.tableScope.hostElement].forEach(t=>t.addEventListener("resize",this.tableScope.adjustContainersAndRows.bind(this.tableScope)))}onContextmenu(e){this.mouseEvent=e;const t=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.contextmenu(t)}onHostElementClicked(e){const t=new Y(e.target,this.tableScope);if(t.action==="toggleExpandCollapseAll")this.expandedAll=!this.expandedAll,this.tableScope.toggleExpandCollapseAll(this.expandedAll),e.preventDefault(),e.stopPropagation();else if(t.inputType==="checkbox"&&t.areaIdent)this.tableScope.toggleRowCheckbox(t.rowIdx,t.colIdx,t.areaIdent),e.preventDefault(),e.stopPropagation();else if(t.row instanceof L&&t.areaModel){const i=t.colIdx===this.getArrowColumnIndex()&&e.altKey,s=t.className.includes("ge-table-tree-arrow-div");if(console.info(s,i),i||s){e.preventDefault(),e.stopPropagation();const o=t.row;o.expanded=!o.expanded,"recalcVisibleTreeRows"in t.areaModel&&t.areaModel.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(o)}}if(t.areaIdent==="body"&&this.tableScope.tableOptions.getFocusModel){const i=this.tableScope.tableOptions.getFocusModel();i==null||i.clear(),i==null||i.setFocus(t.rowIdx,t.colIdx)}this.publishGeMouseEvent(e,1)}onHostElementDblClicked(e){if(e.target instanceof HTMLElement){const t=e.target,i=t.getAttribute("data-area"),s=V(i),o=Number(t.getAttribute("data-row-index")),r=Number(t.getAttribute("data-col-index")),n=this.tableScope.tableModel.getAreaModel(s);if(i&&s==="header")this.tableScope.tableModel.isSortable(r)&&(this.tableScope.clearSelection(),this.tableScope.onHeaderDblClicked(e,o,r));else if(t.getAttribute("data-row-index")){const l=n.getRowByIndex(o);if(i&&s==="body"&&n.isEditable(o,r)&&(this.tableScope.clearSelection(),this.tableScope.initRenderEditor(o,r)),l instanceof L&&r===this.getArrowColumnIndex()){e.preventDefault(),e.stopPropagation();const a=l;a.expanded=!a.expanded,"recalcVisibleTreeRows"in n&&n.recalcVisibleTreeRows(),this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth),this.tableScope.adjustContainersAndRows(),this.updateCollapsedExpandedState(a)}}}this.publishGeMouseEvent(e,2)}publishGeMouseEvent(e,t){var i;this.mouseEvent=e,this.geMouseEventOld=(i=this.geMouseEvent)==null?void 0:i.clone(),this.geMouseEvent=this.tableScope.createGeMouseEvent(e),this.geMouseEvent&&(this.geMouseEvent.clickCount=t),this.tableScope.onMouseClicked(this.geMouseEvent,this.geMouseEventOld)}updateCollapsedExpandedState(e){var i,s,o,r,n;const t=(s=(i=this.tableScope.tableOptions)==null?void 0:i.autoRestoreOptions)==null?void 0:s.getRowId;if(t){const l=(o=this.tableScope.storeStateCollapsedExpandService)==null?void 0:o.collapsedExpandedStateGet().mode,a=l==="collapsed"&&!e.expanded||l==="expanded"&&e.expanded,d=l==="collapsed"&&e.expanded||l==="expanded"&&!e.expanded,S=t(e.data);a?(r=this.tableScope.storeStateCollapsedExpandService)==null||r.collapsedStateIdsPush(S):d&&((n=this.tableScope.storeStateCollapsedExpandService)==null||n.collapsedStateIdsRemove(S))}}getArrowColumnIndex(){return this.tableScope.tableModel.isRowCheckboxVisible()?1:0}onMouseDown(e){this.mouseEvent=e,this.startMouseEvent=this.tableScope.createGeMouseEvent(this.mouseEvent),this.tableScope.onMouseDown(this.startMouseEvent),this.mouseDown=!0}onMouseMove(e){this.mouseEvent=e,this.mouseDown?(this.dragging=!0,requestAnimationFrame(this.mouseDraggingOnFrame.bind(this))):requestAnimationFrame(this.mouseMoveOnFrame.bind(this))}onMouseUp(e){this.mouseEvent=e,this.dragging&&requestAnimationFrame(this.mouseDraggingEndOnFrame.bind(this)),this.mouseDown=!1,this.dragging=!1}mouseDraggingOnFrame(){var e;if(this.mouseEvent){const t=this.tableScope.createGeMouseEvent(this.mouseEvent);(e=this.startMouseEvent)!=null&&e.originalEvent&&(t.draggingX=this.mouseEvent.clientX-this.startMouseEvent.originalEvent.clientX,t.draggingY=this.mouseEvent.clientY-this.startMouseEvent.originalEvent.clientY),this.tableScope.mouseDraggingOnFrame(t)}}mouseDraggingEndOnFrame(){var e;if(this.mouseEvent){const t=this.tableScope.createGeMouseEvent(this.mouseEvent);(e=this.startMouseEvent)!=null&&e.originalEvent&&(t.draggingX=this.mouseEvent.clientX-this.startMouseEvent.originalEvent.clientX,t.draggingY=this.mouseEvent.clientY-this.startMouseEvent.originalEvent.clientY),this.tableScope.mouseDraggingEndOnFrame(t)}}mouseMoveOnFrame(){if(this.mouseEvent){const e=this.tableScope.createGeMouseEvent(this.mouseEvent);this.tableScope.mouseMove(e)}}}class U{constructor(e){this.tableScope=e}updateCells(e){this.tableScope.updateCells(e)}externalFilterChanged(){this.tableScope.externalFilterChanged()}scrollToPixel(e=0,t=0){}scrollToIndex(e=0,t=0){}setHeaderVisible(e=!0){}setColumnVisible(e,t=!0){}isColumnVisible(e){return!0}isHeaderVisible(){return!0}setFooterVisible(e=!0){}isFooterVisible(){return!0}repaint(){this.tableScope.repaint()}}class J{flattenTree(e,t=[]){var i;for(const s of e)this.isVisible(s)&&t.push(s),(i=s.children)!=null&&i.length&&this.flattenTree(s.children,t);return t}isVisible(e){return e.parent?e.parent.expanded?this.isVisible(e.parent):!1:!0}}class Q{constructor(e,t=[],i=-1){this.areaIdent=e,this.columnDefs=t,this.defaultRowHeight=i,this.rowSelectionModel=void 0,this.yPositions=[],this.cellRenderers=t.map(s=>s.rendererMap[e])}getTooltipAt(e,t){return""}getCellRenderer(e,t){if(t<this.cellRenderers.length)return this.cellRenderers[t]}getColspanAt(e,t){return 0}getCustomClassesAt(e,t){return[]}getCustomStyleAt(e,t){}getRowspanAt(e,t){return 0}getRowByIndex(e){}isRowCheckable(e){return!0}isRowChecked(e){var i;const t=this.getRowByIndex(e);return(i=this.rowSelectionModel)==null?void 0:i.isRowChecked(t)}setRowChecked(e,t){if(this.rowSelectionModel){const i=this.getRowByIndex(e);this.rowSelectionModel.checkRow(i,t)}}getMaxColspan(){return 31}getMaxRowspan(){return 31}getYPosByRowIndex(e){return this.defaultRowHeight>0?this.defaultRowHeight*e:this.yPositions[e]}init(){!this.yPositions.length&&this.getRowCount()!==void 0&&this.defaultRowHeight===-1&&this.calcYPositions()}isFilterable(){return this.areaIdent==="body"}doSort(e){return!1}isEditable(e,t){return this.columnDefs&&t<this.columnDefs.length&&this.columnDefs[t].editable?this.columnDefs[t].editable():!1}setValue(e,t,i){var n;const s=(n=this.columnDefs[t])==null?void 0:n.editInputPipe;s&&(i=s(i,e,t));const o=this.getRowByIndex(e),r=this.columnDefs[t].property;return r.includes(".")?this.setPropertyValue(o,r.split("."),i):(o[r]=i,!0)}isSelectable(e,t){return!0}changeColumnOrder(e,t){this.arrayMove(this.cellRenderers,e,t)}setPropertyValue(e,t,i){const s=t.shift();if(s){let o=e[s];return o&&t.length?this.setPropertyValue(o,t,i):(e[s]=i,!0)}return!1}arrayMove(e,t,i){const s=e.splice(t,1)[0];return e.splice(i,0,s),e}calcYPositions(){const e=this.getRowCount();this.yPositions=new Array(e+1),this.yPositions[0]=0;for(let t=0;t<e;t++)this.yPositions[t+1]=this.getRowHeight(t)+this.yPositions[t]}}class Z{genericSortComparator(e,t,i){if(typeof e=="number"&&typeof t=="number")return i*(e-t);if(typeof e=="string"&&typeof t=="string")return i*e.localeCompare(t);if(typeof e=="boolean"&&typeof t=="boolean")return i*((e?-1:1)-(t?-1:1));if(e instanceof Date&&t instanceof Date)return i*(e.getTime()-t.getTime());if(e instanceof Array&&t instanceof Array){const s=e,o=t;if(s.length&&o.length)return this.genericSortComparator(s[0],o[0],i)}return i*(""+e).localeCompare(""+t)}}class B extends Q{constructor(e,t,i,s=[]){super(e,s,i),this.areaIdent=e,this.rows=t,this.defaultRowHeight=i,this.columnDefs=s,this.sorterService=new Z,this.service=new J,this.properties=s.map(o=>o.property),this.flattenRows=this.service.flattenTree(t),this.filteredFlattenRows=[...this.flattenRows]}changeColumnOrder(e,t){this.arrayMove(this.properties,e,t),super.changeColumnOrder(e,t)}recalcVisibleTreeRows(){this.filteredFlattenRows=this.service.flattenTree(this.rows)}getFilteredFlattenRows(){return this.filteredFlattenRows}getRowCount(){let e=0;for(const t of this.filteredFlattenRows)this.service.isVisible(t)&&e++;return e}getValueAt(e,t){const i=this.getRowByIndex(e);if(i){const s=this.properties[t];if(s)return s.includes(".")?this.getPropertyValue(i.data,s.split(".")):i.data[s]}return""}getRowHeight(e){return this.defaultRowHeight}getCustomClassesAt(e,t){return["ge-table-tree-cell","ge-table-tree-deep-"+this.filteredFlattenRows[e].deep]}getRowByIndex(e){return this.filteredFlattenRows[e]}getValueByT(e,t){return t.includes(".")?this.getPropertyValue(e,t.split(".")):e[t]}externalFilterChanged(e){this.lastPredictFn=e,this.doFiltering()}doSort(e){const{columnIndex:t,sortState:i}=e[e.length-1],s=i==="asc"?1:i==="desc"?-1:0,o=this.properties[t];return this.treeSort(this.rows,o,s),this.flattenRows=this.service.flattenTree(this.rows),this.filteredFlattenRows=[...this.flattenRows],!0}toggleExpandCollapseAll(e){this.expandAllRecursive(this.rows,e),this.flattenRows=this.service.flattenTree(this.rows),this.doFiltering()}setAllParentsOk(e){return e.parent&&(e.parent.keep=!0,this.setAllParentsOk(e.parent)),!1}setValue(e,t,i){var r;const s=(r=this.columnDefs[t])==null?void 0:r.editInputPipe;s&&(i=s(i,e,t));const o=this.getRowByIndex(e);if(o){const n=o.data,l=this.columnDefs[t].property;return l.includes(".")?this.setPropertyValue(n,l.split("."),i):(n[l]=i,!0)}return!1}genericTreeTableSortComparator(e,t){return(i,s)=>{const o=this.getValueByT(i.data,e),r=this.getValueByT(s.data,e);return this.sorterService.genericSortComparator(o,r,t)}}expandAllRecursive(e,t){for(const i of e)i.expanded=t,i.children&&this.expandAllRecursive(i.children,t)}doFiltering(){if(!this.lastPredictFn)this.filteredFlattenRows=[...this.flattenRows?this.flattenRows:[]];else{this.flattenRows||(this.flattenRows=[]);let e=0;this.flattenRows.forEach(i=>{e=Math.max(e,i.deep)});const t=this.flattenRows.filter((i,s,o)=>this.lastPredictFn(i,s,o));this.flattenRows.forEach(i=>i.keep=!1),this.flattenRows.forEach(i=>{t.includes(i)&&(i.keep=!0,this.setAllParentsOk(i))}),this.filteredFlattenRows=this.flattenRows.filter((i,s,o)=>i.keep)}}getPropertyValue(e,t){const i=t.shift();let s=e[i];return s&&t.length?this.getPropertyValue(s,t):s}treeSort(e,t,i){e.sort(this.genericTreeTableSortComparator(t,i));for(const s of e)s.children&&this.treeSort(s.children,t,i)}}class H{constructor(e){this.getStorageKeyFn=e}autoConvertMapToObject(e){const t={};if(e instanceof Map){const i=e;for(const s of[...i]){const[o,r]=s;t[o]=r}}return t}checkAndPersistItem(e,t){const i=this.getStorageKeyFn;if(i){const s=i();if(s){const o=s+e;if((t+"").includes("Map")){const r=this.autoConvertMapToObject(t);this.persistItem(o,r)}else this.persistItem(o,t)}}}persistItem(e,t){t?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)}loadFromLocalStorage(e){const t=localStorage.getItem(e);return t?JSON.parse(t):null}}class ee extends H{constructor(e){super(e),this.SCROLL_STATE="scrollState",this.scrollOffset=[0,0],this.load()}getScrollOffset(){return this.scrollOffset}updateScrollOffset(e){this.scrollOffset=e,this.checkAndPersistItem(this.SCROLL_STATE,this.scrollOffset)}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const i=t+this.SCROLL_STATE;let s=this.loadFromLocalStorage(i);this.scrollOffset=s||[0,0]}}}}class te{constructor(e="collapsed",t=[],i=!1,s=!1){this.mode=e,this.rowIds=t,this.allCollapsed=i,this.allExpanded=s}}class ie extends H{constructor(e){super(e),this.COLLAPSED_EXPANDED_STATE="collapsedExpandedState",this.collapsedExpandedState=new te,this.load()}collapsedExpandedStateGet(){return this.collapsedExpandedState}collapsedExpandedStateIncludes(e){return this.collapsedExpandedState.rowIds.includes(e)}collapsedStateIdsPush(e){this.collapsedExpandedState.rowIds.includes(e)||(this.collapsedExpandedState.rowIds.push(e),this.collapsedExpandedState.allCollapsed=!1,this.collapsedExpandedState.allExpanded=!1,this.persist())}collapsedStateIdsRemove(e){const t=this.collapsedExpandedState.rowIds.indexOf(e);t!==-1&&(this.collapsedExpandedState.rowIds.splice(t,1),this.collapsedExpandedState.allCollapsed=!1,this.collapsedExpandedState.allExpanded=!1,this.persist())}collapsedStateAll(e){this.collapsedExpandedState.rowIds=[],this.collapsedExpandedState.mode=e?"collapsed":"expanded",this.collapsedExpandedState.allCollapsed=!e,this.collapsedExpandedState.allExpanded=e,this.persist()}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const i=t+this.COLLAPSED_EXPANDED_STATE,s=this.loadFromLocalStorage(i);s&&(this.collapsedExpandedState=s)}}}persist(){this.checkAndPersistItem(this.COLLAPSED_EXPANDED_STATE,this.collapsedExpandedState)}}class se extends H{constructor(e){super(e),this.SORTING_STATE="sortingState",this.sortItems=[],this.load()}getSortItems(){return this.sortItems}setSortItems(e){this.sortItems=e,this.checkAndPersistItem(this.SORTING_STATE,this.sortItems)}load(){const e=this.getStorageKeyFn;if(e){const t=e();if(t){const i=t+this.SORTING_STATE;let s=this.loadFromLocalStorage(i);this.sortItems=s||[]}}}}class T{constructor(e=0,t=0,i=0,s=0,o){this.left=e,this.width=t,this.height=i,this.top=s,this.index=o}}class oe{constructor(e,t,i,s){this.hostElement=e,this.tableModel=t,this.dom=i,this.tableOptions=s,this.scrollTop=0,this.areaBodyWestGeo=new T,this.areaBodyCenterGeo=new T,this.areaBodyEastGeo=new T;const o=this.hostElement;o.innerText="",this.dom.setAttribute(o,"tabindex","0"),this.dom.setStyle(this.dom.addClass("ge-table",o),"position","relative"),this.hoverRow=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-hover-row",o)),this.hoverColumn=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-hover-column",o)),this.areaHeaderWest=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-header ge-table-header-west",o,"header","west"))),this.areaHeaderCenter=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-header ge-table-header-center",o,"header","center"))),this.areaHeaderEast=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-header ge-table-header-east",o,"body","east"))),this.areaBodyWest=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-body ge-table-body-west",o,"body","west"))),this.areaBodyEast=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-body ge-table-body-east",o,"body","east"))),this.areaFooterWest=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-footer ge-table-footer-west",o,"footer","west"))),this.areaFooterCenter=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-footer ge-table-footer-center",o,"footer","center"))),this.areaFooterEast=i.appendRelativeChildDiv(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-footer ge-table-footer-east",o,"footer","east"))),this.scrollViewport=i.applyStyleOverflowAuto(this.tableOptions.overflowX??"auto",this.tableOptions.overflowY??"auto",i.applyStyleNoPadding(i.applyStylePosistionAbsolute(i.createAreaDivWithClass("ge-table-scroll-viewport",o,"body","center")))),this.contentWrapperDiv=i.applyStyleNoPadding(i.applyStylePosistionRelative(i.createDivWithClass("ge-table-scroll-content-wrapper",this.scrollViewport))),this.contentDiv=i.applyStyleNoPadding(i.applyStylePosistionRelative(i.createDivWithClass("ge-table-scroll-content",this.contentWrapperDiv))),this.areaBodyCenter=i.appendRelativeChildDiv(i.createDivWithClass("ge-table-body-center",this.contentDiv)),this.borderHeaderBottom=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-header-border",o)),this.borderFixedWest=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-west-fixed-column-border",o)),this.borderFixedEast=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-east-fixed-column-border",o)),this.borderFooterTop=i.applyStylePosistionAbsolute(i.createDivWithClass("ge-table-footer-border",o))}adjustContainersAndRows(){const e=this.tableModel.getPadding(),t=this.hostElement.clientWidth,i=this.hostElement.clientHeight;this.dom.applyStyle(this.scrollViewport,{width:`${t-e.left}px`,height:`${i-e.top}px`,top:`${e.top}px`,left:`${e.left}px`}),this.scrollTop=this.scrollViewport.scrollTop,this.dom.applyStyle(this.contentDiv,{width:`${this.scrollViewport.clientWidth}px`,height:`${this.scrollViewport.clientHeight}px`,top:`${this.scrollTop}px`,left:`${this.scrollViewport.scrollLeft}px`}),this.areaBodyWestGeo.width=e.left,this.areaBodyWestGeo.height=i-e.top-e.bottom,this.areaBodyWestGeo.top=e.top,this.areaBodyWestGeo.left=0,this.dom.applyStyleInPx(this.areaBodyWest.parent,this.areaBodyWestGeo),this.tableOptions.fixedWestSeparatorBorderVisible&&this.tableModel.getFixedLeftColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedWest,{width:"1px",height:`${this.areaBodyWestGeo.height}px`,top:`${this.areaBodyWestGeo.top}px`,left:`${this.areaBodyWestGeo.width}px`})):this.dom.applyDisplayNoneStyle(this.borderFixedWest),this.areaBodyEastGeo.width=e.right,this.areaBodyEastGeo.height=i-e.top-e.bottom,this.areaBodyEastGeo.top=e.top,this.areaBodyEastGeo.left=t-e.right,this.dom.applyStyleInPx(this.areaBodyEast.parent,this.areaBodyEastGeo),this.tableOptions.fixedEastSeparatorBorderVisible&&this.tableModel.getFixedLeftColumnCount()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFixedEast,{width:"1px",height:`${this.areaBodyEastGeo.height}px`,top:`${this.areaBodyEastGeo.top}px`,left:`${this.areaBodyEastGeo.left}px`})):this.dom.applyDisplayNoneStyle(this.borderFixedEast),this.areaBodyCenterGeo.width=t-e.left-e.right,this.areaBodyCenterGeo.height=i-e.top-e.bottom,this.areaBodyCenterGeo.top=0,this.areaBodyCenterGeo.left=0,this.dom.applyStyleInPx(this.areaBodyCenter.parent,this.areaBodyCenterGeo),this.dom.applyStyle(this.areaHeaderCenter.parent,{width:`${t-e.left-e.right}px`,height:`${e.top}px`,top:"0",left:`${e.left}px`}),this.dom.applyStyle(this.areaHeaderWest.parent,{width:`${e.left}px`,height:`${e.top}px`,top:"0",left:"0"}),this.dom.applyStyle(this.areaHeaderEast.parent,{width:`${e.right}px`,height:`${e.top}px`,top:"0",left:`${t-e.right}px`}),this.tableOptions.headerSeparatorBorderVisible&&this.tableModel.isHeaderVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderHeaderBottom,{width:`${t}px`,height:"1px",top:`${e.top}px`,left:"0px"})):this.dom.applyDisplayNoneStyle(this.borderHeaderBottom),this.dom.applyStyle(this.areaFooterWest.parent,{width:`${e.left}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:"0"}),this.dom.applyStyle(this.areaFooterCenter.parent,{width:`${t-e.left-e.right}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:`${e.left}px`}),this.dom.applyStyle(this.areaFooterEast.parent,{width:`${e.right}px`,height:`${e.bottom}px`,top:`${i-e.bottom}px`,left:`${t-e.right}px`}),this.tableOptions.footerSeparatorBorderVisible&&this.tableModel.isFooterVisibe()?this.dom.applyDisplayBlockStyle(this.dom.applyStyle(this.borderFooterTop,{width:`${t}px`,height:"1px",top:`${i-e.bottom}px`,left:"0px"})):this.dom.applyDisplayNoneStyle(this.borderFooterTop),this.adjustAfterScrolling()}adjustAfterScrolling(){}resetSizeOfWrapperDiv(){const e=`${this.tableModel.getContentWidthInPixel()}px`,t=`${this.tableModel.getContentHeightInPixel()+1}px`;this.dom.setStyle(this.contentWrapperDiv,"width",e),this.dom.setStyle(this.contentWrapperDiv,"height",t)}}class A{constructor(e,t,i,s,o=!1){this.r1=e,this.c1=t,this.r2=i,this.c2=s,this.gammaRange=o}static create(e){return e.gammaRange===void 0&&(e.gammaRange=!1),new A(e.rowIndex1,e.columnIndex1,e.rowIndex2,e.columnIndex2,e.gammaRange)}static singleCell(e,t){return new A(e,t,e,t)}static singleRow(e){return new A(e,0,e,Number.MAX_SAFE_INTEGER)}static singleColumn(e){return new A(0,e,Number.MAX_SAFE_INTEGER,e)}isInRange(e,t){return e>=this.r1&&e<=this.r2&&t>=this.c1&&t<=this.c2}}class re{constructor(e,t){this.tableModel=e,this.areaModel=t,this.colAndRowspanRanges=void 0}init(){if(this.areaModel.getMaxColspan()<2&&this.areaModel.getMaxRowspan()<2)return;this.colAndRowspanRanges=[];const e=this.areaModel.getRowCount(),t=this.tableModel.getColumnCount();for(let i=0;i<e;i++)for(let s=0;s<t;s++){let o=this.areaModel.getColspanAt(i,s),r=this.areaModel.getRowspanAt(i,s);if(o>1||r>1){o===0&&(o=1),r===0&&(r=1);const n=this.areaModel.hasOwnProperty("gammaCells");this.colAndRowspanRanges.push(new A(i,s,i+r-1,s+o-1,n))}}}getRanges(){return this.colAndRowspanRanges?this.colAndRowspanRanges:[]}isInRange(e,t){if(this.colAndRowspanRanges){for(const i of this.colAndRowspanRanges)if(i.isInRange(e,t))return!0}return!1}}class le{constructor(e,t,i){this.header=e,this.body=t,this.footer=i}}class ne extends oe{constructor(e,t,i,s){var r,n;super(e,t,i,s),this.scrollLeft=0,this.scrollViewportLeft=0,this.scrollFactorY=0,this.scrollFactorX=0,this.cleanupFunctions={header:[],body:[],footer:[]},this.tree=!1,this.colAndRowspanModels=new le,this.firstVisibleRowIndex=-1,this.draggingTargetColumnIndex=-1,this.removables=[],this.editing=!1,this.tableModel.getSelectionModel?this.getSelectionModel=this.tableModel.getSelectionModel:(r=this.tableOptions)!=null&&r.getSelectionModel&&(this.getSelectionModel=this.tableOptions.getSelectionModel),(n=this.tableOptions)!=null&&n.getFocusModel&&(this.getFocusModel=this.tableOptions.getFocusModel),t.getAreaModel("body")instanceof B&&(this.tree=!0),["header","body","footer"].forEach(l=>{var a;this.colAndRowspanModels[l]=new re(t,t.getAreaModel(l)),(a=this.colAndRowspanModels[l])==null||a.init()})}isEditing(){return this.editing}resetEditorRenderer(){this.editorRenderer=void 0,this.editorRendererRow=-1,this.editorRendererColumn=-1,this.editing=!1}clearSelection(){if(this.getSelectionModel){const e=this.getSelectionModel();e==null||e.clear()}}initRenderEditor(e,t){var s;let i=(s=this.tableModel.getColumnDef(t))==null?void 0:s.getEditRenderer;if(i||(i=this.tableOptions.getEditRenderer),i)if(this.editorRenderer=i(e,t),this.editorRenderer){this.editorRendererRow=e,this.editorRendererColumn=t,this.editing=!0,this.repaint();const o=document.querySelector("input.ge-table-cell-editor-input");o&&o.focus()}else this.resetEditorRenderer()}repaint(){this.adjustAfterScrolling()}adjustAfterScrolling(){var e;for(const t of this.removables)t.remove();this.hideHoverRow(),this.hideHoverColumn(),this.scrollTop=this.scrollViewport.scrollTop,this.scrollLeft=this.scrollViewport.scrollLeft,this.debounce(this.checkForScrollPosSaving.bind(this)),this.scrollFactorY=this.scrollTop/(this.scrollViewport.scrollHeight-this.scrollViewport.clientHeight),this.scrollFactorX=this.scrollLeft/(this.scrollViewport.scrollWidth-this.scrollViewport.clientWidth),isNaN(this.scrollFactorY)&&(this.scrollFactorY=0),isNaN(this.scrollFactorX)&&(this.scrollFactorX=0),this.adjustBody(),this.adjustArea("footer"),this.adjustArea("header"),this.tableOptions.tableTopBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,0),this.hostElement,"ge-table-border")),this.tableOptions.tableBottomBorderVisible&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,this.hostElement.clientHeight-1),this.hostElement,"ge-table-border")),this.tableModel.getFixedLeftColumnCount()>0&&this.removables.push(this.dom.addVerticalBorder(new T(this.areaBodyWest.child.clientWidth,1,this.hostElement.clientHeight,0),this.hostElement,"ge-table-body-west-vertical-border")),((e=this.tableModel.getAreaModel("header"))==null?void 0:e.getRowCount())>0&&this.removables.push(this.dom.addHorizontalBorder(new T(0,this.hostElement.clientWidth,1,this.areaHeaderCenter.child.clientHeight),this.hostElement,"ge-table-body-west-vertical-border"))}checkForScrollPosSaving(){var e,t;this.storeScrollPosStateService&&((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreScrollPosition)&&this.storeScrollPosStateService.updateScrollOffset([this.scrollLeft,this.scrollTop])}updateCells(e){e.forEach(t=>this.tableModel.getAreaModel(t.area).setValue(t.rowIndex,t.columnIndex,t.value)),this.repaint()}getAreaAndSideIdentByAttr(e){if(e){const t=this.getStringByAttr(e,"data-area"),i=this.getStringByAttr(e,"data-side");if(i&&t)return[t,i]}return[void 0,void 0]}getArea(e,t){if(e==="header"){if(t==="west")return this.areaHeaderWest;if(t==="center")return this.areaHeaderCenter;if(t==="east")return this.areaHeaderEast}else if(e==="body"){if(t==="west")return this.areaBodyWest;if(t==="center")return this.areaBodyCenter;if(t==="east")return this.areaBodyEast}else if(e==="footer"){if(t==="west")return this.areaFooterWest;if(t==="center")return this.areaFooterCenter;if(t==="east")return this.areaFooterEast}throw Error(`Wrong area identifier: row:${e}, col:${t}`)}adjustBody(){const e=this.areaBodyCenterGeo.height-this.tableModel.getContentHeightInPixel(),t=this.scrollFactorY*e;this.dom.setStyle(this.contentDiv,"top",`${this.scrollTop}px`),this.dom.setStyle(this.contentDiv,"left",`${this.scrollViewport.scrollLeft}px`),this.adjustArea("body",t)}getNumberByAttr(e,t){var i;if(e){const s=(i=e.closest("["+t+"]"))==null?void 0:i.getAttribute(t);if(s)return Number(s)}return-1}getStringByAttr(e,t){var i;if(e){const s=(i=e.closest("["+t+"]"))==null?void 0:i.getAttribute(t);if(s)return s}return""}adjustArea(e,t=0){var h;const i=this.getArea(e,"west"),s=this.getArea(e,"center"),o=this.getArea(e,"east"),r=s.child.clientHeight;i.child.innerText="",s.child.innerText="",o.child.innerText="";const n=0,l=this.areaBodyCenterGeo.width,a=this.tableModel.getPadding(),d=this.tableModel.getAreaModel(e),S=d.getRowCount();for(;this.cleanupFunctions[e].length;){const u=this.cleanupFunctions[e].shift();u&&u()}let g=t;const f=this.tableModel.getColumnCount(),c=this.tableModel.getFixedRightColumnCount(),b=this.tableModel.getFixedLeftColumnCount();for(let u=0;u<S;u++){const v=g,x=u===S-1,C=this.tableModel.getRowHeight(e,u);if(v+C>0){this.firstVisibleRowIndex=u;let w={left:n,width:l,height:C,top:v,index:u},m=this.dom.addRowDiv(s,w,u,e,"center");const M=b;if(this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"center",areaModel:d,geo:w,parent:m,rowIndex:u,columnIndexStart:M,columnIndexEnd:f-c-1,verticalFixed:!1,lastRowOfModel:x}),a.left>0&&(w={left:n,width:this.areaBodyWestGeo.width,height:C,top:v,index:u},m=this.dom.addRowDiv(i,w,u,e,"west"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"west",areaModel:d,geo:w,parent:m,rowIndex:u,columnIndexStart:0,columnIndexEnd:M-1,verticalFixed:!0,lastRowOfModel:x})),a.right>0&&(w={left:n,width:this.areaBodyEastGeo.width,height:C,top:v,index:u},m=this.dom.addRowDiv(o,w,u,e,"east"),this.adjustColumnsToRowParent({areaIdent:e,sideIdent:"east",areaModel:d,geo:w,parent:m,rowIndex:u,columnIndexStart:f-c,columnIndexEnd:f-1,verticalFixed:!0,lastRowOfModel:x})),e==="header"&&this.tree&&u===S-1){const E=this.dom.applyStyle(this.dom.setAttribute(this.dom.addDiv(m,new T(16,20,20,8)),"data-ge-action","toggleExpandCollapseAll"),{cursor:"pointer"}),R=this.tableOptions.treeOptions.arrowExpandCollapseAll;if(R){const D=this.dom.domService.createText(R.content);this.dom.domService.appendChild(E,D),R.style&&this.dom.applyStyleString(E,R.style)}}}if(g=g+C,g>r)break}if(this.colAndRowspanModels&&this.colAndRowspanModels[e]){const u=((h=this.colAndRowspanModels[e])==null?void 0:h.getRanges())??[];if(u.length)for(const v of u){let x=0,C=s.child,w="center";if(v.c1<b)C=i.child,w="west";else if(c>0&&v.c1>=f-c)C=o.child,w="east";else{const m=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();x=this.scrollFactorX*m-this.areaBodyWestGeo.width,w="center"}this.drawBigCell(v,x,t,d,C,w)}}}drawBigCell(e,t,i,s,o,r){const n=i+this.getRowHeights(0,e.r1-1,s).reduce((h,u)=>h+u,0),l=this.tableModel.getColumnCount(),a=this.tableModel.getFixedRightColumnCount();let d=0;a>0&&e.c1>=l-a&&(d=l-a);const S=t+this.getColumnWidths(d,e.c1-1).reduce((h,u)=>h+u,0),g=this.getRowHeights(e.r1,e.r2,s).reduce((h,u)=>h+u,0),f=this.getColumnWidths(e.c1,e.c2).reduce((h,u)=>h+u,0);let c=!1;const b=this.getSelectionModel?this.getSelectionModel():void 0;b&&(c=b.getSelectionCount(e.r1,e.c1)>0),e.gammaRange?(console.info("TODO here",e),this.renderCell({areaModel:s,areaIdent:s.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:S,top:n,width:f,height:g,parent:o,cellSelected:c,lastRowOfModel:!0,gammaRange:e.gammaRange})):this.renderCell({areaModel:s,areaIdent:s.areaIdent,sideIdent:r,rowIndex:e.r1,columnIndex:e.c1,left:S,top:n,width:f,height:g,parent:o,cellSelected:c,lastRowOfModel:!0,gammaRange:e.gammaRange}),s.areaIdent==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:e.r1,columnIndex:e.c1,cellLeft:S,cellTop:n,cellWidth:f,cellHeight:g,parent:o})}findRowOfImportantRowspanCell(e,t,i){const s=e.getMaxRowspan();for(let o=t-1;o>-1;o--){const r=e.getRowspanAt(o,i);if(r>1&&o+r+1>=t)return o;if(t-o>s)return-1}return-1}adjustColumnsToRowParent({areaIdent:e,sideIdent:t,areaModel:i,geo:s,parent:o,rowIndex:r,columnIndexStart:n,columnIndexEnd:l,verticalFixed:a=!1,lastRowOfModel:d=!1}){var b;this.scrollViewportLeft=this.scrollViewport.scrollLeft;let S=0;if(!a){const h=this.areaBodyCenterGeo.width-this.tableModel.getContentWidthInPixel();S=this.scrollFactorX*h}const g=0,f=!!(e==="body"&&t);let c=S;for(let h=n;h<=l;h++){const u=c,v=this.tableModel.getColumnWidth(h);if(v>0&&u+v>0){let x=s.height;const C=i.getRowspanAt(r,h),w=i.getColspanAt(r,h);C>1&&(x=this.getRowHeights(r,r+C-1,i).reduce((E,R)=>E+R,0));let m=v;w>1&&(m=this.getColumnWidths(h,h+w-1).reduce((E,R)=>E+R,0));let M=!1;if(this.colAndRowspanModels&&this.colAndRowspanModels[e]&&(b=this.colAndRowspanModels[e])!=null&&b.isInRange(r,h)&&(M=!0),this.draggingTargetColumnIndex===h&&e!=="header"){this.renderDragTargetDiv(o,u,g,m,x);const E={left:u,top:g,width:m,height:x};this.dom.addColumnBorderDivs(this.tableOptions,o,E,e,t)}else{const E=this.renderSelectedBackgroundDiv(M,f,t,i,r,h,o,u,g,m,x);M||this.renderCell({areaModel:i,areaIdent:e,sideIdent:t,rowIndex:r,columnIndex:h,left:u,top:g,width:m,height:x,parent:o,cellSelected:E,lastRowOfModel:d,gammaRange:!0}),e==="header"&&this.tableOptions.columnsResizable&&this.renderHeaderCellResizeHandle({rowIndex:r,columnIndex:h,cellLeft:u,cellTop:g,cellWidth:m,cellHeight:x,parent:o})}}if(c=c+v,c>this.areaBodyCenterGeo.width)break}this.tableOptions.verticalBorderVisible&&this.dom.addVerticalBorder(new T(c-1,1,s.height,0),o)}getTreeArrowColumnIndex(){return this.tableOptions.showCheckboxWihoutExtraColumn?0:this.tableModel.isRowCheckboxVisible()?1:0}addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:i,rowIndex:s,index:o,left:r,width:n,height:l,top:a,parent:d,lastRowOfModel:S}){var W;const f=this.editorRenderer&&this.editorRendererRow===s&&this.editorRendererColumn===o?this.editorRenderer:e.getCellRenderer(s,o),c={left:r,width:n,height:l,top:a,index:o},b=e.getRowByIndex(s);let h="none";if(o===this.getTreeArrowColumnIndex()&&b instanceof L){const y=b;(W=y.children)!=null&&W.length?y.expanded?h="expanded":h="collapsed":h="hidden"}let v;if(t==="header"){const y=this.tableModel.getColumnDef(o);(!(y!=null&&y.sortIconVisible)||y!=null&&y.sortIconVisible())&&(v=y==null?void 0:y.sortState)}const x=e.getValueAt(s,o),C=f?"":`${x}`,w=e.isRowChecked(s),m=this.dom.addColumnDiv(d,c,s,o,t,i,C,h,this.tableOptions,w,v),M=e.getTooltipAt(s,o);M&&this.dom.setAttribute(m,"title",M);const E=this.tableModel.getColumnDef(o);E&&E.classes[t]&&this.dom.addClasses(E.classes[t],m);let R;f&&(R=f.render(m,s,o,t,e,x,this.dom.domService));const D=e.getCustomClassesAt(s,o);if(D.length&&this.dom.addClasses(D,m),this.dom.addColumnBorderDivs(this.tableOptions,d,c,t,i),S&&this.dom.addHorizontalBorder({left:r,width:n,height:l,top:a+l},d),this.getFocusModel&&t==="body"){const y=this.getFocusModel();y!=null&&y.hasFocus(s,o)&&this.dom.addFocusBorderDivs(d,c,{})}t==="header"&&this.dom.setAttribute(m,"data-ge-action","drag-column");const O=e.getCustomStyleAt(s,o);if(O)for(const y in O)this.dom.setStyle(m,y,O[y]);return[m,R]}getColumnWidths(e,t){const i=[];for(let s=e;s<=t;s++)i.push(this.tableModel.getColumnWidth(s));return i}getRowHeights(e,t,i){const s=[];for(let o=e;o<=t;o++)s.push(i.getRowHeight(o));return s}adjustHoverRows(e){if(this.tableOptions.hoverRowVisible&&e.rowIndex>-1){const t=this.hostElement.clientWidth,i=this.tableModel.getAreaModel("body").getRowHeight(e.rowIndex),s=e.rowTop+this.areaHeaderCenter.parent.clientHeight-this.scrollTop;this.dom.applyStyle(this.hoverRow,{left:"0",top:s+"px",width:t+"px",height:i+"px",display:"block"})}else this.hideHoverRow()}hideHoverRow(){this.dom.applyStyle(this.hoverRow,{display:"none"})}adjustHoverColumns(e){if(this.tableOptions.hoverColumnVisible&&e.rowIndex>-1){const t=this.hostElement.clientHeight,i=this.tableModel.getColumnWidth(e.columnIndex),s=this.areaBodyWestGeo.width,o=e.columnLeft+this.tableModel.getPadding().left-this.scrollLeft-s;this.dom.applyStyle(this.hoverColumn,{left:o+"px",top:"0px",width:i+"px",height:t+"px",display:"block"})}else this.hideHoverColumn()}hideHoverColumn(){this.dom.applyStyle(this.hoverColumn,{display:"none"})}debounce(e,t=1e3){this.debounceTimeout&&clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(e.bind(this),t)}renderDragTargetDiv(e,t,i,s,o){const r=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass("ge-table-drop-zone",e));return this.dom.setStyle(r,"left",`${t}px`),this.dom.setStyle(r,"top",`${i}px`),this.dom.setStyle(r,"width",`${s}px`),this.dom.setStyle(r,"height",`${o}px`),r}renderSelectedBackgroundDiv(e,t,i,s,o,r,n,l,a,d,S){let g=!1;if(!e&&t&&s.isSelectable(o,r)&&this.getSelectionModel){const f=this.getSelectionModel();if(f){const c=f.getSelectionCount(o,r);g=c>0;for(let b=0;b<c;b++){const h=this.dom.applyStylePosistionAbsolute(this.dom.createDivWithClass(`ge-table-${s.areaIdent}-${i}-selected-range`,n));this.dom.setStyle(h,"left",`${l}px`),this.dom.setStyle(h,"top",`${a}px`),this.dom.setStyle(h,"width",`${d}px`),this.dom.setStyle(h,"height",`${S}px`)}}}return g}renderCell({areaModel:e,areaIdent:t,sideIdent:i,rowIndex:s,columnIndex:o,left:r,top:n,width:l,height:a,parent:d,cellSelected:S,lastRowOfModel:g,gammaRange:f}){const[c,b]=this.addAndRenderCellDiv({areaModel:e,areaIdent:t,sideIdent:i,rowIndex:s,index:o,left:r,width:l,height:a,top:n,parent:d,lastRowOfModel:g,gammaRange:f});S&&this.dom.addClass(`ge-table-${t}-${i}-selected-range`,c),b&&this.cleanupFunctions[t].push(b)}renderHeaderCellResizeHandle({rowIndex:e,columnIndex:t,cellLeft:i,cellTop:s,cellWidth:o,cellHeight:r,parent:n}){const l=this.dom.domService,a=this.tableOptions.columnResizeHandleWidthInPx??2,d=l.createElement("div");l.setAttribute(d,"data-col-index",`${t}`),l.setAttribute(d,"data-row-index",`${e}`),l.setAttribute(d,"data-area","header"),l.setAttribute(d,"data-ge-action","resize-column"),l.addClass(d,"ge-table-column-resize-handle"),l.setStyle(d,"display","clip"),l.setStyle(d,"position","absolute"),l.setStyle(d,"cursor","col-resize"),l.setStyle(d,"left",`${i+o-a}px`),l.setStyle(d,"top",`${s}px`),l.setStyle(d,"width",`${a}px`),l.setStyle(d,"height",`${r}px`),l.appendChild(n,d)}}class ae{constructor(e,t){this.columnIndex=e,this.sortState=t}}class de{constructor(e){this.tableScope=e,this.tableScope.hostElement.addEventListener("change",this.onHostElementChanged.bind(this))}onHostElementChanged(e){if(e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||e.target instanceof HTMLTextAreaElement){const t=e.target,i=t.getAttribute("data-area"),s=t.getAttribute("data-row-index"),o=t.getAttribute("data-col-index");if(i&&s&&o){const r=V(i),n=Number(s),l=Number(o);this.tableScope.updateModelValueAfterEdit(r,n,l,t.value)}}}}class he{constructor(e=-1,t=-1){this.rowIndex=e,this.columnIndex=t}}class _{constructor(e){this.cells=e}static createSingle(e,t){return new _([new he(e,t)])}}class ce{constructor(e){var t,i;this.tableScope=e,(t=this.tableScope.tableOptions)!=null&&t.getSelectionModel&&(this.getSelectionModel=this.tableScope.tableOptions.getSelectionModel),(i=this.tableScope.tableOptions)!=null&&i.getFocusModel&&(this.getFocusModel=this.tableScope.tableOptions.getFocusModel)}onMouseClicked(e,t){var o,r,n,l,a,d,S;let i=!1,s=!1;if(this.getSelectionModel&&this.getFocusModel){const g=this.getSelectionModel(),f=this.getFocusModel();g&&f&&(f.hasFocus(e.rowIndex,e.columnIndex)||(f.setFocus(e.rowIndex,e.columnIndex),i=!0),(o=e.originalEvent)!=null&&o.shiftKey||g.hasSelection()&&(g.clear(),i=!0),(r=e.originalEvent)!=null&&r.shiftKey&&this.previousEvt?(g.addSelection(this.createRangeByEvents(e,this.previousEvt)),s=!0,i=!0):(n=e.originalEvent)!=null&&n.ctrlKey||(l=e.originalEvent)!=null&&l.metaKey?(g.addSelection(A.singleCell(e.rowIndex,e.columnIndex)),s=!0,i=!0):(a=e.originalEvent)!=null&&a.altKey&&((d=e.originalEvent)!=null&&d.ctrlKey||(S=e.originalEvent)!=null&&S.metaKey)&&(g.removeSelection(A.singleCell(e.rowIndex,e.columnIndex)),s=!0,i=!0))}return s?this.previousEvt=void 0:this.previousEvt=e==null?void 0:e.clone(),i}onActionTriggered(e){if(this.getSelectionModel&&this.getFocusModel){const t=this.getSelectionModel(),i=this.getFocusModel();if(t&&i){if(e==="SELECT_ALL")return t.selectAll(),this.tableScope.repaint(),!0;if(e==="DESELECT_ALL")return t.clear(),this.tableScope.repaint(),!0;if(e==="TOGGLE_SELECTION"){const[s,o]=i.getFocus();return t.togglePoint(s,o),this.tableScope.repaint(),!0}}}return!1}createRangeByEvents(e,t){t||(t=e);const i=Math.min(e.rowIndex,t==null?void 0:t.rowIndex),s=Math.max(e.rowIndex,t==null?void 0:t.rowIndex),o=Math.min(e.columnIndex,t==null?void 0:t.columnIndex),r=Math.max(e.columnIndex,t==null?void 0:t.columnIndex);return A.create({rowIndex1:i,columnIndex1:o,rowIndex2:s,columnIndex2:r})}}class pe{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","ctrl+a":"SELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+x":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","cmd -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT"}}}class ue{get(){return{f2:"START_EDITING",space:"TOGGLE_SELECTION","ctrl+num_add":"SELECT_ALL","cmd+a":"SELECT_ALL","ctrl+a":"SELECT_ALL","cmd+x":"DESELECT_ALL","cmd+shift+a":"DESELECT_ALL","ctrl+shift+a":"DESELECT_ALL","ctrl+num_subtract":"DESELECT_ALL","ctrl -":"DESELECT_ALL",arrowup:"NAVIGATE_UP",arrowdown:"NAVIGATE_DOWN",arrowleft:"NAVIGATE_LEFT",arrowright:"NAVIGATE_RIGHT"}}}class Se{constructor(e){this.tableScope=e,this.shortcutActionIdMapping={},this.listener=[],this.listener.push(e),this.init()}addListener(e){this.listener.includes(e)||this.listener.push(e)}init(){this.isMacintosh()?Object.assign(this.shortcutActionIdMapping,new ue().get()):Object.assign(this.shortcutActionIdMapping,new pe().get()),Object.assign(this.shortcutActionIdMapping,this.tableScope.tableOptions.shortcutActionIdMapping),this.isDebug()&&console.debug("ShortcutService",this.shortcutActionIdMapping),this.tableScope.hostElement.addEventListener("keydown",this.onKeyDown.bind(this))}isMacintosh(){return navigator.platform.indexOf("Mac")>-1}isDebug(){return this.isLocalhost()}isLocalhost(){return location.hostname==="localhost"||location.hostname==="127.0.0.1"}onKeyDown(e){const t=this.findEnty(e);t&&this.emit(t)&&(e.preventDefault(),e.stopPropagation())}emit(e){this.isDebug()&&console.debug("ShortcutService emit:",e);let t=!1;for(const i of this.listener)i.onActionTriggered(e)&&(t=!0);return t}findEnty(e){const t=this.getTokenByEvent(e);this.isDebug()&&console.debug("ShortcutService tokens:",t);for(const i in this.shortcutActionIdMapping){const s=i.replace(/opt/g,"alt").replace(/cmd/g,"meta").split(/[\+ ]/g).sort();if(this.areTokensEquals(t,s))return this.shortcutActionIdMapping[i]}}areTokensEquals(e,t){if(e.length!==t.length||e.length===0)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}getTokenByEvent(e){const t=[];return e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),e.ctrlKey&&t.push("ctrl"),e.metaKey&&t.push("meta"),e.code&&t.push(e.code.toLowerCase().replace(/key/g,"")),t.sort()}}class ge{onCheckboxChanged(e){}onContextmenu(e){}onModelChanged(e){}onMouseClicked(e){}onMouseDragging(e){}onMouseDraggingEnd(e){}onMouseMoved(e){}}class fe extends ne{constructor(e,t,i,s,o){var r;if(super(e,t,new K(i),s),this.eventListener=o,this.selectionService=new ce(this),this.api=new U(this),this.mouseStartAction="",this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,o||(this.eventListener=new ge),(r=this.tableOptions)!=null&&r.autoRestoreOptions){const n=this.tableOptions.autoRestoreOptions,l=n.getStorageKeyFn;l&&(n.autoRestoreScrollPosition&&(this.storeScrollPosStateService=new ee(l)),n.autoRestoreCollapsedExpandedState&&(this.storeStateCollapsedExpandService=new ie(l)),n.autoRestoreSortingState&&(this.storeSortingService=new se(l)))}this.mouseHandler=new q(this),this.inputHandler=new de(this),this.shortcutService=new Se(this),this.shortcutService.addListener(this.selectionService)}onActionTriggered(e){if(e==="NAVIGATE_DOWN"&&this.changeFocusCell(0,1)||e==="NAVIGATE_UP"&&this.changeFocusCell(0,-1)||e==="NAVIGATE_LEFT"&&this.changeFocusCell(-1,0)||e==="NAVIGATE_RIGHT"&&this.changeFocusCell(1,0))return!0;if(e==="START_EDITING"&&this.getFocusModel){const t=this.getFocusModel();if(t){const[i,s]=t.getFocus();this.tableModel.getBodyModel().isEditable(i,s)&&(this.clearSelection(),this.initRenderEditor(i,s))}return!0}return!1}updateModelValueAfterEdit(e,t,i,s){e==="body"&&this.tableModel.getAreaModel(e).setValue(t,i,s)&&(this.resetEditorRenderer(),this.repaint(),this.eventListener.onModelChanged(_.createSingle(t,i)),this.hostElement.focus())}getApi(){return this.api}firstInit(){var e;this.tableModel.init(),(e=this.tableOptions)!=null&&e.externalFilterFunction&&this.externalFilterChanged(!1),this.autoRestoreCollapsedExpandedState(),this.autoRestoreSortingState(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows(),this.autoRestoreScrollPosition()}createGeMouseEvent(e){const t=new P;if(t.originalEvent=e,e){const i=e.target;if([t.areaIdent,t.sideIdent]=this.getAreaAndSideIdentByAttr(i),t.rowIndex=this.getNumberByAttr(i,"data-row-index"),t.columnIndex=this.getNumberByAttr(i,"data-col-index"),t.action=this.getStringByAttr(i,"data-ge-action"),t.areaIdent){const s=this.tableModel.getAreaModel(t.areaIdent);t.rowTop=s.getYPosByRowIndex(t.rowIndex)}if(t.columnLeft=this.tableModel.getXPosByColumnIndex(t.columnIndex),e.ctrlKey&&e.altKey){const s=e.clientY-this.hostElement.offsetTop-this.areaHeaderCenter.parent.clientHeight,o=e.clientX-this.hostElement.offsetLeft-this.areaBodyWestGeo.width;this.debugOnce(o,s)}}return t}onMouseDown(e){e.columnIndex>-1&&e.action&&["resize-column","drag-column"].includes(e.action)&&(this.mouseStartWidth=this.tableModel.getColumnWidth(e.columnIndex),this.mouseStartAction=e.action,this.mouseStartColumnIndex=e.columnIndex,this.mouseStartAction==="drag-column"&&(this.dragFrom=this.mouseStartColumnIndex))}mouseDraggingOnFrame(e){this.eventListener.onMouseDragging(e),this.mouseEvent=e,this.mouseStartColumnIndex>-1&&this.mouseStartAction==="resize-column"&&this.tableOptions.columnsResizable?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&e.columnIndex>-1&&this.tableOptions.columnsDraggable&&(this.draggingTargetColumnIndex=e.columnIndex,this.dragTo=this.draggingTargetColumnIndex,this.dragFrom>-1&&this.dragTo>-1&&this.dragFrom!==this.dragTo&&(this.tableModel.changeColumnOrder(this.dragFrom,this.dragTo),this.dragFrom=this.dragTo,this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()),this.repaint())}mouseDraggingEndOnFrame(e){this.eventListener.onMouseDraggingEnd(e),this.draggingTargetColumnIndex=-1,this.mouseStartAction==="resize-column"?this.resizeColumn(e):this.mouseStartAction==="drag-column"&&this.repaint(),this.mouseStartWidth=-1,this.mouseStartColumnIndex=-1,this.dragFrom=-1,this.dragTo=-1,this.mouseStartAction=""}mouseMove(e){this.eventListener.onMouseMoved(e),this.adjustHoverRows(e),this.adjustHoverColumns(e)}contextmenu(e){this.eventListener.onContextmenu(e)}toggleExpandCollapseAll(e=!0){var i;const t=this.tableModel.getBodyModel();t instanceof B&&(t.toggleExpandCollapseAll(e),this.repaint(),(i=this.storeStateCollapsedExpandService)==null||i.collapsedStateAll(e))}toggleRowCheckbox(e,t,i){var l;const s=this.tableModel.getAreaModel(i),o=s.isRowChecked(e),r=o===void 0||o==="semi"||o==="none";s.setRowChecked(e,r),this.repaint();const n=(l=s.rowSelectionModel)==null?void 0:l.getCheckedRows();this.eventListener.onCheckboxChanged(n||[])}onMouseClicked(e,t){let i=this.selectionService.onMouseClicked(e,t);if(!i&&this.getFocusModel){const s=this.getFocusModel();s&&(i=s.hasChanged(),s.clearChanged(),i&&this.resetEditorRenderer())}this.eventListener.onMouseClicked(e),i&&this.debounce(this.repaint.bind(this),10)}externalFilterChanged(e=!0){const t=this.tableOptions.externalFilterFunction;t&&(e&&this.clearSelectionModel(),this.tableModel.externalFilterChanged(t),this.scrollViewport.scrollTo(0,0),this.tableModel.recalcHeightAndPadding(),this.resetSizeOfWrapperDiv(),this.repaint())}onHeaderDblClicked(e,t,i){var o,r;const s=this.tableModel.getColumnDef(i);if(s!=null&&s.sortable&&s.sortable()){e.preventDefault(),e.stopPropagation();const n=s.sortStatesOrder?s.sortStatesOrder:this.tableOptions.sortOrder,l=s.sortState??"",a=n[(n.indexOf(l)+1)%n.length],d=new ae(i,a);this.tableModel.doSort([d])&&((o=this.tableModel.getColumnDefs())==null||o.forEach(g=>g.sortState=""),s.sortState=a),this.repaint(),(r=this.storeSortingService)==null||r.setSortItems([d])}}changeFocusCell(e,t){if(!this.isEditing()&&this.getFocusModel){const i=this.getFocusModel();if(i){const[s,o]=i.getFocus();return i.setFocus(s+t,o+e),this.repaint(),!0}}return!1}resizeColumn(e){this.tableModel.setColumnWidth(this.mouseStartColumnIndex,this.mouseStartWidth+e.draggingX),this.tableModel.recalcPadding(),this.resetSizeOfWrapperDiv(),this.adjustContainersAndRows()}clearSelectionModel(){var e;this.getSelectionModel&&((e=this.getSelectionModel())==null||e.clear())}debugOnce(e,t){var i;console.clear(),console.info("this.hostElement.offsetTop",this.hostElement.offsetTop),console.info("this.hostElement.scrollHeight",this.hostElement.scrollHeight),console.info("this.scrollViewportTop",this.scrollTop),console.info("this.areaHeaderCenter.parent.clientHeight",this.areaHeaderCenter.parent.clientHeight),console.info("bodyY",t),console.info("bodyX",e),console.info("rows",this.firstVisibleRowIndex),console.info(""),console.info("this.tableModel",this.tableModel),console.info(""),console.info("this.mouseMoveEvent.clientX",(i=this.mouseHandler.mouseEvent)==null?void 0:i.clientX),console.info("this.hostElement.offsetLeft",this.hostElement.offsetLeft),console.info("this.areaBodyWestGeo.width",this.areaBodyWestGeo.width)}autoRestoreScrollPosition(){var e;if((e=this.tableOptions)!=null&&e.autoRestoreOptions&&this.storeScrollPosStateService&&this.tableOptions.autoRestoreOptions.autoRestoreScrollPosition){const i=this.storeScrollPosStateService.getScrollOffset();i&&this.scrollViewport.scrollTo(...i)}}autoRestoreSortingState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.autoRestoreSortingState&&this.storeSortingService){const i=this.storeSortingService.getSortItems();i!=null&&i.length&&this.tableModel.getBodyModel().doSort(i)}}autoRestoreCollapsedExpandedState(){var e,t;if((t=(e=this.tableOptions)==null?void 0:e.autoRestoreOptions)!=null&&t.getRowId&&this.storeStateCollapsedExpandService){const i=this.tableOptions.autoRestoreOptions,s=i.getRowId;if(i.autoRestoreCollapsedExpandedState&&s){const o=this.storeStateCollapsedExpandService.collapsedExpandedStateGet(),r=this.tableModel.getAreaModel("body");if(r instanceof B){const n=r,l=r.getRowCount();for(let a=0;a<l;a++){const d=r.getRowByIndex(a);if(d)if(o.allExpanded)d.expanded=!0;else if(o.allCollapsed)d.expanded=!1;else{const S=s(d.data);o.mode==="expanded"?d.expanded=this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(S):o.mode==="collapsed"&&(d.expanded=!this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(S))}}n.recalcVisibleTreeRows()}}}}}class me{render(e,t,i,s,o,r,n){if(o.isEditable(t,i)){n.addClass(e,"ge-table-row-input-div");const l=o.getValueAt(t,i);e.innerHTML=`
165
+ class="ge-table-row-checkbox"> `, this.domService.setStyle(o, "display", "inline"), this.domService.setStyle(o, "width", "inherit"), this.domService.setAttribute(o, "data-row-index", `${i}`), this.domService.appendChild(e, o), o;
166
+ }
167
+ addLabelDiv(e, t = "", s = !1, i = -1, o = -1, r = "body") {
168
+ const n = this.domService.createElement("div");
169
+ if (this.domService.addClass(n, "ge-table-label-div"), this.domService.setStyle(n, "position", "relative"), this.domService.setStyle(n, "background", "transparent"), this.domService.setStyle(n, "width", "100%"), this.domService.setStyle(n, "height", "100%"), this.domService.setAttribute(n, "data-row-index", `${i}`), this.domService.setAttribute(n, "data-col-index", `${o}`), this.domService.setAttribute(n, "data-area", `${r}`), t)
170
+ if (s) {
171
+ const l = this.domService.createText(t);
172
+ this.domService.appendChild(n, l);
173
+ } else {
174
+ const l = this.domService.createElement("div");
175
+ this.domService.appendChild(n, l);
176
+ const a = this.domService.createText(t);
177
+ this.domService.addClass(l, "ge-table-label"), this.domService.appendChild(l, a), this.domService.setAttribute(l, "data-row-index", `${i}`), this.domService.setAttribute(l, "data-col-index", `${o}`), this.domService.setAttribute(l, "data-area", `${r}`);
178
+ }
179
+ return this.domService.appendChild(e, n), n;
180
+ }
181
+ addSortedIcon(e, t = "", s = new X(), i = -1) {
182
+ const o = this.domService.createElement("div");
183
+ this.domService.addClass(o, "ge-table-sorted-icon-div"), this.domService.setStyle(o, "position", "absolute"), this.domService.setStyle(o, "top", "0"), this.domService.setStyle(o, "right", "0"), this.domService.setStyle(o, "width", "20px"), this.domService.setStyle(o, "background", "transparent"), this.domService.setStyle(o, "cursor", "pointer"), this.domService.setAttribute(o, "data-col-index", `${i}`), this.domService.setAttribute(o, "data-area", "header");
184
+ let r;
185
+ t === "asc" ? r = s.iconAsc : t === "desc" ? r = s.iconDesc : r = s.iconPlaceholder;
186
+ const n = r.content, l = this.domService.createText(n);
187
+ this.domService.appendChild(o, l), r.style && this.applyStyleString(o, r.style);
188
+ for (const a of r.classes)
189
+ this.domService.addClass(o, a);
190
+ return this.domService.appendChild(e, o), o;
191
+ }
192
+ addArrowDiv(e, t = "none", s = new j(), i = -1, o = -1, r = "body") {
193
+ const n = this.domService.createElement("div");
194
+ this.domService.addClass(n, "ge-table-tree-arrow-div"), this.domService.setStyle(n, "display", "inline-block"), this.domService.setStyle(n, "position", ""), this.domService.setStyle(n, "width", "20px"), this.domService.setStyle(n, "background", "transparent"), this.domService.setStyle(n, "cursor", "pointer"), this.domService.setAttribute(n, "data-row-index", `${i}`), this.domService.setAttribute(n, "data-col-index", `${o}`), this.domService.setAttribute(n, "data-area", `${r}`);
195
+ let l;
196
+ t === "expanded" ? l = s.arrowExpanded : t === "collapsed" ? l = s.arrowCollapsed : l = s.arrowPlaceholder;
197
+ const a = l.content, d = this.domService.createText(a);
198
+ this.domService.appendChild(n, d), l.style && this.applyStyleString(n, l.style);
199
+ for (const u of l.classes)
200
+ this.domService.addClass(n, u);
201
+ return this.domService.appendChild(e, n), n;
202
+ }
203
+ addColumnBorderDivs(e, t, s, i, o) {
204
+ if (e.verticalBorderVisible) {
205
+ const r = `ge-table-${i}-${o}-vertical-border`;
206
+ this.addVerticalBorder(s, t, r);
207
+ }
208
+ if (e.horizontalBorderVisible) {
209
+ const r = `ge-table-${i}-${o}-horizontal-border`;
210
+ this.addHorizontalBorder(s, t, r);
211
+ }
212
+ return t;
213
+ }
214
+ addHorizontalBorder(e, t, s = "ge-table-body-center-horizontal-border") {
215
+ const i = this.domService.createElement("div");
216
+ return this.domService.addClass(i, s), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${e.left}px`), this.domService.setStyle(i, "top", `${e.top}px`), this.domService.setStyle(i, "width", `${e.width}px`), this.domService.setStyle(i, "height", "1px"), this.domService.appendChild(t, i), i;
217
+ }
218
+ addFocusBorderDivs(e, t, s) {
219
+ let i = this.domService.createElement("div");
220
+ return this.domService.addClass(i, "ge-table-focus-border"), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${t.left}px`), this.domService.setStyle(i, "top", `${t.top}px`), this.domService.setStyle(i, "width", "1px"), this.domService.setStyle(i, "height", `${t.height}px`), this.applyStyle(i, s), this.domService.appendChild(e, i), i = this.domService.createElement("div"), this.domService.addClass(i, "ge-table-focus-border"), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${t.left + t.width - 1}px`), this.domService.setStyle(i, "top", `${t.top}px`), this.domService.setStyle(i, "width", "1px"), this.domService.setStyle(i, "height", `${t.height}px`), this.applyStyle(i, s), this.domService.appendChild(e, i), i = this.domService.createElement("div"), this.domService.addClass(i, "ge-table-focus-border"), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${t.left}px`), this.domService.setStyle(i, "top", `${t.top}px`), this.domService.setStyle(i, "width", `${t.width}px`), this.domService.setStyle(i, "height", "1px"), this.applyStyle(i, s), this.domService.appendChild(e, i), i = this.domService.createElement("div"), this.domService.addClass(i, "ge-table-focus-border"), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${t.left}px`), this.domService.setStyle(i, "top", `${t.top + t.height - 1}px`), this.domService.setStyle(i, "width", `${t.width}px`), this.domService.setStyle(i, "height", "1px"), this.applyStyle(i, s), this.domService.appendChild(e, i), e;
221
+ }
222
+ addVerticalBorder(e, t, s = "ge-table-body-center-vertical-border") {
223
+ const i = this.domService.createElement("div");
224
+ return this.domService.addClass(i, s), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${e.left}px`), this.domService.setStyle(i, "top", `${e.top}px`), this.domService.setStyle(i, "width", "1px"), this.domService.setStyle(i, "height", `${e.height}px`), this.domService.appendChild(t, i), i;
225
+ }
226
+ addDiv(e, t, s = "") {
227
+ const i = this.domService.createElement("div");
228
+ return s && this.domService.addClass(i, s), this.domService.setStyle(i, "display", "clip"), this.domService.setStyle(i, "position", "absolute"), this.domService.setStyle(i, "left", `${t.left}px`), this.domService.setStyle(i, "top", `${t.top}px`), this.domService.setStyle(i, "width", `${t.width}px`), this.domService.setStyle(i, "height", `${t.height}px`), this.domService.appendChild(e, i), i;
229
+ }
230
+ applyStyleString(e, t) {
231
+ const s = t.split(";").map((i) => i.trim()).filter((i) => i);
232
+ for (const i of s) {
233
+ const [o, r] = i.split(":");
234
+ this.domService.setStyle(e, o.trim(), r.trim());
235
+ }
236
+ }
237
+ getDivOrCreateDiv(e, t) {
238
+ let s = t.cache[e];
239
+ return s ? (s.innerText = "", s) : (s = this.domService.createElement("div"), t.cache[e] = s, s);
240
+ }
241
+ }
242
+ const H = (p) => p === "header" ? "header" : p === "footer" ? "footer" : "body";
243
+ class Z {
244
+ constructor(e, t) {
245
+ if (this.rowIdx = -1, this.colIdx = -1, this.action = null, this.inputType = null, this.className = "", e !== null && (e instanceof HTMLDivElement || e instanceof HTMLSpanElement || e instanceof HTMLInputElement)) {
246
+ this.className = e.className, this.action = e.getAttribute("data-ge-action"), this.inputType = e.getAttribute("data-input-type"), this.rowIdx = Number(e.getAttribute("data-row-index")), this.colIdx = Number(e.getAttribute("data-col-index"));
247
+ const s = e.getAttribute("data-area");
248
+ if (s && (this.areaIdent = H(s), this.areaModel = t.tableModel.getAreaModel(this.areaIdent), this.row = this.areaModel.getRowByIndex(this.rowIdx)), e instanceof HTMLInputElement) {
249
+ const i = e;
250
+ this.value = i.value;
251
+ }
252
+ }
253
+ }
254
+ }
255
+ class ee {
256
+ constructor(e) {
257
+ this.tableScope = e, this.expandedAll = !0, this.mouseDown = !1, this.dragging = !1, this.tableScope.hostElement.addEventListener("click", this.onHostElementClicked.bind(this)), this.tableScope.hostElement.addEventListener("dblclick", this.onHostElementDblClicked.bind(this)), this.tableScope.hostElement.addEventListener("mousedown", this.onMouseDown.bind(this)), this.tableScope.hostElement.addEventListener("mousemove", this.onMouseMove.bind(this)), this.tableScope.hostElement.addEventListener("mouseup", this.onMouseUp.bind(this)), this.tableScope.hostElement.addEventListener("contextmenu", this.onContextmenu.bind(this)), this.tableScope.hostElement._MouseHandler = "true", this.tableScope.scrollViewport.addEventListener("scroll", this.tableScope.adjustAfterScrolling.bind(this.tableScope)), [window, this.tableScope.hostElement].forEach(
258
+ (t) => t.addEventListener("resize", this.tableScope.adjustContainersAndRows.bind(this.tableScope))
259
+ );
260
+ }
261
+ onContextmenu(e) {
262
+ this.mouseEvent = e;
263
+ const t = this.tableScope.createGeMouseEvent(this.mouseEvent);
264
+ this.tableScope.contextmenu(t);
265
+ }
266
+ onHostElementClicked(e) {
267
+ const t = new Z(e.target, this.tableScope);
268
+ if (t.action === "toggleExpandCollapseAll")
269
+ this.expandedAll = !this.expandedAll, this.tableScope.toggleExpandCollapseAll(this.expandedAll), e.preventDefault(), e.stopPropagation();
270
+ else if (t.inputType === "checkbox" && t.areaIdent)
271
+ this.tableScope.toggleRowCheckbox(t.rowIdx, t.colIdx, t.areaIdent), e.preventDefault(), e.stopPropagation();
272
+ else if (O(t.row) && t.areaModel) {
273
+ const s = t.colIdx === this.getArrowColumnIndex() && e.altKey, i = t.className.includes("ge-table-tree-arrow-div");
274
+ if (console.info(i, s), s || i) {
275
+ e.preventDefault(), e.stopPropagation();
276
+ const o = t.row;
277
+ o.expanded = !o.expanded, "recalcVisibleTreeRows" in t.areaModel && t.areaModel.recalcVisibleTreeRows(), this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth), this.tableScope.adjustContainersAndRows(), this.updateCollapsedExpandedState(o);
278
+ }
279
+ }
280
+ if (t.areaIdent === "body" && this.tableScope.tableOptions.getFocusModel) {
281
+ const s = this.tableScope.tableOptions.getFocusModel();
282
+ s == null || s.clear(), s == null || s.setFocus(t.rowIdx, t.colIdx);
283
+ }
284
+ this.publishGeMouseEvent(e, 1);
285
+ }
286
+ onHostElementDblClicked(e) {
287
+ if (e.target instanceof HTMLElement) {
288
+ const t = e.target, s = t.getAttribute("data-area"), i = H(s), o = Number(t.getAttribute("data-row-index")), r = Number(t.getAttribute("data-col-index")), n = this.tableScope.tableModel.getAreaModel(i);
289
+ if (s && i === "header")
290
+ this.tableScope.tableModel.isSortable(r) && (this.tableScope.clearSelection(), this.tableScope.onHeaderDblClicked(e, o, r));
291
+ else if (t.getAttribute("data-row-index")) {
292
+ const l = n.getRowByIndex(o);
293
+ if (s && i === "body" && n.isEditable(o, r) && (this.tableScope.clearSelection(), this.tableScope.initRenderEditor(o, r)), O(l) && r === this.getArrowColumnIndex()) {
294
+ e.preventDefault(), e.stopPropagation();
295
+ const a = l;
296
+ a.expanded = !a.expanded, "recalcVisibleTreeRows" in n && n.recalcVisibleTreeRows(), this.tableScope.tableModel.recalcSize(this.tableScope.hostElement.clientWidth), this.tableScope.adjustContainersAndRows(), this.updateCollapsedExpandedState(a);
297
+ }
298
+ }
299
+ }
300
+ this.publishGeMouseEvent(e, 2);
301
+ }
302
+ publishGeMouseEvent(e, t) {
303
+ var s;
304
+ this.mouseEvent = e, this.geMouseEventOld = (s = this.geMouseEvent) == null ? void 0 : s.clone(), this.geMouseEvent = this.tableScope.createGeMouseEvent(e), this.geMouseEvent && (this.geMouseEvent.clickCount = t), this.tableScope.onMouseClicked(this.geMouseEvent, this.geMouseEventOld);
305
+ }
306
+ updateCollapsedExpandedState(e) {
307
+ var s, i, o, r, n;
308
+ const t = (i = (s = this.tableScope.tableOptions) == null ? void 0 : s.autoRestoreOptions) == null ? void 0 : i.getRowId;
309
+ if (t) {
310
+ const l = (o = this.tableScope.storeStateCollapsedExpandService) == null ? void 0 : o.collapsedExpandedStateGet().mode, a = l === "collapsed" && !e.expanded || l === "expanded" && e.expanded, d = l === "collapsed" && e.expanded || l === "expanded" && !e.expanded, u = t(e.data);
311
+ a ? (r = this.tableScope.storeStateCollapsedExpandService) == null || r.collapsedStateIdsPush(u) : d && ((n = this.tableScope.storeStateCollapsedExpandService) == null || n.collapsedStateIdsRemove(u));
312
+ }
313
+ }
314
+ getArrowColumnIndex() {
315
+ return this.tableScope.tableModel.isRowCheckboxVisible() ? 1 : 0;
316
+ }
317
+ onMouseDown(e) {
318
+ this.mouseEvent = e, this.startMouseEvent = this.tableScope.createGeMouseEvent(this.mouseEvent), this.tableScope.onMouseDown(this.startMouseEvent), this.mouseDown = !0;
319
+ }
320
+ onMouseMove(e) {
321
+ this.mouseEvent = e, this.mouseDown ? (this.dragging = !0, requestAnimationFrame(this.mouseDraggingOnFrame.bind(this))) : requestAnimationFrame(this.mouseMoveOnFrame.bind(this));
322
+ }
323
+ onMouseUp(e) {
324
+ this.mouseEvent = e, this.dragging && requestAnimationFrame(this.mouseDraggingEndOnFrame.bind(this)), this.mouseDown = !1, this.dragging = !1;
325
+ }
326
+ mouseDraggingOnFrame() {
327
+ var e;
328
+ if (this.mouseEvent) {
329
+ const t = this.tableScope.createGeMouseEvent(this.mouseEvent);
330
+ (e = this.startMouseEvent) != null && e.originalEvent && (t.draggingX = this.mouseEvent.clientX - this.startMouseEvent.originalEvent.clientX, t.draggingY = this.mouseEvent.clientY - this.startMouseEvent.originalEvent.clientY), this.tableScope.mouseDraggingOnFrame(t);
331
+ }
332
+ }
333
+ mouseDraggingEndOnFrame() {
334
+ var e;
335
+ if (this.mouseEvent) {
336
+ const t = this.tableScope.createGeMouseEvent(this.mouseEvent);
337
+ (e = this.startMouseEvent) != null && e.originalEvent && (t.draggingX = this.mouseEvent.clientX - this.startMouseEvent.originalEvent.clientX, t.draggingY = this.mouseEvent.clientY - this.startMouseEvent.originalEvent.clientY), this.tableScope.mouseDraggingEndOnFrame(t);
338
+ }
339
+ }
340
+ mouseMoveOnFrame() {
341
+ if (this.mouseEvent) {
342
+ const e = this.tableScope.createGeMouseEvent(this.mouseEvent);
343
+ this.tableScope.mouseMove(e);
344
+ }
345
+ }
346
+ }
347
+ class te {
348
+ constructor(e) {
349
+ this.tableScope = e;
350
+ }
351
+ updateCells(e, t = !1) {
352
+ this.tableScope.updateCells(e, t);
353
+ }
354
+ externalFilterChanged() {
355
+ this.tableScope.externalFilterChanged();
356
+ }
357
+ scrollToPixel(e = 0, t = 0) {
358
+ }
359
+ scrollToIndex(e = 0, t = 0) {
360
+ }
361
+ setHeaderVisible(e = !0) {
362
+ }
363
+ setColumnVisible(e, t = !0) {
364
+ }
365
+ isColumnVisible(e) {
366
+ return !0;
367
+ }
368
+ isHeaderVisible() {
369
+ return !0;
370
+ }
371
+ setFooterVisible(e = !0) {
372
+ }
373
+ isFooterVisible() {
374
+ return !0;
375
+ }
376
+ repaint() {
377
+ this.tableScope.repaint();
378
+ }
379
+ }
380
+ class P {
381
+ constructor(e) {
382
+ this.getStorageKeyFn = e;
383
+ }
384
+ autoConvertMapToObject(e) {
385
+ const t = {};
386
+ if (e instanceof Map) {
387
+ const s = e;
388
+ for (const i of [...s]) {
389
+ const [
390
+ o,
391
+ r
392
+ ] = i;
393
+ t[o] = r;
394
+ }
395
+ }
396
+ return t;
397
+ }
398
+ checkAndPersistItem(e, t) {
399
+ const s = this.getStorageKeyFn;
400
+ if (s) {
401
+ const i = s();
402
+ if (i) {
403
+ const o = i + e;
404
+ if ((t + "").includes("Map")) {
405
+ const r = this.autoConvertMapToObject(t);
406
+ this.persistItem(o, r);
407
+ } else
408
+ this.persistItem(o, t);
409
+ }
410
+ }
411
+ }
412
+ persistItem(e, t) {
413
+ t ? localStorage.setItem(e, JSON.stringify(t)) : localStorage.removeItem(e);
414
+ }
415
+ loadFromLocalStorage(e) {
416
+ const t = localStorage.getItem(e);
417
+ return t ? JSON.parse(t) : null;
418
+ }
419
+ // private loadItems() {
420
+ // const fn = this.getStorageKeyFn;
421
+ // if (fn) {
422
+ // const key = fn();
423
+ // if (key) {
424
+ // // A main key is given by function from options
425
+ // const subKey = key + this.CHECKED_STATE;
426
+ // const arr = this.loadFromLocalStorage<Array<string | number>>(subKey);
427
+ // if (arr) {
428
+ // this.checkedStateIds.length = 0;
429
+ // arr.forEach(a => this.checkedStateIds.push(a));
430
+ // }
431
+ //
432
+ // const subKey2 = key + this.COLLAPSED_EXPANDED_STATE;
433
+ // const data = this.loadFromLocalStorage<CollapsedExpandedData>(subKey2);
434
+ // if (data) {
435
+ // this.collapsedExpandedState = data;
436
+ // }
437
+ //
438
+ // const subKey3 = key + this.SELECTED_STATE;
439
+ // const arr3 = this.loadFromLocalStorage<object>(subKey3);
440
+ // if (arr3) {
441
+ // const map: Map<string | number, string[]> = new Map(Object.entries(arr3));
442
+ // if (map) {
443
+ // this.selectedStateIds.clear();
444
+ // map.forEach((col, k) => this.selectedStateIds.set(k, col));
445
+ // }
446
+ // }
447
+ //
448
+ // const subKey4 = key + this.SCROLL_STATE;
449
+ // let scrollOffset = this.loadFromLocalStorage<[number, number]>(subKey4);
450
+ // this.scrollOffset = scrollOffset ? scrollOffset : [0, 0];
451
+ // }
452
+ // }
453
+ // }
454
+ }
455
+ class se extends P {
456
+ constructor(e) {
457
+ super(e), this.SCROLL_STATE = "scrollState", this.scrollOffset = [0, 0], this.load();
458
+ }
459
+ getScrollOffset() {
460
+ return this.scrollOffset;
461
+ }
462
+ updateScrollOffset(e) {
463
+ this.scrollOffset = e, this.checkAndPersistItem(this.SCROLL_STATE, this.scrollOffset);
464
+ }
465
+ load() {
466
+ const e = this.getStorageKeyFn;
467
+ if (e) {
468
+ const t = e();
469
+ if (t) {
470
+ const s = t + this.SCROLL_STATE;
471
+ let i = this.loadFromLocalStorage(s);
472
+ this.scrollOffset = i || [0, 0];
473
+ }
474
+ }
475
+ }
476
+ }
477
+ class ie {
478
+ constructor(e = "collapsed", t = [], s = !1, i = !1) {
479
+ this.mode = e, this.rowIds = t, this.allCollapsed = s, this.allExpanded = i;
480
+ }
481
+ }
482
+ class oe extends P {
483
+ constructor(e) {
484
+ super(e), this.COLLAPSED_EXPANDED_STATE = "collapsedExpandedState", this.collapsedExpandedState = new ie(), this.load();
485
+ }
486
+ collapsedExpandedStateGet() {
487
+ return this.collapsedExpandedState;
488
+ }
489
+ collapsedExpandedStateIncludes(e) {
490
+ return this.collapsedExpandedState.rowIds.includes(e);
491
+ }
492
+ collapsedStateIdsPush(e) {
493
+ this.collapsedExpandedState.rowIds.includes(e) || (this.collapsedExpandedState.rowIds.push(e), this.collapsedExpandedState.allCollapsed = !1, this.collapsedExpandedState.allExpanded = !1, this.persist());
494
+ }
495
+ collapsedStateIdsRemove(e) {
496
+ const t = this.collapsedExpandedState.rowIds.indexOf(e);
497
+ t !== -1 && (this.collapsedExpandedState.rowIds.splice(t, 1), this.collapsedExpandedState.allCollapsed = !1, this.collapsedExpandedState.allExpanded = !1, this.persist());
498
+ }
499
+ collapsedStateAll(e) {
500
+ this.collapsedExpandedState.rowIds = [], this.collapsedExpandedState.mode = e ? "collapsed" : "expanded", this.collapsedExpandedState.allCollapsed = !e, this.collapsedExpandedState.allExpanded = e, this.persist();
501
+ }
502
+ load() {
503
+ const e = this.getStorageKeyFn;
504
+ if (e) {
505
+ const t = e();
506
+ if (t) {
507
+ const s = t + this.COLLAPSED_EXPANDED_STATE, i = this.loadFromLocalStorage(s);
508
+ i && (this.collapsedExpandedState = i);
509
+ }
510
+ }
511
+ }
512
+ persist() {
513
+ this.checkAndPersistItem(this.COLLAPSED_EXPANDED_STATE, this.collapsedExpandedState);
514
+ }
515
+ }
516
+ class le extends P {
517
+ constructor(e) {
518
+ super(e), this.SORTING_STATE = "sortingState", this.sortItems = [], this.load();
519
+ }
520
+ getSortItems() {
521
+ return this.sortItems;
522
+ }
523
+ setSortItems(e) {
524
+ this.sortItems = e, this.checkAndPersistItem(this.SORTING_STATE, this.sortItems);
525
+ }
526
+ load() {
527
+ const e = this.getStorageKeyFn;
528
+ if (e) {
529
+ const t = e();
530
+ if (t) {
531
+ const s = t + this.SORTING_STATE;
532
+ let i = this.loadFromLocalStorage(s);
533
+ this.sortItems = i || [];
534
+ }
535
+ }
536
+ }
537
+ }
538
+ class T {
539
+ constructor(e = 0, t = 0, s = 0, i = 0, o) {
540
+ this.left = e, this.width = t, this.height = s, this.top = i, this.index = o;
541
+ }
542
+ }
543
+ class re {
544
+ constructor(e, t, s, i) {
545
+ this.hostElement = e, this.tableModel = t, this.dom = s, this.tableOptions = i, this.scrollTop = 0, this.areaBodyWestGeo = new T(), this.areaBodyCenterGeo = new T(), this.areaBodyEastGeo = new T();
546
+ const o = this.hostElement;
547
+ o.innerText = "", this.dom.setAttribute(o, "tabindex", "0"), this.dom.setStyle(
548
+ this.dom.addClass("ge-table", o),
549
+ "position",
550
+ "relative"
551
+ ), this.hoverRow = s.applyStylePosistionAbsolute(
552
+ s.createDivWithClass("ge-table-hover-row", o)
553
+ ), this.hoverColumn = s.applyStylePosistionAbsolute(
554
+ s.createDivWithClass("ge-table-hover-column", o)
555
+ ), this.areaHeaderWest = s.appendRelativeChildDiv(
556
+ s.applyStylePosistionAbsolute(
557
+ s.createAreaDivWithClass("ge-table-header ge-table-header-west", o, "header", "west")
558
+ )
559
+ ), this.areaHeaderCenter = s.appendRelativeChildDiv(
560
+ s.applyStylePosistionAbsolute(
561
+ s.createAreaDivWithClass("ge-table-header ge-table-header-center", o, "header", "center")
562
+ )
563
+ ), this.areaHeaderEast = s.appendRelativeChildDiv(
564
+ s.applyStylePosistionAbsolute(
565
+ s.createAreaDivWithClass("ge-table-header ge-table-header-east", o, "body", "east")
566
+ )
567
+ ), this.areaBodyWest = s.appendRelativeChildDiv(
568
+ s.applyStylePosistionAbsolute(
569
+ s.createAreaDivWithClass("ge-table-body ge-table-body-west", o, "body", "west")
570
+ )
571
+ ), this.areaBodyEast = s.appendRelativeChildDiv(
572
+ s.applyStylePosistionAbsolute(
573
+ s.createAreaDivWithClass("ge-table-body ge-table-body-east", o, "body", "east")
574
+ )
575
+ ), this.areaFooterWest = s.appendRelativeChildDiv(
576
+ s.applyStylePosistionAbsolute(
577
+ s.createAreaDivWithClass("ge-table-footer ge-table-footer-west", o, "footer", "west")
578
+ )
579
+ ), this.areaFooterCenter = s.appendRelativeChildDiv(
580
+ s.applyStylePosistionAbsolute(
581
+ s.createAreaDivWithClass("ge-table-footer ge-table-footer-center", o, "footer", "center")
582
+ )
583
+ ), this.areaFooterEast = s.appendRelativeChildDiv(
584
+ s.applyStylePosistionAbsolute(
585
+ s.createAreaDivWithClass("ge-table-footer ge-table-footer-east", o, "footer", "east")
586
+ )
587
+ ), this.scrollViewport = s.applyStyleOverflowAuto(
588
+ this.tableOptions.overflowX ?? "auto",
589
+ this.tableOptions.overflowY ?? "auto",
590
+ s.applyStyleNoPadding(
591
+ s.applyStylePosistionAbsolute(
592
+ s.createAreaDivWithClass("ge-table-scroll-viewport", o, "body", "center")
593
+ )
594
+ )
595
+ ), this.contentWrapperDiv = s.applyStyleNoPadding(
596
+ s.applyStylePosistionRelative(
597
+ s.createDivWithClass("ge-table-scroll-content-wrapper", this.scrollViewport)
598
+ )
599
+ ), this.contentDiv = s.applyStyleNoPadding(
600
+ s.applyStylePosistionRelative(
601
+ s.createDivWithClass("ge-table-scroll-content", this.contentWrapperDiv)
602
+ )
603
+ ), this.areaBodyCenter = s.appendRelativeChildDiv(
604
+ s.createDivWithClass("ge-table-body-center", this.contentDiv)
605
+ ), this.borderHeaderBottom = s.applyStylePosistionAbsolute(
606
+ s.createDivWithClass("ge-table-header-border", o)
607
+ ), this.borderFixedWest = s.applyStylePosistionAbsolute(
608
+ s.createDivWithClass("ge-table-west-fixed-column-border", o)
609
+ ), this.borderFixedEast = s.applyStylePosistionAbsolute(
610
+ s.createDivWithClass("ge-table-east-fixed-column-border", o)
611
+ ), this.borderFooterTop = s.applyStylePosistionAbsolute(
612
+ s.createDivWithClass("ge-table-footer-border", o)
613
+ );
614
+ }
615
+ adjustContainersAndRows() {
616
+ const e = this.tableModel.getPadding(), t = this.hostElement.clientWidth, s = this.hostElement.clientHeight;
617
+ this.dom.applyStyle(this.scrollViewport, {
618
+ width: `${t - e.left}px`,
619
+ height: `${s - e.top}px`,
620
+ top: `${e.top}px`,
621
+ left: `${e.left}px`
622
+ }), this.scrollTop = this.scrollViewport.scrollTop, this.dom.applyStyle(this.contentDiv, {
623
+ width: `${this.scrollViewport.clientWidth}px`,
624
+ height: `${this.scrollViewport.clientHeight}px`,
625
+ top: `${this.scrollTop}px`,
626
+ left: `${this.scrollViewport.scrollLeft}px`
627
+ }), this.areaBodyWestGeo.width = e.left, this.areaBodyWestGeo.height = s - e.top - e.bottom, this.areaBodyWestGeo.top = e.top, this.areaBodyWestGeo.left = 0, this.dom.applyStyleInPx(this.areaBodyWest.parent, this.areaBodyWestGeo), this.tableOptions.fixedWestSeparatorBorderVisible && this.tableModel.getFixedLeftColumnCount() ? this.dom.applyDisplayBlockStyle(
628
+ this.dom.applyStyle(this.borderFixedWest, {
629
+ width: "1px",
630
+ height: `${this.areaBodyWestGeo.height}px`,
631
+ top: `${this.areaBodyWestGeo.top}px`,
632
+ left: `${this.areaBodyWestGeo.width}px`
633
+ })
634
+ ) : this.dom.applyDisplayNoneStyle(this.borderFixedWest), this.areaBodyEastGeo.width = e.right, this.areaBodyEastGeo.height = s - e.top - e.bottom, this.areaBodyEastGeo.top = e.top, this.areaBodyEastGeo.left = t - e.right, this.dom.applyStyleInPx(this.areaBodyEast.parent, this.areaBodyEastGeo), this.tableOptions.fixedEastSeparatorBorderVisible && this.tableModel.getFixedLeftColumnCount() ? this.dom.applyDisplayBlockStyle(
635
+ this.dom.applyStyle(this.borderFixedEast, {
636
+ width: "1px",
637
+ height: `${this.areaBodyEastGeo.height}px`,
638
+ top: `${this.areaBodyEastGeo.top}px`,
639
+ left: `${this.areaBodyEastGeo.left}px`
640
+ })
641
+ ) : this.dom.applyDisplayNoneStyle(this.borderFixedEast), this.areaBodyCenterGeo.width = t - e.left - e.right, this.areaBodyCenterGeo.height = s - e.top - e.bottom, this.areaBodyCenterGeo.top = 0, this.areaBodyCenterGeo.left = 0, this.dom.applyStyleInPx(this.areaBodyCenter.parent, this.areaBodyCenterGeo), this.dom.applyStyle(this.areaHeaderCenter.parent, {
642
+ width: `${t - e.left - e.right}px`,
643
+ height: `${e.top}px`,
644
+ top: "0",
645
+ left: `${e.left}px`
646
+ }), this.dom.applyStyle(this.areaHeaderWest.parent, {
647
+ width: `${e.left}px`,
648
+ height: `${e.top}px`,
649
+ top: "0",
650
+ left: "0"
651
+ }), this.dom.applyStyle(this.areaHeaderEast.parent, {
652
+ width: `${e.right}px`,
653
+ height: `${e.top}px`,
654
+ top: "0",
655
+ left: `${t - e.right}px`
656
+ }), this.tableOptions.headerSeparatorBorderVisible && this.tableModel.isHeaderVisibe() ? this.dom.applyDisplayBlockStyle(
657
+ this.dom.applyStyle(this.borderHeaderBottom, {
658
+ width: `${t}px`,
659
+ height: "1px",
660
+ top: `${e.top}px`,
661
+ left: "0px"
662
+ })
663
+ ) : this.dom.applyDisplayNoneStyle(this.borderHeaderBottom), this.dom.applyStyle(this.areaFooterWest.parent, {
664
+ width: `${e.left}px`,
665
+ height: `${e.bottom}px`,
666
+ top: `${s - e.bottom}px`,
667
+ left: "0"
668
+ }), this.dom.applyStyle(this.areaFooterCenter.parent, {
669
+ width: `${t - e.left - e.right}px`,
670
+ height: `${e.bottom}px`,
671
+ top: `${s - e.bottom}px`,
672
+ left: `${e.left}px`
673
+ }), this.dom.applyStyle(this.areaFooterEast.parent, {
674
+ width: `${e.right}px`,
675
+ height: `${e.bottom}px`,
676
+ top: `${s - e.bottom}px`,
677
+ left: `${t - e.right}px`
678
+ }), this.tableOptions.footerSeparatorBorderVisible && this.tableModel.isFooterVisibe() ? this.dom.applyDisplayBlockStyle(
679
+ this.dom.applyStyle(this.borderFooterTop, {
680
+ width: `${t}px`,
681
+ height: "1px",
682
+ top: `${s - e.bottom}px`,
683
+ left: "0px"
684
+ })
685
+ ) : this.dom.applyDisplayNoneStyle(this.borderFooterTop), this.adjustAfterScrolling();
686
+ }
687
+ adjustAfterScrolling() {
688
+ }
689
+ resetSizeOfWrapperDiv() {
690
+ const e = `${this.tableModel.getContentWidthInPixel()}px`, t = `${this.tableModel.getContentHeightInPixel() + 1}px`;
691
+ this.dom.setStyle(this.contentWrapperDiv, "width", e), this.dom.setStyle(this.contentWrapperDiv, "height", t);
692
+ }
693
+ }
694
+ class A {
695
+ constructor(e, t, s, i, o = !1) {
696
+ this.r1 = e, this.c1 = t, this.r2 = s, this.c2 = i, this.gammaRange = o;
697
+ }
698
+ static create(e) {
699
+ return e.gammaRange === void 0 && (e.gammaRange = !1), new A(
700
+ e.rowIndex1,
701
+ e.columnIndex1,
702
+ e.rowIndex2,
703
+ e.columnIndex2,
704
+ e.gammaRange
705
+ );
706
+ }
707
+ static singleCell(e, t) {
708
+ return new A(e, t, e, t);
709
+ }
710
+ static singleRow(e) {
711
+ return new A(e, 0, e, Number.MAX_SAFE_INTEGER);
712
+ }
713
+ static singleColumn(e) {
714
+ return new A(0, e, Number.MAX_SAFE_INTEGER, e);
715
+ }
716
+ isInRange(e, t) {
717
+ return e >= this.r1 && e <= this.r2 && t >= this.c1 && t <= this.c2;
718
+ }
719
+ }
720
+ class ne {
721
+ constructor(e, t) {
722
+ this.tableModel = e, this.areaModel = t, this.colAndRowspanRanges = void 0;
723
+ }
724
+ init() {
725
+ if (this.areaModel.getMaxColspan() < 2 && this.areaModel.getMaxRowspan() < 2)
726
+ return;
727
+ this.colAndRowspanRanges = [];
728
+ const e = this.areaModel.getRowCount(), t = this.tableModel.getColumnCount();
729
+ for (let s = 0; s < e; s++)
730
+ for (let i = 0; i < t; i++) {
731
+ let o = this.areaModel.getColspanAt(s, i), r = this.areaModel.getRowspanAt(s, i);
732
+ if (o > 1 || r > 1) {
733
+ o === 0 && (o = 1), r === 0 && (r = 1);
734
+ const n = this.areaModel.hasOwnProperty("gammaCells");
735
+ this.colAndRowspanRanges.push(
736
+ new A(s, i, s + r - 1, i + o - 1, n)
737
+ );
738
+ }
739
+ }
740
+ }
741
+ getRanges() {
742
+ return this.colAndRowspanRanges ? this.colAndRowspanRanges : [];
743
+ }
744
+ isInRange(e, t) {
745
+ if (this.colAndRowspanRanges) {
746
+ for (const s of this.colAndRowspanRanges)
747
+ if (s.isInRange(e, t))
748
+ return !0;
749
+ }
750
+ return !1;
751
+ }
752
+ }
753
+ class ae {
754
+ constructor(e, t, s) {
755
+ this.header = e, this.body = t, this.footer = s;
756
+ }
757
+ }
758
+ class de extends re {
759
+ constructor(e, t, s, i) {
760
+ var r, n;
761
+ super(e, t, s, i), this.scrollLeft = 0, this.scrollViewportLeft = 0, this.scrollFactorY = 0, this.scrollFactorX = 0, this.cleanupFunctions = {
762
+ header: [],
763
+ body: [],
764
+ footer: []
765
+ }, this.tree = !1, this.colAndRowspanModels = new ae(), this.firstVisibleRowIndex = -1, this.draggingTargetColumnIndex = -1, this.removables = [], this.editing = !1, this.tableModel.getSelectionModel ? this.getSelectionModel = this.tableModel.getSelectionModel : (r = this.tableOptions) != null && r.getSelectionModel && (this.getSelectionModel = this.tableOptions.getSelectionModel), (n = this.tableOptions) != null && n.getFocusModel && (this.getFocusModel = this.tableOptions.getFocusModel), $(t.getAreaModel("body")) && (this.tree = !0), ["header", "body", "footer"].forEach(
766
+ (l) => {
767
+ var a;
768
+ this.colAndRowspanModels[l] = new ne(t, t.getAreaModel(l)), (a = this.colAndRowspanModels[l]) == null || a.init();
769
+ }
770
+ );
771
+ }
772
+ isEditing() {
773
+ return this.editing;
774
+ }
775
+ resetEditorRenderer() {
776
+ this.editorRenderer = void 0, this.editorRendererRow = -1, this.editorRendererColumn = -1, this.editing = !1;
777
+ }
778
+ clearSelection() {
779
+ if (this.getSelectionModel) {
780
+ const e = this.getSelectionModel();
781
+ e == null || e.clear();
782
+ }
783
+ }
784
+ initRenderEditor(e, t) {
785
+ var i;
786
+ let s = (i = this.tableModel.getColumnDef(t)) == null ? void 0 : i.getEditRenderer;
787
+ if (s || (s = this.tableOptions.getEditRenderer), s)
788
+ if (this.editorRenderer = s(e, t), this.editorRenderer) {
789
+ this.editorRendererRow = e, this.editorRendererColumn = t, this.editing = !0, this.repaint();
790
+ const o = document.querySelector("input.ge-table-cell-editor-input");
791
+ o && o.focus();
792
+ } else
793
+ this.resetEditorRenderer();
794
+ }
795
+ repaint() {
796
+ this.adjustAfterScrolling();
797
+ }
798
+ adjustAfterScrolling() {
799
+ var e;
800
+ for (const t of this.removables)
801
+ t.remove();
802
+ this.hideHoverRow(), this.hideHoverColumn(), this.scrollTop = this.scrollViewport.scrollTop, this.scrollLeft = this.scrollViewport.scrollLeft, this.debounce(this.checkForScrollPosSaving.bind(this)), this.scrollFactorY = this.scrollTop / (this.scrollViewport.scrollHeight - this.scrollViewport.clientHeight), this.scrollFactorX = this.scrollLeft / (this.scrollViewport.scrollWidth - this.scrollViewport.clientWidth), isNaN(this.scrollFactorY) && (this.scrollFactorY = 0), isNaN(this.scrollFactorX) && (this.scrollFactorX = 0), this.adjustBody(), this.adjustArea("footer"), this.adjustArea("header"), this.tableOptions.tableTopBorderVisible && this.removables.push(this.dom.addHorizontalBorder(
803
+ new T(0, this.hostElement.clientWidth, 1, 0),
804
+ this.hostElement,
805
+ "ge-table-border"
806
+ )), this.tableOptions.tableBottomBorderVisible && this.removables.push(this.dom.addHorizontalBorder(
807
+ new T(0, this.hostElement.clientWidth, 1, this.hostElement.clientHeight - 1),
808
+ this.hostElement,
809
+ "ge-table-border"
810
+ )), this.tableModel.getFixedLeftColumnCount() > 0 && this.removables.push(this.dom.addVerticalBorder(
811
+ new T(this.areaBodyWest.child.clientWidth, 1, this.hostElement.clientHeight, 0),
812
+ this.hostElement,
813
+ "ge-table-body-west-vertical-border"
814
+ )), ((e = this.tableModel.getAreaModel("header")) == null ? void 0 : e.getRowCount()) > 0 && this.removables.push(this.dom.addHorizontalBorder(
815
+ new T(0, this.hostElement.clientWidth, 1, this.areaHeaderCenter.child.clientHeight),
816
+ this.hostElement,
817
+ "ge-table-body-west-vertical-border"
818
+ ));
819
+ }
820
+ checkForScrollPosSaving() {
821
+ var e, t;
822
+ this.storeScrollPosStateService && ((t = (e = this.tableOptions) == null ? void 0 : e.autoRestoreOptions) != null && t.autoRestoreScrollPosition) && this.storeScrollPosStateService.updateScrollOffset([this.scrollLeft, this.scrollTop]);
823
+ }
824
+ updateCells(e, t = !1) {
825
+ e.forEach(
826
+ (s) => {
827
+ this.tableModel.getAreaModel(s.area).setValue(s.rowIndex, s.columnIndex, s.value), t || this.rerenderCellContent(s);
828
+ }
829
+ ), t && this.repaint();
830
+ }
831
+ getAreaAndSideIdentByAttr(e) {
832
+ if (e) {
833
+ const t = this.getStringByAttr(e, "data-area"), s = this.getStringByAttr(e, "data-side");
834
+ if (s && t)
835
+ return [t, s];
836
+ }
837
+ return [void 0, void 0];
838
+ }
839
+ getArea(e, t) {
840
+ if (e === "header") {
841
+ if (t === "west")
842
+ return this.areaHeaderWest;
843
+ if (t === "center")
844
+ return this.areaHeaderCenter;
845
+ if (t === "east")
846
+ return this.areaHeaderEast;
847
+ } else if (e === "body") {
848
+ if (t === "west")
849
+ return this.areaBodyWest;
850
+ if (t === "center")
851
+ return this.areaBodyCenter;
852
+ if (t === "east")
853
+ return this.areaBodyEast;
854
+ } else if (e === "footer") {
855
+ if (t === "west")
856
+ return this.areaFooterWest;
857
+ if (t === "center")
858
+ return this.areaFooterCenter;
859
+ if (t === "east")
860
+ return this.areaFooterEast;
861
+ }
862
+ throw Error(`Wrong area identifier: row:${e}, col:${t}`);
863
+ }
864
+ adjustBody() {
865
+ const e = this.areaBodyCenterGeo.height - this.tableModel.getContentHeightInPixel(), t = this.scrollFactorY * e;
866
+ this.dom.setStyle(this.contentDiv, "top", `${this.scrollTop}px`), this.dom.setStyle(this.contentDiv, "left", `${this.scrollViewport.scrollLeft}px`), this.adjustArea("body", t);
867
+ }
868
+ getNumberByAttr(e, t) {
869
+ var s;
870
+ if (e) {
871
+ const i = (s = e.closest("[" + t + "]")) == null ? void 0 : s.getAttribute(t);
872
+ if (i)
873
+ return Number(i);
874
+ }
875
+ return -1;
876
+ }
877
+ getStringByAttr(e, t) {
878
+ var s;
879
+ if (e) {
880
+ const i = (s = e.closest("[" + t + "]")) == null ? void 0 : s.getAttribute(t);
881
+ if (i)
882
+ return i;
883
+ }
884
+ return "";
885
+ }
886
+ adjustArea(e, t = 0) {
887
+ var h;
888
+ const s = this.getArea(e, "west"), i = this.getArea(e, "center"), o = this.getArea(e, "east"), r = i.child.clientHeight;
889
+ s.child.innerText = "", i.child.innerText = "", o.child.innerText = "";
890
+ const n = 0, l = this.areaBodyCenterGeo.width, a = this.tableModel.getPadding(), d = this.tableModel.getAreaModel(e), u = d.getRowCount();
891
+ for (; this.cleanupFunctions[e].length; ) {
892
+ const S = this.cleanupFunctions[e].shift();
893
+ S && S();
894
+ }
895
+ let g = t;
896
+ const m = this.tableModel.getColumnCount(), c = this.tableModel.getFixedRightColumnCount(), b = this.tableModel.getFixedLeftColumnCount();
897
+ for (let S = 0; S < u; S++) {
898
+ const C = g, x = S === u - 1, w = this.tableModel.getRowHeight(e, S);
899
+ if (C + w > 0) {
900
+ this.firstVisibleRowIndex = S;
901
+ let v = { left: n, width: l, height: w, top: C, index: S }, f = this.dom.addRowDiv(i, v, S, e, "center");
902
+ const M = b;
903
+ if (this.adjustColumnsToRowParent({
904
+ areaIdent: e,
905
+ sideIdent: "center",
906
+ areaModel: d,
907
+ geo: v,
908
+ parent: f,
909
+ rowIndex: S,
910
+ columnIndexStart: M,
911
+ columnIndexEnd: m - c - 1,
912
+ verticalFixed: !1,
913
+ lastRowOfModel: x
914
+ }), a.left > 0 && (v = { left: n, width: this.areaBodyWestGeo.width, height: w, top: C, index: S }, f = this.dom.addRowDiv(s, v, S, e, "west"), this.adjustColumnsToRowParent({
915
+ areaIdent: e,
916
+ sideIdent: "west",
917
+ areaModel: d,
918
+ geo: v,
919
+ parent: f,
920
+ rowIndex: S,
921
+ columnIndexStart: 0,
922
+ columnIndexEnd: M - 1,
923
+ verticalFixed: !0,
924
+ lastRowOfModel: x
925
+ })), a.right > 0 && (v = { left: n, width: this.areaBodyEastGeo.width, height: w, top: C, index: S }, f = this.dom.addRowDiv(o, v, S, e, "east"), this.adjustColumnsToRowParent({
926
+ areaIdent: e,
927
+ sideIdent: "east",
928
+ areaModel: d,
929
+ geo: v,
930
+ parent: f,
931
+ rowIndex: S,
932
+ columnIndexStart: m - c,
933
+ columnIndexEnd: m - 1,
934
+ verticalFixed: !0,
935
+ lastRowOfModel: x
936
+ })), e === "header" && this.tree && S === u - 1) {
937
+ const E = this.dom.applyStyle(
938
+ this.dom.setAttribute(
939
+ this.dom.addDiv(f, new T(16, 20, 20, 8)),
940
+ "data-ge-action",
941
+ "toggleExpandCollapseAll"
942
+ ),
943
+ { cursor: "pointer" }
944
+ ), R = this.tableOptions.treeOptions.arrowExpandCollapseAll;
945
+ if (R) {
946
+ const I = this.dom.domService.createText(R.content);
947
+ this.dom.domService.appendChild(E, I), R.style && this.dom.applyStyleString(E, R.style);
948
+ }
949
+ }
950
+ }
951
+ if (g = g + w, g > r)
952
+ break;
953
+ }
954
+ if (this.colAndRowspanModels && this.colAndRowspanModels[e]) {
955
+ const S = ((h = this.colAndRowspanModels[e]) == null ? void 0 : h.getRanges()) ?? [];
956
+ if (S.length)
957
+ for (const C of S) {
958
+ let x = 0, w = i.child, v = "center";
959
+ if (C.c1 < b)
960
+ w = s.child, v = "west";
961
+ else if (c > 0 && C.c1 >= m - c)
962
+ w = o.child, v = "east";
963
+ else {
964
+ const f = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
965
+ x = this.scrollFactorX * f - this.areaBodyWestGeo.width, v = "center";
966
+ }
967
+ this.drawBigCell(C, x, t, d, w, v);
968
+ }
969
+ }
970
+ }
971
+ /**
972
+ * Draws big cells (rowspan and or colspan) in body/center
973
+ * @param range CellRange
974
+ * @param xStart X position in pixel for top left corner
975
+ * @param yStart Y position in pixel for top left corner
976
+ * @param areaModel AreaModelIf
977
+ * @param parentDiv Parent div as HTMLDivElement
978
+ * @param sideIdent SideIdent (west,center,east)
979
+ * @protected
980
+ */
981
+ drawBigCell(e, t, s, i, o, r) {
982
+ const n = s + this.getRowHeights(0, e.r1 - 1, i).reduce((h, S) => h + S, 0), l = this.tableModel.getColumnCount(), a = this.tableModel.getFixedRightColumnCount();
983
+ let d = 0;
984
+ a > 0 && e.c1 >= l - a && (d = l - a);
985
+ const u = t + this.getColumnWidths(d, e.c1 - 1).reduce((h, S) => h + S, 0), g = this.getRowHeights(e.r1, e.r2, i).reduce((h, S) => h + S, 0), m = this.getColumnWidths(e.c1, e.c2).reduce((h, S) => h + S, 0);
986
+ let c = !1;
987
+ const b = this.getSelectionModel ? this.getSelectionModel() : void 0;
988
+ b && (c = b.getSelectionCount(e.r1, e.c1) > 0), e.gammaRange ? (console.info("TODO here", e), this.renderCell({
989
+ areaModel: i,
990
+ areaIdent: i.areaIdent,
991
+ sideIdent: r,
992
+ rowIndex: e.r1,
993
+ columnIndex: e.c1,
994
+ left: u,
995
+ top: n,
996
+ width: m,
997
+ height: g,
998
+ parent: o,
999
+ cellSelected: c,
1000
+ lastRowOfModel: !0,
1001
+ gammaRange: e.gammaRange
1002
+ })) : this.renderCell({
1003
+ areaModel: i,
1004
+ areaIdent: i.areaIdent,
1005
+ sideIdent: r,
1006
+ rowIndex: e.r1,
1007
+ columnIndex: e.c1,
1008
+ left: u,
1009
+ top: n,
1010
+ width: m,
1011
+ height: g,
1012
+ parent: o,
1013
+ cellSelected: c,
1014
+ lastRowOfModel: !0,
1015
+ gammaRange: e.gammaRange
1016
+ }), i.areaIdent === "header" && this.tableOptions.columnsResizable && this.renderHeaderCellResizeHandle({
1017
+ rowIndex: e.r1,
1018
+ columnIndex: e.c1,
1019
+ cellLeft: u,
1020
+ cellTop: n,
1021
+ cellWidth: m,
1022
+ cellHeight: g,
1023
+ parent: o
1024
+ });
1025
+ }
1026
+ findRowOfImportantRowspanCell(e, t, s) {
1027
+ const i = e.getMaxRowspan();
1028
+ for (let o = t - 1; o > -1; o--) {
1029
+ const r = e.getRowspanAt(o, s);
1030
+ if (r > 1 && o + r + 1 >= t)
1031
+ return o;
1032
+ if (t - o > i)
1033
+ return -1;
1034
+ }
1035
+ return -1;
1036
+ }
1037
+ adjustColumnsToRowParent({
1038
+ areaIdent: e,
1039
+ sideIdent: t,
1040
+ areaModel: s,
1041
+ geo: i,
1042
+ parent: o,
1043
+ rowIndex: r,
1044
+ columnIndexStart: n,
1045
+ columnIndexEnd: l,
1046
+ verticalFixed: a = !1,
1047
+ lastRowOfModel: d = !1
1048
+ }) {
1049
+ var b;
1050
+ this.scrollViewportLeft = this.scrollViewport.scrollLeft;
1051
+ let u = 0;
1052
+ if (!a) {
1053
+ const h = this.areaBodyCenterGeo.width - this.tableModel.getContentWidthInPixel();
1054
+ u = this.scrollFactorX * h;
1055
+ }
1056
+ const g = 0, m = !!(e === "body" && t);
1057
+ let c = u;
1058
+ for (let h = n; h <= l; h++) {
1059
+ const S = c, C = this.tableModel.getColumnWidth(h);
1060
+ if (C > 0 && S + C > 0) {
1061
+ let x = i.height;
1062
+ const w = s.getRowspanAt(r, h), v = s.getColspanAt(r, h);
1063
+ w > 1 && (x = this.getRowHeights(r, r + w - 1, s).reduce((E, R) => E + R, 0));
1064
+ let f = C;
1065
+ v > 1 && (f = this.getColumnWidths(h, h + v - 1).reduce((E, R) => E + R, 0));
1066
+ let M = !1;
1067
+ if (this.colAndRowspanModels && this.colAndRowspanModels[e] && (b = this.colAndRowspanModels[e]) != null && b.isInRange(r, h) && (M = !0), this.draggingTargetColumnIndex === h && e !== "header") {
1068
+ this.renderDragTargetDiv(o, S, g, f, x);
1069
+ const E = { left: S, top: g, width: f, height: x };
1070
+ this.dom.addColumnBorderDivs(this.tableOptions, o, E, e, t);
1071
+ } else {
1072
+ const E = this.renderSelectedBackgroundDiv(M, m, t, s, r, h, o, S, g, f, x);
1073
+ M || this.renderCell({
1074
+ areaModel: s,
1075
+ areaIdent: e,
1076
+ sideIdent: t,
1077
+ rowIndex: r,
1078
+ columnIndex: h,
1079
+ left: S,
1080
+ top: g,
1081
+ width: f,
1082
+ height: x,
1083
+ parent: o,
1084
+ cellSelected: E,
1085
+ lastRowOfModel: d,
1086
+ gammaRange: !0
1087
+ }), e === "header" && this.tableOptions.columnsResizable && this.renderHeaderCellResizeHandle({
1088
+ rowIndex: r,
1089
+ columnIndex: h,
1090
+ cellLeft: S,
1091
+ cellTop: g,
1092
+ cellWidth: f,
1093
+ cellHeight: x,
1094
+ parent: o
1095
+ });
1096
+ }
1097
+ }
1098
+ if (c = c + C, c > this.areaBodyCenterGeo.width)
1099
+ break;
1100
+ }
1101
+ this.tableOptions.verticalBorderVisible && this.dom.addVerticalBorder(new T(c - 1, 1, i.height, 0), o);
1102
+ }
1103
+ getTreeArrowColumnIndex() {
1104
+ return this.tableOptions.showCheckboxWihoutExtraColumn ? 0 : this.tableModel.isRowCheckboxVisible() ? 1 : 0;
1105
+ }
1106
+ addAndRenderCellDiv({
1107
+ areaModel: e,
1108
+ areaIdent: t,
1109
+ sideIdent: s,
1110
+ rowIndex: i,
1111
+ index: o,
1112
+ left: r,
1113
+ width: n,
1114
+ height: l,
1115
+ top: a,
1116
+ parent: d,
1117
+ lastRowOfModel: u
1118
+ }) {
1119
+ var G;
1120
+ const m = this.editorRenderer && this.editorRendererRow === i && this.editorRendererColumn === o ? this.editorRenderer : e.getCellRenderer(i, o), c = { left: r, width: n, height: l, top: a, index: o }, b = e.getRowByIndex(i);
1121
+ let h = "none";
1122
+ if (o === this.getTreeArrowColumnIndex() && O(b)) {
1123
+ const y = b;
1124
+ (G = y.children) != null && G.length ? y.expanded ? h = "expanded" : h = "collapsed" : h = "hidden";
1125
+ }
1126
+ let C;
1127
+ if (t === "header") {
1128
+ const y = this.tableModel.getColumnDef(o);
1129
+ (!(y != null && y.sortIconVisible) || y != null && y.sortIconVisible()) && (C = y == null ? void 0 : y.sortState);
1130
+ }
1131
+ const x = e.getValueAt(i, o), w = m ? "" : `${x}`, v = e.isRowChecked(i), f = this.dom.addColumnDiv(
1132
+ d,
1133
+ c,
1134
+ i,
1135
+ o,
1136
+ t,
1137
+ s,
1138
+ w,
1139
+ h,
1140
+ this.tableOptions,
1141
+ v,
1142
+ C
1143
+ ), M = e.getTooltipAt(i, o);
1144
+ M && this.dom.setAttribute(f, "title", M);
1145
+ const E = this.tableModel.getColumnDef(o);
1146
+ E && E.classes[t] && this.dom.addClasses(E.classes[t], f);
1147
+ let R;
1148
+ m && (R = m.render(f, i, o, t, e, x, this.dom.domService));
1149
+ const I = e.getCustomClassesAt(i, o);
1150
+ if (I.length && this.dom.addClasses(I, f), this.dom.addColumnBorderDivs(this.tableOptions, d, c, t, s), u && this.dom.addHorizontalBorder({ left: r, width: n, height: l, top: a + l }, d), this.getFocusModel && t === "body") {
1151
+ const y = this.getFocusModel();
1152
+ y != null && y.hasFocus(i, o) && this.dom.addFocusBorderDivs(d, c, {});
1153
+ }
1154
+ t === "header" && this.dom.setAttribute(f, "data-ge-action", "drag-column");
1155
+ const L = e.getCustomStyleAt(i, o);
1156
+ if (L)
1157
+ for (const y in L)
1158
+ this.dom.setStyle(f, y, L[y]);
1159
+ return [f, R];
1160
+ }
1161
+ applyCssClasses(e, t = {}) {
1162
+ e && Object.entries(t).forEach(([s, i]) => {
1163
+ i ? this.dom.addClass(s, e) : this.dom.removeClass(s, e);
1164
+ });
1165
+ }
1166
+ rerenderCellContent({ area: e, rowIndex: t, columnIndex: s, value: i, cssClasses: o }) {
1167
+ const r = this.tableModel.getAreaModel(e), n = 'div[data-col-index="' + s + '"][data-row-index="' + t + '"][data-area="' + e + '"]', l = document.querySelector(n);
1168
+ if (l) {
1169
+ let a;
1170
+ const u = this.editorRenderer && this.editorRendererRow === t && this.editorRendererColumn === s ? this.editorRenderer : r.getCellRenderer(t, s);
1171
+ if (l.innerText = "", this.applyCssClasses(l, o), u)
1172
+ a = u.render(l, t, s, e, r, i, this.dom.domService), a && this.cleanupFunctions[e].push(a);
1173
+ else {
1174
+ const c = `${i}`;
1175
+ this.dom.addLabelDiv(l, c, !1, t, s, e);
1176
+ }
1177
+ const g = r.getCustomClassesAt(t, s);
1178
+ g.length && this.dom.addClasses(g, l);
1179
+ const m = r.getCustomStyleAt(t, s);
1180
+ if (m)
1181
+ for (const c in m)
1182
+ this.dom.setStyle(l, c, m[c]);
1183
+ }
1184
+ }
1185
+ getColumnWidths(e, t) {
1186
+ const s = [];
1187
+ for (let i = e; i <= t; i++)
1188
+ s.push(this.tableModel.getColumnWidth(i));
1189
+ return s;
1190
+ }
1191
+ getRowHeights(e, t, s) {
1192
+ const i = [];
1193
+ for (let o = e; o <= t; o++)
1194
+ i.push(s.getRowHeight(o));
1195
+ return i;
1196
+ }
1197
+ adjustHoverRows(e) {
1198
+ if (this.tableOptions.hoverRowVisible && e.rowIndex > -1) {
1199
+ const t = this.hostElement.clientWidth, s = this.tableModel.getAreaModel("body").getRowHeight(e.rowIndex), i = e.rowTop + this.areaHeaderCenter.parent.clientHeight - this.scrollTop;
1200
+ this.dom.applyStyle(this.hoverRow, {
1201
+ left: "0",
1202
+ top: i + "px",
1203
+ width: t + "px",
1204
+ height: s + "px",
1205
+ display: "block"
1206
+ });
1207
+ } else
1208
+ this.hideHoverRow();
1209
+ }
1210
+ hideHoverRow() {
1211
+ this.dom.applyStyle(this.hoverRow, {
1212
+ display: "none"
1213
+ });
1214
+ }
1215
+ adjustHoverColumns(e) {
1216
+ if (this.tableOptions.hoverColumnVisible && e.rowIndex > -1) {
1217
+ const t = this.hostElement.clientHeight, s = this.tableModel.getColumnWidth(e.columnIndex), i = this.areaBodyWestGeo.width, o = e.columnLeft + this.tableModel.getPadding().left - this.scrollLeft - i;
1218
+ this.dom.applyStyle(this.hoverColumn, {
1219
+ left: o + "px",
1220
+ top: "0px",
1221
+ width: s + "px",
1222
+ height: t + "px",
1223
+ display: "block"
1224
+ });
1225
+ } else
1226
+ this.hideHoverColumn();
1227
+ }
1228
+ hideHoverColumn() {
1229
+ this.dom.applyStyle(this.hoverColumn, {
1230
+ display: "none"
1231
+ });
1232
+ }
1233
+ debounce(e, t = 1e3) {
1234
+ this.debounceTimeout && clearTimeout(this.debounceTimeout), this.debounceTimeout = setTimeout(e.bind(this), t);
1235
+ }
1236
+ renderDragTargetDiv(e, t, s, i, o) {
1237
+ const r = this.dom.applyStylePosistionAbsolute(
1238
+ this.dom.createDivWithClass("ge-table-drop-zone", e)
1239
+ );
1240
+ return this.dom.setStyle(r, "left", `${t}px`), this.dom.setStyle(r, "top", `${s}px`), this.dom.setStyle(r, "width", `${i}px`), this.dom.setStyle(r, "height", `${o}px`), r;
1241
+ }
1242
+ renderSelectedBackgroundDiv(e, t, s, i, o, r, n, l, a, d, u) {
1243
+ let g = !1;
1244
+ if (!e && t && i.isSelectable(o, r) && this.getSelectionModel) {
1245
+ const m = this.getSelectionModel();
1246
+ if (m) {
1247
+ const c = m.getSelectionCount(o, r);
1248
+ g = c > 0;
1249
+ for (let b = 0; b < c; b++) {
1250
+ const h = this.dom.applyStylePosistionAbsolute(
1251
+ // ge-table-body-west-selected-range
1252
+ this.dom.createDivWithClass(`ge-table-${i.areaIdent}-${s}-selected-range`, n)
1253
+ );
1254
+ this.dom.setStyle(h, "left", `${l}px`), this.dom.setStyle(h, "top", `${a}px`), this.dom.setStyle(h, "width", `${d}px`), this.dom.setStyle(h, "height", `${u}px`);
1255
+ }
1256
+ }
1257
+ }
1258
+ return g;
1259
+ }
1260
+ renderCell({
1261
+ areaModel: e,
1262
+ areaIdent: t,
1263
+ sideIdent: s,
1264
+ rowIndex: i,
1265
+ columnIndex: o,
1266
+ left: r,
1267
+ top: n,
1268
+ width: l,
1269
+ height: a,
1270
+ parent: d,
1271
+ cellSelected: u,
1272
+ lastRowOfModel: g,
1273
+ gammaRange: m
1274
+ }) {
1275
+ const [c, b] = this.addAndRenderCellDiv({
1276
+ areaModel: e,
1277
+ areaIdent: t,
1278
+ sideIdent: s,
1279
+ rowIndex: i,
1280
+ index: o,
1281
+ left: r,
1282
+ width: l,
1283
+ height: a,
1284
+ top: n,
1285
+ parent: d,
1286
+ lastRowOfModel: g,
1287
+ gammaRange: m
1288
+ });
1289
+ u && this.dom.addClass(`ge-table-${t}-${s}-selected-range`, c), b && this.cleanupFunctions[t].push(b);
1290
+ }
1291
+ renderHeaderCellResizeHandle({ rowIndex: e, columnIndex: t, cellLeft: s, cellTop: i, cellWidth: o, cellHeight: r, parent: n }) {
1292
+ const l = this.dom.domService, a = this.tableOptions.columnResizeHandleWidthInPx ?? 2, d = l.createElement("div");
1293
+ l.setAttribute(d, "data-col-index", `${t}`), l.setAttribute(d, "data-row-index", `${e}`), l.setAttribute(d, "data-area", "header"), l.setAttribute(d, "data-ge-action", "resize-column"), l.addClass(d, "ge-table-column-resize-handle"), l.setStyle(d, "display", "clip"), l.setStyle(d, "position", "absolute"), l.setStyle(d, "cursor", "col-resize"), l.setStyle(d, "left", `${s + o - a}px`), l.setStyle(d, "top", `${i}px`), l.setStyle(d, "width", `${a}px`), l.setStyle(d, "height", `${r}px`), l.appendChild(n, d);
1294
+ }
1295
+ }
1296
+ class he {
1297
+ constructor(e, t) {
1298
+ this.columnIndex = e, this.sortState = t;
1299
+ }
1300
+ }
1301
+ class ce {
1302
+ constructor(e) {
1303
+ this.tableScope = e, this.tableScope.hostElement.addEventListener("change", this.onHostElementChanged.bind(this));
1304
+ }
1305
+ onHostElementChanged(e) {
1306
+ if (e.target instanceof HTMLInputElement || e.target instanceof HTMLSelectElement || e.target instanceof HTMLTextAreaElement) {
1307
+ const t = e.target, s = t.getAttribute("data-area"), i = t.getAttribute("data-row-index"), o = t.getAttribute("data-col-index");
1308
+ if (s && i && o) {
1309
+ const r = H(s), n = Number(i), l = Number(o);
1310
+ this.tableScope.updateModelValueAfterEdit(r, n, l, t.value);
1311
+ }
1312
+ }
1313
+ }
1314
+ }
1315
+ class pe {
1316
+ constructor(e = -1, t = -1) {
1317
+ this.rowIndex = e, this.columnIndex = t;
1318
+ }
1319
+ }
1320
+ class V {
1321
+ constructor(e) {
1322
+ this.cells = e;
1323
+ }
1324
+ static createSingle(e, t) {
1325
+ return new V([new pe(e, t)]);
1326
+ }
1327
+ }
1328
+ class ue {
1329
+ constructor(e) {
1330
+ var t, s;
1331
+ this.tableScope = e, (t = this.tableScope.tableOptions) != null && t.getSelectionModel && (this.getSelectionModel = this.tableScope.tableOptions.getSelectionModel), (s = this.tableScope.tableOptions) != null && s.getFocusModel && (this.getFocusModel = this.tableScope.tableOptions.getFocusModel);
1332
+ }
1333
+ onMouseClicked(e, t) {
1334
+ var o, r, n, l, a, d, u;
1335
+ let s = !1, i = !1;
1336
+ if (this.getSelectionModel && this.getFocusModel) {
1337
+ const g = this.getSelectionModel(), m = this.getFocusModel();
1338
+ g && m && (m.hasFocus(e.rowIndex, e.columnIndex) || (m.setFocus(e.rowIndex, e.columnIndex), s = !0), (o = e.originalEvent) != null && o.shiftKey || g.hasSelection() && (g.clear(), s = !0), (r = e.originalEvent) != null && r.shiftKey && this.previousEvt ? (g.addSelection(this.createRangeByEvents(e, this.previousEvt)), i = !0, s = !0) : (n = e.originalEvent) != null && n.ctrlKey || (l = e.originalEvent) != null && l.metaKey ? (g.addSelection(A.singleCell(e.rowIndex, e.columnIndex)), i = !0, s = !0) : (a = e.originalEvent) != null && a.altKey && ((d = e.originalEvent) != null && d.ctrlKey || (u = e.originalEvent) != null && u.metaKey) && (g.removeSelection(A.singleCell(e.rowIndex, e.columnIndex)), i = !0, s = !0));
1339
+ }
1340
+ return i ? this.previousEvt = void 0 : this.previousEvt = e == null ? void 0 : e.clone(), s;
1341
+ }
1342
+ onActionTriggered(e) {
1343
+ if (this.getSelectionModel && this.getFocusModel) {
1344
+ const t = this.getSelectionModel(), s = this.getFocusModel();
1345
+ if (t && s) {
1346
+ if (e === "SELECT_ALL")
1347
+ return t.selectAll(), this.tableScope.repaint(), !0;
1348
+ if (e === "DESELECT_ALL")
1349
+ return t.clear(), this.tableScope.repaint(), !0;
1350
+ if (e === "TOGGLE_SELECTION") {
1351
+ const [i, o] = s.getFocus();
1352
+ return t.togglePoint(i, o), this.tableScope.repaint(), !0;
1353
+ }
1354
+ }
1355
+ }
1356
+ return !1;
1357
+ }
1358
+ createRangeByEvents(e, t) {
1359
+ t || (t = e);
1360
+ const s = Math.min(e.rowIndex, t == null ? void 0 : t.rowIndex), i = Math.max(e.rowIndex, t == null ? void 0 : t.rowIndex), o = Math.min(e.columnIndex, t == null ? void 0 : t.columnIndex), r = Math.max(e.columnIndex, t == null ? void 0 : t.columnIndex);
1361
+ return A.create({
1362
+ rowIndex1: s,
1363
+ columnIndex1: o,
1364
+ rowIndex2: i,
1365
+ columnIndex2: r
1366
+ });
1367
+ }
1368
+ }
1369
+ class Se {
1370
+ get() {
1371
+ return {
1372
+ f2: "START_EDITING",
1373
+ space: "TOGGLE_SELECTION",
1374
+ "ctrl+num_add": "SELECT_ALL",
1375
+ "ctrl+a": "SELECT_ALL",
1376
+ "ctrl+shift+a": "DESELECT_ALL",
1377
+ "ctrl+x": "DESELECT_ALL",
1378
+ "ctrl+num_subtract": "DESELECT_ALL",
1379
+ "cmd -": "DESELECT_ALL",
1380
+ arrowup: "NAVIGATE_UP",
1381
+ arrowdown: "NAVIGATE_DOWN",
1382
+ arrowleft: "NAVIGATE_LEFT",
1383
+ arrowright: "NAVIGATE_RIGHT"
1384
+ };
1385
+ }
1386
+ }
1387
+ class ge {
1388
+ get() {
1389
+ return {
1390
+ f2: "START_EDITING",
1391
+ space: "TOGGLE_SELECTION",
1392
+ "ctrl+num_add": "SELECT_ALL",
1393
+ "cmd+a": "SELECT_ALL",
1394
+ "ctrl+a": "SELECT_ALL",
1395
+ "cmd+x": "DESELECT_ALL",
1396
+ "cmd+shift+a": "DESELECT_ALL",
1397
+ "ctrl+shift+a": "DESELECT_ALL",
1398
+ "ctrl+num_subtract": "DESELECT_ALL",
1399
+ "ctrl -": "DESELECT_ALL",
1400
+ arrowup: "NAVIGATE_UP",
1401
+ arrowdown: "NAVIGATE_DOWN",
1402
+ arrowleft: "NAVIGATE_LEFT",
1403
+ arrowright: "NAVIGATE_RIGHT"
1404
+ };
1405
+ }
1406
+ }
1407
+ class me {
1408
+ constructor(e) {
1409
+ this.tableScope = e, this.shortcutActionIdMapping = {}, this.listener = [], this.listener.push(e), this.init();
1410
+ }
1411
+ addListener(e) {
1412
+ this.listener.includes(e) || this.listener.push(e);
1413
+ }
1414
+ init() {
1415
+ this.isMacintosh() ? Object.assign(this.shortcutActionIdMapping, new ge().get()) : Object.assign(this.shortcutActionIdMapping, new Se().get()), Object.assign(this.shortcutActionIdMapping, this.tableScope.tableOptions.shortcutActionIdMapping), this.isDebug() && console.debug("ShortcutService", this.shortcutActionIdMapping), this.tableScope.hostElement.addEventListener("keydown", this.onKeyDown.bind(this));
1416
+ }
1417
+ isMacintosh() {
1418
+ return navigator.platform.indexOf("Mac") > -1;
1419
+ }
1420
+ isDebug() {
1421
+ return this.isLocalhost();
1422
+ }
1423
+ isLocalhost() {
1424
+ return location.hostname === "localhost" || location.hostname === "127.0.0.1";
1425
+ }
1426
+ onKeyDown(e) {
1427
+ const t = this.findEnty(e);
1428
+ t && this.emit(t) && (e.preventDefault(), e.stopPropagation());
1429
+ }
1430
+ emit(e) {
1431
+ this.isDebug() && console.debug("ShortcutService emit:", e);
1432
+ let t = !1;
1433
+ for (const s of this.listener)
1434
+ s.onActionTriggered(e) && (t = !0);
1435
+ return t;
1436
+ }
1437
+ findEnty(e) {
1438
+ const t = this.getTokenByEvent(e);
1439
+ this.isDebug() && console.debug("ShortcutService tokens:", t);
1440
+ for (const s in this.shortcutActionIdMapping) {
1441
+ const i = s.replace(/opt/g, "alt").replace(/cmd/g, "meta").split(/[\+ ]/g).sort();
1442
+ if (this.areTokensEquals(t, i))
1443
+ return this.shortcutActionIdMapping[s];
1444
+ }
1445
+ }
1446
+ areTokensEquals(e, t) {
1447
+ if (e.length !== t.length || e.length === 0)
1448
+ return !1;
1449
+ for (let s = 0; s < e.length; s++)
1450
+ if (e[s] !== t[s])
1451
+ return !1;
1452
+ return !0;
1453
+ }
1454
+ getTokenByEvent(e) {
1455
+ const t = [];
1456
+ return e.altKey && t.push("alt"), e.shiftKey && t.push("shift"), e.ctrlKey && t.push("ctrl"), e.metaKey && t.push("meta"), e.code && t.push(e.code.toLowerCase().replace(/key/g, "")), t.sort();
1457
+ }
1458
+ }
1459
+ class k {
1460
+ onCheckboxChanged(e) {
1461
+ }
1462
+ onContextmenu(e) {
1463
+ }
1464
+ onModelChanged(e) {
1465
+ }
1466
+ onMouseClicked(e) {
1467
+ }
1468
+ onMouseDragging(e) {
1469
+ }
1470
+ onMouseDraggingEnd(e) {
1471
+ }
1472
+ onMouseMoved(e) {
1473
+ }
1474
+ }
1475
+ class z {
1476
+ setStyle(e, t, s) {
1477
+ return e.style[t] = s, e;
1478
+ }
1479
+ appendText(e, t) {
1480
+ const s = this.createText(t);
1481
+ return this.appendChild(e, s), s;
1482
+ }
1483
+ addClass(e, t) {
1484
+ return t.includes(" ") ? t.split(" ").forEach((s) => e.classList.add(s)) : e.classList.add(t), e;
1485
+ }
1486
+ removeClass(e, t) {
1487
+ return t.includes(" ") ? t.split(" ").forEach((s) => e.classList.remove(s)) : e.classList.remove(t), e;
1488
+ }
1489
+ appendChild(e, t) {
1490
+ e.appendChild(t);
1491
+ }
1492
+ createElement(e) {
1493
+ return document.createElement(e);
1494
+ }
1495
+ createText(e) {
1496
+ return document.createTextNode(e);
1497
+ }
1498
+ setAttribute(e, t, s) {
1499
+ e.setAttribute(t, s);
1500
+ }
1501
+ }
1502
+ class fe {
1503
+ render(e, t, s, i, o, r, n) {
1504
+ if (o.isEditable(t, s)) {
1505
+ n.addClass(e, "ge-table-row-input-div");
1506
+ const l = o.getValueAt(t, s);
1507
+ e.innerHTML = `
9
1508
  <input
10
1509
  type="text"
11
1510
  value="${l}"
12
1511
  autofocus
13
1512
  onfocus="this.setSelectionRange(0, this.value.length)"
14
1513
  data-listen="change"
15
- data-area="${s}"
1514
+ data-area="${i}"
16
1515
  data-row-index="${t}"
17
- data-col-index="${i}"
1516
+ data-col-index="${s}"
18
1517
  data-input-type="text"
19
1518
  style="width:calc(100% - 8px);height:100%;border:0;padding:0 0 0 8px;"
20
- class="ge-table-cell-editor-input">`}}}class be{constructor(e="none",t="single"){this.selectionType=e,this.selectionMode=t,this.ranges=[],this.negativeRanges=[],this.allSelected=!1}getSelectionCount(e,t){let i=0;for(const s of this.ranges)s.isInRange(e,t)&&i++;return this.allSelected&&i++,this.isInNegativeRange(e,t)&&(i=0),i}isInNegativeRange(e,t){for(const i of this.negativeRanges)if(i.isInRange(e,t))return!0;return!1}getRanges(){return this.ranges}clear(){this.ranges=[],this.negativeRanges=[],this.allSelected=!1}hasSelection(){return!!this.ranges.length}selectAll(){this.allSelected=!0}addSelection(e){this.addRange(e)}removeSelection(e){if(this.selectionType==="none")return;let t=e;this.selectionType==="row"?t=A.singleRow(e.r1):this.selectionType==="column"&&(t=A.singleColumn(e.c1)),this.negativeRanges.push(t)}togglePoint(e,t){this.getSelectionCount(e,t)>0?this.removeSelection(A.singleCell(e,t)):this.addSelection(A.singleCell(e,t))}addRange(e){this.selectionType!=="none"&&(this.allSelected=!1,this.selectionMode==="single"&&(this.ranges=[]),this.selectionType==="row"?(e.c1=0,e.c2=Number.MAX_SAFE_INTEGER):this.selectionType==="column"?(e.r1=0,e.r2=Number.MAX_SAFE_INTEGER):this.selectionType==="cell"?(e.r2=e.r1,e.c2=e.c1):this.selectionType,this.ranges.push(e))}}class ye{constructor(e="none"){this.selectionType=e,this.rowIndex=-1,this.columnIndex=-1,this.changed=!1}clearChanged(){this.changed=!1}hasChanged(){return this.changed}clear(){this.rowIndex=-1,this.columnIndex=-1}setFocus(e,t){(this.rowIndex!==e||this.columnIndex!==t)&&(this.rowIndex=e,this.columnIndex=t,this.changed=!0)}hasFocus(e,t){return this.rowIndex===e&&this.columnIndex===t}getFocus(){return[this.rowIndex,this.columnIndex]}}const we=new be,ve=new ye("cell");class xe{constructor(){this.overflowX="auto",this.overflowY="auto",this.horizontalBorderVisible=!0,this.verticalBorderVisible=!0,this.footerSeparatorBorderVisible=!0,this.headerSeparatorBorderVisible=!0,this.fixedEastSeparatorBorderVisible=!0,this.fixedWestSeparatorBorderVisible=!0,this.tableTopBorderVisible=!0,this.tableBottomBorderVisible=!0,this.hoverRowVisible=!0,this.hoverColumnVisible=!0,this.columnsResizable=!0,this.columnsDraggable=!0,this.columnResizeHandleWidthInPx=4,this.defaultRowHeights={header:34,body:34,footer:34},this.footerVerticalSeparator=!1,this.headerToggleExpandCollapseIcons=!1,this.headerVerticalSeparator=!1,this.treeOptions=new N,this.showCheckboxWihoutExtraColumn=!1,this.externalFilterFunction=void 0,this.sortedOptions=new j,this.sortOrder=["asc","desc"],this.getEditRenderer=(e,t)=>new me,this.getSelectionModel=()=>we,this.getFocusModel=()=>ve}}class Ce{setStyle(e,t,i){return e.style[t]=i,e}appendText(e,t){const i=this.createText(t);return this.appendChild(e,i),i}addClass(e,t){return t.includes(" ")?t.split(" ").forEach(i=>e.classList.add(i)):e.classList.add(t),e}appendChild(e,t){e.appendChild(t)}createElement(e){return document.createElement(e)}createText(e){return document.createTextNode(e)}setAttribute(e,t,i){e.setAttribute(t,i)}}function Ee({tableModel:p,tableOptions:e=new xe,mouseMoved:t,checkboxChanged:i,contextmenu:s,modelChanged:o,mouseClicked:r,mouseDragging:n,mouseDraggingEnd:l,tableReady:a}){const d=k.useRef(null);let S=!1;k.useEffect(()=>{d.current&&!S&&(g(d.current),S=!0)});const g=f=>{const c={onCheckboxChanged:h=>{i&&i(h)},onContextmenu:h=>{s&&s(h)},onModelChanged:h=>{o&&o(h)},onMouseClicked:h=>{r&&r(h)},onMouseDragging:h=>{n&&n(h)},onMouseDraggingEnd:h=>{l&&l(h)},onMouseMoved:h=>{t&&t(h)}},b=new fe(f,p,new Ce,e,c);b.firstInit(),a&&a(b.getApi())};return z.jsx("div",{ref:d,className:"container-div",style:{width:"100%",height:"100%",backgroundColor:"transparent",padding:"0",margin:"0"}})}var $,F=X;if(process.env.NODE_ENV==="production")$=F.createRoot,F.hydrateRoot;else{var G=F.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;$=function(p,e){G.usingClientEntryPoint=!0;try{return F.createRoot(p,e)}finally{G.usingClientEntryPoint=!1}}}class Ae{constructor(e){this.Component=e,console.info(e)}render(e,t,i,s,o,r,n){const l={cellDiv:e,rowIndex:t,columnIndex:i,areaIdent:s,areaModel:o,cellValue:r},a=$(e,{});return a.render(this.Component(l)),()=>{a.unmount()}}}exports.ComponentRendererWrapper=Ae;exports.GuiexpertTable=Ee;
1519
+ class="ge-table-cell-editor-input">`;
1520
+ }
1521
+ }
1522
+ }
1523
+ class be {
1524
+ constructor(e = "none", t = "single") {
1525
+ this.selectionType = e, this.selectionMode = t, this.ranges = [], this.negativeRanges = [], this.allSelected = !1;
1526
+ }
1527
+ getSelectionCount(e, t) {
1528
+ let s = 0;
1529
+ for (const i of this.ranges)
1530
+ i.isInRange(e, t) && s++;
1531
+ return this.allSelected && s++, this.isInNegativeRange(e, t) && (s = 0), s;
1532
+ }
1533
+ isInNegativeRange(e, t) {
1534
+ for (const s of this.negativeRanges)
1535
+ if (s.isInRange(e, t))
1536
+ return !0;
1537
+ return !1;
1538
+ }
1539
+ getRanges() {
1540
+ return this.ranges;
1541
+ }
1542
+ clear() {
1543
+ this.ranges = [], this.negativeRanges = [], this.allSelected = !1;
1544
+ }
1545
+ hasSelection() {
1546
+ return !!this.ranges.length;
1547
+ }
1548
+ selectAll() {
1549
+ this.allSelected = !0;
1550
+ }
1551
+ addSelection(e) {
1552
+ this.addRange(e);
1553
+ }
1554
+ removeSelection(e) {
1555
+ if (this.selectionType === "none")
1556
+ return;
1557
+ let t = e;
1558
+ this.selectionType === "row" ? t = A.singleRow(e.r1) : this.selectionType === "column" && (t = A.singleColumn(e.c1)), this.negativeRanges.push(t);
1559
+ }
1560
+ togglePoint(e, t) {
1561
+ this.getSelectionCount(e, t) > 0 ? this.removeSelection(A.singleCell(e, t)) : this.addSelection(A.singleCell(e, t));
1562
+ }
1563
+ addRange(e) {
1564
+ this.selectionType !== "none" && (this.allSelected = !1, this.selectionMode === "single" && (this.ranges = []), this.selectionType === "row" ? (e.c1 = 0, e.c2 = Number.MAX_SAFE_INTEGER) : this.selectionType === "column" ? (e.r1 = 0, e.r2 = Number.MAX_SAFE_INTEGER) : this.selectionType === "cell" ? (e.r2 = e.r1, e.c2 = e.c1) : this.selectionType, this.ranges.push(e));
1565
+ }
1566
+ }
1567
+ class ye {
1568
+ constructor(e = "none") {
1569
+ this.selectionType = e, this.rowIndex = -1, this.columnIndex = -1, this.changed = !1;
1570
+ }
1571
+ clearChanged() {
1572
+ this.changed = !1;
1573
+ }
1574
+ hasChanged() {
1575
+ return this.changed;
1576
+ }
1577
+ clear() {
1578
+ this.rowIndex = -1, this.columnIndex = -1;
1579
+ }
1580
+ setFocus(e, t) {
1581
+ (this.rowIndex !== e || this.columnIndex !== t) && (this.rowIndex = e, this.columnIndex = t, this.changed = !0);
1582
+ }
1583
+ hasFocus(e, t) {
1584
+ return this.rowIndex === e && this.columnIndex === t;
1585
+ }
1586
+ getFocus() {
1587
+ return [this.rowIndex, this.columnIndex];
1588
+ }
1589
+ }
1590
+ const ve = new be(), Ce = new ye("cell");
1591
+ class K {
1592
+ constructor() {
1593
+ this.overflowX = "auto", this.overflowY = "auto", this.horizontalBorderVisible = !0, this.verticalBorderVisible = !0, this.footerSeparatorBorderVisible = !0, this.headerSeparatorBorderVisible = !0, this.fixedEastSeparatorBorderVisible = !0, this.fixedWestSeparatorBorderVisible = !0, this.tableTopBorderVisible = !0, this.tableBottomBorderVisible = !0, this.hoverRowVisible = !0, this.hoverColumnVisible = !0, this.columnsResizable = !0, this.columnsDraggable = !0, this.columnResizeHandleWidthInPx = 4, this.defaultRowHeights = {
1594
+ header: 34,
1595
+ body: 34,
1596
+ footer: 34
1597
+ }, this.footerVerticalSeparator = !1, this.headerToggleExpandCollapseIcons = !1, this.headerVerticalSeparator = !1, this.treeOptions = new j(), this.showCheckboxWihoutExtraColumn = !1, this.externalFilterFunction = void 0, this.sortedOptions = new X(), this.sortOrder = ["asc", "desc"], this.getEditRenderer = (e, t) => new fe(), this.getSelectionModel = () => ve, this.getFocusModel = () => Ce;
1598
+ }
1599
+ }
1600
+ class _ extends de {
1601
+ constructor(e, t, s, i, o) {
1602
+ var r;
1603
+ if (super(
1604
+ e,
1605
+ t,
1606
+ new Q(s),
1607
+ i
1608
+ ), this.eventListener = o, this.selectionService = new ue(this), this.api = new te(this), this.mouseStartAction = "", this.mouseStartWidth = -1, this.mouseStartColumnIndex = -1, this.dragFrom = -1, this.dragTo = -1, o || (this.eventListener = new k()), (r = this.tableOptions) != null && r.autoRestoreOptions) {
1609
+ const n = this.tableOptions.autoRestoreOptions, l = n.getStorageKeyFn;
1610
+ l && (n.autoRestoreScrollPosition && (this.storeScrollPosStateService = new se(l)), n.autoRestoreCollapsedExpandedState && (this.storeStateCollapsedExpandService = new oe(l)), n.autoRestoreSortingState && (this.storeSortingService = new le(l)));
1611
+ }
1612
+ this.mouseHandler = new ee(this), this.inputHandler = new ce(this), this.shortcutService = new me(this), this.shortcutService.addListener(this.selectionService);
1613
+ }
1614
+ static create(e, t, s = new K(), i = new k(), o = new z()) {
1615
+ return new _(
1616
+ e,
1617
+ t,
1618
+ o,
1619
+ s,
1620
+ i
1621
+ );
1622
+ }
1623
+ onActionTriggered(e) {
1624
+ if (e === "NAVIGATE_DOWN" && this.changeFocusCell(0, 1) || e === "NAVIGATE_UP" && this.changeFocusCell(0, -1) || e === "NAVIGATE_LEFT" && this.changeFocusCell(-1, 0) || e === "NAVIGATE_RIGHT" && this.changeFocusCell(1, 0))
1625
+ return !0;
1626
+ if (e === "START_EDITING" && this.getFocusModel) {
1627
+ const t = this.getFocusModel();
1628
+ if (t) {
1629
+ const [s, i] = t.getFocus();
1630
+ this.tableModel.getBodyModel().isEditable(s, i) && (this.clearSelection(), this.initRenderEditor(s, i));
1631
+ }
1632
+ return !0;
1633
+ }
1634
+ return !1;
1635
+ }
1636
+ updateModelValueAfterEdit(e, t, s, i) {
1637
+ e === "body" && this.tableModel.getAreaModel(e).setValue(t, s, i) && (this.resetEditorRenderer(), this.repaint(), this.eventListener.onModelChanged(V.createSingle(t, s)), this.hostElement.focus());
1638
+ }
1639
+ getApi() {
1640
+ return this.api;
1641
+ }
1642
+ /*
1643
+ * Called by the table component
1644
+ */
1645
+ firstInit() {
1646
+ var e;
1647
+ return this.tableModel.init(), (e = this.tableOptions) != null && e.externalFilterFunction && this.externalFilterChanged(!1), this.autoRestoreCollapsedExpandedState(), this.autoRestoreSortingState(), this.resetSizeOfWrapperDiv(), this.adjustContainersAndRows(), this.autoRestoreScrollPosition(), this;
1648
+ }
1649
+ createGeMouseEvent(e) {
1650
+ const t = new W();
1651
+ if (t.originalEvent = e, e) {
1652
+ const s = e.target;
1653
+ if ([t.areaIdent, t.sideIdent] = this.getAreaAndSideIdentByAttr(s), t.rowIndex = this.getNumberByAttr(s, "data-row-index"), t.columnIndex = this.getNumberByAttr(s, "data-col-index"), t.action = this.getStringByAttr(s, "data-ge-action"), t.areaIdent) {
1654
+ const i = this.tableModel.getAreaModel(t.areaIdent);
1655
+ t.rowTop = i.getYPosByRowIndex(t.rowIndex);
1656
+ }
1657
+ if (t.columnLeft = this.tableModel.getXPosByColumnIndex(t.columnIndex), e.ctrlKey && e.altKey) {
1658
+ const i = e.clientY - this.hostElement.offsetTop - this.areaHeaderCenter.parent.clientHeight, o = e.clientX - this.hostElement.offsetLeft - this.areaBodyWestGeo.width;
1659
+ this.debugOnce(o, i);
1660
+ }
1661
+ }
1662
+ return t;
1663
+ }
1664
+ onMouseDown(e) {
1665
+ e.columnIndex > -1 && e.action && ["resize-column", "drag-column"].includes(e.action) && (this.mouseStartWidth = this.tableModel.getColumnWidth(e.columnIndex), this.mouseStartAction = e.action, this.mouseStartColumnIndex = e.columnIndex, this.mouseStartAction === "drag-column" && (this.dragFrom = this.mouseStartColumnIndex));
1666
+ }
1667
+ mouseDraggingOnFrame(e) {
1668
+ this.eventListener.onMouseDragging(e), this.mouseEvent = e, this.mouseStartColumnIndex > -1 && this.mouseStartAction === "resize-column" && this.tableOptions.columnsResizable ? this.resizeColumn(e) : this.mouseStartAction === "drag-column" && e.columnIndex > -1 && this.tableOptions.columnsDraggable && (this.draggingTargetColumnIndex = e.columnIndex, this.dragTo = this.draggingTargetColumnIndex, this.dragFrom > -1 && this.dragTo > -1 && this.dragFrom !== this.dragTo && (this.tableModel.changeColumnOrder(this.dragFrom, this.dragTo), this.dragFrom = this.dragTo, this.resetSizeOfWrapperDiv(), this.adjustContainersAndRows()), this.repaint());
1669
+ }
1670
+ mouseDraggingEndOnFrame(e) {
1671
+ this.eventListener.onMouseDraggingEnd(e), this.draggingTargetColumnIndex = -1, this.mouseStartAction === "resize-column" ? this.resizeColumn(e) : this.mouseStartAction === "drag-column" && this.repaint(), this.mouseStartWidth = -1, this.mouseStartColumnIndex = -1, this.dragFrom = -1, this.dragTo = -1, this.mouseStartAction = "";
1672
+ }
1673
+ mouseMove(e) {
1674
+ this.eventListener.onMouseMoved(e), this.adjustHoverRows(e), this.adjustHoverColumns(e);
1675
+ }
1676
+ contextmenu(e) {
1677
+ this.eventListener.onContextmenu(e);
1678
+ }
1679
+ toggleExpandCollapseAll(e = !0) {
1680
+ var s;
1681
+ const t = this.tableModel.getBodyModel();
1682
+ $(t) && (t.toggleExpandCollapseAll(e), this.repaint(), (s = this.storeStateCollapsedExpandService) == null || s.collapsedStateAll(e));
1683
+ }
1684
+ toggleRowCheckbox(e, t, s) {
1685
+ var l;
1686
+ const i = this.tableModel.getAreaModel(s), o = i.isRowChecked(e), r = o === void 0 || o === "semi" || o === "none";
1687
+ i.setRowChecked(e, r), this.repaint();
1688
+ const n = (l = i.rowSelectionModel) == null ? void 0 : l.getCheckedRows();
1689
+ this.eventListener.onCheckboxChanged(n || []);
1690
+ }
1691
+ onMouseClicked(e, t) {
1692
+ let s = this.selectionService.onMouseClicked(e, t);
1693
+ if (!s && this.getFocusModel) {
1694
+ const i = this.getFocusModel();
1695
+ i && (s = i.hasChanged(), i.clearChanged(), s && this.resetEditorRenderer());
1696
+ }
1697
+ this.eventListener.onMouseClicked(e), s && this.debounce(this.repaint.bind(this), 10);
1698
+ }
1699
+ externalFilterChanged(e = !0) {
1700
+ const t = this.tableOptions.externalFilterFunction;
1701
+ t && (e && this.clearSelectionModel(), this.tableModel.externalFilterChanged(t), this.scrollViewport.scrollTo(0, 0), this.tableModel.recalcHeightAndPadding(), this.resetSizeOfWrapperDiv(), this.repaint());
1702
+ }
1703
+ onHeaderDblClicked(e, t, s) {
1704
+ var o, r;
1705
+ const i = this.tableModel.getColumnDef(s);
1706
+ if (i != null && i.sortable && i.sortable()) {
1707
+ e.preventDefault(), e.stopPropagation();
1708
+ const n = i.sortStatesOrder ? i.sortStatesOrder : this.tableOptions.sortOrder, l = i.sortState ?? "", a = n[(n.indexOf(l) + 1) % n.length], d = new he(s, a);
1709
+ this.tableModel.doSort([d]) && ((o = this.tableModel.getColumnDefs()) == null || o.forEach((g) => g.sortState = ""), i.sortState = a), this.repaint(), (r = this.storeSortingService) == null || r.setSortItems([d]);
1710
+ }
1711
+ }
1712
+ changeFocusCell(e, t) {
1713
+ if (!this.isEditing() && this.getFocusModel) {
1714
+ const s = this.getFocusModel();
1715
+ if (s) {
1716
+ const [i, o] = s.getFocus();
1717
+ return s.setFocus(i + t, o + e), this.repaint(), !0;
1718
+ }
1719
+ }
1720
+ return !1;
1721
+ }
1722
+ resizeColumn(e) {
1723
+ this.tableModel.setColumnWidth(this.mouseStartColumnIndex, this.mouseStartWidth + e.draggingX), this.tableModel.recalcPadding(), this.resetSizeOfWrapperDiv(), this.adjustContainersAndRows();
1724
+ }
1725
+ clearSelectionModel() {
1726
+ var e;
1727
+ this.getSelectionModel && ((e = this.getSelectionModel()) == null || e.clear());
1728
+ }
1729
+ debugOnce(e, t) {
1730
+ var s;
1731
+ console.clear(), console.info("this.hostElement.offsetTop", this.hostElement.offsetTop), console.info("this.hostElement.scrollHeight", this.hostElement.scrollHeight), console.info("this.scrollViewportTop", this.scrollTop), console.info("this.areaHeaderCenter.parent.clientHeight", this.areaHeaderCenter.parent.clientHeight), console.info("bodyY", t), console.info("bodyX", e), console.info("rows", this.firstVisibleRowIndex), console.info(""), console.info("this.tableModel", this.tableModel), console.info(""), console.info("this.mouseMoveEvent.clientX", (s = this.mouseHandler.mouseEvent) == null ? void 0 : s.clientX), console.info("this.hostElement.offsetLeft", this.hostElement.offsetLeft), console.info("this.areaBodyWestGeo.width", this.areaBodyWestGeo.width);
1732
+ }
1733
+ autoRestoreScrollPosition() {
1734
+ var e;
1735
+ if ((e = this.tableOptions) != null && e.autoRestoreOptions && this.storeScrollPosStateService && this.tableOptions.autoRestoreOptions.autoRestoreScrollPosition) {
1736
+ const s = this.storeScrollPosStateService.getScrollOffset();
1737
+ s && this.scrollViewport.scrollTo(...s);
1738
+ }
1739
+ }
1740
+ autoRestoreSortingState() {
1741
+ var e, t;
1742
+ if ((t = (e = this.tableOptions) == null ? void 0 : e.autoRestoreOptions) != null && t.autoRestoreSortingState && this.storeSortingService) {
1743
+ const s = this.storeSortingService.getSortItems();
1744
+ s != null && s.length && this.tableModel.getBodyModel().doSort(s);
1745
+ }
1746
+ }
1747
+ autoRestoreCollapsedExpandedState() {
1748
+ var e, t;
1749
+ if ((t = (e = this.tableOptions) == null ? void 0 : e.autoRestoreOptions) != null && t.getRowId && this.storeStateCollapsedExpandService) {
1750
+ const s = this.tableOptions.autoRestoreOptions, i = s.getRowId;
1751
+ if (s.autoRestoreCollapsedExpandedState && i) {
1752
+ const o = this.storeStateCollapsedExpandService.collapsedExpandedStateGet(), r = this.tableModel.getAreaModel("body");
1753
+ if ($(r)) {
1754
+ const n = r, l = r.getRowCount();
1755
+ for (let a = 0; a < l; a++) {
1756
+ const d = r.getRowByIndex(a);
1757
+ if (d)
1758
+ if (o.allExpanded)
1759
+ d.expanded = !0;
1760
+ else if (o.allCollapsed)
1761
+ d.expanded = !1;
1762
+ else {
1763
+ const u = i(d.data);
1764
+ o.mode === "expanded" ? d.expanded = this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(u) : o.mode === "collapsed" && (d.expanded = !this.storeStateCollapsedExpandService.collapsedExpandedStateIncludes(u));
1765
+ }
1766
+ }
1767
+ n.recalcVisibleTreeRows();
1768
+ }
1769
+ }
1770
+ }
1771
+ }
1772
+ }
1773
+ function Ae({
1774
+ tableModel: p,
1775
+ tableOptions: e = new K(),
1776
+ mouseMoved: t,
1777
+ checkboxChanged: s,
1778
+ contextmenu: i,
1779
+ modelChanged: o,
1780
+ mouseClicked: r,
1781
+ mouseDragging: n,
1782
+ mouseDraggingEnd: l,
1783
+ tableReady: a
1784
+ }) {
1785
+ const d = q(null);
1786
+ let u = !1;
1787
+ U(() => {
1788
+ d.current && !u && (g(d.current), u = !0);
1789
+ });
1790
+ const g = (m) => {
1791
+ const c = {
1792
+ onCheckboxChanged: (h) => {
1793
+ s && s(h);
1794
+ },
1795
+ onContextmenu: (h) => {
1796
+ i && i(h);
1797
+ },
1798
+ onModelChanged: (h) => {
1799
+ o && o(h);
1800
+ },
1801
+ onMouseClicked: (h) => {
1802
+ r && r(h);
1803
+ },
1804
+ onMouseDragging: (h) => {
1805
+ n && n(h);
1806
+ },
1807
+ onMouseDraggingEnd: (h) => {
1808
+ l && l(h);
1809
+ },
1810
+ onMouseMoved: (h) => {
1811
+ t && t(h);
1812
+ }
1813
+ }, b = new _(
1814
+ m,
1815
+ p,
1816
+ new z(),
1817
+ e,
1818
+ c
1819
+ );
1820
+ b.firstInit(), a && a(b.getApi());
1821
+ };
1822
+ return /* @__PURE__ */ Y(
1823
+ "div",
1824
+ {
1825
+ ref: d,
1826
+ className: "container-div",
1827
+ style: {
1828
+ width: "100%",
1829
+ height: "100%",
1830
+ background: "transparent",
1831
+ padding: "0",
1832
+ margin: "0"
1833
+ }
1834
+ }
1835
+ );
1836
+ }
1837
+ var B, F = J;
1838
+ if (process.env.NODE_ENV === "production")
1839
+ B = F.createRoot, F.hydrateRoot;
1840
+ else {
1841
+ var N = F.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
1842
+ B = function(p, e) {
1843
+ N.usingClientEntryPoint = !0;
1844
+ try {
1845
+ return F.createRoot(p, e);
1846
+ } finally {
1847
+ N.usingClientEntryPoint = !1;
1848
+ }
1849
+ };
1850
+ }
1851
+ class Re {
1852
+ constructor(e) {
1853
+ this.Component = e, console.info(e);
1854
+ }
1855
+ render(e, t, s, i, o, r, n) {
1856
+ const l = {
1857
+ cellDiv: e,
1858
+ rowIndex: t,
1859
+ columnIndex: s,
1860
+ areaIdent: i,
1861
+ areaModel: o,
1862
+ cellValue: r
1863
+ }, a = B(e, {});
1864
+ return a.render(this.Component(l)), () => {
1865
+ a.unmount();
1866
+ };
1867
+ }
1868
+ }
1869
+ export {
1870
+ Re as ComponentRendererWrapper,
1871
+ Ae as GuiexpertTable
1872
+ };