@lexical/table 0.48.0 → 0.48.1-nightly.20260720.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.
- package/dist/LexicalTable.dev.js +311 -113
- package/dist/LexicalTable.dev.mjs +311 -115
- package/dist/LexicalTable.js.flow +5 -6
- package/dist/LexicalTable.mjs +2 -0
- package/dist/LexicalTable.node.mjs +2 -0
- package/dist/LexicalTable.prod.js +1 -1
- package/dist/LexicalTable.prod.mjs +1 -1
- package/dist/LexicalTableCellNode.d.ts +28 -5
- package/dist/LexicalTableExtension.d.ts +13 -0
- package/dist/LexicalTableNode.d.ts +30 -7
- package/dist/LexicalTableRowNode.d.ts +21 -6
- package/dist/LexicalTableSelection.d.ts +12 -0
- package/dist/LexicalTableUtils.d.ts +4 -0
- package/dist/index.d.ts +3 -2
- package/package.json +7 -7
- package/src/LexicalTableCellNode.ts +14 -29
- package/src/LexicalTableExtension.ts +100 -0
- package/src/LexicalTableNode.ts +234 -43
- package/src/LexicalTableRowNode.ts +13 -21
- package/src/LexicalTableSelection.ts +17 -7
- package/src/LexicalTableSelectionHelpers.ts +2 -62
- package/src/LexicalTableUtils.ts +4 -0
- package/src/index.ts +3 -0
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
"use strict";var e=require("lexical"),t=require("@lexical/extension"),n=require("@lexical/html"),o=require("@lexical/utils"),r=require("@lexical/clipboard");const l=/^(\d+(?:\.\d+)?)px$/,s={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class i extends e.ElementNode{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new i(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,this.__colSpan=e.__colSpan,this.__headerState=e.__headerState,this.__width=e.__width}static importDOM(){return{td:e=>({conversion:c,priority:0}),th:e=>({conversion:c,priority:0})}}static importJSON(e){return u().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=s.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=e.$getDocument().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),a(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(t){const n=super.exportDOM(t);if(e.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(),...a(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=s.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!==s.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 a(e){return"middle"===e||"bottom"===e}function c(t){const n=t,o=t.nodeName.toLowerCase();let r;l.test(n.style.width)&&(r=parseFloat(n.style.width));let i=s.NO_STATUS;if("th"===o){const t=n.getAttribute("scope");if("col"===t)i=s.COLUMN;else if("row"===t)i=s.ROW;else{const t=n.parentElement,o=e.isHTMLElement(t)&&"tr"===t.nodeName.toLowerCase()&&e.isHTMLElement(t.parentElement)&&("thead"===t.parentElement.nodeName.toLowerCase()||0===t.rowIndex),r=0===n.cellIndex;o&&(i|=s.ROW),r&&(i|=s.COLUMN),i===s.NO_STATUS&&(i=s.ROW)}}const c=u(i,n.colSpan,r);c.__rowSpan=n.rowSpan;const d=n.style.backgroundColor;""!==d&&(c.__backgroundColor=d);const h=n.style.verticalAlign;a(h)&&(c.__verticalAlign=h);const g=n.style,f=(g&&g.textDecoration||"").split(" "),m="700"===g.fontWeight||"bold"===g.fontWeight,p=f.includes("line-through"),C="italic"===g.fontStyle,_=f.includes("underline"),S=g.color;return{after:t=>{const n=[];let o=null;const r=()=>{if(o){const t=o.getFirstChild();e.$isLineBreakNode(t)&&1===o.getChildrenSize()&&t.remove()}};for(const l of t)if(e.$isInlineElementOrDecoratorNode(l)||e.$isTextNode(l)||e.$isLineBreakNode(l)){if(e.$isTextNode(l)&&(m&&l.toggleFormat("bold"),p&&l.toggleFormat("strikethrough"),C&&l.toggleFormat("italic"),_&&l.toggleFormat("underline"),S)){const e=l.getStyle();e.includes("color:")||l.setStyle(e+`color: ${S};`)}o?o.append(l):(o=e.$createParagraphNode().append(l),n.push(o))}else n.push(l),r(),o=null;return r(),0===n.length&&n.push(e.$createParagraphNode()),n},node:c}}function u(t=s.NO_STATUS,n=1,o){return e.$applyNodeReplacement(new i(t,n,o))}function d(e){return e instanceof i}const h=/* @__PURE__ */e.createCommand("INSERT_TABLE_COMMAND");function g(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 f extends e.ElementNode{__height;static getType(){return"tablerow"}static clone(e){return new f(e.__height,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__height=e.__height}static importDOM(){return{tr:e=>({conversion:m,priority:0})}}static importJSON(e){return p().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=e.$getDocument().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 m(e){const t=e;let n;return l.test(t.style.height)&&(n=parseFloat(t.style.height)),{after:e=>o.$descendantsMatching(e,d),node:p(n)}}function p(t){return e.$applyNodeReplacement(new f(t))}function C(e){return e instanceof f}function _(t,n,o=!0){const r=qe();for(let l=0;l<t;l++){const t=p();for(let r=0;r<n;r++){let n=s.NO_STATUS;"object"==typeof o?(0===l&&o.rows&&(n|=s.ROW),0===r&&o.columns&&(n|=s.COLUMN)):o&&(0===l&&(n|=s.ROW),0===r&&(n|=s.COLUMN));const i=u(n),a=e.$createParagraphNode();a.append(e.$createTextNode()),i.append(a),t.append(i)}r.append(t)}return r}function S(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 N(t){const n=e.$findMatchingParent(t,e=>Ge(e));if(Ge(n))return n;throw new Error("Expected table cell to be inside of table.")}function b(e,t){const n=N(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)}}const w=(e,t)=>e===s.BOTH||e===t?t:s.NO_STATUS;function T(t=!0){const n=e.$getSelection();e.$isRangeSelection(n)||q(n)||g(188);const o=n.anchor.getNode(),r=n.focus.getNode(),[l]=L(o),[s,,i]=L(r),[,a,c]=H(i,s,l),{startRow:u}=c,{startRow:d}=a;return t?y(u+l.__rowSpan>d+s.__rowSpan?l:s,!0):y(d<u?s:l,!1)}const $=T;function y(t,n=!0){const[,,o]=L(t),[r,l]=H(o,t,t),i=r[0].length,{startRow:a}=l;let c=null;if(n){const n=a+t.__rowSpan-1,l=r[n],d=p();for(let t=0;t<i;t++){const{cell:o,startRow:r}=l[t];if(r+o.__rowSpan-1<=n){const n=l[t].cell.__headerState,o=w(n,s.COLUMN);d.append(u(o).append(e.$createParagraphNode()))}else o.setRowSpan(o.__rowSpan+1)}const h=o.getChildAtIndex(n);C(h)||g(256),h.insertAfter(d),c=d}else{const t=a,n=r[t],l=p();for(let o=0;o<i;o++){const{cell:r,startRow:i}=n[o];if(i===t){const t=n[o].cell.__headerState,r=w(t,s.COLUMN);l.append(u(r).append(e.$createParagraphNode()))}else r.setRowSpan(r.__rowSpan+1)}const d=o.getChildAtIndex(t);C(d)||g(257),d.insertBefore(l),c=l}return c}function R(t=!0){const n=e.$getSelection();e.$isRangeSelection(n)||q(n)||g(188);const o=n.anchor.getNode(),r=n.focus.getNode(),[l]=L(o),[s,,i]=L(r),[,a,c]=H(i,s,l),{startColumn:u}=c,{startColumn:d}=a;return t?M(u+l.__colSpan>d+s.__colSpan?l:s,!0):M(d<u?s:l,!1)}const x=R;function M(t,n=!0,o=!0){const[,,r]=L(t),[l,i]=H(r,t,t),a=l.length,{startColumn:c}=i,d=n?c+t.__colSpan-1:c-1,h=r.getFirstChild();C(h)||g(120);let f=null;function m(t=s.NO_STATUS){const n=u(t).append(e.$createParagraphNode());return null===f&&(f=n),n}let p=h;e:for(let e=0;e<a;e++){if(0!==e){const e=p.getNextSibling();C(e)||g(121),p=e}const t=l[e],n=t[d<0?0:d].cell.__headerState,o=w(n,s.ROW);if(d<0){P(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&&F(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 O(){const t=e.$getSelection();e.$isRangeSelection(t)||q(t)||g(188);const[n,o]=t.isBackward()?[t.focus.getNode(),t.anchor.getNode()]:[t.anchor.getNode(),t.focus.getNode()],[r,,l]=L(n),[s]=L(o),[i,a,c]=H(l,r,s),{startRow:u}=a,{startRow:d}=c,h=d+s.__rowSpan-1;if(i.length===h-u+1)return void l.remove();const f=i[0].length,m=i[h+1],p=l.getChildAtIndex(h+1);for(let e=h;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>h){const e=Math.max(o,u),t=Math.min(n.__rowSpan+o-1,h),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r)}if(o>=u&&o+n.__rowSpan-1>h&&e===h){C(p)||g(387);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?P(p,n):o.insertAfter(n)}}}const t=l.getChildAtIndex(e);C(t)||g(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];F(e)}else{const e=i[u-1],{cell:t}=e[0];F(t)}}const E=O;function A(){const t=e.$getSelection();e.$isRangeSelection(t)||q(t)||g(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r,,l]=L(n),[s]=L(o),[i,a,c]=H(l,r,s),{startColumn:u}=a,{startRow:d,startColumn:h}=c,f=Math.min(u,h),m=Math.max(u+r.__colSpan-1,h+s.__colSpan-1),p=m-f+1;if(i[0].length===m-f+1)return l.selectPrevious(),void l.remove();const C=i.length;for(let e=0;e<C;e++)for(let t=f;t<=m;t++){const{cell:n,startColumn:o}=i[e][t];if(o<f){if(t===f){const e=f-o;n.setColSpan(n.__colSpan-Math.min(p,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const _=i[d],S=u>h?_[u+r.__colSpan]:_[h+s.__colSpan];if(void 0!==S){const{cell:e}=S;F(e)}else{const e=h<u?_[h-1]:_[u-1],{cell:t}=e;F(t)}const N=l.getColWidths();if(N){const e=[...N];e.splice(f,p),l.setColWidths(e)}}const v=A;function F(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function P(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function D(t){if(0===t.length)return null;const n=N(t[0]),[o]=k(n,null,null);let r=1/0,l=-1/0,s=1/0,i=-1/0;const a=new Set;for(const e of o)for(const n of e){if(!n||!n.cell)continue;const e=n.cell.getKey();if(!a.has(e)&&t.some(e=>e.is(n.cell))){a.add(e);const t=n.startRow,o=n.startColumn,c=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;r=Math.min(r,t),l=Math.max(l,t+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);K(r)||h.append(...r.getChildren()),r.remove()}}return 0===h.getChildrenSize()&&h.append(e.$createParagraphNode()),h}function K(t){if(1!==t.getChildrenSize())return!1;const n=t.getFirstChildOrThrow();return!(!e.$isParagraphNode(n)||!n.isEmpty())}function I(t){const[n,o,r]=L(t),l=n.__colSpan,i=n.__rowSpan;if(1===l&&1===i)return;const[a,c]=H(r,n,n),{startColumn:d,startRow:h}=c,f=n.__headerState&s.COLUMN,m=Array.from({length:l},(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&s.ROW,_=Array.from({length:i},(e,t)=>{let n=p;for(let e=0;0!==n&&e<a[0].length;e++)n&=a[t+h][e].cell.__headerState;return n});if(l>1){for(let t=1;t<l;t++)n.insertAfter(u(m[t]|_[0]).append(e.$createParagraphNode()));n.setColSpan(1)}if(i>1){let t;for(let n=1;n<i;n++){const r=h+n,s=a[r];t=(t||o).getNextSibling(),C(t)||g(125);let i=null;for(let e=0;e<d;e++){const t=s[e],n=t.cell;t.startRow===r&&(i=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===i)for(let o=l-1;o>=0;o--)P(t,u(m[o]|_[n]).append(e.$createParagraphNode()));else for(let t=l-1;t>=0;t--)i.insertAfter(u(m[t]|_[n]).append(e.$createParagraphNode()))}n.setRowSpan(1)}}function H(e,t,n){const[o,r,l]=k(e,t,n);return null===r&&g(207),null===l&&g(208),[o,r,l]}function k(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)||g(209);const a=s(e);for(let c=o.getFirstChild(),u=0;null!=c;c=c.getNextSibling()){for(d(c)||g(147);void 0!==a[u];)u++;const o={cell:c,startColumn:u,startRow:e},{__rowSpan:h,__colSpan:f}=c;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<f;e++)n[u+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 L(t){let n;if(t instanceof i)n=t;else if("__type"in t){const o=e.$findMatchingParent(t,d);d(o)||g(148),n=o}else{const o=e.$findMatchingParent(t.getNode(),d);d(o)||g(148),n=o}const o=n.getParent();C(o)||g(149);const r=o.getParent();return Ge(r)||g(210),[n,o,r]}function W(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 B(e){const t=e.getChildren();let n=null;for(const e of t){if(!C(e))return!1;if(null===n&&(n=e.getChildrenSize()),e.getChildrenSize()!==n)return!1;const t=e.getChildren();for(const e of t)if(!d(e)||1!==e.getRowSpan()||1!==e.getColSpan())return!1}return(n||0)>0}function z(e){const[t,,n]=L(e),o=n.getChildren().filter(C),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().filter(d);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 Y(t,n){const o=n.getStartEndPoints(),r=q(n);if(null===o)return!1;const[l,s]=o,[i,a,c]=L(l),u=e.$findMatchingParent(s.getNode(),e=>d(e));if(!(d(i)&&d(u)&&C(a)&&Ge(c)))return!1;const[h,g,f]=H(c,i,u),[m]=k(t,null,null),p=h.length,_=p>0?h[0].length:0;let S=g.startRow,N=g.startColumn,b=m.length,w=b>0?m[0].length:0;if(r){const e=W(h,g,f),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;S=e.minRow,N=e.minColumn,b=Math.min(b,t),w=Math.min(w,n)}let T=!1;const $=Math.min(p,S+b)-1,R=Math.min(_,N+w)-1,x=new Set;for(let e=S;e<=$;e++)for(let t=N;t<=R;t++){const n=h[e][t];x.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(I(n.cell),x.add(n.cell.getKey()),T=!0))}let[O]=k(c.getWritable(),null,null);const E=b-p+S;for(let e=0;e<E;e++){y(O[p-1][0].cell)}const A=w-_+N;for(let e=0;e<A;e++){M(O[0][_-1].cell,!0,!1)}[O]=k(c.getWritable(),null,null);for(let t=S;t<S+b;t++)for(let n=N;n<N+w;n++){const o=t-S,r=n-N,l=m[o][r];if(l.startRow!==o||l.startColumn!==r)continue;const s=l.cell;if(1!==s.__rowSpan||1!==s.__colSpan){const e=[],o=Math.min(t+s.__rowSpan,S+b)-1,r=Math.min(n+s.__colSpan,N+w)-1;for(let l=t;l<=o;l++)for(let t=n;t<=r;t++){const n=O[l][t];e.push(n.cell)}D(e),T=!0}const{cell:i}=O[t][n],a=s.getBackgroundColor();null!=a&&i.setBackgroundColor(a);const c=i.getChildren();s.getChildren().forEach(t=>{if(e.$isTextNode(t)){e.$createParagraphNode().append(t),i.append(t)}else i.append(t)}),c.forEach(e=>e.remove())}if(r&&T){const[e]=k(c.getWritable(),null,null);e[g.startRow][g.startColumn].cell.selectEnd()}return!0}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,d);d(r)||g(238,n,o.getKey(),o.getType());const l=r.getParent();C(l)||g(239,n);const s=l.getParent();return Ge(s)||g(240,n),[o,r,l,s]});return l.is(c)||g(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 t=e.$getNodeByKey(this.tableKey),n=e.$getNodeByKey(this.anchor.key),o=e.$getNodeByKey(this.focus.key);return null!==t&&null!==n&&null!==o}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return q(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,e.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),e.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(t){if(""===t)return;const n=(t.endsWith("\n")?t.slice(0,-1):t).split("\n").map(e=>e.split("\t")),o=qe();for(const t of n){const n=p();for(const o of t){const t=u(s.NO_STATUS),r=e.$createParagraphNode();o&&r.append(e.$createTextNode(o)),t.append(r),n.append(t)}o.append(n)}const{anchorCell:r}=U(this);Y(o,r.select(0,r.getChildrenSize()))}insertText(){}hasFormat(t){let n=0;this.getNodes().filter(d).forEach(t=>{const o=t.getFirstChild();e.$isParagraphNode(o)&&(n|=o.getTextFormat())});const o=e.TEXT_TYPE_TO_FORMAT[t];return 0!==(n&o)}insertNodes(t){const n=this.focus.getNode();e.$isElementNode(n)||g(151);e.$normalizeSelection__EXPERIMENTAL(n.select(0,n.getChildrenSize())).insertNodes(t)}getShape(){const{anchorCell:e,focusCell:t}=U(this),n=z(e);null===n&&g(153);const o=z(t);null===o&&g(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 t=this._cachedNodes;if(null!==t)return t;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&&g(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=n.getParent();null==e&&g(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:h}=W(s,i,a),f=new Map([[n.getKey(),n]]);let m=null;for(let e=d;e<=h;e++)for(let t=c;t<=u;t++){const{cell:n}=s[e][t],o=n.getParent();C(o)||g(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 e.isCurrentlyReadOnlyMode()||(this._cachedNodes=p),p}getTextContent(){const e=this.getNodes().filter(e=>d(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 q(e){return e instanceof X}function G(){const t=e.$createPoint("root",0,"element"),n=e.$createPoint("root",0,"element");return new X("root",t,n)}function J(t,n,o){t.getKey(),n.getKey(),o.getKey();const r=e.$getSelection(),l=q(r)?r.clone():G();return l.set(t.getKey(),n.getKey(),o.getKey()),l}function j(t,n){const o=[[t]];for(let t=o.at(-1);void 0!==t&&o.length>0;t=o.at(-1)){const r=t.pop();void 0===r?o.pop():!1!==n(r)&&e.$isElementNode(r)&&o.push(r.getChildren())}}function V(t,n=e.$getEditor()){const o=e.$getNodeByKey(t);Ge(o)||g(231,t);const r=le(o,n.getElementByKey(t));return null===r&&g(232,t),{tableElement:r,tableNode:o}}class Q{observers;nextFocus;shouldCheckSelectionForTable;constructor(){this.observers=new Map,this.nextFocus=null,this.shouldCheckSelectionForTable=null}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}setShouldCheckSelectionForTable(e){this.shouldCheckSelectionForTable=e}getAndClearShouldCheckSelectionForTable(){const{shouldCheckSelectionForTable:e}=this;return e?(this.shouldCheckSelectionForTable=null,e):null}removeObserver(e){const t=this.observers.get(e);return void 0!==t&&(t[0].removeListeners(),this.observers.delete(e),!0)}removeAllObservers(){for(const e of Array.from(this.observers.keys()))this.removeObserver(e)}$getTableNodesAndObservers(){const t=[];for(const[n,[o]]of Array.from(this.observers.entries())){const r=e.$getNodeByKey(n);Ge(r)?t.push([r,o]):this.removeObserver(n)}return t}}class Z{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;abortController;listenerOptions;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.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},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.read("latest",()=>{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=_e(n,o)})});this.editor.read("latest",()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=_e(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})})}$clearHighlight(t=!0){const n=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:o,tableElement:r}=this.$lookup();Se(n,_e(o,r),null),t&&null!==e.$getSelection()&&(e.$setSelection(null),n.dispatchCommand(e.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&&g(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Se(t,this.table,this.tableSelection)}else this.$clearHighlight()}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const t=e.getDOMSelection(this.editor._window);t&&t.rangeCount>0&&t.removeAllRanges()}}$setFocusCellForSelection(t,n=!1){const o=this.editor,{tableNode:r}=this.$lookup(),l=t.x,s=t.y;if(this.focusCell=t,!this.isHighlightingCells){(n||this.anchorX!==l||this.anchorY!==s||null!=this.tableSelection&&null!=this.anchorCellNodeKey)&&(this.isHighlightingCells=!0,this.$disableHighlightStyle())}if(-1!==this.focusX&&-1!==this.focusY&&l===this.focusX&&s===this.focusY)return!1;if(this.focusX=l,this.focusY=s,this.isHighlightingCells){const i=He(r,t.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey){let t=i;if(null===t&&n&&(t=r.getCellNodeFromCords(l,s,this.table)),null!==t){const n=this.$getAnchorTableCellOrThrow();return this.focusCellNodeKey=t.getKey(),this.tableSelection=J(r,n,t),e.$setSelection(this.tableSelection),o.dispatchCommand(e.SELECTION_CHANGE_COMMAND,void 0),Se(o,this.table,this.tableSelection),!0}}}return!1}$getAnchorTableCell(){const t=this.anchorCellNodeKey?e.$getNodeByKey(this.anchorCellNodeKey):null;return d(t)?t:null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&g(234),e}$getFocusTableCell(){const t=this.focusCellNodeKey?e.$getNodeByKey(this.focusCellNodeKey):null;return d(t)?t:null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&g(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.focusX=-1,this.focusY=-1,this.focusCell=null,this.focusCellNodeKey=null;const{tableNode:t}=this.$lookup(),n=He(t,e.elem);if(null!==n){const e=n.getKey();null!=this.tableSelection?(this.tableSelection=this.tableSelection.clone(),this.tableSelection.set(t.getKey(),e,e)):this.tableSelection=J(t,n,n),this.anchorCellNodeKey=e}}$formatCells(t){const n=e.$getSelection();q(n)||g(236);const o=e.$createRangeSelection(),r=o.anchor,l=o.focus,s=n.getNodes().filter(d);s.length>0||g(237);const i=s[0].getFirstChild(),a=e.$isParagraphNode(i)?i.getFormatFlags(t,null):null;s.forEach(e=>{r.set(e.getKey(),0,"element"),l.set(e.getKey(),e.getChildrenSize(),"element"),o.formatText(t,a)}),e.$setSelection(n),this.editor.dispatchCommand(e.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:t}=this,n=e.$getNodeByKey(this.tableNodeKey);if(!Ge(n))throw new Error("Expected TableNode.");const o=e.$getSelection();q(o)||g(253);const r=o.getNodes().filter(d),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(e.$isRootNode(o)&&o.isEmpty()&&t.dispatchCommand(e.INSERT_PARAGRAPH_COMMAND,void 0))}r.forEach(t=>{if(e.$isElementNode(t)){const n=e.$createParagraphNode(),o=e.$createTextNode();n.append(o),t.append(n),t.getChildren().forEach(e=>{e!==n&&e.remove()})}}),Se(t,this.table,null),e.$setSelection(null),t.dispatchCommand(e.SELECTION_CHANGE_COMMAND,void 0)}}const ee="__lexicalTableSelection";function te(t){const n=e.$getNodeByKeyOrThrow(t);return Ge(n)||g(386,t),n}const ne=40;function oe(e,t,n){const o=e=>Math.max(1,Math.ceil(Math.min(ne,e)/ne*18));return e<=t+ne?-o(t+ne-e):e>=n-ne?o(e-(n-ne)):0}function re(t){return e.isHTMLElement(t)&&"TABLE"===t.nodeName}function le(e,t){if(!t)return t;const n=re(t)?t:t.querySelector("table");return re(n)||g(341,e.constructor.name,e.getType(),e.getKey(),t.nodeName),n}function se(e){return e._window}function ie(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;d(n)&&(o=n)}return null}const ae=[[e.KEY_ARROW_DOWN_COMMAND,"down"],[e.KEY_ARROW_UP_COMMAND,"up"],[e.KEY_ARROW_LEFT_COMMAND,"backward"],[e.KEY_ARROW_RIGHT_COMMAND,"forward"]],ce=[e.DELETE_WORD_COMMAND,e.DELETE_LINE_COMMAND,e.DELETE_CHARACTER_COMMAND],ue=[e.KEY_BACKSPACE_COMMAND,e.KEY_DELETE_COMMAND];function de(t,n){return t.registerRootListener(o=>{if(null===o)return;const r=t._window;if(null===r)return;return e.registerEventListener(r,"pointerdown",r=>{const l=e.getComposedEventTarget(r);if(0!==r.button||!e.isDOMNode(l)||!o.contains(l))return;const s=function(e){const t=pe(e);if(null===t)return null;let n=t.elem;for(;null!=n;){if("TABLE"===n.nodeName&&ee in n&&n[ee])return{cellElement:t,tableElement:n,tableObserver:n[ee]};n=n.parentNode}return null}(l);t.update(()=>{if(q(e.$getSelection())){for(const[e]of n.observers.values())e.$clearHighlight(!1);e.$setSelection(null),t.dispatchCommand(e.SELECTION_CHANGE_COMMAND,void 0)}if(!s)return;const{tableObserver:o,tableElement:l,cellElement:i}=s;!function(t,n,o,r,l,s){const i=t._window;if(!i)return;const a=o=>{if(l.isSelecting)return;l.isSelecting=!0,null!==o&&null===l.anchorCell&&t.update(()=>{l.$setAnchorCellForSelection(o)});let a=n.clientX,c=n.clientY,u=null;const d=()=>{l.isSelecting=!1,null!==u&&(i.cancelAnimationFrame(u),u=null),i.removeEventListener("pointerup",N),i.removeEventListener("pointermove",b)},h=(t,n)=>{const o=r.getRootNode();if(!e.isDOMDocumentNode(o)&&!e.isDOMShadowRoot(o))return null;for(const e of o.elementsFromPoint(t,n)){const t=Ce(r,e);if(t)return t}return null},g=(n,o)=>{null===l.anchorCell&&t.update(()=>{l.$setAnchorCellForSelection(n)}),null!==l.focusCell&&n.elem===l.focusCell.elem||(s.setNextFocus({focusCell:n,override:o,tableKey:l.tableNodeKey}),t.dispatchCommand(e.SELECTION_CHANGE_COMMAND,void 0))},f=e=>{for(let t=r.parentElement;t;t=t.parentElement){if("x"===e?t.scrollWidth>t.clientWidth:t.scrollHeight>t.clientHeight){const n=i.getComputedStyle(t),o="x"===e?n.overflowX:n.overflowY;if("auto"===o||"scroll"===o)return t}}return null},m=(e,t,n)=>{let o,r;if(null===e)o=0,r="x"===n?i.innerWidth:i.innerHeight;else{const t=e.getBoundingClientRect();o="x"===n?t.left:t.top,r="x"===n?t.right:t.bottom}const l=oe(t,o,r);if(0===l)return!1;if(null===e){const e="x"===n?i.scrollX:i.scrollY;return i.scrollBy("x"===n?l:0,"x"===n?0:l),("x"===n?i.scrollX:i.scrollY)!==e}if("x"===n){const t=e.scrollLeft;return e.scrollLeft+=l,e.scrollLeft!==t}const s=e.scrollTop;return e.scrollTop+=l,e.scrollTop!==s},p=(e,t)=>{let n=a,o=c;if(null===e)n=Math.min(Math.max(n,1),i.innerWidth-1);else{const t=e.getBoundingClientRect();n=Math.min(Math.max(n,t.left+1),t.right-1)}if(null===t)o=Math.min(Math.max(o,1),i.innerHeight-1);else{const e=t.getBoundingClientRect();o=Math.min(Math.max(o,e.top+1),e.bottom-1)}return[n,o]},C=()=>{const e=f("x");if(null!==e){const t=e.getBoundingClientRect();if(0!==oe(a,t.left,t.right))return!0}const t=f("y"),n=null===t?0:t.getBoundingClientRect().top,o=null===t?i.innerHeight:t.getBoundingClientRect().bottom;return 0!==oe(c,n,o)},_=()=>{if(u=null,!l.isSelecting)return;const e=f("x"),t=f("y"),n=null!==e&&m(e,a,"x"),o=m(t,c,"y");if(n||o){const[n,o]=p(e,t),r=h(n,o);r&&g(r,!1),u=i.requestAnimationFrame(_)}},S=()=>{null===u&&"touch"!==l.pointerType&&C()&&(u=i.requestAnimationFrame(_))},N=()=>{d()},b=t=>{if(!(e=>!(1&~e.buttons))(t)&&l.isSelecting)return void d();const n=e.getComposedEventTarget(t);if(!e.isDOMNode(n))return;a=t.clientX,c=t.clientY;let o=null;const s=!(e.IS_FIREFOX||r.contains(n));o=s?Ce(r,n):h(t.clientX,t.clientY),o&&g(o,s),S()};i.addEventListener("pointerup",N,l.listenerOptions),i.addEventListener("pointermove",b,l.listenerOptions)};l.pointerType=n.pointerType;const c=te(l.tableNodeKey),u=e.$getPreviousSelection();if(e.IS_FIREFOX&&n.shiftKey&&Re(u,c)&&(e.$isRangeSelection(u)||q(u))){const e=u.anchor.getNode(),t=ie(c,u.anchor.getNode());if(t)l.$setAnchorCellForSelection(Ie(l,t)),l.$setFocusCellForSelection(o),Pe(n);else{(c.isBefore(e)?c.selectStart():c.selectEnd()).anchor.set(u.anchor.key,u.anchor.offset,u.anchor.type)}}else"touch"!==n.pointerType&&l.$setAnchorCellForSelection(o);a(o)}(t,r,i,l,o,n)})})})}function he(t,n,l,s,i){const a=l.getRootElement(),c=se(l);null!==a&&null!==c||g(246);const u=new Z(l,t.getKey()),h=le(t,n);!function(e,t){null!==me(e)&&g(205);e[ee]=t}(h,u),u.listenersToRemove.add(()=>function(e,t){me(e)===t&&delete e[ee]}(h,u));u.listenersToRemove.add(e.registerEventListener(h,"mousedown",t=>{const n=e.getComposedEventTarget(t);if(t.detail>=3&&e.isDOMNode(n)){null!==pe(n)&&t.preventDefault()}},u.listenerOptions));for(const[n,o]of ae)u.listenersToRemove.add(l.registerCommand(n,e=>Fe(l,e,o,t,u,i),e.COMMAND_PRIORITY_HIGH));u.listenersToRemove.add(l.registerCommand(e.KEY_ESCAPE_COMMAND,n=>{const o=e.$getSelection();if(q(o)){const e=ie(t,o.focus.getNode());if(null!==e)return Pe(n),e.selectEnd(),!0}return!1},e.COMMAND_PRIORITY_HIGH));const f=n=>()=>{const o=e.$getSelection();if(!Re(o,t))return!1;if(q(o))return u.$clearText(),!0;if(e.$isRangeSelection(o)){if(!d(ie(t,o.anchor.getNode())))return!1;const r=o.anchor.getNode(),l=o.focus.getNode(),s=t.isParentOf(r),i=t.isParentOf(l);if(s&&!i||i&&!s)return u.$clearText(),!0;const a=e.$findMatchingParent(o.anchor.getNode(),t=>e.$isElementNode(t)),c=a&&e.$findMatchingParent(a,t=>e.$isElementNode(t)&&d(t.getParent()));if(!e.$isElementNode(c)||!e.$isElementNode(a))return!1;if(n===e.DELETE_LINE_COMMAND&&null===c.getPreviousSibling())return!0}return!1};for(const t of ce)u.listenersToRemove.add(l.registerCommand(t,f(t),e.COMMAND_PRIORITY_HIGH));const m=n=>{const o=e.$getSelection();if(!q(o)&&!e.$isRangeSelection(o))return!1;const r=t.isParentOf(o.anchor.getNode());if(r!==t.isParentOf(o.focus.getNode())){const e=r?"anchor":"focus",n=r?"focus":"anchor",{key:l,offset:s,type:i}=o[n];return t[o[e].isBefore(o[n])?"selectPrevious":"selectNext"]()[n].set(l,s,i),!1}return!!Re(o,t)&&(!!q(o)&&(n&&(n.preventDefault(),n.stopPropagation()),u.$clearText(),!0))};for(const t of ue)u.listenersToRemove.add(l.registerCommand(t,m,e.COMMAND_PRIORITY_HIGH));u.listenersToRemove.add(l.registerCommand(e.CUT_COMMAND,t=>{const n=e.$getSelection();if(n){if(!q(n)&&!e.$isRangeSelection(n))return!1;r.copyToClipboard(l,o.objectKlassEquals(t,ClipboardEvent)?t:null,r.$getClipboardDataFromSelection(n));const s=m(t);return e.$isRangeSelection(n)?(n.removeText(),!0):s}return!1},e.COMMAND_PRIORITY_HIGH));const p=a.ownerDocument;return u.listenersToRemove.add(e.registerEventListener(p,"paste",n=>{if(n.defaultPrevented)return;l.read("latest",()=>{const n=e.$getSelection();return a.contains(p.activeElement)&&q(n)&&Re(n,t)})&&(n.preventDefault(),l.dispatchCommand(e.PASTE_COMMAND,n))})),u.listenersToRemove.add(e.registerEventListener(p,"copy",n=>{if(n.defaultPrevented)return;const o=e.getComposedEventTarget(n);if(o===a||e.isDOMNode(o)&&a.contains(o))return;l.read("latest",()=>{const n=e.$getSelection();return a.contains(e.getActiveElement(a))&&q(n)&&Re(n,t)})&&(n.preventDefault(),l.dispatchCommand(e.COPY_COMMAND,n))})),u.listenersToRemove.add(l.registerCommand(e.FORMAT_TEXT_COMMAND,n=>{const o=e.$getSelection();if(!Re(o,t))return!1;if(q(o))return u.$formatCells(n),!0;if(e.$isRangeSelection(o)){const t=e.$findMatchingParent(o.anchor.getNode(),e=>d(e));if(!d(t))return!1}return!1},e.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(l.registerCommand(e.FORMAT_ELEMENT_COMMAND,n=>{const o=e.$getSelection();if(!q(o)||!Re(o,t))return!1;const r=o.anchor.getNode(),l=o.focus.getNode();if(!d(r)||!d(l))return!1;if(function(e,t){if(q(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,t))return t.setFormat(n),!0;const[s,i,a]=H(t,r,l),c=Math.max(i.startRow+i.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),u=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 t=h;t<=c;t++)for(let o=g;o<=u;o++){const r=s[t][o].cell;if(f.has(r))continue;f.add(r),r.setFormat(n);const l=r.getChildren();for(let t=0;t<l.length;t++){const o=l[t];e.$isElementNode(o)&&!o.isInline()&&o.setFormat(n)}}return!0},e.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(l.registerCommand(e.CONTROLLED_TEXT_INSERTION_COMMAND,n=>{const o=e.$getSelection();if(!Re(o,t))return!1;if(q(o))return u.$clearHighlight(),!1;if(e.$isRangeSelection(o)){const r=e.$findMatchingParent(o.anchor.getNode(),e=>d(e));if(!d(r))return!1;if("string"==typeof n){const r=Ke(l,o,t);if(r)return De(r,t,[e.$createTextNode(n)]),!0}}return!1},e.COMMAND_PRIORITY_HIGH)),s&&u.listenersToRemove.add(l.registerCommand(e.KEY_TAB_COMMAND,n=>{const o=e.$getSelection();if(!e.$isRangeSelection(o)||!o.isCollapsed()||!Re(o,t))return!1;const r=Ee(o.anchor.getNode());return!(null===r||!t.is(Ae(r)))&&(Pe(n),function(t,n){const o="next"===n?"getNextSibling":"getPreviousSibling",r="next"===n?"getFirstChild":"getLastChild",l=t[o]();if(e.$isElementNode(l))return l.selectEnd();const s=e.$findMatchingParent(t,C);null===s&&g(247);for(let t=s[o]();C(t);t=t[o]()){const n=t[r]();if(e.$isElementNode(n))return n.selectEnd()}const i=e.$findMatchingParent(s,Ge);null===i&&g(248);"next"===n?i.selectNext():i.selectPrevious()}(r,n.shiftKey?"previous":"next"),!0)},e.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(l.registerCommand(e.FOCUS_COMMAND,e=>t.isSelected(),e.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(l.registerCommand(e.INSERT_PARAGRAPH_COMMAND,()=>{const n=e.$getSelection();if(!e.$isRangeSelection(n)||!n.isCollapsed()||!Re(n,t))return!1;const o=Ke(l,n,t);return!!o&&(De(o,t),!0)},e.COMMAND_PRIORITY_HIGH)),u}function ge(t,n){const o=e.$getSelection(),r=e.$getPreviousSelection(),l=t.getAndClearNextFocus();if(null!==l){const{tableKey:e,focusCell:n}=l,r=t.observers.get(e);r||g(335,e);const[s]=r;if(q(o)&&o.tableKey===s.tableNodeKey)return(n.x!==s.focusX||n.y!==s.focusY)&&(s.$setFocusCellForSelection(n),!0);if(null!==s.anchorCell&&null!==s.anchorCellNodeKey&&n.elem!==s.anchorCell.elem&&null!==s.tableSelection)return s.$setFocusCellForSelection(n,!0),!0}const s=t.getAndClearShouldCheckSelectionForTable();if(s&&e.$isRangeSelection(r)&&e.$isRangeSelection(o)&&o.isCollapsed()){const t=e.$getNodeByKey(s);if(Ge(t)){const n=o.anchor.getNode(),r=t.getFirstChild(),l=Ee(n);if(null!==l&&C(r)){const n=r.getFirstChild();if(d(n)&&t.is(e.$findMatchingParent(l,e=>e.is(t)||e.is(n))))return n.selectStart(),!0}}}q(o)&&function(t,n){const o=se(t),r=e.$getPreviousSelection();if(!n.is(r))return;const l=te(n.tableKey),s=e.getDOMSelection(o),i=s&&e.getDOMSelectionPoints(s,t.getRootElement());if(s&&i&&i.anchorNode&&i.focusNode){const o=e.$getNearestNodeFromDOMNode(i.focusNode),r=o&&!l.isParentOf(o),a=e.$getNearestNodeFromDOMNode(i.anchorNode),c=a&&l.isParentOf(a);if(r&&c&&s.rangeCount>0){const o=e.$createRangeSelectionFromDom(s,t);o&&(o.anchor.set(l.getKey(),n.isBackward()?l.getChildrenSize():0,"element"),s.removeAllRanges(),e.$setSelection(o))}}}(n,o),e.$isRangeSelection(o)&&function(t,n){const o=e.$getPreviousSelection(),{anchor:r,focus:l}=t,s=r.getNode(),i=l.getNode(),a=Ee(s),c=Ee(i),u=a?Ae(a):null,d=c?Ae(c):null,h=t.isBackward(),f=a&&c&&u&&d&&u.is(d),m=d&&(!u||u.isParentOf(d)),p=u&&(!d||d.isParentOf(u));if(m){const n=t.clone(),[o]=H(d,c,c),r=o[0][0].cell,l=o[o.length-1].at(-1).cell;n.focus.set(h?r.getKey():l.getKey(),h?0:l.getChildrenSize(),"element"),e.$setSelection(n)}else if(p){const n=t.clone(),[o]=H(u,a,a),r=o[0][0].cell,l=o[o.length-1].at(-1).cell;n.anchor.set(h?l.getKey():r.getKey(),h?l.getChildrenSize():0,"element"),e.$setSelection(n)}else if(f){const r=n.observers.get(u.getKey());r||g(335,u.getKey());const[l]=r;if(a.is(c)||(l.$setAnchorCellForSelection(Ie(l,a)),l.$setFocusCellForSelection(Ie(l,c),!0)),"touch"===l.pointerType&&l.isSelecting&&t.isCollapsed()&&e.$isRangeSelection(o)&&o.isCollapsed()){const e=Ee(o.anchor.getNode());e&&!e.is(c)&&(l.$setAnchorCellForSelection(Ie(l,e)),l.$setFocusCellForSelection(Ie(l,c),!0),l.pointerType=null)}}}(o,t);for(const[e,o]of t.$getTableNodesAndObservers())fe(n,e,o);return!1}function fe(t,n,o){const r=e.$getSelection(),l=e.$getPreviousSelection();r&&!r.is(l)&&(q(r)||q(l))&&o.tableSelection&&!o.tableSelection.is(l)&&(q(r)&&r.tableKey===o.tableNodeKey?o.$updateTableTableSelection(r):!q(r)&&q(l)&&l.tableKey===o.tableNodeKey&&o.$updateTableTableSelection(null)),o.hasHijackedSelectionStyles&&!n.isSelected()?function(e,t){t.$enableHighlightStyle(),Ne(t.table,t=>{const n=t.elem;t.highlighted=!1,Oe(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(t,o):!o.hasHijackedSelectionStyles&&n.isSelected()&&function(e,t){t.$disableHighlightStyle(),Ne(t.table,t=>{t.highlighted=!0,Me(e,t)})}(t,o)}function me(e){return e[ee]||null}function pe(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 Ce(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 _e(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=le(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 Se(e,t,n){const o=new Set(n?n.getNodes():[]);Ne(t,(t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=!0,Me(e,t)):(t.highlighted=!1,Oe(e,t),r.getAttribute("style")||r.removeAttribute("style"))})}function Ne(t,n){const{domRows:o}=t;for(let t=0;t<o.length;t++){const r=o[t];if(r)for(let o=0;o<r.length;o++){const l=r[o];if(!l)continue;const s=e.$getNearestNodeFromDOMNode(l.elem);null!==s&&n(l,s,{x:o,y:t})}}}const be=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case"backward":case"forward":return n!==(l?e.table.columns-1:0)?xe(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?xe(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?xe(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?xe(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function we(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 Te([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&&g(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&g(250,n,String(s)),i}function ye(e,t,n,o,r){const l=W(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=we(e,t);return null===n&&g(249,t.cell.getKey()),n}(l,n),[h,f]=Te(d);let m=l[h],p=l[f];"forward"===r?m+="maxColumn"===h?1:a:"backward"===r?m-="minColumn"===h?1:u:"down"===r?p+="maxRow"===f?1:i:"up"===r&&(p-="minRow"===f?1:c);const C=t[p];if(void 0===C)return!1;const _=C[m];if(void 0===_)return!1;const[S,N]=function(e,t,n){const o=W(e,t,n),r=we(o,t);if(r)return[$e(e,o,r),$e(e,o,Te(r))];const l=we(o,n);if(l)return[$e(e,o,Te(l)),$e(e,o,l)];const s=["minColumn","minRow"];return[$e(e,o,s),$e(e,o,Te(s))]}(t,n,_),b=Ie(e,S.cell),w=Ie(e,N.cell);return e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(w,!0),!0}function Re(t,n){if(e.$isRangeSelection(t)||q(t)){const e=n.isParentOf(t.anchor.getNode()),o=n.isParentOf(t.focus.getNode());return e&&o}return!1}function xe(e,t){t?e.selectStart():e.selectEnd()}function Me(t,n){const o=n.elem,r=t._config.theme;d(e.$getNearestNodeFromDOMNode(o))||g(131),e.addClassNamesToElement(o,r.tableCellSelected)}function Oe(t,n){const o=n.elem;d(e.$getNearestNodeFromDOMNode(o))||g(131);const r=t._config.theme;e.removeClassNamesFromElement(o,r.tableCellSelected)}function Ee(t){const n=e.$findMatchingParent(t,d);return d(n)?n:null}function Ae(t){const n=e.$findMatchingParent(t,Ge);return Ge(n)?n:null}function ve(t,n,o,r,l,s,i){const a=e.$caretFromPoint(o.focus,l?"previous":"next");if(e.$isExtendableTextPointCaret(a))return!1;let c=a;for(const t of e.$extendCaretToRange(a).iterNodeCarets("shadowRoot")){if(!e.$isSiblingCaret(t)||!e.$isElementNode(t.origin))return!1;c=t}const u=c.getParentAtCaret();if(!d(u))return!1;const h=u,g=function(t){for(const n of e.$extendCaretToRange(t).iterNodeCarets("root")){const{origin:o}=n;if(d(o)){if(e.$isChildCaret(n))return e.$getChildCaret(o,t.direction)}else if(!C(o))break}return null}(e.$getSiblingCaret(h,c.direction)),f=e.$findMatchingParent(h,Ge);if(!f||!f.is(s))return!1;const m=t.getElementByKey(h.getKey()),p=pe(m);if(!m||!p)return!1;const _=Ue(t,f);if(i.table=_,g)if("extend"===r){const e=pe(t.getElementByKey(g.origin.getKey()));if(!e)return!1;i.$setAnchorCellForSelection(p),i.$setFocusCellForSelection(e,!0)}else{const t=e.$normalizeCaret(g);e.$setPointFromCaret(o.anchor,t),e.$setPointFromCaret(o.focus,t)}else if("extend"===r)i.$setAnchorCellForSelection(p),i.$setFocusCellForSelection(p,!0);else{const t=function(t){const n=e.$getAdjacentChildCaret(t);return e.$isChildCaret(n)?e.$normalizeCaret(n):t}(e.$getSiblingCaret(f,a.direction));e.$setPointFromCaret(o.anchor,t),e.$setPointFromCaret(o.focus,t)}return Pe(n),!0}function Fe(t,n,o,r,l,s){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")}(t))return!1;const i=e.$getSelection();if(!Re(i,r)){if(e.$isRangeSelection(i)){if("backward"===o){if(i.focus.offset>0)return!1;const t=function(t){for(let n=t,o=t;null!==o;n=o,o=o.getParent())if(e.$isElementNode(o)){if(o!==n&&o.getFirstChild()!==n)return null;if(!o.isInline())return o}return null}(i.focus.getNode());if(!t)return!1;const o=t.getPreviousSibling();return!!Ge(o)&&(Pe(n),n.shiftKey?i.focus.set(o.getParentOrThrow().getKey(),o.getIndexWithinParent(),"element"):o.selectEnd(),!0)}if(n.shiftKey&&("up"===o||"down"===o)){const t=i.focus.getNode();if(!i.isCollapsed()&&("up"===o&&!i.isBackward()||"down"===o&&i.isBackward())){let l=e.$findMatchingParent(t,e=>Ge(e));if(d(l)&&(l=e.$findMatchingParent(l,Ge)),l!==r)return!1;if(!l)return!1;const s="down"===o?l.getNextSibling():l.getPreviousSibling();if(!s)return!1;let a=0;"up"===o&&e.$isElementNode(s)&&(a=s.getChildrenSize());let c=s;if("up"===o&&e.$isElementNode(s)){const t=s.getLastChild();c=t||s,a=e.$isTextNode(c)?c.getTextContentSize():0}const u=i.clone();return u.focus.set(c.getKey(),a,e.$isTextNode(c)?"text":"element"),e.$setSelection(u),Pe(n),!0}if(e.$isRootOrShadowRoot(t)){const e="up"===o?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==ie(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=L(e),[o]=L(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),a=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),c=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(a),l.$setFocusCellForSelection(c,!0),!0}}return!1}{let r=e.$findMatchingParent(t,t=>e.$isElementNode(t)&&!t.isInline());if(d(r)&&(r=e.$findMatchingParent(r,Ge)),!r)return!1;const s="down"===o?r.getNextSibling():r.getPreviousSibling();if(Ge(s)&&l.tableNodeKey===s.getKey()){const t=s.getFirstDescendant(),r=s.getLastDescendant();if(!t||!r)return!1;const[l]=L(t),[a]=L(r),c=i.clone();return c.focus.set(("up"===o?l:a).getKey(),"up"===o?0:a.getChildrenSize(),"element"),Pe(n),e.$setSelection(c),!0}}}}return"down"===o&&Be(t)&&s.setShouldCheckSelectionForTable(r.getKey()),!1}if(e.$isRangeSelection(i)){if("backward"===o||"forward"===o){return ve(t,n,i,n.shiftKey?"extend":"move","backward"===o,r,l)}if(i.isCollapsed()){const{anchor:a,focus:c}=i,u=e.$findMatchingParent(a.getNode(),d),h=e.$findMatchingParent(c.getNode(),d);if(!d(u)||!u.is(h))return!1;const g=Ae(u);if(g!==r&&null!=g){const e=le(g,t.getElementByKey(g.getKey()));if(null!=e)return l.table=_e(g,e),Fe(t,n,o,g,l,s)}const f=t.getElementByKey(u.__key),m=t.getElementByKey(a.key);if(null==m||null==f)return!1;let p;if("element"===a.type)p=m.getBoundingClientRect();else{const n=e.getDOMSelection(se(t));if(null===n||0===n.rangeCount)return!1;const o=e.getDOMSelectionRange(n,t.getRootElement());if(null===o)return!1;p=o.getBoundingClientRect()}const C="up"===o?u.getFirstChild():u.getLastChild();if(null==C)return!1;const _=t.getElementByKey(C.__key);if(null==_)return!1;const S=_.getBoundingClientRect();if("up"===o?S.top>p.top-p.height:p.bottom+p.height>S.bottom){Pe(n);const e=r.getCordsFromCellNode(u,l.table);if(!n.shiftKey)return be(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(q(i)){const{anchor:s,focus:a,tableKey:c}=i;if(c!==r.getKey())return!1;const u=e.$findMatchingParent(s.getNode(),d),h=e.$findMatchingParent(a.getNode(),d),[f]=i.getNodes();Ge(f)||g(251);const m=le(f,t.getElementByKey(f.getKey()));if(!d(u)||!d(h)||!Ge(f)||null==m)return!1;l.$updateTableTableSelection(i);const p=_e(f,m),C=r.getCordsFromCellNode(u,p),_=r.getDOMCellFromCordsOrThrow(C.x,C.y,p);if(l.$setAnchorCellForSelection(_),Pe(n),n.shiftKey){const[e,t,n]=H(r,u,h);return ye(l,e,t,n,o)}return h.selectEnd(),!0}return!1}function Pe(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function De(t,n,o){const r=e.$createParagraphNode();"first"===t?n.insertBefore(r):n.insertAfter(r),r.append(...o||[]),r.selectEnd()}function Ke(t,n,o){const r=o.getParent();if(!r)return;const l=e.getDOMSelection(se(t));if(!l)return;const s=e.getDOMSelectionPoints(l,t.getRootElement()).anchorNode,i=t.getElementByKey(r.getKey()),a=le(o,t.getElementByKey(o.getKey()));if(!s||!i||!a||!i.contains(s)||a.contains(s))return;const c=e.$findMatchingParent(n.anchor.getNode(),e=>d(e));if(!c)return;const u=e.$findMatchingParent(c,e=>Ge(e));if(!Ge(u)||!u.is(o))return;const[h,g]=H(o,c,c),f=h[0][0],m=h[h.length-1][h[0].length-1],{startRow:p,startColumn:C}=g,_=p===f.startRow&&C===f.startColumn,S=p===m.startRow&&C===m.startColumn;return _?"first":S?"last":void 0}function Ie(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function He(t,n,o){return ie(t,e.$getNearestNodeFromDOMNode(n,o))}function ke(t,n,o){const r=t.querySelector("colgroup");if(!r)return;const l=[];for(let t=0;t<n;t++){const n=e.$getDocument().createElement("col"),r=o&&o[t];r&&(n.style.width=`${r}px`),l.push(n)}r.replaceChildren(...l)}function Le(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 We=new WeakSet;function Be(t=e.$getEditor()){return We.has(t)}function ze(e,t){t?We.add(e):We.delete(e)}class Ye extends e.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 Ye(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:Xe,priority:1})}}static importJSON(e){return qe().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=re(e)?e:e.querySelector("table");return re(t)||g(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=e.$getDocument().createElement("table");this.__style&&e.setDOMStyleFromCSS(o.style,this.__style);const r=e.$getDocument().createElement("colgroup");if(o.appendChild(r),e.setDOMUnmanaged(r),e.addClassNamesToElement(o,t.theme.table),this.updateTableElement(null,o,t),Be(n)){const n=e.$getDocument().createElement("div"),r=t.theme.tableScrollableWrapper;return r?e.addClassNamesToElement(n,r):n.style.overflowX="auto",n.appendChild(o),this.updateTableWrapper(null,n,o,t),n}return o}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:"")&&e.setDOMStyleFromCSS(n.style,this.__style,t?t.__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);const r=t?t.getColumnCount():0,l=t?t.__colWidths:void 0;this.getColumnCount()===r&&this.getColWidths()===l||ke(n,this.getColumnCount(),this.getColWidths()),Le(n,o,this.getFormatType())}updateDOM(t,n,o){const r=le(this,n);return n===r===Be()||(l=n,e.isHTMLElement(l)&&"DIV"===l.nodeName&&this.updateTableWrapper(t,n,r,o),this.updateTableElement(t,r,o),!1);var l}scaleDOMColWidths(e,t){const n=this.getColWidths();if(!n)return;ke(le(this,e),this.getColumnCount(),n.map(e=>e*t))}exportDOM(t){const n=super.exportDOM(t),{element:o}=n;return{after:o=>{if(n.after&&(o=n.after(o)),!re(o)&&e.isHTMLElement(o)&&(o=o.querySelector("table")),!re(o))return null;Le(o,t._config,this.getFormatType());const[r]=k(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 t=e.$getDocument().createElement("tbody");for(const e of a)t.appendChild(e);o.append(t)}return o},element:!re(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=He(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(t,n,o){const r=this.getDOMCellFromCords(t,n,o);if(null==r)return null;const l=e.$getNearestNodeFromDOMNode(r.elem);return d(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(!C(e))return 0;let t=0;return e.getChildren().forEach(e=>{d(e)&&(t+=e.getColSpan())}),t}}function Ue(e,t){const n=e.getElementByKey(t.getKey());return null===n&&g(230),_e(t,n)}function Xe(e){const t=qe();e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0),e.hasAttribute("data-lexical-frozen-column")&&t.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&t.setFrozenRows(1);const n=e.querySelector(":scope > colgroup");if(n){let e=[];for(const t of n.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!l.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&t.setColWidths(e)}return{after:e=>o.$descendantsMatching(e,C),node:t}}function qe(){return e.$applyNodeReplacement(new Ye)}function Ge(e){return e instanceof Ye}function Je(t){C(t.getParent())?t.isEmpty()&&t.append(e.$createParagraphNode()):t.remove()}function je(e){Ge(e.getParent())?o.$unwrapAndFilterDescendants(e,d):e.remove()}function Ve(t){o.$unwrapAndFilterDescendants(t,C);const[n]=k(t,null,null),r=n.reduce((e,t)=>Math.max(e,t.length),0),l=t.getChildren();for(let t=0;t<n.length;++t){const o=l[t];if(!o)continue;C(o)||g(254,o.constructor.name,o.getType());const s=n[t].reduce((e,t)=>t?1+e:e,0);if(s!==r)for(let t=s;t<r;++t){const t=u();t.append(e.$createParagraphNode()),o.append(t)}}const s=t.getColWidths(),i=t.getColumnCount();if(s&&s.length!==i){let e;if(i<s.length)e=s.slice(0,i);else if(s.length>0){const t=s[s.length-1];e=[...s,...Array(i-s.length).fill(t)]}t.setColWidths(e)}}function Qe(t){if(t.detail<3||!e.isDOMNode(t.target))return!1;const n=e.$getNearestNodeFromDOMNode(t.target);if(null===n)return!1;const o=e.$findMatchingParent(n,t=>e.$isElementNode(t)&&!t.isInline());if(null===o)return!1;return!!d(o.getParent())&&(o.select(0),!0)}function Ze(){const t=e.$getSelection();if(!e.$isRangeSelection(t))return!1;const n=Ae(t.anchor.getNode());if(null===n)return!1;const o=e.$getRoot();if(!o.is(n.getParent())||1!==o.getChildrenSize())return!1;const[r]=k(n,null,null);if(0===r.length||0===r[0].length)return!1;const l=r[0][0];if(!l||!l.cell)return!1;const s=r[r.length-1],i=s[s.length-1];if(!i||!i.cell)return!1;const a=J(n,l.cell,i.cell);return e.$setSelection(a),!0}function et(e){return e.registerNodeTransform(i,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=L(e),[n]=H(t,e,e),r=n.length,l=n[0].length;let s=t.getFirstChild();C(s)||g(175);const i=[];for(let e=0;e<r;e++){0!==e&&(s=s.getNextSibling(),C(s)||g(175));let t=null;for(let r=0;r<l;r++){const l=n[e][r],a=l.cell;if(l.startRow===e&&l.startColumn===r)t=a,i.push(a);else if(a.getColSpan()>1||a.getRowSpan()>1){d(a)||g(176);const e=u(a.__headerState);null!==t?t.insertAfter(e):o.$insertFirst(s,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}})}function tt(t,n=!0){const o=new Q,r=(e,r,l)=>{const s=le(e,l),i=he(e,s,t,n,o);o.observers.set(r,[i,s])};return e.mergeRegister(de(t,o),t.registerCommand(e.SELECTION_CHANGE_COMMAND,()=>ge(o,t),e.COMMAND_PRIORITY_HIGH),t.registerMutationListener(Ye,e=>{t.read("latest",()=>{for(const[t,n]of e){const e=o.observers.get(t);if("created"===n||"updated"===n){const{tableNode:n,tableElement:l}=V(t);void 0===e?r(n,t,l):l!==e[1]&&(o.removeObserver(t),r(n,t,l))}else"destroyed"===n&&o.removeObserver(t)}})},{skipInitialization:!1}),()=>{o.removeAllObservers()})}function nt(n,r){n.hasNodes([Ye])||g(255);const{hasNestedTables:l=t.signal(!1)}=r??{};return e.mergeRegister(n.registerCommand(h,t=>function({rows:t,columns:n,includeHeaders:r},l){const s=e.$getSelection()||e.$getPreviousSelection();if(!s||!e.$isRangeSelection(s))return!1;if(!l&&Ae(s.anchor.getNode()))return!1;const i=_(Number(t),Number(n),r);o.$insertNodeToNearestRoot(i);const a=i.getFirstDescendant();return e.$isTextNode(a)&&a.select(),!0}(t,l.peek()),e.COMMAND_PRIORITY_EDITOR),n.registerCommand(e.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(t,r)=>n===r&&function(t,n){const{nodes:r,selection:l}=t;if(!r.some(e=>Ge(e)||o.$dfs(e).some(e=>Ge(e.node)))){if(q(l)){let t="",n=!1;for(const o of r){const r=e.$isElementNode(o)&&!o.isInline();t.length>0&&(r||n)&&(t+="\n"),t+=o.getTextContent(),n=r}return l.insertRawText(t),!0}return!1}const s=q(l),i=e.$isRangeSelection(l);if(!(i&&null!==e.$findMatchingParent(l.anchor.getNode(),e=>d(e))&&null!==e.$findMatchingParent(l.focus.getNode(),e=>d(e))||s))return!1;if(1===r.length&&Ge(r[0]))return Y(r[0],l);if(i&&n.peek()&&!function(t){if(q(t)&&!t.focus.getNode().is(t.anchor.getNode()))return!0;if(e.$isRangeSelection(t)&&d(t.anchor.getNode())&&!t.anchor.getNode().is(t.focus.getNode()))return!0;return!1}(l))return!1;return!0}(t,l),e.COMMAND_PRIORITY_EDITOR),n.registerCommand(e.SELECT_ALL_COMMAND,Ze,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.CLICK_COMMAND,Qe,e.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(Ye,Ve),n.registerNodeTransform(f,je),n.registerNodeTransform(i,Je))}const ot={$accepts:C,$packageRun:e=>e.every(d)?[p().splice(0,0,e)]:[],name:"TableSchema"},rt={$accepts:d,name:"TableRowSchema"},lt=[/* @__PURE__ */n.defineImportRule({$import:(e,t)=>{const n=qe();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 r=t.querySelector(":scope > colgroup");if(r){let e=[];for(const t of r.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!l.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&n.setColWidths(e)}return[n.splice(0,0,o.$descendantsMatching(e.$importChildren(t),C))]},match:n.sel.tag("table"),name:"@lexical/table/table"}),/* @__PURE__ */n.defineImportRule({$import:(e,t)=>[p(l.test(t.style.height)?parseFloat(t.style.height):void 0).splice(0,0,o.$descendantsMatching(e.$importChildren(t),d))],match:n.sel.tag("tr"),name:"@lexical/table/tr"}),/* @__PURE__ */n.defineImportRule({$import:(t,o)=>{const r="TH"===o.nodeName,i=l.test(o.style.width)?parseFloat(o.style.width):void 0;let a=s.NO_STATUS;if(r){const t=o.getAttribute("scope");if("col"===t)a=s.COLUMN;else if("row"===t)a=s.ROW;else{const t=o.parentElement,n=e.isHTMLTableRowElement(t)&&(t.parentElement&&"THEAD"===t.parentElement.nodeName||0===t.rowIndex),r=0===o.cellIndex;n&&(a|=s.ROW),r&&(a|=s.COLUMN),a===s.NO_STATUS&&(a=s.ROW)}}const c=u(a,o.colSpan,i);c.__rowSpan=o.rowSpan;const d=o.style.backgroundColor;""!==d&&(c.__backgroundColor=d);const h=o.style.verticalAlign;(function(e){return"middle"===e||"bottom"===e})(h)&&(c.__verticalAlign=h);const g=t.get(n.ImportTextFormat),f=g|function(t){let n=0;const o=t.fontWeight;"700"!==o&&"bold"!==o||(n|=e.IS_BOLD),"italic"===t.fontStyle&&(n|=e.IS_ITALIC);const r=(t.textDecoration||"").split(" ");return r.includes("underline")&&(n|=e.IS_UNDERLINE),r.includes("line-through")&&(n|=e.IS_STRIKETHROUGH),n}(o.style),m=t.get(n.ImportTextStyle),p=o.style.color,C=p?{...m,color:p}:m,_=[];f!==g&&_.push(n.contextValue(n.ImportTextFormat,f)),C!==m&&_.push(n.contextValue(n.ImportTextStyle,C));const S=function(t){const n=[];let o=null;const r=()=>{if(null!==o){const t=o.getFirstChild();e.$isLineBreakNode(t)&&1===o.getChildrenSize()&&t.remove()}};for(const l of t)e.$isInlineElementOrDecoratorNode(l)||e.$isTextNode(l)||e.$isLineBreakNode(l)?null!==o?o.append(l):(o=e.$createParagraphNode().append(l),n.push(o)):(r(),o=null,n.push(l));return r(),0===n.length&&n.push(e.$createParagraphNode()),n}(t.$importChildren(o,{context:_})),N=r?S:n.$propagateTextAlignToBlockChildren(S,o);return[c.splice(0,0,N)]},match:n.sel.tag("td","th"),name:"@lexical/table/cell"})],st=/* @__PURE__ */e.defineExtension({build:(e,n,o)=>t.namedSignals(n),config:/* @__PURE__ */e.safeCast({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasNestedTables:!1,hasTabHandler:!0}),dependencies:[n.CoreImportExtension,/* @__PURE__ */e.configExtension(n.DOMImportExtension,{rules:lt})],name:"@lexical/table/Table",nodes:()=>[Ye,f,i],register(n,o,r){const l=r.getOutput();return e.mergeRegister(t.effect(()=>{const t=l.hasHorizontalScroll.value;Be(n)!==t&&(ze(n,t),n.update(e.$fullReconcile))}),nt(n,l),t.effect(()=>tt(n,l.hasTabHandler.value)),t.effect(()=>l.hasCellMerge.value?void 0:et(n)),t.effect(()=>l.hasCellBackgroundColor.value?void 0:n.registerNodeTransform(i,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}}),it=/* @__PURE__ */e.defineExtension({dependencies:[st],name:"@lexical/table/Import"});exports.$computeTableMap=H,exports.$computeTableMapSkipCellCheck=k,exports.$createTableCellNode=u,exports.$createTableNode=qe,exports.$createTableNodeWithDimensions=_,exports.$createTableRowNode=p,exports.$createTableSelection=G,exports.$createTableSelectionFrom=J,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=A,exports.$deleteTableColumn__EXPERIMENTAL=v,exports.$deleteTableRowAtSelection=O,exports.$deleteTableRow__EXPERIMENTAL=E,exports.$findCellNode=Ee,exports.$findTableNode=Ae,exports.$getElementForTableNode=Ue,exports.$getNodeTriplet=L,exports.$getTableAndElementByKey=V,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,e=>d(e));return d(n)?n:null},exports.$getTableCellNodeRect=z,exports.$getTableColumnIndexFromTableCellNode=function(e){return S(e).getChildren().findIndex(t=>t.is(e))},exports.$getTableNodeFromLexicalNodeOrThrow=N,exports.$getTableRowIndexFromTableCellNode=function(e){const t=S(e);return N(t).getChildren().findIndex(e=>e.is(t))},exports.$getTableRowNodeFromTableCellNodeOrThrow=S,exports.$insertTableColumn=function(t,n,o=!0,r,l){const i=t.getChildren(),a=[];for(let t=0;t<i.length;t++){const o=i[t];if(C(o))for(let t=0;t<r;t++){const t=o.getChildren();if(n>=t.length||n<0)throw new Error("Table column target index out of range");const r=t[n];d(r)||g(12);const{left:i,right:c}=b(r,l);let h=s.NO_STATUS;(i&&i.hasHeaderState(s.ROW)||c&&c.hasHeaderState(s.ROW))&&(h|=s.ROW);const f=u(h);f.append(e.$createParagraphNode()),a.push({newTableCell:f,targetCell:r})}}return a.forEach(({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)}),t},exports.$insertTableColumnAtNode=M,exports.$insertTableColumnAtSelection=R,exports.$insertTableColumn__EXPERIMENTAL=x,exports.$insertTableRow=function(t,n,o=!0,r,l){const i=t.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 t=0;t<r;t++){const t=a.getChildren(),n=t.length,r=p();for(let o=0;o<n;o++){const n=t[o];d(n)||g(12);const{above:i,below:a}=b(n,l);let c=s.NO_STATUS;const h=i&&i.getWidth()||a&&a.getWidth()||void 0;(i&&i.hasHeaderState(s.COLUMN)||a&&a.hasHeaderState(s.COLUMN))&&(c|=s.COLUMN);const f=u(c,1,h);f.append(e.$createParagraphNode()),r.append(f)}o?a.insertAfter(r):a.insertBefore(r)}return t},exports.$insertTableRowAtNode=y,exports.$insertTableRowAtSelection=T,exports.$insertTableRow__EXPERIMENTAL=$,exports.$isScrollableTablesActive=Be,exports.$isSimpleTable=B,exports.$isTableCellNode=d,exports.$isTableNode=Ge,exports.$isTableRowNode=C,exports.$isTableSelection=q,exports.$mergeCells=D,exports.$moveTableColumn=function(e,t,n){if(t===n)return;const o=e.getColumnCount();if(t<0||t>=o||n<0||n>=o)return;if(!B(e))return;e.getChildren().filter(C).forEach(e=>{const o=e.getChildren(),[r]=o.splice(t,1);o.splice(n,0,r),e.splice(0,o.length,o)});const r=e.getColWidths();if(r&&r.length===o){const o=[...r],[l]=o.splice(t,1);o.splice(n,0,l),e.setColWidths(o)}},exports.$moveTableRow=function(e,t,n){if(t===n)return;const o=e.getChildren().filter(C),r=o.length;if(t<0||t>=r||n<0||n>=r)return;if(!B(e))return;const l=o[t],s=o[n];n>t?s.insertAfter(l):s.insertBefore(l)},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.$setTableColumnIsHeader=function(e,t,n){const[o]=k(e,null,null);o.length>0&&t>=0&&t<o[0].length||g(397,String(t));const r=n?s.COLUMN:s.NO_STATUS,l=new Set;for(let e=0;e<o.length;e++){const n=o[e][t];null!=n&&(l.has(n.cell)||(l.add(n.cell),n.cell.setHeaderStyles(r,s.COLUMN)))}},exports.$setTableRowIsHeader=function(e,t,n){const[o]=k(e,null,null);t>=0&&t<o.length||g(396,String(t));const r=o[t],l=n?s.ROW:s.NO_STATUS,i=new Set;for(let e=0;e<r.length;e++){const t=r[e];null!=t&&(i.has(t.cell)||(i.add(t.cell),t.cell.setHeaderStyles(l,s.ROW)))}},exports.$unmergeCell=function(){const t=e.$getSelection();e.$isRangeSelection(t)||q(t)||g(188);const n=t.anchor.getNode(),o=e.$findMatchingParent(n,d);return d(o)||g(148),I(o)},exports.$unmergeCellNode=I,exports.INSERT_TABLE_COMMAND=h,exports.TableCellHeaderStates=s,exports.TableCellNode=i,exports.TableExtension=st,exports.TableImportExtension=it,exports.TableImportRules=lt,exports.TableNode=Ye,exports.TableObserver=Z,exports.TableRowNode=f,exports.TableRowSchema=rt,exports.TableSchema=ot,exports.applyTableHandlers=he,exports.getDOMCellFromTarget=pe,exports.getTableElement=le,exports.getTableObserverFromTableElement=me,exports.registerTableCellUnmergeTransform=et,exports.registerTablePlugin=nt,exports.registerTableSelectionObserver=tt,exports.setScrollableTablesActive=ze;
|
|
9
|
+
"use strict";var e=require("lexical"),t=require("@lexical/extension"),n=require("@lexical/html"),o=require("@lexical/utils"),l=require("@lexical/clipboard");const r=/^(\d+(?:\.\d+)?)px$/,s={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class i extends e.ElementNode{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;$config(){return this.config("tablecell",{extends:e.ElementNode,importDOM:{td:()=>({conversion:c,priority:0}),th:()=>({conversion:c,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign,this.__colSpan=e.__colSpan,this.__headerState=e.__headerState,this.__width=e.__width}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=s.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=e.$getDocument().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),a(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),e.addClassNamesToElement(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(t){const n=super.exportDOM(t);if(e.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(),...a(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=s.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!==s.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 a(e){return"middle"===e||"bottom"===e}function c(t){const n=t,o=t.nodeName.toLowerCase();let l;r.test(n.style.width)&&(l=parseFloat(n.style.width));let i=s.NO_STATUS;if("th"===o){const t=n.getAttribute("scope");if("col"===t)i=s.COLUMN;else if("row"===t)i=s.ROW;else{const t=n.parentElement,o=e.isHTMLElement(t)&&"tr"===t.nodeName.toLowerCase()&&e.isHTMLElement(t.parentElement)&&("thead"===t.parentElement.nodeName.toLowerCase()||0===t.rowIndex),l=0===n.cellIndex;o&&(i|=s.ROW),l&&(i|=s.COLUMN),i===s.NO_STATUS&&(i=s.ROW)}}const c=u(i,n.colSpan,l);c.__rowSpan=n.rowSpan;const d=n.style.backgroundColor;""!==d&&(c.__backgroundColor=d);const h=n.style.verticalAlign;a(h)&&(c.__verticalAlign=h);const g=n.style,f=(g&&g.textDecoration||"").split(" "),m="700"===g.fontWeight||"bold"===g.fontWeight,p=f.includes("line-through"),C="italic"===g.fontStyle,S=f.includes("underline"),_=g.color;return{after:t=>{const n=[];let o=null;const l=()=>{if(o){const t=o.getFirstChild();e.$isLineBreakNode(t)&&1===o.getChildrenSize()&&t.remove()}};for(const r of t)if(e.$isInlineElementOrDecoratorNode(r)||e.$isTextNode(r)||e.$isLineBreakNode(r)){if(e.$isTextNode(r)&&(m&&r.toggleFormat("bold"),p&&r.toggleFormat("strikethrough"),C&&r.toggleFormat("italic"),S&&r.toggleFormat("underline"),_)){const e=r.getStyle();e.includes("color:")||r.setStyle(e+`color: ${_};`)}o?o.append(r):(o=e.$createParagraphNode().append(r),n.push(o))}else n.push(r),l(),o=null;return l(),0===n.length&&n.push(e.$createParagraphNode()),n},node:c}}function u(t=s.NO_STATUS,n=1,o){return e.$applyNodeReplacement(new i(t,n,o))}function d(e){return e instanceof i}const h=/* @__PURE__ */e.createCommand("INSERT_TABLE_COMMAND");function g(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 f extends e.ElementNode{__height;$config(){return this.config("tablerow",{extends:e.ElementNode,importDOM:{tr:()=>({conversion:m,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__height=e.__height}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e=void 0,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=e.$getDocument().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 m(e){const t=e;let n;return r.test(t.style.height)&&(n=parseFloat(t.style.height)),{after:e=>o.$descendantsMatching(e,d),node:p(n)}}function p(t){return e.$applyNodeReplacement(new f(t))}function C(e){return e instanceof f}function S(t,n,o=!0){const l=Qe();for(let r=0;r<t;r++){const t=p();for(let l=0;l<n;l++){let n=s.NO_STATUS;"object"==typeof o?(0===r&&o.rows&&(n|=s.ROW),0===l&&o.columns&&(n|=s.COLUMN)):o&&(0===r&&(n|=s.ROW),0===l&&(n|=s.COLUMN));const i=u(n),a=e.$createParagraphNode();a.append(e.$createTextNode()),i.append(a),t.append(i)}l.append(t)}return l}function _(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=>Ze(e));if(Ze(n))return n;throw new Error("Expected table cell to be inside of table.")}function N(e,t){const n=b(e),{x:o,y:l}=n.getCordsFromCellNode(e,t);return{above:n.getCellNodeFromCords(o,l-1,t),below:n.getCellNodeFromCords(o,l+1,t),left:n.getCellNodeFromCords(o-1,l,t),right:n.getCellNodeFromCords(o+1,l,t)}}const y=(e,t)=>e===s.BOTH||e===t?t:s.NO_STATUS;function w(t=!0){const n=e.$getSelection();e.$isRangeSelection(n)||q(n)||g(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[r]=H(o),[s,,i]=H(l),[,a,c]=L(i,s,r),{startRow:u}=c,{startRow:d}=a;return t?$(u+r.__rowSpan>d+s.__rowSpan?r:s,!0):$(d<u?s:r,!1)}const T=w;function $(t,n=!0){const[,,o]=H(t),[l,r]=L(o,t,t),i=l[0].length,{startRow:a}=r;let c=null;if(n){const n=a+t.__rowSpan-1,r=l[n],d=p();for(let t=0;t<i;t++){const{cell:o,startRow:l}=r[t];if(l+o.__rowSpan-1<=n){const n=r[t].cell.__headerState,o=y(n,s.COLUMN);d.append(u(o).append(e.$createParagraphNode()))}else o.setRowSpan(o.__rowSpan+1)}const h=o.getChildAtIndex(n);C(h)||g(256),h.insertAfter(d),c=d}else{const t=a,n=l[t],r=p();for(let o=0;o<i;o++){const{cell:l,startRow:i}=n[o];if(i===t){const t=n[o].cell.__headerState,l=y(t,s.COLUMN);r.append(u(l).append(e.$createParagraphNode()))}else l.setRowSpan(l.__rowSpan+1)}const d=o.getChildAtIndex(t);C(d)||g(257),d.insertBefore(r),c=r}return c}function x(t=!0){const n=e.$getSelection();e.$isRangeSelection(n)||q(n)||g(188);const o=n.anchor.getNode(),l=n.focus.getNode(),[r]=H(o),[s,,i]=H(l),[,a,c]=L(i,s,r),{startColumn:u}=c,{startColumn:d}=a;return t?E(u+r.__colSpan>d+s.__colSpan?r:s,!0):E(d<u?s:r,!1)}const R=x;function E(t,n=!0,o=!0){const[,,l]=H(t),[r,i]=L(l,t,t),a=r.length,{startColumn:c}=i,d=n?c+t.__colSpan-1:c-1,h=l.getFirstChild();C(h)||g(120);let f=null;function m(t=s.NO_STATUS){const n=u(t).append(e.$createParagraphNode());return null===f&&(f=n),n}let p=h;e:for(let e=0;e<a;e++){if(0!==e){const e=p.getNextSibling();C(e)||g(121),p=e}const t=r[e],n=t[d<0?0:d].cell.__headerState,o=y(n,s.ROW);if(d<0){D(p,m(o));continue}const{cell:l,startColumn:i,startRow:a}=t[d];if(i+l.__colSpan-1<=d){let n=l,r=a,s=d;for(;r!==e&&n.__rowSpan>1;){if(s-=l.__colSpan,!(s>=0)){p.append(m(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o}}n.insertAfter(m(o))}else l.setColSpan(l.__colSpan+1)}null!==f&&o&&F(f);const S=l.getColWidths();if(S){const e=[...S],t=d<0?0:d,n=e[t];e.splice(t,0,n),l.setColWidths(e)}return f}function M(){const t=e.$getSelection();e.$isRangeSelection(t)||q(t)||g(188);const[n,o]=t.isBackward()?[t.focus.getNode(),t.anchor.getNode()]:[t.anchor.getNode(),t.focus.getNode()],[l,,r]=H(n),[s]=H(o),[i,a,c]=L(r,l,s),{startRow:u}=a,{startRow:d}=c,h=d+s.__rowSpan-1;if(i.length===h-u+1)return void r.remove();const f=i[0].length,m=i[h+1],p=r.getChildAtIndex(h+1);for(let e=h;e>=u;e--){for(let t=f-1;t>=0;t--){const{cell:n,startRow:o,startColumn:l}=i[e][t];if(l===t){if(o<u||o+n.__rowSpan-1>h){const e=Math.max(o,u),t=Math.min(n.__rowSpan+o-1,h),l=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-l)}if(o>=u&&o+n.__rowSpan-1>h&&e===h){C(p)||g(387);let o=null;for(let n=0;n<t;n++){const t=m[n],l=t.cell;t.startRow===e+1&&(o=l),l.__colSpan>1&&(n+=l.__colSpan-1)}null===o?D(p,n):o.insertAfter(n)}}}const t=r.getChildAtIndex(e);C(t)||g(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];F(e)}else{const e=i[u-1],{cell:t}=e[0];F(t)}}const O=M;function v(){const t=e.$getSelection();e.$isRangeSelection(t)||q(t)||g(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[l,,r]=H(n),[s]=H(o),[i,a,c]=L(r,l,s),{startColumn:u}=a,{startRow:d,startColumn:h}=c,f=Math.min(u,h),m=Math.max(u+l.__colSpan-1,h+s.__colSpan-1),p=m-f+1;if(i[0].length===m-f+1)return r.selectPrevious(),void r.remove();const C=i.length;for(let e=0;e<C;e++)for(let t=f;t<=m;t++){const{cell:n,startColumn:o}=i[e][t];if(o<f){if(t===f){const e=f-o;n.setColSpan(n.__colSpan-Math.min(p,n.__colSpan-e))}}else if(o+n.__colSpan-1>m){if(t===m){const e=m-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const S=i[d],_=u>h?S[u+l.__colSpan]:S[h+s.__colSpan];if(void 0!==_){const{cell:e}=_;F(e)}else{const e=h<u?S[h-1]:S[u-1],{cell:t}=e;F(t)}const b=r.getColWidths();if(b){const e=[...b];e.splice(f,p),r.setColWidths(e)}}const A=v;function F(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function D(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function P(t){if(0===t.length)return null;const n=b(t[0]),[o]=k(n,null,null);let l=1/0,r=-1/0,s=1/0,i=-1/0;const a=new Set;for(const e of o)for(const n of e){if(!n||!n.cell)continue;const e=n.cell.getKey();if(!a.has(e)&&t.some(e=>e.is(n.cell))){a.add(e);const t=n.startRow,o=n.startColumn,c=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;l=Math.min(l,t),r=Math.max(r,t+c-1),s=Math.min(s,o),i=Math.max(i,o+u-1)}}if(l===1/0||s===1/0)return null;const c=r-l+1,u=i-s+1,d=o[l][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=l;e<=r;e++)for(let t=s;t<=i;t++){const n=o[e][t];if(!n.cell)continue;const l=n.cell,r=l.getKey();if(!g.has(r)){g.add(r);K(l)||h.append(...l.getChildren()),l.remove()}}return 0===h.getChildrenSize()&&h.append(e.$createParagraphNode()),h}function K(t){if(1!==t.getChildrenSize())return!1;const n=t.getFirstChildOrThrow();return!(!e.$isParagraphNode(n)||!n.isEmpty())}function I(t){const[n,o,l]=H(t),r=n.__colSpan,i=n.__rowSpan;if(1===r&&1===i)return;const[a,c]=L(l,n,n),{startColumn:d,startRow:h}=c,f=n.__headerState&s.COLUMN,m=Array.from({length:r},(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&s.ROW,S=Array.from({length:i},(e,t)=>{let n=p;for(let e=0;0!==n&&e<a[0].length;e++)n&=a[t+h][e].cell.__headerState;return n});if(r>1){for(let t=1;t<r;t++)n.insertAfter(u(m[t]|S[0]).append(e.$createParagraphNode()));n.setColSpan(1)}if(i>1){let t;for(let n=1;n<i;n++){const l=h+n,s=a[l];t=(t||o).getNextSibling(),C(t)||g(125);let i=null;for(let e=0;e<d;e++){const t=s[e],n=t.cell;t.startRow===l&&(i=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===i)for(let o=r-1;o>=0;o--)D(t,u(m[o]|S[n]).append(e.$createParagraphNode()));else for(let t=r-1;t>=0;t--)i.insertAfter(u(m[t]|S[n]).append(e.$createParagraphNode()))}n.setRowSpan(1)}}function L(e,t,n){const[o,l,r]=k(e,t,n);return null===l&&g(207),null===r&&g(208),[o,l,r]}function k(e,t,n){const o=[];let l=null,r=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)||g(209);const a=s(e);for(let c=o.getFirstChild(),u=0;null!=c;c=c.getNextSibling()){for(d(c)||g(147);void 0!==a[u];)u++;const o={cell:c,startColumn:u,startRow:e},{__rowSpan:h,__colSpan:f}=c;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<f;e++)n[u+e]=o}null!==t&&null===l&&t.is(c)&&(l=o),null!==n&&null===r&&n.is(c)&&(r=o)}}return[o,l,r]}function H(t){let n;if(t instanceof i)n=t;else if("__type"in t){const o=e.$findMatchingParent(t,d);d(o)||g(148),n=o}else{const o=e.$findMatchingParent(t.getNode(),d);d(o)||g(148),n=o}const o=n.getParent();C(o)||g(149);const l=o.getParent();return Ze(l)||g(210),[n,o,l]}function W(e,t,n){let o,l=Math.min(t.startColumn,n.startColumn),r=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>=l,h=a.startRow<=i&&u>=r;if(d&&h){const e=Math.min(l,a.startColumn),t=Math.max(s,c),n=Math.min(r,a.startRow),d=Math.max(i,u);e===l&&t===s&&n===r&&d===i||(l=e,s=t,r=n,i=d,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:l,minRow:r}}function B(e){const t=e.getChildren();let n=null;for(const e of t){if(!C(e))return!1;if(null===n&&(n=e.getChildrenSize()),e.getChildrenSize()!==n)return!1;const t=e.getChildren();for(const e of t)if(!d(e)||1!==e.getRowSpan()||1!==e.getColSpan())return!1}return(n||0)>0}function z(e){const[t,,n]=H(e),o=n.getChildren().filter(C),l=o.length,r=o[0].getChildren().length,s=new Array(l);for(let e=0;e<l;e++)s[e]=new Array(r);for(let e=0;e<l;e++){const n=o[e].getChildren().filter(d);let l=0;for(let o=0;o<n.length;o++){for(;s[e][l];)l++;const r=n[o],i=r.__rowSpan||1,a=r.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<a;n++)s[e+t][l+n]=r;if(t===r)return{colSpan:a,columnIndex:l,rowIndex:e,rowSpan:i};l+=a}}return null}function Y(t,n){const o=n.getStartEndPoints(),l=q(n);if(null===o)return!1;const[r,s]=o,[i,a,c]=H(r),u=e.$findMatchingParent(s.getNode(),e=>d(e));if(!(d(i)&&d(u)&&C(a)&&Ze(c)))return!1;const[h,g,f]=L(c,i,u),[m]=k(t,null,null),p=h.length,S=p>0?h[0].length:0;let _=g.startRow,b=g.startColumn,N=m.length,y=N>0?m[0].length:0;if(l){const e=W(h,g,f),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;_=e.minRow,b=e.minColumn,N=Math.min(N,t),y=Math.min(y,n)}let w=!1;const T=Math.min(p,_+N)-1,x=Math.min(S,b+y)-1,R=new Set;for(let e=_;e<=T;e++)for(let t=b;t<=x;t++){const n=h[e][t];R.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(I(n.cell),R.add(n.cell.getKey()),w=!0))}let[M]=k(c.getWritable(),null,null);const O=N-p+_;for(let e=0;e<O;e++){$(M[p-1][0].cell)}const v=y-S+b;for(let e=0;e<v;e++){E(M[0][S-1].cell,!0,!1)}[M]=k(c.getWritable(),null,null);for(let t=_;t<_+N;t++)for(let n=b;n<b+y;n++){const o=t-_,l=n-b,r=m[o][l];if(r.startRow!==o||r.startColumn!==l)continue;const s=r.cell;if(1!==s.__rowSpan||1!==s.__colSpan){const e=[],o=Math.min(t+s.__rowSpan,_+N)-1,l=Math.min(n+s.__colSpan,b+y)-1;for(let r=t;r<=o;r++)for(let t=n;t<=l;t++){const n=M[r][t];e.push(n.cell)}P(e),w=!0}const{cell:i}=M[t][n],a=s.getBackgroundColor();null!=a&&i.setBackgroundColor(a);const c=i.getChildren();s.getChildren().forEach(t=>{if(e.$isTextNode(t)){e.$createParagraphNode().append(t),i.append(t)}else i.append(t)}),c.forEach(e=>e.remove())}if(l&&w){const[e]=k(c.getWritable(),null,null);e[g.startRow][g.startColumn].cell.selectEnd()}return!0}function U(t){const[[n,o,l,r],[s,i,a,c]]=["anchor","focus"].map(n=>{const o=t[n].getNode(),l=e.$findMatchingParent(o,d);d(l)||g(238,n,o.getKey(),o.getType());const r=l.getParent();C(r)||g(239,n);const s=r.getParent();return Ze(s)||g(240,n),[o,l,r,s]});return r.is(c)||g(241),{anchorCell:o,anchorNode:n,anchorRow:l,anchorTable:r,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 t=e.$getNodeByKey(this.tableKey),n=e.$getNodeByKey(this.anchor.key),o=e.$getNodeByKey(this.focus.key);return null!==t&&null!==n&&null!==o}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return q(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,e.$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),e.$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(t){if(""===t)return;const n=(t.endsWith("\n")?t.slice(0,-1):t).split("\n").map(e=>e.split("\t")),o=Qe();for(const t of n){const n=p();for(const o of t){const t=u(s.NO_STATUS),l=e.$createParagraphNode();o&&l.append(e.$createTextNode(o)),t.append(l),n.append(t)}o.append(n)}const{anchorCell:l}=U(this);Y(o,l.select(0,l.getChildrenSize()))}insertText(){}hasFormat(t){let n=0;this.getNodes().filter(d).forEach(t=>{const o=t.getFirstChild();e.$isParagraphNode(o)&&(n|=o.getTextFormat())});const o=e.TEXT_TYPE_TO_FORMAT[t];return 0!==(n&o)}insertNodes(t){const n=this.focus.getNode();e.$isElementNode(n)||g(151);e.$normalizeSelection__EXPERIMENTAL(n.select(0,n.getChildrenSize())).insertNodes(t)}getShape(){const{anchorCell:e,focusCell:t}=U(this),n=z(e);null===n&&g(153);const o=z(t);null===o&&g(155);const l=Math.min(n.columnIndex,o.columnIndex),r=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(l,r),fromY:Math.min(s,i),toX:Math.max(l,r),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return[];const t=this._cachedNodes;if(null!==t)return t;const{anchorTable:n,anchorCell:o,focusCell:l}=U(this),r=l.getParents()[1];if(r!==n){if(n.isParentOf(l)){const e=r.getParent();null==e&&g(159),this.set(this.tableKey,l.getKey(),e.getKey())}else{const e=n.getParent();null==e&&g(158),this.set(this.tableKey,e.getKey(),l.getKey())}return this.getNodes()}const[s,i,a]=L(n,o,l),{minColumn:c,maxColumn:u,minRow:d,maxRow:h}=W(s,i,a),f=new Map([[n.getKey(),n]]);let m=null;for(let e=d;e<=h;e++)for(let t=c;t<=u;t++){const{cell:n}=s[e][t],o=n.getParent();C(o)||g(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 e.isCurrentlyReadOnlyMode()||(this._cachedNodes=p),p}getTextContent(){const e=this.getNodes().filter(e=>d(e));let t="";for(let n=0;n<e.length;n++){const o=e[n],l=o.__parent,r=(e[n+1]||{}).__parent;t+=o.getTextContent()+(r!==l?"\n":"\t")}return t}}function q(e){return e instanceof X}function G(t,n,o){t.getKey(),n.getKey(),o.getKey();const l=e.$getSelection(),r=q(l)?l.clone():new X("root",e.$createPoint("root",0,"element"),e.$createPoint("root",0,"element"));return r.set(t.getKey(),n.getKey(),o.getKey()),r}function J(t,n){const o=[[t]];for(let t=o.at(-1);void 0!==t&&o.length>0;t=o.at(-1)){const l=t.pop();void 0===l?o.pop():!1!==n(l)&&e.$isElementNode(l)&&o.push(l.getChildren())}}function j(t,n=e.$getEditor()){const o=e.$getNodeByKey(t);Ze(o)||g(231,t);const l=le(o,n.getElementByKey(t));return null===l&&g(232,t),{tableElement:l,tableNode:o}}class V{observers;nextFocus;shouldCheckSelectionForTable;constructor(){this.observers=new Map,this.nextFocus=null,this.shouldCheckSelectionForTable=null}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}setShouldCheckSelectionForTable(e){this.shouldCheckSelectionForTable=e}getAndClearShouldCheckSelectionForTable(){const{shouldCheckSelectionForTable:e}=this;return e?(this.shouldCheckSelectionForTable=null,e):null}removeObserver(e){const t=this.observers.get(e);return void 0!==t&&(t[0].removeListeners(),this.observers.delete(e),!0)}removeAllObservers(){for(const e of Array.from(this.observers.keys()))this.removeObserver(e)}$getTableNodesAndObservers(){const t=[];for(const[n,[o]]of Array.from(this.observers.entries())){const l=e.$getNodeByKey(n);Ze(l)?t.push([l,o]):this.removeObserver(n)}return t}}class Q{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;abortController;listenerOptions;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.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear()}$lookup(){return j(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver(e=>{this.editor.read("latest",()=>{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=Ce(n,o)})});this.editor.read("latest",()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Ce(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})})}$clearHighlight(t=!0){const n=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:o,tableElement:l}=this.$lookup();Se(n,Ce(o,l),null),t&&null!==e.$getSelection()&&(e.$setSelection(null),n.dispatchCommand(e.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&&g(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Se(t,this.table,this.tableSelection)}else this.$clearHighlight()}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const t=e.getDOMSelection(this.editor._window);t&&t.rangeCount>0&&t.removeAllRanges()}}$setFocusCellForSelection(t,n=!1){const o=this.editor,{tableNode:l}=this.$lookup(),r=t.x,s=t.y;if(this.focusCell=t,!this.isHighlightingCells){(n||this.anchorX!==r||this.anchorY!==s||null!=this.tableSelection&&null!=this.anchorCellNodeKey)&&(this.isHighlightingCells=!0,this.$disableHighlightStyle())}if(-1!==this.focusX&&-1!==this.focusY&&r===this.focusX&&s===this.focusY)return!1;if(this.focusX=r,this.focusY=s,this.isHighlightingCells){const i=Ie(l,t.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey){let t=i;if(null===t&&n&&(t=l.getCellNodeFromCords(r,s,this.table)),null!==t){const n=this.$getAnchorTableCellOrThrow();return this.focusCellNodeKey=t.getKey(),this.tableSelection=G(l,n,t),e.$setSelection(this.tableSelection),o.dispatchCommand(e.SELECTION_CHANGE_COMMAND,void 0),Se(o,this.table,this.tableSelection),!0}}}return!1}$getAnchorTableCell(){const t=this.anchorCellNodeKey?e.$getNodeByKey(this.anchorCellNodeKey):null;return d(t)?t:null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&g(234),e}$getFocusTableCell(){const t=this.focusCellNodeKey?e.$getNodeByKey(this.focusCellNodeKey):null;return d(t)?t:null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&g(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.focusX=-1,this.focusY=-1,this.focusCell=null,this.focusCellNodeKey=null;const{tableNode:t}=this.$lookup(),n=Ie(t,e.elem);if(null!==n){const e=n.getKey();null!=this.tableSelection?(this.tableSelection=this.tableSelection.clone(),this.tableSelection.set(t.getKey(),e,e)):this.tableSelection=G(t,n,n),this.anchorCellNodeKey=e}}$formatCells(t){const n=e.$getSelection();q(n)||g(236);const o=e.$createRangeSelection(),l=o.anchor,r=o.focus,s=n.getNodes().filter(d);s.length>0||g(237);const i=s[0].getFirstChild(),a=e.$isParagraphNode(i)?i.getFormatFlags(t,null):null;s.forEach(e=>{l.set(e.getKey(),0,"element"),r.set(e.getKey(),e.getChildrenSize(),"element"),o.formatText(t,a)}),e.$setSelection(n),this.editor.dispatchCommand(e.SELECTION_CHANGE_COMMAND,void 0)}$clearText(){const{editor:t}=this,n=e.$getNodeByKey(this.tableNodeKey);if(!Ze(n))throw new Error("Expected TableNode.");const o=e.$getSelection();q(o)||g(253);const l=o.getNodes().filter(d),r=n.getFirstChild(),s=n.getLastChild();if(l.length>0&&null!==r&&null!==s&&C(r)&&C(s)&&l[0]===r.getFirstChild()&&l[l.length-1]===s.getLastChild()){n.selectPrevious();const o=n.getParent();return n.remove(),void(e.$isRootNode(o)&&o.isEmpty()&&t.dispatchCommand(e.INSERT_PARAGRAPH_COMMAND,void 0))}l.forEach(t=>{if(e.$isElementNode(t)){const n=e.$createParagraphNode(),o=e.$createTextNode();n.append(o),t.append(n),t.getChildren().forEach(e=>{e!==n&&e.remove()})}}),Se(t,this.table,null),e.$setSelection(null),t.dispatchCommand(e.SELECTION_CHANGE_COMMAND,void 0)}}const Z="__lexicalTableSelection";function ee(t){const n=e.$getNodeByKeyOrThrow(t);return Ze(n)||g(386,t),n}const te=40;function ne(e,t,n){const o=e=>Math.max(1,Math.ceil(Math.min(te,e)/te*18));return e<=t+te?-o(t+te-e):e>=n-te?o(e-(n-te)):0}function oe(t){return e.isHTMLElement(t)&&"TABLE"===t.nodeName}function le(e,t){if(!t)return t;const n=oe(t)?t:t.querySelector("table");return oe(n)||g(341,e.constructor.name,e.getType(),e.getKey(),t.nodeName),n}function re(e){return e._window}function se(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;d(n)&&(o=n)}return null}const ie=[[e.KEY_ARROW_DOWN_COMMAND,"down"],[e.KEY_ARROW_UP_COMMAND,"up"],[e.KEY_ARROW_LEFT_COMMAND,"backward"],[e.KEY_ARROW_RIGHT_COMMAND,"forward"]],ae=[e.DELETE_WORD_COMMAND,e.DELETE_LINE_COMMAND,e.DELETE_CHARACTER_COMMAND],ce=[e.KEY_BACKSPACE_COMMAND,e.KEY_DELETE_COMMAND];function ue(t,n){return t.registerRootListener(o=>{if(null===o)return;const l=t._window;if(null===l)return;return e.registerEventListener(l,"pointerdown",l=>{const r=e.getComposedEventTarget(l);if(0!==l.button||!e.isDOMNode(r)||!o.contains(r))return;const s=function(e){const t=me(e);if(null===t)return null;let n=t.elem;for(;null!=n;){if("TABLE"===n.nodeName&&Z in n&&n[Z])return{cellElement:t,tableElement:n,tableObserver:n[Z]};n=n.parentNode}return null}(r);t.update(()=>{if(q(e.$getSelection())){for(const[e]of n.observers.values())e.$clearHighlight(!1);e.$setSelection(null),t.dispatchCommand(e.SELECTION_CHANGE_COMMAND,void 0)}if(!s)return;const{tableObserver:o,tableElement:r,cellElement:i}=s;!function(t,n,o,l,r,s){const i=t._window;if(!i)return;const a=o=>{if(r.isSelecting)return;r.isSelecting=!0,null!==o&&null===r.anchorCell&&t.update(()=>{r.$setAnchorCellForSelection(o)});let a=n.clientX,c=n.clientY,u=null;const d=()=>{r.isSelecting=!1,null!==u&&(i.cancelAnimationFrame(u),u=null),i.removeEventListener("pointerup",b),i.removeEventListener("pointermove",N)},h=(t,n)=>{const o=l.getRootNode();if(!e.isDOMDocumentNode(o)&&!e.isDOMShadowRoot(o))return null;for(const e of o.elementsFromPoint(t,n)){const t=pe(l,e);if(t)return t}return null},g=(n,o)=>{null===r.anchorCell&&t.update(()=>{r.$setAnchorCellForSelection(n)}),null!==r.focusCell&&n.elem===r.focusCell.elem||(s.setNextFocus({focusCell:n,override:o,tableKey:r.tableNodeKey}),t.dispatchCommand(e.SELECTION_CHANGE_COMMAND,void 0))},f=e=>{for(let t=l.parentElement;t;t=t.parentElement){if("x"===e?t.scrollWidth>t.clientWidth:t.scrollHeight>t.clientHeight){const n=i.getComputedStyle(t),o="x"===e?n.overflowX:n.overflowY;if("auto"===o||"scroll"===o)return t}}return null},m=(e,t,n)=>{let o,l;if(null===e)o=0,l="x"===n?i.innerWidth:i.innerHeight;else{const t=e.getBoundingClientRect();o="x"===n?t.left:t.top,l="x"===n?t.right:t.bottom}const r=ne(t,o,l);if(0===r)return!1;if(null===e){const e="x"===n?i.scrollX:i.scrollY;return i.scrollBy("x"===n?r:0,"x"===n?0:r),("x"===n?i.scrollX:i.scrollY)!==e}if("x"===n){const t=e.scrollLeft;return e.scrollLeft+=r,e.scrollLeft!==t}const s=e.scrollTop;return e.scrollTop+=r,e.scrollTop!==s},p=(e,t)=>{let n=a,o=c;if(null===e)n=Math.min(Math.max(n,1),i.innerWidth-1);else{const t=e.getBoundingClientRect();n=Math.min(Math.max(n,t.left+1),t.right-1)}if(null===t)o=Math.min(Math.max(o,1),i.innerHeight-1);else{const e=t.getBoundingClientRect();o=Math.min(Math.max(o,e.top+1),e.bottom-1)}return[n,o]},C=()=>{const e=f("x");if(null!==e){const t=e.getBoundingClientRect();if(0!==ne(a,t.left,t.right))return!0}const t=f("y"),n=null===t?0:t.getBoundingClientRect().top,o=null===t?i.innerHeight:t.getBoundingClientRect().bottom;return 0!==ne(c,n,o)},S=()=>{if(u=null,!r.isSelecting)return;const e=f("x"),t=f("y"),n=null!==e&&m(e,a,"x"),o=m(t,c,"y");if(n||o){const[n,o]=p(e,t),l=h(n,o);l&&g(l,!1),u=i.requestAnimationFrame(S)}},_=()=>{null===u&&"touch"!==r.pointerType&&C()&&(u=i.requestAnimationFrame(S))},b=()=>{d()},N=t=>{if(!(e=>!(1&~e.buttons))(t)&&r.isSelecting)return void d();const n=e.getComposedEventTarget(t);if(!e.isDOMNode(n))return;a=t.clientX,c=t.clientY;let o=null;const s=!(e.IS_FIREFOX||l.contains(n));o=s?pe(l,n):h(t.clientX,t.clientY),o&&g(o,s),_()};i.addEventListener("pointerup",b,r.listenerOptions),i.addEventListener("pointermove",N,r.listenerOptions)};r.pointerType=n.pointerType;const c=ee(r.tableNodeKey),u=e.$getPreviousSelection();if(e.IS_FIREFOX&&n.shiftKey&&$e(u,c)&&(e.$isRangeSelection(u)||q(u))){const e=u.anchor.getNode(),t=se(c,u.anchor.getNode());if(t)r.$setAnchorCellForSelection(Ke(r,t)),r.$setFocusCellForSelection(o),Fe(n);else{(c.isBefore(e)?c.selectStart():c.selectEnd()).anchor.set(u.anchor.key,u.anchor.offset,u.anchor.type)}}else"touch"!==n.pointerType&&r.$setAnchorCellForSelection(o);a(o)}(t,l,i,r,o,n)})})})}function de(t,n,r,s,i){const a=r.getRootElement(),c=re(r);null!==a&&null!==c||g(246);const u=new Q(r,t.getKey()),h=le(t,n);!function(e,t){null!==fe(e)&&g(205);e[Z]=t}(h,u),u.listenersToRemove.add(()=>function(e,t){fe(e)===t&&delete e[Z]}(h,u));u.listenersToRemove.add(e.registerEventListener(h,"mousedown",t=>{const n=e.getComposedEventTarget(t);if(t.detail>=3&&e.isDOMNode(n)){null!==me(n)&&t.preventDefault()}},u.listenerOptions));for(const[n,o]of ie)u.listenersToRemove.add(r.registerCommand(n,e=>Ae(r,e,o,t,u,i),e.COMMAND_PRIORITY_HIGH));u.listenersToRemove.add(r.registerCommand(e.KEY_ESCAPE_COMMAND,n=>{const o=e.$getSelection();if(q(o)){const e=se(t,o.focus.getNode());if(null!==e)return Fe(n),e.selectEnd(),!0}return!1},e.COMMAND_PRIORITY_HIGH));const f=()=>{const n=e.$getSelection();return!!$e(n,t)&&(!!q(n)&&(u.$clearText(),!0))};for(const t of ae)u.listenersToRemove.add(r.registerCommand(t,f,e.COMMAND_PRIORITY_HIGH));const m=n=>{const o=e.$getSelection();if(!q(o)&&!e.$isRangeSelection(o))return!1;const l=t.isParentOf(o.anchor.getNode());if(l!==t.isParentOf(o.focus.getNode())){const e=l?"anchor":"focus",n=l?"focus":"anchor",{key:r,offset:s,type:i}=o[n];return t[o[e].isBefore(o[n])?"selectPrevious":"selectNext"]()[n].set(r,s,i),!1}return!!$e(o,t)&&(!!q(o)&&(n&&(n.preventDefault(),n.stopPropagation()),u.$clearText(),!0))};for(const t of ce)u.listenersToRemove.add(r.registerCommand(t,m,e.COMMAND_PRIORITY_HIGH));u.listenersToRemove.add(r.registerCommand(e.CUT_COMMAND,t=>{const n=e.$getSelection();if(n){if(!q(n)&&!e.$isRangeSelection(n))return!1;l.copyToClipboard(r,o.objectKlassEquals(t,ClipboardEvent)?t:null,l.$getClipboardDataFromSelection(n));const s=m(t);return e.$isRangeSelection(n)?(n.removeText(),!0):s}return!1},e.COMMAND_PRIORITY_HIGH));const p=a.ownerDocument;return u.listenersToRemove.add(e.registerEventListener(p,"paste",n=>{if(n.defaultPrevented)return;r.read("latest",()=>{const n=e.$getSelection();return a.contains(p.activeElement)&&q(n)&&$e(n,t)})&&(n.preventDefault(),r.dispatchCommand(e.PASTE_COMMAND,n))})),u.listenersToRemove.add(e.registerEventListener(p,"copy",n=>{if(n.defaultPrevented)return;const o=e.getComposedEventTarget(n);if(o===a||e.isDOMNode(o)&&a.contains(o))return;r.read("latest",()=>{const n=e.$getSelection();return a.contains(e.getActiveElement(a))&&q(n)&&$e(n,t)})&&(n.preventDefault(),r.dispatchCommand(e.COPY_COMMAND,n))})),u.listenersToRemove.add(r.registerCommand(e.FORMAT_TEXT_COMMAND,n=>{const o=e.$getSelection();return!!$e(o,t)&&(!!q(o)&&(u.$formatCells(n),!0))},e.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(r.registerCommand(e.FORMAT_ELEMENT_COMMAND,n=>{const o=e.$getSelection();if(!q(o)||!$e(o,t))return!1;const l=o.anchor.getNode(),r=o.focus.getNode();if(!d(l)||!d(r))return!1;if(function(e,t){if(q(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=L(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(o,t))return t.setFormat(n),!0;const[s,i,a]=L(t,l,r),c=Math.max(i.startRow+i.cell.__rowSpan-1,a.startRow+a.cell.__rowSpan-1),u=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 t=h;t<=c;t++)for(let o=g;o<=u;o++){const l=s[t][o].cell;if(f.has(l))continue;f.add(l),l.setFormat(n);const r=l.getChildren();for(let t=0;t<r.length;t++){const o=r[t];e.$isElementNode(o)&&!o.isInline()&&o.setFormat(n)}}return!0},e.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(r.registerCommand(e.CONTROLLED_TEXT_INSERTION_COMMAND,n=>{const o=e.$getSelection();if(!$e(o,t))return!1;if(q(o))return u.$clearHighlight(),!1;if(e.$isRangeSelection(o)){const l=e.$findMatchingParent(o.anchor.getNode(),e=>d(e));if(!d(l))return!1;if("string"==typeof n){const l=Pe(r,o,t);if(l)return De(l,t,[e.$createTextNode(n)]),!0}}return!1},e.COMMAND_PRIORITY_HIGH)),s&&u.listenersToRemove.add(r.registerCommand(e.KEY_TAB_COMMAND,n=>{const o=e.$getSelection();if(!e.$isRangeSelection(o)||!o.isCollapsed()||!$e(o,t))return!1;const l=Me(o.anchor.getNode());return!(null===l||!t.is(Oe(l)))&&(Fe(n),function(t,n){const o="next"===n?"getNextSibling":"getPreviousSibling",l="next"===n?"getFirstChild":"getLastChild",r=t[o]();if(e.$isElementNode(r))return r.selectEnd();const s=e.$findMatchingParent(t,C);null===s&&g(247);for(let t=s[o]();C(t);t=t[o]()){const n=t[l]();if(e.$isElementNode(n))return n.selectEnd()}const i=e.$findMatchingParent(s,Ze);null===i&&g(248);"next"===n?i.selectNext():i.selectPrevious()}(l,n.shiftKey?"previous":"next"),!0)},e.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(r.registerCommand(e.FOCUS_COMMAND,e=>t.isSelected(),e.COMMAND_PRIORITY_HIGH)),u.listenersToRemove.add(r.registerCommand(e.INSERT_PARAGRAPH_COMMAND,()=>{const n=e.$getSelection();if(!e.$isRangeSelection(n)||!n.isCollapsed()||!$e(n,t))return!1;const o=Pe(r,n,t);return!!o&&(De(o,t),!0)},e.COMMAND_PRIORITY_HIGH)),u}function he(t,n){const o=e.$getSelection(),l=e.$getPreviousSelection(),r=t.getAndClearNextFocus();if(null!==r){const{tableKey:e,focusCell:n}=r,l=t.observers.get(e);l||g(335,e);const[s]=l;if(q(o)&&o.tableKey===s.tableNodeKey)return(n.x!==s.focusX||n.y!==s.focusY)&&(s.$setFocusCellForSelection(n),!0);if(null!==s.anchorCell&&null!==s.anchorCellNodeKey&&n.elem!==s.anchorCell.elem&&null!==s.tableSelection)return s.$setFocusCellForSelection(n,!0),!0}const s=t.getAndClearShouldCheckSelectionForTable();if(s&&e.$isRangeSelection(l)&&e.$isRangeSelection(o)&&o.isCollapsed()){const t=e.$getNodeByKey(s);if(Ze(t)){const n=o.anchor.getNode(),l=t.getFirstChild(),r=Me(n);if(null!==r&&C(l)){const n=l.getFirstChild();if(d(n)&&t.is(e.$findMatchingParent(r,e=>e.is(t)||e.is(n))))return n.selectStart(),!0}}}q(o)&&function(t,n){const o=re(t),l=e.$getPreviousSelection();if(!n.is(l))return;const r=ee(n.tableKey),s=e.getDOMSelection(o),i=s&&e.getDOMSelectionPoints(s,t.getRootElement());if(s&&i&&i.anchorNode&&i.focusNode){const o=e.$getNearestNodeFromDOMNode(i.focusNode),l=o&&!r.isParentOf(o),a=e.$getNearestNodeFromDOMNode(i.anchorNode),c=a&&r.isParentOf(a);if(l&&c&&s.rangeCount>0){const o=e.$createRangeSelectionFromDom(s,t);o&&(o.anchor.set(r.getKey(),n.isBackward()?r.getChildrenSize():0,"element"),s.removeAllRanges(),e.$setSelection(o))}}}(n,o),e.$isRangeSelection(o)&&function(t,n){const o=e.$getPreviousSelection(),{anchor:l,focus:r}=t,s=l.getNode(),i=r.getNode(),a=Me(s),c=Me(i),u=a?Oe(a):null,d=c?Oe(c):null,h=t.isBackward(),f=a&&c&&u&&d&&u.is(d),m=d&&(!u||u.isParentOf(d)),p=u&&(!d||d.isParentOf(u));if(m){const n=t.clone(),[o]=L(d,c,c),l=o[0][0].cell,r=o[o.length-1].at(-1).cell;n.focus.set(h?l.getKey():r.getKey(),h?0:r.getChildrenSize(),"element"),e.$setSelection(n)}else if(p){const n=t.clone(),[o]=L(u,a,a),l=o[0][0].cell,r=o[o.length-1].at(-1).cell;n.anchor.set(h?r.getKey():l.getKey(),h?r.getChildrenSize():0,"element"),e.$setSelection(n)}else if(f){const l=n.observers.get(u.getKey());l||g(335,u.getKey());const[r]=l;if(a.is(c)||(r.$setAnchorCellForSelection(Ke(r,a)),r.$setFocusCellForSelection(Ke(r,c),!0)),"touch"===r.pointerType&&r.isSelecting&&t.isCollapsed()&&e.$isRangeSelection(o)&&o.isCollapsed()){const e=Me(o.anchor.getNode());e&&!e.is(c)&&(r.$setAnchorCellForSelection(Ke(r,e)),r.$setFocusCellForSelection(Ke(r,c),!0),r.pointerType=null)}}}(o,t);for(const[e,o]of t.$getTableNodesAndObservers())ge(n,e,o);return!1}function ge(t,n,o){const l=e.$getSelection(),r=e.$getPreviousSelection();l&&!l.is(r)&&(q(l)||q(r))&&o.tableSelection&&!o.tableSelection.is(r)&&(q(l)&&l.tableKey===o.tableNodeKey?o.$updateTableTableSelection(l):!q(l)&&q(r)&&r.tableKey===o.tableNodeKey&&o.$updateTableTableSelection(null)),o.hasHijackedSelectionStyles&&!n.isSelected()?function(e,t){t.$enableHighlightStyle(),_e(t.table,t=>{const n=t.elem;t.highlighted=!1,Ee(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(t,o):!o.hasHijackedSelectionStyles&&n.isSelected()&&function(e,t){t.$disableHighlightStyle(),_e(t.table,t=>{t.highlighted=!0,Re(e,t)})}(t,o)}function fe(e){return e[Z]||null}function me(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 pe(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 Ce(e,t){const n=[],o={columns:0,domRows:n,rows:0};let l=le(e,t).querySelector("tr"),r=0,s=0;for(n.length=0;null!=l;){const e=l.nodeName;if("TD"===e||"TH"===e){const e={elem:l,hasBackgroundColor:""!==l.style.backgroundColor,highlighted:!1,x:r,y:s};l._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[r]=e}else{const e=l.firstChild;if(null!=e){l=e;continue}}const t=l.nextSibling;if(null!=t){r++,l=t;continue}const o=l.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,r=0,l=e}}return o.columns=r+1,o.rows=s+1,o}function Se(e,t,n){const o=new Set(n?n.getNodes():[]);_e(t,(t,n)=>{const l=t.elem;o.has(n)?(t.highlighted=!0,Re(e,t)):(t.highlighted=!1,Ee(e,t),l.getAttribute("style")||l.removeAttribute("style"))})}function _e(t,n){const{domRows:o}=t;for(let t=0;t<o.length;t++){const l=o[t];if(l)for(let o=0;o<l.length;o++){const r=l[o];if(!r)continue;const s=e.$getNearestNodeFromDOMNode(r.elem);null!==s&&n(r,s,{x:o,y:t})}}}const be=(e,t,n,o,l)=>{const r="forward"===l;switch(l){case"backward":case"forward":return n!==(r?e.table.columns-1:0)?xe(t.getCellNodeFromCordsOrThrow(n+(r?1:-1),o,e.table),r):o!==(r?e.table.rows-1:0)?xe(t.getCellNodeFromCordsOrThrow(r?0:e.table.columns-1,o+(r?1:-1),e.table),r):r?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==o?xe(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?xe(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Ne(e,t){let n,o;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)o="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow"}return[n,o]}function ye([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function we(e,t,[n,o]){const l=t[o],r=e[l];void 0===r&&g(250,o,String(l));const s=t[n],i=r[s];return void 0===i&&g(250,n,String(s)),i}function Te(e,t,n,o,l){const r=W(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:l,maxRow:r}=t;let s=1,i=1,a=1,c=1;const u=e[l],d=e[r];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=l;t<=r;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,r),{topSpan:i,leftSpan:a,bottomSpan:c,rightSpan:u}=s,d=function(e,t){const n=Ne(e,t);return null===n&&g(249,t.cell.getKey()),n}(r,n),[h,f]=ye(d);let m=r[h],p=r[f];"forward"===l?m+="maxColumn"===h?1:a:"backward"===l?m-="minColumn"===h?1:u:"down"===l?p+="maxRow"===f?1:i:"up"===l&&(p-="minRow"===f?1:c);const C=t[p];if(void 0===C)return!1;const S=C[m];if(void 0===S)return!1;const[_,b]=function(e,t,n){const o=W(e,t,n),l=Ne(o,t);if(l)return[we(e,o,l),we(e,o,ye(l))];const r=Ne(o,n);if(r)return[we(e,o,ye(r)),we(e,o,r)];const s=["minColumn","minRow"];return[we(e,o,s),we(e,o,ye(s))]}(t,n,S),N=Ke(e,_.cell),y=Ke(e,b.cell);return e.$setAnchorCellForSelection(N),e.$setFocusCellForSelection(y,!0),!0}function $e(t,n){if(e.$isRangeSelection(t)||q(t)){const e=n.isParentOf(t.anchor.getNode()),o=n.isParentOf(t.focus.getNode());return e&&o}return!1}function xe(e,t){t?e.selectStart():e.selectEnd()}function Re(t,n){const o=n.elem,l=t._config.theme;d(e.$getNearestNodeFromDOMNode(o))||g(131),e.addClassNamesToElement(o,l.tableCellSelected)}function Ee(t,n){const o=n.elem;d(e.$getNearestNodeFromDOMNode(o))||g(131);const l=t._config.theme;e.removeClassNamesFromElement(o,l.tableCellSelected)}function Me(t){const n=e.$findMatchingParent(t,d);return d(n)?n:null}function Oe(t){const n=e.$findMatchingParent(t,Ze);return Ze(n)?n:null}function ve(t,n,o,l,r,s,i){const a=e.$caretFromPoint(o.focus,r?"previous":"next");if(e.$isExtendableTextPointCaret(a))return!1;let c=a;for(const t of e.$extendCaretToRange(a).iterNodeCarets("shadowRoot")){if(!e.$isSiblingCaret(t)||!e.$isElementNode(t.origin))return!1;c=t}const u=c.getParentAtCaret();if(!d(u))return!1;const h=u,g=function(t){for(const n of e.$extendCaretToRange(t).iterNodeCarets("root")){const{origin:o}=n;if(d(o)){if(e.$isChildCaret(n))return e.$getChildCaret(o,t.direction)}else if(!C(o))break}return null}(e.$getSiblingCaret(h,c.direction)),f=e.$findMatchingParent(h,Ze);if(!f||!f.is(s))return!1;const m=t.getElementByKey(h.getKey()),p=me(m);if(!m||!p)return!1;const S=je(t,f);if(i.table=S,g)if("extend"===l){const e=me(t.getElementByKey(g.origin.getKey()));if(!e)return!1;i.$setAnchorCellForSelection(p),i.$setFocusCellForSelection(e,!0)}else{const t=e.$normalizeCaret(g);e.$setPointFromCaret(o.anchor,t),e.$setPointFromCaret(o.focus,t)}else if("extend"===l)i.$setAnchorCellForSelection(p),i.$setFocusCellForSelection(p,!0);else{const t=function(t){const n=e.$getAdjacentChildCaret(t);return e.$isChildCaret(n)?e.$normalizeCaret(n):t}(e.$getSiblingCaret(f,a.direction));e.$setPointFromCaret(o.anchor,t),e.$setPointFromCaret(o.focus,t)}return Fe(n),!0}function Ae(t,n,o,l,r,s){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")}(t))return!1;const i=e.$getSelection();if(!$e(i,l)){if(e.$isRangeSelection(i)){if("backward"===o){if(i.focus.offset>0)return!1;const t=function(t){for(let n=t,o=t;null!==o;n=o,o=o.getParent())if(e.$isElementNode(o)){if(o!==n&&o.getFirstChild()!==n)return null;if(!o.isInline())return o}return null}(i.focus.getNode());if(!t)return!1;const o=t.getPreviousSibling();return!!Ze(o)&&(Fe(n),n.shiftKey?i.focus.set(o.getParentOrThrow().getKey(),o.getIndexWithinParent(),"element"):o.selectEnd(),!0)}if(n.shiftKey&&("up"===o||"down"===o)){const t=i.focus.getNode();if(!i.isCollapsed()&&("up"===o&&!i.isBackward()||"down"===o&&i.isBackward())){let r=e.$findMatchingParent(t,e=>Ze(e));if(d(r)&&(r=e.$findMatchingParent(r,Ze)),r!==l)return!1;if(!r)return!1;const s="down"===o?r.getNextSibling():r.getPreviousSibling();if(!s)return!1;let a=0;"up"===o&&e.$isElementNode(s)&&(a=s.getChildrenSize());let c=s;if("up"===o&&e.$isElementNode(s)){const t=s.getLastChild();c=t||s,a=e.$isTextNode(c)?c.getTextContentSize():0}const u=i.clone();return u.focus.set(c.getKey(),a,e.$isTextNode(c)?"text":"element"),e.$setSelection(u),Fe(n),!0}if(e.$isRootOrShadowRoot(t)){const e="up"===o?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==se(l,e)){const e=l.getFirstDescendant(),t=l.getLastDescendant();if(!e||!t)return!1;const[n]=H(e),[o]=H(t),s=l.getCordsFromCellNode(n,r.table),i=l.getCordsFromCellNode(o,r.table),a=l.getDOMCellFromCordsOrThrow(s.x,s.y,r.table),c=l.getDOMCellFromCordsOrThrow(i.x,i.y,r.table);return r.$setAnchorCellForSelection(a),r.$setFocusCellForSelection(c,!0),!0}}return!1}{let l=e.$findMatchingParent(t,t=>e.$isElementNode(t)&&!t.isInline());if(d(l)&&(l=e.$findMatchingParent(l,Ze)),!l)return!1;const s="down"===o?l.getNextSibling():l.getPreviousSibling();if(Ze(s)&&r.tableNodeKey===s.getKey()){const t=s.getFirstDescendant(),l=s.getLastDescendant();if(!t||!l)return!1;const[r]=H(t),[a]=H(l),c=i.clone();return c.focus.set(("up"===o?r:a).getKey(),"up"===o?0:a.getChildrenSize(),"element"),Fe(n),e.$setSelection(c),!0}}}}return"down"===o&&Xe(t)&&s.setShouldCheckSelectionForTable(l.getKey()),!1}if(e.$isRangeSelection(i)){if("backward"===o||"forward"===o){return ve(t,n,i,n.shiftKey?"extend":"move","backward"===o,l,r)}if(i.isCollapsed()){const{anchor:a,focus:c}=i,u=e.$findMatchingParent(a.getNode(),d),h=e.$findMatchingParent(c.getNode(),d);if(!d(u)||!u.is(h))return!1;const g=Oe(u);if(g!==l&&null!=g){const e=le(g,t.getElementByKey(g.getKey()));if(null!=e)return r.table=Ce(g,e),Ae(t,n,o,g,r,s)}const f=t.getElementByKey(u.__key),m=t.getElementByKey(a.key);if(null==m||null==f)return!1;let p;if("element"===a.type)p=m.getBoundingClientRect();else{const n=e.getDOMSelection(re(t));if(null===n||0===n.rangeCount)return!1;const o=e.getDOMSelectionRange(n,t.getRootElement());if(null===o)return!1;p=o.getBoundingClientRect()}const C="up"===o?u.getFirstChild():u.getLastChild();if(null==C)return!1;const S=t.getElementByKey(C.__key);if(null==S)return!1;const _=S.getBoundingClientRect();if("up"===o?_.top>p.top-p.height:p.bottom+p.height>_.bottom){Fe(n);const e=l.getCordsFromCellNode(u,r.table);if(!n.shiftKey)return be(r,l,e.x,e.y,o);{const t=l.getDOMCellFromCordsOrThrow(e.x,e.y,r.table);r.$setAnchorCellForSelection(t),r.$setFocusCellForSelection(t,!0)}return!0}}}else if(q(i)){const{anchor:s,focus:a,tableKey:c}=i;if(c!==l.getKey())return!1;const u=e.$findMatchingParent(s.getNode(),d),h=e.$findMatchingParent(a.getNode(),d),[f]=i.getNodes();Ze(f)||g(251);const m=le(f,t.getElementByKey(f.getKey()));if(!d(u)||!d(h)||!Ze(f)||null==m)return!1;r.$updateTableTableSelection(i);const p=Ce(f,m),C=l.getCordsFromCellNode(u,p),S=l.getDOMCellFromCordsOrThrow(C.x,C.y,p);if(r.$setAnchorCellForSelection(S),Fe(n),n.shiftKey){const[e,t,n]=L(l,u,h);return Te(r,e,t,n,o)}return h.selectEnd(),!0}return!1}function Fe(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function De(t,n,o){const l=e.$createParagraphNode();"first"===t?n.insertBefore(l):n.insertAfter(l),l.append(...o||[]),l.selectEnd()}function Pe(t,n,o){const l=o.getParent();if(!l)return;const r=e.getDOMSelection(re(t));if(!r)return;const s=e.getDOMSelectionPoints(r,t.getRootElement()).anchorNode,i=t.getElementByKey(l.getKey()),a=le(o,t.getElementByKey(o.getKey()));if(!s||!i||!a||!i.contains(s)||a.contains(s))return;const c=e.$findMatchingParent(n.anchor.getNode(),e=>d(e));if(!c)return;const u=e.$findMatchingParent(c,e=>Ze(e));if(!Ze(u)||!u.is(o))return;const[h,g]=L(o,c,c),f=h[0][0],m=h[h.length-1][h[0].length-1],{startRow:p,startColumn:C}=g,S=p===f.startRow&&C===f.startColumn,_=p===m.startRow&&C===m.startColumn;return S?"first":_?"last":void 0}function Ke(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Ie(t,n,o){return se(t,e.$getNearestNodeFromDOMNode(n,o))}function Le(t){return e.isHTMLElement(t)&&"DIV"===t.nodeName}function ke(t,n,o){const l=t.querySelector("colgroup");if(!l)return;const r=[];for(let t=0;t<n;t++){const n=e.$getDocument().createElement("col"),l=o&&o[t];l&&(n.style.width=`${l}px`),r.push(n)}l.replaceChildren(...r)}function He(t,n,o){if(!n.theme.tableAlignment)return;const l=[],r=[];for(const e of["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===o?r:l).push(t)}e.removeClassNamesFromElement(t,...l),e.addClassNamesToElement(t,...r)}const We=new WeakSet;function Be(e){const{scrollable:t,scrollbar:n,tableElement:o}=e;if(0===n.classList.length&&0===function(e){const t=e.style.display;e.style.display="";const n=e.offsetHeight-e.clientHeight;return e.style.display=t,n}(n))return We.add(n),n.style.display="none",t.style.scrollbarWidth="auto",()=>{};const l=()=>{n.scrollLeft!==t.scrollLeft&&(n.scrollLeft=t.scrollLeft)},r=()=>{t.scrollLeft!==n.scrollLeft&&(t.scrollLeft=n.scrollLeft)};t.addEventListener("scroll",l,{passive:!0}),n.addEventListener("scroll",r,{passive:!0});let s=null;"undefined"!=typeof ResizeObserver&&(s=new ResizeObserver(()=>{ze(t,n)}),s.observe(t),s.observe(o));return ze(t,n),()=>{t.removeEventListener("scroll",l),n.removeEventListener("scroll",r),s&&s.disconnect()}}function ze(t,n){if(We.has(n))return;const o=n.firstElementChild;if(!o||!e.isHTMLElement(o)||!t.isConnected)return;const l=t.ownerDocument.defaultView;if(!l)return void(n.style.display="none");const r=l.getComputedStyle(t).overflowX,s="auto"===r||"scroll"===r,i=t.scrollWidth,a=t.clientWidth,c=i+"px";o.style.width!==c&&(o.style.width=c);const u=s&&i>a;n.style.display=u?"":"none"}function Ye(e){if(!e.hasAttribute("data-lexical-sticky-scrollbar"))return null;const t=e.firstElementChild;if(!Le(t))return null;const n=t.querySelector(":scope > table");if(!oe(n))return null;const o=t.nextElementSibling;return Le(o)?{scrollable:t,scrollbar:o,tableElement:n}:null}const Ue=new WeakSet;function Xe(t=e.$getEditor()){return Ue.has(t)}function qe(n=e.$getEditor()){const o=t.getPeerDependencyFromEditor(n,"@lexical/table/Table");return!!o&&(o.output.hasStickyScrollbar.peek()&&o.output.hasHorizontalScroll.peek())}function Ge(e,t){t?Ue.add(e):Ue.delete(e)}class Je extends e.ElementNode{__rowStriping=!1;__frozenColumnCount=0;__frozenRowCount=0;__colWidths=void 0;$config(){return this.config("table",{extends:e.ElementNode,importDOM:{table:()=>({conversion:Ve,priority:1})}})}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}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=oe(e)?e:e.querySelector("table");return oe(t)||g(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=e.$getDocument().createElement("table");this.__style&&e.setDOMStyleFromCSS(o.style,this.__style);const l=e.$getDocument().createElement("colgroup");if(o.appendChild(l),e.setDOMUnmanaged(l),e.addClassNamesToElement(o,t.theme.table),this.updateTableElement(null,o,t),Xe(n)){const l=qe(n),r=function(t,n,o){const l=e.$getDocument().createElement("div"),r=n.theme.tableScrollableWrapper;return r?e.addClassNamesToElement(l,r):l.style.overflowX="auto",o&&(l.style.scrollbarWidth="none"),l.appendChild(t),l}(o,t,l);if(this.updateTableWrapper(null,r,o,t),l){const n=function(t){const n=e.$getDocument(),o=n.createElement("div"),l=t.theme.tableStickyScrollbar;l?e.addClassNamesToElement(o,l):(o.style.position="sticky",o.style.bottom="0",o.style.overflowX="scroll",o.style.overflowY="hidden"),o.style.display="none",o.setAttribute("aria-hidden","true"),o.tabIndex=-1;const r=n.createElement("div");return r.style.height="1px",r.style.width="0px",o.appendChild(r),o}(t),o=e.$getDocument().createElement("div");return o.setAttribute("data-lexical-sticky-scrollbar","true"),o.appendChild(r),o.appendChild(n),e.setDOMUnmanaged(n),o}return r}return o}updateTableWrapper(t,n,o,l){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,o,l){l>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,l,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,o,l){l>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,l,this.__frozenRowCount)}updateTableElement(t,n,o){this.__style!==(t?t.__style:"")&&e.setDOMStyleFromCSS(n.style,this.__style,t?t.__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);const l=t?t.getColumnCount():0,r=t?t.__colWidths:void 0;this.getColumnCount()===l&&this.getColWidths()===r||ke(n,this.getColumnCount(),this.getColWidths()),He(n,o,this.getFormatType())}updateDOM(e,t,n){const o=le(this,t);if(t===o===Xe())return!0;if(Le(t)){if(t.hasAttribute("data-lexical-sticky-scrollbar")!==qe())return!0;const l=o.parentElement;Le(l)&&this.updateTableWrapper(e,l,o,n)}return this.updateTableElement(e,o,n),!1}scaleDOMColWidths(e,t){const n=this.getColWidths();if(!n)return;ke(le(this,e),this.getColumnCount(),n.map(e=>e*t))}exportDOM(t){const n=super.exportDOM(t),{element:o}=n;return{after:o=>{if(n.after&&(o=n.after(o)),!oe(o)&&e.isHTMLElement(o)&&(o=o.querySelector("table")),!oe(o))return null;He(o,t._config,this.getFormatType());const[l]=k(this,null,null),r=new Map;for(const e of l)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 o.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=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 t=e.$getDocument().createElement("tbody");for(const e of a)t.appendChild(e);o.append(t)}return o},element:!oe(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 l=n[o];if(null==l)continue;const{elem:r}=l,s=Ie(this,r);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,l=o[t];if(null==l)return null;const r=l[e<l.length?e:l.length-1];return null==r?null:r}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(t,n,o){const l=this.getDOMCellFromCords(t,n,o);if(null==l)return null;const r=e.$getNearestNodeFromDOMNode(l.elem);return d(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(!C(e))return 0;let t=0;return e.getChildren().forEach(e=>{d(e)&&(t+=e.getColSpan())}),t}}function je(e,t){const n=e.getElementByKey(t.getKey());return null===n&&g(230),Ce(t,n)}function Ve(e){const t=Qe();e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0),e.hasAttribute("data-lexical-frozen-column")&&t.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&t.setFrozenRows(1);const n=e.querySelector(":scope > colgroup");if(n){let e=[];for(const t of n.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&&t.setColWidths(e)}return{after:e=>o.$descendantsMatching(e,C),node:t}}function Qe(){return e.$applyNodeReplacement(new Je)}function Ze(e){return e instanceof Je}function et(t){C(t.getParent())?t.isEmpty()&&t.append(e.$createParagraphNode()):t.remove()}function tt(e){Ze(e.getParent())?o.$unwrapAndFilterDescendants(e,d):e.remove()}function nt(t){o.$unwrapAndFilterDescendants(t,C);const[n]=k(t,null,null),l=n.reduce((e,t)=>Math.max(e,t.length),0),r=t.getChildren();for(let t=0;t<n.length;++t){const o=r[t];if(!o)continue;C(o)||g(254,o.constructor.name,o.getType());const s=n[t].reduce((e,t)=>t?1+e:e,0);if(s!==l)for(let t=s;t<l;++t){const t=u();t.append(e.$createParagraphNode()),o.append(t)}}const s=t.getColWidths(),i=t.getColumnCount();if(s&&s.length!==i){let e;if(i<s.length)e=s.slice(0,i);else if(s.length>0){const t=s[s.length-1];e=[...s,...Array(i-s.length).fill(t)]}t.setColWidths(e)}}function ot(t){if(t.detail<3||!e.isDOMNode(t.target))return!1;const n=e.$getNearestNodeFromDOMNode(t.target);if(null===n)return!1;const o=e.$findMatchingParent(n,t=>e.$isElementNode(t)&&!t.isInline());if(null===o)return!1;return!!d(o.getParent())&&(o.select(0),!0)}function lt(){const t=e.$getSelection();if(!e.$isRangeSelection(t))return!1;const n=Oe(t.anchor.getNode());if(null===n)return!1;const o=e.$getRoot();if(!o.is(n.getParent())||1!==o.getChildrenSize())return!1;const[l]=k(n,null,null);if(0===l.length||0===l[0].length)return!1;const r=l[0][0];if(!r||!r.cell)return!1;const s=l[l.length-1],i=s[s.length-1];if(!i||!i.cell)return!1;const a=G(n,r.cell,i.cell);return e.$setSelection(a),!0}function rt(e){return e.registerNodeTransform(i,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=H(e),[n]=L(t,e,e),l=n.length,r=n[0].length;let s=t.getFirstChild();C(s)||g(175);const i=[];for(let e=0;e<l;e++){0!==e&&(s=s.getNextSibling(),C(s)||g(175));let t=null;for(let l=0;l<r;l++){const r=n[e][l],a=r.cell;if(r.startRow===e&&r.startColumn===l)t=a,i.push(a);else if(a.getColSpan()>1||a.getRowSpan()>1){d(a)||g(176);const e=u(a.__headerState);null!==t?t.insertAfter(e):o.$insertFirst(s,e)}}}for(const e of i)e.setColSpan(1),e.setRowSpan(1)}})}function st(t,n=!0){const o=new V,l=(e,l,r)=>{const s=le(e,r),i=de(e,s,t,n,o);o.observers.set(l,[i,s])};return e.mergeRegister(ue(t,o),t.registerCommand(e.SELECTION_CHANGE_COMMAND,()=>he(o,t),e.COMMAND_PRIORITY_HIGH),t.registerMutationListener(Je,e=>{t.read("latest",()=>{for(const[t,n]of e){const e=o.observers.get(t);if("created"===n||"updated"===n){const{tableNode:n,tableElement:r}=j(t);void 0===e?l(n,t,r):r!==e[1]&&(o.removeObserver(t),l(n,t,r))}else"destroyed"===n&&o.removeObserver(t)}})},{skipInitialization:!1}),()=>{o.removeAllObservers()})}function it(n,l){n.hasNodes([Je])||g(255);const{hasNestedTables:r=t.signal(!1)}=l??{};return e.mergeRegister(n.registerCommand(h,t=>function({rows:t,columns:n,includeHeaders:l},r){const s=e.$getSelection()||e.$getPreviousSelection();if(!s||!e.$isRangeSelection(s))return!1;if(!r&&Oe(s.anchor.getNode()))return!1;const i=S(Number(t),Number(n),l);o.$insertNodeToNearestRoot(i);const a=i.getFirstDescendant();return e.$isTextNode(a)&&a.select(),!0}(t,r.peek()),e.COMMAND_PRIORITY_EDITOR),n.registerCommand(e.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(t,l)=>n===l&&function(t,n){const{nodes:l,selection:r}=t;if(!l.some(e=>Ze(e)||o.$dfs(e).some(e=>Ze(e.node)))){if(q(r)){let t="",n=!1;for(const o of l){const l=e.$isElementNode(o)&&!o.isInline();t.length>0&&(l||n)&&(t+="\n"),t+=o.getTextContent(),n=l}return r.insertRawText(t),!0}return!1}const s=q(r),i=e.$isRangeSelection(r);if(!(i&&null!==e.$findMatchingParent(r.anchor.getNode(),e=>d(e))&&null!==e.$findMatchingParent(r.focus.getNode(),e=>d(e))||s))return!1;if(1===l.length&&Ze(l[0]))return Y(l[0],r);if(i&&n.peek()&&!function(t){if(q(t)&&!t.focus.getNode().is(t.anchor.getNode()))return!0;if(e.$isRangeSelection(t)&&d(t.anchor.getNode())&&!t.anchor.getNode().is(t.focus.getNode()))return!0;return!1}(r))return!1;return!0}(t,r),e.COMMAND_PRIORITY_EDITOR),n.registerCommand(e.SELECT_ALL_COMMAND,lt,e.COMMAND_PRIORITY_LOW),n.registerCommand(e.CLICK_COMMAND,ot,e.COMMAND_PRIORITY_EDITOR),n.registerNodeTransform(Je,nt),n.registerNodeTransform(f,tt),n.registerNodeTransform(i,et))}const at={$accepts:C,$packageRun:e=>e.every(d)?[p().splice(0,0,e)]:[],name:"TableSchema"},ct={$accepts:d,name:"TableRowSchema"},ut=[/* @__PURE__ */n.defineImportRule({$import:(e,t)=>{const n=Qe();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 l=t.querySelector(":scope > colgroup");if(l){let e=[];for(const t of l.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[n.splice(0,0,o.$descendantsMatching(e.$importChildren(t),C))]},match:n.sel.tag("table"),name:"@lexical/table/table"}),/* @__PURE__ */n.defineImportRule({$import:(e,t)=>[p(r.test(t.style.height)?parseFloat(t.style.height):void 0).splice(0,0,o.$descendantsMatching(e.$importChildren(t),d))],match:n.sel.tag("tr"),name:"@lexical/table/tr"}),/* @__PURE__ */n.defineImportRule({$import:(t,o)=>{const l="TH"===o.nodeName,i=r.test(o.style.width)?parseFloat(o.style.width):void 0;let a=s.NO_STATUS;if(l){const t=o.getAttribute("scope");if("col"===t)a=s.COLUMN;else if("row"===t)a=s.ROW;else{const t=o.parentElement,n=e.isHTMLTableRowElement(t)&&(t.parentElement&&"THEAD"===t.parentElement.nodeName||0===t.rowIndex),l=0===o.cellIndex;n&&(a|=s.ROW),l&&(a|=s.COLUMN),a===s.NO_STATUS&&(a=s.ROW)}}const c=u(a,o.colSpan,i);c.__rowSpan=o.rowSpan;const d=o.style.backgroundColor;""!==d&&(c.__backgroundColor=d);const h=o.style.verticalAlign;(function(e){return"middle"===e||"bottom"===e})(h)&&(c.__verticalAlign=h);const g=t.get(n.ImportTextFormat),f=g|function(t){let n=0;const o=t.fontWeight;"700"!==o&&"bold"!==o||(n|=e.IS_BOLD),"italic"===t.fontStyle&&(n|=e.IS_ITALIC);const l=(t.textDecoration||"").split(" ");return l.includes("underline")&&(n|=e.IS_UNDERLINE),l.includes("line-through")&&(n|=e.IS_STRIKETHROUGH),n}(o.style),m=t.get(n.ImportTextStyle),p=o.style.color,C=p?{...m,color:p}:m,S=[];f!==g&&S.push(n.contextValue(n.ImportTextFormat,f)),C!==m&&S.push(n.contextValue(n.ImportTextStyle,C));const _=function(t){const n=[];let o=null;const l=()=>{if(null!==o){const t=o.getFirstChild();e.$isLineBreakNode(t)&&1===o.getChildrenSize()&&t.remove()}};for(const r of t)e.$isInlineElementOrDecoratorNode(r)||e.$isTextNode(r)||e.$isLineBreakNode(r)?null!==o?o.append(r):(o=e.$createParagraphNode().append(r),n.push(o)):(l(),o=null,n.push(r));return l(),0===n.length&&n.push(e.$createParagraphNode()),n}(t.$importChildren(o,{context:S})),b=l?_:n.$propagateTextAlignToBlockChildren(_,o);return[c.splice(0,0,b)]},match:n.sel.tag("td","th"),name:"@lexical/table/cell"})];const dt=/* @__PURE__ */e.defineExtension({build:(e,n,o)=>t.namedSignals(n),config:/* @__PURE__ */e.safeCast({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasNestedTables:!1,hasStickyScrollbar:!1,hasTabHandler:!0}),dependencies:[n.CoreImportExtension,/* @__PURE__ */e.configExtension(n.DOMImportExtension,{rules:ut})],name:"@lexical/table/Table",nodes:()=>[Je,f,i],register(n,o,l){const r=l.getOutput();let s=!1;return e.mergeRegister(t.effect(()=>{const t=r.hasHorizontalScroll.value,o=r.hasStickyScrollbar.value&&t,l=Xe(n);l!==t&&Ge(n,t),l===t&&s===o||n.update(e.$fullReconcile),s=o}),it(n,r),t.effect(()=>st(n,r.hasTabHandler.value)),t.effect(()=>{if(r.hasStickyScrollbar.value&&r.hasHorizontalScroll.value)return n.registerRootListener(t=>{if(t)return function(t){const n=new Map;return e.mergeRegister(()=>{for(const{cleanup:e}of n.values())e();n.clear()},t.registerMutationListener(Je,o=>{for(const[l,r]of o){const o=n.get(l);if("destroyed"===r){o&&(o.cleanup(),n.delete(l));continue}const s=t.getElementByKey(l),i=s&&e.isHTMLElement(s)?Ye(s):null;o&&i&&o.parts.scrollable===i.scrollable&&o.parts.scrollbar===i.scrollbar&&o.parts.tableElement===i.tableElement?ze(i.scrollable,i.scrollbar):(o&&(o.cleanup(),n.delete(l)),i&&n.set(l,{cleanup:Be(i),parts:i}))}},{skipInitialization:!1}))}(n)})}),t.effect(()=>r.hasCellMerge.value?void 0:rt(n)),t.effect(()=>r.hasCellBackgroundColor.value?void 0:n.registerNodeTransform(i,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}}),ht=/* @__PURE__ */e.defineExtension({dependencies:[dt],name:"@lexical/table/Import"});exports.$computeTableCellRectBoundary=W,exports.$computeTableMap=L,exports.$computeTableMapSkipCellCheck=k,exports.$createTableCellNode=u,exports.$createTableNode=Qe,exports.$createTableNodeWithDimensions=S,exports.$createTableRowNode=p,exports.$createTableSelection=function(){const t=e.$createPoint("root",0,"element"),n=e.$createPoint("root",0,"element");return new X("root",t,n)},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=v,exports.$deleteTableColumn__EXPERIMENTAL=A,exports.$deleteTableRowAtSelection=M,exports.$deleteTableRow__EXPERIMENTAL=O,exports.$findCellNode=Me,exports.$findTableNode=Oe,exports.$getElementForTableNode=je,exports.$getNodeTriplet=H,exports.$getTableAndElementByKey=j,exports.$getTableCellNodeFromLexicalNode=function(t){const n=e.$findMatchingParent(t,e=>d(e));return d(n)?n:null},exports.$getTableCellNodeRect=z,exports.$getTableColumnIndexFromTableCellNode=function(e){return _(e).getChildren().findIndex(t=>t.is(e))},exports.$getTableNodeFromLexicalNodeOrThrow=b,exports.$getTableRowIndexFromTableCellNode=function(e){const t=_(e);return b(t).getChildren().findIndex(e=>e.is(t))},exports.$getTableRowNodeFromTableCellNodeOrThrow=_,exports.$insertTableColumn=function(t,n,o=!0,l,r){const i=t.getChildren(),a=[];for(let t=0;t<i.length;t++){const o=i[t];if(C(o))for(let t=0;t<l;t++){const t=o.getChildren();if(n>=t.length||n<0)throw new Error("Table column target index out of range");const l=t[n];d(l)||g(12);const{left:i,right:c}=N(l,r);let h=s.NO_STATUS;(i&&i.hasHeaderState(s.ROW)||c&&c.hasHeaderState(s.ROW))&&(h|=s.ROW);const f=u(h);f.append(e.$createParagraphNode()),a.push({newTableCell:f,targetCell:l})}}return a.forEach(({newTableCell:e,targetCell:t})=>{o?t.insertAfter(e):t.insertBefore(e)}),t},exports.$insertTableColumnAtNode=E,exports.$insertTableColumnAtSelection=x,exports.$insertTableColumn__EXPERIMENTAL=R,exports.$insertTableRow=function(t,n,o=!0,l,r){const i=t.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 t=0;t<l;t++){const t=a.getChildren(),n=t.length,l=p();for(let o=0;o<n;o++){const n=t[o];d(n)||g(12);const{above:i,below:a}=N(n,r);let c=s.NO_STATUS;const h=i&&i.getWidth()||a&&a.getWidth()||void 0;(i&&i.hasHeaderState(s.COLUMN)||a&&a.hasHeaderState(s.COLUMN))&&(c|=s.COLUMN);const f=u(c,1,h);f.append(e.$createParagraphNode()),l.append(f)}o?a.insertAfter(l):a.insertBefore(l)}return t},exports.$insertTableRowAtNode=$,exports.$insertTableRowAtSelection=w,exports.$insertTableRow__EXPERIMENTAL=T,exports.$isScrollableTablesActive=Xe,exports.$isSimpleTable=B,exports.$isStickyScrollbarActive=qe,exports.$isTableCellNode=d,exports.$isTableNode=Ze,exports.$isTableRowNode=C,exports.$isTableSelection=q,exports.$mergeCells=P,exports.$moveTableColumn=function(e,t,n){if(t===n)return;const o=e.getColumnCount();if(t<0||t>=o||n<0||n>=o)return;if(!B(e))return;e.getChildren().filter(C).forEach(e=>{const o=e.getChildren(),[l]=o.splice(t,1);o.splice(n,0,l),e.splice(0,o.length,o)});const l=e.getColWidths();if(l&&l.length===o){const o=[...l],[r]=o.splice(t,1);o.splice(n,0,r),e.setColWidths(o)}},exports.$moveTableRow=function(e,t,n){if(t===n)return;const o=e.getChildren().filter(C),l=o.length;if(t<0||t>=l||n<0||n>=l)return;if(!B(e))return;const r=o[t],s=o[n];n>t?s.insertAfter(r):s.insertBefore(r)},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.$setTableColumnIsHeader=function(e,t,n){const[o]=k(e,null,null);o.length>0&&t>=0&&t<o[0].length||g(397,String(t));const l=n?s.COLUMN:s.NO_STATUS,r=new Set;for(let e=0;e<o.length;e++){const n=o[e][t];null!=n&&(r.has(n.cell)||(r.add(n.cell),n.cell.setHeaderStyles(l,s.COLUMN)))}},exports.$setTableRowIsHeader=function(e,t,n){const[o]=k(e,null,null);t>=0&&t<o.length||g(396,String(t));const l=o[t],r=n?s.ROW:s.NO_STATUS,i=new Set;for(let e=0;e<l.length;e++){const t=l[e];null!=t&&(i.has(t.cell)||(i.add(t.cell),t.cell.setHeaderStyles(r,s.ROW)))}},exports.$unmergeCell=function(){const t=e.$getSelection();e.$isRangeSelection(t)||q(t)||g(188);const n=t.anchor.getNode(),o=e.$findMatchingParent(n,d);return d(o)||g(148),I(o)},exports.$unmergeCellNode=I,exports.INSERT_TABLE_COMMAND=h,exports.TableCellHeaderStates=s,exports.TableCellNode=i,exports.TableExtension=dt,exports.TableImportExtension=ht,exports.TableImportRules=ut,exports.TableNode=Je,exports.TableObserver=Q,exports.TableRowNode=f,exports.TableRowSchema=ct,exports.TableSchema=at,exports.applyTableHandlers=de,exports.getDOMCellFromTarget=me,exports.getTableElement=le,exports.getTableObserverFromTableElement=fe,exports.registerTableCellUnmergeTransform=rt,exports.registerTablePlugin=it,exports.registerTableSelectionObserver=st,exports.setScrollableTablesActive=Ge;
|