@lexical/table 0.24.1-nightly.20250210.0 → 0.24.1-nightly.20250212.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,6 +52,8 @@ class TableCellNode extends lexical.ElementNode {
52
52
 
53
53
  /** @internal */
54
54
 
55
+ /** @internal */
56
+
55
57
  static getType() {
56
58
  return 'tablecell';
57
59
  }
@@ -62,6 +64,7 @@ class TableCellNode extends lexical.ElementNode {
62
64
  super.afterCloneFrom(node);
63
65
  this.__rowSpan = node.__rowSpan;
64
66
  this.__backgroundColor = node.__backgroundColor;
67
+ this.__verticalAlign = node.__verticalAlign;
65
68
  }
66
69
  static importDOM() {
67
70
  return {
@@ -79,7 +82,7 @@ class TableCellNode extends lexical.ElementNode {
79
82
  return $createTableCellNode().updateFromJSON(serializedNode);
80
83
  }
81
84
  updateFromJSON(serializedNode) {
82
- return super.updateFromJSON(serializedNode).setHeaderStyles(serializedNode.headerState).setColSpan(serializedNode.colSpan || 1).setRowSpan(serializedNode.rowSpan || 1).setWidth(serializedNode.width || undefined).setBackgroundColor(serializedNode.backgroundColor || null);
85
+ return super.updateFromJSON(serializedNode).setHeaderStyles(serializedNode.headerState).setColSpan(serializedNode.colSpan || 1).setRowSpan(serializedNode.rowSpan || 1).setWidth(serializedNode.width || undefined).setBackgroundColor(serializedNode.backgroundColor || null).setVerticalAlign(serializedNode.verticalAlign || undefined);
83
86
  }
84
87
  constructor(headerState = TableCellHeaderStates.NO_STATUS, colSpan = 1, width, key) {
85
88
  super(key);
@@ -103,6 +106,9 @@ class TableCellNode extends lexical.ElementNode {
103
106
  if (this.__backgroundColor !== null) {
104
107
  element.style.backgroundColor = this.__backgroundColor;
105
108
  }
109
+ if (isValidVerticalAlign(this.__verticalAlign)) {
110
+ element.style.verticalAlign = this.__verticalAlign;
111
+ }
106
112
  utils.addClassNamesToElement(element, config.theme.tableCell, this.hasHeader() && config.theme.tableCellHeader);
107
113
  return element;
108
114
  }
@@ -119,7 +125,7 @@ class TableCellNode extends lexical.ElementNode {
119
125
  element.rowSpan = this.__rowSpan;
120
126
  }
121
127
  element.style.width = `${this.getWidth() || COLUMN_WIDTH}px`;
122
- element.style.verticalAlign = 'top';
128
+ element.style.verticalAlign = this.getVerticalAlign() || 'top';
123
129
  element.style.textAlign = 'start';
124
130
  if (this.__backgroundColor === null && this.hasHeader()) {
125
131
  element.style.backgroundColor = '#f2f3f5';
@@ -130,6 +136,9 @@ class TableCellNode extends lexical.ElementNode {
130
136
  exportJSON() {
131
137
  return {
132
138
  ...super.exportJSON(),
139
+ ...(isValidVerticalAlign(this.__verticalAlign) && {
140
+ verticalAlign: this.__verticalAlign
141
+ }),
133
142
  backgroundColor: this.getBackgroundColor(),
134
143
  colSpan: this.__colSpan,
135
144
  headerState: this.__headerState,
@@ -180,6 +189,14 @@ class TableCellNode extends lexical.ElementNode {
180
189
  self.__backgroundColor = newBackgroundColor;
181
190
  return self;
182
191
  }
192
+ getVerticalAlign() {
193
+ return this.getLatest().__verticalAlign;
194
+ }
195
+ setVerticalAlign(newVerticalAlign) {
196
+ const self = this.getWritable();
197
+ self.__verticalAlign = newVerticalAlign || undefined;
198
+ return self;
199
+ }
183
200
  toggleHeaderStyle(headerStateToToggle) {
184
201
  const self = this.getWritable();
185
202
  if ((self.__headerState & headerStateToToggle) === headerStateToToggle) {
@@ -196,7 +213,7 @@ class TableCellNode extends lexical.ElementNode {
196
213
  return this.getLatest().__headerState !== TableCellHeaderStates.NO_STATUS;
197
214
  }
198
215
  updateDOM(prevNode) {
199
- return prevNode.__headerState !== this.__headerState || prevNode.__width !== this.__width || prevNode.__colSpan !== this.__colSpan || prevNode.__rowSpan !== this.__rowSpan || prevNode.__backgroundColor !== this.__backgroundColor;
216
+ return prevNode.__headerState !== this.__headerState || prevNode.__width !== this.__width || prevNode.__colSpan !== this.__colSpan || prevNode.__rowSpan !== this.__rowSpan || prevNode.__backgroundColor !== this.__backgroundColor || prevNode.__verticalAlign !== this.__verticalAlign;
200
217
  }
201
218
  isShadowRoot() {
202
219
  return true;
@@ -211,6 +228,9 @@ class TableCellNode extends lexical.ElementNode {
211
228
  return false;
212
229
  }
213
230
  }
231
+ function isValidVerticalAlign(verticalAlign) {
232
+ return verticalAlign === 'middle' || verticalAlign === 'bottom';
233
+ }
214
234
  function $convertTableCellNodeElement(domNode) {
215
235
  const domNode_ = domNode;
216
236
  const nodeName = domNode.nodeName.toLowerCase();
@@ -224,6 +244,10 @@ function $convertTableCellNodeElement(domNode) {
224
244
  if (backgroundColor !== '') {
225
245
  tableCellNode.__backgroundColor = backgroundColor;
226
246
  }
247
+ const verticalAlign = domNode_.style.verticalAlign;
248
+ if (isValidVerticalAlign(verticalAlign)) {
249
+ tableCellNode.__verticalAlign = verticalAlign;
250
+ }
227
251
  const style = domNode_.style;
228
252
  const textDecoration = (style && style.textDecoration || '').split(' ');
229
253
  const hasBoldFontWeight = style.fontWeight === '700' || style.fontWeight === 'bold';
@@ -50,6 +50,8 @@ class TableCellNode extends ElementNode {
50
50
 
51
51
  /** @internal */
52
52
 
53
+ /** @internal */
54
+
53
55
  static getType() {
54
56
  return 'tablecell';
55
57
  }
@@ -60,6 +62,7 @@ class TableCellNode extends ElementNode {
60
62
  super.afterCloneFrom(node);
61
63
  this.__rowSpan = node.__rowSpan;
62
64
  this.__backgroundColor = node.__backgroundColor;
65
+ this.__verticalAlign = node.__verticalAlign;
63
66
  }
64
67
  static importDOM() {
65
68
  return {
@@ -77,7 +80,7 @@ class TableCellNode extends ElementNode {
77
80
  return $createTableCellNode().updateFromJSON(serializedNode);
78
81
  }
79
82
  updateFromJSON(serializedNode) {
80
- return super.updateFromJSON(serializedNode).setHeaderStyles(serializedNode.headerState).setColSpan(serializedNode.colSpan || 1).setRowSpan(serializedNode.rowSpan || 1).setWidth(serializedNode.width || undefined).setBackgroundColor(serializedNode.backgroundColor || null);
83
+ return super.updateFromJSON(serializedNode).setHeaderStyles(serializedNode.headerState).setColSpan(serializedNode.colSpan || 1).setRowSpan(serializedNode.rowSpan || 1).setWidth(serializedNode.width || undefined).setBackgroundColor(serializedNode.backgroundColor || null).setVerticalAlign(serializedNode.verticalAlign || undefined);
81
84
  }
82
85
  constructor(headerState = TableCellHeaderStates.NO_STATUS, colSpan = 1, width, key) {
83
86
  super(key);
@@ -101,6 +104,9 @@ class TableCellNode extends ElementNode {
101
104
  if (this.__backgroundColor !== null) {
102
105
  element.style.backgroundColor = this.__backgroundColor;
103
106
  }
107
+ if (isValidVerticalAlign(this.__verticalAlign)) {
108
+ element.style.verticalAlign = this.__verticalAlign;
109
+ }
104
110
  addClassNamesToElement(element, config.theme.tableCell, this.hasHeader() && config.theme.tableCellHeader);
105
111
  return element;
106
112
  }
@@ -117,7 +123,7 @@ class TableCellNode extends ElementNode {
117
123
  element.rowSpan = this.__rowSpan;
118
124
  }
119
125
  element.style.width = `${this.getWidth() || COLUMN_WIDTH}px`;
120
- element.style.verticalAlign = 'top';
126
+ element.style.verticalAlign = this.getVerticalAlign() || 'top';
121
127
  element.style.textAlign = 'start';
122
128
  if (this.__backgroundColor === null && this.hasHeader()) {
123
129
  element.style.backgroundColor = '#f2f3f5';
@@ -128,6 +134,9 @@ class TableCellNode extends ElementNode {
128
134
  exportJSON() {
129
135
  return {
130
136
  ...super.exportJSON(),
137
+ ...(isValidVerticalAlign(this.__verticalAlign) && {
138
+ verticalAlign: this.__verticalAlign
139
+ }),
131
140
  backgroundColor: this.getBackgroundColor(),
132
141
  colSpan: this.__colSpan,
133
142
  headerState: this.__headerState,
@@ -178,6 +187,14 @@ class TableCellNode extends ElementNode {
178
187
  self.__backgroundColor = newBackgroundColor;
179
188
  return self;
180
189
  }
190
+ getVerticalAlign() {
191
+ return this.getLatest().__verticalAlign;
192
+ }
193
+ setVerticalAlign(newVerticalAlign) {
194
+ const self = this.getWritable();
195
+ self.__verticalAlign = newVerticalAlign || undefined;
196
+ return self;
197
+ }
181
198
  toggleHeaderStyle(headerStateToToggle) {
182
199
  const self = this.getWritable();
183
200
  if ((self.__headerState & headerStateToToggle) === headerStateToToggle) {
@@ -194,7 +211,7 @@ class TableCellNode extends ElementNode {
194
211
  return this.getLatest().__headerState !== TableCellHeaderStates.NO_STATUS;
195
212
  }
196
213
  updateDOM(prevNode) {
197
- return prevNode.__headerState !== this.__headerState || prevNode.__width !== this.__width || prevNode.__colSpan !== this.__colSpan || prevNode.__rowSpan !== this.__rowSpan || prevNode.__backgroundColor !== this.__backgroundColor;
214
+ return prevNode.__headerState !== this.__headerState || prevNode.__width !== this.__width || prevNode.__colSpan !== this.__colSpan || prevNode.__rowSpan !== this.__rowSpan || prevNode.__backgroundColor !== this.__backgroundColor || prevNode.__verticalAlign !== this.__verticalAlign;
198
215
  }
199
216
  isShadowRoot() {
200
217
  return true;
@@ -209,6 +226,9 @@ class TableCellNode extends ElementNode {
209
226
  return false;
210
227
  }
211
228
  }
229
+ function isValidVerticalAlign(verticalAlign) {
230
+ return verticalAlign === 'middle' || verticalAlign === 'bottom';
231
+ }
212
232
  function $convertTableCellNodeElement(domNode) {
213
233
  const domNode_ = domNode;
214
234
  const nodeName = domNode.nodeName.toLowerCase();
@@ -222,6 +242,10 @@ function $convertTableCellNodeElement(domNode) {
222
242
  if (backgroundColor !== '') {
223
243
  tableCellNode.__backgroundColor = backgroundColor;
224
244
  }
245
+ const verticalAlign = domNode_.style.verticalAlign;
246
+ if (isValidVerticalAlign(verticalAlign)) {
247
+ tableCellNode.__verticalAlign = verticalAlign;
248
+ }
225
249
  const style = domNode_.style;
226
250
  const textDecoration = (style && style.textDecoration || '').split(' ');
227
251
  const hasBoldFontWeight = style.fontWeight === '700' || style.fontWeight === 'bold';
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/clipboard");const o=/^(\d+(?:\.\d+)?)px$/,r={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class l extends t.ElementNode{static getType(){return"tablecell"}static clone(e){return new l(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor}static importDOM(){return{td:e=>({conversion:s,priority:0}),th:e=>({conversion:s,priority:0})}}static importJSON(e){return i().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null)}constructor(e=r.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),e.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const n=super.exportDOM(e);if(t.isHTMLElement(n.element)){const e=n.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign="top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return n}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=r.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==r.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function s(e){const n=e,l=e.nodeName.toLowerCase();let s;o.test(n.style.width)&&(s=parseFloat(n.style.width));const c=i("th"===l?r.ROW:r.NO_STATUS,n.colSpan,s);c.__rowSpan=n.rowSpan;const u=n.style.backgroundColor;""!==u&&(c.__backgroundColor=u);const d=n.style,h=(d&&d.textDecoration||"").split(" "),g="700"===d.fontWeight||"bold"===d.fontWeight,f=h.includes("line-through"),m="italic"===d.fontStyle,p=h.includes("underline");return{after:e=>(0===e.length&&e.push(t.$createParagraphNode()),e),forChild:(e,n)=>{if(a(n)&&!t.$isElementNode(e)){const n=t.$createParagraphNode();return t.$isLineBreakNode(e)&&"\n"===e.getTextContent()?null:(t.$isTextNode(e)&&(g&&e.toggleFormat("bold"),f&&e.toggleFormat("strikethrough"),m&&e.toggleFormat("italic"),p&&e.toggleFormat("underline")),n.append(e),n)}return e},node:c}}function i(e=r.NO_STATUS,n=1,o){return t.$applyNodeReplacement(new l(e,n,o))}function a(e){return e instanceof l}const c=t.createCommand("INSERT_TABLE_COMMAND");function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var d=u((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class h extends t.ElementNode{static getType(){return"tablerow"}static clone(e){return new h(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:g,priority:0})}}static importJSON(e){return f().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e.addClassNamesToElement(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function g(t){const n=t;let r;return o.test(n.style.height)&&(r=parseFloat(n.style.height)),{after:t=>e.$descendantsMatching(t,a),node:f(r)}}function f(e){return t.$applyNodeReplacement(new h(e))}function m(e){return e instanceof h}const p="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,C=p&&"documentMode"in document?document.documentMode:null,S=p&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function _(e,n,o=!0){const l=ye();for(let s=0;s<e;s++){const e=f();for(let l=0;l<n;l++){let n=r.NO_STATUS;"object"==typeof o?(0===s&&o.rows&&(n|=r.ROW),0===l&&o.columns&&(n|=r.COLUMN)):o&&(0===s&&(n|=r.ROW),0===l&&(n|=r.COLUMN));const a=i(n),c=t.$createParagraphNode();c.append(t.$createTextNode()),a.append(c),e.append(a)}l.append(e)}return l}function N(t){const n=e.$findMatchingParent(t,(e=>m(e)));if(m(n))return n;throw new Error("Expected table cell to be inside of table row.")}function b(t){const n=e.$findMatchingParent(t,(e=>$e(e)));if($e(n))return n;throw new Error("Expected table cell to be inside of table.")}function w(e,t){const n=b(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}p&&"InputEvent"in window&&!C&&new window.InputEvent("input");const T=(e,t)=>e===r.BOTH||e===t?t:r.NO_STATUS;function y(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function $(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function M(e,t,n){const[o,r,l]=R(e,t,n);return null===r&&d(207),null===l&&d(208),[o,r,l]}function R(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];m(o)||d(209);const c=s(e);for(let u=o.getFirstChild(),h=0;null!=u;u=u.getNextSibling()){for(a(u)||d(147);void 0!==c[h];)h++;const o={cell:u,startColumn:h,startRow:e},{__rowSpan:g,__colSpan:f}=u;for(let t=0;t<g&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<f;e++)n[h+e]=o}null!==t&&null===r&&t.is(u)&&(r=o),null!==n&&null===l&&n.is(u)&&(l=o)}}return[o,r,l]}function x(t){let n;if(t instanceof l)n=t;else if("__type"in t){const o=e.$findMatchingParent(t,a);a(o)||d(148),n=o}else{const o=e.$findMatchingParent(t.getNode(),a);a(o)||d(148),n=o}const o=n.getParent();m(o)||d(149);const r=o.getParent();return $e(r)||d(210),[n,o,r]}function O(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),s=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),i=o,a=r,c=o,u=r;function d(e){const{cell:t,startColumn:n,startRow:i}=e;o=Math.min(o,n),r=Math.min(r,i),l=Math.max(l,n+t.__colSpan-1),s=Math.max(s,i+t.__rowSpan-1)}for(;o<i||r<a||l>c||s>u;){if(o<i){const t=u-a,n=i-1;for(let o=0;o<=t;o++)d(e[a+o][n]);i=n}if(r<a){const t=c-i,n=a-1;for(let o=0;o<=t;o++)d(e[n][i+o]);a=n}if(l>c){const t=u-a,n=c+1;for(let o=0;o<=t;o++)d(e[a+o][n]);c=n}if(s>u){const t=c-i,n=u+1;for(let o=0;o<=t;o++)d(e[n][i+o]);u=n}}return{maxColumn:l,maxRow:s,minColumn:o,minRow:r}}function E(e){const[t,,n]=x(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,a=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<a;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:a,columnIndex:r,rowIndex:e,rowSpan:i};r+=a}}return null}function A(t){const[[n,o,r,l],[s,i,c,u]]=["anchor","focus"].map((n=>{const o=t[n].getNode(),r=e.$findMatchingParent(o,a);a(r)||d(238,n,o.getKey(),o.getType());const l=r.getParent();m(l)||d(239,n);const s=l.getParent();return $e(s)||d(240,n),[o,r,l,s]}));return l.is(u)||d(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:u}}class v{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return F(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new v(this.tableKey,t.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),t.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let n=0;this.getNodes().filter(a).forEach((e=>{const o=e.getFirstChild();t.$isParagraphNode(o)&&(n|=o.getTextFormat())}));const o=t.TEXT_TYPE_TO_FORMAT[e];return!!(n&o)}insertNodes(e){const n=this.focus.getNode();t.$isElementNode(n)||d(151);t.$normalizeSelection__EXPERIMENTAL(n.select(0,n.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=A(this),n=E(e);null===n&&d(153);const o=E(t);null===o&&d(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:n,anchorCell:o,focusCell:r}=A(this),l=r.getParents()[1];if(l!==n){if(n.isParentOf(r)){const e=l.getParent();null==e&&d(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=n.getParent();null==e&&d(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}const[s,i,a]=M(n,o,r),{minColumn:c,maxColumn:u,minRow:h,maxRow:g}=O(s,i,a),f=new Map([[n.getKey(),n]]);let p=null;for(let e=h;e<=g;e++)for(let t=c;t<=u;t++){const{cell:n}=s[e][t],o=n.getParent();m(o)||d(160),o!==p&&(f.set(o.getKey(),o),p=o),f.has(n.getKey())||K(n,(e=>{f.set(e.getKey(),e)}))}const C=Array.from(f.values());return t.isCurrentlyReadOnlyMode()||(this._cachedNodes=C),C}getTextContent(){const e=this.getNodes().filter((e=>a(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function F(e){return e instanceof v}function P(){const e=t.$createPoint("root",0,"element"),n=t.$createPoint("root",0,"element");return new v("root",e,n)}function D(e,n,o){e.getKey(),n.getKey(),o.getKey();const r=t.$getSelection(),l=F(r)?r.clone():P();return l.set(e.getKey(),n.getKey(),o.getKey()),l}function K(e,n){const o=[[e]];for(let e=o.at(-1);void 0!==e&&o.length>0;e=o.at(-1)){const r=e.pop();void 0===r?o.pop():!1!==n(r)&&t.$isElementNode(r)&&o.push(r.getChildren())}}function I(e,n=t.$getEditor()){const o=t.$getNodeByKey(e);$e(o)||d(231,e);const r=B(o,n.getElementByKey(e));return null===r&&d(232,e),{tableElement:r,tableNode:o}}class k{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return I(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=j(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=j(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:n,tableElement:o}=this.$lookup();V(e,j(n,o),null),null!==t.$getSelection()&&(t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))}$enableHighlightStyle(){const t=this.editor,{tableElement:n}=this.$lookup();e.removeClassNamesFromElement(n,t._config.theme.tableSelection),n.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e.addClassNamesToElement(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&d(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),V(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=t.getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,n=!1){const o=this.editor,{tableNode:r}=this.$lookup(),l=e.x,s=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===l&&this.anchorY===s&&!n){if(l===this.focusX&&s===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=l,this.focusY=s,this.isHighlightingCells){const n=pe(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==n)return this.focusCellNodeKey=n.getKey(),this.tableSelection=D(r,this.$getAnchorTableCellOrThrow(),n),t.$setSelection(this.tableSelection),o.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0),V(o,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?t.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&d(234),e}$getFocusTableCell(){return this.focusCellNodeKey?t.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&d(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=pe(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():P(),this.anchorCellNodeKey=e}}$formatCells(e){const n=t.$getSelection();F(n)||d(236);const o=t.$createRangeSelection(),r=o.anchor,l=o.focus,s=n.getNodes().filter(a);s.length>0||d(237);const i=s[0].getFirstChild(),c=t.$isParagraphNode(i)?i.getFormatFlags(e,null):null;s.forEach((t=>{r.set(t.getKey(),0,"element"),l.set(t.getKey(),t.getChildrenSize(),"element"),o.formatText(e,c)})),t.$setSelection(n),this.editor.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:e}=this,n=t.$getNodeByKey(this.tableNodeKey);if(!$e(n))throw new Error("Expected TableNode.");const o=t.$getSelection();F(o)||d(253);const r=o.getNodes().filter(a);if(r.length===this.table.columns*this.table.rows)return n.selectPrevious(),void n.remove();r.forEach((e=>{if(t.$isElementNode(e)){const n=t.$createParagraphNode(),o=t.$createTextNode();n.append(o),e.append(n),e.getChildren().forEach((e=>{e!==n&&e.remove()}))}})),V(e,this.table,null),t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}}const L="__lexicalTableSelection",H=e=>!(1&~e.buttons);function B(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&d(245,t.nodeName),n}function W(e){return e._window}function Y(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;a(n)&&(o=n)}return null}const U=[[t.KEY_ARROW_DOWN_COMMAND,"down"],[t.KEY_ARROW_UP_COMMAND,"up"],[t.KEY_ARROW_LEFT_COMMAND,"backward"],[t.KEY_ARROW_RIGHT_COMMAND,"forward"]],X=[t.DELETE_WORD_COMMAND,t.DELETE_LINE_COMMAND,t.DELETE_CHARACTER_COMMAND],J=[t.KEY_BACKSPACE_COMMAND,t.KEY_DELETE_COMMAND];function q(o,r,l,s){const i=l.getRootElement(),c=W(l);null!==i&&null!==c||d(246);const u=new k(l,o.getKey()),h=B(o,r);!function(e,t){null!==z(e)&&d(205);e[L]=t}(h,u),u.listenersToRemove.add((()=>function(e,t){z(e)===t&&delete e[L]}(h,u)));h.addEventListener("mousedown",(e=>{if(0!==e.button||!t.isDOMNode(e.target)||!c)return;const n=G(e.target);null!==n&&l.update((()=>{const r=t.$getPreviousSelection();if(S&&e.shiftKey&&le(r,o)&&(t.$isRangeSelection(r)||F(r))){const t=r.anchor.getNode(),l=Y(o,r.anchor.getNode());if(l)u.$setAnchorCellForSelection(me(u,l)),u.$setFocusCellForSelection(n),he(e);else{(o.isBefore(t)?o.selectStart():o.selectEnd()).anchor.set(r.anchor.key,r.anchor.offset,r.anchor.type)}}else u.$setAnchorCellForSelection(n)})),(()=>{if(u.isSelecting)return;const e=()=>{u.isSelecting=!1,c.removeEventListener("mouseup",e),c.removeEventListener("mousemove",n)},n=o=>{if(!t.isDOMNode(o.target))return;if(!H(o)&&u.isSelecting)return u.isSelecting=!1,c.removeEventListener("mouseup",e),void c.removeEventListener("mousemove",n);const r=!h.contains(o.target);let s=null;if(r){for(const e of document.elementsFromPoint(o.clientX,o.clientY))if(s=h.contains(e)?G(e):null,s)break}else s=G(o.target);!s||null!==u.focusCell&&s.elem===u.focusCell.elem||(u.setNextFocus({focusCell:s,override:r}),l.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))};u.isSelecting=!0,c.addEventListener("mouseup",e,u.listenerOptions),c.addEventListener("mousemove",n,u.listenerOptions)})()}),u.listenerOptions);c.addEventListener("mousedown",(e=>{const n=e.target;0===e.button&&t.isDOMNode(n)&&l.update((()=>{const e=t.$getSelection();F(e)&&e.tableKey===u.tableNodeKey&&i.contains(n)&&u.$clearHighlight()}))}),u.listenerOptions);for(const[e,n]of U)u.listenersToRemove.add(l.registerCommand(e,(e=>de(l,e,n,o,u)),t.COMMAND_PRIORITY_HIGH));u.listenersToRemove.add(l.registerCommand(t.KEY_ESCAPE_COMMAND,(e=>{const n=t.$getSelection();if(F(n)){const t=Y(o,n.focus.getNode());if(null!==t)return he(e),t.selectEnd(),!0}return!1}),t.COMMAND_PRIORITY_HIGH));const g=n=>()=>{const r=t.$getSelection();if(!le(r,o))return!1;if(F(r))return u.$clearText(),!0;if(t.$isRangeSelection(r)){if(!a(Y(o,r.anchor.getNode())))return!1;const l=r.anchor.getNode(),s=r.focus.getNode(),i=o.isParentOf(l),c=o.isParentOf(s);if(i&&!c||c&&!i)return u.$clearText(),!0;const d=e.$findMatchingParent(r.anchor.getNode(),(e=>t.$isElementNode(e))),h=d&&e.$findMatchingParent(d,(e=>t.$isElementNode(e)&&a(e.getParent())));if(!t.$isElementNode(h)||!t.$isElementNode(d))return!1;if(n===t.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return!0}return!1};for(const e of X)u.listenersToRemove.add(l.registerCommand(e,g(e),t.COMMAND_PRIORITY_CRITICAL));const f=e=>{const n=t.$getSelection();if(!F(n)&&!t.$isRangeSelection(n))return!1;const r=o.isParentOf(n.anchor.getNode());if(r!==o.isParentOf(n.focus.getNode())){const e=r?"anchor":"focus",t=r?"focus":"anchor",{key:l,offset:s,type:i}=n[t];return o[n[e].isBefore(n[t])?"selectPrevious":"selectNext"]()[t].set(l,s,i),!1}return!!le(n,o)&&(!!F(n)&&(e&&(e.preventDefault(),e.stopPropagation()),u.$clearText(),!0))};for(const e of J)u.listenersToRemove.add(l.registerCommand(e,f,t.COMMAND_PRIORITY_CRITICAL));return u.listenersToRemove.add(l.registerCommand(t.CUT_COMMAND,(o=>{const r=t.$getSelection();if(r){if(!F(r)&&!t.$isRangeSelection(r))return!1;n.copyToClipboard(l,e.objectKlassEquals(o,ClipboardEvent)?o:null,n.$getClipboardDataFromSelection(r));const s=f(o);return t.$isRangeSelection(r)?(r.removeText(),!0):s}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_TEXT_COMMAND,(n=>{const r=t.$getSelection();if(!le(r,o))return!1;if(F(r))return u.$formatCells(n),!0;if(t.$isRangeSelection(r)){const t=e.$findMatchingParent(r.anchor.getNode(),(e=>a(e)));if(!a(t))return!1}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_ELEMENT_COMMAND,(e=>{const n=t.$getSelection();if(!F(n)||!le(n,o))return!1;const r=n.anchor.getNode(),l=n.focus.getNode();if(!a(r)||!a(l))return!1;if(function(e,t){if(F(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=M(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,o))return o.setFormat(e),!0;const[s,i,c]=M(o,r,l),u=Math.max(i.startRow+i.cell.__rowSpan-1,c.startRow+c.cell.__rowSpan-1),d=Math.max(i.startColumn+i.cell.__colSpan-1,c.startColumn+c.cell.__colSpan-1),h=Math.min(i.startRow,c.startRow),g=Math.min(i.startColumn,c.startColumn),f=new Set;for(let n=h;n<=u;n++)for(let o=g;o<=d;o++){const r=s[n][o].cell;if(f.has(r))continue;f.add(r),r.setFormat(e);const l=r.getChildren();for(let n=0;n<l.length;n++){const o=l[n];t.$isElementNode(o)&&!o.isInline()&&o.setFormat(e)}}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.CONTROLLED_TEXT_INSERTION_COMMAND,(n=>{const r=t.$getSelection();if(!le(r,o))return!1;if(F(r))return u.$clearHighlight(),!1;if(t.$isRangeSelection(r)){const s=e.$findMatchingParent(r.anchor.getNode(),(e=>a(e)));if(!a(s))return!1;if("string"==typeof n){const e=fe(l,r,o);if(e)return ge(e,o,[t.$createTextNode(n)]),!0}}return!1}),t.COMMAND_PRIORITY_CRITICAL)),s&&u.listenersToRemove.add(l.registerCommand(t.KEY_TAB_COMMAND,(n=>{const r=t.$getSelection();if(!t.$isRangeSelection(r)||!r.isCollapsed()||!le(r,o))return!1;const l=ce(r.anchor.getNode());return!(null===l||!o.is(ue(l)))&&(he(n),function(n,o){const r="next"===o?"getNextSibling":"getPreviousSibling",l="next"===o?"getFirstChild":"getLastChild",s=n[r]();if(t.$isElementNode(s))return s.selectEnd();const i=e.$findMatchingParent(n,m);null===i&&d(247);for(let e=i[r]();m(e);e=e[r]()){const n=e[l]();if(t.$isElementNode(n))return n.selectEnd()}const a=e.$findMatchingParent(i,$e);null===a&&d(248);"next"===o?a.selectNext():a.selectPrevious()}(l,n.shiftKey?"previous":"next"),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FOCUS_COMMAND,(e=>o.isSelected()),t.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(n=>{const{nodes:o,selection:r}=n,l=r.getStartEndPoints(),s=F(r),i=t.$isRangeSelection(r)&&null!==e.$findMatchingParent(r.anchor.getNode(),(e=>a(e)))&&null!==e.$findMatchingParent(r.focus.getNode(),(e=>a(e)))||s;if(1!==o.length||!$e(o[0])||!i||null===l)return!1;const[c]=l,u=o[0],d=u.getChildren(),h=u.getFirstChildOrThrow().getChildrenSize(),g=u.getChildrenSize(),f=e.$findMatchingParent(c.getNode(),(e=>a(e))),p=f&&e.$findMatchingParent(f,(e=>m(e))),C=p&&e.$findMatchingParent(p,(e=>$e(e)));if(!a(f)||!m(p)||!$e(C))return!1;const S=p.getIndexWithinParent(),_=Math.min(C.getChildrenSize()-1,S+g-1),N=f.getIndexWithinParent(),b=Math.min(p.getChildrenSize()-1,N+h-1),w=Math.min(N,b),T=Math.min(S,_),y=Math.max(N,b),$=Math.max(S,_),M=C.getChildren();let R=0;for(let e=T;e<=$;e++){const n=M[e];if(!m(n))return!1;const o=d[R];if(!m(o))return!1;const r=n.getChildren(),l=o.getChildren();let s=0;for(let e=w;e<=y;e++){const n=r[e];if(!a(n))return!1;const o=l[s];if(!a(o))return!1;const i=n.getChildren();o.getChildren().forEach((e=>{if(t.$isTextNode(e)){t.$createParagraphNode().append(e),n.append(e)}else n.append(e)})),i.forEach((e=>e.remove())),s++}R++}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_CHANGE_COMMAND,(()=>{const n=t.$getSelection(),r=t.$getPreviousSelection(),s=u.getAndClearNextFocus();if(null!==s){const{focusCell:e}=s;if(F(n)&&n.tableKey===u.tableNodeKey)return(e.x!==u.focusX||e.y!==u.focusY)&&(u.$setFocusCellForSelection(e),!0);if(e!==u.anchorCell&&le(n,o))return u.$setFocusCellForSelection(e),!0}if(u.getAndClearShouldCheckSelection()&&t.$isRangeSelection(r)&&t.$isRangeSelection(n)&&n.isCollapsed()){const t=n.anchor.getNode(),r=o.getFirstChild(),l=ce(t);if(null!==l&&m(r)){const t=r.getFirstChild();if(a(t)&&o.is(e.$findMatchingParent(l,(e=>e.is(o)||e.is(t)))))return t.selectStart(),!0}}if(t.$isRangeSelection(n)){const{anchor:e,focus:r}=n,s=e.getNode(),i=r.getNode(),a=ce(s),c=ce(i),d=!(!a||!o.is(ue(a))),h=!(!c||!o.is(ue(c))),g=d!==h,f=d&&h,m=n.isBackward();if(g){const e=n.clone();if(h){const[t]=M(o,c,c),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.focus.set(m?n.getKey():r.getKey(),m?n.getChildrenSize():r.getChildrenSize(),"element")}else if(d){const[t]=M(o,a,a),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.anchor.set(m?r.getKey():n.getKey(),m?r.getChildrenSize():0,"element")}t.$setSelection(e),Z(l,u)}else f&&(a.is(c)||(u.$setAnchorCellForSelection(me(u,a)),u.$setFocusCellForSelection(me(u,c),!0)))}else if(n&&F(n)&&n.is(r)&&n.tableKey===o.getKey()){const e=t.getDOMSelection(c);if(e&&e.anchorNode&&e.focusNode){const r=t.$getNearestNodeFromDOMNode(e.focusNode),s=r&&!o.isParentOf(r),i=t.$getNearestNodeFromDOMNode(e.anchorNode),a=i&&o.isParentOf(i);if(s&&a&&e.rangeCount>0){const r=t.$createRangeSelectionFromDom(e,l);r&&(r.anchor.set(o.getKey(),n.isBackward()?o.getChildrenSize():0,"element"),e.removeAllRanges(),t.$setSelection(r))}}}return n&&!n.is(r)&&(F(n)||F(r))&&u.tableSelection&&!u.tableSelection.is(r)?(F(n)&&n.tableKey===u.tableNodeKey?u.$updateTableTableSelection(n):!F(n)&&F(r)&&r.tableKey===u.tableNodeKey&&u.$updateTableTableSelection(null),!1):(u.hasHijackedSelectionStyles&&!o.isSelected()?function(e,t){t.$enableHighlightStyle(),Q(t.table,(t=>{const n=t.elem;t.highlighted=!1,ae(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(l,u):!u.hasHijackedSelectionStyles&&o.isSelected()&&Z(l,u),!1)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>{const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||!le(e,o))return!1;const n=fe(l,e,o);return!!n&&(ge(n,o),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u}function z(e){return e[L]||null}function G(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function j(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=B(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function V(e,t,n){const o=new Set(n?n.getNodes():[]);Q(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,ie(e,t)):(t.highlighted=!1,ae(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function Q(e,n){const{domRows:o}=e;for(let e=0;e<o.length;e++){const r=o[e];if(r)for(let o=0;o<r.length;o++){const l=r[o];if(!l)continue;const s=t.$getNearestNodeFromDOMNode(l.elem);null!==s&&n(l,s,{x:o,y:e})}}}function Z(e,t){t.$disableHighlightStyle(),Q(t.table,(t=>{t.highlighted=!0,ie(e,t)}))}const ee=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?se(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?se(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?se(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?se(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function te(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function ne([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function oe(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&d(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&d(250,n,String(s)),i}function re(e,t,n,o,r){const l=O(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,a=1,c=1;const u=e[r],d=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),c=Math.max(c,d[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),a=Math.max(a,e[t][o].cell.__colSpan);return{bottomSpan:c,leftSpan:i,rightSpan:a,topSpan:s}}(t,l),{topSpan:i,leftSpan:a,bottomSpan:c,rightSpan:u}=s,h=function(e,t){const n=te(e,t);return null===n&&d(249,t.cell.getKey()),n}(l,n),[g,f]=ne(h);let m=l[g],p=l[f];"forward"===r?m+="maxColumn"===g?1:a:"backward"===r?m-="minColumn"===g?1:u:"down"===r?p+="maxRow"===f?1:i:"up"===r&&(p-="minRow"===f?1:c);const C=t[p];if(void 0===C)return!1;const S=C[m];if(void 0===S)return!1;const[_,N]=function(e,t,n){const o=O(e,t,n),r=te(o,t);if(r)return[oe(e,o,r),oe(e,o,ne(r))];const l=te(o,n);if(l)return[oe(e,o,ne(l)),oe(e,o,l)];const s=["minColumn","minRow"];return[oe(e,o,s),oe(e,o,ne(s))]}(t,n,S),b=me(e,_.cell),w=me(e,N.cell);return e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(w,!0),!0}function le(e,n){if(t.$isRangeSelection(e)||F(e)){const t=n.isParentOf(e.anchor.getNode()),o=n.isParentOf(e.focus.getNode());return t&&o}return!1}function se(e,t){t?e.selectStart():e.selectEnd()}function ie(n,o){const r=o.elem,l=n._config.theme;a(t.$getNearestNodeFromDOMNode(r))||d(131),e.addClassNamesToElement(r,l.tableCellSelected)}function ae(n,o){const r=o.elem;a(t.$getNearestNodeFromDOMNode(r))||d(131);const l=n._config.theme;e.removeClassNamesFromElement(r,l.tableCellSelected)}function ce(t){const n=e.$findMatchingParent(t,a);return a(n)?n:null}function ue(t){const n=e.$findMatchingParent(t,$e);return $e(n)?n:null}function de(n,o,r,l,s){if(("up"===r||"down"===r)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(n))return!1;const i=t.$getSelection();if(!le(i,l)){if(t.$isRangeSelection(i)){if("backward"===r){if(i.focus.offset>0)return!1;const e=function(e){for(let n=e,o=e;null!==o;n=o,o=o.getParent())if(t.$isElementNode(o)){if(o!==n&&o.getFirstChild()!==n)return null;if(!o.isInline())return o}return null}(i.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!$e(n)&&(he(o),o.shiftKey?i.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(o.shiftKey&&("up"===r||"down"===r)){const n=i.focus.getNode();if(!i.isCollapsed()&&("up"===r&&!i.isBackward()||"down"===r&&i.isBackward())){let s=e.$findMatchingParent(n,(e=>$e(e)));if(a(s)&&(s=e.$findMatchingParent(s,$e)),s!==l)return!1;if(!s)return!1;const c="down"===r?s.getNextSibling():s.getPreviousSibling();if(!c)return!1;let u=0;"up"===r&&t.$isElementNode(c)&&(u=c.getChildrenSize());let d=c;if("up"===r&&t.$isElementNode(c)){const e=c.getLastChild();d=e||c,u=t.$isTextNode(d)?d.getTextContentSize():0}const h=i.clone();return h.focus.set(d.getKey(),u,t.$isTextNode(d)?"text":"element"),t.$setSelection(h),he(o),!0}if(t.$isRootOrShadowRoot(n)){const e="up"===r?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==Y(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=x(e),[o]=x(t),r=l.getCordsFromCellNode(n,s.table),i=l.getCordsFromCellNode(o,s.table),a=l.getDOMCellFromCordsOrThrow(r.x,r.y,s.table),c=l.getDOMCellFromCordsOrThrow(i.x,i.y,s.table);return s.$setAnchorCellForSelection(a),s.$setFocusCellForSelection(c,!0),!0}}return!1}{let l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(a(l)&&(l=e.$findMatchingParent(l,$e)),!l)return!1;const c="down"===r?l.getNextSibling():l.getPreviousSibling();if($e(c)&&s.tableNodeKey===c.getKey()){const e=c.getFirstDescendant(),n=c.getLastDescendant();if(!e||!n)return!1;const[l]=x(e),[s]=x(n),a=i.clone();return a.focus.set(("up"===r?l:s).getKey(),"up"===r?0:s.getChildrenSize(),"element"),he(o),t.$setSelection(a),!0}}}}return"down"===r&&be(n)&&s.setShouldCheckSelection(),!1}if(t.$isRangeSelection(i)&&i.isCollapsed()){const{anchor:c,focus:u}=i,d=e.$findMatchingParent(c.getNode(),a),h=e.$findMatchingParent(u.getNode(),a);if(!a(d)||!d.is(h))return!1;const g=ue(d);if(g!==l&&null!=g){const e=B(g,n.getElementByKey(g.getKey()));if(null!=e)return s.table=j(g,e),de(n,o,r,g,s)}if("backward"===r||"forward"===r){const n=c.type,s=c.offset,a=c.getNode();if(!a)return!1;const u=i.getNodes();return(1!==u.length||!t.$isDecoratorNode(u[0]))&&(!!function(n,o,r,l){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(n,r,l)||function(n,o,r,l){const s=e.$findMatchingParent(r,(e=>t.$isElementNode(e)&&!e.isInline()));if(!s)return!1;const i="backward"===l?0===o:o===r.getTextContentSize();return"text"===n&&i&&("backward"===l?null===s.getPreviousSibling():null===s.getNextSibling())}(n,o,r,l)}(n,s,a,r)&&function(n,o,r,l,s){const[i,a]=M(l,r,r);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(i,a,s))return!1;const c=function(n,o,r){const l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(!l)return;const s="backward"===o?l.getPreviousSibling():l.getNextSibling();return s&&$e(s)?s:"backward"===o?r.getPreviousSibling():r.getNextSibling()}(o,s,l);if(!c||$e(c))return!1;he(n),"backward"===s?c.selectEnd():c.selectStart();return!0}(o,a,d,l,r))}const f=n.getElementByKey(d.__key),m=n.getElementByKey(c.key);if(null==m||null==f)return!1;let p;if("element"===c.type)p=m.getBoundingClientRect();else{const e=t.getDOMSelection(W(n));if(null===e||0===e.rangeCount)return!1;p=e.getRangeAt(0).getBoundingClientRect()}const C="up"===r?d.getFirstChild():d.getLastChild();if(null==C)return!1;const S=n.getElementByKey(C.__key);if(null==S)return!1;const _=S.getBoundingClientRect();if("up"===r?_.top>p.top-p.height:p.bottom+p.height>_.bottom){he(o);const e=l.getCordsFromCellNode(d,s.table);if(!o.shiftKey)return ee(s,l,e.x,e.y,r);{const t=l.getDOMCellFromCordsOrThrow(e.x,e.y,s.table);s.$setAnchorCellForSelection(t),s.$setFocusCellForSelection(t,!0)}return!0}}else if(F(i)){const{anchor:t,focus:c}=i,u=e.$findMatchingParent(t.getNode(),a),h=e.$findMatchingParent(c.getNode(),a),[g]=i.getNodes();$e(g)||d(251);const f=B(g,n.getElementByKey(g.getKey()));if(!a(u)||!a(h)||!$e(g)||null==f)return!1;s.$updateTableTableSelection(i);const m=j(g,f),p=l.getCordsFromCellNode(u,m),C=l.getDOMCellFromCordsOrThrow(p.x,p.y,m);if(s.$setAnchorCellForSelection(C),he(o),o.shiftKey){const[e,t,n]=M(l,u,h);return re(s,e,t,n,r)}return h.selectEnd(),!0}return!1}function he(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function ge(e,n,o){const r=t.$createParagraphNode();"first"===e?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function fe(n,o,r){const l=r.getParent();if(!l)return;const s=t.getDOMSelection(W(n));if(!s)return;const i=s.anchorNode,c=n.getElementByKey(l.getKey()),u=B(r,n.getElementByKey(r.getKey()));if(!i||!c||!u||!c.contains(i)||u.contains(i))return;const d=e.$findMatchingParent(o.anchor.getNode(),(e=>a(e)));if(!d)return;const h=e.$findMatchingParent(d,(e=>$e(e)));if(!$e(h)||!h.is(r))return;const[g,f]=M(r,d,d),m=g[0][0],p=g[g.length-1][g[0].length-1],{startRow:C,startColumn:S}=f,_=C===m.startRow&&S===m.startColumn,N=C===p.startRow&&S===p.startColumn;return _?"first":N?"last":void 0}function me(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function pe(e,n,o){return Y(e,t.$getNearestNodeFromDOMNode(n,o))}function Ce(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function Se(t,n,o){o?(e.addClassNamesToElement(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(e.removeClassNamesFromElement(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}function _e(t,n,o){if(!n.theme.tableAlignment)return;const r=[],l=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===o?l:r).push(t)}e.removeClassNamesFromElement(t,...r),e.addClassNamesToElement(t,...l)}const Ne=new WeakSet;function be(e=t.$getEditor()){return Ne.has(e)}class we extends t.ElementNode{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new we(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:Te,priority:1})}}static importJSON(e){return ye().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&d(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(n,o){const r=document.createElement("table"),l=document.createElement("colgroup");if(r.appendChild(l),Ce(r,0,this.getColumnCount(),this.getColWidths()),t.setDOMUnmanaged(l),e.addClassNamesToElement(r,n.theme.table),_e(r,n,this.getFormatType()),this.__rowStriping&&Se(r,n,!0),be(o)){const t=document.createElement("div"),o=n.theme.tableScrollableWrapper;return o?e.addClassNamesToElement(t,o):t.style.cssText="overflow-x: auto;",t.appendChild(r),t}return r}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&Se(t,n,this.__rowStriping),Ce(t,0,this.getColumnCount(),this.getColWidths()),_e(this.getDOMSlot(t).element,n,this.getFormatType()),!1}exportDOM(t){const n=super.exportDOM(t),{element:o}=n;return{after:o=>{if(n.after&&(o=n.after(o),this.__format&&_e(o,t._config,this.getFormatType())),e.isHTMLElement(o)&&"TABLE"!==o.nodeName&&(o=o.querySelector("table")),!e.isHTMLElement(o))return null;const[r]=R(this,null,null),l=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();l.has(e)||l.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of o.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=l.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){l.delete(t);for(let e=0;e<n.colSpan;e++)s.add(e+n.startColumn)}}}const i=o.querySelector(":scope > colgroup");if(i){const e=Array.from(o.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>s.has(t)));i.replaceChildren(...e)}const a=o.querySelectorAll(":scope > tr");if(a.length>0){const e=document.createElement("tbody");for(const t of a)e.appendChild(t);o.append(e)}return o},element:e.isHTMLElement(o)&&"TABLE"!==o.nodeName?o.querySelector("table"):o}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=pe(this,l);if(null!==s&&e.is(s))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,n,o){const r=this.getDOMCellFromCords(e,n,o);if(null==r)return null;const l=t.$getNearestNodeFromDOMNode(r.elem);return a(l)?l:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{a(e)&&(t+=e.getColSpan())})),t}}function Te(t){const n=ye();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const r=t.querySelector(":scope > colgroup");if(r){let e=[];for(const t of r.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!o.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:t=>e.$descendantsMatching(t,m),node:n}}function ye(){return t.$applyNodeReplacement(new we)}function $e(e){return e instanceof we}function Me({rows:n,columns:o,includeHeaders:r}){const l=_(Number(n),Number(o),r);e.$insertNodeToNearestRoot(l);const s=l.getFirstDescendant();return t.$isTextNode(s)&&s.select(),!0}function Re(e){m(e.getParent())?e.isEmpty()&&e.append(t.$createParagraphNode()):e.remove()}function xe(t){$e(t.getParent())?e.$unwrapAndFilterDescendants(t,a):t.remove()}function Oe(n){e.$unwrapAndFilterDescendants(n,m);const[o]=R(n,null,null),r=o.reduce(((e,t)=>Math.max(e,t.length)),0),l=n.getChildren();for(let e=0;e<o.length;++e){const n=l[e];if(!n)continue;m(n)||d(254,n.constructor.name,n.getType());const s=o[e].reduce(((e,t)=>t?1+e:e),0);if(s!==r)for(let e=s;e<r;++e){const e=i();e.append(t.$createParagraphNode()),n.append(e)}}}exports.$computeTableMap=M,exports.$computeTableMapSkipCellCheck=R,exports.$createTableCellNode=i,exports.$createTableNode=ye,exports.$createTableNodeWithDimensions=_,exports.$createTableRowNode=f,exports.$createTableSelection=P,exports.$createTableSelectionFrom=D,exports.$deleteTableColumn=function(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(m(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e},exports.$deleteTableColumn__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||F(e)||d(188);const n=e.anchor.getNode(),o=e.focus.getNode(),[r,,l]=x(n),[s]=x(o),[i,a,c]=M(l,r,s),{startColumn:u}=a,{startRow:h,startColumn:g}=c,f=Math.min(u,g),m=Math.max(u+r.__colSpan-1,g+s.__colSpan-1),p=m-f+1;if(i[0].length===m-f+1)return l.selectPrevious(),void l.remove();const C=i.length;for(let e=0;e<C;e++)for(let t=f;t<=m;t++){const{cell:n,startColumn:o}=i[e][t];if(o<f){if(t===f){const e=f-o;n.setColSpan(n.__colSpan-Math.min(p,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const S=i[h],_=u>g?S[u+r.__colSpan]:S[g+s.__colSpan];if(void 0!==_){const{cell:e}=_;y(e)}else{const e=g<u?S[g-1]:S[u-1],{cell:t}=e;y(t)}const N=l.getColWidths();if(N){const e=[...N];e.splice(f,p),l.setColWidths(e)}},exports.$deleteTableRow__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||F(e)||d(188);const[n,o]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,l]=x(n),[s]=x(o),[i,a,c]=M(l,r,s),{startRow:u}=a,{startRow:h}=c,g=h+s.__rowSpan-1;if(i.length===g-u+1)return void l.remove();const f=i[0].length,p=r.__rowSpan,C=i[g+1],S=l.getChildAtIndex(g+1);for(let e=g;e>=u;e--){for(let t=f-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=i[e][t];if(r===t){if(e===u&&o<u){const e=u-o;n.setRowSpan(n.__rowSpan-Math.min(p,n.__rowSpan-e))}if(o>=u&&o+n.__rowSpan-1>g){n.setRowSpan(n.__rowSpan-(g-o+1)),null===S&&d(122);let r=null;for(let n=0;n<t;n++){const t=C[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?$(S,n):r.insertAfter(n)}}}const t=l.getChildAtIndex(e);m(t)||d(206,String(e)),t.remove()}if(void 0!==C){const{cell:e}=C[0];y(e)}else{const e=i[u-1],{cell:t}=e[0];y(t)}},exports.$findCellNode=ce,exports.$findTableNode=ue,exports.$getElementForTableNode=function(e,t){const n=e.getElementByKey(t.getKey());return null===n&&d(230),j(t,n)},exports.$getNodeTriplet=x,exports.$getTableAndElementByKey=I,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,(e=>a(e)));return a(n)?n:null},exports.$getTableCellNodeRect=E,exports.$getTableColumnIndexFromTableCellNode=function(e){return N(e).getChildren().findIndex((t=>t.is(e)))},exports.$getTableNodeFromLexicalNodeOrThrow=b,exports.$getTableRowIndexFromTableCellNode=function(e){const t=N(e);return b(t).getChildren().findIndex((e=>e.is(t)))},exports.$getTableRowNodeFromTableCellNodeOrThrow=N,exports.$insertTableColumn=function(e,n,o=!0,l,s){const c=e.getChildren(),u=[];for(let e=0;e<c.length;e++){const o=c[e];if(m(o))for(let e=0;e<l;e++){const e=o.getChildren();if(n>=e.length||n<0)throw new Error("Table column target index out of range");const l=e[n];a(l)||d(12);const{left:c,right:h}=w(l,s);let g=r.NO_STATUS;(c&&c.hasHeaderState(r.ROW)||h&&h.hasHeaderState(r.ROW))&&(g|=r.ROW);const f=i(g);f.append(t.$createParagraphNode()),u.push({newTableCell:f,targetCell:l})}}return u.forEach((({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)})),e},exports.$insertTableColumn__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||F(n)||d(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[s]=x(o),[a,,c]=x(l),[u,h,g]=M(c,a,s),f=u.length,p=e?Math.max(h.startColumn,g.startColumn):Math.min(h.startColumn,g.startColumn),C=e?p+a.__colSpan-1:p-1,S=c.getFirstChild();m(S)||d(120);let _=null;function N(e=r.NO_STATUS){const n=i(e).append(t.$createParagraphNode());return null===_&&(_=n),n}let b=S;e:for(let e=0;e<f;e++){if(0!==e){const e=b.getNextSibling();m(e)||d(121),b=e}const t=u[e],n=t[C<0?0:C].cell.__headerState,o=T(n,r.ROW);if(C<0){$(b,N(o));continue}const{cell:l,startColumn:s,startRow:i}=t[C];if(s+l.__colSpan-1<=C){let n=l,r=i,s=C;for(;r!==e&&n.__rowSpan>1;){if(s-=l.__colSpan,!(s>=0)){b.append(N(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o}}n.insertAfter(N(o))}else l.setColSpan(l.__colSpan+1)}null!==_&&y(_);const w=c.getColWidths();if(w){const e=[...w],t=C<0?0:C,n=e[t];e.splice(t,0,n),c.setColWidths(e)}return _},exports.$insertTableRow=function(e,n,o=!0,l,s){const c=e.getChildren();if(n>=c.length||n<0)throw new Error("Table row target index out of range");const u=c[n];if(!m(u))throw new Error("Row before insertion index does not exist.");for(let e=0;e<l;e++){const e=u.getChildren(),n=e.length,l=f();for(let o=0;o<n;o++){const n=e[o];a(n)||d(12);const{above:c,below:u}=w(n,s);let h=r.NO_STATUS;const g=c&&c.getWidth()||u&&u.getWidth()||void 0;(c&&c.hasHeaderState(r.COLUMN)||u&&u.hasHeaderState(r.COLUMN))&&(h|=r.COLUMN);const f=i(h,1,g);f.append(t.$createParagraphNode()),l.append(f)}o?u.insertAfter(l):u.insertBefore(l)}return e},exports.$insertTableRow__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||F(n)||d(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[s]=x(o),[a,,c]=x(l),[u,h,g]=M(c,a,s),p=u[0].length,{startRow:C}=g,{startRow:S}=h;let _=null;if(e){const e=Math.max(S+a.__rowSpan,C+s.__rowSpan)-1,n=u[e],o=f();for(let l=0;l<p;l++){const{cell:s,startRow:a}=n[l];if(a+s.__rowSpan-1<=e){const e=n[l].cell.__headerState,s=T(e,r.COLUMN);o.append(i(s).append(t.$createParagraphNode()))}else s.setRowSpan(s.__rowSpan+1)}const l=c.getChildAtIndex(e);m(l)||d(256),l.insertAfter(o),_=o}else{const e=Math.min(S,C),n=u[e],o=f();for(let l=0;l<p;l++){const{cell:s,startRow:a}=n[l];if(a===e){const e=n[l].cell.__headerState,s=T(e,r.COLUMN);o.append(i(s).append(t.$createParagraphNode()))}else s.setRowSpan(s.__rowSpan+1)}const l=c.getChildAtIndex(e);m(l)||d(257),l.insertBefore(o),_=o}return _},exports.$isScrollableTablesActive=be,exports.$isTableCellNode=a,exports.$isTableNode=$e,exports.$isTableRowNode=m,exports.$isTableSelection=F,exports.$removeTableRowAtIndex=function(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e},exports.$unmergeCell=function(){const e=t.$getSelection();t.$isRangeSelection(e)||F(e)||d(188);const n=e.anchor.getNode(),[o,l,s]=x(n),a=o.__colSpan,c=o.__rowSpan;if(1===a&&1===c)return;const[u,h]=M(s,o,o),{startColumn:g,startRow:f}=h,p=o.__headerState&r.COLUMN,C=Array.from({length:a},((e,t)=>{let n=p;for(let e=0;0!==n&&e<u.length;e++)n&=u[e][t+g].cell.__headerState;return n})),S=o.__headerState&r.ROW,_=Array.from({length:c},((e,t)=>{let n=S;for(let e=0;0!==n&&e<u[0].length;e++)n&=u[t+f][e].cell.__headerState;return n}));if(a>1){for(let e=1;e<a;e++)o.insertAfter(i(C[e]|_[0]).append(t.$createParagraphNode()));o.setColSpan(1)}if(c>1){let e;for(let n=1;n<c;n++){const o=f+n,r=u[o];e=(e||l).getNextSibling(),m(e)||d(125);let s=null;for(let e=0;e<g;e++){const t=r[e],n=t.cell;t.startRow===o&&(s=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===s)for(let o=a-1;o>=0;o--)$(e,i(C[o]|_[n]).append(t.$createParagraphNode()));else for(let e=a-1;e>=0;e--)s.insertAfter(i(C[e]|_[n]).append(t.$createParagraphNode()))}o.setRowSpan(1)}},exports.INSERT_TABLE_COMMAND=c,exports.TableCellHeaderStates=r,exports.TableCellNode=l,exports.TableNode=we,exports.TableObserver=k,exports.TableRowNode=h,exports.applyTableHandlers=q,exports.getDOMCellFromTarget=G,exports.getTableElement=B,exports.getTableObserverFromTableElement=z,exports.registerTableCellUnmergeTransform=function(t){return t.registerNodeTransform(l,(t=>{if(t.getColSpan()>1||t.getRowSpan()>1){const[,,n]=x(t),[o]=M(n,t,t),r=o.length,l=o[0].length;let s=n.getFirstChild();m(s)||d(175);const c=[];for(let t=0;t<r;t++){0!==t&&(s=s.getNextSibling(),m(s)||d(175));let n=null;for(let r=0;r<l;r++){const l=o[t][r],u=l.cell;if(l.startRow===t&&l.startColumn===r)n=u,c.push(u);else if(u.getColSpan()>1||u.getRowSpan()>1){a(u)||d(176);const t=i(u.__headerState);null!==n?n.insertAfter(t):e.$insertFirst(s,t)}}}for(const e of c)e.setColSpan(1),e.setRowSpan(1)}}))},exports.registerTablePlugin=function(n){return n.hasNodes([we])||d(255),e.mergeRegister(n.registerCommand(c,Me,t.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(we,Oe),n.registerNodeTransform(h,xe),n.registerNodeTransform(l,Re))},exports.registerTableSelectionObserver=function(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=B(o,l),i=q(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(we,(t=>{e.getEditorState().read((()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=I(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}},exports.setScrollableTablesActive=function(e,t){t?Ne.add(e):Ne.delete(e)};
9
+ "use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/clipboard");const o=/^(\d+(?:\.\d+)?)px$/,r={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class l extends t.ElementNode{static getType(){return"tablecell"}static clone(e){return new l(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:s,priority:0}),th:e=>({conversion:s,priority:0})}}static importJSON(e){return a().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=r.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),i(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const n=super.exportDOM(e);if(t.isHTMLElement(n.element)){const e=n.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return n}exportJSON(){return{...super.exportJSON(),...i(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=r.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==r.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function i(e){return"middle"===e||"bottom"===e}function s(e){const n=e,l=e.nodeName.toLowerCase();let s;o.test(n.style.width)&&(s=parseFloat(n.style.width));const u=a("th"===l?r.ROW:r.NO_STATUS,n.colSpan,s);u.__rowSpan=n.rowSpan;const d=n.style.backgroundColor;""!==d&&(u.__backgroundColor=d);const h=n.style.verticalAlign;i(h)&&(u.__verticalAlign=h);const g=n.style,f=(g&&g.textDecoration||"").split(" "),m="700"===g.fontWeight||"bold"===g.fontWeight,p=f.includes("line-through"),C="italic"===g.fontStyle,S=f.includes("underline");return{after:e=>(0===e.length&&e.push(t.$createParagraphNode()),e),forChild:(e,n)=>{if(c(n)&&!t.$isElementNode(e)){const n=t.$createParagraphNode();return t.$isLineBreakNode(e)&&"\n"===e.getTextContent()?null:(t.$isTextNode(e)&&(m&&e.toggleFormat("bold"),p&&e.toggleFormat("strikethrough"),C&&e.toggleFormat("italic"),S&&e.toggleFormat("underline")),n.append(e),n)}return e},node:u}}function a(e=r.NO_STATUS,n=1,o){return t.$applyNodeReplacement(new l(e,n,o))}function c(e){return e instanceof l}const u=t.createCommand("INSERT_TABLE_COMMAND");function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h=d((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class g extends t.ElementNode{static getType(){return"tablerow"}static clone(e){return new g(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:f,priority:0})}}static importJSON(e){return m().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e.addClassNamesToElement(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function f(t){const n=t;let r;return o.test(n.style.height)&&(r=parseFloat(n.style.height)),{after:t=>e.$descendantsMatching(t,c),node:m(r)}}function m(e){return t.$applyNodeReplacement(new g(e))}function p(e){return e instanceof g}const C="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,S=C&&"documentMode"in document?document.documentMode:null,_=C&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function N(e,n,o=!0){const l=$e();for(let i=0;i<e;i++){const e=m();for(let l=0;l<n;l++){let n=r.NO_STATUS;"object"==typeof o?(0===i&&o.rows&&(n|=r.ROW),0===l&&o.columns&&(n|=r.COLUMN)):o&&(0===i&&(n|=r.ROW),0===l&&(n|=r.COLUMN));const s=a(n),c=t.$createParagraphNode();c.append(t.$createTextNode()),s.append(c),e.append(s)}l.append(e)}return l}function b(t){const n=e.$findMatchingParent(t,(e=>p(e)));if(p(n))return n;throw new Error("Expected table cell to be inside of table row.")}function w(t){const n=e.$findMatchingParent(t,(e=>Me(e)));if(Me(n))return n;throw new Error("Expected table cell to be inside of table.")}function T(e,t){const n=w(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}C&&"InputEvent"in window&&!S&&new window.InputEvent("input");const y=(e,t)=>e===r.BOTH||e===t?t:r.NO_STATUS;function $(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function M(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function R(e,t,n){const[o,r,l]=x(e,t,n);return null===r&&h(207),null===l&&h(208),[o,r,l]}function x(e,t,n){const o=[];let r=null,l=null;function i(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const s=e.getChildren();for(let e=0;e<s.length;e++){const o=s[e];p(o)||h(209);const a=i(e);for(let u=o.getFirstChild(),d=0;null!=u;u=u.getNextSibling()){for(c(u)||h(147);void 0!==a[d];)d++;const o={cell:u,startColumn:d,startRow:e},{__rowSpan:g,__colSpan:f}=u;for(let t=0;t<g&&!(e+t>=s.length);t++){const n=i(e+t);for(let e=0;e<f;e++)n[d+e]=o}null!==t&&null===r&&t.is(u)&&(r=o),null!==n&&null===l&&n.is(u)&&(l=o)}}return[o,r,l]}function O(t){let n;if(t instanceof l)n=t;else if("__type"in t){const o=e.$findMatchingParent(t,c);c(o)||h(148),n=o}else{const o=e.$findMatchingParent(t.getNode(),c);c(o)||h(148),n=o}const o=n.getParent();p(o)||h(149);const r=o.getParent();return Me(r)||h(210),[n,o,r]}function E(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),i=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),s=o,a=r,c=o,u=r;function d(e){const{cell:t,startColumn:n,startRow:s}=e;o=Math.min(o,n),r=Math.min(r,s),l=Math.max(l,n+t.__colSpan-1),i=Math.max(i,s+t.__rowSpan-1)}for(;o<s||r<a||l>c||i>u;){if(o<s){const t=u-a,n=s-1;for(let o=0;o<=t;o++)d(e[a+o][n]);s=n}if(r<a){const t=c-s,n=a-1;for(let o=0;o<=t;o++)d(e[n][s+o]);a=n}if(l>c){const t=u-a,n=c+1;for(let o=0;o<=t;o++)d(e[a+o][n]);c=n}if(i>u){const t=c-s,n=u+1;for(let o=0;o<=t;o++)d(e[n][s+o]);u=n}}return{maxColumn:l,maxRow:i,minColumn:o,minRow:r}}function A(e){const[t,,n]=O(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,i=new Array(r);for(let e=0;e<r;e++)i[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;i[e][r];)r++;const l=n[o],s=l.__rowSpan||1,a=l.__colSpan||1;for(let t=0;t<s;t++)for(let n=0;n<a;n++)i[e+t][r+n]=l;if(t===l)return{colSpan:a,columnIndex:r,rowIndex:e,rowSpan:s};r+=a}}return null}function v(t){const[[n,o,r,l],[i,s,a,u]]=["anchor","focus"].map((n=>{const o=t[n].getNode(),r=e.$findMatchingParent(o,c);c(r)||h(238,n,o.getKey(),o.getType());const l=r.getParent();p(l)||h(239,n);const i=l.getParent();return Me(i)||h(240,n),[o,r,l,i]}));return l.is(u)||h(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:s,focusNode:i,focusRow:a,focusTable:u}}class F{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return P(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new F(this.tableKey,t.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),t.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let n=0;this.getNodes().filter(c).forEach((e=>{const o=e.getFirstChild();t.$isParagraphNode(o)&&(n|=o.getTextFormat())}));const o=t.TEXT_TYPE_TO_FORMAT[e];return!!(n&o)}insertNodes(e){const n=this.focus.getNode();t.$isElementNode(n)||h(151);t.$normalizeSelection__EXPERIMENTAL(n.select(0,n.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=v(this),n=A(e);null===n&&h(153);const o=A(t);null===o&&h(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),i=Math.min(n.rowIndex,o.rowIndex),s=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(i,s),toX:Math.max(r,l),toY:Math.max(i,s)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:n,anchorCell:o,focusCell:r}=v(this),l=r.getParents()[1];if(l!==n){if(n.isParentOf(r)){const e=l.getParent();null==e&&h(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=n.getParent();null==e&&h(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}const[i,s,a]=R(n,o,r),{minColumn:c,maxColumn:u,minRow:d,maxRow:g}=E(i,s,a),f=new Map([[n.getKey(),n]]);let m=null;for(let e=d;e<=g;e++)for(let t=c;t<=u;t++){const{cell:n}=i[e][t],o=n.getParent();p(o)||h(160),o!==m&&(f.set(o.getKey(),o),m=o),f.has(n.getKey())||I(n,(e=>{f.set(e.getKey(),e)}))}const C=Array.from(f.values());return t.isCurrentlyReadOnlyMode()||(this._cachedNodes=C),C}getTextContent(){const e=this.getNodes().filter((e=>c(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function P(e){return e instanceof F}function D(){const e=t.$createPoint("root",0,"element"),n=t.$createPoint("root",0,"element");return new F("root",e,n)}function K(e,n,o){e.getKey(),n.getKey(),o.getKey();const r=t.$getSelection(),l=P(r)?r.clone():D();return l.set(e.getKey(),n.getKey(),o.getKey()),l}function I(e,n){const o=[[e]];for(let e=o.at(-1);void 0!==e&&o.length>0;e=o.at(-1)){const r=e.pop();void 0===r?o.pop():!1!==n(r)&&t.$isElementNode(r)&&o.push(r.getChildren())}}function k(e,n=t.$getEditor()){const o=t.$getNodeByKey(e);Me(o)||h(231,e);const r=B(o,n.getElementByKey(e));return null===r&&h(232,e),{tableElement:r,tableNode:o}}class L{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return k(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=V(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=V(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:n,tableElement:o}=this.$lookup();Q(e,V(n,o),null),null!==t.$getSelection()&&(t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))}$enableHighlightStyle(){const t=this.editor,{tableElement:n}=this.$lookup();e.removeClassNamesFromElement(n,t._config.theme.tableSelection),n.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e.addClassNamesToElement(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&h(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Q(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=t.getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,n=!1){const o=this.editor,{tableNode:r}=this.$lookup(),l=e.x,i=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===l&&this.anchorY===i&&!n){if(l===this.focusX&&i===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=l,this.focusY=i,this.isHighlightingCells){const n=Ce(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==n)return this.focusCellNodeKey=n.getKey(),this.tableSelection=K(r,this.$getAnchorTableCellOrThrow(),n),t.$setSelection(this.tableSelection),o.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0),Q(o,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?t.$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&h(234),e}$getFocusTableCell(){return this.focusCellNodeKey?t.$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&h(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=Ce(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():D(),this.anchorCellNodeKey=e}}$formatCells(e){const n=t.$getSelection();P(n)||h(236);const o=t.$createRangeSelection(),r=o.anchor,l=o.focus,i=n.getNodes().filter(c);i.length>0||h(237);const s=i[0].getFirstChild(),a=t.$isParagraphNode(s)?s.getFormatFlags(e,null):null;i.forEach((t=>{r.set(t.getKey(),0,"element"),l.set(t.getKey(),t.getChildrenSize(),"element"),o.formatText(e,a)})),t.$setSelection(n),this.editor.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:e}=this,n=t.$getNodeByKey(this.tableNodeKey);if(!Me(n))throw new Error("Expected TableNode.");const o=t.$getSelection();P(o)||h(253);const r=o.getNodes().filter(c);if(r.length===this.table.columns*this.table.rows)return n.selectPrevious(),void n.remove();r.forEach((e=>{if(t.$isElementNode(e)){const n=t.$createParagraphNode(),o=t.$createTextNode();n.append(o),e.append(n),e.getChildren().forEach((e=>{e!==n&&e.remove()}))}})),Q(e,this.table,null),t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}}const H="__lexicalTableSelection",W=e=>!(1&~e.buttons);function B(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&h(245,t.nodeName),n}function Y(e){return e._window}function U(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;c(n)&&(o=n)}return null}const X=[[t.KEY_ARROW_DOWN_COMMAND,"down"],[t.KEY_ARROW_UP_COMMAND,"up"],[t.KEY_ARROW_LEFT_COMMAND,"backward"],[t.KEY_ARROW_RIGHT_COMMAND,"forward"]],J=[t.DELETE_WORD_COMMAND,t.DELETE_LINE_COMMAND,t.DELETE_CHARACTER_COMMAND],q=[t.KEY_BACKSPACE_COMMAND,t.KEY_DELETE_COMMAND];function z(o,r,l,i){const s=l.getRootElement(),a=Y(l);null!==s&&null!==a||h(246);const u=new L(l,o.getKey()),d=B(o,r);!function(e,t){null!==G(e)&&h(205);e[H]=t}(d,u),u.listenersToRemove.add((()=>function(e,t){G(e)===t&&delete e[H]}(d,u)));d.addEventListener("mousedown",(e=>{if(0!==e.button||!t.isDOMNode(e.target)||!a)return;const n=j(e.target);null!==n&&l.update((()=>{const r=t.$getPreviousSelection();if(_&&e.shiftKey&&ie(r,o)&&(t.$isRangeSelection(r)||P(r))){const t=r.anchor.getNode(),l=U(o,r.anchor.getNode());if(l)u.$setAnchorCellForSelection(pe(u,l)),u.$setFocusCellForSelection(n),ge(e);else{(o.isBefore(t)?o.selectStart():o.selectEnd()).anchor.set(r.anchor.key,r.anchor.offset,r.anchor.type)}}else u.$setAnchorCellForSelection(n)})),(()=>{if(u.isSelecting)return;const e=()=>{u.isSelecting=!1,a.removeEventListener("mouseup",e),a.removeEventListener("mousemove",n)},n=o=>{if(!t.isDOMNode(o.target))return;if(!W(o)&&u.isSelecting)return u.isSelecting=!1,a.removeEventListener("mouseup",e),void a.removeEventListener("mousemove",n);const r=!d.contains(o.target);let i=null;if(r){for(const e of document.elementsFromPoint(o.clientX,o.clientY))if(i=d.contains(e)?j(e):null,i)break}else i=j(o.target);!i||null!==u.focusCell&&i.elem===u.focusCell.elem||(u.setNextFocus({focusCell:i,override:r}),l.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))};u.isSelecting=!0,a.addEventListener("mouseup",e,u.listenerOptions),a.addEventListener("mousemove",n,u.listenerOptions)})()}),u.listenerOptions);a.addEventListener("mousedown",(e=>{const n=e.target;0===e.button&&t.isDOMNode(n)&&l.update((()=>{const e=t.$getSelection();P(e)&&e.tableKey===u.tableNodeKey&&s.contains(n)&&u.$clearHighlight()}))}),u.listenerOptions);for(const[e,n]of X)u.listenersToRemove.add(l.registerCommand(e,(e=>he(l,e,n,o,u)),t.COMMAND_PRIORITY_HIGH));u.listenersToRemove.add(l.registerCommand(t.KEY_ESCAPE_COMMAND,(e=>{const n=t.$getSelection();if(P(n)){const t=U(o,n.focus.getNode());if(null!==t)return ge(e),t.selectEnd(),!0}return!1}),t.COMMAND_PRIORITY_HIGH));const g=n=>()=>{const r=t.$getSelection();if(!ie(r,o))return!1;if(P(r))return u.$clearText(),!0;if(t.$isRangeSelection(r)){if(!c(U(o,r.anchor.getNode())))return!1;const l=r.anchor.getNode(),i=r.focus.getNode(),s=o.isParentOf(l),a=o.isParentOf(i);if(s&&!a||a&&!s)return u.$clearText(),!0;const d=e.$findMatchingParent(r.anchor.getNode(),(e=>t.$isElementNode(e))),h=d&&e.$findMatchingParent(d,(e=>t.$isElementNode(e)&&c(e.getParent())));if(!t.$isElementNode(h)||!t.$isElementNode(d))return!1;if(n===t.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return!0}return!1};for(const e of J)u.listenersToRemove.add(l.registerCommand(e,g(e),t.COMMAND_PRIORITY_CRITICAL));const f=e=>{const n=t.$getSelection();if(!P(n)&&!t.$isRangeSelection(n))return!1;const r=o.isParentOf(n.anchor.getNode());if(r!==o.isParentOf(n.focus.getNode())){const e=r?"anchor":"focus",t=r?"focus":"anchor",{key:l,offset:i,type:s}=n[t];return o[n[e].isBefore(n[t])?"selectPrevious":"selectNext"]()[t].set(l,i,s),!1}return!!ie(n,o)&&(!!P(n)&&(e&&(e.preventDefault(),e.stopPropagation()),u.$clearText(),!0))};for(const e of q)u.listenersToRemove.add(l.registerCommand(e,f,t.COMMAND_PRIORITY_CRITICAL));return u.listenersToRemove.add(l.registerCommand(t.CUT_COMMAND,(o=>{const r=t.$getSelection();if(r){if(!P(r)&&!t.$isRangeSelection(r))return!1;n.copyToClipboard(l,e.objectKlassEquals(o,ClipboardEvent)?o:null,n.$getClipboardDataFromSelection(r));const i=f(o);return t.$isRangeSelection(r)?(r.removeText(),!0):i}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_TEXT_COMMAND,(n=>{const r=t.$getSelection();if(!ie(r,o))return!1;if(P(r))return u.$formatCells(n),!0;if(t.$isRangeSelection(r)){const t=e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)));if(!c(t))return!1}return!1}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FORMAT_ELEMENT_COMMAND,(e=>{const n=t.$getSelection();if(!P(n)||!ie(n,o))return!1;const r=n.anchor.getNode(),l=n.focus.getNode();if(!c(r)||!c(l))return!1;if(function(e,t){if(P(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=R(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,o))return o.setFormat(e),!0;const[i,s,a]=R(o,r,l),u=Math.max(s.startRow+s.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),d=Math.max(s.startColumn+s.cell.__colSpan-1,a.startColumn+a.cell.__colSpan-1),h=Math.min(s.startRow,a.startRow),g=Math.min(s.startColumn,a.startColumn),f=new Set;for(let n=h;n<=u;n++)for(let o=g;o<=d;o++){const r=i[n][o].cell;if(f.has(r))continue;f.add(r),r.setFormat(e);const l=r.getChildren();for(let n=0;n<l.length;n++){const o=l[n];t.$isElementNode(o)&&!o.isInline()&&o.setFormat(e)}}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.CONTROLLED_TEXT_INSERTION_COMMAND,(n=>{const r=t.$getSelection();if(!ie(r,o))return!1;if(P(r))return u.$clearHighlight(),!1;if(t.$isRangeSelection(r)){const i=e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)));if(!c(i))return!1;if("string"==typeof n){const e=me(l,r,o);if(e)return fe(e,o,[t.$createTextNode(n)]),!0}}return!1}),t.COMMAND_PRIORITY_CRITICAL)),i&&u.listenersToRemove.add(l.registerCommand(t.KEY_TAB_COMMAND,(n=>{const r=t.$getSelection();if(!t.$isRangeSelection(r)||!r.isCollapsed()||!ie(r,o))return!1;const l=ue(r.anchor.getNode());return!(null===l||!o.is(de(l)))&&(ge(n),function(n,o){const r="next"===o?"getNextSibling":"getPreviousSibling",l="next"===o?"getFirstChild":"getLastChild",i=n[r]();if(t.$isElementNode(i))return i.selectEnd();const s=e.$findMatchingParent(n,p);null===s&&h(247);for(let e=s[r]();p(e);e=e[r]()){const n=e[l]();if(t.$isElementNode(n))return n.selectEnd()}const a=e.$findMatchingParent(s,Me);null===a&&h(248);"next"===o?a.selectNext():a.selectPrevious()}(l,n.shiftKey?"previous":"next"),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.FOCUS_COMMAND,(e=>o.isSelected()),t.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(n=>{const{nodes:o,selection:r}=n,l=r.getStartEndPoints(),i=P(r),s=t.$isRangeSelection(r)&&null!==e.$findMatchingParent(r.anchor.getNode(),(e=>c(e)))&&null!==e.$findMatchingParent(r.focus.getNode(),(e=>c(e)))||i;if(1!==o.length||!Me(o[0])||!s||null===l)return!1;const[a]=l,u=o[0],d=u.getChildren(),h=u.getFirstChildOrThrow().getChildrenSize(),g=u.getChildrenSize(),f=e.$findMatchingParent(a.getNode(),(e=>c(e))),m=f&&e.$findMatchingParent(f,(e=>p(e))),C=m&&e.$findMatchingParent(m,(e=>Me(e)));if(!c(f)||!p(m)||!Me(C))return!1;const S=m.getIndexWithinParent(),_=Math.min(C.getChildrenSize()-1,S+g-1),N=f.getIndexWithinParent(),b=Math.min(m.getChildrenSize()-1,N+h-1),w=Math.min(N,b),T=Math.min(S,_),y=Math.max(N,b),$=Math.max(S,_),M=C.getChildren();let R=0;for(let e=T;e<=$;e++){const n=M[e];if(!p(n))return!1;const o=d[R];if(!p(o))return!1;const r=n.getChildren(),l=o.getChildren();let i=0;for(let e=w;e<=y;e++){const n=r[e];if(!c(n))return!1;const o=l[i];if(!c(o))return!1;const s=n.getChildren();o.getChildren().forEach((e=>{if(t.$isTextNode(e)){t.$createParagraphNode().append(e),n.append(e)}else n.append(e)})),s.forEach((e=>e.remove())),i++}R++}return!0}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.SELECTION_CHANGE_COMMAND,(()=>{const n=t.$getSelection(),r=t.$getPreviousSelection(),i=u.getAndClearNextFocus();if(null!==i){const{focusCell:e}=i;if(P(n)&&n.tableKey===u.tableNodeKey)return(e.x!==u.focusX||e.y!==u.focusY)&&(u.$setFocusCellForSelection(e),!0);if(e!==u.anchorCell&&ie(n,o))return u.$setFocusCellForSelection(e),!0}if(u.getAndClearShouldCheckSelection()&&t.$isRangeSelection(r)&&t.$isRangeSelection(n)&&n.isCollapsed()){const t=n.anchor.getNode(),r=o.getFirstChild(),l=ue(t);if(null!==l&&p(r)){const t=r.getFirstChild();if(c(t)&&o.is(e.$findMatchingParent(l,(e=>e.is(o)||e.is(t)))))return t.selectStart(),!0}}if(t.$isRangeSelection(n)){const{anchor:e,focus:r}=n,i=e.getNode(),s=r.getNode(),a=ue(i),c=ue(s),d=!(!a||!o.is(de(a))),h=!(!c||!o.is(de(c))),g=d!==h,f=d&&h,m=n.isBackward();if(g){const e=n.clone();if(h){const[t]=R(o,c,c),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.focus.set(m?n.getKey():r.getKey(),m?n.getChildrenSize():r.getChildrenSize(),"element")}else if(d){const[t]=R(o,a,a),n=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.anchor.set(m?r.getKey():n.getKey(),m?r.getChildrenSize():0,"element")}t.$setSelection(e),ee(l,u)}else f&&(a.is(c)||(u.$setAnchorCellForSelection(pe(u,a)),u.$setFocusCellForSelection(pe(u,c),!0)))}else if(n&&P(n)&&n.is(r)&&n.tableKey===o.getKey()){const e=t.getDOMSelection(a);if(e&&e.anchorNode&&e.focusNode){const r=t.$getNearestNodeFromDOMNode(e.focusNode),i=r&&!o.isParentOf(r),s=t.$getNearestNodeFromDOMNode(e.anchorNode),a=s&&o.isParentOf(s);if(i&&a&&e.rangeCount>0){const r=t.$createRangeSelectionFromDom(e,l);r&&(r.anchor.set(o.getKey(),n.isBackward()?o.getChildrenSize():0,"element"),e.removeAllRanges(),t.$setSelection(r))}}}return n&&!n.is(r)&&(P(n)||P(r))&&u.tableSelection&&!u.tableSelection.is(r)?(P(n)&&n.tableKey===u.tableNodeKey?u.$updateTableTableSelection(n):!P(n)&&P(r)&&r.tableKey===u.tableNodeKey&&u.$updateTableTableSelection(null),!1):(u.hasHijackedSelectionStyles&&!o.isSelected()?function(e,t){t.$enableHighlightStyle(),Z(t.table,(t=>{const n=t.elem;t.highlighted=!1,ce(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(l,u):!u.hasHijackedSelectionStyles&&o.isSelected()&&ee(l,u),!1)}),t.COMMAND_PRIORITY_CRITICAL)),u.listenersToRemove.add(l.registerCommand(t.INSERT_PARAGRAPH_COMMAND,(()=>{const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||!ie(e,o))return!1;const n=me(l,e,o);return!!n&&(fe(n,o),!0)}),t.COMMAND_PRIORITY_CRITICAL)),u}function G(e){return e[H]||null}function j(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function V(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=B(e,t).querySelector("tr"),l=0,i=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:i};r._cell=e;let t=n[i];void 0===t&&(t=n[i]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;i++,l=0,r=e}}return o.columns=l+1,o.rows=i+1,o}function Q(e,t,n){const o=new Set(n?n.getNodes():[]);Z(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,ae(e,t)):(t.highlighted=!1,ce(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function Z(e,n){const{domRows:o}=e;for(let e=0;e<o.length;e++){const r=o[e];if(r)for(let o=0;o<r.length;o++){const l=r[o];if(!l)continue;const i=t.$getNearestNodeFromDOMNode(l.elem);null!==i&&n(l,i,{x:o,y:e})}}}function ee(e,t){t.$disableHighlightStyle(),Z(t.table,(t=>{t.highlighted=!0,ae(e,t)}))}const te=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?se(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?se(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?se(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?se(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function ne(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function oe([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function re(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&h(250,o,String(r));const i=t[n],s=l[i];return void 0===s&&h(250,n,String(i)),s}function le(e,t,n,o,r){const l=E(t,n,o),i=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let i=1,s=1,a=1,c=1;const u=e[r],d=e[l];for(let e=n;e<=o;e++)i=Math.max(i,u[e].cell.__rowSpan),c=Math.max(c,d[e].cell.__rowSpan);for(let t=r;t<=l;t++)s=Math.max(s,e[t][n].cell.__colSpan),a=Math.max(a,e[t][o].cell.__colSpan);return{bottomSpan:c,leftSpan:s,rightSpan:a,topSpan:i}}(t,l),{topSpan:s,leftSpan:a,bottomSpan:c,rightSpan:u}=i,d=function(e,t){const n=ne(e,t);return null===n&&h(249,t.cell.getKey()),n}(l,n),[g,f]=oe(d);let m=l[g],p=l[f];"forward"===r?m+="maxColumn"===g?1:a:"backward"===r?m-="minColumn"===g?1:u:"down"===r?p+="maxRow"===f?1:s:"up"===r&&(p-="minRow"===f?1:c);const C=t[p];if(void 0===C)return!1;const S=C[m];if(void 0===S)return!1;const[_,N]=function(e,t,n){const o=E(e,t,n),r=ne(o,t);if(r)return[re(e,o,r),re(e,o,oe(r))];const l=ne(o,n);if(l)return[re(e,o,oe(l)),re(e,o,l)];const i=["minColumn","minRow"];return[re(e,o,i),re(e,o,oe(i))]}(t,n,S),b=pe(e,_.cell),w=pe(e,N.cell);return e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(w,!0),!0}function ie(e,n){if(t.$isRangeSelection(e)||P(e)){const t=n.isParentOf(e.anchor.getNode()),o=n.isParentOf(e.focus.getNode());return t&&o}return!1}function se(e,t){t?e.selectStart():e.selectEnd()}function ae(n,o){const r=o.elem,l=n._config.theme;c(t.$getNearestNodeFromDOMNode(r))||h(131),e.addClassNamesToElement(r,l.tableCellSelected)}function ce(n,o){const r=o.elem;c(t.$getNearestNodeFromDOMNode(r))||h(131);const l=n._config.theme;e.removeClassNamesFromElement(r,l.tableCellSelected)}function ue(t){const n=e.$findMatchingParent(t,c);return c(n)?n:null}function de(t){const n=e.$findMatchingParent(t,Me);return Me(n)?n:null}function he(n,o,r,l,i){if(("up"===r||"down"===r)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(n))return!1;const s=t.$getSelection();if(!ie(s,l)){if(t.$isRangeSelection(s)){if("backward"===r){if(s.focus.offset>0)return!1;const e=function(e){for(let n=e,o=e;null!==o;n=o,o=o.getParent())if(t.$isElementNode(o)){if(o!==n&&o.getFirstChild()!==n)return null;if(!o.isInline())return o}return null}(s.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!Me(n)&&(ge(o),o.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(o.shiftKey&&("up"===r||"down"===r)){const n=s.focus.getNode();if(!s.isCollapsed()&&("up"===r&&!s.isBackward()||"down"===r&&s.isBackward())){let i=e.$findMatchingParent(n,(e=>Me(e)));if(c(i)&&(i=e.$findMatchingParent(i,Me)),i!==l)return!1;if(!i)return!1;const a="down"===r?i.getNextSibling():i.getPreviousSibling();if(!a)return!1;let u=0;"up"===r&&t.$isElementNode(a)&&(u=a.getChildrenSize());let d=a;if("up"===r&&t.$isElementNode(a)){const e=a.getLastChild();d=e||a,u=t.$isTextNode(d)?d.getTextContentSize():0}const h=s.clone();return h.focus.set(d.getKey(),u,t.$isTextNode(d)?"text":"element"),t.$setSelection(h),ge(o),!0}if(t.$isRootOrShadowRoot(n)){const e="up"===r?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==U(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=O(e),[o]=O(t),r=l.getCordsFromCellNode(n,i.table),s=l.getCordsFromCellNode(o,i.table),a=l.getDOMCellFromCordsOrThrow(r.x,r.y,i.table),c=l.getDOMCellFromCordsOrThrow(s.x,s.y,i.table);return i.$setAnchorCellForSelection(a),i.$setFocusCellForSelection(c,!0),!0}}return!1}{let l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(c(l)&&(l=e.$findMatchingParent(l,Me)),!l)return!1;const a="down"===r?l.getNextSibling():l.getPreviousSibling();if(Me(a)&&i.tableNodeKey===a.getKey()){const e=a.getFirstDescendant(),n=a.getLastDescendant();if(!e||!n)return!1;const[l]=O(e),[i]=O(n),c=s.clone();return c.focus.set(("up"===r?l:i).getKey(),"up"===r?0:i.getChildrenSize(),"element"),ge(o),t.$setSelection(c),!0}}}}return"down"===r&&we(n)&&i.setShouldCheckSelection(),!1}if(t.$isRangeSelection(s)&&s.isCollapsed()){const{anchor:a,focus:u}=s,d=e.$findMatchingParent(a.getNode(),c),h=e.$findMatchingParent(u.getNode(),c);if(!c(d)||!d.is(h))return!1;const g=de(d);if(g!==l&&null!=g){const e=B(g,n.getElementByKey(g.getKey()));if(null!=e)return i.table=V(g,e),he(n,o,r,g,i)}if("backward"===r||"forward"===r){const n=a.type,i=a.offset,c=a.getNode();if(!c)return!1;const u=s.getNodes();return(1!==u.length||!t.$isDecoratorNode(u[0]))&&(!!function(n,o,r,l){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(n,r,l)||function(n,o,r,l){const i=e.$findMatchingParent(r,(e=>t.$isElementNode(e)&&!e.isInline()));if(!i)return!1;const s="backward"===l?0===o:o===r.getTextContentSize();return"text"===n&&s&&("backward"===l?null===i.getPreviousSibling():null===i.getNextSibling())}(n,o,r,l)}(n,i,c,r)&&function(n,o,r,l,i){const[s,a]=R(l,r,r);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:i}=t;return"backward"===n?l===o.startColumn&&i===o.startRow:l===r.startColumn&&i===r.startRow}(s,a,i))return!1;const c=function(n,o,r){const l=e.$findMatchingParent(n,(e=>t.$isElementNode(e)&&!e.isInline()));if(!l)return;const i="backward"===o?l.getPreviousSibling():l.getNextSibling();return i&&Me(i)?i:"backward"===o?r.getPreviousSibling():r.getNextSibling()}(o,i,l);if(!c||Me(c))return!1;ge(n),"backward"===i?c.selectEnd():c.selectStart();return!0}(o,c,d,l,r))}const f=n.getElementByKey(d.__key),m=n.getElementByKey(a.key);if(null==m||null==f)return!1;let p;if("element"===a.type)p=m.getBoundingClientRect();else{const e=t.getDOMSelection(Y(n));if(null===e||0===e.rangeCount)return!1;p=e.getRangeAt(0).getBoundingClientRect()}const C="up"===r?d.getFirstChild():d.getLastChild();if(null==C)return!1;const S=n.getElementByKey(C.__key);if(null==S)return!1;const _=S.getBoundingClientRect();if("up"===r?_.top>p.top-p.height:p.bottom+p.height>_.bottom){ge(o);const e=l.getCordsFromCellNode(d,i.table);if(!o.shiftKey)return te(i,l,e.x,e.y,r);{const t=l.getDOMCellFromCordsOrThrow(e.x,e.y,i.table);i.$setAnchorCellForSelection(t),i.$setFocusCellForSelection(t,!0)}return!0}}else if(P(s)){const{anchor:t,focus:a}=s,u=e.$findMatchingParent(t.getNode(),c),d=e.$findMatchingParent(a.getNode(),c),[g]=s.getNodes();Me(g)||h(251);const f=B(g,n.getElementByKey(g.getKey()));if(!c(u)||!c(d)||!Me(g)||null==f)return!1;i.$updateTableTableSelection(s);const m=V(g,f),p=l.getCordsFromCellNode(u,m),C=l.getDOMCellFromCordsOrThrow(p.x,p.y,m);if(i.$setAnchorCellForSelection(C),ge(o),o.shiftKey){const[e,t,n]=R(l,u,d);return le(i,e,t,n,r)}return d.selectEnd(),!0}return!1}function ge(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function fe(e,n,o){const r=t.$createParagraphNode();"first"===e?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function me(n,o,r){const l=r.getParent();if(!l)return;const i=t.getDOMSelection(Y(n));if(!i)return;const s=i.anchorNode,a=n.getElementByKey(l.getKey()),u=B(r,n.getElementByKey(r.getKey()));if(!s||!a||!u||!a.contains(s)||u.contains(s))return;const d=e.$findMatchingParent(o.anchor.getNode(),(e=>c(e)));if(!d)return;const h=e.$findMatchingParent(d,(e=>Me(e)));if(!Me(h)||!h.is(r))return;const[g,f]=R(r,d,d),m=g[0][0],p=g[g.length-1][g[0].length-1],{startRow:C,startColumn:S}=f,_=C===m.startRow&&S===m.startColumn,N=C===p.startRow&&S===p.startColumn;return _?"first":N?"last":void 0}function pe(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Ce(e,n,o){return U(e,t.$getNearestNodeFromDOMNode(n,o))}function Se(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function _e(t,n,o){o?(e.addClassNamesToElement(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(e.removeClassNamesFromElement(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}function Ne(t,n,o){if(!n.theme.tableAlignment)return;const r=[],l=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===o?l:r).push(t)}e.removeClassNamesFromElement(t,...r),e.addClassNamesToElement(t,...l)}const be=new WeakSet;function we(e=t.$getEditor()){return be.has(e)}class Te extends t.ElementNode{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Te(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:ye,priority:1})}}static importJSON(e){return $e().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&h(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(n,o){const r=document.createElement("table"),l=document.createElement("colgroup");if(r.appendChild(l),Se(r,0,this.getColumnCount(),this.getColWidths()),t.setDOMUnmanaged(l),e.addClassNamesToElement(r,n.theme.table),Ne(r,n,this.getFormatType()),this.__rowStriping&&_e(r,n,!0),we(o)){const t=document.createElement("div"),o=n.theme.tableScrollableWrapper;return o?e.addClassNamesToElement(t,o):t.style.cssText="overflow-x: auto;",t.appendChild(r),t}return r}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&_e(t,n,this.__rowStriping),Se(t,0,this.getColumnCount(),this.getColWidths()),Ne(this.getDOMSlot(t).element,n,this.getFormatType()),!1}exportDOM(t){const n=super.exportDOM(t),{element:o}=n;return{after:o=>{if(n.after&&(o=n.after(o),this.__format&&Ne(o,t._config,this.getFormatType())),e.isHTMLElement(o)&&"TABLE"!==o.nodeName&&(o=o.querySelector("table")),!e.isHTMLElement(o))return null;const[r]=x(this,null,null),l=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();l.has(e)||l.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const i=new Set;for(const e of o.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=l.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){l.delete(t);for(let e=0;e<n.colSpan;e++)i.add(e+n.startColumn)}}}const s=o.querySelector(":scope > colgroup");if(s){const e=Array.from(o.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>i.has(t)));s.replaceChildren(...e)}const a=o.querySelectorAll(":scope > tr");if(a.length>0){const e=document.createElement("tbody");for(const t of a)e.appendChild(t);o.append(e)}return o},element:e.isHTMLElement(o)&&"TABLE"!==o.nodeName?o.querySelector("table"):o}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,i=Ce(this,l);if(null!==i&&e.is(i))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,n,o){const r=this.getDOMCellFromCords(e,n,o);if(null==r)return null;const l=t.$getNearestNodeFromDOMNode(r.elem);return c(l)?l:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{c(e)&&(t+=e.getColSpan())})),t}}function ye(t){const n=$e();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const r=t.querySelector(":scope > colgroup");if(r){let e=[];for(const t of r.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!o.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:t=>e.$descendantsMatching(t,p),node:n}}function $e(){return t.$applyNodeReplacement(new Te)}function Me(e){return e instanceof Te}function Re({rows:n,columns:o,includeHeaders:r}){const l=N(Number(n),Number(o),r);e.$insertNodeToNearestRoot(l);const i=l.getFirstDescendant();return t.$isTextNode(i)&&i.select(),!0}function xe(e){p(e.getParent())?e.isEmpty()&&e.append(t.$createParagraphNode()):e.remove()}function Oe(t){Me(t.getParent())?e.$unwrapAndFilterDescendants(t,c):t.remove()}function Ee(n){e.$unwrapAndFilterDescendants(n,p);const[o]=x(n,null,null),r=o.reduce(((e,t)=>Math.max(e,t.length)),0),l=n.getChildren();for(let e=0;e<o.length;++e){const n=l[e];if(!n)continue;p(n)||h(254,n.constructor.name,n.getType());const i=o[e].reduce(((e,t)=>t?1+e:e),0);if(i!==r)for(let e=i;e<r;++e){const e=a();e.append(t.$createParagraphNode()),n.append(e)}}}exports.$computeTableMap=R,exports.$computeTableMapSkipCellCheck=x,exports.$createTableCellNode=a,exports.$createTableNode=$e,exports.$createTableNodeWithDimensions=N,exports.$createTableRowNode=m,exports.$createTableSelection=D,exports.$createTableSelectionFrom=K,exports.$deleteTableColumn=function(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(p(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e},exports.$deleteTableColumn__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const n=e.anchor.getNode(),o=e.focus.getNode(),[r,,l]=O(n),[i]=O(o),[s,a,c]=R(l,r,i),{startColumn:u}=a,{startRow:d,startColumn:g}=c,f=Math.min(u,g),m=Math.max(u+r.__colSpan-1,g+i.__colSpan-1),p=m-f+1;if(s[0].length===m-f+1)return l.selectPrevious(),void l.remove();const C=s.length;for(let e=0;e<C;e++)for(let t=f;t<=m;t++){const{cell:n,startColumn:o}=s[e][t];if(o<f){if(t===f){const e=f-o;n.setColSpan(n.__colSpan-Math.min(p,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const S=s[d],_=u>g?S[u+r.__colSpan]:S[g+i.__colSpan];if(void 0!==_){const{cell:e}=_;$(e)}else{const e=g<u?S[g-1]:S[u-1],{cell:t}=e;$(t)}const N=l.getColWidths();if(N){const e=[...N];e.splice(f,p),l.setColWidths(e)}},exports.$deleteTableRow__EXPERIMENTAL=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const[n,o]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,l]=O(n),[i]=O(o),[s,a,c]=R(l,r,i),{startRow:u}=a,{startRow:d}=c,g=d+i.__rowSpan-1;if(s.length===g-u+1)return void l.remove();const f=s[0].length,m=r.__rowSpan,C=s[g+1],S=l.getChildAtIndex(g+1);for(let e=g;e>=u;e--){for(let t=f-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(e===u&&o<u){const e=u-o;n.setRowSpan(n.__rowSpan-Math.min(m,n.__rowSpan-e))}if(o>=u&&o+n.__rowSpan-1>g){n.setRowSpan(n.__rowSpan-(g-o+1)),null===S&&h(122);let r=null;for(let n=0;n<t;n++){const t=C[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?M(S,n):r.insertAfter(n)}}}const t=l.getChildAtIndex(e);p(t)||h(206,String(e)),t.remove()}if(void 0!==C){const{cell:e}=C[0];$(e)}else{const e=s[u-1],{cell:t}=e[0];$(t)}},exports.$findCellNode=ue,exports.$findTableNode=de,exports.$getElementForTableNode=function(e,t){const n=e.getElementByKey(t.getKey());return null===n&&h(230),V(t,n)},exports.$getNodeTriplet=O,exports.$getTableAndElementByKey=k,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,(e=>c(e)));return c(n)?n:null},exports.$getTableCellNodeRect=A,exports.$getTableColumnIndexFromTableCellNode=function(e){return b(e).getChildren().findIndex((t=>t.is(e)))},exports.$getTableNodeFromLexicalNodeOrThrow=w,exports.$getTableRowIndexFromTableCellNode=function(e){const t=b(e);return w(t).getChildren().findIndex((e=>e.is(t)))},exports.$getTableRowNodeFromTableCellNodeOrThrow=b,exports.$insertTableColumn=function(e,n,o=!0,l,i){const s=e.getChildren(),u=[];for(let e=0;e<s.length;e++){const o=s[e];if(p(o))for(let e=0;e<l;e++){const e=o.getChildren();if(n>=e.length||n<0)throw new Error("Table column target index out of range");const l=e[n];c(l)||h(12);const{left:s,right:d}=T(l,i);let g=r.NO_STATUS;(s&&s.hasHeaderState(r.ROW)||d&&d.hasHeaderState(r.ROW))&&(g|=r.ROW);const f=a(g);f.append(t.$createParagraphNode()),u.push({newTableCell:f,targetCell:l})}}return u.forEach((({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)})),e},exports.$insertTableColumn__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||P(n)||h(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[i]=O(o),[s,,c]=O(l),[u,d,g]=R(c,s,i),f=u.length,m=e?Math.max(d.startColumn,g.startColumn):Math.min(d.startColumn,g.startColumn),C=e?m+s.__colSpan-1:m-1,S=c.getFirstChild();p(S)||h(120);let _=null;function N(e=r.NO_STATUS){const n=a(e).append(t.$createParagraphNode());return null===_&&(_=n),n}let b=S;e:for(let e=0;e<f;e++){if(0!==e){const e=b.getNextSibling();p(e)||h(121),b=e}const t=u[e],n=t[C<0?0:C].cell.__headerState,o=y(n,r.ROW);if(C<0){M(b,N(o));continue}const{cell:l,startColumn:i,startRow:s}=t[C];if(i+l.__colSpan-1<=C){let n=l,r=s,i=C;for(;r!==e&&n.__rowSpan>1;){if(i-=l.__colSpan,!(i>=0)){b.append(N(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,r=o}}n.insertAfter(N(o))}else l.setColSpan(l.__colSpan+1)}null!==_&&$(_);const w=c.getColWidths();if(w){const e=[...w],t=C<0?0:C,n=e[t];e.splice(t,0,n),c.setColWidths(e)}return _},exports.$insertTableRow=function(e,n,o=!0,l,i){const s=e.getChildren();if(n>=s.length||n<0)throw new Error("Table row target index out of range");const u=s[n];if(!p(u))throw new Error("Row before insertion index does not exist.");for(let e=0;e<l;e++){const e=u.getChildren(),n=e.length,l=m();for(let o=0;o<n;o++){const n=e[o];c(n)||h(12);const{above:s,below:u}=T(n,i);let d=r.NO_STATUS;const g=s&&s.getWidth()||u&&u.getWidth()||void 0;(s&&s.hasHeaderState(r.COLUMN)||u&&u.hasHeaderState(r.COLUMN))&&(d|=r.COLUMN);const f=a(d,1,g);f.append(t.$createParagraphNode()),l.append(f)}o?u.insertAfter(l):u.insertBefore(l)}return e},exports.$insertTableRow__EXPERIMENTAL=function(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||P(n)||h(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[i]=O(o),[s,,c]=O(l),[u,d,g]=R(c,s,i),f=u[0].length,{startRow:C}=g,{startRow:S}=d;let _=null;if(e){const e=Math.max(S+s.__rowSpan,C+i.__rowSpan)-1,n=u[e],o=m();for(let l=0;l<f;l++){const{cell:i,startRow:s}=n[l];if(s+i.__rowSpan-1<=e){const e=n[l].cell.__headerState,i=y(e,r.COLUMN);o.append(a(i).append(t.$createParagraphNode()))}else i.setRowSpan(i.__rowSpan+1)}const l=c.getChildAtIndex(e);p(l)||h(256),l.insertAfter(o),_=o}else{const e=Math.min(S,C),n=u[e],o=m();for(let l=0;l<f;l++){const{cell:i,startRow:s}=n[l];if(s===e){const e=n[l].cell.__headerState,i=y(e,r.COLUMN);o.append(a(i).append(t.$createParagraphNode()))}else i.setRowSpan(i.__rowSpan+1)}const l=c.getChildAtIndex(e);p(l)||h(257),l.insertBefore(o),_=o}return _},exports.$isScrollableTablesActive=we,exports.$isTableCellNode=c,exports.$isTableNode=Me,exports.$isTableRowNode=p,exports.$isTableSelection=P,exports.$removeTableRowAtIndex=function(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e},exports.$unmergeCell=function(){const e=t.$getSelection();t.$isRangeSelection(e)||P(e)||h(188);const n=e.anchor.getNode(),[o,l,i]=O(n),s=o.__colSpan,c=o.__rowSpan;if(1===s&&1===c)return;const[u,d]=R(i,o,o),{startColumn:g,startRow:f}=d,m=o.__headerState&r.COLUMN,C=Array.from({length:s},((e,t)=>{let n=m;for(let e=0;0!==n&&e<u.length;e++)n&=u[e][t+g].cell.__headerState;return n})),S=o.__headerState&r.ROW,_=Array.from({length:c},((e,t)=>{let n=S;for(let e=0;0!==n&&e<u[0].length;e++)n&=u[t+f][e].cell.__headerState;return n}));if(s>1){for(let e=1;e<s;e++)o.insertAfter(a(C[e]|_[0]).append(t.$createParagraphNode()));o.setColSpan(1)}if(c>1){let e;for(let n=1;n<c;n++){const o=f+n,r=u[o];e=(e||l).getNextSibling(),p(e)||h(125);let i=null;for(let e=0;e<g;e++){const t=r[e],n=t.cell;t.startRow===o&&(i=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===i)for(let o=s-1;o>=0;o--)M(e,a(C[o]|_[n]).append(t.$createParagraphNode()));else for(let e=s-1;e>=0;e--)i.insertAfter(a(C[e]|_[n]).append(t.$createParagraphNode()))}o.setRowSpan(1)}},exports.INSERT_TABLE_COMMAND=u,exports.TableCellHeaderStates=r,exports.TableCellNode=l,exports.TableNode=Te,exports.TableObserver=L,exports.TableRowNode=g,exports.applyTableHandlers=z,exports.getDOMCellFromTarget=j,exports.getTableElement=B,exports.getTableObserverFromTableElement=G,exports.registerTableCellUnmergeTransform=function(t){return t.registerNodeTransform(l,(t=>{if(t.getColSpan()>1||t.getRowSpan()>1){const[,,n]=O(t),[o]=R(n,t,t),r=o.length,l=o[0].length;let i=n.getFirstChild();p(i)||h(175);const s=[];for(let t=0;t<r;t++){0!==t&&(i=i.getNextSibling(),p(i)||h(175));let n=null;for(let r=0;r<l;r++){const l=o[t][r],u=l.cell;if(l.startRow===t&&l.startColumn===r)n=u,s.push(u);else if(u.getColSpan()>1||u.getRowSpan()>1){c(u)||h(176);const t=a(u.__headerState);null!==n?n.insertAfter(t):e.$insertFirst(i,t)}}}for(const e of s)e.setColSpan(1),e.setRowSpan(1)}}))},exports.registerTablePlugin=function(n){return n.hasNodes([Te])||h(255),e.mergeRegister(n.registerCommand(u,Re,t.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(Te,Ee),n.registerNodeTransform(g,Oe),n.registerNodeTransform(l,xe))},exports.registerTableSelectionObserver=function(e,t=!0){const n=new Map,o=(o,r,l)=>{const i=B(o,l),s=z(o,i,e,t);n.set(r,[s,i])},r=e.registerMutationListener(Te,(t=>{e.getEditorState().read((()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=k(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}},exports.setScrollableTablesActive=function(e,t){t?be.add(e):be.delete(e)};
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{addClassNamesToElement as e,$descendantsMatching as t,$findMatchingParent as n,removeClassNamesFromElement as o,objectKlassEquals as r,isHTMLElement as l,$insertFirst as s,mergeRegister as i,$insertNodeToNearestRoot as c,$unwrapAndFilterDescendants as a}from"@lexical/utils";import{ElementNode as u,isHTMLElement as h,$createParagraphNode as d,$isElementNode as g,$isLineBreakNode as f,$isTextNode as m,$applyNodeReplacement as p,createCommand as S,$createTextNode as C,$getSelection as _,$isRangeSelection as w,$createPoint as b,$isParagraphNode as y,$normalizeSelection__EXPERIMENTAL as N,isCurrentlyReadOnlyMode as x,TEXT_TYPE_TO_FORMAT as T,$getNodeByKey as v,$getEditor as R,$setSelection as O,SELECTION_CHANGE_COMMAND as F,getDOMSelection as k,$createRangeSelection as K,COMMAND_PRIORITY_HIGH as E,KEY_ESCAPE_COMMAND as M,COMMAND_PRIORITY_CRITICAL as A,CUT_COMMAND as $,FORMAT_TEXT_COMMAND as H,FORMAT_ELEMENT_COMMAND as L,CONTROLLED_TEXT_INSERTION_COMMAND as P,KEY_TAB_COMMAND as W,FOCUS_COMMAND as B,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as D,$getPreviousSelection as I,$getNearestNodeFromDOMNode as U,$createRangeSelectionFromDom as J,INSERT_PARAGRAPH_COMMAND as z,$isRootOrShadowRoot as Y,$isDecoratorNode as q,KEY_ARROW_DOWN_COMMAND as X,KEY_ARROW_UP_COMMAND as j,KEY_ARROW_LEFT_COMMAND as V,KEY_ARROW_RIGHT_COMMAND as G,DELETE_WORD_COMMAND as Q,DELETE_LINE_COMMAND as Z,DELETE_CHARACTER_COMMAND as ee,KEY_BACKSPACE_COMMAND as te,KEY_DELETE_COMMAND as ne,isDOMNode as oe,setDOMUnmanaged as re,COMMAND_PRIORITY_EDITOR as le}from"lexical";import{copyToClipboard as se,$getClipboardDataFromSelection as ie}from"@lexical/clipboard";const ce=/^(\d+(?:\.\d+)?)px$/,ae={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class ue extends u{static getType(){return"tablecell"}static clone(e){return new ue(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor}static importDOM(){return{td:e=>({conversion:he,priority:0}),th:e=>({conversion:he,priority:0})}}static importJSON(e){return de().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null)}constructor(e=ae.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(h(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign="top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ae.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ae.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function he(e){const t=e,n=e.nodeName.toLowerCase();let o;ce.test(t.style.width)&&(o=parseFloat(t.style.width));const r=de("th"===n?ae.ROW:ae.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style,i=(s&&s.textDecoration||"").split(" "),c="700"===s.fontWeight||"bold"===s.fontWeight,a=i.includes("line-through"),u="italic"===s.fontStyle,h=i.includes("underline");return{after:e=>(0===e.length&&e.push(d()),e),forChild:(e,t)=>{if(ge(t)&&!g(e)){const t=d();return f(e)&&"\n"===e.getTextContent()?null:(m(e)&&(c&&e.toggleFormat("bold"),a&&e.toggleFormat("strikethrough"),u&&e.toggleFormat("italic"),h&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function de(e=ae.NO_STATUS,t=1,n){return p(new ue(e,t,n))}function ge(e){return e instanceof ue}const fe=S("INSERT_TABLE_COMMAND");function me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pe=me((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class Se extends u{static getType(){return"tablerow"}static clone(e){return new Se(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:Ce,priority:0})}}static importJSON(e){return _e().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function Ce(e){const n=e;let o;return ce.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>t(e,ge),node:_e(o)}}function _e(e){return p(new Se(e))}function we(e){return e instanceof Se}const be="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,ye=be&&"documentMode"in document?document.documentMode:null,Ne=be&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function xe(e,t,n=!0){const o=Ut();for(let r=0;r<e;r++){const e=_e();for(let o=0;o<t;o++){let t=ae.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=ae.ROW),0===o&&n.columns&&(t|=ae.COLUMN)):n&&(0===r&&(t|=ae.ROW),0===o&&(t|=ae.COLUMN));const l=de(t),s=d();s.append(C()),l.append(s),e.append(l)}o.append(e)}return o}function Te(e){const t=n(e,(e=>ge(e)));return ge(t)?t:null}function ve(e){const t=n(e,(e=>we(e)));if(we(t))return t;throw new Error("Expected table cell to be inside of table row.")}function Re(e){const t=n(e,(e=>Jt(e)));if(Jt(t))return t;throw new Error("Expected table cell to be inside of table.")}function Oe(e){const t=ve(e);return Re(t).getChildren().findIndex((e=>e.is(t)))}function Fe(e){return ve(e).getChildren().findIndex((t=>t.is(e)))}function ke(e,t){const n=Re(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function Ke(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function Ee(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const s=l[t];if(!we(s))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=s.getChildren(),t=e.length,o=_e();for(let n=0;n<t;n++){const t=e[n];ge(t)||pe(12);const{above:l,below:s}=ke(t,r);let i=ae.NO_STATUS;const c=l&&l.getWidth()||s&&s.getWidth()||void 0;(l&&l.hasHeaderState(ae.COLUMN)||s&&s.hasHeaderState(ae.COLUMN))&&(i|=ae.COLUMN);const a=de(i,1,c);a.append(d()),o.append(a)}n?s.insertAfter(o):s.insertBefore(o)}return e}be&&"InputEvent"in window&&!ye&&new window.InputEvent("input");const Me=(e,t)=>e===ae.BOTH||e===t?t:ae.NO_STATUS;function Ae(e=!0){const t=_();w(t)||Ve(t)||pe(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=ze(n),[l,,s]=ze(o),[i,c,a]=Ue(s,l,r),u=i[0].length,{startRow:h}=a,{startRow:g}=c;let f=null;if(e){const e=Math.max(g+l.__rowSpan,h+r.__rowSpan)-1,t=i[e],n=_e();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=Me(e,ae.COLUMN);n.append(de(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);we(o)||pe(256),o.insertAfter(n),f=n}else{const e=Math.min(g,h),t=i[e],n=_e();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l===e){const e=t[o].cell.__headerState,r=Me(e,ae.COLUMN);n.append(de(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);we(o)||pe(257),o.insertBefore(n),f=n}return f}function $e(e,t,n=!0,o,r){const l=e.getChildren(),s=[];for(let e=0;e<l.length;e++){const n=l[e];if(we(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];ge(o)||pe(12);const{left:l,right:i}=ke(o,r);let c=ae.NO_STATUS;(l&&l.hasHeaderState(ae.ROW)||i&&i.hasHeaderState(ae.ROW))&&(c|=ae.ROW);const a=de(c);a.append(d()),s.push({newTableCell:a,targetCell:o})}}return s.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function He(e=!0){const t=_();w(t)||Ve(t)||pe(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=ze(n),[l,,s]=ze(o),[i,c,a]=Ue(s,l,r),u=i.length,h=e?Math.max(c.startColumn,a.startColumn):Math.min(c.startColumn,a.startColumn),g=e?h+l.__colSpan-1:h-1,f=s.getFirstChild();we(f)||pe(120);let m=null;function p(e=ae.NO_STATUS){const t=de(e).append(d());return null===m&&(m=t),t}let S=f;e:for(let e=0;e<u;e++){if(0!==e){const e=S.getNextSibling();we(e)||pe(121),S=e}const t=i[e],n=t[g<0?0:g].cell.__headerState,o=Me(n,ae.ROW);if(g<0){De(S,p(o));continue}const{cell:r,startColumn:l,startRow:s}=t[g];if(l+r.__colSpan-1<=g){let n=r,l=s,i=g;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){S.append(p(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o}}n.insertAfter(p(o))}else r.setColSpan(r.__colSpan+1)}null!==m&&Be(m);const C=s.getColWidths();if(C){const e=[...C],t=g<0?0:g,n=e[t];e.splice(t,0,n),s.setColWidths(e)}return m}function Le(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(we(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function Pe(){const e=_();w(e)||Ve(e)||pe(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=ze(t),[l]=ze(n),[s,i,c]=Ue(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;if(s.length===h-a+1)return void r.remove();const d=s[0].length,g=o.__rowSpan,f=s[h+1],m=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(e===a&&o<a){const e=a-o;n.setRowSpan(n.__rowSpan-Math.min(g,n.__rowSpan-e))}if(o>=a&&o+n.__rowSpan-1>h){n.setRowSpan(n.__rowSpan-(h-o+1)),null===m&&pe(122);let r=null;for(let n=0;n<t;n++){const t=f[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?De(m,n):r.insertAfter(n)}}}const t=r.getChildAtIndex(e);we(t)||pe(206,String(e)),t.remove()}if(void 0!==f){const{cell:e}=f[0];Be(e)}else{const e=s[a-1],{cell:t}=e[0];Be(t)}}function We(){const e=_();w(e)||Ve(e)||pe(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=ze(t),[l]=ze(n),[s,i,c]=Ue(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),g=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),f=g-d+1;if(s[0].length===g-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;e<m;e++)for(let t=d;t<=g;t++){const{cell:n,startColumn:o}=s[e][t];if(o<d){if(t===d){const e=d-o;n.setColSpan(n.__colSpan-Math.min(f,n.__colSpan-e))}}else if(o+n.__colSpan-1>g){if(t===g){const e=g-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=s[u],S=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==S){const{cell:e}=S;Be(e)}else{const e=h<a?p[h-1]:p[a-1],{cell:t}=e;Be(t)}const C=r.getColWidths();if(C){const e=[...C];e.splice(d,f),r.setColWidths(e)}}function Be(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function De(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Ie(){const e=_();w(e)||Ve(e)||pe(188);const t=e.anchor.getNode(),[n,o,r]=ze(t),l=n.__colSpan,s=n.__rowSpan;if(1===l&&1===s)return;const[i,c]=Ue(r,n,n),{startColumn:a,startRow:u}=c,h=n.__headerState&ae.COLUMN,g=Array.from({length:l},((e,t)=>{let n=h;for(let e=0;0!==n&&e<i.length;e++)n&=i[e][t+a].cell.__headerState;return n})),f=n.__headerState&ae.ROW,m=Array.from({length:s},((e,t)=>{let n=f;for(let e=0;0!==n&&e<i[0].length;e++)n&=i[t+u][e].cell.__headerState;return n}));if(l>1){for(let e=1;e<l;e++)n.insertAfter(de(g[e]|m[0]).append(d()));n.setColSpan(1)}if(s>1){let e;for(let t=1;t<s;t++){const n=u+t,r=i[n];e=(e||o).getNextSibling(),we(e)||pe(125);let s=null;for(let e=0;e<a;e++){const t=r[e],o=t.cell;t.startRow===n&&(s=o),o.__colSpan>1&&(e+=o.__colSpan-1)}if(null===s)for(let n=l-1;n>=0;n--)De(e,de(g[n]|m[t]).append(d()));else for(let e=l-1;e>=0;e--)s.insertAfter(de(g[e]|m[t]).append(d()))}n.setRowSpan(1)}}function Ue(e,t,n){const[o,r,l]=Je(e,t,n);return null===r&&pe(207),null===l&&pe(208),[o,r,l]}function Je(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];we(o)||pe(209);const c=s(e);for(let a=o.getFirstChild(),u=0;null!=a;a=a.getNextSibling()){for(ge(a)||pe(147);void 0!==c[u];)u++;const o={cell:a,startColumn:u,startRow:e},{__rowSpan:h,__colSpan:d}=a;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[u+e]=o}null!==t&&null===r&&t.is(a)&&(r=o),null!==n&&null===l&&n.is(a)&&(l=o)}}return[o,r,l]}function ze(e){let t;if(e instanceof ue)t=e;else if("__type"in e){const o=n(e,ge);ge(o)||pe(148),t=o}else{const o=n(e.getNode(),ge);ge(o)||pe(148),t=o}const o=t.getParent();we(o)||pe(149);const r=o.getParent();return Jt(r)||pe(210),[t,o,r]}function Ye(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),s=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),i=o,c=r,a=o,u=r;function h(e){const{cell:t,startColumn:n,startRow:i}=e;o=Math.min(o,n),r=Math.min(r,i),l=Math.max(l,n+t.__colSpan-1),s=Math.max(s,i+t.__rowSpan-1)}for(;o<i||r<c||l>a||s>u;){if(o<i){const t=u-c,n=i-1;for(let o=0;o<=t;o++)h(e[c+o][n]);i=n}if(r<c){const t=a-i,n=c-1;for(let o=0;o<=t;o++)h(e[n][i+o]);c=n}if(l>a){const t=u-c,n=a+1;for(let o=0;o<=t;o++)h(e[c+o][n]);a=n}if(s>u){const t=a-i,n=u+1;for(let o=0;o<=t;o++)h(e[n][i+o]);u=n}}return{maxColumn:l,maxRow:s,minColumn:o,minRow:r}}function qe(e){const[t,,n]=ze(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,c=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:c,columnIndex:r,rowIndex:e,rowSpan:i};r+=c}}return null}function Xe(e){const[[t,o,r,l],[s,i,c,a]]=["anchor","focus"].map((t=>{const o=e[t].getNode(),r=n(o,ge);ge(r)||pe(238,t,o.getKey(),o.getType());const l=r.getParent();we(l)||pe(239,t);const s=l.getParent();return Jt(s)||pe(240,t),[o,r,l,s]}));return l.is(a)||pe(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class je{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return Ve(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new je(this.tableKey,b(this.anchor.key,this.anchor.offset,this.anchor.type),b(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(ge).forEach((e=>{const n=e.getFirstChild();y(n)&&(t|=n.getTextFormat())}));const n=T[e];return!!(t&n)}insertNodes(e){const t=this.focus.getNode();g(t)||pe(151);N(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=Xe(this),n=qe(e);null===n&&pe(153);const o=qe(t);null===o&&pe(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=Xe(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&pe(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&pe(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=Ue(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=Ye(l,s,i),d=new Map([[t.getKey(),t]]);let g=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();we(o)||pe(160),o!==g&&(d.set(o.getKey(),o),g=o),d.has(n.getKey())||Ze(n,(e=>{d.set(e.getKey(),e)}))}const f=Array.from(d.values());return x()||(this._cachedNodes=f),f}getTextContent(){const e=this.getNodes().filter((e=>ge(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function Ve(e){return e instanceof je}function Ge(){const e=b("root",0,"element"),t=b("root",0,"element");return new je("root",e,t)}function Qe(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=_(),r=Ve(o)?o.clone():Ge();return r.set(e.getKey(),t.getKey(),n.getKey()),r}function Ze(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&g(o)&&n.push(o.getChildren())}}function et(e,t=R()){const n=v(e);Jt(n)||pe(231,e);const o=rt(n,t.getElementByKey(e));return null===o&&pe(232,e),{tableElement:o,tableNode:n}}class tt{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return et(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=gt(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=gt(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();ft(e,gt(t,n),null),null!==_()&&(O(null),e.dispatchCommand(F,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();o(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&pe(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),ft(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=k(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=Mt(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=Qe(o,this.$getAnchorTableCellOrThrow(),t),O(this.tableSelection),n.dispatchCommand(F,void 0),ft(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?v(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&pe(234),e}$getFocusTableCell(){return this.focusCellNodeKey?v(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&pe(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=Mt(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():Ge(),this.anchorCellNodeKey=e}}$formatCells(e){const t=_();Ve(t)||pe(236);const n=K(),o=n.anchor,r=n.focus,l=t.getNodes().filter(ge);l.length>0||pe(237);const s=l[0].getFirstChild(),i=y(s)?s.getFormatFlags(e,null):null;l.forEach((t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)})),O(t),this.editor.dispatchCommand(F,void 0)}$clearText(){const{editor:e}=this,t=v(this.tableNodeKey);if(!Jt(t))throw new Error("Expected TableNode.");const n=_();Ve(n)||pe(253);const o=n.getNodes().filter(ge);if(o.length===this.table.columns*this.table.rows)return t.selectPrevious(),void t.remove();o.forEach((e=>{if(g(e)){const t=d(),n=C();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),ft(e,this.table,null),O(null),e.dispatchCommand(F,void 0)}}const nt="__lexicalTableSelection",ot=e=>!(1&~e.buttons);function rt(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&pe(245,t.nodeName),n}function lt(e){return e._window}function st(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;ge(n)&&(o=n)}return null}const it=[[X,"down"],[j,"up"],[V,"backward"],[G,"forward"]],ct=[Q,Z,ee],at=[te,ne];function ut(e,t,o,l){const s=o.getRootElement(),i=lt(o);null!==s&&null!==i||pe(246);const c=new tt(o,e.getKey()),a=rt(e,t);!function(e,t){null!==ht(e)&&pe(205);e[nt]=t}(a,c),c.listenersToRemove.add((()=>function(e,t){ht(e)===t&&delete e[nt]}(a,c)));a.addEventListener("mousedown",(t=>{if(0!==t.button||!oe(t.target)||!i)return;const n=dt(t.target);null!==n&&o.update((()=>{const o=I();if(Ne&&t.shiftKey&&yt(o,e)&&(w(o)||Ve(o))){const r=o.anchor.getNode(),l=st(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(Et(c,l)),c.$setFocusCellForSelection(n),Ft(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else c.$setAnchorCellForSelection(n)})),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,i.removeEventListener("mouseup",e),i.removeEventListener("mousemove",t)},t=n=>{if(!oe(n.target))return;if(!ot(n)&&c.isSelecting)return c.isSelecting=!1,i.removeEventListener("mouseup",e),void i.removeEventListener("mousemove",t);const r=!a.contains(n.target);let l=null;if(r){for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(l=a.contains(e)?dt(e):null,l)break}else l=dt(n.target);!l||null!==c.focusCell&&l.elem===c.focusCell.elem||(c.setNextFocus({focusCell:l,override:r}),o.dispatchCommand(F,void 0))};c.isSelecting=!0,i.addEventListener("mouseup",e,c.listenerOptions),i.addEventListener("mousemove",t,c.listenerOptions)})()}),c.listenerOptions);i.addEventListener("mousedown",(e=>{const t=e.target;0===e.button&&oe(t)&&o.update((()=>{const e=_();Ve(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight()}))}),c.listenerOptions);for(const[t,n]of it)c.listenersToRemove.add(o.registerCommand(t,(t=>Ot(o,t,n,e,c)),E));c.listenersToRemove.add(o.registerCommand(M,(t=>{const n=_();if(Ve(n)){const o=st(e,n.focus.getNode());if(null!==o)return Ft(t),o.selectEnd(),!0}return!1}),E));const u=t=>()=>{const o=_();if(!yt(o,e))return!1;if(Ve(o))return c.$clearText(),!0;if(w(o)){if(!ge(st(e,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),i=e.isParentOf(l);if(s&&!i||i&&!s)return c.$clearText(),!0;const a=n(o.anchor.getNode(),(e=>g(e))),u=a&&n(a,(e=>g(e)&&ge(e.getParent())));if(!g(u)||!g(a))return!1;if(t===Z&&null===u.getPreviousSibling())return!0}return!1};for(const e of ct)c.listenersToRemove.add(o.registerCommand(e,u(e),A));const h=t=>{const n=_();if(!Ve(n)&&!w(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),!1}return!!yt(n,e)&&(!!Ve(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),!0))};for(const e of at)c.listenersToRemove.add(o.registerCommand(e,h,A));return c.listenersToRemove.add(o.registerCommand($,(e=>{const t=_();if(t){if(!Ve(t)&&!w(t))return!1;se(o,r(e,ClipboardEvent)?e:null,ie(t));const n=h(e);return w(t)?(t.removeText(),!0):n}return!1}),A)),c.listenersToRemove.add(o.registerCommand(H,(t=>{const o=_();if(!yt(o,e))return!1;if(Ve(o))return c.$formatCells(t),!0;if(w(o)){const e=n(o.anchor.getNode(),(e=>ge(e)));if(!ge(e))return!1}return!1}),A)),c.listenersToRemove.add(o.registerCommand(L,(t=>{const n=_();if(!Ve(n)||!yt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!ge(o)||!ge(r))return!1;if(function(e,t){if(Ve(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=Ue(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,e))return e.setFormat(t),!0;const[l,s,i]=Ue(e,o,r),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),h=Math.min(s.startColumn,i.startColumn),d=new Set;for(let e=u;e<=c;e++)for(let n=h;n<=a;n++){const o=l[e][n].cell;if(d.has(o))continue;d.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];g(n)&&!n.isInline()&&n.setFormat(t)}}return!0}),A)),c.listenersToRemove.add(o.registerCommand(P,(t=>{const r=_();if(!yt(r,e))return!1;if(Ve(r))return c.$clearHighlight(),!1;if(w(r)){const l=n(r.anchor.getNode(),(e=>ge(e)));if(!ge(l))return!1;if("string"==typeof t){const n=Kt(o,r,e);if(n)return kt(n,e,[C(t)]),!0}}return!1}),A)),l&&c.listenersToRemove.add(o.registerCommand(W,(t=>{const o=_();if(!w(o)||!o.isCollapsed()||!yt(o,e))return!1;const r=vt(o.anchor.getNode());return!(null===r||!e.is(Rt(r)))&&(Ft(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(g(l))return l.selectEnd();const s=n(e,we);null===s&&pe(247);for(let e=s[o]();we(e);e=e[o]()){const t=e[r]();if(g(t))return t.selectEnd()}const i=n(s,Jt);null===i&&pe(248);"next"===t?i.selectNext():i.selectPrevious()}(r,t.shiftKey?"previous":"next"),!0)}),A)),c.listenersToRemove.add(o.registerCommand(B,(t=>e.isSelected()),E)),c.listenersToRemove.add(o.registerCommand(D,(e=>{const{nodes:t,selection:o}=e,r=o.getStartEndPoints(),l=Ve(o),s=w(o)&&null!==n(o.anchor.getNode(),(e=>ge(e)))&&null!==n(o.focus.getNode(),(e=>ge(e)))||l;if(1!==t.length||!Jt(t[0])||!s||null===r)return!1;const[i]=r,c=t[0],a=c.getChildren(),u=c.getFirstChildOrThrow().getChildrenSize(),h=c.getChildrenSize(),g=n(i.getNode(),(e=>ge(e))),f=g&&n(g,(e=>we(e))),p=f&&n(f,(e=>Jt(e)));if(!ge(g)||!we(f)||!Jt(p))return!1;const S=f.getIndexWithinParent(),C=Math.min(p.getChildrenSize()-1,S+h-1),_=g.getIndexWithinParent(),b=Math.min(f.getChildrenSize()-1,_+u-1),y=Math.min(_,b),N=Math.min(S,C),x=Math.max(_,b),T=Math.max(S,C),v=p.getChildren();let R=0;for(let e=N;e<=T;e++){const t=v[e];if(!we(t))return!1;const n=a[R];if(!we(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=x;e++){const t=o[e];if(!ge(t))return!1;const n=r[l];if(!ge(n))return!1;const s=t.getChildren();n.getChildren().forEach((e=>{if(m(e)){d().append(e),t.append(e)}else t.append(e)})),s.forEach((e=>e.remove())),l++}R++}return!0}),A)),c.listenersToRemove.add(o.registerCommand(F,(()=>{const t=_(),r=I(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(Ve(t)&&t.tableKey===c.tableNodeKey)return(n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),!0);if(n!==c.anchorCell&&yt(t,e))return c.$setFocusCellForSelection(n),!0}if(c.getAndClearShouldCheckSelection()&&w(r)&&w(t)&&t.isCollapsed()){const o=t.anchor.getNode(),r=e.getFirstChild(),l=vt(o);if(null!==l&&we(r)){const t=r.getFirstChild();if(ge(t)&&e.is(n(l,(n=>n.is(e)||n.is(t)))))return t.selectStart(),!0}}if(w(t)){const{anchor:n,focus:r}=t,l=n.getNode(),s=r.getNode(),i=vt(l),a=vt(s),u=!(!i||!e.is(Rt(i))),h=!(!a||!e.is(Rt(a))),d=u!==h,g=u&&h,f=t.isBackward();if(d){const n=t.clone();if(h){const[t]=Ue(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(f?o.getKey():r.getKey(),f?o.getChildrenSize():r.getChildrenSize(),"element")}else if(u){const[t]=Ue(e,i,i),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(f?r.getKey():o.getKey(),f?r.getChildrenSize():0,"element")}O(n),pt(o,c)}else g&&(i.is(a)||(c.$setAnchorCellForSelection(Et(c,i)),c.$setFocusCellForSelection(Et(c,a),!0)))}else if(t&&Ve(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=k(i);if(n&&n.anchorNode&&n.focusNode){const r=U(n.focusNode),l=r&&!e.isParentOf(r),s=U(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=J(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),O(r))}}}return t&&!t.is(r)&&(Ve(t)||Ve(r))&&c.tableSelection&&!c.tableSelection.is(r)?(Ve(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!Ve(t)&&Ve(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),mt(t.table,(t=>{const n=t.elem;t.highlighted=!1,Tt(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&pt(o,c),!1)}),A)),c.listenersToRemove.add(o.registerCommand(z,(()=>{const t=_();if(!w(t)||!t.isCollapsed()||!yt(t,e))return!1;const n=Kt(o,t,e);return!!n&&(kt(n,e),!0)}),A)),c}function ht(e){return e[nt]||null}function dt(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function gt(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=rt(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function ft(e,t,n){const o=new Set(n?n.getNodes():[]);mt(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,xt(e,t)):(t.highlighted=!1,Tt(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function mt(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=U(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function pt(e,t){t.$disableHighlightStyle(),mt(t.table,(t=>{t.highlighted=!0,xt(e,t)}))}const St=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?Nt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?Nt(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?Nt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Nt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Ct(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function _t([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function wt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&pe(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&pe(250,n,String(s)),i}function bt(e,t,n,o,r){const l=Ye(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=Ct(e,t);return null===n&&pe(249,t.cell.getKey()),n}(l,n),[d,g]=_t(h);let f=l[d],m=l[g];"forward"===r?f+="maxColumn"===d?1:c:"backward"===r?f-="minColumn"===d?1:u:"down"===r?m+="maxRow"===g?1:i:"up"===r&&(m-="minRow"===g?1:a);const p=t[m];if(void 0===p)return!1;const S=p[f];if(void 0===S)return!1;const[C,_]=function(e,t,n){const o=Ye(e,t,n),r=Ct(o,t);if(r)return[wt(e,o,r),wt(e,o,_t(r))];const l=Ct(o,n);if(l)return[wt(e,o,_t(l)),wt(e,o,l)];const s=["minColumn","minRow"];return[wt(e,o,s),wt(e,o,_t(s))]}(t,n,S),w=Et(e,C.cell),b=Et(e,_.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function yt(e,t){if(w(e)||Ve(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function Nt(e,t){t?e.selectStart():e.selectEnd()}function xt(t,n){const o=n.elem,r=t._config.theme;ge(U(o))||pe(131),e(o,r.tableCellSelected)}function Tt(e,t){const n=t.elem;ge(U(n))||pe(131);const r=e._config.theme;o(n,r.tableCellSelected)}function vt(e){const t=n(e,ge);return ge(t)?t:null}function Rt(e){const t=n(e,Jt);return Jt(t)?t:null}function Ot(e,t,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=_();if(!yt(s,r)){if(w(s)){if("backward"===o){if(s.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(g(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!Jt(n)&&(Ft(t),t.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=n(e,(e=>Jt(e)));if(ge(l)&&(l=n(l,Jt)),l!==r)return!1;if(!l)return!1;const i="down"===o?l.getNextSibling():l.getPreviousSibling();if(!i)return!1;let c=0;"up"===o&&g(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&g(i)){const e=i.getLastChild();a=e||i,c=m(a)?a.getTextContentSize():0}const u=s.clone();return u.focus.set(a.getKey(),c,m(a)?"text":"element"),O(u),Ft(t),!0}if(Y(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==st(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=ze(e),[o]=ze(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),c=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let r=n(e,(e=>g(e)&&!e.isInline()));if(ge(r)&&(r=n(r,Jt)),!r)return!1;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(Jt(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return!1;const[r]=ze(e),[l]=ze(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),Ft(t),O(c),!0}}}}return"down"===o&&Pt(e)&&l.setShouldCheckSelection(),!1}if(w(s)&&s.isCollapsed()){const{anchor:i,focus:c}=s,a=n(i.getNode(),ge),u=n(c.getNode(),ge);if(!ge(a)||!a.is(u))return!1;const h=Rt(a);if(h!==r&&null!=h){const n=rt(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=gt(h,n),Ot(e,t,o,h,l)}if("backward"===o||"forward"===o){const e=i.type,l=i.offset,c=i.getNode();if(!c)return!1;const u=s.getNodes();return(1!==u.length||!q(u[0]))&&(!!function(e,t,o,r){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,t,o,r){const l=n(o,(e=>g(e)&&!e.isInline()));if(!l)return!1;const s="backward"===r?0===t:t===o.getTextContentSize();return"text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,t,o,r)}(e,l,c,o)&&function(e,t,o,r,l){const[s,i]=Ue(r,o,o);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(s,i,l))return!1;const c=function(e,t,o){const r=n(e,(e=>g(e)&&!e.isInline()));if(!r)return;const l="backward"===t?r.getPreviousSibling():r.getNextSibling();return l&&Jt(l)?l:"backward"===t?o.getPreviousSibling():o.getNextSibling()}(t,l,r);if(!c||Jt(c))return!1;Ft(e),"backward"===l?c.selectEnd():c.selectStart();return!0}(t,c,a,r,o))}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return!1;let m;if("element"===i.type)m=f.getBoundingClientRect();else{const t=k(lt(e));if(null===t||0===t.rangeCount)return!1;m=t.getRangeAt(0).getBoundingClientRect()}const p="up"===o?a.getFirstChild():a.getLastChild();if(null==p)return!1;const S=e.getElementByKey(p.__key);if(null==S)return!1;const C=S.getBoundingClientRect();if("up"===o?C.top>m.top-m.height:m.bottom+m.height>C.bottom){Ft(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return St(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}else if(Ve(s)){const{anchor:i,focus:c}=s,a=n(i.getNode(),ge),u=n(c.getNode(),ge),[h]=s.getNodes();Jt(h)||pe(251);const d=rt(h,e.getElementByKey(h.getKey()));if(!ge(a)||!ge(u)||!Jt(h)||null==d)return!1;l.$updateTableTableSelection(s);const g=gt(h,d),f=r.getCordsFromCellNode(a,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.$setAnchorCellForSelection(m),Ft(t),t.shiftKey){const[e,t,n]=Ue(r,a,u);return bt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function Ft(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function kt(e,t,n){const o=d();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function Kt(e,t,o){const r=o.getParent();if(!r)return;const l=k(lt(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=rt(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=n(t.anchor.getNode(),(e=>ge(e)));if(!a)return;const u=n(a,(e=>Jt(e)));if(!Jt(u)||!u.is(o))return;const[h,d]=Ue(o,a,a),g=h[0][0],f=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,S=m===g.startRow&&p===g.startColumn,C=m===f.startRow&&p===f.startColumn;return S?"first":C?"last":void 0}function Et(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Mt(e,t,n){return st(e,U(t,n))}function At(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function $t(t,n,r){r?(e(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(o(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}function Ht(t,n,r){if(!n.theme.tableAlignment)return;const l=[],s=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===r?s:l).push(t)}o(t,...l),e(t,...s)}const Lt=new WeakSet;function Pt(e=R()){return Lt.has(e)}function Wt(e,t){t?Lt.add(e):Lt.delete(e)}class Bt extends u{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Bt(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:It,priority:1})}}static importJSON(e){return Ut().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&pe(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table"),r=document.createElement("colgroup");if(o.appendChild(r),At(o,0,this.getColumnCount(),this.getColWidths()),re(r),e(o,t.theme.table),Ht(o,t,this.getFormatType()),this.__rowStriping&&$t(o,t,!0),Pt(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),n}return o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&$t(t,n,this.__rowStriping),At(t,0,this.getColumnCount(),this.getColWidths()),Ht(this.getDOMSlot(t).element,n,this.getFormatType()),!1}exportDOM(e){const t=super.exportDOM(e),{element:n}=t;return{after:n=>{if(t.after&&(n=t.after(n),this.__format&&Ht(n,e._config,this.getFormatType())),l(n)&&"TABLE"!==n.nodeName&&(n=n.querySelector("table")),!l(n))return null;const[o]=Je(this,null,null),r=new Map;for(const e of o)for(const t of e){const e=t.cell.getKey();r.has(e)||r.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=r.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){r.delete(t);for(let e=0;e<n.colSpan;e++)s.add(e+n.startColumn)}}}const i=n.querySelector(":scope > colgroup");if(i){const e=Array.from(n.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>s.has(t)));i.replaceChildren(...e)}const c=n.querySelectorAll(":scope > tr");if(c.length>0){const e=document.createElement("tbody");for(const t of c)e.appendChild(t);n.append(e)}return n},element:l(n)&&"TABLE"!==n.nodeName?n.querySelector("table"):n}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=Mt(this,l);if(null!==s&&e.is(s))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=U(o.elem);return ge(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{ge(e)&&(t+=e.getColSpan())})),t}}function Dt(e,t){const n=e.getElementByKey(t.getKey());return null===n&&pe(230),gt(t,n)}function It(e){const n=Ut();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!ce.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:e=>t(e,we),node:n}}function Ut(){return p(new Bt)}function Jt(e){return e instanceof Bt}function zt({rows:e,columns:t,includeHeaders:n}){const o=xe(Number(e),Number(t),n);c(o);const r=o.getFirstDescendant();return m(r)&&r.select(),!0}function Yt(e){we(e.getParent())?e.isEmpty()&&e.append(d()):e.remove()}function qt(e){Jt(e.getParent())?a(e,ge):e.remove()}function Xt(e){a(e,we);const[t]=Je(e,null,null),n=t.reduce(((e,t)=>Math.max(e,t.length)),0),o=e.getChildren();for(let e=0;e<t.length;++e){const r=o[e];if(!r)continue;we(r)||pe(254,r.constructor.name,r.getType());const l=t[e].reduce(((e,t)=>t?1+e:e),0);if(l!==n)for(let e=l;e<n;++e){const e=de();e.append(d()),r.append(e)}}}function jt(e){return e.registerNodeTransform(ue,(e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=ze(e),[n]=Ue(t,e,e),o=n.length,r=n[0].length;let l=t.getFirstChild();we(l)||pe(175);const i=[];for(let e=0;e<o;e++){0!==e&&(l=l.getNextSibling(),we(l)||pe(175));let t=null;for(let o=0;o<r;o++){const r=n[e][o],c=r.cell;if(r.startRow===e&&r.startColumn===o)t=c,i.push(c);else if(c.getColSpan()>1||c.getRowSpan()>1){ge(c)||pe(176);const e=de(c.__headerState);null!==t?t.insertAfter(e):s(l,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}}))}function Vt(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=rt(o,l),i=ut(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(Bt,(t=>{e.getEditorState().read((()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=et(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}}function Gt(e){return e.hasNodes([Bt])||pe(255),i(e.registerCommand(fe,zt,le),e.registerNodeTransform(Bt,Xt),e.registerNodeTransform(Se,qt),e.registerNodeTransform(ue,Yt))}export{Ue as $computeTableMap,Je as $computeTableMapSkipCellCheck,de as $createTableCellNode,Ut as $createTableNode,xe as $createTableNodeWithDimensions,_e as $createTableRowNode,Ge as $createTableSelection,Qe as $createTableSelectionFrom,Le as $deleteTableColumn,We as $deleteTableColumn__EXPERIMENTAL,Pe as $deleteTableRow__EXPERIMENTAL,vt as $findCellNode,Rt as $findTableNode,Dt as $getElementForTableNode,ze as $getNodeTriplet,et as $getTableAndElementByKey,Te as $getTableCellNodeFromLexicalNode,qe as $getTableCellNodeRect,Fe as $getTableColumnIndexFromTableCellNode,Re as $getTableNodeFromLexicalNodeOrThrow,Oe as $getTableRowIndexFromTableCellNode,ve as $getTableRowNodeFromTableCellNodeOrThrow,$e as $insertTableColumn,He as $insertTableColumn__EXPERIMENTAL,Ee as $insertTableRow,Ae as $insertTableRow__EXPERIMENTAL,Pt as $isScrollableTablesActive,ge as $isTableCellNode,Jt as $isTableNode,we as $isTableRowNode,Ve as $isTableSelection,Ke as $removeTableRowAtIndex,Ie as $unmergeCell,fe as INSERT_TABLE_COMMAND,ae as TableCellHeaderStates,ue as TableCellNode,Bt as TableNode,tt as TableObserver,Se as TableRowNode,ut as applyTableHandlers,dt as getDOMCellFromTarget,rt as getTableElement,ht as getTableObserverFromTableElement,jt as registerTableCellUnmergeTransform,Gt as registerTablePlugin,Vt as registerTableSelectionObserver,Wt as setScrollableTablesActive};
9
+ import{addClassNamesToElement as e,$descendantsMatching as t,$findMatchingParent as n,removeClassNamesFromElement as o,objectKlassEquals as r,isHTMLElement as l,$insertFirst as s,mergeRegister as i,$insertNodeToNearestRoot as c,$unwrapAndFilterDescendants as a}from"@lexical/utils";import{ElementNode as u,isHTMLElement as h,$createParagraphNode as d,$isElementNode as g,$isLineBreakNode as f,$isTextNode as m,$applyNodeReplacement as p,createCommand as S,$createTextNode as C,$getSelection as _,$isRangeSelection as w,$createPoint as b,$isParagraphNode as y,$normalizeSelection__EXPERIMENTAL as N,isCurrentlyReadOnlyMode as x,TEXT_TYPE_TO_FORMAT as v,$getNodeByKey as T,$getEditor as R,$setSelection as O,SELECTION_CHANGE_COMMAND as F,getDOMSelection as A,$createRangeSelection as k,COMMAND_PRIORITY_HIGH as K,KEY_ESCAPE_COMMAND as E,COMMAND_PRIORITY_CRITICAL as M,CUT_COMMAND as $,FORMAT_TEXT_COMMAND as L,FORMAT_ELEMENT_COMMAND as W,CONTROLLED_TEXT_INSERTION_COMMAND as H,KEY_TAB_COMMAND as P,FOCUS_COMMAND as B,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as D,$getPreviousSelection as I,$getNearestNodeFromDOMNode as U,$createRangeSelectionFromDom as J,INSERT_PARAGRAPH_COMMAND as z,$isRootOrShadowRoot as Y,$isDecoratorNode as q,KEY_ARROW_DOWN_COMMAND as X,KEY_ARROW_UP_COMMAND as j,KEY_ARROW_LEFT_COMMAND as V,KEY_ARROW_RIGHT_COMMAND as G,DELETE_WORD_COMMAND as Q,DELETE_LINE_COMMAND as Z,DELETE_CHARACTER_COMMAND as ee,KEY_BACKSPACE_COMMAND as te,KEY_DELETE_COMMAND as ne,isDOMNode as oe,setDOMUnmanaged as re,COMMAND_PRIORITY_EDITOR as le}from"lexical";import{copyToClipboard as se,$getClipboardDataFromSelection as ie}from"@lexical/clipboard";const ce=/^(\d+(?:\.\d+)?)px$/,ae={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class ue extends u{static getType(){return"tablecell"}static clone(e){return new ue(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:de,priority:0}),th:e=>({conversion:de,priority:0})}}static importJSON(e){return ge().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=ae.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),he(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(h(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...he(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ae.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ae.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function he(e){return"middle"===e||"bottom"===e}function de(e){const t=e,n=e.nodeName.toLowerCase();let o;ce.test(t.style.width)&&(o=parseFloat(t.style.width));const r=ge("th"===n?ae.ROW:ae.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style.verticalAlign;he(s)&&(r.__verticalAlign=s);const i=t.style,c=(i&&i.textDecoration||"").split(" "),a="700"===i.fontWeight||"bold"===i.fontWeight,u=c.includes("line-through"),h="italic"===i.fontStyle,p=c.includes("underline");return{after:e=>(0===e.length&&e.push(d()),e),forChild:(e,t)=>{if(fe(t)&&!g(e)){const t=d();return f(e)&&"\n"===e.getTextContent()?null:(m(e)&&(a&&e.toggleFormat("bold"),u&&e.toggleFormat("strikethrough"),h&&e.toggleFormat("italic"),p&&e.toggleFormat("underline")),t.append(e),t)}return e},node:r}}function ge(e=ae.NO_STATUS,t=1,n){return p(new ue(e,t,n))}function fe(e){return e instanceof ue}const me=S("INSERT_TABLE_COMMAND");function pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Se=pe((function(e){const t=new URLSearchParams;t.append("code",e);for(let e=1;e<arguments.length;e++)t.append("v",arguments[e]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}));class Ce extends u{static getType(){return"tablerow"}static clone(e){return new Ce(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:_e,priority:0})}}static importJSON(e){return we().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),e(n,t.theme.tableRow),n}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function _e(e){const n=e;let o;return ce.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>t(e,fe),node:we(o)}}function we(e){return p(new Ce(e))}function be(e){return e instanceof Ce}const ye="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Ne=ye&&"documentMode"in document?document.documentMode:null,xe=ye&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function ve(e,t,n=!0){const o=Jt();for(let r=0;r<e;r++){const e=we();for(let o=0;o<t;o++){let t=ae.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=ae.ROW),0===o&&n.columns&&(t|=ae.COLUMN)):n&&(0===r&&(t|=ae.ROW),0===o&&(t|=ae.COLUMN));const l=ge(t),s=d();s.append(C()),l.append(s),e.append(l)}o.append(e)}return o}function Te(e){const t=n(e,(e=>fe(e)));return fe(t)?t:null}function Re(e){const t=n(e,(e=>be(e)));if(be(t))return t;throw new Error("Expected table cell to be inside of table row.")}function Oe(e){const t=n(e,(e=>zt(e)));if(zt(t))return t;throw new Error("Expected table cell to be inside of table.")}function Fe(e){const t=Re(e);return Oe(t).getChildren().findIndex((e=>e.is(t)))}function Ae(e){return Re(e).getChildren().findIndex((t=>t.is(e)))}function ke(e,t){const n=Oe(e),{x:o,y:r}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,r-1,t),below:n.getCellNodeFromCords(o,r+1,t),left:n.getCellNodeFromCords(o-1,r,t),right:n.getCellNodeFromCords(o+1,r,t)}}function Ke(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function Ee(e,t,n=!0,o,r){const l=e.getChildren();if(t>=l.length||t<0)throw new Error("Table row target index out of range");const s=l[t];if(!be(s))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=s.getChildren(),t=e.length,o=we();for(let n=0;n<t;n++){const t=e[n];fe(t)||Se(12);const{above:l,below:s}=ke(t,r);let i=ae.NO_STATUS;const c=l&&l.getWidth()||s&&s.getWidth()||void 0;(l&&l.hasHeaderState(ae.COLUMN)||s&&s.hasHeaderState(ae.COLUMN))&&(i|=ae.COLUMN);const a=ge(i,1,c);a.append(d()),o.append(a)}n?s.insertAfter(o):s.insertBefore(o)}return e}ye&&"InputEvent"in window&&!Ne&&new window.InputEvent("input");const Me=(e,t)=>e===ae.BOTH||e===t?t:ae.NO_STATUS;function $e(e=!0){const t=_();w(t)||Ge(t)||Se(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Ye(n),[l,,s]=Ye(o),[i,c,a]=Je(s,l,r),u=i[0].length,{startRow:h}=a,{startRow:g}=c;let f=null;if(e){const e=Math.max(g+l.__rowSpan,h+r.__rowSpan)-1,t=i[e],n=we();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l+r.__rowSpan-1<=e){const e=t[o].cell.__headerState,r=Me(e,ae.COLUMN);n.append(ge(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);be(o)||Se(256),o.insertAfter(n),f=n}else{const e=Math.min(g,h),t=i[e],n=we();for(let o=0;o<u;o++){const{cell:r,startRow:l}=t[o];if(l===e){const e=t[o].cell.__headerState,r=Me(e,ae.COLUMN);n.append(ge(r).append(d()))}else r.setRowSpan(r.__rowSpan+1)}const o=s.getChildAtIndex(e);be(o)||Se(257),o.insertBefore(n),f=n}return f}function Le(e,t,n=!0,o,r){const l=e.getChildren(),s=[];for(let e=0;e<l.length;e++){const n=l[e];if(be(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];fe(o)||Se(12);const{left:l,right:i}=ke(o,r);let c=ae.NO_STATUS;(l&&l.hasHeaderState(ae.ROW)||i&&i.hasHeaderState(ae.ROW))&&(c|=ae.ROW);const a=ge(c);a.append(d()),s.push({newTableCell:a,targetCell:o})}}return s.forEach((({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)})),e}function We(e=!0){const t=_();w(t)||Ge(t)||Se(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=Ye(n),[l,,s]=Ye(o),[i,c,a]=Je(s,l,r),u=i.length,h=e?Math.max(c.startColumn,a.startColumn):Math.min(c.startColumn,a.startColumn),g=e?h+l.__colSpan-1:h-1,f=s.getFirstChild();be(f)||Se(120);let m=null;function p(e=ae.NO_STATUS){const t=ge(e).append(d());return null===m&&(m=t),t}let S=f;e:for(let e=0;e<u;e++){if(0!==e){const e=S.getNextSibling();be(e)||Se(121),S=e}const t=i[e],n=t[g<0?0:g].cell.__headerState,o=Me(n,ae.ROW);if(g<0){Ie(S,p(o));continue}const{cell:r,startColumn:l,startRow:s}=t[g];if(l+r.__colSpan-1<=g){let n=r,l=s,i=g;for(;l!==e&&n.__rowSpan>1;){if(i-=r.__colSpan,!(i>=0)){S.append(p(o));continue e}{const{cell:e,startRow:o}=t[i];n=e,l=o}}n.insertAfter(p(o))}else r.setColSpan(r.__colSpan+1)}null!==m&&De(m);const C=s.getColWidths();if(C){const e=[...C],t=g<0?0:g,n=e[t];e.splice(t,0,n),s.setColWidths(e)}return m}function He(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(be(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function Pe(){const e=_();w(e)||Ge(e)||Se(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=Ye(t),[l]=Ye(n),[s,i,c]=Je(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;if(s.length===h-a+1)return void r.remove();const d=s[0].length,g=o.__rowSpan,f=s[h+1],m=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(e===a&&o<a){const e=a-o;n.setRowSpan(n.__rowSpan-Math.min(g,n.__rowSpan-e))}if(o>=a&&o+n.__rowSpan-1>h){n.setRowSpan(n.__rowSpan-(h-o+1)),null===m&&Se(122);let r=null;for(let n=0;n<t;n++){const t=f[n],o=t.cell;t.startRow===e+1&&(r=o),o.__colSpan>1&&(n+=o.__colSpan-1)}null===r?Ie(m,n):r.insertAfter(n)}}}const t=r.getChildAtIndex(e);be(t)||Se(206,String(e)),t.remove()}if(void 0!==f){const{cell:e}=f[0];De(e)}else{const e=s[a-1],{cell:t}=e[0];De(t)}}function Be(){const e=_();w(e)||Ge(e)||Se(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=Ye(t),[l]=Ye(n),[s,i,c]=Je(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),g=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),f=g-d+1;if(s[0].length===g-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;e<m;e++)for(let t=d;t<=g;t++){const{cell:n,startColumn:o}=s[e][t];if(o<d){if(t===d){const e=d-o;n.setColSpan(n.__colSpan-Math.min(f,n.__colSpan-e))}}else if(o+n.__colSpan-1>g){if(t===g){const e=g-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=s[u],S=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==S){const{cell:e}=S;De(e)}else{const e=h<a?p[h-1]:p[a-1],{cell:t}=e;De(t)}const C=r.getColWidths();if(C){const e=[...C];e.splice(d,f),r.setColWidths(e)}}function De(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Ie(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Ue(){const e=_();w(e)||Ge(e)||Se(188);const t=e.anchor.getNode(),[n,o,r]=Ye(t),l=n.__colSpan,s=n.__rowSpan;if(1===l&&1===s)return;const[i,c]=Je(r,n,n),{startColumn:a,startRow:u}=c,h=n.__headerState&ae.COLUMN,g=Array.from({length:l},((e,t)=>{let n=h;for(let e=0;0!==n&&e<i.length;e++)n&=i[e][t+a].cell.__headerState;return n})),f=n.__headerState&ae.ROW,m=Array.from({length:s},((e,t)=>{let n=f;for(let e=0;0!==n&&e<i[0].length;e++)n&=i[t+u][e].cell.__headerState;return n}));if(l>1){for(let e=1;e<l;e++)n.insertAfter(ge(g[e]|m[0]).append(d()));n.setColSpan(1)}if(s>1){let e;for(let t=1;t<s;t++){const n=u+t,r=i[n];e=(e||o).getNextSibling(),be(e)||Se(125);let s=null;for(let e=0;e<a;e++){const t=r[e],o=t.cell;t.startRow===n&&(s=o),o.__colSpan>1&&(e+=o.__colSpan-1)}if(null===s)for(let n=l-1;n>=0;n--)Ie(e,ge(g[n]|m[t]).append(d()));else for(let e=l-1;e>=0;e--)s.insertAfter(ge(g[e]|m[t]).append(d()))}n.setRowSpan(1)}}function Je(e,t,n){const[o,r,l]=ze(e,t,n);return null===r&&Se(207),null===l&&Se(208),[o,r,l]}function ze(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];be(o)||Se(209);const c=s(e);for(let a=o.getFirstChild(),u=0;null!=a;a=a.getNextSibling()){for(fe(a)||Se(147);void 0!==c[u];)u++;const o={cell:a,startColumn:u,startRow:e},{__rowSpan:h,__colSpan:d}=a;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[u+e]=o}null!==t&&null===r&&t.is(a)&&(r=o),null!==n&&null===l&&n.is(a)&&(l=o)}}return[o,r,l]}function Ye(e){let t;if(e instanceof ue)t=e;else if("__type"in e){const o=n(e,fe);fe(o)||Se(148),t=o}else{const o=n(e.getNode(),fe);fe(o)||Se(148),t=o}const o=t.getParent();be(o)||Se(149);const r=o.getParent();return zt(r)||Se(210),[t,o,r]}function qe(e,t,n){let o=Math.min(t.startColumn,n.startColumn),r=Math.min(t.startRow,n.startRow),l=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),s=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1),i=o,c=r,a=o,u=r;function h(e){const{cell:t,startColumn:n,startRow:i}=e;o=Math.min(o,n),r=Math.min(r,i),l=Math.max(l,n+t.__colSpan-1),s=Math.max(s,i+t.__rowSpan-1)}for(;o<i||r<c||l>a||s>u;){if(o<i){const t=u-c,n=i-1;for(let o=0;o<=t;o++)h(e[c+o][n]);i=n}if(r<c){const t=a-i,n=c-1;for(let o=0;o<=t;o++)h(e[n][i+o]);c=n}if(l>a){const t=u-c,n=a+1;for(let o=0;o<=t;o++)h(e[c+o][n]);a=n}if(s>u){const t=a-i,n=u+1;for(let o=0;o<=t;o++)h(e[n][i+o]);u=n}}return{maxColumn:l,maxRow:s,minColumn:o,minRow:r}}function Xe(e){const[t,,n]=Ye(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,c=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][r+n]=l;if(t===l)return{colSpan:c,columnIndex:r,rowIndex:e,rowSpan:i};r+=c}}return null}function je(e){const[[t,o,r,l],[s,i,c,a]]=["anchor","focus"].map((t=>{const o=e[t].getNode(),r=n(o,fe);fe(r)||Se(238,t,o.getKey(),o.getType());const l=r.getParent();be(l)||Se(239,t);const s=l.getParent();return zt(s)||Se(240,t),[o,r,l,s]}));return l.is(a)||Se(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class Ve{constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){return"root"!==this.tableKey&&"root"!==this.anchor.key&&"element"===this.anchor.type&&"root"!==this.focus.key&&"element"===this.focus.type}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return Ge(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new Ve(this.tableKey,b(this.anchor.key,this.anchor.offset,this.anchor.type),b(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(fe).forEach((e=>{const n=e.getFirstChild();y(n)&&(t|=n.getTextFormat())}));const n=v[e];return!!(t&n)}insertNodes(e){const t=this.focus.getNode();g(t)||Se(151);N(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=je(this),n=Xe(e);null===n&&Se(153);const o=Xe(t);null===o&&Se(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=je(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&Se(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&Se(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=Je(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=qe(l,s,i),d=new Map([[t.getKey(),t]]);let g=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();be(o)||Se(160),o!==g&&(d.set(o.getKey(),o),g=o),d.has(n.getKey())||et(n,(e=>{d.set(e.getKey(),e)}))}const f=Array.from(d.values());return x()||(this._cachedNodes=f),f}getTextContent(){const e=this.getNodes().filter((e=>fe(e)));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t")}return t}}function Ge(e){return e instanceof Ve}function Qe(){const e=b("root",0,"element"),t=b("root",0,"element");return new Ve("root",e,t)}function Ze(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=_(),r=Ge(o)?o.clone():Qe();return r.set(e.getKey(),t.getKey(),n.getKey()),r}function et(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&g(o)&&n.push(o.getChildren())}}function tt(e,t=R()){const n=T(e);zt(n)||Se(231,e);const o=lt(n,t.getElementByKey(e));return null===o&&Se(232,e),{tableElement:o,tableNode:n}}class nt{constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return tt(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=!0;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=ft(n,o)}),{editor:this.editor})}));this.editor.getEditorState().read((()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=ft(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();mt(e,ft(t,n),null),null!==_()&&(O(null),e.dispatchCommand(F,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();o(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();e(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&Se(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),mt(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=A(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=Mt(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=Ze(o,this.$getAnchorTableCellOrThrow(),t),O(this.tableSelection),n.dispatchCommand(F,void 0),mt(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?T(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Se(234),e}$getFocusTableCell(){return this.focusCellNodeKey?T(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Se(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=Mt(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():Qe(),this.anchorCellNodeKey=e}}$formatCells(e){const t=_();Ge(t)||Se(236);const n=k(),o=n.anchor,r=n.focus,l=t.getNodes().filter(fe);l.length>0||Se(237);const s=l[0].getFirstChild(),i=y(s)?s.getFormatFlags(e,null):null;l.forEach((t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)})),O(t),this.editor.dispatchCommand(F,void 0)}$clearText(){const{editor:e}=this,t=T(this.tableNodeKey);if(!zt(t))throw new Error("Expected TableNode.");const n=_();Ge(n)||Se(253);const o=n.getNodes().filter(fe);if(o.length===this.table.columns*this.table.rows)return t.selectPrevious(),void t.remove();o.forEach((e=>{if(g(e)){const t=d(),n=C();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),mt(e,this.table,null),O(null),e.dispatchCommand(F,void 0)}}const ot="__lexicalTableSelection",rt=e=>!(1&~e.buttons);function lt(e,t){if(!t)return t;const n="TABLE"===t.nodeName?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&Se(245,t.nodeName),n}function st(e){return e._window}function it(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;fe(n)&&(o=n)}return null}const ct=[[X,"down"],[j,"up"],[V,"backward"],[G,"forward"]],at=[Q,Z,ee],ut=[te,ne];function ht(e,t,o,l){const s=o.getRootElement(),i=st(o);null!==s&&null!==i||Se(246);const c=new nt(o,e.getKey()),a=lt(e,t);!function(e,t){null!==dt(e)&&Se(205);e[ot]=t}(a,c),c.listenersToRemove.add((()=>function(e,t){dt(e)===t&&delete e[ot]}(a,c)));a.addEventListener("mousedown",(t=>{if(0!==t.button||!oe(t.target)||!i)return;const n=gt(t.target);null!==n&&o.update((()=>{const o=I();if(xe&&t.shiftKey&&Nt(o,e)&&(w(o)||Ge(o))){const r=o.anchor.getNode(),l=it(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(Et(c,l)),c.$setFocusCellForSelection(n),At(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else c.$setAnchorCellForSelection(n)})),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,i.removeEventListener("mouseup",e),i.removeEventListener("mousemove",t)},t=n=>{if(!oe(n.target))return;if(!rt(n)&&c.isSelecting)return c.isSelecting=!1,i.removeEventListener("mouseup",e),void i.removeEventListener("mousemove",t);const r=!a.contains(n.target);let l=null;if(r){for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(l=a.contains(e)?gt(e):null,l)break}else l=gt(n.target);!l||null!==c.focusCell&&l.elem===c.focusCell.elem||(c.setNextFocus({focusCell:l,override:r}),o.dispatchCommand(F,void 0))};c.isSelecting=!0,i.addEventListener("mouseup",e,c.listenerOptions),i.addEventListener("mousemove",t,c.listenerOptions)})()}),c.listenerOptions);i.addEventListener("mousedown",(e=>{const t=e.target;0===e.button&&oe(t)&&o.update((()=>{const e=_();Ge(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight()}))}),c.listenerOptions);for(const[t,n]of ct)c.listenersToRemove.add(o.registerCommand(t,(t=>Ft(o,t,n,e,c)),K));c.listenersToRemove.add(o.registerCommand(E,(t=>{const n=_();if(Ge(n)){const o=it(e,n.focus.getNode());if(null!==o)return At(t),o.selectEnd(),!0}return!1}),K));const u=t=>()=>{const o=_();if(!Nt(o,e))return!1;if(Ge(o))return c.$clearText(),!0;if(w(o)){if(!fe(it(e,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),i=e.isParentOf(l);if(s&&!i||i&&!s)return c.$clearText(),!0;const a=n(o.anchor.getNode(),(e=>g(e))),u=a&&n(a,(e=>g(e)&&fe(e.getParent())));if(!g(u)||!g(a))return!1;if(t===Z&&null===u.getPreviousSibling())return!0}return!1};for(const e of at)c.listenersToRemove.add(o.registerCommand(e,u(e),M));const h=t=>{const n=_();if(!Ge(n)&&!w(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),!1}return!!Nt(n,e)&&(!!Ge(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),!0))};for(const e of ut)c.listenersToRemove.add(o.registerCommand(e,h,M));return c.listenersToRemove.add(o.registerCommand($,(e=>{const t=_();if(t){if(!Ge(t)&&!w(t))return!1;se(o,r(e,ClipboardEvent)?e:null,ie(t));const n=h(e);return w(t)?(t.removeText(),!0):n}return!1}),M)),c.listenersToRemove.add(o.registerCommand(L,(t=>{const o=_();if(!Nt(o,e))return!1;if(Ge(o))return c.$formatCells(t),!0;if(w(o)){const e=n(o.anchor.getNode(),(e=>fe(e)));if(!fe(e))return!1}return!1}),M)),c.listenersToRemove.add(o.registerCommand(W,(t=>{const n=_();if(!Ge(n)||!Nt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!fe(o)||!fe(r))return!1;if(function(e,t){if(Ge(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=Je(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,e))return e.setFormat(t),!0;const[l,s,i]=Je(e,o,r),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),h=Math.min(s.startColumn,i.startColumn),d=new Set;for(let e=u;e<=c;e++)for(let n=h;n<=a;n++){const o=l[e][n].cell;if(d.has(o))continue;d.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];g(n)&&!n.isInline()&&n.setFormat(t)}}return!0}),M)),c.listenersToRemove.add(o.registerCommand(H,(t=>{const r=_();if(!Nt(r,e))return!1;if(Ge(r))return c.$clearHighlight(),!1;if(w(r)){const l=n(r.anchor.getNode(),(e=>fe(e)));if(!fe(l))return!1;if("string"==typeof t){const n=Kt(o,r,e);if(n)return kt(n,e,[C(t)]),!0}}return!1}),M)),l&&c.listenersToRemove.add(o.registerCommand(P,(t=>{const o=_();if(!w(o)||!o.isCollapsed()||!Nt(o,e))return!1;const r=Rt(o.anchor.getNode());return!(null===r||!e.is(Ot(r)))&&(At(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(g(l))return l.selectEnd();const s=n(e,be);null===s&&Se(247);for(let e=s[o]();be(e);e=e[o]()){const t=e[r]();if(g(t))return t.selectEnd()}const i=n(s,zt);null===i&&Se(248);"next"===t?i.selectNext():i.selectPrevious()}(r,t.shiftKey?"previous":"next"),!0)}),M)),c.listenersToRemove.add(o.registerCommand(B,(t=>e.isSelected()),K)),c.listenersToRemove.add(o.registerCommand(D,(e=>{const{nodes:t,selection:o}=e,r=o.getStartEndPoints(),l=Ge(o),s=w(o)&&null!==n(o.anchor.getNode(),(e=>fe(e)))&&null!==n(o.focus.getNode(),(e=>fe(e)))||l;if(1!==t.length||!zt(t[0])||!s||null===r)return!1;const[i]=r,c=t[0],a=c.getChildren(),u=c.getFirstChildOrThrow().getChildrenSize(),h=c.getChildrenSize(),g=n(i.getNode(),(e=>fe(e))),f=g&&n(g,(e=>be(e))),p=f&&n(f,(e=>zt(e)));if(!fe(g)||!be(f)||!zt(p))return!1;const S=f.getIndexWithinParent(),C=Math.min(p.getChildrenSize()-1,S+h-1),_=g.getIndexWithinParent(),b=Math.min(f.getChildrenSize()-1,_+u-1),y=Math.min(_,b),N=Math.min(S,C),x=Math.max(_,b),v=Math.max(S,C),T=p.getChildren();let R=0;for(let e=N;e<=v;e++){const t=T[e];if(!be(t))return!1;const n=a[R];if(!be(n))return!1;const o=t.getChildren(),r=n.getChildren();let l=0;for(let e=y;e<=x;e++){const t=o[e];if(!fe(t))return!1;const n=r[l];if(!fe(n))return!1;const s=t.getChildren();n.getChildren().forEach((e=>{if(m(e)){d().append(e),t.append(e)}else t.append(e)})),s.forEach((e=>e.remove())),l++}R++}return!0}),M)),c.listenersToRemove.add(o.registerCommand(F,(()=>{const t=_(),r=I(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(Ge(t)&&t.tableKey===c.tableNodeKey)return(n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),!0);if(n!==c.anchorCell&&Nt(t,e))return c.$setFocusCellForSelection(n),!0}if(c.getAndClearShouldCheckSelection()&&w(r)&&w(t)&&t.isCollapsed()){const o=t.anchor.getNode(),r=e.getFirstChild(),l=Rt(o);if(null!==l&&be(r)){const t=r.getFirstChild();if(fe(t)&&e.is(n(l,(n=>n.is(e)||n.is(t)))))return t.selectStart(),!0}}if(w(t)){const{anchor:n,focus:r}=t,l=n.getNode(),s=r.getNode(),i=Rt(l),a=Rt(s),u=!(!i||!e.is(Ot(i))),h=!(!a||!e.is(Ot(a))),d=u!==h,g=u&&h,f=t.isBackward();if(d){const n=t.clone();if(h){const[t]=Je(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(f?o.getKey():r.getKey(),f?o.getChildrenSize():r.getChildrenSize(),"element")}else if(u){const[t]=Je(e,i,i),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(f?r.getKey():o.getKey(),f?r.getChildrenSize():0,"element")}O(n),St(o,c)}else g&&(i.is(a)||(c.$setAnchorCellForSelection(Et(c,i)),c.$setFocusCellForSelection(Et(c,a),!0)))}else if(t&&Ge(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=A(i);if(n&&n.anchorNode&&n.focusNode){const r=U(n.focusNode),l=r&&!e.isParentOf(r),s=U(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=J(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),O(r))}}}return t&&!t.is(r)&&(Ge(t)||Ge(r))&&c.tableSelection&&!c.tableSelection.is(r)?(Ge(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!Ge(t)&&Ge(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),pt(t.table,(t=>{const n=t.elem;t.highlighted=!1,Tt(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&St(o,c),!1)}),M)),c.listenersToRemove.add(o.registerCommand(z,(()=>{const t=_();if(!w(t)||!t.isCollapsed()||!Nt(t,e))return!1;const n=Kt(o,t,e);return!!n&&(kt(n,e),!0)}),M)),c}function dt(e){return e[ot]||null}function gt(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function ft(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=lt(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:!1,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e}else{const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e}}return o.columns=l+1,o.rows=s+1,o}function mt(e,t,n){const o=new Set(n?n.getNodes():[]);pt(t,((t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,vt(e,t)):(t.highlighted=!1,Tt(e,t),r.getAttribute("style")||r.removeAttribute("style"))}))}function pt(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=U(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function St(e,t){t.$disableHighlightStyle(),pt(t.table,(t=>{t.highlighted=!0,vt(e,t)}))}const Ct=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?xt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?xt(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?xt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?xt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function _t(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function wt([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function bt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&Se(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&Se(250,n,String(s)),i}function yt(e,t,n,o,r){const l=qe(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=_t(e,t);return null===n&&Se(249,t.cell.getKey()),n}(l,n),[d,g]=wt(h);let f=l[d],m=l[g];"forward"===r?f+="maxColumn"===d?1:c:"backward"===r?f-="minColumn"===d?1:u:"down"===r?m+="maxRow"===g?1:i:"up"===r&&(m-="minRow"===g?1:a);const p=t[m];if(void 0===p)return!1;const S=p[f];if(void 0===S)return!1;const[C,_]=function(e,t,n){const o=qe(e,t,n),r=_t(o,t);if(r)return[bt(e,o,r),bt(e,o,wt(r))];const l=_t(o,n);if(l)return[bt(e,o,wt(l)),bt(e,o,l)];const s=["minColumn","minRow"];return[bt(e,o,s),bt(e,o,wt(s))]}(t,n,S),w=Et(e,C.cell),b=Et(e,_.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function Nt(e,t){if(w(e)||Ge(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function xt(e,t){t?e.selectStart():e.selectEnd()}function vt(t,n){const o=n.elem,r=t._config.theme;fe(U(o))||Se(131),e(o,r.tableCellSelected)}function Tt(e,t){const n=t.elem;fe(U(n))||Se(131);const r=e._config.theme;o(n,r.tableCellSelected)}function Rt(e){const t=n(e,fe);return fe(t)?t:null}function Ot(e){const t=n(e,zt);return zt(t)?t:null}function Ft(e,t,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const s=_();if(!Nt(s,r)){if(w(s)){if("backward"===o){if(s.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(g(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!zt(n)&&(At(t),t.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=n(e,(e=>zt(e)));if(fe(l)&&(l=n(l,zt)),l!==r)return!1;if(!l)return!1;const i="down"===o?l.getNextSibling():l.getPreviousSibling();if(!i)return!1;let c=0;"up"===o&&g(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&g(i)){const e=i.getLastChild();a=e||i,c=m(a)?a.getTextContentSize():0}const u=s.clone();return u.focus.set(a.getKey(),c,m(a)?"text":"element"),O(u),At(t),!0}if(Y(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==it(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=Ye(e),[o]=Ye(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),c=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let r=n(e,(e=>g(e)&&!e.isInline()));if(fe(r)&&(r=n(r,zt)),!r)return!1;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(zt(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return!1;const[r]=Ye(e),[l]=Ye(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),At(t),O(c),!0}}}}return"down"===o&&Pt(e)&&l.setShouldCheckSelection(),!1}if(w(s)&&s.isCollapsed()){const{anchor:i,focus:c}=s,a=n(i.getNode(),fe),u=n(c.getNode(),fe);if(!fe(a)||!a.is(u))return!1;const h=Ot(a);if(h!==r&&null!=h){const n=lt(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=ft(h,n),Ft(e,t,o,h,l)}if("backward"===o||"forward"===o){const e=i.type,l=i.offset,c=i.getNode();if(!c)return!1;const u=s.getNodes();return(1!==u.length||!q(u[0]))&&(!!function(e,t,o,r){return function(e,t,n){return"element"===e&&("backward"===n?null===t.getPreviousSibling():null===t.getNextSibling())}(e,o,r)||function(e,t,o,r){const l=n(o,(e=>g(e)&&!e.isInline()));if(!l)return!1;const s="backward"===r?0===t:t===o.getTextContentSize();return"text"===e&&s&&("backward"===r?null===l.getPreviousSibling():null===l.getNextSibling())}(e,t,o,r)}(e,l,c,o)&&function(e,t,o,r,l){const[s,i]=Je(r,o,o);if(!function(e,t,n){const o=e[0][0],r=e[e.length-1][e[0].length-1],{startColumn:l,startRow:s}=t;return"backward"===n?l===o.startColumn&&s===o.startRow:l===r.startColumn&&s===r.startRow}(s,i,l))return!1;const c=function(e,t,o){const r=n(e,(e=>g(e)&&!e.isInline()));if(!r)return;const l="backward"===t?r.getPreviousSibling():r.getNextSibling();return l&&zt(l)?l:"backward"===t?o.getPreviousSibling():o.getNextSibling()}(t,l,r);if(!c||zt(c))return!1;At(e),"backward"===l?c.selectEnd():c.selectStart();return!0}(t,c,a,r,o))}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return!1;let m;if("element"===i.type)m=f.getBoundingClientRect();else{const t=A(st(e));if(null===t||0===t.rangeCount)return!1;m=t.getRangeAt(0).getBoundingClientRect()}const p="up"===o?a.getFirstChild():a.getLastChild();if(null==p)return!1;const S=e.getElementByKey(p.__key);if(null==S)return!1;const C=S.getBoundingClientRect();if("up"===o?C.top>m.top-m.height:m.bottom+m.height>C.bottom){At(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return Ct(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}else if(Ge(s)){const{anchor:i,focus:c}=s,a=n(i.getNode(),fe),u=n(c.getNode(),fe),[h]=s.getNodes();zt(h)||Se(251);const d=lt(h,e.getElementByKey(h.getKey()));if(!fe(a)||!fe(u)||!zt(h)||null==d)return!1;l.$updateTableTableSelection(s);const g=ft(h,d),f=r.getCordsFromCellNode(a,g),m=r.getDOMCellFromCordsOrThrow(f.x,f.y,g);if(l.$setAnchorCellForSelection(m),At(t),t.shiftKey){const[e,t,n]=Je(r,a,u);return yt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function At(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function kt(e,t,n){const o=d();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function Kt(e,t,o){const r=o.getParent();if(!r)return;const l=A(st(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=lt(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=n(t.anchor.getNode(),(e=>fe(e)));if(!a)return;const u=n(a,(e=>zt(e)));if(!zt(u)||!u.is(o))return;const[h,d]=Je(o,a,a),g=h[0][0],f=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,S=m===g.startRow&&p===g.startColumn,C=m===f.startRow&&p===f.startColumn;return S?"first":C?"last":void 0}function Et(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Mt(e,t,n){return it(e,U(t,n))}function $t(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t)}r.replaceChildren(...l)}function Lt(t,n,r){r?(e(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(o(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"))}function Wt(t,n,r){if(!n.theme.tableAlignment)return;const l=[],s=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===r?s:l).push(t)}o(t,...l),e(t,...s)}const Ht=new WeakSet;function Pt(e=R()){return Ht.has(e)}function Bt(e,t){t?Ht.add(e):Ht.delete(e)}class Dt extends u{static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Dt(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping}static importDOM(){return{table:e=>({conversion:Ut,priority:1})}}static importJSON(e){return Jt().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t="TABLE"!==e.nodeName&&e.querySelector("table")||e;return"TABLE"!==t.nodeName&&Se(229),super.getDOMSlot(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table"),r=document.createElement("colgroup");if(o.appendChild(r),$t(o,0,this.getColumnCount(),this.getColWidths()),re(r),e(o,t.theme.table),Wt(o,t,this.getFormatType()),this.__rowStriping&&Lt(o,t,!0),Pt(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),n}return o}updateDOM(e,t,n){return e.__rowStriping!==this.__rowStriping&&Lt(t,n,this.__rowStriping),$t(t,0,this.getColumnCount(),this.getColWidths()),Wt(this.getDOMSlot(t).element,n,this.getFormatType()),!1}exportDOM(e){const t=super.exportDOM(e),{element:n}=t;return{after:n=>{if(t.after&&(n=t.after(n),this.__format&&Wt(n,e._config,this.getFormatType())),l(n)&&"TABLE"!==n.nodeName&&(n=n.querySelector("table")),!l(n))return null;const[o]=ze(this,null,null),r=new Map;for(const e of o)for(const t of e){const e=t.cell.getKey();r.has(e)||r.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const s=new Set;for(const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=r.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){r.delete(t);for(let e=0;e<n.colSpan;e++)s.add(e+n.startColumn)}}}const i=n.querySelector(":scope > colgroup");if(i){const e=Array.from(n.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>s.has(t)));i.replaceChildren(...e)}const c=n.querySelectorAll(":scope > tr");if(c.length>0){const e=document.createElement("tbody");for(const t of c)e.appendChild(t);n.append(e)}return n},element:l(n)&&"TABLE"!==n.nodeName?n.querySelector("table"):n}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=Mt(this,l);if(null!==s&&e.is(s))return{x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=U(o.elem);return fe(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach((e=>{fe(e)&&(t+=e.getColSpan())})),t}}function It(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Se(230),ft(t,n)}function Ut(e){const n=Jt();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!ce.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return{after:e=>t(e,be),node:n}}function Jt(){return p(new Dt)}function zt(e){return e instanceof Dt}function Yt({rows:e,columns:t,includeHeaders:n}){const o=ve(Number(e),Number(t),n);c(o);const r=o.getFirstDescendant();return m(r)&&r.select(),!0}function qt(e){be(e.getParent())?e.isEmpty()&&e.append(d()):e.remove()}function Xt(e){zt(e.getParent())?a(e,fe):e.remove()}function jt(e){a(e,be);const[t]=ze(e,null,null),n=t.reduce(((e,t)=>Math.max(e,t.length)),0),o=e.getChildren();for(let e=0;e<t.length;++e){const r=o[e];if(!r)continue;be(r)||Se(254,r.constructor.name,r.getType());const l=t[e].reduce(((e,t)=>t?1+e:e),0);if(l!==n)for(let e=l;e<n;++e){const e=ge();e.append(d()),r.append(e)}}}function Vt(e){return e.registerNodeTransform(ue,(e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=Ye(e),[n]=Je(t,e,e),o=n.length,r=n[0].length;let l=t.getFirstChild();be(l)||Se(175);const i=[];for(let e=0;e<o;e++){0!==e&&(l=l.getNextSibling(),be(l)||Se(175));let t=null;for(let o=0;o<r;o++){const r=n[e][o],c=r.cell;if(r.startRow===e&&r.startColumn===o)t=c,i.push(c);else if(c.getColSpan()>1||c.getRowSpan()>1){fe(c)||Se(176);const e=ge(c.__headerState);null!==t?t.insertAfter(e):s(l,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}}))}function Gt(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=lt(o,l),i=ht(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(Dt,(t=>{e.getEditorState().read((()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=tt(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l))}else"destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{r();for(const[,[e]]of n)e.removeListeners()}}function Qt(e){return e.hasNodes([Dt])||Se(255),i(e.registerCommand(me,Yt,le),e.registerNodeTransform(Dt,jt),e.registerNodeTransform(Ce,Xt),e.registerNodeTransform(ue,qt))}export{Je as $computeTableMap,ze as $computeTableMapSkipCellCheck,ge as $createTableCellNode,Jt as $createTableNode,ve as $createTableNodeWithDimensions,we as $createTableRowNode,Qe as $createTableSelection,Ze as $createTableSelectionFrom,He as $deleteTableColumn,Be as $deleteTableColumn__EXPERIMENTAL,Pe as $deleteTableRow__EXPERIMENTAL,Rt as $findCellNode,Ot as $findTableNode,It as $getElementForTableNode,Ye as $getNodeTriplet,tt as $getTableAndElementByKey,Te as $getTableCellNodeFromLexicalNode,Xe as $getTableCellNodeRect,Ae as $getTableColumnIndexFromTableCellNode,Oe as $getTableNodeFromLexicalNodeOrThrow,Fe as $getTableRowIndexFromTableCellNode,Re as $getTableRowNodeFromTableCellNodeOrThrow,Le as $insertTableColumn,We as $insertTableColumn__EXPERIMENTAL,Ee as $insertTableRow,$e as $insertTableRow__EXPERIMENTAL,Pt as $isScrollableTablesActive,fe as $isTableCellNode,zt as $isTableNode,be as $isTableRowNode,Ge as $isTableSelection,Ke as $removeTableRowAtIndex,Ue as $unmergeCell,me as INSERT_TABLE_COMMAND,ae as TableCellHeaderStates,ue as TableCellNode,Dt as TableNode,nt as TableObserver,Ce as TableRowNode,ht as applyTableHandlers,gt as getDOMCellFromTarget,lt as getTableElement,dt as getTableObserverFromTableElement,Vt as registerTableCellUnmergeTransform,Qt as registerTablePlugin,Gt as registerTableSelectionObserver,Bt as setScrollableTablesActive};
@@ -20,6 +20,7 @@ export type SerializedTableCellNode = Spread<{
20
20
  headerState: TableCellHeaderState;
21
21
  width?: number;
22
22
  backgroundColor?: null | string;
23
+ verticalAlign?: string;
23
24
  }, SerializedElementNode>;
24
25
  /** @noInheritDoc */
25
26
  export declare class TableCellNode extends ElementNode {
@@ -33,6 +34,8 @@ export declare class TableCellNode extends ElementNode {
33
34
  __width?: number | undefined;
34
35
  /** @internal */
35
36
  __backgroundColor: null | string;
37
+ /** @internal */
38
+ __verticalAlign?: undefined | string;
36
39
  static getType(): string;
37
40
  static clone(node: TableCellNode): TableCellNode;
38
41
  afterCloneFrom(node: this): void;
@@ -54,6 +57,8 @@ export declare class TableCellNode extends ElementNode {
54
57
  getWidth(): number | undefined;
55
58
  getBackgroundColor(): null | string;
56
59
  setBackgroundColor(newBackgroundColor: null | string): this;
60
+ getVerticalAlign(): undefined | string;
61
+ setVerticalAlign(newVerticalAlign: null | undefined | string): this;
57
62
  toggleHeaderStyle(headerStateToToggle: TableCellHeaderState): this;
58
63
  hasHeaderState(headerState: TableCellHeaderState): boolean;
59
64
  hasHeader(): boolean;
package/package.json CHANGED
@@ -8,13 +8,13 @@
8
8
  "table"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.24.1-nightly.20250210.0",
11
+ "version": "0.24.1-nightly.20250212.0",
12
12
  "main": "LexicalTable.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/clipboard": "0.24.1-nightly.20250210.0",
16
- "@lexical/utils": "0.24.1-nightly.20250210.0",
17
- "lexical": "0.24.1-nightly.20250210.0"
15
+ "@lexical/clipboard": "0.24.1-nightly.20250212.0",
16
+ "@lexical/utils": "0.24.1-nightly.20250212.0",
17
+ "lexical": "0.24.1-nightly.20250212.0"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",