@lexical/table 0.36.3-nightly.20251002.0 → 0.36.3-nightly.20251006.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.
@@ -3659,6 +3659,7 @@ class TableNode extends lexical.ElementNode {
3659
3659
  this.__rowStriping = false;
3660
3660
  this.__frozenColumnCount = 0;
3661
3661
  this.__frozenRowCount = 0;
3662
+ this.__colWidths = undefined;
3662
3663
  }
3663
3664
  exportJSON() {
3664
3665
  return {
@@ -3657,6 +3657,7 @@ class TableNode extends ElementNode {
3657
3657
  this.__rowStriping = false;
3658
3658
  this.__frozenColumnCount = 0;
3659
3659
  this.__frozenRowCount = 0;
3660
+ this.__colWidths = undefined;
3660
3661
  }
3661
3662
  exportJSON() {
3662
3663
  return {
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- "use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/extension"),o=require("@lexical/clipboard");const r=/^(\d+(?:\.\d+)?)px$/,l={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class s extends t.ElementNode{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new s(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:a,priority:0}),th:e=>({conversion:a,priority:0})}}static importJSON(e){return c().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=l.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0}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=l.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!==l.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 a(e){const n=e,o=e.nodeName.toLowerCase();let s;r.test(n.style.width)&&(s=parseFloat(n.style.width));const a=c("th"===o?l.ROW:l.NO_STATUS,n.colSpan,s);a.__rowSpan=n.rowSpan;const u=n.style.backgroundColor;""!==u&&(a.__backgroundColor=u);const d=n.style.verticalAlign;i(d)&&(a.__verticalAlign=d);const h=n.style,g=(h&&h.textDecoration||"").split(" "),f="700"===h.fontWeight||"bold"===h.fontWeight,m=g.includes("line-through"),C="italic"===h.fontStyle,p=g.includes("underline");return{after:e=>{const n=[];let o=null;const r=()=>{if(o){const e=o.getFirstChild();t.$isLineBreakNode(e)&&1===o.getChildrenSize()&&e.remove()}};for(const l of e)t.$isInlineElementOrDecoratorNode(l)||t.$isTextNode(l)||t.$isLineBreakNode(l)?(t.$isTextNode(l)&&(f&&l.toggleFormat("bold"),m&&l.toggleFormat("strikethrough"),C&&l.toggleFormat("italic"),p&&l.toggleFormat("underline")),o?o.append(l):(o=t.$createParagraphNode().append(l),n.push(o))):(n.push(l),r(),o=null);return r(),0===n.length&&n.push(t.$createParagraphNode()),n},node:a}}function c(e=l.NO_STATUS,n=1,o){return t.$applyNodeReplacement(new s(e,n,o))}function u(e){return e instanceof s}const d=t.createCommand("INSERT_TABLE_COMMAND");function h(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class g extends t.ElementNode{__height;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 o;return r.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:t=>e.$descendantsMatching(t,u),node:m(o)}}function m(e){return t.$applyNodeReplacement(new g(e))}function C(e){return e instanceof g}const p="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,_=p&&"documentMode"in document?document.documentMode:null,S=p&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function N(e,n,o=!0){const r=He();for(let s=0;s<e;s++){const e=m();for(let r=0;r<n;r++){let n=l.NO_STATUS;"object"==typeof o?(0===s&&o.rows&&(n|=l.ROW),0===r&&o.columns&&(n|=l.COLUMN)):o&&(0===s&&(n|=l.ROW),0===r&&(n|=l.COLUMN));const i=c(n),a=t.$createParagraphNode();a.append(t.$createTextNode()),i.append(a),e.append(i)}r.append(e)}return r}function w(t){const n=e.$findMatchingParent(t,e=>C(e));if(C(n))return n;throw new Error("Expected table cell to be inside of table row.")}function b(t){const n=e.$findMatchingParent(t,e=>Be(e));if(Be(n))return n;throw new Error("Expected table cell to be inside of table.")}function T(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&&!_&&new window.InputEvent("input");const y=(e,t)=>e===l.BOTH||e===t?t:l.NO_STATUS;function $(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||J(n)||h(188);const o=n.anchor.getNode(),r=n.focus.getNode(),[l]=W(o),[s,,i]=W(r),[,a,c]=H(i,s,l),{startRow:u}=c,{startRow:d}=a;return e?M(u+l.__rowSpan>d+s.__rowSpan?l:s,!0):M(d<u?s:l,!1)}const R=$;function M(e,n=!0){const[,,o]=W(e),[r,s]=H(o,e,e),i=r[0].length,{startRow:a}=s;let u=null;if(n){const n=a+e.__rowSpan-1,s=r[n],d=m();for(let e=0;e<i;e++){const{cell:o,startRow:r}=s[e];if(r+o.__rowSpan-1<=n){const n=s[e].cell.__headerState,o=y(n,l.COLUMN);d.append(c(o).append(t.$createParagraphNode()))}else o.setRowSpan(o.__rowSpan+1)}const g=o.getChildAtIndex(n);C(g)||h(256),g.insertAfter(d),u=d}else{const e=a,n=r[e],s=m();for(let o=0;o<i;o++){const{cell:r,startRow:i}=n[o];if(i===e){const e=n[o].cell.__headerState,r=y(e,l.COLUMN);s.append(c(r).append(t.$createParagraphNode()))}else r.setRowSpan(r.__rowSpan+1)}const d=o.getChildAtIndex(e);C(d)||h(257),d.insertBefore(s),u=s}return u}function x(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||J(n)||h(188);const o=n.anchor.getNode(),r=n.focus.getNode(),[l]=W(o),[s,,i]=W(r),[,a,c]=H(i,s,l),{startColumn:u}=c,{startColumn:d}=a;return e?O(u+l.__colSpan>d+s.__colSpan?l:s,!0):O(d<u?s:l,!1)}const E=x;function O(e,n=!0,o=!0){const[,,r]=W(e),[s,i]=H(r,e,e),a=s.length,{startColumn:u}=i,d=n?u+e.__colSpan-1:u-1,g=r.getFirstChild();C(g)||h(120);let f=null;function m(e=l.NO_STATUS){const n=c(e).append(t.$createParagraphNode());return null===f&&(f=n),n}let p=g;e:for(let e=0;e<a;e++){if(0!==e){const e=p.getNextSibling();C(e)||h(121),p=e}const t=s[e],n=t[d<0?0:d].cell.__headerState,o=y(n,l.ROW);if(d<0){K(p,m(o));continue}const{cell:r,startColumn:i,startRow:a}=t[d];if(i+r.__colSpan-1<=d){let n=r,l=a,s=d;for(;l!==e&&n.__rowSpan>1;){if(s-=r.__colSpan,!(s>=0)){p.append(m(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,l=o}}n.insertAfter(m(o))}else r.setColSpan(r.__colSpan+1)}null!==f&&o&&D(f);const _=r.getColWidths();if(_){const e=[..._],t=d<0?0:d,n=e[t];e.splice(t,0,n),r.setColWidths(e)}return f}function A(){const e=t.$getSelection();t.$isRangeSelection(e)||J(e)||h(188);const[n,o]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,l]=W(n),[s]=W(o),[i,a,c]=H(l,r,s),{startRow:u}=a,{startRow:d}=c,g=d+s.__rowSpan-1;if(i.length===g-u+1)return void l.remove();const f=i[0].length,m=i[g+1],p=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(o<u||o+n.__rowSpan-1>g){const e=Math.max(o,u),t=Math.min(n.__rowSpan+o-1,g),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r)}if(o>=u&&o+n.__rowSpan-1>g&&e===g){null===p&&h(122);let o=null;for(let n=0;n<t;n++){const t=m[n],r=t.cell;t.startRow===e+1&&(o=r),r.__colSpan>1&&(n+=r.__colSpan-1)}null===o?K(p,n):o.insertAfter(n)}}}const t=l.getChildAtIndex(e);C(t)||h(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];D(e)}else{const e=i[u-1],{cell:t}=e[0];D(t)}}const v=A;function F(){const e=t.$getSelection();t.$isRangeSelection(e)||J(e)||h(188);const n=e.anchor.getNode(),o=e.focus.getNode(),[r,,l]=W(n),[s]=W(o),[i,a,c]=H(l,r,s),{startColumn:u}=a,{startRow:d,startColumn:g}=c,f=Math.min(u,g),m=Math.max(u+r.__colSpan-1,g+s.__colSpan-1),C=m-f+1;if(i[0].length===m-f+1)return l.selectPrevious(),void l.remove();const p=i.length;for(let e=0;e<p;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(C,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 _=i[d],S=u>g?_[u+r.__colSpan]:_[g+s.__colSpan];if(void 0!==S){const{cell:e}=S;D(e)}else{const e=g<u?_[g-1]:_[u-1],{cell:t}=e;D(t)}const N=l.getColWidths();if(N){const e=[...N];e.splice(f,C),l.setColWidths(e)}}const P=F;function D(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function K(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function I(e){if(0===e.length)return null;const n=b(e[0]),[o]=B(n,null,null);let r=1/0,l=-1/0,s=1/0,i=-1/0;const a=new Set;for(const t of o)for(const n of t){if(!n||!n.cell)continue;const t=n.cell.getKey();if(!a.has(t)&&e.some(e=>e.is(n.cell))){a.add(t);const e=n.startRow,o=n.startColumn,c=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;r=Math.min(r,e),l=Math.max(l,e+c-1),s=Math.min(s,o),i=Math.max(i,o+u-1)}}if(r===1/0||s===1/0)return null;const c=l-r+1,u=i-s+1,d=o[r][s];if(!d.cell)return null;const h=d.cell;h.setColSpan(u),h.setRowSpan(c);const g=new Set([h.getKey()]);for(let e=r;e<=l;e++)for(let t=s;t<=i;t++){const n=o[e][t];if(!n.cell)continue;const r=n.cell,l=r.getKey();if(!g.has(l)){g.add(l);L(r)||h.append(...r.getChildren()),r.remove()}}return 0===h.getChildrenSize()&&h.append(t.$createParagraphNode()),h}function L(e){if(1!==e.getChildrenSize())return!1;const n=e.getFirstChildOrThrow();return!(!t.$isParagraphNode(n)||!n.isEmpty())}function k(e){const[n,o,r]=W(e),s=n.__colSpan,i=n.__rowSpan;if(1===s&&1===i)return;const[a,u]=H(r,n,n),{startColumn:d,startRow:g}=u,f=n.__headerState&l.COLUMN,m=Array.from({length:s},(e,t)=>{let n=f;for(let e=0;0!==n&&e<a.length;e++)n&=a[e][t+d].cell.__headerState;return n}),p=n.__headerState&l.ROW,_=Array.from({length:i},(e,t)=>{let n=p;for(let e=0;0!==n&&e<a[0].length;e++)n&=a[t+g][e].cell.__headerState;return n});if(s>1){for(let e=1;e<s;e++)n.insertAfter(c(m[e]|_[0]).append(t.$createParagraphNode()));n.setColSpan(1)}if(i>1){let e;for(let n=1;n<i;n++){const r=g+n,l=a[r];e=(e||o).getNextSibling(),C(e)||h(125);let i=null;for(let e=0;e<d;e++){const t=l[e],n=t.cell;t.startRow===r&&(i=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===i)for(let o=s-1;o>=0;o--)K(e,c(m[o]|_[n]).append(t.$createParagraphNode()));else for(let e=s-1;e>=0;e--)i.insertAfter(c(m[e]|_[n]).append(t.$createParagraphNode()))}n.setRowSpan(1)}}function H(e,t,n){const[o,r,l]=B(e,t,n);return null===r&&h(207),null===l&&h(208),[o,r,l]}function B(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];C(o)||h(209);const a=s(e);for(let c=o.getFirstChild(),d=0;null!=c;c=c.getNextSibling()){for(u(c)||h(147);void 0!==a[d];)d++;const o={cell:c,startColumn:d,startRow:e},{__rowSpan:g,__colSpan:f}=c;for(let t=0;t<g&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<f;e++)n[d+e]=o}null!==t&&null===r&&t.is(c)&&(r=o),null!==n&&null===l&&n.is(c)&&(l=o)}}return[o,r,l]}function W(t){let n;if(t instanceof s)n=t;else if("__type"in t){const o=e.$findMatchingParent(t,u);u(o)||h(148),n=o}else{const o=e.$findMatchingParent(t.getNode(),u);u(o)||h(148),n=o}const o=n.getParent();C(o)||h(149);const r=o.getParent();return Be(r)||h(210),[n,o,r]}function z(e,t,n){let o,r=Math.min(t.startColumn,n.startColumn),l=Math.min(t.startRow,n.startRow),s=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);do{o=!1;for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const a=e[t][n];if(!a)continue;const c=a.startColumn+a.cell.__colSpan-1,u=a.startRow+a.cell.__rowSpan-1,d=a.startColumn<=s&&c>=r,h=a.startRow<=i&&u>=l;if(d&&h){const e=Math.min(r,a.startColumn),t=Math.max(s,c),n=Math.min(l,a.startRow),d=Math.max(i,u);e===r&&t===s&&n===l&&d===i||(r=e,s=t,l=n,i=d,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function Y(e){const[t,,n]=W(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 U(t){const[[n,o,r,l],[s,i,a,c]]=["anchor","focus"].map(n=>{const o=t[n].getNode(),r=e.$findMatchingParent(o,u);u(r)||h(238,n,o.getKey(),o.getType());const l=r.getParent();C(l)||h(239,n);const s=l.getParent();return Be(s)||h(240,n),[o,r,l,s]});return l.is(c)||h(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:a,focusTable:c}}class X{tableKey;anchor;focus;_cachedNodes;dirty;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(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=t.$getNodeByKey(this.tableKey),n=t.$getNodeByKey(this.anchor.key),o=t.$getNodeByKey(this.focus.key);return null!==e&&null!==n&&null!==o}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return J(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 X(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(u).forEach(e=>{const o=e.getFirstChild();t.$isParagraphNode(o)&&(n|=o.getTextFormat())});const o=t.TEXT_TYPE_TO_FORMAT[e];return 0!==(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}=U(this),n=Y(e);null===n&&h(153);const o=Y(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),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}=U(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[s,i,a]=H(n,o,r),{minColumn:c,maxColumn:u,minRow:d,maxRow:g}=z(s,i,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}=s[e][t],o=n.getParent();C(o)||h(160),o!==m&&(f.set(o.getKey(),o),m=o),f.has(n.getKey())||j(n,e=>{f.set(e.getKey(),e)})}const p=Array.from(f.values());return t.isCurrentlyReadOnlyMode()||(this._cachedNodes=p),p}getTextContent(){const e=this.getNodes().filter(e=>u(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 J(e){return e instanceof X}function q(){const e=t.$createPoint("root",0,"element"),n=t.$createPoint("root",0,"element");return new X("root",e,n)}function G(e,n,o){e.getKey(),n.getKey(),o.getKey();const r=t.$getSelection(),l=J(r)?r.clone():q();return l.set(e.getKey(),n.getKey(),o.getKey()),l}function j(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 V(e,n=t.$getEditor()){const o=t.$getNodeByKey(e);Be(o)||h(231,e);const r=te(o,n.getElementByKey(e));return null===r&&h(232,e),{tableElement:r,tableNode:o}}class Q{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;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.pointerType=null,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 V(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=de(n,o)},{editor:this.editor})});this.editor.getEditorState().read(()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=de(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();he(e,de(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(),he(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=ve(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==n)return this.focusCellNodeKey=n.getKey(),this.tableSelection=G(r,this.$getAnchorTableCellOrThrow(),n),t.$setSelection(this.tableSelection),o.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0),he(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=ve(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():q(),this.anchorCellNodeKey=e}}$formatCells(e){const n=t.$getSelection();J(n)||h(236);const o=t.$createRangeSelection(),r=o.anchor,l=o.focus,s=n.getNodes().filter(u);s.length>0||h(237);const i=s[0].getFirstChild(),a=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,a)}),t.$setSelection(n),this.editor.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:e}=this,n=t.$getNodeByKey(this.tableNodeKey);if(!Be(n))throw new Error("Expected TableNode.");const o=t.$getSelection();J(o)||h(253);const r=o.getNodes().filter(u),l=n.getFirstChild(),s=n.getLastChild();if(r.length>0&&null!==l&&null!==s&&C(l)&&C(s)&&r[0]===l.getFirstChild()&&r[r.length-1]===s.getLastChild()){n.selectPrevious();const o=n.getParent();return n.remove(),void(t.$isRootNode(o)&&o.isEmpty()&&e.dispatchCommand(t.INSERT_PARAGRAPH_COMMAND,void 0))}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()})}}),he(e,this.table,null),t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}}const Z="__lexicalTableSelection";function ee(e){return t.isHTMLElement(e)&&"TABLE"===e.nodeName}function te(e,t){if(!t)return t;const n=ee(t)?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&h(245,t.nodeName),n}function ne(e){return e._window}function oe(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;u(n)&&(o=n)}return null}const re=[[t.KEY_ARROW_DOWN_COMMAND,"down"],[t.KEY_ARROW_UP_COMMAND,"up"],[t.KEY_ARROW_LEFT_COMMAND,"backward"],[t.KEY_ARROW_RIGHT_COMMAND,"forward"]],le=[t.DELETE_WORD_COMMAND,t.DELETE_LINE_COMMAND,t.DELETE_CHARACTER_COMMAND],se=[t.KEY_BACKSPACE_COMMAND,t.KEY_DELETE_COMMAND];function ie(n,r,l,s){const i=l.getRootElement(),a=ne(l);null!==i&&null!==a||h(246);const c=new Q(l,n.getKey()),d=te(n,r);!function(e,t){null!==ae(e)&&h(205);e[Z]=t}(d,c),c.listenersToRemove.add(()=>function(e,t){ae(e)===t&&delete e[Z]}(d,c));const g=e=>{if(c.pointerType=e.pointerType,0!==e.button||!t.isDOMNode(e.target)||!a)return;const o=ce(e.target);null!==o&&l.update(()=>{const r=t.$getPreviousSelection();if(S&&e.shiftKey&&Ne(r,n)&&(t.$isRangeSelection(r)||J(r))){const t=r.anchor.getNode(),l=oe(n,r.anchor.getNode());if(l)c.$setAnchorCellForSelection(Ae(c,l)),c.$setFocusCellForSelection(o),xe(e);else{(n.isBefore(t)?n.selectStart():n.selectEnd()).anchor.set(r.anchor.key,r.anchor.offset,r.anchor.type)}}else"touch"!==e.pointerType&&c.$setAnchorCellForSelection(o)}),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,a.removeEventListener("pointerup",e),a.removeEventListener("pointermove",n)},n=o=>{if(1&~o.buttons&&c.isSelecting)return c.isSelecting=!1,a.removeEventListener("pointerup",e),void a.removeEventListener("pointermove",n);if(!t.isDOMNode(o.target))return;let r=null;const s=!(S||d.contains(o.target));if(s)r=ue(d,o.target);else for(const e of document.elementsFromPoint(o.clientX,o.clientY))if(r=ue(d,e),r)break;!r||null!==c.focusCell&&r.elem===c.focusCell.elem||(c.setNextFocus({focusCell:r,override:s}),l.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))};c.isSelecting=!0,a.addEventListener("pointerup",e,c.listenerOptions),a.addEventListener("pointermove",n,c.listenerOptions)})()};d.addEventListener("pointerdown",g,c.listenerOptions),c.listenersToRemove.add(()=>{d.removeEventListener("pointerdown",g)});const f=e=>{if(e.detail>=3&&t.isDOMNode(e.target)){null!==ce(e.target)&&e.preventDefault()}};d.addEventListener("mousedown",f,c.listenerOptions),c.listenersToRemove.add(()=>{d.removeEventListener("mousedown",f)});const m=e=>{const n=e.target;0===e.button&&t.isDOMNode(n)&&l.update(()=>{const e=t.$getSelection();J(e)&&e.tableKey===c.tableNodeKey&&i.contains(n)&&c.$clearHighlight()})};a.addEventListener("pointerdown",m,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("pointerdown",m)});for(const[e,o]of re)c.listenersToRemove.add(l.registerCommand(e,e=>Me(l,e,o,n,c),t.COMMAND_PRIORITY_HIGH));c.listenersToRemove.add(l.registerCommand(t.KEY_ESCAPE_COMMAND,e=>{const o=t.$getSelection();if(J(o)){const t=oe(n,o.focus.getNode());if(null!==t)return xe(e),t.selectEnd(),!0}return!1},t.COMMAND_PRIORITY_HIGH));const p=o=>()=>{const r=t.$getSelection();if(!Ne(r,n))return!1;if(J(r))return c.$clearText(),!0;if(t.$isRangeSelection(r)){if(!u(oe(n,r.anchor.getNode())))return!1;const l=r.anchor.getNode(),s=r.focus.getNode(),i=n.isParentOf(l),a=n.isParentOf(s);if(i&&!a||a&&!i)return c.$clearText(),!0;const d=e.$findMatchingParent(r.anchor.getNode(),e=>t.$isElementNode(e)),h=d&&e.$findMatchingParent(d,e=>t.$isElementNode(e)&&u(e.getParent()));if(!t.$isElementNode(h)||!t.$isElementNode(d))return!1;if(o===t.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return!0}return!1};for(const e of le)c.listenersToRemove.add(l.registerCommand(e,p(e),t.COMMAND_PRIORITY_CRITICAL));const _=e=>{const o=t.$getSelection();if(!J(o)&&!t.$isRangeSelection(o))return!1;const r=n.isParentOf(o.anchor.getNode());if(r!==n.isParentOf(o.focus.getNode())){const e=r?"anchor":"focus",t=r?"focus":"anchor",{key:l,offset:s,type:i}=o[t];return n[o[e].isBefore(o[t])?"selectPrevious":"selectNext"]()[t].set(l,s,i),!1}return!!Ne(o,n)&&(!!J(o)&&(e&&(e.preventDefault(),e.stopPropagation()),c.$clearText(),!0))};for(const e of se)c.listenersToRemove.add(l.registerCommand(e,_,t.COMMAND_PRIORITY_CRITICAL));return c.listenersToRemove.add(l.registerCommand(t.CUT_COMMAND,n=>{const r=t.$getSelection();if(r){if(!J(r)&&!t.$isRangeSelection(r))return!1;o.copyToClipboard(l,e.objectKlassEquals(n,ClipboardEvent)?n:null,o.$getClipboardDataFromSelection(r));const s=_(n);return t.$isRangeSelection(r)?(r.removeText(),!0):s}return!1},t.COMMAND_PRIORITY_CRITICAL)),c.listenersToRemove.add(l.registerCommand(t.FORMAT_TEXT_COMMAND,o=>{const r=t.$getSelection();if(!Ne(r,n))return!1;if(J(r))return c.$formatCells(o),!0;if(t.$isRangeSelection(r)){const t=e.$findMatchingParent(r.anchor.getNode(),e=>u(e));if(!u(t))return!1}return!1},t.COMMAND_PRIORITY_CRITICAL)),c.listenersToRemove.add(l.registerCommand(t.FORMAT_ELEMENT_COMMAND,e=>{const o=t.$getSelection();if(!J(o)||!Ne(o,n))return!1;const r=o.anchor.getNode(),l=o.focus.getNode();if(!u(r)||!u(l))return!1;if(function(e,t){if(J(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=H(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(o,n))return n.setFormat(e),!0;const[s,i,a]=H(n,r,l),c=Math.max(i.startRow+i.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),d=Math.max(i.startColumn+i.cell.__colSpan-1,a.startColumn+a.cell.__colSpan-1),h=Math.min(i.startRow,a.startRow),g=Math.min(i.startColumn,a.startColumn),f=new Set;for(let n=h;n<=c;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)),c.listenersToRemove.add(l.registerCommand(t.CONTROLLED_TEXT_INSERTION_COMMAND,o=>{const r=t.$getSelection();if(!Ne(r,n))return!1;if(J(r))return c.$clearHighlight(),!1;if(t.$isRangeSelection(r)){const s=e.$findMatchingParent(r.anchor.getNode(),e=>u(e));if(!u(s))return!1;if("string"==typeof o){const e=Oe(l,r,n);if(e)return Ee(e,n,[t.$createTextNode(o)]),!0}}return!1},t.COMMAND_PRIORITY_CRITICAL)),s&&c.listenersToRemove.add(l.registerCommand(t.KEY_TAB_COMMAND,o=>{const r=t.$getSelection();if(!t.$isRangeSelection(r)||!r.isCollapsed()||!Ne(r,n))return!1;const l=ye(r.anchor.getNode());return!(null===l||!n.is($e(l)))&&(xe(o),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,C);null===i&&h(247);for(let e=i[r]();C(e);e=e[r]()){const n=e[l]();if(t.$isElementNode(n))return n.selectEnd()}const a=e.$findMatchingParent(i,Be);null===a&&h(248);"next"===o?a.selectNext():a.selectPrevious()}(l,o.shiftKey?"previous":"next"),!0)},t.COMMAND_PRIORITY_CRITICAL)),c.listenersToRemove.add(l.registerCommand(t.FOCUS_COMMAND,e=>n.isSelected(),t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(n,o)=>{if(l!==o)return!1;const{nodes:r,selection:s}=n,i=s.getStartEndPoints(),a=J(s),c=t.$isRangeSelection(s)&&null!==e.$findMatchingParent(s.anchor.getNode(),e=>u(e))&&null!==e.$findMatchingParent(s.focus.getNode(),e=>u(e))||a;if(1!==r.length||!Be(r[0])||!c||null===i)return!1;const[d,h]=i,[g,f,m]=W(d),p=e.$findMatchingParent(h.getNode(),e=>u(e));if(!(u(g)&&u(p)&&C(f)&&Be(m)))return!1;const _=r[0],[S,N,w]=H(m,g,p),[b]=B(_,null,null),T=S.length,y=T>0?S[0].length:0;let $=N.startRow,R=N.startColumn,x=b.length,E=x>0?b[0].length:0;if(a){const e=z(S,N,w),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;$=e.minRow,R=e.minColumn,x=Math.min(x,t),E=Math.min(E,n)}let A=!1;const v=Math.min(T,$+x)-1,F=Math.min(y,R+E)-1,P=new Set;for(let e=$;e<=v;e++)for(let t=R;t<=F;t++){const n=S[e][t];P.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(k(n.cell),P.add(n.cell.getKey()),A=!0))}let[D]=B(m.getWritable(),null,null);const K=x-T+$;for(let e=0;e<K;e++){M(D[T-1][0].cell)}const L=E-y+R;for(let e=0;e<L;e++){O(D[0][y-1].cell,!0,!1)}[D]=B(m.getWritable(),null,null);for(let e=$;e<$+x;e++)for(let n=R;n<R+E;n++){const o=e-$,r=n-R,l=b[o][r];if(l.startRow!==o||l.startColumn!==r)continue;const s=l.cell;if(1!==s.__rowSpan||1!==s.__colSpan){const t=[],o=Math.min(e+s.__rowSpan,$+x)-1,r=Math.min(n+s.__colSpan,R+E)-1;for(let l=e;l<=o;l++)for(let e=n;e<=r;e++){const n=D[l][e];t.push(n.cell)}I(t),A=!0}const{cell:i}=D[e][n],a=i.getChildren();s.getChildren().forEach(e=>{if(t.$isTextNode(e)){t.$createParagraphNode().append(e),i.append(e)}else i.append(e)}),a.forEach(e=>e.remove())}if(a&&A){const[e]=B(m.getWritable(),null,null);e[N.startRow][N.startColumn].cell.selectEnd()}return!0},t.COMMAND_PRIORITY_CRITICAL)),c.listenersToRemove.add(l.registerCommand(t.SELECTION_CHANGE_COMMAND,()=>{const o=t.$getSelection(),r=t.$getPreviousSelection(),s=c.getAndClearNextFocus();if(null!==s){const{focusCell:e}=s;if(J(o)&&o.tableKey===c.tableNodeKey)return(e.x!==c.focusX||e.y!==c.focusY)&&(c.$setFocusCellForSelection(e),!0);if(e!==c.anchorCell&&Ne(o,n))return c.$setFocusCellForSelection(e),!0}if(c.getAndClearShouldCheckSelection()&&t.$isRangeSelection(r)&&t.$isRangeSelection(o)&&o.isCollapsed()){const t=o.anchor.getNode(),r=n.getFirstChild(),l=ye(t);if(null!==l&&C(r)){const t=r.getFirstChild();if(u(t)&&n.is(e.$findMatchingParent(l,e=>e.is(n)||e.is(t))))return t.selectStart(),!0}}if(t.$isRangeSelection(o)){const{anchor:e,focus:s}=o,i=e.getNode(),a=s.getNode(),u=ye(i),d=ye(a),h=!(!u||!n.is($e(u))),g=!(!d||!n.is($e(d))),f=h!==g,m=h&&g,C=o.isBackward();if(f){const e=o.clone();if(g){const[t]=H(n,d,d),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.focus.set(C?o.getKey():r.getKey(),C?o.getChildrenSize():r.getChildrenSize(),"element")}else if(h){const[t]=H(n,u,u),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.anchor.set(C?r.getKey():o.getKey(),C?r.getChildrenSize():0,"element")}t.$setSelection(e),fe(l,c)}else if(m&&(u.is(d)||(c.$setAnchorCellForSelection(Ae(c,u)),c.$setFocusCellForSelection(Ae(c,d),!0)),"touch"===c.pointerType&&c.isSelecting&&o.isCollapsed()&&t.$isRangeSelection(r)&&r.isCollapsed())){const e=ye(r.anchor.getNode());e&&!e.is(d)&&(c.$setAnchorCellForSelection(Ae(c,e)),c.$setFocusCellForSelection(Ae(c,d),!0),c.pointerType=null)}}else if(o&&J(o)&&o.is(r)&&o.tableKey===n.getKey()){const e=t.getDOMSelection(a);if(e&&e.anchorNode&&e.focusNode){const r=t.$getNearestNodeFromDOMNode(e.focusNode),s=r&&!n.isParentOf(r),i=t.$getNearestNodeFromDOMNode(e.anchorNode),a=i&&n.isParentOf(i);if(s&&a&&e.rangeCount>0){const r=t.$createRangeSelectionFromDom(e,l);r&&(r.anchor.set(n.getKey(),o.isBackward()?n.getChildrenSize():0,"element"),e.removeAllRanges(),t.$setSelection(r))}}}return o&&!o.is(r)&&(J(o)||J(r))&&c.tableSelection&&!c.tableSelection.is(r)?(J(o)&&o.tableKey===c.tableNodeKey?c.$updateTableTableSelection(o):!J(o)&&J(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!n.isSelected()?function(e,t){t.$enableHighlightStyle(),ge(t.table,t=>{const n=t.elem;t.highlighted=!1,Te(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(l,c):!c.hasHijackedSelectionStyles&&n.isSelected()&&fe(l,c),!1)},t.COMMAND_PRIORITY_CRITICAL)),c.listenersToRemove.add(l.registerCommand(t.INSERT_PARAGRAPH_COMMAND,()=>{const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||!Ne(e,n))return!1;const o=Oe(l,e,n);return!!o&&(Ee(o,n),!0)},t.COMMAND_PRIORITY_CRITICAL)),c}function ae(e){return e[Z]||null}function ce(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 ue(e,t){if(!e.contains(t))return null;let n=null;for(let o=t;null!=o;o=o.parentNode){if(o===e)return n;const t=o.nodeName;"TD"!==t&&"TH"!==t||(n=o._cell||null)}return null}function de(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=te(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 he(e,t,n){const o=new Set(n?n.getNodes():[]);ge(t,(t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,be(e,t)):(t.highlighted=!1,Te(e,t),r.getAttribute("style")||r.removeAttribute("style"))})}function ge(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 fe(e,t){t.$disableHighlightStyle(),ge(t.table,t=>{t.highlighted=!0,be(e,t)})}const me=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?we(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?we(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?we(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?we(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Ce(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 pe([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function _e(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&h(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&h(250,n,String(s)),i}function Se(e,t,n,o,r){const l=z(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,d=function(e,t){const n=Ce(e,t);return null===n&&h(249,t.cell.getKey()),n}(l,n),[g,f]=pe(d);let m=l[g],C=l[f];"forward"===r?m+="maxColumn"===g?1:a:"backward"===r?m-="minColumn"===g?1:u:"down"===r?C+="maxRow"===f?1:i:"up"===r&&(C-="minRow"===f?1:c);const p=t[C];if(void 0===p)return!1;const _=p[m];if(void 0===_)return!1;const[S,N]=function(e,t,n){const o=z(e,t,n),r=Ce(o,t);if(r)return[_e(e,o,r),_e(e,o,pe(r))];const l=Ce(o,n);if(l)return[_e(e,o,pe(l)),_e(e,o,l)];const s=["minColumn","minRow"];return[_e(e,o,s),_e(e,o,pe(s))]}(t,n,_),w=Ae(e,S.cell),b=Ae(e,N.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function Ne(e,n){if(t.$isRangeSelection(e)||J(e)){const t=n.isParentOf(e.anchor.getNode()),o=n.isParentOf(e.focus.getNode());return t&&o}return!1}function we(e,t){t?e.selectStart():e.selectEnd()}function be(n,o){const r=o.elem,l=n._config.theme;u(t.$getNearestNodeFromDOMNode(r))||h(131),e.addClassNamesToElement(r,l.tableCellSelected)}function Te(n,o){const r=o.elem;u(t.$getNearestNodeFromDOMNode(r))||h(131);const l=n._config.theme;e.removeClassNamesFromElement(r,l.tableCellSelected)}function ye(t){const n=e.$findMatchingParent(t,u);return u(n)?n:null}function $e(t){const n=e.$findMatchingParent(t,Be);return Be(n)?n:null}function Re(n,o,r,l,s,i,a){const c=t.$caretFromPoint(r.focus,s?"previous":"next");if(t.$isExtendableTextPointCaret(c))return!1;let d=c;for(const e of t.$extendCaretToRange(c).iterNodeCarets("shadowRoot")){if(!t.$isSiblingCaret(e)||!t.$isElementNode(e.origin))return!1;d=e}const h=d.getParentAtCaret();if(!u(h))return!1;const g=h,f=function(e){for(const n of t.$extendCaretToRange(e).iterNodeCarets("root")){const{origin:o}=n;if(u(o)){if(t.$isChildCaret(n))return t.$getChildCaret(o,e.direction)}else if(!C(o))break}return null}(t.$getSiblingCaret(g,d.direction)),m=e.$findMatchingParent(g,Be);if(!m||!m.is(i))return!1;const p=n.getElementByKey(g.getKey()),_=ce(p);if(!p||!_)return!1;const S=Le(n,m);if(a.table=S,f)if("extend"===l){const e=ce(n.getElementByKey(f.origin.getKey()));if(!e)return!1;a.$setAnchorCellForSelection(_),a.$setFocusCellForSelection(e,!0)}else{const e=t.$normalizeCaret(f);t.$setPointFromCaret(r.anchor,e),t.$setPointFromCaret(r.focus,e)}else if("extend"===l)a.$setAnchorCellForSelection(_),a.$setFocusCellForSelection(_,!0);else{const e=function(e){const n=t.$getAdjacentChildCaret(e);return t.$isChildCaret(n)?t.$normalizeCaret(n):e}(t.$getSiblingCaret(m,c.direction));t.$setPointFromCaret(r.anchor,e),t.$setPointFromCaret(r.focus,e)}return xe(o),!0}function Me(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(!Ne(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!!Be(n)&&(xe(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=>Be(e));if(u(s)&&(s=e.$findMatchingParent(s,Be)),s!==l)return!1;if(!s)return!1;const a="down"===r?s.getNextSibling():s.getPreviousSibling();if(!a)return!1;let c=0;"up"===r&&t.$isElementNode(a)&&(c=a.getChildrenSize());let d=a;if("up"===r&&t.$isElementNode(a)){const e=a.getLastChild();d=e||a,c=t.$isTextNode(d)?d.getTextContentSize():0}const h=i.clone();return h.focus.set(d.getKey(),c,t.$isTextNode(d)?"text":"element"),t.$setSelection(h),xe(o),!0}if(t.$isRootOrShadowRoot(n)){const e="up"===r?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==oe(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=W(e),[o]=W(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(u(l)&&(l=e.$findMatchingParent(l,Be)),!l)return!1;const a="down"===r?l.getNextSibling():l.getPreviousSibling();if(Be(a)&&s.tableNodeKey===a.getKey()){const e=a.getFirstDescendant(),n=a.getLastDescendant();if(!e||!n)return!1;const[l]=W(e),[s]=W(n),c=i.clone();return c.focus.set(("up"===r?l:s).getKey(),"up"===r?0:s.getChildrenSize(),"element"),xe(o),t.$setSelection(c),!0}}}}return"down"===r&&De(n)&&s.setShouldCheckSelection(),!1}if(t.$isRangeSelection(i)){if("backward"===r||"forward"===r){return Re(n,o,i,o.shiftKey?"extend":"move","backward"===r,l,s)}if(i.isCollapsed()){const{anchor:a,focus:c}=i,d=e.$findMatchingParent(a.getNode(),u),h=e.$findMatchingParent(c.getNode(),u);if(!u(d)||!d.is(h))return!1;const g=$e(d);if(g!==l&&null!=g){const e=te(g,n.getElementByKey(g.getKey()));if(null!=e)return s.table=de(g,e),Me(n,o,r,g,s)}const f=n.getElementByKey(d.__key),m=n.getElementByKey(a.key);if(null==m||null==f)return!1;let C;if("element"===a.type)C=m.getBoundingClientRect();else{const e=t.getDOMSelection(ne(n));if(null===e||0===e.rangeCount)return!1;C=e.getRangeAt(0).getBoundingClientRect()}const p="up"===r?d.getFirstChild():d.getLastChild();if(null==p)return!1;const _=n.getElementByKey(p.__key);if(null==_)return!1;const S=_.getBoundingClientRect();if("up"===r?S.top>C.top-C.height:C.bottom+C.height>S.bottom){xe(o);const e=l.getCordsFromCellNode(d,s.table);if(!o.shiftKey)return me(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(J(i)){const{anchor:t,focus:a}=i,c=e.$findMatchingParent(t.getNode(),u),d=e.$findMatchingParent(a.getNode(),u),[g]=i.getNodes();Be(g)||h(251);const f=te(g,n.getElementByKey(g.getKey()));if(!u(c)||!u(d)||!Be(g)||null==f)return!1;s.$updateTableTableSelection(i);const m=de(g,f),C=l.getCordsFromCellNode(c,m),p=l.getDOMCellFromCordsOrThrow(C.x,C.y,m);if(s.$setAnchorCellForSelection(p),xe(o),o.shiftKey){const[e,t,n]=H(l,c,d);return Se(s,e,t,n,r)}return d.selectEnd(),!0}return!1}function xe(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function Ee(e,n,o){const r=t.$createParagraphNode();"first"===e?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function Oe(n,o,r){const l=r.getParent();if(!l)return;const s=t.getDOMSelection(ne(n));if(!s)return;const i=s.anchorNode,a=n.getElementByKey(l.getKey()),c=te(r,n.getElementByKey(r.getKey()));if(!i||!a||!c||!a.contains(i)||c.contains(i))return;const d=e.$findMatchingParent(o.anchor.getNode(),e=>u(e));if(!d)return;const h=e.$findMatchingParent(d,e=>Be(e));if(!Be(h)||!h.is(r))return;const[g,f]=H(r,d,d),m=g[0][0],C=g[g.length-1][g[0].length-1],{startRow:p,startColumn:_}=f,S=p===m.startRow&&_===m.startColumn,N=p===C.startRow&&_===C.startColumn;return S?"first":N?"last":void 0}function Ae(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function ve(e,n,o){return oe(e,t.$getNearestNodeFromDOMNode(n,o))}function Fe(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 Pe=new WeakSet;function De(e=t.$getEditor()){return Pe.has(e)}function Ke(e,t){t?Pe.add(e):Pe.delete(e)}class Ie extends t.ElementNode{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;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 Ie(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:ke,priority:1})}}static importJSON(e){return He().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t=ee(e)?e:e.querySelector("table");return ee(t)||h(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(n,o){const r=document.createElement("table");this.__style&&(r.style.cssText=this.__style);const l=document.createElement("colgroup");if(r.appendChild(l),t.setDOMUnmanaged(l),e.addClassNamesToElement(r,n.theme.table),this.updateTableElement(null,r,n),De(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),this.updateTableWrapper(null,t,r,n),t}return r}updateTableWrapper(t,n,o,r){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,o,r){r>0?(e.addClassNamesToElement(t,o.theme.tableFrozenColumn),n.setAttribute("data-lexical-frozen-column","true")):(e.removeClassNamesFromElement(t,o.theme.tableFrozenColumn),n.removeAttribute("data-lexical-frozen-column"))}(n,o,r,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,o,r){r>0?(e.addClassNamesToElement(t,o.theme.tableFrozenRow),n.setAttribute("data-lexical-frozen-row","true")):(e.removeClassNamesFromElement(t,o.theme.tableFrozenRow),n.removeAttribute("data-lexical-frozen-row"))}(n,o,r,this.__frozenRowCount)}updateTableElement(t,n,o){this.__style!==(t?t.__style:"")&&(n.style.cssText=this.__style),this.__rowStriping!==(!!t&&t.__rowStriping)&&function(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"))}(n,o,this.__rowStriping),function(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)}(n,0,this.getColumnCount(),this.getColWidths()),Fe(n,o,this.getFormatType())}updateDOM(t,n,o){const r=this.getDOMSlot(n).element;return n===r===De()||(l=n,e.isHTMLElement(l)&&"DIV"===l.nodeName&&this.updateTableWrapper(t,n,r,o),this.updateTableElement(t,r,o),!1);var l}exportDOM(t){const n=super.exportDOM(t),{element:o}=n;return{after:o=>{if(n.after&&(o=n.after(o)),!ee(o)&&e.isHTMLElement(o)&&(o=o.querySelector("table")),!ee(o))return null;Fe(o,t._config,this.getFormatType());const[r]=B(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:!ee(o)&&e.isHTMLElement(o)?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=ve(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 u(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}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){const t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach(e=>{u(e)&&(t+=e.getColSpan())}),t}}function Le(e,t){const n=e.getElementByKey(t.getKey());return null===n&&h(230),de(t,n)}function ke(t){const n=He();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0),t.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),t.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=t.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!r.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,C),node:n}}function He(){return t.$applyNodeReplacement(new Ie)}function Be(e){return e instanceof Ie}function We({rows:n,columns:o,includeHeaders:r}){const l=t.$getSelection()||t.$getPreviousSelection();if(!l||!t.$isRangeSelection(l))return!1;if($e(l.anchor.getNode()))return!1;const s=N(Number(n),Number(o),r);e.$insertNodeToNearestRoot(s);const i=s.getFirstDescendant();return t.$isTextNode(i)&&i.select(),!0}function ze(e){C(e.getParent())?e.isEmpty()&&e.append(t.$createParagraphNode()):e.remove()}function Ye(t){Be(t.getParent())?e.$unwrapAndFilterDescendants(t,u):t.remove()}function Ue(n){e.$unwrapAndFilterDescendants(n,C);const[o]=B(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;C(n)||h(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=c();e.append(t.$createParagraphNode()),n.append(e)}}}function Xe(n){if(n.detail<3||!t.isDOMNode(n.target))return!1;const o=t.$getNearestNodeFromDOMNode(n.target);if(null===o)return!1;const r=e.$findMatchingParent(o,e=>t.$isElementNode(e)&&!e.isInline());if(null===r)return!1;return!!u(r.getParent())&&(r.select(0),!0)}function Je(t){return t.registerNodeTransform(s,t=>{if(t.getColSpan()>1||t.getRowSpan()>1){const[,,n]=W(t),[o]=H(n,t,t),r=o.length,l=o[0].length;let s=n.getFirstChild();C(s)||h(175);const i=[];for(let t=0;t<r;t++){0!==t&&(s=s.getNextSibling(),C(s)||h(175));let n=null;for(let r=0;r<l;r++){const l=o[t][r],a=l.cell;if(l.startRow===t&&l.startColumn===r)n=a,i.push(a);else if(a.getColSpan()>1||a.getRowSpan()>1){u(a)||h(176);const t=c(a.__headerState);null!==n?n.insertAfter(t):e.$insertFirst(s,t)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}})}function qe(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=te(o,l),i=ie(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(Ie,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}=V(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 Ge(n){return n.hasNodes([Ie])||h(255),e.mergeRegister(n.registerCommand(d,We,t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,({nodes:e,selection:o},r)=>{if(n!==r||!t.$isRangeSelection(o))return!1;return null!==$e(o.anchor.getNode())&&e.some(Be)},t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.CLICK_COMMAND,Xe,t.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(Ie,Ue),n.registerNodeTransform(g,Ye),n.registerNodeTransform(s,ze))}const je=t.defineExtension({build:(e,t,o)=>n.namedSignals(t),config:t.safeCast({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasTabHandler:!0}),name:"@lexical/table/Table",nodes:[Ie,g,s],register(t,o,r){const l=r.getOutput();return e.mergeRegister(n.effect(()=>{const e=l.hasHorizontalScroll.value;De(t)!==e&&(Ke(t,e),t.registerNodeTransform(Ie,()=>{})())}),Ge(t),n.effect(()=>qe(t,l.hasTabHandler.value)),n.effect(()=>l.hasCellMerge.value?void 0:Je(t)),n.effect(()=>l.hasCellBackgroundColor.value?void 0:t.registerNodeTransform(s,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}});exports.$computeTableMap=H,exports.$computeTableMapSkipCellCheck=B,exports.$createTableCellNode=c,exports.$createTableNode=He,exports.$createTableNodeWithDimensions=N,exports.$createTableRowNode=m,exports.$createTableSelection=q,exports.$createTableSelectionFrom=G,exports.$deleteTableColumn=function(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(C(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.$deleteTableColumnAtSelection=F,exports.$deleteTableColumn__EXPERIMENTAL=P,exports.$deleteTableRowAtSelection=A,exports.$deleteTableRow__EXPERIMENTAL=v,exports.$findCellNode=ye,exports.$findTableNode=$e,exports.$getElementForTableNode=Le,exports.$getNodeTriplet=W,exports.$getTableAndElementByKey=V,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,e=>u(e));return u(n)?n:null},exports.$getTableCellNodeRect=Y,exports.$getTableColumnIndexFromTableCellNode=function(e){return w(e).getChildren().findIndex(t=>t.is(e))},exports.$getTableNodeFromLexicalNodeOrThrow=b,exports.$getTableRowIndexFromTableCellNode=function(e){const t=w(e);return b(t).getChildren().findIndex(e=>e.is(t))},exports.$getTableRowNodeFromTableCellNodeOrThrow=w,exports.$insertTableColumn=function(e,n,o=!0,r,s){const i=e.getChildren(),a=[];for(let e=0;e<i.length;e++){const o=i[e];if(C(o))for(let e=0;e<r;e++){const e=o.getChildren();if(n>=e.length||n<0)throw new Error("Table column target index out of range");const r=e[n];u(r)||h(12);const{left:i,right:d}=T(r,s);let g=l.NO_STATUS;(i&&i.hasHeaderState(l.ROW)||d&&d.hasHeaderState(l.ROW))&&(g|=l.ROW);const f=c(g);f.append(t.$createParagraphNode()),a.push({newTableCell:f,targetCell:r})}}return a.forEach(({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)}),e},exports.$insertTableColumnAtSelection=x,exports.$insertTableColumn__EXPERIMENTAL=E,exports.$insertTableRow=function(e,n,o=!0,r,s){const i=e.getChildren();if(n>=i.length||n<0)throw new Error("Table row target index out of range");const a=i[n];if(!C(a))throw new Error("Row before insertion index does not exist.");for(let e=0;e<r;e++){const e=a.getChildren(),n=e.length,r=m();for(let o=0;o<n;o++){const n=e[o];u(n)||h(12);const{above:i,below:a}=T(n,s);let d=l.NO_STATUS;const g=i&&i.getWidth()||a&&a.getWidth()||void 0;(i&&i.hasHeaderState(l.COLUMN)||a&&a.hasHeaderState(l.COLUMN))&&(d|=l.COLUMN);const f=c(d,1,g);f.append(t.$createParagraphNode()),r.append(f)}o?a.insertAfter(r):a.insertBefore(r)}return e},exports.$insertTableRowAtSelection=$,exports.$insertTableRow__EXPERIMENTAL=R,exports.$isScrollableTablesActive=De,exports.$isTableCellNode=u,exports.$isTableNode=Be,exports.$isTableRowNode=C,exports.$isTableSelection=J,exports.$mergeCells=I,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 n=t.$getSelection();t.$isRangeSelection(n)||J(n)||h(188);const o=n.anchor.getNode(),r=e.$findMatchingParent(o,u);return u(r)||h(148),k(r)},exports.INSERT_TABLE_COMMAND=d,exports.TableCellHeaderStates=l,exports.TableCellNode=s,exports.TableExtension=je,exports.TableNode=Ie,exports.TableObserver=Q,exports.TableRowNode=g,exports.applyTableHandlers=ie,exports.getDOMCellFromTarget=ce,exports.getTableElement=te,exports.getTableObserverFromTableElement=ae,exports.registerTableCellUnmergeTransform=Je,exports.registerTablePlugin=Ge,exports.registerTableSelectionObserver=qe,exports.setScrollableTablesActive=Ke;
9
+ "use strict";var e=require("@lexical/utils"),t=require("lexical"),n=require("@lexical/extension"),o=require("@lexical/clipboard");const r=/^(\d+(?:\.\d+)?)px$/,l={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class s extends t.ElementNode{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new s(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:a,priority:0}),th:e=>({conversion:a,priority:0})}}static importJSON(e){return c().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=l.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0}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=l.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!==l.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 a(e){const n=e,o=e.nodeName.toLowerCase();let s;r.test(n.style.width)&&(s=parseFloat(n.style.width));const a=c("th"===o?l.ROW:l.NO_STATUS,n.colSpan,s);a.__rowSpan=n.rowSpan;const u=n.style.backgroundColor;""!==u&&(a.__backgroundColor=u);const d=n.style.verticalAlign;i(d)&&(a.__verticalAlign=d);const h=n.style,g=(h&&h.textDecoration||"").split(" "),f="700"===h.fontWeight||"bold"===h.fontWeight,m=g.includes("line-through"),C="italic"===h.fontStyle,p=g.includes("underline");return{after:e=>{const n=[];let o=null;const r=()=>{if(o){const e=o.getFirstChild();t.$isLineBreakNode(e)&&1===o.getChildrenSize()&&e.remove()}};for(const l of e)t.$isInlineElementOrDecoratorNode(l)||t.$isTextNode(l)||t.$isLineBreakNode(l)?(t.$isTextNode(l)&&(f&&l.toggleFormat("bold"),m&&l.toggleFormat("strikethrough"),C&&l.toggleFormat("italic"),p&&l.toggleFormat("underline")),o?o.append(l):(o=t.$createParagraphNode().append(l),n.push(o))):(n.push(l),r(),o=null);return r(),0===n.length&&n.push(t.$createParagraphNode()),n},node:a}}function c(e=l.NO_STATUS,n=1,o){return t.$applyNodeReplacement(new s(e,n,o))}function u(e){return e instanceof s}const d=t.createCommand("INSERT_TABLE_COMMAND");function h(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class g extends t.ElementNode{__height;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 o;return r.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:t=>e.$descendantsMatching(t,u),node:m(o)}}function m(e){return t.$applyNodeReplacement(new g(e))}function C(e){return e instanceof g}const p="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,_=p&&"documentMode"in document?document.documentMode:null,S=p&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function N(e,n,o=!0){const r=He();for(let s=0;s<e;s++){const e=m();for(let r=0;r<n;r++){let n=l.NO_STATUS;"object"==typeof o?(0===s&&o.rows&&(n|=l.ROW),0===r&&o.columns&&(n|=l.COLUMN)):o&&(0===s&&(n|=l.ROW),0===r&&(n|=l.COLUMN));const i=c(n),a=t.$createParagraphNode();a.append(t.$createTextNode()),i.append(a),e.append(i)}r.append(e)}return r}function w(t){const n=e.$findMatchingParent(t,e=>C(e));if(C(n))return n;throw new Error("Expected table cell to be inside of table row.")}function b(t){const n=e.$findMatchingParent(t,e=>We(e));if(We(n))return n;throw new Error("Expected table cell to be inside of table.")}function T(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&&!_&&new window.InputEvent("input");const y=(e,t)=>e===l.BOTH||e===t?t:l.NO_STATUS;function $(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||J(n)||h(188);const o=n.anchor.getNode(),r=n.focus.getNode(),[l]=B(o),[s,,i]=B(r),[,a,c]=H(i,s,l),{startRow:u}=c,{startRow:d}=a;return e?M(u+l.__rowSpan>d+s.__rowSpan?l:s,!0):M(d<u?s:l,!1)}const R=$;function M(e,n=!0){const[,,o]=B(e),[r,s]=H(o,e,e),i=r[0].length,{startRow:a}=s;let u=null;if(n){const n=a+e.__rowSpan-1,s=r[n],d=m();for(let e=0;e<i;e++){const{cell:o,startRow:r}=s[e];if(r+o.__rowSpan-1<=n){const n=s[e].cell.__headerState,o=y(n,l.COLUMN);d.append(c(o).append(t.$createParagraphNode()))}else o.setRowSpan(o.__rowSpan+1)}const g=o.getChildAtIndex(n);C(g)||h(256),g.insertAfter(d),u=d}else{const e=a,n=r[e],s=m();for(let o=0;o<i;o++){const{cell:r,startRow:i}=n[o];if(i===e){const e=n[o].cell.__headerState,r=y(e,l.COLUMN);s.append(c(r).append(t.$createParagraphNode()))}else r.setRowSpan(r.__rowSpan+1)}const d=o.getChildAtIndex(e);C(d)||h(257),d.insertBefore(s),u=s}return u}function x(e=!0){const n=t.$getSelection();t.$isRangeSelection(n)||J(n)||h(188);const o=n.anchor.getNode(),r=n.focus.getNode(),[l]=B(o),[s,,i]=B(r),[,a,c]=H(i,s,l),{startColumn:u}=c,{startColumn:d}=a;return e?O(u+l.__colSpan>d+s.__colSpan?l:s,!0):O(d<u?s:l,!1)}const E=x;function O(e,n=!0,o=!0){const[,,r]=B(e),[s,i]=H(r,e,e),a=s.length,{startColumn:u}=i,d=n?u+e.__colSpan-1:u-1,g=r.getFirstChild();C(g)||h(120);let f=null;function m(e=l.NO_STATUS){const n=c(e).append(t.$createParagraphNode());return null===f&&(f=n),n}let p=g;e:for(let e=0;e<a;e++){if(0!==e){const e=p.getNextSibling();C(e)||h(121),p=e}const t=s[e],n=t[d<0?0:d].cell.__headerState,o=y(n,l.ROW);if(d<0){K(p,m(o));continue}const{cell:r,startColumn:i,startRow:a}=t[d];if(i+r.__colSpan-1<=d){let n=r,l=a,s=d;for(;l!==e&&n.__rowSpan>1;){if(s-=r.__colSpan,!(s>=0)){p.append(m(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,l=o}}n.insertAfter(m(o))}else r.setColSpan(r.__colSpan+1)}null!==f&&o&&D(f);const _=r.getColWidths();if(_){const e=[..._],t=d<0?0:d,n=e[t];e.splice(t,0,n),r.setColWidths(e)}return f}function A(){const e=t.$getSelection();t.$isRangeSelection(e)||J(e)||h(188);const[n,o]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,l]=B(n),[s]=B(o),[i,a,c]=H(l,r,s),{startRow:u}=a,{startRow:d}=c,g=d+s.__rowSpan-1;if(i.length===g-u+1)return void l.remove();const f=i[0].length,m=i[g+1],p=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(o<u||o+n.__rowSpan-1>g){const e=Math.max(o,u),t=Math.min(n.__rowSpan+o-1,g),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r)}if(o>=u&&o+n.__rowSpan-1>g&&e===g){null===p&&h(122);let o=null;for(let n=0;n<t;n++){const t=m[n],r=t.cell;t.startRow===e+1&&(o=r),r.__colSpan>1&&(n+=r.__colSpan-1)}null===o?K(p,n):o.insertAfter(n)}}}const t=l.getChildAtIndex(e);C(t)||h(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];D(e)}else{const e=i[u-1],{cell:t}=e[0];D(t)}}const v=A;function F(){const e=t.$getSelection();t.$isRangeSelection(e)||J(e)||h(188);const n=e.anchor.getNode(),o=e.focus.getNode(),[r,,l]=B(n),[s]=B(o),[i,a,c]=H(l,r,s),{startColumn:u}=a,{startRow:d,startColumn:g}=c,f=Math.min(u,g),m=Math.max(u+r.__colSpan-1,g+s.__colSpan-1),C=m-f+1;if(i[0].length===m-f+1)return l.selectPrevious(),void l.remove();const p=i.length;for(let e=0;e<p;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(C,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 _=i[d],S=u>g?_[u+r.__colSpan]:_[g+s.__colSpan];if(void 0!==S){const{cell:e}=S;D(e)}else{const e=g<u?_[g-1]:_[u-1],{cell:t}=e;D(t)}const N=l.getColWidths();if(N){const e=[...N];e.splice(f,C),l.setColWidths(e)}}const P=F;function D(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function K(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function I(e){if(0===e.length)return null;const n=b(e[0]),[o]=W(n,null,null);let r=1/0,l=-1/0,s=1/0,i=-1/0;const a=new Set;for(const t of o)for(const n of t){if(!n||!n.cell)continue;const t=n.cell.getKey();if(!a.has(t)&&e.some(e=>e.is(n.cell))){a.add(t);const e=n.startRow,o=n.startColumn,c=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;r=Math.min(r,e),l=Math.max(l,e+c-1),s=Math.min(s,o),i=Math.max(i,o+u-1)}}if(r===1/0||s===1/0)return null;const c=l-r+1,u=i-s+1,d=o[r][s];if(!d.cell)return null;const h=d.cell;h.setColSpan(u),h.setRowSpan(c);const g=new Set([h.getKey()]);for(let e=r;e<=l;e++)for(let t=s;t<=i;t++){const n=o[e][t];if(!n.cell)continue;const r=n.cell,l=r.getKey();if(!g.has(l)){g.add(l);L(r)||h.append(...r.getChildren()),r.remove()}}return 0===h.getChildrenSize()&&h.append(t.$createParagraphNode()),h}function L(e){if(1!==e.getChildrenSize())return!1;const n=e.getFirstChildOrThrow();return!(!t.$isParagraphNode(n)||!n.isEmpty())}function k(e){const[n,o,r]=B(e),s=n.__colSpan,i=n.__rowSpan;if(1===s&&1===i)return;const[a,u]=H(r,n,n),{startColumn:d,startRow:g}=u,f=n.__headerState&l.COLUMN,m=Array.from({length:s},(e,t)=>{let n=f;for(let e=0;0!==n&&e<a.length;e++)n&=a[e][t+d].cell.__headerState;return n}),p=n.__headerState&l.ROW,_=Array.from({length:i},(e,t)=>{let n=p;for(let e=0;0!==n&&e<a[0].length;e++)n&=a[t+g][e].cell.__headerState;return n});if(s>1){for(let e=1;e<s;e++)n.insertAfter(c(m[e]|_[0]).append(t.$createParagraphNode()));n.setColSpan(1)}if(i>1){let e;for(let n=1;n<i;n++){const r=g+n,l=a[r];e=(e||o).getNextSibling(),C(e)||h(125);let i=null;for(let e=0;e<d;e++){const t=l[e],n=t.cell;t.startRow===r&&(i=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===i)for(let o=s-1;o>=0;o--)K(e,c(m[o]|_[n]).append(t.$createParagraphNode()));else for(let e=s-1;e>=0;e--)i.insertAfter(c(m[e]|_[n]).append(t.$createParagraphNode()))}n.setRowSpan(1)}}function H(e,t,n){const[o,r,l]=W(e,t,n);return null===r&&h(207),null===l&&h(208),[o,r,l]}function W(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];C(o)||h(209);const a=s(e);for(let c=o.getFirstChild(),d=0;null!=c;c=c.getNextSibling()){for(u(c)||h(147);void 0!==a[d];)d++;const o={cell:c,startColumn:d,startRow:e},{__rowSpan:g,__colSpan:f}=c;for(let t=0;t<g&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<f;e++)n[d+e]=o}null!==t&&null===r&&t.is(c)&&(r=o),null!==n&&null===l&&n.is(c)&&(l=o)}}return[o,r,l]}function B(t){let n;if(t instanceof s)n=t;else if("__type"in t){const o=e.$findMatchingParent(t,u);u(o)||h(148),n=o}else{const o=e.$findMatchingParent(t.getNode(),u);u(o)||h(148),n=o}const o=n.getParent();C(o)||h(149);const r=o.getParent();return We(r)||h(210),[n,o,r]}function z(e,t,n){let o,r=Math.min(t.startColumn,n.startColumn),l=Math.min(t.startRow,n.startRow),s=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);do{o=!1;for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const a=e[t][n];if(!a)continue;const c=a.startColumn+a.cell.__colSpan-1,u=a.startRow+a.cell.__rowSpan-1,d=a.startColumn<=s&&c>=r,h=a.startRow<=i&&u>=l;if(d&&h){const e=Math.min(r,a.startColumn),t=Math.max(s,c),n=Math.min(l,a.startRow),d=Math.max(i,u);e===r&&t===s&&n===l&&d===i||(r=e,s=t,l=n,i=d,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function Y(e){const[t,,n]=B(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 U(t){const[[n,o,r,l],[s,i,a,c]]=["anchor","focus"].map(n=>{const o=t[n].getNode(),r=e.$findMatchingParent(o,u);u(r)||h(238,n,o.getKey(),o.getType());const l=r.getParent();C(l)||h(239,n);const s=l.getParent();return We(s)||h(240,n),[o,r,l,s]});return l.is(c)||h(241),{anchorCell:o,anchorNode:n,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:a,focusTable:c}}class X{tableKey;anchor;focus;_cachedNodes;dirty;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(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=t.$getNodeByKey(this.tableKey),n=t.$getNodeByKey(this.anchor.key),o=t.$getNodeByKey(this.focus.key);return null!==e&&null!==n&&null!==o}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return J(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 X(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(u).forEach(e=>{const o=e.getFirstChild();t.$isParagraphNode(o)&&(n|=o.getTextFormat())});const o=t.TEXT_TYPE_TO_FORMAT[e];return 0!==(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}=U(this),n=Y(e);null===n&&h(153);const o=Y(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),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}=U(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[s,i,a]=H(n,o,r),{minColumn:c,maxColumn:u,minRow:d,maxRow:g}=z(s,i,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}=s[e][t],o=n.getParent();C(o)||h(160),o!==m&&(f.set(o.getKey(),o),m=o),f.has(n.getKey())||j(n,e=>{f.set(e.getKey(),e)})}const p=Array.from(f.values());return t.isCurrentlyReadOnlyMode()||(this._cachedNodes=p),p}getTextContent(){const e=this.getNodes().filter(e=>u(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 J(e){return e instanceof X}function q(){const e=t.$createPoint("root",0,"element"),n=t.$createPoint("root",0,"element");return new X("root",e,n)}function G(e,n,o){e.getKey(),n.getKey(),o.getKey();const r=t.$getSelection(),l=J(r)?r.clone():q();return l.set(e.getKey(),n.getKey(),o.getKey()),l}function j(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 V(e,n=t.$getEditor()){const o=t.$getNodeByKey(e);We(o)||h(231,e);const r=te(o,n.getElementByKey(e));return null===r&&h(232,e),{tableElement:r,tableNode:o}}class Q{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;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.pointerType=null,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 V(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=de(n,o)},{editor:this.editor})});this.editor.getEditorState().read(()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=de(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();he(e,de(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(),he(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=ve(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==n)return this.focusCellNodeKey=n.getKey(),this.tableSelection=G(r,this.$getAnchorTableCellOrThrow(),n),t.$setSelection(this.tableSelection),o.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0),he(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=ve(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():q(),this.anchorCellNodeKey=e}}$formatCells(e){const n=t.$getSelection();J(n)||h(236);const o=t.$createRangeSelection(),r=o.anchor,l=o.focus,s=n.getNodes().filter(u);s.length>0||h(237);const i=s[0].getFirstChild(),a=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,a)}),t.$setSelection(n),this.editor.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:e}=this,n=t.$getNodeByKey(this.tableNodeKey);if(!We(n))throw new Error("Expected TableNode.");const o=t.$getSelection();J(o)||h(253);const r=o.getNodes().filter(u),l=n.getFirstChild(),s=n.getLastChild();if(r.length>0&&null!==l&&null!==s&&C(l)&&C(s)&&r[0]===l.getFirstChild()&&r[r.length-1]===s.getLastChild()){n.selectPrevious();const o=n.getParent();return n.remove(),void(t.$isRootNode(o)&&o.isEmpty()&&e.dispatchCommand(t.INSERT_PARAGRAPH_COMMAND,void 0))}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()})}}),he(e,this.table,null),t.$setSelection(null),e.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0)}}const Z="__lexicalTableSelection";function ee(e){return t.isHTMLElement(e)&&"TABLE"===e.nodeName}function te(e,t){if(!t)return t;const n=ee(t)?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&h(245,t.nodeName),n}function ne(e){return e._window}function oe(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;u(n)&&(o=n)}return null}const re=[[t.KEY_ARROW_DOWN_COMMAND,"down"],[t.KEY_ARROW_UP_COMMAND,"up"],[t.KEY_ARROW_LEFT_COMMAND,"backward"],[t.KEY_ARROW_RIGHT_COMMAND,"forward"]],le=[t.DELETE_WORD_COMMAND,t.DELETE_LINE_COMMAND,t.DELETE_CHARACTER_COMMAND],se=[t.KEY_BACKSPACE_COMMAND,t.KEY_DELETE_COMMAND];function ie(n,r,l,s){const i=l.getRootElement(),a=ne(l);null!==i&&null!==a||h(246);const c=new Q(l,n.getKey()),d=te(n,r);!function(e,t){null!==ae(e)&&h(205);e[Z]=t}(d,c),c.listenersToRemove.add(()=>function(e,t){ae(e)===t&&delete e[Z]}(d,c));const g=e=>{if(c.pointerType=e.pointerType,0!==e.button||!t.isDOMNode(e.target)||!a)return;const o=ce(e.target);null!==o&&l.update(()=>{const r=t.$getPreviousSelection();if(S&&e.shiftKey&&Ne(r,n)&&(t.$isRangeSelection(r)||J(r))){const t=r.anchor.getNode(),l=oe(n,r.anchor.getNode());if(l)c.$setAnchorCellForSelection(Ae(c,l)),c.$setFocusCellForSelection(o),xe(e);else{(n.isBefore(t)?n.selectStart():n.selectEnd()).anchor.set(r.anchor.key,r.anchor.offset,r.anchor.type)}}else"touch"!==e.pointerType&&c.$setAnchorCellForSelection(o)}),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,a.removeEventListener("pointerup",e),a.removeEventListener("pointermove",n)},n=o=>{if(1&~o.buttons&&c.isSelecting)return c.isSelecting=!1,a.removeEventListener("pointerup",e),void a.removeEventListener("pointermove",n);if(!t.isDOMNode(o.target))return;let r=null;const s=!(S||d.contains(o.target));if(s)r=ue(d,o.target);else for(const e of document.elementsFromPoint(o.clientX,o.clientY))if(r=ue(d,e),r)break;!r||null!==c.focusCell&&r.elem===c.focusCell.elem||(c.setNextFocus({focusCell:r,override:s}),l.dispatchCommand(t.SELECTION_CHANGE_COMMAND,void 0))};c.isSelecting=!0,a.addEventListener("pointerup",e,c.listenerOptions),a.addEventListener("pointermove",n,c.listenerOptions)})()};d.addEventListener("pointerdown",g,c.listenerOptions),c.listenersToRemove.add(()=>{d.removeEventListener("pointerdown",g)});const f=e=>{if(e.detail>=3&&t.isDOMNode(e.target)){null!==ce(e.target)&&e.preventDefault()}};d.addEventListener("mousedown",f,c.listenerOptions),c.listenersToRemove.add(()=>{d.removeEventListener("mousedown",f)});const m=e=>{const n=e.target;0===e.button&&t.isDOMNode(n)&&l.update(()=>{const e=t.$getSelection();J(e)&&e.tableKey===c.tableNodeKey&&i.contains(n)&&c.$clearHighlight()})};a.addEventListener("pointerdown",m,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("pointerdown",m)});for(const[e,o]of re)c.listenersToRemove.add(l.registerCommand(e,e=>Me(l,e,o,n,c),t.COMMAND_PRIORITY_HIGH));c.listenersToRemove.add(l.registerCommand(t.KEY_ESCAPE_COMMAND,e=>{const o=t.$getSelection();if(J(o)){const t=oe(n,o.focus.getNode());if(null!==t)return xe(e),t.selectEnd(),!0}return!1},t.COMMAND_PRIORITY_HIGH));const p=o=>()=>{const r=t.$getSelection();if(!Ne(r,n))return!1;if(J(r))return c.$clearText(),!0;if(t.$isRangeSelection(r)){if(!u(oe(n,r.anchor.getNode())))return!1;const l=r.anchor.getNode(),s=r.focus.getNode(),i=n.isParentOf(l),a=n.isParentOf(s);if(i&&!a||a&&!i)return c.$clearText(),!0;const d=e.$findMatchingParent(r.anchor.getNode(),e=>t.$isElementNode(e)),h=d&&e.$findMatchingParent(d,e=>t.$isElementNode(e)&&u(e.getParent()));if(!t.$isElementNode(h)||!t.$isElementNode(d))return!1;if(o===t.DELETE_LINE_COMMAND&&null===h.getPreviousSibling())return!0}return!1};for(const e of le)c.listenersToRemove.add(l.registerCommand(e,p(e),t.COMMAND_PRIORITY_CRITICAL));const _=e=>{const o=t.$getSelection();if(!J(o)&&!t.$isRangeSelection(o))return!1;const r=n.isParentOf(o.anchor.getNode());if(r!==n.isParentOf(o.focus.getNode())){const e=r?"anchor":"focus",t=r?"focus":"anchor",{key:l,offset:s,type:i}=o[t];return n[o[e].isBefore(o[t])?"selectPrevious":"selectNext"]()[t].set(l,s,i),!1}return!!Ne(o,n)&&(!!J(o)&&(e&&(e.preventDefault(),e.stopPropagation()),c.$clearText(),!0))};for(const e of se)c.listenersToRemove.add(l.registerCommand(e,_,t.COMMAND_PRIORITY_CRITICAL));return c.listenersToRemove.add(l.registerCommand(t.CUT_COMMAND,n=>{const r=t.$getSelection();if(r){if(!J(r)&&!t.$isRangeSelection(r))return!1;o.copyToClipboard(l,e.objectKlassEquals(n,ClipboardEvent)?n:null,o.$getClipboardDataFromSelection(r));const s=_(n);return t.$isRangeSelection(r)?(r.removeText(),!0):s}return!1},t.COMMAND_PRIORITY_CRITICAL)),c.listenersToRemove.add(l.registerCommand(t.FORMAT_TEXT_COMMAND,o=>{const r=t.$getSelection();if(!Ne(r,n))return!1;if(J(r))return c.$formatCells(o),!0;if(t.$isRangeSelection(r)){const t=e.$findMatchingParent(r.anchor.getNode(),e=>u(e));if(!u(t))return!1}return!1},t.COMMAND_PRIORITY_CRITICAL)),c.listenersToRemove.add(l.registerCommand(t.FORMAT_ELEMENT_COMMAND,e=>{const o=t.$getSelection();if(!J(o)||!Ne(o,n))return!1;const r=o.anchor.getNode(),l=o.focus.getNode();if(!u(r)||!u(l))return!1;if(function(e,t){if(J(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=H(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(o,n))return n.setFormat(e),!0;const[s,i,a]=H(n,r,l),c=Math.max(i.startRow+i.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),d=Math.max(i.startColumn+i.cell.__colSpan-1,a.startColumn+a.cell.__colSpan-1),h=Math.min(i.startRow,a.startRow),g=Math.min(i.startColumn,a.startColumn),f=new Set;for(let n=h;n<=c;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)),c.listenersToRemove.add(l.registerCommand(t.CONTROLLED_TEXT_INSERTION_COMMAND,o=>{const r=t.$getSelection();if(!Ne(r,n))return!1;if(J(r))return c.$clearHighlight(),!1;if(t.$isRangeSelection(r)){const s=e.$findMatchingParent(r.anchor.getNode(),e=>u(e));if(!u(s))return!1;if("string"==typeof o){const e=Oe(l,r,n);if(e)return Ee(e,n,[t.$createTextNode(o)]),!0}}return!1},t.COMMAND_PRIORITY_CRITICAL)),s&&c.listenersToRemove.add(l.registerCommand(t.KEY_TAB_COMMAND,o=>{const r=t.$getSelection();if(!t.$isRangeSelection(r)||!r.isCollapsed()||!Ne(r,n))return!1;const l=ye(r.anchor.getNode());return!(null===l||!n.is($e(l)))&&(xe(o),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,C);null===i&&h(247);for(let e=i[r]();C(e);e=e[r]()){const n=e[l]();if(t.$isElementNode(n))return n.selectEnd()}const a=e.$findMatchingParent(i,We);null===a&&h(248);"next"===o?a.selectNext():a.selectPrevious()}(l,o.shiftKey?"previous":"next"),!0)},t.COMMAND_PRIORITY_CRITICAL)),c.listenersToRemove.add(l.registerCommand(t.FOCUS_COMMAND,e=>n.isSelected(),t.COMMAND_PRIORITY_HIGH)),c.listenersToRemove.add(l.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(n,o)=>{if(l!==o)return!1;const{nodes:r,selection:s}=n,i=s.getStartEndPoints(),a=J(s),c=t.$isRangeSelection(s)&&null!==e.$findMatchingParent(s.anchor.getNode(),e=>u(e))&&null!==e.$findMatchingParent(s.focus.getNode(),e=>u(e))||a;if(1!==r.length||!We(r[0])||!c||null===i)return!1;const[d,h]=i,[g,f,m]=B(d),p=e.$findMatchingParent(h.getNode(),e=>u(e));if(!(u(g)&&u(p)&&C(f)&&We(m)))return!1;const _=r[0],[S,N,w]=H(m,g,p),[b]=W(_,null,null),T=S.length,y=T>0?S[0].length:0;let $=N.startRow,R=N.startColumn,x=b.length,E=x>0?b[0].length:0;if(a){const e=z(S,N,w),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;$=e.minRow,R=e.minColumn,x=Math.min(x,t),E=Math.min(E,n)}let A=!1;const v=Math.min(T,$+x)-1,F=Math.min(y,R+E)-1,P=new Set;for(let e=$;e<=v;e++)for(let t=R;t<=F;t++){const n=S[e][t];P.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(k(n.cell),P.add(n.cell.getKey()),A=!0))}let[D]=W(m.getWritable(),null,null);const K=x-T+$;for(let e=0;e<K;e++){M(D[T-1][0].cell)}const L=E-y+R;for(let e=0;e<L;e++){O(D[0][y-1].cell,!0,!1)}[D]=W(m.getWritable(),null,null);for(let e=$;e<$+x;e++)for(let n=R;n<R+E;n++){const o=e-$,r=n-R,l=b[o][r];if(l.startRow!==o||l.startColumn!==r)continue;const s=l.cell;if(1!==s.__rowSpan||1!==s.__colSpan){const t=[],o=Math.min(e+s.__rowSpan,$+x)-1,r=Math.min(n+s.__colSpan,R+E)-1;for(let l=e;l<=o;l++)for(let e=n;e<=r;e++){const n=D[l][e];t.push(n.cell)}I(t),A=!0}const{cell:i}=D[e][n],a=i.getChildren();s.getChildren().forEach(e=>{if(t.$isTextNode(e)){t.$createParagraphNode().append(e),i.append(e)}else i.append(e)}),a.forEach(e=>e.remove())}if(a&&A){const[e]=W(m.getWritable(),null,null);e[N.startRow][N.startColumn].cell.selectEnd()}return!0},t.COMMAND_PRIORITY_CRITICAL)),c.listenersToRemove.add(l.registerCommand(t.SELECTION_CHANGE_COMMAND,()=>{const o=t.$getSelection(),r=t.$getPreviousSelection(),s=c.getAndClearNextFocus();if(null!==s){const{focusCell:e}=s;if(J(o)&&o.tableKey===c.tableNodeKey)return(e.x!==c.focusX||e.y!==c.focusY)&&(c.$setFocusCellForSelection(e),!0);if(e!==c.anchorCell&&Ne(o,n))return c.$setFocusCellForSelection(e),!0}if(c.getAndClearShouldCheckSelection()&&t.$isRangeSelection(r)&&t.$isRangeSelection(o)&&o.isCollapsed()){const t=o.anchor.getNode(),r=n.getFirstChild(),l=ye(t);if(null!==l&&C(r)){const t=r.getFirstChild();if(u(t)&&n.is(e.$findMatchingParent(l,e=>e.is(n)||e.is(t))))return t.selectStart(),!0}}if(t.$isRangeSelection(o)){const{anchor:e,focus:s}=o,i=e.getNode(),a=s.getNode(),u=ye(i),d=ye(a),h=!(!u||!n.is($e(u))),g=!(!d||!n.is($e(d))),f=h!==g,m=h&&g,C=o.isBackward();if(f){const e=o.clone();if(g){const[t]=H(n,d,d),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.focus.set(C?o.getKey():r.getKey(),C?o.getChildrenSize():r.getChildrenSize(),"element")}else if(h){const[t]=H(n,u,u),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;e.anchor.set(C?r.getKey():o.getKey(),C?r.getChildrenSize():0,"element")}t.$setSelection(e),fe(l,c)}else if(m&&(u.is(d)||(c.$setAnchorCellForSelection(Ae(c,u)),c.$setFocusCellForSelection(Ae(c,d),!0)),"touch"===c.pointerType&&c.isSelecting&&o.isCollapsed()&&t.$isRangeSelection(r)&&r.isCollapsed())){const e=ye(r.anchor.getNode());e&&!e.is(d)&&(c.$setAnchorCellForSelection(Ae(c,e)),c.$setFocusCellForSelection(Ae(c,d),!0),c.pointerType=null)}}else if(o&&J(o)&&o.is(r)&&o.tableKey===n.getKey()){const e=t.getDOMSelection(a);if(e&&e.anchorNode&&e.focusNode){const r=t.$getNearestNodeFromDOMNode(e.focusNode),s=r&&!n.isParentOf(r),i=t.$getNearestNodeFromDOMNode(e.anchorNode),a=i&&n.isParentOf(i);if(s&&a&&e.rangeCount>0){const r=t.$createRangeSelectionFromDom(e,l);r&&(r.anchor.set(n.getKey(),o.isBackward()?n.getChildrenSize():0,"element"),e.removeAllRanges(),t.$setSelection(r))}}}return o&&!o.is(r)&&(J(o)||J(r))&&c.tableSelection&&!c.tableSelection.is(r)?(J(o)&&o.tableKey===c.tableNodeKey?c.$updateTableTableSelection(o):!J(o)&&J(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),!1):(c.hasHijackedSelectionStyles&&!n.isSelected()?function(e,t){t.$enableHighlightStyle(),ge(t.table,t=>{const n=t.elem;t.highlighted=!1,Te(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(l,c):!c.hasHijackedSelectionStyles&&n.isSelected()&&fe(l,c),!1)},t.COMMAND_PRIORITY_CRITICAL)),c.listenersToRemove.add(l.registerCommand(t.INSERT_PARAGRAPH_COMMAND,()=>{const e=t.$getSelection();if(!t.$isRangeSelection(e)||!e.isCollapsed()||!Ne(e,n))return!1;const o=Oe(l,e,n);return!!o&&(Ee(o,n),!0)},t.COMMAND_PRIORITY_CRITICAL)),c}function ae(e){return e[Z]||null}function ce(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 ue(e,t){if(!e.contains(t))return null;let n=null;for(let o=t;null!=o;o=o.parentNode){if(o===e)return n;const t=o.nodeName;"TD"!==t&&"TH"!==t||(n=o._cell||null)}return null}function de(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=te(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 he(e,t,n){const o=new Set(n?n.getNodes():[]);ge(t,(t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,be(e,t)):(t.highlighted=!1,Te(e,t),r.getAttribute("style")||r.removeAttribute("style"))})}function ge(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 fe(e,t){t.$disableHighlightStyle(),ge(t.table,t=>{t.highlighted=!0,be(e,t)})}const me=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?we(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?we(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?we(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?we(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Ce(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 pe([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function _e(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&h(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&h(250,n,String(s)),i}function Se(e,t,n,o,r){const l=z(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,d=function(e,t){const n=Ce(e,t);return null===n&&h(249,t.cell.getKey()),n}(l,n),[g,f]=pe(d);let m=l[g],C=l[f];"forward"===r?m+="maxColumn"===g?1:a:"backward"===r?m-="minColumn"===g?1:u:"down"===r?C+="maxRow"===f?1:i:"up"===r&&(C-="minRow"===f?1:c);const p=t[C];if(void 0===p)return!1;const _=p[m];if(void 0===_)return!1;const[S,N]=function(e,t,n){const o=z(e,t,n),r=Ce(o,t);if(r)return[_e(e,o,r),_e(e,o,pe(r))];const l=Ce(o,n);if(l)return[_e(e,o,pe(l)),_e(e,o,l)];const s=["minColumn","minRow"];return[_e(e,o,s),_e(e,o,pe(s))]}(t,n,_),w=Ae(e,S.cell),b=Ae(e,N.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function Ne(e,n){if(t.$isRangeSelection(e)||J(e)){const t=n.isParentOf(e.anchor.getNode()),o=n.isParentOf(e.focus.getNode());return t&&o}return!1}function we(e,t){t?e.selectStart():e.selectEnd()}function be(n,o){const r=o.elem,l=n._config.theme;u(t.$getNearestNodeFromDOMNode(r))||h(131),e.addClassNamesToElement(r,l.tableCellSelected)}function Te(n,o){const r=o.elem;u(t.$getNearestNodeFromDOMNode(r))||h(131);const l=n._config.theme;e.removeClassNamesFromElement(r,l.tableCellSelected)}function ye(t){const n=e.$findMatchingParent(t,u);return u(n)?n:null}function $e(t){const n=e.$findMatchingParent(t,We);return We(n)?n:null}function Re(n,o,r,l,s,i,a){const c=t.$caretFromPoint(r.focus,s?"previous":"next");if(t.$isExtendableTextPointCaret(c))return!1;let d=c;for(const e of t.$extendCaretToRange(c).iterNodeCarets("shadowRoot")){if(!t.$isSiblingCaret(e)||!t.$isElementNode(e.origin))return!1;d=e}const h=d.getParentAtCaret();if(!u(h))return!1;const g=h,f=function(e){for(const n of t.$extendCaretToRange(e).iterNodeCarets("root")){const{origin:o}=n;if(u(o)){if(t.$isChildCaret(n))return t.$getChildCaret(o,e.direction)}else if(!C(o))break}return null}(t.$getSiblingCaret(g,d.direction)),m=e.$findMatchingParent(g,We);if(!m||!m.is(i))return!1;const p=n.getElementByKey(g.getKey()),_=ce(p);if(!p||!_)return!1;const S=Le(n,m);if(a.table=S,f)if("extend"===l){const e=ce(n.getElementByKey(f.origin.getKey()));if(!e)return!1;a.$setAnchorCellForSelection(_),a.$setFocusCellForSelection(e,!0)}else{const e=t.$normalizeCaret(f);t.$setPointFromCaret(r.anchor,e),t.$setPointFromCaret(r.focus,e)}else if("extend"===l)a.$setAnchorCellForSelection(_),a.$setFocusCellForSelection(_,!0);else{const e=function(e){const n=t.$getAdjacentChildCaret(e);return t.$isChildCaret(n)?t.$normalizeCaret(n):e}(t.$getSiblingCaret(m,c.direction));t.$setPointFromCaret(r.anchor,e),t.$setPointFromCaret(r.focus,e)}return xe(o),!0}function Me(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(!Ne(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!!We(n)&&(xe(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=>We(e));if(u(s)&&(s=e.$findMatchingParent(s,We)),s!==l)return!1;if(!s)return!1;const a="down"===r?s.getNextSibling():s.getPreviousSibling();if(!a)return!1;let c=0;"up"===r&&t.$isElementNode(a)&&(c=a.getChildrenSize());let d=a;if("up"===r&&t.$isElementNode(a)){const e=a.getLastChild();d=e||a,c=t.$isTextNode(d)?d.getTextContentSize():0}const h=i.clone();return h.focus.set(d.getKey(),c,t.$isTextNode(d)?"text":"element"),t.$setSelection(h),xe(o),!0}if(t.$isRootOrShadowRoot(n)){const e="up"===r?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==oe(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=B(e),[o]=B(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(u(l)&&(l=e.$findMatchingParent(l,We)),!l)return!1;const a="down"===r?l.getNextSibling():l.getPreviousSibling();if(We(a)&&s.tableNodeKey===a.getKey()){const e=a.getFirstDescendant(),n=a.getLastDescendant();if(!e||!n)return!1;const[l]=B(e),[s]=B(n),c=i.clone();return c.focus.set(("up"===r?l:s).getKey(),"up"===r?0:s.getChildrenSize(),"element"),xe(o),t.$setSelection(c),!0}}}}return"down"===r&&De(n)&&s.setShouldCheckSelection(),!1}if(t.$isRangeSelection(i)){if("backward"===r||"forward"===r){return Re(n,o,i,o.shiftKey?"extend":"move","backward"===r,l,s)}if(i.isCollapsed()){const{anchor:a,focus:c}=i,d=e.$findMatchingParent(a.getNode(),u),h=e.$findMatchingParent(c.getNode(),u);if(!u(d)||!d.is(h))return!1;const g=$e(d);if(g!==l&&null!=g){const e=te(g,n.getElementByKey(g.getKey()));if(null!=e)return s.table=de(g,e),Me(n,o,r,g,s)}const f=n.getElementByKey(d.__key),m=n.getElementByKey(a.key);if(null==m||null==f)return!1;let C;if("element"===a.type)C=m.getBoundingClientRect();else{const e=t.getDOMSelection(ne(n));if(null===e||0===e.rangeCount)return!1;C=e.getRangeAt(0).getBoundingClientRect()}const p="up"===r?d.getFirstChild():d.getLastChild();if(null==p)return!1;const _=n.getElementByKey(p.__key);if(null==_)return!1;const S=_.getBoundingClientRect();if("up"===r?S.top>C.top-C.height:C.bottom+C.height>S.bottom){xe(o);const e=l.getCordsFromCellNode(d,s.table);if(!o.shiftKey)return me(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(J(i)){const{anchor:t,focus:a}=i,c=e.$findMatchingParent(t.getNode(),u),d=e.$findMatchingParent(a.getNode(),u),[g]=i.getNodes();We(g)||h(251);const f=te(g,n.getElementByKey(g.getKey()));if(!u(c)||!u(d)||!We(g)||null==f)return!1;s.$updateTableTableSelection(i);const m=de(g,f),C=l.getCordsFromCellNode(c,m),p=l.getDOMCellFromCordsOrThrow(C.x,C.y,m);if(s.$setAnchorCellForSelection(p),xe(o),o.shiftKey){const[e,t,n]=H(l,c,d);return Se(s,e,t,n,r)}return d.selectEnd(),!0}return!1}function xe(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function Ee(e,n,o){const r=t.$createParagraphNode();"first"===e?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function Oe(n,o,r){const l=r.getParent();if(!l)return;const s=t.getDOMSelection(ne(n));if(!s)return;const i=s.anchorNode,a=n.getElementByKey(l.getKey()),c=te(r,n.getElementByKey(r.getKey()));if(!i||!a||!c||!a.contains(i)||c.contains(i))return;const d=e.$findMatchingParent(o.anchor.getNode(),e=>u(e));if(!d)return;const h=e.$findMatchingParent(d,e=>We(e));if(!We(h)||!h.is(r))return;const[g,f]=H(r,d,d),m=g[0][0],C=g[g.length-1][g[0].length-1],{startRow:p,startColumn:_}=f,S=p===m.startRow&&_===m.startColumn,N=p===C.startRow&&_===C.startColumn;return S?"first":N?"last":void 0}function Ae(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function ve(e,n,o){return oe(e,t.$getNearestNodeFromDOMNode(n,o))}function Fe(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 Pe=new WeakSet;function De(e=t.$getEditor()){return Pe.has(e)}function Ke(e,t){t?Pe.add(e):Pe.delete(e)}class Ie extends t.ElementNode{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;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 Ie(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:ke,priority:1})}}static importJSON(e){return He().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0,this.__colWidths=void 0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t=ee(e)?e:e.querySelector("table");return ee(t)||h(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(n,o){const r=document.createElement("table");this.__style&&(r.style.cssText=this.__style);const l=document.createElement("colgroup");if(r.appendChild(l),t.setDOMUnmanaged(l),e.addClassNamesToElement(r,n.theme.table),this.updateTableElement(null,r,n),De(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),this.updateTableWrapper(null,t,r,n),t}return r}updateTableWrapper(t,n,o,r){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,o,r){r>0?(e.addClassNamesToElement(t,o.theme.tableFrozenColumn),n.setAttribute("data-lexical-frozen-column","true")):(e.removeClassNamesFromElement(t,o.theme.tableFrozenColumn),n.removeAttribute("data-lexical-frozen-column"))}(n,o,r,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,o,r){r>0?(e.addClassNamesToElement(t,o.theme.tableFrozenRow),n.setAttribute("data-lexical-frozen-row","true")):(e.removeClassNamesFromElement(t,o.theme.tableFrozenRow),n.removeAttribute("data-lexical-frozen-row"))}(n,o,r,this.__frozenRowCount)}updateTableElement(t,n,o){this.__style!==(t?t.__style:"")&&(n.style.cssText=this.__style),this.__rowStriping!==(!!t&&t.__rowStriping)&&function(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"))}(n,o,this.__rowStriping),function(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)}(n,0,this.getColumnCount(),this.getColWidths()),Fe(n,o,this.getFormatType())}updateDOM(t,n,o){const r=this.getDOMSlot(n).element;return n===r===De()||(l=n,e.isHTMLElement(l)&&"DIV"===l.nodeName&&this.updateTableWrapper(t,n,r,o),this.updateTableElement(t,r,o),!1);var l}exportDOM(t){const n=super.exportDOM(t),{element:o}=n;return{after:o=>{if(n.after&&(o=n.after(o)),!ee(o)&&e.isHTMLElement(o)&&(o=o.querySelector("table")),!ee(o))return null;Fe(o,t._config,this.getFormatType());const[r]=W(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:!ee(o)&&e.isHTMLElement(o)?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=ve(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 u(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}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){const t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach(e=>{u(e)&&(t+=e.getColSpan())}),t}}function Le(e,t){const n=e.getElementByKey(t.getKey());return null===n&&h(230),de(t,n)}function ke(t){const n=He();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0),t.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),t.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=t.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!r.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,C),node:n}}function He(){return t.$applyNodeReplacement(new Ie)}function We(e){return e instanceof Ie}function Be({rows:n,columns:o,includeHeaders:r}){const l=t.$getSelection()||t.$getPreviousSelection();if(!l||!t.$isRangeSelection(l))return!1;if($e(l.anchor.getNode()))return!1;const s=N(Number(n),Number(o),r);e.$insertNodeToNearestRoot(s);const i=s.getFirstDescendant();return t.$isTextNode(i)&&i.select(),!0}function ze(e){C(e.getParent())?e.isEmpty()&&e.append(t.$createParagraphNode()):e.remove()}function Ye(t){We(t.getParent())?e.$unwrapAndFilterDescendants(t,u):t.remove()}function Ue(n){e.$unwrapAndFilterDescendants(n,C);const[o]=W(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;C(n)||h(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=c();e.append(t.$createParagraphNode()),n.append(e)}}}function Xe(n){if(n.detail<3||!t.isDOMNode(n.target))return!1;const o=t.$getNearestNodeFromDOMNode(n.target);if(null===o)return!1;const r=e.$findMatchingParent(o,e=>t.$isElementNode(e)&&!e.isInline());if(null===r)return!1;return!!u(r.getParent())&&(r.select(0),!0)}function Je(t){return t.registerNodeTransform(s,t=>{if(t.getColSpan()>1||t.getRowSpan()>1){const[,,n]=B(t),[o]=H(n,t,t),r=o.length,l=o[0].length;let s=n.getFirstChild();C(s)||h(175);const i=[];for(let t=0;t<r;t++){0!==t&&(s=s.getNextSibling(),C(s)||h(175));let n=null;for(let r=0;r<l;r++){const l=o[t][r],a=l.cell;if(l.startRow===t&&l.startColumn===r)n=a,i.push(a);else if(a.getColSpan()>1||a.getRowSpan()>1){u(a)||h(176);const t=c(a.__headerState);null!==n?n.insertAfter(t):e.$insertFirst(s,t)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}})}function qe(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=te(o,l),i=ie(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(Ie,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}=V(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 Ge(n){return n.hasNodes([Ie])||h(255),e.mergeRegister(n.registerCommand(d,Be,t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,({nodes:e,selection:o},r)=>{if(n!==r||!t.$isRangeSelection(o))return!1;return null!==$e(o.anchor.getNode())&&e.some(We)},t.COMMAND_PRIORITY_EDITOR),n.registerCommand(t.CLICK_COMMAND,Xe,t.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(Ie,Ue),n.registerNodeTransform(g,Ye),n.registerNodeTransform(s,ze))}const je=t.defineExtension({build:(e,t,o)=>n.namedSignals(t),config:t.safeCast({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasTabHandler:!0}),name:"@lexical/table/Table",nodes:[Ie,g,s],register(t,o,r){const l=r.getOutput();return e.mergeRegister(n.effect(()=>{const e=l.hasHorizontalScroll.value;De(t)!==e&&(Ke(t,e),t.registerNodeTransform(Ie,()=>{})())}),Ge(t),n.effect(()=>qe(t,l.hasTabHandler.value)),n.effect(()=>l.hasCellMerge.value?void 0:Je(t)),n.effect(()=>l.hasCellBackgroundColor.value?void 0:t.registerNodeTransform(s,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}});exports.$computeTableMap=H,exports.$computeTableMapSkipCellCheck=W,exports.$createTableCellNode=c,exports.$createTableNode=He,exports.$createTableNodeWithDimensions=N,exports.$createTableRowNode=m,exports.$createTableSelection=q,exports.$createTableSelectionFrom=G,exports.$deleteTableColumn=function(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(C(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.$deleteTableColumnAtSelection=F,exports.$deleteTableColumn__EXPERIMENTAL=P,exports.$deleteTableRowAtSelection=A,exports.$deleteTableRow__EXPERIMENTAL=v,exports.$findCellNode=ye,exports.$findTableNode=$e,exports.$getElementForTableNode=Le,exports.$getNodeTriplet=B,exports.$getTableAndElementByKey=V,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,e=>u(e));return u(n)?n:null},exports.$getTableCellNodeRect=Y,exports.$getTableColumnIndexFromTableCellNode=function(e){return w(e).getChildren().findIndex(t=>t.is(e))},exports.$getTableNodeFromLexicalNodeOrThrow=b,exports.$getTableRowIndexFromTableCellNode=function(e){const t=w(e);return b(t).getChildren().findIndex(e=>e.is(t))},exports.$getTableRowNodeFromTableCellNodeOrThrow=w,exports.$insertTableColumn=function(e,n,o=!0,r,s){const i=e.getChildren(),a=[];for(let e=0;e<i.length;e++){const o=i[e];if(C(o))for(let e=0;e<r;e++){const e=o.getChildren();if(n>=e.length||n<0)throw new Error("Table column target index out of range");const r=e[n];u(r)||h(12);const{left:i,right:d}=T(r,s);let g=l.NO_STATUS;(i&&i.hasHeaderState(l.ROW)||d&&d.hasHeaderState(l.ROW))&&(g|=l.ROW);const f=c(g);f.append(t.$createParagraphNode()),a.push({newTableCell:f,targetCell:r})}}return a.forEach(({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)}),e},exports.$insertTableColumnAtSelection=x,exports.$insertTableColumn__EXPERIMENTAL=E,exports.$insertTableRow=function(e,n,o=!0,r,s){const i=e.getChildren();if(n>=i.length||n<0)throw new Error("Table row target index out of range");const a=i[n];if(!C(a))throw new Error("Row before insertion index does not exist.");for(let e=0;e<r;e++){const e=a.getChildren(),n=e.length,r=m();for(let o=0;o<n;o++){const n=e[o];u(n)||h(12);const{above:i,below:a}=T(n,s);let d=l.NO_STATUS;const g=i&&i.getWidth()||a&&a.getWidth()||void 0;(i&&i.hasHeaderState(l.COLUMN)||a&&a.hasHeaderState(l.COLUMN))&&(d|=l.COLUMN);const f=c(d,1,g);f.append(t.$createParagraphNode()),r.append(f)}o?a.insertAfter(r):a.insertBefore(r)}return e},exports.$insertTableRowAtSelection=$,exports.$insertTableRow__EXPERIMENTAL=R,exports.$isScrollableTablesActive=De,exports.$isTableCellNode=u,exports.$isTableNode=We,exports.$isTableRowNode=C,exports.$isTableSelection=J,exports.$mergeCells=I,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 n=t.$getSelection();t.$isRangeSelection(n)||J(n)||h(188);const o=n.anchor.getNode(),r=e.$findMatchingParent(o,u);return u(r)||h(148),k(r)},exports.INSERT_TABLE_COMMAND=d,exports.TableCellHeaderStates=l,exports.TableCellNode=s,exports.TableExtension=je,exports.TableNode=Ie,exports.TableObserver=Q,exports.TableRowNode=g,exports.applyTableHandlers=ie,exports.getDOMCellFromTarget=ce,exports.getTableElement=te,exports.getTableObserverFromTableElement=ae,exports.registerTableCellUnmergeTransform=Je,exports.registerTablePlugin=Ge,exports.registerTableSelectionObserver=qe,exports.setScrollableTablesActive=Ke;
@@ -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,$isInlineElementOrDecoratorNode as d,$isTextNode as f,$isLineBreakNode as g,$createParagraphNode as m,$applyNodeReplacement as p,createCommand as C,$createTextNode as _,$getSelection as S,$isRangeSelection as w,$isParagraphNode as b,$createPoint as y,$getNodeByKey as N,$isElementNode as v,$normalizeSelection__EXPERIMENTAL as x,isCurrentlyReadOnlyMode as T,TEXT_TYPE_TO_FORMAT as R,$getEditor as F,$setSelection as O,SELECTION_CHANGE_COMMAND as A,getDOMSelection as K,$createRangeSelection as E,$isRootNode as k,INSERT_PARAGRAPH_COMMAND as M,KEY_ARROW_DOWN_COMMAND as $,KEY_ARROW_UP_COMMAND as z,KEY_ARROW_LEFT_COMMAND as H,KEY_ARROW_RIGHT_COMMAND as W,COMMAND_PRIORITY_HIGH as L,KEY_ESCAPE_COMMAND as B,DELETE_WORD_COMMAND as P,DELETE_LINE_COMMAND as D,DELETE_CHARACTER_COMMAND as I,COMMAND_PRIORITY_CRITICAL as U,KEY_BACKSPACE_COMMAND as J,KEY_DELETE_COMMAND as Y,CUT_COMMAND as X,FORMAT_TEXT_COMMAND as q,FORMAT_ELEMENT_COMMAND as j,CONTROLLED_TEXT_INSERTION_COMMAND as V,KEY_TAB_COMMAND as G,FOCUS_COMMAND as Q,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as Z,$getPreviousSelection as ee,$getNearestNodeFromDOMNode as te,$createRangeSelectionFromDom as ne,isDOMNode as oe,$isRootOrShadowRoot as re,$caretFromPoint as le,$isExtendableTextPointCaret as se,$extendCaretToRange as ie,$isSiblingCaret as ce,$getSiblingCaret as ae,$setPointFromCaret as ue,$normalizeCaret as he,$isChildCaret as de,$getChildCaret as fe,$getAdjacentChildCaret as ge,setDOMUnmanaged as me,COMMAND_PRIORITY_EDITOR as pe,CLICK_COMMAND as Ce,defineExtension as _e,safeCast as Se}from"lexical";import{effect as we,namedSignals as be}from"@lexical/extension";import{copyToClipboard as ye,$getClipboardDataFromSelection as Ne}from"@lexical/clipboard";const ve=/^(\d+(?:\.\d+)?)px$/,xe={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class Te extends u{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new Te(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:Fe,priority:0}),th:e=>({conversion:Fe,priority:0})}}static importJSON(e){return Oe().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=xe.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0}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),Re(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(),...Re(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=xe.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!==xe.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 Re(e){return"middle"===e||"bottom"===e}function Fe(e){const t=e,n=e.nodeName.toLowerCase();let o;ve.test(t.style.width)&&(o=parseFloat(t.style.width));const r=Oe("th"===n?xe.ROW:xe.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style.verticalAlign;Re(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=>{const t=[];let n=null;const o=()=>{if(n){const e=n.getFirstChild();g(e)&&1===n.getChildrenSize()&&e.remove()}};for(const r of e)d(r)||f(r)||g(r)?(f(r)&&(a&&r.toggleFormat("bold"),u&&r.toggleFormat("strikethrough"),h&&r.toggleFormat("italic"),p&&r.toggleFormat("underline")),n?n.append(r):(n=m().append(r),t.push(n))):(t.push(r),o(),n=null);return o(),0===t.length&&t.push(m()),t},node:r}}function Oe(e=xe.NO_STATUS,t=1,n){return p(new Te(e,t,n))}function Ae(e){return e instanceof Te}const Ke=C("INSERT_TABLE_COMMAND");function Ee(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class ke extends u{__height;static getType(){return"tablerow"}static clone(e){return new ke(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:Me,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 Me(e){const n=e;let o;return ve.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>t(e,Ae),node:$e(o)}}function $e(e){return p(new ke(e))}function ze(e){return e instanceof ke}const He="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,We=He&&"documentMode"in document?document.documentMode:null,Le=He&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function Be(e,t,n=!0){const o=mn();for(let r=0;r<e;r++){const e=$e();for(let o=0;o<t;o++){let t=xe.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=xe.ROW),0===o&&n.columns&&(t|=xe.COLUMN)):n&&(0===r&&(t|=xe.ROW),0===o&&(t|=xe.COLUMN));const l=Oe(t),s=m();s.append(_()),l.append(s),e.append(l)}o.append(e)}return o}function Pe(e){const t=n(e,e=>Ae(e));return Ae(t)?t:null}function De(e){const t=n(e,e=>ze(e));if(ze(t))return t;throw new Error("Expected table cell to be inside of table row.")}function Ie(e){const t=n(e,e=>pn(e));if(pn(t))return t;throw new Error("Expected table cell to be inside of table.")}function Ue(e){const t=De(e);return Ie(t).getChildren().findIndex(e=>e.is(t))}function Je(e){return De(e).getChildren().findIndex(t=>t.is(e))}function Ye(e,t){const n=Ie(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 Xe(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 qe(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(!ze(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];Ae(t)||Ee(12);const{above:l,below:s}=Ye(t,r);let i=xe.NO_STATUS;const c=l&&l.getWidth()||s&&s.getWidth()||void 0;(l&&l.hasHeaderState(xe.COLUMN)||s&&s.hasHeaderState(xe.COLUMN))&&(i|=xe.COLUMN);const a=Oe(i,1,c);a.append(m()),o.append(a)}n?s.insertAfter(o):s.insertBefore(o)}return e}He&&"InputEvent"in window&&!We&&new window.InputEvent("input");const je=(e,t)=>e===xe.BOTH||e===t?t:xe.NO_STATUS;function Ve(e=!0){const t=S();w(t)||bt(t)||Ee(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=pt(n),[l,,s]=pt(o),[,i,c]=gt(s,l,r),{startRow:a}=c,{startRow:u}=i;return e?Qe(a+r.__rowSpan>u+l.__rowSpan?r:l,!0):Qe(u<a?l:r,!1)}const Ge=Ve;function Qe(e,t=!0){const[,,n]=pt(e),[o,r]=gt(n,e,e),l=o[0].length,{startRow:s}=r;let i=null;if(t){const t=s+e.__rowSpan-1,r=o[t],c=$e();for(let e=0;e<l;e++){const{cell:n,startRow:o}=r[e];if(o+n.__rowSpan-1<=t){const t=r[e].cell.__headerState,n=je(t,xe.COLUMN);c.append(Oe(n).append(m()))}else n.setRowSpan(n.__rowSpan+1)}const a=n.getChildAtIndex(t);ze(a)||Ee(256),a.insertAfter(c),i=c}else{const e=s,t=o[e],r=$e();for(let n=0;n<l;n++){const{cell:o,startRow:l}=t[n];if(l===e){const e=t[n].cell.__headerState,o=je(e,xe.COLUMN);r.append(Oe(o).append(m()))}else o.setRowSpan(o.__rowSpan+1)}const c=n.getChildAtIndex(e);ze(c)||Ee(257),c.insertBefore(r),i=r}return i}function Ze(e,t,n=!0,o,r){const l=e.getChildren(),s=[];for(let e=0;e<l.length;e++){const n=l[e];if(ze(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];Ae(o)||Ee(12);const{left:l,right:i}=Ye(o,r);let c=xe.NO_STATUS;(l&&l.hasHeaderState(xe.ROW)||i&&i.hasHeaderState(xe.ROW))&&(c|=xe.ROW);const a=Oe(c);a.append(m()),s.push({newTableCell:a,targetCell:o})}}return s.forEach(({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)}),e}function et(e=!0){const t=S();w(t)||bt(t)||Ee(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=pt(n),[l,,s]=pt(o),[,i,c]=gt(s,l,r),{startColumn:a}=c,{startColumn:u}=i;return e?nt(a+r.__colSpan>u+l.__colSpan?r:l,!0):nt(u<a?l:r,!1)}const tt=et;function nt(e,t=!0,n=!0){const[,,o]=pt(e),[r,l]=gt(o,e,e),s=r.length,{startColumn:i}=l,c=t?i+e.__colSpan-1:i-1,a=o.getFirstChild();ze(a)||Ee(120);let u=null;function h(e=xe.NO_STATUS){const t=Oe(e).append(m());return null===u&&(u=t),t}let d=a;e:for(let e=0;e<s;e++){if(0!==e){const e=d.getNextSibling();ze(e)||Ee(121),d=e}const t=r[e],n=t[c<0?0:c].cell.__headerState,o=je(n,xe.ROW);if(c<0){at(d,h(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)){d.append(h(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o}}n.insertAfter(h(o))}else l.setColSpan(l.__colSpan+1)}null!==u&&n&&ct(u);const f=o.getColWidths();if(f){const e=[...f],t=c<0?0:c,n=e[t];e.splice(t,0,n),o.setColWidths(e)}return u}function ot(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(ze(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 rt(){const e=S();w(e)||bt(e)||Ee(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=pt(t),[l]=pt(n),[s,i,c]=gt(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,f=s[h+1],g=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(o<a||o+n.__rowSpan-1>h){const e=Math.max(o,a),t=Math.min(n.__rowSpan+o-1,h),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r)}if(o>=a&&o+n.__rowSpan-1>h&&e===h){null===g&&Ee(122);let o=null;for(let n=0;n<t;n++){const t=f[n],r=t.cell;t.startRow===e+1&&(o=r),r.__colSpan>1&&(n+=r.__colSpan-1)}null===o?at(g,n):o.insertAfter(n)}}}const t=r.getChildAtIndex(e);ze(t)||Ee(206,String(e)),t.remove()}if(void 0!==f){const{cell:e}=f[0];ct(e)}else{const e=s[a-1],{cell:t}=e[0];ct(t)}}const lt=rt;function st(){const e=S();w(e)||bt(e)||Ee(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=pt(t),[l]=pt(n),[s,i,c]=gt(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),f=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),g=f-d+1;if(s[0].length===f-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;e<m;e++)for(let t=d;t<=f;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(g,n.__colSpan-e))}}else if(o+n.__colSpan-1>f){if(t===f){const e=f-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=s[u],C=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==C){const{cell:e}=C;ct(e)}else{const e=h<a?p[h-1]:p[a-1],{cell:t}=e;ct(t)}const _=r.getColWidths();if(_){const e=[..._];e.splice(d,g),r.setColWidths(e)}}const it=st;function ct(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function at(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function ut(e){if(0===e.length)return null;const t=Ie(e[0]),[n]=mt(t,null,null);let o=1/0,r=-1/0,l=1/0,s=-1/0;const i=new Set;for(const t of n)for(const n of t){if(!n||!n.cell)continue;const t=n.cell.getKey();if(!i.has(t)&&e.some(e=>e.is(n.cell))){i.add(t);const e=n.startRow,c=n.startColumn,a=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;o=Math.min(o,e),r=Math.max(r,e+a-1),l=Math.min(l,c),s=Math.max(s,c+u-1)}}if(o===1/0||l===1/0)return null;const c=r-o+1,a=s-l+1,u=n[o][l];if(!u.cell)return null;const h=u.cell;h.setColSpan(a),h.setRowSpan(c);const d=new Set([h.getKey()]);for(let e=o;e<=r;e++)for(let t=l;t<=s;t++){const o=n[e][t];if(!o.cell)continue;const r=o.cell,l=r.getKey();if(!d.has(l)){d.add(l);ht(r)||h.append(...r.getChildren()),r.remove()}}return 0===h.getChildrenSize()&&h.append(m()),h}function ht(e){if(1!==e.getChildrenSize())return!1;const t=e.getFirstChildOrThrow();return!(!b(t)||!t.isEmpty())}function dt(){const e=S();w(e)||bt(e)||Ee(188);const t=e.anchor.getNode(),o=n(t,Ae);return Ae(o)||Ee(148),ft(o)}function ft(e){const[t,n,o]=pt(e),r=t.__colSpan,l=t.__rowSpan;if(1===r&&1===l)return;const[s,i]=gt(o,t,t),{startColumn:c,startRow:a}=i,u=t.__headerState&xe.COLUMN,h=Array.from({length:r},(e,t)=>{let n=u;for(let e=0;0!==n&&e<s.length;e++)n&=s[e][t+c].cell.__headerState;return n}),d=t.__headerState&xe.ROW,f=Array.from({length:l},(e,t)=>{let n=d;for(let e=0;0!==n&&e<s[0].length;e++)n&=s[t+a][e].cell.__headerState;return n});if(r>1){for(let e=1;e<r;e++)t.insertAfter(Oe(h[e]|f[0]).append(m()));t.setColSpan(1)}if(l>1){let e;for(let t=1;t<l;t++){const o=a+t,l=s[o];e=(e||n).getNextSibling(),ze(e)||Ee(125);let i=null;for(let e=0;e<c;e++){const t=l[e],n=t.cell;t.startRow===o&&(i=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===i)for(let n=r-1;n>=0;n--)at(e,Oe(h[n]|f[t]).append(m()));else for(let e=r-1;e>=0;e--)i.insertAfter(Oe(h[e]|f[t]).append(m()))}t.setRowSpan(1)}}function gt(e,t,n){const[o,r,l]=mt(e,t,n);return null===r&&Ee(207),null===l&&Ee(208),[o,r,l]}function mt(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];ze(o)||Ee(209);const c=s(e);for(let a=o.getFirstChild(),u=0;null!=a;a=a.getNextSibling()){for(Ae(a)||Ee(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 pt(e){let t;if(e instanceof Te)t=e;else if("__type"in e){const o=n(e,Ae);Ae(o)||Ee(148),t=o}else{const o=n(e.getNode(),Ae);Ae(o)||Ee(148),t=o}const o=t.getParent();ze(o)||Ee(149);const r=o.getParent();return pn(r)||Ee(210),[t,o,r]}function Ct(e,t,n){let o,r=Math.min(t.startColumn,n.startColumn),l=Math.min(t.startRow,n.startRow),s=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);do{o=!1;for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const c=e[t][n];if(!c)continue;const a=c.startColumn+c.cell.__colSpan-1,u=c.startRow+c.cell.__rowSpan-1,h=c.startColumn<=s&&a>=r,d=c.startRow<=i&&u>=l;if(h&&d){const e=Math.min(r,c.startColumn),t=Math.max(s,a),n=Math.min(l,c.startRow),h=Math.max(i,u);e===r&&t===s&&n===l&&h===i||(r=e,s=t,l=n,i=h,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function _t(e){const[t,,n]=pt(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 St(e){const[[t,o,r,l],[s,i,c,a]]=["anchor","focus"].map(t=>{const o=e[t].getNode(),r=n(o,Ae);Ae(r)||Ee(238,t,o.getKey(),o.getType());const l=r.getParent();ze(l)||Ee(239,t);const s=l.getParent();return pn(s)||Ee(240,t),[o,r,l,s]});return l.is(a)||Ee(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class wt{tableKey;anchor;focus;_cachedNodes;dirty;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(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=N(this.tableKey),t=N(this.anchor.key),n=N(this.focus.key);return null!==e&&null!==t&&null!==n}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return bt(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 wt(this.tableKey,y(this.anchor.key,this.anchor.offset,this.anchor.type),y(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(Ae).forEach(e=>{const n=e.getFirstChild();b(n)&&(t|=n.getTextFormat())});const n=R[e];return 0!==(t&n)}insertNodes(e){const t=this.focus.getNode();v(t)||Ee(151);x(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=St(this),n=_t(e);null===n&&Ee(153);const o=_t(t);null===o&&Ee(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}=St(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&Ee(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&Ee(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=gt(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=Ct(l,s,i),d=new Map([[t.getKey(),t]]);let f=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();ze(o)||Ee(160),o!==f&&(d.set(o.getKey(),o),f=o),d.has(n.getKey())||vt(n,e=>{d.set(e.getKey(),e)})}const g=Array.from(d.values());return T()||(this._cachedNodes=g),g}getTextContent(){const e=this.getNodes().filter(e=>Ae(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 bt(e){return e instanceof wt}function yt(){const e=y("root",0,"element"),t=y("root",0,"element");return new wt("root",e,t)}function Nt(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=S(),r=bt(o)?o.clone():yt();return r.set(e.getKey(),t.getKey(),n.getKey()),r}function vt(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)&&v(o)&&n.push(o.getChildren())}}function xt(e,t=F()){const n=N(e);pn(n)||Ee(231,e);const o=Ot(n,t.getElementByKey(e));return null===o&&Ee(232,e),{tableElement:o,tableNode:n}}class Tt{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;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.pointerType=null,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 xt(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=Lt(n,o)},{editor:this.editor})});this.editor.getEditorState().read(()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Lt(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();Bt(e,Lt(t,n),null),null!==S()&&(O(null),e.dispatchCommand(A,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&&Ee(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Bt(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=sn(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=Nt(o,this.$getAnchorTableCellOrThrow(),t),O(this.tableSelection),n.dispatchCommand(A,void 0),Bt(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?N(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Ee(234),e}$getFocusTableCell(){return this.focusCellNodeKey?N(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Ee(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=sn(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():yt(),this.anchorCellNodeKey=e}}$formatCells(e){const t=S();bt(t)||Ee(236);const n=E(),o=n.anchor,r=n.focus,l=t.getNodes().filter(Ae);l.length>0||Ee(237);const s=l[0].getFirstChild(),i=b(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(A,void 0)}$clearText(){const{editor:e}=this,t=N(this.tableNodeKey);if(!pn(t))throw new Error("Expected TableNode.");const n=S();bt(n)||Ee(253);const o=n.getNodes().filter(Ae),r=t.getFirstChild(),l=t.getLastChild();if(o.length>0&&null!==r&&null!==l&&ze(r)&&ze(l)&&o[0]===r.getFirstChild()&&o[o.length-1]===l.getLastChild()){t.selectPrevious();const n=t.getParent();return t.remove(),void(k(n)&&n.isEmpty()&&e.dispatchCommand(M,void 0))}o.forEach(e=>{if(v(e)){const t=m(),n=_();t.append(n),e.append(t),e.getChildren().forEach(e=>{e!==t&&e.remove()})}}),Bt(e,this.table,null),O(null),e.dispatchCommand(A,void 0)}}const Rt="__lexicalTableSelection";function Ft(e){return h(e)&&"TABLE"===e.nodeName}function Ot(e,t){if(!t)return t;const n=Ft(t)?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&Ee(245,t.nodeName),n}function At(e){return e._window}function Kt(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;Ae(n)&&(o=n)}return null}const Et=[[$,"down"],[z,"up"],[H,"backward"],[W,"forward"]],kt=[P,D,I],Mt=[J,Y];function $t(e,t,o,l){const s=o.getRootElement(),i=At(o);null!==s&&null!==i||Ee(246);const c=new Tt(o,e.getKey()),a=Ot(e,t);!function(e,t){null!==zt(e)&&Ee(205);e[Rt]=t}(a,c),c.listenersToRemove.add(()=>function(e,t){zt(e)===t&&delete e[Rt]}(a,c));const u=t=>{if(c.pointerType=t.pointerType,0!==t.button||!oe(t.target)||!i)return;const n=Ht(t.target);null!==n&&o.update(()=>{const o=ee();if(Le&&t.shiftKey&&qt(o,e)&&(w(o)||bt(o))){const r=o.anchor.getNode(),l=Kt(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(ln(c,l)),c.$setFocusCellForSelection(n),nn(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else"touch"!==t.pointerType&&c.$setAnchorCellForSelection(n)}),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,i.removeEventListener("pointerup",e),i.removeEventListener("pointermove",t)},t=n=>{if(1&~n.buttons&&c.isSelecting)return c.isSelecting=!1,i.removeEventListener("pointerup",e),void i.removeEventListener("pointermove",t);if(!oe(n.target))return;let r=null;const l=!(Le||a.contains(n.target));if(l)r=Wt(a,n.target);else for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(r=Wt(a,e),r)break;!r||null!==c.focusCell&&r.elem===c.focusCell.elem||(c.setNextFocus({focusCell:r,override:l}),o.dispatchCommand(A,void 0))};c.isSelecting=!0,i.addEventListener("pointerup",e,c.listenerOptions),i.addEventListener("pointermove",t,c.listenerOptions)})()};a.addEventListener("pointerdown",u,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("pointerdown",u)});const h=e=>{if(e.detail>=3&&oe(e.target)){null!==Ht(e.target)&&e.preventDefault()}};a.addEventListener("mousedown",h,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("mousedown",h)});const d=e=>{const t=e.target;0===e.button&&oe(t)&&o.update(()=>{const e=S();bt(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight()})};i.addEventListener("pointerdown",d,c.listenerOptions),c.listenersToRemove.add(()=>{i.removeEventListener("pointerdown",d)});for(const[t,n]of Et)c.listenersToRemove.add(o.registerCommand(t,t=>tn(o,t,n,e,c),L));c.listenersToRemove.add(o.registerCommand(B,t=>{const n=S();if(bt(n)){const o=Kt(e,n.focus.getNode());if(null!==o)return nn(t),o.selectEnd(),!0}return!1},L));const g=t=>()=>{const o=S();if(!qt(o,e))return!1;if(bt(o))return c.$clearText(),!0;if(w(o)){if(!Ae(Kt(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=>v(e)),u=a&&n(a,e=>v(e)&&Ae(e.getParent()));if(!v(u)||!v(a))return!1;if(t===D&&null===u.getPreviousSibling())return!0}return!1};for(const e of kt)c.listenersToRemove.add(o.registerCommand(e,g(e),U));const p=t=>{const n=S();if(!bt(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!!qt(n,e)&&(!!bt(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),!0))};for(const e of Mt)c.listenersToRemove.add(o.registerCommand(e,p,U));return c.listenersToRemove.add(o.registerCommand(X,e=>{const t=S();if(t){if(!bt(t)&&!w(t))return!1;ye(o,r(e,ClipboardEvent)?e:null,Ne(t));const n=p(e);return w(t)?(t.removeText(),!0):n}return!1},U)),c.listenersToRemove.add(o.registerCommand(q,t=>{const o=S();if(!qt(o,e))return!1;if(bt(o))return c.$formatCells(t),!0;if(w(o)){const e=n(o.anchor.getNode(),e=>Ae(e));if(!Ae(e))return!1}return!1},U)),c.listenersToRemove.add(o.registerCommand(j,t=>{const n=S();if(!bt(n)||!qt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!Ae(o)||!Ae(r))return!1;if(function(e,t){if(bt(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=gt(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]=gt(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];v(n)&&!n.isInline()&&n.setFormat(t)}}return!0},U)),c.listenersToRemove.add(o.registerCommand(V,t=>{const r=S();if(!qt(r,e))return!1;if(bt(r))return c.$clearHighlight(),!1;if(w(r)){const l=n(r.anchor.getNode(),e=>Ae(e));if(!Ae(l))return!1;if("string"==typeof t){const n=rn(o,r,e);if(n)return on(n,e,[_(t)]),!0}}return!1},U)),l&&c.listenersToRemove.add(o.registerCommand(G,t=>{const o=S();if(!w(o)||!o.isCollapsed()||!qt(o,e))return!1;const r=Qt(o.anchor.getNode());return!(null===r||!e.is(Zt(r)))&&(nn(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(v(l))return l.selectEnd();const s=n(e,ze);null===s&&Ee(247);for(let e=s[o]();ze(e);e=e[o]()){const t=e[r]();if(v(t))return t.selectEnd()}const i=n(s,pn);null===i&&Ee(248);"next"===t?i.selectNext():i.selectPrevious()}(r,t.shiftKey?"previous":"next"),!0)},U)),c.listenersToRemove.add(o.registerCommand(Q,t=>e.isSelected(),L)),c.listenersToRemove.add(o.registerCommand(Z,(e,t)=>{if(o!==t)return!1;const{nodes:r,selection:l}=e,s=l.getStartEndPoints(),i=bt(l),c=w(l)&&null!==n(l.anchor.getNode(),e=>Ae(e))&&null!==n(l.focus.getNode(),e=>Ae(e))||i;if(1!==r.length||!pn(r[0])||!c||null===s)return!1;const[a,u]=s,[h,d,g]=pt(a),p=n(u.getNode(),e=>Ae(e));if(!(Ae(h)&&Ae(p)&&ze(d)&&pn(g)))return!1;const C=r[0],[_,S,b]=gt(g,h,p),[y]=mt(C,null,null),N=_.length,v=N>0?_[0].length:0;let x=S.startRow,T=S.startColumn,R=y.length,F=R>0?y[0].length:0;if(i){const e=Ct(_,S,b),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;x=e.minRow,T=e.minColumn,R=Math.min(R,t),F=Math.min(F,n)}let O=!1;const A=Math.min(N,x+R)-1,K=Math.min(v,T+F)-1,E=new Set;for(let e=x;e<=A;e++)for(let t=T;t<=K;t++){const n=_[e][t];E.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(ft(n.cell),E.add(n.cell.getKey()),O=!0))}let[k]=mt(g.getWritable(),null,null);const M=R-N+x;for(let e=0;e<M;e++){Qe(k[N-1][0].cell)}const $=F-v+T;for(let e=0;e<$;e++){nt(k[0][v-1].cell,!0,!1)}[k]=mt(g.getWritable(),null,null);for(let e=x;e<x+R;e++)for(let t=T;t<T+F;t++){const n=e-x,o=t-T,r=y[n][o];if(r.startRow!==n||r.startColumn!==o)continue;const l=r.cell;if(1!==l.__rowSpan||1!==l.__colSpan){const n=[],o=Math.min(e+l.__rowSpan,x+R)-1,r=Math.min(t+l.__colSpan,T+F)-1;for(let l=e;l<=o;l++)for(let e=t;e<=r;e++){const t=k[l][e];n.push(t.cell)}ut(n),O=!0}const{cell:s}=k[e][t],i=s.getChildren();l.getChildren().forEach(e=>{if(f(e)){m().append(e),s.append(e)}else s.append(e)}),i.forEach(e=>e.remove())}if(i&&O){const[e]=mt(g.getWritable(),null,null);e[S.startRow][S.startColumn].cell.selectEnd()}return!0},U)),c.listenersToRemove.add(o.registerCommand(A,()=>{const t=S(),r=ee(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(bt(t)&&t.tableKey===c.tableNodeKey)return(n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),!0);if(n!==c.anchorCell&&qt(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=Qt(o);if(null!==l&&ze(r)){const t=r.getFirstChild();if(Ae(t)&&e.is(n(l,n=>n.is(e)||n.is(t))))return t.selectStart(),!0}}if(w(t)){const{anchor:n,focus:l}=t,s=n.getNode(),i=l.getNode(),a=Qt(s),u=Qt(i),h=!(!a||!e.is(Zt(a))),d=!(!u||!e.is(Zt(u))),f=h!==d,g=h&&d,m=t.isBackward();if(f){const n=t.clone();if(d){const[t]=gt(e,u,u),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(m?o.getKey():r.getKey(),m?o.getChildrenSize():r.getChildrenSize(),"element")}else if(h){const[t]=gt(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(m?r.getKey():o.getKey(),m?r.getChildrenSize():0,"element")}O(n),Dt(o,c)}else if(g&&(a.is(u)||(c.$setAnchorCellForSelection(ln(c,a)),c.$setFocusCellForSelection(ln(c,u),!0)),"touch"===c.pointerType&&c.isSelecting&&t.isCollapsed()&&w(r)&&r.isCollapsed())){const e=Qt(r.anchor.getNode());e&&!e.is(u)&&(c.$setAnchorCellForSelection(ln(c,e)),c.$setFocusCellForSelection(ln(c,u),!0),c.pointerType=null)}}else if(t&&bt(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=K(i);if(n&&n.anchorNode&&n.focusNode){const r=te(n.focusNode),l=r&&!e.isParentOf(r),s=te(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=ne(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),O(r))}}}return t&&!t.is(r)&&(bt(t)||bt(r))&&c.tableSelection&&!c.tableSelection.is(r)?(bt(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!bt(t)&&bt(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,Gt(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&Dt(o,c),!1)},U)),c.listenersToRemove.add(o.registerCommand(M,()=>{const t=S();if(!w(t)||!t.isCollapsed()||!qt(t,e))return!1;const n=rn(o,t,e);return!!n&&(on(n,e),!0)},U)),c}function zt(e){return e[Rt]||null}function Ht(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 Wt(e,t){if(!e.contains(t))return null;let n=null;for(let o=t;null!=o;o=o.parentNode){if(o===e)return n;const t=o.nodeName;"TD"!==t&&"TH"!==t||(n=o._cell||null)}return null}function Lt(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=Ot(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 Bt(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,Gt(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=te(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function Dt(e,t){t.$disableHighlightStyle(),Pt(t.table,t=>{t.highlighted=!0,Vt(e,t)})}const It=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?jt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?jt(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?jt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?jt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Ut(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 Jt([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function Yt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&Ee(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&Ee(250,n,String(s)),i}function Xt(e,t,n,o,r){const l=Ct(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=Ut(e,t);return null===n&&Ee(249,t.cell.getKey()),n}(l,n),[d,f]=Jt(h);let g=l[d],m=l[f];"forward"===r?g+="maxColumn"===d?1:c:"backward"===r?g-="minColumn"===d?1:u:"down"===r?m+="maxRow"===f?1:i:"up"===r&&(m-="minRow"===f?1:a);const p=t[m];if(void 0===p)return!1;const C=p[g];if(void 0===C)return!1;const[_,S]=function(e,t,n){const o=Ct(e,t,n),r=Ut(o,t);if(r)return[Yt(e,o,r),Yt(e,o,Jt(r))];const l=Ut(o,n);if(l)return[Yt(e,o,Jt(l)),Yt(e,o,l)];const s=["minColumn","minRow"];return[Yt(e,o,s),Yt(e,o,Jt(s))]}(t,n,C),w=ln(e,_.cell),b=ln(e,S.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function qt(e,t){if(w(e)||bt(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function jt(e,t){t?e.selectStart():e.selectEnd()}function Vt(t,n){const o=n.elem,r=t._config.theme;Ae(te(o))||Ee(131),e(o,r.tableCellSelected)}function Gt(e,t){const n=t.elem;Ae(te(n))||Ee(131);const r=e._config.theme;o(n,r.tableCellSelected)}function Qt(e){const t=n(e,Ae);return Ae(t)?t:null}function Zt(e){const t=n(e,pn);return pn(t)?t:null}function en(e,t,o,r,l,s,i){const c=le(o.focus,l?"previous":"next");if(se(c))return!1;let a=c;for(const e of ie(c).iterNodeCarets("shadowRoot")){if(!ce(e)||!v(e.origin))return!1;a=e}const u=a.getParentAtCaret();if(!Ae(u))return!1;const h=u,d=function(e){for(const t of ie(e).iterNodeCarets("root")){const{origin:n}=t;if(Ae(n)){if(de(t))return fe(n,e.direction)}else if(!ze(n))break}return null}(ae(h,a.direction)),f=n(h,pn);if(!f||!f.is(s))return!1;const g=e.getElementByKey(h.getKey()),m=Ht(g);if(!g||!m)return!1;const p=fn(e,f);if(i.table=p,d)if("extend"===r){const t=Ht(e.getElementByKey(d.origin.getKey()));if(!t)return!1;i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(t,!0)}else{const e=he(d);ue(o.anchor,e),ue(o.focus,e)}else if("extend"===r)i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(m,!0);else{const e=function(e){const t=ge(e);return de(t)?he(t):e}(ae(f,c.direction));ue(o.anchor,e),ue(o.focus,e)}return nn(t),!0}function tn(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=S();if(!qt(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(v(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!!pn(n)&&(nn(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=>pn(e));if(Ae(l)&&(l=n(l,pn)),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&&v(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&v(i)){const e=i.getLastChild();a=e||i,c=f(a)?a.getTextContentSize():0}const u=s.clone();return u.focus.set(a.getKey(),c,f(a)?"text":"element"),O(u),nn(t),!0}if(re(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==Kt(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=pt(e),[o]=pt(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=>v(e)&&!e.isInline());if(Ae(r)&&(r=n(r,pn)),!r)return!1;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(pn(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return!1;const[r]=pt(e),[l]=pt(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),nn(t),O(c),!0}}}}return"down"===o&&un(e)&&l.setShouldCheckSelection(),!1}if(w(s)){if("backward"===o||"forward"===o){return en(e,t,s,t.shiftKey?"extend":"move","backward"===o,r,l)}if(s.isCollapsed()){const{anchor:i,focus:c}=s,a=n(i.getNode(),Ae),u=n(c.getNode(),Ae);if(!Ae(a)||!a.is(u))return!1;const h=Zt(a);if(h!==r&&null!=h){const n=Ot(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=Lt(h,n),tn(e,t,o,h,l)}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return!1;let g;if("element"===i.type)g=f.getBoundingClientRect();else{const t=K(At(e));if(null===t||0===t.rangeCount)return!1;g=t.getRangeAt(0).getBoundingClientRect()}const m="up"===o?a.getFirstChild():a.getLastChild();if(null==m)return!1;const p=e.getElementByKey(m.__key);if(null==p)return!1;const C=p.getBoundingClientRect();if("up"===o?C.top>g.top-g.height:g.bottom+g.height>C.bottom){nn(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return It(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(bt(s)){const{anchor:i,focus:c}=s,a=n(i.getNode(),Ae),u=n(c.getNode(),Ae),[h]=s.getNodes();pn(h)||Ee(251);const d=Ot(h,e.getElementByKey(h.getKey()));if(!Ae(a)||!Ae(u)||!pn(h)||null==d)return!1;l.$updateTableTableSelection(s);const f=Lt(h,d),g=r.getCordsFromCellNode(a,f),m=r.getDOMCellFromCordsOrThrow(g.x,g.y,f);if(l.$setAnchorCellForSelection(m),nn(t),t.shiftKey){const[e,t,n]=gt(r,a,u);return Xt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function nn(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function on(e,t,n){const o=m();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function rn(e,t,o){const r=o.getParent();if(!r)return;const l=K(At(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=Ot(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=n(t.anchor.getNode(),e=>Ae(e));if(!a)return;const u=n(a,e=>pn(e));if(!pn(u)||!u.is(o))return;const[h,d]=gt(o,a,a),f=h[0][0],g=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,C=m===f.startRow&&p===f.startColumn,_=m===g.startRow&&p===g.startColumn;return C?"first":_?"last":void 0}function ln(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function sn(e,t,n){return Kt(e,te(t,n))}function cn(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 an=new WeakSet;function un(e=F()){return an.has(e)}function hn(e,t){t?an.add(e):an.delete(e)}class dn extends u{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;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 dn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:gn,priority:1})}}static importJSON(e){return mn().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t=Ft(e)?e:e.querySelector("table");return Ft(t)||Ee(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table");this.__style&&(o.style.cssText=this.__style);const r=document.createElement("colgroup");if(o.appendChild(r),me(r),e(o,t.theme.table),this.updateTableElement(null,o,t),un(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),this.updateTableWrapper(null,n,o,t),n}return o}updateTableWrapper(t,n,r,l){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,r,l){l>0?(e(t,r.theme.tableFrozenColumn),n.setAttribute("data-lexical-frozen-column","true")):(o(t,r.theme.tableFrozenColumn),n.removeAttribute("data-lexical-frozen-column"))}(n,r,l,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,r,l){l>0?(e(t,r.theme.tableFrozenRow),n.setAttribute("data-lexical-frozen-row","true")):(o(t,r.theme.tableFrozenRow),n.removeAttribute("data-lexical-frozen-row"))}(n,r,l,this.__frozenRowCount)}updateTableElement(t,n,r){this.__style!==(t?t.__style:"")&&(n.style.cssText=this.__style),this.__rowStriping!==(!!t&&t.__rowStriping)&&function(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"))}(n,r,this.__rowStriping),function(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)}(n,0,this.getColumnCount(),this.getColWidths()),cn(n,r,this.getFormatType())}updateDOM(e,t,n){const o=this.getDOMSlot(t).element;return t===o===un()||(l(r=t)&&"DIV"===r.nodeName&&this.updateTableWrapper(e,t,o,n),this.updateTableElement(e,o,n),!1);var r}exportDOM(e){const t=super.exportDOM(e),{element:n}=t;return{after:n=>{if(t.after&&(n=t.after(n)),!Ft(n)&&l(n)&&(n=n.querySelector("table")),!Ft(n))return null;cn(n,e._config,this.getFormatType());const[o]=mt(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:!Ft(n)&&l(n)?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=sn(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=te(o.elem);return Ae(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}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){const t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach(e=>{Ae(e)&&(t+=e.getColSpan())}),t}}function fn(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Ee(230),Lt(t,n)}function gn(e){const n=mn();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0),e.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!ve.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,ze),node:n}}function mn(){return p(new dn)}function pn(e){return e instanceof dn}function Cn({rows:e,columns:t,includeHeaders:n}){const o=S()||ee();if(!o||!w(o))return!1;if(Zt(o.anchor.getNode()))return!1;const r=Be(Number(e),Number(t),n);c(r);const l=r.getFirstDescendant();return f(l)&&l.select(),!0}function _n(e){ze(e.getParent())?e.isEmpty()&&e.append(m()):e.remove()}function Sn(e){pn(e.getParent())?a(e,Ae):e.remove()}function wn(e){a(e,ze);const[t]=mt(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;ze(r)||Ee(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=Oe();e.append(m()),r.append(e)}}}function bn(e){if(e.detail<3||!oe(e.target))return!1;const t=te(e.target);if(null===t)return!1;const o=n(t,e=>v(e)&&!e.isInline());if(null===o)return!1;return!!Ae(o.getParent())&&(o.select(0),!0)}function yn(e){return e.registerNodeTransform(Te,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=pt(e),[n]=gt(t,e,e),o=n.length,r=n[0].length;let l=t.getFirstChild();ze(l)||Ee(175);const i=[];for(let e=0;e<o;e++){0!==e&&(l=l.getNextSibling(),ze(l)||Ee(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){Ae(c)||Ee(176);const e=Oe(c.__headerState);null!==t?t.insertAfter(e):s(l,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}})}function Nn(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=Ot(o,l),i=$t(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(dn,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}=xt(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 vn(e){return e.hasNodes([dn])||Ee(255),i(e.registerCommand(Ke,Cn,pe),e.registerCommand(Z,({nodes:t,selection:n},o)=>{if(e!==o||!w(n))return!1;return null!==Zt(n.anchor.getNode())&&t.some(pn)},pe),e.registerCommand(Ce,bn,pe),e.registerNodeTransform(dn,wn),e.registerNodeTransform(ke,Sn),e.registerNodeTransform(Te,_n))}const xn=_e({build:(e,t,n)=>be(t),config:Se({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasTabHandler:!0}),name:"@lexical/table/Table",nodes:[dn,ke,Te],register(e,t,n){const o=n.getOutput();return i(we(()=>{const t=o.hasHorizontalScroll.value;un(e)!==t&&(hn(e,t),e.registerNodeTransform(dn,()=>{})())}),vn(e),we(()=>Nn(e,o.hasTabHandler.value)),we(()=>o.hasCellMerge.value?void 0:yn(e)),we(()=>o.hasCellBackgroundColor.value?void 0:e.registerNodeTransform(Te,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}});export{gt as $computeTableMap,mt as $computeTableMapSkipCellCheck,Oe as $createTableCellNode,mn as $createTableNode,Be as $createTableNodeWithDimensions,$e as $createTableRowNode,yt as $createTableSelection,Nt as $createTableSelectionFrom,ot as $deleteTableColumn,st as $deleteTableColumnAtSelection,it as $deleteTableColumn__EXPERIMENTAL,rt as $deleteTableRowAtSelection,lt as $deleteTableRow__EXPERIMENTAL,Qt as $findCellNode,Zt as $findTableNode,fn as $getElementForTableNode,pt as $getNodeTriplet,xt as $getTableAndElementByKey,Pe as $getTableCellNodeFromLexicalNode,_t as $getTableCellNodeRect,Je as $getTableColumnIndexFromTableCellNode,Ie as $getTableNodeFromLexicalNodeOrThrow,Ue as $getTableRowIndexFromTableCellNode,De as $getTableRowNodeFromTableCellNodeOrThrow,Ze as $insertTableColumn,et as $insertTableColumnAtSelection,tt as $insertTableColumn__EXPERIMENTAL,qe as $insertTableRow,Ve as $insertTableRowAtSelection,Ge as $insertTableRow__EXPERIMENTAL,un as $isScrollableTablesActive,Ae as $isTableCellNode,pn as $isTableNode,ze as $isTableRowNode,bt as $isTableSelection,ut as $mergeCells,Xe as $removeTableRowAtIndex,dt as $unmergeCell,Ke as INSERT_TABLE_COMMAND,xe as TableCellHeaderStates,Te as TableCellNode,xn as TableExtension,dn as TableNode,Tt as TableObserver,ke as TableRowNode,$t as applyTableHandlers,Ht as getDOMCellFromTarget,Ot as getTableElement,zt as getTableObserverFromTableElement,yn as registerTableCellUnmergeTransform,vn as registerTablePlugin,Nn as registerTableSelectionObserver,hn 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,$isInlineElementOrDecoratorNode as d,$isTextNode as f,$isLineBreakNode as g,$createParagraphNode as m,$applyNodeReplacement as p,createCommand as C,$createTextNode as _,$getSelection as S,$isRangeSelection as w,$isParagraphNode as b,$createPoint as y,$getNodeByKey as N,$isElementNode as v,$normalizeSelection__EXPERIMENTAL as x,isCurrentlyReadOnlyMode as T,TEXT_TYPE_TO_FORMAT as R,$getEditor as F,$setSelection as O,SELECTION_CHANGE_COMMAND as A,getDOMSelection as K,$createRangeSelection as E,$isRootNode as k,INSERT_PARAGRAPH_COMMAND as M,KEY_ARROW_DOWN_COMMAND as $,KEY_ARROW_UP_COMMAND as z,KEY_ARROW_LEFT_COMMAND as W,KEY_ARROW_RIGHT_COMMAND as H,COMMAND_PRIORITY_HIGH as L,KEY_ESCAPE_COMMAND as B,DELETE_WORD_COMMAND as P,DELETE_LINE_COMMAND as D,DELETE_CHARACTER_COMMAND as I,COMMAND_PRIORITY_CRITICAL as U,KEY_BACKSPACE_COMMAND as J,KEY_DELETE_COMMAND as Y,CUT_COMMAND as X,FORMAT_TEXT_COMMAND as q,FORMAT_ELEMENT_COMMAND as j,CONTROLLED_TEXT_INSERTION_COMMAND as V,KEY_TAB_COMMAND as G,FOCUS_COMMAND as Q,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as Z,$getPreviousSelection as ee,$getNearestNodeFromDOMNode as te,$createRangeSelectionFromDom as ne,isDOMNode as oe,$isRootOrShadowRoot as re,$caretFromPoint as le,$isExtendableTextPointCaret as se,$extendCaretToRange as ie,$isSiblingCaret as ce,$getSiblingCaret as ae,$setPointFromCaret as ue,$normalizeCaret as he,$isChildCaret as de,$getChildCaret as fe,$getAdjacentChildCaret as ge,setDOMUnmanaged as me,COMMAND_PRIORITY_EDITOR as pe,CLICK_COMMAND as Ce,defineExtension as _e,safeCast as Se}from"lexical";import{effect as we,namedSignals as be}from"@lexical/extension";import{copyToClipboard as ye,$getClipboardDataFromSelection as Ne}from"@lexical/clipboard";const ve=/^(\d+(?:\.\d+)?)px$/,xe={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class Te extends u{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new Te(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:Fe,priority:0}),th:e=>({conversion:Fe,priority:0})}}static importJSON(e){return Oe().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=xe.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0}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),Re(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(),...Re(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=xe.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!==xe.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 Re(e){return"middle"===e||"bottom"===e}function Fe(e){const t=e,n=e.nodeName.toLowerCase();let o;ve.test(t.style.width)&&(o=parseFloat(t.style.width));const r=Oe("th"===n?xe.ROW:xe.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style.verticalAlign;Re(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=>{const t=[];let n=null;const o=()=>{if(n){const e=n.getFirstChild();g(e)&&1===n.getChildrenSize()&&e.remove()}};for(const r of e)d(r)||f(r)||g(r)?(f(r)&&(a&&r.toggleFormat("bold"),u&&r.toggleFormat("strikethrough"),h&&r.toggleFormat("italic"),p&&r.toggleFormat("underline")),n?n.append(r):(n=m().append(r),t.push(n))):(t.push(r),o(),n=null);return o(),0===t.length&&t.push(m()),t},node:r}}function Oe(e=xe.NO_STATUS,t=1,n){return p(new Te(e,t,n))}function Ae(e){return e instanceof Te}const Ke=C("INSERT_TABLE_COMMAND");function Ee(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class ke extends u{__height;static getType(){return"tablerow"}static clone(e){return new ke(e.__height,e.__key)}static importDOM(){return{tr:e=>({conversion:Me,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 Me(e){const n=e;let o;return ve.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>t(e,Ae),node:$e(o)}}function $e(e){return p(new ke(e))}function ze(e){return e instanceof ke}const We="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,He=We&&"documentMode"in document?document.documentMode:null,Le=We&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function Be(e,t,n=!0){const o=mn();for(let r=0;r<e;r++){const e=$e();for(let o=0;o<t;o++){let t=xe.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=xe.ROW),0===o&&n.columns&&(t|=xe.COLUMN)):n&&(0===r&&(t|=xe.ROW),0===o&&(t|=xe.COLUMN));const l=Oe(t),s=m();s.append(_()),l.append(s),e.append(l)}o.append(e)}return o}function Pe(e){const t=n(e,e=>Ae(e));return Ae(t)?t:null}function De(e){const t=n(e,e=>ze(e));if(ze(t))return t;throw new Error("Expected table cell to be inside of table row.")}function Ie(e){const t=n(e,e=>pn(e));if(pn(t))return t;throw new Error("Expected table cell to be inside of table.")}function Ue(e){const t=De(e);return Ie(t).getChildren().findIndex(e=>e.is(t))}function Je(e){return De(e).getChildren().findIndex(t=>t.is(e))}function Ye(e,t){const n=Ie(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 Xe(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 qe(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(!ze(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];Ae(t)||Ee(12);const{above:l,below:s}=Ye(t,r);let i=xe.NO_STATUS;const c=l&&l.getWidth()||s&&s.getWidth()||void 0;(l&&l.hasHeaderState(xe.COLUMN)||s&&s.hasHeaderState(xe.COLUMN))&&(i|=xe.COLUMN);const a=Oe(i,1,c);a.append(m()),o.append(a)}n?s.insertAfter(o):s.insertBefore(o)}return e}We&&"InputEvent"in window&&!He&&new window.InputEvent("input");const je=(e,t)=>e===xe.BOTH||e===t?t:xe.NO_STATUS;function Ve(e=!0){const t=S();w(t)||bt(t)||Ee(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=pt(n),[l,,s]=pt(o),[,i,c]=gt(s,l,r),{startRow:a}=c,{startRow:u}=i;return e?Qe(a+r.__rowSpan>u+l.__rowSpan?r:l,!0):Qe(u<a?l:r,!1)}const Ge=Ve;function Qe(e,t=!0){const[,,n]=pt(e),[o,r]=gt(n,e,e),l=o[0].length,{startRow:s}=r;let i=null;if(t){const t=s+e.__rowSpan-1,r=o[t],c=$e();for(let e=0;e<l;e++){const{cell:n,startRow:o}=r[e];if(o+n.__rowSpan-1<=t){const t=r[e].cell.__headerState,n=je(t,xe.COLUMN);c.append(Oe(n).append(m()))}else n.setRowSpan(n.__rowSpan+1)}const a=n.getChildAtIndex(t);ze(a)||Ee(256),a.insertAfter(c),i=c}else{const e=s,t=o[e],r=$e();for(let n=0;n<l;n++){const{cell:o,startRow:l}=t[n];if(l===e){const e=t[n].cell.__headerState,o=je(e,xe.COLUMN);r.append(Oe(o).append(m()))}else o.setRowSpan(o.__rowSpan+1)}const c=n.getChildAtIndex(e);ze(c)||Ee(257),c.insertBefore(r),i=r}return i}function Ze(e,t,n=!0,o,r){const l=e.getChildren(),s=[];for(let e=0;e<l.length;e++){const n=l[e];if(ze(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];Ae(o)||Ee(12);const{left:l,right:i}=Ye(o,r);let c=xe.NO_STATUS;(l&&l.hasHeaderState(xe.ROW)||i&&i.hasHeaderState(xe.ROW))&&(c|=xe.ROW);const a=Oe(c);a.append(m()),s.push({newTableCell:a,targetCell:o})}}return s.forEach(({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)}),e}function et(e=!0){const t=S();w(t)||bt(t)||Ee(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=pt(n),[l,,s]=pt(o),[,i,c]=gt(s,l,r),{startColumn:a}=c,{startColumn:u}=i;return e?nt(a+r.__colSpan>u+l.__colSpan?r:l,!0):nt(u<a?l:r,!1)}const tt=et;function nt(e,t=!0,n=!0){const[,,o]=pt(e),[r,l]=gt(o,e,e),s=r.length,{startColumn:i}=l,c=t?i+e.__colSpan-1:i-1,a=o.getFirstChild();ze(a)||Ee(120);let u=null;function h(e=xe.NO_STATUS){const t=Oe(e).append(m());return null===u&&(u=t),t}let d=a;e:for(let e=0;e<s;e++){if(0!==e){const e=d.getNextSibling();ze(e)||Ee(121),d=e}const t=r[e],n=t[c<0?0:c].cell.__headerState,o=je(n,xe.ROW);if(c<0){at(d,h(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)){d.append(h(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o}}n.insertAfter(h(o))}else l.setColSpan(l.__colSpan+1)}null!==u&&n&&ct(u);const f=o.getColWidths();if(f){const e=[...f],t=c<0?0:c,n=e[t];e.splice(t,0,n),o.setColWidths(e)}return u}function ot(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(ze(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 rt(){const e=S();w(e)||bt(e)||Ee(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=pt(t),[l]=pt(n),[s,i,c]=gt(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,f=s[h+1],g=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(o<a||o+n.__rowSpan-1>h){const e=Math.max(o,a),t=Math.min(n.__rowSpan+o-1,h),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r)}if(o>=a&&o+n.__rowSpan-1>h&&e===h){null===g&&Ee(122);let o=null;for(let n=0;n<t;n++){const t=f[n],r=t.cell;t.startRow===e+1&&(o=r),r.__colSpan>1&&(n+=r.__colSpan-1)}null===o?at(g,n):o.insertAfter(n)}}}const t=r.getChildAtIndex(e);ze(t)||Ee(206,String(e)),t.remove()}if(void 0!==f){const{cell:e}=f[0];ct(e)}else{const e=s[a-1],{cell:t}=e[0];ct(t)}}const lt=rt;function st(){const e=S();w(e)||bt(e)||Ee(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=pt(t),[l]=pt(n),[s,i,c]=gt(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),f=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),g=f-d+1;if(s[0].length===f-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;e<m;e++)for(let t=d;t<=f;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(g,n.__colSpan-e))}}else if(o+n.__colSpan-1>f){if(t===f){const e=f-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const p=s[u],C=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==C){const{cell:e}=C;ct(e)}else{const e=h<a?p[h-1]:p[a-1],{cell:t}=e;ct(t)}const _=r.getColWidths();if(_){const e=[..._];e.splice(d,g),r.setColWidths(e)}}const it=st;function ct(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function at(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function ut(e){if(0===e.length)return null;const t=Ie(e[0]),[n]=mt(t,null,null);let o=1/0,r=-1/0,l=1/0,s=-1/0;const i=new Set;for(const t of n)for(const n of t){if(!n||!n.cell)continue;const t=n.cell.getKey();if(!i.has(t)&&e.some(e=>e.is(n.cell))){i.add(t);const e=n.startRow,c=n.startColumn,a=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;o=Math.min(o,e),r=Math.max(r,e+a-1),l=Math.min(l,c),s=Math.max(s,c+u-1)}}if(o===1/0||l===1/0)return null;const c=r-o+1,a=s-l+1,u=n[o][l];if(!u.cell)return null;const h=u.cell;h.setColSpan(a),h.setRowSpan(c);const d=new Set([h.getKey()]);for(let e=o;e<=r;e++)for(let t=l;t<=s;t++){const o=n[e][t];if(!o.cell)continue;const r=o.cell,l=r.getKey();if(!d.has(l)){d.add(l);ht(r)||h.append(...r.getChildren()),r.remove()}}return 0===h.getChildrenSize()&&h.append(m()),h}function ht(e){if(1!==e.getChildrenSize())return!1;const t=e.getFirstChildOrThrow();return!(!b(t)||!t.isEmpty())}function dt(){const e=S();w(e)||bt(e)||Ee(188);const t=e.anchor.getNode(),o=n(t,Ae);return Ae(o)||Ee(148),ft(o)}function ft(e){const[t,n,o]=pt(e),r=t.__colSpan,l=t.__rowSpan;if(1===r&&1===l)return;const[s,i]=gt(o,t,t),{startColumn:c,startRow:a}=i,u=t.__headerState&xe.COLUMN,h=Array.from({length:r},(e,t)=>{let n=u;for(let e=0;0!==n&&e<s.length;e++)n&=s[e][t+c].cell.__headerState;return n}),d=t.__headerState&xe.ROW,f=Array.from({length:l},(e,t)=>{let n=d;for(let e=0;0!==n&&e<s[0].length;e++)n&=s[t+a][e].cell.__headerState;return n});if(r>1){for(let e=1;e<r;e++)t.insertAfter(Oe(h[e]|f[0]).append(m()));t.setColSpan(1)}if(l>1){let e;for(let t=1;t<l;t++){const o=a+t,l=s[o];e=(e||n).getNextSibling(),ze(e)||Ee(125);let i=null;for(let e=0;e<c;e++){const t=l[e],n=t.cell;t.startRow===o&&(i=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===i)for(let n=r-1;n>=0;n--)at(e,Oe(h[n]|f[t]).append(m()));else for(let e=r-1;e>=0;e--)i.insertAfter(Oe(h[e]|f[t]).append(m()))}t.setRowSpan(1)}}function gt(e,t,n){const[o,r,l]=mt(e,t,n);return null===r&&Ee(207),null===l&&Ee(208),[o,r,l]}function mt(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];ze(o)||Ee(209);const c=s(e);for(let a=o.getFirstChild(),u=0;null!=a;a=a.getNextSibling()){for(Ae(a)||Ee(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 pt(e){let t;if(e instanceof Te)t=e;else if("__type"in e){const o=n(e,Ae);Ae(o)||Ee(148),t=o}else{const o=n(e.getNode(),Ae);Ae(o)||Ee(148),t=o}const o=t.getParent();ze(o)||Ee(149);const r=o.getParent();return pn(r)||Ee(210),[t,o,r]}function Ct(e,t,n){let o,r=Math.min(t.startColumn,n.startColumn),l=Math.min(t.startRow,n.startRow),s=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);do{o=!1;for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const c=e[t][n];if(!c)continue;const a=c.startColumn+c.cell.__colSpan-1,u=c.startRow+c.cell.__rowSpan-1,h=c.startColumn<=s&&a>=r,d=c.startRow<=i&&u>=l;if(h&&d){const e=Math.min(r,c.startColumn),t=Math.max(s,a),n=Math.min(l,c.startRow),h=Math.max(i,u);e===r&&t===s&&n===l&&h===i||(r=e,s=t,l=n,i=h,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function _t(e){const[t,,n]=pt(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 St(e){const[[t,o,r,l],[s,i,c,a]]=["anchor","focus"].map(t=>{const o=e[t].getNode(),r=n(o,Ae);Ae(r)||Ee(238,t,o.getKey(),o.getType());const l=r.getParent();ze(l)||Ee(239,t);const s=l.getParent();return pn(s)||Ee(240,t),[o,r,l,s]});return l.is(a)||Ee(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class wt{tableKey;anchor;focus;_cachedNodes;dirty;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(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=N(this.tableKey),t=N(this.anchor.key),n=N(this.focus.key);return null!==e&&null!==t&&null!==n}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return bt(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 wt(this.tableKey,y(this.anchor.key,this.anchor.offset,this.anchor.type),y(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(Ae).forEach(e=>{const n=e.getFirstChild();b(n)&&(t|=n.getTextFormat())});const n=R[e];return 0!==(t&n)}insertNodes(e){const t=this.focus.getNode();v(t)||Ee(151);x(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=St(this),n=_t(e);null===n&&Ee(153);const o=_t(t);null===o&&Ee(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}=St(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&Ee(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&Ee(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[l,s,i]=gt(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=Ct(l,s,i),d=new Map([[t.getKey(),t]]);let f=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();ze(o)||Ee(160),o!==f&&(d.set(o.getKey(),o),f=o),d.has(n.getKey())||vt(n,e=>{d.set(e.getKey(),e)})}const g=Array.from(d.values());return T()||(this._cachedNodes=g),g}getTextContent(){const e=this.getNodes().filter(e=>Ae(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 bt(e){return e instanceof wt}function yt(){const e=y("root",0,"element"),t=y("root",0,"element");return new wt("root",e,t)}function Nt(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=S(),r=bt(o)?o.clone():yt();return r.set(e.getKey(),t.getKey(),n.getKey()),r}function vt(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)&&v(o)&&n.push(o.getChildren())}}function xt(e,t=F()){const n=N(e);pn(n)||Ee(231,e);const o=Ot(n,t.getElementByKey(e));return null===o&&Ee(232,e),{tableElement:o,tableNode:n}}class Tt{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;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.pointerType=null,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 xt(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=Lt(n,o)},{editor:this.editor})});this.editor.getEditorState().read(()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Lt(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();Bt(e,Lt(t,n),null),null!==S()&&(O(null),e.dispatchCommand(A,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&&Ee(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Bt(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=sn(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=Nt(o,this.$getAnchorTableCellOrThrow(),t),O(this.tableSelection),n.dispatchCommand(A,void 0),Bt(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?N(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Ee(234),e}$getFocusTableCell(){return this.focusCellNodeKey?N(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Ee(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=sn(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():yt(),this.anchorCellNodeKey=e}}$formatCells(e){const t=S();bt(t)||Ee(236);const n=E(),o=n.anchor,r=n.focus,l=t.getNodes().filter(Ae);l.length>0||Ee(237);const s=l[0].getFirstChild(),i=b(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(A,void 0)}$clearText(){const{editor:e}=this,t=N(this.tableNodeKey);if(!pn(t))throw new Error("Expected TableNode.");const n=S();bt(n)||Ee(253);const o=n.getNodes().filter(Ae),r=t.getFirstChild(),l=t.getLastChild();if(o.length>0&&null!==r&&null!==l&&ze(r)&&ze(l)&&o[0]===r.getFirstChild()&&o[o.length-1]===l.getLastChild()){t.selectPrevious();const n=t.getParent();return t.remove(),void(k(n)&&n.isEmpty()&&e.dispatchCommand(M,void 0))}o.forEach(e=>{if(v(e)){const t=m(),n=_();t.append(n),e.append(t),e.getChildren().forEach(e=>{e!==t&&e.remove()})}}),Bt(e,this.table,null),O(null),e.dispatchCommand(A,void 0)}}const Rt="__lexicalTableSelection";function Ft(e){return h(e)&&"TABLE"===e.nodeName}function Ot(e,t){if(!t)return t;const n=Ft(t)?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&Ee(245,t.nodeName),n}function At(e){return e._window}function Kt(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;Ae(n)&&(o=n)}return null}const Et=[[$,"down"],[z,"up"],[W,"backward"],[H,"forward"]],kt=[P,D,I],Mt=[J,Y];function $t(e,t,o,l){const s=o.getRootElement(),i=At(o);null!==s&&null!==i||Ee(246);const c=new Tt(o,e.getKey()),a=Ot(e,t);!function(e,t){null!==zt(e)&&Ee(205);e[Rt]=t}(a,c),c.listenersToRemove.add(()=>function(e,t){zt(e)===t&&delete e[Rt]}(a,c));const u=t=>{if(c.pointerType=t.pointerType,0!==t.button||!oe(t.target)||!i)return;const n=Wt(t.target);null!==n&&o.update(()=>{const o=ee();if(Le&&t.shiftKey&&qt(o,e)&&(w(o)||bt(o))){const r=o.anchor.getNode(),l=Kt(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(ln(c,l)),c.$setFocusCellForSelection(n),nn(t);else{(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type)}}else"touch"!==t.pointerType&&c.$setAnchorCellForSelection(n)}),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=!1,i.removeEventListener("pointerup",e),i.removeEventListener("pointermove",t)},t=n=>{if(1&~n.buttons&&c.isSelecting)return c.isSelecting=!1,i.removeEventListener("pointerup",e),void i.removeEventListener("pointermove",t);if(!oe(n.target))return;let r=null;const l=!(Le||a.contains(n.target));if(l)r=Ht(a,n.target);else for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(r=Ht(a,e),r)break;!r||null!==c.focusCell&&r.elem===c.focusCell.elem||(c.setNextFocus({focusCell:r,override:l}),o.dispatchCommand(A,void 0))};c.isSelecting=!0,i.addEventListener("pointerup",e,c.listenerOptions),i.addEventListener("pointermove",t,c.listenerOptions)})()};a.addEventListener("pointerdown",u,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("pointerdown",u)});const h=e=>{if(e.detail>=3&&oe(e.target)){null!==Wt(e.target)&&e.preventDefault()}};a.addEventListener("mousedown",h,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("mousedown",h)});const d=e=>{const t=e.target;0===e.button&&oe(t)&&o.update(()=>{const e=S();bt(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight()})};i.addEventListener("pointerdown",d,c.listenerOptions),c.listenersToRemove.add(()=>{i.removeEventListener("pointerdown",d)});for(const[t,n]of Et)c.listenersToRemove.add(o.registerCommand(t,t=>tn(o,t,n,e,c),L));c.listenersToRemove.add(o.registerCommand(B,t=>{const n=S();if(bt(n)){const o=Kt(e,n.focus.getNode());if(null!==o)return nn(t),o.selectEnd(),!0}return!1},L));const g=t=>()=>{const o=S();if(!qt(o,e))return!1;if(bt(o))return c.$clearText(),!0;if(w(o)){if(!Ae(Kt(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=>v(e)),u=a&&n(a,e=>v(e)&&Ae(e.getParent()));if(!v(u)||!v(a))return!1;if(t===D&&null===u.getPreviousSibling())return!0}return!1};for(const e of kt)c.listenersToRemove.add(o.registerCommand(e,g(e),U));const p=t=>{const n=S();if(!bt(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!!qt(n,e)&&(!!bt(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),!0))};for(const e of Mt)c.listenersToRemove.add(o.registerCommand(e,p,U));return c.listenersToRemove.add(o.registerCommand(X,e=>{const t=S();if(t){if(!bt(t)&&!w(t))return!1;ye(o,r(e,ClipboardEvent)?e:null,Ne(t));const n=p(e);return w(t)?(t.removeText(),!0):n}return!1},U)),c.listenersToRemove.add(o.registerCommand(q,t=>{const o=S();if(!qt(o,e))return!1;if(bt(o))return c.$formatCells(t),!0;if(w(o)){const e=n(o.anchor.getNode(),e=>Ae(e));if(!Ae(e))return!1}return!1},U)),c.listenersToRemove.add(o.registerCommand(j,t=>{const n=S();if(!bt(n)||!qt(n,e))return!1;const o=n.anchor.getNode(),r=n.focus.getNode();if(!Ae(o)||!Ae(r))return!1;if(function(e,t){if(bt(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=gt(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]=gt(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];v(n)&&!n.isInline()&&n.setFormat(t)}}return!0},U)),c.listenersToRemove.add(o.registerCommand(V,t=>{const r=S();if(!qt(r,e))return!1;if(bt(r))return c.$clearHighlight(),!1;if(w(r)){const l=n(r.anchor.getNode(),e=>Ae(e));if(!Ae(l))return!1;if("string"==typeof t){const n=rn(o,r,e);if(n)return on(n,e,[_(t)]),!0}}return!1},U)),l&&c.listenersToRemove.add(o.registerCommand(G,t=>{const o=S();if(!w(o)||!o.isCollapsed()||!qt(o,e))return!1;const r=Qt(o.anchor.getNode());return!(null===r||!e.is(Zt(r)))&&(nn(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(v(l))return l.selectEnd();const s=n(e,ze);null===s&&Ee(247);for(let e=s[o]();ze(e);e=e[o]()){const t=e[r]();if(v(t))return t.selectEnd()}const i=n(s,pn);null===i&&Ee(248);"next"===t?i.selectNext():i.selectPrevious()}(r,t.shiftKey?"previous":"next"),!0)},U)),c.listenersToRemove.add(o.registerCommand(Q,t=>e.isSelected(),L)),c.listenersToRemove.add(o.registerCommand(Z,(e,t)=>{if(o!==t)return!1;const{nodes:r,selection:l}=e,s=l.getStartEndPoints(),i=bt(l),c=w(l)&&null!==n(l.anchor.getNode(),e=>Ae(e))&&null!==n(l.focus.getNode(),e=>Ae(e))||i;if(1!==r.length||!pn(r[0])||!c||null===s)return!1;const[a,u]=s,[h,d,g]=pt(a),p=n(u.getNode(),e=>Ae(e));if(!(Ae(h)&&Ae(p)&&ze(d)&&pn(g)))return!1;const C=r[0],[_,S,b]=gt(g,h,p),[y]=mt(C,null,null),N=_.length,v=N>0?_[0].length:0;let x=S.startRow,T=S.startColumn,R=y.length,F=R>0?y[0].length:0;if(i){const e=Ct(_,S,b),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;x=e.minRow,T=e.minColumn,R=Math.min(R,t),F=Math.min(F,n)}let O=!1;const A=Math.min(N,x+R)-1,K=Math.min(v,T+F)-1,E=new Set;for(let e=x;e<=A;e++)for(let t=T;t<=K;t++){const n=_[e][t];E.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(ft(n.cell),E.add(n.cell.getKey()),O=!0))}let[k]=mt(g.getWritable(),null,null);const M=R-N+x;for(let e=0;e<M;e++){Qe(k[N-1][0].cell)}const $=F-v+T;for(let e=0;e<$;e++){nt(k[0][v-1].cell,!0,!1)}[k]=mt(g.getWritable(),null,null);for(let e=x;e<x+R;e++)for(let t=T;t<T+F;t++){const n=e-x,o=t-T,r=y[n][o];if(r.startRow!==n||r.startColumn!==o)continue;const l=r.cell;if(1!==l.__rowSpan||1!==l.__colSpan){const n=[],o=Math.min(e+l.__rowSpan,x+R)-1,r=Math.min(t+l.__colSpan,T+F)-1;for(let l=e;l<=o;l++)for(let e=t;e<=r;e++){const t=k[l][e];n.push(t.cell)}ut(n),O=!0}const{cell:s}=k[e][t],i=s.getChildren();l.getChildren().forEach(e=>{if(f(e)){m().append(e),s.append(e)}else s.append(e)}),i.forEach(e=>e.remove())}if(i&&O){const[e]=mt(g.getWritable(),null,null);e[S.startRow][S.startColumn].cell.selectEnd()}return!0},U)),c.listenersToRemove.add(o.registerCommand(A,()=>{const t=S(),r=ee(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(bt(t)&&t.tableKey===c.tableNodeKey)return(n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),!0);if(n!==c.anchorCell&&qt(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=Qt(o);if(null!==l&&ze(r)){const t=r.getFirstChild();if(Ae(t)&&e.is(n(l,n=>n.is(e)||n.is(t))))return t.selectStart(),!0}}if(w(t)){const{anchor:n,focus:l}=t,s=n.getNode(),i=l.getNode(),a=Qt(s),u=Qt(i),h=!(!a||!e.is(Zt(a))),d=!(!u||!e.is(Zt(u))),f=h!==d,g=h&&d,m=t.isBackward();if(f){const n=t.clone();if(d){const[t]=gt(e,u,u),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(m?o.getKey():r.getKey(),m?o.getChildrenSize():r.getChildrenSize(),"element")}else if(h){const[t]=gt(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(m?r.getKey():o.getKey(),m?r.getChildrenSize():0,"element")}O(n),Dt(o,c)}else if(g&&(a.is(u)||(c.$setAnchorCellForSelection(ln(c,a)),c.$setFocusCellForSelection(ln(c,u),!0)),"touch"===c.pointerType&&c.isSelecting&&t.isCollapsed()&&w(r)&&r.isCollapsed())){const e=Qt(r.anchor.getNode());e&&!e.is(u)&&(c.$setAnchorCellForSelection(ln(c,e)),c.$setFocusCellForSelection(ln(c,u),!0),c.pointerType=null)}}else if(t&&bt(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=K(i);if(n&&n.anchorNode&&n.focusNode){const r=te(n.focusNode),l=r&&!e.isParentOf(r),s=te(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=ne(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),O(r))}}}return t&&!t.is(r)&&(bt(t)||bt(r))&&c.tableSelection&&!c.tableSelection.is(r)?(bt(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!bt(t)&&bt(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,Gt(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&Dt(o,c),!1)},U)),c.listenersToRemove.add(o.registerCommand(M,()=>{const t=S();if(!w(t)||!t.isCollapsed()||!qt(t,e))return!1;const n=rn(o,t,e);return!!n&&(on(n,e),!0)},U)),c}function zt(e){return e[Rt]||null}function Wt(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 Ht(e,t){if(!e.contains(t))return null;let n=null;for(let o=t;null!=o;o=o.parentNode){if(o===e)return n;const t=o.nodeName;"TD"!==t&&"TH"!==t||(n=o._cell||null)}return null}function Lt(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=Ot(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 Bt(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,Gt(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=te(r.elem);null!==l&&t(r,l,{x:n,y:e})}}}function Dt(e,t){t.$disableHighlightStyle(),Pt(t.table,t=>{t.highlighted=!0,Vt(e,t)})}const It=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?jt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?jt(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?jt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?jt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Ut(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 Jt([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function Yt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&Ee(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&Ee(250,n,String(s)),i}function Xt(e,t,n,o,r){const l=Ct(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=Ut(e,t);return null===n&&Ee(249,t.cell.getKey()),n}(l,n),[d,f]=Jt(h);let g=l[d],m=l[f];"forward"===r?g+="maxColumn"===d?1:c:"backward"===r?g-="minColumn"===d?1:u:"down"===r?m+="maxRow"===f?1:i:"up"===r&&(m-="minRow"===f?1:a);const p=t[m];if(void 0===p)return!1;const C=p[g];if(void 0===C)return!1;const[_,S]=function(e,t,n){const o=Ct(e,t,n),r=Ut(o,t);if(r)return[Yt(e,o,r),Yt(e,o,Jt(r))];const l=Ut(o,n);if(l)return[Yt(e,o,Jt(l)),Yt(e,o,l)];const s=["minColumn","minRow"];return[Yt(e,o,s),Yt(e,o,Jt(s))]}(t,n,C),w=ln(e,_.cell),b=ln(e,S.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,!0),!0}function qt(e,t){if(w(e)||bt(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function jt(e,t){t?e.selectStart():e.selectEnd()}function Vt(t,n){const o=n.elem,r=t._config.theme;Ae(te(o))||Ee(131),e(o,r.tableCellSelected)}function Gt(e,t){const n=t.elem;Ae(te(n))||Ee(131);const r=e._config.theme;o(n,r.tableCellSelected)}function Qt(e){const t=n(e,Ae);return Ae(t)?t:null}function Zt(e){const t=n(e,pn);return pn(t)?t:null}function en(e,t,o,r,l,s,i){const c=le(o.focus,l?"previous":"next");if(se(c))return!1;let a=c;for(const e of ie(c).iterNodeCarets("shadowRoot")){if(!ce(e)||!v(e.origin))return!1;a=e}const u=a.getParentAtCaret();if(!Ae(u))return!1;const h=u,d=function(e){for(const t of ie(e).iterNodeCarets("root")){const{origin:n}=t;if(Ae(n)){if(de(t))return fe(n,e.direction)}else if(!ze(n))break}return null}(ae(h,a.direction)),f=n(h,pn);if(!f||!f.is(s))return!1;const g=e.getElementByKey(h.getKey()),m=Wt(g);if(!g||!m)return!1;const p=fn(e,f);if(i.table=p,d)if("extend"===r){const t=Wt(e.getElementByKey(d.origin.getKey()));if(!t)return!1;i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(t,!0)}else{const e=he(d);ue(o.anchor,e),ue(o.focus,e)}else if("extend"===r)i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(m,!0);else{const e=function(e){const t=ge(e);return de(t)?he(t):e}(ae(f,c.direction));ue(o.anchor,e),ue(o.focus,e)}return nn(t),!0}function tn(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=S();if(!qt(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(v(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!!pn(n)&&(nn(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=>pn(e));if(Ae(l)&&(l=n(l,pn)),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&&v(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&v(i)){const e=i.getLastChild();a=e||i,c=f(a)?a.getTextContentSize():0}const u=s.clone();return u.focus.set(a.getKey(),c,f(a)?"text":"element"),O(u),nn(t),!0}if(re(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==Kt(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=pt(e),[o]=pt(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=>v(e)&&!e.isInline());if(Ae(r)&&(r=n(r,pn)),!r)return!1;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(pn(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return!1;const[r]=pt(e),[l]=pt(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),nn(t),O(c),!0}}}}return"down"===o&&un(e)&&l.setShouldCheckSelection(),!1}if(w(s)){if("backward"===o||"forward"===o){return en(e,t,s,t.shiftKey?"extend":"move","backward"===o,r,l)}if(s.isCollapsed()){const{anchor:i,focus:c}=s,a=n(i.getNode(),Ae),u=n(c.getNode(),Ae);if(!Ae(a)||!a.is(u))return!1;const h=Zt(a);if(h!==r&&null!=h){const n=Ot(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=Lt(h,n),tn(e,t,o,h,l)}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return!1;let g;if("element"===i.type)g=f.getBoundingClientRect();else{const t=K(At(e));if(null===t||0===t.rangeCount)return!1;g=t.getRangeAt(0).getBoundingClientRect()}const m="up"===o?a.getFirstChild():a.getLastChild();if(null==m)return!1;const p=e.getElementByKey(m.__key);if(null==p)return!1;const C=p.getBoundingClientRect();if("up"===o?C.top>g.top-g.height:g.bottom+g.height>C.bottom){nn(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return It(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(bt(s)){const{anchor:i,focus:c}=s,a=n(i.getNode(),Ae),u=n(c.getNode(),Ae),[h]=s.getNodes();pn(h)||Ee(251);const d=Ot(h,e.getElementByKey(h.getKey()));if(!Ae(a)||!Ae(u)||!pn(h)||null==d)return!1;l.$updateTableTableSelection(s);const f=Lt(h,d),g=r.getCordsFromCellNode(a,f),m=r.getDOMCellFromCordsOrThrow(g.x,g.y,f);if(l.$setAnchorCellForSelection(m),nn(t),t.shiftKey){const[e,t,n]=gt(r,a,u);return Xt(l,e,t,n,o)}return u.selectEnd(),!0}return!1}function nn(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function on(e,t,n){const o=m();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function rn(e,t,o){const r=o.getParent();if(!r)return;const l=K(At(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=Ot(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=n(t.anchor.getNode(),e=>Ae(e));if(!a)return;const u=n(a,e=>pn(e));if(!pn(u)||!u.is(o))return;const[h,d]=gt(o,a,a),f=h[0][0],g=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,C=m===f.startRow&&p===f.startColumn,_=m===g.startRow&&p===g.startColumn;return C?"first":_?"last":void 0}function ln(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function sn(e,t,n){return Kt(e,te(t,n))}function cn(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 an=new WeakSet;function un(e=F()){return an.has(e)}function hn(e,t){t?an.add(e):an.delete(e)}class dn extends u{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;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 dn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:gn,priority:1})}}static importJSON(e){return mn().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0,this.__colWidths=void 0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t=Ft(e)?e:e.querySelector("table");return Ft(t)||Ee(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table");this.__style&&(o.style.cssText=this.__style);const r=document.createElement("colgroup");if(o.appendChild(r),me(r),e(o,t.theme.table),this.updateTableElement(null,o,t),un(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?e(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),this.updateTableWrapper(null,n,o,t),n}return o}updateTableWrapper(t,n,r,l){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,r,l){l>0?(e(t,r.theme.tableFrozenColumn),n.setAttribute("data-lexical-frozen-column","true")):(o(t,r.theme.tableFrozenColumn),n.removeAttribute("data-lexical-frozen-column"))}(n,r,l,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,r,l){l>0?(e(t,r.theme.tableFrozenRow),n.setAttribute("data-lexical-frozen-row","true")):(o(t,r.theme.tableFrozenRow),n.removeAttribute("data-lexical-frozen-row"))}(n,r,l,this.__frozenRowCount)}updateTableElement(t,n,r){this.__style!==(t?t.__style:"")&&(n.style.cssText=this.__style),this.__rowStriping!==(!!t&&t.__rowStriping)&&function(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"))}(n,r,this.__rowStriping),function(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)}(n,0,this.getColumnCount(),this.getColWidths()),cn(n,r,this.getFormatType())}updateDOM(e,t,n){const o=this.getDOMSlot(t).element;return t===o===un()||(l(r=t)&&"DIV"===r.nodeName&&this.updateTableWrapper(e,t,o,n),this.updateTableElement(e,o,n),!1);var r}exportDOM(e){const t=super.exportDOM(e),{element:n}=t;return{after:n=>{if(t.after&&(n=t.after(n)),!Ft(n)&&l(n)&&(n=n.querySelector("table")),!Ft(n))return null;cn(n,e._config,this.getFormatType());const[o]=mt(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:!Ft(n)&&l(n)?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=sn(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=te(o.elem);return Ae(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}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){const t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach(e=>{Ae(e)&&(t+=e.getColSpan())}),t}}function fn(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Ee(230),Lt(t,n)}function gn(e){const n=mn();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0),e.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!ve.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,ze),node:n}}function mn(){return p(new dn)}function pn(e){return e instanceof dn}function Cn({rows:e,columns:t,includeHeaders:n}){const o=S()||ee();if(!o||!w(o))return!1;if(Zt(o.anchor.getNode()))return!1;const r=Be(Number(e),Number(t),n);c(r);const l=r.getFirstDescendant();return f(l)&&l.select(),!0}function _n(e){ze(e.getParent())?e.isEmpty()&&e.append(m()):e.remove()}function Sn(e){pn(e.getParent())?a(e,Ae):e.remove()}function wn(e){a(e,ze);const[t]=mt(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;ze(r)||Ee(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=Oe();e.append(m()),r.append(e)}}}function bn(e){if(e.detail<3||!oe(e.target))return!1;const t=te(e.target);if(null===t)return!1;const o=n(t,e=>v(e)&&!e.isInline());if(null===o)return!1;return!!Ae(o.getParent())&&(o.select(0),!0)}function yn(e){return e.registerNodeTransform(Te,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=pt(e),[n]=gt(t,e,e),o=n.length,r=n[0].length;let l=t.getFirstChild();ze(l)||Ee(175);const i=[];for(let e=0;e<o;e++){0!==e&&(l=l.getNextSibling(),ze(l)||Ee(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){Ae(c)||Ee(176);const e=Oe(c.__headerState);null!==t?t.insertAfter(e):s(l,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}})}function Nn(e,t=!0){const n=new Map,o=(o,r,l)=>{const s=Ot(o,l),i=$t(o,s,e,t);n.set(r,[i,s])},r=e.registerMutationListener(dn,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}=xt(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 vn(e){return e.hasNodes([dn])||Ee(255),i(e.registerCommand(Ke,Cn,pe),e.registerCommand(Z,({nodes:t,selection:n},o)=>{if(e!==o||!w(n))return!1;return null!==Zt(n.anchor.getNode())&&t.some(pn)},pe),e.registerCommand(Ce,bn,pe),e.registerNodeTransform(dn,wn),e.registerNodeTransform(ke,Sn),e.registerNodeTransform(Te,_n))}const xn=_e({build:(e,t,n)=>be(t),config:Se({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasTabHandler:!0}),name:"@lexical/table/Table",nodes:[dn,ke,Te],register(e,t,n){const o=n.getOutput();return i(we(()=>{const t=o.hasHorizontalScroll.value;un(e)!==t&&(hn(e,t),e.registerNodeTransform(dn,()=>{})())}),vn(e),we(()=>Nn(e,o.hasTabHandler.value)),we(()=>o.hasCellMerge.value?void 0:yn(e)),we(()=>o.hasCellBackgroundColor.value?void 0:e.registerNodeTransform(Te,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}});export{gt as $computeTableMap,mt as $computeTableMapSkipCellCheck,Oe as $createTableCellNode,mn as $createTableNode,Be as $createTableNodeWithDimensions,$e as $createTableRowNode,yt as $createTableSelection,Nt as $createTableSelectionFrom,ot as $deleteTableColumn,st as $deleteTableColumnAtSelection,it as $deleteTableColumn__EXPERIMENTAL,rt as $deleteTableRowAtSelection,lt as $deleteTableRow__EXPERIMENTAL,Qt as $findCellNode,Zt as $findTableNode,fn as $getElementForTableNode,pt as $getNodeTriplet,xt as $getTableAndElementByKey,Pe as $getTableCellNodeFromLexicalNode,_t as $getTableCellNodeRect,Je as $getTableColumnIndexFromTableCellNode,Ie as $getTableNodeFromLexicalNodeOrThrow,Ue as $getTableRowIndexFromTableCellNode,De as $getTableRowNodeFromTableCellNodeOrThrow,Ze as $insertTableColumn,et as $insertTableColumnAtSelection,tt as $insertTableColumn__EXPERIMENTAL,qe as $insertTableRow,Ve as $insertTableRowAtSelection,Ge as $insertTableRow__EXPERIMENTAL,un as $isScrollableTablesActive,Ae as $isTableCellNode,pn as $isTableNode,ze as $isTableRowNode,bt as $isTableSelection,ut as $mergeCells,Xe as $removeTableRowAtIndex,dt as $unmergeCell,Ke as INSERT_TABLE_COMMAND,xe as TableCellHeaderStates,Te as TableCellNode,xn as TableExtension,dn as TableNode,Tt as TableObserver,ke as TableRowNode,$t as applyTableHandlers,Wt as getDOMCellFromTarget,Ot as getTableElement,zt as getTableObserverFromTableElement,yn as registerTableCellUnmergeTransform,vn as registerTablePlugin,Nn as registerTableSelectionObserver,hn as setScrollableTablesActive};
package/package.json CHANGED
@@ -8,14 +8,14 @@
8
8
  "table"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.36.3-nightly.20251002.0",
11
+ "version": "0.36.3-nightly.20251006.0",
12
12
  "main": "LexicalTable.js",
13
13
  "types": "index.d.ts",
14
14
  "dependencies": {
15
- "@lexical/clipboard": "0.36.3-nightly.20251002.0",
16
- "@lexical/extension": "0.36.3-nightly.20251002.0",
17
- "@lexical/utils": "0.36.3-nightly.20251002.0",
18
- "lexical": "0.36.3-nightly.20251002.0"
15
+ "@lexical/clipboard": "0.36.3-nightly.20251006.0",
16
+ "@lexical/extension": "0.36.3-nightly.20251006.0",
17
+ "@lexical/utils": "0.36.3-nightly.20251006.0",
18
+ "lexical": "0.36.3-nightly.20251006.0"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",