react-mail-inbox 2.1.9 → 2.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {createCommand,defineExtension,safeCast,$getEditor,ElementNode,isHTMLElement,setDOMUnmanaged,$getNearestNodeFromDOMNode,COMMAND_PRIORITY_EDITOR,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,$isRangeSelection,CLICK_COMMAND,$isInlineElementOrDecoratorNode,$isTextNode,$isLineBreakNode,$createParagraphNode,$applyNodeReplacement,RootNode,TextNode,LineBreakNode,TabNode,ParagraphNode,$isEditorState,isDOMNode,$getNodeFromDOMNode,COMMAND_PRIORITY_LOW,HISTORY_MERGE_TAG,DecoratorNode,$getSelection,$isNodeSelection,$createNodeSelection,$setSelection,$getPreviousSelection,$isElementNode,$getNodeByKey,$getRoot,$create,$createTextNode,COMMAND_PRIORITY_HIGH,KEY_ESCAPE_COMMAND,CUT_COMMAND,FORMAT_TEXT_COMMAND,FORMAT_ELEMENT_COMMAND,CONTROLLED_TEXT_INSERTION_COMMAND,KEY_TAB_COMMAND,FOCUS_COMMAND,SELECTION_CHANGE_COMMAND,getDOMSelection,$createRangeSelectionFromDom,INSERT_PARAGRAPH_COMMAND,$isRootOrShadowRoot,DELETE_LINE_COMMAND,$caretFromPoint,$isExtendableTextPointCaret,$extendCaretToRange,$isSiblingCaret,$isChildCaret,$getChildCaret,$getSiblingCaret,$normalizeCaret,$setPointFromCaret,$getAdjacentChildCaret,$isParagraphNode,shallowMergeConfig,declarePeerDependency,configExtension,CLEAR_EDITOR_COMMAND,OUTDENT_CONTENT_COMMAND,INDENT_CONTENT_COMMAND,INSERT_TAB_COMMAND,COMMAND_PRIORITY_CRITICAL,createEditor,$isBlockElementNode,$createRangeSelection,$normalizeSelection__EXPERIMENTAL,$createTabNode,$isTextPointCaret,$getCaretRange,$parseSerializedNode,COPY_COMMAND,isSelectionWithinEditor,$createPoint,TEXT_TYPE_TO_FORMAT,isCurrentlyReadOnlyMode,$isRootNode,KEY_ARROW_DOWN_COMMAND,KEY_ARROW_UP_COMMAND,KEY_ARROW_LEFT_COMMAND,KEY_ARROW_RIGHT_COMMAND,DELETE_WORD_COMMAND,DELETE_CHARACTER_COMMAND,KEY_BACKSPACE_COMMAND,KEY_DELETE_COMMAND,$insertNodes,PASTE_COMMAND,REDO_COMMAND,UNDO_COMMAND}from'lexical';import {mergeRegister,addClassNamesToElement,removeClassNamesFromElement,isHTMLElement as isHTMLElement$1,$insertFirst,$descendantsMatching,$insertNodeToNearestRoot,$findMatchingParent,$unwrapAndFilterDescendants,objectKlassEquals,$getNearestBlockElementAncestorOrThrow,$filter,$getNearestNodeOfType}from'@lexical/utils';import {$generateHtmlFromNodes,$generateNodesFromDOM}from'@lexical/html';import {$addNodeStyle,$sliceSelectedTextNodeContent,$isAtNodeEnd,$patchStyleText}from'@lexical/selection';import*as Qc from'react';import Qc__default,{createContext,useContext,useState,Children,cloneElement,isValidElement,useEffect,useRef,useCallback,useMemo,useLayoutEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {AutoFocusPlugin}from'@lexical/react/LexicalAutoFocusPlugin';import {LexicalComposer}from'@lexical/react/LexicalComposer';import {RichTextPlugin}from'@lexical/react/LexicalRichTextPlugin';import {ContentEditable}from'@lexical/react/LexicalContentEditable';import {HistoryPlugin}from'@lexical/react/LexicalHistoryPlugin';import {LexicalErrorBoundary}from'@lexical/react/LexicalErrorBoundary';import {ListPlugin}from'@lexical/react/LexicalListPlugin';import {LinkPlugin}from'@lexical/react/LexicalLinkPlugin';import {LinkNode,AutoLinkNode,$isLinkNode,TOGGLE_LINK_COMMAND}from'@lexical/link';import {ListNode,ListItemNode,$isListNode,INSERT_UNORDERED_LIST_COMMAND,REMOVE_LIST_COMMAND,INSERT_ORDERED_LIST_COMMAND}from'@lexical/list';import {useLexicalComposerContext}from'@lexical/react/LexicalComposerContext';import {createPortal}from'react-dom';import {MdLockClock,MdPhoto,MdOutlineEmojiEmotions,MdClose,MdEdit,MdTextFields,MdCheck,MdImage,MdLink,MdAttachFile,MdTextFormat,MdArrowDropDown,MdFormatQuote,MdStrikethroughS,MdFormatClear,MdOutlineFormatIndentIncrease,MdFormatIndentDecrease,MdFormatListNumbered,MdFormatListBulleted,MdFormatAlignCenter,MdFormatAlignRight,MdFormatAlignLeft,MdFormatUnderlined,MdFormatItalic,MdFormatBold,MdRedo,MdUndo}from'react-icons/md';import {TbBrandGoogleDrive}from'react-icons/tb';import {RiBallPenFill}from'react-icons/ri';import Ug from'reactjs-popup';import {useDropzone}from'react-dropzone';import Ab from'heic2any';import Wb from'@emoji-mart/react';import Ub from'@emoji-mart/data';var md=Object.defineProperty;var rt=(o,e)=>()=>(o&&(e=o(o=0)),e);var jt=(o,e)=>{for(var t in e)md(o,t,{get:e[t],enumerable:true});};var ks={};jt(ks,{$createHorizontalRuleNode:()=>br,$isHorizontalRuleNode:()=>Os,AutoFocusExtension:()=>nu,ClearEditorExtension:()=>ru,EditorStateExtension:()=>an,HorizontalRuleExtension:()=>Ou,HorizontalRuleNode:()=>wt,INSERT_HORIZONTAL_RULE_COMMAND:()=>Tu,InitialStateExtension:()=>vs,LexicalBuilder:()=>Xt,NodeSelectionExtension:()=>pr,TabIndentationExtension:()=>ku,batch:()=>ms,buildEditorFromExtensions:()=>yu,computed:()=>xs,configExtension:()=>configExtension,declarePeerDependency:()=>declarePeerDependency,defineExtension:()=>defineExtension,effect:()=>lt,getExtensionDependencyFromEditor:()=>Nu,getKnownTypesAndNodes:()=>iu,getPeerDependencyFromEditor:()=>Rs,getPeerDependencyFromEditorOrThrow:()=>_u,namedSignals:()=>un,registerClearEditor:()=>Ns,registerTabIndentation:()=>Ms,safeCast:()=>safeCast,shallowMergeConfig:()=>shallowMergeConfig,signal:()=>Gt,untracked:()=>hr,watchedSignal:()=>gr});function dn(){if(st>1){st--;return}let o,e=false;for(;Eo!==void 0;){let t=Eo;for(Eo=void 0,dr++;t!==void 0;){let n=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&bs(t))try{t.c();}catch(r){e||(o=r,e=true);}t=n;}}if(dr=0,st--,e)throw o}function ms(o){if(st>0)return o();st++;try{return o()}finally{dn();}}function hr(o){let e=Y;Y=void 0;try{return o()}finally{Y=e;}}function gs(o){if(Y===void 0)return;let e=o.n;if(e===void 0||e.t!==Y)return e={i:0,S:o,p:Y.s,n:void 0,t:Y,e:void 0,x:void 0,r:e},Y.s!==void 0&&(Y.s.n=e),Y.s=e,o.n=e,32&Y.f&&o.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=Y.s,e.n=void 0,Y.s.n=e,Y.s=e),e}function Ee(o,e){this.v=o,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name;}function Gt(o,e){return new Ee(o,e)}function bs(o){for(let e=o.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function Cs(o){for(let e=o.s;e!==void 0;e=e.n){let t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){o.s=e;break}}}function Ss(o){let e,t=o.s;for(;t!==void 0;){let n=t.p;t.i===-1?(t.S.U(t),n!==void 0&&(n.n=t.n),t.n!==void 0&&(t.n.p=n)):e=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=n;}o.s=e;}function _t(o,e){Ee.call(this,void 0),this.x=o,this.s=void 0,this.g=ln-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name;}function xs(o,e){return new _t(o,e)}function ys(o){let e=o.u;if(o.u=void 0,typeof e=="function"){st++;let t=Y;Y=void 0;try{e();}catch(n){throw o.f&=-2,o.f|=8,mr(o),n}finally{Y=t,dn();}}}function mr(o){for(let e=o.s;e!==void 0;e=e.n)e.S.U(e);o.x=void 0,o.s=void 0,ys(o);}function ou(o){if(Y!==this)throw new Error("Out-of-order effect");Ss(this),Y=o,this.f&=-2,8&this.f&&mr(this),dn();}function Vt(o,e){this.x=o,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name;}function lt(o,e){let t=new Vt(o,e);try{t.c();}catch(r){throw t.d(),r}let n=t.d.bind(t);return n[Symbol.dispose]=n,n}function un(o,e={}){let t={};for(let n in o){let r=e[n],i=Gt(r===void 0?o[n]:r);t[n]=i;}return t}function ws(){let o=$getRoot(),e=$getSelection(),t=$createParagraphNode();o.clear(),o.append(t),e!==null&&t.select(),$isRangeSelection(e)&&(e.format=0);}function Ns(o,e=ws){return o.registerCommand(CLEAR_EDITOR_COMMAND,t=>(o.update(e),true),COMMAND_PRIORITY_EDITOR)}function iu(o){let e=new Set,t=new Set;for(let n of _s(o)){let r=typeof n=="function"?n:n.replace;e.add(r.getType()),t.add(r);}return {nodes:t,types:e}}function _s(o){return (typeof o.nodes=="function"?o.nodes():o.nodes)||[]}function gr(o,e){let t;return Gt(o(),{unwatched(){t&&(t(),t=void 0);},watched(){this.value=o(),t=e(this);}})}function J(o){throw new Error(o)}function Es(o,e){if(o&&e&&!Array.isArray(e)&&typeof o=="object"&&typeof e=="object"){let t=o,n=e;for(let r in n)t[r]=Es(t[r],n[r]);return o}return e}function ur(o){return o.id===q.unmarked}function su(o){return o.id===q.temporary}function Ts(o){return o.id===q.permanent}function lu(o){return o.id>=q.configured}function au(o){return o.id>=q.initialized}function cu(o){return o.id>=q.built}function du(o){return o.id>=q.afterRegistration}function uu(o){return ur(o)||J(`LexicalBuilder: Can not apply a temporary mark from state id ${String(o.id)} (expected ${String(q.unmarked)} unmarked)`),Object.assign(o,{id:q.temporary})}function fu(o){return su(o)||J(`LexicalBuilder: Can not apply a permanent mark from state id ${String(o.id)} (expected ${String(q.temporary)} temporary)`),Object.assign(o,{id:q.permanent})}function pu(o,e,t){return Object.assign(o,{config:e,id:q.configured,registerState:t})}function hu(o,e,t){return Object.assign(o,{id:q.initialized,initResult:e,registerState:t})}function mu(o,e,t){return Object.assign(o,{id:q.built,output:e,registerState:t})}function gu(o){return Object.assign(o,{id:q.registered})}function bu(o){return Object.assign(o,{id:q.afterRegistration})}function Cu(o){return Object.assign(o,{id:q.built})}function xu(){let o=$getRoot();o.isEmpty()&&o.append($createParagraphNode());}function yu(...o){return Xt.fromExtensions(o).buildEditor()}function cs(){}function wu(o){throw o}function sn(o){return Array.isArray(o)?o:[o]}function Nu(o,e){let n=Xt.fromEditor(o).getExtensionRep(e);return n===void 0&&J(`getExtensionDependencyFromEditor: Extension ${e.name} was not built when creating this editor`),n.getExtensionDependency()}function Rs(o,e){let n=Xt.fromEditor(o).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function _u(o,e){let t=Rs(o,e);return t===void 0&&J(`getPeerDependencyFromEditorOrThrow: Editor was not built with Extension ${e}`),t}function vu(){return {node:br()}}function br(){return $create(wt)}function Os(o){return o instanceof wt}function Ru(o,e=false){let t=$getSelection(),n=o.isSelected(),r=o.getKey(),i;e&&$isNodeSelection(t)?i=t:(i=$createNodeSelection(),$setSelection(i)),n?i.delete(r):i.add(r);}function Mu(o){let e=o.getNodes();if($filter(e,a=>$isBlockElementNode(a)&&a.canIndent()?a:null).length>0)return true;let n=o.anchor,r=o.focus,i=r.isBefore(n)?r:n,s=i.getNode(),l=$getNearestBlockElementAncestorOrThrow(s);if(l.canIndent()){let a=l.getKey(),c=$createRangeSelection();if(c.anchor.set(a,0,"element"),c.focus.set(a,0,"element"),c=$normalizeSelection__EXPERIMENTAL(c),c.anchor.is(i))return true}return false}function Ms(o,e){return mergeRegister(o.registerCommand(KEY_TAB_COMMAND,t=>{let n=$getSelection();if(!$isRangeSelection(n))return false;t.preventDefault();let r=Mu(n)?t.shiftKey?OUTDENT_CONTENT_COMMAND:INDENT_CONTENT_COMMAND:INSERT_TAB_COMMAND;return o.dispatchCommand(r,void 0)},COMMAND_PRIORITY_EDITOR),o.registerCommand(INDENT_CONTENT_COMMAND,()=>{let t=typeof e=="number"?e:e?e.peek():null;if(t==null)return false;let n=$getSelection();if(!$isRangeSelection(n))return false;let r=n.getNodes().map(i=>$getNearestBlockElementAncestorOrThrow(i).getIndent());return Math.max(...r)+1>=t},COMMAND_PRIORITY_CRITICAL))}var tu,Y,Eo,st,dr,ln,nu,ru,an,q,Su,fr,ls,vs,as,ar,Xt,Eu,pr,Tu,wt,Ou,ku,As=rt(()=>{tu=Symbol.for("preact-signals");st=0,dr=0,ln=0;Ee.prototype.brand=tu;Ee.prototype.h=function(){return true};Ee.prototype.S=function(o){let e=this.t;e!==o&&o.e===void 0&&(o.x=e,this.t=o,e!==void 0?e.e=o:hr(()=>{var t;(t=this.W)==null||t.call(this);}));};Ee.prototype.U=function(o){if(this.t!==void 0){let e=o.e,t=o.x;e!==void 0&&(e.x=t,o.e=void 0),t!==void 0&&(t.e=e,o.x=void 0),o===this.t&&(this.t=t,t===void 0&&hr(()=>{var n;(n=this.Z)==null||n.call(this);}));}};Ee.prototype.subscribe=function(o){return lt(()=>{let e=this.value,t=Y;Y=void 0;try{o(e);}finally{Y=t;}},{name:"sub"})};Ee.prototype.valueOf=function(){return this.value};Ee.prototype.toString=function(){return this.value+""};Ee.prototype.toJSON=function(){return this.value};Ee.prototype.peek=function(){let o=Y;Y=void 0;try{return this.value}finally{Y=o;}};Object.defineProperty(Ee.prototype,"value",{get(){let o=gs(this);return o!==void 0&&(o.i=this.i),this.v},set(o){if(o!==this.v){if(dr>100)throw new Error("Cycle detected");this.v=o,this.i++,ln++,st++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N();}finally{dn();}}}});_t.prototype=new Ee;_t.prototype.h=function(){if(this.f&=-3,1&this.f)return false;if((36&this.f)==32||(this.f&=-5,this.g===ln))return true;if(this.g=ln,this.f|=1,this.i>0&&!bs(this))return this.f&=-2,true;let o=Y;try{Cs(this),Y=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++);}catch(e){this.v=e,this.f|=16,this.i++;}return Y=o,Ss(this),this.f&=-2,true};_t.prototype.S=function(o){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e);}Ee.prototype.S.call(this,o);};_t.prototype.U=function(o){if(this.t!==void 0&&(Ee.prototype.U.call(this,o),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e);}};_t.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let o=this.t;o!==void 0;o=o.x)o.t.N();}};Object.defineProperty(_t.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");let o=gs(this);if(this.h(),o!==void 0&&(o.i=this.i),16&this.f)throw this.v;return this.v}});Vt.prototype.c=function(){let o=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e=="function"&&(this.u=e);}finally{o();}};Vt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ys(this),Cs(this),st++;let o=Y;return Y=this,ou.bind(this,o)};Vt.prototype.N=function(){2&this.f||(this.f|=2,this.o=Eo,Eo=this);};Vt.prototype.d=function(){this.f|=8,1&this.f||mr(this);};Vt.prototype.dispose=function(){this.d();};nu=defineExtension({build:(o,e,t)=>un(e),config:safeCast({defaultSelection:"rootEnd",disabled:false}),name:"@lexical/extension/AutoFocus",register(o,e,t){let n=t.getOutput();return lt(()=>n.disabled.value?void 0:o.registerRootListener(r=>{o.focus(()=>{let i=document.activeElement;r!==null&&(i===null||!r.contains(i))&&r.focus({preventScroll:true});},{defaultSelection:n.defaultSelection.peek()});}))}});ru=defineExtension({build(o,e,t){return un(e)},config:safeCast({$onClear:ws}),name:"@lexical/extension/ClearEditor",register(o,e,t){let{$onClear:n}=t.getOutput();return lt(()=>Ns(o,n.value))}});an=defineExtension({build(o){return gr(()=>o.getEditorState(),e=>o.registerUpdateListener(t=>{e.value=t.editorState;}))},name:"@lexical/extension/EditorState"});q={unmarked:0,temporary:1,permanent:2,configured:3,initialized:4,built:5,registered:6,afterRegistration:7};Su=new Set,fr=class{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(e,t){this.builder=e,this.extension=t,this.configs=new Set,this.state={id:q.unmarked};}mergeConfigs(){let e=this.extension.config||{},t=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):shallowMergeConfig;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;Ts(t)||J(`ExtensionRep: Can not configure from state id ${String(t.id)}`);let n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},r={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=pu(t,this.mergeConfigs(),n);this.state=i;let s;this.extension.init&&(s=this.extension.init(e,i.config,n)),this.state=hu(i,s,r);}build(e){let t=this.state;t.id!==q.initialized&&J(`ExtensionRep: register called in state id ${String(t.id)} (expected ${String(q.built)} initialized)`);let n;this.extension.build&&(n=this.extension.build(e,t.config,t.registerState));let r={...t.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=mu(t,n,r);}register(e,t){this._signal=t;let n=this.state;n.id!==q.built&&J(`ExtensionRep: register called in state id ${String(n.id)} (expected ${String(q.built)} built)`);let r=this.extension.register&&this.extension.register(e,n.config,n.registerState);return this.state=gu(n),()=>{let i=this.state;i.id!==q.afterRegistration&&J(`ExtensionRep: rollbackToBuiltState called in state id ${String(n.id)} (expected ${String(q.afterRegistration)} afterRegistration)`),this.state=Cu(i),r&&r();}}afterRegistration(e){let t=this.state;t.id!==q.registered&&J(`ExtensionRep: afterRegistration called in state id ${String(t.id)} (expected ${String(q.registered)} registered)`);let n;return this.extension.afterRegistration&&(n=this.extension.afterRegistration(e,t.config,t.registerState)),this.state=bu(t),n}getSignal(){return this._signal===void 0&&J("ExtensionRep.getSignal() called before register"),this._signal}getInitResult(){this.extension.init===void 0&&J(`ExtensionRep: getInitResult() called for Extension ${this.extension.name} that does not define init`);let e=this.state;return au(e)||J(`ExtensionRep: getInitResult() called for ExtensionRep in state id ${String(e.id)} < ${String(q.initialized)} (initialized)`),e.initResult}getInitPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionInitDependency():void 0}getExtensionInitDependency(){let e=this.state;return lu(e)||J(`ExtensionRep: getExtensionInitDependency called in state id ${String(e.id)} (expected >= ${String(q.configured)} configured)`),{config:e.config}}getPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}getInitDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&J(`LexicalExtensionBuilder: Extension ${this.extension.name} missing dependency extension ${e.name} to be in registry`),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&J(`LexicalExtensionBuilder: Extension ${this.extension.name} missing dependency extension ${e.name} to be in registry`),t.getExtensionDependency()}getState(){let e=this.state;return du(e)||J(`ExtensionRep getState called in state id ${String(e.id)} (expected ${String(q.afterRegistration)} afterRegistration)`),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Su}getPeerNameSet(){let e=this._peerNameSet;return e||(e=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=e),e}getExtensionDependency(){if(!this._dependency){let e=this.state;cu(e)||J(`Extension ${this.extension.name} used as a dependency before build`),this._dependency={config:e.config,init:e.initResult,output:e.output};}return this._dependency}},ls={tag:HISTORY_MERGE_TAG};vs=defineExtension({config:safeCast({setOptions:ls,updateOptions:ls}),init({$initialEditorState:o=xu}){return {$initialEditorState:o,initialized:false}},afterRegistration(o,{updateOptions:e,setOptions:t},n){let r=n.getInitResult();if(!r.initialized){r.initialized=true;let{$initialEditorState:i}=r;if($isEditorState(i))o.setEditorState(i,t);else if(typeof i=="function")o.update(()=>{i(o);},e);else if(i&&(typeof i=="string"||typeof i=="object")){let s=o.parseEditorState(i);o.setEditorState(s,t);}}return ()=>{}},name:"@lexical/extension/InitialState",nodes:[RootNode,TextNode,LineBreakNode,TabNode,ParagraphNode]}),as=Symbol.for("@lexical/extension/LexicalBuilder");ar="0.38.2+dev.esm",Xt=class o{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(e){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=ar,this.roots=e;for(let t of e)this.addExtension(t);}static fromExtensions(e){let t=[sn(vs)];for(let n of e)t.push(sn(n));return new o(t)}static maybeFromEditor(e){let t=e[as];return t&&(t.PACKAGE_VERSION!==ar&&J(`LexicalBuilder.fromEditor: The given editor was created with LexicalBuilder ${t.PACKAGE_VERSION} but this version is ${ar}. A project should have exactly one copy of LexicalBuilder`),t instanceof o||J("LexicalBuilder.fromEditor: There are multiple copies of the same version of LexicalBuilder in your project, and this editor was created with another one. Your project, or one of its dependencies, has its package.json and/or bundler configured incorrectly.")),t}static fromEditor(e){let t=o.maybeFromEditor(e);return t===void 0&&J("LexicalBuilder.fromEditor: The given editor was not created with LexicalBuilder"),t}constructEditor(){let{$initialEditorState:e,onError:t,...n}=this.buildCreateEditorArgs(),r=Object.assign(createEditor({...n,...t?{onError:i=>{t(i,r);}}:{}}),{[as]:this});for(let i of this.sortedExtensionReps())i.build(r);return r}buildEditor(){let e=cs;function t(){try{e();}finally{e=cs;}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=mergeRegister(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(e){return this.extensionNameMap.has(e)}getExtensionRep(e){let t=this.extensionNameMap.get(e.name);if(t)return t.extension!==e&&J(`LexicalBuilder: A registered extension with name ${e.name} exists but does not match the given extension`),t}addEdge(e,t,n){let r=this.outgoingConfigEdges.get(e);r?r.set(t,n):this.outgoingConfigEdges.set(e,new Map([[t,n]]));let i=this.incomingEdges.get(t);i?i.add(e):this.incomingEdges.set(t,new Set([e]));}addExtension(e){this._sortedExtensionReps!==void 0&&J("LexicalBuilder: addExtension called after finalization");let t=sn(e),[n]=t;typeof n.name!="string"&&J(`LexicalBuilder: extension name must be string, not ${typeof n.name}`);let r=this.extensionNameMap.get(n.name);if(r===void 0||r.extension===n||J(`LexicalBuilder: Multiple extensions registered with name ${n.name}, names must be unique`),!r){r=new fr(this,n),this.extensionNameMap.set(n.name,r);let i=this.conflicts.get(n.name);typeof i=="string"&&J(`LexicalBuilder: extension ${n.name} conflicts with ${i}`);for(let s of n.conflictsWith||[])this.extensionNameMap.has(s)&&J(`LexicalBuilder: extension ${n.name} conflicts with ${s}`),this.conflicts.set(s,n.name);for(let s of n.dependencies||[]){let l=sn(s);this.addEdge(n.name,l[0].name,l.slice(1)),this.addExtension(l);}for(let[s,l]of n.peerDependencies||[])this.addEdge(n.name,s,l?[l]:[]);}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;let e=[],t=(n,r)=>{let i=n.state;if(Ts(i))return;let s=n.extension.name;ur(i)||J(`LexicalBuilder: Circular dependency detected for Extension ${s} from ${r||"[unknown]"}`),i=uu(i),n.state=i;let l=this.outgoingConfigEdges.get(s);if(l)for(let a of l.keys()){let c=this.extensionNameMap.get(a);c&&t(c,s);}i=fu(i),n.state=i,e.push(n);};for(let n of this.extensionNameMap.values())ur(n.state)&&t(n);for(let n of e)for(let[r,i]of this.outgoingConfigEdges.get(n.extension.name)||[])if(i.length>0){let s=this.extensionNameMap.get(r);if(s)for(let l of i)s.configs.add(l);}for(let[n,...r]of this.roots)if(r.length>0){let i=this.extensionNameMap.get(n.name);i===void 0&&J(`LexicalBuilder: Expecting existing ExtensionRep for ${n.name}`);for(let s of r)i.configs.add(s);}return this._sortedExtensionReps=e,this._sortedExtensionReps}registerEditor(e){let t=this.sortedExtensionReps(),n=new AbortController,r=[()=>n.abort()],i=n.signal;for(let s of t){let l=s.register(e,i);l&&r.push(l);}for(let s of t){let l=s.afterRegistration(e);l&&r.push(l);}return mergeRegister(...r)}buildCreateEditorArgs(){let e={},t=new Set,n=new Map,r=new Map,i={},s={},l=this.sortedExtensionReps();for(let d of l){let{extension:u}=d;if(u.onError!==void 0&&(e.onError=u.onError),u.disableEvents!==void 0&&(e.disableEvents=u.disableEvents),u.parentEditor!==void 0&&(e.parentEditor=u.parentEditor),u.editable!==void 0&&(e.editable=u.editable),u.namespace!==void 0&&(e.namespace=u.namespace),u.$initialEditorState!==void 0&&(e.$initialEditorState=u.$initialEditorState),u.nodes)for(let h of _s(u)){if(typeof h!="function"){let p=n.get(h.replace);p&&J(`LexicalBuilder: Extension ${u.name} can not register replacement for node ${h.replace.name} because ${p.extension.name} already did`),n.set(h.replace,d);}t.add(h);}if(u.html){if(u.html.export)for(let[h,p]of u.html.export.entries())r.set(h,p);u.html.import&&Object.assign(i,u.html.import);}u.theme&&Es(s,u.theme);}Object.keys(s).length>0&&(e.theme=s),t.size&&(e.nodes=[...t]);let a=Object.keys(i).length>0,c=r.size>0;(a||c)&&(e.html={},a&&(e.html.import=i),c&&(e.html.export=r));for(let d of l)d.init(e);return e.onError||(e.onError=wu),e}};Eu=new Set,pr=defineExtension({build(o,e,t){let n=t.getDependency(an).output,r=Gt({watchedNodeKeys:new Map}),i=gr(()=>{},()=>lt(()=>{let l=i.peek(),{watchedNodeKeys:a}=r.value,c,d=false;n.value.read(()=>{if($getSelection())for(let[h,p]of a.entries()){if(p.size===0){a.delete(h);continue}let f=$getNodeByKey(h),m=f&&f.isSelected()||false;d=d||m!==(l?l.has(h):false),m&&(c=c||new Set,c.add(h));}}),!d&&c&&l&&c.size===l.size||(i.value=c);}));function s(l){let a=xs(()=>(i.value||Eu).has(l)),{watchedNodeKeys:c}=r.peek(),d=c.get(l),u=d!==void 0;return d=d||new Set,d.add(a),u||(c.set(l,d),r.value={watchedNodeKeys:c}),a}return {watchNodeKey:s}},dependencies:[an],name:"@lexical/extension/NodeSelection"}),Tu=createCommand("INSERT_HORIZONTAL_RULE_COMMAND"),wt=class o extends DecoratorNode{static getType(){return "horizontalrule"}static clone(e){return new o(e.__key)}static importJSON(e){return br().updateFromJSON(e)}static importDOM(){return {hr:()=>({conversion:vu,priority:0})}}exportDOM(){return {element:document.createElement("hr")}}createDOM(e){let t=document.createElement("hr");return addClassNamesToElement(t,e.theme.hr),t}getTextContent(){return `
|
|
2
|
-
`}isInline(){return false}updateDOM(){return false}};Ou=defineExtension({dependencies:[an,pr],name:"@lexical/extension/HorizontalRule",nodes:[wt],register(o,e,t){let{watchNodeKey:n}=t.getDependency(pr).output,r=Gt({nodeSelections:new Map}),i=o._config.theme.hrSelected??"selected";return mergeRegister(o.registerCommand(CLICK_COMMAND,s=>{if(isDOMNode(s.target)){let l=$getNodeFromDOMNode(s.target);if(Os(l))return Ru(l,s.shiftKey),true}return false},COMMAND_PRIORITY_LOW),o.registerMutationListener(wt,(s,l)=>{ms(()=>{let a=!1,{nodeSelections:c}=r.peek();for(let[d,u]of s.entries())if(u==="destroyed")c.delete(d),a=!0;else {let h=c.get(d),p=o.getElementByKey(d);h?h.domNode.value=p:(a=!0,c.set(d,{domNode:Gt(p),selectedSignal:n(d)}));}a&&(r.value={nodeSelections:c});});}),lt(()=>{let s=[];for(let{domNode:l,selectedSignal:a}of r.value.nodeSelections.values())s.push(lt(()=>{let c=l.value;c&&(a.value?addClassNamesToElement(c,i):removeClassNamesFromElement(c,i));}));return mergeRegister(...s)}))}});ku=defineExtension({build(o,e,t){return un(e)},config:safeCast({disabled:false,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(o,e,t){let{disabled:n,maxIndent:r}=t.getOutput();return lt(()=>{if(!n.value)return Ms(o,r)})}});});var il={};jt(il,{$createHorizontalRuleNode:()=>kr,$isHorizontalRuleNode:()=>nl,AutoFocusExtension:()=>gf,ClearEditorExtension:()=>bf,EditorStateExtension:()=>mn,HorizontalRuleExtension:()=>Of,HorizontalRuleNode:()=>Tt,INSERT_HORIZONTAL_RULE_COMMAND:()=>vf,InitialStateExtension:()=>tl,LexicalBuilder:()=>Qt,NodeSelectionExtension:()=>vr,TabIndentationExtension:()=>Mf,batch:()=>Us,buildEditorFromExtensions:()=>wf,computed:()=>Gs,configExtension:()=>configExtension,declarePeerDependency:()=>declarePeerDependency,defineExtension:()=>defineExtension,effect:()=>ct,getExtensionDependencyFromEditor:()=>_f,getKnownTypesAndNodes:()=>Cf,getPeerDependencyFromEditor:()=>ol,getPeerDependencyFromEditorOrThrow:()=>Ef,namedSignals:()=>Cn,registerClearEditor:()=>Js,registerTabIndentation:()=>rl,safeCast:()=>safeCast,shallowMergeConfig:()=>shallowMergeConfig,signal:()=>Zt,untracked:()=>Nr,watchedSignal:()=>Or});function bn(){if(at>1)return void at--;let o,e=false;for(;Oo!==void 0;){let t=Oo;for(Oo=void 0,_r++;t!==void 0;){let n=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&js(t))try{t.c();}catch(r){e||(o=r,e=true);}t=n;}}if(_r=0,at--,e)throw o}function Us(o){if(at>0)return o();at++;try{return o()}finally{bn();}}function Nr(o){let e=G;G=void 0;try{return o()}finally{G=e;}}function Ds(o){if(G===void 0)return;let e=o.n;return e===void 0||e.t!==G?(e={i:0,S:o,p:G.s,n:void 0,t:G,e:void 0,x:void 0,r:e},G.s!==void 0&&(G.s.n=e),G.s=e,o.n=e,32&G.f&&o.S(e),e):e.i===-1?(e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=G.s,e.n=void 0,G.s.n=e,G.s=e),e):void 0}function Te(o,e){this.v=o,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name;}function Zt(o,e){return new Te(o,e)}function js(o){for(let e=o.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function Ls(o){for(let e=o.s;e!==void 0;e=e.n){let t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){o.s=e;break}}}function Ys(o){let e,t=o.s;for(;t!==void 0;){let n=t.p;t.i===-1?(t.S.U(t),n!==void 0&&(n.n=t.n),t.n!==void 0&&(t.n.p=n)):e=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=n;}o.s=e;}function Et(o,e){Te.call(this,void 0),this.x=o,this.s=void 0,this.g=hn-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name;}function Gs(o,e){return new Et(o,e)}function Xs(o){let e=o.u;if(o.u=void 0,typeof e=="function"){at++;let t=G;G=void 0;try{e();}catch(n){throw o.f&=-2,o.f|=8,Rr(o),n}finally{G=t,bn();}}}function Rr(o){for(let e=o.s;e!==void 0;e=e.n)e.S.U(e);o.x=void 0,o.s=void 0,Xs(o);}function mf(o){if(G!==this)throw new Error("Out-of-order effect");Ys(this),G=o,this.f&=-2,8&this.f&&Rr(this),bn();}function qt(o,e){this.x=o,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name;}function ct(o,e){let t=new qt(o,e);try{t.c();}catch(r){throw t.d(),r}let n=t.d.bind(t);return n[Symbol.dispose]=n,n}function Cn(o,e={}){let t={};for(let n in o){let r=e[n],i=Zt(r===void 0?o[n]:r);t[n]=i;}return t}function Vs(){let o=$getRoot(),e=$getSelection(),t=$createParagraphNode();o.clear(),o.append(t),e!==null&&t.select(),$isRangeSelection(e)&&(e.format=0);}function Js(o,e=Vs){return o.registerCommand(CLEAR_EDITOR_COMMAND,t=>(o.update(e),true),COMMAND_PRIORITY_EDITOR)}function Cf(o){let e=new Set,t=new Set;for(let n of qs(o)){let r=typeof n=="function"?n:n.replace;e.add(r.getType()),t.add(r);}return {nodes:t,types:e}}function qs(o){return (typeof o.nodes=="function"?o.nodes():o.nodes)||[]}function Or(o,e){let t;return Zt(o(),{unwatched(){t&&(t(),t=void 0);},watched(){this.value=o(),t=e(this);}})}function Z(o,...e){let t=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",o);for(let r of e)n.append("v",r);throw t.search=n.toString(),Error(`Minified Lexical error #${o}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Zs(o,e){if(o&&e&&!Array.isArray(e)&&typeof o=="object"&&typeof e=="object"){let t=o,n=e;for(let r in n)t[r]=Zs(t[r],n[r]);return o}return e}function xr(o){return o.id===Mr}function el(o){return o.id===Qs}function Sf(o){return (function(e){return e.id===Er})(o)||Z(305,String(o.id),String(Er)),Object.assign(o,{id:Qs})}function yf(){let o=$getRoot();o.isEmpty()&&o.append($createParagraphNode());}function wf(...o){return Qt.fromExtensions(o).buildEditor()}function Ks(){}function Nf(o){throw o}function pn(o){return Array.isArray(o)?o:[o]}function _f(o,e){let t=Qt.fromEditor(o).getExtensionRep(e);return t===void 0&&Z(303,e.name),t.getExtensionDependency()}function ol(o,e){let t=Qt.fromEditor(o).extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}function Ef(o,e){let t=ol(o,e);return t===void 0&&Z(291,e),t}function Rf(){return {node:kr()}}function kr(){return $create(Tt)}function nl(o){return o instanceof Tt}function rl(o,e){return mergeRegister(o.registerCommand(KEY_TAB_COMMAND,t=>{let n=$getSelection();if(!$isRangeSelection(n))return false;t.preventDefault();let r=(function(i){let s=i.getNodes();if($filter(s,h=>$isBlockElementNode(h)&&h.canIndent()?h:null).length>0)return true;let l=i.anchor,a=i.focus,c=a.isBefore(l)?a:l,d=c.getNode(),u=$getNearestBlockElementAncestorOrThrow(d);if(u.canIndent()){let h=u.getKey(),p=$createRangeSelection();if(p.anchor.set(h,0,"element"),p.focus.set(h,0,"element"),p=$normalizeSelection__EXPERIMENTAL(p),p.anchor.is(c))return true}return false})(n)?t.shiftKey?OUTDENT_CONTENT_COMMAND:INDENT_CONTENT_COMMAND:INSERT_TAB_COMMAND;return o.dispatchCommand(r,void 0)},COMMAND_PRIORITY_EDITOR),o.registerCommand(INDENT_CONTENT_COMMAND,()=>{let t=typeof e=="number"?e:e?e.peek():null;if(t==null)return false;let n=$getSelection();if(!$isRangeSelection(n))return false;let r=n.getNodes().map(i=>$getNearestBlockElementAncestorOrThrow(i).getIndent());return Math.max(...r)+1>=t},COMMAND_PRIORITY_CRITICAL))}var hf,G,Oo,at,_r,hn,gf,bf,mn,Mr,Er,Qs,Cr,fn,Jt,Sr,Ro,xf,Tr,Ps,tl,Is,yr,Qt,Tf,vr,vf,Tt,Of,Mf,sl=rt(()=>{hf=Symbol.for("preact-signals");at=0,_r=0,hn=0;Te.prototype.brand=hf,Te.prototype.h=function(){return true},Te.prototype.S=function(o){let e=this.t;e!==o&&o.e===void 0&&(o.x=e,this.t=o,e!==void 0?e.e=o:Nr(()=>{var t;(t=this.W)==null||t.call(this);}));},Te.prototype.U=function(o){if(this.t!==void 0){let e=o.e,t=o.x;e!==void 0&&(e.x=t,o.e=void 0),t!==void 0&&(t.e=e,o.x=void 0),o===this.t&&(this.t=t,t===void 0&&Nr(()=>{var n;(n=this.Z)==null||n.call(this);}));}},Te.prototype.subscribe=function(o){return ct(()=>{let e=this.value,t=G;G=void 0;try{o(e);}finally{G=t;}},{name:"sub"})},Te.prototype.valueOf=function(){return this.value},Te.prototype.toString=function(){return this.value+""},Te.prototype.toJSON=function(){return this.value},Te.prototype.peek=function(){let o=G;G=void 0;try{return this.value}finally{G=o;}},Object.defineProperty(Te.prototype,"value",{get(){let o=Ds(this);return o!==void 0&&(o.i=this.i),this.v},set(o){if(o!==this.v){if(_r>100)throw new Error("Cycle detected");this.v=o,this.i++,hn++,at++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N();}finally{bn();}}}}),Et.prototype=new Te,Et.prototype.h=function(){if(this.f&=-3,1&this.f)return false;if((36&this.f)==32||(this.f&=-5,this.g===hn))return true;if(this.g=hn,this.f|=1,this.i>0&&!js(this))return this.f&=-2,true;let o=G;try{Ls(this),G=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++);}catch(e){this.v=e,this.f|=16,this.i++;}return G=o,Ys(this),this.f&=-2,true},Et.prototype.S=function(o){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e);}Te.prototype.S.call(this,o);},Et.prototype.U=function(o){if(this.t!==void 0&&(Te.prototype.U.call(this,o),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e);}},Et.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let o=this.t;o!==void 0;o=o.x)o.t.N();}},Object.defineProperty(Et.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");let o=Ds(this);if(this.h(),o!==void 0&&(o.i=this.i),16&this.f)throw this.v;return this.v}}),qt.prototype.c=function(){let o=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e=="function"&&(this.u=e);}finally{o();}},qt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Xs(this),Ls(this),at++;let o=G;return G=this,mf.bind(this,o)},qt.prototype.N=function(){2&this.f||(this.f|=2,this.o=Oo,Oo=this);},qt.prototype.d=function(){this.f|=8,1&this.f||Rr(this);},qt.prototype.dispose=function(){this.d();};gf=defineExtension({build:(o,e,t)=>Cn(e),config:safeCast({defaultSelection:"rootEnd",disabled:false}),name:"@lexical/extension/AutoFocus",register(o,e,t){let n=t.getOutput();return ct(()=>n.disabled.value?void 0:o.registerRootListener(r=>{o.focus(()=>{let i=document.activeElement;r===null||i!==null&&r.contains(i)||r.focus({preventScroll:true});},{defaultSelection:n.defaultSelection.peek()});}))}});bf=defineExtension({build:(o,e,t)=>Cn(e),config:safeCast({$onClear:Vs}),name:"@lexical/extension/ClearEditor",register(o,e,t){let{$onClear:n}=t.getOutput();return ct(()=>Js(o,n.value))}});mn=defineExtension({build:o=>Or(()=>o.getEditorState(),e=>o.registerUpdateListener(t=>{e.value=t.editorState;})),name:"@lexical/extension/EditorState"});Mr=0,Er=1,Qs=2,Cr=3,fn=4,Jt=5,Sr=6,Ro=7;xf=new Set,Tr=class{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(e,t){this.builder=e,this.extension=t,this.configs=new Set,this.state={id:Mr};}mergeConfigs(){let e=this.extension.config||{},t=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):shallowMergeConfig;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;el(t)||Z(306,String(t.id));let n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},r={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=(function(l,a,c){return Object.assign(l,{config:a,id:Cr,registerState:c})})(t,this.mergeConfigs(),n),s;this.state=i,this.extension.init&&(s=this.extension.init(e,i.config,n)),this.state=(function(l,a,c){return Object.assign(l,{id:fn,initResult:a,registerState:c})})(i,s,r);}build(e){let t=this.state,n;t.id!==fn&&Z(307,String(t.id),String(Jt)),this.extension.build&&(n=this.extension.build(e,t.config,t.registerState));let r={...t.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=(function(i,s,l){return Object.assign(i,{id:Jt,output:s,registerState:l})})(t,n,r);}register(e,t){this._signal=t;let n=this.state;n.id!==Jt&&Z(308,String(n.id),String(Jt));let r=this.extension.register&&this.extension.register(e,n.config,n.registerState);return this.state=(function(i){return Object.assign(i,{id:Sr})})(n),()=>{let i=this.state;i.id!==Ro&&Z(309,String(n.id),String(Ro)),this.state=(function(s){return Object.assign(s,{id:Jt})})(i),r&&r();}}afterRegistration(e){let t=this.state,n;return t.id!==Sr&&Z(310,String(t.id),String(Sr)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(e,t.config,t.registerState)),this.state=(function(r){return Object.assign(r,{id:Ro})})(t),n}getSignal(){return this._signal===void 0&&Z(311),this._signal}getInitResult(){this.extension.init===void 0&&Z(312,this.extension.name);let e=this.state;return (function(t){return t.id>=fn})(e)||Z(313,String(e.id),String(fn)),e.initResult}getInitPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionInitDependency():void 0}getExtensionInitDependency(){let e=this.state;return (function(t){return t.id>=Cr})(e)||Z(314,String(e.id),String(Cr)),{config:e.config}}getPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}getInitDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Z(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Z(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return (function(t){return t.id>=Ro})(e)||Z(316,String(e.id),String(Ro)),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||xf}getPeerNameSet(){let e=this._peerNameSet;return e||(e=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=e),e}getExtensionDependency(){if(!this._dependency){let e=this.state;((function(t){return t.id>=Jt}))(e)||Z(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output};}return this._dependency}},Ps={tag:HISTORY_MERGE_TAG};tl=defineExtension({config:safeCast({setOptions:Ps,updateOptions:Ps}),init:({$initialEditorState:o=yf})=>({$initialEditorState:o,initialized:false}),afterRegistration(o,{updateOptions:e,setOptions:t},n){let r=n.getInitResult();if(!r.initialized){r.initialized=true;let{$initialEditorState:i}=r;if($isEditorState(i))o.setEditorState(i,t);else if(typeof i=="function")o.update(()=>{i(o);},e);else if(i&&(typeof i=="string"||typeof i=="object")){let s=o.parseEditorState(i);o.setEditorState(s,t);}}return ()=>{}},name:"@lexical/extension/InitialState",nodes:[RootNode,TextNode,LineBreakNode,TabNode,ParagraphNode]}),Is=Symbol.for("@lexical/extension/LexicalBuilder");yr="0.38.2+prod.esm",Qt=class o{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(e){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=yr,this.roots=e;for(let t of e)this.addExtension(t);}static fromExtensions(e){let t=[pn(tl)];for(let n of e)t.push(pn(n));return new o(t)}static maybeFromEditor(e){let t=e[Is];return t&&(t.PACKAGE_VERSION!==yr&&Z(292,t.PACKAGE_VERSION,yr),t instanceof o||Z(293)),t}static fromEditor(e){let t=o.maybeFromEditor(e);return t===void 0&&Z(294),t}constructEditor(){let{$initialEditorState:e,onError:t,...n}=this.buildCreateEditorArgs(),r=Object.assign(createEditor({...n,...t?{onError:i=>{t(i,r);}}:{}}),{[Is]:this});for(let i of this.sortedExtensionReps())i.build(r);return r}buildEditor(){let e=Ks;function t(){try{e();}finally{e=Ks;}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=mergeRegister(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(e){return this.extensionNameMap.has(e)}getExtensionRep(e){let t=this.extensionNameMap.get(e.name);if(t)return t.extension!==e&&Z(295,e.name),t}addEdge(e,t,n){let r=this.outgoingConfigEdges.get(e);r?r.set(t,n):this.outgoingConfigEdges.set(e,new Map([[t,n]]));let i=this.incomingEdges.get(t);i?i.add(e):this.incomingEdges.set(t,new Set([e]));}addExtension(e){this._sortedExtensionReps!==void 0&&Z(296);let t=pn(e),[n]=t;typeof n.name!="string"&&Z(297,typeof n.name);let r=this.extensionNameMap.get(n.name);if(r!==void 0&&r.extension!==n&&Z(298,n.name),!r){r=new Tr(this,n),this.extensionNameMap.set(n.name,r);let i=this.conflicts.get(n.name);typeof i=="string"&&Z(299,n.name,i);for(let s of n.conflictsWith||[])this.extensionNameMap.has(s)&&Z(299,n.name,s),this.conflicts.set(s,n.name);for(let s of n.dependencies||[]){let l=pn(s);this.addEdge(n.name,l[0].name,l.slice(1)),this.addExtension(l);}for(let[s,l]of n.peerDependencies||[])this.addEdge(n.name,s,l?[l]:[]);}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;let e=[],t=(n,r)=>{let i=n.state;if(el(i))return;let s=n.extension.name;var l;xr(i)||Z(300,s,r||"[unknown]"),xr(l=i)||Z(304,String(l.id),String(Mr)),i=Object.assign(l,{id:Er}),n.state=i;let a=this.outgoingConfigEdges.get(s);if(a)for(let c of a.keys()){let d=this.extensionNameMap.get(c);d&&t(d,s);}i=Sf(i),n.state=i,e.push(n);};for(let n of this.extensionNameMap.values())xr(n.state)&&t(n);for(let n of e)for(let[r,i]of this.outgoingConfigEdges.get(n.extension.name)||[])if(i.length>0){let s=this.extensionNameMap.get(r);if(s)for(let l of i)s.configs.add(l);}for(let[n,...r]of this.roots)if(r.length>0){let i=this.extensionNameMap.get(n.name);i===void 0&&Z(301,n.name);for(let s of r)i.configs.add(s);}return this._sortedExtensionReps=e,this._sortedExtensionReps}registerEditor(e){let t=this.sortedExtensionReps(),n=new AbortController,r=[()=>n.abort()],i=n.signal;for(let s of t){let l=s.register(e,i);l&&r.push(l);}for(let s of t){let l=s.afterRegistration(e);l&&r.push(l);}return mergeRegister(...r)}buildCreateEditorArgs(){let e={},t=new Set,n=new Map,r=new Map,i={},s={},l=this.sortedExtensionReps();for(let d of l){let{extension:u}=d;if(u.onError!==void 0&&(e.onError=u.onError),u.disableEvents!==void 0&&(e.disableEvents=u.disableEvents),u.parentEditor!==void 0&&(e.parentEditor=u.parentEditor),u.editable!==void 0&&(e.editable=u.editable),u.namespace!==void 0&&(e.namespace=u.namespace),u.$initialEditorState!==void 0&&(e.$initialEditorState=u.$initialEditorState),u.nodes)for(let h of qs(u)){if(typeof h!="function"){let p=n.get(h.replace);p&&Z(302,u.name,h.replace.name,p.extension.name),n.set(h.replace,d);}t.add(h);}if(u.html){if(u.html.export)for(let[h,p]of u.html.export.entries())r.set(h,p);u.html.import&&Object.assign(i,u.html.import);}u.theme&&Zs(s,u.theme);}Object.keys(s).length>0&&(e.theme=s),t.size&&(e.nodes=[...t]);let a=Object.keys(i).length>0,c=r.size>0;(a||c)&&(e.html={},a&&(e.html.import=i),c&&(e.html.export=r));for(let d of l)d.init(e);return e.onError||(e.onError=Nf),e}};Tf=new Set,vr=defineExtension({build(o,e,t){let n=t.getDependency(mn).output,r=Zt({watchedNodeKeys:new Map}),i=Or(()=>{},()=>ct(()=>{let s=i.peek(),{watchedNodeKeys:l}=r.value,a,c=false;n.value.read(()=>{if($getSelection())for(let[d,u]of l.entries()){if(u.size===0){l.delete(d);continue}let h=$getNodeByKey(d),p=h&&h.isSelected()||false;c=c||p!==(!!s&&s.has(d)),p&&(a=a||new Set,a.add(d));}}),!c&&a&&s&&a.size===s.size||(i.value=a);}));return {watchNodeKey:function(s){let l=Gs(()=>(i.value||Tf).has(s)),{watchedNodeKeys:a}=r.peek(),c=a.get(s),d=c!==void 0;return c=c||new Set,c.add(l),d||(a.set(s,c),r.value={watchedNodeKeys:a}),l}}},dependencies:[mn],name:"@lexical/extension/NodeSelection"}),vf=createCommand("INSERT_HORIZONTAL_RULE_COMMAND"),Tt=class o extends DecoratorNode{static getType(){return "horizontalrule"}static clone(e){return new o(e.__key)}static importJSON(e){return kr().updateFromJSON(e)}static importDOM(){return {hr:()=>({conversion:Rf,priority:0})}}exportDOM(){return {element:document.createElement("hr")}}createDOM(e){let t=document.createElement("hr");return addClassNamesToElement(t,e.theme.hr),t}getTextContent(){return `
|
|
3
|
-
`}isInline(){return false}updateDOM(){return false}};
|
|
1
|
+
import {createCommand,defineExtension,safeCast,$getEditor,ElementNode,isHTMLElement,setDOMUnmanaged,$getNearestNodeFromDOMNode,COMMAND_PRIORITY_EDITOR,SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,$isRangeSelection,CLICK_COMMAND,$isInlineElementOrDecoratorNode,$isTextNode,$isLineBreakNode,$createParagraphNode,$applyNodeReplacement,RootNode,TextNode,LineBreakNode,TabNode,ParagraphNode,$isEditorState,isDOMNode,$getNodeFromDOMNode,COMMAND_PRIORITY_LOW,HISTORY_MERGE_TAG,DecoratorNode,$getSelection,$isNodeSelection,$createNodeSelection,$setSelection,$getPreviousSelection,$isElementNode,$getNodeByKey,$getRoot,$create,$createTextNode,COMMAND_PRIORITY_HIGH,KEY_ESCAPE_COMMAND,CUT_COMMAND,FORMAT_TEXT_COMMAND,FORMAT_ELEMENT_COMMAND,CONTROLLED_TEXT_INSERTION_COMMAND,KEY_TAB_COMMAND,FOCUS_COMMAND,SELECTION_CHANGE_COMMAND,getDOMSelection,$createRangeSelectionFromDom,INSERT_PARAGRAPH_COMMAND,$isRootOrShadowRoot,DELETE_LINE_COMMAND,$caretFromPoint,$isExtendableTextPointCaret,$extendCaretToRange,$isSiblingCaret,$isChildCaret,$getChildCaret,$getSiblingCaret,$normalizeCaret,$setPointFromCaret,$getAdjacentChildCaret,$isParagraphNode,shallowMergeConfig,declarePeerDependency,configExtension,CLEAR_EDITOR_COMMAND,OUTDENT_CONTENT_COMMAND,INDENT_CONTENT_COMMAND,INSERT_TAB_COMMAND,COMMAND_PRIORITY_CRITICAL,createEditor,$isBlockElementNode,$createRangeSelection,$normalizeSelection__EXPERIMENTAL,$createTabNode,$isTextPointCaret,$getCaretRange,$parseSerializedNode,COPY_COMMAND,isSelectionWithinEditor,$createPoint,TEXT_TYPE_TO_FORMAT,isCurrentlyReadOnlyMode,$isRootNode,KEY_ARROW_DOWN_COMMAND,KEY_ARROW_UP_COMMAND,KEY_ARROW_LEFT_COMMAND,KEY_ARROW_RIGHT_COMMAND,DELETE_WORD_COMMAND,DELETE_CHARACTER_COMMAND,KEY_BACKSPACE_COMMAND,KEY_DELETE_COMMAND,$insertNodes,PASTE_COMMAND,REDO_COMMAND,UNDO_COMMAND}from'lexical';import {mergeRegister,addClassNamesToElement,removeClassNamesFromElement,isHTMLElement as isHTMLElement$1,$insertFirst,$descendantsMatching,$insertNodeToNearestRoot,$findMatchingParent,$unwrapAndFilterDescendants,objectKlassEquals,$getNearestBlockElementAncestorOrThrow,$filter,$getNearestNodeOfType}from'@lexical/utils';import {$generateHtmlFromNodes,$generateNodesFromDOM}from'@lexical/html';import {$addNodeStyle,$sliceSelectedTextNodeContent,$isAtNodeEnd,$patchStyleText}from'@lexical/selection';import*as Qc from'react';import Qc__default,{createContext,useContext,useState,Children,cloneElement,isValidElement,useEffect,useRef,useCallback,useMemo,useLayoutEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {AutoFocusPlugin}from'@lexical/react/LexicalAutoFocusPlugin';import {LexicalComposer}from'@lexical/react/LexicalComposer';import {RichTextPlugin}from'@lexical/react/LexicalRichTextPlugin';import {ContentEditable}from'@lexical/react/LexicalContentEditable';import {HistoryPlugin}from'@lexical/react/LexicalHistoryPlugin';import {LexicalErrorBoundary}from'@lexical/react/LexicalErrorBoundary';import {ListPlugin}from'@lexical/react/LexicalListPlugin';import {LinkPlugin}from'@lexical/react/LexicalLinkPlugin';import {LinkNode,AutoLinkNode,$isLinkNode,TOGGLE_LINK_COMMAND}from'@lexical/link';import {ListNode,ListItemNode,$isListNode,INSERT_UNORDERED_LIST_COMMAND,REMOVE_LIST_COMMAND,INSERT_ORDERED_LIST_COMMAND}from'@lexical/list';import {useLexicalComposerContext}from'@lexical/react/LexicalComposerContext';import {createPortal}from'react-dom';import {MdLockClock,MdPhoto,MdOutlineEmojiEmotions,MdClose,MdEdit,MdTextFields,MdCheck,MdImage,MdLink,MdAttachFile,MdTextFormat,MdArrowDropDown,MdFormatQuote,MdStrikethroughS,MdFormatClear,MdOutlineFormatIndentIncrease,MdFormatIndentDecrease,MdFormatListNumbered,MdFormatListBulleted,MdFormatAlignCenter,MdFormatAlignRight,MdFormatAlignLeft,MdFormatUnderlined,MdFormatItalic,MdFormatBold,MdRedo,MdUndo}from'react-icons/md';import {TbBrandGoogleDrive}from'react-icons/tb';import {RiBallPenFill}from'react-icons/ri';import {FaBan}from'react-icons/fa';import jg from'reactjs-popup';import {useDropzone}from'react-dropzone';import $b from'heic2any';import Ub from'@emoji-mart/react';import jb from'@emoji-mart/data';var md=Object.defineProperty;var rt=(o,e)=>()=>(o&&(e=o(o=0)),e);var jt=(o,e)=>{for(var t in e)md(o,t,{get:e[t],enumerable:true});};var ks={};jt(ks,{$createHorizontalRuleNode:()=>br,$isHorizontalRuleNode:()=>Ms,AutoFocusExtension:()=>nu,ClearEditorExtension:()=>ru,EditorStateExtension:()=>an,HorizontalRuleExtension:()=>Mu,HorizontalRuleNode:()=>wt,INSERT_HORIZONTAL_RULE_COMMAND:()=>Tu,InitialStateExtension:()=>vs,LexicalBuilder:()=>Xt,NodeSelectionExtension:()=>pr,TabIndentationExtension:()=>ku,batch:()=>ms,buildEditorFromExtensions:()=>yu,computed:()=>xs,configExtension:()=>configExtension,declarePeerDependency:()=>declarePeerDependency,defineExtension:()=>defineExtension,effect:()=>lt,getExtensionDependencyFromEditor:()=>Nu,getKnownTypesAndNodes:()=>iu,getPeerDependencyFromEditor:()=>Rs,getPeerDependencyFromEditorOrThrow:()=>_u,namedSignals:()=>un,registerClearEditor:()=>Ns,registerTabIndentation:()=>Os,safeCast:()=>safeCast,shallowMergeConfig:()=>shallowMergeConfig,signal:()=>Gt,untracked:()=>hr,watchedSignal:()=>gr});function dn(){if(st>1){st--;return}let o,e=false;for(;Eo!==void 0;){let t=Eo;for(Eo=void 0,dr++;t!==void 0;){let n=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&bs(t))try{t.c();}catch(r){e||(o=r,e=true);}t=n;}}if(dr=0,st--,e)throw o}function ms(o){if(st>0)return o();st++;try{return o()}finally{dn();}}function hr(o){let e=G;G=void 0;try{return o()}finally{G=e;}}function gs(o){if(G===void 0)return;let e=o.n;if(e===void 0||e.t!==G)return e={i:0,S:o,p:G.s,n:void 0,t:G,e:void 0,x:void 0,r:e},G.s!==void 0&&(G.s.n=e),G.s=e,o.n=e,32&G.f&&o.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=G.s,e.n=void 0,G.s.n=e,G.s=e),e}function Ee(o,e){this.v=o,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name;}function Gt(o,e){return new Ee(o,e)}function bs(o){for(let e=o.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function Cs(o){for(let e=o.s;e!==void 0;e=e.n){let t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){o.s=e;break}}}function Ss(o){let e,t=o.s;for(;t!==void 0;){let n=t.p;t.i===-1?(t.S.U(t),n!==void 0&&(n.n=t.n),t.n!==void 0&&(t.n.p=n)):e=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=n;}o.s=e;}function _t(o,e){Ee.call(this,void 0),this.x=o,this.s=void 0,this.g=ln-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name;}function xs(o,e){return new _t(o,e)}function ys(o){let e=o.u;if(o.u=void 0,typeof e=="function"){st++;let t=G;G=void 0;try{e();}catch(n){throw o.f&=-2,o.f|=8,mr(o),n}finally{G=t,dn();}}}function mr(o){for(let e=o.s;e!==void 0;e=e.n)e.S.U(e);o.x=void 0,o.s=void 0,ys(o);}function ou(o){if(G!==this)throw new Error("Out-of-order effect");Ss(this),G=o,this.f&=-2,8&this.f&&mr(this),dn();}function Jt(o,e){this.x=o,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name;}function lt(o,e){let t=new Jt(o,e);try{t.c();}catch(r){throw t.d(),r}let n=t.d.bind(t);return n[Symbol.dispose]=n,n}function un(o,e={}){let t={};for(let n in o){let r=e[n],i=Gt(r===void 0?o[n]:r);t[n]=i;}return t}function ws(){let o=$getRoot(),e=$getSelection(),t=$createParagraphNode();o.clear(),o.append(t),e!==null&&t.select(),$isRangeSelection(e)&&(e.format=0);}function Ns(o,e=ws){return o.registerCommand(CLEAR_EDITOR_COMMAND,t=>(o.update(e),true),COMMAND_PRIORITY_EDITOR)}function iu(o){let e=new Set,t=new Set;for(let n of _s(o)){let r=typeof n=="function"?n:n.replace;e.add(r.getType()),t.add(r);}return {nodes:t,types:e}}function _s(o){return (typeof o.nodes=="function"?o.nodes():o.nodes)||[]}function gr(o,e){let t;return Gt(o(),{unwatched(){t&&(t(),t=void 0);},watched(){this.value=o(),t=e(this);}})}function q(o){throw new Error(o)}function Es(o,e){if(o&&e&&!Array.isArray(e)&&typeof o=="object"&&typeof e=="object"){let t=o,n=e;for(let r in n)t[r]=Es(t[r],n[r]);return o}return e}function ur(o){return o.id===Z.unmarked}function su(o){return o.id===Z.temporary}function Ts(o){return o.id===Z.permanent}function lu(o){return o.id>=Z.configured}function au(o){return o.id>=Z.initialized}function cu(o){return o.id>=Z.built}function du(o){return o.id>=Z.afterRegistration}function uu(o){return ur(o)||q(`LexicalBuilder: Can not apply a temporary mark from state id ${String(o.id)} (expected ${String(Z.unmarked)} unmarked)`),Object.assign(o,{id:Z.temporary})}function fu(o){return su(o)||q(`LexicalBuilder: Can not apply a permanent mark from state id ${String(o.id)} (expected ${String(Z.temporary)} temporary)`),Object.assign(o,{id:Z.permanent})}function pu(o,e,t){return Object.assign(o,{config:e,id:Z.configured,registerState:t})}function hu(o,e,t){return Object.assign(o,{id:Z.initialized,initResult:e,registerState:t})}function mu(o,e,t){return Object.assign(o,{id:Z.built,output:e,registerState:t})}function gu(o){return Object.assign(o,{id:Z.registered})}function bu(o){return Object.assign(o,{id:Z.afterRegistration})}function Cu(o){return Object.assign(o,{id:Z.built})}function xu(){let o=$getRoot();o.isEmpty()&&o.append($createParagraphNode());}function yu(...o){return Xt.fromExtensions(o).buildEditor()}function cs(){}function wu(o){throw o}function sn(o){return Array.isArray(o)?o:[o]}function Nu(o,e){let n=Xt.fromEditor(o).getExtensionRep(e);return n===void 0&&q(`getExtensionDependencyFromEditor: Extension ${e.name} was not built when creating this editor`),n.getExtensionDependency()}function Rs(o,e){let n=Xt.fromEditor(o).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0}function _u(o,e){let t=Rs(o,e);return t===void 0&&q(`getPeerDependencyFromEditorOrThrow: Editor was not built with Extension ${e}`),t}function vu(){return {node:br()}}function br(){return $create(wt)}function Ms(o){return o instanceof wt}function Ru(o,e=false){let t=$getSelection(),n=o.isSelected(),r=o.getKey(),i;e&&$isNodeSelection(t)?i=t:(i=$createNodeSelection(),$setSelection(i)),n?i.delete(r):i.add(r);}function Ou(o){let e=o.getNodes();if($filter(e,a=>$isBlockElementNode(a)&&a.canIndent()?a:null).length>0)return true;let n=o.anchor,r=o.focus,i=r.isBefore(n)?r:n,s=i.getNode(),l=$getNearestBlockElementAncestorOrThrow(s);if(l.canIndent()){let a=l.getKey(),c=$createRangeSelection();if(c.anchor.set(a,0,"element"),c.focus.set(a,0,"element"),c=$normalizeSelection__EXPERIMENTAL(c),c.anchor.is(i))return true}return false}function Os(o,e){return mergeRegister(o.registerCommand(KEY_TAB_COMMAND,t=>{let n=$getSelection();if(!$isRangeSelection(n))return false;t.preventDefault();let r=Ou(n)?t.shiftKey?OUTDENT_CONTENT_COMMAND:INDENT_CONTENT_COMMAND:INSERT_TAB_COMMAND;return o.dispatchCommand(r,void 0)},COMMAND_PRIORITY_EDITOR),o.registerCommand(INDENT_CONTENT_COMMAND,()=>{let t=typeof e=="number"?e:e?e.peek():null;if(t==null)return false;let n=$getSelection();if(!$isRangeSelection(n))return false;let r=n.getNodes().map(i=>$getNearestBlockElementAncestorOrThrow(i).getIndent());return Math.max(...r)+1>=t},COMMAND_PRIORITY_CRITICAL))}var tu,G,Eo,st,dr,ln,nu,ru,an,Z,Su,fr,ls,vs,as,ar,Xt,Eu,pr,Tu,wt,Mu,ku,As=rt(()=>{tu=Symbol.for("preact-signals");st=0,dr=0,ln=0;Ee.prototype.brand=tu;Ee.prototype.h=function(){return true};Ee.prototype.S=function(o){let e=this.t;e!==o&&o.e===void 0&&(o.x=e,this.t=o,e!==void 0?e.e=o:hr(()=>{var t;(t=this.W)==null||t.call(this);}));};Ee.prototype.U=function(o){if(this.t!==void 0){let e=o.e,t=o.x;e!==void 0&&(e.x=t,o.e=void 0),t!==void 0&&(t.e=e,o.x=void 0),o===this.t&&(this.t=t,t===void 0&&hr(()=>{var n;(n=this.Z)==null||n.call(this);}));}};Ee.prototype.subscribe=function(o){return lt(()=>{let e=this.value,t=G;G=void 0;try{o(e);}finally{G=t;}},{name:"sub"})};Ee.prototype.valueOf=function(){return this.value};Ee.prototype.toString=function(){return this.value+""};Ee.prototype.toJSON=function(){return this.value};Ee.prototype.peek=function(){let o=G;G=void 0;try{return this.value}finally{G=o;}};Object.defineProperty(Ee.prototype,"value",{get(){let o=gs(this);return o!==void 0&&(o.i=this.i),this.v},set(o){if(o!==this.v){if(dr>100)throw new Error("Cycle detected");this.v=o,this.i++,ln++,st++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N();}finally{dn();}}}});_t.prototype=new Ee;_t.prototype.h=function(){if(this.f&=-3,1&this.f)return false;if((36&this.f)==32||(this.f&=-5,this.g===ln))return true;if(this.g=ln,this.f|=1,this.i>0&&!bs(this))return this.f&=-2,true;let o=G;try{Cs(this),G=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++);}catch(e){this.v=e,this.f|=16,this.i++;}return G=o,Ss(this),this.f&=-2,true};_t.prototype.S=function(o){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e);}Ee.prototype.S.call(this,o);};_t.prototype.U=function(o){if(this.t!==void 0&&(Ee.prototype.U.call(this,o),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e);}};_t.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let o=this.t;o!==void 0;o=o.x)o.t.N();}};Object.defineProperty(_t.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");let o=gs(this);if(this.h(),o!==void 0&&(o.i=this.i),16&this.f)throw this.v;return this.v}});Jt.prototype.c=function(){let o=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e=="function"&&(this.u=e);}finally{o();}};Jt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ys(this),Cs(this),st++;let o=G;return G=this,ou.bind(this,o)};Jt.prototype.N=function(){2&this.f||(this.f|=2,this.o=Eo,Eo=this);};Jt.prototype.d=function(){this.f|=8,1&this.f||mr(this);};Jt.prototype.dispose=function(){this.d();};nu=defineExtension({build:(o,e,t)=>un(e),config:safeCast({defaultSelection:"rootEnd",disabled:false}),name:"@lexical/extension/AutoFocus",register(o,e,t){let n=t.getOutput();return lt(()=>n.disabled.value?void 0:o.registerRootListener(r=>{o.focus(()=>{let i=document.activeElement;r!==null&&(i===null||!r.contains(i))&&r.focus({preventScroll:true});},{defaultSelection:n.defaultSelection.peek()});}))}});ru=defineExtension({build(o,e,t){return un(e)},config:safeCast({$onClear:ws}),name:"@lexical/extension/ClearEditor",register(o,e,t){let{$onClear:n}=t.getOutput();return lt(()=>Ns(o,n.value))}});an=defineExtension({build(o){return gr(()=>o.getEditorState(),e=>o.registerUpdateListener(t=>{e.value=t.editorState;}))},name:"@lexical/extension/EditorState"});Z={unmarked:0,temporary:1,permanent:2,configured:3,initialized:4,built:5,registered:6,afterRegistration:7};Su=new Set,fr=class{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(e,t){this.builder=e,this.extension=t,this.configs=new Set,this.state={id:Z.unmarked};}mergeConfigs(){let e=this.extension.config||{},t=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):shallowMergeConfig;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;Ts(t)||q(`ExtensionRep: Can not configure from state id ${String(t.id)}`);let n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},r={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=pu(t,this.mergeConfigs(),n);this.state=i;let s;this.extension.init&&(s=this.extension.init(e,i.config,n)),this.state=hu(i,s,r);}build(e){let t=this.state;t.id!==Z.initialized&&q(`ExtensionRep: register called in state id ${String(t.id)} (expected ${String(Z.built)} initialized)`);let n;this.extension.build&&(n=this.extension.build(e,t.config,t.registerState));let r={...t.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=mu(t,n,r);}register(e,t){this._signal=t;let n=this.state;n.id!==Z.built&&q(`ExtensionRep: register called in state id ${String(n.id)} (expected ${String(Z.built)} built)`);let r=this.extension.register&&this.extension.register(e,n.config,n.registerState);return this.state=gu(n),()=>{let i=this.state;i.id!==Z.afterRegistration&&q(`ExtensionRep: rollbackToBuiltState called in state id ${String(n.id)} (expected ${String(Z.afterRegistration)} afterRegistration)`),this.state=Cu(i),r&&r();}}afterRegistration(e){let t=this.state;t.id!==Z.registered&&q(`ExtensionRep: afterRegistration called in state id ${String(t.id)} (expected ${String(Z.registered)} registered)`);let n;return this.extension.afterRegistration&&(n=this.extension.afterRegistration(e,t.config,t.registerState)),this.state=bu(t),n}getSignal(){return this._signal===void 0&&q("ExtensionRep.getSignal() called before register"),this._signal}getInitResult(){this.extension.init===void 0&&q(`ExtensionRep: getInitResult() called for Extension ${this.extension.name} that does not define init`);let e=this.state;return au(e)||q(`ExtensionRep: getInitResult() called for ExtensionRep in state id ${String(e.id)} < ${String(Z.initialized)} (initialized)`),e.initResult}getInitPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionInitDependency():void 0}getExtensionInitDependency(){let e=this.state;return lu(e)||q(`ExtensionRep: getExtensionInitDependency called in state id ${String(e.id)} (expected >= ${String(Z.configured)} configured)`),{config:e.config}}getPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}getInitDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&q(`LexicalExtensionBuilder: Extension ${this.extension.name} missing dependency extension ${e.name} to be in registry`),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&q(`LexicalExtensionBuilder: Extension ${this.extension.name} missing dependency extension ${e.name} to be in registry`),t.getExtensionDependency()}getState(){let e=this.state;return du(e)||q(`ExtensionRep getState called in state id ${String(e.id)} (expected ${String(Z.afterRegistration)} afterRegistration)`),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Su}getPeerNameSet(){let e=this._peerNameSet;return e||(e=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=e),e}getExtensionDependency(){if(!this._dependency){let e=this.state;cu(e)||q(`Extension ${this.extension.name} used as a dependency before build`),this._dependency={config:e.config,init:e.initResult,output:e.output};}return this._dependency}},ls={tag:HISTORY_MERGE_TAG};vs=defineExtension({config:safeCast({setOptions:ls,updateOptions:ls}),init({$initialEditorState:o=xu}){return {$initialEditorState:o,initialized:false}},afterRegistration(o,{updateOptions:e,setOptions:t},n){let r=n.getInitResult();if(!r.initialized){r.initialized=true;let{$initialEditorState:i}=r;if($isEditorState(i))o.setEditorState(i,t);else if(typeof i=="function")o.update(()=>{i(o);},e);else if(i&&(typeof i=="string"||typeof i=="object")){let s=o.parseEditorState(i);o.setEditorState(s,t);}}return ()=>{}},name:"@lexical/extension/InitialState",nodes:[RootNode,TextNode,LineBreakNode,TabNode,ParagraphNode]}),as=Symbol.for("@lexical/extension/LexicalBuilder");ar="0.38.2+dev.esm",Xt=class o{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(e){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=ar,this.roots=e;for(let t of e)this.addExtension(t);}static fromExtensions(e){let t=[sn(vs)];for(let n of e)t.push(sn(n));return new o(t)}static maybeFromEditor(e){let t=e[as];return t&&(t.PACKAGE_VERSION!==ar&&q(`LexicalBuilder.fromEditor: The given editor was created with LexicalBuilder ${t.PACKAGE_VERSION} but this version is ${ar}. A project should have exactly one copy of LexicalBuilder`),t instanceof o||q("LexicalBuilder.fromEditor: There are multiple copies of the same version of LexicalBuilder in your project, and this editor was created with another one. Your project, or one of its dependencies, has its package.json and/or bundler configured incorrectly.")),t}static fromEditor(e){let t=o.maybeFromEditor(e);return t===void 0&&q("LexicalBuilder.fromEditor: The given editor was not created with LexicalBuilder"),t}constructEditor(){let{$initialEditorState:e,onError:t,...n}=this.buildCreateEditorArgs(),r=Object.assign(createEditor({...n,...t?{onError:i=>{t(i,r);}}:{}}),{[as]:this});for(let i of this.sortedExtensionReps())i.build(r);return r}buildEditor(){let e=cs;function t(){try{e();}finally{e=cs;}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=mergeRegister(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(e){return this.extensionNameMap.has(e)}getExtensionRep(e){let t=this.extensionNameMap.get(e.name);if(t)return t.extension!==e&&q(`LexicalBuilder: A registered extension with name ${e.name} exists but does not match the given extension`),t}addEdge(e,t,n){let r=this.outgoingConfigEdges.get(e);r?r.set(t,n):this.outgoingConfigEdges.set(e,new Map([[t,n]]));let i=this.incomingEdges.get(t);i?i.add(e):this.incomingEdges.set(t,new Set([e]));}addExtension(e){this._sortedExtensionReps!==void 0&&q("LexicalBuilder: addExtension called after finalization");let t=sn(e),[n]=t;typeof n.name!="string"&&q(`LexicalBuilder: extension name must be string, not ${typeof n.name}`);let r=this.extensionNameMap.get(n.name);if(r===void 0||r.extension===n||q(`LexicalBuilder: Multiple extensions registered with name ${n.name}, names must be unique`),!r){r=new fr(this,n),this.extensionNameMap.set(n.name,r);let i=this.conflicts.get(n.name);typeof i=="string"&&q(`LexicalBuilder: extension ${n.name} conflicts with ${i}`);for(let s of n.conflictsWith||[])this.extensionNameMap.has(s)&&q(`LexicalBuilder: extension ${n.name} conflicts with ${s}`),this.conflicts.set(s,n.name);for(let s of n.dependencies||[]){let l=sn(s);this.addEdge(n.name,l[0].name,l.slice(1)),this.addExtension(l);}for(let[s,l]of n.peerDependencies||[])this.addEdge(n.name,s,l?[l]:[]);}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;let e=[],t=(n,r)=>{let i=n.state;if(Ts(i))return;let s=n.extension.name;ur(i)||q(`LexicalBuilder: Circular dependency detected for Extension ${s} from ${r||"[unknown]"}`),i=uu(i),n.state=i;let l=this.outgoingConfigEdges.get(s);if(l)for(let a of l.keys()){let c=this.extensionNameMap.get(a);c&&t(c,s);}i=fu(i),n.state=i,e.push(n);};for(let n of this.extensionNameMap.values())ur(n.state)&&t(n);for(let n of e)for(let[r,i]of this.outgoingConfigEdges.get(n.extension.name)||[])if(i.length>0){let s=this.extensionNameMap.get(r);if(s)for(let l of i)s.configs.add(l);}for(let[n,...r]of this.roots)if(r.length>0){let i=this.extensionNameMap.get(n.name);i===void 0&&q(`LexicalBuilder: Expecting existing ExtensionRep for ${n.name}`);for(let s of r)i.configs.add(s);}return this._sortedExtensionReps=e,this._sortedExtensionReps}registerEditor(e){let t=this.sortedExtensionReps(),n=new AbortController,r=[()=>n.abort()],i=n.signal;for(let s of t){let l=s.register(e,i);l&&r.push(l);}for(let s of t){let l=s.afterRegistration(e);l&&r.push(l);}return mergeRegister(...r)}buildCreateEditorArgs(){let e={},t=new Set,n=new Map,r=new Map,i={},s={},l=this.sortedExtensionReps();for(let d of l){let{extension:u}=d;if(u.onError!==void 0&&(e.onError=u.onError),u.disableEvents!==void 0&&(e.disableEvents=u.disableEvents),u.parentEditor!==void 0&&(e.parentEditor=u.parentEditor),u.editable!==void 0&&(e.editable=u.editable),u.namespace!==void 0&&(e.namespace=u.namespace),u.$initialEditorState!==void 0&&(e.$initialEditorState=u.$initialEditorState),u.nodes)for(let h of _s(u)){if(typeof h!="function"){let p=n.get(h.replace);p&&q(`LexicalBuilder: Extension ${u.name} can not register replacement for node ${h.replace.name} because ${p.extension.name} already did`),n.set(h.replace,d);}t.add(h);}if(u.html){if(u.html.export)for(let[h,p]of u.html.export.entries())r.set(h,p);u.html.import&&Object.assign(i,u.html.import);}u.theme&&Es(s,u.theme);}Object.keys(s).length>0&&(e.theme=s),t.size&&(e.nodes=[...t]);let a=Object.keys(i).length>0,c=r.size>0;(a||c)&&(e.html={},a&&(e.html.import=i),c&&(e.html.export=r));for(let d of l)d.init(e);return e.onError||(e.onError=wu),e}};Eu=new Set,pr=defineExtension({build(o,e,t){let n=t.getDependency(an).output,r=Gt({watchedNodeKeys:new Map}),i=gr(()=>{},()=>lt(()=>{let l=i.peek(),{watchedNodeKeys:a}=r.value,c,d=false;n.value.read(()=>{if($getSelection())for(let[h,p]of a.entries()){if(p.size===0){a.delete(h);continue}let f=$getNodeByKey(h),m=f&&f.isSelected()||false;d=d||m!==(l?l.has(h):false),m&&(c=c||new Set,c.add(h));}}),!d&&c&&l&&c.size===l.size||(i.value=c);}));function s(l){let a=xs(()=>(i.value||Eu).has(l)),{watchedNodeKeys:c}=r.peek(),d=c.get(l),u=d!==void 0;return d=d||new Set,d.add(a),u||(c.set(l,d),r.value={watchedNodeKeys:c}),a}return {watchNodeKey:s}},dependencies:[an],name:"@lexical/extension/NodeSelection"}),Tu=createCommand("INSERT_HORIZONTAL_RULE_COMMAND"),wt=class o extends DecoratorNode{static getType(){return "horizontalrule"}static clone(e){return new o(e.__key)}static importJSON(e){return br().updateFromJSON(e)}static importDOM(){return {hr:()=>({conversion:vu,priority:0})}}exportDOM(){return {element:document.createElement("hr")}}createDOM(e){let t=document.createElement("hr");return addClassNamesToElement(t,e.theme.hr),t}getTextContent(){return `
|
|
2
|
+
`}isInline(){return false}updateDOM(){return false}};Mu=defineExtension({dependencies:[an,pr],name:"@lexical/extension/HorizontalRule",nodes:[wt],register(o,e,t){let{watchNodeKey:n}=t.getDependency(pr).output,r=Gt({nodeSelections:new Map}),i=o._config.theme.hrSelected??"selected";return mergeRegister(o.registerCommand(CLICK_COMMAND,s=>{if(isDOMNode(s.target)){let l=$getNodeFromDOMNode(s.target);if(Ms(l))return Ru(l,s.shiftKey),true}return false},COMMAND_PRIORITY_LOW),o.registerMutationListener(wt,(s,l)=>{ms(()=>{let a=!1,{nodeSelections:c}=r.peek();for(let[d,u]of s.entries())if(u==="destroyed")c.delete(d),a=!0;else {let h=c.get(d),p=o.getElementByKey(d);h?h.domNode.value=p:(a=!0,c.set(d,{domNode:Gt(p),selectedSignal:n(d)}));}a&&(r.value={nodeSelections:c});});}),lt(()=>{let s=[];for(let{domNode:l,selectedSignal:a}of r.value.nodeSelections.values())s.push(lt(()=>{let c=l.value;c&&(a.value?addClassNamesToElement(c,i):removeClassNamesFromElement(c,i));}));return mergeRegister(...s)}))}});ku=defineExtension({build(o,e,t){return un(e)},config:safeCast({disabled:false,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(o,e,t){let{disabled:n,maxIndent:r}=t.getOutput();return lt(()=>{if(!n.value)return Os(o,r)})}});});var il={};jt(il,{$createHorizontalRuleNode:()=>kr,$isHorizontalRuleNode:()=>nl,AutoFocusExtension:()=>gf,ClearEditorExtension:()=>bf,EditorStateExtension:()=>mn,HorizontalRuleExtension:()=>Mf,HorizontalRuleNode:()=>Tt,INSERT_HORIZONTAL_RULE_COMMAND:()=>vf,InitialStateExtension:()=>tl,LexicalBuilder:()=>Qt,NodeSelectionExtension:()=>vr,TabIndentationExtension:()=>Of,batch:()=>Us,buildEditorFromExtensions:()=>wf,computed:()=>Gs,configExtension:()=>configExtension,declarePeerDependency:()=>declarePeerDependency,defineExtension:()=>defineExtension,effect:()=>ct,getExtensionDependencyFromEditor:()=>_f,getKnownTypesAndNodes:()=>Cf,getPeerDependencyFromEditor:()=>ol,getPeerDependencyFromEditorOrThrow:()=>Ef,namedSignals:()=>Cn,registerClearEditor:()=>Vs,registerTabIndentation:()=>rl,safeCast:()=>safeCast,shallowMergeConfig:()=>shallowMergeConfig,signal:()=>Zt,untracked:()=>Nr,watchedSignal:()=>Mr});function bn(){if(at>1)return void at--;let o,e=false;for(;Mo!==void 0;){let t=Mo;for(Mo=void 0,_r++;t!==void 0;){let n=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&js(t))try{t.c();}catch(r){e||(o=r,e=true);}t=n;}}if(_r=0,at--,e)throw o}function Us(o){if(at>0)return o();at++;try{return o()}finally{bn();}}function Nr(o){let e=X;X=void 0;try{return o()}finally{X=e;}}function Ds(o){if(X===void 0)return;let e=o.n;return e===void 0||e.t!==X?(e={i:0,S:o,p:X.s,n:void 0,t:X,e:void 0,x:void 0,r:e},X.s!==void 0&&(X.s.n=e),X.s=e,o.n=e,32&X.f&&o.S(e),e):e.i===-1?(e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=X.s,e.n=void 0,X.s.n=e,X.s=e),e):void 0}function Te(o,e){this.v=o,this.i=0,this.n=void 0,this.t=void 0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name;}function Zt(o,e){return new Te(o,e)}function js(o){for(let e=o.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function Ls(o){for(let e=o.s;e!==void 0;e=e.n){let t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){o.s=e;break}}}function Ys(o){let e,t=o.s;for(;t!==void 0;){let n=t.p;t.i===-1?(t.S.U(t),n!==void 0&&(n.n=t.n),t.n!==void 0&&(t.n.p=n)):e=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=n;}o.s=e;}function Et(o,e){Te.call(this,void 0),this.x=o,this.s=void 0,this.g=hn-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name;}function Gs(o,e){return new Et(o,e)}function Xs(o){let e=o.u;if(o.u=void 0,typeof e=="function"){at++;let t=X;X=void 0;try{e();}catch(n){throw o.f&=-2,o.f|=8,Rr(o),n}finally{X=t,bn();}}}function Rr(o){for(let e=o.s;e!==void 0;e=e.n)e.S.U(e);o.x=void 0,o.s=void 0,Xs(o);}function mf(o){if(X!==this)throw new Error("Out-of-order effect");Ys(this),X=o,this.f&=-2,8&this.f&&Rr(this),bn();}function qt(o,e){this.x=o,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=e?.name;}function ct(o,e){let t=new qt(o,e);try{t.c();}catch(r){throw t.d(),r}let n=t.d.bind(t);return n[Symbol.dispose]=n,n}function Cn(o,e={}){let t={};for(let n in o){let r=e[n],i=Zt(r===void 0?o[n]:r);t[n]=i;}return t}function Js(){let o=$getRoot(),e=$getSelection(),t=$createParagraphNode();o.clear(),o.append(t),e!==null&&t.select(),$isRangeSelection(e)&&(e.format=0);}function Vs(o,e=Js){return o.registerCommand(CLEAR_EDITOR_COMMAND,t=>(o.update(e),true),COMMAND_PRIORITY_EDITOR)}function Cf(o){let e=new Set,t=new Set;for(let n of qs(o)){let r=typeof n=="function"?n:n.replace;e.add(r.getType()),t.add(r);}return {nodes:t,types:e}}function qs(o){return (typeof o.nodes=="function"?o.nodes():o.nodes)||[]}function Mr(o,e){let t;return Zt(o(),{unwatched(){t&&(t(),t=void 0);},watched(){this.value=o(),t=e(this);}})}function Q(o,...e){let t=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",o);for(let r of e)n.append("v",r);throw t.search=n.toString(),Error(`Minified Lexical error #${o}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Zs(o,e){if(o&&e&&!Array.isArray(e)&&typeof o=="object"&&typeof e=="object"){let t=o,n=e;for(let r in n)t[r]=Zs(t[r],n[r]);return o}return e}function xr(o){return o.id===Or}function el(o){return o.id===Qs}function Sf(o){return (function(e){return e.id===Er})(o)||Q(305,String(o.id),String(Er)),Object.assign(o,{id:Qs})}function yf(){let o=$getRoot();o.isEmpty()&&o.append($createParagraphNode());}function wf(...o){return Qt.fromExtensions(o).buildEditor()}function Ks(){}function Nf(o){throw o}function pn(o){return Array.isArray(o)?o:[o]}function _f(o,e){let t=Qt.fromEditor(o).getExtensionRep(e);return t===void 0&&Q(303,e.name),t.getExtensionDependency()}function ol(o,e){let t=Qt.fromEditor(o).extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}function Ef(o,e){let t=ol(o,e);return t===void 0&&Q(291,e),t}function Rf(){return {node:kr()}}function kr(){return $create(Tt)}function nl(o){return o instanceof Tt}function rl(o,e){return mergeRegister(o.registerCommand(KEY_TAB_COMMAND,t=>{let n=$getSelection();if(!$isRangeSelection(n))return false;t.preventDefault();let r=(function(i){let s=i.getNodes();if($filter(s,h=>$isBlockElementNode(h)&&h.canIndent()?h:null).length>0)return true;let l=i.anchor,a=i.focus,c=a.isBefore(l)?a:l,d=c.getNode(),u=$getNearestBlockElementAncestorOrThrow(d);if(u.canIndent()){let h=u.getKey(),p=$createRangeSelection();if(p.anchor.set(h,0,"element"),p.focus.set(h,0,"element"),p=$normalizeSelection__EXPERIMENTAL(p),p.anchor.is(c))return true}return false})(n)?t.shiftKey?OUTDENT_CONTENT_COMMAND:INDENT_CONTENT_COMMAND:INSERT_TAB_COMMAND;return o.dispatchCommand(r,void 0)},COMMAND_PRIORITY_EDITOR),o.registerCommand(INDENT_CONTENT_COMMAND,()=>{let t=typeof e=="number"?e:e?e.peek():null;if(t==null)return false;let n=$getSelection();if(!$isRangeSelection(n))return false;let r=n.getNodes().map(i=>$getNearestBlockElementAncestorOrThrow(i).getIndent());return Math.max(...r)+1>=t},COMMAND_PRIORITY_CRITICAL))}var hf,X,Mo,at,_r,hn,gf,bf,mn,Or,Er,Qs,Cr,fn,Vt,Sr,Ro,xf,Tr,Ps,tl,Is,yr,Qt,Tf,vr,vf,Tt,Mf,Of,sl=rt(()=>{hf=Symbol.for("preact-signals");at=0,_r=0,hn=0;Te.prototype.brand=hf,Te.prototype.h=function(){return true},Te.prototype.S=function(o){let e=this.t;e!==o&&o.e===void 0&&(o.x=e,this.t=o,e!==void 0?e.e=o:Nr(()=>{var t;(t=this.W)==null||t.call(this);}));},Te.prototype.U=function(o){if(this.t!==void 0){let e=o.e,t=o.x;e!==void 0&&(e.x=t,o.e=void 0),t!==void 0&&(t.e=e,o.x=void 0),o===this.t&&(this.t=t,t===void 0&&Nr(()=>{var n;(n=this.Z)==null||n.call(this);}));}},Te.prototype.subscribe=function(o){return ct(()=>{let e=this.value,t=X;X=void 0;try{o(e);}finally{X=t;}},{name:"sub"})},Te.prototype.valueOf=function(){return this.value},Te.prototype.toString=function(){return this.value+""},Te.prototype.toJSON=function(){return this.value},Te.prototype.peek=function(){let o=X;X=void 0;try{return this.value}finally{X=o;}},Object.defineProperty(Te.prototype,"value",{get(){let o=Ds(this);return o!==void 0&&(o.i=this.i),this.v},set(o){if(o!==this.v){if(_r>100)throw new Error("Cycle detected");this.v=o,this.i++,hn++,at++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N();}finally{bn();}}}}),Et.prototype=new Te,Et.prototype.h=function(){if(this.f&=-3,1&this.f)return false;if((36&this.f)==32||(this.f&=-5,this.g===hn))return true;if(this.g=hn,this.f|=1,this.i>0&&!js(this))return this.f&=-2,true;let o=X;try{Ls(this),X=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++);}catch(e){this.v=e,this.f|=16,this.i++;}return X=o,Ys(this),this.f&=-2,true},Et.prototype.S=function(o){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e);}Te.prototype.S.call(this,o);},Et.prototype.U=function(o){if(this.t!==void 0&&(Te.prototype.U.call(this,o),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e);}},Et.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let o=this.t;o!==void 0;o=o.x)o.t.N();}},Object.defineProperty(Et.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");let o=Ds(this);if(this.h(),o!==void 0&&(o.i=this.i),16&this.f)throw this.v;return this.v}}),qt.prototype.c=function(){let o=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e=="function"&&(this.u=e);}finally{o();}},qt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Xs(this),Ls(this),at++;let o=X;return X=this,mf.bind(this,o)},qt.prototype.N=function(){2&this.f||(this.f|=2,this.o=Mo,Mo=this);},qt.prototype.d=function(){this.f|=8,1&this.f||Rr(this);},qt.prototype.dispose=function(){this.d();};gf=defineExtension({build:(o,e,t)=>Cn(e),config:safeCast({defaultSelection:"rootEnd",disabled:false}),name:"@lexical/extension/AutoFocus",register(o,e,t){let n=t.getOutput();return ct(()=>n.disabled.value?void 0:o.registerRootListener(r=>{o.focus(()=>{let i=document.activeElement;r===null||i!==null&&r.contains(i)||r.focus({preventScroll:true});},{defaultSelection:n.defaultSelection.peek()});}))}});bf=defineExtension({build:(o,e,t)=>Cn(e),config:safeCast({$onClear:Js}),name:"@lexical/extension/ClearEditor",register(o,e,t){let{$onClear:n}=t.getOutput();return ct(()=>Vs(o,n.value))}});mn=defineExtension({build:o=>Mr(()=>o.getEditorState(),e=>o.registerUpdateListener(t=>{e.value=t.editorState;})),name:"@lexical/extension/EditorState"});Or=0,Er=1,Qs=2,Cr=3,fn=4,Vt=5,Sr=6,Ro=7;xf=new Set,Tr=class{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(e,t){this.builder=e,this.extension=t,this.configs=new Set,this.state={id:Or};}mergeConfigs(){let e=this.extension.config||{},t=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):shallowMergeConfig;for(let n of this.configs)e=t(e,n);return e}init(e){let t=this.state;el(t)||Q(306,String(t.id));let n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},r={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},i=(function(l,a,c){return Object.assign(l,{config:a,id:Cr,registerState:c})})(t,this.mergeConfigs(),n),s;this.state=i,this.extension.init&&(s=this.extension.init(e,i.config,n)),this.state=(function(l,a,c){return Object.assign(l,{id:fn,initResult:a,registerState:c})})(i,s,r);}build(e){let t=this.state,n;t.id!==fn&&Q(307,String(t.id),String(Vt)),this.extension.build&&(n=this.extension.build(e,t.config,t.registerState));let r={...t.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=(function(i,s,l){return Object.assign(i,{id:Vt,output:s,registerState:l})})(t,n,r);}register(e,t){this._signal=t;let n=this.state;n.id!==Vt&&Q(308,String(n.id),String(Vt));let r=this.extension.register&&this.extension.register(e,n.config,n.registerState);return this.state=(function(i){return Object.assign(i,{id:Sr})})(n),()=>{let i=this.state;i.id!==Ro&&Q(309,String(n.id),String(Ro)),this.state=(function(s){return Object.assign(s,{id:Vt})})(i),r&&r();}}afterRegistration(e){let t=this.state,n;return t.id!==Sr&&Q(310,String(t.id),String(Sr)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(e,t.config,t.registerState)),this.state=(function(r){return Object.assign(r,{id:Ro})})(t),n}getSignal(){return this._signal===void 0&&Q(311),this._signal}getInitResult(){this.extension.init===void 0&&Q(312,this.extension.name);let e=this.state;return (function(t){return t.id>=fn})(e)||Q(313,String(e.id),String(fn)),e.initResult}getInitPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionInitDependency():void 0}getExtensionInitDependency(){let e=this.state;return (function(t){return t.id>=Cr})(e)||Q(314,String(e.id),String(Cr)),{config:e.config}}getPeer(e){let t=this.builder.extensionNameMap.get(e);return t?t.getExtensionDependency():void 0}getInitDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Q(315,this.extension.name,e.name),t.getExtensionInitDependency()}getDependency(e){let t=this.builder.getExtensionRep(e);return t===void 0&&Q(315,this.extension.name,e.name),t.getExtensionDependency()}getState(){let e=this.state;return (function(t){return t.id>=Ro})(e)||Q(316,String(e.id),String(Ro)),e}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||xf}getPeerNameSet(){let e=this._peerNameSet;return e||(e=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=e),e}getExtensionDependency(){if(!this._dependency){let e=this.state;((function(t){return t.id>=Vt}))(e)||Q(317,this.extension.name),this._dependency={config:e.config,init:e.initResult,output:e.output};}return this._dependency}},Ps={tag:HISTORY_MERGE_TAG};tl=defineExtension({config:safeCast({setOptions:Ps,updateOptions:Ps}),init:({$initialEditorState:o=yf})=>({$initialEditorState:o,initialized:false}),afterRegistration(o,{updateOptions:e,setOptions:t},n){let r=n.getInitResult();if(!r.initialized){r.initialized=true;let{$initialEditorState:i}=r;if($isEditorState(i))o.setEditorState(i,t);else if(typeof i=="function")o.update(()=>{i(o);},e);else if(i&&(typeof i=="string"||typeof i=="object")){let s=o.parseEditorState(i);o.setEditorState(s,t);}}return ()=>{}},name:"@lexical/extension/InitialState",nodes:[RootNode,TextNode,LineBreakNode,TabNode,ParagraphNode]}),Is=Symbol.for("@lexical/extension/LexicalBuilder");yr="0.38.2+prod.esm",Qt=class o{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(e){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=yr,this.roots=e;for(let t of e)this.addExtension(t);}static fromExtensions(e){let t=[pn(tl)];for(let n of e)t.push(pn(n));return new o(t)}static maybeFromEditor(e){let t=e[Is];return t&&(t.PACKAGE_VERSION!==yr&&Q(292,t.PACKAGE_VERSION,yr),t instanceof o||Q(293)),t}static fromEditor(e){let t=o.maybeFromEditor(e);return t===void 0&&Q(294),t}constructEditor(){let{$initialEditorState:e,onError:t,...n}=this.buildCreateEditorArgs(),r=Object.assign(createEditor({...n,...t?{onError:i=>{t(i,r);}}:{}}),{[Is]:this});for(let i of this.sortedExtensionReps())i.build(r);return r}buildEditor(){let e=Ks;function t(){try{e();}finally{e=Ks;}}let n=Object.assign(this.constructEditor(),{dispose:t,[Symbol.dispose]:t});return e=mergeRegister(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(e){return this.extensionNameMap.has(e)}getExtensionRep(e){let t=this.extensionNameMap.get(e.name);if(t)return t.extension!==e&&Q(295,e.name),t}addEdge(e,t,n){let r=this.outgoingConfigEdges.get(e);r?r.set(t,n):this.outgoingConfigEdges.set(e,new Map([[t,n]]));let i=this.incomingEdges.get(t);i?i.add(e):this.incomingEdges.set(t,new Set([e]));}addExtension(e){this._sortedExtensionReps!==void 0&&Q(296);let t=pn(e),[n]=t;typeof n.name!="string"&&Q(297,typeof n.name);let r=this.extensionNameMap.get(n.name);if(r!==void 0&&r.extension!==n&&Q(298,n.name),!r){r=new Tr(this,n),this.extensionNameMap.set(n.name,r);let i=this.conflicts.get(n.name);typeof i=="string"&&Q(299,n.name,i);for(let s of n.conflictsWith||[])this.extensionNameMap.has(s)&&Q(299,n.name,s),this.conflicts.set(s,n.name);for(let s of n.dependencies||[]){let l=pn(s);this.addEdge(n.name,l[0].name,l.slice(1)),this.addExtension(l);}for(let[s,l]of n.peerDependencies||[])this.addEdge(n.name,s,l?[l]:[]);}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;let e=[],t=(n,r)=>{let i=n.state;if(el(i))return;let s=n.extension.name;var l;xr(i)||Q(300,s,r||"[unknown]"),xr(l=i)||Q(304,String(l.id),String(Or)),i=Object.assign(l,{id:Er}),n.state=i;let a=this.outgoingConfigEdges.get(s);if(a)for(let c of a.keys()){let d=this.extensionNameMap.get(c);d&&t(d,s);}i=Sf(i),n.state=i,e.push(n);};for(let n of this.extensionNameMap.values())xr(n.state)&&t(n);for(let n of e)for(let[r,i]of this.outgoingConfigEdges.get(n.extension.name)||[])if(i.length>0){let s=this.extensionNameMap.get(r);if(s)for(let l of i)s.configs.add(l);}for(let[n,...r]of this.roots)if(r.length>0){let i=this.extensionNameMap.get(n.name);i===void 0&&Q(301,n.name);for(let s of r)i.configs.add(s);}return this._sortedExtensionReps=e,this._sortedExtensionReps}registerEditor(e){let t=this.sortedExtensionReps(),n=new AbortController,r=[()=>n.abort()],i=n.signal;for(let s of t){let l=s.register(e,i);l&&r.push(l);}for(let s of t){let l=s.afterRegistration(e);l&&r.push(l);}return mergeRegister(...r)}buildCreateEditorArgs(){let e={},t=new Set,n=new Map,r=new Map,i={},s={},l=this.sortedExtensionReps();for(let d of l){let{extension:u}=d;if(u.onError!==void 0&&(e.onError=u.onError),u.disableEvents!==void 0&&(e.disableEvents=u.disableEvents),u.parentEditor!==void 0&&(e.parentEditor=u.parentEditor),u.editable!==void 0&&(e.editable=u.editable),u.namespace!==void 0&&(e.namespace=u.namespace),u.$initialEditorState!==void 0&&(e.$initialEditorState=u.$initialEditorState),u.nodes)for(let h of qs(u)){if(typeof h!="function"){let p=n.get(h.replace);p&&Q(302,u.name,h.replace.name,p.extension.name),n.set(h.replace,d);}t.add(h);}if(u.html){if(u.html.export)for(let[h,p]of u.html.export.entries())r.set(h,p);u.html.import&&Object.assign(i,u.html.import);}u.theme&&Zs(s,u.theme);}Object.keys(s).length>0&&(e.theme=s),t.size&&(e.nodes=[...t]);let a=Object.keys(i).length>0,c=r.size>0;(a||c)&&(e.html={},a&&(e.html.import=i),c&&(e.html.export=r));for(let d of l)d.init(e);return e.onError||(e.onError=Nf),e}};Tf=new Set,vr=defineExtension({build(o,e,t){let n=t.getDependency(mn).output,r=Zt({watchedNodeKeys:new Map}),i=Mr(()=>{},()=>ct(()=>{let s=i.peek(),{watchedNodeKeys:l}=r.value,a,c=false;n.value.read(()=>{if($getSelection())for(let[d,u]of l.entries()){if(u.size===0){l.delete(d);continue}let h=$getNodeByKey(d),p=h&&h.isSelected()||false;c=c||p!==(!!s&&s.has(d)),p&&(a=a||new Set,a.add(d));}}),!c&&a&&s&&a.size===s.size||(i.value=a);}));return {watchNodeKey:function(s){let l=Gs(()=>(i.value||Tf).has(s)),{watchedNodeKeys:a}=r.peek(),c=a.get(s),d=c!==void 0;return c=c||new Set,c.add(l),d||(a.set(s,c),r.value={watchedNodeKeys:a}),l}}},dependencies:[mn],name:"@lexical/extension/NodeSelection"}),vf=createCommand("INSERT_HORIZONTAL_RULE_COMMAND"),Tt=class o extends DecoratorNode{static getType(){return "horizontalrule"}static clone(e){return new o(e.__key)}static importJSON(e){return kr().updateFromJSON(e)}static importDOM(){return {hr:()=>({conversion:Rf,priority:0})}}exportDOM(){return {element:document.createElement("hr")}}createDOM(e){let t=document.createElement("hr");return addClassNamesToElement(t,e.theme.hr),t}getTextContent(){return `
|
|
3
|
+
`}isInline(){return false}updateDOM(){return false}};Mf=defineExtension({dependencies:[mn,vr],name:"@lexical/extension/HorizontalRule",nodes:[Tt],register(o,e,t){let{watchNodeKey:n}=t.getDependency(vr).output,r=Zt({nodeSelections:new Map}),i=o._config.theme.hrSelected??"selected";return mergeRegister(o.registerCommand(CLICK_COMMAND,s=>{if(isDOMNode(s.target)){let l=$getNodeFromDOMNode(s.target);if(nl(l))return (function(a,c=false){let d=$getSelection(),u=a.isSelected(),h=a.getKey(),p;c&&$isNodeSelection(d)?p=d:(p=$createNodeSelection(),$setSelection(p)),u?p.delete(h):p.add(h);})(l,s.shiftKey),true}return false},COMMAND_PRIORITY_LOW),o.registerMutationListener(Tt,(s,l)=>{Us(()=>{let a=!1,{nodeSelections:c}=r.peek();for(let[d,u]of s.entries())if(u==="destroyed")c.delete(d),a=!0;else {let h=c.get(d),p=o.getElementByKey(d);h?h.domNode.value=p:(a=!0,c.set(d,{domNode:Zt(p),selectedSignal:n(d)}));}a&&(r.value={nodeSelections:c});});}),ct(()=>{let s=[];for(let{domNode:l,selectedSignal:a}of r.value.nodeSelections.values())s.push(ct(()=>{let c=l.value;c&&(a.value?addClassNamesToElement(c,i):removeClassNamesFromElement(c,i));}));return mergeRegister(...s)}))}});Of=defineExtension({build:(o,e,t)=>Cn(e),config:safeCast({disabled:false,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(o,e,t){let{disabled:n,maxIndent:r}=t.getOutput();return ct(()=>{if(!n.value)return rl(o,r)})}});});var H,Ke,Sn,Ar=rt(async()=>{H=await(process.env.NODE_ENV!=="production"?Promise.resolve().then(()=>(As(),ks)):Promise.resolve().then(()=>(sl(),il))),H.$createHorizontalRuleNode,H.$isHorizontalRuleNode,H.AutoFocusExtension,H.ClearEditorExtension,H.EditorStateExtension,H.HorizontalRuleExtension,H.HorizontalRuleNode,H.INSERT_HORIZONTAL_RULE_COMMAND,H.InitialStateExtension,H.LexicalBuilder,H.NodeSelectionExtension,H.TabIndentationExtension,H.batch,H.buildEditorFromExtensions,H.computed,H.configExtension,H.declarePeerDependency,H.defineExtension,Ke=H.effect,H.getExtensionDependencyFromEditor,H.getKnownTypesAndNodes,H.getPeerDependencyFromEditor,H.getPeerDependencyFromEditorOrThrow,Sn=H.namedSignals,H.registerClearEditor,H.registerTabIndentation,H.safeCast,H.shallowMergeConfig,H.signal,H.untracked,H.watchedSignal;});var Cl={};jt(Cl,{$generateJSONFromSelectedNodes:()=>pl,$generateNodesFromSerializedNodes:()=>hl,$getClipboardDataFromSelection:()=>gl,$getHtmlContent:()=>dl,$getLexicalContent:()=>ul,$insertDataTransferForPlainText:()=>Zf,$insertDataTransferForRichText:()=>Qf,$insertGeneratedNodes:()=>$r,copyToClipboard:()=>rp,setLexicalClipboardDataTransfer:()=>bl});function xn(o){throw new Error(o)}function dl(o,e=$getSelection()){return e==null&&xn("Expected valid LexicalSelection"),$isRangeSelection(e)&&e.isCollapsed()||e.getNodes().length===0?"":$generateHtmlFromNodes(o,e)}function ul(o,e=$getSelection()){return e==null&&xn("Expected valid LexicalSelection"),$isRangeSelection(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(pl(o,e))}function Zf(o,e){let t=o.getData("text/plain")||o.getData("text/uri-list");t!=null&&e.insertRawText(t);}function Qf(o,e,t){let n=o.getData("application/x-lexical-editor");if(n)try{let l=JSON.parse(n);if(l.namespace===t._config.namespace&&Array.isArray(l.nodes)){let a=hl(l.nodes);return $r(t,a,e)}}catch(l){console.error(l);}let r=o.getData("text/html"),i=o.getData("text/plain");if(r&&i!==r)try{let a=new DOMParser().parseFromString(ep(r),"text/html"),c=$generateNodesFromDOM(t,a);return $r(t,c,e)}catch(l){console.error(l);}let s=i||o.getData("text/uri-list");if(s!=null)if($isRangeSelection(e)){let l=s.split(/(\r?\n|\t)/);l[l.length-1]===""&&l.pop();for(let a=0;a<l.length;a++){let c=$getSelection();if($isRangeSelection(c)){let d=l[a];d===`
|
|
4
4
|
`||d===`\r
|
|
5
|
-
`?c.insertParagraph():d===" "?c.insertNodes([$createTabNode()]):c.insertText(d);}}}else e.insertRawText(s);}function ep(o){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(o):o}function $r(o,e,t){o.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:t})||(t.insertNodes(e),tp(t));}function tp(o){if($isRangeSelection(o)&&o.isCollapsed()){let e=o.anchor,t=null,n=$caretFromPoint(e,"previous");if(n)if($isTextPointCaret(n))t=n.origin;else {let r=$getCaretRange(n,$getChildCaret($getRoot(),"next").getFlipped());for(let i of r)if($isTextNode(i.origin)){t=i.origin;break}else if($isElementNode(i.origin)&&!i.origin.isInline())break}if(t&&$isTextNode(t)){let r=t.getFormat(),i=t.getStyle();(o.format!==r||o.style!==i)&&(o.format=r,o.style=i,o.dirty=true);}}}function op(o){let e=o.exportJSON(),t=o.constructor;if(e.type!==t.getType()&&xn(`LexicalNode: Node ${t.name} does not implement .exportJSON().`),$isElementNode(o)){let n=e.children;Array.isArray(n)||xn(`LexicalNode: Node ${t.name} is an element but .exportJSON() does not have a children array.`);}return e}function fl(o,e,t,n=[]){let r=e!==null?t.isSelected(e):true,i=$isElementNode(t)&&t.excludeFromCopy("html"),s=t;e!==null&&$isTextNode(s)&&(s=$sliceSelectedTextNodeContent(e,s,"clone"));let l=$isElementNode(s)?s.getChildren():[],a=op(s);$isTextNode(s)&&s.getTextContentSize()===0&&(r=false);for(let c=0;c<l.length;c++){let d=l[c],u=fl(o,e,d,a.children);!r&&$isElementNode(t)&&u&&t.extractWithChild(d,e,"clone")&&(r=true);}if(r&&!i)n.push(a);else if(Array.isArray(a.children))for(let c=0;c<a.children.length;c++){let d=a.children[c];n.push(d);}return r}function pl(o,e){let t=[],r=$getRoot().getChildren();for(let i=0;i<r.length;i++){let s=r[i];fl(o,e,s,t);}return {namespace:o._config.namespace,nodes:t}}function hl(o){let e=[];for(let t=0;t<o.length;t++){let n=o[t],r=$parseSerializedNode(n);$isTextNode(r)&&$addNodeStyle(r),e.push(r);}return e}async function rp(o,e,t){if(eo!==null)return false;if(e!==null)return new Promise((c,d)=>{o.update(()=>{c(ll(o,e,t));});});let n=o.getRootElement(),r=o._window||window,i=r.document,s=getDOMSelection(r);if(n===null||s===null)return false;let l=i.createElement("span");l.style.cssText="position: fixed; top: -1000px;",l.append(i.createTextNode("#")),n.append(l);let a=new Range;return a.setStart(l,0),a.setEnd(l,1),s.removeAllRanges(),s.addRange(a),new Promise((c,d)=>{let u=o.registerCommand(COPY_COMMAND,h=>(objectKlassEquals(h,ClipboardEvent)&&(u(),eo!==null&&(r.clearTimeout(eo),eo=null),c(ll(o,h,t))),true),COMMAND_PRIORITY_CRITICAL);eo=r.setTimeout(()=>{u(),eo=null,c(false);},np),i.execCommand("copy"),l.remove();})}function ll(o,e,t){if(t===void 0){let r=getDOMSelection(o._window),i=$getSelection();if(!i||i.isCollapsed()||!r)return false;let s=r.anchorNode,l=r.focusNode;if(s!==null&&l!==null&&!isSelectionWithinEditor(o,s,l))return false;t=gl(i);}e.preventDefault();let n=e.clipboardData;return n===null?false:(bl(n,t),true)}function gl(o=$getSelection()){let e={"text/plain":o?o.getTextContent():""};if(o){let t=$getEditor();for(let[n,r]of ml){let i=r(t,o);i!==null&&(e[n]=i);}}return e}function bl(o,e){for(let[t]of ml)e[t]===void 0&&o.setData(t,"");for(let t in e){let n=e[t];n!==void 0&&o.setData(t,n);}}var np,eo,ml,Sl=rt(()=>{np=50,eo=null;ml=[["text/html",dl],["application/x-lexical-editor",ul]];});var kl={};jt(kl,{$generateJSONFromSelectedNodes:()=>Tl,$generateNodesFromSerializedNodes:()=>vl,$getClipboardDataFromSelection:()=>
|
|
5
|
+
`?c.insertParagraph():d===" "?c.insertNodes([$createTabNode()]):c.insertText(d);}}}else e.insertRawText(s);}function ep(o){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(o):o}function $r(o,e,t){o.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:t})||(t.insertNodes(e),tp(t));}function tp(o){if($isRangeSelection(o)&&o.isCollapsed()){let e=o.anchor,t=null,n=$caretFromPoint(e,"previous");if(n)if($isTextPointCaret(n))t=n.origin;else {let r=$getCaretRange(n,$getChildCaret($getRoot(),"next").getFlipped());for(let i of r)if($isTextNode(i.origin)){t=i.origin;break}else if($isElementNode(i.origin)&&!i.origin.isInline())break}if(t&&$isTextNode(t)){let r=t.getFormat(),i=t.getStyle();(o.format!==r||o.style!==i)&&(o.format=r,o.style=i,o.dirty=true);}}}function op(o){let e=o.exportJSON(),t=o.constructor;if(e.type!==t.getType()&&xn(`LexicalNode: Node ${t.name} does not implement .exportJSON().`),$isElementNode(o)){let n=e.children;Array.isArray(n)||xn(`LexicalNode: Node ${t.name} is an element but .exportJSON() does not have a children array.`);}return e}function fl(o,e,t,n=[]){let r=e!==null?t.isSelected(e):true,i=$isElementNode(t)&&t.excludeFromCopy("html"),s=t;e!==null&&$isTextNode(s)&&(s=$sliceSelectedTextNodeContent(e,s,"clone"));let l=$isElementNode(s)?s.getChildren():[],a=op(s);$isTextNode(s)&&s.getTextContentSize()===0&&(r=false);for(let c=0;c<l.length;c++){let d=l[c],u=fl(o,e,d,a.children);!r&&$isElementNode(t)&&u&&t.extractWithChild(d,e,"clone")&&(r=true);}if(r&&!i)n.push(a);else if(Array.isArray(a.children))for(let c=0;c<a.children.length;c++){let d=a.children[c];n.push(d);}return r}function pl(o,e){let t=[],r=$getRoot().getChildren();for(let i=0;i<r.length;i++){let s=r[i];fl(o,e,s,t);}return {namespace:o._config.namespace,nodes:t}}function hl(o){let e=[];for(let t=0;t<o.length;t++){let n=o[t],r=$parseSerializedNode(n);$isTextNode(r)&&$addNodeStyle(r),e.push(r);}return e}async function rp(o,e,t){if(eo!==null)return false;if(e!==null)return new Promise((c,d)=>{o.update(()=>{c(ll(o,e,t));});});let n=o.getRootElement(),r=o._window||window,i=r.document,s=getDOMSelection(r);if(n===null||s===null)return false;let l=i.createElement("span");l.style.cssText="position: fixed; top: -1000px;",l.append(i.createTextNode("#")),n.append(l);let a=new Range;return a.setStart(l,0),a.setEnd(l,1),s.removeAllRanges(),s.addRange(a),new Promise((c,d)=>{let u=o.registerCommand(COPY_COMMAND,h=>(objectKlassEquals(h,ClipboardEvent)&&(u(),eo!==null&&(r.clearTimeout(eo),eo=null),c(ll(o,h,t))),true),COMMAND_PRIORITY_CRITICAL);eo=r.setTimeout(()=>{u(),eo=null,c(false);},np),i.execCommand("copy"),l.remove();})}function ll(o,e,t){if(t===void 0){let r=getDOMSelection(o._window),i=$getSelection();if(!i||i.isCollapsed()||!r)return false;let s=r.anchorNode,l=r.focusNode;if(s!==null&&l!==null&&!isSelectionWithinEditor(o,s,l))return false;t=gl(i);}e.preventDefault();let n=e.clipboardData;return n===null?false:(bl(n,t),true)}function gl(o=$getSelection()){let e={"text/plain":o?o.getTextContent():""};if(o){let t=$getEditor();for(let[n,r]of ml){let i=r(t,o);i!==null&&(e[n]=i);}}return e}function bl(o,e){for(let[t]of ml)e[t]===void 0&&o.setData(t,"");for(let t in e){let n=e[t];n!==void 0&&o.setData(t,n);}}var np,eo,ml,Sl=rt(()=>{np=50,eo=null;ml=[["text/html",dl],["application/x-lexical-editor",ul]];});var kl={};jt(kl,{$generateJSONFromSelectedNodes:()=>Tl,$generateNodesFromSerializedNodes:()=>vl,$getClipboardDataFromSelection:()=>Ml,$getHtmlContent:()=>Nl,$getLexicalContent:()=>_l,$insertDataTransferForPlainText:()=>yp,$insertDataTransferForRichText:()=>wp,$insertGeneratedNodes:()=>Fr,copyToClipboard:()=>Np,setLexicalClipboardDataTransfer:()=>Ol});function yn(o,...e){let t=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",o);for(let r of e)n.append("v",r);throw t.search=n.toString(),Error(`Minified Lexical error #${o}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Nl(o,e=$getSelection()){return e==null&&yn(166),$isRangeSelection(e)&&e.isCollapsed()||e.getNodes().length===0?"":$generateHtmlFromNodes(o,e)}function _l(o,e=$getSelection()){return e==null&&yn(166),$isRangeSelection(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(Tl(o,e))}function yp(o,e){let t=o.getData("text/plain")||o.getData("text/uri-list");t!=null&&e.insertRawText(t);}function wp(o,e,t){let n=o.getData("application/x-lexical-editor");if(n)try{let l=JSON.parse(n);if(l.namespace===t._config.namespace&&Array.isArray(l.nodes))return Fr(t,vl(l.nodes),e)}catch(l){console.error(l);}let r=o.getData("text/html"),i=o.getData("text/plain");if(r&&i!==r)try{let l=new DOMParser().parseFromString((function(a){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:c=>c}).createHTML(a):a})(r),"text/html");return Fr(t,$generateNodesFromDOM(t,l),e)}catch(l){console.error(l);}let s=i||o.getData("text/uri-list");if(s!=null)if($isRangeSelection(e)){let l=s.split(/(\r?\n|\t)/);l[l.length-1]===""&&l.pop();for(let a=0;a<l.length;a++){let c=$getSelection();if($isRangeSelection(c)){let d=l[a];d===`
|
|
6
6
|
`||d===`\r
|
|
7
|
-
`?c.insertParagraph():d===" "?c.insertNodes([$createTabNode()]):c.insertText(d);}}}else e.insertRawText(s);}function Fr(o,e,t){o.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:t})||(t.insertNodes(e),(function(n){if($isRangeSelection(n)&&n.isCollapsed()){let r=n.anchor,i=null,s=$caretFromPoint(r,"previous");if(s)if($isTextPointCaret(s))i=s.origin;else {let l=$getCaretRange(s,$getChildCaret($getRoot(),"next").getFlipped());for(let a of l){if($isTextNode(a.origin)){i=a.origin;break}if($isElementNode(a.origin)&&!a.origin.isInline())break}}if(i&&$isTextNode(i)){let l=i.getFormat(),a=i.getStyle();n.format===l&&n.style===a||(n.format=l,n.style=a,n.dirty=true);}}})(t));}function El(o,e,t,n=[]){let r=e===null||t.isSelected(e),i=$isElementNode(t)&&t.excludeFromCopy("html"),s=t;e!==null&&$isTextNode(s)&&(s=$sliceSelectedTextNodeContent(e,s,"clone"));let l=$isElementNode(s)?s.getChildren():[],a=(function(c){let d=c.exportJSON(),u=c.constructor;if(d.type!==u.getType()&&yn(58,u.name),$isElementNode(c)){let h=d.children;Array.isArray(h)||yn(59,u.name);}return d})(s);$isTextNode(s)&&s.getTextContentSize()===0&&(r=false);for(let c=0;c<l.length;c++){let d=l[c],u=El(o,e,d,a.children);!r&&$isElementNode(t)&&u&&t.extractWithChild(d,e,"clone")&&(r=true);}if(r&&!i)n.push(a);else if(Array.isArray(a.children))for(let c=0;c<a.children.length;c++){let d=a.children[c];n.push(d);}return r}function Tl(o,e){let t=[],n=$getRoot().getChildren();for(let r=0;r<n.length;r++)El(o,e,n[r],t);return {namespace:o._config.namespace,nodes:t}}function vl(o){let e=[];for(let t=0;t<o.length;t++){let n=o[t],r=$parseSerializedNode(n);$isTextNode(r)&&$addNodeStyle(r),e.push(r);}return e}async function Np(o,e,t){if(to!==null)return false;if(e!==null)return new Promise((c,d)=>{o.update(()=>{c(xl(o,e,t));});});let n=o.getRootElement(),r=o._window||window,i=r.document,s=getDOMSelection(r);if(n===null||s===null)return false;let l=i.createElement("span");l.style.cssText="position: fixed; top: -1000px;",l.append(i.createTextNode("#")),n.append(l);let a=new Range;return a.setStart(l,0),a.setEnd(l,1),s.removeAllRanges(),s.addRange(a),new Promise((c,d)=>{let u=o.registerCommand(COPY_COMMAND,h=>(objectKlassEquals(h,ClipboardEvent)&&(u(),to!==null&&(r.clearTimeout(to),to=null),c(xl(o,h,t))),true),COMMAND_PRIORITY_CRITICAL);to=r.setTimeout(()=>{u(),to=null,c(false);},50),i.execCommand("copy"),l.remove();})}function xl(o,e,t){if(t===void 0){let r=getDOMSelection(o._window),i=$getSelection();if(!i||i.isCollapsed()||!r)return false;let s=r.anchorNode,l=r.focusNode;if(s!==null&&l!==null&&!isSelectionWithinEditor(o,s,l))return false;t=Ol(i);}e.preventDefault();let n=e.clipboardData;return n!==null&&(Ml(n,t),true)}function Ol(o=$getSelection()){let e={"text/plain":o?o.getTextContent():""};if(o){let t=$getEditor();for(let[n,r]of Rl){let i=r(t,o);i!==null&&(e[n]=i);}}return e}function Ml(o,e){for(let[t]of Rl)e[t]===void 0&&o.setData(t,"");for(let t in e){let n=e[t];n!==void 0&&o.setData(t,n);}}var to,Rl,Al=rt(()=>{to=null;Rl=[["text/html",Nl],["application/x-lexical-editor",_l]];});var ze,wn,Nn,Dr=rt(async()=>{ze=await(process.env.NODE_ENV!=="production"?Promise.resolve().then(()=>(Sl(),Cl)):Promise.resolve().then(()=>(Al(),kl))),ze.$generateJSONFromSelectedNodes,ze.$generateNodesFromSerializedNodes,wn=ze.$getClipboardDataFromSelection,ze.$getHtmlContent,ze.$getLexicalContent,ze.$insertDataTransferForPlainText,ze.$insertDataTransferForRichText,ze.$insertGeneratedNodes,Nn=ze.copyToClipboard,ze.setLexicalClipboardDataTransfer;});var Sa={};jt(Sa,{$computeTableMap:()=>Se,$computeTableMapSkipCellCheck:()=>Ze,$createTableCellNode:()=>Me,$createTableNode:()=>Fn,$createTableNodeWithDimensions:()=>ta,$createTableRowNode:()=>kt,$createTableSelection:()=>ti,$createTableSelectionFrom:()=>ca,$deleteTableColumn:()=>bh,$deleteTableColumnAtSelection:()=>sa,$deleteTableColumn__EXPERIMENTAL:()=>Sh,$deleteTableRowAtSelection:()=>ia,$deleteTableRow__EXPERIMENTAL:()=>Ch,$findCellNode:()=>ro,$findTableNode:()=>Qe,$getElementForTableNode:()=>ma,$getNodeTriplet:()=>ge,$getTableAndElementByKey:()=>oi,$getTableCellNodeFromLexicalNode:()=>ch,$getTableCellNodeRect:()=>Wr,$getTableColumnIndexFromTableCellNode:()=>uh,$getTableNodeFromLexicalNodeOrThrow:()=>An,$getTableRowIndexFromTableCellNode:()=>dh,$getTableRowNodeFromTableCellNodeOrThrow:()=>Qr,$insertTableColumn:()=>mh,$insertTableColumnAtSelection:()=>ra,$insertTableColumn__EXPERIMENTAL:()=>gh,$insertTableRow:()=>ph,$insertTableRowAtSelection:()=>na,$insertTableRow__EXPERIMENTAL:()=>hh,$isScrollableTablesActive:()=>Uo,$isTableCellNode:()=>$,$isTableNode:()=>ae,$isTableRowNode:()=>Q,$isTableSelection:()=>H,$mergeCells:()=>la,$removeTableRowAtIndex:()=>fh,$unmergeCell:()=>yh,INSERT_TABLE_COMMAND:()=>ea,TableCellHeaderStates:()=>te,TableCellNode:()=>We,TableExtension:()=>Qh,TableNode:()=>Ue,TableObserver:()=>Mn,TableRowNode:()=>Mt,applyTableHandlers:()=>da,getDOMCellFromTarget:()=>Wo,getTableElement:()=>ft,getTableObserverFromTableElement:()=>ii,registerTableCellUnmergeTransform:()=>ga,registerTablePlugin:()=>Ca,registerTableSelectionObserver:()=>ba,setScrollableTablesActive:()=>ha});function Kr(o){return o==="middle"||o==="bottom"}function Dl(o){let e=o,t=o.nodeName.toLowerCase(),n;qr.test(e.style.width)&&(n=parseFloat(e.style.width));let r=Me(t==="th"?te.ROW:te.NO_STATUS,e.colSpan,n);r.__rowSpan=e.rowSpan;let i=e.style.backgroundColor;i!==""&&(r.__backgroundColor=i);let s=e.style.verticalAlign;Kr(s)&&(r.__verticalAlign=s);let l=e.style,a=(l&&l.textDecoration||"").split(" "),c=l.fontWeight==="700"||l.fontWeight==="bold",d=a.includes("line-through"),u=l.fontStyle==="italic",h=a.includes("underline");return {after:p=>{let f=[],m=null,g=()=>{if(m){let b=m.getFirstChild();$isLineBreakNode(b)&&m.getChildrenSize()===1&&b.remove();}};for(let b of p)$isInlineElementOrDecoratorNode(b)||$isTextNode(b)||$isLineBreakNode(b)?($isTextNode(b)&&(c&&b.toggleFormat("bold"),d&&b.toggleFormat("strikethrough"),u&&b.toggleFormat("italic"),h&&b.toggleFormat("underline")),m?m.append(b):(m=$createParagraphNode().append(b),f.push(m))):(f.push(b),g(),m=null);return g(),f.length===0&&f.push($createParagraphNode()),f},node:r}}function Me(o=te.NO_STATUS,e=1,t){return $applyNodeReplacement(new We(o,e,t))}function $(o){return o instanceof We}function O(o){throw new Error(o)}function lh(o){let e=o,t;return qr.test(e.style.height)&&(t=parseFloat(e.style.height)),{after:n=>$descendantsMatching(n,$),node:kt(t)}}function kt(o){return $applyNodeReplacement(new Mt(o))}function Q(o){return o instanceof Mt}function ta(o,e,t=true){let n=Fn();for(let r=0;r<o;r++){let i=kt();for(let s=0;s<e;s++){let l=te.NO_STATUS;typeof t=="object"?(r===0&&t.rows&&(l|=te.ROW),s===0&&t.columns&&(l|=te.COLUMN)):t&&(r===0&&(l|=te.ROW),s===0&&(l|=te.COLUMN));let a=Me(l),c=$createParagraphNode();c.append($createTextNode()),a.append(c),i.append(a);}n.append(i);}return n}function ch(o){let e=$findMatchingParent(o,t=>$(t));return $(e)?e:null}function Qr(o){let e=$findMatchingParent(o,t=>Q(t));if(Q(e))return e;throw new Error("Expected table cell to be inside of table row.")}function An(o){let e=$findMatchingParent(o,t=>ae(t));if(ae(e))return e;throw new Error("Expected table cell to be inside of table.")}function dh(o){let e=Qr(o);return An(e).getChildren().findIndex(n=>n.is(e))}function uh(o){return Qr(o).getChildren().findIndex(t=>t.is(o))}function oa(o,e){let t=An(o),{x:n,y:r}=t.getCordsFromCellNode(o,e);return {above:t.getCellNodeFromCords(n,r-1,e),below:t.getCellNodeFromCords(n,r+1,e),left:t.getCellNodeFromCords(n-1,r,e),right:t.getCellNodeFromCords(n+1,r,e)}}function fh(o,e){let t=o.getChildren();if(e>=t.length||e<0)throw new Error("Expected table cell to be inside of table row.");return t[e].remove(),o}function ph(o,e,t=true,n,r){let i=o.getChildren();if(e>=i.length||e<0)throw new Error("Table row target index out of range");let s=i[e];if(Q(s))for(let l=0;l<n;l++){let a=s.getChildren(),c=a.length,d=kt();for(let u=0;u<c;u++){let h=a[u];$(h)||O("Expected table cell");let{above:p,below:f}=oa(h,r),m=te.NO_STATUS,g=p&&p.getWidth()||f&&f.getWidth()||void 0;(p&&p.hasHeaderState(te.COLUMN)||f&&f.hasHeaderState(te.COLUMN))&&(m|=te.COLUMN);let b=Me(m,1,g);b.append($createParagraphNode()),d.append(b);}t?s.insertAfter(d):s.insertBefore(d);}else throw new Error("Row before insertion index does not exist.");return o}function na(o=true){let e=$getSelection();$isRangeSelection(e)||H(e)||O("Expected a RangeSelection or TableSelection");let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=ge(t),[i,,s]=ge(n),[,l,a]=Se(s,i,r),{startRow:c}=a,{startRow:d}=l;return o?Br(c+r.__rowSpan>d+i.__rowSpan?r:i,true):Br(d<c?i:r,false)}function Br(o,e=true){let[,,t]=ge(o),[n,r]=Se(t,o,o),i=n[0].length,{startRow:s}=r,l=null;if(e){let a=s+o.__rowSpan-1,c=n[a],d=kt();for(let h=0;h<i;h++){let{cell:p,startRow:f}=c[h];if(f+p.__rowSpan-1<=a){let g=c[h].cell.__headerState,b=zr(g,te.COLUMN);d.append(Me(b).append($createParagraphNode()));}else p.setRowSpan(p.__rowSpan+1);}let u=t.getChildAtIndex(a);Q(u)||O("insertAfterEndRow is not a TableRowNode"),u.insertAfter(d),l=d;}else {let a=s,c=n[a],d=kt();for(let h=0;h<i;h++){let{cell:p,startRow:f}=c[h];if(f===a){let g=c[h].cell.__headerState,b=zr(g,te.COLUMN);d.append(Me(b).append($createParagraphNode()));}else p.setRowSpan(p.__rowSpan+1);}let u=t.getChildAtIndex(a);Q(u)||O("insertBeforeStartRow is not a TableRowNode"),u.insertBefore(d),l=d;}return l}function mh(o,e,t=true,n,r){let i=o.getChildren(),s=[];for(let l=0;l<i.length;l++){let a=i[l];if(Q(a))for(let c=0;c<n;c++){let d=a.getChildren();if(e>=d.length||e<0)throw new Error("Table column target index out of range");let u=d[e];$(u)||O("Expected table cell");let{left:h,right:p}=oa(u,r),f=te.NO_STATUS;(h&&h.hasHeaderState(te.ROW)||p&&p.hasHeaderState(te.ROW))&&(f|=te.ROW);let m=Me(f);m.append($createParagraphNode()),s.push({newTableCell:m,targetCell:u});}}return s.forEach(({newTableCell:l,targetCell:a})=>{t?a.insertAfter(l):a.insertBefore(l);}),o}function ra(o=true){let e=$getSelection();$isRangeSelection(e)||H(e)||O("Expected a RangeSelection or TableSelection");let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=ge(t),[i,,s]=ge(n),[,l,a]=Se(s,i,r),{startColumn:c}=a,{startColumn:d}=l;return o?Hr(c+r.__colSpan>d+i.__colSpan?r:i,true):Hr(d<c?i:r,false)}function Hr(o,e=true,t=true){let[,,n]=ge(o),[r,i]=Se(n,o,o),s=r.length,{startColumn:l}=i,a=e?l+o.__colSpan-1:l-1,c=n.getFirstChild();Q(c)||O("Expected firstTable child to be a row");let d=null;function u(f=te.NO_STATUS){let m=Me(f).append($createParagraphNode());return d===null&&(d=m),m}let h=c;e:for(let f=0;f<s;f++){if(f!==0){let S=h.getNextSibling();Q(S)||O("Expected row nextSibling to be a row"),h=S;}let m=r[f],g=m[a<0?0:a].cell.__headerState,b=zr(g,te.ROW);if(a<0){ei(h,u(b));continue}let{cell:C,startColumn:x,startRow:w}=m[a];if(x+C.__colSpan-1<=a){let S=C,y=w,N=a;for(;y!==f&&S.__rowSpan>1;)if(N-=C.__colSpan,N>=0){let{cell:E,startRow:R}=m[N];S=E,y=R;}else {h.append(u(b));continue e}S.insertAfter(u(b));}else C.setColSpan(C.__colSpan+1);}d!==null&&t&&Ho(d);let p=n.getColWidths();if(p){let f=[...p],m=a<0?0:a,g=f[m];f.splice(m,0,g),n.setColWidths(f);}return d}function bh(o,e){let t=o.getChildren();for(let n=0;n<t.length;n++){let r=t[n];if(Q(r)){let i=r.getChildren();if(e>=i.length||e<0)throw new Error("Table column target index out of range");i[e].remove();}}return o}function ia(){let o=$getSelection();$isRangeSelection(o)||H(o)||O("Expected a RangeSelection or TableSelection");let[e,t]=o.isBackward()?[o.focus.getNode(),o.anchor.getNode()]:[o.anchor.getNode(),o.focus.getNode()],[n,,r]=ge(e),[i]=ge(t),[s,l,a]=Se(r,n,i),{startRow:c}=l,{startRow:d}=a,u=d+i.__rowSpan-1;if(s.length===u-c+1){r.remove();return}let h=s[0].length,p=s[u+1],f=r.getChildAtIndex(u+1);for(let m=u;m>=c;m--){for(let b=h-1;b>=0;b--){let{cell:C,startRow:x,startColumn:w}=s[m][b];if(w===b){if(x<c||x+C.__rowSpan-1>u){let S=Math.max(x,c),y=Math.min(C.__rowSpan+x-1,u),N=S<=y?y-S+1:0;C.setRowSpan(C.__rowSpan-N);}if(x>=c&&x+C.__rowSpan-1>u&&m===u){f===null&&O("Expected nextRowNode not to be null");let S=null;for(let y=0;y<b;y++){let N=p[y],E=N.cell;N.startRow===m+1&&(S=E),E.__colSpan>1&&(y+=E.__colSpan-1);}S===null?ei(f,C):S.insertAfter(C);}}}let g=r.getChildAtIndex(m);Q(g)||O(`Expected TableNode childAtIndex(${String(m)}) to be RowNode`),g.remove();}if(p!==void 0){let{cell:m}=p[0];Ho(m);}else {let m=s[c-1],{cell:g}=m[0];Ho(g);}}function sa(){let o=$getSelection();$isRangeSelection(o)||H(o)||O("Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=ge(e),[i]=ge(t),[s,l,a]=Se(r,n,i),{startColumn:c}=l,{startRow:d,startColumn:u}=a,h=Math.min(c,u),p=Math.max(c+n.__colSpan-1,u+i.__colSpan-1),f=p-h+1;if(s[0].length===p-h+1){r.selectPrevious(),r.remove();return}let g=s.length;for(let w=0;w<g;w++)for(let S=h;S<=p;S++){let{cell:y,startColumn:N}=s[w][S];if(N<h){if(S===h){let E=h-N;y.setColSpan(y.__colSpan-Math.min(f,y.__colSpan-E));}}else if(N+y.__colSpan-1>p){if(S===p){let E=p-N+1;y.setColSpan(y.__colSpan-E);}}else y.remove();}let b=s[d],C=c>u?b[c+n.__colSpan]:b[u+i.__colSpan];if(C!==void 0){let{cell:w}=C;Ho(w);}else {let w=u<c?b[u-1]:b[c-1],{cell:S}=w;Ho(S);}let x=r.getColWidths();if(x){let w=[...x];w.splice(h,f),r.setColWidths(w);}}function Ho(o){let e=o.getFirstDescendant();e==null?o.selectStart():e.getParentOrThrow().selectStart();}function ei(o,e){let t=o.getFirstChild();t!==null?t.insertBefore(e):o.append(e);}function la(o){if(o.length===0)return null;let e=An(o[0]),[t]=Ze(e,null,null),n=1/0,r=-1/0,i=1/0,s=-1/0,l=new Set;for(let p of t)for(let f of p){if(!f||!f.cell)continue;let m=f.cell.getKey();if(!l.has(m)&&o.some(g=>g.is(f.cell))){l.add(m);let g=f.startRow,b=f.startColumn,C=f.cell.__rowSpan||1,x=f.cell.__colSpan||1;n=Math.min(n,g),r=Math.max(r,g+C-1),i=Math.min(i,b),s=Math.max(s,b+x-1);}}if(n===1/0||i===1/0)return null;let a=r-n+1,c=s-i+1,d=t[n][i];if(!d.cell)return null;let u=d.cell;u.setColSpan(c),u.setRowSpan(a);let h=new Set([u.getKey()]);for(let p=n;p<=r;p++)for(let f=i;f<=s;f++){let m=t[p][f];if(!m.cell)continue;let g=m.cell,b=g.getKey();h.has(b)||(h.add(b),xh(g)||u.append(...g.getChildren()),g.remove());}return u.getChildrenSize()===0&&u.append($createParagraphNode()),u}function xh(o){if(o.getChildrenSize()!==1)return false;let e=o.getFirstChildOrThrow();return !(!$isParagraphNode(e)||!e.isEmpty())}function yh(){let o=$getSelection();$isRangeSelection(o)||H(o)||O("Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=$findMatchingParent(e,$);return $(t)||O("Expected to find a parent TableCellNode"),aa(t)}function aa(o){let[e,t,n]=ge(o),r=e.__colSpan,i=e.__rowSpan;if(r===1&&i===1)return;let[s,l]=Se(n,e,e),{startColumn:a,startRow:c}=l,d=e.__headerState&te.COLUMN,u=Array.from({length:r},(f,m)=>{let g=d;for(let b=0;g!==0&&b<s.length;b++)g&=s[b][m+a].cell.__headerState;return g}),h=e.__headerState&te.ROW,p=Array.from({length:i},(f,m)=>{let g=h;for(let b=0;g!==0&&b<s[0].length;b++)g&=s[m+c][b].cell.__headerState;return g});if(r>1){for(let f=1;f<r;f++)e.insertAfter(Me(u[f]|p[0]).append($createParagraphNode()));e.setColSpan(1);}if(i>1){let f;for(let m=1;m<i;m++){let g=c+m,b=s[g];f=(f||t).getNextSibling(),Q(f)||O("Expected row next sibling to be a row");let C=null;for(let x=0;x<a;x++){let w=b[x],S=w.cell;w.startRow===g&&(C=S),S.__colSpan>1&&(x+=S.__colSpan-1);}if(C===null)for(let x=r-1;x>=0;x--)ei(f,Me(u[x]|p[m]).append($createParagraphNode()));else for(let x=r-1;x>=0;x--)C.insertAfter(Me(u[x]|p[m]).append($createParagraphNode()));}e.setRowSpan(1);}}function Se(o,e,t){let[n,r,i]=Ze(o,e,t);return r===null&&O("Anchor not found in Table"),i===null&&O("Focus not found in Table"),[n,r,i]}function Ze(o,e,t){let n=[],r=null,i=null;function s(a){let c=n[a];return c===void 0&&(n[a]=c=[]),c}let l=o.getChildren();for(let a=0;a<l.length;a++){let c=l[a];Q(c)||O("Expected TableNode children to be TableRowNode");let d=s(a);for(let u=c.getFirstChild(),h=0;u!=null;u=u.getNextSibling()){for($(u)||O("Expected TableRowNode children to be TableCellNode");d[h]!==void 0;)h++;let p={cell:u,startColumn:h,startRow:a},{__rowSpan:f,__colSpan:m}=u;for(let g=0;g<f&&!(a+g>=l.length);g++){let b=s(a+g);for(let C=0;C<m;C++)b[h+C]=p;}e!==null&&r===null&&e.is(u)&&(r=p),t!==null&&i===null&&t.is(u)&&(i=p);}}return [n,r,i]}function ge(o){let e;if(o instanceof We)e=o;else if("__type"in o){let r=$findMatchingParent(o,$);$(r)||O("Expected to find a parent TableCellNode"),e=r;}else {let r=$findMatchingParent(o.getNode(),$);$(r)||O("Expected to find a parent TableCellNode"),e=r;}let t=e.getParent();Q(t)||O("Expected TableCellNode to have a parent TableRowNode");let n=t.getParent();return ae(n)||O("Expected TableRowNode to have a parent TableNode"),[e,t,n]}function wh(o,e){let{minColumn:t,maxColumn:n,minRow:r,maxRow:i}=e,s=1,l=1,a=1,c=1,d=o[r],u=o[i];for(let h=t;h<=n;h++)s=Math.max(s,d[h].cell.__rowSpan),c=Math.max(c,u[h].cell.__rowSpan);for(let h=r;h<=i;h++)l=Math.max(l,o[h][t].cell.__colSpan),a=Math.max(a,o[h][n].cell.__colSpan);return {bottomSpan:c,leftSpan:l,rightSpan:a,topSpan:s}}function $n(o,e,t){let n=Math.min(e.startColumn,t.startColumn),r=Math.min(e.startRow,t.startRow),i=Math.max(e.startColumn+e.cell.__colSpan-1,t.startColumn+t.cell.__colSpan-1),s=Math.max(e.startRow+e.cell.__rowSpan-1,t.startRow+t.cell.__rowSpan-1),l;do{l=false;for(let a=0;a<o.length;a++)for(let c=0;c<o[0].length;c++){let d=o[a][c];if(!d)continue;let u=d.startColumn+d.cell.__colSpan-1,h=d.startRow+d.cell.__rowSpan-1,p=d.startColumn<=i&&u>=n,f=d.startRow<=s&&h>=r;if(p&&f){let m=Math.min(n,d.startColumn),g=Math.max(i,u),b=Math.min(r,d.startRow),C=Math.max(s,h);(m!==n||g!==i||b!==r||C!==s)&&(n=m,i=g,r=b,s=C,l=true);}}}while(l);return {maxColumn:i,maxRow:s,minColumn:n,minRow:r}}function Wr(o){let[e,,t]=ge(o),n=t.getChildren(),r=n.length,i=n[0].getChildren().length,s=new Array(r);for(let l=0;l<r;l++)s[l]=new Array(i);for(let l=0;l<r;l++){let c=n[l].getChildren(),d=0;for(let u=0;u<c.length;u++){for(;s[l][d];)d++;let h=c[u],p=h.__rowSpan||1,f=h.__colSpan||1;for(let m=0;m<p;m++)for(let g=0;g<f;g++)s[l+m][d+g]=h;if(e===h)return {colSpan:f,columnIndex:d,rowIndex:l,rowSpan:p};d+=f;}}return null}function Pl(o){let[[e,t,n,r],[i,s,l,a]]=["anchor","focus"].map(c=>{let d=o[c].getNode(),u=$findMatchingParent(d,$);$(u)||O(`Expected TableSelection ${c} to be (or a child of) TableCellNode, got key ${d.getKey()} of type ${d.getType()}`);let h=u.getParent();Q(h)||O(`Expected TableSelection ${c} cell parent to be a TableRowNode`);let p=h.getParent();return ae(p)||O(`Expected TableSelection ${c} row parent to be a TableNode`),[d,u,h,p]});return r.is(a)||O("Expected TableSelection anchor and focus to be in the same table"),{anchorCell:t,anchorNode:e,anchorRow:n,anchorTable:r,focusCell:s,focusNode:i,focusRow:l,focusTable:a}}function H(o){return o instanceof On}function ti(){let o=$createPoint("root",0,"element"),e=$createPoint("root",0,"element");return new On("root",o,e)}function ca(o,e,t){let n=o.getKey(),r=e.getKey(),i=t.getKey();o.isAttached()||O(`$createTableSelectionFrom: tableNode ${n} is not attached`),o.is(Qe(e))||O(`$createTableSelectionFrom: anchorCell ${r} is not in table ${n}`),o.is(Qe(t))||O(`$createTableSelectionFrom: focusCell ${i} is not in table ${n}`);let s=$getSelection(),l=H(s)?s.clone():ti();return l.set(o.getKey(),e.getKey(),t.getKey()),l}function Nh(o,e){let t=[[o]];for(let n=t.at(-1);n!==void 0&&t.length>0;n=t.at(-1)){let r=n.pop();r===void 0?t.pop():e(r)!==false&&$isElementNode(r)&&t.push(r.getChildren());}}function oi(o,e=$getEditor()){let t=$getNodeByKey(o);ae(t)||O(`TableObserver: Expected tableNodeKey ${o} to be a TableNode`);let n=ft(t,e.getElementByKey(o));return n===null&&O(`TableObserver: Expected to find TableElement in DOM for key ${o}`),{tableElement:n,tableNode:t}}function no(o){return isHTMLElement(o)&&o.nodeName==="TABLE"}function ft(o,e){if(!e)return e;let t=no(e)?e:o.getDOMSlot(e).element;return t.nodeName!=="TABLE"&&O(`getTableElement: Expecting table in as DOM node for TableNode, not ${e.nodeName}`),t}function ri(o){return o._window}function Bo(o,e){for(let t=e,n=null;t!==null;t=t.getParent()){if(o.is(t))return n;$(t)&&(n=t);}return null}function da(o,e,t,n){let r=t.getRootElement(),i=ri(t);r!==null&&i!==null||O("applyTableHandlers: editor has no root element set");let s=new Mn(t,o.getKey()),l=ft(o,e);Oh(l,s),s.listenersToRemove.add(()=>Rh(l,s));let a=()=>{if(s.isSelecting)return;let f=()=>{s.isSelecting=false,i.removeEventListener("pointerup",f),i.removeEventListener("pointermove",m);},m=g=>{if(!_h(g)&&s.isSelecting){s.isSelecting=false,i.removeEventListener("pointerup",f),i.removeEventListener("pointermove",m);return}if(!isDOMNode(g.target))return;let b=null,C=!(Ll||l.contains(g.target));if(C)b=Il(l,g.target);else for(let x of document.elementsFromPoint(g.clientX,g.clientY))if(b=Il(l,x),b)break;b&&(s.focusCell===null||b.elem!==s.focusCell.elem)&&(s.setNextFocus({focusCell:b,override:C}),t.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0));};s.isSelecting=true,i.addEventListener("pointerup",f,s.listenerOptions),i.addEventListener("pointermove",m,s.listenerOptions);},c=f=>{if(s.pointerType=f.pointerType,f.button!==0||!isDOMNode(f.target)||!i)return;let m=Wo(f.target);m!==null&&t.update(()=>{let g=$getPreviousSelection();if(Ll&&f.shiftKey&&Be(g,o)&&($isRangeSelection(g)||H(g))){let b=g.anchor.getNode(),C=Bo(o,g.anchor.getNode());C?(s.$setAnchorCellForSelection(Rt(s,C)),s.$setFocusCellForSelection(m),qe(f)):(o.isBefore(b)?o.selectStart():o.selectEnd()).anchor.set(g.anchor.key,g.anchor.offset,g.anchor.type);}else f.pointerType!=="touch"&&s.$setAnchorCellForSelection(m);}),a();};l.addEventListener("pointerdown",c,s.listenerOptions),s.listenersToRemove.add(()=>{l.removeEventListener("pointerdown",c);});let d=f=>{f.detail>=3&&isDOMNode(f.target)&&Wo(f.target)!==null&&f.preventDefault();};l.addEventListener("mousedown",d,s.listenerOptions),s.listenersToRemove.add(()=>{l.removeEventListener("mousedown",d);});let u=f=>{let m=f.target;f.button!==0||!isDOMNode(m)||t.update(()=>{let g=$getSelection();H(g)&&g.tableKey===s.tableNodeKey&&r.contains(m)&&s.$clearHighlight();});};i.addEventListener("pointerdown",u,s.listenerOptions),s.listenersToRemove.add(()=>{i.removeEventListener("pointerdown",u);});for(let[f,m]of Eh)s.listenersToRemove.add(t.registerCommand(f,g=>pa(t,g,m,o,s),COMMAND_PRIORITY_HIGH));s.listenersToRemove.add(t.registerCommand(KEY_ESCAPE_COMMAND,f=>{let m=$getSelection();if(H(m)){let g=Bo(o,m.focus.getNode());if(g!==null)return qe(f),g.selectEnd(),true}return false},COMMAND_PRIORITY_HIGH));let h=f=>()=>{let m=$getSelection();if(!Be(m,o))return false;if(H(m))return s.$clearText(),true;if($isRangeSelection(m)){let g=Bo(o,m.anchor.getNode());if(!$(g))return false;let b=m.anchor.getNode(),C=m.focus.getNode(),x=o.isParentOf(b),w=o.isParentOf(C);if(x&&!w||w&&!x)return s.$clearText(),true;let y=$findMatchingParent(m.anchor.getNode(),E=>$isElementNode(E)),N=y&&$findMatchingParent(y,E=>$isElementNode(E)&&$(E.getParent()));if(!$isElementNode(N)||!$isElementNode(y))return false;if(f===DELETE_LINE_COMMAND&&N.getPreviousSibling()===null)return true}return false};for(let f of Th)s.listenersToRemove.add(t.registerCommand(f,h(f),COMMAND_PRIORITY_HIGH));let p=f=>{let m=$getSelection();if(!(H(m)||$isRangeSelection(m)))return false;let g=o.isParentOf(m.anchor.getNode()),b=o.isParentOf(m.focus.getNode());if(g!==b){let C=g?"anchor":"focus",x=g?"focus":"anchor",{key:w,offset:S,type:y}=m[x];return o[m[C].isBefore(m[x])?"selectPrevious":"selectNext"]()[x].set(w,S,y),false}return Be(m,o)&&H(m)?(f&&(f.preventDefault(),f.stopPropagation()),s.$clearText(),true):false};for(let f of vh)s.listenersToRemove.add(t.registerCommand(f,p,COMMAND_PRIORITY_HIGH));return s.listenersToRemove.add(t.registerCommand(CUT_COMMAND,f=>{let m=$getSelection();if(m){if(!(H(m)||$isRangeSelection(m)))return false;Nn(t,objectKlassEquals(f,ClipboardEvent)?f:null,wn(m));let g=p(f);return $isRangeSelection(m)?(m.removeText(),true):g}return false},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FORMAT_TEXT_COMMAND,f=>{let m=$getSelection();if(!Be(m,o))return false;if(H(m))return s.$formatCells(f),true;if($isRangeSelection(m)){let g=$findMatchingParent(m.anchor.getNode(),b=>$(b));if(!$(g))return false}return false},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FORMAT_ELEMENT_COMMAND,f=>{let m=$getSelection();if(!H(m)||!Be(m,o))return false;let g=m.anchor.getNode(),b=m.focus.getNode();if(!$(g)||!$(b))return false;if(Lh(m,o))return o.setFormat(f),true;let[C,x,w]=Se(o,g,b),S=Math.max(x.startRow+x.cell.__rowSpan-1,w.startRow+w.cell.__rowSpan-1),y=Math.max(x.startColumn+x.cell.__colSpan-1,w.startColumn+w.cell.__colSpan-1),N=Math.min(x.startRow,w.startRow),E=Math.min(x.startColumn,w.startColumn),R=new Set;for(let L=N;L<=S;L++)for(let k=E;k<=y;k++){let M=C[L][k].cell;if(R.has(M))continue;R.add(M),M.setFormat(f);let v=M.getChildren();for(let T=0;T<v.length;T++){let K=v[T];$isElementNode(K)&&!K.isInline()&&K.setFormat(f);}}return true},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND,f=>{let m=$getSelection();if(!Be(m,o))return false;if(H(m))return s.$clearHighlight(),false;if($isRangeSelection(m)){let g=$findMatchingParent(m.anchor.getNode(),b=>$(b));if(!$(g))return false;if(typeof f=="string"){let b=Bl(t,m,o);if(b)return zl(b,o,[$createTextNode(f)]),true}}return false},COMMAND_PRIORITY_HIGH)),n&&s.listenersToRemove.add(t.registerCommand(KEY_TAB_COMMAND,f=>{let m=$getSelection();if(!$isRangeSelection(m)||!m.isCollapsed()||!Be(m,o))return false;let g=ro(m.anchor.getNode());return g===null||!o.is(Qe(g))?false:(qe(f),kh(g,f.shiftKey?"previous":"next"),true)},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FOCUS_COMMAND,f=>o.isSelected(),COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(f,m)=>{if(t!==m)return false;let{nodes:g,selection:b}=f,C=b.getStartEndPoints(),x=H(b),S=$isRangeSelection(b)&&$findMatchingParent(b.anchor.getNode(),P=>$(P))!==null&&$findMatchingParent(b.focus.getNode(),P=>$(P))!==null||x;if(g.length!==1||!ae(g[0])||!S||C===null)return false;let[y,N]=C,[E,R,L]=ge(y),k=$findMatchingParent(N.getNode(),P=>$(P));if(!$(E)||!$(k)||!Q(R)||!ae(L))return false;let M=g[0],[v,T,K]=Se(L,E,k),[V]=Ze(M,null,null),ie=v.length,re=ie>0?v[0].length:0,se=T.startRow,Ce=T.startColumn,ve=V.length,Le=ve>0?V[0].length:0;if(x){let P=$n(v,T,K),he=P.maxRow-P.minRow+1,Oe=P.maxColumn-P.minColumn+1;se=P.minRow,Ce=P.minColumn,ve=Math.min(ve,he),Le=Math.min(Le,Oe);}let Ae=false,on=Math.min(ie,se+ve)-1,Ct=Math.min(re,Ce+Le)-1,nn=new Set;for(let P=se;P<=on;P++)for(let he=Ce;he<=Ct;he++){let Oe=v[P][he];nn.has(Oe.cell.getKey())||Oe.cell.__rowSpan===1&&Oe.cell.__colSpan===1||(aa(Oe.cell),nn.add(Oe.cell.getKey()),Ae=true);}let[St]=Ze(L.getWritable(),null,null),z=ve-ie+se;for(let P=0;P<z;P++){let he=St[ie-1][0];Br(he.cell);}let Re=Le-re+Ce;for(let P=0;P<Re;P++){let he=St[0][re-1];Hr(he.cell,true,false);}[St]=Ze(L.getWritable(),null,null);for(let P=se;P<se+ve;P++)for(let he=Ce;he<Ce+Le;he++){let Oe=P-se,nt=he-Ce,xt=V[Oe][nt];if(xt.startRow!==Oe||xt.startColumn!==nt)continue;let yt=xt.cell;if(yt.__rowSpan!==1||yt.__colSpan!==1){let Ie=[],Ut=Math.min(P+yt.__rowSpan,se+ve)-1,No=Math.min(he+yt.__colSpan,Ce+Le)-1;for(let _o=P;_o<=Ut;_o++)for(let lr=he;lr<=No;lr++){let hd=St[_o][lr];Ie.push(hd.cell);}la(Ie),Ae=true;}let{cell:$e}=St[P][he],sr=$e.getChildren();yt.getChildren().forEach(Ie=>{$isTextNode(Ie)&&$createParagraphNode().append(Ie),$e.append(Ie);}),sr.forEach(Ie=>Ie.remove());}if(x&&Ae){let[P]=Ze(L.getWritable(),null,null);P[T.startRow][T.startColumn].cell.selectEnd();}return true},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(SELECTION_CHANGE_COMMAND,()=>{let f=$getSelection(),m=$getPreviousSelection(),g=s.getAndClearNextFocus();if(g!==null){let{focusCell:C}=g;if(H(f)&&f.tableKey===s.tableNodeKey)return C.x===s.focusX&&C.y===s.focusY?false:(s.$setFocusCellForSelection(C),true);if(C!==s.anchorCell&&Be(f,o))return s.$setFocusCellForSelection(C),true}if(s.getAndClearShouldCheckSelection()&&$isRangeSelection(m)&&$isRangeSelection(f)&&f.isCollapsed()){let C=f.anchor.getNode(),x=o.getFirstChild(),w=ro(C);if(w!==null&&Q(x)){let S=x.getFirstChild();if($(S)&&o.is($findMatchingParent(w,y=>y.is(o)||y.is(S))))return S.selectStart(),true}}if($isRangeSelection(f)){let{anchor:C,focus:x}=f,w=C.getNode(),S=x.getNode(),y=ro(w),N=ro(S),E=!!(y&&o.is(Qe(y))),R=!!(N&&o.is(Qe(N))),L=E!==R,k=E&&R,M=f.isBackward();if(L){let v=f.clone();if(R){let[T]=Se(o,N,N),K=T[0][0].cell,V=T[T.length-1].at(-1).cell;v.focus.set(M?K.getKey():V.getKey(),M?K.getChildrenSize():V.getChildrenSize(),"element");}else if(E){let[T]=Se(o,y,y),K=T[0][0].cell,V=T[T.length-1].at(-1).cell;v.anchor.set(M?V.getKey():K.getKey(),M?V.getChildrenSize():0,"element");}$setSelection(v),Kl(t,s);}else if(k&&(y.is(N)||(s.$setAnchorCellForSelection(Rt(s,y)),s.$setFocusCellForSelection(Rt(s,N),true)),s.pointerType==="touch"&&s.isSelecting&&f.isCollapsed()&&$isRangeSelection(m)&&m.isCollapsed())){let v=ro(m.anchor.getNode());v&&!v.is(N)&&(s.$setAnchorCellForSelection(Rt(s,v)),s.$setFocusCellForSelection(Rt(s,N),true),s.pointerType=null);}}else if(f&&H(f)&&f.is(m)&&f.tableKey===o.getKey()){let C=getDOMSelection(i);if(C&&C.anchorNode&&C.focusNode){let x=$getNearestNodeFromDOMNode(C.focusNode),w=x&&!o.isParentOf(x),S=$getNearestNodeFromDOMNode(C.anchorNode),y=S&&o.isParentOf(S);if(w&&y&&C.rangeCount>0){let N=$createRangeSelectionFromDom(C,t);N&&(N.anchor.set(o.getKey(),f.isBackward()?o.getChildrenSize():0,"element"),C.removeAllRanges(),$setSelection(N));}}}return f&&!f.is(m)&&(H(f)||H(m))&&s.tableSelection&&!s.tableSelection.is(m)?(H(f)&&f.tableKey===s.tableNodeKey?s.$updateTableTableSelection(f):!H(f)&&H(m)&&m.tableKey===s.tableNodeKey&&s.$updateTableTableSelection(null),false):(s.hasHijackedSelectionStyles&&!o.isSelected()?Mh(t,s):!s.hasHijackedSelectionStyles&&o.isSelected()&&Kl(t,s),false)},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(INSERT_PARAGRAPH_COMMAND,()=>{let f=$getSelection();if(!$isRangeSelection(f)||!f.isCollapsed()||!Be(f,o))return false;let m=Bl(t,f,o);return m?(zl(m,o),true):false},COMMAND_PRIORITY_HIGH)),s}function Rh(o,e){ii(o)===e&&delete o[ni];}function Oh(o,e){ii(o)!==null&&O("tableElement already has an attached TableObserver"),o[ni]=e;}function ii(o){return o[ni]||null}function Wo(o){let e=o;for(;e!=null;){let t=e.nodeName;if(t==="TD"||t==="TH"){let n=e._cell;return n===void 0?null:n}e=e.parentNode;}return null}function Il(o,e){if(!o.contains(e))return null;let t=null;for(let n=e;n!=null;n=n.parentNode){if(n===o)return t;let r=n.nodeName;(r==="TD"||r==="TH")&&(t=n._cell||null);}return null}function so(o,e){let t=ft(o,e),n=[],r={columns:0,domRows:n,rows:0},i=t.querySelector("tr"),s=0,l=0;for(n.length=0;i!=null;){let a=i.nodeName;if(a==="TD"||a==="TH"){let u=i,h={elem:u,hasBackgroundColor:u.style.backgroundColor!=="",highlighted:false,x:s,y:l};i._cell=h;let p=n[l];p===void 0&&(p=n[l]=[]),p[s]=h;}else {let u=i.firstChild;if(u!=null){i=u;continue}}let c=i.nextSibling;if(c!=null){s++,i=c;continue}let d=i.parentNode;if(d!=null){let u=d.nextSibling;if(u==null)break;l++,s=0,i=u;}}return r.columns=s+1,r.rows=l+1,r}function En(o,e,t){let n=new Set(t?t.getNodes():[]);si(e,(r,i)=>{let s=r.elem;n.has(i)?(r.highlighted=true,ua(o,r)):(r.highlighted=false,fa(o,r),s.getAttribute("style")||s.removeAttribute("style"));});}function si(o,e){let{domRows:t}=o;for(let n=0;n<t.length;n++){let r=t[n];if(r)for(let i=0;i<r.length;i++){let s=r[i];if(!s)continue;let l=$getNearestNodeFromDOMNode(s.elem);l!==null&&e(s,l,{x:i,y:n});}}}function Kl(o,e){e.$disableHighlightStyle(),si(e.table,t=>{t.highlighted=true,ua(o,t);});}function Mh(o,e){e.$enableHighlightStyle(),si(e.table,t=>{let n=t.elem;t.highlighted=false,fa(o,t),n.getAttribute("style")||n.removeAttribute("style");});}function kh(o,e){let t=e==="next"?"getNextSibling":"getPreviousSibling",n=e==="next"?"getFirstChild":"getLastChild",r=o[t]();if($isElementNode(r))return r.selectEnd();let i=$findMatchingParent(o,Q);i===null&&O("selectAdjacentCell: Cell not in table row");for(let l=i[t]();Q(l);l=l[t]()){let a=l[n]();if($isElementNode(a))return a.selectEnd()}let s=$findMatchingParent(i,ae);return s===null&&O("selectAdjacentCell: Row not in table"),e==="next"?s.selectNext():s.selectPrevious()}function Ur(o,e){let t,n;if(e.startColumn===o.minColumn)t="minColumn";else if(e.startColumn+e.cell.__colSpan-1===o.maxColumn)t="maxColumn";else return null;if(e.startRow===o.minRow)n="minRow";else if(e.startRow+e.cell.__rowSpan-1===o.maxRow)n="maxRow";else return null;return [t,n]}function $h(o,e){let t=Ur(o,e);return t===null&&O(`getCornerOrThrow: cell ${e.cell.getKey()} is not at a corner of rect`),t}function vn([o,e]){return [o==="minColumn"?"maxColumn":"minColumn",e==="minRow"?"maxRow":"minRow"]}function oo(o,e,[t,n]){let r=e[n],i=o[r];i===void 0&&O(`cellAtCornerOrThrow: ${n} = ${String(r)} missing in tableMap`);let s=e[t],l=i[s];return l===void 0&&O(`cellAtCornerOrThrow: ${t} = ${String(s)} missing in tableMap`),l}function Fh(o,e,t){let n=$n(o,e,t),r=Ur(n,e);if(r)return [oo(o,n,r),oo(o,n,vn(r))];let i=Ur(n,t);if(i)return [oo(o,n,vn(i)),oo(o,n,i)];let s=["minColumn","minRow"];return [oo(o,n,s),oo(o,n,vn(s))]}function Dh(o,e,t,n,r){let i=$n(e,t,n),s=wh(e,i),{topSpan:l,leftSpan:a,bottomSpan:c,rightSpan:d}=s,u=$h(i,t),[h,p]=vn(u),f=i[h],m=i[p];r==="forward"?f+=h==="maxColumn"?1:a:r==="backward"?f-=h==="minColumn"?1:d:r==="down"?m+=p==="maxRow"?1:l:r==="up"&&(m-=p==="minRow"?1:c);let g=e[m];if(g===void 0)return false;let b=g[f];if(b===void 0)return false;let[C,x]=Fh(e,t,b),w=Rt(o,C.cell),S=Rt(o,x.cell);return o.$setAnchorCellForSelection(w),o.$setFocusCellForSelection(S,true),true}function Be(o,e){if($isRangeSelection(o)||H(o)){let t=e.isParentOf(o.anchor.getNode()),n=e.isParentOf(o.focus.getNode());return t&&n}return false}function Lh(o,e){if(H(o)){let t=o.anchor.getNode(),n=o.focus.getNode();if(e&&t&&n){let[r]=Se(e,t,n);return t.getKey()===r[0][0].cell.getKey()&&n.getKey()===r[r.length-1].at(-1).cell.getKey()}}return false}function Tn(o,e){e?o.selectStart():o.selectEnd();}function ua(o,e){let t=e.elem,n=o._config.theme,r=$getNearestNodeFromDOMNode(t);$(r)||O("Expected to find LexicalNode from Table Cell DOMNode"),addClassNamesToElement(t,n.tableCellSelected);}function fa(o,e){let t=e.elem,n=$getNearestNodeFromDOMNode(t);$(n)||O("Expected to find LexicalNode from Table Cell DOMNode");let r=o._config.theme;removeClassNamesFromElement(t,r.tableCellSelected);}function ro(o){let e=$findMatchingParent(o,$);return $(e)?e:null}function Qe(o){let e=$findMatchingParent(o,ae);return ae(e)?e:null}function Ph(o){for(let e=o,t=o;t!==null;e=t,t=t.getParent())if($isElementNode(t)){if(t!==e&&t.getFirstChild()!==e)return null;if(!t.isInline())return t}return null}function Ih(o,e,t,n,r,i,s){let l=$caretFromPoint(t.focus,r?"previous":"next");if($isExtendableTextPointCaret(l))return false;let a=l;for(let g of $extendCaretToRange(l).iterNodeCarets("shadowRoot")){if(!($isSiblingCaret(g)&&$isElementNode(g.origin)))return false;a=g;}let c=a.getParentAtCaret();if(!$(c))return false;let d=c,u=zh($getSiblingCaret(d,a.direction)),h=$findMatchingParent(d,ae);if(!(h&&h.is(i)))return false;let p=o.getElementByKey(d.getKey()),f=Wo(p);if(!p||!f)return false;let m=ma(o,h);if(s.table=m,u)if(n==="extend"){let g=Wo(o.getElementByKey(u.origin.getKey()));if(!g)return false;s.$setAnchorCellForSelection(f),s.$setFocusCellForSelection(g,true);}else {let g=$normalizeCaret(u);$setPointFromCaret(t.anchor,g),$setPointFromCaret(t.focus,g);}else if(n==="extend")s.$setAnchorCellForSelection(f),s.$setFocusCellForSelection(f,true);else {let g=Kh($getSiblingCaret(h,l.direction));$setPointFromCaret(t.anchor,g),$setPointFromCaret(t.focus,g);}return qe(e),true}function Kh(o){let e=$getAdjacentChildCaret(o);return $isChildCaret(e)?$normalizeCaret(e):o}function zh(o){for(let e of $extendCaretToRange(o).iterNodeCarets("root")){let{origin:t}=e;if($(t)){if($isChildCaret(e))return $getChildCaret(t,o.direction)}else if(!Q(t))break}return null}function pa(o,e,t,n,r){if((t==="up"||t==="down")&&Bh(o))return false;let i=$getSelection();if(!Be(i,n)){if($isRangeSelection(i)){if(t==="backward"){if(i.focus.offset>0)return false;let s=Ph(i.focus.getNode());if(!s)return false;let l=s.getPreviousSibling();return ae(l)?(qe(e),e.shiftKey?i.focus.set(l.getParentOrThrow().getKey(),l.getIndexWithinParent(),"element"):l.selectEnd(),true):false}else if(e.shiftKey&&(t==="up"||t==="down")){let s=i.focus.getNode();if(!i.isCollapsed()&&(t==="up"&&!i.isBackward()||t==="down"&&i.isBackward())){let a=$findMatchingParent(s,p=>ae(p));if($(a)&&(a=$findMatchingParent(a,ae)),a!==n||!a)return false;let c=t==="down"?a.getNextSibling():a.getPreviousSibling();if(!c)return false;let d=0;t==="up"&&$isElementNode(c)&&(d=c.getChildrenSize());let u=c;if(t==="up"&&$isElementNode(c)){let p=c.getLastChild();u=p||c,d=$isTextNode(u)?u.getTextContentSize():0;}let h=i.clone();return h.focus.set(u.getKey(),d,$isTextNode(u)?"text":"element"),$setSelection(h),qe(e),true}else if($isRootOrShadowRoot(s)){let a=t==="up"?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(a&&Bo(n,a)!==null){let d=n.getFirstDescendant(),u=n.getLastDescendant();if(!d||!u)return false;let[h]=ge(d),[p]=ge(u),f=n.getCordsFromCellNode(h,r.table),m=n.getCordsFromCellNode(p,r.table),g=n.getDOMCellFromCordsOrThrow(f.x,f.y,r.table),b=n.getDOMCellFromCordsOrThrow(m.x,m.y,r.table);return r.$setAnchorCellForSelection(g),r.$setFocusCellForSelection(b,true),true}return false}else {let a=$findMatchingParent(s,d=>$isElementNode(d)&&!d.isInline());if($(a)&&(a=$findMatchingParent(a,ae)),!a)return false;let c=t==="down"?a.getNextSibling():a.getPreviousSibling();if(ae(c)&&r.tableNodeKey===c.getKey()){let d=c.getFirstDescendant(),u=c.getLastDescendant();if(!d||!u)return false;let[h]=ge(d),[p]=ge(u),f=i.clone();return f.focus.set((t==="up"?h:p).getKey(),t==="up"?0:p.getChildrenSize(),"element"),qe(e),$setSelection(f),true}}}}return t==="down"&&Uo(o)&&r.setShouldCheckSelection(),false}if($isRangeSelection(i)){if(t==="backward"||t==="forward"){let s=e.shiftKey?"extend":"move";return Ih(o,e,i,s,t==="backward",n,r)}if(i.isCollapsed()){let{anchor:s,focus:l}=i,a=$findMatchingParent(s.getNode(),$),c=$findMatchingParent(l.getNode(),$);if(!$(a)||!a.is(c))return false;let d=Qe(a);if(d!==n&&d!=null){let C=ft(d,o.getElementByKey(d.getKey()));if(C!=null)return r.table=so(d,C),pa(o,e,t,d,r)}let u=o.getElementByKey(a.__key),h=o.getElementByKey(s.key);if(h==null||u==null)return false;let p;if(s.type==="element")p=h.getBoundingClientRect();else {let C=getDOMSelection(ri(o));if(C===null||C.rangeCount===0)return false;p=C.getRangeAt(0).getBoundingClientRect();}let f=t==="up"?a.getFirstChild():a.getLastChild();if(f==null)return false;let m=o.getElementByKey(f.__key);if(m==null)return false;let g=m.getBoundingClientRect();if(t==="up"?g.top>p.top-p.height:p.bottom+p.height>g.bottom){qe(e);let C=n.getCordsFromCellNode(a,r.table);if(e.shiftKey){let x=n.getDOMCellFromCordsOrThrow(C.x,C.y,r.table);r.$setAnchorCellForSelection(x),r.$setFocusCellForSelection(x,true);}else return Ah(r,n,C.x,C.y,t);return true}}}else if(H(i)){let{anchor:s,focus:l}=i,a=$findMatchingParent(s.getNode(),$),c=$findMatchingParent(l.getNode(),$),[d]=i.getNodes();ae(d)||O("$handleArrowKey: TableSelection.getNodes()[0] expected to be TableNode");let u=ft(d,o.getElementByKey(d.getKey()));if(!$(a)||!$(c)||!ae(d)||u==null)return false;r.$updateTableTableSelection(i);let h=so(d,u),p=n.getCordsFromCellNode(a,h),f=n.getDOMCellFromCordsOrThrow(p.x,p.y,h);if(r.$setAnchorCellForSelection(f),qe(e),e.shiftKey){let[m,g,b]=Se(n,a,c);return Dh(r,m,g,b,t)}else c.selectEnd();return true}return false}function qe(o){o.preventDefault(),o.stopImmediatePropagation(),o.stopPropagation();}function Bh(o){let e=o.getRootElement();return e?e.hasAttribute("aria-controls")&&e.getAttribute("aria-controls")==="typeahead-menu":false}function zl(o,e,t){let n=$createParagraphNode();o==="first"?e.insertBefore(n):e.insertAfter(n),n.append(...t||[]),n.selectEnd();}function Bl(o,e,t){let n=t.getParent();if(!n)return;let r=getDOMSelection(ri(o));if(!r)return;let i=r.anchorNode,s=o.getElementByKey(n.getKey()),l=ft(t,o.getElementByKey(t.getKey()));if(!i||!s||!l||!s.contains(i)||l.contains(i))return;let a=$findMatchingParent(e.anchor.getNode(),C=>$(C));if(!a)return;let c=$findMatchingParent(a,C=>ae(C));if(!ae(c)||!c.is(t))return;let[d,u]=Se(t,a,a),h=d[0][0],p=d[d.length-1][d[0].length-1],{startRow:f,startColumn:m}=u,g=f===h.startRow&&m===h.startColumn,b=f===p.startRow&&m===p.startColumn;return g?"first":b?"last":void 0}function Rt(o,e){let{tableNode:t}=o.$lookup(),n=t.getCordsFromCellNode(e,o.table);return t.getDOMCellFromCordsOrThrow(n.x,n.y,o.table)}function jr(o,e,t){return Bo(o,$getNearestNodeFromDOMNode(e,t))}function Hh(o){return isHTMLElement$1(o)&&o.nodeName==="DIV"}function Wh(o,e,t,n){let r=o.querySelector("colgroup");if(!r)return;let i=[];for(let s=0;s<t;s++){let l=document.createElement("col"),a=n&&n[s];a&&(l.style.width=`${a}px`),i.push(l);}r.replaceChildren(...i);}function Uh(o,e,t){t?(addClassNamesToElement(o,e.theme.tableRowStriping),o.setAttribute("data-lexical-row-striping","true")):(removeClassNamesFromElement(o,e.theme.tableRowStriping),o.removeAttribute("data-lexical-row-striping"));}function jh(o,e,t,n){n>0?(addClassNamesToElement(o,t.theme.tableFrozenColumn),e.setAttribute("data-lexical-frozen-column","true")):(removeClassNamesFromElement(o,t.theme.tableFrozenColumn),e.removeAttribute("data-lexical-frozen-column"));}function Yh(o,e,t,n){n>0?(addClassNamesToElement(o,t.theme.tableFrozenRow),e.setAttribute("data-lexical-frozen-row","true")):(removeClassNamesFromElement(o,t.theme.tableFrozenRow),e.removeAttribute("data-lexical-frozen-row"));}function Hl(o,e,t){if(!e.theme.tableAlignment)return;let n=[],r=[];for(let i of ["center","right"]){let s=e.theme.tableAlignment[i];s&&(i===t?r:n).push(s);}removeClassNamesFromElement(o,...n),addClassNamesToElement(o,...r);}function Uo(o=$getEditor()){return Yr.has(o)}function ha(o,e){e?(o._config.theme.tableScrollableWrapper||console.warn("TableNode: hasHorizontalScroll is active but theme.tableScrollableWrapper is not defined."),Yr.add(o)):Yr.delete(o);}function ma(o,e){let t=o.getElementByKey(e.getKey());return t===null&&O("$getElementForTableNode: Table Element Not Found"),so(e,t)}function Gh(o){let e=Fn();o.hasAttribute("data-lexical-row-striping")&&e.setRowStriping(true),o.hasAttribute("data-lexical-frozen-column")&&e.setFrozenColumns(1),o.hasAttribute("data-lexical-frozen-row")&&e.setFrozenRows(1);let t=o.querySelector(":scope > colgroup");if(t){let n=[];for(let r of t.querySelectorAll(":scope > col")){let i=r.style.width||"";if(!qr.test(i)&&(i=r.getAttribute("width")||"",!/^\d+$/.test(i))){n=void 0;break}n.push(parseFloat(i));}n&&e.setColWidths(n);}return {after:n=>$descendantsMatching(n,Q),node:e}}function Fn(){return $applyNodeReplacement(new Ue)}function ae(o){return o instanceof Ue}function Xh({rows:o,columns:e,includeHeaders:t}){let n=$getSelection()||$getPreviousSelection();if(!n||!$isRangeSelection(n)||Qe(n.anchor.getNode()))return false;let r=ta(Number(o),Number(e),t);$insertNodeToNearestRoot(r);let i=r.getFirstDescendant();return $isTextNode(i)&&i.select(),true}function Vh(o){Q(o.getParent())?o.isEmpty()&&o.append($createParagraphNode()):o.remove();}function Jh(o){ae(o.getParent())?$unwrapAndFilterDescendants(o,$):o.remove();}function qh(o){$unwrapAndFilterDescendants(o,Q);let[e]=Ze(o,null,null),t=e.reduce((r,i)=>Math.max(r,i.length),0),n=o.getChildren();for(let r=0;r<e.length;++r){let i=n[r];if(!i)continue;Q(i)||O(`TablePlugin: Expecting all children of TableNode to be TableRowNode, found ${i.constructor.name} (type ${i.getType()})`);let s=e[r].reduce((l,a)=>a?1+l:l,0);if(s!==t)for(let l=s;l<t;++l){let a=Me();a.append($createParagraphNode()),i.append(a);}}}function Zh(o){if(o.detail<3||!isDOMNode(o.target))return false;let e=$getNearestNodeFromDOMNode(o.target);if(e===null)return false;let t=$findMatchingParent(e,r=>$isElementNode(r)&&!r.isInline());if(t===null)return false;let n=t.getParent();return $(n)?(t.select(0),true):false}function ga(o){return o.registerNodeTransform(We,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){let[,,t]=ge(e),[n]=Se(t,e,e),r=n.length,i=n[0].length,s=t.getFirstChild();Q(s)||O("Expected TableNode first child to be a RowNode");let l=[];for(let a=0;a<r;a++){a!==0&&(s=s.getNextSibling(),Q(s)||O("Expected TableNode first child to be a RowNode"));let c=null;for(let d=0;d<i;d++){let u=n[a][d],h=u.cell;if(u.startRow===a&&u.startColumn===d)c=h,l.push(h);else if(h.getColSpan()>1||h.getRowSpan()>1){$(h)||O("Expected TableNode cell to be a TableCellNode");let p=Me(h.__headerState);c!==null?c.insertAfter(p):$insertFirst(s,p);}}}for(let a of l)a.setColSpan(1),a.setRowSpan(1);}})}function ba(o,e=true){let t=new Map,n=(i,s,l)=>{let a=ft(i,l),c=da(i,a,o,e);t.set(s,[c,a]);},r=o.registerMutationListener(Ue,i=>{o.getEditorState().read(()=>{for(let[s,l]of i){let a=t.get(s);if(l==="created"||l==="updated"){let{tableNode:c,tableElement:d}=oi(s);a===void 0?n(c,s,d):d!==a[1]&&(a[0].removeListeners(),t.delete(s),n(c,s,d));}else l==="destroyed"&&a!==void 0&&(a[0].removeListeners(),t.delete(s));}},{editor:o});},{skipInitialization:false});return ()=>{r();for(let[,[i]]of t)i.removeListeners();}}function Ca(o){return o.hasNodes([Ue])||O("TablePlugin: TableNode is not registered on editor"),mergeRegister(o.registerCommand(ea,Xh,COMMAND_PRIORITY_EDITOR),o.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,({nodes:e,selection:t},n)=>o!==n||!$isRangeSelection(t)?false:Qe(t.anchor.getNode())!==null&&e.some(ae),COMMAND_PRIORITY_EDITOR),o.registerCommand(CLICK_COMMAND,Zh,COMMAND_PRIORITY_EDITOR),o.registerNodeTransform(Ue,qh),o.registerNodeTransform(Mt,Jh),o.registerNodeTransform(We,Vh))}var qr,sh,te,We,ea,Mt,Zr,ah,Ll,zr,hh,gh,Ch,Sh,On,Mn,ni,_h,Eh,Th,vh,Ah,Yr,Ue,Qh,xa=rt(async()=>{await Ar();await Dr();qr=/^(\d+(?:\.\d+)?)px$/,sh=75,te={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1},We=class o extends ElementNode{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return "tablecell"}static clone(e){return new o(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign;}static importDOM(){return {td:e=>({conversion:Dl,priority:0}),th:e=>({conversion:Dl,priority:0})}}static importJSON(e){return Me().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=te.NO_STATUS,t=1,n,r){super(r),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0;}createDOM(e){let t=document.createElement(this.getTag());return this.__width&&(t.style.width=`${this.__width}px`),this.__colSpan>1&&(t.colSpan=this.__colSpan),this.__rowSpan>1&&(t.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(t.style.backgroundColor=this.__backgroundColor),Kr(this.__verticalAlign)&&(t.style.verticalAlign=this.__verticalAlign),addClassNamesToElement(t,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),t}exportDOM(e){let t=super.exportDOM(e);if(isHTMLElement(t.element)){let n=t.element;n.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),n.style.border="1px solid black",this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),n.style.width=`${this.getWidth()||sh}px`,n.style.verticalAlign=this.getVerticalAlign()||"top",n.style.textAlign="start",this.__backgroundColor===null&&this.hasHeader()&&(n.style.backgroundColor="#f2f3f5");}return t}exportJSON(){return {...super.exportJSON(),...Kr(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){let t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){let t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=te.BOTH){let n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){let t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){let t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){let t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){let 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!==te.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 true}collapseAtStart(){return true}canBeEmpty(){return false}canIndent(){return false}};ea=createCommand("INSERT_TABLE_COMMAND");Mt=class o extends ElementNode{__height;static getType(){return "tablerow"}static clone(e){return new o(e.__height,e.__key)}static importDOM(){return {tr:e=>({conversion:lh,priority:0})}}static importJSON(e){return kt().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e;}exportJSON(){let e=this.getHeight();return {...super.exportJSON(),...e===void 0?void 0:{height:e}}}createDOM(e){let t=document.createElement("tr");return this.__height&&(t.style.height=`${this.__height}px`),addClassNamesToElement(t,e.theme.tableRow),t}extractWithChild(e,t,n){return n==="html"}isShadowRoot(){return true}setHeight(e){let t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return false}canIndent(){return false}};Zr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ah=Zr&&"documentMode"in document?document.documentMode:null,Ll=Zr&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);Zr&&"InputEvent"in window&&!ah&&"getTargetRanges"in new window.InputEvent("input");zr=(o,e)=>o===te.BOTH||o===e?e:te.NO_STATUS;hh=na;gh=ra;Ch=ia;Sh=sa;On=class o{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=false,this.tableKey=e;}getStartEndPoints(){return [this.anchor,this.focus]}isValid(){if(this.tableKey==="root"||this.anchor.key==="root"||this.anchor.type!=="element"||this.focus.key==="root"||this.focus.type!=="element")return false;let e=$getNodeByKey(this.tableKey),t=$getNodeByKey(this.anchor.key),n=$getNodeByKey(this.focus.key);return e!==null&&t!==null&&n!==null}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e;}is(e){return H(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 o(this.tableKey,$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return false}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter($).forEach(i=>{let s=i.getFirstChild();$isParagraphNode(s)&&(t|=s.getTextFormat());});let r=TEXT_TYPE_TO_FORMAT[e];return (t&r)!==0}insertNodes(e){let t=this.focus.getNode();$isElementNode(t)||O("Expected TableSelection focus to be an ElementNode"),$normalizeSelection__EXPERIMENTAL(t.select(0,t.getChildrenSize())).insertNodes(e);}getShape(){let{anchorCell:e,focusCell:t}=Pl(this),n=Wr(e);n===null&&O("getCellRect: expected to find AnchorNode");let r=Wr(t);r===null&&O("getCellRect: expected to find focusCellNode");let i=Math.min(n.columnIndex,r.columnIndex),s=Math.max(n.columnIndex+n.colSpan-1,r.columnIndex+r.colSpan-1),l=Math.min(n.rowIndex,r.rowIndex),a=Math.max(n.rowIndex+n.rowSpan-1,r.rowIndex+r.rowSpan-1);return {fromX:Math.min(i,s),fromY:Math.min(l,a),toX:Math.max(i,s),toY:Math.max(l,a)}}getNodes(){if(!this.isValid())return [];let e=this._cachedNodes;if(e!==null)return e;let{anchorTable:t,anchorCell:n,focusCell:r}=Pl(this),i=r.getParents()[1];if(i!==t){if(t.isParentOf(r)){let g=i.getParent();g==null&&O("Expected focusCellParent to have a parent"),this.set(this.tableKey,r.getKey(),g.getKey());}else {let g=t.getParent();g==null&&O("Expected gridParent to have a parent"),this.set(this.tableKey,g.getKey(),r.getKey());}return this.getNodes()}let[s,l,a]=Se(t,n,r),{minColumn:c,maxColumn:d,minRow:u,maxRow:h}=$n(s,l,a),p=new Map([[t.getKey(),t]]),f=null;for(let g=u;g<=h;g++)for(let b=c;b<=d;b++){let{cell:C}=s[g][b],x=C.getParent();Q(x)||O("Expected TableCellNode parent to be a TableRowNode"),x!==f&&(p.set(x.getKey(),x),f=x),p.has(C.getKey())||Nh(C,w=>{p.set(w.getKey(),w);});}let m=Array.from(p.values());return isCurrentlyReadOnlyMode()||(this._cachedNodes=m),m}getTextContent(){let e=this.getNodes().filter(n=>$(n)),t="";for(let n=0;n<e.length;n++){let r=e[n],i=r.__parent,s=(e[n+1]||{}).__parent;t+=r.getTextContent()+(s!==i?`
|
|
8
|
-
`:" ");}return t}};Mn=class{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=false,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=false,this.isSelecting=false,this.pointerType=null,this.shouldCheckSelection=false,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable();}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear();}$lookup(){return oi(this.tableNodeKey,this.editor)}trackTable(){let e=new MutationObserver(t=>{this.editor.getEditorState().read(()=>{let n=false;for(let s=0;s<t.length;s++){let c=t[s].target.nodeName;if(c==="TABLE"||c==="TBODY"||c==="THEAD"||c==="TR"){n=true;break}}if(!n)return;let{tableNode:r,tableElement:i}=this.$lookup();this.table=so(r,i);},{editor:this.editor});});this.editor.getEditorState().read(()=>{let{tableNode:t,tableElement:n}=this.$lookup();this.table=so(t,n),e.observe(n,{attributes:true,childList:true,subtree:true});},{editor:this.editor});}$clearHighlight(){let e=this.editor;this.isHighlightingCells=false,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=false,this.$enableHighlightStyle();let{tableNode:t,tableElement:n}=this.$lookup(),r=so(t,n);En(e,r,null),$getSelection()!==null&&($setSelection(null),e.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0));}$enableHighlightStyle(){let e=this.editor,{tableElement:t}=this.$lookup();removeClassNamesFromElement(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=false;}$disableHighlightStyle(){let{tableElement:e}=this.$lookup();addClassNamesToElement(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=true;}$updateTableTableSelection(e){if(e!==null){e.tableKey!==this.tableNodeKey&&O(`TableObserver.$updateTableTableSelection: selection.tableKey !== this.tableNodeKey ('${e.tableKey}' !== '${this.tableNodeKey}')`);let t=this.editor;this.tableSelection=e,this.isHighlightingCells=true,this.$disableHighlightStyle(),this.updateDOMSelection(),En(t,this.table,this.tableSelection);}else this.$clearHighlight();}setShouldCheckSelection(){this.shouldCheckSelection=true;}getAndClearShouldCheckSelection(){return this.shouldCheckSelection?(this.shouldCheckSelection=false,true):false}setNextFocus(e){this.nextFocus=e;}getAndClearNextFocus(){let{nextFocus:e}=this;return e!==null&&(this.nextFocus=null),e}updateDOMSelection(){if(this.anchorCell!==null&&this.focusCell!==null){let e=getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges();}}$setFocusCellForSelection(e,t=false){let n=this.editor,{tableNode:r}=this.$lookup(),i=e.x,s=e.y;if(this.focusCell=e,!this.isHighlightingCells&&(this.anchorX!==i||this.anchorY!==s||t))this.isHighlightingCells=true,this.$disableHighlightStyle();else if(i===this.focusX&&s===this.focusY)return false;if(this.focusX=i,this.focusY=s,this.isHighlightingCells){let l=jr(r,e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&l!==null)return this.focusCellNodeKey=l.getKey(),this.tableSelection=ca(r,this.$getAnchorTableCellOrThrow(),l),$setSelection(this.tableSelection),n.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0),En(n,this.table,this.tableSelection),true}return false}$getAnchorTableCell(){return this.anchorCellNodeKey?$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){let e=this.$getAnchorTableCell();return e===null&&O("TableObserver anchorTableCell is null"),e}$getFocusTableCell(){return this.focusCellNodeKey?$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){let e=this.$getFocusTableCell();return e===null&&O("TableObserver focusTableCell is null"),e}$setAnchorCellForSelection(e){this.isHighlightingCells=false,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;let{tableNode:t}=this.$lookup(),n=jr(t,e.elem);if(n!==null){let r=n.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():ti(),this.anchorCellNodeKey=r;}}$formatCells(e){let t=$getSelection();H(t)||O("Expected Table selection");let n=$createRangeSelection(),r=n.anchor,i=n.focus,s=t.getNodes().filter($);s.length>0||O("No table cells present");let l=s[0].getFirstChild(),a=$isParagraphNode(l)?l.getFormatFlags(e,null):null;s.forEach(c=>{r.set(c.getKey(),0,"element"),i.set(c.getKey(),c.getChildrenSize(),"element"),n.formatText(e,a);}),$setSelection(t),this.editor.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0);}$clearText(){let{editor:e}=this,t=$getNodeByKey(this.tableNodeKey);if(!ae(t))throw new Error("Expected TableNode.");let n=$getSelection();H(n)||O("Expected TableSelection");let r=n.getNodes().filter($),i=t.getFirstChild(),s=t.getLastChild();if(r.length>0&&i!==null&&s!==null&&Q(i)&&Q(s)&&r[0]===i.getFirstChild()&&r[r.length-1]===s.getLastChild()){t.selectPrevious();let a=t.getParent();t.remove(),$isRootNode(a)&&a.isEmpty()&&e.dispatchCommand(INSERT_PARAGRAPH_COMMAND,void 0);return}r.forEach(a=>{if($isElementNode(a)){let c=$createParagraphNode(),d=$createTextNode();c.append(d),a.append(c),a.getChildren().forEach(u=>{u!==c&&u.remove();});}}),En(e,this.table,null),$setSelection(null),e.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0);}},ni="__lexicalTableSelection",_h=o=>(o.buttons&1)===1;Eh=[[KEY_ARROW_DOWN_COMMAND,"down"],[KEY_ARROW_UP_COMMAND,"up"],[KEY_ARROW_LEFT_COMMAND,"backward"],[KEY_ARROW_RIGHT_COMMAND,"forward"]],Th=[DELETE_WORD_COMMAND,DELETE_LINE_COMMAND,DELETE_CHARACTER_COMMAND],vh=[KEY_BACKSPACE_COMMAND,KEY_DELETE_COMMAND];Ah=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case "backward":case "forward":return t!==(i?o.table.columns-1:0)?Tn(e.getCellNodeFromCordsOrThrow(t+(i?1:-1),n,o.table),i):n!==(i?o.table.rows-1:0)?Tn(e.getCellNodeFromCordsOrThrow(i?0:o.table.columns-1,n+(i?1:-1),o.table),i):i?e.selectNext():e.selectPrevious(),true;case "up":return n!==0?Tn(e.getCellNodeFromCordsOrThrow(t,n-1,o.table),false):e.selectPrevious(),true;case "down":return n!==o.table.rows-1?Tn(e.getCellNodeFromCordsOrThrow(t,n+1,o.table),true):e.selectNext(),true;default:return false}};Yr=new WeakSet;Ue=class o extends ElementNode{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return "table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){let t=this.getWritable();return t.__colWidths=e!==void 0?Object.freeze(e):e,t}static clone(e){return new o(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:Gh,priority:1})}}static importJSON(e){return Fn().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||false).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=false,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 n==="html"}getDOMSlot(e){let t=no(e)?e:e.querySelector("table");return no(t)||O("TableNode.getDOMSlot: createDOM() did not return a table"),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(e,t){let n=document.createElement("table");this.__style&&(n.style.cssText=this.__style);let r=document.createElement("colgroup");if(n.appendChild(r),setDOMUnmanaged(r),addClassNamesToElement(n,e.theme.table),this.updateTableElement(null,n,e),Uo(t)){let i=document.createElement("div"),s=e.theme.tableScrollableWrapper;return s?addClassNamesToElement(i,s):i.style.cssText="overflow-x: auto;",i.appendChild(n),this.updateTableWrapper(null,i,n,e),i}return n}updateTableWrapper(e,t,n,r){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&jh(t,n,r,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&Yh(t,n,r,this.__frozenRowCount);}updateTableElement(e,t,n){this.__style!==(e?e.__style:"")&&(t.style.cssText=this.__style),this.__rowStriping!==(e?e.__rowStriping:false)&&Uh(t,n,this.__rowStriping),Wh(t,n,this.getColumnCount(),this.getColWidths()),Hl(t,n,this.getFormatType());}updateDOM(e,t,n){let i=this.getDOMSlot(t).element;return t===i===Uo()?true:(Hh(t)&&this.updateTableWrapper(e,t,i,n),this.updateTableElement(e,i,n),false)}exportDOM(e){let t=super.exportDOM(e),{element:n}=t;return {after:r=>{if(t.after&&(r=t.after(r)),!no(r)&&isHTMLElement$1(r)&&(r=r.querySelector("table")),!no(r))return null;Hl(r,e._config,this.getFormatType());let[i]=Ze(this,null,null),s=new Map;for(let d of i)for(let u of d){let h=u.cell.getKey();s.has(h)||s.set(h,{colSpan:u.cell.getColSpan(),startColumn:u.startColumn});}let l=new Set;for(let d of r.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){let u=d.getAttribute("data-temporary-table-cell-lexical-key");if(u){let h=s.get(u);if(d.removeAttribute("data-temporary-table-cell-lexical-key"),h){s.delete(u);for(let p=0;p<h.colSpan;p++)l.add(p+h.startColumn);}}}let a=r.querySelector(":scope > colgroup");if(a){let d=Array.from(r.querySelectorAll(":scope > colgroup > col")).filter((u,h)=>l.has(h));a.replaceChildren(...d);}let c=r.querySelectorAll(":scope > tr");if(c.length>0){let d=document.createElement("tbody");for(let u of c)d.appendChild(u);r.append(d);}return r},element:!no(n)&&isHTMLElement$1(n)?n.querySelector("table"):n}}canBeEmpty(){return false}isShadowRoot(){return true}getCordsFromCellNode(e,t){let{rows:n,domRows:r}=t;for(let i=0;i<n;i++){let s=r[i];if(s!=null)for(let l=0;l<s.length;l++){let a=s[l];if(a==null)continue;let{elem:c}=a,d=jr(this,c);if(d!==null&&e.is(d))return {x:l,y:i}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){let{domRows:r}=n,i=r[t];if(i==null)return null;let s=e<i.length?e:i.length-1,l=i[s];return l??null}getDOMCellFromCordsOrThrow(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(!r)throw new Error("Cell not found at cords.");return r}getCellNodeFromCords(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(r==null)return null;let i=$getNearestNodeFromDOMNode(r.elem);return $(i)?i:null}getCellNodeFromCordsOrThrow(e,t,n){let r=this.getCellNodeFromCords(e,t,n);if(!r)throw new Error("Node at cords not TableCellNode.");return r}getRowStriping(){return !!this.getLatest().__rowStriping}setRowStriping(e){let t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){let t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){let t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return true}canIndent(){return false}getColumnCount(){let e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach(n=>{$(n)&&(t+=n.getColSpan());}),t}};Qh=defineExtension({build(o,e,t){return Sn(e)},config:safeCast({hasCellBackgroundColor:true,hasCellMerge:true,hasHorizontalScroll:true,hasTabHandler:true}),name:"@lexical/table/Table",nodes:[Ue,Mt,We],register(o,e,t){let n=t.getOutput();return mergeRegister(Ke(()=>{let r=n.hasHorizontalScroll.value;Uo(o)!==r&&(ha(o,r),o.registerNodeTransform(Ue,()=>{})());}),Ca(o),Ke(()=>ba(o,n.hasTabHandler.value)),Ke(()=>n.hasCellMerge.value?void 0:ga(o)),Ke(()=>n.hasCellBackgroundColor.value?void 0:o.registerNodeTransform(We,r=>{r.getBackgroundColor()!==null&&r.setBackgroundColor(null);})))}});});var lc={};jt(lc,{$computeTableMap:()=>ye,$computeTableMapSkipCellCheck:()=>tt,$createTableCellNode:()=>ke,$createTableNode:()=>jn,$createTableNodeWithDimensions:()=>Wa,$createTableRowNode:()=>Lt,$createTableSelection:()=>Ri,$createTableSelectionFrom:()=>qa,$deleteTableColumn:()=>Ym,$deleteTableColumnAtSelection:()=>Xa,$deleteTableColumn__EXPERIMENTAL:()=>Xm,$deleteTableRowAtSelection:()=>Ga,$deleteTableRow__EXPERIMENTAL:()=>Gm,$findCellNode:()=>fo,$findTableNode:()=>Ft,$getElementForTableNode:()=>nc,$getNodeTriplet:()=>be,$getTableAndElementByKey:()=>Oi,$getTableCellNodeFromLexicalNode:()=>Im,$getTableCellNodeRect:()=>mi,$getTableColumnIndexFromTableCellNode:()=>zm,$getTableNodeFromLexicalNodeOrThrow:()=>Un,$getTableRowIndexFromTableCellNode:()=>Km,$getTableRowNodeFromTableCellNodeOrThrow:()=>Ti,$insertTableColumn:()=>Um,$insertTableColumnAtSelection:()=>Ya,$insertTableColumn__EXPERIMENTAL:()=>jm,$insertTableRow:()=>Hm,$insertTableRowAtSelection:()=>ja,$insertTableRow__EXPERIMENTAL:()=>Wm,$isScrollableTablesActive:()=>Vo,$isTableCellNode:()=>F,$isTableNode:()=>de,$isTableRowNode:()=>ee,$isTableSelection:()=>U,$mergeCells:()=>Va,$removeTableRowAtIndex:()=>Bm,$unmergeCell:()=>Jm,INSERT_TABLE_COMMAND:()=>Ha,TableCellHeaderStates:()=>oe,TableCellNode:()=>Ge,TableExtension:()=>dg,TableNode:()=>Xe,TableObserver:()=>Hn,TableRowNode:()=>Dt,applyTableHandlers:()=>Za,getDOMCellFromTarget:()=>Xo,getTableElement:()=>mt,getTableObserverFromTableElement:()=>bi,registerTableCellUnmergeTransform:()=>rc,registerTablePlugin:()=>sc,registerTableSelectionObserver:()=>ic,setScrollableTablesActive:()=>oc});function ui(o){return o==="middle"||o==="bottom"}function Ta(o){let e=o,t=o.nodeName.toLowerCase(),n;_i.test(e.style.width)&&(n=parseFloat(e.style.width));let r=ke(t==="th"?oe.ROW:oe.NO_STATUS,e.colSpan,n);r.__rowSpan=e.rowSpan;let i=e.style.backgroundColor;i!==""&&(r.__backgroundColor=i);let s=e.style.verticalAlign;ui(s)&&(r.__verticalAlign=s);let l=e.style,a=(l&&l.textDecoration||"").split(" "),c=l.fontWeight==="700"||l.fontWeight==="bold",d=a.includes("line-through"),u=l.fontStyle==="italic",h=a.includes("underline");return {after:p=>{let f=[],m=null,g=()=>{if(m){let b=m.getFirstChild();$isLineBreakNode(b)&&m.getChildrenSize()===1&&b.remove();}};for(let b of p)$isInlineElementOrDecoratorNode(b)||$isTextNode(b)||$isLineBreakNode(b)?($isTextNode(b)&&(c&&b.toggleFormat("bold"),d&&b.toggleFormat("strikethrough"),u&&b.toggleFormat("italic"),h&&b.toggleFormat("underline")),m?m.append(b):(m=$createParagraphNode().append(b),f.push(m))):(f.push(b),g(),m=null);return g(),f.length===0&&f.push($createParagraphNode()),f},node:r}}function ke(o=oe.NO_STATUS,e=1,t){return $applyNodeReplacement(new Ge(o,e,t))}function F(o){return o instanceof Ge}function A(o,...e){let t=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",o);for(let r of e)n.append("v",r);throw t.search=n.toString(),Error(`Minified Lexical error #${o}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Lm(o){let e=o,t;return _i.test(e.style.height)&&(t=parseFloat(e.style.height)),{after:n=>$descendantsMatching(n,F),node:Lt(t)}}function Lt(o){return $applyNodeReplacement(new Dt(o))}function ee(o){return o instanceof Dt}function Wa(o,e,t=true){let n=jn();for(let r=0;r<o;r++){let i=Lt();for(let s=0;s<e;s++){let l=oe.NO_STATUS;typeof t=="object"?(r===0&&t.rows&&(l|=oe.ROW),s===0&&t.columns&&(l|=oe.COLUMN)):t&&(r===0&&(l|=oe.ROW),s===0&&(l|=oe.COLUMN));let a=ke(l),c=$createParagraphNode();c.append($createTextNode()),a.append(c),i.append(a);}n.append(i);}return n}function Im(o){let e=$findMatchingParent(o,t=>F(t));return F(e)?e:null}function Ti(o){let e=$findMatchingParent(o,t=>ee(t));if(ee(e))return e;throw new Error("Expected table cell to be inside of table row.")}function Un(o){let e=$findMatchingParent(o,t=>de(t));if(de(e))return e;throw new Error("Expected table cell to be inside of table.")}function Km(o){let e=Ti(o);return Un(e).getChildren().findIndex(t=>t.is(e))}function zm(o){return Ti(o).getChildren().findIndex(e=>e.is(o))}function Ua(o,e){let t=Un(o),{x:n,y:r}=t.getCordsFromCellNode(o,e);return {above:t.getCellNodeFromCords(n,r-1,e),below:t.getCellNodeFromCords(n,r+1,e),left:t.getCellNodeFromCords(n-1,r,e),right:t.getCellNodeFromCords(n+1,r,e)}}function Bm(o,e){let t=o.getChildren();if(e>=t.length||e<0)throw new Error("Expected table cell to be inside of table row.");return t[e].remove(),o}function Hm(o,e,t=true,n,r){let i=o.getChildren();if(e>=i.length||e<0)throw new Error("Table row target index out of range");let s=i[e];if(!ee(s))throw new Error("Row before insertion index does not exist.");for(let l=0;l<n;l++){let a=s.getChildren(),c=a.length,d=Lt();for(let u=0;u<c;u++){let h=a[u];F(h)||A(12);let{above:p,below:f}=Ua(h,r),m=oe.NO_STATUS,g=p&&p.getWidth()||f&&f.getWidth()||void 0;(p&&p.hasHeaderState(oe.COLUMN)||f&&f.hasHeaderState(oe.COLUMN))&&(m|=oe.COLUMN);let b=ke(m,1,g);b.append($createParagraphNode()),d.append(b);}t?s.insertAfter(d):s.insertBefore(d);}return o}function ja(o=true){let e=$getSelection();$isRangeSelection(e)||U(e)||A(188);let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=be(t),[i,,s]=be(n),[,l,a]=ye(s,i,r),{startRow:c}=a,{startRow:d}=l;return o?pi(c+r.__rowSpan>d+i.__rowSpan?r:i,true):pi(d<c?i:r,false)}function pi(o,e=true){let[,,t]=be(o),[n,r]=ye(t,o,o),i=n[0].length,{startRow:s}=r,l=null;if(e){let a=s+o.__rowSpan-1,c=n[a],d=Lt();for(let h=0;h<i;h++){let{cell:p,startRow:f}=c[h];if(f+p.__rowSpan-1<=a){let m=c[h].cell.__headerState,g=fi(m,oe.COLUMN);d.append(ke(g).append($createParagraphNode()));}else p.setRowSpan(p.__rowSpan+1);}let u=t.getChildAtIndex(a);ee(u)||A(256),u.insertAfter(d),l=d;}else {let a=s,c=n[a],d=Lt();for(let h=0;h<i;h++){let{cell:p,startRow:f}=c[h];if(f===a){let m=c[h].cell.__headerState,g=fi(m,oe.COLUMN);d.append(ke(g).append($createParagraphNode()));}else p.setRowSpan(p.__rowSpan+1);}let u=t.getChildAtIndex(a);ee(u)||A(257),u.insertBefore(d),l=d;}return l}function Um(o,e,t=true,n,r){let i=o.getChildren(),s=[];for(let l=0;l<i.length;l++){let a=i[l];if(ee(a))for(let c=0;c<n;c++){let d=a.getChildren();if(e>=d.length||e<0)throw new Error("Table column target index out of range");let u=d[e];F(u)||A(12);let{left:h,right:p}=Ua(u,r),f=oe.NO_STATUS;(h&&h.hasHeaderState(oe.ROW)||p&&p.hasHeaderState(oe.ROW))&&(f|=oe.ROW);let m=ke(f);m.append($createParagraphNode()),s.push({newTableCell:m,targetCell:u});}}return s.forEach(({newTableCell:l,targetCell:a})=>{t?a.insertAfter(l):a.insertBefore(l);}),o}function Ya(o=true){let e=$getSelection();$isRangeSelection(e)||U(e)||A(188);let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=be(t),[i,,s]=be(n),[,l,a]=ye(s,i,r),{startColumn:c}=a,{startColumn:d}=l;return o?hi(c+r.__colSpan>d+i.__colSpan?r:i,true):hi(d<c?i:r,false)}function hi(o,e=true,t=true){let[,,n]=be(o),[r,i]=ye(n,o,o),s=r.length,{startColumn:l}=i,a=e?l+o.__colSpan-1:l-1,c=n.getFirstChild();ee(c)||A(120);let d=null;function u(f=oe.NO_STATUS){let m=ke(f).append($createParagraphNode());return d===null&&(d=m),m}let h=c;e:for(let f=0;f<s;f++){if(f!==0){let S=h.getNextSibling();ee(S)||A(121),h=S;}let m=r[f],g=m[a<0?0:a].cell.__headerState,b=fi(g,oe.ROW);if(a<0){vi(h,u(b));continue}let{cell:C,startColumn:x,startRow:w}=m[a];if(x+C.__colSpan-1<=a){let S=C,y=w,N=a;for(;y!==f&&S.__rowSpan>1;){if(N-=C.__colSpan,!(N>=0)){h.append(u(b));continue e}{let{cell:E,startRow:R}=m[N];S=E,y=R;}}S.insertAfter(u(b));}else C.setColSpan(C.__colSpan+1);}d!==null&&t&&Go(d);let p=n.getColWidths();if(p){let f=[...p],m=a<0?0:a,g=f[m];f.splice(m,0,g),n.setColWidths(f);}return d}function Ym(o,e){let t=o.getChildren();for(let n=0;n<t.length;n++){let r=t[n];if(ee(r)){let i=r.getChildren();if(e>=i.length||e<0)throw new Error("Table column target index out of range");i[e].remove();}}return o}function Ga(){let o=$getSelection();$isRangeSelection(o)||U(o)||A(188);let[e,t]=o.isBackward()?[o.focus.getNode(),o.anchor.getNode()]:[o.anchor.getNode(),o.focus.getNode()],[n,,r]=be(e),[i]=be(t),[s,l,a]=ye(r,n,i),{startRow:c}=l,{startRow:d}=a,u=d+i.__rowSpan-1;if(s.length===u-c+1)return void r.remove();let h=s[0].length,p=s[u+1],f=r.getChildAtIndex(u+1);for(let m=u;m>=c;m--){for(let b=h-1;b>=0;b--){let{cell:C,startRow:x,startColumn:w}=s[m][b];if(w===b){if(x<c||x+C.__rowSpan-1>u){let S=Math.max(x,c),y=Math.min(C.__rowSpan+x-1,u),N=S<=y?y-S+1:0;C.setRowSpan(C.__rowSpan-N);}if(x>=c&&x+C.__rowSpan-1>u&&m===u){f===null&&A(122);let S=null;for(let y=0;y<b;y++){let N=p[y],E=N.cell;N.startRow===m+1&&(S=E),E.__colSpan>1&&(y+=E.__colSpan-1);}S===null?vi(f,C):S.insertAfter(C);}}}let g=r.getChildAtIndex(m);ee(g)||A(206,String(m)),g.remove();}if(p!==void 0){let{cell:m}=p[0];Go(m);}else {let m=s[c-1],{cell:g}=m[0];Go(g);}}function Xa(){let o=$getSelection();$isRangeSelection(o)||U(o)||A(188);let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=be(e),[i]=be(t),[s,l,a]=ye(r,n,i),{startColumn:c}=l,{startRow:d,startColumn:u}=a,h=Math.min(c,u),p=Math.max(c+n.__colSpan-1,u+i.__colSpan-1),f=p-h+1;if(s[0].length===p-h+1)return r.selectPrevious(),void r.remove();let m=s.length;for(let x=0;x<m;x++)for(let w=h;w<=p;w++){let{cell:S,startColumn:y}=s[x][w];if(y<h){if(w===h){let N=h-y;S.setColSpan(S.__colSpan-Math.min(f,S.__colSpan-N));}}else if(y+S.__colSpan-1>p){if(w===p){let N=p-y+1;S.setColSpan(S.__colSpan-N);}}else S.remove();}let g=s[d],b=c>u?g[c+n.__colSpan]:g[u+i.__colSpan];if(b!==void 0){let{cell:x}=b;Go(x);}else {let x=u<c?g[u-1]:g[c-1],{cell:w}=x;Go(w);}let C=r.getColWidths();if(C){let x=[...C];x.splice(h,f),r.setColWidths(x);}}function Go(o){let e=o.getFirstDescendant();e==null?o.selectStart():e.getParentOrThrow().selectStart();}function vi(o,e){let t=o.getFirstChild();t!==null?t.insertBefore(e):o.append(e);}function Va(o){if(o.length===0)return null;let e=Un(o[0]),[t]=tt(e,null,null),n=1/0,r=-1/0,i=1/0,s=-1/0,l=new Set;for(let p of t)for(let f of p){if(!f||!f.cell)continue;let m=f.cell.getKey();if(!l.has(m)&&o.some(g=>g.is(f.cell))){l.add(m);let g=f.startRow,b=f.startColumn,C=f.cell.__rowSpan||1,x=f.cell.__colSpan||1;n=Math.min(n,g),r=Math.max(r,g+C-1),i=Math.min(i,b),s=Math.max(s,b+x-1);}}if(n===1/0||i===1/0)return null;let a=r-n+1,c=s-i+1,d=t[n][i];if(!d.cell)return null;let u=d.cell;u.setColSpan(c),u.setRowSpan(a);let h=new Set([u.getKey()]);for(let p=n;p<=r;p++)for(let f=i;f<=s;f++){let m=t[p][f];if(!m.cell)continue;let g=m.cell,b=g.getKey();h.has(b)||(h.add(b),Vm(g)||u.append(...g.getChildren()),g.remove());}return u.getChildrenSize()===0&&u.append($createParagraphNode()),u}function Vm(o){if(o.getChildrenSize()!==1)return false;let e=o.getFirstChildOrThrow();return !(!$isParagraphNode(e)||!e.isEmpty())}function Jm(){let o=$getSelection();$isRangeSelection(o)||U(o)||A(188);let e=o.anchor.getNode(),t=$findMatchingParent(e,F);return F(t)||A(148),Ja(t)}function Ja(o){let[e,t,n]=be(o),r=e.__colSpan,i=e.__rowSpan;if(r===1&&i===1)return;let[s,l]=ye(n,e,e),{startColumn:a,startRow:c}=l,d=e.__headerState&oe.COLUMN,u=Array.from({length:r},(f,m)=>{let g=d;for(let b=0;g!==0&&b<s.length;b++)g&=s[b][m+a].cell.__headerState;return g}),h=e.__headerState&oe.ROW,p=Array.from({length:i},(f,m)=>{let g=h;for(let b=0;g!==0&&b<s[0].length;b++)g&=s[m+c][b].cell.__headerState;return g});if(r>1){for(let f=1;f<r;f++)e.insertAfter(ke(u[f]|p[0]).append($createParagraphNode()));e.setColSpan(1);}if(i>1){let f;for(let m=1;m<i;m++){let g=c+m,b=s[g];f=(f||t).getNextSibling(),ee(f)||A(125);let C=null;for(let x=0;x<a;x++){let w=b[x],S=w.cell;w.startRow===g&&(C=S),S.__colSpan>1&&(x+=S.__colSpan-1);}if(C===null)for(let x=r-1;x>=0;x--)vi(f,ke(u[x]|p[m]).append($createParagraphNode()));else for(let x=r-1;x>=0;x--)C.insertAfter(ke(u[x]|p[m]).append($createParagraphNode()));}e.setRowSpan(1);}}function ye(o,e,t){let[n,r,i]=tt(o,e,t);return r===null&&A(207),i===null&&A(208),[n,r,i]}function tt(o,e,t){let n=[],r=null,i=null;function s(a){let c=n[a];return c===void 0&&(n[a]=c=[]),c}let l=o.getChildren();for(let a=0;a<l.length;a++){let c=l[a];ee(c)||A(209);let d=s(a);for(let u=c.getFirstChild(),h=0;u!=null;u=u.getNextSibling()){for(F(u)||A(147);d[h]!==void 0;)h++;let p={cell:u,startColumn:h,startRow:a},{__rowSpan:f,__colSpan:m}=u;for(let g=0;g<f&&!(a+g>=l.length);g++){let b=s(a+g);for(let C=0;C<m;C++)b[h+C]=p;}e!==null&&r===null&&e.is(u)&&(r=p),t!==null&&i===null&&t.is(u)&&(i=p);}}return [n,r,i]}function be(o){let e;if(o instanceof Ge)e=o;else if("__type"in o){let r=$findMatchingParent(o,F);F(r)||A(148),e=r;}else {let r=$findMatchingParent(o.getNode(),F);F(r)||A(148),e=r;}let t=e.getParent();ee(t)||A(149);let n=t.getParent();return de(n)||A(210),[e,t,n]}function zn(o,e,t){let n,r=Math.min(e.startColumn,t.startColumn),i=Math.min(e.startRow,t.startRow),s=Math.max(e.startColumn+e.cell.__colSpan-1,t.startColumn+t.cell.__colSpan-1),l=Math.max(e.startRow+e.cell.__rowSpan-1,t.startRow+t.cell.__rowSpan-1);do{n=false;for(let a=0;a<o.length;a++)for(let c=0;c<o[0].length;c++){let d=o[a][c];if(!d)continue;let u=d.startColumn+d.cell.__colSpan-1,h=d.startRow+d.cell.__rowSpan-1,p=d.startColumn<=s&&u>=r,f=d.startRow<=l&&h>=i;if(p&&f){let m=Math.min(r,d.startColumn),g=Math.max(s,u),b=Math.min(i,d.startRow),C=Math.max(l,h);m===r&&g===s&&b===i&&C===l||(r=m,s=g,i=b,l=C,n=true);}}}while(n);return {maxColumn:s,maxRow:l,minColumn:r,minRow:i}}function mi(o){let[e,,t]=be(o),n=t.getChildren(),r=n.length,i=n[0].getChildren().length,s=new Array(r);for(let l=0;l<r;l++)s[l]=new Array(i);for(let l=0;l<r;l++){let a=n[l].getChildren(),c=0;for(let d=0;d<a.length;d++){for(;s[l][c];)c++;let u=a[d],h=u.__rowSpan||1,p=u.__colSpan||1;for(let f=0;f<h;f++)for(let m=0;m<p;m++)s[l+f][c+m]=u;if(e===u)return {colSpan:p,columnIndex:c,rowIndex:l,rowSpan:h};c+=p;}}return null}function Ra(o){let[[e,t,n,r],[i,s,l,a]]=["anchor","focus"].map(c=>{let d=o[c].getNode(),u=$findMatchingParent(d,F);F(u)||A(238,c,d.getKey(),d.getType());let h=u.getParent();ee(h)||A(239,c);let p=h.getParent();return de(p)||A(240,c),[d,u,h,p]});return r.is(a)||A(241),{anchorCell:t,anchorNode:e,anchorRow:n,anchorTable:r,focusCell:s,focusNode:i,focusRow:l,focusTable:a}}function U(o){return o instanceof Bn}function Ri(){let o=$createPoint("root",0,"element"),e=$createPoint("root",0,"element");return new Bn("root",o,e)}function qa(o,e,t){o.getKey(),e.getKey(),t.getKey();let n=$getSelection(),r=U(n)?n.clone():Ri();return r.set(o.getKey(),e.getKey(),t.getKey()),r}function qm(o,e){let t=[[o]];for(let n=t.at(-1);n!==void 0&&t.length>0;n=t.at(-1)){let r=n.pop();r===void 0?t.pop():e(r)!==false&&$isElementNode(r)&&t.push(r.getChildren());}}function Oi(o,e=$getEditor()){let t=$getNodeByKey(o);de(t)||A(231,o);let n=mt(t,e.getElementByKey(o));return n===null&&A(232,o),{tableElement:n,tableNode:t}}function uo(o){return isHTMLElement(o)&&o.nodeName==="TABLE"}function mt(o,e){if(!e)return e;let t=uo(e)?e:o.getDOMSlot(e).element;return t.nodeName!=="TABLE"&&A(245,e.nodeName),t}function Mi(o){return o._window}function Yo(o,e){for(let t=e,n=null;t!==null;t=t.getParent()){if(o.is(t))return n;F(t)&&(n=t);}return null}function Za(o,e,t,n){let r=t.getRootElement(),i=Mi(t);r!==null&&i!==null||A(246);let s=new Hn(t,o.getKey()),l=mt(o,e);((function(p,f){bi(p)!==null&&A(205),p[gi]=f;}))(l,s),s.listenersToRemove.add(()=>(function(p,f){bi(p)===f&&delete p[gi];})(l,s));let a=p=>{if(s.pointerType=p.pointerType,p.button!==0||!isDOMNode(p.target)||!i)return;let f=Xo(p.target);f!==null&&t.update(()=>{let m=$getPreviousSelection();if(va&&p.shiftKey&&je(m,o)&&($isRangeSelection(m)||U(m))){let g=m.anchor.getNode(),b=Yo(o,m.anchor.getNode());b?(s.$setAnchorCellForSelection(At(s,b)),s.$setFocusCellForSelection(f),et(p)):(o.isBefore(g)?o.selectStart():o.selectEnd()).anchor.set(m.anchor.key,m.anchor.offset,m.anchor.type);}else p.pointerType!=="touch"&&s.$setAnchorCellForSelection(f);}),(()=>{if(s.isSelecting)return;let m=()=>{s.isSelecting=false,i.removeEventListener("pointerup",m),i.removeEventListener("pointermove",g);},g=b=>{if(1&~b.buttons&&s.isSelecting)return s.isSelecting=false,i.removeEventListener("pointerup",m),void i.removeEventListener("pointermove",g);if(!isDOMNode(b.target))return;let C=null,x=!(va||l.contains(b.target));if(x)C=Oa(l,b.target);else for(let w of document.elementsFromPoint(b.clientX,b.clientY))if(C=Oa(l,w),C)break;!C||s.focusCell!==null&&C.elem===s.focusCell.elem||(s.setNextFocus({focusCell:C,override:x}),t.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0));};s.isSelecting=true,i.addEventListener("pointerup",m,s.listenerOptions),i.addEventListener("pointermove",g,s.listenerOptions);})();};l.addEventListener("pointerdown",a,s.listenerOptions),s.listenersToRemove.add(()=>{l.removeEventListener("pointerdown",a);});let c=p=>{p.detail>=3&&isDOMNode(p.target)&&Xo(p.target)!==null&&p.preventDefault();};l.addEventListener("mousedown",c,s.listenerOptions),s.listenersToRemove.add(()=>{l.removeEventListener("mousedown",c);});let d=p=>{let f=p.target;p.button===0&&isDOMNode(f)&&t.update(()=>{let m=$getSelection();U(m)&&m.tableKey===s.tableNodeKey&&r.contains(f)&&s.$clearHighlight();});};i.addEventListener("pointerdown",d,s.listenerOptions),s.listenersToRemove.add(()=>{i.removeEventListener("pointerdown",d);});for(let[p,f]of Zm)s.listenersToRemove.add(t.registerCommand(p,m=>tc(t,m,f,o,s),COMMAND_PRIORITY_HIGH));s.listenersToRemove.add(t.registerCommand(KEY_ESCAPE_COMMAND,p=>{let f=$getSelection();if(U(f)){let m=Yo(o,f.focus.getNode());if(m!==null)return et(p),m.selectEnd(),true}return false},COMMAND_PRIORITY_HIGH));let u=p=>()=>{let f=$getSelection();if(!je(f,o))return false;if(U(f))return s.$clearText(),true;if($isRangeSelection(f)){if(!F(Yo(o,f.anchor.getNode())))return false;let m=f.anchor.getNode(),g=f.focus.getNode(),b=o.isParentOf(m),C=o.isParentOf(g);if(b&&!C||C&&!b)return s.$clearText(),true;let x=$findMatchingParent(f.anchor.getNode(),S=>$isElementNode(S)),w=x&&$findMatchingParent(x,S=>$isElementNode(S)&&F(S.getParent()));if(!$isElementNode(w)||!$isElementNode(x))return false;if(p===DELETE_LINE_COMMAND&&w.getPreviousSibling()===null)return true}return false};for(let p of Qm)s.listenersToRemove.add(t.registerCommand(p,u(p),COMMAND_PRIORITY_HIGH));let h=p=>{let f=$getSelection();if(!U(f)&&!$isRangeSelection(f))return false;let m=o.isParentOf(f.anchor.getNode());if(m!==o.isParentOf(f.focus.getNode())){let g=m?"anchor":"focus",b=m?"focus":"anchor",{key:C,offset:x,type:w}=f[b];return o[f[g].isBefore(f[b])?"selectPrevious":"selectNext"]()[b].set(C,x,w),false}return !!je(f,o)&&!!U(f)&&(p&&(p.preventDefault(),p.stopPropagation()),s.$clearText(),true)};for(let p of eg)s.listenersToRemove.add(t.registerCommand(p,h,COMMAND_PRIORITY_HIGH));return s.listenersToRemove.add(t.registerCommand(CUT_COMMAND,p=>{let f=$getSelection();if(f){if(!U(f)&&!$isRangeSelection(f))return false;Nn(t,objectKlassEquals(p,ClipboardEvent)?p:null,wn(f));let m=h(p);return $isRangeSelection(f)?(f.removeText(),true):m}return false},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FORMAT_TEXT_COMMAND,p=>{let f=$getSelection();if(!je(f,o))return false;if(U(f))return s.$formatCells(p),true;if($isRangeSelection(f)){let m=$findMatchingParent(f.anchor.getNode(),g=>F(g));if(!F(m))return false}return false},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FORMAT_ELEMENT_COMMAND,p=>{let f=$getSelection();if(!U(f)||!je(f,o))return false;let m=f.anchor.getNode(),g=f.focus.getNode();if(!F(m)||!F(g))return false;if((function(R,L){if(U(R)){let k=R.anchor.getNode(),M=R.focus.getNode();if(L&&k&&M){let[v]=ye(L,k,M);return k.getKey()===v[0][0].cell.getKey()&&M.getKey()===v[v.length-1].at(-1).cell.getKey()}}return false})(f,o))return o.setFormat(p),true;let[b,C,x]=ye(o,m,g),w=Math.max(C.startRow+C.cell.__rowSpan-1,x.startRow+x.cell.__rowSpan-1),S=Math.max(C.startColumn+C.cell.__colSpan-1,x.startColumn+x.cell.__colSpan-1),y=Math.min(C.startRow,x.startRow),N=Math.min(C.startColumn,x.startColumn),E=new Set;for(let R=y;R<=w;R++)for(let L=N;L<=S;L++){let k=b[R][L].cell;if(E.has(k))continue;E.add(k),k.setFormat(p);let M=k.getChildren();for(let v=0;v<M.length;v++){let T=M[v];$isElementNode(T)&&!T.isInline()&&T.setFormat(p);}}return true},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND,p=>{let f=$getSelection();if(!je(f,o))return false;if(U(f))return s.$clearHighlight(),false;if($isRangeSelection(f)){let m=$findMatchingParent(f.anchor.getNode(),g=>F(g));if(!F(m))return false;if(typeof p=="string"){let g=Aa(t,f,o);if(g)return ka(g,o,[$createTextNode(p)]),true}}return false},COMMAND_PRIORITY_HIGH)),n&&s.listenersToRemove.add(t.registerCommand(KEY_TAB_COMMAND,p=>{let f=$getSelection();if(!$isRangeSelection(f)||!f.isCollapsed()||!je(f,o))return false;let m=fo(f.anchor.getNode());return !(m===null||!o.is(Ft(m)))&&(et(p),(function(g,b){let C=b==="next"?"getNextSibling":"getPreviousSibling",x=b==="next"?"getFirstChild":"getLastChild",w=g[C]();if($isElementNode(w))return w.selectEnd();let S=$findMatchingParent(g,ee);S===null&&A(247);for(let N=S[C]();ee(N);N=N[C]()){let E=N[x]();if($isElementNode(E))return E.selectEnd()}let y=$findMatchingParent(S,de);y===null&&A(248),b==="next"?y.selectNext():y.selectPrevious();})(m,p.shiftKey?"previous":"next"),true)},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FOCUS_COMMAND,p=>o.isSelected(),COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(p,f)=>{if(t!==f)return false;let{nodes:m,selection:g}=p,b=g.getStartEndPoints(),C=U(g),x=$isRangeSelection(g)&&$findMatchingParent(g.anchor.getNode(),z=>F(z))!==null&&$findMatchingParent(g.focus.getNode(),z=>F(z))!==null||C;if(m.length!==1||!de(m[0])||!x||b===null)return false;let[w,S]=b,[y,N,E]=be(w),R=$findMatchingParent(S.getNode(),z=>F(z));if(!(F(y)&&F(R)&&ee(N)&&de(E)))return false;let L=m[0],[k,M,v]=ye(E,y,R),[T]=tt(L,null,null),K=k.length,V=K>0?k[0].length:0,ie=M.startRow,re=M.startColumn,se=T.length,Ce=se>0?T[0].length:0;if(C){let z=zn(k,M,v),Re=z.maxRow-z.minRow+1,P=z.maxColumn-z.minColumn+1;ie=z.minRow,re=z.minColumn,se=Math.min(se,Re),Ce=Math.min(Ce,P);}let ve=false,Le=Math.min(K,ie+se)-1,Ae=Math.min(V,re+Ce)-1,on=new Set;for(let z=ie;z<=Le;z++)for(let Re=re;Re<=Ae;Re++){let P=k[z][Re];on.has(P.cell.getKey())||P.cell.__rowSpan===1&&P.cell.__colSpan===1||(Ja(P.cell),on.add(P.cell.getKey()),ve=true);}let[Ct]=tt(E.getWritable(),null,null),nn=se-K+ie;for(let z=0;z<nn;z++)pi(Ct[K-1][0].cell);let St=Ce-V+re;for(let z=0;z<St;z++)hi(Ct[0][V-1].cell,true,false);[Ct]=tt(E.getWritable(),null,null);for(let z=ie;z<ie+se;z++)for(let Re=re;Re<re+Ce;Re++){let P=z-ie,he=Re-re,Oe=T[P][he];if(Oe.startRow!==P||Oe.startColumn!==he)continue;let nt=Oe.cell;if(nt.__rowSpan!==1||nt.__colSpan!==1){let $e=[],sr=Math.min(z+nt.__rowSpan,ie+se)-1,Ie=Math.min(Re+nt.__colSpan,re+Ce)-1;for(let Ut=z;Ut<=sr;Ut++)for(let No=Re;No<=Ie;No++){let _o=Ct[Ut][No];$e.push(_o.cell);}Va($e),ve=true;}let{cell:xt}=Ct[z][Re],yt=xt.getChildren();nt.getChildren().forEach($e=>{$isTextNode($e)&&$createParagraphNode().append($e),xt.append($e);}),yt.forEach($e=>$e.remove());}if(C&&ve){let[z]=tt(E.getWritable(),null,null);z[M.startRow][M.startColumn].cell.selectEnd();}return true},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(SELECTION_CHANGE_COMMAND,()=>{let p=$getSelection(),f=$getPreviousSelection(),m=s.getAndClearNextFocus();if(m!==null){let{focusCell:g}=m;if(U(p)&&p.tableKey===s.tableNodeKey)return (g.x!==s.focusX||g.y!==s.focusY)&&(s.$setFocusCellForSelection(g),true);if(g!==s.anchorCell&&je(p,o))return s.$setFocusCellForSelection(g),true}if(s.getAndClearShouldCheckSelection()&&$isRangeSelection(f)&&$isRangeSelection(p)&&p.isCollapsed()){let g=p.anchor.getNode(),b=o.getFirstChild(),C=fo(g);if(C!==null&&ee(b)){let x=b.getFirstChild();if(F(x)&&o.is($findMatchingParent(C,w=>w.is(o)||w.is(x))))return x.selectStart(),true}}if($isRangeSelection(p)){let{anchor:g,focus:b}=p,C=g.getNode(),x=b.getNode(),w=fo(C),S=fo(x),y=!(!w||!o.is(Ft(w))),N=!(!S||!o.is(Ft(S))),E=y!==N,R=y&&N,L=p.isBackward();if(E){let k=p.clone();if(N){let[M]=ye(o,S,S),v=M[0][0].cell,T=M[M.length-1].at(-1).cell;k.focus.set(L?v.getKey():T.getKey(),L?v.getChildrenSize():T.getChildrenSize(),"element");}else if(y){let[M]=ye(o,w,w),v=M[0][0].cell,T=M[M.length-1].at(-1).cell;k.anchor.set(L?T.getKey():v.getKey(),L?T.getChildrenSize():0,"element");}$setSelection(k),Ma(t,s);}else if(R&&(w.is(S)||(s.$setAnchorCellForSelection(At(s,w)),s.$setFocusCellForSelection(At(s,S),true)),s.pointerType==="touch"&&s.isSelecting&&p.isCollapsed()&&$isRangeSelection(f)&&f.isCollapsed())){let k=fo(f.anchor.getNode());k&&!k.is(S)&&(s.$setAnchorCellForSelection(At(s,k)),s.$setFocusCellForSelection(At(s,S),true),s.pointerType=null);}}else if(p&&U(p)&&p.is(f)&&p.tableKey===o.getKey()){let g=getDOMSelection(i);if(g&&g.anchorNode&&g.focusNode){let b=$getNearestNodeFromDOMNode(g.focusNode),C=b&&!o.isParentOf(b),x=$getNearestNodeFromDOMNode(g.anchorNode),w=x&&o.isParentOf(x);if(C&&w&&g.rangeCount>0){let S=$createRangeSelectionFromDom(g,t);S&&(S.anchor.set(o.getKey(),p.isBackward()?o.getChildrenSize():0,"element"),g.removeAllRanges(),$setSelection(S));}}}return p&&!p.is(f)&&(U(p)||U(f))&&s.tableSelection&&!s.tableSelection.is(f)?(U(p)&&p.tableKey===s.tableNodeKey?s.$updateTableTableSelection(p):!U(p)&&U(f)&&f.tableKey===s.tableNodeKey&&s.$updateTableTableSelection(null),false):(s.hasHijackedSelectionStyles&&!o.isSelected()?(function(g,b){b.$enableHighlightStyle(),ki(b.table,C=>{let x=C.elem;C.highlighted=false,ec(g,C),x.getAttribute("style")||x.removeAttribute("style");});})(t,s):!s.hasHijackedSelectionStyles&&o.isSelected()&&Ma(t,s),false)},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(INSERT_PARAGRAPH_COMMAND,()=>{let p=$getSelection();if(!$isRangeSelection(p)||!p.isCollapsed()||!je(p,o))return false;let f=Aa(t,p,o);return !!f&&(ka(f,o),true)},COMMAND_PRIORITY_HIGH)),s}function bi(o){return o[gi]||null}function Xo(o){let e=o;for(;e!=null;){let t=e.nodeName;if(t==="TD"||t==="TH"){let n=e._cell;return n===void 0?null:n}e=e.parentNode;}return null}function Oa(o,e){if(!o.contains(e))return null;let t=null;for(let n=e;n!=null;n=n.parentNode){if(n===o)return t;let r=n.nodeName;r!=="TD"&&r!=="TH"||(t=n._cell||null);}return null}function mo(o,e){let t=[],n={columns:0,domRows:t,rows:0},r=mt(o,e).querySelector("tr"),i=0,s=0;for(t.length=0;r!=null;){let l=r.nodeName;if(l==="TD"||l==="TH"){let d={elem:r,hasBackgroundColor:r.style.backgroundColor!=="",highlighted:false,x:i,y:s};r._cell=d;let u=t[s];u===void 0&&(u=t[s]=[]),u[i]=d;}else {let d=r.firstChild;if(d!=null){r=d;continue}}let a=r.nextSibling;if(a!=null){i++,r=a;continue}let c=r.parentNode;if(c!=null){let d=c.nextSibling;if(d==null)break;s++,i=0,r=d;}}return n.columns=i+1,n.rows=s+1,n}function Ln(o,e,t){let n=new Set(t?t.getNodes():[]);ki(e,(r,i)=>{let s=r.elem;n.has(i)?(r.highlighted=true,Qa(o,r)):(r.highlighted=false,ec(o,r),s.getAttribute("style")||s.removeAttribute("style"));});}function ki(o,e){let{domRows:t}=o;for(let n=0;n<t.length;n++){let r=t[n];if(r)for(let i=0;i<r.length;i++){let s=r[i];if(!s)continue;let l=$getNearestNodeFromDOMNode(s.elem);l!==null&&e(s,l,{x:i,y:n});}}}function Ma(o,e){e.$disableHighlightStyle(),ki(e.table,t=>{t.highlighted=true,Qa(o,t);});}function ci(o,e){let t,n;if(e.startColumn===o.minColumn)t="minColumn";else {if(e.startColumn+e.cell.__colSpan-1!==o.maxColumn)return null;t="maxColumn";}if(e.startRow===o.minRow)n="minRow";else {if(e.startRow+e.cell.__rowSpan-1!==o.maxRow)return null;n="maxRow";}return [t,n]}function Pn([o,e]){return [o==="minColumn"?"maxColumn":"minColumn",e==="minRow"?"maxRow":"minRow"]}function co(o,e,[t,n]){let r=e[n],i=o[r];i===void 0&&A(250,n,String(r));let s=e[t],l=i[s];return l===void 0&&A(250,t,String(s)),l}function og(o,e,t,n,r){let i=zn(e,t,n),s=(function(y,N){let{minColumn:E,maxColumn:R,minRow:L,maxRow:k}=N,M=1,v=1,T=1,K=1,V=y[L],ie=y[k];for(let re=E;re<=R;re++)M=Math.max(M,V[re].cell.__rowSpan),K=Math.max(K,ie[re].cell.__rowSpan);for(let re=L;re<=k;re++)v=Math.max(v,y[re][E].cell.__colSpan),T=Math.max(T,y[re][R].cell.__colSpan);return {bottomSpan:K,leftSpan:v,rightSpan:T,topSpan:M}})(e,i),{topSpan:l,leftSpan:a,bottomSpan:c,rightSpan:d}=s,u=(function(y,N){let E=ci(y,N);return E===null&&A(249,N.cell.getKey()),E})(i,t),[h,p]=Pn(u),f=i[h],m=i[p];r==="forward"?f+=h==="maxColumn"?1:a:r==="backward"?f-=h==="minColumn"?1:d:r==="down"?m+=p==="maxRow"?1:l:r==="up"&&(m-=p==="minRow"?1:c);let g=e[m];if(g===void 0)return false;let b=g[f];if(b===void 0)return false;let[C,x]=(function(y,N,E){let R=zn(y,N,E),L=ci(R,N);if(L)return [co(y,R,L),co(y,R,Pn(L))];let k=ci(R,E);if(k)return [co(y,R,Pn(k)),co(y,R,k)];let M=["minColumn","minRow"];return [co(y,R,M),co(y,R,Pn(M))]})(e,t,b),w=At(o,C.cell),S=At(o,x.cell);return o.$setAnchorCellForSelection(w),o.$setFocusCellForSelection(S,true),true}function je(o,e){if($isRangeSelection(o)||U(o)){let t=e.isParentOf(o.anchor.getNode()),n=e.isParentOf(o.focus.getNode());return t&&n}return false}function In(o,e){e?o.selectStart():o.selectEnd();}function Qa(o,e){let t=e.elem,n=o._config.theme;F($getNearestNodeFromDOMNode(t))||A(131),addClassNamesToElement(t,n.tableCellSelected);}function ec(o,e){let t=e.elem;F($getNearestNodeFromDOMNode(t))||A(131);let n=o._config.theme;removeClassNamesFromElement(t,n.tableCellSelected);}function fo(o){let e=$findMatchingParent(o,F);return F(e)?e:null}function Ft(o){let e=$findMatchingParent(o,de);return de(e)?e:null}function ng(o,e,t,n,r,i,s){let l=$caretFromPoint(t.focus,r?"previous":"next");if($isExtendableTextPointCaret(l))return false;let a=l;for(let g of $extendCaretToRange(l).iterNodeCarets("shadowRoot")){if(!$isSiblingCaret(g)||!$isElementNode(g.origin))return false;a=g;}let c=a.getParentAtCaret();if(!F(c))return false;let d=c,u=(function(g){for(let b of $extendCaretToRange(g).iterNodeCarets("root")){let{origin:C}=b;if(F(C)){if($isChildCaret(b))return $getChildCaret(C,g.direction)}else if(!ee(C))break}return null})($getSiblingCaret(d,a.direction)),h=$findMatchingParent(d,de);if(!h||!h.is(i))return false;let p=o.getElementByKey(d.getKey()),f=Xo(p);if(!p||!f)return false;let m=nc(o,h);if(s.table=m,u)if(n==="extend"){let g=Xo(o.getElementByKey(u.origin.getKey()));if(!g)return false;s.$setAnchorCellForSelection(f),s.$setFocusCellForSelection(g,true);}else {let g=$normalizeCaret(u);$setPointFromCaret(t.anchor,g),$setPointFromCaret(t.focus,g);}else if(n==="extend")s.$setAnchorCellForSelection(f),s.$setFocusCellForSelection(f,true);else {let g=(function(b){let C=$getAdjacentChildCaret(b);return $isChildCaret(C)?$normalizeCaret(C):b})($getSiblingCaret(h,l.direction));$setPointFromCaret(t.anchor,g),$setPointFromCaret(t.focus,g);}return et(e),true}function tc(o,e,t,n,r){if((t==="up"||t==="down")&&(function(s){let l=s.getRootElement();return l?l.hasAttribute("aria-controls")&&l.getAttribute("aria-controls")==="typeahead-menu":false})(o))return false;let i=$getSelection();if(!je(i,n)){if($isRangeSelection(i)){if(t==="backward"){if(i.focus.offset>0)return false;let s=(function(a){for(let c=a,d=a;d!==null;c=d,d=d.getParent())if($isElementNode(d)){if(d!==c&&d.getFirstChild()!==c)return null;if(!d.isInline())return d}return null})(i.focus.getNode());if(!s)return false;let l=s.getPreviousSibling();return !!de(l)&&(et(e),e.shiftKey?i.focus.set(l.getParentOrThrow().getKey(),l.getIndexWithinParent(),"element"):l.selectEnd(),true)}if(e.shiftKey&&(t==="up"||t==="down")){let s=i.focus.getNode();if(!i.isCollapsed()&&(t==="up"&&!i.isBackward()||t==="down"&&i.isBackward())){let l=$findMatchingParent(s,h=>de(h));if(F(l)&&(l=$findMatchingParent(l,de)),l!==n||!l)return false;let a=t==="down"?l.getNextSibling():l.getPreviousSibling();if(!a)return false;let c=0;t==="up"&&$isElementNode(a)&&(c=a.getChildrenSize());let d=a;t==="up"&&$isElementNode(a)&&(d=a.getLastChild()||a,c=$isTextNode(d)?d.getTextContentSize():0);let u=i.clone();return u.focus.set(d.getKey(),c,$isTextNode(d)?"text":"element"),$setSelection(u),et(e),true}if($isRootOrShadowRoot(s)){let l=t==="up"?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(l&&Yo(n,l)!==null){let a=n.getFirstDescendant(),c=n.getLastDescendant();if(!a||!c)return false;let[d]=be(a),[u]=be(c),h=n.getCordsFromCellNode(d,r.table),p=n.getCordsFromCellNode(u,r.table),f=n.getDOMCellFromCordsOrThrow(h.x,h.y,r.table),m=n.getDOMCellFromCordsOrThrow(p.x,p.y,r.table);return r.$setAnchorCellForSelection(f),r.$setFocusCellForSelection(m,true),true}return false}{let l=$findMatchingParent(s,c=>$isElementNode(c)&&!c.isInline());if(F(l)&&(l=$findMatchingParent(l,de)),!l)return false;let a=t==="down"?l.getNextSibling():l.getPreviousSibling();if(de(a)&&r.tableNodeKey===a.getKey()){let c=a.getFirstDescendant(),d=a.getLastDescendant();if(!c||!d)return false;let[u]=be(c),[h]=be(d),p=i.clone();return p.focus.set((t==="up"?u:h).getKey(),t==="up"?0:h.getChildrenSize(),"element"),et(e),$setSelection(p),true}}}}return t==="down"&&Vo(o)&&r.setShouldCheckSelection(),false}if($isRangeSelection(i)){if(t==="backward"||t==="forward")return ng(o,e,i,e.shiftKey?"extend":"move",t==="backward",n,r);if(i.isCollapsed()){let{anchor:s,focus:l}=i,a=$findMatchingParent(s.getNode(),F),c=$findMatchingParent(l.getNode(),F);if(!F(a)||!a.is(c))return false;let d=Ft(a);if(d!==n&&d!=null){let b=mt(d,o.getElementByKey(d.getKey()));if(b!=null)return r.table=mo(d,b),tc(o,e,t,d,r)}let u=o.getElementByKey(a.__key),h=o.getElementByKey(s.key);if(h==null||u==null)return false;let p;if(s.type==="element")p=h.getBoundingClientRect();else {let b=getDOMSelection(Mi(o));if(b===null||b.rangeCount===0)return false;p=b.getRangeAt(0).getBoundingClientRect();}let f=t==="up"?a.getFirstChild():a.getLastChild();if(f==null)return false;let m=o.getElementByKey(f.__key);if(m==null)return false;let g=m.getBoundingClientRect();if(t==="up"?g.top>p.top-p.height:p.bottom+p.height>g.bottom){et(e);let b=n.getCordsFromCellNode(a,r.table);if(!e.shiftKey)return tg(r,n,b.x,b.y,t);{let C=n.getDOMCellFromCordsOrThrow(b.x,b.y,r.table);r.$setAnchorCellForSelection(C),r.$setFocusCellForSelection(C,true);}return true}}}else if(U(i)){let{anchor:s,focus:l}=i,a=$findMatchingParent(s.getNode(),F),c=$findMatchingParent(l.getNode(),F),[d]=i.getNodes();de(d)||A(251);let u=mt(d,o.getElementByKey(d.getKey()));if(!F(a)||!F(c)||!de(d)||u==null)return false;r.$updateTableTableSelection(i);let h=mo(d,u),p=n.getCordsFromCellNode(a,h),f=n.getDOMCellFromCordsOrThrow(p.x,p.y,h);if(r.$setAnchorCellForSelection(f),et(e),e.shiftKey){let[m,g,b]=ye(n,a,c);return og(r,m,g,b,t)}return c.selectEnd(),true}return false}function et(o){o.preventDefault(),o.stopImmediatePropagation(),o.stopPropagation();}function ka(o,e,t){let n=$createParagraphNode();o==="first"?e.insertBefore(n):e.insertAfter(n),n.append(...t||[]),n.selectEnd();}function Aa(o,e,t){let n=t.getParent();if(!n)return;let r=getDOMSelection(Mi(o));if(!r)return;let i=r.anchorNode,s=o.getElementByKey(n.getKey()),l=mt(t,o.getElementByKey(t.getKey()));if(!i||!s||!l||!s.contains(i)||l.contains(i))return;let a=$findMatchingParent(e.anchor.getNode(),C=>F(C));if(!a)return;let c=$findMatchingParent(a,C=>de(C));if(!de(c)||!c.is(t))return;let[d,u]=ye(t,a,a),h=d[0][0],p=d[d.length-1][d[0].length-1],{startRow:f,startColumn:m}=u,g=f===h.startRow&&m===h.startColumn,b=f===p.startRow&&m===p.startColumn;return g?"first":b?"last":void 0}function At(o,e){let{tableNode:t}=o.$lookup(),n=t.getCordsFromCellNode(e,o.table);return t.getDOMCellFromCordsOrThrow(n.x,n.y,o.table)}function Ci(o,e,t){return Yo(o,$getNearestNodeFromDOMNode(e,t))}function $a(o,e,t){if(!e.theme.tableAlignment)return;let n=[],r=[];for(let i of ["center","right"]){let s=e.theme.tableAlignment[i];s&&(i===t?r:n).push(s);}removeClassNamesFromElement(o,...n),addClassNamesToElement(o,...r);}function Vo(o=$getEditor()){return Si.has(o)}function oc(o,e){e?Si.add(o):Si.delete(o);}function nc(o,e){let t=o.getElementByKey(e.getKey());return t===null&&A(230),mo(e,t)}function rg(o){let e=jn();o.hasAttribute("data-lexical-row-striping")&&e.setRowStriping(true),o.hasAttribute("data-lexical-frozen-column")&&e.setFrozenColumns(1),o.hasAttribute("data-lexical-frozen-row")&&e.setFrozenRows(1);let t=o.querySelector(":scope > colgroup");if(t){let n=[];for(let r of t.querySelectorAll(":scope > col")){let i=r.style.width||"";if(!_i.test(i)&&(i=r.getAttribute("width")||"",!/^\d+$/.test(i))){n=void 0;break}n.push(parseFloat(i));}n&&e.setColWidths(n);}return {after:n=>$descendantsMatching(n,ee),node:e}}function jn(){return $applyNodeReplacement(new Xe)}function de(o){return o instanceof Xe}function ig({rows:o,columns:e,includeHeaders:t}){let n=$getSelection()||$getPreviousSelection();if(!n||!$isRangeSelection(n)||Ft(n.anchor.getNode()))return false;let r=Wa(Number(o),Number(e),t);$insertNodeToNearestRoot(r);let i=r.getFirstDescendant();return $isTextNode(i)&&i.select(),true}function sg(o){ee(o.getParent())?o.isEmpty()&&o.append($createParagraphNode()):o.remove();}function lg(o){de(o.getParent())?$unwrapAndFilterDescendants(o,F):o.remove();}function ag(o){$unwrapAndFilterDescendants(o,ee);let[e]=tt(o,null,null),t=e.reduce((r,i)=>Math.max(r,i.length),0),n=o.getChildren();for(let r=0;r<e.length;++r){let i=n[r];if(!i)continue;ee(i)||A(254,i.constructor.name,i.getType());let s=e[r].reduce((l,a)=>a?1+l:l,0);if(s!==t)for(let l=s;l<t;++l){let a=ke();a.append($createParagraphNode()),i.append(a);}}}function cg(o){if(o.detail<3||!isDOMNode(o.target))return false;let e=$getNearestNodeFromDOMNode(o.target);if(e===null)return false;let t=$findMatchingParent(e,n=>$isElementNode(n)&&!n.isInline());return t===null?false:!!F(t.getParent())&&(t.select(0),true)}function rc(o){return o.registerNodeTransform(Ge,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){let[,,t]=be(e),[n]=ye(t,e,e),r=n.length,i=n[0].length,s=t.getFirstChild();ee(s)||A(175);let l=[];for(let a=0;a<r;a++){a!==0&&(s=s.getNextSibling(),ee(s)||A(175));let c=null;for(let d=0;d<i;d++){let u=n[a][d],h=u.cell;if(u.startRow===a&&u.startColumn===d)c=h,l.push(h);else if(h.getColSpan()>1||h.getRowSpan()>1){F(h)||A(176);let p=ke(h.__headerState);c!==null?c.insertAfter(p):$insertFirst(s,p);}}}for(let a of l)a.setColSpan(1),a.setRowSpan(1);}})}function ic(o,e=true){let t=new Map,n=(i,s,l)=>{let a=mt(i,l),c=Za(i,a,o,e);t.set(s,[c,a]);},r=o.registerMutationListener(Xe,i=>{o.getEditorState().read(()=>{for(let[s,l]of i){let a=t.get(s);if(l==="created"||l==="updated"){let{tableNode:c,tableElement:d}=Oi(s);a===void 0?n(c,s,d):d!==a[1]&&(a[0].removeListeners(),t.delete(s),n(c,s,d));}else l==="destroyed"&&a!==void 0&&(a[0].removeListeners(),t.delete(s));}},{editor:o});},{skipInitialization:false});return ()=>{r();for(let[,[i]]of t)i.removeListeners();}}function sc(o){return o.hasNodes([Xe])||A(255),mergeRegister(o.registerCommand(Ha,ig,COMMAND_PRIORITY_EDITOR),o.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,({nodes:e,selection:t},n)=>o!==n||!$isRangeSelection(t)?false:Ft(t.anchor.getNode())!==null&&e.some(de),COMMAND_PRIORITY_EDITOR),o.registerCommand(CLICK_COMMAND,cg,COMMAND_PRIORITY_EDITOR),o.registerNodeTransform(Xe,ag),o.registerNodeTransform(Dt,lg),o.registerNodeTransform(Ge,sg))}var _i,oe,Ge,Ha,Dt,Ei,Pm,va,fi,Wm,jm,Gm,Xm,Bn,Hn,gi,Zm,Qm,eg,tg,Si,Xe,dg,ac=rt(async()=>{await Ar();await Dr();_i=/^(\d+(?:\.\d+)?)px$/,oe={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1},Ge=class o extends ElementNode{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return "tablecell"}static clone(e){return new o(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign;}static importDOM(){return {td:e=>({conversion:Ta,priority:0}),th:e=>({conversion:Ta,priority:0})}}static importJSON(e){return ke().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=oe.NO_STATUS,t=1,n,r){super(r),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0;}createDOM(e){let t=document.createElement(this.getTag());return this.__width&&(t.style.width=`${this.__width}px`),this.__colSpan>1&&(t.colSpan=this.__colSpan),this.__rowSpan>1&&(t.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(t.style.backgroundColor=this.__backgroundColor),ui(this.__verticalAlign)&&(t.style.verticalAlign=this.__verticalAlign),addClassNamesToElement(t,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),t}exportDOM(e){let t=super.exportDOM(e);if(isHTMLElement(t.element)){let n=t.element;n.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),n.style.border="1px solid black",this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),n.style.width=`${this.getWidth()||75}px`,n.style.verticalAlign=this.getVerticalAlign()||"top",n.style.textAlign="start",this.__backgroundColor===null&&this.hasHeader()&&(n.style.backgroundColor="#f2f3f5");}return t}exportJSON(){return {...super.exportJSON(),...ui(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){let t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){let t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=oe.BOTH){let n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){let t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){let t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){let t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){let 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!==oe.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 true}collapseAtStart(){return true}canBeEmpty(){return false}canIndent(){return false}};Ha=createCommand("INSERT_TABLE_COMMAND");Dt=class o extends ElementNode{__height;static getType(){return "tablerow"}static clone(e){return new o(e.__height,e.__key)}static importDOM(){return {tr:e=>({conversion:Lm,priority:0})}}static importJSON(e){return Lt().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e;}exportJSON(){let e=this.getHeight();return {...super.exportJSON(),...e===void 0?void 0:{height:e}}}createDOM(e){let t=document.createElement("tr");return this.__height&&(t.style.height=`${this.__height}px`),addClassNamesToElement(t,e.theme.tableRow),t}extractWithChild(e,t,n){return n==="html"}isShadowRoot(){return true}setHeight(e){let t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return false}canIndent(){return false}};Ei=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Pm=Ei&&"documentMode"in document?document.documentMode:null,va=Ei&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);Ei&&"InputEvent"in window&&!Pm&&new window.InputEvent("input");fi=(o,e)=>o===oe.BOTH||o===e?e:oe.NO_STATUS;Wm=ja;jm=Ya;Gm=Ga;Xm=Xa;Bn=class o{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=false,this.tableKey=e;}getStartEndPoints(){return [this.anchor,this.focus]}isValid(){if(this.tableKey==="root"||this.anchor.key==="root"||this.anchor.type!=="element"||this.focus.key==="root"||this.focus.type!=="element")return false;let e=$getNodeByKey(this.tableKey),t=$getNodeByKey(this.anchor.key),n=$getNodeByKey(this.focus.key);return e!==null&&t!==null&&n!==null}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e;}is(e){return U(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 o(this.tableKey,$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return false}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(F).forEach(r=>{let i=r.getFirstChild();$isParagraphNode(i)&&(t|=i.getTextFormat());});let n=TEXT_TYPE_TO_FORMAT[e];return (t&n)!==0}insertNodes(e){let t=this.focus.getNode();$isElementNode(t)||A(151),$normalizeSelection__EXPERIMENTAL(t.select(0,t.getChildrenSize())).insertNodes(e);}getShape(){let{anchorCell:e,focusCell:t}=Ra(this),n=mi(e);n===null&&A(153);let r=mi(t);r===null&&A(155);let i=Math.min(n.columnIndex,r.columnIndex),s=Math.max(n.columnIndex+n.colSpan-1,r.columnIndex+r.colSpan-1),l=Math.min(n.rowIndex,r.rowIndex),a=Math.max(n.rowIndex+n.rowSpan-1,r.rowIndex+r.rowSpan-1);return {fromX:Math.min(i,s),fromY:Math.min(l,a),toX:Math.max(i,s),toY:Math.max(l,a)}}getNodes(){if(!this.isValid())return [];let e=this._cachedNodes;if(e!==null)return e;let{anchorTable:t,anchorCell:n,focusCell:r}=Ra(this),i=r.getParents()[1];if(i!==t){if(t.isParentOf(r)){let g=i.getParent();g==null&&A(159),this.set(this.tableKey,r.getKey(),g.getKey());}else {let g=t.getParent();g==null&&A(158),this.set(this.tableKey,g.getKey(),r.getKey());}return this.getNodes()}let[s,l,a]=ye(t,n,r),{minColumn:c,maxColumn:d,minRow:u,maxRow:h}=zn(s,l,a),p=new Map([[t.getKey(),t]]),f=null;for(let g=u;g<=h;g++)for(let b=c;b<=d;b++){let{cell:C}=s[g][b],x=C.getParent();ee(x)||A(160),x!==f&&(p.set(x.getKey(),x),f=x),p.has(C.getKey())||qm(C,w=>{p.set(w.getKey(),w);});}let m=Array.from(p.values());return isCurrentlyReadOnlyMode()||(this._cachedNodes=m),m}getTextContent(){let e=this.getNodes().filter(n=>F(n)),t="";for(let n=0;n<e.length;n++){let r=e[n],i=r.__parent,s=(e[n+1]||{}).__parent;t+=r.getTextContent()+(s!==i?`
|
|
9
|
-
`:" ");}return t}};Hn=class{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=false,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=false,this.isSelecting=false,this.pointerType=null,this.shouldCheckSelection=false,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable();}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear();}$lookup(){return Oi(this.tableNodeKey,this.editor)}trackTable(){let e=new MutationObserver(t=>{this.editor.getEditorState().read(()=>{let n=false;for(let s=0;s<t.length;s++){let l=t[s].target.nodeName;if(l==="TABLE"||l==="TBODY"||l==="THEAD"||l==="TR"){n=true;break}}if(!n)return;let{tableNode:r,tableElement:i}=this.$lookup();this.table=mo(r,i);},{editor:this.editor});});this.editor.getEditorState().read(()=>{let{tableNode:t,tableElement:n}=this.$lookup();this.table=mo(t,n),e.observe(n,{attributes:true,childList:true,subtree:true});},{editor:this.editor});}$clearHighlight(){let e=this.editor;this.isHighlightingCells=false,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=false,this.$enableHighlightStyle();let{tableNode:t,tableElement:n}=this.$lookup();Ln(e,mo(t,n),null),$getSelection()!==null&&($setSelection(null),e.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0));}$enableHighlightStyle(){let e=this.editor,{tableElement:t}=this.$lookup();removeClassNamesFromElement(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=false;}$disableHighlightStyle(){let{tableElement:e}=this.$lookup();addClassNamesToElement(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=true;}$updateTableTableSelection(e){if(e!==null){e.tableKey!==this.tableNodeKey&&A(233,e.tableKey,this.tableNodeKey);let t=this.editor;this.tableSelection=e,this.isHighlightingCells=true,this.$disableHighlightStyle(),this.updateDOMSelection(),Ln(t,this.table,this.tableSelection);}else this.$clearHighlight();}setShouldCheckSelection(){this.shouldCheckSelection=true;}getAndClearShouldCheckSelection(){return !!this.shouldCheckSelection&&(this.shouldCheckSelection=false,true)}setNextFocus(e){this.nextFocus=e;}getAndClearNextFocus(){let{nextFocus:e}=this;return e!==null&&(this.nextFocus=null),e}updateDOMSelection(){if(this.anchorCell!==null&&this.focusCell!==null){let e=getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges();}}$setFocusCellForSelection(e,t=false){let n=this.editor,{tableNode:r}=this.$lookup(),i=e.x,s=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===i&&this.anchorY===s&&!t){if(i===this.focusX&&s===this.focusY)return false}else this.isHighlightingCells=true,this.$disableHighlightStyle();if(this.focusX=i,this.focusY=s,this.isHighlightingCells){let l=Ci(r,e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&l!==null)return this.focusCellNodeKey=l.getKey(),this.tableSelection=qa(r,this.$getAnchorTableCellOrThrow(),l),$setSelection(this.tableSelection),n.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0),Ln(n,this.table,this.tableSelection),true}return false}$getAnchorTableCell(){return this.anchorCellNodeKey?$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){let e=this.$getAnchorTableCell();return e===null&&A(234),e}$getFocusTableCell(){return this.focusCellNodeKey?$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){let e=this.$getFocusTableCell();return e===null&&A(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=false,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;let{tableNode:t}=this.$lookup(),n=Ci(t,e.elem);if(n!==null){let r=n.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():Ri(),this.anchorCellNodeKey=r;}}$formatCells(e){let t=$getSelection();U(t)||A(236);let n=$createRangeSelection(),r=n.anchor,i=n.focus,s=t.getNodes().filter(F);s.length>0||A(237);let l=s[0].getFirstChild(),a=$isParagraphNode(l)?l.getFormatFlags(e,null):null;s.forEach(c=>{r.set(c.getKey(),0,"element"),i.set(c.getKey(),c.getChildrenSize(),"element"),n.formatText(e,a);}),$setSelection(t),this.editor.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0);}$clearText(){let{editor:e}=this,t=$getNodeByKey(this.tableNodeKey);if(!de(t))throw new Error("Expected TableNode.");let n=$getSelection();U(n)||A(253);let r=n.getNodes().filter(F),i=t.getFirstChild(),s=t.getLastChild();if(r.length>0&&i!==null&&s!==null&&ee(i)&&ee(s)&&r[0]===i.getFirstChild()&&r[r.length-1]===s.getLastChild()){t.selectPrevious();let l=t.getParent();return t.remove(),void($isRootNode(l)&&l.isEmpty()&&e.dispatchCommand(INSERT_PARAGRAPH_COMMAND,void 0))}r.forEach(l=>{if($isElementNode(l)){let a=$createParagraphNode(),c=$createTextNode();a.append(c),l.append(a),l.getChildren().forEach(d=>{d!==a&&d.remove();});}}),Ln(e,this.table,null),$setSelection(null),e.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0);}},gi="__lexicalTableSelection";Zm=[[KEY_ARROW_DOWN_COMMAND,"down"],[KEY_ARROW_UP_COMMAND,"up"],[KEY_ARROW_LEFT_COMMAND,"backward"],[KEY_ARROW_RIGHT_COMMAND,"forward"]],Qm=[DELETE_WORD_COMMAND,DELETE_LINE_COMMAND,DELETE_CHARACTER_COMMAND],eg=[KEY_BACKSPACE_COMMAND,KEY_DELETE_COMMAND];tg=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case "backward":case "forward":return t!==(i?o.table.columns-1:0)?In(e.getCellNodeFromCordsOrThrow(t+(i?1:-1),n,o.table),i):n!==(i?o.table.rows-1:0)?In(e.getCellNodeFromCordsOrThrow(i?0:o.table.columns-1,n+(i?1:-1),o.table),i):i?e.selectNext():e.selectPrevious(),true;case "up":return n!==0?In(e.getCellNodeFromCordsOrThrow(t,n-1,o.table),false):e.selectPrevious(),true;case "down":return n!==o.table.rows-1?In(e.getCellNodeFromCordsOrThrow(t,n+1,o.table),true):e.selectNext(),true;default:return false}};Si=new WeakSet;Xe=class o extends ElementNode{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return "table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){let t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new o(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:rg,priority:1})}}static importJSON(e){return jn().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||false).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=false,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 n==="html"}getDOMSlot(e){let t=uo(e)?e:e.querySelector("table");return uo(t)||A(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(e,t){let n=document.createElement("table");this.__style&&(n.style.cssText=this.__style);let r=document.createElement("colgroup");if(n.appendChild(r),setDOMUnmanaged(r),addClassNamesToElement(n,e.theme.table),this.updateTableElement(null,n,e),Vo(t)){let i=document.createElement("div"),s=e.theme.tableScrollableWrapper;return s?addClassNamesToElement(i,s):i.style.cssText="overflow-x: auto;",i.appendChild(n),this.updateTableWrapper(null,i,n,e),i}return n}updateTableWrapper(e,t,n,r){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&(function(i,s,l,a){a>0?(addClassNamesToElement(i,l.theme.tableFrozenColumn),s.setAttribute("data-lexical-frozen-column","true")):(removeClassNamesFromElement(i,l.theme.tableFrozenColumn),s.removeAttribute("data-lexical-frozen-column"));})(t,n,r,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&(function(i,s,l,a){a>0?(addClassNamesToElement(i,l.theme.tableFrozenRow),s.setAttribute("data-lexical-frozen-row","true")):(removeClassNamesFromElement(i,l.theme.tableFrozenRow),s.removeAttribute("data-lexical-frozen-row"));})(t,n,r,this.__frozenRowCount);}updateTableElement(e,t,n){this.__style!==(e?e.__style:"")&&(t.style.cssText=this.__style),this.__rowStriping!==(!!e&&e.__rowStriping)&&(function(r,i,s){s?(addClassNamesToElement(r,i.theme.tableRowStriping),r.setAttribute("data-lexical-row-striping","true")):(removeClassNamesFromElement(r,i.theme.tableRowStriping),r.removeAttribute("data-lexical-row-striping"));})(t,n,this.__rowStriping),(function(r,i,s,l){let a=r.querySelector("colgroup");if(!a)return;let c=[];for(let d=0;d<s;d++){let u=document.createElement("col"),h=l&&l[d];h&&(u.style.width=`${h}px`),c.push(u);}a.replaceChildren(...c);})(t,0,this.getColumnCount(),this.getColWidths()),$a(t,n,this.getFormatType());}updateDOM(e,t,n){let r=this.getDOMSlot(t).element;return t===r===Vo()||(isHTMLElement$1(i=t)&&i.nodeName==="DIV"&&this.updateTableWrapper(e,t,r,n),this.updateTableElement(e,r,n),false);var i;}exportDOM(e){let t=super.exportDOM(e),{element:n}=t;return {after:r=>{if(t.after&&(r=t.after(r)),!uo(r)&&isHTMLElement$1(r)&&(r=r.querySelector("table")),!uo(r))return null;$a(r,e._config,this.getFormatType());let[i]=tt(this,null,null),s=new Map;for(let d of i)for(let u of d){let h=u.cell.getKey();s.has(h)||s.set(h,{colSpan:u.cell.getColSpan(),startColumn:u.startColumn});}let l=new Set;for(let d of r.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){let u=d.getAttribute("data-temporary-table-cell-lexical-key");if(u){let h=s.get(u);if(d.removeAttribute("data-temporary-table-cell-lexical-key"),h){s.delete(u);for(let p=0;p<h.colSpan;p++)l.add(p+h.startColumn);}}}let a=r.querySelector(":scope > colgroup");if(a){let d=Array.from(r.querySelectorAll(":scope > colgroup > col")).filter((u,h)=>l.has(h));a.replaceChildren(...d);}let c=r.querySelectorAll(":scope > tr");if(c.length>0){let d=document.createElement("tbody");for(let u of c)d.appendChild(u);r.append(d);}return r},element:!uo(n)&&isHTMLElement$1(n)?n.querySelector("table"):n}}canBeEmpty(){return false}isShadowRoot(){return true}getCordsFromCellNode(e,t){let{rows:n,domRows:r}=t;for(let i=0;i<n;i++){let s=r[i];if(s!=null)for(let l=0;l<s.length;l++){let a=s[l];if(a==null)continue;let{elem:c}=a,d=Ci(this,c);if(d!==null&&e.is(d))return {x:l,y:i}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){let{domRows:r}=n,i=r[t];if(i==null)return null;let s=i[e<i.length?e:i.length-1];return s??null}getDOMCellFromCordsOrThrow(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(!r)throw new Error("Cell not found at cords.");return r}getCellNodeFromCords(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(r==null)return null;let i=$getNearestNodeFromDOMNode(r.elem);return F(i)?i:null}getCellNodeFromCordsOrThrow(e,t,n){let r=this.getCellNodeFromCords(e,t,n);if(!r)throw new Error("Node at cords not TableCellNode.");return r}getRowStriping(){return !!this.getLatest().__rowStriping}setRowStriping(e){let t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){let t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){let t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return true}canIndent(){return false}getColumnCount(){let e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach(n=>{F(n)&&(t+=n.getColSpan());}),t}};dg=defineExtension({build:(o,e,t)=>Sn(e),config:safeCast({hasCellBackgroundColor:true,hasCellMerge:true,hasHorizontalScroll:true,hasTabHandler:true}),name:"@lexical/table/Table",nodes:[Xe,Dt,Ge],register(o,e,t){let n=t.getOutput();return mergeRegister(Ke(()=>{let r=n.hasHorizontalScroll.value;Vo(o)!==r&&(oc(o,r),o.registerNodeTransform(Xe,()=>{})());}),sc(o),Ke(()=>ic(o,n.hasTabHandler.value)),Ke(()=>n.hasCellMerge.value?void 0:rc(o)),Ke(()=>n.hasCellBackgroundColor.value?void 0:o.registerNodeTransform(Ge,r=>{r.getBackgroundColor()!==null&&r.setBackgroundColor(null);})))}});});var os=createContext(void 0),rn=()=>{let o=useContext(os);if(!o)throw new Error("useTheme must be used within a ThemeProvider");return o},ns=({children:o,initialTheme:e="dark",onThemeChange:t})=>{let[n,r]=useState(e);useEffect(()=>{t&&t(n);},[n,t]);let i=()=>{r(s=>s==="light"?"dark":"light");};return jsx(os.Provider,{value:{theme:n,toggleTheme:i},children:o})};var rs=createContext(void 0),it=()=>{let o=useContext(rs);if(!o)throw new Error("useEmailContext must be used within an EmailProvider");return o},is=({children:o,googleDriveConfig:e})=>{let[t,n]=useState({to:[],cc:[],bcc:[]}),[r,i]=useState(false),[s,l]=useState(""),[a,c]=useState(false),[d,u]=useState(false),[h,p]=useState([]);return useEffect(()=>{console.log("EmailProvider emails updated:",t);},[t]),jsx(rs.Provider,{value:{emails:t,setEmails:n,subject:s,setSubject:l,showCC:a,setShowCC:c,showBCC:d,setShowBCC:u,attachments:h,setAttachments:p,isReply:r,setIsReply:i,googleDriveConfig:e},children:o})};var D=await(process.env.NODE_ENV!=="production"?xa().then(()=>Sa):ac().then(()=>lc));D.$computeTableMap;D.$computeTableMapSkipCellCheck;D.$createTableCellNode;D.$createTableNode;D.$createTableNodeWithDimensions;D.$createTableRowNode;D.$createTableSelection;D.$createTableSelectionFrom;D.$deleteTableColumn;D.$deleteTableColumnAtSelection;D.$deleteTableColumn__EXPERIMENTAL;D.$deleteTableRowAtSelection;D.$deleteTableRow__EXPERIMENTAL;D.$findCellNode;D.$findTableNode;D.$getElementForTableNode;D.$getNodeTriplet;D.$getTableAndElementByKey;D.$getTableCellNodeFromLexicalNode;D.$getTableCellNodeRect;D.$getTableColumnIndexFromTableCellNode;D.$getTableNodeFromLexicalNodeOrThrow;D.$getTableRowIndexFromTableCellNode;D.$getTableRowNodeFromTableCellNodeOrThrow;D.$insertTableColumn;D.$insertTableColumnAtSelection;D.$insertTableColumn__EXPERIMENTAL;D.$insertTableRow;D.$insertTableRowAtSelection;D.$insertTableRow__EXPERIMENTAL;D.$isScrollableTablesActive;D.$isTableCellNode;D.$isTableNode;D.$isTableRowNode;D.$isTableSelection;D.$mergeCells;D.$removeTableRowAtIndex;D.$unmergeCell;D.INSERT_TABLE_COMMAND;D.TableCellHeaderStates;var cc=D.TableCellNode;D.TableExtension;var dc=D.TableNode;D.TableObserver;var uc=D.TableRowNode;D.applyTableHandlers;D.getDOMCellFromTarget;D.getTableElement;D.getTableObserverFromTableElement;D.registerTableCellUnmergeTransform;D.registerTablePlugin;D.registerTableSelectionObserver;D.setScrollableTablesActive;var _={undo:"undo",redo:"redo",bold:"bold",italic:"italic",underline:"underline",color:{base:"colors"},code:"code",link:"link",listNumber:"listNumber",listBullet:"listBullet",align:{base:"align"},indent:"indent",indentDecrease:"indentDecrease",strike:"strike",attachFile:"attachFile",insertPhoto:"insertPhoto",fontSize:"fontSize",fontFamily:"fontFamily",emoji:"emoji",drive:"drive",lockClock:"lockClock",insertSignature:"insertSignature"},ne={styling:"styling",divider:"divider",component:"component"},Ai=[{type:ne.styling,icon:"Styling",id:"4bc66ea9-2e35-4a7b-a674-be7e4ee163c5",label:"Formatting options",options:[{name:_.undo,type:ne.component,icon:"Undo",label:"Undo",id:"29cf5eb3-37cd-482f-9a15-c358faf19cc2"},{name:_.redo,type:ne.component,icon:"Redo",label:"Redo",id:"8744f7ab-5818-46ce-9417-2fec87123afe"},{type:ne.divider,id:"ed0104fd-3507-43f6-80c1-813fbdf04479"},{name:_.fontFamily,type:ne.component,id:"1c12d7e2-aa6a-42b4-b25c-b55fe3bcf524",label:"Font"},{type:ne.divider,id:"d0f67d01-0731-411a-b448-e1dca47014f4"},{name:_.fontSize,type:ne.component,id:"82e31b62-5441-4052-887c-faa02d0b7075",label:"Size"},{type:ne.divider,id:"2e3558e4-3ad4-422b-8502-ea3c58fb8c2e"},{name:_.bold,type:ne.component,icon:"Bold",label:"Bold",id:"ac2b5b54-7323-44a4-bc6d-8bae6e48efe2"},{name:_.italic,type:ne.component,icon:"Italic",label:"Italic",id:"6a927c2a-2230-4dc7-af71-47fbe9fb784d"},{name:_.underline,type:ne.component,icon:"Underline",label:"Underline",id:"f07b3a6f-ffaa-4153-beae-79a36acb6a08"},{name:_.color.base,type:ne.component,icon:"Text color",label:"Text color",id:"e14ec25f-3dd3-4ed5-b33a-a033684d248b"},{type:ne.divider,id:"93e60297-206f-4f31-bc29-11daff2052bd"},{name:_.align.base,type:ne.component,id:"30da93ea-efa6-4642-bfa5-28fd4dc9c5b3",label:"Align",collapse:true},{type:ne.divider,id:"9bad0563-6118-4855-9286-402bf98e00ad",hideOnCollapse:true},{name:_.listNumber,type:ne.component,icon:"OrderedList",label:"Ordered list",id:"d37865e1-ff54-4118-a5cc-fa147d222471",collapse:true},{name:_.listBullet,type:ne.component,icon:"UnOrderedList",label:"Unordered list",id:"ed77e7c9-b89c-41c5-a749-e68ea0b30497",collapse:true},{type:ne.divider,id:"e5ecd77b-44cc-42fe-badb-48cadf3ddfb1",hideOnCollapse:true},{name:_.indentDecrease,type:ne.component,icon:"IndentLess",label:"Decrease indent",id:"2dc6a5e4-b1b5-47d1-ac2f-5d0becb02d33",collapse:true},{name:_.indent,type:ne.component,icon:"IndentMore",label:"Increase indent",id:"6903a3d1-a83f-4bc6-9bd9-f673feffe84f",collapse:true}]},{type:"component",name:_.attachFile,icon:"Attach",label:"Attach file",id:"f43a284e-113e-4095-b001-9d00a1dddc4c"},{type:ne.component,name:_.link,icon:"Link",label:"Insert link",id:"580db61e-7939-4efe-914c-304b271998ec"},{type:ne.component,name:_.emoji,icon:"Emoji",id:"e1f2c6d1-emoji"},{type:"component",name:_.insertPhoto,icon:"InsertImage",label:"Insert photo",id:"d032ba91-3e78-4ed5-8561-insertPhoto"},{type:"component",name:_.lockClock,icon:"LockClock",id:"d032ba91-3e78-4ed5-8561-lockClock"},{type:"component",name:_.insertSignature,icon:"Signature",label:"Insert signature",id:"d032ba91-3e78-4ed5-8561-lockClock"}];var Kg={Undo:MdUndo,Redo:MdRedo,Bold:MdFormatBold,Italic:MdFormatItalic,Underline:MdFormatUnderlined,Color:MdTextFormat,LeftAlign:MdFormatAlignLeft,RightAlign:MdFormatAlignRight,CenterAlign:MdFormatAlignCenter,UnOrderedList:MdFormatListBulleted,OrderedList:MdFormatListNumbered,IndentLess:MdFormatIndentDecrease,IndentMore:MdOutlineFormatIndentIncrease,RemoveFormat:MdFormatClear,StrikeThrough:MdStrikethroughS,CodeQuote:MdFormatQuote,DownArrow:MdArrowDropDown,Styling:MdTextFormat,Attach:MdAttachFile,Link:MdLink,Image:MdImage,Check:MdCheck,TextFields:MdTextFields,Edit:MdEdit,Close:MdClose,Emoji:MdOutlineEmojiEmotions,InsertImage:MdPhoto,LockClock:MdLockClock,GoogleDrive:TbBrandGoogleDrive,Signature:RiBallPenFill},pc=Kg;var zg=({name:o,size:e=24,color:t,className:n})=>{let r=pc[o];return r?jsx(r,{size:e,color:t,className:n}):(console.warn(`Icon "${o}" not found.`),null)},X=zg;var jg=({trigger:o,children:e,popUpDirection:t="top center",on:n="click"})=>{let r=useRef(null),i=()=>{r.current&&typeof r.current.close=="function"&&r.current.close();},s=l=>e({close:()=>{l?.(),i();}});return useEffect(()=>{let l=()=>{try{r.current?.reposition?.();let d=document.querySelector(".mail-inbox-popup .popup-content, .mail-inbox-popup-content, .mail-inbox-popup > .popup-content");if(!d)return;let u=d.getBoundingClientRect(),h=8;if(u.right>window.innerWidth-h){let p=u.right-(window.innerWidth-h),f=parseFloat(getComputedStyle(d).left||`${u.left}`);d.style.left=`${Math.max(h,f-p)}px`;}u.left<h&&(d.style.left=`${h}px`);}catch{}},a=()=>l();window.addEventListener("resize",a),window.addEventListener("scroll",a,true);let c=new MutationObserver(()=>{setTimeout(l,0);});return c.observe(document.body,{childList:true,subtree:true}),()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a,true),c.disconnect();}},[]),jsx(Ug,{ref:r,trigger:o,on:n,closeOnDocumentClick:true,repositionOnResize:true,position:t,className:"mail-inbox-popup",children:s})},Ve=jg;var Gg=[{label:"Sans Serif",value:"sans-serif",style:{fontFamily:"sans-serif"}},{label:"Serif",value:"serif",style:{fontFamily:"serif"}},{label:"Fixed Width",value:"monospace",style:{fontFamily:"monospace"}},{label:"Wide",value:"wide",style:{fontWeight:"bold",letterSpacing:"0.05em"}},{label:"Narrow",value:"narrow",style:{fontStretch:"condensed"}},{label:"Comic Sans MS",value:"Comic Sans MS",style:{fontFamily:"Comic Sans MS, cursive"}},{label:"Garamond",value:"Garamond",style:{fontFamily:"Garamond, serif"}},{label:"Georgia",value:"Georgia",style:{fontFamily:"Georgia, serif"}},{label:"Tahoma",value:"Tahoma",style:{fontFamily:"Tahoma, sans-serif"}},{label:"Trebuchet MS",value:"Trebuchet MS",style:{fontFamily:"Trebuchet MS, sans-serif"}},{label:"Verdana",value:"Verdana",style:{fontFamily:"Verdana, sans-serif"}}],bo=[{key:"small",label:"Small",sizePx:12,htmlNodeVal:"2"},{key:"normal",label:"Normal",sizePx:18,htmlNodeVal:"4"},{key:"large",label:"Large",sizePx:28,htmlNodeVal:"6"},{key:"huge",label:"Huge",sizePx:56,htmlNodeVal:"7"}],$i=["#000000","#3a3a3a","#5a5a5a","#8a8a8a","#bfbfbf","#dedede","#f3f3f3","#ffffff"],Fi=["#e53935","#fb8c00","#ffee58","#66ff66","#4dd0e1","#1e88e5","#9c27b0","#ff3bd6"],Di=[["#f7d7d7","#f3d0c8","#f0c5c5","#efc9d8","#f7e6e9","#f3edf7","#f0eaf6","#f8f0f6"],["#f0b9b9","#f0d4c2","#e6f0d2","#e4f7e8","#d8eef8","#dbe1ff","#e9d9f6","#f5d9f7"],["#e69a9a","#e6caa3","#d7e6b0","#c8f0e6","#bfe3ff","#cbd8ff","#d6c3f3","#f0c2f3"],["#d16464","#d09a6a","#a8cf7b","#7fd6c0","#73b7ff","#7a9cff","#b483f1","#f08cf2"],["#b23a3a","#b26a3a","#7aa04a","#3fb092","#296f94","#2a4177","#452a68","#6e1f4d"],["#7a1d1d","#7a4a1e","#556a2a","#195b47","#123f5a","#182840","#2a1836","#3a1026"]],Li=Gg;function Pi({value:o="sans-serif",onChange:e}){let n=Li?.find(r=>r.value===o)?.label||(o==="serif"?"Serif":"Sans Serif");return jsx("div",{children:jsx(Ve,{trigger:jsxs("button",{className:"font-option heading",children:[n,jsx(X,{name:"DownArrow"})]}),children:({close:r})=>jsx("div",{className:"p-4 mail-inbox-popup-content",children:jsx("div",{className:"font-options",children:Li.map(i=>jsx("button",{className:"btn-mail-editor",onClick:()=>{e(i.value),r();},style:{...i.style},children:jsxs("div",{className:"font-option",children:[o===i.value&&jsx(X,{name:"Check"}),i.label]})},i.value))})})})})}function Ii({value:o=16,onChange:e=()=>{}}){return jsx("div",{children:jsx(Ve,{trigger:jsxs("button",{className:"font-option heading tool-bar-button","data-tooltip":"Size",children:[jsx(X,{name:"TextFields",className:"tool-bar-button-icon"}),jsx(X,{name:"DownArrow",className:"tool-bar-button-icon"})]}),children:({close:t})=>jsx("div",{className:"p-4 mail-inbox-popup-content",children:jsx("div",{className:"font-options",children:bo.map(n=>jsx("button",{className:"btn-mail-editor",onClick:()=>{e(n.key),t();},style:{fontSize:`${n.sizePx}px`},children:jsxs("div",{className:"font-option",children:[o===n.sizePx&&jsx(X,{name:"Check"}),n.label]})},n.key))})})})})}function Co({color:o,selected:e,onClick:t,label:n}){return jsx("button",{className:"swatch",title:n||o,"aria-pressed":e,onClick:()=>t(o),style:{background:o},children:e&&jsx("svg",{className:"check",viewBox:"0 0 24 24","aria-hidden":true,children:jsx("path",{d:"M20 6L9 17l-5-5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})}function Ki({value:o={background:null,text:null},onChange:e=()=>{}}){function t(n,r){e({...o,[n]:r});}return jsx("div",{children:jsx(Ve,{trigger:jsxs("button",{className:"font-option heading tool-bar-button","data-tooltip":"Text color",children:[jsx(X,{name:"Styling",className:"tool-bar-button-icon"}),jsx(X,{name:"DownArrow",className:"tool-bar-button-icon"})]}),children:({close:n})=>jsx("div",{className:"color-popover mail-inbox-popup-content",role:"dialog","aria-label":"Choose colors",children:jsxs("div",{className:"color-columns",children:[jsxs("section",{className:"color-column","aria-labelledby":"bg-label",children:[jsx("h4",{id:"bg-label",children:"Background color"}),jsx("div",{className:"row",children:$i.map(r=>jsx(Co,{color:r,selected:o.background===r,onClick:i=>{t("background",i),n();},label:r},r+"bg"))}),jsx("div",{className:"row accent-row",children:Fi.map(r=>jsx(Co,{color:r,selected:o.background===r,onClick:i=>{t("background",i),n();},label:r},r+"bgacc"))}),jsx("div",{className:"palette",children:Di.map((r,i)=>jsx("div",{className:"palette-row",children:r.map(s=>jsx(Co,{color:s,selected:o.background===s,onClick:l=>{t("background",l),n();},label:s},s+"bgp"+i))},"row"+i))})]}),jsxs("section",{className:"color-column","aria-labelledby":"text-label",children:[jsx("h4",{id:"text-label",children:"Text color"}),jsx("div",{className:"row",children:$i.map(r=>jsx(Co,{color:r,selected:o.text===r,onClick:i=>{t("text",i),n();},label:r},r+"tx"))}),jsx("div",{className:"row accent-row",children:Fi.map(r=>jsx(Co,{color:r,selected:o.text===r,onClick:i=>{t("text",i),n();},label:r},r+"txacc"))}),jsx("div",{className:"palette",children:Di.map((r,i)=>jsx("div",{className:"palette-row",children:r.map(s=>jsx(Co,{color:s,selected:o.text===s,onClick:l=>{t("text",l),n();},label:s},s+"txp"+i))},"txrow"+i))})]})]})})})})}var gc=[{key:"left",iconName:"LeftAlign",label:"Left align"},{key:"center",iconName:"CenterAlign",label:"Center align"},{key:"right",iconName:"RightAlign",label:"Right align"}];function zi({value:o="left",onChange:e=()=>{}}){function t(n){e(n);}return jsx("div",{children:jsx(Ve,{trigger:jsxs("button",{className:"font-option heading tool-bar-button","data-tooltip":"Align",children:[jsx(X,{name:gc?.find(n=>n.key===o)?.iconName||"LeftAlign"}),jsx(X,{name:"DownArrow",className:"tool-bar-button-icon"})]}),children:({close:n})=>jsx(Fragment,{children:gc.map(r=>{let i=r.key===o;return jsxs("button",{role:"menuitemradio","aria-checked":i,tabIndex:0,className:`alignment-option ${i?"active":""}`,onClick:()=>{t(r.key),n();},children:[jsx(X,{name:r.iconName,size:20,className:"select-option-icon"}),jsx("div",{className:`option-check ${i?"":"hidden"}`,"aria-hidden":true,children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",children:jsx("path",{d:"M20 6L9 17l-5-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},r.key)})})})})}var So=class o extends TextNode{__customStyle;static getType(){return "styled-text"}static clone(e){let t=new o(e.__text,e.__key);return t.__customStyle=e.__customStyle??"",t}constructor(e,t){super(e,t),this.__customStyle="";}static importJSON(e){let t=super.importJSON(e);return t.__customStyle=e.style??"",t}exportJSON(){return {...super.exportJSON(),style:this.__customStyle}}static importDOM(){let e=t=>{let n=t.tagName,r=Sc(t);return {node:null,forChild:i=>{if(!(i instanceof TextNode))return i;let s=i instanceof o?i.getWritable():new o(i.getTextContent());return r&&(s.__customStyle=Bi(s.__customStyle,Jo(r))),(n==="STRONG"||n==="B")&&s.toggleFormat("bold"),(n==="EM"||n==="I")&&s.toggleFormat("italic"),n==="U"&&s.toggleFormat("underline"),(n==="S"||n==="STRIKE")&&s.toggleFormat("strikethrough"),n==="CODE"&&s.toggleFormat("code"),s}}};return {span:()=>({conversion:e,priority:2}),strong:()=>({conversion:e,priority:2}),b:()=>({conversion:e,priority:2}),em:()=>({conversion:e,priority:2}),i:()=>({conversion:e,priority:2}),u:()=>({conversion:e,priority:2}),s:()=>({conversion:e,priority:2}),code:()=>({conversion:e,priority:2})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&"setAttribute"in t&&this.__customStyle&&t.setAttribute("style",this.__customStyle),{element:t}}createDOM(e){let t=super.createDOM(e);return this.__customStyle&&t.setAttribute("style",this.__customStyle),t}updateDOM(e,t,n){return super.updateDOM(e,t,n)?true:(e.__customStyle!==this.__customStyle&&(this.__customStyle?t.setAttribute("style",this.__customStyle):t.removeAttribute("style")),false)}patchStyle(e){let t=this.getWritable();t.__customStyle=Bi(t.__customStyle,e);}getStyleProperty(e){return Jo(this.__customStyle)[e]}setCustomStyle(e){let t=this.getWritable();t.__customStyle=e;}clearStyle(){let e=this.getWritable();e.__customStyle="";}getCustomStyle(){return this.__customStyle}};function xo(o){return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)}function Jo(o){return Object.fromEntries(o.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let[t,...n]=e.split(":");return [t.trim(),n.join(":").trim()]}))}function xc(o){return Object.entries(o).filter(([,e])=>e!=null&&e!=="").map(([e,t])=>`${e}: ${t}`).join("; ")}function Bi(o,e){let t=Jo(o);for(let[n,r]of Object.entries(e))r===null?delete t[n]:t[n]=r;return xc(t)}function Sc(o){let e=Jo(o.getAttribute("style")??"");return delete e["white-space"],xc(e)}function qo(o){let e=$getSelection();if(!$isRangeSelection(e))return;e.getNodes().forEach(n=>{if(n instanceof So)n.patchStyle(o);else {let r=Object.fromEntries(Object.entries(o).filter(([,i])=>i!==null));Object.keys(r).length&&$patchStyleText(e,r);}});}function Gn(o,e){document.dispatchEvent(new CustomEvent("signature:style",{detail:{command:o,value:e}}));}function yc(){let[o,e]=useState(false);return useEffect(()=>{let t=()=>{let n=window.getSelection();if(!n||n.rangeCount===0){e(false);return}let r=n.anchorNode,i=!!r?.closest?.('[data-signature="true"]')||!!r?.parentElement?.closest('[data-signature="true"]');e(i);};return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[]),o}var Zo={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikeThrough",subscript:"subscript",superscript:"superscript",fontSize:"fontSize",backColor:"backColor",foreColor:"foreColor"};function sb(o){let[e,t]=useState(false);return useEffect(()=>{let n=()=>{let r=window.getSelection();if(!r||r.rangeCount===0||!o.current){t(false);return}t(o.current.contains(r.anchorNode));};return document.addEventListener("selectionchange",n),()=>document.removeEventListener("selectionchange",n)},[o]),e}function Nc({nodeKey:o,html:e}){let[t]=useLexicalComposerContext(),n=useRef(null),r=useRef(false),i=sb(n);useEffect(()=>{r.current=i;},[i]);let s=useCallback(()=>{let a=n.current?.innerHTML??"";t.update(()=>{let c=$getNodeByKey(o);c&&a!==c.__html&&c.setHTML(a);});},[t,o]);useEffect(()=>{let a=t.registerCommand(FORMAT_TEXT_COMMAND,c=>{if(!r.current)return false;let d=Zo[c];return d&&document.execCommand(d,false),s(),true},COMMAND_PRIORITY_CRITICAL);return ()=>{a();}},[t,s]),useEffect(()=>{let a=c=>{if(!r.current)return;let{command:d,value:u}=c.detail;document.execCommand(d,false,u),s();};return document.addEventListener("signature:style",a),()=>document.removeEventListener("signature:style",a)},[s]);let l=a=>a.stopPropagation();return jsx("div",{ref:n,contentEditable:true,suppressContentEditableWarning:true,dangerouslySetInnerHTML:{__html:e},onBlur:s,onInput:l,onKeyDown:l,onKeyUp:l,onKeyPress:l,onPaste:l,onCut:l,onCopy:l,onClick:l,onMouseDown:l,"data-signature":"true",style:{outline:"none",cursor:"text",borderRadius:4},onFocus:a=>{},onBlurCapture:a=>{a.currentTarget.style.outline="none";}})}var yb=1;function Mc(o){if(!o||o.startsWith("#"))return o;if(o.startsWith("rgba")){let t=o.match(/rgba?\((\d+),\s*(\d+),\s*(\d+),?\s*([\d.]+)?\)/);if(t){let[,n,r,i,s]=t;return s==="0"?"transparent":"#"+[n,r,i].map(l=>{let a=parseInt(l).toString(16);return a.length===1?"0"+a:a}).join("")}}let e=o.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){let[,t,n,r]=e;return "#"+[t,n,r].map(i=>{let s=parseInt(i).toString(16);return s.length===1?"0"+s:s}).join("")}return o}function wb(){let[o]=useLexicalComposerContext(),[e,t]=useState("paragraph"),[n,r]=useState({[_.fontFamily]:"sans-serif",[_.fontSize]:16,[_.align.base]:"left",[_.bold]:false,[_.italic]:false,[_.underline]:false}),[i,s]=useState(false),l=yc(),a=useCallback(()=>{o.getEditorState().read(()=>{let w=$getSelection(),S={[_.fontFamily]:"sans-serif",[_.fontSize]:16,[_.align.base]:"left"};if($isRangeSelection(w)){let y=w.anchor.getNode();if(y===null)return;let N=y.getKey()==="root"?y:y.getTopLevelElementOrThrow(),E=N.getKey(),R=o.getElementByKey(E);if(R!==null)if($isListNode(N)){let K=$getNearestNodeOfType(y,ListNode),V=K?K.getTag():N.getTag();t(V);}else {let K=N.getType();t(K);}S[_.strike]=w.hasFormat("strikethrough"),S[_.code]=w.hasFormat("code");let L=x(w),k=L.getParent();$isLinkNode(k)||$isLinkNode(L)?(S[_.link]=true,s(true)):(S[_.link]=false,s(false));let M=o.getElementByKey(L.getKey()),v=o.getElementByKey(k.getKey()),T=M||v||R;if(T){let K=window.getComputedStyle(T),V="";if(w.isCollapsed()&&(V=w.style.split("font-family:")[1]?.split(";")[0]?.trim().replace(/['"]/g,"")||""),V||(V=K.getPropertyValue("font-family")),V){let Ae=V.split(",")[0].trim().replace(/['"]/g,"");(["-apple-system","BlinkMacSystemFont","system-ui","Arial","Helvetica"].includes(Ae)||["Times New Roman","Times"].includes(Ae))&&(Ae="sans-serif"),S[_.fontFamily]=Ae;}let ie="";if(w.isCollapsed()&&(ie=w.style.split("font-size:")[1]?.split(";")[0]?.trim()||""),ie||(ie=K.getPropertyValue("font-size")),ie){let Ae=parseInt(ie,10);S[_.fontSize]=Ae||16;}let re=null,se=null;T instanceof HTMLElement&&T.style&&(re=T.style.color||null,se=T.style.backgroundColor||null);let Ce=re?Mc(re):null,ve=se&&se!=="rgba(0, 0, 0, 0)"&&se!=="transparent"?Mc(se):null;(Ce||ve)&&(S[_.color.base]={text:Ce||"#000000",background:ve});let Le=K.getPropertyValue("text-align")||"left";Le==="start"&&(Le="left"),S[_.align.base]=Le;}r(K=>({...K,...S}));}});},[o]),c=(w,S,y,N)=>{o.update(()=>{let E=$getSelection();if(!$isRangeSelection(E))return;let R=x(E),L=o.getElementByKey(R.getKey())||o.getElementByKey(R.getParent().getKey()),k=L?window.getComputedStyle(L).getPropertyValue(S):"",M=N(k);r(v=>({...v,[w]:!v[w]})),qo({[S]:M?"":y});});};useEffect(()=>{a();},[o,a]),useEffect(()=>mergeRegister(o.registerUpdateListener(({editorState:w})=>{w.read(()=>{a();});}),o.registerCommand(SELECTION_CHANGE_COMMAND,()=>(a(),false),yb)),[o,a]);function d(w,S){switch(w){case _.bold:c(_.bold,"font-weight","700",y=>y==="bold"||(parseInt(y||"0",10)||0)>=600);break;case _.italic:c(_.italic,"font-style","italic",y=>y==="italic");break;case _.underline:c(_.underline,"text-decoration","underline",y=>y.includes("underline"));break;case _.align.base:o.dispatchCommand(FORMAT_ELEMENT_COMMAND,S);break;case _.undo:o.dispatchCommand(UNDO_COMMAND,void 0);break;case _.redo:o.dispatchCommand(REDO_COMMAND,void 0);break;case _.listNumber:C();break;case _.listBullet:b();break;case _.indent:u();break;case _.indentDecrease:g();break;case _.color.base:f(S);break;case _.fontFamily:{let y=S;r(N=>({...N,[_.fontFamily]:y})),h(y);break}case _.fontSize:{let y=S,N=bo.find(E=>E.key===y)?.sizePx??16;r(E=>({...E,[_.fontSize]:N})),p(y);break}case _.link:m();break;}}let u=()=>{o.dispatchCommand(INDENT_CONTENT_COMMAND,void 0);},h=w=>{o.update(()=>{let S=$getSelection();$isRangeSelection(S)&&qo({"font-family":w});});},p=w=>{if(l){let S=bo.find(y=>y.key===w)?.htmlNodeVal??"2";Gn(Zo.fontSize,S);}else {let S=bo.find(y=>y.key===w)?.sizePx??16;o.update(()=>{let y=$getSelection();$isRangeSelection(y)&&qo({"font-size":`${S}px`});});}},f=w=>{l?(Gn(Zo.backColor,w.background),Gn(Zo.foreColor,w.text)):o.update(()=>{let S=$getSelection();$isRangeSelection(S)&&qo({"background-color":w.background,color:w.text});});},m=useCallback(()=>{i?o.dispatchCommand(TOGGLE_LINK_COMMAND,null):o.update(()=>{let w=$getSelection();if($isRangeSelection(w)){w.isCollapsed()&&w.modify("extend",true,"word");let S=$getSelection();$isRangeSelection(S)&&!S.isCollapsed()&&o.dispatchCommand(TOGGLE_LINK_COMMAND,"https://");}});},[o,i]),g=()=>{o.dispatchCommand(OUTDENT_CONTENT_COMMAND,void 0);},b=()=>{e!=="ul"?o.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND,void 0):o.dispatchCommand(REMOVE_LIST_COMMAND,void 0);},C=()=>{e!=="ol"?o.dispatchCommand(INSERT_ORDERED_LIST_COMMAND,void 0):o.dispatchCommand(REMOVE_LIST_COMMAND,void 0);};function x(w){let S=w.anchor,y=w.focus,N=w.anchor.getNode(),E=w.focus.getNode();return N===E?N:w.isBackward()?$isAtNodeEnd(y)?N:E:$isAtNodeEnd(S)?E:N}return {onChange:d,isLink:i,editor:o,selectedEventTypes:n,blockType:e}}var kc=wb;function Rb({editor:o}){let e=useRef(null),t=useRef(null),n=useRef(false),[r,i]=useState(""),[s,l]=useState(false),[a,c]=useState(false),[d,u]=useState(null),h=useCallback(()=>{let p=window.getSelection(),f=$getSelection(),m=false,g="";if($isRangeSelection(f)){let w=Ob(f),S=w.getParent();$isLinkNode(S)?(g=S.getURL(),m=true):$isLinkNode(w)&&(g=w.getURL(),m=true);}i(g),c(m);let b=e.current,C=document.activeElement;if(!b)return;let x=o.getRootElement();if(f&&p&&x&&x.contains(p.anchorNode)&&(s||!p.isCollapsed||m||g!=="")){let w=p.getRangeAt(0),S;if(p.anchorNode===x){let y=x;for(;y.firstElementChild!=null;)y=y.firstElementChild;S=y.getBoundingClientRect();}else S=w.getBoundingClientRect();n.current||Fc(b,S),u(f);}else (!C||C.className!=="link-input")&&(Fc(b,null),u(null),l(false),i(""));return true},[o]);return useEffect(()=>mergeRegister(o.registerUpdateListener(({editorState:p})=>{p.read(()=>{h();});}),o.registerCommand(SELECTION_CHANGE_COMMAND,()=>(h(),true),1)),[o,h]),useEffect(()=>{o.getEditorState().read(()=>{h();});},[o,h]),useEffect(()=>{s&&t.current&&t.current.focus();},[s]),useEffect(()=>{r==="https://"&&l(true);},[r]),jsx("div",{className:"floating-link-editor",ref:e,children:s?jsxs(Fragment,{children:[jsx("input",{ref:t,className:"link-input",value:r,onChange:p=>i(p.target.value),onKeyDown:p=>{p.key==="Enter"?(p.preventDefault(),d&&r!==""&&o.dispatchCommand(TOGGLE_LINK_COMMAND,r),l(false)):p.key==="Escape"&&(p.preventDefault(),l(false));},placeholder:"Enter link..."}),jsx("button",{className:"link-button",onMouseDown:p=>p.preventDefault(),onClick:()=>{s&&o.dispatchCommand(TOGGLE_LINK_COMMAND,r),l(false);},children:jsx(X,{name:"Check"})})]}):jsxs("div",{className:"link-view-mode",children:[jsx("span",{className:"link-view-label",children:"Go to link:"}),jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"link-view-url",children:r}),jsx("span",{className:"link-view-divider",children:"|"}),jsx("button",{className:"link-text-button",onMouseDown:p=>p.preventDefault(),onClick:()=>l(true),children:"Change"}),jsx("span",{className:"link-view-divider",children:"|"}),jsx("button",{className:"link-text-button",onMouseDown:p=>p.preventDefault(),onClick:()=>{o.dispatchCommand(TOGGLE_LINK_COMMAND,null),l(false);},children:"Remove"})]})})}function Ob(o){let e=o.anchor.getNode(),t=o.focus.getNode();return e===t?e:o.isBackward()?$isAtNodeEnd(o.focus)?e:t:$isAtNodeEnd(o.anchor)?t:e}function Fc(o,e){if(!e){o.style.opacity="0",o.style.top="-1000px",o.style.left="-1000px";return}let t=o.offsetWidth,n=o.offsetHeight,r=window.innerWidth,i=window.innerHeight,s=e.top+e.height+window.pageYOffset+10,l=e.left+window.pageXOffset-t/2+e.width/2;l<8&&(l=8),l+t>r-8&&(l=r-t-8),s+n>i-8&&(s=e.top+window.pageYOffset-n-10),s<8&&(s=8),o.style.opacity="1",o.style.top=`${s}px`,o.style.left=`${l}px`;}var Lc=Rb;var bt={FILE_INVALID_TYPE:"file-invalid-type",FILE_TOO_LARGE:"file-too-large",TOO_MANY_FILES:"too-many-files",HEIC_CONVERSION_ERROR:"heic-conversion-error"},$b=10,Fb=10,Kc=()=>Math.random().toString(36).substring(2,10)+Date.now().toString(36),Db=o=>{if(o<1024)return {value:o.toString(),type:"bytes"};let e=o/1024;if(e<1024)return {value:e.toFixed(1),type:"KB"};let t=e/1024;return t<1024?{value:t.toFixed(1),type:"MB"}:{value:(t/1024).toFixed(1),type:"GB"}},zc=({accept:o={"image/*":[".png",".gif",".jpeg",".jpg"],"application/pdf":[".pdf"]},maxSize:e=Fb*1024*1024,maxFiles:t=$b,multiple:n=true,isDisabled:r=false,replaceAfterUpload:i=false,files:s=[],handleFileChange:l=()=>{}})=>{let[a,c]=useState(false),[d,u]=useState(s??[]),[h,p]=useState([]),f=S=>{switch(S){case bt.FILE_INVALID_TYPE:return "Invalid file type. Please upload a supported format.";case bt.FILE_TOO_LARGE:{let{value:y,type:N}=Db(e);return `File too large. Maximum allowed size is ${y} ${N}.`}case bt.TOO_MANY_FILES:return `Too many files selected. Maximum allowed: ${t}.`;case bt.HEIC_CONVERSION_ERROR:return "Failed to convert HEIC image. Please upload a JPEG or PNG instead.";default:return "An unknown file error occurred."}};useEffect(()=>{l(d);},[d]);let{getRootProps:m,getInputProps:g,isDragActive:b,open:C}=useDropzone({accept:o,maxSize:e,multiple:n,maxFiles:t,disabled:r,noClick:true,onFileDialogCancel:()=>c(false),onFileDialogOpen:()=>{r||c(true);},onDrop:async(S,y)=>{let E=(await Promise.all(S.map(async R=>{if(!R)return null;if(R.type==="image/heic")try{let L=await Ab({blob:R,toType:"image/jpeg"}),k=Array.isArray(L)?L[0]:L,M=new File([k],`${R.name.replace(/\.heic$/i,"")}.jpeg`,{type:"image/jpeg"});return Object.assign(M,{uuid:Kc(),preview:URL.createObjectURL(M)})}catch(L){console.error("HEIC conversion error:",L);let k=f(bt.HEIC_CONVERSION_ERROR);return p(M=>[...M,{file:R,preview:URL.createObjectURL(R),readableErrors:[k],errors:[{code:bt.HEIC_CONVERSION_ERROR,message:k}]}]),null}return Object.assign(R,{uuid:Kc(),preview:URL.createObjectURL(R)})}))).filter(Boolean);if(!r){let R=i?[]:[...d];R=[...R,...E];let L=y.map(k=>{let M=k.errors.map(v=>f(v.code));return {file:k.file,errors:k.errors.map(v=>({code:v.code,message:v.message})),preview:URL.createObjectURL(k.file),readableErrors:M}});return p(k=>[...k,...L]),u(R),R}return d},validator:S=>{let{name:y,type:N}=S;if(y){let E=y.split(".").pop()?.toLowerCase();if(o&&o?.[N]&&o?.[N].length&&!o?.[N].includes(`.${E}`))return {code:bt.FILE_INVALID_TYPE,message:f(bt.FILE_INVALID_TYPE)}}return null}}),x=useCallback(S=>{u(y=>y.filter(N=>N.uuid!==S));},[u]),w=useCallback(()=>{p([]);},[]);return useEffect(()=>()=>{d.forEach(S=>S.preview&&URL.revokeObjectURL(S.preview)),h.forEach(S=>S.preview&&URL.revokeObjectURL(S.preview));},[]),{getRootProps:m,getInputProps:g,isDragActive:b,isFileDialogOpen:a,rejectedFiles:h,openFileDialog:C,removeFile:x,clearRejectedFiles:w}};var Lb=({handleFileChange:o})=>{let{getRootProps:e,getInputProps:t,openFileDialog:n}=zc({multiple:true,maxFiles:5,maxSize:5242880,handleFileChange:r=>{o(r);}});return jsx("div",{className:"uploader-container",children:jsxs("div",{...e(),children:[jsx("input",{...t()}),jsx("button",{onClick:n,className:"tool-bar-button","data-tooltip":"Attach files",children:jsx(X,{className:"upload-icon",name:"Attach"})})]})})},Bc=Lb;function Gi({file:o,index:e,onRemove:t,onView:n}){if(!o)return null;let r=o?.name??"unknown",i=o instanceof File||"size"in o&&o.size!==void 0?o.size:"bytes"in o&&o.bytes!==void 0?o.bytes:null,s=("url"in o?o?.url:null)??null,l=useMemo(()=>{if(s)return s;if(typeof window<"u"&&o instanceof File)try{return URL.createObjectURL(o)}catch{return null}return null},[o,s]),a=u=>{if(!u&&u!==0)return "";let h=Math.round(u/1024);return h<1024?`${h}K`:`${Math.round(u/1024/1024*10)/10}M`},c=u=>{if(u.preventDefault(),n)return n(l??null);l&&window.open(l,"_blank","noopener");},d=u=>{t&&t(u);};return jsxs("div",{className:"fps-row",role:"group","aria-label":`Attachment ${r}`,children:[jsxs("div",{className:"fps-left",children:[jsx("a",{href:l??"#",className:"fps-filename",onClick:c,title:r,target:"_blank",rel:"noopener noreferrer",children:r}),i!=null&&jsxs("span",{className:"fps-size",children:["\xA0(",a(i),")"]})]}),jsx("button",{type:"button",className:"fps-close","aria-label":`Remove ${r}`,onClick:()=>d(e),children:"\xD7"})]})}function Uc(o,e,t,n,r){let i=n||["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"],s=r||"https://www.googleapis.com/auth/drive.readonly",[l,a]=useState(false),[c,d]=useState(false),[u,h]=useState(null),[p,f]=useState(null);useEffect(()=>{o&&e&&(()=>{let C=document.createElement("script");C.src="https://apis.google.com/js/api.js",C.async=true,C.defer=true,C.onload=()=>{e&&window.gapi.load("client:picker",async()=>{await window.gapi.client.init({apiKey:e,discoveryDocs:i}),a(true);});},document.body.appendChild(C);let x=document.createElement("script");x.src="https://accounts.google.com/gsi/client",x.async=true,x.defer=true,x.onload=()=>{if(!o)return;let w=window.google.accounts.oauth2.initTokenClient({client_id:o,scope:s,callback:""});h(w),d(true);},document.body.appendChild(x);})();},[o,e]);let m=useCallback(b=>{if(!e)return;new window.google.picker.PickerBuilder().addView(window.google.picker.ViewId.DOCS).setOAuthToken(b).setDeveloperKey(e).setSize(1051,650).setCallback(async x=>{if(x.action===window.google.picker.Action.PICKED){let w=x.docs.map(S=>new File([],S.name,{type:S.mimeType}));t(w);}}).build().setVisible(true);},[t]);return {openPicker:useCallback(()=>{if(u){if(p){m(p);return}u.callback=async b=>{if(b.error!==void 0)throw b;f(b.access_token),m(b.access_token);},u.requestAccessToken({prompt:"consent"});}},[u,p,m]),isLoaded:l&&c}}var jb=({onEmojiSelect:o})=>{let e=useRef(null),[t,n]=Qc__default.useState(false);return useEffect(()=>{n(true),console.log("EmojiPicker: isClient set to true");},[]),t?jsx("div",{ref:e,onClick:r=>r.stopPropagation(),onMouseDown:r=>r.stopPropagation(),children:jsx(Wb,{data:Ub,onEmojiSelect:r=>{console.log("Emoji selected:",r),o(r);}})}):null},Yc=jb;function Gb({src:o,altText:e}){return jsx("img",{src:o,alt:e})}var zt=class o extends DecoratorNode{__src;__altText;static getType(){return "image"}static clone(e){let t=new o(e.__key);return t.__src=e.__src,t.__altText=e.__altText,t}constructor(e){super(e),this.__src="",this.__altText="";}static importJSON(e){let t=Xi(e.src,e.altText);return t.setSrc(e.src),t.setAltText(e.altText),t}exportJSON(){return {altText:this.getAltText(),src:this.getSrc(),type:"image",version:1}}createDOM(e){let t=document.createElement("div");return t.style.display="contents",t}updateDOM(){return false}setSrc(e){let t=this.getWritable();t.__src=e;}getSrc(){return this.__src}setAltText(e){let t=this.getWritable();t.__altText=e;}getAltText(){return this.__altText}getTextContent(){return this.__altText}decorate(){return Qc.createElement(Gb,{src:this.__src,altText:this.__altText})}};function Xi(o,e){let t=new zt;return t.setSrc(o),t.setAltText(e),t}var Vi=createCommand();function Ji(){let[o]=useLexicalComposerContext();return useEffect(()=>{if(!o.hasNodes([zt]))throw new Error("ImagesPlugin: ImageNode not registered on editor");return o.registerCommand(Vi,e=>{let{src:t,altText:n}=e,r=Xi(t,n);return $insertNodeToNearestRoot(r),true},COMMAND_PRIORITY_EDITOR)},[o]),null}var Qn=(o,{onChange:e,state:t,setState:n,selectedEventTypes:r,blockType:i,setAttachments:s,setShowEmojiPicker:l,setEmojiPosition:a,isLink:c,editor:d,openDrivePicker:u})=>{switch(o.name){case _.undo:case _.redo:case _.bold:case _.italic:case _.underline:case _.indentDecrease:case _.indent:return jsx("button",{className:`tool-bar-button ${r?.[o.name]?"active-btn-toolbar":""}`,onClick:()=>e(o.name,true),"data-tooltip":o.label,children:jsx(X,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`);case _.drive:return jsx("button",{className:`tool-bar-button ${r?.[o.name]?"active-btn-toolbar":""}`,onClick:u,"data-tooltip":"Insert files using Drive",children:jsx(X,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`);case _.insertPhoto:return jsxs(Fragment,{children:[jsx("input",{type:"file",accept:"image/*",style:{display:"none"},id:"image-upload",onChange:h=>{let p=h.target.files;if(p&&p.length>0){let f=new FileReader;f.onloadend=()=>{d&&d.dispatchCommand(Vi,{src:f.result,altText:p[0].name});},f.readAsDataURL(p[0]);}}}),jsx("button",{className:`tool-bar-button ${r?.[o.name]?"active-btn-toolbar":""}`,onClick:()=>{document.getElementById("image-upload")?.click();},"data-tooltip":o.label,children:jsx(X,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`)]});case _.link:return jsx("button",{className:`tool-bar-button ${c?"active-btn-toolbar":""}`,onClick:()=>e(o.name,true),"data-tooltip":o.label,children:jsx(X,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`);case _.listNumber:return jsx("button",{className:`tool-bar-button ${i==="ol"?"active-btn-toolbar":""}`,onClick:()=>e(o.name,true),"data-tooltip":o.label,children:jsx(X,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`);case _.listBullet:return jsx("button",{className:`tool-bar-button ${i==="ul"?"active-btn-toolbar":""}`,onClick:()=>e(o.name,true),"data-tooltip":o.label,children:jsx(X,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`);case _.attachFile:return jsx(Bc,{value:t?.[o.name],handleFileChange:h=>{n(p=>({...p,[o.name]:h})),s(h);}});case _.fontFamily:return jsx(Pi,{value:r?.[o.name]||t?.[o.name],onChange:h=>e(o.name,h)});case _.fontSize:return jsx(Ii,{value:r?.[o.name]||t?.[o.name],onChange:h=>e(o.name,h)});case _.color.base:return jsx(Ki,{value:r?.[o.name]||t?.[o.name],onChange:h=>e(o.name,h)});case _.align.base:return jsx(zi,{value:r?.[o.name]||t?.[o.name],onChange:h=>e(o.name,h)});case _.emoji:return jsx("button",{className:"tool-bar-button",onMouseDown:h=>{h.preventDefault(),h.stopPropagation(),console.log("Emoji button clicked, current state:",l);let p=h.currentTarget.getBoundingClientRect(),f=p.top+window.scrollY-440;a({top:f<0?p.bottom+window.scrollY+10:f,left:Math.max(10,p.left+window.scrollX)}),l(m=>!m);},type:"button","data-tooltip":"Insert emoji",children:jsx("div",{style:{pointerEvents:"none"},children:jsx(X,{className:"tool-bar-button-icon",name:o.icon})})},o.name);}if(o.type===ne.divider)return jsx("span",{className:"divider"})},rC=(o,e)=>{let{key:t,...n}=e;switch(o.type){case ne.divider:return jsx("div",{className:"divider"},t);case ne.component:return jsx("div",{style:{display:"contents"},children:Qn(o,n)},t);case ne.styling:return jsxs("div",{className:"styling-toolbar",children:[e.toggle&&o.options?.length?jsxs("div",{className:"styling-options",children:[e.isMoreVisible?e.visibleFormattingPlugins.map((r,i)=>jsx("div",{style:{display:"contents"},children:r.hideOnCollapse?null:Qn(r,n)},`${r.name}-${i}`)):o.options.map((r,i)=>jsx("div",{style:{display:"contents"},children:Qn(r,n)},`${r.name}-${i}`)),jsxs("div",{className:"more-wrapper",children:[jsx("button",{className:"tool-bar-button more-button",onClick:()=>e.setMoreOpen(r=>!r),"data-tooltip":"More",children:jsx(X,{className:"tool-bar-button-icon",name:"DownArrow"})}),e.moreOpen&&jsx("div",{className:"more-dropdown",children:e.collapsedFormattingPlugins.map((r,i)=>jsx("div",{className:"more-item",children:jsx("div",{style:{display:"contents"},children:Qn(r,n)},`${r.name}-${i}`)},`more-${i}`))})]})]}):null,jsx("button",{onClick:()=>e.setToggle(r=>!r),className:"tool-bar-button","data-tooltip":"Formatting options",children:jsx(X,{className:"tool-bar-button-icon",name:o.icon})})]},t);default:return}};function iC({rightChildren:o,leftChildren:e,customTool:t,disabled:n}){let[r,i]=useState(true),[s,l]=useState({}),[a,c]=useState(false),[d,u]=useState(null),[h,p]=useState(false),[f,m]=useState(false),b=Ai.find(v=>v.type===ne.styling)?.options||[],C=b.filter(v=>v?.collapse),x=b.filter(v=>!v?.collapse),{setAttachments:w,googleDriveConfig:S}=it(),{onChange:y,isLink:N,editor:E,selectedEventTypes:R,blockType:L}=kc(),{openPicker:k}=Uc(S?.clientId,S?.apiKey,v=>{l(T=>{let V=[...T[_.attachFile]||[],...v];return w(V),{...T,[_.attachFile]:V}});},S?.discoveryDocs,S?.scopes),M=useRef(null);return useEffect(()=>{let v=new ResizeObserver(T=>{let K=T[0].contentRect.width;m(K<=720);});return M.current&&v.observe(M.current),()=>v.disconnect()},[]),jsxs("div",{ref:M,className:`toolbar-container ${n?"toolbar-disabled":""}`,children:[s[_.attachFile]?.length?jsx("div",{className:"file-upload-container",children:s[_.attachFile].map((v,T)=>jsx(Gi,{file:v,index:T,onRemove:K=>{l(V=>{let ie=V[_.attachFile].filter((re,se)=>se!==K);return w(ie),{...V,[_.attachFile]:ie}});}},v.name+T))}):null,jsxs("div",{className:"toolbar-wrapper",children:[e,jsxs("div",{className:"plugin-wrapper",children:[Ai.map((v,T)=>rC(v,{key:`${v.name||v.type}-${T}`,toggle:r,setToggle:i,onChange:y,state:s,setState:l,selectedEventTypes:R,blockType:L,setAttachments:w,setShowEmojiPicker:c,setEmojiPosition:u,isLink:N,editor:E,openDrivePicker:k,isMoreVisible:f,collapsedFormattingPlugins:C,visibleFormattingPlugins:x,moreOpen:h,setMoreOpen:p})),t]}),o,N&&createPortal(jsx(Lc,{editor:E}),document.body)]}),a&&d&&createPortal(jsx("div",{className:"emoji-picker-container",style:{position:"absolute",top:d.top,left:d.left,zIndex:9999},children:jsx(Yc,{onEmojiSelect:v=>{E?.update(()=>{let T=$getSelection();$isRangeSelection(T)?T.insertNodes([$createTextNode(v.native)]):T&&T.insertNodes([$createTextNode(v.native)]);}),c(false);}})}),document.body)]})}var Jc=iC;var lC={ltr:"ltr",rtl:"rtl",placeholder:"editor-placeholder",paragraph:"editor-paragraph",quote:"editor-quote",heading:{h1:"editor-heading-h1",h2:"editor-heading-h2",h3:"editor-heading-h3",h4:"editor-heading-h4",h5:"editor-heading-h5"},list:{nested:{listitem:"editor-nested-listitem"},ol:"editor-list-ol",ul:"editor-list-ul",listitem:"editor-listitem"},image:"editor-image",link:"editor-link",text:{bold:"editor-text-bold",italic:"editor-text-italic",overflowed:"editor-text-overflowed",hashtag:"editor-text-hashtag",underline:"editor-text-underline",strikethrough:"editor-text-strikethrough",underlineStrikethrough:"editor-text-underlineStrikethrough",code:"editor-text-code"},code:"editor-code",codeHighlight:{atrule:"editor-tokenAttr",attr:"editor-tokenAttr",boolean:"editor-tokenProperty",builtin:"editor-tokenSelector",cdata:"editor-tokenComment",char:"editor-tokenSelector",class:"editor-tokenFunction","class-name":"editor-tokenFunction",comment:"editor-tokenComment",constant:"editor-tokenProperty",deleted:"editor-tokenProperty",doctype:"editor-tokenComment",entity:"editor-tokenOperator",function:"editor-tokenFunction",important:"editor-tokenVariable",inserted:"editor-tokenSelector",keyword:"editor-tokenAttr",namespace:"editor-tokenVariable",number:"editor-tokenProperty",operator:"editor-tokenOperator",prolog:"editor-tokenComment",property:"editor-tokenProperty",punctuation:"editor-tokenPunctuation",regex:"editor-tokenVariable",selector:"editor-tokenSelector",string:"editor-tokenSelector",symbol:"editor-tokenProperty",tag:"editor-tokenProperty",url:"editor-tokenOperator",variable:"editor-tokenVariable"}},qc=lC;function qi({onChange:o}){let[e]=useLexicalComposerContext();return useEffect(()=>e.registerUpdateListener(({editorState:t})=>{t.read(()=>{let n=$generateHtmlFromNodes(e,null);o(n);});}),[e,o]),null}function Zi(){let[o]=useLexicalComposerContext();return useEffect(()=>o.registerUpdateListener(({dirtyElements:e,tags:t})=>{t.has("history-merge")||o.update(()=>{let n=$getRoot();n.getDirection()!=="ltr"&&n.setDirection("ltr");let r=n.getChildren();for(let i of r)$isParagraphNode(i)&&i.getDirection()!=="ltr"&&i.setDirection("ltr");});}),[o]),null}function Zc(o){let e=t=>{Array.from(t.classList).forEach(r=>{r.startsWith("editor-")&&t.classList.remove(r);}),t.classList.length===0&&t.removeAttribute("class");};return o.querySelectorAll("[class*='editor-text-']").forEach(t=>{let n=t,r=Array.from(n.classList),i=[];if(r.includes("editor-text-bold")&&i.push("strong"),r.includes("editor-text-italic")&&i.push("em"),r.includes("editor-text-underline")&&i.push("u"),r.includes("editor-text-strikethrough")&&i.push("s"),r.includes("editor-text-underlineStrikethrough")&&i.push("u","s"),r.includes("editor-text-code")&&i.push("code"),i.length===0)return;let s=r.filter(h=>!h.startsWith("editor-text-")),l=n.getAttribute("style")||"",a=null,c=null,d=h=>{let p=o.createElement(h);return a?c&&c.append(p):a=p,c=p,p};if(!!l.trim()||s.length>0){let h=d("span");l.trim()&&h.setAttribute("style",l),s.length>0&&h.setAttribute("class",s.join(" "));}i.forEach(h=>d(h)),!(!a||!c)&&(c.append(...Array.from(t.childNodes)),t.replaceWith(a));}),o.querySelectorAll("[style]").forEach(t=>{let r=t.style,i=r.fontWeight?.trim().toLowerCase()||"",s=Number.parseInt(i,10),l=i==="bold"||i==="bolder"||!Number.isNaN(s)&&s>=600,a=r.fontStyle?.trim().toLowerCase()||"",c=a==="italic"||a==="oblique",d=(r.textDecorationLine||r.textDecoration||"").trim().toLowerCase(),u=d.includes("underline"),h=d.includes("line-through"),p=[];if(l&&!["STRONG","B"].includes(t.tagName)&&p.push("strong"),c&&!["EM","I"].includes(t.tagName)&&p.push("em"),u&&t.tagName!=="U"&&p.push("u"),h&&!["S","DEL","STRIKE"].includes(t.tagName)&&p.push("s"),p.length===0)return;let f=Array.from(t.childNodes);if(f.length===0)return;let m=null,g=null;p.forEach(b=>{let C=o.createElement(b);m?g&&g.append(C):(m=C,t.append(C)),g=C;}),g&&g.append(...f);}),o.querySelectorAll("span, p, div, strong, em, u, s").forEach(t=>{let n=t;n.style.removeProperty("white-space"),t.tagName==="SPAN"&&!n.style.cssText.trim()&&t.className===""&&t.replaceWith(...Array.from(t.childNodes));}),o.querySelectorAll(".editor-paragraph").forEach(t=>{e(t);}),["h1","h2","h3","h4","h5","h6"].forEach(t=>{o.querySelectorAll(`.editor-heading-${t}`).forEach(n=>{let r=o.createElement(t);r.innerHTML=n.innerHTML;let i=n;i.style.cssText&&(r.style.cssText=i.style.cssText),r.style.removeProperty("white-space"),n.replaceWith(r);});}),o.querySelectorAll(".editor-listitem").forEach(t=>{e(t);}),o.querySelectorAll(".editor-list-ul, .editor-list-ol").forEach(t=>{e(t);}),o.querySelectorAll(".editor-link").forEach(t=>{e(t);}),o}function Qi({initialHTML:o}){let[e]=useLexicalComposerContext(),t=useRef(false);return useEffect(()=>{t.current||e.update(()=>{let n=$getRoot();if(n.setDirection("ltr"),n.clear(),o){let i=new DOMParser().parseFromString(o,"text/html"),s=Zc(i),l=$generateNodesFromDOM(e,s);$insertNodes(l);}else if(n.isEmpty()){let r=$createParagraphNode();r.setDirection("ltr"),n.append(r);}t.current=true;});},[e,o]),null}var wo=class o extends DecoratorNode{__html;static getType(){return "signature"}static clone(e){return new o(e.__html,e.__key)}static importJSON(e){return new o(e.html)}constructor(e,t){super(t),this.__html=e;}exportJSON(){return {html:this.__html,type:"signature",version:1}}exportDOM(e){let t=document.createElement("div");return t.innerHTML=this.__html,{element:t}}setHTML(e){let t=this.getWritable();t.__html=e;}isInline(){return false}createDOM(){return document.createElement("div")}updateDOM(){return false}decorate(){return jsx(Nc,{nodeKey:this.__key,html:this.__html})}};function AC(o){let e=new DOMParser().parseFromString(o,"text/html"),t=e.querySelectorAll("table"),n=e.querySelector('img[alt="mobilePhone"], img[alt="emailAddress"], img[alt="website"]');return t.length>=3||!!n}function er(){let[o]=useLexicalComposerContext();return useEffect(()=>o.registerCommand(PASTE_COMMAND,e=>{let t=e.clipboardData?.getData("text/html"),n=e.clipboardData?.getData("text/plain"),r=$getSelection();return $isRangeSelection(r)?t&&AC(t)?($insertNodes([new wo(t),$createParagraphNode()]),true):t?false:n?(r.insertText(n),true):false:false},COMMAND_PRIORITY_CRITICAL),[o]),null}var ZC=({aiContent:o,onAiInsert:e,onAiDiscard:t,aiContentComponent:n,showAiPreview:r})=>{let[i]=useLexicalComposerContext(),s=Qc__default.useCallback(()=>{o&&(i.update(()=>{try{let c=new DOMParser().parseFromString(o,"text/html"),d=$generateNodesFromDOM(i,c);d.forEach(u=>{"setDirection"in u&&u.setDirection("ltr");}),$insertNodes(d);}catch{let c=$createTextNode(o);$insertNodes([c]);}}),e&&e(o));},[i,o,e]),l=Qc__default.useCallback(()=>{t&&t();},[t]);return !r||!n?null:jsx("div",{className:"ai-preview-container",children:Children.map(n,a=>isValidElement(a)?cloneElement(a,{onInsert:s,onDiscard:l}):a)})};function QC({aiContentComponent:o,aiContent:e,showAiPreview:t,onAiInsert:n,onAiDiscard:r,placeholder:i="",initialHTML:s="",rightChildren:l,leftChildren:a,customTool:c,minHeight:d="200px",onChange:u,editorChildren:h,isEditorVisible:p=true}){let[f,m]=useState(s),g=x=>{m(x),u&&u(x);},b=t&&o;return jsx("div",{className:"compose-box-wrapper",style:{minHeight:d},children:jsxs(LexicalComposer,{initialConfig:{namespace:"ComposeBox",theme:qc,nodes:[ListNode,ListItemNode,LinkNode,AutoLinkNode,dc,uc,cc,zt,wo,So],onError:x=>{console.error(x);}},children:[jsxs("div",{className:"compose-box-editor-container",style:{flex:1},children:[jsxs("div",{className:"compose-box-scroll-area",style:{flex:1,overflowY:"auto",minHeight:d},children:[b&&f&&f!=='<p class="editor-paragraph"><br></p>'&&jsx("div",{className:"compose-box-content-preview",dangerouslySetInnerHTML:{__html:f}}),jsx(ZC,{aiContent:e,onAiInsert:n,onAiDiscard:r,aiContentComponent:o,showAiPreview:t}),jsx("div",{style:{display:b?"none":"block"},children:p?jsxs(Fragment,{children:[jsx(RichTextPlugin,{contentEditable:jsx(ContentEditable,{style:{minHeight:d,padding:"16px"},className:"compose-box-content-editable","aria-placeholder":i,placeholder:null}),placeholder:jsx("div",{className:"compose-box-placeholder",children:i}),ErrorBoundary:LexicalErrorBoundary}),jsx(er,{}),jsx(Ji,{})]}):h})]}),jsx(Jc,{rightChildren:l,leftChildren:a,customTool:c,disabled:!!b})]}),jsx(HistoryPlugin,{}),jsx(Qi,{initialHTML:s}),jsx(Zi,{}),jsx(AutoFocusPlugin,{}),jsx(ListPlugin,{}),jsx(LinkPlugin,{}),jsx(Ji,{}),jsx(er,{}),jsx(qi,{onChange:g})]})})}var es=QC;function oS({emails:o=[],setEmails:e,fetchOptions:t}){let n=useRef(null),r=useRef(null),[i,s]=useState(""),[l,a]=useState(false),[c,d]=useState(-1),[u,h]=useState([]),[p,f]=useState(false),m=useRef([]),g=useRef([]);useEffect(()=>{m.current=m.current.slice(0,o.length);},[o.length]),useEffect(()=>{g.current=g.current.slice(0,u.length);},[u.length]),useEffect(()=>{xo(i)?(async()=>{f(true);try{let y=await t(i);h(y);}catch(y){console.error("Error fetching email options:",y),h([]);}finally{f(false);}})():(h([]),f(false));},[i,t]),useEffect(()=>{l||d(-1);},[l]),useEffect(()=>{c>=0&&c<g.current.length&&g.current[c]?.scrollIntoView({block:"nearest",behavior:"smooth"});},[c]);let b=()=>{r.current?.focus();},C=S=>{n.current?.close(),s(""),e(y=>[...y,S]),d(-1),requestAnimationFrame(()=>r.current?.focus());},x=S=>{if(l&&xo(i)&&u.length>0){if(S.key==="ArrowDown"){S.preventDefault(),d(y=>y<u.length-1?y+1:y);return}if(S.key==="ArrowUp"){S.preventDefault(),d(y=>y>0?y-1:-1);return}if(S.key==="Enter"&&c>=0){S.preventDefault(),C(u[c]);return}if(S.key==="Escape"){S.preventDefault(),n.current?.close(),d(-1);return}}if((S.key==="Enter"||S.key===",")&&xo(i)&&(S.preventDefault(),C({email:i,name:i})),S.key==="Backspace"&&i===""){let y=o.length-1,N=m.current[y];N&&(N.focus(),S.preventDefault());}},w=S=>{e(y=>{let N=[...y];return N.splice(S,1),N}),requestAnimationFrame(()=>{let y=Math.min(Math.max(0,S-1),o.length-2),N=m.current[y];N?N.focus():b();});};return jsx(Fragment,{children:jsx(Ug,{ref:n,trigger:jsxs("div",{className:"container-receipts",children:[o?.length?jsx("div",{className:"emails-container",children:o.map((S,y)=>jsxs("div",{className:"emails",tabIndex:0,ref:N=>{m.current[y]=N;},onKeyDown:N=>{N.key==="Backspace"&&(N.preventDefault(),w(y)),N.key==="Enter"&&(N.preventDefault(),w(y),b());},role:"button","aria-label":`Email ${S.email}`,children:[jsx("span",{style:{marginRight:8},children:S.email}),jsx("button",{className:"emails-close",onClick:N=>{N.stopPropagation(),w(y);},"aria-label":`Remove ${S.email}`,children:jsx(X,{name:"Close"})})]},S.email??y))}):null,jsx("input",{ref:r,type:"text",className:"input-header",value:i,autoFocus:true,onKeyDown:x,onChange:S=>{let y=S.target.value;xo(y)&&n.current?.open(),s(y);}})]}),closeOnDocumentClick:true,repositionOnResize:true,position:"bottom left",className:"mail-inbox-popup",onOpen:()=>{a(true),requestAnimationFrame(()=>r.current?.focus());},onClose:()=>{a(false);},children:xo(i)?jsx("div",{className:"options-dropdown",children:p?jsx(Fragment,{children:[1,2,3].map(S=>jsxs("div",{className:"option-dropdown skeleton-loader",children:[jsx("div",{className:"skeleton-line skeleton-name"}),jsx("div",{className:"skeleton-line skeleton-email"})]},S))}):u.length>0?u.map((S,y)=>jsxs("button",{ref:N=>{g.current[y]=N;},className:`option-dropdown ${c===y?"selected":""}`,onBlur:N=>{N.stopPropagation();},onFocus:N=>{N.stopPropagation();},onMouseEnter:()=>d(y),onMouseLeave:()=>d(-1),onClick:N=>{N.stopPropagation(),C(S);},"aria-selected":c===y,children:[jsx("h4",{children:S.name}),S.email]},y)):null}):null})})}var od=oS;function nS({name:o,needCCAndBCC:e,setShowCC:t,setShowBCC:n,showBCC:r,showCC:i,emails:s,handleChange:l,fetchOptions:a}){return jsxs("div",{className:"container-receipts",children:[jsx("label",{className:"block text-sm font-medium",children:o}),jsx(od,{emails:s,setEmails:l,fetchOptions:a}),e&&!r?jsx("button",{className:"btn-mail-editor",onClick:()=>n?.(c=>!c),children:"Bcc"}):null,e&&!i?jsx("button",{className:"btn-mail-editor",onClick:()=>t?.(c=>!c),children:"Cc"}):null]})}var ir=nS;function lS({fetchEmailOptions:o}){let[e,t]=useState(false),n=useRef(null),{emails:r,setEmails:i,showCC:s,setShowCC:l,showBCC:a,setShowBCC:c}=it();return useEffect(()=>{e&&(l(r.cc.length>0),c(r.bcc.length>0));},[e,r.cc.length,r.bcc.length]),useEffect(()=>{let u=n.current;if(!u)return;let h=()=>{t(true);},p=f=>{console.log("\u{1F680} ~ handleFocusOut ~ e:",f);let m=f.relatedTarget;m&&m.classList&&m.classList.contains("option-dropdown")||m&&u.contains(m)||(console.log("why this ",m?.classList),t(false));};return u.addEventListener("focusin",h),u.addEventListener("focusout",p),()=>{u.removeEventListener("focusin",h),u.removeEventListener("focusout",p);}},[]),jsx("div",{ref:n,tabIndex:-1,className:"relative",children:e?jsxs("div",{children:[jsx(ir,{name:"To",needCCAndBCC:true,setShowCC:l,setShowBCC:c,showBCC:a,showCC:s,emails:r.to,handleChange:u=>{i(h=>({...h,to:typeof u=="function"?u(h.to):u}));},fetchOptions:o}),a?jsx(ir,{name:"Bcc",needCCAndBCC:false,setShowCC:l,setShowBCC:c,showBCC:a,showCC:s,emails:r.bcc,handleChange:u=>{i(h=>({...h,bcc:typeof u=="function"?u(h.bcc):u}));},fetchOptions:o}):null,s?jsx(ir,{name:"Cc",needCCAndBCC:false,setShowCC:l,setShowBCC:c,showBCC:a,showCC:s,emails:r.cc,handleChange:u=>{i(h=>({...h,cc:typeof u=="function"?u(h.cc):u}));},fetchOptions:o}):null]}):jsx("input",{type:"text",placeholder:"Recipients",className:"input-header",value:(()=>{if(r.to.length===0&&r.cc.length===0&&r.bcc.length===0)return "Recipients";let u=[];return r.to.length>0&&u.push(r.to.map(h=>h.email).join(", ")),r.cc.length>0&&u.push(r.cc.map(h=>h.email).join(", ")),r.bcc.length>0&&u.push("bcc: "+r.bcc.map(h=>h.email).join(", ")),u.join(", ")})(),readOnly:true})})}var rd=lS;var cS=({content:o,children:e,position:t="bottom center"})=>jsx(Ve,{trigger:e,on:"hover",popUpDirection:t,children:()=>jsx("div",{className:"mail-inbox-tooltip-content mail-inbox-popup-content",style:{padding:"6px 10px",maxWidth:"50%",wordBreak:"break-word",fontSize:"12px",borderRadius:"6px",backgroundColor:"#333",color:"#fff",zIndex:1e4,boxShadow:"0 2px 3px rgba(0, 0, 0, 0.2)"},children:o})}),sd=cS;function pS({fetchEmailOptions:o}){let{subject:e,setSubject:t,isReply:n}=it(),r=useRef(null),[i,s]=useState(false),l=n&&e&&!e.startsWith("Re: ")?`Re: ${e}`:e;return useLayoutEffect(()=>{let a=()=>{if(n&&r.current){let c=r.current,d=c.scrollWidth>c.clientWidth;s(d);}};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[l,n]),jsxs("div",{className:"gmail-header",children:[jsx("div",{className:"receipt-heading",children:jsx(rd,{fetchEmailOptions:o})}),jsx("div",{className:"reply-heading",children:n?i?jsx(sd,{content:l,position:"bottom center",children:jsx("div",{ref:r,className:"subject-display",children:l})}):jsx("div",{ref:r,className:"subject-display",children:l}):jsx("input",{type:"text",placeholder:"Subject",className:"input-header",value:l,onChange:a=>t(a.target.value)})})]})}var ld=pS;function mS({initialData:o,isReply:e,fetchEmailOptions:t,handleChange:n,leftChildren:r,rightChildren:i,customTool:s,editorChildren:l,isEditorVisible:a=true,showOnlyBody:c=false,aiContentComponent:d,aiContent:u,showAiPreview:h,onAiInsert:p,onAiDiscard:f,placeholder:m,minHeight:g="400px"}){let{emails:b,subject:C,attachments:x,setEmails:w,setSubject:S,setAttachments:y,setIsReply:N}=it(),{theme:E}=rn(),[R,L]=useState(o?.body||""),[k,M]=useState({to:o?.to||[],cc:o?.cc||[],bcc:o?.bcc||[],subject:o?.subject||"",body:o?.body||"",attachments:o?.attachments||[],isReply:e||false});useEffect(()=>{o&&((o.to||o.cc||o.bcc)&&w({to:o.to||[],cc:o.cc||[],bcc:o.bcc||[]}),o.subject&&S(o.subject),o.attachments&&y(o.attachments),o.body&&L(o.body)),e!==void 0&&N(e);},[e]);let v=T=>{L(T);};return useEffect(()=>{M(T=>({...T,to:b.to,cc:b.cc,bcc:b.bcc}));},[b]),useEffect(()=>{M(T=>({...T,subject:C}));},[C]),useEffect(()=>{M(T=>({...T,body:R}));},[R]),useEffect(()=>{M(T=>({...T,attachments:x}));},[x]),useEffect(()=>{M(T=>({...T,isReply:e}));},[e]),useEffect(()=>{n(k);},[k,n]),jsx("div",{className:"react-mail-inbox-root gmail-wrapper","data-theme":E,children:jsxs("div",{className:"mail-inbox-internal",children:[c?null:jsx(ld,{fetchEmailOptions:t}),jsx(es,{initialHTML:o?.body,onChange:v,editorChildren:l,rightChildren:i,leftChildren:r,customTool:s,isEditorVisible:a,minHeight:g,placeholder:m,aiContentComponent:d,aiContent:u,showAiPreview:h,onAiInsert:p,onAiDiscard:f})]})})}var cd=mS;function bS({fetchEmailOptions:o,handleChange:e,initialData:t,leftChildren:n,rightChildren:r,customTool:i,isReply:s,showOnlyBody:l,googleDriveConfig:a,aiContentComponent:c,aiContent:d,showAiPreview:u,onAiInsert:h,onAiDiscard:p,placeholder:f,minHeight:m="400px"}){return jsx(is,{googleDriveConfig:a,children:jsx(cd,{fetchEmailOptions:o,handleChange:e,initialData:t,isReply:s,leftChildren:n,rightChildren:r,customTool:i,showOnlyBody:l,aiContentComponent:c,aiContent:d,showAiPreview:u,onAiInsert:h,onAiDiscard:p,placeholder:f,minHeight:m})})}var ud=bS;function CS({fetchEmailOptions:o,handleChange:e,initialData:t,initialTheme:n="dark",onThemeChange:r,leftChildren:i,rightChildren:s,customTool:l,showOnlyBody:a=false,isReply:c=false,googleDriveConfig:d,aiContentComponent:u,aiContent:h,showAiPreview:p,onAiInsert:f,onAiDiscard:m,placeholder:g,minHeight:b}){return jsx(ns,{initialTheme:n,onThemeChange:r,children:jsx(ud,{fetchEmailOptions:o,handleChange:e,initialData:t,leftChildren:i,rightChildren:s,customTool:l,showOnlyBody:a,isReply:c,googleDriveConfig:d,aiContentComponent:u,aiContent:h,showAiPreview:p,onAiInsert:f,onAiDiscard:m,placeholder:g,minHeight:b})})}var pd=CS;var pT=pd;
|
|
10
|
-
export{es as ComposeBox,pd as GmailInbox,
|
|
7
|
+
`?c.insertParagraph():d===" "?c.insertNodes([$createTabNode()]):c.insertText(d);}}}else e.insertRawText(s);}function Fr(o,e,t){o.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:t})||(t.insertNodes(e),(function(n){if($isRangeSelection(n)&&n.isCollapsed()){let r=n.anchor,i=null,s=$caretFromPoint(r,"previous");if(s)if($isTextPointCaret(s))i=s.origin;else {let l=$getCaretRange(s,$getChildCaret($getRoot(),"next").getFlipped());for(let a of l){if($isTextNode(a.origin)){i=a.origin;break}if($isElementNode(a.origin)&&!a.origin.isInline())break}}if(i&&$isTextNode(i)){let l=i.getFormat(),a=i.getStyle();n.format===l&&n.style===a||(n.format=l,n.style=a,n.dirty=true);}}})(t));}function El(o,e,t,n=[]){let r=e===null||t.isSelected(e),i=$isElementNode(t)&&t.excludeFromCopy("html"),s=t;e!==null&&$isTextNode(s)&&(s=$sliceSelectedTextNodeContent(e,s,"clone"));let l=$isElementNode(s)?s.getChildren():[],a=(function(c){let d=c.exportJSON(),u=c.constructor;if(d.type!==u.getType()&&yn(58,u.name),$isElementNode(c)){let h=d.children;Array.isArray(h)||yn(59,u.name);}return d})(s);$isTextNode(s)&&s.getTextContentSize()===0&&(r=false);for(let c=0;c<l.length;c++){let d=l[c],u=El(o,e,d,a.children);!r&&$isElementNode(t)&&u&&t.extractWithChild(d,e,"clone")&&(r=true);}if(r&&!i)n.push(a);else if(Array.isArray(a.children))for(let c=0;c<a.children.length;c++){let d=a.children[c];n.push(d);}return r}function Tl(o,e){let t=[],n=$getRoot().getChildren();for(let r=0;r<n.length;r++)El(o,e,n[r],t);return {namespace:o._config.namespace,nodes:t}}function vl(o){let e=[];for(let t=0;t<o.length;t++){let n=o[t],r=$parseSerializedNode(n);$isTextNode(r)&&$addNodeStyle(r),e.push(r);}return e}async function Np(o,e,t){if(to!==null)return false;if(e!==null)return new Promise((c,d)=>{o.update(()=>{c(xl(o,e,t));});});let n=o.getRootElement(),r=o._window||window,i=r.document,s=getDOMSelection(r);if(n===null||s===null)return false;let l=i.createElement("span");l.style.cssText="position: fixed; top: -1000px;",l.append(i.createTextNode("#")),n.append(l);let a=new Range;return a.setStart(l,0),a.setEnd(l,1),s.removeAllRanges(),s.addRange(a),new Promise((c,d)=>{let u=o.registerCommand(COPY_COMMAND,h=>(objectKlassEquals(h,ClipboardEvent)&&(u(),to!==null&&(r.clearTimeout(to),to=null),c(xl(o,h,t))),true),COMMAND_PRIORITY_CRITICAL);to=r.setTimeout(()=>{u(),to=null,c(false);},50),i.execCommand("copy"),l.remove();})}function xl(o,e,t){if(t===void 0){let r=getDOMSelection(o._window),i=$getSelection();if(!i||i.isCollapsed()||!r)return false;let s=r.anchorNode,l=r.focusNode;if(s!==null&&l!==null&&!isSelectionWithinEditor(o,s,l))return false;t=Ml(i);}e.preventDefault();let n=e.clipboardData;return n!==null&&(Ol(n,t),true)}function Ml(o=$getSelection()){let e={"text/plain":o?o.getTextContent():""};if(o){let t=$getEditor();for(let[n,r]of Rl){let i=r(t,o);i!==null&&(e[n]=i);}}return e}function Ol(o,e){for(let[t]of Rl)e[t]===void 0&&o.setData(t,"");for(let t in e){let n=e[t];n!==void 0&&o.setData(t,n);}}var to,Rl,Al=rt(()=>{to=null;Rl=[["text/html",Nl],["application/x-lexical-editor",_l]];});var ze,wn,Nn,Dr=rt(async()=>{ze=await(process.env.NODE_ENV!=="production"?Promise.resolve().then(()=>(Sl(),Cl)):Promise.resolve().then(()=>(Al(),kl))),ze.$generateJSONFromSelectedNodes,ze.$generateNodesFromSerializedNodes,wn=ze.$getClipboardDataFromSelection,ze.$getHtmlContent,ze.$getLexicalContent,ze.$insertDataTransferForPlainText,ze.$insertDataTransferForRichText,ze.$insertGeneratedNodes,Nn=ze.copyToClipboard,ze.setLexicalClipboardDataTransfer;});var Sa={};jt(Sa,{$computeTableMap:()=>Se,$computeTableMapSkipCellCheck:()=>Ze,$createTableCellNode:()=>Oe,$createTableNode:()=>Fn,$createTableNodeWithDimensions:()=>ta,$createTableRowNode:()=>kt,$createTableSelection:()=>ti,$createTableSelectionFrom:()=>ca,$deleteTableColumn:()=>bh,$deleteTableColumnAtSelection:()=>sa,$deleteTableColumn__EXPERIMENTAL:()=>Sh,$deleteTableRowAtSelection:()=>ia,$deleteTableRow__EXPERIMENTAL:()=>Ch,$findCellNode:()=>ro,$findTableNode:()=>Qe,$getElementForTableNode:()=>ma,$getNodeTriplet:()=>ge,$getTableAndElementByKey:()=>oi,$getTableCellNodeFromLexicalNode:()=>ch,$getTableCellNodeRect:()=>Wr,$getTableColumnIndexFromTableCellNode:()=>uh,$getTableNodeFromLexicalNodeOrThrow:()=>An,$getTableRowIndexFromTableCellNode:()=>dh,$getTableRowNodeFromTableCellNodeOrThrow:()=>Qr,$insertTableColumn:()=>mh,$insertTableColumnAtSelection:()=>ra,$insertTableColumn__EXPERIMENTAL:()=>gh,$insertTableRow:()=>ph,$insertTableRowAtSelection:()=>na,$insertTableRow__EXPERIMENTAL:()=>hh,$isScrollableTablesActive:()=>Uo,$isTableCellNode:()=>$,$isTableNode:()=>ce,$isTableRowNode:()=>ee,$isTableSelection:()=>W,$mergeCells:()=>la,$removeTableRowAtIndex:()=>fh,$unmergeCell:()=>yh,INSERT_TABLE_COMMAND:()=>ea,TableCellHeaderStates:()=>oe,TableCellNode:()=>We,TableExtension:()=>Qh,TableNode:()=>Ue,TableObserver:()=>On,TableRowNode:()=>Ot,applyTableHandlers:()=>da,getDOMCellFromTarget:()=>Wo,getTableElement:()=>ft,getTableObserverFromTableElement:()=>ii,registerTableCellUnmergeTransform:()=>ga,registerTablePlugin:()=>Ca,registerTableSelectionObserver:()=>ba,setScrollableTablesActive:()=>ha});function Kr(o){return o==="middle"||o==="bottom"}function Dl(o){let e=o,t=o.nodeName.toLowerCase(),n;qr.test(e.style.width)&&(n=parseFloat(e.style.width));let r=Oe(t==="th"?oe.ROW:oe.NO_STATUS,e.colSpan,n);r.__rowSpan=e.rowSpan;let i=e.style.backgroundColor;i!==""&&(r.__backgroundColor=i);let s=e.style.verticalAlign;Kr(s)&&(r.__verticalAlign=s);let l=e.style,a=(l&&l.textDecoration||"").split(" "),c=l.fontWeight==="700"||l.fontWeight==="bold",d=a.includes("line-through"),u=l.fontStyle==="italic",h=a.includes("underline");return {after:p=>{let f=[],m=null,g=()=>{if(m){let b=m.getFirstChild();$isLineBreakNode(b)&&m.getChildrenSize()===1&&b.remove();}};for(let b of p)$isInlineElementOrDecoratorNode(b)||$isTextNode(b)||$isLineBreakNode(b)?($isTextNode(b)&&(c&&b.toggleFormat("bold"),d&&b.toggleFormat("strikethrough"),u&&b.toggleFormat("italic"),h&&b.toggleFormat("underline")),m?m.append(b):(m=$createParagraphNode().append(b),f.push(m))):(f.push(b),g(),m=null);return g(),f.length===0&&f.push($createParagraphNode()),f},node:r}}function Oe(o=oe.NO_STATUS,e=1,t){return $applyNodeReplacement(new We(o,e,t))}function $(o){return o instanceof We}function M(o){throw new Error(o)}function lh(o){let e=o,t;return qr.test(e.style.height)&&(t=parseFloat(e.style.height)),{after:n=>$descendantsMatching(n,$),node:kt(t)}}function kt(o){return $applyNodeReplacement(new Ot(o))}function ee(o){return o instanceof Ot}function ta(o,e,t=true){let n=Fn();for(let r=0;r<o;r++){let i=kt();for(let s=0;s<e;s++){let l=oe.NO_STATUS;typeof t=="object"?(r===0&&t.rows&&(l|=oe.ROW),s===0&&t.columns&&(l|=oe.COLUMN)):t&&(r===0&&(l|=oe.ROW),s===0&&(l|=oe.COLUMN));let a=Oe(l),c=$createParagraphNode();c.append($createTextNode()),a.append(c),i.append(a);}n.append(i);}return n}function ch(o){let e=$findMatchingParent(o,t=>$(t));return $(e)?e:null}function Qr(o){let e=$findMatchingParent(o,t=>ee(t));if(ee(e))return e;throw new Error("Expected table cell to be inside of table row.")}function An(o){let e=$findMatchingParent(o,t=>ce(t));if(ce(e))return e;throw new Error("Expected table cell to be inside of table.")}function dh(o){let e=Qr(o);return An(e).getChildren().findIndex(n=>n.is(e))}function uh(o){return Qr(o).getChildren().findIndex(t=>t.is(o))}function oa(o,e){let t=An(o),{x:n,y:r}=t.getCordsFromCellNode(o,e);return {above:t.getCellNodeFromCords(n,r-1,e),below:t.getCellNodeFromCords(n,r+1,e),left:t.getCellNodeFromCords(n-1,r,e),right:t.getCellNodeFromCords(n+1,r,e)}}function fh(o,e){let t=o.getChildren();if(e>=t.length||e<0)throw new Error("Expected table cell to be inside of table row.");return t[e].remove(),o}function ph(o,e,t=true,n,r){let i=o.getChildren();if(e>=i.length||e<0)throw new Error("Table row target index out of range");let s=i[e];if(ee(s))for(let l=0;l<n;l++){let a=s.getChildren(),c=a.length,d=kt();for(let u=0;u<c;u++){let h=a[u];$(h)||M("Expected table cell");let{above:p,below:f}=oa(h,r),m=oe.NO_STATUS,g=p&&p.getWidth()||f&&f.getWidth()||void 0;(p&&p.hasHeaderState(oe.COLUMN)||f&&f.hasHeaderState(oe.COLUMN))&&(m|=oe.COLUMN);let b=Oe(m,1,g);b.append($createParagraphNode()),d.append(b);}t?s.insertAfter(d):s.insertBefore(d);}else throw new Error("Row before insertion index does not exist.");return o}function na(o=true){let e=$getSelection();$isRangeSelection(e)||W(e)||M("Expected a RangeSelection or TableSelection");let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=ge(t),[i,,s]=ge(n),[,l,a]=Se(s,i,r),{startRow:c}=a,{startRow:d}=l;return o?Br(c+r.__rowSpan>d+i.__rowSpan?r:i,true):Br(d<c?i:r,false)}function Br(o,e=true){let[,,t]=ge(o),[n,r]=Se(t,o,o),i=n[0].length,{startRow:s}=r,l=null;if(e){let a=s+o.__rowSpan-1,c=n[a],d=kt();for(let h=0;h<i;h++){let{cell:p,startRow:f}=c[h];if(f+p.__rowSpan-1<=a){let g=c[h].cell.__headerState,b=zr(g,oe.COLUMN);d.append(Oe(b).append($createParagraphNode()));}else p.setRowSpan(p.__rowSpan+1);}let u=t.getChildAtIndex(a);ee(u)||M("insertAfterEndRow is not a TableRowNode"),u.insertAfter(d),l=d;}else {let a=s,c=n[a],d=kt();for(let h=0;h<i;h++){let{cell:p,startRow:f}=c[h];if(f===a){let g=c[h].cell.__headerState,b=zr(g,oe.COLUMN);d.append(Oe(b).append($createParagraphNode()));}else p.setRowSpan(p.__rowSpan+1);}let u=t.getChildAtIndex(a);ee(u)||M("insertBeforeStartRow is not a TableRowNode"),u.insertBefore(d),l=d;}return l}function mh(o,e,t=true,n,r){let i=o.getChildren(),s=[];for(let l=0;l<i.length;l++){let a=i[l];if(ee(a))for(let c=0;c<n;c++){let d=a.getChildren();if(e>=d.length||e<0)throw new Error("Table column target index out of range");let u=d[e];$(u)||M("Expected table cell");let{left:h,right:p}=oa(u,r),f=oe.NO_STATUS;(h&&h.hasHeaderState(oe.ROW)||p&&p.hasHeaderState(oe.ROW))&&(f|=oe.ROW);let m=Oe(f);m.append($createParagraphNode()),s.push({newTableCell:m,targetCell:u});}}return s.forEach(({newTableCell:l,targetCell:a})=>{t?a.insertAfter(l):a.insertBefore(l);}),o}function ra(o=true){let e=$getSelection();$isRangeSelection(e)||W(e)||M("Expected a RangeSelection or TableSelection");let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=ge(t),[i,,s]=ge(n),[,l,a]=Se(s,i,r),{startColumn:c}=a,{startColumn:d}=l;return o?Hr(c+r.__colSpan>d+i.__colSpan?r:i,true):Hr(d<c?i:r,false)}function Hr(o,e=true,t=true){let[,,n]=ge(o),[r,i]=Se(n,o,o),s=r.length,{startColumn:l}=i,a=e?l+o.__colSpan-1:l-1,c=n.getFirstChild();ee(c)||M("Expected firstTable child to be a row");let d=null;function u(f=oe.NO_STATUS){let m=Oe(f).append($createParagraphNode());return d===null&&(d=m),m}let h=c;e:for(let f=0;f<s;f++){if(f!==0){let S=h.getNextSibling();ee(S)||M("Expected row nextSibling to be a row"),h=S;}let m=r[f],g=m[a<0?0:a].cell.__headerState,b=zr(g,oe.ROW);if(a<0){ei(h,u(b));continue}let{cell:C,startColumn:x,startRow:w}=m[a];if(x+C.__colSpan-1<=a){let S=C,y=w,N=a;for(;y!==f&&S.__rowSpan>1;)if(N-=C.__colSpan,N>=0){let{cell:E,startRow:R}=m[N];S=E,y=R;}else {h.append(u(b));continue e}S.insertAfter(u(b));}else C.setColSpan(C.__colSpan+1);}d!==null&&t&&Ho(d);let p=n.getColWidths();if(p){let f=[...p],m=a<0?0:a,g=f[m];f.splice(m,0,g),n.setColWidths(f);}return d}function bh(o,e){let t=o.getChildren();for(let n=0;n<t.length;n++){let r=t[n];if(ee(r)){let i=r.getChildren();if(e>=i.length||e<0)throw new Error("Table column target index out of range");i[e].remove();}}return o}function ia(){let o=$getSelection();$isRangeSelection(o)||W(o)||M("Expected a RangeSelection or TableSelection");let[e,t]=o.isBackward()?[o.focus.getNode(),o.anchor.getNode()]:[o.anchor.getNode(),o.focus.getNode()],[n,,r]=ge(e),[i]=ge(t),[s,l,a]=Se(r,n,i),{startRow:c}=l,{startRow:d}=a,u=d+i.__rowSpan-1;if(s.length===u-c+1){r.remove();return}let h=s[0].length,p=s[u+1],f=r.getChildAtIndex(u+1);for(let m=u;m>=c;m--){for(let b=h-1;b>=0;b--){let{cell:C,startRow:x,startColumn:w}=s[m][b];if(w===b){if(x<c||x+C.__rowSpan-1>u){let S=Math.max(x,c),y=Math.min(C.__rowSpan+x-1,u),N=S<=y?y-S+1:0;C.setRowSpan(C.__rowSpan-N);}if(x>=c&&x+C.__rowSpan-1>u&&m===u){f===null&&M("Expected nextRowNode not to be null");let S=null;for(let y=0;y<b;y++){let N=p[y],E=N.cell;N.startRow===m+1&&(S=E),E.__colSpan>1&&(y+=E.__colSpan-1);}S===null?ei(f,C):S.insertAfter(C);}}}let g=r.getChildAtIndex(m);ee(g)||M(`Expected TableNode childAtIndex(${String(m)}) to be RowNode`),g.remove();}if(p!==void 0){let{cell:m}=p[0];Ho(m);}else {let m=s[c-1],{cell:g}=m[0];Ho(g);}}function sa(){let o=$getSelection();$isRangeSelection(o)||W(o)||M("Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=ge(e),[i]=ge(t),[s,l,a]=Se(r,n,i),{startColumn:c}=l,{startRow:d,startColumn:u}=a,h=Math.min(c,u),p=Math.max(c+n.__colSpan-1,u+i.__colSpan-1),f=p-h+1;if(s[0].length===p-h+1){r.selectPrevious(),r.remove();return}let g=s.length;for(let w=0;w<g;w++)for(let S=h;S<=p;S++){let{cell:y,startColumn:N}=s[w][S];if(N<h){if(S===h){let E=h-N;y.setColSpan(y.__colSpan-Math.min(f,y.__colSpan-E));}}else if(N+y.__colSpan-1>p){if(S===p){let E=p-N+1;y.setColSpan(y.__colSpan-E);}}else y.remove();}let b=s[d],C=c>u?b[c+n.__colSpan]:b[u+i.__colSpan];if(C!==void 0){let{cell:w}=C;Ho(w);}else {let w=u<c?b[u-1]:b[c-1],{cell:S}=w;Ho(S);}let x=r.getColWidths();if(x){let w=[...x];w.splice(h,f),r.setColWidths(w);}}function Ho(o){let e=o.getFirstDescendant();e==null?o.selectStart():e.getParentOrThrow().selectStart();}function ei(o,e){let t=o.getFirstChild();t!==null?t.insertBefore(e):o.append(e);}function la(o){if(o.length===0)return null;let e=An(o[0]),[t]=Ze(e,null,null),n=1/0,r=-1/0,i=1/0,s=-1/0,l=new Set;for(let p of t)for(let f of p){if(!f||!f.cell)continue;let m=f.cell.getKey();if(!l.has(m)&&o.some(g=>g.is(f.cell))){l.add(m);let g=f.startRow,b=f.startColumn,C=f.cell.__rowSpan||1,x=f.cell.__colSpan||1;n=Math.min(n,g),r=Math.max(r,g+C-1),i=Math.min(i,b),s=Math.max(s,b+x-1);}}if(n===1/0||i===1/0)return null;let a=r-n+1,c=s-i+1,d=t[n][i];if(!d.cell)return null;let u=d.cell;u.setColSpan(c),u.setRowSpan(a);let h=new Set([u.getKey()]);for(let p=n;p<=r;p++)for(let f=i;f<=s;f++){let m=t[p][f];if(!m.cell)continue;let g=m.cell,b=g.getKey();h.has(b)||(h.add(b),xh(g)||u.append(...g.getChildren()),g.remove());}return u.getChildrenSize()===0&&u.append($createParagraphNode()),u}function xh(o){if(o.getChildrenSize()!==1)return false;let e=o.getFirstChildOrThrow();return !(!$isParagraphNode(e)||!e.isEmpty())}function yh(){let o=$getSelection();$isRangeSelection(o)||W(o)||M("Expected a RangeSelection or TableSelection");let e=o.anchor.getNode(),t=$findMatchingParent(e,$);return $(t)||M("Expected to find a parent TableCellNode"),aa(t)}function aa(o){let[e,t,n]=ge(o),r=e.__colSpan,i=e.__rowSpan;if(r===1&&i===1)return;let[s,l]=Se(n,e,e),{startColumn:a,startRow:c}=l,d=e.__headerState&oe.COLUMN,u=Array.from({length:r},(f,m)=>{let g=d;for(let b=0;g!==0&&b<s.length;b++)g&=s[b][m+a].cell.__headerState;return g}),h=e.__headerState&oe.ROW,p=Array.from({length:i},(f,m)=>{let g=h;for(let b=0;g!==0&&b<s[0].length;b++)g&=s[m+c][b].cell.__headerState;return g});if(r>1){for(let f=1;f<r;f++)e.insertAfter(Oe(u[f]|p[0]).append($createParagraphNode()));e.setColSpan(1);}if(i>1){let f;for(let m=1;m<i;m++){let g=c+m,b=s[g];f=(f||t).getNextSibling(),ee(f)||M("Expected row next sibling to be a row");let C=null;for(let x=0;x<a;x++){let w=b[x],S=w.cell;w.startRow===g&&(C=S),S.__colSpan>1&&(x+=S.__colSpan-1);}if(C===null)for(let x=r-1;x>=0;x--)ei(f,Oe(u[x]|p[m]).append($createParagraphNode()));else for(let x=r-1;x>=0;x--)C.insertAfter(Oe(u[x]|p[m]).append($createParagraphNode()));}e.setRowSpan(1);}}function Se(o,e,t){let[n,r,i]=Ze(o,e,t);return r===null&&M("Anchor not found in Table"),i===null&&M("Focus not found in Table"),[n,r,i]}function Ze(o,e,t){let n=[],r=null,i=null;function s(a){let c=n[a];return c===void 0&&(n[a]=c=[]),c}let l=o.getChildren();for(let a=0;a<l.length;a++){let c=l[a];ee(c)||M("Expected TableNode children to be TableRowNode");let d=s(a);for(let u=c.getFirstChild(),h=0;u!=null;u=u.getNextSibling()){for($(u)||M("Expected TableRowNode children to be TableCellNode");d[h]!==void 0;)h++;let p={cell:u,startColumn:h,startRow:a},{__rowSpan:f,__colSpan:m}=u;for(let g=0;g<f&&!(a+g>=l.length);g++){let b=s(a+g);for(let C=0;C<m;C++)b[h+C]=p;}e!==null&&r===null&&e.is(u)&&(r=p),t!==null&&i===null&&t.is(u)&&(i=p);}}return [n,r,i]}function ge(o){let e;if(o instanceof We)e=o;else if("__type"in o){let r=$findMatchingParent(o,$);$(r)||M("Expected to find a parent TableCellNode"),e=r;}else {let r=$findMatchingParent(o.getNode(),$);$(r)||M("Expected to find a parent TableCellNode"),e=r;}let t=e.getParent();ee(t)||M("Expected TableCellNode to have a parent TableRowNode");let n=t.getParent();return ce(n)||M("Expected TableRowNode to have a parent TableNode"),[e,t,n]}function wh(o,e){let{minColumn:t,maxColumn:n,minRow:r,maxRow:i}=e,s=1,l=1,a=1,c=1,d=o[r],u=o[i];for(let h=t;h<=n;h++)s=Math.max(s,d[h].cell.__rowSpan),c=Math.max(c,u[h].cell.__rowSpan);for(let h=r;h<=i;h++)l=Math.max(l,o[h][t].cell.__colSpan),a=Math.max(a,o[h][n].cell.__colSpan);return {bottomSpan:c,leftSpan:l,rightSpan:a,topSpan:s}}function $n(o,e,t){let n=Math.min(e.startColumn,t.startColumn),r=Math.min(e.startRow,t.startRow),i=Math.max(e.startColumn+e.cell.__colSpan-1,t.startColumn+t.cell.__colSpan-1),s=Math.max(e.startRow+e.cell.__rowSpan-1,t.startRow+t.cell.__rowSpan-1),l;do{l=false;for(let a=0;a<o.length;a++)for(let c=0;c<o[0].length;c++){let d=o[a][c];if(!d)continue;let u=d.startColumn+d.cell.__colSpan-1,h=d.startRow+d.cell.__rowSpan-1,p=d.startColumn<=i&&u>=n,f=d.startRow<=s&&h>=r;if(p&&f){let m=Math.min(n,d.startColumn),g=Math.max(i,u),b=Math.min(r,d.startRow),C=Math.max(s,h);(m!==n||g!==i||b!==r||C!==s)&&(n=m,i=g,r=b,s=C,l=true);}}}while(l);return {maxColumn:i,maxRow:s,minColumn:n,minRow:r}}function Wr(o){let[e,,t]=ge(o),n=t.getChildren(),r=n.length,i=n[0].getChildren().length,s=new Array(r);for(let l=0;l<r;l++)s[l]=new Array(i);for(let l=0;l<r;l++){let c=n[l].getChildren(),d=0;for(let u=0;u<c.length;u++){for(;s[l][d];)d++;let h=c[u],p=h.__rowSpan||1,f=h.__colSpan||1;for(let m=0;m<p;m++)for(let g=0;g<f;g++)s[l+m][d+g]=h;if(e===h)return {colSpan:f,columnIndex:d,rowIndex:l,rowSpan:p};d+=f;}}return null}function Pl(o){let[[e,t,n,r],[i,s,l,a]]=["anchor","focus"].map(c=>{let d=o[c].getNode(),u=$findMatchingParent(d,$);$(u)||M(`Expected TableSelection ${c} to be (or a child of) TableCellNode, got key ${d.getKey()} of type ${d.getType()}`);let h=u.getParent();ee(h)||M(`Expected TableSelection ${c} cell parent to be a TableRowNode`);let p=h.getParent();return ce(p)||M(`Expected TableSelection ${c} row parent to be a TableNode`),[d,u,h,p]});return r.is(a)||M("Expected TableSelection anchor and focus to be in the same table"),{anchorCell:t,anchorNode:e,anchorRow:n,anchorTable:r,focusCell:s,focusNode:i,focusRow:l,focusTable:a}}function W(o){return o instanceof Mn}function ti(){let o=$createPoint("root",0,"element"),e=$createPoint("root",0,"element");return new Mn("root",o,e)}function ca(o,e,t){let n=o.getKey(),r=e.getKey(),i=t.getKey();o.isAttached()||M(`$createTableSelectionFrom: tableNode ${n} is not attached`),o.is(Qe(e))||M(`$createTableSelectionFrom: anchorCell ${r} is not in table ${n}`),o.is(Qe(t))||M(`$createTableSelectionFrom: focusCell ${i} is not in table ${n}`);let s=$getSelection(),l=W(s)?s.clone():ti();return l.set(o.getKey(),e.getKey(),t.getKey()),l}function Nh(o,e){let t=[[o]];for(let n=t.at(-1);n!==void 0&&t.length>0;n=t.at(-1)){let r=n.pop();r===void 0?t.pop():e(r)!==false&&$isElementNode(r)&&t.push(r.getChildren());}}function oi(o,e=$getEditor()){let t=$getNodeByKey(o);ce(t)||M(`TableObserver: Expected tableNodeKey ${o} to be a TableNode`);let n=ft(t,e.getElementByKey(o));return n===null&&M(`TableObserver: Expected to find TableElement in DOM for key ${o}`),{tableElement:n,tableNode:t}}function no(o){return isHTMLElement(o)&&o.nodeName==="TABLE"}function ft(o,e){if(!e)return e;let t=no(e)?e:o.getDOMSlot(e).element;return t.nodeName!=="TABLE"&&M(`getTableElement: Expecting table in as DOM node for TableNode, not ${e.nodeName}`),t}function ri(o){return o._window}function Bo(o,e){for(let t=e,n=null;t!==null;t=t.getParent()){if(o.is(t))return n;$(t)&&(n=t);}return null}function da(o,e,t,n){let r=t.getRootElement(),i=ri(t);r!==null&&i!==null||M("applyTableHandlers: editor has no root element set");let s=new On(t,o.getKey()),l=ft(o,e);Mh(l,s),s.listenersToRemove.add(()=>Rh(l,s));let a=()=>{if(s.isSelecting)return;let f=()=>{s.isSelecting=false,i.removeEventListener("pointerup",f),i.removeEventListener("pointermove",m);},m=g=>{if(!_h(g)&&s.isSelecting){s.isSelecting=false,i.removeEventListener("pointerup",f),i.removeEventListener("pointermove",m);return}if(!isDOMNode(g.target))return;let b=null,C=!(Ll||l.contains(g.target));if(C)b=Il(l,g.target);else for(let x of document.elementsFromPoint(g.clientX,g.clientY))if(b=Il(l,x),b)break;b&&(s.focusCell===null||b.elem!==s.focusCell.elem)&&(s.setNextFocus({focusCell:b,override:C}),t.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0));};s.isSelecting=true,i.addEventListener("pointerup",f,s.listenerOptions),i.addEventListener("pointermove",m,s.listenerOptions);},c=f=>{if(s.pointerType=f.pointerType,f.button!==0||!isDOMNode(f.target)||!i)return;let m=Wo(f.target);m!==null&&t.update(()=>{let g=$getPreviousSelection();if(Ll&&f.shiftKey&&Be(g,o)&&($isRangeSelection(g)||W(g))){let b=g.anchor.getNode(),C=Bo(o,g.anchor.getNode());C?(s.$setAnchorCellForSelection(Rt(s,C)),s.$setFocusCellForSelection(m),qe(f)):(o.isBefore(b)?o.selectStart():o.selectEnd()).anchor.set(g.anchor.key,g.anchor.offset,g.anchor.type);}else f.pointerType!=="touch"&&s.$setAnchorCellForSelection(m);}),a();};l.addEventListener("pointerdown",c,s.listenerOptions),s.listenersToRemove.add(()=>{l.removeEventListener("pointerdown",c);});let d=f=>{f.detail>=3&&isDOMNode(f.target)&&Wo(f.target)!==null&&f.preventDefault();};l.addEventListener("mousedown",d,s.listenerOptions),s.listenersToRemove.add(()=>{l.removeEventListener("mousedown",d);});let u=f=>{let m=f.target;f.button!==0||!isDOMNode(m)||t.update(()=>{let g=$getSelection();W(g)&&g.tableKey===s.tableNodeKey&&r.contains(m)&&s.$clearHighlight();});};i.addEventListener("pointerdown",u,s.listenerOptions),s.listenersToRemove.add(()=>{i.removeEventListener("pointerdown",u);});for(let[f,m]of Eh)s.listenersToRemove.add(t.registerCommand(f,g=>pa(t,g,m,o,s),COMMAND_PRIORITY_HIGH));s.listenersToRemove.add(t.registerCommand(KEY_ESCAPE_COMMAND,f=>{let m=$getSelection();if(W(m)){let g=Bo(o,m.focus.getNode());if(g!==null)return qe(f),g.selectEnd(),true}return false},COMMAND_PRIORITY_HIGH));let h=f=>()=>{let m=$getSelection();if(!Be(m,o))return false;if(W(m))return s.$clearText(),true;if($isRangeSelection(m)){let g=Bo(o,m.anchor.getNode());if(!$(g))return false;let b=m.anchor.getNode(),C=m.focus.getNode(),x=o.isParentOf(b),w=o.isParentOf(C);if(x&&!w||w&&!x)return s.$clearText(),true;let y=$findMatchingParent(m.anchor.getNode(),E=>$isElementNode(E)),N=y&&$findMatchingParent(y,E=>$isElementNode(E)&&$(E.getParent()));if(!$isElementNode(N)||!$isElementNode(y))return false;if(f===DELETE_LINE_COMMAND&&N.getPreviousSibling()===null)return true}return false};for(let f of Th)s.listenersToRemove.add(t.registerCommand(f,h(f),COMMAND_PRIORITY_HIGH));let p=f=>{let m=$getSelection();if(!(W(m)||$isRangeSelection(m)))return false;let g=o.isParentOf(m.anchor.getNode()),b=o.isParentOf(m.focus.getNode());if(g!==b){let C=g?"anchor":"focus",x=g?"focus":"anchor",{key:w,offset:S,type:y}=m[x];return o[m[C].isBefore(m[x])?"selectPrevious":"selectNext"]()[x].set(w,S,y),false}return Be(m,o)&&W(m)?(f&&(f.preventDefault(),f.stopPropagation()),s.$clearText(),true):false};for(let f of vh)s.listenersToRemove.add(t.registerCommand(f,p,COMMAND_PRIORITY_HIGH));return s.listenersToRemove.add(t.registerCommand(CUT_COMMAND,f=>{let m=$getSelection();if(m){if(!(W(m)||$isRangeSelection(m)))return false;Nn(t,objectKlassEquals(f,ClipboardEvent)?f:null,wn(m));let g=p(f);return $isRangeSelection(m)?(m.removeText(),true):g}return false},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FORMAT_TEXT_COMMAND,f=>{let m=$getSelection();if(!Be(m,o))return false;if(W(m))return s.$formatCells(f),true;if($isRangeSelection(m)){let g=$findMatchingParent(m.anchor.getNode(),b=>$(b));if(!$(g))return false}return false},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FORMAT_ELEMENT_COMMAND,f=>{let m=$getSelection();if(!W(m)||!Be(m,o))return false;let g=m.anchor.getNode(),b=m.focus.getNode();if(!$(g)||!$(b))return false;if(Lh(m,o))return o.setFormat(f),true;let[C,x,w]=Se(o,g,b),S=Math.max(x.startRow+x.cell.__rowSpan-1,w.startRow+w.cell.__rowSpan-1),y=Math.max(x.startColumn+x.cell.__colSpan-1,w.startColumn+w.cell.__colSpan-1),N=Math.min(x.startRow,w.startRow),E=Math.min(x.startColumn,w.startColumn),R=new Set;for(let L=N;L<=S;L++)for(let k=E;k<=y;k++){let O=C[L][k].cell;if(R.has(O))continue;R.add(O),O.setFormat(f);let v=O.getChildren();for(let T=0;T<v.length;T++){let K=v[T];$isElementNode(K)&&!K.isInline()&&K.setFormat(f);}}return true},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND,f=>{let m=$getSelection();if(!Be(m,o))return false;if(W(m))return s.$clearHighlight(),false;if($isRangeSelection(m)){let g=$findMatchingParent(m.anchor.getNode(),b=>$(b));if(!$(g))return false;if(typeof f=="string"){let b=Bl(t,m,o);if(b)return zl(b,o,[$createTextNode(f)]),true}}return false},COMMAND_PRIORITY_HIGH)),n&&s.listenersToRemove.add(t.registerCommand(KEY_TAB_COMMAND,f=>{let m=$getSelection();if(!$isRangeSelection(m)||!m.isCollapsed()||!Be(m,o))return false;let g=ro(m.anchor.getNode());return g===null||!o.is(Qe(g))?false:(qe(f),kh(g,f.shiftKey?"previous":"next"),true)},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FOCUS_COMMAND,f=>o.isSelected(),COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(f,m)=>{if(t!==m)return false;let{nodes:g,selection:b}=f,C=b.getStartEndPoints(),x=W(b),S=$isRangeSelection(b)&&$findMatchingParent(b.anchor.getNode(),P=>$(P))!==null&&$findMatchingParent(b.focus.getNode(),P=>$(P))!==null||x;if(g.length!==1||!ce(g[0])||!S||C===null)return false;let[y,N]=C,[E,R,L]=ge(y),k=$findMatchingParent(N.getNode(),P=>$(P));if(!$(E)||!$(k)||!ee(R)||!ce(L))return false;let O=g[0],[v,T,K]=Se(L,E,k),[V]=Ze(O,null,null),se=v.length,ie=se>0?v[0].length:0,le=T.startRow,Ce=T.startColumn,ve=V.length,Ae=ve>0?V[0].length:0;if(x){let P=$n(v,T,K),he=P.maxRow-P.minRow+1,Me=P.maxColumn-P.minColumn+1;le=P.minRow,Ce=P.minColumn,ve=Math.min(ve,he),Ae=Math.min(Ae,Me);}let $e=false,on=Math.min(se,le+ve)-1,Ct=Math.min(ie,Ce+Ae)-1,nn=new Set;for(let P=le;P<=on;P++)for(let he=Ce;he<=Ct;he++){let Me=v[P][he];nn.has(Me.cell.getKey())||Me.cell.__rowSpan===1&&Me.cell.__colSpan===1||(aa(Me.cell),nn.add(Me.cell.getKey()),$e=true);}let[St]=Ze(L.getWritable(),null,null),z=ve-se+le;for(let P=0;P<z;P++){let he=St[se-1][0];Br(he.cell);}let Re=Ae-ie+Ce;for(let P=0;P<Re;P++){let he=St[0][ie-1];Hr(he.cell,true,false);}[St]=Ze(L.getWritable(),null,null);for(let P=le;P<le+ve;P++)for(let he=Ce;he<Ce+Ae;he++){let Me=P-le,nt=he-Ce,xt=V[Me][nt];if(xt.startRow!==Me||xt.startColumn!==nt)continue;let yt=xt.cell;if(yt.__rowSpan!==1||yt.__colSpan!==1){let Ie=[],Ut=Math.min(P+yt.__rowSpan,le+ve)-1,No=Math.min(he+yt.__colSpan,Ce+Ae)-1;for(let _o=P;_o<=Ut;_o++)for(let lr=he;lr<=No;lr++){let hd=St[_o][lr];Ie.push(hd.cell);}la(Ie),$e=true;}let{cell:Fe}=St[P][he],sr=Fe.getChildren();yt.getChildren().forEach(Ie=>{$isTextNode(Ie)&&$createParagraphNode().append(Ie),Fe.append(Ie);}),sr.forEach(Ie=>Ie.remove());}if(x&&$e){let[P]=Ze(L.getWritable(),null,null);P[T.startRow][T.startColumn].cell.selectEnd();}return true},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(SELECTION_CHANGE_COMMAND,()=>{let f=$getSelection(),m=$getPreviousSelection(),g=s.getAndClearNextFocus();if(g!==null){let{focusCell:C}=g;if(W(f)&&f.tableKey===s.tableNodeKey)return C.x===s.focusX&&C.y===s.focusY?false:(s.$setFocusCellForSelection(C),true);if(C!==s.anchorCell&&Be(f,o))return s.$setFocusCellForSelection(C),true}if(s.getAndClearShouldCheckSelection()&&$isRangeSelection(m)&&$isRangeSelection(f)&&f.isCollapsed()){let C=f.anchor.getNode(),x=o.getFirstChild(),w=ro(C);if(w!==null&&ee(x)){let S=x.getFirstChild();if($(S)&&o.is($findMatchingParent(w,y=>y.is(o)||y.is(S))))return S.selectStart(),true}}if($isRangeSelection(f)){let{anchor:C,focus:x}=f,w=C.getNode(),S=x.getNode(),y=ro(w),N=ro(S),E=!!(y&&o.is(Qe(y))),R=!!(N&&o.is(Qe(N))),L=E!==R,k=E&&R,O=f.isBackward();if(L){let v=f.clone();if(R){let[T]=Se(o,N,N),K=T[0][0].cell,V=T[T.length-1].at(-1).cell;v.focus.set(O?K.getKey():V.getKey(),O?K.getChildrenSize():V.getChildrenSize(),"element");}else if(E){let[T]=Se(o,y,y),K=T[0][0].cell,V=T[T.length-1].at(-1).cell;v.anchor.set(O?V.getKey():K.getKey(),O?V.getChildrenSize():0,"element");}$setSelection(v),Kl(t,s);}else if(k&&(y.is(N)||(s.$setAnchorCellForSelection(Rt(s,y)),s.$setFocusCellForSelection(Rt(s,N),true)),s.pointerType==="touch"&&s.isSelecting&&f.isCollapsed()&&$isRangeSelection(m)&&m.isCollapsed())){let v=ro(m.anchor.getNode());v&&!v.is(N)&&(s.$setAnchorCellForSelection(Rt(s,v)),s.$setFocusCellForSelection(Rt(s,N),true),s.pointerType=null);}}else if(f&&W(f)&&f.is(m)&&f.tableKey===o.getKey()){let C=getDOMSelection(i);if(C&&C.anchorNode&&C.focusNode){let x=$getNearestNodeFromDOMNode(C.focusNode),w=x&&!o.isParentOf(x),S=$getNearestNodeFromDOMNode(C.anchorNode),y=S&&o.isParentOf(S);if(w&&y&&C.rangeCount>0){let N=$createRangeSelectionFromDom(C,t);N&&(N.anchor.set(o.getKey(),f.isBackward()?o.getChildrenSize():0,"element"),C.removeAllRanges(),$setSelection(N));}}}return f&&!f.is(m)&&(W(f)||W(m))&&s.tableSelection&&!s.tableSelection.is(m)?(W(f)&&f.tableKey===s.tableNodeKey?s.$updateTableTableSelection(f):!W(f)&&W(m)&&m.tableKey===s.tableNodeKey&&s.$updateTableTableSelection(null),false):(s.hasHijackedSelectionStyles&&!o.isSelected()?Oh(t,s):!s.hasHijackedSelectionStyles&&o.isSelected()&&Kl(t,s),false)},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(INSERT_PARAGRAPH_COMMAND,()=>{let f=$getSelection();if(!$isRangeSelection(f)||!f.isCollapsed()||!Be(f,o))return false;let m=Bl(t,f,o);return m?(zl(m,o),true):false},COMMAND_PRIORITY_HIGH)),s}function Rh(o,e){ii(o)===e&&delete o[ni];}function Mh(o,e){ii(o)!==null&&M("tableElement already has an attached TableObserver"),o[ni]=e;}function ii(o){return o[ni]||null}function Wo(o){let e=o;for(;e!=null;){let t=e.nodeName;if(t==="TD"||t==="TH"){let n=e._cell;return n===void 0?null:n}e=e.parentNode;}return null}function Il(o,e){if(!o.contains(e))return null;let t=null;for(let n=e;n!=null;n=n.parentNode){if(n===o)return t;let r=n.nodeName;(r==="TD"||r==="TH")&&(t=n._cell||null);}return null}function so(o,e){let t=ft(o,e),n=[],r={columns:0,domRows:n,rows:0},i=t.querySelector("tr"),s=0,l=0;for(n.length=0;i!=null;){let a=i.nodeName;if(a==="TD"||a==="TH"){let u=i,h={elem:u,hasBackgroundColor:u.style.backgroundColor!=="",highlighted:false,x:s,y:l};i._cell=h;let p=n[l];p===void 0&&(p=n[l]=[]),p[s]=h;}else {let u=i.firstChild;if(u!=null){i=u;continue}}let c=i.nextSibling;if(c!=null){s++,i=c;continue}let d=i.parentNode;if(d!=null){let u=d.nextSibling;if(u==null)break;l++,s=0,i=u;}}return r.columns=s+1,r.rows=l+1,r}function En(o,e,t){let n=new Set(t?t.getNodes():[]);si(e,(r,i)=>{let s=r.elem;n.has(i)?(r.highlighted=true,ua(o,r)):(r.highlighted=false,fa(o,r),s.getAttribute("style")||s.removeAttribute("style"));});}function si(o,e){let{domRows:t}=o;for(let n=0;n<t.length;n++){let r=t[n];if(r)for(let i=0;i<r.length;i++){let s=r[i];if(!s)continue;let l=$getNearestNodeFromDOMNode(s.elem);l!==null&&e(s,l,{x:i,y:n});}}}function Kl(o,e){e.$disableHighlightStyle(),si(e.table,t=>{t.highlighted=true,ua(o,t);});}function Oh(o,e){e.$enableHighlightStyle(),si(e.table,t=>{let n=t.elem;t.highlighted=false,fa(o,t),n.getAttribute("style")||n.removeAttribute("style");});}function kh(o,e){let t=e==="next"?"getNextSibling":"getPreviousSibling",n=e==="next"?"getFirstChild":"getLastChild",r=o[t]();if($isElementNode(r))return r.selectEnd();let i=$findMatchingParent(o,ee);i===null&&M("selectAdjacentCell: Cell not in table row");for(let l=i[t]();ee(l);l=l[t]()){let a=l[n]();if($isElementNode(a))return a.selectEnd()}let s=$findMatchingParent(i,ce);return s===null&&M("selectAdjacentCell: Row not in table"),e==="next"?s.selectNext():s.selectPrevious()}function Ur(o,e){let t,n;if(e.startColumn===o.minColumn)t="minColumn";else if(e.startColumn+e.cell.__colSpan-1===o.maxColumn)t="maxColumn";else return null;if(e.startRow===o.minRow)n="minRow";else if(e.startRow+e.cell.__rowSpan-1===o.maxRow)n="maxRow";else return null;return [t,n]}function $h(o,e){let t=Ur(o,e);return t===null&&M(`getCornerOrThrow: cell ${e.cell.getKey()} is not at a corner of rect`),t}function vn([o,e]){return [o==="minColumn"?"maxColumn":"minColumn",e==="minRow"?"maxRow":"minRow"]}function oo(o,e,[t,n]){let r=e[n],i=o[r];i===void 0&&M(`cellAtCornerOrThrow: ${n} = ${String(r)} missing in tableMap`);let s=e[t],l=i[s];return l===void 0&&M(`cellAtCornerOrThrow: ${t} = ${String(s)} missing in tableMap`),l}function Fh(o,e,t){let n=$n(o,e,t),r=Ur(n,e);if(r)return [oo(o,n,r),oo(o,n,vn(r))];let i=Ur(n,t);if(i)return [oo(o,n,vn(i)),oo(o,n,i)];let s=["minColumn","minRow"];return [oo(o,n,s),oo(o,n,vn(s))]}function Dh(o,e,t,n,r){let i=$n(e,t,n),s=wh(e,i),{topSpan:l,leftSpan:a,bottomSpan:c,rightSpan:d}=s,u=$h(i,t),[h,p]=vn(u),f=i[h],m=i[p];r==="forward"?f+=h==="maxColumn"?1:a:r==="backward"?f-=h==="minColumn"?1:d:r==="down"?m+=p==="maxRow"?1:l:r==="up"&&(m-=p==="minRow"?1:c);let g=e[m];if(g===void 0)return false;let b=g[f];if(b===void 0)return false;let[C,x]=Fh(e,t,b),w=Rt(o,C.cell),S=Rt(o,x.cell);return o.$setAnchorCellForSelection(w),o.$setFocusCellForSelection(S,true),true}function Be(o,e){if($isRangeSelection(o)||W(o)){let t=e.isParentOf(o.anchor.getNode()),n=e.isParentOf(o.focus.getNode());return t&&n}return false}function Lh(o,e){if(W(o)){let t=o.anchor.getNode(),n=o.focus.getNode();if(e&&t&&n){let[r]=Se(e,t,n);return t.getKey()===r[0][0].cell.getKey()&&n.getKey()===r[r.length-1].at(-1).cell.getKey()}}return false}function Tn(o,e){e?o.selectStart():o.selectEnd();}function ua(o,e){let t=e.elem,n=o._config.theme,r=$getNearestNodeFromDOMNode(t);$(r)||M("Expected to find LexicalNode from Table Cell DOMNode"),addClassNamesToElement(t,n.tableCellSelected);}function fa(o,e){let t=e.elem,n=$getNearestNodeFromDOMNode(t);$(n)||M("Expected to find LexicalNode from Table Cell DOMNode");let r=o._config.theme;removeClassNamesFromElement(t,r.tableCellSelected);}function ro(o){let e=$findMatchingParent(o,$);return $(e)?e:null}function Qe(o){let e=$findMatchingParent(o,ce);return ce(e)?e:null}function Ph(o){for(let e=o,t=o;t!==null;e=t,t=t.getParent())if($isElementNode(t)){if(t!==e&&t.getFirstChild()!==e)return null;if(!t.isInline())return t}return null}function Ih(o,e,t,n,r,i,s){let l=$caretFromPoint(t.focus,r?"previous":"next");if($isExtendableTextPointCaret(l))return false;let a=l;for(let g of $extendCaretToRange(l).iterNodeCarets("shadowRoot")){if(!($isSiblingCaret(g)&&$isElementNode(g.origin)))return false;a=g;}let c=a.getParentAtCaret();if(!$(c))return false;let d=c,u=zh($getSiblingCaret(d,a.direction)),h=$findMatchingParent(d,ce);if(!(h&&h.is(i)))return false;let p=o.getElementByKey(d.getKey()),f=Wo(p);if(!p||!f)return false;let m=ma(o,h);if(s.table=m,u)if(n==="extend"){let g=Wo(o.getElementByKey(u.origin.getKey()));if(!g)return false;s.$setAnchorCellForSelection(f),s.$setFocusCellForSelection(g,true);}else {let g=$normalizeCaret(u);$setPointFromCaret(t.anchor,g),$setPointFromCaret(t.focus,g);}else if(n==="extend")s.$setAnchorCellForSelection(f),s.$setFocusCellForSelection(f,true);else {let g=Kh($getSiblingCaret(h,l.direction));$setPointFromCaret(t.anchor,g),$setPointFromCaret(t.focus,g);}return qe(e),true}function Kh(o){let e=$getAdjacentChildCaret(o);return $isChildCaret(e)?$normalizeCaret(e):o}function zh(o){for(let e of $extendCaretToRange(o).iterNodeCarets("root")){let{origin:t}=e;if($(t)){if($isChildCaret(e))return $getChildCaret(t,o.direction)}else if(!ee(t))break}return null}function pa(o,e,t,n,r){if((t==="up"||t==="down")&&Bh(o))return false;let i=$getSelection();if(!Be(i,n)){if($isRangeSelection(i)){if(t==="backward"){if(i.focus.offset>0)return false;let s=Ph(i.focus.getNode());if(!s)return false;let l=s.getPreviousSibling();return ce(l)?(qe(e),e.shiftKey?i.focus.set(l.getParentOrThrow().getKey(),l.getIndexWithinParent(),"element"):l.selectEnd(),true):false}else if(e.shiftKey&&(t==="up"||t==="down")){let s=i.focus.getNode();if(!i.isCollapsed()&&(t==="up"&&!i.isBackward()||t==="down"&&i.isBackward())){let a=$findMatchingParent(s,p=>ce(p));if($(a)&&(a=$findMatchingParent(a,ce)),a!==n||!a)return false;let c=t==="down"?a.getNextSibling():a.getPreviousSibling();if(!c)return false;let d=0;t==="up"&&$isElementNode(c)&&(d=c.getChildrenSize());let u=c;if(t==="up"&&$isElementNode(c)){let p=c.getLastChild();u=p||c,d=$isTextNode(u)?u.getTextContentSize():0;}let h=i.clone();return h.focus.set(u.getKey(),d,$isTextNode(u)?"text":"element"),$setSelection(h),qe(e),true}else if($isRootOrShadowRoot(s)){let a=t==="up"?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(a&&Bo(n,a)!==null){let d=n.getFirstDescendant(),u=n.getLastDescendant();if(!d||!u)return false;let[h]=ge(d),[p]=ge(u),f=n.getCordsFromCellNode(h,r.table),m=n.getCordsFromCellNode(p,r.table),g=n.getDOMCellFromCordsOrThrow(f.x,f.y,r.table),b=n.getDOMCellFromCordsOrThrow(m.x,m.y,r.table);return r.$setAnchorCellForSelection(g),r.$setFocusCellForSelection(b,true),true}return false}else {let a=$findMatchingParent(s,d=>$isElementNode(d)&&!d.isInline());if($(a)&&(a=$findMatchingParent(a,ce)),!a)return false;let c=t==="down"?a.getNextSibling():a.getPreviousSibling();if(ce(c)&&r.tableNodeKey===c.getKey()){let d=c.getFirstDescendant(),u=c.getLastDescendant();if(!d||!u)return false;let[h]=ge(d),[p]=ge(u),f=i.clone();return f.focus.set((t==="up"?h:p).getKey(),t==="up"?0:p.getChildrenSize(),"element"),qe(e),$setSelection(f),true}}}}return t==="down"&&Uo(o)&&r.setShouldCheckSelection(),false}if($isRangeSelection(i)){if(t==="backward"||t==="forward"){let s=e.shiftKey?"extend":"move";return Ih(o,e,i,s,t==="backward",n,r)}if(i.isCollapsed()){let{anchor:s,focus:l}=i,a=$findMatchingParent(s.getNode(),$),c=$findMatchingParent(l.getNode(),$);if(!$(a)||!a.is(c))return false;let d=Qe(a);if(d!==n&&d!=null){let C=ft(d,o.getElementByKey(d.getKey()));if(C!=null)return r.table=so(d,C),pa(o,e,t,d,r)}let u=o.getElementByKey(a.__key),h=o.getElementByKey(s.key);if(h==null||u==null)return false;let p;if(s.type==="element")p=h.getBoundingClientRect();else {let C=getDOMSelection(ri(o));if(C===null||C.rangeCount===0)return false;p=C.getRangeAt(0).getBoundingClientRect();}let f=t==="up"?a.getFirstChild():a.getLastChild();if(f==null)return false;let m=o.getElementByKey(f.__key);if(m==null)return false;let g=m.getBoundingClientRect();if(t==="up"?g.top>p.top-p.height:p.bottom+p.height>g.bottom){qe(e);let C=n.getCordsFromCellNode(a,r.table);if(e.shiftKey){let x=n.getDOMCellFromCordsOrThrow(C.x,C.y,r.table);r.$setAnchorCellForSelection(x),r.$setFocusCellForSelection(x,true);}else return Ah(r,n,C.x,C.y,t);return true}}}else if(W(i)){let{anchor:s,focus:l}=i,a=$findMatchingParent(s.getNode(),$),c=$findMatchingParent(l.getNode(),$),[d]=i.getNodes();ce(d)||M("$handleArrowKey: TableSelection.getNodes()[0] expected to be TableNode");let u=ft(d,o.getElementByKey(d.getKey()));if(!$(a)||!$(c)||!ce(d)||u==null)return false;r.$updateTableTableSelection(i);let h=so(d,u),p=n.getCordsFromCellNode(a,h),f=n.getDOMCellFromCordsOrThrow(p.x,p.y,h);if(r.$setAnchorCellForSelection(f),qe(e),e.shiftKey){let[m,g,b]=Se(n,a,c);return Dh(r,m,g,b,t)}else c.selectEnd();return true}return false}function qe(o){o.preventDefault(),o.stopImmediatePropagation(),o.stopPropagation();}function Bh(o){let e=o.getRootElement();return e?e.hasAttribute("aria-controls")&&e.getAttribute("aria-controls")==="typeahead-menu":false}function zl(o,e,t){let n=$createParagraphNode();o==="first"?e.insertBefore(n):e.insertAfter(n),n.append(...t||[]),n.selectEnd();}function Bl(o,e,t){let n=t.getParent();if(!n)return;let r=getDOMSelection(ri(o));if(!r)return;let i=r.anchorNode,s=o.getElementByKey(n.getKey()),l=ft(t,o.getElementByKey(t.getKey()));if(!i||!s||!l||!s.contains(i)||l.contains(i))return;let a=$findMatchingParent(e.anchor.getNode(),C=>$(C));if(!a)return;let c=$findMatchingParent(a,C=>ce(C));if(!ce(c)||!c.is(t))return;let[d,u]=Se(t,a,a),h=d[0][0],p=d[d.length-1][d[0].length-1],{startRow:f,startColumn:m}=u,g=f===h.startRow&&m===h.startColumn,b=f===p.startRow&&m===p.startColumn;return g?"first":b?"last":void 0}function Rt(o,e){let{tableNode:t}=o.$lookup(),n=t.getCordsFromCellNode(e,o.table);return t.getDOMCellFromCordsOrThrow(n.x,n.y,o.table)}function jr(o,e,t){return Bo(o,$getNearestNodeFromDOMNode(e,t))}function Hh(o){return isHTMLElement$1(o)&&o.nodeName==="DIV"}function Wh(o,e,t,n){let r=o.querySelector("colgroup");if(!r)return;let i=[];for(let s=0;s<t;s++){let l=document.createElement("col"),a=n&&n[s];a&&(l.style.width=`${a}px`),i.push(l);}r.replaceChildren(...i);}function Uh(o,e,t){t?(addClassNamesToElement(o,e.theme.tableRowStriping),o.setAttribute("data-lexical-row-striping","true")):(removeClassNamesFromElement(o,e.theme.tableRowStriping),o.removeAttribute("data-lexical-row-striping"));}function jh(o,e,t,n){n>0?(addClassNamesToElement(o,t.theme.tableFrozenColumn),e.setAttribute("data-lexical-frozen-column","true")):(removeClassNamesFromElement(o,t.theme.tableFrozenColumn),e.removeAttribute("data-lexical-frozen-column"));}function Yh(o,e,t,n){n>0?(addClassNamesToElement(o,t.theme.tableFrozenRow),e.setAttribute("data-lexical-frozen-row","true")):(removeClassNamesFromElement(o,t.theme.tableFrozenRow),e.removeAttribute("data-lexical-frozen-row"));}function Hl(o,e,t){if(!e.theme.tableAlignment)return;let n=[],r=[];for(let i of ["center","right"]){let s=e.theme.tableAlignment[i];s&&(i===t?r:n).push(s);}removeClassNamesFromElement(o,...n),addClassNamesToElement(o,...r);}function Uo(o=$getEditor()){return Yr.has(o)}function ha(o,e){e?(o._config.theme.tableScrollableWrapper||console.warn("TableNode: hasHorizontalScroll is active but theme.tableScrollableWrapper is not defined."),Yr.add(o)):Yr.delete(o);}function ma(o,e){let t=o.getElementByKey(e.getKey());return t===null&&M("$getElementForTableNode: Table Element Not Found"),so(e,t)}function Gh(o){let e=Fn();o.hasAttribute("data-lexical-row-striping")&&e.setRowStriping(true),o.hasAttribute("data-lexical-frozen-column")&&e.setFrozenColumns(1),o.hasAttribute("data-lexical-frozen-row")&&e.setFrozenRows(1);let t=o.querySelector(":scope > colgroup");if(t){let n=[];for(let r of t.querySelectorAll(":scope > col")){let i=r.style.width||"";if(!qr.test(i)&&(i=r.getAttribute("width")||"",!/^\d+$/.test(i))){n=void 0;break}n.push(parseFloat(i));}n&&e.setColWidths(n);}return {after:n=>$descendantsMatching(n,ee),node:e}}function Fn(){return $applyNodeReplacement(new Ue)}function ce(o){return o instanceof Ue}function Xh({rows:o,columns:e,includeHeaders:t}){let n=$getSelection()||$getPreviousSelection();if(!n||!$isRangeSelection(n)||Qe(n.anchor.getNode()))return false;let r=ta(Number(o),Number(e),t);$insertNodeToNearestRoot(r);let i=r.getFirstDescendant();return $isTextNode(i)&&i.select(),true}function Jh(o){ee(o.getParent())?o.isEmpty()&&o.append($createParagraphNode()):o.remove();}function Vh(o){ce(o.getParent())?$unwrapAndFilterDescendants(o,$):o.remove();}function qh(o){$unwrapAndFilterDescendants(o,ee);let[e]=Ze(o,null,null),t=e.reduce((r,i)=>Math.max(r,i.length),0),n=o.getChildren();for(let r=0;r<e.length;++r){let i=n[r];if(!i)continue;ee(i)||M(`TablePlugin: Expecting all children of TableNode to be TableRowNode, found ${i.constructor.name} (type ${i.getType()})`);let s=e[r].reduce((l,a)=>a?1+l:l,0);if(s!==t)for(let l=s;l<t;++l){let a=Oe();a.append($createParagraphNode()),i.append(a);}}}function Zh(o){if(o.detail<3||!isDOMNode(o.target))return false;let e=$getNearestNodeFromDOMNode(o.target);if(e===null)return false;let t=$findMatchingParent(e,r=>$isElementNode(r)&&!r.isInline());if(t===null)return false;let n=t.getParent();return $(n)?(t.select(0),true):false}function ga(o){return o.registerNodeTransform(We,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){let[,,t]=ge(e),[n]=Se(t,e,e),r=n.length,i=n[0].length,s=t.getFirstChild();ee(s)||M("Expected TableNode first child to be a RowNode");let l=[];for(let a=0;a<r;a++){a!==0&&(s=s.getNextSibling(),ee(s)||M("Expected TableNode first child to be a RowNode"));let c=null;for(let d=0;d<i;d++){let u=n[a][d],h=u.cell;if(u.startRow===a&&u.startColumn===d)c=h,l.push(h);else if(h.getColSpan()>1||h.getRowSpan()>1){$(h)||M("Expected TableNode cell to be a TableCellNode");let p=Oe(h.__headerState);c!==null?c.insertAfter(p):$insertFirst(s,p);}}}for(let a of l)a.setColSpan(1),a.setRowSpan(1);}})}function ba(o,e=true){let t=new Map,n=(i,s,l)=>{let a=ft(i,l),c=da(i,a,o,e);t.set(s,[c,a]);},r=o.registerMutationListener(Ue,i=>{o.getEditorState().read(()=>{for(let[s,l]of i){let a=t.get(s);if(l==="created"||l==="updated"){let{tableNode:c,tableElement:d}=oi(s);a===void 0?n(c,s,d):d!==a[1]&&(a[0].removeListeners(),t.delete(s),n(c,s,d));}else l==="destroyed"&&a!==void 0&&(a[0].removeListeners(),t.delete(s));}},{editor:o});},{skipInitialization:false});return ()=>{r();for(let[,[i]]of t)i.removeListeners();}}function Ca(o){return o.hasNodes([Ue])||M("TablePlugin: TableNode is not registered on editor"),mergeRegister(o.registerCommand(ea,Xh,COMMAND_PRIORITY_EDITOR),o.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,({nodes:e,selection:t},n)=>o!==n||!$isRangeSelection(t)?false:Qe(t.anchor.getNode())!==null&&e.some(ce),COMMAND_PRIORITY_EDITOR),o.registerCommand(CLICK_COMMAND,Zh,COMMAND_PRIORITY_EDITOR),o.registerNodeTransform(Ue,qh),o.registerNodeTransform(Ot,Vh),o.registerNodeTransform(We,Jh))}var qr,sh,oe,We,ea,Ot,Zr,ah,Ll,zr,hh,gh,Ch,Sh,Mn,On,ni,_h,Eh,Th,vh,Ah,Yr,Ue,Qh,xa=rt(async()=>{await Ar();await Dr();qr=/^(\d+(?:\.\d+)?)px$/,sh=75,oe={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1},We=class o extends ElementNode{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return "tablecell"}static clone(e){return new o(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign;}static importDOM(){return {td:e=>({conversion:Dl,priority:0}),th:e=>({conversion:Dl,priority:0})}}static importJSON(e){return Oe().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=oe.NO_STATUS,t=1,n,r){super(r),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0;}createDOM(e){let t=document.createElement(this.getTag());return this.__width&&(t.style.width=`${this.__width}px`),this.__colSpan>1&&(t.colSpan=this.__colSpan),this.__rowSpan>1&&(t.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(t.style.backgroundColor=this.__backgroundColor),Kr(this.__verticalAlign)&&(t.style.verticalAlign=this.__verticalAlign),addClassNamesToElement(t,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),t}exportDOM(e){let t=super.exportDOM(e);if(isHTMLElement(t.element)){let n=t.element;n.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),n.style.border="1px solid black",this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),n.style.width=`${this.getWidth()||sh}px`,n.style.verticalAlign=this.getVerticalAlign()||"top",n.style.textAlign="start",this.__backgroundColor===null&&this.hasHeader()&&(n.style.backgroundColor="#f2f3f5");}return t}exportJSON(){return {...super.exportJSON(),...Kr(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){let t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){let t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=oe.BOTH){let n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){let t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){let t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){let t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){let 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!==oe.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 true}collapseAtStart(){return true}canBeEmpty(){return false}canIndent(){return false}};ea=createCommand("INSERT_TABLE_COMMAND");Ot=class o extends ElementNode{__height;static getType(){return "tablerow"}static clone(e){return new o(e.__height,e.__key)}static importDOM(){return {tr:e=>({conversion:lh,priority:0})}}static importJSON(e){return kt().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e;}exportJSON(){let e=this.getHeight();return {...super.exportJSON(),...e===void 0?void 0:{height:e}}}createDOM(e){let t=document.createElement("tr");return this.__height&&(t.style.height=`${this.__height}px`),addClassNamesToElement(t,e.theme.tableRow),t}extractWithChild(e,t,n){return n==="html"}isShadowRoot(){return true}setHeight(e){let t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return false}canIndent(){return false}};Zr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ah=Zr&&"documentMode"in document?document.documentMode:null,Ll=Zr&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);Zr&&"InputEvent"in window&&!ah&&"getTargetRanges"in new window.InputEvent("input");zr=(o,e)=>o===oe.BOTH||o===e?e:oe.NO_STATUS;hh=na;gh=ra;Ch=ia;Sh=sa;Mn=class o{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=false,this.tableKey=e;}getStartEndPoints(){return [this.anchor,this.focus]}isValid(){if(this.tableKey==="root"||this.anchor.key==="root"||this.anchor.type!=="element"||this.focus.key==="root"||this.focus.type!=="element")return false;let e=$getNodeByKey(this.tableKey),t=$getNodeByKey(this.anchor.key),n=$getNodeByKey(this.focus.key);return e!==null&&t!==null&&n!==null}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e;}is(e){return W(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 o(this.tableKey,$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return false}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter($).forEach(i=>{let s=i.getFirstChild();$isParagraphNode(s)&&(t|=s.getTextFormat());});let r=TEXT_TYPE_TO_FORMAT[e];return (t&r)!==0}insertNodes(e){let t=this.focus.getNode();$isElementNode(t)||M("Expected TableSelection focus to be an ElementNode"),$normalizeSelection__EXPERIMENTAL(t.select(0,t.getChildrenSize())).insertNodes(e);}getShape(){let{anchorCell:e,focusCell:t}=Pl(this),n=Wr(e);n===null&&M("getCellRect: expected to find AnchorNode");let r=Wr(t);r===null&&M("getCellRect: expected to find focusCellNode");let i=Math.min(n.columnIndex,r.columnIndex),s=Math.max(n.columnIndex+n.colSpan-1,r.columnIndex+r.colSpan-1),l=Math.min(n.rowIndex,r.rowIndex),a=Math.max(n.rowIndex+n.rowSpan-1,r.rowIndex+r.rowSpan-1);return {fromX:Math.min(i,s),fromY:Math.min(l,a),toX:Math.max(i,s),toY:Math.max(l,a)}}getNodes(){if(!this.isValid())return [];let e=this._cachedNodes;if(e!==null)return e;let{anchorTable:t,anchorCell:n,focusCell:r}=Pl(this),i=r.getParents()[1];if(i!==t){if(t.isParentOf(r)){let g=i.getParent();g==null&&M("Expected focusCellParent to have a parent"),this.set(this.tableKey,r.getKey(),g.getKey());}else {let g=t.getParent();g==null&&M("Expected gridParent to have a parent"),this.set(this.tableKey,g.getKey(),r.getKey());}return this.getNodes()}let[s,l,a]=Se(t,n,r),{minColumn:c,maxColumn:d,minRow:u,maxRow:h}=$n(s,l,a),p=new Map([[t.getKey(),t]]),f=null;for(let g=u;g<=h;g++)for(let b=c;b<=d;b++){let{cell:C}=s[g][b],x=C.getParent();ee(x)||M("Expected TableCellNode parent to be a TableRowNode"),x!==f&&(p.set(x.getKey(),x),f=x),p.has(C.getKey())||Nh(C,w=>{p.set(w.getKey(),w);});}let m=Array.from(p.values());return isCurrentlyReadOnlyMode()||(this._cachedNodes=m),m}getTextContent(){let e=this.getNodes().filter(n=>$(n)),t="";for(let n=0;n<e.length;n++){let r=e[n],i=r.__parent,s=(e[n+1]||{}).__parent;t+=r.getTextContent()+(s!==i?`
|
|
8
|
+
`:" ");}return t}};On=class{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=false,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=false,this.isSelecting=false,this.pointerType=null,this.shouldCheckSelection=false,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable();}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear();}$lookup(){return oi(this.tableNodeKey,this.editor)}trackTable(){let e=new MutationObserver(t=>{this.editor.getEditorState().read(()=>{let n=false;for(let s=0;s<t.length;s++){let c=t[s].target.nodeName;if(c==="TABLE"||c==="TBODY"||c==="THEAD"||c==="TR"){n=true;break}}if(!n)return;let{tableNode:r,tableElement:i}=this.$lookup();this.table=so(r,i);},{editor:this.editor});});this.editor.getEditorState().read(()=>{let{tableNode:t,tableElement:n}=this.$lookup();this.table=so(t,n),e.observe(n,{attributes:true,childList:true,subtree:true});},{editor:this.editor});}$clearHighlight(){let e=this.editor;this.isHighlightingCells=false,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=false,this.$enableHighlightStyle();let{tableNode:t,tableElement:n}=this.$lookup(),r=so(t,n);En(e,r,null),$getSelection()!==null&&($setSelection(null),e.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0));}$enableHighlightStyle(){let e=this.editor,{tableElement:t}=this.$lookup();removeClassNamesFromElement(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=false;}$disableHighlightStyle(){let{tableElement:e}=this.$lookup();addClassNamesToElement(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=true;}$updateTableTableSelection(e){if(e!==null){e.tableKey!==this.tableNodeKey&&M(`TableObserver.$updateTableTableSelection: selection.tableKey !== this.tableNodeKey ('${e.tableKey}' !== '${this.tableNodeKey}')`);let t=this.editor;this.tableSelection=e,this.isHighlightingCells=true,this.$disableHighlightStyle(),this.updateDOMSelection(),En(t,this.table,this.tableSelection);}else this.$clearHighlight();}setShouldCheckSelection(){this.shouldCheckSelection=true;}getAndClearShouldCheckSelection(){return this.shouldCheckSelection?(this.shouldCheckSelection=false,true):false}setNextFocus(e){this.nextFocus=e;}getAndClearNextFocus(){let{nextFocus:e}=this;return e!==null&&(this.nextFocus=null),e}updateDOMSelection(){if(this.anchorCell!==null&&this.focusCell!==null){let e=getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges();}}$setFocusCellForSelection(e,t=false){let n=this.editor,{tableNode:r}=this.$lookup(),i=e.x,s=e.y;if(this.focusCell=e,!this.isHighlightingCells&&(this.anchorX!==i||this.anchorY!==s||t))this.isHighlightingCells=true,this.$disableHighlightStyle();else if(i===this.focusX&&s===this.focusY)return false;if(this.focusX=i,this.focusY=s,this.isHighlightingCells){let l=jr(r,e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&l!==null)return this.focusCellNodeKey=l.getKey(),this.tableSelection=ca(r,this.$getAnchorTableCellOrThrow(),l),$setSelection(this.tableSelection),n.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0),En(n,this.table,this.tableSelection),true}return false}$getAnchorTableCell(){return this.anchorCellNodeKey?$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){let e=this.$getAnchorTableCell();return e===null&&M("TableObserver anchorTableCell is null"),e}$getFocusTableCell(){return this.focusCellNodeKey?$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){let e=this.$getFocusTableCell();return e===null&&M("TableObserver focusTableCell is null"),e}$setAnchorCellForSelection(e){this.isHighlightingCells=false,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;let{tableNode:t}=this.$lookup(),n=jr(t,e.elem);if(n!==null){let r=n.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():ti(),this.anchorCellNodeKey=r;}}$formatCells(e){let t=$getSelection();W(t)||M("Expected Table selection");let n=$createRangeSelection(),r=n.anchor,i=n.focus,s=t.getNodes().filter($);s.length>0||M("No table cells present");let l=s[0].getFirstChild(),a=$isParagraphNode(l)?l.getFormatFlags(e,null):null;s.forEach(c=>{r.set(c.getKey(),0,"element"),i.set(c.getKey(),c.getChildrenSize(),"element"),n.formatText(e,a);}),$setSelection(t),this.editor.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0);}$clearText(){let{editor:e}=this,t=$getNodeByKey(this.tableNodeKey);if(!ce(t))throw new Error("Expected TableNode.");let n=$getSelection();W(n)||M("Expected TableSelection");let r=n.getNodes().filter($),i=t.getFirstChild(),s=t.getLastChild();if(r.length>0&&i!==null&&s!==null&&ee(i)&&ee(s)&&r[0]===i.getFirstChild()&&r[r.length-1]===s.getLastChild()){t.selectPrevious();let a=t.getParent();t.remove(),$isRootNode(a)&&a.isEmpty()&&e.dispatchCommand(INSERT_PARAGRAPH_COMMAND,void 0);return}r.forEach(a=>{if($isElementNode(a)){let c=$createParagraphNode(),d=$createTextNode();c.append(d),a.append(c),a.getChildren().forEach(u=>{u!==c&&u.remove();});}}),En(e,this.table,null),$setSelection(null),e.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0);}},ni="__lexicalTableSelection",_h=o=>(o.buttons&1)===1;Eh=[[KEY_ARROW_DOWN_COMMAND,"down"],[KEY_ARROW_UP_COMMAND,"up"],[KEY_ARROW_LEFT_COMMAND,"backward"],[KEY_ARROW_RIGHT_COMMAND,"forward"]],Th=[DELETE_WORD_COMMAND,DELETE_LINE_COMMAND,DELETE_CHARACTER_COMMAND],vh=[KEY_BACKSPACE_COMMAND,KEY_DELETE_COMMAND];Ah=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case "backward":case "forward":return t!==(i?o.table.columns-1:0)?Tn(e.getCellNodeFromCordsOrThrow(t+(i?1:-1),n,o.table),i):n!==(i?o.table.rows-1:0)?Tn(e.getCellNodeFromCordsOrThrow(i?0:o.table.columns-1,n+(i?1:-1),o.table),i):i?e.selectNext():e.selectPrevious(),true;case "up":return n!==0?Tn(e.getCellNodeFromCordsOrThrow(t,n-1,o.table),false):e.selectPrevious(),true;case "down":return n!==o.table.rows-1?Tn(e.getCellNodeFromCordsOrThrow(t,n+1,o.table),true):e.selectNext(),true;default:return false}};Yr=new WeakSet;Ue=class o extends ElementNode{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return "table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){let t=this.getWritable();return t.__colWidths=e!==void 0?Object.freeze(e):e,t}static clone(e){return new o(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:Gh,priority:1})}}static importJSON(e){return Fn().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||false).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=false,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 n==="html"}getDOMSlot(e){let t=no(e)?e:e.querySelector("table");return no(t)||M("TableNode.getDOMSlot: createDOM() did not return a table"),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(e,t){let n=document.createElement("table");this.__style&&(n.style.cssText=this.__style);let r=document.createElement("colgroup");if(n.appendChild(r),setDOMUnmanaged(r),addClassNamesToElement(n,e.theme.table),this.updateTableElement(null,n,e),Uo(t)){let i=document.createElement("div"),s=e.theme.tableScrollableWrapper;return s?addClassNamesToElement(i,s):i.style.cssText="overflow-x: auto;",i.appendChild(n),this.updateTableWrapper(null,i,n,e),i}return n}updateTableWrapper(e,t,n,r){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&jh(t,n,r,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&Yh(t,n,r,this.__frozenRowCount);}updateTableElement(e,t,n){this.__style!==(e?e.__style:"")&&(t.style.cssText=this.__style),this.__rowStriping!==(e?e.__rowStriping:false)&&Uh(t,n,this.__rowStriping),Wh(t,n,this.getColumnCount(),this.getColWidths()),Hl(t,n,this.getFormatType());}updateDOM(e,t,n){let i=this.getDOMSlot(t).element;return t===i===Uo()?true:(Hh(t)&&this.updateTableWrapper(e,t,i,n),this.updateTableElement(e,i,n),false)}exportDOM(e){let t=super.exportDOM(e),{element:n}=t;return {after:r=>{if(t.after&&(r=t.after(r)),!no(r)&&isHTMLElement$1(r)&&(r=r.querySelector("table")),!no(r))return null;Hl(r,e._config,this.getFormatType());let[i]=Ze(this,null,null),s=new Map;for(let d of i)for(let u of d){let h=u.cell.getKey();s.has(h)||s.set(h,{colSpan:u.cell.getColSpan(),startColumn:u.startColumn});}let l=new Set;for(let d of r.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){let u=d.getAttribute("data-temporary-table-cell-lexical-key");if(u){let h=s.get(u);if(d.removeAttribute("data-temporary-table-cell-lexical-key"),h){s.delete(u);for(let p=0;p<h.colSpan;p++)l.add(p+h.startColumn);}}}let a=r.querySelector(":scope > colgroup");if(a){let d=Array.from(r.querySelectorAll(":scope > colgroup > col")).filter((u,h)=>l.has(h));a.replaceChildren(...d);}let c=r.querySelectorAll(":scope > tr");if(c.length>0){let d=document.createElement("tbody");for(let u of c)d.appendChild(u);r.append(d);}return r},element:!no(n)&&isHTMLElement$1(n)?n.querySelector("table"):n}}canBeEmpty(){return false}isShadowRoot(){return true}getCordsFromCellNode(e,t){let{rows:n,domRows:r}=t;for(let i=0;i<n;i++){let s=r[i];if(s!=null)for(let l=0;l<s.length;l++){let a=s[l];if(a==null)continue;let{elem:c}=a,d=jr(this,c);if(d!==null&&e.is(d))return {x:l,y:i}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){let{domRows:r}=n,i=r[t];if(i==null)return null;let s=e<i.length?e:i.length-1,l=i[s];return l??null}getDOMCellFromCordsOrThrow(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(!r)throw new Error("Cell not found at cords.");return r}getCellNodeFromCords(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(r==null)return null;let i=$getNearestNodeFromDOMNode(r.elem);return $(i)?i:null}getCellNodeFromCordsOrThrow(e,t,n){let r=this.getCellNodeFromCords(e,t,n);if(!r)throw new Error("Node at cords not TableCellNode.");return r}getRowStriping(){return !!this.getLatest().__rowStriping}setRowStriping(e){let t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){let t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){let t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return true}canIndent(){return false}getColumnCount(){let e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach(n=>{$(n)&&(t+=n.getColSpan());}),t}};Qh=defineExtension({build(o,e,t){return Sn(e)},config:safeCast({hasCellBackgroundColor:true,hasCellMerge:true,hasHorizontalScroll:true,hasTabHandler:true}),name:"@lexical/table/Table",nodes:[Ue,Ot,We],register(o,e,t){let n=t.getOutput();return mergeRegister(Ke(()=>{let r=n.hasHorizontalScroll.value;Uo(o)!==r&&(ha(o,r),o.registerNodeTransform(Ue,()=>{})());}),Ca(o),Ke(()=>ba(o,n.hasTabHandler.value)),Ke(()=>n.hasCellMerge.value?void 0:ga(o)),Ke(()=>n.hasCellBackgroundColor.value?void 0:o.registerNodeTransform(We,r=>{r.getBackgroundColor()!==null&&r.setBackgroundColor(null);})))}});});var lc={};jt(lc,{$computeTableMap:()=>ye,$computeTableMapSkipCellCheck:()=>tt,$createTableCellNode:()=>ke,$createTableNode:()=>jn,$createTableNodeWithDimensions:()=>Wa,$createTableRowNode:()=>Lt,$createTableSelection:()=>Ri,$createTableSelectionFrom:()=>qa,$deleteTableColumn:()=>Ym,$deleteTableColumnAtSelection:()=>Xa,$deleteTableColumn__EXPERIMENTAL:()=>Xm,$deleteTableRowAtSelection:()=>Ga,$deleteTableRow__EXPERIMENTAL:()=>Gm,$findCellNode:()=>fo,$findTableNode:()=>Ft,$getElementForTableNode:()=>nc,$getNodeTriplet:()=>be,$getTableAndElementByKey:()=>Mi,$getTableCellNodeFromLexicalNode:()=>Im,$getTableCellNodeRect:()=>mi,$getTableColumnIndexFromTableCellNode:()=>zm,$getTableNodeFromLexicalNodeOrThrow:()=>Un,$getTableRowIndexFromTableCellNode:()=>Km,$getTableRowNodeFromTableCellNodeOrThrow:()=>Ti,$insertTableColumn:()=>Um,$insertTableColumnAtSelection:()=>Ya,$insertTableColumn__EXPERIMENTAL:()=>jm,$insertTableRow:()=>Hm,$insertTableRowAtSelection:()=>ja,$insertTableRow__EXPERIMENTAL:()=>Wm,$isScrollableTablesActive:()=>Jo,$isTableCellNode:()=>F,$isTableNode:()=>ue,$isTableRowNode:()=>te,$isTableSelection:()=>j,$mergeCells:()=>Ja,$removeTableRowAtIndex:()=>Bm,$unmergeCell:()=>Vm,INSERT_TABLE_COMMAND:()=>Ha,TableCellHeaderStates:()=>ne,TableCellNode:()=>Ge,TableExtension:()=>dg,TableNode:()=>Xe,TableObserver:()=>Hn,TableRowNode:()=>Dt,applyTableHandlers:()=>Za,getDOMCellFromTarget:()=>Xo,getTableElement:()=>mt,getTableObserverFromTableElement:()=>bi,registerTableCellUnmergeTransform:()=>rc,registerTablePlugin:()=>sc,registerTableSelectionObserver:()=>ic,setScrollableTablesActive:()=>oc});function ui(o){return o==="middle"||o==="bottom"}function Ta(o){let e=o,t=o.nodeName.toLowerCase(),n;_i.test(e.style.width)&&(n=parseFloat(e.style.width));let r=ke(t==="th"?ne.ROW:ne.NO_STATUS,e.colSpan,n);r.__rowSpan=e.rowSpan;let i=e.style.backgroundColor;i!==""&&(r.__backgroundColor=i);let s=e.style.verticalAlign;ui(s)&&(r.__verticalAlign=s);let l=e.style,a=(l&&l.textDecoration||"").split(" "),c=l.fontWeight==="700"||l.fontWeight==="bold",d=a.includes("line-through"),u=l.fontStyle==="italic",h=a.includes("underline");return {after:p=>{let f=[],m=null,g=()=>{if(m){let b=m.getFirstChild();$isLineBreakNode(b)&&m.getChildrenSize()===1&&b.remove();}};for(let b of p)$isInlineElementOrDecoratorNode(b)||$isTextNode(b)||$isLineBreakNode(b)?($isTextNode(b)&&(c&&b.toggleFormat("bold"),d&&b.toggleFormat("strikethrough"),u&&b.toggleFormat("italic"),h&&b.toggleFormat("underline")),m?m.append(b):(m=$createParagraphNode().append(b),f.push(m))):(f.push(b),g(),m=null);return g(),f.length===0&&f.push($createParagraphNode()),f},node:r}}function ke(o=ne.NO_STATUS,e=1,t){return $applyNodeReplacement(new Ge(o,e,t))}function F(o){return o instanceof Ge}function A(o,...e){let t=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",o);for(let r of e)n.append("v",r);throw t.search=n.toString(),Error(`Minified Lexical error #${o}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Lm(o){let e=o,t;return _i.test(e.style.height)&&(t=parseFloat(e.style.height)),{after:n=>$descendantsMatching(n,F),node:Lt(t)}}function Lt(o){return $applyNodeReplacement(new Dt(o))}function te(o){return o instanceof Dt}function Wa(o,e,t=true){let n=jn();for(let r=0;r<o;r++){let i=Lt();for(let s=0;s<e;s++){let l=ne.NO_STATUS;typeof t=="object"?(r===0&&t.rows&&(l|=ne.ROW),s===0&&t.columns&&(l|=ne.COLUMN)):t&&(r===0&&(l|=ne.ROW),s===0&&(l|=ne.COLUMN));let a=ke(l),c=$createParagraphNode();c.append($createTextNode()),a.append(c),i.append(a);}n.append(i);}return n}function Im(o){let e=$findMatchingParent(o,t=>F(t));return F(e)?e:null}function Ti(o){let e=$findMatchingParent(o,t=>te(t));if(te(e))return e;throw new Error("Expected table cell to be inside of table row.")}function Un(o){let e=$findMatchingParent(o,t=>ue(t));if(ue(e))return e;throw new Error("Expected table cell to be inside of table.")}function Km(o){let e=Ti(o);return Un(e).getChildren().findIndex(t=>t.is(e))}function zm(o){return Ti(o).getChildren().findIndex(e=>e.is(o))}function Ua(o,e){let t=Un(o),{x:n,y:r}=t.getCordsFromCellNode(o,e);return {above:t.getCellNodeFromCords(n,r-1,e),below:t.getCellNodeFromCords(n,r+1,e),left:t.getCellNodeFromCords(n-1,r,e),right:t.getCellNodeFromCords(n+1,r,e)}}function Bm(o,e){let t=o.getChildren();if(e>=t.length||e<0)throw new Error("Expected table cell to be inside of table row.");return t[e].remove(),o}function Hm(o,e,t=true,n,r){let i=o.getChildren();if(e>=i.length||e<0)throw new Error("Table row target index out of range");let s=i[e];if(!te(s))throw new Error("Row before insertion index does not exist.");for(let l=0;l<n;l++){let a=s.getChildren(),c=a.length,d=Lt();for(let u=0;u<c;u++){let h=a[u];F(h)||A(12);let{above:p,below:f}=Ua(h,r),m=ne.NO_STATUS,g=p&&p.getWidth()||f&&f.getWidth()||void 0;(p&&p.hasHeaderState(ne.COLUMN)||f&&f.hasHeaderState(ne.COLUMN))&&(m|=ne.COLUMN);let b=ke(m,1,g);b.append($createParagraphNode()),d.append(b);}t?s.insertAfter(d):s.insertBefore(d);}return o}function ja(o=true){let e=$getSelection();$isRangeSelection(e)||j(e)||A(188);let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=be(t),[i,,s]=be(n),[,l,a]=ye(s,i,r),{startRow:c}=a,{startRow:d}=l;return o?pi(c+r.__rowSpan>d+i.__rowSpan?r:i,true):pi(d<c?i:r,false)}function pi(o,e=true){let[,,t]=be(o),[n,r]=ye(t,o,o),i=n[0].length,{startRow:s}=r,l=null;if(e){let a=s+o.__rowSpan-1,c=n[a],d=Lt();for(let h=0;h<i;h++){let{cell:p,startRow:f}=c[h];if(f+p.__rowSpan-1<=a){let m=c[h].cell.__headerState,g=fi(m,ne.COLUMN);d.append(ke(g).append($createParagraphNode()));}else p.setRowSpan(p.__rowSpan+1);}let u=t.getChildAtIndex(a);te(u)||A(256),u.insertAfter(d),l=d;}else {let a=s,c=n[a],d=Lt();for(let h=0;h<i;h++){let{cell:p,startRow:f}=c[h];if(f===a){let m=c[h].cell.__headerState,g=fi(m,ne.COLUMN);d.append(ke(g).append($createParagraphNode()));}else p.setRowSpan(p.__rowSpan+1);}let u=t.getChildAtIndex(a);te(u)||A(257),u.insertBefore(d),l=d;}return l}function Um(o,e,t=true,n,r){let i=o.getChildren(),s=[];for(let l=0;l<i.length;l++){let a=i[l];if(te(a))for(let c=0;c<n;c++){let d=a.getChildren();if(e>=d.length||e<0)throw new Error("Table column target index out of range");let u=d[e];F(u)||A(12);let{left:h,right:p}=Ua(u,r),f=ne.NO_STATUS;(h&&h.hasHeaderState(ne.ROW)||p&&p.hasHeaderState(ne.ROW))&&(f|=ne.ROW);let m=ke(f);m.append($createParagraphNode()),s.push({newTableCell:m,targetCell:u});}}return s.forEach(({newTableCell:l,targetCell:a})=>{t?a.insertAfter(l):a.insertBefore(l);}),o}function Ya(o=true){let e=$getSelection();$isRangeSelection(e)||j(e)||A(188);let t=e.anchor.getNode(),n=e.focus.getNode(),[r]=be(t),[i,,s]=be(n),[,l,a]=ye(s,i,r),{startColumn:c}=a,{startColumn:d}=l;return o?hi(c+r.__colSpan>d+i.__colSpan?r:i,true):hi(d<c?i:r,false)}function hi(o,e=true,t=true){let[,,n]=be(o),[r,i]=ye(n,o,o),s=r.length,{startColumn:l}=i,a=e?l+o.__colSpan-1:l-1,c=n.getFirstChild();te(c)||A(120);let d=null;function u(f=ne.NO_STATUS){let m=ke(f).append($createParagraphNode());return d===null&&(d=m),m}let h=c;e:for(let f=0;f<s;f++){if(f!==0){let S=h.getNextSibling();te(S)||A(121),h=S;}let m=r[f],g=m[a<0?0:a].cell.__headerState,b=fi(g,ne.ROW);if(a<0){vi(h,u(b));continue}let{cell:C,startColumn:x,startRow:w}=m[a];if(x+C.__colSpan-1<=a){let S=C,y=w,N=a;for(;y!==f&&S.__rowSpan>1;){if(N-=C.__colSpan,!(N>=0)){h.append(u(b));continue e}{let{cell:E,startRow:R}=m[N];S=E,y=R;}}S.insertAfter(u(b));}else C.setColSpan(C.__colSpan+1);}d!==null&&t&&Go(d);let p=n.getColWidths();if(p){let f=[...p],m=a<0?0:a,g=f[m];f.splice(m,0,g),n.setColWidths(f);}return d}function Ym(o,e){let t=o.getChildren();for(let n=0;n<t.length;n++){let r=t[n];if(te(r)){let i=r.getChildren();if(e>=i.length||e<0)throw new Error("Table column target index out of range");i[e].remove();}}return o}function Ga(){let o=$getSelection();$isRangeSelection(o)||j(o)||A(188);let[e,t]=o.isBackward()?[o.focus.getNode(),o.anchor.getNode()]:[o.anchor.getNode(),o.focus.getNode()],[n,,r]=be(e),[i]=be(t),[s,l,a]=ye(r,n,i),{startRow:c}=l,{startRow:d}=a,u=d+i.__rowSpan-1;if(s.length===u-c+1)return void r.remove();let h=s[0].length,p=s[u+1],f=r.getChildAtIndex(u+1);for(let m=u;m>=c;m--){for(let b=h-1;b>=0;b--){let{cell:C,startRow:x,startColumn:w}=s[m][b];if(w===b){if(x<c||x+C.__rowSpan-1>u){let S=Math.max(x,c),y=Math.min(C.__rowSpan+x-1,u),N=S<=y?y-S+1:0;C.setRowSpan(C.__rowSpan-N);}if(x>=c&&x+C.__rowSpan-1>u&&m===u){f===null&&A(122);let S=null;for(let y=0;y<b;y++){let N=p[y],E=N.cell;N.startRow===m+1&&(S=E),E.__colSpan>1&&(y+=E.__colSpan-1);}S===null?vi(f,C):S.insertAfter(C);}}}let g=r.getChildAtIndex(m);te(g)||A(206,String(m)),g.remove();}if(p!==void 0){let{cell:m}=p[0];Go(m);}else {let m=s[c-1],{cell:g}=m[0];Go(g);}}function Xa(){let o=$getSelection();$isRangeSelection(o)||j(o)||A(188);let e=o.anchor.getNode(),t=o.focus.getNode(),[n,,r]=be(e),[i]=be(t),[s,l,a]=ye(r,n,i),{startColumn:c}=l,{startRow:d,startColumn:u}=a,h=Math.min(c,u),p=Math.max(c+n.__colSpan-1,u+i.__colSpan-1),f=p-h+1;if(s[0].length===p-h+1)return r.selectPrevious(),void r.remove();let m=s.length;for(let x=0;x<m;x++)for(let w=h;w<=p;w++){let{cell:S,startColumn:y}=s[x][w];if(y<h){if(w===h){let N=h-y;S.setColSpan(S.__colSpan-Math.min(f,S.__colSpan-N));}}else if(y+S.__colSpan-1>p){if(w===p){let N=p-y+1;S.setColSpan(S.__colSpan-N);}}else S.remove();}let g=s[d],b=c>u?g[c+n.__colSpan]:g[u+i.__colSpan];if(b!==void 0){let{cell:x}=b;Go(x);}else {let x=u<c?g[u-1]:g[c-1],{cell:w}=x;Go(w);}let C=r.getColWidths();if(C){let x=[...C];x.splice(h,f),r.setColWidths(x);}}function Go(o){let e=o.getFirstDescendant();e==null?o.selectStart():e.getParentOrThrow().selectStart();}function vi(o,e){let t=o.getFirstChild();t!==null?t.insertBefore(e):o.append(e);}function Ja(o){if(o.length===0)return null;let e=Un(o[0]),[t]=tt(e,null,null),n=1/0,r=-1/0,i=1/0,s=-1/0,l=new Set;for(let p of t)for(let f of p){if(!f||!f.cell)continue;let m=f.cell.getKey();if(!l.has(m)&&o.some(g=>g.is(f.cell))){l.add(m);let g=f.startRow,b=f.startColumn,C=f.cell.__rowSpan||1,x=f.cell.__colSpan||1;n=Math.min(n,g),r=Math.max(r,g+C-1),i=Math.min(i,b),s=Math.max(s,b+x-1);}}if(n===1/0||i===1/0)return null;let a=r-n+1,c=s-i+1,d=t[n][i];if(!d.cell)return null;let u=d.cell;u.setColSpan(c),u.setRowSpan(a);let h=new Set([u.getKey()]);for(let p=n;p<=r;p++)for(let f=i;f<=s;f++){let m=t[p][f];if(!m.cell)continue;let g=m.cell,b=g.getKey();h.has(b)||(h.add(b),Jm(g)||u.append(...g.getChildren()),g.remove());}return u.getChildrenSize()===0&&u.append($createParagraphNode()),u}function Jm(o){if(o.getChildrenSize()!==1)return false;let e=o.getFirstChildOrThrow();return !(!$isParagraphNode(e)||!e.isEmpty())}function Vm(){let o=$getSelection();$isRangeSelection(o)||j(o)||A(188);let e=o.anchor.getNode(),t=$findMatchingParent(e,F);return F(t)||A(148),Va(t)}function Va(o){let[e,t,n]=be(o),r=e.__colSpan,i=e.__rowSpan;if(r===1&&i===1)return;let[s,l]=ye(n,e,e),{startColumn:a,startRow:c}=l,d=e.__headerState&ne.COLUMN,u=Array.from({length:r},(f,m)=>{let g=d;for(let b=0;g!==0&&b<s.length;b++)g&=s[b][m+a].cell.__headerState;return g}),h=e.__headerState&ne.ROW,p=Array.from({length:i},(f,m)=>{let g=h;for(let b=0;g!==0&&b<s[0].length;b++)g&=s[m+c][b].cell.__headerState;return g});if(r>1){for(let f=1;f<r;f++)e.insertAfter(ke(u[f]|p[0]).append($createParagraphNode()));e.setColSpan(1);}if(i>1){let f;for(let m=1;m<i;m++){let g=c+m,b=s[g];f=(f||t).getNextSibling(),te(f)||A(125);let C=null;for(let x=0;x<a;x++){let w=b[x],S=w.cell;w.startRow===g&&(C=S),S.__colSpan>1&&(x+=S.__colSpan-1);}if(C===null)for(let x=r-1;x>=0;x--)vi(f,ke(u[x]|p[m]).append($createParagraphNode()));else for(let x=r-1;x>=0;x--)C.insertAfter(ke(u[x]|p[m]).append($createParagraphNode()));}e.setRowSpan(1);}}function ye(o,e,t){let[n,r,i]=tt(o,e,t);return r===null&&A(207),i===null&&A(208),[n,r,i]}function tt(o,e,t){let n=[],r=null,i=null;function s(a){let c=n[a];return c===void 0&&(n[a]=c=[]),c}let l=o.getChildren();for(let a=0;a<l.length;a++){let c=l[a];te(c)||A(209);let d=s(a);for(let u=c.getFirstChild(),h=0;u!=null;u=u.getNextSibling()){for(F(u)||A(147);d[h]!==void 0;)h++;let p={cell:u,startColumn:h,startRow:a},{__rowSpan:f,__colSpan:m}=u;for(let g=0;g<f&&!(a+g>=l.length);g++){let b=s(a+g);for(let C=0;C<m;C++)b[h+C]=p;}e!==null&&r===null&&e.is(u)&&(r=p),t!==null&&i===null&&t.is(u)&&(i=p);}}return [n,r,i]}function be(o){let e;if(o instanceof Ge)e=o;else if("__type"in o){let r=$findMatchingParent(o,F);F(r)||A(148),e=r;}else {let r=$findMatchingParent(o.getNode(),F);F(r)||A(148),e=r;}let t=e.getParent();te(t)||A(149);let n=t.getParent();return ue(n)||A(210),[e,t,n]}function zn(o,e,t){let n,r=Math.min(e.startColumn,t.startColumn),i=Math.min(e.startRow,t.startRow),s=Math.max(e.startColumn+e.cell.__colSpan-1,t.startColumn+t.cell.__colSpan-1),l=Math.max(e.startRow+e.cell.__rowSpan-1,t.startRow+t.cell.__rowSpan-1);do{n=false;for(let a=0;a<o.length;a++)for(let c=0;c<o[0].length;c++){let d=o[a][c];if(!d)continue;let u=d.startColumn+d.cell.__colSpan-1,h=d.startRow+d.cell.__rowSpan-1,p=d.startColumn<=s&&u>=r,f=d.startRow<=l&&h>=i;if(p&&f){let m=Math.min(r,d.startColumn),g=Math.max(s,u),b=Math.min(i,d.startRow),C=Math.max(l,h);m===r&&g===s&&b===i&&C===l||(r=m,s=g,i=b,l=C,n=true);}}}while(n);return {maxColumn:s,maxRow:l,minColumn:r,minRow:i}}function mi(o){let[e,,t]=be(o),n=t.getChildren(),r=n.length,i=n[0].getChildren().length,s=new Array(r);for(let l=0;l<r;l++)s[l]=new Array(i);for(let l=0;l<r;l++){let a=n[l].getChildren(),c=0;for(let d=0;d<a.length;d++){for(;s[l][c];)c++;let u=a[d],h=u.__rowSpan||1,p=u.__colSpan||1;for(let f=0;f<h;f++)for(let m=0;m<p;m++)s[l+f][c+m]=u;if(e===u)return {colSpan:p,columnIndex:c,rowIndex:l,rowSpan:h};c+=p;}}return null}function Ra(o){let[[e,t,n,r],[i,s,l,a]]=["anchor","focus"].map(c=>{let d=o[c].getNode(),u=$findMatchingParent(d,F);F(u)||A(238,c,d.getKey(),d.getType());let h=u.getParent();te(h)||A(239,c);let p=h.getParent();return ue(p)||A(240,c),[d,u,h,p]});return r.is(a)||A(241),{anchorCell:t,anchorNode:e,anchorRow:n,anchorTable:r,focusCell:s,focusNode:i,focusRow:l,focusTable:a}}function j(o){return o instanceof Bn}function Ri(){let o=$createPoint("root",0,"element"),e=$createPoint("root",0,"element");return new Bn("root",o,e)}function qa(o,e,t){o.getKey(),e.getKey(),t.getKey();let n=$getSelection(),r=j(n)?n.clone():Ri();return r.set(o.getKey(),e.getKey(),t.getKey()),r}function qm(o,e){let t=[[o]];for(let n=t.at(-1);n!==void 0&&t.length>0;n=t.at(-1)){let r=n.pop();r===void 0?t.pop():e(r)!==false&&$isElementNode(r)&&t.push(r.getChildren());}}function Mi(o,e=$getEditor()){let t=$getNodeByKey(o);ue(t)||A(231,o);let n=mt(t,e.getElementByKey(o));return n===null&&A(232,o),{tableElement:n,tableNode:t}}function uo(o){return isHTMLElement(o)&&o.nodeName==="TABLE"}function mt(o,e){if(!e)return e;let t=uo(e)?e:o.getDOMSlot(e).element;return t.nodeName!=="TABLE"&&A(245,e.nodeName),t}function Oi(o){return o._window}function Yo(o,e){for(let t=e,n=null;t!==null;t=t.getParent()){if(o.is(t))return n;F(t)&&(n=t);}return null}function Za(o,e,t,n){let r=t.getRootElement(),i=Oi(t);r!==null&&i!==null||A(246);let s=new Hn(t,o.getKey()),l=mt(o,e);((function(p,f){bi(p)!==null&&A(205),p[gi]=f;}))(l,s),s.listenersToRemove.add(()=>(function(p,f){bi(p)===f&&delete p[gi];})(l,s));let a=p=>{if(s.pointerType=p.pointerType,p.button!==0||!isDOMNode(p.target)||!i)return;let f=Xo(p.target);f!==null&&t.update(()=>{let m=$getPreviousSelection();if(va&&p.shiftKey&&je(m,o)&&($isRangeSelection(m)||j(m))){let g=m.anchor.getNode(),b=Yo(o,m.anchor.getNode());b?(s.$setAnchorCellForSelection(At(s,b)),s.$setFocusCellForSelection(f),et(p)):(o.isBefore(g)?o.selectStart():o.selectEnd()).anchor.set(m.anchor.key,m.anchor.offset,m.anchor.type);}else p.pointerType!=="touch"&&s.$setAnchorCellForSelection(f);}),(()=>{if(s.isSelecting)return;let m=()=>{s.isSelecting=false,i.removeEventListener("pointerup",m),i.removeEventListener("pointermove",g);},g=b=>{if(1&~b.buttons&&s.isSelecting)return s.isSelecting=false,i.removeEventListener("pointerup",m),void i.removeEventListener("pointermove",g);if(!isDOMNode(b.target))return;let C=null,x=!(va||l.contains(b.target));if(x)C=Ma(l,b.target);else for(let w of document.elementsFromPoint(b.clientX,b.clientY))if(C=Ma(l,w),C)break;!C||s.focusCell!==null&&C.elem===s.focusCell.elem||(s.setNextFocus({focusCell:C,override:x}),t.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0));};s.isSelecting=true,i.addEventListener("pointerup",m,s.listenerOptions),i.addEventListener("pointermove",g,s.listenerOptions);})();};l.addEventListener("pointerdown",a,s.listenerOptions),s.listenersToRemove.add(()=>{l.removeEventListener("pointerdown",a);});let c=p=>{p.detail>=3&&isDOMNode(p.target)&&Xo(p.target)!==null&&p.preventDefault();};l.addEventListener("mousedown",c,s.listenerOptions),s.listenersToRemove.add(()=>{l.removeEventListener("mousedown",c);});let d=p=>{let f=p.target;p.button===0&&isDOMNode(f)&&t.update(()=>{let m=$getSelection();j(m)&&m.tableKey===s.tableNodeKey&&r.contains(f)&&s.$clearHighlight();});};i.addEventListener("pointerdown",d,s.listenerOptions),s.listenersToRemove.add(()=>{i.removeEventListener("pointerdown",d);});for(let[p,f]of Zm)s.listenersToRemove.add(t.registerCommand(p,m=>tc(t,m,f,o,s),COMMAND_PRIORITY_HIGH));s.listenersToRemove.add(t.registerCommand(KEY_ESCAPE_COMMAND,p=>{let f=$getSelection();if(j(f)){let m=Yo(o,f.focus.getNode());if(m!==null)return et(p),m.selectEnd(),true}return false},COMMAND_PRIORITY_HIGH));let u=p=>()=>{let f=$getSelection();if(!je(f,o))return false;if(j(f))return s.$clearText(),true;if($isRangeSelection(f)){if(!F(Yo(o,f.anchor.getNode())))return false;let m=f.anchor.getNode(),g=f.focus.getNode(),b=o.isParentOf(m),C=o.isParentOf(g);if(b&&!C||C&&!b)return s.$clearText(),true;let x=$findMatchingParent(f.anchor.getNode(),S=>$isElementNode(S)),w=x&&$findMatchingParent(x,S=>$isElementNode(S)&&F(S.getParent()));if(!$isElementNode(w)||!$isElementNode(x))return false;if(p===DELETE_LINE_COMMAND&&w.getPreviousSibling()===null)return true}return false};for(let p of Qm)s.listenersToRemove.add(t.registerCommand(p,u(p),COMMAND_PRIORITY_HIGH));let h=p=>{let f=$getSelection();if(!j(f)&&!$isRangeSelection(f))return false;let m=o.isParentOf(f.anchor.getNode());if(m!==o.isParentOf(f.focus.getNode())){let g=m?"anchor":"focus",b=m?"focus":"anchor",{key:C,offset:x,type:w}=f[b];return o[f[g].isBefore(f[b])?"selectPrevious":"selectNext"]()[b].set(C,x,w),false}return !!je(f,o)&&!!j(f)&&(p&&(p.preventDefault(),p.stopPropagation()),s.$clearText(),true)};for(let p of eg)s.listenersToRemove.add(t.registerCommand(p,h,COMMAND_PRIORITY_HIGH));return s.listenersToRemove.add(t.registerCommand(CUT_COMMAND,p=>{let f=$getSelection();if(f){if(!j(f)&&!$isRangeSelection(f))return false;Nn(t,objectKlassEquals(p,ClipboardEvent)?p:null,wn(f));let m=h(p);return $isRangeSelection(f)?(f.removeText(),true):m}return false},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FORMAT_TEXT_COMMAND,p=>{let f=$getSelection();if(!je(f,o))return false;if(j(f))return s.$formatCells(p),true;if($isRangeSelection(f)){let m=$findMatchingParent(f.anchor.getNode(),g=>F(g));if(!F(m))return false}return false},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FORMAT_ELEMENT_COMMAND,p=>{let f=$getSelection();if(!j(f)||!je(f,o))return false;let m=f.anchor.getNode(),g=f.focus.getNode();if(!F(m)||!F(g))return false;if((function(R,L){if(j(R)){let k=R.anchor.getNode(),O=R.focus.getNode();if(L&&k&&O){let[v]=ye(L,k,O);return k.getKey()===v[0][0].cell.getKey()&&O.getKey()===v[v.length-1].at(-1).cell.getKey()}}return false})(f,o))return o.setFormat(p),true;let[b,C,x]=ye(o,m,g),w=Math.max(C.startRow+C.cell.__rowSpan-1,x.startRow+x.cell.__rowSpan-1),S=Math.max(C.startColumn+C.cell.__colSpan-1,x.startColumn+x.cell.__colSpan-1),y=Math.min(C.startRow,x.startRow),N=Math.min(C.startColumn,x.startColumn),E=new Set;for(let R=y;R<=w;R++)for(let L=N;L<=S;L++){let k=b[R][L].cell;if(E.has(k))continue;E.add(k),k.setFormat(p);let O=k.getChildren();for(let v=0;v<O.length;v++){let T=O[v];$isElementNode(T)&&!T.isInline()&&T.setFormat(p);}}return true},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND,p=>{let f=$getSelection();if(!je(f,o))return false;if(j(f))return s.$clearHighlight(),false;if($isRangeSelection(f)){let m=$findMatchingParent(f.anchor.getNode(),g=>F(g));if(!F(m))return false;if(typeof p=="string"){let g=Aa(t,f,o);if(g)return ka(g,o,[$createTextNode(p)]),true}}return false},COMMAND_PRIORITY_HIGH)),n&&s.listenersToRemove.add(t.registerCommand(KEY_TAB_COMMAND,p=>{let f=$getSelection();if(!$isRangeSelection(f)||!f.isCollapsed()||!je(f,o))return false;let m=fo(f.anchor.getNode());return !(m===null||!o.is(Ft(m)))&&(et(p),(function(g,b){let C=b==="next"?"getNextSibling":"getPreviousSibling",x=b==="next"?"getFirstChild":"getLastChild",w=g[C]();if($isElementNode(w))return w.selectEnd();let S=$findMatchingParent(g,te);S===null&&A(247);for(let N=S[C]();te(N);N=N[C]()){let E=N[x]();if($isElementNode(E))return E.selectEnd()}let y=$findMatchingParent(S,ue);y===null&&A(248),b==="next"?y.selectNext():y.selectPrevious();})(m,p.shiftKey?"previous":"next"),true)},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(FOCUS_COMMAND,p=>o.isSelected(),COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,(p,f)=>{if(t!==f)return false;let{nodes:m,selection:g}=p,b=g.getStartEndPoints(),C=j(g),x=$isRangeSelection(g)&&$findMatchingParent(g.anchor.getNode(),z=>F(z))!==null&&$findMatchingParent(g.focus.getNode(),z=>F(z))!==null||C;if(m.length!==1||!ue(m[0])||!x||b===null)return false;let[w,S]=b,[y,N,E]=be(w),R=$findMatchingParent(S.getNode(),z=>F(z));if(!(F(y)&&F(R)&&te(N)&&ue(E)))return false;let L=m[0],[k,O,v]=ye(E,y,R),[T]=tt(L,null,null),K=k.length,V=K>0?k[0].length:0,se=O.startRow,ie=O.startColumn,le=T.length,Ce=le>0?T[0].length:0;if(C){let z=zn(k,O,v),Re=z.maxRow-z.minRow+1,P=z.maxColumn-z.minColumn+1;se=z.minRow,ie=z.minColumn,le=Math.min(le,Re),Ce=Math.min(Ce,P);}let ve=false,Ae=Math.min(K,se+le)-1,$e=Math.min(V,ie+Ce)-1,on=new Set;for(let z=se;z<=Ae;z++)for(let Re=ie;Re<=$e;Re++){let P=k[z][Re];on.has(P.cell.getKey())||P.cell.__rowSpan===1&&P.cell.__colSpan===1||(Va(P.cell),on.add(P.cell.getKey()),ve=true);}let[Ct]=tt(E.getWritable(),null,null),nn=le-K+se;for(let z=0;z<nn;z++)pi(Ct[K-1][0].cell);let St=Ce-V+ie;for(let z=0;z<St;z++)hi(Ct[0][V-1].cell,true,false);[Ct]=tt(E.getWritable(),null,null);for(let z=se;z<se+le;z++)for(let Re=ie;Re<ie+Ce;Re++){let P=z-se,he=Re-ie,Me=T[P][he];if(Me.startRow!==P||Me.startColumn!==he)continue;let nt=Me.cell;if(nt.__rowSpan!==1||nt.__colSpan!==1){let Fe=[],sr=Math.min(z+nt.__rowSpan,se+le)-1,Ie=Math.min(Re+nt.__colSpan,ie+Ce)-1;for(let Ut=z;Ut<=sr;Ut++)for(let No=Re;No<=Ie;No++){let _o=Ct[Ut][No];Fe.push(_o.cell);}Ja(Fe),ve=true;}let{cell:xt}=Ct[z][Re],yt=xt.getChildren();nt.getChildren().forEach(Fe=>{$isTextNode(Fe)&&$createParagraphNode().append(Fe),xt.append(Fe);}),yt.forEach(Fe=>Fe.remove());}if(C&&ve){let[z]=tt(E.getWritable(),null,null);z[O.startRow][O.startColumn].cell.selectEnd();}return true},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(SELECTION_CHANGE_COMMAND,()=>{let p=$getSelection(),f=$getPreviousSelection(),m=s.getAndClearNextFocus();if(m!==null){let{focusCell:g}=m;if(j(p)&&p.tableKey===s.tableNodeKey)return (g.x!==s.focusX||g.y!==s.focusY)&&(s.$setFocusCellForSelection(g),true);if(g!==s.anchorCell&&je(p,o))return s.$setFocusCellForSelection(g),true}if(s.getAndClearShouldCheckSelection()&&$isRangeSelection(f)&&$isRangeSelection(p)&&p.isCollapsed()){let g=p.anchor.getNode(),b=o.getFirstChild(),C=fo(g);if(C!==null&&te(b)){let x=b.getFirstChild();if(F(x)&&o.is($findMatchingParent(C,w=>w.is(o)||w.is(x))))return x.selectStart(),true}}if($isRangeSelection(p)){let{anchor:g,focus:b}=p,C=g.getNode(),x=b.getNode(),w=fo(C),S=fo(x),y=!(!w||!o.is(Ft(w))),N=!(!S||!o.is(Ft(S))),E=y!==N,R=y&&N,L=p.isBackward();if(E){let k=p.clone();if(N){let[O]=ye(o,S,S),v=O[0][0].cell,T=O[O.length-1].at(-1).cell;k.focus.set(L?v.getKey():T.getKey(),L?v.getChildrenSize():T.getChildrenSize(),"element");}else if(y){let[O]=ye(o,w,w),v=O[0][0].cell,T=O[O.length-1].at(-1).cell;k.anchor.set(L?T.getKey():v.getKey(),L?T.getChildrenSize():0,"element");}$setSelection(k),Oa(t,s);}else if(R&&(w.is(S)||(s.$setAnchorCellForSelection(At(s,w)),s.$setFocusCellForSelection(At(s,S),true)),s.pointerType==="touch"&&s.isSelecting&&p.isCollapsed()&&$isRangeSelection(f)&&f.isCollapsed())){let k=fo(f.anchor.getNode());k&&!k.is(S)&&(s.$setAnchorCellForSelection(At(s,k)),s.$setFocusCellForSelection(At(s,S),true),s.pointerType=null);}}else if(p&&j(p)&&p.is(f)&&p.tableKey===o.getKey()){let g=getDOMSelection(i);if(g&&g.anchorNode&&g.focusNode){let b=$getNearestNodeFromDOMNode(g.focusNode),C=b&&!o.isParentOf(b),x=$getNearestNodeFromDOMNode(g.anchorNode),w=x&&o.isParentOf(x);if(C&&w&&g.rangeCount>0){let S=$createRangeSelectionFromDom(g,t);S&&(S.anchor.set(o.getKey(),p.isBackward()?o.getChildrenSize():0,"element"),g.removeAllRanges(),$setSelection(S));}}}return p&&!p.is(f)&&(j(p)||j(f))&&s.tableSelection&&!s.tableSelection.is(f)?(j(p)&&p.tableKey===s.tableNodeKey?s.$updateTableTableSelection(p):!j(p)&&j(f)&&f.tableKey===s.tableNodeKey&&s.$updateTableTableSelection(null),false):(s.hasHijackedSelectionStyles&&!o.isSelected()?(function(g,b){b.$enableHighlightStyle(),ki(b.table,C=>{let x=C.elem;C.highlighted=false,ec(g,C),x.getAttribute("style")||x.removeAttribute("style");});})(t,s):!s.hasHijackedSelectionStyles&&o.isSelected()&&Oa(t,s),false)},COMMAND_PRIORITY_HIGH)),s.listenersToRemove.add(t.registerCommand(INSERT_PARAGRAPH_COMMAND,()=>{let p=$getSelection();if(!$isRangeSelection(p)||!p.isCollapsed()||!je(p,o))return false;let f=Aa(t,p,o);return !!f&&(ka(f,o),true)},COMMAND_PRIORITY_HIGH)),s}function bi(o){return o[gi]||null}function Xo(o){let e=o;for(;e!=null;){let t=e.nodeName;if(t==="TD"||t==="TH"){let n=e._cell;return n===void 0?null:n}e=e.parentNode;}return null}function Ma(o,e){if(!o.contains(e))return null;let t=null;for(let n=e;n!=null;n=n.parentNode){if(n===o)return t;let r=n.nodeName;r!=="TD"&&r!=="TH"||(t=n._cell||null);}return null}function mo(o,e){let t=[],n={columns:0,domRows:t,rows:0},r=mt(o,e).querySelector("tr"),i=0,s=0;for(t.length=0;r!=null;){let l=r.nodeName;if(l==="TD"||l==="TH"){let d={elem:r,hasBackgroundColor:r.style.backgroundColor!=="",highlighted:false,x:i,y:s};r._cell=d;let u=t[s];u===void 0&&(u=t[s]=[]),u[i]=d;}else {let d=r.firstChild;if(d!=null){r=d;continue}}let a=r.nextSibling;if(a!=null){i++,r=a;continue}let c=r.parentNode;if(c!=null){let d=c.nextSibling;if(d==null)break;s++,i=0,r=d;}}return n.columns=i+1,n.rows=s+1,n}function Ln(o,e,t){let n=new Set(t?t.getNodes():[]);ki(e,(r,i)=>{let s=r.elem;n.has(i)?(r.highlighted=true,Qa(o,r)):(r.highlighted=false,ec(o,r),s.getAttribute("style")||s.removeAttribute("style"));});}function ki(o,e){let{domRows:t}=o;for(let n=0;n<t.length;n++){let r=t[n];if(r)for(let i=0;i<r.length;i++){let s=r[i];if(!s)continue;let l=$getNearestNodeFromDOMNode(s.elem);l!==null&&e(s,l,{x:i,y:n});}}}function Oa(o,e){e.$disableHighlightStyle(),ki(e.table,t=>{t.highlighted=true,Qa(o,t);});}function ci(o,e){let t,n;if(e.startColumn===o.minColumn)t="minColumn";else {if(e.startColumn+e.cell.__colSpan-1!==o.maxColumn)return null;t="maxColumn";}if(e.startRow===o.minRow)n="minRow";else {if(e.startRow+e.cell.__rowSpan-1!==o.maxRow)return null;n="maxRow";}return [t,n]}function Pn([o,e]){return [o==="minColumn"?"maxColumn":"minColumn",e==="minRow"?"maxRow":"minRow"]}function co(o,e,[t,n]){let r=e[n],i=o[r];i===void 0&&A(250,n,String(r));let s=e[t],l=i[s];return l===void 0&&A(250,t,String(s)),l}function og(o,e,t,n,r){let i=zn(e,t,n),s=(function(y,N){let{minColumn:E,maxColumn:R,minRow:L,maxRow:k}=N,O=1,v=1,T=1,K=1,V=y[L],se=y[k];for(let ie=E;ie<=R;ie++)O=Math.max(O,V[ie].cell.__rowSpan),K=Math.max(K,se[ie].cell.__rowSpan);for(let ie=L;ie<=k;ie++)v=Math.max(v,y[ie][E].cell.__colSpan),T=Math.max(T,y[ie][R].cell.__colSpan);return {bottomSpan:K,leftSpan:v,rightSpan:T,topSpan:O}})(e,i),{topSpan:l,leftSpan:a,bottomSpan:c,rightSpan:d}=s,u=(function(y,N){let E=ci(y,N);return E===null&&A(249,N.cell.getKey()),E})(i,t),[h,p]=Pn(u),f=i[h],m=i[p];r==="forward"?f+=h==="maxColumn"?1:a:r==="backward"?f-=h==="minColumn"?1:d:r==="down"?m+=p==="maxRow"?1:l:r==="up"&&(m-=p==="minRow"?1:c);let g=e[m];if(g===void 0)return false;let b=g[f];if(b===void 0)return false;let[C,x]=(function(y,N,E){let R=zn(y,N,E),L=ci(R,N);if(L)return [co(y,R,L),co(y,R,Pn(L))];let k=ci(R,E);if(k)return [co(y,R,Pn(k)),co(y,R,k)];let O=["minColumn","minRow"];return [co(y,R,O),co(y,R,Pn(O))]})(e,t,b),w=At(o,C.cell),S=At(o,x.cell);return o.$setAnchorCellForSelection(w),o.$setFocusCellForSelection(S,true),true}function je(o,e){if($isRangeSelection(o)||j(o)){let t=e.isParentOf(o.anchor.getNode()),n=e.isParentOf(o.focus.getNode());return t&&n}return false}function In(o,e){e?o.selectStart():o.selectEnd();}function Qa(o,e){let t=e.elem,n=o._config.theme;F($getNearestNodeFromDOMNode(t))||A(131),addClassNamesToElement(t,n.tableCellSelected);}function ec(o,e){let t=e.elem;F($getNearestNodeFromDOMNode(t))||A(131);let n=o._config.theme;removeClassNamesFromElement(t,n.tableCellSelected);}function fo(o){let e=$findMatchingParent(o,F);return F(e)?e:null}function Ft(o){let e=$findMatchingParent(o,ue);return ue(e)?e:null}function ng(o,e,t,n,r,i,s){let l=$caretFromPoint(t.focus,r?"previous":"next");if($isExtendableTextPointCaret(l))return false;let a=l;for(let g of $extendCaretToRange(l).iterNodeCarets("shadowRoot")){if(!$isSiblingCaret(g)||!$isElementNode(g.origin))return false;a=g;}let c=a.getParentAtCaret();if(!F(c))return false;let d=c,u=(function(g){for(let b of $extendCaretToRange(g).iterNodeCarets("root")){let{origin:C}=b;if(F(C)){if($isChildCaret(b))return $getChildCaret(C,g.direction)}else if(!te(C))break}return null})($getSiblingCaret(d,a.direction)),h=$findMatchingParent(d,ue);if(!h||!h.is(i))return false;let p=o.getElementByKey(d.getKey()),f=Xo(p);if(!p||!f)return false;let m=nc(o,h);if(s.table=m,u)if(n==="extend"){let g=Xo(o.getElementByKey(u.origin.getKey()));if(!g)return false;s.$setAnchorCellForSelection(f),s.$setFocusCellForSelection(g,true);}else {let g=$normalizeCaret(u);$setPointFromCaret(t.anchor,g),$setPointFromCaret(t.focus,g);}else if(n==="extend")s.$setAnchorCellForSelection(f),s.$setFocusCellForSelection(f,true);else {let g=(function(b){let C=$getAdjacentChildCaret(b);return $isChildCaret(C)?$normalizeCaret(C):b})($getSiblingCaret(h,l.direction));$setPointFromCaret(t.anchor,g),$setPointFromCaret(t.focus,g);}return et(e),true}function tc(o,e,t,n,r){if((t==="up"||t==="down")&&(function(s){let l=s.getRootElement();return l?l.hasAttribute("aria-controls")&&l.getAttribute("aria-controls")==="typeahead-menu":false})(o))return false;let i=$getSelection();if(!je(i,n)){if($isRangeSelection(i)){if(t==="backward"){if(i.focus.offset>0)return false;let s=(function(a){for(let c=a,d=a;d!==null;c=d,d=d.getParent())if($isElementNode(d)){if(d!==c&&d.getFirstChild()!==c)return null;if(!d.isInline())return d}return null})(i.focus.getNode());if(!s)return false;let l=s.getPreviousSibling();return !!ue(l)&&(et(e),e.shiftKey?i.focus.set(l.getParentOrThrow().getKey(),l.getIndexWithinParent(),"element"):l.selectEnd(),true)}if(e.shiftKey&&(t==="up"||t==="down")){let s=i.focus.getNode();if(!i.isCollapsed()&&(t==="up"&&!i.isBackward()||t==="down"&&i.isBackward())){let l=$findMatchingParent(s,h=>ue(h));if(F(l)&&(l=$findMatchingParent(l,ue)),l!==n||!l)return false;let a=t==="down"?l.getNextSibling():l.getPreviousSibling();if(!a)return false;let c=0;t==="up"&&$isElementNode(a)&&(c=a.getChildrenSize());let d=a;t==="up"&&$isElementNode(a)&&(d=a.getLastChild()||a,c=$isTextNode(d)?d.getTextContentSize():0);let u=i.clone();return u.focus.set(d.getKey(),c,$isTextNode(d)?"text":"element"),$setSelection(u),et(e),true}if($isRootOrShadowRoot(s)){let l=t==="up"?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(l&&Yo(n,l)!==null){let a=n.getFirstDescendant(),c=n.getLastDescendant();if(!a||!c)return false;let[d]=be(a),[u]=be(c),h=n.getCordsFromCellNode(d,r.table),p=n.getCordsFromCellNode(u,r.table),f=n.getDOMCellFromCordsOrThrow(h.x,h.y,r.table),m=n.getDOMCellFromCordsOrThrow(p.x,p.y,r.table);return r.$setAnchorCellForSelection(f),r.$setFocusCellForSelection(m,true),true}return false}{let l=$findMatchingParent(s,c=>$isElementNode(c)&&!c.isInline());if(F(l)&&(l=$findMatchingParent(l,ue)),!l)return false;let a=t==="down"?l.getNextSibling():l.getPreviousSibling();if(ue(a)&&r.tableNodeKey===a.getKey()){let c=a.getFirstDescendant(),d=a.getLastDescendant();if(!c||!d)return false;let[u]=be(c),[h]=be(d),p=i.clone();return p.focus.set((t==="up"?u:h).getKey(),t==="up"?0:h.getChildrenSize(),"element"),et(e),$setSelection(p),true}}}}return t==="down"&&Jo(o)&&r.setShouldCheckSelection(),false}if($isRangeSelection(i)){if(t==="backward"||t==="forward")return ng(o,e,i,e.shiftKey?"extend":"move",t==="backward",n,r);if(i.isCollapsed()){let{anchor:s,focus:l}=i,a=$findMatchingParent(s.getNode(),F),c=$findMatchingParent(l.getNode(),F);if(!F(a)||!a.is(c))return false;let d=Ft(a);if(d!==n&&d!=null){let b=mt(d,o.getElementByKey(d.getKey()));if(b!=null)return r.table=mo(d,b),tc(o,e,t,d,r)}let u=o.getElementByKey(a.__key),h=o.getElementByKey(s.key);if(h==null||u==null)return false;let p;if(s.type==="element")p=h.getBoundingClientRect();else {let b=getDOMSelection(Oi(o));if(b===null||b.rangeCount===0)return false;p=b.getRangeAt(0).getBoundingClientRect();}let f=t==="up"?a.getFirstChild():a.getLastChild();if(f==null)return false;let m=o.getElementByKey(f.__key);if(m==null)return false;let g=m.getBoundingClientRect();if(t==="up"?g.top>p.top-p.height:p.bottom+p.height>g.bottom){et(e);let b=n.getCordsFromCellNode(a,r.table);if(!e.shiftKey)return tg(r,n,b.x,b.y,t);{let C=n.getDOMCellFromCordsOrThrow(b.x,b.y,r.table);r.$setAnchorCellForSelection(C),r.$setFocusCellForSelection(C,true);}return true}}}else if(j(i)){let{anchor:s,focus:l}=i,a=$findMatchingParent(s.getNode(),F),c=$findMatchingParent(l.getNode(),F),[d]=i.getNodes();ue(d)||A(251);let u=mt(d,o.getElementByKey(d.getKey()));if(!F(a)||!F(c)||!ue(d)||u==null)return false;r.$updateTableTableSelection(i);let h=mo(d,u),p=n.getCordsFromCellNode(a,h),f=n.getDOMCellFromCordsOrThrow(p.x,p.y,h);if(r.$setAnchorCellForSelection(f),et(e),e.shiftKey){let[m,g,b]=ye(n,a,c);return og(r,m,g,b,t)}return c.selectEnd(),true}return false}function et(o){o.preventDefault(),o.stopImmediatePropagation(),o.stopPropagation();}function ka(o,e,t){let n=$createParagraphNode();o==="first"?e.insertBefore(n):e.insertAfter(n),n.append(...t||[]),n.selectEnd();}function Aa(o,e,t){let n=t.getParent();if(!n)return;let r=getDOMSelection(Oi(o));if(!r)return;let i=r.anchorNode,s=o.getElementByKey(n.getKey()),l=mt(t,o.getElementByKey(t.getKey()));if(!i||!s||!l||!s.contains(i)||l.contains(i))return;let a=$findMatchingParent(e.anchor.getNode(),C=>F(C));if(!a)return;let c=$findMatchingParent(a,C=>ue(C));if(!ue(c)||!c.is(t))return;let[d,u]=ye(t,a,a),h=d[0][0],p=d[d.length-1][d[0].length-1],{startRow:f,startColumn:m}=u,g=f===h.startRow&&m===h.startColumn,b=f===p.startRow&&m===p.startColumn;return g?"first":b?"last":void 0}function At(o,e){let{tableNode:t}=o.$lookup(),n=t.getCordsFromCellNode(e,o.table);return t.getDOMCellFromCordsOrThrow(n.x,n.y,o.table)}function Ci(o,e,t){return Yo(o,$getNearestNodeFromDOMNode(e,t))}function $a(o,e,t){if(!e.theme.tableAlignment)return;let n=[],r=[];for(let i of ["center","right"]){let s=e.theme.tableAlignment[i];s&&(i===t?r:n).push(s);}removeClassNamesFromElement(o,...n),addClassNamesToElement(o,...r);}function Jo(o=$getEditor()){return Si.has(o)}function oc(o,e){e?Si.add(o):Si.delete(o);}function nc(o,e){let t=o.getElementByKey(e.getKey());return t===null&&A(230),mo(e,t)}function rg(o){let e=jn();o.hasAttribute("data-lexical-row-striping")&&e.setRowStriping(true),o.hasAttribute("data-lexical-frozen-column")&&e.setFrozenColumns(1),o.hasAttribute("data-lexical-frozen-row")&&e.setFrozenRows(1);let t=o.querySelector(":scope > colgroup");if(t){let n=[];for(let r of t.querySelectorAll(":scope > col")){let i=r.style.width||"";if(!_i.test(i)&&(i=r.getAttribute("width")||"",!/^\d+$/.test(i))){n=void 0;break}n.push(parseFloat(i));}n&&e.setColWidths(n);}return {after:n=>$descendantsMatching(n,te),node:e}}function jn(){return $applyNodeReplacement(new Xe)}function ue(o){return o instanceof Xe}function ig({rows:o,columns:e,includeHeaders:t}){let n=$getSelection()||$getPreviousSelection();if(!n||!$isRangeSelection(n)||Ft(n.anchor.getNode()))return false;let r=Wa(Number(o),Number(e),t);$insertNodeToNearestRoot(r);let i=r.getFirstDescendant();return $isTextNode(i)&&i.select(),true}function sg(o){te(o.getParent())?o.isEmpty()&&o.append($createParagraphNode()):o.remove();}function lg(o){ue(o.getParent())?$unwrapAndFilterDescendants(o,F):o.remove();}function ag(o){$unwrapAndFilterDescendants(o,te);let[e]=tt(o,null,null),t=e.reduce((r,i)=>Math.max(r,i.length),0),n=o.getChildren();for(let r=0;r<e.length;++r){let i=n[r];if(!i)continue;te(i)||A(254,i.constructor.name,i.getType());let s=e[r].reduce((l,a)=>a?1+l:l,0);if(s!==t)for(let l=s;l<t;++l){let a=ke();a.append($createParagraphNode()),i.append(a);}}}function cg(o){if(o.detail<3||!isDOMNode(o.target))return false;let e=$getNearestNodeFromDOMNode(o.target);if(e===null)return false;let t=$findMatchingParent(e,n=>$isElementNode(n)&&!n.isInline());return t===null?false:!!F(t.getParent())&&(t.select(0),true)}function rc(o){return o.registerNodeTransform(Ge,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){let[,,t]=be(e),[n]=ye(t,e,e),r=n.length,i=n[0].length,s=t.getFirstChild();te(s)||A(175);let l=[];for(let a=0;a<r;a++){a!==0&&(s=s.getNextSibling(),te(s)||A(175));let c=null;for(let d=0;d<i;d++){let u=n[a][d],h=u.cell;if(u.startRow===a&&u.startColumn===d)c=h,l.push(h);else if(h.getColSpan()>1||h.getRowSpan()>1){F(h)||A(176);let p=ke(h.__headerState);c!==null?c.insertAfter(p):$insertFirst(s,p);}}}for(let a of l)a.setColSpan(1),a.setRowSpan(1);}})}function ic(o,e=true){let t=new Map,n=(i,s,l)=>{let a=mt(i,l),c=Za(i,a,o,e);t.set(s,[c,a]);},r=o.registerMutationListener(Xe,i=>{o.getEditorState().read(()=>{for(let[s,l]of i){let a=t.get(s);if(l==="created"||l==="updated"){let{tableNode:c,tableElement:d}=Mi(s);a===void 0?n(c,s,d):d!==a[1]&&(a[0].removeListeners(),t.delete(s),n(c,s,d));}else l==="destroyed"&&a!==void 0&&(a[0].removeListeners(),t.delete(s));}},{editor:o});},{skipInitialization:false});return ()=>{r();for(let[,[i]]of t)i.removeListeners();}}function sc(o){return o.hasNodes([Xe])||A(255),mergeRegister(o.registerCommand(Ha,ig,COMMAND_PRIORITY_EDITOR),o.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,({nodes:e,selection:t},n)=>o!==n||!$isRangeSelection(t)?false:Ft(t.anchor.getNode())!==null&&e.some(ue),COMMAND_PRIORITY_EDITOR),o.registerCommand(CLICK_COMMAND,cg,COMMAND_PRIORITY_EDITOR),o.registerNodeTransform(Xe,ag),o.registerNodeTransform(Dt,lg),o.registerNodeTransform(Ge,sg))}var _i,ne,Ge,Ha,Dt,Ei,Pm,va,fi,Wm,jm,Gm,Xm,Bn,Hn,gi,Zm,Qm,eg,tg,Si,Xe,dg,ac=rt(async()=>{await Ar();await Dr();_i=/^(\d+(?:\.\d+)?)px$/,ne={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1},Ge=class o extends ElementNode{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return "tablecell"}static clone(e){return new o(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign;}static importDOM(){return {td:e=>({conversion:Ta,priority:0}),th:e=>({conversion:Ta,priority:0})}}static importJSON(e){return ke().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=ne.NO_STATUS,t=1,n,r){super(r),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0;}createDOM(e){let t=document.createElement(this.getTag());return this.__width&&(t.style.width=`${this.__width}px`),this.__colSpan>1&&(t.colSpan=this.__colSpan),this.__rowSpan>1&&(t.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(t.style.backgroundColor=this.__backgroundColor),ui(this.__verticalAlign)&&(t.style.verticalAlign=this.__verticalAlign),addClassNamesToElement(t,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),t}exportDOM(e){let t=super.exportDOM(e);if(isHTMLElement(t.element)){let n=t.element;n.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),n.style.border="1px solid black",this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),n.style.width=`${this.getWidth()||75}px`,n.style.verticalAlign=this.getVerticalAlign()||"top",n.style.textAlign="start",this.__backgroundColor===null&&this.hasHeader()&&(n.style.backgroundColor="#f2f3f5");}return t}exportJSON(){return {...super.exportJSON(),...ui(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){let t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){let t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ne.BOTH){let n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){let t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){let t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){let t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){let 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!==ne.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 true}collapseAtStart(){return true}canBeEmpty(){return false}canIndent(){return false}};Ha=createCommand("INSERT_TABLE_COMMAND");Dt=class o extends ElementNode{__height;static getType(){return "tablerow"}static clone(e){return new o(e.__height,e.__key)}static importDOM(){return {tr:e=>({conversion:Lm,priority:0})}}static importJSON(e){return Lt().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e;}exportJSON(){let e=this.getHeight();return {...super.exportJSON(),...e===void 0?void 0:{height:e}}}createDOM(e){let t=document.createElement("tr");return this.__height&&(t.style.height=`${this.__height}px`),addClassNamesToElement(t,e.theme.tableRow),t}extractWithChild(e,t,n){return n==="html"}isShadowRoot(){return true}setHeight(e){let t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return false}canIndent(){return false}};Ei=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Pm=Ei&&"documentMode"in document?document.documentMode:null,va=Ei&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);Ei&&"InputEvent"in window&&!Pm&&new window.InputEvent("input");fi=(o,e)=>o===ne.BOTH||o===e?e:ne.NO_STATUS;Wm=ja;jm=Ya;Gm=Ga;Xm=Xa;Bn=class o{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=false,this.tableKey=e;}getStartEndPoints(){return [this.anchor,this.focus]}isValid(){if(this.tableKey==="root"||this.anchor.key==="root"||this.anchor.type!=="element"||this.focus.key==="root"||this.focus.type!=="element")return false;let e=$getNodeByKey(this.tableKey),t=$getNodeByKey(this.anchor.key),n=$getNodeByKey(this.focus.key);return e!==null&&t!==null&&n!==null}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e;}is(e){return j(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null;}clone(){return new o(this.tableKey,$createPoint(this.anchor.key,this.anchor.offset,this.anchor.type),$createPoint(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return false}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(F).forEach(r=>{let i=r.getFirstChild();$isParagraphNode(i)&&(t|=i.getTextFormat());});let n=TEXT_TYPE_TO_FORMAT[e];return (t&n)!==0}insertNodes(e){let t=this.focus.getNode();$isElementNode(t)||A(151),$normalizeSelection__EXPERIMENTAL(t.select(0,t.getChildrenSize())).insertNodes(e);}getShape(){let{anchorCell:e,focusCell:t}=Ra(this),n=mi(e);n===null&&A(153);let r=mi(t);r===null&&A(155);let i=Math.min(n.columnIndex,r.columnIndex),s=Math.max(n.columnIndex+n.colSpan-1,r.columnIndex+r.colSpan-1),l=Math.min(n.rowIndex,r.rowIndex),a=Math.max(n.rowIndex+n.rowSpan-1,r.rowIndex+r.rowSpan-1);return {fromX:Math.min(i,s),fromY:Math.min(l,a),toX:Math.max(i,s),toY:Math.max(l,a)}}getNodes(){if(!this.isValid())return [];let e=this._cachedNodes;if(e!==null)return e;let{anchorTable:t,anchorCell:n,focusCell:r}=Ra(this),i=r.getParents()[1];if(i!==t){if(t.isParentOf(r)){let g=i.getParent();g==null&&A(159),this.set(this.tableKey,r.getKey(),g.getKey());}else {let g=t.getParent();g==null&&A(158),this.set(this.tableKey,g.getKey(),r.getKey());}return this.getNodes()}let[s,l,a]=ye(t,n,r),{minColumn:c,maxColumn:d,minRow:u,maxRow:h}=zn(s,l,a),p=new Map([[t.getKey(),t]]),f=null;for(let g=u;g<=h;g++)for(let b=c;b<=d;b++){let{cell:C}=s[g][b],x=C.getParent();te(x)||A(160),x!==f&&(p.set(x.getKey(),x),f=x),p.has(C.getKey())||qm(C,w=>{p.set(w.getKey(),w);});}let m=Array.from(p.values());return isCurrentlyReadOnlyMode()||(this._cachedNodes=m),m}getTextContent(){let e=this.getNodes().filter(n=>F(n)),t="";for(let n=0;n<e.length;n++){let r=e[n],i=r.__parent,s=(e[n+1]||{}).__parent;t+=r.getTextContent()+(s!==i?`
|
|
9
|
+
`:" ");}return t}};Hn=class{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=false,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=false,this.isSelecting=false,this.pointerType=null,this.shouldCheckSelection=false,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable();}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear();}$lookup(){return Mi(this.tableNodeKey,this.editor)}trackTable(){let e=new MutationObserver(t=>{this.editor.getEditorState().read(()=>{let n=false;for(let s=0;s<t.length;s++){let l=t[s].target.nodeName;if(l==="TABLE"||l==="TBODY"||l==="THEAD"||l==="TR"){n=true;break}}if(!n)return;let{tableNode:r,tableElement:i}=this.$lookup();this.table=mo(r,i);},{editor:this.editor});});this.editor.getEditorState().read(()=>{let{tableNode:t,tableElement:n}=this.$lookup();this.table=mo(t,n),e.observe(n,{attributes:true,childList:true,subtree:true});},{editor:this.editor});}$clearHighlight(){let e=this.editor;this.isHighlightingCells=false,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=false,this.$enableHighlightStyle();let{tableNode:t,tableElement:n}=this.$lookup();Ln(e,mo(t,n),null),$getSelection()!==null&&($setSelection(null),e.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0));}$enableHighlightStyle(){let e=this.editor,{tableElement:t}=this.$lookup();removeClassNamesFromElement(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=false;}$disableHighlightStyle(){let{tableElement:e}=this.$lookup();addClassNamesToElement(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=true;}$updateTableTableSelection(e){if(e!==null){e.tableKey!==this.tableNodeKey&&A(233,e.tableKey,this.tableNodeKey);let t=this.editor;this.tableSelection=e,this.isHighlightingCells=true,this.$disableHighlightStyle(),this.updateDOMSelection(),Ln(t,this.table,this.tableSelection);}else this.$clearHighlight();}setShouldCheckSelection(){this.shouldCheckSelection=true;}getAndClearShouldCheckSelection(){return !!this.shouldCheckSelection&&(this.shouldCheckSelection=false,true)}setNextFocus(e){this.nextFocus=e;}getAndClearNextFocus(){let{nextFocus:e}=this;return e!==null&&(this.nextFocus=null),e}updateDOMSelection(){if(this.anchorCell!==null&&this.focusCell!==null){let e=getDOMSelection(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges();}}$setFocusCellForSelection(e,t=false){let n=this.editor,{tableNode:r}=this.$lookup(),i=e.x,s=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===i&&this.anchorY===s&&!t){if(i===this.focusX&&s===this.focusY)return false}else this.isHighlightingCells=true,this.$disableHighlightStyle();if(this.focusX=i,this.focusY=s,this.isHighlightingCells){let l=Ci(r,e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null&&l!==null)return this.focusCellNodeKey=l.getKey(),this.tableSelection=qa(r,this.$getAnchorTableCellOrThrow(),l),$setSelection(this.tableSelection),n.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0),Ln(n,this.table,this.tableSelection),true}return false}$getAnchorTableCell(){return this.anchorCellNodeKey?$getNodeByKey(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){let e=this.$getAnchorTableCell();return e===null&&A(234),e}$getFocusTableCell(){return this.focusCellNodeKey?$getNodeByKey(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){let e=this.$getFocusTableCell();return e===null&&A(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=false,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;let{tableNode:t}=this.$lookup(),n=Ci(t,e.elem);if(n!==null){let r=n.getKey();this.tableSelection=this.tableSelection!=null?this.tableSelection.clone():Ri(),this.anchorCellNodeKey=r;}}$formatCells(e){let t=$getSelection();j(t)||A(236);let n=$createRangeSelection(),r=n.anchor,i=n.focus,s=t.getNodes().filter(F);s.length>0||A(237);let l=s[0].getFirstChild(),a=$isParagraphNode(l)?l.getFormatFlags(e,null):null;s.forEach(c=>{r.set(c.getKey(),0,"element"),i.set(c.getKey(),c.getChildrenSize(),"element"),n.formatText(e,a);}),$setSelection(t),this.editor.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0);}$clearText(){let{editor:e}=this,t=$getNodeByKey(this.tableNodeKey);if(!ue(t))throw new Error("Expected TableNode.");let n=$getSelection();j(n)||A(253);let r=n.getNodes().filter(F),i=t.getFirstChild(),s=t.getLastChild();if(r.length>0&&i!==null&&s!==null&&te(i)&&te(s)&&r[0]===i.getFirstChild()&&r[r.length-1]===s.getLastChild()){t.selectPrevious();let l=t.getParent();return t.remove(),void($isRootNode(l)&&l.isEmpty()&&e.dispatchCommand(INSERT_PARAGRAPH_COMMAND,void 0))}r.forEach(l=>{if($isElementNode(l)){let a=$createParagraphNode(),c=$createTextNode();a.append(c),l.append(a),l.getChildren().forEach(d=>{d!==a&&d.remove();});}}),Ln(e,this.table,null),$setSelection(null),e.dispatchCommand(SELECTION_CHANGE_COMMAND,void 0);}},gi="__lexicalTableSelection";Zm=[[KEY_ARROW_DOWN_COMMAND,"down"],[KEY_ARROW_UP_COMMAND,"up"],[KEY_ARROW_LEFT_COMMAND,"backward"],[KEY_ARROW_RIGHT_COMMAND,"forward"]],Qm=[DELETE_WORD_COMMAND,DELETE_LINE_COMMAND,DELETE_CHARACTER_COMMAND],eg=[KEY_BACKSPACE_COMMAND,KEY_DELETE_COMMAND];tg=(o,e,t,n,r)=>{let i=r==="forward";switch(r){case "backward":case "forward":return t!==(i?o.table.columns-1:0)?In(e.getCellNodeFromCordsOrThrow(t+(i?1:-1),n,o.table),i):n!==(i?o.table.rows-1:0)?In(e.getCellNodeFromCordsOrThrow(i?0:o.table.columns-1,n+(i?1:-1),o.table),i):i?e.selectNext():e.selectPrevious(),true;case "up":return n!==0?In(e.getCellNodeFromCordsOrThrow(t,n-1,o.table),false):e.selectPrevious(),true;case "down":return n!==o.table.rows-1?In(e.getCellNodeFromCordsOrThrow(t,n+1,o.table),true):e.selectNext(),true;default:return false}};Si=new WeakSet;Xe=class o extends ElementNode{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return "table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){let t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new o(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:rg,priority:1})}}static importJSON(e){return jn().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||false).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=false,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 n==="html"}getDOMSlot(e){let t=uo(e)?e:e.querySelector("table");return uo(t)||A(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(e,t){let n=document.createElement("table");this.__style&&(n.style.cssText=this.__style);let r=document.createElement("colgroup");if(n.appendChild(r),setDOMUnmanaged(r),addClassNamesToElement(n,e.theme.table),this.updateTableElement(null,n,e),Jo(t)){let i=document.createElement("div"),s=e.theme.tableScrollableWrapper;return s?addClassNamesToElement(i,s):i.style.cssText="overflow-x: auto;",i.appendChild(n),this.updateTableWrapper(null,i,n,e),i}return n}updateTableWrapper(e,t,n,r){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&(function(i,s,l,a){a>0?(addClassNamesToElement(i,l.theme.tableFrozenColumn),s.setAttribute("data-lexical-frozen-column","true")):(removeClassNamesFromElement(i,l.theme.tableFrozenColumn),s.removeAttribute("data-lexical-frozen-column"));})(t,n,r,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&(function(i,s,l,a){a>0?(addClassNamesToElement(i,l.theme.tableFrozenRow),s.setAttribute("data-lexical-frozen-row","true")):(removeClassNamesFromElement(i,l.theme.tableFrozenRow),s.removeAttribute("data-lexical-frozen-row"));})(t,n,r,this.__frozenRowCount);}updateTableElement(e,t,n){this.__style!==(e?e.__style:"")&&(t.style.cssText=this.__style),this.__rowStriping!==(!!e&&e.__rowStriping)&&(function(r,i,s){s?(addClassNamesToElement(r,i.theme.tableRowStriping),r.setAttribute("data-lexical-row-striping","true")):(removeClassNamesFromElement(r,i.theme.tableRowStriping),r.removeAttribute("data-lexical-row-striping"));})(t,n,this.__rowStriping),(function(r,i,s,l){let a=r.querySelector("colgroup");if(!a)return;let c=[];for(let d=0;d<s;d++){let u=document.createElement("col"),h=l&&l[d];h&&(u.style.width=`${h}px`),c.push(u);}a.replaceChildren(...c);})(t,0,this.getColumnCount(),this.getColWidths()),$a(t,n,this.getFormatType());}updateDOM(e,t,n){let r=this.getDOMSlot(t).element;return t===r===Jo()||(isHTMLElement$1(i=t)&&i.nodeName==="DIV"&&this.updateTableWrapper(e,t,r,n),this.updateTableElement(e,r,n),false);var i;}exportDOM(e){let t=super.exportDOM(e),{element:n}=t;return {after:r=>{if(t.after&&(r=t.after(r)),!uo(r)&&isHTMLElement$1(r)&&(r=r.querySelector("table")),!uo(r))return null;$a(r,e._config,this.getFormatType());let[i]=tt(this,null,null),s=new Map;for(let d of i)for(let u of d){let h=u.cell.getKey();s.has(h)||s.set(h,{colSpan:u.cell.getColSpan(),startColumn:u.startColumn});}let l=new Set;for(let d of r.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){let u=d.getAttribute("data-temporary-table-cell-lexical-key");if(u){let h=s.get(u);if(d.removeAttribute("data-temporary-table-cell-lexical-key"),h){s.delete(u);for(let p=0;p<h.colSpan;p++)l.add(p+h.startColumn);}}}let a=r.querySelector(":scope > colgroup");if(a){let d=Array.from(r.querySelectorAll(":scope > colgroup > col")).filter((u,h)=>l.has(h));a.replaceChildren(...d);}let c=r.querySelectorAll(":scope > tr");if(c.length>0){let d=document.createElement("tbody");for(let u of c)d.appendChild(u);r.append(d);}return r},element:!uo(n)&&isHTMLElement$1(n)?n.querySelector("table"):n}}canBeEmpty(){return false}isShadowRoot(){return true}getCordsFromCellNode(e,t){let{rows:n,domRows:r}=t;for(let i=0;i<n;i++){let s=r[i];if(s!=null)for(let l=0;l<s.length;l++){let a=s[l];if(a==null)continue;let{elem:c}=a,d=Ci(this,c);if(d!==null&&e.is(d))return {x:l,y:i}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){let{domRows:r}=n,i=r[t];if(i==null)return null;let s=i[e<i.length?e:i.length-1];return s??null}getDOMCellFromCordsOrThrow(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(!r)throw new Error("Cell not found at cords.");return r}getCellNodeFromCords(e,t,n){let r=this.getDOMCellFromCords(e,t,n);if(r==null)return null;let i=$getNearestNodeFromDOMNode(r.elem);return F(i)?i:null}getCellNodeFromCordsOrThrow(e,t,n){let r=this.getCellNodeFromCords(e,t,n);if(!r)throw new Error("Node at cords not TableCellNode.");return r}getRowStriping(){return !!this.getLatest().__rowStriping}setRowStriping(e){let t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){let t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){let t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return true}canIndent(){return false}getColumnCount(){let e=this.getFirstChild();if(!e)return 0;let t=0;return e.getChildren().forEach(n=>{F(n)&&(t+=n.getColSpan());}),t}};dg=defineExtension({build:(o,e,t)=>Sn(e),config:safeCast({hasCellBackgroundColor:true,hasCellMerge:true,hasHorizontalScroll:true,hasTabHandler:true}),name:"@lexical/table/Table",nodes:[Xe,Dt,Ge],register(o,e,t){let n=t.getOutput();return mergeRegister(Ke(()=>{let r=n.hasHorizontalScroll.value;Jo(o)!==r&&(oc(o,r),o.registerNodeTransform(Xe,()=>{})());}),sc(o),Ke(()=>ic(o,n.hasTabHandler.value)),Ke(()=>n.hasCellMerge.value?void 0:rc(o)),Ke(()=>n.hasCellBackgroundColor.value?void 0:o.registerNodeTransform(Ge,r=>{r.getBackgroundColor()!==null&&r.setBackgroundColor(null);})))}});});var os=createContext(void 0),rn=()=>{let o=useContext(os);if(!o)throw new Error("useTheme must be used within a ThemeProvider");return o},ns=({children:o,initialTheme:e="dark",onThemeChange:t})=>{let[n,r]=useState(e);useEffect(()=>{t&&t(n);},[n,t]);let i=()=>{r(s=>s==="light"?"dark":"light");};return jsx(os.Provider,{value:{theme:n,toggleTheme:i},children:o})};var rs=createContext(void 0),it=()=>{let o=useContext(rs);if(!o)throw new Error("useEmailContext must be used within an EmailProvider");return o},is=({children:o,googleDriveConfig:e})=>{let[t,n]=useState({to:[],cc:[],bcc:[]}),[r,i]=useState(false),[s,l]=useState(""),[a,c]=useState(false),[d,u]=useState(false),[h,p]=useState([]);return useEffect(()=>{console.log("EmailProvider emails updated:",t);},[t]),jsx(rs.Provider,{value:{emails:t,setEmails:n,subject:s,setSubject:l,showCC:a,setShowCC:c,showBCC:d,setShowBCC:u,attachments:h,setAttachments:p,isReply:r,setIsReply:i,googleDriveConfig:e},children:o})};var D=await(process.env.NODE_ENV!=="production"?xa().then(()=>Sa):ac().then(()=>lc));D.$computeTableMap;D.$computeTableMapSkipCellCheck;D.$createTableCellNode;D.$createTableNode;D.$createTableNodeWithDimensions;D.$createTableRowNode;D.$createTableSelection;D.$createTableSelectionFrom;D.$deleteTableColumn;D.$deleteTableColumnAtSelection;D.$deleteTableColumn__EXPERIMENTAL;D.$deleteTableRowAtSelection;D.$deleteTableRow__EXPERIMENTAL;D.$findCellNode;D.$findTableNode;D.$getElementForTableNode;D.$getNodeTriplet;D.$getTableAndElementByKey;D.$getTableCellNodeFromLexicalNode;D.$getTableCellNodeRect;D.$getTableColumnIndexFromTableCellNode;D.$getTableNodeFromLexicalNodeOrThrow;D.$getTableRowIndexFromTableCellNode;D.$getTableRowNodeFromTableCellNodeOrThrow;D.$insertTableColumn;D.$insertTableColumnAtSelection;D.$insertTableColumn__EXPERIMENTAL;D.$insertTableRow;D.$insertTableRowAtSelection;D.$insertTableRow__EXPERIMENTAL;D.$isScrollableTablesActive;D.$isTableCellNode;D.$isTableNode;D.$isTableRowNode;D.$isTableSelection;D.$mergeCells;D.$removeTableRowAtIndex;D.$unmergeCell;D.INSERT_TABLE_COMMAND;D.TableCellHeaderStates;var cc=D.TableCellNode;D.TableExtension;var dc=D.TableNode;D.TableObserver;var uc=D.TableRowNode;D.applyTableHandlers;D.getDOMCellFromTarget;D.getTableElement;D.getTableObserverFromTableElement;D.registerTableCellUnmergeTransform;D.registerTablePlugin;D.registerTableSelectionObserver;D.setScrollableTablesActive;var _={undo:"undo",redo:"redo",bold:"bold",italic:"italic",underline:"underline",color:{base:"colors"},code:"code",link:"link",listNumber:"listNumber",listBullet:"listBullet",align:{base:"align"},indent:"indent",indentDecrease:"indentDecrease",strike:"strike",attachFile:"attachFile",insertPhoto:"insertPhoto",fontSize:"fontSize",fontFamily:"fontFamily",emoji:"emoji",drive:"drive",lockClock:"lockClock",insertSignature:"insertSignature"},re={styling:"styling",divider:"divider",component:"component"},Ai=[{type:re.styling,icon:"Styling",id:"4bc66ea9-2e35-4a7b-a674-be7e4ee163c5",label:"Formatting options",options:[{name:_.undo,type:re.component,icon:"Undo",label:"Undo",id:"29cf5eb3-37cd-482f-9a15-c358faf19cc2"},{name:_.redo,type:re.component,icon:"Redo",label:"Redo",id:"8744f7ab-5818-46ce-9417-2fec87123afe"},{type:re.divider,id:"ed0104fd-3507-43f6-80c1-813fbdf04479"},{name:_.fontFamily,type:re.component,id:"1c12d7e2-aa6a-42b4-b25c-b55fe3bcf524",label:"Font"},{type:re.divider,id:"d0f67d01-0731-411a-b448-e1dca47014f4"},{name:_.fontSize,type:re.component,id:"82e31b62-5441-4052-887c-faa02d0b7075",label:"Size"},{type:re.divider,id:"2e3558e4-3ad4-422b-8502-ea3c58fb8c2e"},{name:_.bold,type:re.component,icon:"Bold",label:"Bold",id:"ac2b5b54-7323-44a4-bc6d-8bae6e48efe2"},{name:_.italic,type:re.component,icon:"Italic",label:"Italic",id:"6a927c2a-2230-4dc7-af71-47fbe9fb784d"},{name:_.underline,type:re.component,icon:"Underline",label:"Underline",id:"f07b3a6f-ffaa-4153-beae-79a36acb6a08"},{name:_.color.base,type:re.component,icon:"Text color",label:"Text color",id:"e14ec25f-3dd3-4ed5-b33a-a033684d248b"},{type:re.divider,id:"93e60297-206f-4f31-bc29-11daff2052bd"},{name:_.align.base,type:re.component,id:"30da93ea-efa6-4642-bfa5-28fd4dc9c5b3",label:"Align",collapse:true},{type:re.divider,id:"9bad0563-6118-4855-9286-402bf98e00ad",hideOnCollapse:true},{name:_.listNumber,type:re.component,icon:"OrderedList",label:"Ordered list",id:"d37865e1-ff54-4118-a5cc-fa147d222471",collapse:true},{name:_.listBullet,type:re.component,icon:"UnOrderedList",label:"Unordered list",id:"ed77e7c9-b89c-41c5-a749-e68ea0b30497",collapse:true},{type:re.divider,id:"e5ecd77b-44cc-42fe-badb-48cadf3ddfb1",hideOnCollapse:true},{name:_.indentDecrease,type:re.component,icon:"IndentLess",label:"Decrease indent",id:"2dc6a5e4-b1b5-47d1-ac2f-5d0becb02d33",collapse:true},{name:_.indent,type:re.component,icon:"IndentMore",label:"Increase indent",id:"6903a3d1-a83f-4bc6-9bd9-f673feffe84f",collapse:true}]},{type:"component",name:_.attachFile,icon:"Attach",label:"Attach file",id:"f43a284e-113e-4095-b001-9d00a1dddc4c"},{type:re.component,name:_.link,icon:"Link",label:"Insert link",id:"580db61e-7939-4efe-914c-304b271998ec"},{type:re.component,name:_.emoji,icon:"Emoji",id:"e1f2c6d1-emoji"},{type:"component",name:_.insertPhoto,icon:"InsertImage",label:"Insert photo",id:"d032ba91-3e78-4ed5-8561-insertPhoto"},{type:"component",name:_.lockClock,icon:"LockClock",id:"d032ba91-3e78-4ed5-8561-lockClock"},{type:"component",name:_.insertSignature,icon:"Signature",label:"Insert signature",id:"d032ba91-3e78-4ed5-8561-lockClock"}];var zg={Undo:MdUndo,Redo:MdRedo,Bold:MdFormatBold,Italic:MdFormatItalic,Underline:MdFormatUnderlined,Color:MdTextFormat,LeftAlign:MdFormatAlignLeft,RightAlign:MdFormatAlignRight,CenterAlign:MdFormatAlignCenter,UnOrderedList:MdFormatListBulleted,OrderedList:MdFormatListNumbered,IndentLess:MdFormatIndentDecrease,IndentMore:MdOutlineFormatIndentIncrease,RemoveFormat:MdFormatClear,StrikeThrough:MdStrikethroughS,CodeQuote:MdFormatQuote,DownArrow:MdArrowDropDown,Styling:MdTextFormat,Attach:MdAttachFile,Link:MdLink,Image:MdImage,Check:MdCheck,TextFields:MdTextFields,Edit:MdEdit,Close:MdClose,Emoji:MdOutlineEmojiEmotions,InsertImage:MdPhoto,LockClock:MdLockClock,GoogleDrive:TbBrandGoogleDrive,Signature:RiBallPenFill,Ban:FaBan},pc=zg;var Bg=({name:o,size:e=24,color:t,className:n})=>{let r=pc[o];return r?jsx(r,{size:e,color:t,className:n}):(console.warn(`Icon "${o}" not found.`),null)},B=Bg;var Yg=({trigger:o,children:e,popUpDirection:t="top center",on:n="click"})=>{let r=useRef(null),i=()=>{r.current&&typeof r.current.close=="function"&&r.current.close();},s=l=>e({close:()=>{l?.(),i();}});return useEffect(()=>{let l=()=>{try{r.current?.reposition?.();let d=document.querySelector(".mail-inbox-popup .popup-content, .mail-inbox-popup-content, .mail-inbox-popup > .popup-content");if(!d)return;let u=d.getBoundingClientRect(),h=8;if(u.right>window.innerWidth-h){let p=u.right-(window.innerWidth-h),f=parseFloat(getComputedStyle(d).left||`${u.left}`);d.style.left=`${Math.max(h,f-p)}px`;}u.left<h&&(d.style.left=`${h}px`);}catch{}},a=()=>l();window.addEventListener("resize",a),window.addEventListener("scroll",a,true);let c=new MutationObserver(()=>{setTimeout(l,0);});return c.observe(document.body,{childList:true,subtree:true}),()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a,true),c.disconnect();}},[]),jsx(jg,{ref:r,trigger:o,on:n,closeOnDocumentClick:true,repositionOnResize:true,position:t,className:"mail-inbox-popup",children:s})},Je=Yg;var Xg=[{label:"Sans Serif",value:"sans-serif",style:{fontFamily:"sans-serif"}},{label:"Serif",value:"serif",style:{fontFamily:"serif"}},{label:"Fixed Width",value:"monospace",style:{fontFamily:"monospace"}},{label:"Wide",value:"wide",style:{fontWeight:"bold",letterSpacing:"0.05em"}},{label:"Narrow",value:"narrow",style:{fontStretch:"condensed"}},{label:"Comic Sans MS",value:"Comic Sans MS",style:{fontFamily:"Comic Sans MS, cursive"}},{label:"Garamond",value:"Garamond",style:{fontFamily:"Garamond, serif"}},{label:"Georgia",value:"Georgia",style:{fontFamily:"Georgia, serif"}},{label:"Tahoma",value:"Tahoma",style:{fontFamily:"Tahoma, sans-serif"}},{label:"Trebuchet MS",value:"Trebuchet MS",style:{fontFamily:"Trebuchet MS, sans-serif"}},{label:"Verdana",value:"Verdana",style:{fontFamily:"Verdana, sans-serif"}}],bo=[{key:"small",label:"Small",sizePx:12,htmlNodeVal:"2"},{key:"normal",label:"Normal",sizePx:18,htmlNodeVal:"4"},{key:"large",label:"Large",sizePx:28,htmlNodeVal:"6"},{key:"huge",label:"Huge",sizePx:56,htmlNodeVal:"7"}],$i=["#000000","#3a3a3a","#5a5a5a","#8a8a8a","#bfbfbf","#dedede","#f3f3f3","#ffffff"],Fi=["#e53935","#fb8c00","#ffee58","#66ff66","#4dd0e1","#1e88e5","#9c27b0","#ff3bd6"],Di=[["#f7d7d7","#f3d0c8","#f0c5c5","#efc9d8","#f7e6e9","#f3edf7","#f0eaf6","#f8f0f6"],["#f0b9b9","#f0d4c2","#e6f0d2","#e4f7e8","#d8eef8","#dbe1ff","#e9d9f6","#f5d9f7"],["#e69a9a","#e6caa3","#d7e6b0","#c8f0e6","#bfe3ff","#cbd8ff","#d6c3f3","#f0c2f3"],["#d16464","#d09a6a","#a8cf7b","#7fd6c0","#73b7ff","#7a9cff","#b483f1","#f08cf2"],["#b23a3a","#b26a3a","#7aa04a","#3fb092","#296f94","#2a4177","#452a68","#6e1f4d"],["#7a1d1d","#7a4a1e","#556a2a","#195b47","#123f5a","#182840","#2a1836","#3a1026"]],Li=Xg;function Pi({value:o="sans-serif",onChange:e}){let n=Li?.find(r=>r.value===o)?.label||(o==="serif"?"Serif":"Sans Serif");return jsx("div",{children:jsx(Je,{trigger:jsxs("button",{className:"font-option heading",children:[n,jsx(B,{name:"DownArrow"})]}),children:({close:r})=>jsx("div",{className:"p-4 mail-inbox-popup-content",children:jsx("div",{className:"font-options",children:Li.map(i=>jsx("button",{className:"btn-mail-editor",onClick:()=>{e(i.value),r();},style:{...i.style},children:jsxs("div",{className:"font-option",children:[o===i.value&&jsx(B,{name:"Check"}),i.label]})},i.value))})})})})}function Ii({value:o=16,onChange:e=()=>{}}){return jsx("div",{children:jsx(Je,{trigger:jsxs("button",{className:"font-option heading tool-bar-button","data-tooltip":"Size",children:[jsx(B,{name:"TextFields",className:"tool-bar-button-icon"}),jsx(B,{name:"DownArrow",className:"tool-bar-button-icon"})]}),children:({close:t})=>jsx("div",{className:"p-4 mail-inbox-popup-content",children:jsx("div",{className:"font-options",children:bo.map(n=>jsx("button",{className:"btn-mail-editor",onClick:()=>{e(n.key),t();},style:{fontSize:`${n.sizePx}px`},children:jsxs("div",{className:"font-option",children:[o===n.sizePx&&jsx(B,{name:"Check"}),n.label]})},n.key))})})})})}function Co({color:o,selected:e,onClick:t,label:n}){return jsx("button",{className:"swatch",title:n||o,"aria-pressed":e,onClick:()=>t(o),style:{background:o},children:e&&jsx("svg",{className:"check",viewBox:"0 0 24 24","aria-hidden":true,children:jsx("path",{d:"M20 6L9 17l-5-5",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})}function Ki({value:o={background:null,text:null},onChange:e=()=>{}}){function t(n,r){e({...o,[n]:r});}return jsx("div",{children:jsx(Je,{trigger:jsxs("button",{className:"font-option heading tool-bar-button","data-tooltip":"Text color",children:[jsx(B,{name:"Styling",className:"tool-bar-button-icon"}),jsx(B,{name:"DownArrow",className:"tool-bar-button-icon"})]}),children:({close:n})=>jsx("div",{className:"color-popover mail-inbox-popup-content",role:"dialog","aria-label":"Choose colors",children:jsxs("div",{className:"color-columns",children:[jsxs("section",{className:"color-column","aria-labelledby":"bg-label",children:[jsx("h4",{id:"bg-label",children:"Background color"}),jsx("div",{className:"row",children:jsx("button",{className:"swatch clear-swatch",title:"Remove color","aria-pressed":!o.background,onClick:()=>{t("background",null),n();},style:{background:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx(B,{name:"Ban",size:14,color:"#666"})})}),jsx("div",{className:"row",children:$i.map(r=>jsx(Co,{color:r,selected:o.background===r,onClick:i=>{t("background",i),n();},label:r},r+"bg"))}),jsx("div",{className:"row accent-row",children:Fi.map(r=>jsx(Co,{color:r,selected:o.background===r,onClick:i=>{t("background",i),n();},label:r},r+"bgacc"))}),jsx("div",{className:"palette",children:Di.map((r,i)=>jsx("div",{className:"palette-row",children:r.map(s=>jsx(Co,{color:s,selected:o.background===s,onClick:l=>{t("background",l),n();},label:s},s+"bgp"+i))},"row"+i))})]}),jsxs("section",{className:"color-column","aria-labelledby":"text-label",children:[jsx("h4",{id:"text-label",children:"Text color"}),jsx("div",{className:"row",children:jsx("button",{className:"swatch clear-swatch",title:"Remove color","aria-pressed":!o.text,onClick:()=>{t("text",null),n();},style:{background:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},children:jsx(B,{name:"Ban",size:14,color:"#666"})})}),jsx("div",{className:"row",children:$i.map(r=>jsx(Co,{color:r,selected:o.text===r,onClick:i=>{t("text",i),n();},label:r},r+"tx"))}),jsx("div",{className:"row accent-row",children:Fi.map(r=>jsx(Co,{color:r,selected:o.text===r,onClick:i=>{t("text",i),n();},label:r},r+"txacc"))}),jsx("div",{className:"palette",children:Di.map((r,i)=>jsx("div",{className:"palette-row",children:r.map(s=>jsx(Co,{color:s,selected:o.text===s,onClick:l=>{t("text",l),n();},label:s},s+"txp"+i))},"txrow"+i))})]})]})})})})}var gc=[{key:"left",iconName:"LeftAlign",label:"Left align"},{key:"center",iconName:"CenterAlign",label:"Center align"},{key:"right",iconName:"RightAlign",label:"Right align"}];function zi({value:o="left",onChange:e=()=>{}}){function t(n){e(n);}return jsx("div",{children:jsx(Je,{trigger:jsxs("button",{className:"font-option heading tool-bar-button","data-tooltip":"Align",children:[jsx(B,{name:gc?.find(n=>n.key===o)?.iconName||"LeftAlign"}),jsx(B,{name:"DownArrow",className:"tool-bar-button-icon"})]}),children:({close:n})=>jsx(Fragment,{children:gc.map(r=>{let i=r.key===o;return jsxs("button",{role:"menuitemradio","aria-checked":i,tabIndex:0,className:`alignment-option ${i?"active":""}`,onClick:()=>{t(r.key),n();},children:[jsx("div",{className:"option-check",style:{opacity:i?1:0},"aria-hidden":true,children:jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",children:jsx("path",{d:"M20 6L9 17l-5-5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsx(B,{name:r.iconName,size:20,className:"select-option-icon"})]},r.key)})})})})}var So=class o extends TextNode{__customStyle;static getType(){return "styled-text"}static clone(e){let t=new o(e.__text,e.__key);return t.__customStyle=e.__customStyle??"",t}constructor(e,t){super(e,t),this.__customStyle="";}static importJSON(e){let t=super.importJSON(e);return t.__customStyle=e.style??"",t}exportJSON(){return {...super.exportJSON(),style:this.__customStyle}}static importDOM(){let e=t=>{let n=t.tagName,r=Sc(t);return {node:null,forChild:i=>{if(!(i instanceof TextNode))return i;let s=i instanceof o?i.getWritable():new o(i.getTextContent());return r&&(s.__customStyle=Bi(s.__customStyle,Vo(r))),(n==="STRONG"||n==="B")&&s.toggleFormat("bold"),(n==="EM"||n==="I")&&s.toggleFormat("italic"),n==="U"&&s.toggleFormat("underline"),(n==="S"||n==="STRIKE")&&s.toggleFormat("strikethrough"),n==="CODE"&&s.toggleFormat("code"),s}}};return {span:()=>({conversion:e,priority:2}),strong:()=>({conversion:e,priority:2}),b:()=>({conversion:e,priority:2}),em:()=>({conversion:e,priority:2}),i:()=>({conversion:e,priority:2}),u:()=>({conversion:e,priority:2}),s:()=>({conversion:e,priority:2}),code:()=>({conversion:e,priority:2})}}exportDOM(e){let{element:t}=super.exportDOM(e);return t&&"setAttribute"in t&&this.__customStyle&&t.setAttribute("style",this.__customStyle),{element:t}}createDOM(e){let t=super.createDOM(e);return this.__customStyle&&t.setAttribute("style",this.__customStyle),t}updateDOM(e,t,n){return super.updateDOM(e,t,n)?true:(e.__customStyle!==this.__customStyle&&(this.__customStyle?t.setAttribute("style",this.__customStyle):t.removeAttribute("style")),false)}patchStyle(e){let t=this.getWritable();t.__customStyle=Bi(t.__customStyle,e);}getStyleProperty(e){return Vo(this.__customStyle)[e]}setCustomStyle(e){let t=this.getWritable();t.__customStyle=e;}clearStyle(){let e=this.getWritable();e.__customStyle="";}getCustomStyle(){return this.__customStyle}};function xo(o){return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)}function Vo(o){return Object.fromEntries(o.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let[t,...n]=e.split(":");return [t.trim(),n.join(":").trim()]}))}function xc(o){return Object.entries(o).filter(([,e])=>e!=null&&e!=="").map(([e,t])=>`${e}: ${t}`).join("; ")}function Bi(o,e){let t=Vo(o);for(let[n,r]of Object.entries(e))r===null?delete t[n]:t[n]=r;return xc(t)}function Sc(o){let e=Vo(o.getAttribute("style")??"");return delete e["white-space"],xc(e)}function qo(o){let e=$getSelection();if(!$isRangeSelection(e))return;e.getNodes().forEach(n=>{n instanceof So?n.patchStyle(o):Object.keys(o).length&&$patchStyleText(e,o);});}function Gn(o,e){document.dispatchEvent(new CustomEvent("signature:style",{detail:{command:o,value:e}}));}function yc(){let[o,e]=useState(false);return useEffect(()=>{let t=()=>{let n=window.getSelection();if(!n||n.rangeCount===0){e(false);return}let r=n.anchorNode,i=!!r?.closest?.('[data-signature="true"]')||!!r?.parentElement?.closest('[data-signature="true"]');e(i);};return document.addEventListener("selectionchange",t),()=>document.removeEventListener("selectionchange",t)},[]),o}var Zo={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikeThrough",subscript:"subscript",superscript:"superscript",fontSize:"fontSize",backColor:"backColor",foreColor:"foreColor"};function lb(o){let[e,t]=useState(false);return useEffect(()=>{let n=()=>{let r=window.getSelection();if(!r||r.rangeCount===0||!o.current){t(false);return}t(o.current.contains(r.anchorNode));};return document.addEventListener("selectionchange",n),()=>document.removeEventListener("selectionchange",n)},[o]),e}function Nc({nodeKey:o,html:e}){let[t]=useLexicalComposerContext(),n=useRef(null),r=useRef(false),i=lb(n);useEffect(()=>{r.current=i;},[i]);let s=useCallback(()=>{let a=n.current?.innerHTML??"";t.update(()=>{let c=$getNodeByKey(o);c&&a!==c.__html&&c.setHTML(a);});},[t,o]);useEffect(()=>{let a=t.registerCommand(FORMAT_TEXT_COMMAND,c=>{if(!r.current)return false;let d=Zo[c];return d&&document.execCommand(d,false),s(),true},COMMAND_PRIORITY_CRITICAL);return ()=>{a();}},[t,s]),useEffect(()=>{let a=c=>{if(!r.current)return;let{command:d,value:u}=c.detail;document.execCommand(d,false,u),s();};return document.addEventListener("signature:style",a),()=>document.removeEventListener("signature:style",a)},[s]);let l=a=>a.stopPropagation();return jsx("div",{ref:n,contentEditable:true,suppressContentEditableWarning:true,dangerouslySetInnerHTML:{__html:e},onBlur:s,onInput:l,onKeyDown:l,onKeyUp:l,onKeyPress:l,onPaste:l,onCut:l,onCopy:l,onClick:l,onMouseDown:l,"data-signature":"true",style:{outline:"none",cursor:"text",borderRadius:4},onFocus:a=>{},onBlurCapture:a=>{a.currentTarget.style.outline="none";}})}var wb=1;function Oc(o){if(!o||o.startsWith("#"))return o;if(o.startsWith("rgba")){let t=o.match(/rgba?\((\d+),\s*(\d+),\s*(\d+),?\s*([\d.]+)?\)/);if(t){let[,n,r,i,s]=t;return s==="0"?"transparent":"#"+[n,r,i].map(l=>{let a=parseInt(l).toString(16);return a.length===1?"0"+a:a}).join("")}}let e=o.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(e){let[,t,n,r]=e;return "#"+[t,n,r].map(i=>{let s=parseInt(i).toString(16);return s.length===1?"0"+s:s}).join("")}return o}function Nb(){let[o]=useLexicalComposerContext(),[e,t]=useState("paragraph"),[n,r]=useState({[_.fontFamily]:"sans-serif",[_.fontSize]:16,[_.align.base]:"left",[_.bold]:false,[_.italic]:false,[_.underline]:false}),[i,s]=useState(false),l=yc(),a=useCallback(()=>{o.getEditorState().read(()=>{let w=$getSelection(),S={[_.fontFamily]:"sans-serif",[_.fontSize]:16,[_.align.base]:"left"};if($isRangeSelection(w)){let y=w.anchor.getNode();if(y===null)return;let N=y.getKey()==="root"?y:y.getTopLevelElementOrThrow(),E=N.getKey(),R=o.getElementByKey(E);if(R!==null)if($isListNode(N)){let K=$getNearestNodeOfType(y,ListNode),V=K?K.getTag():N.getTag();t(V);}else {let K=N.getType();t(K);}S[_.strike]=w.hasFormat("strikethrough"),S[_.code]=w.hasFormat("code");let L=x(w),k=L.getParent();$isLinkNode(k)||$isLinkNode(L)?(S[_.link]=true,s(true)):(S[_.link]=false,s(false));let O=o.getElementByKey(L.getKey()),v=o.getElementByKey(k.getKey()),T=O||v||R;if(T){let K=window.getComputedStyle(T),V="";if(w.isCollapsed()&&(V=w.style.split("font-family:")[1]?.split(";")[0]?.trim().replace(/['"]/g,"")||""),V||(V=K.getPropertyValue("font-family")),V){let $e=V.split(",")[0].trim().replace(/['"]/g,"");(["-apple-system","BlinkMacSystemFont","system-ui","Arial","Helvetica"].includes($e)||["Times New Roman","Times"].includes($e))&&($e="sans-serif"),S[_.fontFamily]=$e;}let se="";if(w.isCollapsed()&&(se=w.style.split("font-size:")[1]?.split(";")[0]?.trim()||""),se||(se=K.getPropertyValue("font-size")),se){let $e=parseInt(se,10);S[_.fontSize]=$e||16;}let ie=null,le=null;T instanceof HTMLElement&&T.style&&(ie=T.style.color||null,le=T.style.backgroundColor||null);let Ce=ie?Oc(ie):null,ve=le&&le!=="rgba(0, 0, 0, 0)"&&le!=="transparent"?Oc(le):null;Ce||ve?S[_.color.base]={text:Ce||null,background:ve||null}:S[_.color.base]={text:null,background:null};let Ae=typeof N.getFormatType=="function"?N.getFormatType():"left";(Ae==="start"||Ae==="")&&(Ae="left"),S[_.align.base]=Ae;}r(K=>({...K,...S}));}});},[o]),c=(w,S,y,N)=>{o.update(()=>{let E=$getSelection();if(!$isRangeSelection(E))return;let R=x(E),L=o.getElementByKey(R.getKey())||o.getElementByKey(R.getParent().getKey()),k=L?window.getComputedStyle(L).getPropertyValue(S):"",O=N(k);r(v=>({...v,[w]:!v[w]})),qo({[S]:O?"":y});});};useEffect(()=>{a();},[o,a]),useEffect(()=>mergeRegister(o.registerUpdateListener(({editorState:w})=>{w.read(()=>{a();});}),o.registerCommand(SELECTION_CHANGE_COMMAND,()=>(a(),false),wb)),[o,a]);function d(w,S){switch(w){case _.bold:c(_.bold,"font-weight","700",y=>y==="bold"||(parseInt(y||"0",10)||0)>=600);break;case _.italic:c(_.italic,"font-style","italic",y=>y==="italic");break;case _.underline:c(_.underline,"text-decoration","underline",y=>y.includes("underline"));break;case _.align.base:o.dispatchCommand(FORMAT_ELEMENT_COMMAND,S);break;case _.undo:o.dispatchCommand(UNDO_COMMAND,void 0);break;case _.redo:o.dispatchCommand(REDO_COMMAND,void 0);break;case _.listNumber:C();break;case _.listBullet:b();break;case _.indent:u();break;case _.indentDecrease:g();break;case _.color.base:f(S);break;case _.fontFamily:{let y=S;r(N=>({...N,[_.fontFamily]:y})),h(y);break}case _.fontSize:{let y=S,N=bo.find(E=>E.key===y)?.sizePx??16;r(E=>({...E,[_.fontSize]:N})),p(y);break}case _.link:m();break;}}let u=()=>{o.dispatchCommand(INDENT_CONTENT_COMMAND,void 0);},h=w=>{o.update(()=>{let S=$getSelection();$isRangeSelection(S)&&qo({"font-family":w});});},p=w=>{if(l){let S=bo.find(y=>y.key===w)?.htmlNodeVal??"2";Gn(Zo.fontSize,S);}else {let S=bo.find(y=>y.key===w)?.sizePx??16;o.update(()=>{let y=$getSelection();$isRangeSelection(y)&&qo({"font-size":`${S}px`});});}},f=w=>{l?(Gn(Zo.backColor,w.background),Gn(Zo.foreColor,w.text)):o.update(()=>{let S=$getSelection();$isRangeSelection(S)&&qo({"background-color":w.background,color:w.text});});},m=useCallback(()=>{i?o.dispatchCommand(TOGGLE_LINK_COMMAND,null):o.update(()=>{let w=$getSelection();if($isRangeSelection(w)){w.isCollapsed()&&w.modify("extend",true,"word");let S=$getSelection();$isRangeSelection(S)&&!S.isCollapsed()&&o.dispatchCommand(TOGGLE_LINK_COMMAND,"https://");}});},[o,i]),g=()=>{o.dispatchCommand(OUTDENT_CONTENT_COMMAND,void 0);},b=()=>{e!=="ul"?o.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND,void 0):o.dispatchCommand(REMOVE_LIST_COMMAND,void 0);},C=()=>{e!=="ol"?o.dispatchCommand(INSERT_ORDERED_LIST_COMMAND,void 0):o.dispatchCommand(REMOVE_LIST_COMMAND,void 0);};function x(w){let S=w.anchor,y=w.focus,N=w.anchor.getNode(),E=w.focus.getNode();return N===E?N:w.isBackward()?$isAtNodeEnd(y)?N:E:$isAtNodeEnd(S)?E:N}return {onChange:d,isLink:i,editor:o,selectedEventTypes:n,blockType:e}}var kc=Nb;function Mb({editor:o}){let e=useRef(null),t=useRef(null),n=useRef(false),[r,i]=useState(""),[s,l]=useState(false),[a,c]=useState(false),[d,u]=useState(null),h=useCallback(()=>{let p=window.getSelection(),f=$getSelection(),m=false,g="";if($isRangeSelection(f)){let w=Ob(f),S=w.getParent();$isLinkNode(S)?(g=S.getURL(),m=true):$isLinkNode(w)&&(g=w.getURL(),m=true);}i(g),c(m);let b=e.current,C=document.activeElement;if(!b)return;let x=o.getRootElement();if(f&&p&&x&&x.contains(p.anchorNode)&&(s||!p.isCollapsed||m||g!=="")){let w=p.getRangeAt(0),S;if(p.anchorNode===x){let y=x;for(;y.firstElementChild!=null;)y=y.firstElementChild;S=y.getBoundingClientRect();}else S=w.getBoundingClientRect();n.current||Fc(b,S),u(f);}else (!C||C.className!=="link-input")&&(Fc(b,null),u(null),l(false),i(""));return true},[o]);return useEffect(()=>mergeRegister(o.registerUpdateListener(({editorState:p})=>{p.read(()=>{h();});}),o.registerCommand(SELECTION_CHANGE_COMMAND,()=>(h(),true),1)),[o,h]),useEffect(()=>{o.getEditorState().read(()=>{h();});},[o,h]),useEffect(()=>{s&&t.current&&t.current.focus();},[s]),useEffect(()=>{r==="https://"&&l(true);},[r]),jsx("div",{className:"floating-link-editor",ref:e,children:s?jsxs(Fragment,{children:[jsx("input",{ref:t,className:"link-input",value:r,onChange:p=>i(p.target.value),onKeyDown:p=>{p.key==="Enter"?(p.preventDefault(),d&&r!==""&&o.dispatchCommand(TOGGLE_LINK_COMMAND,r),l(false)):p.key==="Escape"&&(p.preventDefault(),l(false));},placeholder:"Enter link..."}),jsx("button",{className:"link-button",onMouseDown:p=>p.preventDefault(),onClick:()=>{s&&o.dispatchCommand(TOGGLE_LINK_COMMAND,r),l(false);},children:jsx(B,{name:"Check"})})]}):jsxs("div",{className:"link-view-mode",children:[jsx("span",{className:"link-view-label",children:"Go to link:"}),jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"link-view-url",children:r}),jsx("span",{className:"link-view-divider",children:"|"}),jsx("button",{className:"link-text-button",onMouseDown:p=>p.preventDefault(),onClick:()=>l(true),children:"Change"}),jsx("span",{className:"link-view-divider",children:"|"}),jsx("button",{className:"link-text-button",onMouseDown:p=>p.preventDefault(),onClick:()=>{o.dispatchCommand(TOGGLE_LINK_COMMAND,null),l(false);},children:"Remove"})]})})}function Ob(o){let e=o.anchor.getNode(),t=o.focus.getNode();return e===t?e:o.isBackward()?$isAtNodeEnd(o.focus)?e:t:$isAtNodeEnd(o.anchor)?t:e}function Fc(o,e){if(!e){o.style.opacity="0",o.style.top="-1000px",o.style.left="-1000px";return}let t=o.offsetWidth,n=o.offsetHeight,r=window.innerWidth,i=window.innerHeight,s=e.top+e.height+window.pageYOffset+10,l=e.left+window.pageXOffset-t/2+e.width/2;l<8&&(l=8),l+t>r-8&&(l=r-t-8),s+n>i-8&&(s=e.top+window.pageYOffset-n-10),s<8&&(s=8),o.style.opacity="1",o.style.top=`${s}px`,o.style.left=`${l}px`;}var Lc=Mb;var bt={FILE_INVALID_TYPE:"file-invalid-type",FILE_TOO_LARGE:"file-too-large",TOO_MANY_FILES:"too-many-files",HEIC_CONVERSION_ERROR:"heic-conversion-error"},Fb=10,Db=10,Kc=()=>Math.random().toString(36).substring(2,10)+Date.now().toString(36),Lb=o=>{if(o<1024)return {value:o.toString(),type:"bytes"};let e=o/1024;if(e<1024)return {value:e.toFixed(1),type:"KB"};let t=e/1024;return t<1024?{value:t.toFixed(1),type:"MB"}:{value:(t/1024).toFixed(1),type:"GB"}},zc=({accept:o={"image/*":[".png",".gif",".jpeg",".jpg"],"application/pdf":[".pdf"]},maxSize:e=Db*1024*1024,maxFiles:t=Fb,multiple:n=true,isDisabled:r=false,replaceAfterUpload:i=false,files:s=[],handleFileChange:l=()=>{}})=>{let[a,c]=useState(false),[d,u]=useState(s??[]),[h,p]=useState([]),f=S=>{switch(S){case bt.FILE_INVALID_TYPE:return "Invalid file type. Please upload a supported format.";case bt.FILE_TOO_LARGE:{let{value:y,type:N}=Lb(e);return `File too large. Maximum allowed size is ${y} ${N}.`}case bt.TOO_MANY_FILES:return `Too many files selected. Maximum allowed: ${t}.`;case bt.HEIC_CONVERSION_ERROR:return "Failed to convert HEIC image. Please upload a JPEG or PNG instead.";default:return "An unknown file error occurred."}};useEffect(()=>{l(d);},[d]);let{getRootProps:m,getInputProps:g,isDragActive:b,open:C}=useDropzone({accept:o,maxSize:e,multiple:n,maxFiles:t,disabled:r,noClick:true,onFileDialogCancel:()=>c(false),onFileDialogOpen:()=>{r||c(true);},onDrop:async(S,y)=>{let E=(await Promise.all(S.map(async R=>{if(!R)return null;if(R.type==="image/heic")try{let L=await $b({blob:R,toType:"image/jpeg"}),k=Array.isArray(L)?L[0]:L,O=new File([k],`${R.name.replace(/\.heic$/i,"")}.jpeg`,{type:"image/jpeg"});return Object.assign(O,{uuid:Kc(),preview:URL.createObjectURL(O)})}catch(L){console.error("HEIC conversion error:",L);let k=f(bt.HEIC_CONVERSION_ERROR);return p(O=>[...O,{file:R,preview:URL.createObjectURL(R),readableErrors:[k],errors:[{code:bt.HEIC_CONVERSION_ERROR,message:k}]}]),null}return Object.assign(R,{uuid:Kc(),preview:URL.createObjectURL(R)})}))).filter(Boolean);if(!r){let R=i?[]:[...d];R=[...R,...E];let L=y.map(k=>{let O=k.errors.map(v=>f(v.code));return {file:k.file,errors:k.errors.map(v=>({code:v.code,message:v.message})),preview:URL.createObjectURL(k.file),readableErrors:O}});return p(k=>[...k,...L]),u(R),R}return d},validator:S=>{let{name:y,type:N}=S;if(y){let E=y.split(".").pop()?.toLowerCase();if(o&&o?.[N]&&o?.[N].length&&!o?.[N].includes(`.${E}`))return {code:bt.FILE_INVALID_TYPE,message:f(bt.FILE_INVALID_TYPE)}}return null}}),x=useCallback(S=>{u(y=>y.filter(N=>N.uuid!==S));},[u]),w=useCallback(()=>{p([]);},[]);return useEffect(()=>()=>{d.forEach(S=>S.preview&&URL.revokeObjectURL(S.preview)),h.forEach(S=>S.preview&&URL.revokeObjectURL(S.preview));},[]),{getRootProps:m,getInputProps:g,isDragActive:b,isFileDialogOpen:a,rejectedFiles:h,openFileDialog:C,removeFile:x,clearRejectedFiles:w}};var Pb=({handleFileChange:o})=>{let{getRootProps:e,getInputProps:t,openFileDialog:n}=zc({multiple:true,maxFiles:5,maxSize:5242880,handleFileChange:r=>{o(r);}});return jsx("div",{className:"uploader-container",children:jsxs("div",{...e(),children:[jsx("input",{...t()}),jsx("button",{onClick:n,className:"tool-bar-button","data-tooltip":"Attach files",children:jsx(B,{className:"upload-icon",name:"Attach"})})]})})},Bc=Pb;function Gi({file:o,index:e,onRemove:t,onView:n}){if(!o)return null;let r=o?.name??"unknown",i=o instanceof File||"size"in o&&o.size!==void 0?o.size:"bytes"in o&&o.bytes!==void 0?o.bytes:null,s=("url"in o?o?.url:null)??null,l=useMemo(()=>{if(s)return s;if(typeof window<"u"&&o instanceof File)try{return URL.createObjectURL(o)}catch{return null}return null},[o,s]),a=u=>{if(!u&&u!==0)return "";let h=Math.round(u/1024);return h<1024?`${h}K`:`${Math.round(u/1024/1024*10)/10}M`},c=u=>{if(u.preventDefault(),n)return n(l??null);l&&window.open(l,"_blank","noopener");},d=u=>{t&&t(u);};return jsxs("div",{className:"fps-row",role:"group","aria-label":`Attachment ${r}`,children:[jsxs("div",{className:"fps-left",children:[jsx("a",{href:l??"#",className:"fps-filename",onClick:c,title:r,target:"_blank",rel:"noopener noreferrer",children:r}),i!=null&&jsxs("span",{className:"fps-size",children:["\xA0(",a(i),")"]})]}),jsx("button",{type:"button",className:"fps-close","aria-label":`Remove ${r}`,onClick:()=>d(e),children:"\xD7"})]})}function Uc(o,e,t,n,r){let i=n||["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"],s=r||"https://www.googleapis.com/auth/drive.readonly",[l,a]=useState(false),[c,d]=useState(false),[u,h]=useState(null),[p,f]=useState(null);useEffect(()=>{o&&e&&(()=>{let C=document.createElement("script");C.src="https://apis.google.com/js/api.js",C.async=true,C.defer=true,C.onload=()=>{e&&window.gapi.load("client:picker",async()=>{await window.gapi.client.init({apiKey:e,discoveryDocs:i}),a(true);});},document.body.appendChild(C);let x=document.createElement("script");x.src="https://accounts.google.com/gsi/client",x.async=true,x.defer=true,x.onload=()=>{if(!o)return;let w=window.google.accounts.oauth2.initTokenClient({client_id:o,scope:s,callback:""});h(w),d(true);},document.body.appendChild(x);})();},[o,e]);let m=useCallback(b=>{if(!e)return;new window.google.picker.PickerBuilder().addView(window.google.picker.ViewId.DOCS).setOAuthToken(b).setDeveloperKey(e).setSize(1051,650).setCallback(async x=>{if(x.action===window.google.picker.Action.PICKED){let w=x.docs.map(S=>new File([],S.name,{type:S.mimeType}));t(w);}}).build().setVisible(true);},[t]);return {openPicker:useCallback(()=>{if(u){if(p){m(p);return}u.callback=async b=>{if(b.error!==void 0)throw b;f(b.access_token),m(b.access_token);},u.requestAccessToken({prompt:"consent"});}},[u,p,m]),isLoaded:l&&c}}var Yb=({onEmojiSelect:o})=>{let e=useRef(null),[t,n]=Qc__default.useState(false);return useEffect(()=>{n(true),console.log("EmojiPicker: isClient set to true");},[]),t?jsx("div",{ref:e,onClick:r=>r.stopPropagation(),onMouseDown:r=>r.stopPropagation(),children:jsx(Ub,{data:jb,onEmojiSelect:r=>{console.log("Emoji selected:",r),o(r);}})}):null},Yc=Yb;function Xb({src:o,altText:e}){return jsx("img",{src:o,alt:e})}var zt=class o extends DecoratorNode{__src;__altText;static getType(){return "image"}static clone(e){let t=new o(e.__key);return t.__src=e.__src,t.__altText=e.__altText,t}constructor(e){super(e),this.__src="",this.__altText="";}static importJSON(e){let t=Xi(e.src,e.altText);return t.setSrc(e.src),t.setAltText(e.altText),t}exportJSON(){return {altText:this.getAltText(),src:this.getSrc(),type:"image",version:1}}createDOM(e){let t=document.createElement("div");return t.style.display="contents",t}updateDOM(){return false}setSrc(e){let t=this.getWritable();t.__src=e;}getSrc(){return this.__src}setAltText(e){let t=this.getWritable();t.__altText=e;}getAltText(){return this.__altText}getTextContent(){return this.__altText}decorate(){return Qc.createElement(Xb,{src:this.__src,altText:this.__altText})}};function Xi(o,e){let t=new zt;return t.setSrc(o),t.setAltText(e),t}var Ji=createCommand();function Vi(){let[o]=useLexicalComposerContext();return useEffect(()=>{if(!o.hasNodes([zt]))throw new Error("ImagesPlugin: ImageNode not registered on editor");return o.registerCommand(Ji,e=>{let{src:t,altText:n}=e,r=Xi(t,n);return $insertNodeToNearestRoot(r),true},COMMAND_PRIORITY_EDITOR)},[o]),null}var Qn=(o,{onChange:e,state:t,setState:n,selectedEventTypes:r,blockType:i,setAttachments:s,setShowEmojiPicker:l,setEmojiPosition:a,isLink:c,editor:d,openDrivePicker:u})=>{switch(o.name){case _.undo:case _.redo:case _.bold:case _.italic:case _.underline:case _.indentDecrease:case _.indent:return jsx("button",{className:`tool-bar-button ${r?.[o.name]?"active-btn-toolbar":""}`,onClick:()=>e(o.name,true),"data-tooltip":o.label,children:jsx(B,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`);case _.drive:return jsx("button",{className:`tool-bar-button ${r?.[o.name]?"active-btn-toolbar":""}`,onClick:u,"data-tooltip":"Insert files using Drive",children:jsx(B,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`);case _.insertPhoto:return jsxs(Fragment,{children:[jsx("input",{type:"file",accept:"image/*",style:{display:"none"},id:"image-upload",onChange:h=>{let p=h.target.files;if(p&&p.length>0){let f=new FileReader;f.onloadend=()=>{d&&d.dispatchCommand(Ji,{src:f.result,altText:p[0].name});},f.readAsDataURL(p[0]);}}}),jsx("button",{className:`tool-bar-button ${r?.[o.name]?"active-btn-toolbar":""}`,onClick:()=>{document.getElementById("image-upload")?.click();},"data-tooltip":o.label,children:jsx(B,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`)]});case _.link:return jsx("button",{className:`tool-bar-button ${c?"active-btn-toolbar":""}`,onClick:()=>e(o.name,true),"data-tooltip":o.label,children:jsx(B,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`);case _.listNumber:return jsx("button",{className:`tool-bar-button ${i==="ol"?"active-btn-toolbar":""}`,onClick:()=>e(o.name,true),"data-tooltip":o.label,children:jsx(B,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`);case _.listBullet:return jsx("button",{className:`tool-bar-button ${i==="ul"?"active-btn-toolbar":""}`,onClick:()=>e(o.name,true),"data-tooltip":o.label,children:jsx(B,{className:"tool-bar-button-icon",name:o.icon})},`${o.name}-${o.icon}`);case _.attachFile:return jsx(Bc,{value:t?.[o.name],handleFileChange:h=>{n(p=>({...p,[o.name]:h})),s(h);}});case _.fontFamily:return jsx(Pi,{value:r?.[o.name]||t?.[o.name],onChange:h=>e(o.name,h)});case _.fontSize:return jsx(Ii,{value:r?.[o.name]||t?.[o.name],onChange:h=>e(o.name,h)});case _.color.base:return jsx(Ki,{value:r?.[o.name]||t?.[o.name],onChange:h=>e(o.name,h)});case _.align.base:return jsx(zi,{value:r?.[o.name]||t?.[o.name],onChange:h=>e(o.name,h)});case _.emoji:return jsx("button",{className:"tool-bar-button",onMouseDown:h=>{h.preventDefault(),h.stopPropagation(),console.log("Emoji button clicked, current state:",l);let p=h.currentTarget.getBoundingClientRect(),f=p.top+window.scrollY-440;a({top:f<0?p.bottom+window.scrollY+10:f,left:Math.max(10,p.left+window.scrollX)}),l(m=>!m);},type:"button","data-tooltip":"Insert emoji",children:jsx("div",{style:{pointerEvents:"none"},children:jsx(B,{className:"tool-bar-button-icon",name:o.icon})})},o.name);}if(o.type===re.divider)return jsx("span",{className:"divider"})},iC=(o,e)=>{let{key:t,...n}=e;switch(o.type){case re.divider:return jsx("div",{className:"divider"},t);case re.component:return jsx("div",{style:{display:"contents"},children:Qn(o,n)},t);case re.styling:return jsxs("div",{className:"styling-toolbar",children:[e.toggle&&o.options?.length?jsxs("div",{className:"styling-options",children:[e.isMoreVisible?e.visibleFormattingPlugins.map((r,i)=>jsx("div",{style:{display:"contents"},children:r.hideOnCollapse?null:Qn(r,n)},`${r.name}-${i}`)):o.options.map((r,i)=>jsx("div",{style:{display:"contents"},children:Qn(r,n)},`${r.name}-${i}`)),jsxs("div",{className:"more-wrapper",children:[jsx("button",{className:"tool-bar-button more-button",onClick:()=>e.setMoreOpen(r=>!r),"data-tooltip":"More",children:jsx(B,{className:"tool-bar-button-icon",name:"DownArrow"})}),e.moreOpen&&jsx("div",{className:"more-dropdown",children:e.collapsedFormattingPlugins.map((r,i)=>jsx("div",{className:"more-item",children:jsx("div",{style:{display:"contents"},children:Qn(r,n)},`${r.name}-${i}`)},`more-${i}`))})]})]}):null,jsx("button",{onClick:()=>e.setToggle(r=>!r),className:"tool-bar-button","data-tooltip":"Formatting options",children:jsx(B,{className:"tool-bar-button-icon",name:o.icon})})]},t);default:return}};function sC({rightChildren:o,leftChildren:e,customTool:t,disabled:n}){let[r,i]=useState(true),[s,l]=useState({}),[a,c]=useState(false),[d,u]=useState(null),[h,p]=useState(false),[f,m]=useState(false),b=Ai.find(v=>v.type===re.styling)?.options||[],C=b.filter(v=>v?.collapse),x=b.filter(v=>!v?.collapse),{setAttachments:w,googleDriveConfig:S}=it(),{onChange:y,isLink:N,editor:E,selectedEventTypes:R,blockType:L}=kc(),{openPicker:k}=Uc(S?.clientId,S?.apiKey,v=>{l(T=>{let V=[...T[_.attachFile]||[],...v];return w(V),{...T,[_.attachFile]:V}});},S?.discoveryDocs,S?.scopes),O=useRef(null);return useEffect(()=>{let v=new ResizeObserver(T=>{let K=T[0].contentRect.width;m(K<=720);});return O.current&&v.observe(O.current),()=>v.disconnect()},[]),jsxs("div",{ref:O,className:`toolbar-container ${n?"toolbar-disabled":""}`,children:[s[_.attachFile]?.length?jsx("div",{className:"file-upload-container",children:s[_.attachFile].map((v,T)=>jsx(Gi,{file:v,index:T,onRemove:K=>{l(V=>{let se=V[_.attachFile].filter((ie,le)=>le!==K);return w(se),{...V,[_.attachFile]:se}});}},v.name+T))}):null,jsxs("div",{className:"toolbar-wrapper",children:[e,jsxs("div",{className:"plugin-wrapper",children:[Ai.map((v,T)=>iC(v,{key:`${v.name||v.type}-${T}`,toggle:r,setToggle:i,onChange:y,state:s,setState:l,selectedEventTypes:R,blockType:L,setAttachments:w,setShowEmojiPicker:c,setEmojiPosition:u,isLink:N,editor:E,openDrivePicker:k,isMoreVisible:f,collapsedFormattingPlugins:C,visibleFormattingPlugins:x,moreOpen:h,setMoreOpen:p})),t]}),o,N&&createPortal(jsx(Lc,{editor:E}),document.body)]}),a&&d&&createPortal(jsx("div",{className:"emoji-picker-container",style:{position:"absolute",top:d.top,left:d.left,zIndex:9999},children:jsx(Yc,{onEmojiSelect:v=>{E?.update(()=>{let T=$getSelection();$isRangeSelection(T)?T.insertNodes([$createTextNode(v.native)]):T&&T.insertNodes([$createTextNode(v.native)]);}),c(false);}})}),document.body)]})}var Vc=sC;var aC={ltr:"ltr",rtl:"rtl",placeholder:"editor-placeholder",paragraph:"editor-paragraph",quote:"editor-quote",heading:{h1:"editor-heading-h1",h2:"editor-heading-h2",h3:"editor-heading-h3",h4:"editor-heading-h4",h5:"editor-heading-h5"},list:{nested:{listitem:"editor-nested-listitem"},ol:"editor-list-ol",ul:"editor-list-ul",listitem:"editor-listitem"},image:"editor-image",link:"editor-link",text:{bold:"editor-text-bold",italic:"editor-text-italic",overflowed:"editor-text-overflowed",hashtag:"editor-text-hashtag",underline:"editor-text-underline",strikethrough:"editor-text-strikethrough",underlineStrikethrough:"editor-text-underlineStrikethrough",code:"editor-text-code"},code:"editor-code",codeHighlight:{atrule:"editor-tokenAttr",attr:"editor-tokenAttr",boolean:"editor-tokenProperty",builtin:"editor-tokenSelector",cdata:"editor-tokenComment",char:"editor-tokenSelector",class:"editor-tokenFunction","class-name":"editor-tokenFunction",comment:"editor-tokenComment",constant:"editor-tokenProperty",deleted:"editor-tokenProperty",doctype:"editor-tokenComment",entity:"editor-tokenOperator",function:"editor-tokenFunction",important:"editor-tokenVariable",inserted:"editor-tokenSelector",keyword:"editor-tokenAttr",namespace:"editor-tokenVariable",number:"editor-tokenProperty",operator:"editor-tokenOperator",prolog:"editor-tokenComment",property:"editor-tokenProperty",punctuation:"editor-tokenPunctuation",regex:"editor-tokenVariable",selector:"editor-tokenSelector",string:"editor-tokenSelector",symbol:"editor-tokenProperty",tag:"editor-tokenProperty",url:"editor-tokenOperator",variable:"editor-tokenVariable"}},qc=aC;function qi({onChange:o}){let[e]=useLexicalComposerContext();return useEffect(()=>e.registerUpdateListener(({editorState:t})=>{t.read(()=>{let n=$generateHtmlFromNodes(e,null);o(n);});}),[e,o]),null}function Zi(){let[o]=useLexicalComposerContext();return useEffect(()=>o.registerUpdateListener(({dirtyElements:e,tags:t})=>{t.has("history-merge")||o.update(()=>{let n=$getRoot();n.getDirection()!=="ltr"&&n.setDirection("ltr");let r=n.getChildren();for(let i of r)$isParagraphNode(i)&&i.getDirection()!=="ltr"&&i.setDirection("ltr");});}),[o]),null}function Zc(o){let e=t=>{Array.from(t.classList).forEach(r=>{r.startsWith("editor-")&&t.classList.remove(r);}),t.classList.length===0&&t.removeAttribute("class");};return o.querySelectorAll("[class*='editor-text-']").forEach(t=>{let n=t,r=Array.from(n.classList),i=[];if(r.includes("editor-text-bold")&&i.push("strong"),r.includes("editor-text-italic")&&i.push("em"),r.includes("editor-text-underline")&&i.push("u"),r.includes("editor-text-strikethrough")&&i.push("s"),r.includes("editor-text-underlineStrikethrough")&&i.push("u","s"),r.includes("editor-text-code")&&i.push("code"),i.length===0)return;let s=r.filter(h=>!h.startsWith("editor-text-")),l=n.getAttribute("style")||"",a=null,c=null,d=h=>{let p=o.createElement(h);return a?c&&c.append(p):a=p,c=p,p};if(!!l.trim()||s.length>0){let h=d("span");l.trim()&&h.setAttribute("style",l),s.length>0&&h.setAttribute("class",s.join(" "));}i.forEach(h=>d(h)),!(!a||!c)&&(c.append(...Array.from(t.childNodes)),t.replaceWith(a));}),o.querySelectorAll("[style]").forEach(t=>{let r=t.style,i=r.fontWeight?.trim().toLowerCase()||"",s=Number.parseInt(i,10),l=i==="bold"||i==="bolder"||!Number.isNaN(s)&&s>=600,a=r.fontStyle?.trim().toLowerCase()||"",c=a==="italic"||a==="oblique",d=(r.textDecorationLine||r.textDecoration||"").trim().toLowerCase(),u=d.includes("underline"),h=d.includes("line-through"),p=[];if(l&&!["STRONG","B"].includes(t.tagName)&&p.push("strong"),c&&!["EM","I"].includes(t.tagName)&&p.push("em"),u&&t.tagName!=="U"&&p.push("u"),h&&!["S","DEL","STRIKE"].includes(t.tagName)&&p.push("s"),p.length===0)return;let f=Array.from(t.childNodes);if(f.length===0)return;let m=null,g=null;p.forEach(b=>{let C=o.createElement(b);m?g&&g.append(C):(m=C,t.append(C)),g=C;}),g&&g.append(...f);}),o.querySelectorAll("span, p, div, strong, em, u, s").forEach(t=>{let n=t;n.style.removeProperty("white-space"),t.tagName==="SPAN"&&!n.style.cssText.trim()&&t.className===""&&t.replaceWith(...Array.from(t.childNodes));}),o.querySelectorAll(".editor-paragraph").forEach(t=>{e(t);}),["h1","h2","h3","h4","h5","h6"].forEach(t=>{o.querySelectorAll(`.editor-heading-${t}`).forEach(n=>{let r=o.createElement(t);r.innerHTML=n.innerHTML;let i=n;i.style.cssText&&(r.style.cssText=i.style.cssText),r.style.removeProperty("white-space"),n.replaceWith(r);});}),o.querySelectorAll(".editor-listitem").forEach(t=>{e(t);}),o.querySelectorAll(".editor-list-ul, .editor-list-ol").forEach(t=>{e(t);}),o.querySelectorAll(".editor-link").forEach(t=>{e(t);}),o}function Qi({initialHTML:o}){let[e]=useLexicalComposerContext(),t=useRef(false);return useEffect(()=>{t.current||e.update(()=>{let n=$getRoot();if(n.setDirection("ltr"),n.clear(),o){let i=new DOMParser().parseFromString(o,"text/html"),s=Zc(i),l=$generateNodesFromDOM(e,s);$insertNodes(l);}else if(n.isEmpty()){let r=$createParagraphNode();r.setDirection("ltr"),n.append(r);}t.current=true;});},[e,o]),null}var wo=class o extends DecoratorNode{__html;static getType(){return "signature"}static clone(e){return new o(e.__html,e.__key)}static importJSON(e){return new o(e.html)}constructor(e,t){super(t),this.__html=e;}exportJSON(){return {html:this.__html,type:"signature",version:1}}exportDOM(e){let t=document.createElement("div");return t.innerHTML=this.__html,{element:t}}setHTML(e){let t=this.getWritable();t.__html=e;}isInline(){return false}createDOM(){return document.createElement("div")}updateDOM(){return false}decorate(){return jsx(Nc,{nodeKey:this.__key,html:this.__html})}};function $C(o){let e=new DOMParser().parseFromString(o,"text/html"),t=e.querySelectorAll("table"),n=e.querySelector('img[alt="mobilePhone"], img[alt="emailAddress"], img[alt="website"]');return t.length>=3||!!n}function er(){let[o]=useLexicalComposerContext();return useEffect(()=>o.registerCommand(PASTE_COMMAND,e=>{let t=e.clipboardData?.getData("text/html"),n=e.clipboardData?.getData("text/plain"),r=$getSelection();return $isRangeSelection(r)?t&&$C(t)?($insertNodes([new wo(t),$createParagraphNode()]),true):t?false:n?(r.insertText(n),true):false:false},COMMAND_PRIORITY_CRITICAL),[o]),null}var QC=({aiContent:o,onAiInsert:e,onAiDiscard:t,aiContentComponent:n,showAiPreview:r})=>{let[i]=useLexicalComposerContext(),s=Qc__default.useCallback(()=>{o&&(i.update(()=>{try{let c=new DOMParser().parseFromString(o,"text/html"),d=$generateNodesFromDOM(i,c);d.forEach(u=>{"setDirection"in u&&u.setDirection("ltr");}),$insertNodes(d);}catch{let c=$createTextNode(o);$insertNodes([c]);}}),e&&e(o));},[i,o,e]),l=Qc__default.useCallback(()=>{t&&t();},[t]);return !r||!n?null:jsx("div",{className:"ai-preview-container",children:Children.map(n,a=>isValidElement(a)?cloneElement(a,{onInsert:s,onDiscard:l}):a)})};function eS({aiContentComponent:o,aiContent:e,showAiPreview:t,onAiInsert:n,onAiDiscard:r,placeholder:i="",initialHTML:s="",rightChildren:l,leftChildren:a,customTool:c,minHeight:d="200px",onChange:u,editorChildren:h,isEditorVisible:p=true}){let[f,m]=useState(s),g=x=>{m(x),u&&u(x);},b=t&&o;return jsx("div",{className:"compose-box-wrapper",style:{minHeight:d},children:jsxs(LexicalComposer,{initialConfig:{namespace:"ComposeBox",theme:qc,nodes:[ListNode,ListItemNode,LinkNode,AutoLinkNode,dc,uc,cc,zt,wo,So],onError:x=>{console.error(x);}},children:[jsxs("div",{className:"compose-box-editor-container",style:{flex:1},children:[jsxs("div",{className:"compose-box-scroll-area",style:{flex:1,overflowY:"auto",minHeight:d},children:[b&&f&&f!=='<p class="editor-paragraph"><br></p>'&&jsx("div",{className:"compose-box-content-preview",dangerouslySetInnerHTML:{__html:f}}),jsx(QC,{aiContent:e,onAiInsert:n,onAiDiscard:r,aiContentComponent:o,showAiPreview:t}),jsx("div",{style:{display:b?"none":"block"},children:p?jsxs(Fragment,{children:[jsx(RichTextPlugin,{contentEditable:jsx(ContentEditable,{style:{minHeight:d,padding:"16px"},className:"compose-box-content-editable","aria-placeholder":i,placeholder:null}),placeholder:jsx("div",{className:"compose-box-placeholder",children:i}),ErrorBoundary:LexicalErrorBoundary}),jsx(er,{}),jsx(Vi,{})]}):h})]}),jsx(Vc,{rightChildren:l,leftChildren:a,customTool:c,disabled:!!b})]}),jsx(HistoryPlugin,{}),jsx(Qi,{initialHTML:s}),jsx(Zi,{}),jsx(AutoFocusPlugin,{}),jsx(ListPlugin,{}),jsx(LinkPlugin,{}),jsx(Vi,{}),jsx(er,{}),jsx(qi,{onChange:g})]})})}var es=eS;function nS({emails:o=[],setEmails:e,fetchOptions:t}){let n=useRef(null),r=useRef(null),[i,s]=useState(""),[l,a]=useState(false),[c,d]=useState(-1),[u,h]=useState([]),[p,f]=useState(false),m=useRef([]),g=useRef([]);useEffect(()=>{m.current=m.current.slice(0,o.length);},[o.length]),useEffect(()=>{g.current=g.current.slice(0,u.length);},[u.length]),useEffect(()=>{xo(i)?(async()=>{f(true);try{let y=await t(i);h(y);}catch(y){console.error("Error fetching email options:",y),h([]);}finally{f(false);}})():(h([]),f(false));},[i,t]),useEffect(()=>{l||d(-1);},[l]),useEffect(()=>{c>=0&&c<g.current.length&&g.current[c]?.scrollIntoView({block:"nearest",behavior:"smooth"});},[c]);let b=()=>{r.current?.focus();},C=S=>{n.current?.close(),s(""),e(y=>[...y,S]),d(-1),requestAnimationFrame(()=>r.current?.focus());},x=S=>{if(l&&xo(i)&&u.length>0){if(S.key==="ArrowDown"){S.preventDefault(),d(y=>y<u.length-1?y+1:y);return}if(S.key==="ArrowUp"){S.preventDefault(),d(y=>y>0?y-1:-1);return}if(S.key==="Enter"&&c>=0){S.preventDefault(),C(u[c]);return}if(S.key==="Escape"){S.preventDefault(),n.current?.close(),d(-1);return}}if((S.key==="Enter"||S.key===",")&&xo(i)&&(S.preventDefault(),C({email:i,name:i})),S.key==="Backspace"&&i===""){let y=o.length-1,N=m.current[y];N&&(N.focus(),S.preventDefault());}},w=S=>{e(y=>{let N=[...y];return N.splice(S,1),N}),requestAnimationFrame(()=>{let y=Math.min(Math.max(0,S-1),o.length-2),N=m.current[y];N?N.focus():b();});};return jsx(Fragment,{children:jsx(jg,{ref:n,trigger:jsxs("div",{className:"container-receipts",children:[o?.length?jsx("div",{className:"emails-container",children:o.map((S,y)=>jsxs("div",{className:"emails",tabIndex:0,ref:N=>{m.current[y]=N;},onKeyDown:N=>{N.key==="Backspace"&&(N.preventDefault(),w(y)),N.key==="Enter"&&(N.preventDefault(),w(y),b());},role:"button","aria-label":`Email ${S.email}`,children:[jsx("span",{style:{marginRight:8},children:S.email}),jsx("button",{className:"emails-close",onClick:N=>{N.stopPropagation(),w(y);},"aria-label":`Remove ${S.email}`,children:jsx(B,{name:"Close"})})]},S.email??y))}):null,jsx("input",{ref:r,type:"text",className:"input-header",value:i,autoFocus:true,onKeyDown:x,onChange:S=>{let y=S.target.value;xo(y)&&n.current?.open(),s(y);}})]}),closeOnDocumentClick:true,repositionOnResize:true,position:"bottom left",className:"mail-inbox-popup",onOpen:()=>{a(true),requestAnimationFrame(()=>r.current?.focus());},onClose:()=>{a(false);},children:xo(i)?jsx("div",{className:"options-dropdown",children:p?jsx(Fragment,{children:[1,2,3].map(S=>jsxs("div",{className:"option-dropdown skeleton-loader",children:[jsx("div",{className:"skeleton-line skeleton-name"}),jsx("div",{className:"skeleton-line skeleton-email"})]},S))}):u.length>0?u.map((S,y)=>jsxs("button",{ref:N=>{g.current[y]=N;},className:`option-dropdown ${c===y?"selected":""}`,onBlur:N=>{N.stopPropagation();},onFocus:N=>{N.stopPropagation();},onMouseEnter:()=>d(y),onMouseLeave:()=>d(-1),onClick:N=>{N.stopPropagation(),C(S);},"aria-selected":c===y,children:[jsx("h4",{children:S.name}),S.email]},y)):null}):null})})}var od=nS;function rS({name:o,needCCAndBCC:e,setShowCC:t,setShowBCC:n,showBCC:r,showCC:i,emails:s,handleChange:l,fetchOptions:a}){return jsxs("div",{className:"container-receipts",children:[jsx("label",{className:"block text-sm font-medium",children:o}),jsx(od,{emails:s,setEmails:l,fetchOptions:a}),e&&!r?jsx("button",{className:"btn-mail-editor",onClick:()=>n?.(c=>!c),children:"Bcc"}):null,e&&!i?jsx("button",{className:"btn-mail-editor",onClick:()=>t?.(c=>!c),children:"Cc"}):null]})}var ir=rS;function aS({fetchEmailOptions:o}){let[e,t]=useState(false),n=useRef(null),{emails:r,setEmails:i,showCC:s,setShowCC:l,showBCC:a,setShowBCC:c}=it();return useEffect(()=>{e&&(l(r.cc.length>0),c(r.bcc.length>0));},[e,r.cc.length,r.bcc.length]),useEffect(()=>{let u=n.current;if(!u)return;let h=()=>{t(true);},p=f=>{console.log("\u{1F680} ~ handleFocusOut ~ e:",f);let m=f.relatedTarget;m&&m.classList&&m.classList.contains("option-dropdown")||m&&u.contains(m)||(console.log("why this ",m?.classList),t(false));};return u.addEventListener("focusin",h),u.addEventListener("focusout",p),()=>{u.removeEventListener("focusin",h),u.removeEventListener("focusout",p);}},[]),jsx("div",{ref:n,tabIndex:-1,className:"relative",children:e?jsxs("div",{children:[jsx(ir,{name:"To",needCCAndBCC:true,setShowCC:l,setShowBCC:c,showBCC:a,showCC:s,emails:r.to,handleChange:u=>{i(h=>({...h,to:typeof u=="function"?u(h.to):u}));},fetchOptions:o}),a?jsx(ir,{name:"Bcc",needCCAndBCC:false,setShowCC:l,setShowBCC:c,showBCC:a,showCC:s,emails:r.bcc,handleChange:u=>{i(h=>({...h,bcc:typeof u=="function"?u(h.bcc):u}));},fetchOptions:o}):null,s?jsx(ir,{name:"Cc",needCCAndBCC:false,setShowCC:l,setShowBCC:c,showBCC:a,showCC:s,emails:r.cc,handleChange:u=>{i(h=>({...h,cc:typeof u=="function"?u(h.cc):u}));},fetchOptions:o}):null]}):jsx("input",{type:"text",placeholder:"Recipients",className:"input-header",value:(()=>{if(r.to.length===0&&r.cc.length===0&&r.bcc.length===0)return "Recipients";let u=[];return r.to.length>0&&u.push(r.to.map(h=>h.email).join(", ")),r.cc.length>0&&u.push(r.cc.map(h=>h.email).join(", ")),r.bcc.length>0&&u.push("bcc: "+r.bcc.map(h=>h.email).join(", ")),u.join(", ")})(),readOnly:true})})}var rd=aS;var dS=({content:o,children:e,position:t="bottom center"})=>jsx(Je,{trigger:e,on:"hover",popUpDirection:t,children:()=>jsx("div",{className:"mail-inbox-tooltip-content mail-inbox-popup-content",style:{padding:"6px 10px",maxWidth:"400px",wordBreak:"break-word",whiteSpace:"pre-wrap",fontSize:"12px",borderRadius:"6px",backgroundColor:"#333",color:"#fff",zIndex:1e4,boxShadow:"0 2px 3px rgba(0, 0, 0, 0.2)"},children:o})}),sd=dS;function hS({fetchEmailOptions:o}){let{subject:e,setSubject:t,isReply:n}=it(),r=useRef(null),[i,s]=useState(false),l=n&&e&&!e.startsWith("Re: ")?`Re: ${e}`:e,c=(d=>{let u=document.createElement("textarea");return u.innerHTML=d||"",u.value})(l||"");return useLayoutEffect(()=>{let d=()=>{if(n&&r.current){let u=r.current,h=u.scrollWidth>u.clientWidth;s(h);}};return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[l,n]),jsxs("div",{className:"gmail-header",children:[jsx("div",{className:"receipt-heading",children:jsx(rd,{fetchEmailOptions:o})}),jsx("div",{className:"reply-heading",children:n?i?jsx(sd,{content:c,position:"bottom center",children:jsx("div",{ref:r,className:"subject-display",children:c})}):jsx("div",{ref:r,className:"subject-display",children:c}):jsx("input",{type:"text",placeholder:"Subject",className:"input-header",value:c,onChange:d=>t(d.target.value)})})]})}var ld=hS;function gS({initialData:o,isReply:e,fetchEmailOptions:t,handleChange:n,leftChildren:r,rightChildren:i,customTool:s,editorChildren:l,isEditorVisible:a=true,showOnlyBody:c=false,aiContentComponent:d,aiContent:u,showAiPreview:h,onAiInsert:p,onAiDiscard:f,placeholder:m,minHeight:g="400px"}){let{emails:b,subject:C,attachments:x,setEmails:w,setSubject:S,setAttachments:y,setIsReply:N}=it(),{theme:E}=rn(),[R,L]=useState(o?.body||""),[k,O]=useState({to:o?.to||[],cc:o?.cc||[],bcc:o?.bcc||[],subject:o?.subject||"",body:o?.body||"",attachments:o?.attachments||[],isReply:e||false});useEffect(()=>{o&&((o.to||o.cc||o.bcc)&&w({to:o.to||[],cc:o.cc||[],bcc:o.bcc||[]}),o.subject&&S(o.subject),o.attachments&&y(o.attachments),o.body&&L(o.body)),e!==void 0&&N(e);},[e]);let v=T=>{L(T);};return useEffect(()=>{O(T=>({...T,to:b.to,cc:b.cc,bcc:b.bcc}));},[b]),useEffect(()=>{O(T=>({...T,subject:C}));},[C]),useEffect(()=>{O(T=>({...T,body:R}));},[R]),useEffect(()=>{O(T=>({...T,attachments:x}));},[x]),useEffect(()=>{O(T=>({...T,isReply:e}));},[e]),useEffect(()=>{n(k);},[k,n]),jsx("div",{className:"react-mail-inbox-root gmail-wrapper","data-theme":E,children:jsxs("div",{className:"mail-inbox-internal",children:[c?null:jsx(ld,{fetchEmailOptions:t}),jsx(es,{initialHTML:o?.body,onChange:v,editorChildren:l,rightChildren:i,leftChildren:r,customTool:s,isEditorVisible:a,minHeight:g,placeholder:m,aiContentComponent:d,aiContent:u,showAiPreview:h,onAiInsert:p,onAiDiscard:f})]})})}var cd=gS;function CS({fetchEmailOptions:o,handleChange:e,initialData:t,leftChildren:n,rightChildren:r,customTool:i,isReply:s,showOnlyBody:l,googleDriveConfig:a,aiContentComponent:c,aiContent:d,showAiPreview:u,onAiInsert:h,onAiDiscard:p,placeholder:f,minHeight:m="400px"}){return jsx(is,{googleDriveConfig:a,children:jsx(cd,{fetchEmailOptions:o,handleChange:e,initialData:t,isReply:s,leftChildren:n,rightChildren:r,customTool:i,showOnlyBody:l,aiContentComponent:c,aiContent:d,showAiPreview:u,onAiInsert:h,onAiDiscard:p,placeholder:f,minHeight:m})})}var ud=CS;function SS({fetchEmailOptions:o,handleChange:e,initialData:t,initialTheme:n="dark",onThemeChange:r,leftChildren:i,rightChildren:s,customTool:l,showOnlyBody:a=false,isReply:c=false,googleDriveConfig:d,aiContentComponent:u,aiContent:h,showAiPreview:p,onAiInsert:f,onAiDiscard:m,placeholder:g,minHeight:b}){return jsx(ns,{initialTheme:n,onThemeChange:r,children:jsx(ud,{fetchEmailOptions:o,handleChange:e,initialData:t,leftChildren:i,rightChildren:s,customTool:l,showOnlyBody:a,isReply:c,googleDriveConfig:d,aiContentComponent:u,aiContent:h,showAiPreview:p,onAiInsert:f,onAiDiscard:m,placeholder:g,minHeight:b})})}var pd=SS;var mT=pd;
|
|
10
|
+
export{es as ComposeBox,pd as GmailInbox,mT as default,rn as useTheme};//# sourceMappingURL=index.js.map
|
|
11
11
|
//# sourceMappingURL=index.js.map
|