@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.
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
 
9
- import{ElementNode as e,$getDocument as t,addClassNamesToElement as n,isHTMLElement as o,$isInlineElementOrDecoratorNode as l,$isTextNode as r,$isLineBreakNode as s,$createParagraphNode as i,$applyNodeReplacement as c,createCommand as a,$createTextNode as u,$getSelection as h,$isRangeSelection as d,$findMatchingParent as f,$isParagraphNode as g,$createPoint as m,$getNodeByKey as p,$isElementNode as C,$normalizeSelection__EXPERIMENTAL as _,isCurrentlyReadOnlyMode as S,TEXT_TYPE_TO_FORMAT as b,$getEditor as w,$setSelection as y,SELECTION_CHANGE_COMMAND as N,removeClassNamesFromElement as x,getDOMSelection as v,$createRangeSelection as T,$isRootNode as R,INSERT_PARAGRAPH_COMMAND as F,registerEventListener as O,KEY_ARROW_DOWN_COMMAND as A,KEY_ARROW_UP_COMMAND as K,KEY_ARROW_LEFT_COMMAND as k,KEY_ARROW_RIGHT_COMMAND as M,COMMAND_PRIORITY_HIGH as E,KEY_ESCAPE_COMMAND as $,DELETE_WORD_COMMAND as W,DELETE_LINE_COMMAND as z,DELETE_CHARACTER_COMMAND as H,KEY_BACKSPACE_COMMAND as B,KEY_DELETE_COMMAND as L,CUT_COMMAND as P,PASTE_COMMAND as D,getComposedEventTarget as I,isDOMNode as U,getActiveElement as X,COPY_COMMAND as Y,FORMAT_TEXT_COMMAND as J,FORMAT_ELEMENT_COMMAND as q,CONTROLLED_TEXT_INSERTION_COMMAND as j,KEY_TAB_COMMAND as V,FOCUS_COMMAND as G,$getNearestNodeFromDOMNode as Q,$isRootOrShadowRoot as Z,getDOMSelectionRange as ee,getDOMSelectionPoints as te,$getPreviousSelection as ne,$caretFromPoint as oe,$isExtendableTextPointCaret as le,$extendCaretToRange as re,$isSiblingCaret as se,$getSiblingCaret as ie,$setPointFromCaret as ce,$normalizeCaret as ae,$createRangeSelectionFromDom as ue,$isChildCaret as he,$getChildCaret as de,$getAdjacentChildCaret as fe,IS_FIREFOX as ge,$getNodeByKeyOrThrow as me,isDOMDocumentNode as pe,isDOMShadowRoot as Ce,setDOMStyleFromCSS as _e,setDOMUnmanaged as Se,mergeRegister as be,COMMAND_PRIORITY_EDITOR as we,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as ye,SELECT_ALL_COMMAND as Ne,COMMAND_PRIORITY_LOW as xe,CLICK_COMMAND as ve,$getRoot as Te,isHTMLTableRowElement as Re,IS_BOLD as Fe,IS_ITALIC as Oe,IS_UNDERLINE as Ae,IS_STRIKETHROUGH as Ke,defineExtension as ke,$fullReconcile as Me,configExtension as Ee,safeCast as $e}from"lexical";import{signal as We,effect as ze,namedSignals as He}from"@lexical/extension";import{defineImportRule as Be,sel as Le,ImportTextFormat as Pe,ImportTextStyle as De,contextValue as Ie,$propagateTextAlignToBlockChildren as Ue,CoreImportExtension as Xe,DOMImportExtension as Ye}from"@lexical/html";import{$descendantsMatching as Je,objectKlassEquals as qe,$insertFirst as je,$insertNodeToNearestRoot as Ve,$dfs as Ge,$unwrapAndFilterDescendants as Qe}from"@lexical/utils";import{copyToClipboard as Ze,$getClipboardDataFromSelection as et}from"@lexical/clipboard";const tt=/^(\d+(?:\.\d+)?)px$/,nt={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class ot extends e{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new ot(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:rt,priority:0}),th:e=>({conversion:rt,priority:0})}}static importJSON(e){return st().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=nt.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(e){const o=t().createElement(this.getTag());return this.__width&&(o.style.width=`${this.__width}px`),this.__colSpan>1&&(o.colSpan=this.__colSpan),this.__rowSpan>1&&(o.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(o.style.backgroundColor=this.__backgroundColor),lt(this.__verticalAlign)&&(o.style.verticalAlign=this.__verticalAlign),n(o,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),o}exportDOM(e){const t=super.exportDOM(e);if(o(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...lt(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=nt.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!==nt.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 lt(e){return"middle"===e||"bottom"===e}function rt(e){const t=e,n=e.nodeName.toLowerCase();let c;tt.test(t.style.width)&&(c=parseFloat(t.style.width));let a=nt.NO_STATUS;if("th"===n){const e=t.getAttribute("scope");if("col"===e)a=nt.COLUMN;else if("row"===e)a=nt.ROW;else{const e=t.parentElement,n=o(e)&&"tr"===e.nodeName.toLowerCase()&&o(e.parentElement)&&("thead"===e.parentElement.nodeName.toLowerCase()||0===e.rowIndex),l=0===t.cellIndex;n&&(a|=nt.ROW),l&&(a|=nt.COLUMN),a===nt.NO_STATUS&&(a=nt.ROW)}}const u=st(a,t.colSpan,c);u.__rowSpan=t.rowSpan;const h=t.style.backgroundColor;""!==h&&(u.__backgroundColor=h);const d=t.style.verticalAlign;lt(d)&&(u.__verticalAlign=d);const f=t.style,g=(f&&f.textDecoration||"").split(" "),m="700"===f.fontWeight||"bold"===f.fontWeight,p=g.includes("line-through"),C="italic"===f.fontStyle,_=g.includes("underline"),S=f.color;return{after:e=>{const t=[];let n=null;const o=()=>{if(n){const e=n.getFirstChild();s(e)&&1===n.getChildrenSize()&&e.remove()}};for(const c of e)if(l(c)||r(c)||s(c)){if(r(c)&&(m&&c.toggleFormat("bold"),p&&c.toggleFormat("strikethrough"),C&&c.toggleFormat("italic"),_&&c.toggleFormat("underline"),S)){const e=c.getStyle();e.includes("color:")||c.setStyle(e+`color: ${S};`)}n?n.append(c):(n=i().append(c),t.push(n))}else t.push(c),o(),n=null;return o(),0===t.length&&t.push(i()),t},node:u}}function st(e=nt.NO_STATUS,t=1,n){return c(new ot(e,t,n))}function it(e){return e instanceof ot}const ct=/* @__PURE__ */a("INSERT_TABLE_COMMAND");function at(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 ut extends e{__height;static getType(){return"tablerow"}static clone(e){return new ut(e.__height,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__height=e.__height}static importDOM(){return{tr:e=>({conversion:ht,priority:0})}}static importJSON(e){return dt().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(e){const o=t().createElement("tr");return this.__height&&(o.style.height=`${this.__height}px`),n(o,e.theme.tableRow),o}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 ht(e){const t=e;let n;return tt.test(t.style.height)&&(n=parseFloat(t.style.height)),{after:e=>Je(e,it),node:dt(n)}}function dt(e){return c(new ut(e))}function ft(e){return e instanceof ut}function gt(e,t,n=!0){const o=no();for(let l=0;l<e;l++){const e=dt();for(let o=0;o<t;o++){let t=nt.NO_STATUS;"object"==typeof n?(0===l&&n.rows&&(t|=nt.ROW),0===o&&n.columns&&(t|=nt.COLUMN)):n&&(0===l&&(t|=nt.ROW),0===o&&(t|=nt.COLUMN));const r=st(t),s=i();s.append(u()),r.append(s),e.append(r)}o.append(e)}return o}function mt(e){const t=f(e,e=>it(e));return it(t)?t:null}function pt(e){const t=f(e,e=>ft(e));if(ft(t))return t;throw new Error("Expected table cell to be inside of table row.")}function Ct(e){const t=f(e,e=>oo(e));if(oo(t))return t;throw new Error("Expected table cell to be inside of table.")}function _t(e){const t=pt(e);return Ct(t).getChildren().findIndex(e=>e.is(t))}function St(e){return pt(e).getChildren().findIndex(t=>t.is(e))}function bt(e,t){const n=Ct(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)}}function wt(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function yt(e,t,n=!0,o,l){const r=e.getChildren();if(t>=r.length||t<0)throw new Error("Table row target index out of range");const s=r[t];if(!ft(s))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=s.getChildren(),t=e.length,o=dt();for(let n=0;n<t;n++){const t=e[n];it(t)||at(12);const{above:r,below:s}=bt(t,l);let c=nt.NO_STATUS;const a=r&&r.getWidth()||s&&s.getWidth()||void 0;(r&&r.hasHeaderState(nt.COLUMN)||s&&s.hasHeaderState(nt.COLUMN))&&(c|=nt.COLUMN);const u=st(c,1,a);u.append(i()),o.append(u)}n?s.insertAfter(o):s.insertBefore(o)}return e}const Nt=(e,t)=>e===nt.BOTH||e===t?t:nt.NO_STATUS;function xt(e=!0){const t=h();d(t)||tn(t)||at(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[l]=Ut(n),[r,,s]=Ut(o),[,i,c]=Dt(s,r,l),{startRow:a}=c,{startRow:u}=i;return e?Tt(a+l.__rowSpan>u+r.__rowSpan?l:r,!0):Tt(u<a?r:l,!1)}const vt=xt;function Tt(e,t=!0){const[,,n]=Ut(e),[o,l]=Dt(n,e,e),r=o[0].length,{startRow:s}=l;let c=null;if(t){const t=s+e.__rowSpan-1,l=o[t],a=dt();for(let e=0;e<r;e++){const{cell:n,startRow:o}=l[e];if(o+n.__rowSpan-1<=t){const t=l[e].cell.__headerState,n=Nt(t,nt.COLUMN);a.append(st(n).append(i()))}else n.setRowSpan(n.__rowSpan+1)}const u=n.getChildAtIndex(t);ft(u)||at(256),u.insertAfter(a),c=a}else{const e=s,t=o[e],l=dt();for(let n=0;n<r;n++){const{cell:o,startRow:r}=t[n];if(r===e){const e=t[n].cell.__headerState,o=Nt(e,nt.COLUMN);l.append(st(o).append(i()))}else o.setRowSpan(o.__rowSpan+1)}const a=n.getChildAtIndex(e);ft(a)||at(257),a.insertBefore(l),c=l}return c}function Rt(e,t,n=!0,o,l){const r=e.getChildren(),s=[];for(let e=0;e<r.length;e++){const n=r[e];if(ft(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];it(o)||at(12);const{left:r,right:c}=bt(o,l);let a=nt.NO_STATUS;(r&&r.hasHeaderState(nt.ROW)||c&&c.hasHeaderState(nt.ROW))&&(a|=nt.ROW);const u=st(a);u.append(i()),s.push({newTableCell:u,targetCell:o})}}return s.forEach(({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)}),e}function Ft(e=!0){const t=h();d(t)||tn(t)||at(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[l]=Ut(n),[r,,s]=Ut(o),[,i,c]=Dt(s,r,l),{startColumn:a}=c,{startColumn:u}=i;return e?At(a+l.__colSpan>u+r.__colSpan?l:r,!0):At(u<a?r:l,!1)}const Ot=Ft;function At(e,t=!0,n=!0){const[,,o]=Ut(e),[l,r]=Dt(o,e,e),s=l.length,{startColumn:c}=r,a=t?c+e.__colSpan-1:c-1,u=o.getFirstChild();ft(u)||at(120);let h=null;function d(e=nt.NO_STATUS){const t=st(e).append(i());return null===h&&(h=t),t}let f=u;e:for(let e=0;e<s;e++){if(0!==e){const e=f.getNextSibling();ft(e)||at(121),f=e}const t=l[e],n=t[a<0?0:a].cell.__headerState,o=Nt(n,nt.ROW);if(a<0){zt(f,d(o));continue}const{cell:r,startColumn:s,startRow:i}=t[a];if(s+r.__colSpan-1<=a){let n=r,l=i,s=a;for(;l!==e&&n.__rowSpan>1;){if(s-=r.__colSpan,!(s>=0)){f.append(d(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,l=o}}n.insertAfter(d(o))}else r.setColSpan(r.__colSpan+1)}null!==h&&n&&Wt(h);const g=o.getColWidths();if(g){const e=[...g],t=a<0?0:a,n=e[t];e.splice(t,0,n),o.setColWidths(e)}return h}function Kt(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(ft(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function kt(){const e=h();d(e)||tn(e)||at(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,l]=Ut(t),[r]=Ut(n),[s,i,c]=Dt(l,o,r),{startRow:a}=i,{startRow:u}=c,f=u+r.__rowSpan-1;if(s.length===f-a+1)return void l.remove();const g=s[0].length,m=s[f+1],p=l.getChildAtIndex(f+1);for(let e=f;e>=a;e--){for(let t=g-1;t>=0;t--){const{cell:n,startRow:o,startColumn:l}=s[e][t];if(l===t){if(o<a||o+n.__rowSpan-1>f){const e=Math.max(o,a),t=Math.min(n.__rowSpan+o-1,f),l=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-l)}if(o>=a&&o+n.__rowSpan-1>f&&e===f){ft(p)||at(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?zt(p,n):o.insertAfter(n)}}}const t=l.getChildAtIndex(e);ft(t)||at(206,String(e)),t.remove()}if(void 0!==m){const{cell:e}=m[0];Wt(e)}else{const e=s[a-1],{cell:t}=e[0];Wt(t)}}const Mt=kt;function Et(){const e=h();d(e)||tn(e)||at(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,l]=Ut(t),[r]=Ut(n),[s,i,c]=Dt(l,o,r),{startColumn:a}=i,{startRow:u,startColumn:f}=c,g=Math.min(a,f),m=Math.max(a+o.__colSpan-1,f+r.__colSpan-1),p=m-g+1;if(s[0].length===m-g+1)return l.selectPrevious(),void l.remove();const C=s.length;for(let e=0;e<C;e++)for(let t=g;t<=m;t++){const{cell:n,startColumn:o}=s[e][t];if(o<g){if(t===g){const e=g-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[u],S=a>f?_[a+o.__colSpan]:_[f+r.__colSpan];if(void 0!==S){const{cell:e}=S;Wt(e)}else{const e=f<a?_[f-1]:_[a-1],{cell:t}=e;Wt(t)}const b=l.getColWidths();if(b){const e=[...b];e.splice(g,p),l.setColWidths(e)}}const $t=Et;function Wt(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function zt(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Ht(e){if(0===e.length)return null;const t=Ct(e[0]),[n]=It(t,null,null);let o=1/0,l=-1/0,r=1/0,s=-1/0;const c=new Set;for(const t of n)for(const n of t){if(!n||!n.cell)continue;const t=n.cell.getKey();if(!c.has(t)&&e.some(e=>e.is(n.cell))){c.add(t);const e=n.startRow,i=n.startColumn,a=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;o=Math.min(o,e),l=Math.max(l,e+a-1),r=Math.min(r,i),s=Math.max(s,i+u-1)}}if(o===1/0||r===1/0)return null;const a=l-o+1,u=s-r+1,h=n[o][r];if(!h.cell)return null;const d=h.cell;d.setColSpan(u),d.setRowSpan(a);const f=new Set([d.getKey()]);for(let e=o;e<=l;e++)for(let t=r;t<=s;t++){const o=n[e][t];if(!o.cell)continue;const l=o.cell,r=l.getKey();if(!f.has(r)){f.add(r);Bt(l)||d.append(...l.getChildren()),l.remove()}}return 0===d.getChildrenSize()&&d.append(i()),d}function Bt(e){if(1!==e.getChildrenSize())return!1;const t=e.getFirstChildOrThrow();return!(!g(t)||!t.isEmpty())}function Lt(){const e=h();d(e)||tn(e)||at(188);const t=e.anchor.getNode(),n=f(t,it);return it(n)||at(148),Pt(n)}function Pt(e){const[t,n,o]=Ut(e),l=t.__colSpan,r=t.__rowSpan;if(1===l&&1===r)return;const[s,c]=Dt(o,t,t),{startColumn:a,startRow:u}=c,h=t.__headerState&nt.COLUMN,d=Array.from({length:l},(e,t)=>{let n=h;for(let e=0;0!==n&&e<s.length;e++)n&=s[e][t+a].cell.__headerState;return n}),f=t.__headerState&nt.ROW,g=Array.from({length:r},(e,t)=>{let n=f;for(let e=0;0!==n&&e<s[0].length;e++)n&=s[t+u][e].cell.__headerState;return n});if(l>1){for(let e=1;e<l;e++)t.insertAfter(st(d[e]|g[0]).append(i()));t.setColSpan(1)}if(r>1){let e;for(let t=1;t<r;t++){const o=u+t,r=s[o];e=(e||n).getNextSibling(),ft(e)||at(125);let c=null;for(let e=0;e<a;e++){const t=r[e],n=t.cell;t.startRow===o&&(c=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===c)for(let n=l-1;n>=0;n--)zt(e,st(d[n]|g[t]).append(i()));else for(let e=l-1;e>=0;e--)c.insertAfter(st(d[e]|g[t]).append(i()))}t.setRowSpan(1)}}function Dt(e,t,n){const[o,l,r]=It(e,t,n);return null===l&&at(207),null===r&&at(208),[o,l,r]}function It(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];ft(o)||at(209);const c=s(e);for(let a=o.getFirstChild(),u=0;null!=a;a=a.getNextSibling()){for(it(a)||at(147);void 0!==c[u];)u++;const o={cell:a,startColumn:u,startRow:e},{__rowSpan:h,__colSpan:d}=a;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[u+e]=o}null!==t&&null===l&&t.is(a)&&(l=o),null!==n&&null===r&&n.is(a)&&(r=o)}}return[o,l,r]}function Ut(e){let t;if(e instanceof ot)t=e;else if("__type"in e){const n=f(e,it);it(n)||at(148),t=n}else{const n=f(e.getNode(),it);it(n)||at(148),t=n}const n=t.getParent();ft(n)||at(149);const o=n.getParent();return oo(o)||at(210),[t,n,o]}function Xt(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 c=e[t][n];if(!c)continue;const a=c.startColumn+c.cell.__colSpan-1,u=c.startRow+c.cell.__rowSpan-1,h=c.startColumn<=s&&a>=l,d=c.startRow<=i&&u>=r;if(h&&d){const e=Math.min(l,c.startColumn),t=Math.max(s,a),n=Math.min(r,c.startRow),h=Math.max(i,u);e===l&&t===s&&n===r&&h===i||(l=e,s=t,r=n,i=h,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:l,minRow:r}}function Yt(e){const t=e.getChildren();let n=null;for(const e of t){if(!ft(e))return!1;if(null===n&&(n=e.getChildrenSize()),e.getChildrenSize()!==n)return!1;const t=e.getChildren();for(const e of t)if(!it(e)||1!==e.getRowSpan()||1!==e.getColSpan())return!1}return(n||0)>0}function Jt(e,t,n){if(t===n)return;const o=e.getColumnCount();if(t<0||t>=o||n<0||n>=o)return;if(!Yt(e))return;e.getChildren().filter(ft).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)}}function qt(e,t,n){if(t===n)return;const o=e.getChildren().filter(ft),l=o.length;if(t<0||t>=l||n<0||n>=l)return;if(!Yt(e))return;const r=o[t],s=o[n];n>t?s.insertAfter(r):s.insertBefore(r)}function jt(e){const[t,,n]=Ut(e),o=n.getChildren().filter(ft),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(it);let l=0;for(let o=0;o<n.length;o++){for(;s[e][l];)l++;const r=n[o],i=r.__rowSpan||1,c=r.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][l+n]=r;if(t===r)return{colSpan:c,columnIndex:l,rowIndex:e,rowSpan:i};l+=c}}return null}function Vt(e,t){const n=t.getStartEndPoints(),o=tn(t);if(null===n)return!1;const[l,s]=n,[c,a,u]=Ut(l),h=f(s.getNode(),e=>it(e));if(!(it(c)&&it(h)&&ft(a)&&oo(u)))return!1;const[d,g,m]=Dt(u,c,h),[p]=It(e,null,null),C=d.length,_=C>0?d[0].length:0;let S=g.startRow,b=g.startColumn,w=p.length,y=w>0?p[0].length:0;if(o){const e=Xt(d,g,m),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;S=e.minRow,b=e.minColumn,w=Math.min(w,t),y=Math.min(y,n)}let N=!1;const x=Math.min(C,S+w)-1,v=Math.min(_,b+y)-1,T=new Set;for(let e=S;e<=x;e++)for(let t=b;t<=v;t++){const n=d[e][t];T.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(Pt(n.cell),T.add(n.cell.getKey()),N=!0))}let[R]=It(u.getWritable(),null,null);const F=w-C+S;for(let e=0;e<F;e++){Tt(R[C-1][0].cell)}const O=y-_+b;for(let e=0;e<O;e++){At(R[0][_-1].cell,!0,!1)}[R]=It(u.getWritable(),null,null);for(let e=S;e<S+w;e++)for(let t=b;t<b+y;t++){const n=e-S,o=t-b,l=p[n][o];if(l.startRow!==n||l.startColumn!==o)continue;const s=l.cell;if(1!==s.__rowSpan||1!==s.__colSpan){const n=[],o=Math.min(e+s.__rowSpan,S+w)-1,l=Math.min(t+s.__colSpan,b+y)-1;for(let r=e;r<=o;r++)for(let e=t;e<=l;e++){const t=R[r][e];n.push(t.cell)}Ht(n),N=!0}const{cell:c}=R[e][t],a=s.getBackgroundColor();null!=a&&c.setBackgroundColor(a);const u=c.getChildren();s.getChildren().forEach(e=>{if(r(e)){i().append(e),c.append(e)}else c.append(e)}),u.forEach(e=>e.remove())}if(o&&N){const[e]=It(u.getWritable(),null,null);e[g.startRow][g.startColumn].cell.selectEnd()}return!0}function Gt(e,t,n){const[o]=It(e,null,null);t>=0&&t<o.length||at(396,String(t));const l=o[t],r=n?nt.ROW:nt.NO_STATUS,s=new Set;for(let e=0;e<l.length;e++){const t=l[e];null!=t&&(s.has(t.cell)||(s.add(t.cell),t.cell.setHeaderStyles(r,nt.ROW)))}}function Qt(e,t,n){const[o]=It(e,null,null);o.length>0&&t>=0&&t<o[0].length||at(397,String(t));const l=n?nt.COLUMN:nt.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,nt.COLUMN)))}}function Zt(e){const[[t,n,o,l],[r,s,i,c]]=["anchor","focus"].map(t=>{const n=e[t].getNode(),o=f(n,it);it(o)||at(238,t,n.getKey(),n.getType());const l=o.getParent();ft(l)||at(239,t);const r=l.getParent();return oo(r)||at(240,t),[n,o,l,r]});return l.is(c)||at(241),{anchorCell:n,anchorNode:t,anchorRow:o,anchorTable:l,focusCell:s,focusNode:r,focusRow:i,focusTable:c}}class en{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=p(this.tableKey),t=p(this.anchor.key),n=p(this.focus.key);return null!==e&&null!==t&&null!==n}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return tn(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 en(this.tableKey,m(this.anchor.key,this.anchor.offset,this.anchor.type),m(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){if(""===e)return;const t=(e.endsWith("\n")?e.slice(0,-1):e).split("\n").map(e=>e.split("\t")),n=no();for(const e of t){const t=dt();for(const n of e){const e=st(nt.NO_STATUS),o=i();n&&o.append(u(n)),e.append(o),t.append(e)}n.append(t)}const{anchorCell:o}=Zt(this);Vt(n,o.select(0,o.getChildrenSize()))}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(it).forEach(e=>{const n=e.getFirstChild();g(n)&&(t|=n.getTextFormat())});const n=b[e];return 0!==(t&n)}insertNodes(e){const t=this.focus.getNode();C(t)||at(151);_(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=Zt(this),n=jt(e);null===n&&at(153);const o=jt(t);null===o&&at(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 e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=Zt(this),l=o.getParents()[1];if(l!==t){if(t.isParentOf(o)){const e=l.getParent();null==e&&at(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&at(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[r,s,i]=Dt(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=Xt(r,s,i),d=new Map([[t.getKey(),t]]);let f=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=r[e][t],o=n.getParent();ft(o)||at(160),o!==f&&(d.set(o.getKey(),o),f=o),d.has(n.getKey())||ln(n,e=>{d.set(e.getKey(),e)})}const g=Array.from(d.values());return S()||(this._cachedNodes=g),g}getTextContent(){const e=this.getNodes().filter(e=>it(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 tn(e){return e instanceof en}function nn(){const e=m("root",0,"element"),t=m("root",0,"element");return new en("root",e,t)}function on(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=h(),l=tn(o)?o.clone():nn();return l.set(e.getKey(),t.getKey(),n.getKey()),l}function ln(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&C(o)&&n.push(o.getChildren())}}function rn(e,t=w()){const n=p(e);oo(n)||at(231,e);const o=gn(n,t.getElementByKey(e));return null===o&&at(232,e),{tableElement:o,tableNode:n}}class sn{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 e=[];for(const[t,[n]]of Array.from(this.observers.entries())){const o=p(t);oo(o)?e.push([o,n]):this.removeObserver(t)}return e}}class cn{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 rn(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=Rn(n,o)})});this.editor.read("latest",()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Rn(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})})}$clearHighlight(e=!0){const t=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:n,tableElement:o}=this.$lookup();Fn(t,Rn(n,o),null),e&&null!==h()&&(y(null),t.dispatchCommand(N,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();x(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:e}=this.$lookup();n(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&at(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Fn(t,this.table,this.tableSelection)}else this.$clearHighlight()}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=v(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),l=e.x,r=e.y;if(this.focusCell=e,!this.isHighlightingCells){(t||this.anchorX!==l||this.anchorY!==r||null!=this.tableSelection&&null!=this.anchorCellNodeKey)&&(this.isHighlightingCells=!0,this.$disableHighlightStyle())}if(-1!==this.focusX&&-1!==this.focusY&&l===this.focusX&&r===this.focusY)return!1;if(this.focusX=l,this.focusY=r,this.isHighlightingCells){const s=Jn(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey){let e=s;if(null===e&&t&&(e=o.getCellNodeFromCords(l,r,this.table)),null!==e){const t=this.$getAnchorTableCellOrThrow();return this.focusCellNodeKey=e.getKey(),this.tableSelection=on(o,t,e),y(this.tableSelection),n.dispatchCommand(N,void 0),Fn(n,this.table,this.tableSelection),!0}}}return!1}$getAnchorTableCell(){const e=this.anchorCellNodeKey?p(this.anchorCellNodeKey):null;return it(e)?e:null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&at(234),e}$getFocusTableCell(){const e=this.focusCellNodeKey?p(this.focusCellNodeKey):null;return it(e)?e:null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&at(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=Jn(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=on(t,n,n),this.anchorCellNodeKey=e}}$formatCells(e){const t=h();tn(t)||at(236);const n=T(),o=n.anchor,l=n.focus,r=t.getNodes().filter(it);r.length>0||at(237);const s=r[0].getFirstChild(),i=g(s)?s.getFormatFlags(e,null):null;r.forEach(t=>{o.set(t.getKey(),0,"element"),l.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)}),y(t),this.editor.dispatchCommand(N,void 0)}$clearText(){const{editor:e}=this,t=p(this.tableNodeKey);if(!oo(t))throw new Error("Expected TableNode.");const n=h();tn(n)||at(253);const o=n.getNodes().filter(it),l=t.getFirstChild(),r=t.getLastChild();if(o.length>0&&null!==l&&null!==r&&ft(l)&&ft(r)&&o[0]===l.getFirstChild()&&o[o.length-1]===r.getLastChild()){t.selectPrevious();const n=t.getParent();return t.remove(),void(R(n)&&n.isEmpty()&&e.dispatchCommand(F,void 0))}o.forEach(e=>{if(C(e)){const t=i(),n=u();t.append(n),e.append(t),e.getChildren().forEach(e=>{e!==t&&e.remove()})}}),Fn(e,this.table,null),y(null),e.dispatchCommand(N,void 0)}}const an="__lexicalTableSelection";function un(e){const t=me(e);return oo(t)||at(386,e),t}const hn=40;function dn(e,t,n){const o=e=>Math.max(1,Math.ceil(Math.min(hn,e)/hn*18));return e<=t+hn?-o(t+hn-e):e>=n-hn?o(e-(n-hn)):0}function fn(e){return o(e)&&"TABLE"===e.nodeName}function gn(e,t){if(!t)return t;const n=fn(t)?t:t.querySelector("table");return fn(n)||at(341,e.constructor.name,e.getType(),e.getKey(),t.nodeName),n}function mn(e){return e._window}function pn(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;it(n)&&(o=n)}return null}const Cn=[[A,"down"],[K,"up"],[k,"backward"],[M,"forward"]],_n=[W,z,H],Sn=[B,L];function bn(e,t){return e.registerRootListener(n=>{if(null===n)return;const o=e._window;if(null===o)return;return O(o,"pointerdown",o=>{const l=I(o);if(0!==o.button||!U(l)||!n.contains(l))return;const r=function(e){const t=vn(e);if(null===t)return null;let n=t.elem;for(;null!=n;){if("TABLE"===n.nodeName&&an in n&&n[an])return{cellElement:t,tableElement:n,tableObserver:n[an]};n=n.parentNode}return null}(l);e.update(()=>{if(tn(h())){for(const[e]of t.observers.values())e.$clearHighlight(!1);y(null),e.dispatchCommand(N,void 0)}if(!r)return;const{tableObserver:n,tableElement:l,cellElement:s}=r;!function(e,t,n,o,l,r){const s=e._window;if(!s)return;const i=n=>{if(l.isSelecting)return;l.isSelecting=!0,null!==n&&null===l.anchorCell&&e.update(()=>{l.$setAnchorCellForSelection(n)});let i=t.clientX,c=t.clientY,a=null;const u=()=>{l.isSelecting=!1,null!==a&&(s.cancelAnimationFrame(a),a=null),s.removeEventListener("pointerup",S),s.removeEventListener("pointermove",b)},h=(e,t)=>{const n=o.getRootNode();if(!pe(n)&&!Ce(n))return null;for(const l of n.elementsFromPoint(e,t)){const e=Tn(o,l);if(e)return e}return null},d=(t,n)=>{null===l.anchorCell&&e.update(()=>{l.$setAnchorCellForSelection(t)}),null!==l.focusCell&&t.elem===l.focusCell.elem||(r.setNextFocus({focusCell:t,override:n,tableKey:l.tableNodeKey}),e.dispatchCommand(N,void 0))},f=e=>{for(let t=o.parentElement;t;t=t.parentElement){if("x"===e?t.scrollWidth>t.clientWidth:t.scrollHeight>t.clientHeight){const n=s.getComputedStyle(t),o="x"===e?n.overflowX:n.overflowY;if("auto"===o||"scroll"===o)return t}}return null},g=(e,t,n)=>{let o,l;if(null===e)o=0,l="x"===n?s.innerWidth:s.innerHeight;else{const t=e.getBoundingClientRect();o="x"===n?t.left:t.top,l="x"===n?t.right:t.bottom}const r=dn(t,o,l);if(0===r)return!1;if(null===e){const e="x"===n?s.scrollX:s.scrollY;return s.scrollBy("x"===n?r:0,"x"===n?0:r),("x"===n?s.scrollX:s.scrollY)!==e}if("x"===n){const t=e.scrollLeft;return e.scrollLeft+=r,e.scrollLeft!==t}const i=e.scrollTop;return e.scrollTop+=r,e.scrollTop!==i},m=(e,t)=>{let n=i,o=c;if(null===e)n=Math.min(Math.max(n,1),s.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),s.innerHeight-1);else{const e=t.getBoundingClientRect();o=Math.min(Math.max(o,e.top+1),e.bottom-1)}return[n,o]},p=()=>{const e=f("x");if(null!==e){const t=e.getBoundingClientRect();if(0!==dn(i,t.left,t.right))return!0}const t=f("y"),n=null===t?0:t.getBoundingClientRect().top,o=null===t?s.innerHeight:t.getBoundingClientRect().bottom;return 0!==dn(c,n,o)},C=()=>{if(a=null,!l.isSelecting)return;const e=f("x"),t=f("y"),n=null!==e&&g(e,i,"x"),o=g(t,c,"y");if(n||o){const[n,o]=m(e,t),l=h(n,o);l&&d(l,!1),a=s.requestAnimationFrame(C)}},_=()=>{null===a&&"touch"!==l.pointerType&&p()&&(a=s.requestAnimationFrame(C))},S=()=>{u()},b=e=>{if(!(e=>!(1&~e.buttons))(e)&&l.isSelecting)return void u();const t=I(e);if(!U(t))return;i=e.clientX,c=e.clientY;let n=null;const r=!(ge||o.contains(t));n=r?Tn(o,t):h(e.clientX,e.clientY),n&&d(n,r),_()};s.addEventListener("pointerup",S,l.listenerOptions),s.addEventListener("pointermove",b,l.listenerOptions)};l.pointerType=t.pointerType;const c=un(l.tableNodeKey),a=ne();if(ge&&t.shiftKey&&$n(a,c)&&(d(a)||tn(a))){const e=a.anchor.getNode(),o=pn(c,a.anchor.getNode());if(o)l.$setAnchorCellForSelection(Yn(l,o)),l.$setFocusCellForSelection(n),In(t);else{(c.isBefore(e)?c.selectStart():c.selectEnd()).anchor.set(a.anchor.key,a.anchor.offset,a.anchor.type)}}else"touch"!==t.pointerType&&l.$setAnchorCellForSelection(n);i(n)}(e,o,s,l,n,t)})})})}function wn(e,t,n,o,l){const r=n.getRootElement(),s=mn(n);null!==r&&null!==s||at(246);const i=new cn(n,e.getKey()),c=gn(e,t);!function(e,t){null!==xn(e)&&at(205);e[an]=t}(c,i),i.listenersToRemove.add(()=>function(e,t){xn(e)===t&&delete e[an]}(c,i));i.listenersToRemove.add(O(c,"mousedown",e=>{const t=I(e);if(e.detail>=3&&U(t)){null!==vn(t)&&e.preventDefault()}},i.listenerOptions));for(const[t,o]of Cn)i.listenersToRemove.add(n.registerCommand(t,t=>Dn(n,t,o,e,i,l),E));i.listenersToRemove.add(n.registerCommand($,t=>{const n=h();if(tn(n)){const o=pn(e,n.focus.getNode());if(null!==o)return In(t),o.selectEnd(),!0}return!1},E));const a=t=>()=>{const n=h();if(!$n(n,e))return!1;if(tn(n))return i.$clearText(),!0;if(d(n)){if(!it(pn(e,n.anchor.getNode())))return!1;const o=n.anchor.getNode(),l=n.focus.getNode(),r=e.isParentOf(o),s=e.isParentOf(l);if(r&&!s||s&&!r)return i.$clearText(),!0;const c=f(n.anchor.getNode(),e=>C(e)),a=c&&f(c,e=>C(e)&&it(e.getParent()));if(!C(a)||!C(c))return!1;if(t===z&&null===a.getPreviousSibling())return!0}return!1};for(const e of _n)i.listenersToRemove.add(n.registerCommand(e,a(e),E));const g=t=>{const n=h();if(!tn(n)&&!d(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",l=o?"focus":"anchor",{key:r,offset:s,type:i}=n[l];return e[n[t].isBefore(n[l])?"selectPrevious":"selectNext"]()[l].set(r,s,i),!1}return!!$n(n,e)&&(!!tn(n)&&(t&&(t.preventDefault(),t.stopPropagation()),i.$clearText(),!0))};for(const e of Sn)i.listenersToRemove.add(n.registerCommand(e,g,E));i.listenersToRemove.add(n.registerCommand(P,e=>{const t=h();if(t){if(!tn(t)&&!d(t))return!1;Ze(n,qe(e,ClipboardEvent)?e:null,et(t));const o=g(e);return d(t)?(t.removeText(),!0):o}return!1},E));const m=r.ownerDocument;return i.listenersToRemove.add(O(m,"paste",t=>{if(t.defaultPrevented)return;n.read("latest",()=>{const t=h();return r.contains(m.activeElement)&&tn(t)&&$n(t,e)})&&(t.preventDefault(),n.dispatchCommand(D,t))})),i.listenersToRemove.add(O(m,"copy",t=>{if(t.defaultPrevented)return;const o=I(t);if(o===r||U(o)&&r.contains(o))return;n.read("latest",()=>{const t=h();return r.contains(X(r))&&tn(t)&&$n(t,e)})&&(t.preventDefault(),n.dispatchCommand(Y,t))})),i.listenersToRemove.add(n.registerCommand(J,t=>{const n=h();if(!$n(n,e))return!1;if(tn(n))return i.$formatCells(t),!0;if(d(n)){const e=f(n.anchor.getNode(),e=>it(e));if(!it(e))return!1}return!1},E)),i.listenersToRemove.add(n.registerCommand(q,t=>{const n=h();if(!tn(n)||!$n(n,e))return!1;const o=n.anchor.getNode(),l=n.focus.getNode();if(!it(o)||!it(l))return!1;if(function(e,t){if(tn(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=Dt(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,e))return e.setFormat(t),!0;const[r,s,i]=Dt(e,o,l),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),d=Math.min(s.startColumn,i.startColumn),f=new Set;for(let e=u;e<=c;e++)for(let n=d;n<=a;n++){const o=r[e][n].cell;if(f.has(o))continue;f.add(o),o.setFormat(t);const l=o.getChildren();for(let e=0;e<l.length;e++){const n=l[e];C(n)&&!n.isInline()&&n.setFormat(t)}}return!0},E)),i.listenersToRemove.add(n.registerCommand(j,t=>{const o=h();if(!$n(o,e))return!1;if(tn(o))return i.$clearHighlight(),!1;if(d(o)){const l=f(o.anchor.getNode(),e=>it(e));if(!it(l))return!1;if("string"==typeof t){const l=Xn(n,o,e);if(l)return Un(l,e,[u(t)]),!0}}return!1},E)),o&&i.listenersToRemove.add(n.registerCommand(V,t=>{const n=h();if(!d(n)||!n.isCollapsed()||!$n(n,e))return!1;const o=Bn(n.anchor.getNode());return!(null===o||!e.is(Ln(o)))&&(In(t),function(e,t){const n="next"===t?"getNextSibling":"getPreviousSibling",o="next"===t?"getFirstChild":"getLastChild",l=e[n]();if(C(l))return l.selectEnd();const r=f(e,ft);null===r&&at(247);for(let e=r[n]();ft(e);e=e[n]()){const t=e[o]();if(C(t))return t.selectEnd()}const s=f(r,oo);null===s&&at(248);"next"===t?s.selectNext():s.selectPrevious()}(o,t.shiftKey?"previous":"next"),!0)},E)),i.listenersToRemove.add(n.registerCommand(G,t=>e.isSelected(),E)),i.listenersToRemove.add(n.registerCommand(F,()=>{const t=h();if(!d(t)||!t.isCollapsed()||!$n(t,e))return!1;const o=Xn(n,t,e);return!!o&&(Un(o,e),!0)},E)),i}function yn(e,t){const n=h(),o=ne(),l=e.getAndClearNextFocus();if(null!==l){const{tableKey:t,focusCell:o}=l,r=e.observers.get(t);r||at(335,t);const[s]=r;if(tn(n)&&n.tableKey===s.tableNodeKey)return(o.x!==s.focusX||o.y!==s.focusY)&&(s.$setFocusCellForSelection(o),!0);if(null!==s.anchorCell&&null!==s.anchorCellNodeKey&&o.elem!==s.anchorCell.elem&&null!==s.tableSelection)return s.$setFocusCellForSelection(o,!0),!0}const r=e.getAndClearShouldCheckSelectionForTable();if(r&&d(o)&&d(n)&&n.isCollapsed()){const e=p(r);if(oo(e)){const t=n.anchor.getNode(),o=e.getFirstChild(),l=Bn(t);if(null!==l&&ft(o)){const t=o.getFirstChild();if(it(t)&&e.is(f(l,n=>n.is(e)||n.is(t))))return t.selectStart(),!0}}}tn(n)&&function(e,t){const n=mn(e),o=ne();if(!t.is(o))return;const l=un(t.tableKey),r=v(n),s=r&&te(r,e.getRootElement());if(r&&s&&s.anchorNode&&s.focusNode){const n=Q(s.focusNode),o=n&&!l.isParentOf(n),i=Q(s.anchorNode),c=i&&l.isParentOf(i);if(o&&c&&r.rangeCount>0){const n=ue(r,e);n&&(n.anchor.set(l.getKey(),t.isBackward()?l.getChildrenSize():0,"element"),r.removeAllRanges(),y(n))}}}(t,n),d(n)&&function(e,t){const n=ne(),{anchor:o,focus:l}=e,r=o.getNode(),s=l.getNode(),i=Bn(r),c=Bn(s),a=i?Ln(i):null,u=c?Ln(c):null,h=e.isBackward(),f=i&&c&&a&&u&&a.is(u),g=u&&(!a||a.isParentOf(u)),m=a&&(!u||u.isParentOf(a));if(g){const t=e.clone(),[n]=Dt(u,c,c),o=n[0][0].cell,l=n[n.length-1].at(-1).cell;t.focus.set(h?o.getKey():l.getKey(),h?0:l.getChildrenSize(),"element"),y(t)}else if(m){const t=e.clone(),[n]=Dt(a,i,i),o=n[0][0].cell,l=n[n.length-1].at(-1).cell;t.anchor.set(h?l.getKey():o.getKey(),h?l.getChildrenSize():0,"element"),y(t)}else if(f){const o=t.observers.get(a.getKey());o||at(335,a.getKey());const[l]=o;if(i.is(c)||(l.$setAnchorCellForSelection(Yn(l,i)),l.$setFocusCellForSelection(Yn(l,c),!0)),"touch"===l.pointerType&&l.isSelecting&&e.isCollapsed()&&d(n)&&n.isCollapsed()){const e=Bn(n.anchor.getNode());e&&!e.is(c)&&(l.$setAnchorCellForSelection(Yn(l,e)),l.$setFocusCellForSelection(Yn(l,c),!0),l.pointerType=null)}}}(n,e);for(const[n,o]of e.$getTableNodesAndObservers())Nn(t,n,o);return!1}function Nn(e,t,n){const o=h(),l=ne();o&&!o.is(l)&&(tn(o)||tn(l))&&n.tableSelection&&!n.tableSelection.is(l)&&(tn(o)&&o.tableKey===n.tableNodeKey?n.$updateTableTableSelection(o):!tn(o)&&tn(l)&&l.tableKey===n.tableNodeKey&&n.$updateTableTableSelection(null)),n.hasHijackedSelectionStyles&&!t.isSelected()?function(e,t){t.$enableHighlightStyle(),On(t.table,t=>{const n=t.elem;t.highlighted=!1,Hn(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(e,n):!n.hasHijackedSelectionStyles&&t.isSelected()&&function(e,t){t.$disableHighlightStyle(),On(t.table,t=>{t.highlighted=!0,zn(e,t)})}(e,n)}function xn(e){return e[an]||null}function vn(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 Tn(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 Rn(e,t){const n=[],o={columns:0,domRows:n,rows:0};let l=gn(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 Fn(e,t,n){const o=new Set(n?n.getNodes():[]);On(t,(t,n)=>{const l=t.elem;o.has(n)?(t.highlighted=!0,zn(e,t)):(t.highlighted=!1,Hn(e,t),l.getAttribute("style")||l.removeAttribute("style"))})}function On(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const l=o[n];if(!l)continue;const r=Q(l.elem);null!==r&&t(l,r,{x:n,y:e})}}}const An=(e,t,n,o,l)=>{const r="forward"===l;switch(l){case"backward":case"forward":return n!==(r?e.table.columns-1:0)?Wn(t.getCellNodeFromCordsOrThrow(n+(r?1:-1),o,e.table),r):o!==(r?e.table.rows-1:0)?Wn(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?Wn(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Wn(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Kn(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 kn([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function Mn(e,t,[n,o]){const l=t[o],r=e[l];void 0===r&&at(250,o,String(l));const s=t[n],i=r[s];return void 0===i&&at(250,n,String(s)),i}function En(e,t,n,o,l){const r=Xt(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:l,maxRow:r}=t;let s=1,i=1,c=1,a=1;const u=e[l],h=e[r];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=l;t<=r;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,r),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=Kn(e,t);return null===n&&at(249,t.cell.getKey()),n}(r,n),[d,f]=kn(h);let g=r[d],m=r[f];"forward"===l?g+="maxColumn"===d?1:c:"backward"===l?g-="minColumn"===d?1:u:"down"===l?m+="maxRow"===f?1:i:"up"===l&&(m-="minRow"===f?1:a);const p=t[m];if(void 0===p)return!1;const C=p[g];if(void 0===C)return!1;const[_,S]=function(e,t,n){const o=Xt(e,t,n),l=Kn(o,t);if(l)return[Mn(e,o,l),Mn(e,o,kn(l))];const r=Kn(o,n);if(r)return[Mn(e,o,kn(r)),Mn(e,o,r)];const s=["minColumn","minRow"];return[Mn(e,o,s),Mn(e,o,kn(s))]}(t,n,C),b=Yn(e,_.cell),w=Yn(e,S.cell);return e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(w,!0),!0}function $n(e,t){if(d(e)||tn(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function Wn(e,t){t?e.selectStart():e.selectEnd()}function zn(e,t){const o=t.elem,l=e._config.theme;it(Q(o))||at(131),n(o,l.tableCellSelected)}function Hn(e,t){const n=t.elem;it(Q(n))||at(131);const o=e._config.theme;x(n,o.tableCellSelected)}function Bn(e){const t=f(e,it);return it(t)?t:null}function Ln(e){const t=f(e,oo);return oo(t)?t:null}function Pn(e,t,n,o,l,r,s){const i=oe(n.focus,l?"previous":"next");if(le(i))return!1;let c=i;for(const e of re(i).iterNodeCarets("shadowRoot")){if(!se(e)||!C(e.origin))return!1;c=e}const a=c.getParentAtCaret();if(!it(a))return!1;const u=a,h=function(e){for(const t of re(e).iterNodeCarets("root")){const{origin:n}=t;if(it(n)){if(he(t))return de(n,e.direction)}else if(!ft(n))break}return null}(ie(u,c.direction)),d=f(u,oo);if(!d||!d.is(r))return!1;const g=e.getElementByKey(u.getKey()),m=vn(g);if(!g||!m)return!1;const p=eo(e,d);if(s.table=p,h)if("extend"===o){const t=vn(e.getElementByKey(h.origin.getKey()));if(!t)return!1;s.$setAnchorCellForSelection(m),s.$setFocusCellForSelection(t,!0)}else{const e=ae(h);ce(n.anchor,e),ce(n.focus,e)}else if("extend"===o)s.$setAnchorCellForSelection(m),s.$setFocusCellForSelection(m,!0);else{const e=function(e){const t=fe(e);return he(t)?ae(t):e}(ie(d,i.direction));ce(n.anchor,e),ce(n.focus,e)}return In(t),!0}function Dn(e,t,n,o,l,s){if(("up"===n||"down"===n)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const i=h();if(!$n(i,o)){if(d(i)){if("backward"===n){if(i.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(C(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(i.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!oo(n)&&(In(t),t.shiftKey?i.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===n||"down"===n)){const e=i.focus.getNode();if(!i.isCollapsed()&&("up"===n&&!i.isBackward()||"down"===n&&i.isBackward())){let l=f(e,e=>oo(e));if(it(l)&&(l=f(l,oo)),l!==o)return!1;if(!l)return!1;const s="down"===n?l.getNextSibling():l.getPreviousSibling();if(!s)return!1;let c=0;"up"===n&&C(s)&&(c=s.getChildrenSize());let a=s;if("up"===n&&C(s)){const e=s.getLastChild();a=e||s,c=r(a)?a.getTextContentSize():0}const u=i.clone();return u.focus.set(a.getKey(),c,r(a)?"text":"element"),y(u),In(t),!0}if(Z(e)){const e="up"===n?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==pn(o,e)){const e=o.getFirstDescendant(),t=o.getLastDescendant();if(!e||!t)return!1;const[n]=Ut(e),[r]=Ut(t),s=o.getCordsFromCellNode(n,l.table),i=o.getCordsFromCellNode(r,l.table),c=o.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=o.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let o=f(e,e=>C(e)&&!e.isInline());if(it(o)&&(o=f(o,oo)),!o)return!1;const r="down"===n?o.getNextSibling():o.getPreviousSibling();if(oo(r)&&l.tableNodeKey===r.getKey()){const e=r.getFirstDescendant(),o=r.getLastDescendant();if(!e||!o)return!1;const[l]=Ut(e),[s]=Ut(o),c=i.clone();return c.focus.set(("up"===n?l:s).getKey(),"up"===n?0:s.getChildrenSize(),"element"),In(t),y(c),!0}}}}return"down"===n&&Gn(e)&&s.setShouldCheckSelectionForTable(o.getKey()),!1}if(d(i)){if("backward"===n||"forward"===n){return Pn(e,t,i,t.shiftKey?"extend":"move","backward"===n,o,l)}if(i.isCollapsed()){const{anchor:r,focus:c}=i,a=f(r.getNode(),it),u=f(c.getNode(),it);if(!it(a)||!a.is(u))return!1;const h=Ln(a);if(h!==o&&null!=h){const o=gn(h,e.getElementByKey(h.getKey()));if(null!=o)return l.table=Rn(h,o),Dn(e,t,n,h,l,s)}const d=e.getElementByKey(a.__key),g=e.getElementByKey(r.key);if(null==g||null==d)return!1;let m;if("element"===r.type)m=g.getBoundingClientRect();else{const t=v(mn(e));if(null===t||0===t.rangeCount)return!1;const n=ee(t,e.getRootElement());if(null===n)return!1;m=n.getBoundingClientRect()}const p="up"===n?a.getFirstChild():a.getLastChild();if(null==p)return!1;const C=e.getElementByKey(p.__key);if(null==C)return!1;const _=C.getBoundingClientRect();if("up"===n?_.top>m.top-m.height:m.bottom+m.height>_.bottom){In(t);const e=o.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return An(l,o,e.x,e.y,n);{const t=o.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}}else if(tn(i)){const{anchor:r,focus:s,tableKey:c}=i;if(c!==o.getKey())return!1;const a=f(r.getNode(),it),u=f(s.getNode(),it),[h]=i.getNodes();oo(h)||at(251);const d=gn(h,e.getElementByKey(h.getKey()));if(!it(a)||!it(u)||!oo(h)||null==d)return!1;l.$updateTableTableSelection(i);const g=Rn(h,d),m=o.getCordsFromCellNode(a,g),p=o.getDOMCellFromCordsOrThrow(m.x,m.y,g);if(l.$setAnchorCellForSelection(p),In(t),t.shiftKey){const[e,t,r]=Dt(o,a,u);return En(l,e,t,r,n)}return u.selectEnd(),!0}return!1}function In(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function Un(e,t,n){const o=i();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function Xn(e,t,n){const o=n.getParent();if(!o)return;const l=v(mn(e));if(!l)return;const r=te(l,e.getRootElement()).anchorNode,s=e.getElementByKey(o.getKey()),i=gn(n,e.getElementByKey(n.getKey()));if(!r||!s||!i||!s.contains(r)||i.contains(r))return;const c=f(t.anchor.getNode(),e=>it(e));if(!c)return;const a=f(c,e=>oo(e));if(!oo(a)||!a.is(n))return;const[u,h]=Dt(n,c,c),d=u[0][0],g=u[u.length-1][u[0].length-1],{startRow:m,startColumn:p}=h,C=m===d.startRow&&p===d.startColumn,_=m===g.startRow&&p===g.startColumn;return C?"first":_?"last":void 0}function Yn(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Jn(e,t,n){return pn(e,Q(t,n))}function qn(e,n,o){const l=e.querySelector("colgroup");if(!l)return;const r=[];for(let e=0;e<n;e++){const n=t().createElement("col"),l=o&&o[e];l&&(n.style.width=`${l}px`),r.push(n)}l.replaceChildren(...r)}function jn(e,t,o){if(!t.theme.tableAlignment)return;const l=[],r=[];for(const e of["center","right"]){const n=t.theme.tableAlignment[e];n&&(e===o?r:l).push(n)}x(e,...l),n(e,...r)}const Vn=new WeakSet;function Gn(e=w()){return Vn.has(e)}function Qn(e,t){t?Vn.add(e):Vn.delete(e)}class Zn extends e{__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 Zn(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:to,priority:1})}}static importJSON(e){return no().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=fn(e)?e:e.querySelector("table");return fn(t)||at(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(e,o){const l=t().createElement("table");this.__style&&_e(l.style,this.__style);const r=t().createElement("colgroup");if(l.appendChild(r),Se(r),n(l,e.theme.table),this.updateTableElement(null,l,e),Gn(o)){const o=t().createElement("div"),r=e.theme.tableScrollableWrapper;return r?n(o,r):o.style.overflowX="auto",o.appendChild(l),this.updateTableWrapper(null,o,l,e),o}return l}updateTableWrapper(e,t,o,l){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&function(e,t,o,l){l>0?(n(e,o.theme.tableFrozenColumn),t.setAttribute("data-lexical-frozen-column","true")):(x(e,o.theme.tableFrozenColumn),t.removeAttribute("data-lexical-frozen-column"))}(t,o,l,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&function(e,t,o,l){l>0?(n(e,o.theme.tableFrozenRow),t.setAttribute("data-lexical-frozen-row","true")):(x(e,o.theme.tableFrozenRow),t.removeAttribute("data-lexical-frozen-row"))}(t,o,l,this.__frozenRowCount)}updateTableElement(e,t,o){this.__style!==(e?e.__style:"")&&_e(t.style,this.__style,e?e.__style:""),this.__rowStriping!==(!!e&&e.__rowStriping)&&function(e,t,o){o?(n(e,t.theme.tableRowStriping),e.setAttribute("data-lexical-row-striping","true")):(x(e,t.theme.tableRowStriping),e.removeAttribute("data-lexical-row-striping"))}(t,o,this.__rowStriping);const l=e?e.getColumnCount():0,r=e?e.__colWidths:void 0;this.getColumnCount()===l&&this.getColWidths()===r||qn(t,this.getColumnCount(),this.getColWidths()),jn(t,o,this.getFormatType())}updateDOM(e,t,n){const l=gn(this,t);return t===l===Gn()||(o(r=t)&&"DIV"===r.nodeName&&this.updateTableWrapper(e,t,l,n),this.updateTableElement(e,l,n),!1);var r}scaleDOMColWidths(e,t){const n=this.getColWidths();if(!n)return;qn(gn(this,e),this.getColumnCount(),n.map(e=>e*t))}exportDOM(e){const n=super.exportDOM(e),{element:l}=n;return{after:l=>{if(n.after&&(l=n.after(l)),!fn(l)&&o(l)&&(l=l.querySelector("table")),!fn(l))return null;jn(l,e._config,this.getFormatType());const[r]=It(this,null,null),s=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();s.has(e)||s.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const i=new Set;for(const e of l.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=s.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){s.delete(t);for(let e=0;e<n.colSpan;e++)i.add(e+n.startColumn)}}}const c=l.querySelector(":scope > colgroup");if(c){const e=Array.from(l.querySelectorAll(":scope > colgroup > col")).filter((e,t)=>i.has(t));c.replaceChildren(...e)}const a=l.querySelectorAll(":scope > tr");if(a.length>0){const e=t().createElement("tbody");for(const t of a)e.appendChild(t);l.append(e)}return l},element:!fn(l)&&o(l)?l.querySelector("table"):l}}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=Jn(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(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const l=Q(o.elem);return it(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(!ft(e))return 0;let t=0;return e.getChildren().forEach(e=>{it(e)&&(t+=e.getColSpan())}),t}}function eo(e,t){const n=e.getElementByKey(t.getKey());return null===n&&at(230),Rn(t,n)}function to(e){const t=no();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(!tt.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&t.setColWidths(e)}return{after:e=>Je(e,ft),node:t}}function no(){return c(new Zn)}function oo(e){return e instanceof Zn}function lo(e){ft(e.getParent())?e.isEmpty()&&e.append(i()):e.remove()}function ro(e){oo(e.getParent())?Qe(e,it):e.remove()}function so(e){Qe(e,ft);const[t]=It(e,null,null),n=t.reduce((e,t)=>Math.max(e,t.length),0),o=e.getChildren();for(let e=0;e<t.length;++e){const l=o[e];if(!l)continue;ft(l)||at(254,l.constructor.name,l.getType());const r=t[e].reduce((e,t)=>t?1+e:e,0);if(r!==n)for(let e=r;e<n;++e){const e=st();e.append(i()),l.append(e)}}const l=e.getColWidths(),r=e.getColumnCount();if(l&&l.length!==r){let t;if(r<l.length)t=l.slice(0,r);else if(l.length>0){const e=l[l.length-1];t=[...l,...Array(r-l.length).fill(e)]}e.setColWidths(t)}}function io(e){if(e.detail<3||!U(e.target))return!1;const t=Q(e.target);if(null===t)return!1;const n=f(t,e=>C(e)&&!e.isInline());if(null===n)return!1;return!!it(n.getParent())&&(n.select(0),!0)}function co(){const e=h();if(!d(e))return!1;const t=Ln(e.anchor.getNode());if(null===t)return!1;const n=Te();if(!n.is(t.getParent())||1!==n.getChildrenSize())return!1;const[o]=It(t,null,null);if(0===o.length||0===o[0].length)return!1;const l=o[0][0];if(!l||!l.cell)return!1;const r=o[o.length-1],s=r[r.length-1];if(!s||!s.cell)return!1;const i=on(t,l.cell,s.cell);return y(i),!0}function ao(e){return e.registerNodeTransform(ot,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=Ut(e),[n]=Dt(t,e,e),o=n.length,l=n[0].length;let r=t.getFirstChild();ft(r)||at(175);const s=[];for(let e=0;e<o;e++){0!==e&&(r=r.getNextSibling(),ft(r)||at(175));let t=null;for(let o=0;o<l;o++){const l=n[e][o],i=l.cell;if(l.startRow===e&&l.startColumn===o)t=i,s.push(i);else if(i.getColSpan()>1||i.getRowSpan()>1){it(i)||at(176);const e=st(i.__headerState);null!==t?t.insertAfter(e):je(r,e)}}}for(const e of s)e.setColSpan(1),e.setRowSpan(1)}})}function uo(e,t=!0){const n=new sn,o=(o,l,r)=>{const s=gn(o,r),i=wn(o,s,e,t,n);n.observers.set(l,[i,s])};return be(bn(e,n),e.registerCommand(N,()=>yn(n,e),E),e.registerMutationListener(Zn,t=>{e.read("latest",()=>{for(const[e,l]of t){const t=n.observers.get(e);if("created"===l||"updated"===l){const{tableNode:l,tableElement:r}=rn(e);void 0===t?o(l,e,r):r!==t[1]&&(n.removeObserver(e),o(l,e,r))}else"destroyed"===l&&n.removeObserver(e)}})},{skipInitialization:!1}),()=>{n.removeAllObservers()})}function ho(e,t){e.hasNodes([Zn])||at(255);const{hasNestedTables:n=We(!1)}=t??{};return be(e.registerCommand(ct,e=>function({rows:e,columns:t,includeHeaders:n},o){const l=h()||ne();if(!l||!d(l))return!1;if(!o&&Ln(l.anchor.getNode()))return!1;const s=gt(Number(e),Number(t),n);Ve(s);const i=s.getFirstDescendant();return r(i)&&i.select(),!0}(e,n.peek()),we),e.registerCommand(ye,(t,o)=>e===o&&function(e,t){const{nodes:n,selection:o}=e;if(!n.some(e=>oo(e)||Ge(e).some(e=>oo(e.node)))){if(tn(o)){let e="",t=!1;for(const o of n){const n=C(o)&&!o.isInline();e.length>0&&(n||t)&&(e+="\n"),e+=o.getTextContent(),t=n}return o.insertRawText(e),!0}return!1}const l=tn(o),r=d(o);if(!(r&&null!==f(o.anchor.getNode(),e=>it(e))&&null!==f(o.focus.getNode(),e=>it(e))||l))return!1;if(1===n.length&&oo(n[0]))return Vt(n[0],o);if(r&&t.peek()&&!function(e){if(tn(e)&&!e.focus.getNode().is(e.anchor.getNode()))return!0;if(d(e)&&it(e.anchor.getNode())&&!e.anchor.getNode().is(e.focus.getNode()))return!0;return!1}(o))return!1;return!0}(t,n),we),e.registerCommand(Ne,co,xe),e.registerCommand(ve,io,we),e.registerNodeTransform(Zn,so),e.registerNodeTransform(ut,ro),e.registerNodeTransform(ot,lo))}const fo={$accepts:ft,$packageRun:e=>e.every(it)?[dt().splice(0,0,e)]:[],name:"TableSchema"},go={$accepts:it,name:"TableRowSchema"},mo=[/* @__PURE__ */Be({$import:(e,t)=>{const n=no();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0),t.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),t.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=t.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!tt.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,Je(e.$importChildren(t),ft))]},match:Le.tag("table"),name:"@lexical/table/table"}),/* @__PURE__ */Be({$import:(e,t)=>[dt(tt.test(t.style.height)?parseFloat(t.style.height):void 0).splice(0,0,Je(e.$importChildren(t),it))],match:Le.tag("tr"),name:"@lexical/table/tr"}),/* @__PURE__ */Be({$import:(e,t)=>{const n="TH"===t.nodeName,o=tt.test(t.style.width)?parseFloat(t.style.width):void 0;let c=nt.NO_STATUS;if(n){const e=t.getAttribute("scope");if("col"===e)c=nt.COLUMN;else if("row"===e)c=nt.ROW;else{const e=t.parentElement,n=Re(e)&&(e.parentElement&&"THEAD"===e.parentElement.nodeName||0===e.rowIndex),o=0===t.cellIndex;n&&(c|=nt.ROW),o&&(c|=nt.COLUMN),c===nt.NO_STATUS&&(c=nt.ROW)}}const a=st(c,t.colSpan,o);a.__rowSpan=t.rowSpan;const u=t.style.backgroundColor;""!==u&&(a.__backgroundColor=u);const h=t.style.verticalAlign;(function(e){return"middle"===e||"bottom"===e})(h)&&(a.__verticalAlign=h);const d=e.get(Pe),f=d|function(e){let t=0;const n=e.fontWeight;"700"!==n&&"bold"!==n||(t|=Fe),"italic"===e.fontStyle&&(t|=Oe);const o=(e.textDecoration||"").split(" ");return o.includes("underline")&&(t|=Ae),o.includes("line-through")&&(t|=Ke),t}(t.style),g=e.get(De),m=t.style.color,p=m?{...g,color:m}:g,C=[];f!==d&&C.push(Ie(Pe,f)),p!==g&&C.push(Ie(De,p));const _=function(e){const t=[];let n=null;const o=()=>{if(null!==n){const e=n.getFirstChild();s(e)&&1===n.getChildrenSize()&&e.remove()}};for(const c of e)l(c)||r(c)||s(c)?null!==n?n.append(c):(n=i().append(c),t.push(n)):(o(),n=null,t.push(c));return o(),0===t.length&&t.push(i()),t}(e.$importChildren(t,{context:C})),S=n?_:Ue(_,t);return[a.splice(0,0,S)]},match:Le.tag("td","th"),name:"@lexical/table/cell"})],po=/* @__PURE__ */ke({build:(e,t,n)=>He(t),config:/* @__PURE__ */$e({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasNestedTables:!1,hasTabHandler:!0}),dependencies:[Xe,/* @__PURE__ */Ee(Ye,{rules:mo})],name:"@lexical/table/Table",nodes:()=>[Zn,ut,ot],register(e,t,n){const o=n.getOutput();return be(ze(()=>{const t=o.hasHorizontalScroll.value;Gn(e)!==t&&(Qn(e,t),e.update(Me))}),ho(e,o),ze(()=>uo(e,o.hasTabHandler.value)),ze(()=>o.hasCellMerge.value?void 0:ao(e)),ze(()=>o.hasCellBackgroundColor.value?void 0:e.registerNodeTransform(ot,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}}),Co=/* @__PURE__ */ke({dependencies:[po],name:"@lexical/table/Import"});export{Dt as $computeTableMap,It as $computeTableMapSkipCellCheck,st as $createTableCellNode,no as $createTableNode,gt as $createTableNodeWithDimensions,dt as $createTableRowNode,nn as $createTableSelection,on as $createTableSelectionFrom,Kt as $deleteTableColumn,Et as $deleteTableColumnAtSelection,$t as $deleteTableColumn__EXPERIMENTAL,kt as $deleteTableRowAtSelection,Mt as $deleteTableRow__EXPERIMENTAL,Bn as $findCellNode,Ln as $findTableNode,eo as $getElementForTableNode,Ut as $getNodeTriplet,rn as $getTableAndElementByKey,mt as $getTableCellNodeFromLexicalNode,jt as $getTableCellNodeRect,St as $getTableColumnIndexFromTableCellNode,Ct as $getTableNodeFromLexicalNodeOrThrow,_t as $getTableRowIndexFromTableCellNode,pt as $getTableRowNodeFromTableCellNodeOrThrow,Rt as $insertTableColumn,At as $insertTableColumnAtNode,Ft as $insertTableColumnAtSelection,Ot as $insertTableColumn__EXPERIMENTAL,yt as $insertTableRow,Tt as $insertTableRowAtNode,xt as $insertTableRowAtSelection,vt as $insertTableRow__EXPERIMENTAL,Gn as $isScrollableTablesActive,Yt as $isSimpleTable,it as $isTableCellNode,oo as $isTableNode,ft as $isTableRowNode,tn as $isTableSelection,Ht as $mergeCells,Jt as $moveTableColumn,qt as $moveTableRow,wt as $removeTableRowAtIndex,Qt as $setTableColumnIsHeader,Gt as $setTableRowIsHeader,Lt as $unmergeCell,Pt as $unmergeCellNode,ct as INSERT_TABLE_COMMAND,nt as TableCellHeaderStates,ot as TableCellNode,po as TableExtension,Co as TableImportExtension,mo as TableImportRules,Zn as TableNode,cn as TableObserver,ut as TableRowNode,go as TableRowSchema,fo as TableSchema,wn as applyTableHandlers,vn as getDOMCellFromTarget,gn as getTableElement,xn as getTableObserverFromTableElement,ao as registerTableCellUnmergeTransform,ho as registerTablePlugin,uo as registerTableSelectionObserver,Qn as setScrollableTablesActive};
9
+ import{ElementNode as e,$getDocument as t,addClassNamesToElement as n,isHTMLElement as o,$isInlineElementOrDecoratorNode as l,$isTextNode as r,$isLineBreakNode as s,$createParagraphNode as i,$applyNodeReplacement as c,createCommand as a,$createTextNode as u,$getSelection as h,$isRangeSelection as d,$findMatchingParent as f,$isParagraphNode as g,$createPoint as p,$getNodeByKey as m,$isElementNode as C,$normalizeSelection__EXPERIMENTAL as _,isCurrentlyReadOnlyMode as S,TEXT_TYPE_TO_FORMAT as b,$getEditor as w,$setSelection as y,SELECTION_CHANGE_COMMAND as N,removeClassNamesFromElement as v,getDOMSelection as x,$createRangeSelection as T,$isRootNode as R,INSERT_PARAGRAPH_COMMAND as F,registerEventListener as A,KEY_ARROW_DOWN_COMMAND as O,KEY_ARROW_UP_COMMAND as K,KEY_ARROW_LEFT_COMMAND as E,KEY_ARROW_RIGHT_COMMAND as k,COMMAND_PRIORITY_HIGH as M,KEY_ESCAPE_COMMAND as W,DELETE_WORD_COMMAND as $,DELETE_LINE_COMMAND as L,DELETE_CHARACTER_COMMAND as z,KEY_BACKSPACE_COMMAND as H,KEY_DELETE_COMMAND as B,CUT_COMMAND as D,PASTE_COMMAND as P,getComposedEventTarget as I,isDOMNode as U,getActiveElement as X,COPY_COMMAND as Y,FORMAT_TEXT_COMMAND as q,FORMAT_ELEMENT_COMMAND as J,CONTROLLED_TEXT_INSERTION_COMMAND as j,KEY_TAB_COMMAND as V,FOCUS_COMMAND as G,$getNearestNodeFromDOMNode as Q,$isRootOrShadowRoot as Z,getDOMSelectionRange as ee,getDOMSelectionPoints as te,$getPreviousSelection as ne,$caretFromPoint as oe,$isExtendableTextPointCaret as le,$extendCaretToRange as re,$isSiblingCaret as se,$getSiblingCaret as ie,$setPointFromCaret as ce,$normalizeCaret as ae,$createRangeSelectionFromDom as ue,$isChildCaret as he,$getChildCaret as de,$getAdjacentChildCaret as fe,IS_FIREFOX as ge,$getNodeByKeyOrThrow as pe,isDOMDocumentNode as me,isDOMShadowRoot as Ce,setDOMStyleFromCSS as _e,setDOMUnmanaged as Se,mergeRegister as be,COMMAND_PRIORITY_EDITOR as we,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND as ye,SELECT_ALL_COMMAND as Ne,COMMAND_PRIORITY_LOW as ve,CLICK_COMMAND as xe,$getRoot as Te,isHTMLTableRowElement as Re,IS_BOLD as Fe,IS_ITALIC as Ae,IS_UNDERLINE as Oe,IS_STRIKETHROUGH as Ke,defineExtension as Ee,$fullReconcile as ke,configExtension as Me,safeCast as We}from"lexical";import{getPeerDependencyFromEditor as $e,signal as Le,effect as ze,namedSignals as He}from"@lexical/extension";import{defineImportRule as Be,sel as De,ImportTextFormat as Pe,ImportTextStyle as Ie,contextValue as Ue,$propagateTextAlignToBlockChildren as Xe,CoreImportExtension as Ye,DOMImportExtension as qe}from"@lexical/html";import{$descendantsMatching as Je,objectKlassEquals as je,$insertFirst as Ve,$insertNodeToNearestRoot as Ge,$dfs as Qe,$unwrapAndFilterDescendants as Ze}from"@lexical/utils";import{copyToClipboard as et,$getClipboardDataFromSelection as tt}from"@lexical/clipboard";const nt=/^(\d+(?:\.\d+)?)px$/,ot={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class lt extends e{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;$config(){return this.config("tablecell",{extends:e,importDOM:{td:()=>({conversion:st,priority:0}),th:()=>({conversion:st,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=ot.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(e){const o=t().createElement(this.getTag());return this.__width&&(o.style.width=`${this.__width}px`),this.__colSpan>1&&(o.colSpan=this.__colSpan),this.__rowSpan>1&&(o.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(o.style.backgroundColor=this.__backgroundColor),rt(this.__verticalAlign)&&(o.style.verticalAlign=this.__verticalAlign),n(o,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),o}exportDOM(e){const t=super.exportDOM(e);if(o(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...rt(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=ot.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!==ot.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 rt(e){return"middle"===e||"bottom"===e}function st(e){const t=e,n=e.nodeName.toLowerCase();let c;nt.test(t.style.width)&&(c=parseFloat(t.style.width));let a=ot.NO_STATUS;if("th"===n){const e=t.getAttribute("scope");if("col"===e)a=ot.COLUMN;else if("row"===e)a=ot.ROW;else{const e=t.parentElement,n=o(e)&&"tr"===e.nodeName.toLowerCase()&&o(e.parentElement)&&("thead"===e.parentElement.nodeName.toLowerCase()||0===e.rowIndex),l=0===t.cellIndex;n&&(a|=ot.ROW),l&&(a|=ot.COLUMN),a===ot.NO_STATUS&&(a=ot.ROW)}}const u=it(a,t.colSpan,c);u.__rowSpan=t.rowSpan;const h=t.style.backgroundColor;""!==h&&(u.__backgroundColor=h);const d=t.style.verticalAlign;rt(d)&&(u.__verticalAlign=d);const f=t.style,g=(f&&f.textDecoration||"").split(" "),p="700"===f.fontWeight||"bold"===f.fontWeight,m=g.includes("line-through"),C="italic"===f.fontStyle,_=g.includes("underline"),S=f.color;return{after:e=>{const t=[];let n=null;const o=()=>{if(n){const e=n.getFirstChild();s(e)&&1===n.getChildrenSize()&&e.remove()}};for(const c of e)if(l(c)||r(c)||s(c)){if(r(c)&&(p&&c.toggleFormat("bold"),m&&c.toggleFormat("strikethrough"),C&&c.toggleFormat("italic"),_&&c.toggleFormat("underline"),S)){const e=c.getStyle();e.includes("color:")||c.setStyle(e+`color: ${S};`)}n?n.append(c):(n=i().append(c),t.push(n))}else t.push(c),o(),n=null;return o(),0===t.length&&t.push(i()),t},node:u}}function it(e=ot.NO_STATUS,t=1,n){return c(new lt(e,t,n))}function ct(e){return e instanceof lt}const at=/* @__PURE__ */a("INSERT_TABLE_COMMAND");function ut(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 ht extends e{__height;$config(){return this.config("tablerow",{extends:e,importDOM:{tr:()=>({conversion:dt,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(e){const o=t().createElement("tr");return this.__height&&(o.style.height=`${this.__height}px`),n(o,e.theme.tableRow),o}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 dt(e){const t=e;let n;return nt.test(t.style.height)&&(n=parseFloat(t.style.height)),{after:e=>Je(e,ct),node:ft(n)}}function ft(e){return c(new ht(e))}function gt(e){return e instanceof ht}function pt(e,t,n=!0){const o=ao();for(let l=0;l<e;l++){const e=ft();for(let o=0;o<t;o++){let t=ot.NO_STATUS;"object"==typeof n?(0===l&&n.rows&&(t|=ot.ROW),0===o&&n.columns&&(t|=ot.COLUMN)):n&&(0===l&&(t|=ot.ROW),0===o&&(t|=ot.COLUMN));const r=it(t),s=i();s.append(u()),r.append(s),e.append(r)}o.append(e)}return o}function mt(e){const t=f(e,e=>ct(e));return ct(t)?t:null}function Ct(e){const t=f(e,e=>gt(e));if(gt(t))return t;throw new Error("Expected table cell to be inside of table row.")}function _t(e){const t=f(e,e=>uo(e));if(uo(t))return t;throw new Error("Expected table cell to be inside of table.")}function St(e){const t=Ct(e);return _t(t).getChildren().findIndex(e=>e.is(t))}function bt(e){return Ct(e).getChildren().findIndex(t=>t.is(e))}function wt(e,t){const n=_t(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)}}function yt(e,t){const n=e.getChildren();if(t>=n.length||t<0)throw new Error("Expected table cell to be inside of table row.");return n[t].remove(),e}function Nt(e,t,n=!0,o,l){const r=e.getChildren();if(t>=r.length||t<0)throw new Error("Table row target index out of range");const s=r[t];if(!gt(s))throw new Error("Row before insertion index does not exist.");for(let e=0;e<o;e++){const e=s.getChildren(),t=e.length,o=ft();for(let n=0;n<t;n++){const t=e[n];ct(t)||ut(12);const{above:r,below:s}=wt(t,l);let c=ot.NO_STATUS;const a=r&&r.getWidth()||s&&s.getWidth()||void 0;(r&&r.hasHeaderState(ot.COLUMN)||s&&s.hasHeaderState(ot.COLUMN))&&(c|=ot.COLUMN);const u=it(c,1,a);u.append(i()),o.append(u)}n?s.insertAfter(o):s.insertBefore(o)}return e}const vt=(e,t)=>e===ot.BOTH||e===t?t:ot.NO_STATUS;function xt(e=!0){const t=h();d(t)||nn(t)||ut(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[l]=Xt(n),[r,,s]=Xt(o),[,i,c]=It(s,r,l),{startRow:a}=c,{startRow:u}=i;return e?Rt(a+l.__rowSpan>u+r.__rowSpan?l:r,!0):Rt(u<a?r:l,!1)}const Tt=xt;function Rt(e,t=!0){const[,,n]=Xt(e),[o,l]=It(n,e,e),r=o[0].length,{startRow:s}=l;let c=null;if(t){const t=s+e.__rowSpan-1,l=o[t],a=ft();for(let e=0;e<r;e++){const{cell:n,startRow:o}=l[e];if(o+n.__rowSpan-1<=t){const t=l[e].cell.__headerState,n=vt(t,ot.COLUMN);a.append(it(n).append(i()))}else n.setRowSpan(n.__rowSpan+1)}const u=n.getChildAtIndex(t);gt(u)||ut(256),u.insertAfter(a),c=a}else{const e=s,t=o[e],l=ft();for(let n=0;n<r;n++){const{cell:o,startRow:r}=t[n];if(r===e){const e=t[n].cell.__headerState,o=vt(e,ot.COLUMN);l.append(it(o).append(i()))}else o.setRowSpan(o.__rowSpan+1)}const a=n.getChildAtIndex(e);gt(a)||ut(257),a.insertBefore(l),c=l}return c}function Ft(e,t,n=!0,o,l){const r=e.getChildren(),s=[];for(let e=0;e<r.length;e++){const n=r[e];if(gt(n))for(let e=0;e<o;e++){const e=n.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");const o=e[t];ct(o)||ut(12);const{left:r,right:c}=wt(o,l);let a=ot.NO_STATUS;(r&&r.hasHeaderState(ot.ROW)||c&&c.hasHeaderState(ot.ROW))&&(a|=ot.ROW);const u=it(a);u.append(i()),s.push({newTableCell:u,targetCell:o})}}return s.forEach(({newTableCell:e,targetCell:t})=>{n?t.insertAfter(e):t.insertBefore(e)}),e}function At(e=!0){const t=h();d(t)||nn(t)||ut(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[l]=Xt(n),[r,,s]=Xt(o),[,i,c]=It(s,r,l),{startColumn:a}=c,{startColumn:u}=i;return e?Kt(a+l.__colSpan>u+r.__colSpan?l:r,!0):Kt(u<a?r:l,!1)}const Ot=At;function Kt(e,t=!0,n=!0){const[,,o]=Xt(e),[l,r]=It(o,e,e),s=l.length,{startColumn:c}=r,a=t?c+e.__colSpan-1:c-1,u=o.getFirstChild();gt(u)||ut(120);let h=null;function d(e=ot.NO_STATUS){const t=it(e).append(i());return null===h&&(h=t),t}let f=u;e:for(let e=0;e<s;e++){if(0!==e){const e=f.getNextSibling();gt(e)||ut(121),f=e}const t=l[e],n=t[a<0?0:a].cell.__headerState,o=vt(n,ot.ROW);if(a<0){zt(f,d(o));continue}const{cell:r,startColumn:s,startRow:i}=t[a];if(s+r.__colSpan-1<=a){let n=r,l=i,s=a;for(;l!==e&&n.__rowSpan>1;){if(s-=r.__colSpan,!(s>=0)){f.append(d(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,l=o}}n.insertAfter(d(o))}else r.setColSpan(r.__colSpan+1)}null!==h&&n&&Lt(h);const g=o.getColWidths();if(g){const e=[...g],t=a<0?0:a,n=e[t];e.splice(t,0,n),o.setColWidths(e)}return h}function Et(e,t){const n=e.getChildren();for(let e=0;e<n.length;e++){const o=n[e];if(gt(o)){const e=o.getChildren();if(t>=e.length||t<0)throw new Error("Table column target index out of range");e[t].remove()}}return e}function kt(){const e=h();d(e)||nn(e)||ut(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,l]=Xt(t),[r]=Xt(n),[s,i,c]=It(l,o,r),{startRow:a}=i,{startRow:u}=c,f=u+r.__rowSpan-1;if(s.length===f-a+1)return void l.remove();const g=s[0].length,p=s[f+1],m=l.getChildAtIndex(f+1);for(let e=f;e>=a;e--){for(let t=g-1;t>=0;t--){const{cell:n,startRow:o,startColumn:l}=s[e][t];if(l===t){if(o<a||o+n.__rowSpan-1>f){const e=Math.max(o,a),t=Math.min(n.__rowSpan+o-1,f),l=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-l)}if(o>=a&&o+n.__rowSpan-1>f&&e===f){gt(m)||ut(387);let o=null;for(let n=0;n<t;n++){const t=p[n],l=t.cell;t.startRow===e+1&&(o=l),l.__colSpan>1&&(n+=l.__colSpan-1)}null===o?zt(m,n):o.insertAfter(n)}}}const t=l.getChildAtIndex(e);gt(t)||ut(206,String(e)),t.remove()}if(void 0!==p){const{cell:e}=p[0];Lt(e)}else{const e=s[a-1],{cell:t}=e[0];Lt(t)}}const Mt=kt;function Wt(){const e=h();d(e)||nn(e)||ut(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,l]=Xt(t),[r]=Xt(n),[s,i,c]=It(l,o,r),{startColumn:a}=i,{startRow:u,startColumn:f}=c,g=Math.min(a,f),p=Math.max(a+o.__colSpan-1,f+r.__colSpan-1),m=p-g+1;if(s[0].length===p-g+1)return l.selectPrevious(),void l.remove();const C=s.length;for(let e=0;e<C;e++)for(let t=g;t<=p;t++){const{cell:n,startColumn:o}=s[e][t];if(o<g){if(t===g){const e=g-o;n.setColSpan(n.__colSpan-Math.min(m,n.__colSpan-e))}}else if(o+n.__colSpan-1>p){if(t===p){const e=p-o+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const _=s[u],S=a>f?_[a+o.__colSpan]:_[f+r.__colSpan];if(void 0!==S){const{cell:e}=S;Lt(e)}else{const e=f<a?_[f-1]:_[a-1],{cell:t}=e;Lt(t)}const b=l.getColWidths();if(b){const e=[...b];e.splice(g,m),l.setColWidths(e)}}const $t=Wt;function Lt(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function zt(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function Ht(e){if(0===e.length)return null;const t=_t(e[0]),[n]=Ut(t,null,null);let o=1/0,l=-1/0,r=1/0,s=-1/0;const c=new Set;for(const t of n)for(const n of t){if(!n||!n.cell)continue;const t=n.cell.getKey();if(!c.has(t)&&e.some(e=>e.is(n.cell))){c.add(t);const e=n.startRow,i=n.startColumn,a=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;o=Math.min(o,e),l=Math.max(l,e+a-1),r=Math.min(r,i),s=Math.max(s,i+u-1)}}if(o===1/0||r===1/0)return null;const a=l-o+1,u=s-r+1,h=n[o][r];if(!h.cell)return null;const d=h.cell;d.setColSpan(u),d.setRowSpan(a);const f=new Set([d.getKey()]);for(let e=o;e<=l;e++)for(let t=r;t<=s;t++){const o=n[e][t];if(!o.cell)continue;const l=o.cell,r=l.getKey();if(!f.has(r)){f.add(r);Bt(l)||d.append(...l.getChildren()),l.remove()}}return 0===d.getChildrenSize()&&d.append(i()),d}function Bt(e){if(1!==e.getChildrenSize())return!1;const t=e.getFirstChildOrThrow();return!(!g(t)||!t.isEmpty())}function Dt(){const e=h();d(e)||nn(e)||ut(188);const t=e.anchor.getNode(),n=f(t,ct);return ct(n)||ut(148),Pt(n)}function Pt(e){const[t,n,o]=Xt(e),l=t.__colSpan,r=t.__rowSpan;if(1===l&&1===r)return;const[s,c]=It(o,t,t),{startColumn:a,startRow:u}=c,h=t.__headerState&ot.COLUMN,d=Array.from({length:l},(e,t)=>{let n=h;for(let e=0;0!==n&&e<s.length;e++)n&=s[e][t+a].cell.__headerState;return n}),f=t.__headerState&ot.ROW,g=Array.from({length:r},(e,t)=>{let n=f;for(let e=0;0!==n&&e<s[0].length;e++)n&=s[t+u][e].cell.__headerState;return n});if(l>1){for(let e=1;e<l;e++)t.insertAfter(it(d[e]|g[0]).append(i()));t.setColSpan(1)}if(r>1){let e;for(let t=1;t<r;t++){const o=u+t,r=s[o];e=(e||n).getNextSibling(),gt(e)||ut(125);let c=null;for(let e=0;e<a;e++){const t=r[e],n=t.cell;t.startRow===o&&(c=n),n.__colSpan>1&&(e+=n.__colSpan-1)}if(null===c)for(let n=l-1;n>=0;n--)zt(e,it(d[n]|g[t]).append(i()));else for(let e=l-1;e>=0;e--)c.insertAfter(it(d[e]|g[t]).append(i()))}t.setRowSpan(1)}}function It(e,t,n){const[o,l,r]=Ut(e,t,n);return null===l&&ut(207),null===r&&ut(208),[o,l,r]}function Ut(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];gt(o)||ut(209);const c=s(e);for(let a=o.getFirstChild(),u=0;null!=a;a=a.getNextSibling()){for(ct(a)||ut(147);void 0!==c[u];)u++;const o={cell:a,startColumn:u,startRow:e},{__rowSpan:h,__colSpan:d}=a;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[u+e]=o}null!==t&&null===l&&t.is(a)&&(l=o),null!==n&&null===r&&n.is(a)&&(r=o)}}return[o,l,r]}function Xt(e){let t;if(e instanceof lt)t=e;else if("__type"in e){const n=f(e,ct);ct(n)||ut(148),t=n}else{const n=f(e.getNode(),ct);ct(n)||ut(148),t=n}const n=t.getParent();gt(n)||ut(149);const o=n.getParent();return uo(o)||ut(210),[t,n,o]}function Yt(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 c=e[t][n];if(!c)continue;const a=c.startColumn+c.cell.__colSpan-1,u=c.startRow+c.cell.__rowSpan-1,h=c.startColumn<=s&&a>=l,d=c.startRow<=i&&u>=r;if(h&&d){const e=Math.min(l,c.startColumn),t=Math.max(s,a),n=Math.min(r,c.startRow),h=Math.max(i,u);e===l&&t===s&&n===r&&h===i||(l=e,s=t,r=n,i=h,o=!0)}}}while(o);return{maxColumn:s,maxRow:i,minColumn:l,minRow:r}}function qt(e){const t=e.getChildren();let n=null;for(const e of t){if(!gt(e))return!1;if(null===n&&(n=e.getChildrenSize()),e.getChildrenSize()!==n)return!1;const t=e.getChildren();for(const e of t)if(!ct(e)||1!==e.getRowSpan()||1!==e.getColSpan())return!1}return(n||0)>0}function Jt(e,t,n){if(t===n)return;const o=e.getColumnCount();if(t<0||t>=o||n<0||n>=o)return;if(!qt(e))return;e.getChildren().filter(gt).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)}}function jt(e,t,n){if(t===n)return;const o=e.getChildren().filter(gt),l=o.length;if(t<0||t>=l||n<0||n>=l)return;if(!qt(e))return;const r=o[t],s=o[n];n>t?s.insertAfter(r):s.insertBefore(r)}function Vt(e){const[t,,n]=Xt(e),o=n.getChildren().filter(gt),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(ct);let l=0;for(let o=0;o<n.length;o++){for(;s[e][l];)l++;const r=n[o],i=r.__rowSpan||1,c=r.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][l+n]=r;if(t===r)return{colSpan:c,columnIndex:l,rowIndex:e,rowSpan:i};l+=c}}return null}function Gt(e,t){const n=t.getStartEndPoints(),o=nn(t);if(null===n)return!1;const[l,s]=n,[c,a,u]=Xt(l),h=f(s.getNode(),e=>ct(e));if(!(ct(c)&&ct(h)&&gt(a)&&uo(u)))return!1;const[d,g,p]=It(u,c,h),[m]=Ut(e,null,null),C=d.length,_=C>0?d[0].length:0;let S=g.startRow,b=g.startColumn,w=m.length,y=w>0?m[0].length:0;if(o){const e=Yt(d,g,p),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;S=e.minRow,b=e.minColumn,w=Math.min(w,t),y=Math.min(y,n)}let N=!1;const v=Math.min(C,S+w)-1,x=Math.min(_,b+y)-1,T=new Set;for(let e=S;e<=v;e++)for(let t=b;t<=x;t++){const n=d[e][t];T.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(Pt(n.cell),T.add(n.cell.getKey()),N=!0))}let[R]=Ut(u.getWritable(),null,null);const F=w-C+S;for(let e=0;e<F;e++){Rt(R[C-1][0].cell)}const A=y-_+b;for(let e=0;e<A;e++){Kt(R[0][_-1].cell,!0,!1)}[R]=Ut(u.getWritable(),null,null);for(let e=S;e<S+w;e++)for(let t=b;t<b+y;t++){const n=e-S,o=t-b,l=m[n][o];if(l.startRow!==n||l.startColumn!==o)continue;const s=l.cell;if(1!==s.__rowSpan||1!==s.__colSpan){const n=[],o=Math.min(e+s.__rowSpan,S+w)-1,l=Math.min(t+s.__colSpan,b+y)-1;for(let r=e;r<=o;r++)for(let e=t;e<=l;e++){const t=R[r][e];n.push(t.cell)}Ht(n),N=!0}const{cell:c}=R[e][t],a=s.getBackgroundColor();null!=a&&c.setBackgroundColor(a);const u=c.getChildren();s.getChildren().forEach(e=>{if(r(e)){i().append(e),c.append(e)}else c.append(e)}),u.forEach(e=>e.remove())}if(o&&N){const[e]=Ut(u.getWritable(),null,null);e[g.startRow][g.startColumn].cell.selectEnd()}return!0}function Qt(e,t,n){const[o]=Ut(e,null,null);t>=0&&t<o.length||ut(396,String(t));const l=o[t],r=n?ot.ROW:ot.NO_STATUS,s=new Set;for(let e=0;e<l.length;e++){const t=l[e];null!=t&&(s.has(t.cell)||(s.add(t.cell),t.cell.setHeaderStyles(r,ot.ROW)))}}function Zt(e,t,n){const[o]=Ut(e,null,null);o.length>0&&t>=0&&t<o[0].length||ut(397,String(t));const l=n?ot.COLUMN:ot.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,ot.COLUMN)))}}function en(e){const[[t,n,o,l],[r,s,i,c]]=["anchor","focus"].map(t=>{const n=e[t].getNode(),o=f(n,ct);ct(o)||ut(238,t,n.getKey(),n.getType());const l=o.getParent();gt(l)||ut(239,t);const r=l.getParent();return uo(r)||ut(240,t),[n,o,l,r]});return l.is(c)||ut(241),{anchorCell:n,anchorNode:t,anchorRow:o,anchorTable:l,focusCell:s,focusNode:r,focusRow:i,focusTable:c}}class tn{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=m(this.tableKey),t=m(this.anchor.key),n=m(this.focus.key);return null!==e&&null!==t&&null!==n}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return nn(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 tn(this.tableKey,p(this.anchor.key,this.anchor.offset,this.anchor.type),p(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){if(""===e)return;const t=(e.endsWith("\n")?e.slice(0,-1):e).split("\n").map(e=>e.split("\t")),n=ao();for(const e of t){const t=ft();for(const n of e){const e=it(ot.NO_STATUS),o=i();n&&o.append(u(n)),e.append(o),t.append(e)}n.append(t)}const{anchorCell:o}=en(this);Gt(n,o.select(0,o.getChildrenSize()))}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(ct).forEach(e=>{const n=e.getFirstChild();g(n)&&(t|=n.getTextFormat())});const n=b[e];return 0!==(t&n)}insertNodes(e){const t=this.focus.getNode();C(t)||ut(151);_(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=en(this),n=Vt(e);null===n&&ut(153);const o=Vt(t);null===o&&ut(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 e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=en(this),l=o.getParents()[1];if(l!==t){if(t.isParentOf(o)){const e=l.getParent();null==e&&ut(159),this.set(this.tableKey,o.getKey(),e.getKey())}else{const e=t.getParent();null==e&&ut(158),this.set(this.tableKey,e.getKey(),o.getKey())}return this.getNodes()}const[r,s,i]=It(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=Yt(r,s,i),d=new Map([[t.getKey(),t]]);let f=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=r[e][t],o=n.getParent();gt(o)||ut(160),o!==f&&(d.set(o.getKey(),o),f=o),d.has(n.getKey())||rn(n,e=>{d.set(e.getKey(),e)})}const g=Array.from(d.values());return S()||(this._cachedNodes=g),g}getTextContent(){const e=this.getNodes().filter(e=>ct(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 nn(e){return e instanceof tn}function on(){const e=p("root",0,"element"),t=p("root",0,"element");return new tn("root",e,t)}function ln(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=h(),l=nn(o)?o.clone():new tn("root",p("root",0,"element"),p("root",0,"element"));return l.set(e.getKey(),t.getKey(),n.getKey()),l}function rn(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():!1!==t(o)&&C(o)&&n.push(o.getChildren())}}function sn(e,t=w()){const n=m(e);uo(n)||ut(231,e);const o=pn(n,t.getElementByKey(e));return null===o&&ut(232,e),{tableElement:o,tableNode:n}}class cn{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 e=[];for(const[t,[n]]of Array.from(this.observers.entries())){const o=m(t);uo(o)?e.push([o,n]):this.removeObserver(t)}return e}}class an{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 sn(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=Fn(n,o)})});this.editor.read("latest",()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Fn(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})})}$clearHighlight(e=!0){const t=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:n,tableElement:o}=this.$lookup();An(t,Fn(n,o),null),e&&null!==h()&&(y(null),t.dispatchCommand(N,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();v(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:e}=this.$lookup();n(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&ut(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),An(t,this.table,this.tableSelection)}else this.$clearHighlight()}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=x(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:o}=this.$lookup(),l=e.x,r=e.y;if(this.focusCell=e,!this.isHighlightingCells){(t||this.anchorX!==l||this.anchorY!==r||null!=this.tableSelection&&null!=this.anchorCellNodeKey)&&(this.isHighlightingCells=!0,this.$disableHighlightStyle())}if(-1!==this.focusX&&-1!==this.focusY&&l===this.focusX&&r===this.focusY)return!1;if(this.focusX=l,this.focusY=r,this.isHighlightingCells){const s=Jn(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey){let e=s;if(null===e&&t&&(e=o.getCellNodeFromCords(l,r,this.table)),null!==e){const t=this.$getAnchorTableCellOrThrow();return this.focusCellNodeKey=e.getKey(),this.tableSelection=ln(o,t,e),y(this.tableSelection),n.dispatchCommand(N,void 0),An(n,this.table,this.tableSelection),!0}}}return!1}$getAnchorTableCell(){const e=this.anchorCellNodeKey?m(this.anchorCellNodeKey):null;return ct(e)?e:null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&ut(234),e}$getFocusTableCell(){const e=this.focusCellNodeKey?m(this.focusCellNodeKey):null;return ct(e)?e:null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&ut(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=Jn(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=ln(t,n,n),this.anchorCellNodeKey=e}}$formatCells(e){const t=h();nn(t)||ut(236);const n=T(),o=n.anchor,l=n.focus,r=t.getNodes().filter(ct);r.length>0||ut(237);const s=r[0].getFirstChild(),i=g(s)?s.getFormatFlags(e,null):null;r.forEach(t=>{o.set(t.getKey(),0,"element"),l.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i)}),y(t),this.editor.dispatchCommand(N,void 0)}$clearText(){const{editor:e}=this,t=m(this.tableNodeKey);if(!uo(t))throw new Error("Expected TableNode.");const n=h();nn(n)||ut(253);const o=n.getNodes().filter(ct),l=t.getFirstChild(),r=t.getLastChild();if(o.length>0&&null!==l&&null!==r&&gt(l)&&gt(r)&&o[0]===l.getFirstChild()&&o[o.length-1]===r.getLastChild()){t.selectPrevious();const n=t.getParent();return t.remove(),void(R(n)&&n.isEmpty()&&e.dispatchCommand(F,void 0))}o.forEach(e=>{if(C(e)){const t=i(),n=u();t.append(n),e.append(t),e.getChildren().forEach(e=>{e!==t&&e.remove()})}}),An(e,this.table,null),y(null),e.dispatchCommand(N,void 0)}}const un="__lexicalTableSelection";function hn(e){const t=pe(e);return uo(t)||ut(386,e),t}const dn=40;function fn(e,t,n){const o=e=>Math.max(1,Math.ceil(Math.min(dn,e)/dn*18));return e<=t+dn?-o(t+dn-e):e>=n-dn?o(e-(n-dn)):0}function gn(e){return o(e)&&"TABLE"===e.nodeName}function pn(e,t){if(!t)return t;const n=gn(t)?t:t.querySelector("table");return gn(n)||ut(341,e.constructor.name,e.getType(),e.getKey(),t.nodeName),n}function mn(e){return e._window}function Cn(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;ct(n)&&(o=n)}return null}const _n=[[O,"down"],[K,"up"],[E,"backward"],[k,"forward"]],Sn=[$,L,z],bn=[H,B];function wn(e,t){return e.registerRootListener(n=>{if(null===n)return;const o=e._window;if(null===o)return;return A(o,"pointerdown",o=>{const l=I(o);if(0!==o.button||!U(l)||!n.contains(l))return;const r=function(e){const t=Tn(e);if(null===t)return null;let n=t.elem;for(;null!=n;){if("TABLE"===n.nodeName&&un in n&&n[un])return{cellElement:t,tableElement:n,tableObserver:n[un]};n=n.parentNode}return null}(l);e.update(()=>{if(nn(h())){for(const[e]of t.observers.values())e.$clearHighlight(!1);y(null),e.dispatchCommand(N,void 0)}if(!r)return;const{tableObserver:n,tableElement:l,cellElement:s}=r;!function(e,t,n,o,l,r){const s=e._window;if(!s)return;const i=n=>{if(l.isSelecting)return;l.isSelecting=!0,null!==n&&null===l.anchorCell&&e.update(()=>{l.$setAnchorCellForSelection(n)});let i=t.clientX,c=t.clientY,a=null;const u=()=>{l.isSelecting=!1,null!==a&&(s.cancelAnimationFrame(a),a=null),s.removeEventListener("pointerup",S),s.removeEventListener("pointermove",b)},h=(e,t)=>{const n=o.getRootNode();if(!me(n)&&!Ce(n))return null;for(const l of n.elementsFromPoint(e,t)){const e=Rn(o,l);if(e)return e}return null},d=(t,n)=>{null===l.anchorCell&&e.update(()=>{l.$setAnchorCellForSelection(t)}),null!==l.focusCell&&t.elem===l.focusCell.elem||(r.setNextFocus({focusCell:t,override:n,tableKey:l.tableNodeKey}),e.dispatchCommand(N,void 0))},f=e=>{for(let t=o.parentElement;t;t=t.parentElement){if("x"===e?t.scrollWidth>t.clientWidth:t.scrollHeight>t.clientHeight){const n=s.getComputedStyle(t),o="x"===e?n.overflowX:n.overflowY;if("auto"===o||"scroll"===o)return t}}return null},g=(e,t,n)=>{let o,l;if(null===e)o=0,l="x"===n?s.innerWidth:s.innerHeight;else{const t=e.getBoundingClientRect();o="x"===n?t.left:t.top,l="x"===n?t.right:t.bottom}const r=fn(t,o,l);if(0===r)return!1;if(null===e){const e="x"===n?s.scrollX:s.scrollY;return s.scrollBy("x"===n?r:0,"x"===n?0:r),("x"===n?s.scrollX:s.scrollY)!==e}if("x"===n){const t=e.scrollLeft;return e.scrollLeft+=r,e.scrollLeft!==t}const i=e.scrollTop;return e.scrollTop+=r,e.scrollTop!==i},p=(e,t)=>{let n=i,o=c;if(null===e)n=Math.min(Math.max(n,1),s.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),s.innerHeight-1);else{const e=t.getBoundingClientRect();o=Math.min(Math.max(o,e.top+1),e.bottom-1)}return[n,o]},m=()=>{const e=f("x");if(null!==e){const t=e.getBoundingClientRect();if(0!==fn(i,t.left,t.right))return!0}const t=f("y"),n=null===t?0:t.getBoundingClientRect().top,o=null===t?s.innerHeight:t.getBoundingClientRect().bottom;return 0!==fn(c,n,o)},C=()=>{if(a=null,!l.isSelecting)return;const e=f("x"),t=f("y"),n=null!==e&&g(e,i,"x"),o=g(t,c,"y");if(n||o){const[n,o]=p(e,t),l=h(n,o);l&&d(l,!1),a=s.requestAnimationFrame(C)}},_=()=>{null===a&&"touch"!==l.pointerType&&m()&&(a=s.requestAnimationFrame(C))},S=()=>{u()},b=e=>{if(!(e=>!(1&~e.buttons))(e)&&l.isSelecting)return void u();const t=I(e);if(!U(t))return;i=e.clientX,c=e.clientY;let n=null;const r=!(ge||o.contains(t));n=r?Rn(o,t):h(e.clientX,e.clientY),n&&d(n,r),_()};s.addEventListener("pointerup",S,l.listenerOptions),s.addEventListener("pointermove",b,l.listenerOptions)};l.pointerType=t.pointerType;const c=hn(l.tableNodeKey),a=ne();if(ge&&t.shiftKey&&$n(a,c)&&(d(a)||nn(a))){const e=a.anchor.getNode(),o=Cn(c,a.anchor.getNode());if(o)l.$setAnchorCellForSelection(qn(l,o)),l.$setFocusCellForSelection(n),Un(t);else{(c.isBefore(e)?c.selectStart():c.selectEnd()).anchor.set(a.anchor.key,a.anchor.offset,a.anchor.type)}}else"touch"!==t.pointerType&&l.$setAnchorCellForSelection(n);i(n)}(e,o,s,l,n,t)})})})}function yn(e,t,n,o,l){const r=n.getRootElement(),s=mn(n);null!==r&&null!==s||ut(246);const i=new an(n,e.getKey()),c=pn(e,t);!function(e,t){null!==xn(e)&&ut(205);e[un]=t}(c,i),i.listenersToRemove.add(()=>function(e,t){xn(e)===t&&delete e[un]}(c,i));i.listenersToRemove.add(A(c,"mousedown",e=>{const t=I(e);if(e.detail>=3&&U(t)){null!==Tn(t)&&e.preventDefault()}},i.listenerOptions));for(const[t,o]of _n)i.listenersToRemove.add(n.registerCommand(t,t=>In(n,t,o,e,i,l),M));i.listenersToRemove.add(n.registerCommand(W,t=>{const n=h();if(nn(n)){const o=Cn(e,n.focus.getNode());if(null!==o)return Un(t),o.selectEnd(),!0}return!1},M));const a=()=>{const t=h();return!!$n(t,e)&&(!!nn(t)&&(i.$clearText(),!0))};for(const e of Sn)i.listenersToRemove.add(n.registerCommand(e,a,M));const g=t=>{const n=h();if(!nn(n)&&!d(n))return!1;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",l=o?"focus":"anchor",{key:r,offset:s,type:i}=n[l];return e[n[t].isBefore(n[l])?"selectPrevious":"selectNext"]()[l].set(r,s,i),!1}return!!$n(n,e)&&(!!nn(n)&&(t&&(t.preventDefault(),t.stopPropagation()),i.$clearText(),!0))};for(const e of bn)i.listenersToRemove.add(n.registerCommand(e,g,M));i.listenersToRemove.add(n.registerCommand(D,e=>{const t=h();if(t){if(!nn(t)&&!d(t))return!1;et(n,je(e,ClipboardEvent)?e:null,tt(t));const o=g(e);return d(t)?(t.removeText(),!0):o}return!1},M));const p=r.ownerDocument;return i.listenersToRemove.add(A(p,"paste",t=>{if(t.defaultPrevented)return;n.read("latest",()=>{const t=h();return r.contains(p.activeElement)&&nn(t)&&$n(t,e)})&&(t.preventDefault(),n.dispatchCommand(P,t))})),i.listenersToRemove.add(A(p,"copy",t=>{if(t.defaultPrevented)return;const o=I(t);if(o===r||U(o)&&r.contains(o))return;n.read("latest",()=>{const t=h();return r.contains(X(r))&&nn(t)&&$n(t,e)})&&(t.preventDefault(),n.dispatchCommand(Y,t))})),i.listenersToRemove.add(n.registerCommand(q,t=>{const n=h();return!!$n(n,e)&&(!!nn(n)&&(i.$formatCells(t),!0))},M)),i.listenersToRemove.add(n.registerCommand(J,t=>{const n=h();if(!nn(n)||!$n(n,e))return!1;const o=n.anchor.getNode(),l=n.focus.getNode();if(!ct(o)||!ct(l))return!1;if(function(e,t){if(nn(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=It(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,e))return e.setFormat(t),!0;const[r,s,i]=It(e,o,l),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),d=Math.min(s.startColumn,i.startColumn),f=new Set;for(let e=u;e<=c;e++)for(let n=d;n<=a;n++){const o=r[e][n].cell;if(f.has(o))continue;f.add(o),o.setFormat(t);const l=o.getChildren();for(let e=0;e<l.length;e++){const n=l[e];C(n)&&!n.isInline()&&n.setFormat(t)}}return!0},M)),i.listenersToRemove.add(n.registerCommand(j,t=>{const o=h();if(!$n(o,e))return!1;if(nn(o))return i.$clearHighlight(),!1;if(d(o)){const l=f(o.anchor.getNode(),e=>ct(e));if(!ct(l))return!1;if("string"==typeof t){const l=Yn(n,o,e);if(l)return Xn(l,e,[u(t)]),!0}}return!1},M)),o&&i.listenersToRemove.add(n.registerCommand(V,t=>{const n=h();if(!d(n)||!n.isCollapsed()||!$n(n,e))return!1;const o=Bn(n.anchor.getNode());return!(null===o||!e.is(Dn(o)))&&(Un(t),function(e,t){const n="next"===t?"getNextSibling":"getPreviousSibling",o="next"===t?"getFirstChild":"getLastChild",l=e[n]();if(C(l))return l.selectEnd();const r=f(e,gt);null===r&&ut(247);for(let e=r[n]();gt(e);e=e[n]()){const t=e[o]();if(C(t))return t.selectEnd()}const s=f(r,uo);null===s&&ut(248);"next"===t?s.selectNext():s.selectPrevious()}(o,t.shiftKey?"previous":"next"),!0)},M)),i.listenersToRemove.add(n.registerCommand(G,t=>e.isSelected(),M)),i.listenersToRemove.add(n.registerCommand(F,()=>{const t=h();if(!d(t)||!t.isCollapsed()||!$n(t,e))return!1;const o=Yn(n,t,e);return!!o&&(Xn(o,e),!0)},M)),i}function Nn(e,t){const n=h(),o=ne(),l=e.getAndClearNextFocus();if(null!==l){const{tableKey:t,focusCell:o}=l,r=e.observers.get(t);r||ut(335,t);const[s]=r;if(nn(n)&&n.tableKey===s.tableNodeKey)return(o.x!==s.focusX||o.y!==s.focusY)&&(s.$setFocusCellForSelection(o),!0);if(null!==s.anchorCell&&null!==s.anchorCellNodeKey&&o.elem!==s.anchorCell.elem&&null!==s.tableSelection)return s.$setFocusCellForSelection(o,!0),!0}const r=e.getAndClearShouldCheckSelectionForTable();if(r&&d(o)&&d(n)&&n.isCollapsed()){const e=m(r);if(uo(e)){const t=n.anchor.getNode(),o=e.getFirstChild(),l=Bn(t);if(null!==l&&gt(o)){const t=o.getFirstChild();if(ct(t)&&e.is(f(l,n=>n.is(e)||n.is(t))))return t.selectStart(),!0}}}nn(n)&&function(e,t){const n=mn(e),o=ne();if(!t.is(o))return;const l=hn(t.tableKey),r=x(n),s=r&&te(r,e.getRootElement());if(r&&s&&s.anchorNode&&s.focusNode){const n=Q(s.focusNode),o=n&&!l.isParentOf(n),i=Q(s.anchorNode),c=i&&l.isParentOf(i);if(o&&c&&r.rangeCount>0){const n=ue(r,e);n&&(n.anchor.set(l.getKey(),t.isBackward()?l.getChildrenSize():0,"element"),r.removeAllRanges(),y(n))}}}(t,n),d(n)&&function(e,t){const n=ne(),{anchor:o,focus:l}=e,r=o.getNode(),s=l.getNode(),i=Bn(r),c=Bn(s),a=i?Dn(i):null,u=c?Dn(c):null,h=e.isBackward(),f=i&&c&&a&&u&&a.is(u),g=u&&(!a||a.isParentOf(u)),p=a&&(!u||u.isParentOf(a));if(g){const t=e.clone(),[n]=It(u,c,c),o=n[0][0].cell,l=n[n.length-1].at(-1).cell;t.focus.set(h?o.getKey():l.getKey(),h?0:l.getChildrenSize(),"element"),y(t)}else if(p){const t=e.clone(),[n]=It(a,i,i),o=n[0][0].cell,l=n[n.length-1].at(-1).cell;t.anchor.set(h?l.getKey():o.getKey(),h?l.getChildrenSize():0,"element"),y(t)}else if(f){const o=t.observers.get(a.getKey());o||ut(335,a.getKey());const[l]=o;if(i.is(c)||(l.$setAnchorCellForSelection(qn(l,i)),l.$setFocusCellForSelection(qn(l,c),!0)),"touch"===l.pointerType&&l.isSelecting&&e.isCollapsed()&&d(n)&&n.isCollapsed()){const e=Bn(n.anchor.getNode());e&&!e.is(c)&&(l.$setAnchorCellForSelection(qn(l,e)),l.$setFocusCellForSelection(qn(l,c),!0),l.pointerType=null)}}}(n,e);for(const[n,o]of e.$getTableNodesAndObservers())vn(t,n,o);return!1}function vn(e,t,n){const o=h(),l=ne();o&&!o.is(l)&&(nn(o)||nn(l))&&n.tableSelection&&!n.tableSelection.is(l)&&(nn(o)&&o.tableKey===n.tableNodeKey?n.$updateTableTableSelection(o):!nn(o)&&nn(l)&&l.tableKey===n.tableNodeKey&&n.$updateTableTableSelection(null)),n.hasHijackedSelectionStyles&&!t.isSelected()?function(e,t){t.$enableHighlightStyle(),On(t.table,t=>{const n=t.elem;t.highlighted=!1,Hn(e,t),n.getAttribute("style")||n.removeAttribute("style")})}(e,n):!n.hasHijackedSelectionStyles&&t.isSelected()&&function(e,t){t.$disableHighlightStyle(),On(t.table,t=>{t.highlighted=!0,zn(e,t)})}(e,n)}function xn(e){return e[un]||null}function Tn(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 Rn(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 Fn(e,t){const n=[],o={columns:0,domRows:n,rows:0};let l=pn(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 An(e,t,n){const o=new Set(n?n.getNodes():[]);On(t,(t,n)=>{const l=t.elem;o.has(n)?(t.highlighted=!0,zn(e,t)):(t.highlighted=!1,Hn(e,t),l.getAttribute("style")||l.removeAttribute("style"))})}function On(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const l=o[n];if(!l)continue;const r=Q(l.elem);null!==r&&t(l,r,{x:n,y:e})}}}const Kn=(e,t,n,o,l)=>{const r="forward"===l;switch(l){case"backward":case"forward":return n!==(r?e.table.columns-1:0)?Ln(t.getCellNodeFromCordsOrThrow(n+(r?1:-1),o,e.table),r):o!==(r?e.table.rows-1:0)?Ln(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?Ln(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),!1):t.selectPrevious(),!0;case"down":return o!==e.table.rows-1?Ln(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),!0):t.selectNext(),!0;default:return!1}};function En(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 kn([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function Mn(e,t,[n,o]){const l=t[o],r=e[l];void 0===r&&ut(250,o,String(l));const s=t[n],i=r[s];return void 0===i&&ut(250,n,String(s)),i}function Wn(e,t,n,o,l){const r=Yt(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:l,maxRow:r}=t;let s=1,i=1,c=1,a=1;const u=e[l],h=e[r];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=l;t<=r;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return{bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,r),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=En(e,t);return null===n&&ut(249,t.cell.getKey()),n}(r,n),[d,f]=kn(h);let g=r[d],p=r[f];"forward"===l?g+="maxColumn"===d?1:c:"backward"===l?g-="minColumn"===d?1:u:"down"===l?p+="maxRow"===f?1:i:"up"===l&&(p-="minRow"===f?1:a);const m=t[p];if(void 0===m)return!1;const C=m[g];if(void 0===C)return!1;const[_,S]=function(e,t,n){const o=Yt(e,t,n),l=En(o,t);if(l)return[Mn(e,o,l),Mn(e,o,kn(l))];const r=En(o,n);if(r)return[Mn(e,o,kn(r)),Mn(e,o,r)];const s=["minColumn","minRow"];return[Mn(e,o,s),Mn(e,o,kn(s))]}(t,n,C),b=qn(e,_.cell),w=qn(e,S.cell);return e.$setAnchorCellForSelection(b),e.$setFocusCellForSelection(w,!0),!0}function $n(e,t){if(d(e)||nn(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return!1}function Ln(e,t){t?e.selectStart():e.selectEnd()}function zn(e,t){const o=t.elem,l=e._config.theme;ct(Q(o))||ut(131),n(o,l.tableCellSelected)}function Hn(e,t){const n=t.elem;ct(Q(n))||ut(131);const o=e._config.theme;v(n,o.tableCellSelected)}function Bn(e){const t=f(e,ct);return ct(t)?t:null}function Dn(e){const t=f(e,uo);return uo(t)?t:null}function Pn(e,t,n,o,l,r,s){const i=oe(n.focus,l?"previous":"next");if(le(i))return!1;let c=i;for(const e of re(i).iterNodeCarets("shadowRoot")){if(!se(e)||!C(e.origin))return!1;c=e}const a=c.getParentAtCaret();if(!ct(a))return!1;const u=a,h=function(e){for(const t of re(e).iterNodeCarets("root")){const{origin:n}=t;if(ct(n)){if(he(t))return de(n,e.direction)}else if(!gt(n))break}return null}(ie(u,c.direction)),d=f(u,uo);if(!d||!d.is(r))return!1;const g=e.getElementByKey(u.getKey()),p=Tn(g);if(!g||!p)return!1;const m=io(e,d);if(s.table=m,h)if("extend"===o){const t=Tn(e.getElementByKey(h.origin.getKey()));if(!t)return!1;s.$setAnchorCellForSelection(p),s.$setFocusCellForSelection(t,!0)}else{const e=ae(h);ce(n.anchor,e),ce(n.focus,e)}else if("extend"===o)s.$setAnchorCellForSelection(p),s.$setFocusCellForSelection(p,!0);else{const e=function(e){const t=fe(e);return he(t)?ae(t):e}(ie(d,i.direction));ce(n.anchor,e),ce(n.focus,e)}return Un(t),!0}function In(e,t,n,o,l,s){if(("up"===n||"down"===n)&&function(e){const t=e.getRootElement();if(!t)return!1;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return!1;const i=h();if(!$n(i,o)){if(d(i)){if("backward"===n){if(i.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(C(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(i.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!uo(n)&&(Un(t),t.shiftKey?i.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===n||"down"===n)){const e=i.focus.getNode();if(!i.isCollapsed()&&("up"===n&&!i.isBackward()||"down"===n&&i.isBackward())){let l=f(e,e=>uo(e));if(ct(l)&&(l=f(l,uo)),l!==o)return!1;if(!l)return!1;const s="down"===n?l.getNextSibling():l.getPreviousSibling();if(!s)return!1;let c=0;"up"===n&&C(s)&&(c=s.getChildrenSize());let a=s;if("up"===n&&C(s)){const e=s.getLastChild();a=e||s,c=r(a)?a.getTextContentSize():0}const u=i.clone();return u.focus.set(a.getKey(),c,r(a)?"text":"element"),y(u),Un(t),!0}if(Z(e)){const e="up"===n?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(e){if(null!==Cn(o,e)){const e=o.getFirstDescendant(),t=o.getLastDescendant();if(!e||!t)return!1;const[n]=Xt(e),[r]=Xt(t),s=o.getCordsFromCellNode(n,l.table),i=o.getCordsFromCellNode(r,l.table),c=o.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=o.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,!0),!0}}return!1}{let o=f(e,e=>C(e)&&!e.isInline());if(ct(o)&&(o=f(o,uo)),!o)return!1;const r="down"===n?o.getNextSibling():o.getPreviousSibling();if(uo(r)&&l.tableNodeKey===r.getKey()){const e=r.getFirstDescendant(),o=r.getLastDescendant();if(!e||!o)return!1;const[l]=Xt(e),[s]=Xt(o),c=i.clone();return c.focus.set(("up"===n?l:s).getKey(),"up"===n?0:s.getChildrenSize(),"element"),Un(t),y(c),!0}}}}return"down"===n&&oo(e)&&s.setShouldCheckSelectionForTable(o.getKey()),!1}if(d(i)){if("backward"===n||"forward"===n){return Pn(e,t,i,t.shiftKey?"extend":"move","backward"===n,o,l)}if(i.isCollapsed()){const{anchor:r,focus:c}=i,a=f(r.getNode(),ct),u=f(c.getNode(),ct);if(!ct(a)||!a.is(u))return!1;const h=Dn(a);if(h!==o&&null!=h){const o=pn(h,e.getElementByKey(h.getKey()));if(null!=o)return l.table=Fn(h,o),In(e,t,n,h,l,s)}const d=e.getElementByKey(a.__key),g=e.getElementByKey(r.key);if(null==g||null==d)return!1;let p;if("element"===r.type)p=g.getBoundingClientRect();else{const t=x(mn(e));if(null===t||0===t.rangeCount)return!1;const n=ee(t,e.getRootElement());if(null===n)return!1;p=n.getBoundingClientRect()}const m="up"===n?a.getFirstChild():a.getLastChild();if(null==m)return!1;const C=e.getElementByKey(m.__key);if(null==C)return!1;const _=C.getBoundingClientRect();if("up"===n?_.top>p.top-p.height:p.bottom+p.height>_.bottom){Un(t);const e=o.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return Kn(l,o,e.x,e.y,n);{const t=o.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,!0)}return!0}}}else if(nn(i)){const{anchor:r,focus:s,tableKey:c}=i;if(c!==o.getKey())return!1;const a=f(r.getNode(),ct),u=f(s.getNode(),ct),[h]=i.getNodes();uo(h)||ut(251);const d=pn(h,e.getElementByKey(h.getKey()));if(!ct(a)||!ct(u)||!uo(h)||null==d)return!1;l.$updateTableTableSelection(i);const g=Fn(h,d),p=o.getCordsFromCellNode(a,g),m=o.getDOMCellFromCordsOrThrow(p.x,p.y,g);if(l.$setAnchorCellForSelection(m),Un(t),t.shiftKey){const[e,t,r]=It(o,a,u);return Wn(l,e,t,r,n)}return u.selectEnd(),!0}return!1}function Un(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function Xn(e,t,n){const o=i();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd()}function Yn(e,t,n){const o=n.getParent();if(!o)return;const l=x(mn(e));if(!l)return;const r=te(l,e.getRootElement()).anchorNode,s=e.getElementByKey(o.getKey()),i=pn(n,e.getElementByKey(n.getKey()));if(!r||!s||!i||!s.contains(r)||i.contains(r))return;const c=f(t.anchor.getNode(),e=>ct(e));if(!c)return;const a=f(c,e=>uo(e));if(!uo(a)||!a.is(n))return;const[u,h]=It(n,c,c),d=u[0][0],g=u[u.length-1][u[0].length-1],{startRow:p,startColumn:m}=h,C=p===d.startRow&&m===d.startColumn,_=p===g.startRow&&m===g.startColumn;return C?"first":_?"last":void 0}function qn(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function Jn(e,t,n){return Cn(e,Q(t,n))}function jn(e){return o(e)&&"DIV"===e.nodeName}function Vn(e,n,o){const l=e.querySelector("colgroup");if(!l)return;const r=[];for(let e=0;e<n;e++){const n=t().createElement("col"),l=o&&o[e];l&&(n.style.width=`${l}px`),r.push(n)}l.replaceChildren(...r)}function Gn(e,t,o){if(!t.theme.tableAlignment)return;const l=[],r=[];for(const e of["center","right"]){const n=t.theme.tableAlignment[e];n&&(e===o?r:l).push(n)}v(e,...l),n(e,...r)}const Qn=new WeakSet;function Zn(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 Qn.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(()=>{eo(t,n)}),s.observe(t),s.observe(o));return eo(t,n),()=>{t.removeEventListener("scroll",l),n.removeEventListener("scroll",r),s&&s.disconnect()}}function eo(e,t){if(Qn.has(t))return;const n=t.firstElementChild;if(!n||!o(n)||!e.isConnected)return;const l=e.ownerDocument.defaultView;if(!l)return void(t.style.display="none");const r=l.getComputedStyle(e).overflowX,s="auto"===r||"scroll"===r,i=e.scrollWidth,c=e.clientWidth,a=i+"px";n.style.width!==a&&(n.style.width=a);const u=s&&i>c;t.style.display=u?"":"none"}function to(e){if(!e.hasAttribute("data-lexical-sticky-scrollbar"))return null;const t=e.firstElementChild;if(!jn(t))return null;const n=t.querySelector(":scope > table");if(!gn(n))return null;const o=t.nextElementSibling;return jn(o)?{scrollable:t,scrollbar:o,tableElement:n}:null}const no=new WeakSet;function oo(e=w()){return no.has(e)}function lo(e=w()){const t=$e(e,"@lexical/table/Table");return!!t&&(t.output.hasStickyScrollbar.peek()&&t.output.hasHorizontalScroll.peek())}function ro(e,t){t?no.add(e):no.delete(e)}class so extends e{__rowStriping=!1;__frozenColumnCount=0;__frozenRowCount=0;__colWidths=void 0;$config(){return this.config("table",{extends:e,importDOM:{table:()=>({conversion:co,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=gn(e)?e:e.querySelector("table");return gn(t)||ut(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(e,o){const l=t().createElement("table");this.__style&&_e(l.style,this.__style);const r=t().createElement("colgroup");if(l.appendChild(r),Se(r),n(l,e.theme.table),this.updateTableElement(null,l,e),oo(o)){const r=lo(o),s=function(e,o,l){const r=t().createElement("div"),s=o.theme.tableScrollableWrapper;return s?n(r,s):r.style.overflowX="auto",l&&(r.style.scrollbarWidth="none"),r.appendChild(e),r}(l,e,r);if(this.updateTableWrapper(null,s,l,e),r){const o=function(e){const o=t(),l=o.createElement("div"),r=e.theme.tableStickyScrollbar;r?n(l,r):(l.style.position="sticky",l.style.bottom="0",l.style.overflowX="scroll",l.style.overflowY="hidden"),l.style.display="none",l.setAttribute("aria-hidden","true"),l.tabIndex=-1;const s=o.createElement("div");return s.style.height="1px",s.style.width="0px",l.appendChild(s),l}(e),l=t().createElement("div");return l.setAttribute("data-lexical-sticky-scrollbar","true"),l.appendChild(s),l.appendChild(o),Se(o),l}return s}return l}updateTableWrapper(e,t,o,l){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&function(e,t,o,l){l>0?(n(e,o.theme.tableFrozenColumn),t.setAttribute("data-lexical-frozen-column","true")):(v(e,o.theme.tableFrozenColumn),t.removeAttribute("data-lexical-frozen-column"))}(t,o,l,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&function(e,t,o,l){l>0?(n(e,o.theme.tableFrozenRow),t.setAttribute("data-lexical-frozen-row","true")):(v(e,o.theme.tableFrozenRow),t.removeAttribute("data-lexical-frozen-row"))}(t,o,l,this.__frozenRowCount)}updateTableElement(e,t,o){this.__style!==(e?e.__style:"")&&_e(t.style,this.__style,e?e.__style:""),this.__rowStriping!==(!!e&&e.__rowStriping)&&function(e,t,o){o?(n(e,t.theme.tableRowStriping),e.setAttribute("data-lexical-row-striping","true")):(v(e,t.theme.tableRowStriping),e.removeAttribute("data-lexical-row-striping"))}(t,o,this.__rowStriping);const l=e?e.getColumnCount():0,r=e?e.__colWidths:void 0;this.getColumnCount()===l&&this.getColWidths()===r||Vn(t,this.getColumnCount(),this.getColWidths()),Gn(t,o,this.getFormatType())}updateDOM(e,t,n){const o=pn(this,t);if(t===o===oo())return!0;if(jn(t)){if(t.hasAttribute("data-lexical-sticky-scrollbar")!==lo())return!0;const l=o.parentElement;jn(l)&&this.updateTableWrapper(e,l,o,n)}return this.updateTableElement(e,o,n),!1}scaleDOMColWidths(e,t){const n=this.getColWidths();if(!n)return;Vn(pn(this,e),this.getColumnCount(),n.map(e=>e*t))}exportDOM(e){const n=super.exportDOM(e),{element:l}=n;return{after:l=>{if(n.after&&(l=n.after(l)),!gn(l)&&o(l)&&(l=l.querySelector("table")),!gn(l))return null;Gn(l,e._config,this.getFormatType());const[r]=Ut(this,null,null),s=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();s.has(e)||s.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const i=new Set;for(const e of l.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=s.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){s.delete(t);for(let e=0;e<n.colSpan;e++)i.add(e+n.startColumn)}}}const c=l.querySelector(":scope > colgroup");if(c){const e=Array.from(l.querySelectorAll(":scope > colgroup > col")).filter((e,t)=>i.has(t));c.replaceChildren(...e)}const a=l.querySelectorAll(":scope > tr");if(a.length>0){const e=t().createElement("tbody");for(const t of a)e.appendChild(t);l.append(e)}return l},element:!gn(l)&&o(l)?l.querySelector("table"):l}}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=Jn(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(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const l=Q(o.elem);return ct(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(!gt(e))return 0;let t=0;return e.getChildren().forEach(e=>{ct(e)&&(t+=e.getColSpan())}),t}}function io(e,t){const n=e.getElementByKey(t.getKey());return null===n&&ut(230),Fn(t,n)}function co(e){const t=ao();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(!nt.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&t.setColWidths(e)}return{after:e=>Je(e,gt),node:t}}function ao(){return c(new so)}function uo(e){return e instanceof so}function ho(e){gt(e.getParent())?e.isEmpty()&&e.append(i()):e.remove()}function fo(e){uo(e.getParent())?Ze(e,ct):e.remove()}function go(e){Ze(e,gt);const[t]=Ut(e,null,null),n=t.reduce((e,t)=>Math.max(e,t.length),0),o=e.getChildren();for(let e=0;e<t.length;++e){const l=o[e];if(!l)continue;gt(l)||ut(254,l.constructor.name,l.getType());const r=t[e].reduce((e,t)=>t?1+e:e,0);if(r!==n)for(let e=r;e<n;++e){const e=it();e.append(i()),l.append(e)}}const l=e.getColWidths(),r=e.getColumnCount();if(l&&l.length!==r){let t;if(r<l.length)t=l.slice(0,r);else if(l.length>0){const e=l[l.length-1];t=[...l,...Array(r-l.length).fill(e)]}e.setColWidths(t)}}function po(e){if(e.detail<3||!U(e.target))return!1;const t=Q(e.target);if(null===t)return!1;const n=f(t,e=>C(e)&&!e.isInline());if(null===n)return!1;return!!ct(n.getParent())&&(n.select(0),!0)}function mo(){const e=h();if(!d(e))return!1;const t=Dn(e.anchor.getNode());if(null===t)return!1;const n=Te();if(!n.is(t.getParent())||1!==n.getChildrenSize())return!1;const[o]=Ut(t,null,null);if(0===o.length||0===o[0].length)return!1;const l=o[0][0];if(!l||!l.cell)return!1;const r=o[o.length-1],s=r[r.length-1];if(!s||!s.cell)return!1;const i=ln(t,l.cell,s.cell);return y(i),!0}function Co(e){return e.registerNodeTransform(lt,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=Xt(e),[n]=It(t,e,e),o=n.length,l=n[0].length;let r=t.getFirstChild();gt(r)||ut(175);const s=[];for(let e=0;e<o;e++){0!==e&&(r=r.getNextSibling(),gt(r)||ut(175));let t=null;for(let o=0;o<l;o++){const l=n[e][o],i=l.cell;if(l.startRow===e&&l.startColumn===o)t=i,s.push(i);else if(i.getColSpan()>1||i.getRowSpan()>1){ct(i)||ut(176);const e=it(i.__headerState);null!==t?t.insertAfter(e):Ve(r,e)}}}for(const e of s)e.setColSpan(1),e.setRowSpan(1)}})}function _o(e,t=!0){const n=new cn,o=(o,l,r)=>{const s=pn(o,r),i=yn(o,s,e,t,n);n.observers.set(l,[i,s])};return be(wn(e,n),e.registerCommand(N,()=>Nn(n,e),M),e.registerMutationListener(so,t=>{e.read("latest",()=>{for(const[e,l]of t){const t=n.observers.get(e);if("created"===l||"updated"===l){const{tableNode:l,tableElement:r}=sn(e);void 0===t?o(l,e,r):r!==t[1]&&(n.removeObserver(e),o(l,e,r))}else"destroyed"===l&&n.removeObserver(e)}})},{skipInitialization:!1}),()=>{n.removeAllObservers()})}function So(e,t){e.hasNodes([so])||ut(255);const{hasNestedTables:n=Le(!1)}=t??{};return be(e.registerCommand(at,e=>function({rows:e,columns:t,includeHeaders:n},o){const l=h()||ne();if(!l||!d(l))return!1;if(!o&&Dn(l.anchor.getNode()))return!1;const s=pt(Number(e),Number(t),n);Ge(s);const i=s.getFirstDescendant();return r(i)&&i.select(),!0}(e,n.peek()),we),e.registerCommand(ye,(t,o)=>e===o&&function(e,t){const{nodes:n,selection:o}=e;if(!n.some(e=>uo(e)||Qe(e).some(e=>uo(e.node)))){if(nn(o)){let e="",t=!1;for(const o of n){const n=C(o)&&!o.isInline();e.length>0&&(n||t)&&(e+="\n"),e+=o.getTextContent(),t=n}return o.insertRawText(e),!0}return!1}const l=nn(o),r=d(o);if(!(r&&null!==f(o.anchor.getNode(),e=>ct(e))&&null!==f(o.focus.getNode(),e=>ct(e))||l))return!1;if(1===n.length&&uo(n[0]))return Gt(n[0],o);if(r&&t.peek()&&!function(e){if(nn(e)&&!e.focus.getNode().is(e.anchor.getNode()))return!0;if(d(e)&&ct(e.anchor.getNode())&&!e.anchor.getNode().is(e.focus.getNode()))return!0;return!1}(o))return!1;return!0}(t,n),we),e.registerCommand(Ne,mo,ve),e.registerCommand(xe,po,we),e.registerNodeTransform(so,go),e.registerNodeTransform(ht,fo),e.registerNodeTransform(lt,ho))}const bo={$accepts:gt,$packageRun:e=>e.every(ct)?[ft().splice(0,0,e)]:[],name:"TableSchema"},wo={$accepts:ct,name:"TableRowSchema"},yo=[/* @__PURE__ */Be({$import:(e,t)=>{const n=ao();t.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(!0),t.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),t.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=t.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!nt.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,Je(e.$importChildren(t),gt))]},match:De.tag("table"),name:"@lexical/table/table"}),/* @__PURE__ */Be({$import:(e,t)=>[ft(nt.test(t.style.height)?parseFloat(t.style.height):void 0).splice(0,0,Je(e.$importChildren(t),ct))],match:De.tag("tr"),name:"@lexical/table/tr"}),/* @__PURE__ */Be({$import:(e,t)=>{const n="TH"===t.nodeName,o=nt.test(t.style.width)?parseFloat(t.style.width):void 0;let c=ot.NO_STATUS;if(n){const e=t.getAttribute("scope");if("col"===e)c=ot.COLUMN;else if("row"===e)c=ot.ROW;else{const e=t.parentElement,n=Re(e)&&(e.parentElement&&"THEAD"===e.parentElement.nodeName||0===e.rowIndex),o=0===t.cellIndex;n&&(c|=ot.ROW),o&&(c|=ot.COLUMN),c===ot.NO_STATUS&&(c=ot.ROW)}}const a=it(c,t.colSpan,o);a.__rowSpan=t.rowSpan;const u=t.style.backgroundColor;""!==u&&(a.__backgroundColor=u);const h=t.style.verticalAlign;(function(e){return"middle"===e||"bottom"===e})(h)&&(a.__verticalAlign=h);const d=e.get(Pe),f=d|function(e){let t=0;const n=e.fontWeight;"700"!==n&&"bold"!==n||(t|=Fe),"italic"===e.fontStyle&&(t|=Ae);const o=(e.textDecoration||"").split(" ");return o.includes("underline")&&(t|=Oe),o.includes("line-through")&&(t|=Ke),t}(t.style),g=e.get(Ie),p=t.style.color,m=p?{...g,color:p}:g,C=[];f!==d&&C.push(Ue(Pe,f)),m!==g&&C.push(Ue(Ie,m));const _=function(e){const t=[];let n=null;const o=()=>{if(null!==n){const e=n.getFirstChild();s(e)&&1===n.getChildrenSize()&&e.remove()}};for(const c of e)l(c)||r(c)||s(c)?null!==n?n.append(c):(n=i().append(c),t.push(n)):(o(),n=null,t.push(c));return o(),0===t.length&&t.push(i()),t}(e.$importChildren(t,{context:C})),S=n?_:Xe(_,t);return[a.splice(0,0,S)]},match:De.tag("td","th"),name:"@lexical/table/cell"})];const No=/* @__PURE__ */Ee({build:(e,t,n)=>He(t),config:/* @__PURE__ */We({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasNestedTables:!1,hasStickyScrollbar:!1,hasTabHandler:!0}),dependencies:[Ye,/* @__PURE__ */Me(qe,{rules:yo})],name:"@lexical/table/Table",nodes:()=>[so,ht,lt],register(e,t,n){const l=n.getOutput();let r=!1;return be(ze(()=>{const t=l.hasHorizontalScroll.value,n=l.hasStickyScrollbar.value&&t,o=oo(e);o!==t&&ro(e,t),o===t&&r===n||e.update(ke),r=n}),So(e,l),ze(()=>_o(e,l.hasTabHandler.value)),ze(()=>{if(l.hasStickyScrollbar.value&&l.hasHorizontalScroll.value)return e.registerRootListener(t=>{if(t)return function(e){const t=new Map;return be(()=>{for(const{cleanup:e}of t.values())e();t.clear()},e.registerMutationListener(so,n=>{for(const[l,r]of n){const n=t.get(l);if("destroyed"===r){n&&(n.cleanup(),t.delete(l));continue}const s=e.getElementByKey(l),i=s&&o(s)?to(s):null;n&&i&&n.parts.scrollable===i.scrollable&&n.parts.scrollbar===i.scrollbar&&n.parts.tableElement===i.tableElement?eo(i.scrollable,i.scrollbar):(n&&(n.cleanup(),t.delete(l)),i&&t.set(l,{cleanup:Zn(i),parts:i}))}},{skipInitialization:!1}))}(e)})}),ze(()=>l.hasCellMerge.value?void 0:Co(e)),ze(()=>l.hasCellBackgroundColor.value?void 0:e.registerNodeTransform(lt,e=>{null!==e.getBackgroundColor()&&e.setBackgroundColor(null)})))}}),vo=/* @__PURE__ */Ee({dependencies:[No],name:"@lexical/table/Import"});export{Yt as $computeTableCellRectBoundary,It as $computeTableMap,Ut as $computeTableMapSkipCellCheck,it as $createTableCellNode,ao as $createTableNode,pt as $createTableNodeWithDimensions,ft as $createTableRowNode,on as $createTableSelection,ln as $createTableSelectionFrom,Et as $deleteTableColumn,Wt as $deleteTableColumnAtSelection,$t as $deleteTableColumn__EXPERIMENTAL,kt as $deleteTableRowAtSelection,Mt as $deleteTableRow__EXPERIMENTAL,Bn as $findCellNode,Dn as $findTableNode,io as $getElementForTableNode,Xt as $getNodeTriplet,sn as $getTableAndElementByKey,mt as $getTableCellNodeFromLexicalNode,Vt as $getTableCellNodeRect,bt as $getTableColumnIndexFromTableCellNode,_t as $getTableNodeFromLexicalNodeOrThrow,St as $getTableRowIndexFromTableCellNode,Ct as $getTableRowNodeFromTableCellNodeOrThrow,Ft as $insertTableColumn,Kt as $insertTableColumnAtNode,At as $insertTableColumnAtSelection,Ot as $insertTableColumn__EXPERIMENTAL,Nt as $insertTableRow,Rt as $insertTableRowAtNode,xt as $insertTableRowAtSelection,Tt as $insertTableRow__EXPERIMENTAL,oo as $isScrollableTablesActive,qt as $isSimpleTable,lo as $isStickyScrollbarActive,ct as $isTableCellNode,uo as $isTableNode,gt as $isTableRowNode,nn as $isTableSelection,Ht as $mergeCells,Jt as $moveTableColumn,jt as $moveTableRow,yt as $removeTableRowAtIndex,Zt as $setTableColumnIsHeader,Qt as $setTableRowIsHeader,Dt as $unmergeCell,Pt as $unmergeCellNode,at as INSERT_TABLE_COMMAND,ot as TableCellHeaderStates,lt as TableCellNode,No as TableExtension,vo as TableImportExtension,yo as TableImportRules,so as TableNode,an as TableObserver,ht as TableRowNode,wo as TableRowSchema,bo as TableSchema,yn as applyTableHandlers,Tn as getDOMCellFromTarget,pn as getTableElement,xn as getTableObserverFromTableElement,Co as registerTableCellUnmergeTransform,So as registerTablePlugin,_o as registerTableSelectionObserver,ro as setScrollableTablesActive};
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import { type DOMConversionMap, type DOMConversionOutput, type DOMExportOutput, type EditorConfig, ElementNode, type LexicalEditor, type LexicalNode, type LexicalUpdateJSON, type NodeKey, type SerializedElementNode, type Spread } from 'lexical';
8
+ import { type DOMConversionOutput, type DOMExportOutput, type EditorConfig, ElementNode, type LexicalEditor, type LexicalNode, type LexicalUpdateJSON, type NodeKey, type SerializedElementNode, type Spread } from 'lexical';
9
9
  export declare const TableCellHeaderStates: {
10
10
  BOTH: number;
11
11
  COLUMN: number;
@@ -35,11 +35,34 @@ export declare class TableCellNode extends ElementNode {
35
35
  __backgroundColor: null | string;
36
36
  /** @internal */
37
37
  __verticalAlign?: undefined | string;
38
- static getType(): string;
39
- static clone(node: TableCellNode): TableCellNode;
38
+ $config(): import("lexical").BaseStaticNodeConfig & {
39
+ readonly tablecell?: {
40
+ readonly extends: typeof ElementNode;
41
+ readonly importDOM: {
42
+ readonly td: () => {
43
+ conversion: typeof $convertTableCellNodeElement;
44
+ priority: 0;
45
+ };
46
+ readonly th: () => {
47
+ conversion: typeof $convertTableCellNodeElement;
48
+ priority: 0;
49
+ };
50
+ };
51
+ } | undefined;
52
+ } & import("lexical").StaticNodeTypeAccessor<"tablecell"> & import("lexical").StaticNodeConfigAccessor<{
53
+ readonly extends: typeof ElementNode;
54
+ readonly importDOM: {
55
+ readonly td: () => {
56
+ conversion: typeof $convertTableCellNodeElement;
57
+ priority: 0;
58
+ };
59
+ readonly th: () => {
60
+ conversion: typeof $convertTableCellNodeElement;
61
+ priority: 0;
62
+ };
63
+ };
64
+ }>;
40
65
  afterCloneFrom(node: this): void;
41
- static importDOM(): DOMConversionMap | null;
42
- static importJSON(serializedNode: SerializedTableCellNode): TableCellNode;
43
66
  updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedTableCellNode>): this;
44
67
  constructor(headerState?: number, colSpan?: number, width?: number, key?: NodeKey);
45
68
  createDOM(config: EditorConfig): HTMLTableCellElement;
@@ -23,6 +23,19 @@ export interface TableConfig {
23
23
  * When `true` (default `true`), tables will be wrapped in a `<div>` to enable horizontal scrolling
24
24
  */
25
25
  hasHorizontalScroll: boolean;
26
+ /**
27
+ * When `true` (default `false`), a sticky scrollbar is rendered below each table that overflows horizontally.
28
+ * Requires `hasHorizontalScroll` to be `true`. The native scrollbar is hidden via inline
29
+ * `scrollbar-width: none` (Firefox/Chromium). Themed consumers providing a `tableScrollableWrapper`
30
+ * class should also add `::-webkit-scrollbar { display: none }` for Safari/WebKit.
31
+ * A themed scrollbar is expected to guarantee its own visible height (the
32
+ * playground does this with `::-webkit-scrollbar { height: ... }`); the
33
+ * unthemed fallback depends on classic native scrollbars, so on platforms
34
+ * where those render with no thickness (overlay scrollbars, and non-layout
35
+ * environments like jsdom) it is disabled at runtime and the wrapper's
36
+ * native scrollbar is restored.
37
+ */
38
+ hasStickyScrollbar: boolean;
26
39
  /**
27
40
  * When `true` (default `false`), nested tables will be allowed.
28
41
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  */
8
8
  import type { TableDOMCell, TableDOMTable } from './LexicalTableObserver';
9
- import { type BaseSelection, type DOMConversionMap, type DOMConversionOutput, type DOMExportOutput, type EditorConfig, type ElementDOMSlot, ElementNode, type LexicalEditor, type LexicalNode, type LexicalUpdateJSON, type NodeKey, type SerializedElementNode, type Spread } from 'lexical';
9
+ import { type BaseSelection, type DOMConversionOutput, type DOMExportOutput, type EditorConfig, type ElementDOMSlot, ElementNode, type LexicalEditor, type LexicalNode, type LexicalUpdateJSON, type SerializedElementNode, type Spread } from 'lexical';
10
10
  import { type TableCellNode } from './LexicalTableCellNode';
11
11
  export type SerializedTableNode = Spread<{
12
12
  colWidths?: readonly number[];
@@ -14,7 +14,16 @@ export type SerializedTableNode = Spread<{
14
14
  frozenColumnCount?: number;
15
15
  frozenRowCount?: number;
16
16
  }, SerializedElementNode>;
17
+ export interface StickyScrollbarElements {
18
+ scrollable: HTMLDivElement;
19
+ scrollbar: HTMLDivElement;
20
+ tableElement: HTMLTableElement;
21
+ }
22
+ export declare function attachStickyScrollbarListeners(elements: StickyScrollbarElements): () => void;
23
+ export declare function syncStickyScrollbar(scrollable: HTMLDivElement, scrollbar: HTMLDivElement): void;
24
+ export declare function findStickyScrollbarElements(dom: HTMLElement): StickyScrollbarElements | null;
17
25
  export declare function $isScrollableTablesActive(editor?: LexicalEditor): boolean;
26
+ export declare function $isStickyScrollbarActive(editor?: LexicalEditor): boolean;
18
27
  export declare function setScrollableTablesActive(editor: LexicalEditor, active: boolean): void;
19
28
  /** @noInheritDoc */
20
29
  export declare class TableNode extends ElementNode {
@@ -22,16 +31,30 @@ export declare class TableNode extends ElementNode {
22
31
  __rowStriping: boolean;
23
32
  __frozenColumnCount: number;
24
33
  __frozenRowCount: number;
25
- __colWidths?: readonly number[];
26
- static getType(): string;
34
+ __colWidths: readonly number[] | undefined;
35
+ $config(): import("lexical").BaseStaticNodeConfig & {
36
+ readonly table?: {
37
+ readonly extends: typeof ElementNode;
38
+ readonly importDOM: {
39
+ readonly table: () => {
40
+ conversion: typeof $convertTableElement;
41
+ priority: 1;
42
+ };
43
+ };
44
+ } | undefined;
45
+ } & import("lexical").StaticNodeTypeAccessor<"table"> & import("lexical").StaticNodeConfigAccessor<{
46
+ readonly extends: typeof ElementNode;
47
+ readonly importDOM: {
48
+ readonly table: () => {
49
+ conversion: typeof $convertTableElement;
50
+ priority: 1;
51
+ };
52
+ };
53
+ }>;
27
54
  getColWidths(): readonly number[] | undefined;
28
55
  setColWidths(colWidths: readonly number[] | undefined): this;
29
- static clone(node: TableNode): TableNode;
30
56
  afterCloneFrom(prevNode: this): void;
31
- static importDOM(): DOMConversionMap | null;
32
- static importJSON(serializedNode: SerializedTableNode): TableNode;
33
57
  updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedTableNode>): this;
34
- constructor(key?: NodeKey);
35
58
  exportJSON(): SerializedTableNode;
36
59
  extractWithChild(child: LexicalNode, selection: BaseSelection | null, destination: 'clone' | 'html'): boolean;
37
60
  getDOMSlot(element: HTMLElement): ElementDOMSlot<HTMLTableElement>;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
- import { type BaseSelection, type DOMConversionMap, type DOMConversionOutput, type EditorConfig, ElementNode, type LexicalNode, type LexicalUpdateJSON, type NodeKey, type SerializedElementNode, type Spread } from 'lexical';
8
+ import { type BaseSelection, type DOMConversionOutput, type EditorConfig, ElementNode, type LexicalNode, type LexicalUpdateJSON, type NodeKey, type SerializedElementNode, type Spread } from 'lexical';
9
9
  export type SerializedTableRowNode = Spread<{
10
10
  height?: number;
11
11
  }, SerializedElementNode>;
@@ -13,13 +13,28 @@ export type SerializedTableRowNode = Spread<{
13
13
  export declare class TableRowNode extends ElementNode {
14
14
  /** @internal */
15
15
  __height?: number;
16
- static getType(): string;
17
- static clone(node: TableRowNode): TableRowNode;
16
+ $config(): import("lexical").BaseStaticNodeConfig & {
17
+ readonly tablerow?: {
18
+ readonly extends: typeof ElementNode;
19
+ readonly importDOM: {
20
+ readonly tr: () => {
21
+ conversion: typeof $convertTableRowElement;
22
+ priority: 0;
23
+ };
24
+ };
25
+ } | undefined;
26
+ } & import("lexical").StaticNodeTypeAccessor<"tablerow"> & import("lexical").StaticNodeConfigAccessor<{
27
+ readonly extends: typeof ElementNode;
28
+ readonly importDOM: {
29
+ readonly tr: () => {
30
+ conversion: typeof $convertTableRowElement;
31
+ priority: 0;
32
+ };
33
+ };
34
+ }>;
18
35
  afterCloneFrom(prevNode: this): void;
19
- static importDOM(): DOMConversionMap | null;
20
- static importJSON(serializedNode: SerializedTableRowNode): TableRowNode;
21
36
  updateFromJSON(serializedNode: LexicalUpdateJSON<SerializedTableRowNode>): this;
22
- constructor(height?: number, key?: NodeKey);
37
+ constructor(height?: number | undefined, key?: NodeKey);
23
38
  exportJSON(): SerializedTableRowNode;
24
39
  createDOM(config: EditorConfig): HTMLElement;
25
40
  extractWithChild(child: LexicalNode, selection: BaseSelection | null, destination: 'clone' | 'html'): boolean;
@@ -60,12 +60,24 @@ export declare class TableSelection implements BaseSelection {
60
60
  */
61
61
  hasFormat(type: TextFormatType): boolean;
62
62
  insertNodes(nodes: LexicalNode[]): void;
63
+ /** @deprecated Use {@link $computeTableMap} and {@link $computeTableCellRectBoundary} directly. */
63
64
  getShape(): TableSelectionShape;
64
65
  getNodes(): LexicalNode[];
65
66
  getTextContent(): string;
66
67
  }
68
+ /** Type guard for {@link TableSelection}. */
67
69
  export declare function $isTableSelection(x: unknown): x is TableSelection;
70
+ /** @deprecated Use {@link $createTableSelectionFrom} instead. */
68
71
  export declare function $createTableSelection(): TableSelection;
72
+ /**
73
+ * Creates a {@link TableSelection} spanning from `anchorCell` to `focusCell`
74
+ * within `tableNode`. In `__DEV__` mode, validates that both cells belong to
75
+ * the given table and that the table is attached to the editor state.
76
+ *
77
+ * If the current selection is already a TableSelection, it clones and
78
+ * re-targets it (preserving identity for dirty-checking); otherwise it
79
+ * constructs a fresh one.
80
+ */
69
81
  export declare function $createTableSelectionFrom(tableNode: TableNode, anchorCell: TableCellNode, focusCell: TableCellNode): TableSelection;
70
82
  /**
71
83
  * Depth first visitor
@@ -110,6 +110,10 @@ export interface TableCellRectSpans {
110
110
  bottomSpan: number;
111
111
  }
112
112
  export declare function $computeTableCellRectSpans(map: TableMapType, boundary: TableCellRectBoundary): TableCellRectSpans;
113
+ /**
114
+ * Compute the bounding rectangle of two table cells in a table map,
115
+ * expanding iteratively to include any merged cells that overlap the boundary.
116
+ */
113
117
  export declare function $computeTableCellRectBoundary(map: TableMapType, cellAMap: TableMapValueType, cellBMap: TableMapValueType): TableCellRectBoundary;
114
118
  /**
115
119
  * Checks if the table does not have any merged cells.
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export type { InsertTableCommandPayload, InsertTableCommandPayloadHeaders, } fro
11
11
  export { INSERT_TABLE_COMMAND } from './LexicalTableCommands';
12
12
  export { type TableConfig, TableExtension, TableImportExtension, } from './LexicalTableExtension';
13
13
  export type { SerializedTableNode } from './LexicalTableNode';
14
- export { $createTableNode, $getElementForTableNode, $isScrollableTablesActive, $isTableNode, setScrollableTablesActive, TableNode, } from './LexicalTableNode';
14
+ export { $createTableNode, $getElementForTableNode, $isScrollableTablesActive, $isStickyScrollbarActive, $isTableNode, setScrollableTablesActive, TableNode, } from './LexicalTableNode';
15
15
  export type { TableDOMCell } from './LexicalTableObserver';
16
16
  export { $getTableAndElementByKey, TableObserver } from './LexicalTableObserver';
17
17
  export { registerTableCellUnmergeTransform, registerTablePlugin, registerTableSelectionObserver, } from './LexicalTablePluginHelpers';
@@ -21,5 +21,6 @@ export type { TableMapType, TableMapValueType, TableSelection, TableSelectionSha
21
21
  export { $createTableSelection, $createTableSelectionFrom, $isTableSelection, } from './LexicalTableSelection';
22
22
  export type { HTMLTableElementWithWithTableSelectionState } from './LexicalTableSelectionHelpers';
23
23
  export { $findCellNode, $findTableNode, applyTableHandlers, getDOMCellFromTarget, getTableElement, getTableObserverFromTableElement, } from './LexicalTableSelectionHelpers';
24
- export { $computeTableMap, $computeTableMapSkipCellCheck, $createTableNodeWithDimensions, $deleteTableColumn, $deleteTableColumn__EXPERIMENTAL, $deleteTableColumnAtSelection, $deleteTableRow__EXPERIMENTAL, $deleteTableRowAtSelection, $getNodeTriplet, $getTableCellNodeFromLexicalNode, $getTableCellNodeRect, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $getTableRowNodeFromTableCellNodeOrThrow, $insertTableColumn, $insertTableColumn__EXPERIMENTAL, $insertTableColumnAtNode, $insertTableColumnAtSelection, $insertTableRow, $insertTableRow__EXPERIMENTAL, $insertTableRowAtNode, $insertTableRowAtSelection, $isSimpleTable, $mergeCells, $moveTableColumn, $moveTableRow, $removeTableRowAtIndex, $setTableColumnIsHeader, $setTableRowIsHeader, $unmergeCell, $unmergeCellNode, } from './LexicalTableUtils';
24
+ export type { TableCellRectBoundary } from './LexicalTableUtils';
25
+ export { $computeTableCellRectBoundary, $computeTableMap, $computeTableMapSkipCellCheck, $createTableNodeWithDimensions, $deleteTableColumn, $deleteTableColumn__EXPERIMENTAL, $deleteTableColumnAtSelection, $deleteTableRow__EXPERIMENTAL, $deleteTableRowAtSelection, $getNodeTriplet, $getTableCellNodeFromLexicalNode, $getTableCellNodeRect, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $getTableRowNodeFromTableCellNodeOrThrow, $insertTableColumn, $insertTableColumn__EXPERIMENTAL, $insertTableColumnAtNode, $insertTableColumnAtSelection, $insertTableRow, $insertTableRow__EXPERIMENTAL, $insertTableRowAtNode, $insertTableRowAtSelection, $isSimpleTable, $mergeCells, $moveTableColumn, $moveTableRow, $removeTableRowAtIndex, $setTableColumnIsHeader, $setTableRowIsHeader, $unmergeCell, $unmergeCellNode, } from './LexicalTableUtils';
25
26
  export { TableImportRules, TableRowSchema, TableSchema, } from './TableImportExtension';
package/package.json CHANGED
@@ -8,16 +8,16 @@
8
8
  "table"
9
9
  ],
10
10
  "license": "MIT",
11
- "version": "0.48.0",
11
+ "version": "0.48.1-nightly.20260720.0",
12
12
  "main": "./dist/LexicalTable.js",
13
13
  "types": "./dist/typescript-too-old.d.ts",
14
14
  "dependencies": {
15
- "@lexical/extension": "0.48.0",
16
- "@lexical/html": "0.48.0",
17
- "@lexical/clipboard": "0.48.0",
18
- "@lexical/internal": "0.48.0",
19
- "@lexical/utils": "0.48.0",
20
- "lexical": "0.48.0"
15
+ "@lexical/html": "0.48.1-nightly.20260720.0",
16
+ "@lexical/extension": "0.48.1-nightly.20260720.0",
17
+ "@lexical/clipboard": "0.48.1-nightly.20260720.0",
18
+ "@lexical/internal": "0.48.1-nightly.20260720.0",
19
+ "@lexical/utils": "0.48.1-nightly.20260720.0",
20
+ "lexical": "0.48.1-nightly.20260720.0"
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",