sykpcomposer 0.0.87 → 0.0.88

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.umd.js CHANGED
@@ -1426,7 +1426,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1426
1426
  animation: ${this.isEditingInProgress?rr.tooltipAnimations.hideAtOnce:rr.tooltipAnimations.hideWithDelay};
1427
1427
  left: ${n?"0px":"100%"};
1428
1428
  z-index: 10;
1429
- `,A.append(q),_=q}!R&&w.width<1&&r.length>1&&(A.style.width="3px")}v.forEach(x=>{this.hoverList.push([x,_,e])})});this.remoteSelections=[],this.isEditingInProgress=!1,this.hoverList=[],this.trackedNodesKeys=new Set,this.remoteSelectionDOMsMap={},this.activeEditorsKeys={},this.keyboardBindedListener=this._keyboardEventsListener.bind(this),this.mouseBindedListener=this._mouseEventsListener.bind(this),this.resizeBindedListener=this._resizeEventListener.bind(this),this.hideInUI=!1}_mouseEventsListener(c){let p=!1,t=c.target,f=!1,r=3;for(;r&&t;){if(t.__codox_track){p=!0;break}if(t.__lexicalEditor){p=!0,f=!0;break}t=t.parentNode,r--}if(!p)return;let n=null;for(let i in this.activeEditorsKeys){if(t[`__lexicalKey_${i}`]){n=i;break}t.__lexicalEditor&&(n=t.__lexicalEditor._key)}if(!n)return;let e=f?"root":t[`__lexicalKey_${n}`];if(!e||!this.trackedNodesKeys.has(`${e}__${n}`))return;let s=new Set;for(let i=0;i<this.hoverList.length;i++){let l=this.hoverList[i],[o,a,d]=l;if(s.has(d))continue;let u=rr.isMousePositionWithinElementCords(c,o);c.type===Sr.mouseover&&u&&(a.style.animation=this.isEditingInProgress?rr.tooltipAnimations.hideAtOnce:rr.tooltipAnimations.showAtOnce,s.add(d)),c.type===Sr.mouseout&&(a.style.animation=rr.tooltipAnimations.hideWithDelay,s.add(d)),c.type===Sr.mousemove&&u&&(a.style.animation=this.isEditingInProgress?rr.tooltipAnimations.hideAtOnce:rr.tooltipAnimations.showAtOnce,s.add(d))}}_keyboardEventsListener(c){c.type===Sr.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),c.type===Sr.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(c){Se.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(Sr.keypress,this.keyboardBindedListener),window.addEventListener(Sr.keyup,this.keyboardBindedListener),window.addEventListener(Sr.resize,this.resizeBindedListener),window.addEventListener(Sr.scroll,this.resizeBindedListener);for(const c of G0)window.addEventListener(c,this.mouseBindedListener)}unmount(){window.removeEventListener(Sr.keypress,this.keyboardBindedListener),window.removeEventListener(Sr.keyup,this.keyboardBindedListener),window.removeEventListener(Sr.resize,this.resizeBindedListener),window.removeEventListener(Sr.scroll,this.resizeBindedListener);for(const c of G0)window.removeEventListener(c,this.mouseBindedListener);this.gcPrevPaintedRemoteSelections()}shouldUpdateRemoteSelections(){return!0}gcPrevPaintedRemoteSelections(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];for(let p in this.remoteSelectionDOMsMap)this.remoteSelectionDOMsMap[p].remove();this.hoverList=[],this.trackedNodesKeys=new Set,this.remoteSelections=c||[],this.remoteSelectionDOMsMap={},this.activeEditorsKeys={}}paintRemoteSelections(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];this.gcPrevPaintedRemoteSelections(c);let p=Se.getMainEditorState();p.read&&p.read(()=>{for(let t of this.remoteSelections)if(gp.validateJSONSelection(t,dp.remote))if($e.isNestedSelectionJSON(t)){let{nestedSelectionJSON:f,nestedEditor:r}=$e.getNestedSelectionJSONFromMainSelectionJSON(t);if(!r)continue;r.getEditorState().read(()=>{let n=$e.JSONToLexical(f);if(n)try{this.paintSingleRemoteSelection({editor:r,selectionJSON:t,lexicalSelection:n,selectedNodes:n.getNodes(),isBackward:n.isBackward()})}catch(e){ue.warn("[PAINT REMOTE SELECTION] failed for nested editor - ",{error:e,nestedSelectionJSON:f,fullSelection:t,lexicalSelection:n})}else ue.error("DEBUGGER: [paintRemoteSelections] nested selection from json to lexical is null: ",{selection:t,nestedSelectionJSON:f,lexicalSelection:n})})}else{let f=$e.JSONToLexical(t);if(!f){ue.error("DEBUGGER: [paintRemoteSelections] selection from json to lexical is null: ",{selection:t,lexicalSelection:f});continue}try{this.paintSingleRemoteSelection({editor:Se.getMainEditor(),selectionJSON:t,lexicalSelection:f,selectedNodes:f.getNodes(),isBackward:f.isBackward()})}catch(r){ue.warn("[PAINT REMOTE SELECTION] failed - ",{error:r,fullSelection:t,lexicalSelection:f})}}})}updateRemoteSelections(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";this.shouldUpdateRemoteSelections(c)&&(ue.log("[updateRemoteSelections] "+p,{newRemoteSelections:c}),Promise.resolve().then(()=>{this.paintRemoteSelections(c),this.hideInUI&&this.hideRemoteSelectionsFromUI()}))}clear(){this.gcPrevPaintedRemoteSelections()}getCurrentRemoteSelections(){return this.remoteSelections}hideRemoteSelectionsFromUI(){this.hideInUI||(this.hideInUI=!0);const c=document.querySelectorAll(".codox_remote_selection");for(let p of c)p.classList.add("hidden_codox_remote_selection")}showHiddenRemoteSelectionsInUI(){this.hideInUI=!1;const c=document.querySelectorAll(".hidden_codox_remote_selection");for(let p of c)p.classList.remove("hidden_codox_remote_selection")}}const So=new OS;function TS(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(m=>m===Oa.editorState)}function Du(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,p=Se.getMainEditorNodesClassesMap();const{klass:t}=p.get(m.type)||{};if(!t)return;const f=t.importJSON(m);if(m.children&&m.children.length)for(const r of m.children)Du(r,f);return c&&c.getChildrenSize&&c.splice(c.getChildrenSize(),0,[f]),f}function Lu(m){if(m.getChildren)for(let c of m.getChildren())Lu(c);m.remove()}function py(m){m.__parent=null,m.__next=null,m.__prev=null}function hy(m,c){return!!Se.isLexicalEditorInstance(m)&&!(typeof c!="object"||!c.editorState||(m.update(()=>{try{let p=(0,_e.$getSelection)();const t=m.parseEditorState(c.editorState);if(t.isEmpty())return(0,_e.$getRoot)().clear(),!0;(0,_e.$setSelection)(p),m.setEditorState(t)}catch(p){ue.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",p)}}),0))}function AS(m,c){let p=c;for(const t of m)p=p[t];return p}function Aa(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,p=arguments.length>2&&arguments[2]!==void 0&&arguments[2],t=null,f=AS(m,p?c:Se.getMainEditorState().toJSON());return f&&(t=Pa(f)?(0,_e.$getRoot)():Nn.get(f.codoxId)),t||ue.debug("[WARNING][getLexicalNodeByPathOutOfJSONState] lexical node not found: ",{jsonNode:f,lexicalNode:t,pathArray:m,currentStateJSON:Se.getMainEditorState().toJSON(),newStateJSON:c,codoxNodes:Nn.nodesToArray(),searchInNewState:p}),t||(p?t:Aa(m,c,!0))}function gy(m){ue.log("[applyFullLexicalStateReplace] clear current state and apply new");const c=(0,_e.$getRoot)();c.clear();let p=Se.getMainEditorNodesClassesMap();function t(f){const r=p.get(f.type).klass.importJSON(f);if(f.children)for(const n of f.children)r.append(t(n));return r}for(const f of m.root.children)c.append(t(f))}function PS(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(c.length){ue.log("[applyDeltasToLexicalState] Original Deltas: ",{newStateJSON:m,deltas:JSON.parse(JSON.stringify(c))});for(const p of c){let{p:t}=p;const f=t[t.length-1],r=f==="children",n=typeof f=="number",e=!n&&!r,s=TS(t),i=s!==-1,l=p.hasOwnProperty("lm")&&typeof p.lm=="number";if(t.length)if(i){let o=s-1,a=Aa(t.slice(0,o),m);if(a){let d=t.slice(0,s),u=m;for(const h of d)u=u[h];let g=Gl(t[o]);hy(a.getWritable()[g],u)}}else{if(r){let o=p.oi;if(!o){ue.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi attr expected for path",{delta:p});continue}if(o.some(d=>!(!d.hasOwnProperty("text")||typeof d.text=="string"))){ue.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi children contain invalid text value",{delta:p});continue}t.length=t.length-1;let a=Aa(t,m);if(!a)continue;if(o.some(d=>!!d.codoxDId)){try{a=a.getWritable()}catch(h){ue.debug("[applyDeltasToLexicalState][shouldUpdateLeaves] getWritable error: ",{err:h,delta:p,fullStateJSON:m});continue}let d={};for(let h of a.getChildren())h.codoxDId?d[h.codoxDId]=h:Lu(h);let u=[],g=["codoxDId","codoxId","__key","__parent","__prev","__next"];for(let h=0;h<o.length;h++){let y=o[h],v=h===0,_=h===o.length-1,b=null,x=h>=0?u[h-1]:null;if(y.codoxDId){let w=d[y.codoxDId];if(w){w=w.getWritable();let S=Du(y);if(ue.debug("[DELTA_DECORATOR_UPDATE]: ",{exisingDecorator:w,tmpDecorator:S}),!S){ue.debug("[DELTA_DECORATOR_UPDATE] UPADATE SKIPPED: ",{exisingDecorator:w,tmpDecorator:S});continue}for(let C in S)if(S.hasOwnProperty(C)&&!g.includes(C))if(Se.isLexicalEditorInstance(S[C])){let k={editorState:S[C].getEditorState().toJSON()};hy(w[C],k)}else{let k=up(C),D=y[k];if(D===w[C]||!y.hasOwnProperty(k))continue;let N=D!==void 0&&S[C]!==D?D:S[C];k!=="height"&&k!=="width"||S[C]==="inherit"&&D===0&&(N=S[C]),w[C]=N}S.remove(),py(w),b=w,delete d[y.codoxDId]}}b||(b=Du(y),b.codoxDId&&b.__type==="excalidraw"&&b.__data==="[]"&&(b.__data="{}")),b=b.getWritable(),u.push(b),b.__parent=a.__key,v?(a.__first=b.__key,b.__prev=null,_&&(a.__last=b.__key)):_?(a.__last=b.__key,b.__next=null,b.__prev=x.__key,x.__next=b.__key):(b.__prev=x.__key,x.__next=b.__key),a.__size=u.length}for(let h in d){let y=d[h];y=y.getWritable(),py(y),Lu(y),delete d[h]}}else{let d=o.map(u=>Du(u));a.splice(0,a.getChildrenSize(),d)}}if(n){if(p.ld){const o=p.ld,a=Nn.get(o.codoxId);a.getChildrenSize&&a.getChildrenSize()?Lu(a):a.remove()}if(p.li){let o=Se.getMainEditorNodesClassesMap();const a=p.li,d=o.get(a.type).klass.importJSON(a);if(t.length===1&&t[0]==="root")(0,_e.$getRoot)().splice(0,0,[d]);else{const u=t[t.length-1];t.length=t.length-2;let g=Aa(t,m);g&&g.splice(u,0,[d])}if(a.children&&a.children.length){let u=function(g,h){const y=o.get(g.type).klass.importJSON(g);if(h.splice(h.getChildrenSize(),0,[y]),g.children&&g.children.length)for(const v of g.children)u(v,y)};for(const g of a.children)u(g,d)}}if(p.oi||p.od){let{p:o,oi:a,od:d}=p,u=Aa(o,m);if(u)try{let g=u.getWritable();if(a){let h=Object.keys(a);for(let y of h)g[Gl(y)]=a[y]}if(d){let h=Object.keys(d);for(let y of h)delete g[Gl(y)]}}catch(g){ue.debug("[applyDeltasToLexicalState][delta oi/od] getWritable error: ",{err:g,delta:p})}}if(l){let{p:o,lm:a}=p,d=o[o.length-1],u=a,g=u<d,h=Aa(o,m);if(h){let y=h.getParent().getChildren(),v=y[d],_=y[u];g?_.insertBefore(v):_.insertAfter(v)}}}if(e){const o=t[t.length-1];let a=Gl(o);t.length=t.length-1;let d,u=Aa(t,m);if(!u){ue.error("Missing node when update node attr from delta: ",{path:t,delta:p,fullStateJSON:m,currentEditorState:Se.getMainEditorState().toJSON()});continue}try{d=u.getWritable()}catch(h){ue.debug("[applyDeltasToLexicalState][shouldUpdateBlockAttr] getWritable error: ",{err:h,delta:p})}if(!d)continue;let g=p.oi;if(o==="format"&&(g=Aw(g)),o==="direction"&&(u.hasOwnProperty(a)||(a="__dir")),!d.hasOwnProperty(a)){let h=Object.keys(d);for(let y of h){let v=up(y);if(o.startsWith(v)){a=y;break}}}d[a]=g}}else if(p.oi&&p.oi.root)return gy(p.oi)}}else ue.log("[applyDeltasToLexicalState] stop, no deltas: ",c)}function jS(m){let c=m.clipboardData.getData(jw.paste),p=!1;try{c=JSON.parse(c),typeof c=="object"&&c.nodes&&Array.isArray(c.nodes)&&(p=!0)}catch{return!1}if(!p)return!1;if(p){Nn.clearPastedIds();const t=f=>{if(f.codoxId&&Nn.addPastedId(f.codoxId),f.children&&f.children.length)for(const r of f.children)t(r)};for(const f of c.nodes)t(f)}return!1}var NS=m=>{var c={};return on.d(c,m),c};const my=NS({useCollaborationContext:()=>Wx});var IS=m=>{var c={};return on.d(c,m),c};const Ki=IS({LexicalComposerContext:()=>Kf,useLexicalComposerContext:()=>hr});class yy{constructor(){this.blacklist=Object.keys(Y0).reduce((c,p)=>{let t=Y0[p];return c[p]=t.reduce((f,r)=>(f[r]=r,f),{}),c},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(c){return c instanceof _e.TextNode||c instanceof _e.ParagraphNode||c instanceof _e.RootNode}setClientCallback(c){this._clientCallback=c}removeClientCallback(){this._clientCallback=null}invokeClientCallback(){this._clientCallback&&this._clientCallback()}trackBlacklisted(c){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>2?arguments[2]:void 0;if(mp||p!==Yr.created||this._isBlacklistedFound||!c||!c.__type||this._shouldSkipNode(c))return;let f=t||Se.getMainEditorState(),r=c.__type,n=this.blacklist[r];n&&f.read(()=>{let e=c.getParent();for(;e!==null;){let s=e?e.__type:null;if(!s)return;if(n[s])return ue.warn("[ContentNestingsWatcher][trackBlacklisted] FOUND: ",{targetNode:c,targetType:r,parent:e,parentType:s,mutationType:p}),void(this._isBlacklistedFound=!0);e=e.getParent()}})}trackBlacklistedInNestedEditor(c){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>3?arguments[3]:void 0;if(p!==Yr.created||this._isBlacklistedFound||this._shouldSkipNode(c))return;let f=t.__type,r=c.__type;if(!f||!r)return;let n=this.blacklist[r];n&&n[f]&&(this._isBlacklistedFound=!0,ue.warn("[ContentNestingsWatcher][trackBlacklistedInNestedEditor] FOUND: ",{targetNode:c,targetType:r,rootNode:t,rootType:f,mutationType:p}))}isBlacklistedFound(){let c=this._isBlacklistedFound;return c&&(this._isBlacklistedFound=!1),c}}const RS=new yy,Gi=RS,MS=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function DS(m,c){if(m==null)return{};var p,t,f=LS(m,c);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(m);for(t=0;t<r.length;t++)p=r[t],c.indexOf(p)>=0||{}.propertyIsEnumerable.call(m,p)&&(f[p]=m[p])}return f}function LS(m,c){if(m==null)return{};var p={};for(var t in m)if({}.hasOwnProperty.call(m,t)){if(c.indexOf(t)>=0)continue;p[t]=m[t]}return p}class BS{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(c,p){let t=!1;return function(f){let{editorState:r,prevEditorState:n,dirtyElements:e,dirtyLeaves:s}=f,i=(DS(f,MS),Se.getMainEditor()),l=Se.getMainEditorState(),o=r.toJSON(),a=n.toJSON(),d=hp(o,a),u=r._selection,g=n._selection,h=!1,y=null,v=Se.isOnlySelectionChanged(e,s),_=c[p];if(ue.debug("[NESTED EDITOR LISTENER] invoked: ",{lexicalNode:c,key:c.__key,onlySelectionChanged:v,newEditorStateJSON:o,prevEditorStateJSON:a,isSameState:d,lexicalSelection:u,prevLexicalSelection:g,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,nestedEditorKey:_._key}),Gi.isBlacklistedFound())return t=!0,ue.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),Se.scanLexicalNodeForNestedEditorAttribute(c)?(_.update(()=>{try{const b=_.parseEditorState(a);if(b.isEmpty())return(0,_e.$getRoot)().clear(),!0;_.setEditorState(b)}catch(b){ue.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",b)}}),void Gi.invokeClientCallback()):void 0;if(t)t=!1;else{if(c.codoxId||c.codoxDId){let b=null;l.read(()=>{b=$e.getNodeAncestorsCodoxIds(c),!c.codoxId&&c.codoxDId&&b.push(c.codoxDId)}),r.read(()=>{let x=up(p),w=$e.lexicalToJSONNested(u,x,b);y=Se.getCurrentNestedSelectionJSON(),h=$e.equalSelectionsJSON(y,w),h||Se.setNestedSelectionJSON(w)})}d&&h||i.update(()=>{try{ue.debug("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE",{mainTags:i._updateTags,nestedTags:_&&_._updateTags,isSameState:d,isSameSelection:h,onlyNestedSelectionChanged:v,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,lexicalNode:c,lexicalSelection:u,prevLexicalSelection:g,mainEditorTags:i._updateTags,mainEditorTagsSize:i._updateTags.size}),Se.addUpdateTag({fromNestedEditor:!0}),c.markDirty()}catch(b){ue.error("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE - ERROR: ",b)}})}}}_isNestedEditorManaged(c){return!!this.nestedEditorsListenersMap[c]}gc(){for(let c in this.nestedEditorsListenersMap)if(!Se.getLexicalNodeByKey(c)){let p=this.nestedEditorsListenersMap[c];p&&p(),delete this.nestedEditorsListenersMap[c]}}manageNestedEditorInLexicalNode(c){if(this._isNestedEditorManaged(c.getKey()))return;let p=Se.scanLexicalNodeForNestedEditorAttribute(c);if(p){let t=c[p],f=this._createNestedEditorUpdatesListener(c,p),r=[];t._nodes.forEach((s,i,l)=>{let{klass:o}=s,a=t.registerMutationListener(o,d=>{for(let[u,g]of d)if(g===Yr.created){let h=t.getEditorState()._nodeMap.get(u);h&&Gi.trackBlacklistedInNestedEditor(h,g,t.getEditorState(),c)}});r.push(a)});let n=(0,Os.mergeRegister)(t.registerUpdateListener(f),...r),e=c.getKey();this.nestedEditorsListenersMap[e]=n}}gcNestedEditorListenerInLexicalNode(c){let p=c.getKey(),t=this.nestedEditorsListenersMap[p];t&&(t(),delete this.nestedEditorsListenersMap[p])}manageNestedEditorInClonedLexicalNode(c,p){let t=c.getKey();t!==p.getKey()&&this._isNestedEditorManaged(t)&&(this.gcNestedEditorListenerInLexicalNode(c),this.manageNestedEditorInLexicalNode(p))}setNestedEditorSelection(c){let{nestedSelectionJSON:p,nestedEditor:t}=$e.getNestedSelectionJSONFromMainSelectionJSON(c);if(!t)return!1;let f=!0;return t.update(()=>{try{let r=$e.JSONToLexical(p);(0,_e.$setSelection)(r),ue.debug("[setNestedEditorSelection]: lexical nested selection: ",r)}catch(r){ue.error("[setNestedEditorSelection] set nested selection error: ",r),f=!1}}),f}clearListeners(){for(let c in this.nestedEditorsListenersMap){let p=this.nestedEditorsListenersMap[c];p&&p(),delete this.nestedEditorsListenersMap[c]}}}const FS=new BS,di=FS,zS=function(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let p=(0,_e.createEditor)({namespace:"validation",nodes:[...c],onError:e=>{throw e},parentEditor:null});const t=new yy,f=p.parseEditorState(m);if(f.isEmpty())return;p.setEditorState(f);let r=p.getEditorState();const n=r._nodeMap[Symbol.iterator]();for(const e of n){let[s,i]=e;if(i&&(t.trackBlacklisted(i,Yr.created,r),t.isBlacklistedFound()))throw new Error(Nw)}}catch(p){throw p}};class US{constructor(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}_scanForCellHeaderState(c,p,t,f){if(p.length<f)return null;let r,n=p.some(s=>s.__headerState===Ji.BOTH||s.__headerState===Ji.ROW),e=c.some((s,i)=>{if(s.__size<f)return!1;let l=s.getChildAtIndex(t);return!(!l||l.__headerState!==Ji.BOTH&&l.__headerState!==Ji.COLUMN)});return n&&e?r=Ji.BOTH:n&&!e?r=Ji.ROW:e&&!n&&(r=Ji.COLUMN),r}_isValidCellChildren(c){for(let p of c)if(Is(p)||!Ns(p)&&Tn(p))return!1;return!0}_createEmptyCell(){let c=(0,An.$createTableCellNode)();return c.append((0,_e.$createParagraphNode)()),c}_wrapInvalidCellChildrenIntoParagraph(c){let p=(0,_e.$createParagraphNode)().getWritable(),t=c.getChildren();(c=c.getWritable()).__first=p.__key,c.__last=p.__key,c.__size=1,p.__parent=c.__key,t.forEach((f,r)=>{(f=f.getWritable()).__parent=null,p.append(f)})}_createFixAction_APPEND_CELLS_TO_ROW(c,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - APPEND_CELLS_TO_ROW] invoked: ",{rowKey:c,numOfCellsToAppend:p});let t=(0,_e.$getNodeByKey)(c);for(;p;){let f=(0,An.$createTableCellNode)().append((0,_e.$createParagraphNode)());f.setRowSpan(1).setColSpan(1),t.append(f),p--}}}_createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(c){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - ADD_PARAGRAPH_TO_EMPTY_CELL] invoked: ",{cellKey:c}),(0,_e.$getNodeByKey)(c).append((0,_e.$createParagraphNode)())}}_createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(c){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_CELL_CHILDREN_IN_PARAGRAPH] invoked: ",{cellKey:c});let p=(0,_e.$getNodeByKey)(c);this._wrapInvalidCellChildrenIntoParagraph(p)}}_createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(c){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - ADD_ROW_CELL_TO_EMPTY_TABLE_NODE] invoked: ",{tableKey:c});let p=(0,_e.$getNodeByKey)(c),t=(0,An.$createTableRowNode)();t.append(this._createEmptyCell()),p.append(t)}}_createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(c,p){return()=>{for(p||(p=1);p;)(0,_e.$getNodeByKey)(c).append(this._createEmptyCell()),p--}}_createFixAction_WRAP_INVALID_ROW_NODE(c,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_ROW_NODE] invoked: ",{tableKey:c,rowKey:p});let t=(0,_e.$getNodeByKey)(c);if(!t)return;let f=(0,_e.$getNodeByKey)(p);if(!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling();f.__parent=null,f.__prev=null,f.__next=null;let e=(0,An.$createTableRowNode)();if((0,An.$isTableCellNode)(f))f.getChildren().length?this._isValidCellChildren()||this._wrapInvalidCellChildrenIntoParagraph(f):f.append((0,_e.$createParagraphNode)()),e.append(f);else{let s=this._isValidCellChildren([f]),i=(0,An.$createTableCellNode)();if(e.append(i),s)i.append(f);else{let l=(0,_e.$createParagraphNode)();l.append(f),i.append(l)}}e.__parent=t.__key,t.__first===f.__key&&(t.__first=e.__key),t.__last===f.__key&&(t.__last=e.__key),r&&(r=r.getWritable(),r.__next=e.__key,e.__prev=r.__key),n&&(n=n.getWritable(),n.__prev=e.__key,e.__next=n.__key)}}_createFixAction_WRAP_INVALID_CELL_NODE(c,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_CELL_NODE] invoked: ",{rowKey:c,cellKey:p});let t=(0,_e.$getNodeByKey)(c);if(!t)return;let f=(0,_e.$getNodeByKey)(p);if(f.remove(),f=(0,_e.$createParagraphNode)(),!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling(),e=(0,An.$createTableCellNode)();if(e.__parent=t.__key,t.__first===f.__key&&(t.__first=e.__key),t.__last===f.__key&&(t.__last=e.__key),r&&(r=r.getWritable(),r.__next=e.__key,e.__prev=r.__key),n&&(n=n.getWritable(),n.__prev=e.__key,e.__next=n.__key),f.__parent=null,f.__prev=null,f.__next=null,this._isValidCellChildren([f]))e.append(f);else{let s=(0,_e.$createParagraphNode)();s.append(f),e.append(s)}}}_createFixAction_APPLY_HEADER_STATE_TO_CELL(c,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - APPLY_HEADER_STATE_TO_CELL] invoked: ",{cellKey:c,headerStateToApply:p});let t=(0,_e.$getNodeByKey)(c);t&&(t=t.getWritable(),t.__headerState=p)}}clear(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}tableRemoveEventListener(c){let p=Se.getMainEditorState()._selection;if(ue.debug(`[${c}]`,{selection:p}),!(0,_e.$isRangeSelection)(p))return;let t=[];try{let f=Se.getLexicalNodeByKey(p.anchor.key),r=Se.getLexicalNodeByKey(p.focus.key);f&&r&&(t=p.isBackward()?r.getNodesBetween(f):f.getNodesBetween(r))}catch(f){ue.warn("[TablesValidator][tableRemoveEventListener] get range selection nodes internal lexical error: ",f)}t.forEach(f=>{(0,An.$isTableNode)(f)&&this.removeCandidateTableKeys.add(f.__key)})}tableNodeRemoveListener(c){this.removeCandidateTableKeys.has(c)&&this.removeCandidateTableKeys.delete(c)}shouldGCRemovedTables(){return!!this.removeCandidateTableKeys.size}gcRemovedTables(){ue.debug("[TablesValidator][gcRemovedTable] candidate table keys ",{tableKeys:this.removeCandidateTableKeys}),Se.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(c=>{let p=(0,_e.$getNodeByKey)(c);p&&p.remove()}),this.removeCandidateTableKeys.clear(),(0,_e.$addUpdateTag)(ao.historic)})}tableUpdateListener(c){this.validateTableCandidateKeys.add(c)}tableRowNodeChangesListener(c){let p=arguments.length>1&&arguments[1]!==void 0&&arguments[1],t=Se.getLexicalNodeByKey(c);if(!t)return void(p&&ue.debug("[TablesValidator][tableRowNodeChangesListener] no row node found in lexical: ",{tableRowNodeKey:c}));let f=t.__parent;f?this.validateTableCandidateKeys.add(f):ue.debug("[tableRowNodeChangesListener] no parent table for row node found in lexical: ",{rowNode:t})}tableCellNodeChangesListener(c){let p=Se.getLexicalNodeByKey(c);if(!p||!p.__parent)return;let t=Se.getLexicalNodeByKey(p.__parent);t&&t.__parent&&this.validateTableCandidateKeys.add(t.__parent)}shouldValidateUpdatedTables(){return!!this.validateTableCandidateKeys.size}validateUpdatedTables(){let c=Array.from(this.validateTableCandidateKeys);return Se.getMainEditorState().read(()=>{for(let p of c){let t=Se.getLexicalNodeByKey(p);if(!t)continue;let f=t.getChildren();if(!f.length){this.tableFixActions.push(this._createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(p));continue}let r=0;f.forEach(i=>{i.__size>r&&(r=i.__size)});let n=[],e=f.map((i,l)=>{if(!(0,An.$isTableRowNode)(i))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_ROW_NODE(p,i.__key)),"invalid_row_node";let o=i.getChildren();if(!o.length&&!n.length)return this.tableFixActions.push(this._createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(i.__key,r)),"empty_row_should_add_cell";if(!o.length&&n.length)return n=[],"empty_row_should_be_empty";let a=0;if(n.length){let u=[];n.forEach(g=>{let[h,y]=g;a+=y,h--,h&&u.push([h,y])}),n=[...u]}let d=o.map((u,g)=>{if(!(0,An.$isTableCellNode)(u))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_CELL_NODE(i.__key,u.__key)),a++,"invalid_cell_node_should_wrap_in_cell";let h,y=u.getChildren(),v=!y.length;if(v?this.tableFixActions.push(this._createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(u.__key)):(h=this._isValidCellChildren(y),h||this.tableFixActions.push(this._createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(u.__key))),u.__rowSpan>1){let _=u.__rowSpan,b=u.__colSpan;n.push([_-1,b])}if(a+=u.__colSpan,u.__headerState===Ji.NO_STATUS){let _=this._scanForCellHeaderState(f,o,g,r);_&&this.tableFixActions.push(this._createFixAction_APPLY_HEADER_STATE_TO_CELL(u.__key,_))}return{cellKey:u.__key,rowKey:i.__key,tableKey:p,colSpan:u.__colSpan,rowSpan:u.__rowSpan,headerState:u.__headerState,childrenAreValid:h,isEmptyCell:v}});if(a<r){let u=r-a;this.tableFixActions.push(this._createFixAction_APPEND_CELLS_TO_ROW(i.__key,u))}return{realRowLength:a,rowKey:i.__key,tableKey:p,cells:d}}),s=!this.tableFixActions.length;ue[s?"debug":"warn"](`[TablesValidator][validateUpdatedTables] IS TABLE VALID: ${s}`,{tableNodeKey:p,tableValidationMatrix:e,requiredRowLength:r}),this.validateTableCandidateKeys.delete(p)}}),!this.tableFixActions.length}shouldFixTablesStructure(){return!!this.tableFixActions.length}fixTablesStructure(){if(!this.tableFixActions.length)return;let c=Se.getMainEditor();ue.log("[TablesValidator][fixTablesStructure]: fix actions to apply - count: ",this.tableFixActions.length),c.update(()=>{for(let p of this.tableFixActions)p();this.tableFixActions=[],(0,_e.$addUpdateTag)(ao.historic)})}ensureDocTablesAreValid(c){return this.shouldGCRemovedTables()?(ue.warn("[TablesValidator][GARBAGE COLLECT TABLE NODES AFTER TABLE REMOVAL ATTEMPT]"),this.gcRemovedTables(),!1):!(this.shouldValidateUpdatedTables()&&(ue.debug("[TablesValidator][shouldValidateUpdatedTables] invoked"),!this.validateUpdatedTables()))||(ue.warn("[TablesValidator][shouldValidateUpdatedTables] INVALID LEXICAL TABLE(S) STRUCTURE FOUND - FIXING",{state:JSON.parse(JSON.stringify(c.toJSON()))}),this.fixTablesStructure(),!1)}}const Ro=new US,$S=["contentChanged"],HS=["state","remoteSelection"];function vy(m,c){var p=Object.keys(m);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(m);c&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(m,f).enumerable})),p.push.apply(p,t)}return p}function Ps(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?vy(Object(p),!0).forEach(function(t){qS(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):vy(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function qS(m,c,p){return(c=WS(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function WS(m){var c=JS(m,"string");return typeof c=="symbol"?c:c+""}function JS(m,c){if(typeof m!="object"||!m)return m;var p=m[Symbol.toPrimitive];if(p!==void 0){var t=p.call(m,c||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(m)}function by(m,c){if(m==null)return{};var p,t,f=VS(m,c);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(m);for(t=0;t<r.length;t++)p=r[t],c.indexOf(p)>=0||{}.propertyIsEnumerable.call(m,p)&&(f[p]=m[p])}return f}function VS(m,c){if(m==null)return{};var p={};for(var t in m)if({}.hasOwnProperty.call(m,t)){if(c.indexOf(t)>=0)continue;p[t]=m[t]}return p}const mp={DEBUG:!1,VERSION:"1.0.2",NAME:"@codoxhq/lexical-provider",SDKUI_SOURCE_PATH:"../../../sdkui/dist-production2/codox.bundle.js"}.LOCAL==="true";ue.info("MODE: ","production");const KS=m=>async()=>{const{state:c,timestamp:p}=await m();if(!Se.isValidJSONState(c))throw new Error("Invalid state received from fetchDocOnNetworkReconnect hook");const{commentThreads:t,root:f}=c,r={content:{comments:t,root:f},timestamp:p};return ue.info("[decorateFetchOnReconnctHook] hook invoked: ",{returnObj:r}),r};let Bu=0,fi=null,yp=!1,Eo={},vp={};const GS=(0,Gt.forwardRef)((m,c)=>{let{onBlacklistedInsert:p}=m;const t=(0,Gt.useContext)(Ki.LexicalComposerContext);if(!t)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[f]=(0,Ki.useLexicalComposerContext)(),r=(0,my.useCollaborationContext)();(0,Gt.useEffect)(()=>{if(ue.debug("[INIT] lexical context check: ",{lexicalContext:t,editor:f}),!f)return;ue.log("[useEffect][editor] Editor instance changed: ",{editor:f,key:f._key}),Se.setMainEditor(f),Nn.gcAbandonedNodes(),di.gc(),Ro.clear(),ue.log("[useEffect][editor] subscribe to editor changes");const v=(0,Os.mergeRegister)(f.registerUpdateListener(g),f.registerCommand(_e.PASTE_COMMAND,jS,_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.UNDO_COMMAND,()=>{Se.setUndoInvoked(!0)},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.REDO_COMMAND,()=>{Se.setRedoInvoked(!0)},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.KEY_DELETE_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("KEY_DELETE_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.KEY_BACKSPACE_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.CUT_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("CUT_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),...h());So.mount(),Se.alignStateSelectionJSONsFromLatestEditor(),ue.debug("New editor mounted: ",{isCodoxStarted:Se.isCodoxStarted,codoxLexicalEditorManager:Se,nestedEditorsProcessor:di});let _=f._onError;return f._onError=b=>{ue.error("[ERROR HANDLER WRAPPER] error from editor: ",b),_&&_(b),u()},p&&Gi.setClientCallback(p),()=>{Se.getMainEditorKey()&&(ue.debug("Unmount prev editor"),v(),Se.removeMainEditor(),So.unmount(),Se.clearJSONs(),On.clear(),Ro.clear(),Se.isCodoxStarted&&(ue.debug("EDITOR USE_EFFECT stopping codox"),n(),Se.setIsCodoxStarted(!1)),Gi.removeClientCallback())}},[f]);const n=()=>{Se.isCodoxStarted&&(ue.log("[stopCodoxInstance] stopping codox"),Se.setIsCodoxStarted(!1),mp||oi().stop(),Se.clearJSONs(),Nn.clearAll(),So.clear(),On.resetComments(),di.clearListeners())},e=async v=>{ue.debug("[startCodoxInstance] invoked"),oi().createNewInstance(),ue.debug("[startCodoxInstance] instance created");for(let O in vp)oi().instance.on(O,vp[O]);if(ue.debug("[startCodoxInstance] events subscribed"),Eo=v,fi=Eo.docId,!fi)return ue.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:fi});let _=On.initialCommentsExist();ue.debug("[startCodoxInstance] initCommentsExist: ",_),_&&(On.activateInitialComments(f,Nn),ue.log("[activateInitialComments] "));let b=Se.getMainEditorState().toJSON();if(!Se.isValidJSONState(b))throw ue.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:fi,initJSONState:b}),new Error("start codox skipped - invalid init state");ue.log("[startCodoxInstance] starting codox with: ",{docId:fi,initJSONState:b,config:Eo,codoxComments:On}),Se.currentContentStateJSON||Se.setCurrentContentStateJSON(b),Se.isCodoxStarted&&n();let{username:x,apiKey:w,getServerState:S,domain:C="",demo:k=!1,hooks:D}=Eo;D&&D.fetchDocOnNetworkReconnect&&(D.fetchDocOnNetworkReconnect=KS(D.fetchDocOnNetworkReconnect));const N=by(D,$S);await oi().start(oi().createConfig(Ps(Ps({},Eo),{},{docId:fi,username:x,apiKey:w,domain:C,hooks:Ps({syncState:l,getState:i,getServerState:async()=>await S(fi)},N),editorInstanceHooks:{getSelection:()=>Se.getCurrentActiveSelectionJSON(),setSelection:O=>o(O),getState:i,setState:O=>{const{root:R,comments:A}=O;ue.info("DEBUG: EDITOR INSTANCE setState:",{fullState:O}),a({state:{root:R},selection:Se.getCurrentActiveSelectionJSON()},So.getCurrentRemoteSelections()),On.setAllComments(A)},enableEditor:()=>{Se.disableEditorReadOnlyMode()},disableEditor:()=>{Se.enableEditorReadOnlyMode(),So.updateRemoteSelections([])},getContent:()=>{let O=Se.composeFullStateWithRootAndComments();return ue.info("[getContent]: ",O),{state:O}}},appServer:Eo.appServer,demo:k}))),ue.log("[startCodoxInstance] codox started - first sync invoking"),Se.setIsCodoxStarted(!0),r.clientID=Eo.username,r.name=Eo.username,d()},s=()=>{let v=Se.composeFullStateWithRootAndComments({directlyFromEditor:!0});e(v)},i=()=>({state:Ps(Ps({},Se.getMainEditorState().toJSON()),{},{comments:On.getAllComments()}),docId:fi}),l=v=>{if(!Se.isCodoxStarted)return;ue.log("[SYNC_STATE]: Before sync payload = ",v);const _=oi().sync({meta:v}),{state:b,remoteSelection:x=[]}=_,w=by(_,HS);if(ue.log("[SYNC_STATE]: After sync",{state:b,remoteSelection:x,rest:w}),!b)return ue.error("[SYNC_STATE] abort apply - synced state is not valid - restarting codox"),s();const S=b.state;ue.log("[SYNC_STATE] synced state: ",{synced:JSON.parse(JSON.stringify(S))});let{stateFromSync:C,commentsFromSync:k}=Se.extractStateAndCommentsFromSynced(S);if(!Se.isValidJSONState(C.state))return ue.error("[SYNC_STATE] - invalid state from sync - local update skipped - restarting codox",{contentState:C.state}),s();a(C,x),On.setAllComments(k)},o=v=>{if(!Se.isCodoxStarted||(ue.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:v}),!gp.validateJSONSelection(v,dp.local)))return;let _=Se.getCurrentActiveSelectionJSON();if($e.equalSelectionsJSON(_,v))return void ue.log("[setLocalSelectionFromSync] STOP - local and synced selections are equal");let b=$e.isNestedSelectionJSON(v);f.update(()=>{ue.log("[setLocalSelectionFromSync] json selection to apply: ",{syncedSelectionJSON:v});const x=$e.JSONToLexical(v);if(ue.log("[setLocalSelectionFromSync] lexical selection to apply: ",x),b){let w=di.setNestedEditorSelection(v);Se.setNestedSelectionJSON(w?v:null)}else(0,_e.$setSelection)(x),Se.setMainSelectionJSON(v);ue.log("[setLocalSelectionFromSync] selection updated. latest selection: ",{latestSelectionJSON:Se.getCurrentActiveSelectionJSON()})})},a=function(){let{state:v,selection:_,stateReplace:b}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",S=Se.getCurrentContentStateJSON();ue.log("[updateEditor] invoked: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:JSON.parse(JSON.stringify(v)),newSelectionJSON:_,remoteSelection:x,stateReplace:b,editor:f}),_===void 0&&ue.error("SELECTION FROm SYNC IS UNDEFINED - will default prev selection",_);const C=hp(S,v),k=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),_);f.update(()=>{if(Se.addUpdateTag({isSameState:C,isSameSelection:k,updateTag:w}),b)ue.log("[updateEditor] invoke full stateReplace after sync"),gy(v),S=Se.setCurrentContentStateJSON(v),(0,_e.$addUpdateTag)("codox_sync_state_changes"),ue.log("[updateEditor] state updated: ",S);else{ue.log("[updateEditor] invoke deltas diff");let N=oi().diff(S,v,{keyNames:{default:"codoxId"}});ue.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:v,deltas:N&&JSON.parse(JSON.stringify(N))}),N&&N.length&&(ue.log("[updateEditor] apply deltas to lexical state"),PS(v,N),S=Se.setCurrentContentStateJSON(v),(0,_e.$addUpdateTag)("codox_sync_state_changes"),ue.log("[updateEditor] state updated: ",S))}let D=$e.isNestedSelectionJSON(_);if(gp.validateJSONSelection(_,dp.local)||(_=Se.getCurrentActiveSelectionJSON()),D){let N=di.setNestedEditorSelection(_);Se.setNestedSelectionJSON(N?_:null),ue.log("[updateEditor] nested selection updated",N?_:null)}else if(_!==void 0){const N=$e.JSONToLexical(_);ue.log("[updateEditor] updated selection to apply: ",{isSameSelection:k,newSelectionJSON:_,lexicalSelection:N}),(0,_e.$setSelection)(N),Se.setMainSelectionJSON(_),ue.log("[updateEditor] selection updated",_)}},{onUpdate:()=>{C||So.updateRemoteSelections(x,"from onUpdate hook")}}),C&&So.updateRemoteSelections(x,"from direct updateEditor")},d=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";if(!Se.isCodoxStarted)return;ue.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:v});let _=Se.composeFullStateWithRootAndComments();const b={docId:fi,state:{state:_,selection:Se.getCurrentActiveSelectionJSON()}};ue.log("[codoxSync]: Before sync",{local:b,upd_call_counter:v}),ue.log("[codoxSync]: Before sync state",JSON.parse(JSON.stringify(b.state)));let{state:x,remoteSelection:w=[],changes:S}=oi().sync({state:b,meta:{}});if(ue.log("[codoxSync]: After sync",{afterSyncState:JSON.parse(JSON.stringify(x)),remoteSelection:w,changes:S}),!x)return ue.error("[codoxSync] abort apply - synced state is not valid - restarting codox "),s();const C=x.state;ue.log("[codoxSync]: synced state: ",JSON.parse(JSON.stringify(C)),v);let{stateFromSync:k,commentsFromSync:D}=Se.extractStateAndCommentsFromSynced(C);if(!Se.isValidJSONState(k.state))return ue.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:k.state}),s();a(k,w),On.setAllComments(D)},u=()=>{ue.warn("[rollbackStateDuringUpdateError] rollback invoked"),ue.log("[rollbackStateDuringUpdateError] values: ",{prevState:Se.getPrevContentStateJSON(),currentState:Se.getCurrentContentStateJSON(),prevSelection:Se.getPrevMainSelectionJSON(),currentSelection:Se.getCurrentActiveSelectionJSON(),codoxComments:On});let v=Se.getPrevContentStateJSON(),_=Se.getPrevMainSelectionJSON();a({state:v,selection:_},So.getCurrentRemoteSelections(),ao.historic);let b=Se.undoInvoked(),x=Se.redoInvoked();On.gcAbandonedNodeKeys(Se.getMainEditorState()._nodeMap),b&&f.dispatchCommand(_e.CAN_REDO_COMMAND,!1),x&&f.dispatchCommand(_e.CAN_UNDO_COMMAND,!1)},g=v=>{let{editorState:_,prevEditorState:b,tags:x,dirtyElements:w,dirtyLeaves:S}=v;if(yp)return yp=!1,void ue.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(Gi.isBlacklistedFound())return yp=!0,ue.warn("[editorUpdatesListener] BLACKLISTED CHANGES FOUND - revert back to prev state"),((V,K)=>{let z=null,F=null;K.read(()=>{z=$e.lexicalToJSON(K._selection),F=K.toJSON()});let T=null,j=null;V.read(()=>{let L=(0,_e.$getSelection)();j=$e.lexicalToJSON(L),T=V.toJSON()}),Se.setCurrentContentStateJSON(T),Se.setMainSelectionJSON(j),a({state:F,selection:z},So.getCurrentRemoteSelections(),ao.historic),f.dispatchCommand(_e.CAN_REDO_COMMAND,!1),f.dispatchCommand(_e.CAN_UNDO_COMMAND,!1)})(_,b),void Gi.invokeClientCallback();if(!Ro.ensureDocTablesAreValid(_))return;Bu++,ue.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:Bu,isCodoxStarted:Se.isCodoxStarted});let C=Se.isOnlySelectionChanged(w,S),k=null,D=null,N=null,O=null,R=Se.getCurrentContentStateJSON(),A=x.has("codox_sync_state_changes"),U=x.has(Yl),q=Se.undoInvoked(),H=Se.redoInvoked(),M=Se.canUndo(),W=Se.canRedo();k=_.toJSON(),D=b.toJSON(),b.read(()=>{O=$e.lexicalToJSON(b._selection)}),_.read(()=>{let V=(0,_e.$getSelection)();N=$e.lexicalToJSON(V);let K=$e.JSONToLexical(N),z=V===null&&K===null||V.is(K);ue.log("[editorUpdatesListener] new values: ",{newContentStateJSON:k,currentContentStateJSON:JSON.parse(JSON.stringify(R)),prevContentStateJSON:JSON.parse(JSON.stringify(D)),currentCommentsJSON:JSON.parse(JSON.stringify(On.getAllComments())),newSelectionJSON:JSON.parse(JSON.stringify(N)),currentMainSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentMainSelectionJSON())),currentNestedSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentNestedSelectionJSON())),currentActiveSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentActiveSelectionJSON())),lexicalSelection:V,convertedBackMainSelection:K,isMainSelectionConvertionCorrect:z,nodes:f._editorState._nodeMap,fullEditor:f,codoxNodesMap:Nn.toArray(),codoxComments:On,isUpdateFromSync:A,isUpdateFromComments:U,tags:x,onlySelectionChanged:C,undoInvoked:q,redoInvoked:H,canUndo:M,canRedo:W})});let G=hp(R,k),I=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),N);ue.log("[editorUpdatesListener] compares: ",{isStateSame:G,isSelectionSame:I});let $=G&&I&&!U;if(!G||U||A){let V=Ps({},G?R:k),K=On.getAllComments();K.length&&(V.commentThreads=K);let z={source:A?Z0.remote:Z0.local,content:V};Eo.hooks&&Eo.hooks.contentChanged&&Eo.hooks.contentChanged(z),oi().instance.emit("content_changed",z)}if($)ue.log("[editorUpdatesListener] STOP - state and selection and comments are same ",Bu);else if(Se.undoInvoked()&&Se.setUndoInvoked(!1),Se.redoInvoked()&&Se.setRedoInvoked(!1),Se.setCurrentContentStateJSON(k),Se.setPrevContentStateJSON(D),Se.setMainSelectionJSON(N),Se.setPrevMainSelectionJSON(O),mp){let V=Se.getCurrentActiveSelectionJSON();a({state:Se.getCurrentContentStateJSON(),selection:V},[])}else d(Bu)},h=()=>{let v=[];return Se.getMainEditorNodesClassesMap().forEach((_,b,x)=>{let{klass:w}=_,S=f.registerMutationListener(w,C=>{for(let[k,D]of C){if(!Yr[D])continue;const N=Se.getLexicalNodeByKey(k);if(D===Yr.created&&N&&Gi.trackBlacklisted(N,D),w.name===An.TableNode.name&&(D===Yr.destroyed?Ro.tableNodeRemoveListener(k):Ro.tableUpdateListener(k)),w.name===An.TableRowNode.name&&D!==Yr.destroyed&&Ro.tableRowNodeChangesListener(k,D===Yr.updated),w.name===An.TableCellNode.name&&D===Yr.updated&&Ro.tableCellNodeChangesListener(k),w.name===io.MarkNode.name&&(ue.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:k,node:N,mutationType:D,codoxComments:On}),D===Yr.destroyed?On.removeRelatedNodeKey(k):N&&On.addRelatedNodeKey(N.__key,N.__ids,D===Yr.created)),N&&N.codoxId){if(D===Yr.destroyed)return void(N.codoxId&&Nn.remove(N.codoxId));Oy(N)||ue.warn("[MutationListener Error] duplicating codoxId detected - such codoxId already exists in codoxNodesMap - updating node ref to latest: ",{mutationType:D,node:N}),Nn.add(N.codoxId,N)}}v.push(S)})}),v},y={start:e,stop:n,on:(v,_)=>{ue.info(`Subscribing client to codox ${v} event`),vp[v]=_},cursor:{hide:()=>{So.hideRemoteSelectionsFromUI()},show:()=>{So.showHiddenRemoteSelectionsInUI()}},initComments:v=>{On.setInitialComments(v)}};return(0,Gt.useImperativeHandle)(c,()=>y),null}),YS=GS,ZS=["comments"];function _y(m,c){var p=Object.keys(m);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(m);c&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(m,f).enumerable})),p.push.apply(p,t)}return p}function bp(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?_y(Object(p),!0).forEach(function(t){XS(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):_y(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function XS(m,c,p){return(c=QS(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function QS(m){var c=t2(m,"string");return typeof c=="symbol"?c:c+""}function t2(m,c){if(typeof m!="object"||!m)return m;var p=m[Symbol.toPrimitive];if(p!==void 0){var t=p.call(m,c||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(m)}function e2(m,c){if(m==null)return{};var p,t,f=n2(m,c);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(m);for(t=0;t<r.length;t++)p=r[t],c.indexOf(p)>=0||{}.propertyIsEnumerable.call(m,p)&&(f[p]=m[p])}return f}function n2(m,c){if(m==null)return{};var p={};for(var t in m)if({}.hasOwnProperty.call(m,t)){if(c.indexOf(t)>=0)continue;p[t]=m[t]}return p}class r2 extends K0{constructor(){super(),this.mainEditor=null,this.mainEditorKey=null,this.currentContentStateJSON=null,this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null,this._isCodoxStarted=!1,this.prevContentStateJSON=null,this.prevMainSelectionJSON=null,this._undoInvoked=!1,this._redoInvoked=!1,this._canUndo=!1,this._canRedo=!1}setCanUndo(c){this._canUndo=c}setCanRedo(c){this._canRedo=c}canUndo(){return this._canUndo}canRedo(){return this._canRedo}setUndoInvoked(c){this._undoInvoked=c}setRedoInvoked(c){this._redoInvoked=c}undoInvoked(){return this._undoInvoked}redoInvoked(){return this._redoInvoked}setIsCodoxStarted(){let c=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this._isCodoxStarted=c}get isCodoxStarted(){return this._isCodoxStarted}getMainEditorKey(){return this.mainEditorKey}setMainEditor(c){this.mainEditor=c,this.mainEditorKey=c._key}clearJSONs(){ue.debug("[CodoxLexicalEditorManager][clearJSONs] invoked"),this.currentContentStateJSON=null,this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null,this.prevContentStateJSON=null,this.prevMainSelectionJSON=null}removeMainEditor(){this.mainEditor=null,this.mainEditorKey=null,this._undoInvoked=!1,this._redoInvoked=!1,this._canUndo=!1,this._canRedo=!1,super.clear()}getMainEditor(){return this.mainEditor}alignStateSelectionJSONsFromLatestEditor(){this.getMainEditorState().read(()=>{this.setCurrentContentStateJSON(this.getMainEditorState().toJSON()),this.setMainSelectionJSON($e.lexicalToJSON((0,_e.$getSelection)()))})}mainEditorExists(){return!!this.mainEditor}getMainEditorState(){return this.mainEditor?this.mainEditor.getEditorState():{}}getMainEditorNodesClassesMap(){return this.mainEditor?this.mainEditor._nodes:new Map}getLexicalNodeByKey(c){return this.mainEditor?this.getMainEditorState()._nodeMap.get(c):null}isLexicalEditorInstance(c){return c&&typeof c=="object"&&!!c.setEditorState}setCurrentContentStateJSON(c){return this.currentContentStateJSON=c,this.currentContentStateJSON}getCurrentContentStateJSON(){return this.currentContentStateJSON}setPrevContentStateJSON(c){this.prevContentStateJSON=c}getPrevContentStateJSON(){return this.prevContentStateJSON}setMainSelectionJSON(c){this.currentMainSelectionJSON=c,this.currentMainSelectionJSON&&this.currentNestedSelectionJSON&&(this.currentNestedSelectionJSON=null)}setNestedSelectionJSON(c){this.currentNestedSelectionJSON=c,this.currentNestedSelectionJSON&&this.currentMainSelectionJSON&&(this.currentMainSelectionJSON=null)}getCurrentMainSelectionJSON(){return this.currentMainSelectionJSON}getCurrentNestedSelectionJSON(){return this.currentNestedSelectionJSON}getCurrentActiveSelectionJSON(){return!this.currentMainSelectionJSON&&this.currentNestedSelectionJSON?this.currentNestedSelectionJSON:this.currentMainSelectionJSON}clearSelectionJSON(){this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null}setPrevMainSelectionJSON(c){this.prevMainSelectionJSON=c}getPrevMainSelectionJSON(){return this.prevMainSelectionJSON}extractStateAndCommentsFromSynced(c){let{state:{comments:p},selection:t,stateReplace:f}=c;return{stateFromSync:{state:bp({},e2(c.state,ZS)),selection:t,stateReplace:f},commentsFromSync:p}}composeFullStateWithRootAndComments(){let{directlyFromEditor:c=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return bp(bp({},c?this.getMainEditorState().toJSON():this.currentContentStateJSON),{},{comments:On.getAllComments()})}isValidJSONState(c){let p=!1;try{if(!c)throw new Error("State is undefined");if(!c.root)throw new Error("State 'root' node is missing");let t=this.getMainEditorNodesClassesMap(),f=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",e=r,s=t.get(e.type);if(!s)throw new Error(`Node with type "${e.type}" is not registered in editor`);let{klass:i}=s;if(n==="root"){let l=i.prototype instanceof _e.ElementNode,o=i.prototype instanceof _e.DecoratorNode;if(!l&&!o)throw new Error("State root node can have only element nodes as children")}if(e.children)for(let l of e.children)f(l,e.type)};f(c.root),p=!0}catch(t){ue.error("[isValidJSONState] invalid state found: ",t.message),p=!1}return p}scanLexicalNodeForNestedEditorAttribute(c){for(let p in c){let t=c[p];if(this.isLexicalEditorInstance(t))return p}return""}isOnlySelectionChanged(c,p){return c.size===0&&p.size===0}addUpdateTag(){let{isSameState:c,isSameSelection:p,fromNestedEditor:t=!1,updateTag:f=""}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return f?(ue.log(`[addUpdateTag] explicit add of tag "${f}" `),void(0,_e.$addUpdateTag)(f)):t?(ue.log(`[addUpdateTag] add "${ao.historic}" tag - change invoked by nested editor`),void(0,_e.$addUpdateTag)(ao.historic)):void(c?(ue.log(`[addUpdateTag] add "${ao.historic}" tag - state is same`),(0,_e.$addUpdateTag)(ao.historic)):(ue.log(`[addUpdateTag] add "${ao.historyMerge}" tag - state is different`),(0,_e.$addUpdateTag)(ao.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const o2=new r2,Se=o2;class i2{constructor(){this._nodesMap=new Map,this._pastedNodesCodoxIds=new Set}get size(){return this._nodesMap.size}add(c,p){this._nodesMap.set(c,p)}get(c){return this._nodesMap.get(c)||null}remove(c){this._nodesMap.delete(c)}has(c){return this._nodesMap.has(c)}nodesToArray(){return Array.from(this._nodesMap.values())}keysToArray(){return Array.from(this._nodesMap.keys())}toArray(){return Array.from(this._nodesMap.entries())}addPastedId(c){this._pastedNodesCodoxIds.add(c)}removePastedId(c){this._pastedNodesCodoxIds.delete(c)}hasPastedId(c){return this._pastedNodesCodoxIds.has(c)}clearPastedIds(){this._pastedNodesCodoxIds.size>0&&this._pastedNodesCodoxIds.clear()}isEmptyPastedIds(){return this._pastedNodesCodoxIds.size===0}getPastedIdsSize(){return this._pastedNodesCodoxIds.size}clearAll(){this._nodesMap.clear(),this._pastedNodesCodoxIds.clear()}gcAbandonedNodes(){let c=Se.getMainEditorState();if(!c._nodeMap)return;let p=this.nodesToArray();for(let t of p)c._nodeMap.has(t.__key)||this.remove(t.codoxId)}}const a2=new i2,Nn=a2;function xy(m,c){var p=Object.keys(m);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(m);c&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(m,f).enumerable})),p.push.apply(p,t)}return p}function wy(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?xy(Object(p),!0).forEach(function(t){s2(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):xy(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function s2(m,c,p){return(c=l2(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function l2(m){var c=c2(m,"string");return typeof c=="symbol"?c:c+""}function c2(m,c){if(typeof m!="object"||!m)return m;var p=m[Symbol.toPrimitive];if(p!==void 0){var t=p.call(m,c||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(m)}const _p=()=>yw(),Sy=m=>typeof m=="number";function js(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const p=function(){for(var t=arguments.length,f=new Array(t),r=0;r<t;r++)f[r]=arguments[r];return m.apply(this,f)};return Object.defineProperty(p,"name",{value:c,writable:!0}),p}const Pa=m=>m.__type==="root"||m.type==="root",Ey=m=>Pa(m.getParent()),Wn=m=>m.__type===Nu.text||m.type===Nu.text||m.hasOwnProperty("__text")||m.hasOwnProperty("text"),Ns=m=>(0,_e.$isElementNode)(m),Is=m=>(0,An.$isTableNode)(m)||(0,An.$isTableRowNode)(m)||(0,An.$isTableCellNode)(m),u2=m=>!m.getChildren,Cy=m=>!!m.getChildren,Tn=m=>(0,_e.$isDecoratorNode)(m),Xl=m=>(0,cw.$isLinkNode)(m),Ql=m=>m.__type==="mark"||m.type==="mark",xp=m=>(0,_e.$isLineBreakNode)(m),Yi=m=>Wn(m)||xp(m),wp=m=>m.__type===Nu.horizontalrule||m.type===Nu.horizontalrule,ky=m=>{if(Yi(m)||Xl(m)||Ql(m))return!1;if(!m.__parent||m.__parent==="root"||(0,_e.$isParagraphNode)(m))return!0;let c=m.getParent().getChildren();return c.length===1&&c[0].__key===m.__key?!((Tn(m)||Xl(m)||Ql(m))&&!wp(m)):!c.some(p=>{let t=wp(p);return p.__key!==m.__key&&(Yi(p)||Tn(p)&&!t||Xl(p)||Ql(p))})},Oy=m=>{const c=Nn.get(m.codoxId);return!c||m.__key===c.__key},Rs=function(m){const c=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||_p();m.codoxId=c,Nn.add(c,m)},Ty=m=>{Nn.remove(m.codoxId),delete m.codoxId},d2=m=>{if(!Cy(m)||!m.getChildrenSize())return;const c=m.getChildren();if(c.some(f=>!!(0,_e.$isParagraphNode)(f)))return;let p=!1,t=[];for(let f of c)(Yi(f)||Tn(f)||Xl(f)||Ql(f))&&!p&&(wp(f)||(p=!0)),(Cy(f)||Tn(f))&&t.push(f);for(let f of t)p||f.codoxId?p&&f.codoxId&&(f=f.getWritable(),Ty(f)):(f=f.getWritable(),Rs(f))},f2=m=>{const c=wy({},m);for(const p in m)m[p]===void 0&&m.hasOwnProperty(p)&&delete c[p];return c},p2=m=>{const c=`__nativeCreateDOM_${m.name}`;m.prototype[c]=js(m.prototype.createDOM,c),m.prototype.createDOM=function(p,t){if(ky(this))if(this.codoxId){if(!Oy(this)){let r=Nn.get(this.codoxId);r.__type===this.__type&&this.isAttached()&&!r.isAttached()?(ue.warn("[createDOM][Non-unique codoxId] overwrite abandoned existing node with latest: ",{latestNode:this,existingNode:r}),Nn.add(this.codoxId,this)):Rs(this)}}else Rs(this);else this.codoxId&&Ty(this);Tn(this)&&!this.codoxDId&&(this.codoxDId=_p()),di.manageNestedEditorInLexicalNode(this);let f=this[c](p,t);return f.__codox_track=!0,f}},h2=m=>{const c=`__nativeUpdateDOM_${m.name}`;return m.prototype[c]=js(m.prototype.updateDOM,c),m.prototype.updateDOM=function(){const p=this[c](...arguments);return d2(this),p},m},g2=m=>{const c=`__nativeRemove_${m.name}`;return m.prototype[c]=js(m.prototype.remove,c),m.prototype.remove=function(){const p=this.codoxId;return p&&Nn.remove(p),di.gcNestedEditorListenerInLexicalNode(this),this[c](...arguments)},m},m2=m=>{const c=`__nativeExportJSON_${m.name}`;m.prototype[c]=js(m.prototype.exportJSON,c),m.prototype.exportJSON=function(){const p=this[c]();return this.codoxId&&(p.codoxId=this.codoxId),this.codoxDId&&(p.codoxDId=this.codoxDId),Wn(this)&&Sy(p.format)&&this.hasFormat&&(p.format=Tw(this)),f2(p)}},y2=m=>{const c="__nativeImportJSON";m[c]=js(m.importJSON,c),m.importJSON=function(p){const t=wy({},p);Wn(t)&&!Sy(t.format)&&(t.format=Ow(t.format));const f=m[c](t);di.manageNestedEditorInLexicalNode(f);const r=ky(f);return r&&t.codoxId&&(Nn.hasPastedId(t.codoxId)&&Nn.has(t.codoxId)?(Nn.removePastedId(t.codoxId),Rs(f)):Rs(f,t.codoxId)),r&&!f.codoxId&&Rs(f),t.codoxDId&&(f.codoxDId=t.codoxDId),f}},v2=m=>{const c="__nativeClone";m[c]=js(m.clone,c),m.clone=function(p){const t=m[c](p);return p.codoxId&&(t.codoxId=p.codoxId),p.codoxDId&&(t.codoxDId=p.codoxDId),di.manageNestedEditorInClonedLexicalNode(p,t),t}},b2=m=>{let c=!1,p=!1,t=!1,f=!1;m.forEach(n=>{n.name===_e.TextNode.name?c=!0:n.name===_e.ParagraphNode.name?p=!0:n.name===_e.LineBreakNode.name?t=!0:n.name===io.MarkNode.name&&(f=!0)});let r=[];return c||r.push(_e.TextNode),p||r.push(_e.ParagraphNode),t||r.push(_e.LineBreakNode),f||r.push(io.MarkNode),r.length?[...r,...m]:m},_2=function(){return b2(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(m=>(m.hasOwnProperty("__isCodoxExtended")||(p2(m),h2(m),m2(m),g2(m),y2(m),v2(m),Object.defineProperty(m,"__isCodoxExtended",{value:!0,writable:!1})),m))};var Fu=on(777),Ms={};Ms.styleTagTransform=ui(),Ms.setAttributes=li(),Ms.insert=si().bind(null,"head"),Ms.domAPI=ai(),Ms.insertStyleElement=ci(),ii()(Fu.A,Ms),Fu.A&&Fu.A.locals&&Fu.A.locals;var x2=m=>{var c={};return on.d(c,m),c};const w2=x2({AutoFocusPlugin:()=>Im});var S2=m=>{var c={};return on.d(c,m),c};const E2=S2({ClearEditorPlugin:()=>Vx});var C2=m=>{var c={};return on.d(c,m),c};const k2=C2({LexicalComposer:()=>Nm});var O2=m=>{var c={};return on.d(c,m),c};const Ay=O2({default:()=>Gx});var T2=m=>{var c={};return on.d(c,m),c};const A2=T2({HistoryPlugin:()=>Xm});var P2=m=>{var c={};return on.d(c,m),c};const j2=P2({OnChangePlugin:()=>$0});var N2=m=>{var c={};return on.d(c,m),c};const I2=N2({PlainTextPlugin:()=>ow});var R2=m=>{var c={};return on.d(c,m),c};const Py=R2({$isRootTextContentEmpty:()=>t0,$rootTextContent:()=>Qm});var M2=m=>{var c={};return on.d(c,m),c};const Ds=M2({createPortal:()=>_1.createPortal}),D2=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,L2=D2?Gt.useLayoutEffect:Gt.useEffect,jy=L2;var zu=on(253),Ls={};Ls.styleTagTransform=ui(),Ls.setAttributes=li(),Ls.insert=si().bind(null,"head"),Ls.domAPI=ai(),Ls.insertStyleElement=ci(),ii()(zu.A,Ls),zu.A&&zu.A.locals&&zu.A.locals;function B2(m){let{onClose:c,children:p,title:t,closeOnClickOutside:f}=m;const r=(0,Gt.useRef)(null);return(0,Gt.useEffect)(()=>{r.current!==null&&r.current.focus()},[]),(0,Gt.useEffect)(()=>{let n=null;const e=l=>{l.key==="Escape"&&c()},s=l=>{const o=l.target;r.current!==null&&!r.current.contains(o)&&f&&c()},i=r.current;return i!==null&&(n=i.parentElement,n!==null&&n.addEventListener("click",s)),window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),n!==null&&(n==null||n.removeEventListener("click",s))}},[f,c]),Gt.createElement("div",{className:"Modal__overlay",role:"dialog"},Gt.createElement("div",{className:"Modal__modal",tabIndex:-1,ref:r},Gt.createElement("h2",{className:"Modal__title"},t),Gt.createElement("button",{className:"Modal__closeButton","aria-label":"Close modal",type:"button",onClick:c},"X"),Gt.createElement("div",{className:"Modal__content"},p)))}function F2(m){let{onClose:c,children:p,title:t,closeOnClickOutside:f=!1}=m;return(0,Ds.createPortal)(Gt.createElement(B2,{onClose:c,title:t,closeOnClickOutside:f},p),document.body)}function Ny(){const[m,c]=(0,Gt.useState)(null),p=(0,Gt.useCallback)(()=>{c(null)},[]),t=(0,Gt.useMemo)(()=>{if(m===null)return null;const{title:r,content:n,closeOnClickOutside:e}=m;return Gt.createElement(F2,{onClose:p,title:r,closeOnClickOutside:e},n)},[m,p]),f=(0,Gt.useCallback)(function(r,n){c({closeOnClickOutside:arguments.length>2&&arguments[2]!==void 0&&arguments[2],content:n(p),title:r})},[p]);return[t,f]}var Uu=on(191),Bs={};Bs.styleTagTransform=ui(),Bs.setAttributes=li(),Bs.insert=si().bind(null,"head"),Bs.domAPI=ai(),Bs.insertStyleElement=ci(),ii()(Uu.A,Bs),Uu.A&&Uu.A.locals&&Uu.A.locals;const z2={blockCursor:"CommentEditorTheme__blockCursor",characterLimit:"CommentEditorTheme__characterLimit",code:"CommentEditorTheme__code",codeHighlight:{atrule:"CommentEditorTheme__tokenAttr",attr:"CommentEditorTheme__tokenAttr",boolean:"CommentEditorTheme__tokenProperty",builtin:"CommentEditorTheme__tokenSelector",cdata:"CommentEditorTheme__tokenComment",char:"CommentEditorTheme__tokenSelector",class:"CommentEditorTheme__tokenFunction","class-name":"CommentEditorTheme__tokenFunction",comment:"CommentEditorTheme__tokenComment",constant:"CommentEditorTheme__tokenProperty",deleted:"CommentEditorTheme__tokenProperty",doctype:"CommentEditorTheme__tokenComment",entity:"CommentEditorTheme__tokenOperator",function:"CommentEditorTheme__tokenFunction",important:"CommentEditorTheme__tokenVariable",inserted:"CommentEditorTheme__tokenSelector",keyword:"CommentEditorTheme__tokenAttr",namespace:"CommentEditorTheme__tokenVariable",number:"CommentEditorTheme__tokenProperty",operator:"CommentEditorTheme__tokenOperator",prolog:"CommentEditorTheme__tokenComment",property:"CommentEditorTheme__tokenProperty",punctuation:"CommentEditorTheme__tokenPunctuation",regex:"CommentEditorTheme__tokenVariable",selector:"CommentEditorTheme__tokenSelector",string:"CommentEditorTheme__tokenSelector",symbol:"CommentEditorTheme__tokenProperty",tag:"CommentEditorTheme__tokenProperty",url:"CommentEditorTheme__tokenOperator",variable:"CommentEditorTheme__tokenVariable"},embedBlock:{base:"CommentEditorTheme__embedBlock",focus:"CommentEditorTheme__embedBlockFocus"},hashtag:"CommentEditorTheme__hashtag",heading:{h1:"CommentEditorTheme__h1",h2:"CommentEditorTheme__h2",h3:"CommentEditorTheme__h3",h4:"CommentEditorTheme__h4",h5:"CommentEditorTheme__h5",h6:"CommentEditorTheme__h6"},image:"editor-image",indent:"CommentEditorTheme__indent",inlineImage:"inline-editor-image",layoutContainer:"CommentEditorTheme__layoutContainer",layoutItem:"CommentEditorTheme__layoutItem",link:"CommentEditorTheme__link",list:{checklist:"CommentEditorTheme__checklist",listitem:"CommentEditorTheme__listItem",listitemChecked:"CommentEditorTheme__listItemChecked",listitemUnchecked:"CommentEditorTheme__listItemUnchecked",nested:{listitem:"CommentEditorTheme__nestedListItem"},olDepth:["CommentEditorTheme__ol1","CommentEditorTheme__ol2","CommentEditorTheme__ol3","CommentEditorTheme__ol4","CommentEditorTheme__ol5"],ul:"CommentEditorTheme__ul"},ltr:"CommentEditorTheme__ltr",mark:"CommentEditorTheme__mark",markOverlap:"CommentEditorTheme__markOverlap",paragraph:"CommentEditorTheme__paragraph",quote:"CommentEditorTheme__quote",rtl:"CommentEditorTheme__rtl",table:"CommentEditorTheme__table",tableCell:"CommentEditorTheme__tableCell",tableCellActionButton:"CommentEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"CommentEditorTheme__tableCellActionButtonContainer",tableCellEditing:"CommentEditorTheme__tableCellEditing",tableCellHeader:"CommentEditorTheme__tableCellHeader",tableCellPrimarySelected:"CommentEditorTheme__tableCellPrimarySelected",tableCellResizer:"CommentEditorTheme__tableCellResizer",tableCellSelected:"CommentEditorTheme__tableCellSelected",tableCellSortedIndicator:"CommentEditorTheme__tableCellSortedIndicator",tableResizeRuler:"CommentEditorTheme__tableCellResizeRuler",tableSelected:"CommentEditorTheme__tableSelected",tableSelection:"CommentEditorTheme__tableSelection",text:{bold:"CommentEditorTheme__textBold",code:"CommentEditorTheme__textCode",italic:"CommentEditorTheme__textItalic",strikethrough:"CommentEditorTheme__textStrikethrough",subscript:"CommentEditorTheme__textSubscript",superscript:"CommentEditorTheme__textSuperscript",underline:"CommentEditorTheme__textUnderline",underlineStrikethrough:"CommentEditorTheme__textUnderlineStrikethrough"}},U2=z2;var $u=on(72),Fs={};Fs.styleTagTransform=ui(),Fs.setAttributes=li(),Fs.insert=si().bind(null,"head"),Fs.domAPI=ai(),Fs.insertStyleElement=ci(),ii()($u.A,Fs),$u.A&&$u.A.locals&&$u.A.locals;function $2(){for(var m=arguments.length,c=new Array(m),p=0;p<m;p++)c[p]=arguments[p];return c.filter(Boolean).join(" ")}function Sp(){return Sp=Object.assign?Object.assign.bind():function(m){for(var c=1;c<arguments.length;c++){var p=arguments[c];for(var t in p)({}).hasOwnProperty.call(p,t)&&(m[t]=p[t])}return m},Sp.apply(null,arguments)}function Zi(m){let{"data-test-id":c,children:p,className:t,onClick:f,disabled:r,small:n,title:e}=m;return Gt.createElement("button",Sp({disabled:r,className:$2("Button__root",r&&"Button__disabled",n&&"Button__small",t),onClick:f,title:e,"aria-label":e},c&&{"data-test-id":c}),p)}var Hu=on(129),zs={};zs.styleTagTransform=ui(),zs.setAttributes=li(),zs.insert=si().bind(null,"head"),zs.domAPI=ai(),zs.insertStyleElement=ci(),ii()(Hu.A,zs),Hu.A&&Hu.A.locals&&Hu.A.locals;var H2=m=>{var c={};return on.d(c,m),c};const q2=H2({ContentEditable:()=>Rm});function W2(m){let{className:c}=m;return Gt.createElement(q2.ContentEditable,{className:c||"ContentEditable__root"})}var qu=on(457),Us={};Us.styleTagTransform=ui(),Us.setAttributes=li(),Us.insert=si().bind(null,"head"),Us.domAPI=ai(),Us.insertStyleElement=ci(),ii()(qu.A,Us),qu.A&&qu.A.locals&&qu.A.locals;function J2(m){let{children:c,className:p}=m;return Gt.createElement("div",{className:p||"Placeholder__root"},c)}const V2=Ay.default.LexicalErrorBoundary||Ay.default,K2=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"#050505",className:"codox-add-comment-right"},Gt.createElement("path",{d:"M14 1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H4.414A2 2 0 0 0 3 11.586l-2 2V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12.793a.5.5 0 0 0 .854.353l2.853-2.853A1 1 0 0 1 4.414 12H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"}),Gt.createElement("path",{d:"M3 3.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 6a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 6zm0 2.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"})),Iy=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",className:"codox-remove-comment"},Gt.createElement("path",{d:"M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5ZM11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H2.506a.58.58 0 0 0-.01 0H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1h-.995a.59.59 0 0 0-.01 0H11Zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5h9.916Zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47ZM8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5Z"})),G2=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",className:"codox-add-comment"},Gt.createElement("path",{d:"M15.854.146a.5.5 0 0 1 .11.54l-5.819 14.547a.75.75 0 0 1-1.329.124l-3.178-4.995L.643 7.184a.75.75 0 0 1 .124-1.33L15.314.037a.5.5 0 0 1 .54.11ZM6.636 10.07l2.761 4.338L14.13 2.576 6.636 10.07Zm6.787-8.201L1.591 6.602l4.339 2.76 7.494-7.493Z"})),Y2=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"#0000008c",className:"codox-hide-show-comments"},Gt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13 5.885v1.166a3.95 3.95 0 0 1-3.949 3.95H6.917a.748.748 0 0 0-.45.15l-1.345 1.007a.752.752 0 0 0-.032 1.181A2.933 2.933 0 0 0 6.95 14h2.716l2.534 1.901a.506.506 0 0 0 .524.047A.501.501 0 0 0 13 15.5V14h.051a2.949 2.949 0 0 0 2.95-2.949v-3.05a3.002 3.002 0 0 0-2.002-2.83.756.756 0 0 0-.999.714"}),Gt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.05 1H2.95A2.952 2.952 0 0 0 0 3.949v3.102A2.952 2.952 0 0 0 2.949 10H3v1.5a.502.502 0 0 0 .8.4L6.334 10H9.05A2.952 2.952 0 0 0 12 7.05V3.95A2.952 2.952 0 0 0 9.05 1"}));function Ry(m,c,p){let t=arguments.length>3&&arguments[3]!==void 0?arguments[3]:performance.now(),f=arguments.length>4&&arguments[4]!==void 0&&arguments[4];return On.createNewCommentObj({content:m,author:c,codoxId:p,timeStamp:t,deleted:f})}function Z2(m,c,p){return On.createNewThreadObj({quote:m,comments:c,codoxId:p})}function X2(m){let{anchorKey:c,editor:p,onAddComment:t}=m;const f=(0,Gt.useRef)(null),r=(0,Gt.useCallback)(()=>{const n=f.current,e=p.getRootElement(),s=p.getElementByKey(c);if(n!==null&&e!==null&&s!==null){const{right:i}=e.getBoundingClientRect(),{top:l}=s.getBoundingClientRect();n.style.left=i-20+"px",n.style.top=l-30+"px"}},[c,p]);return(0,Gt.useEffect)(()=>(window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}),[p,r]),jy(()=>{r()},[c,p,r]),Gt.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:f},Gt.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:t},Gt.createElement(K2,null)))}function Q2(m){let{onEscape:c}=m;const[p]=(0,Ki.useLexicalComposerContext)();return(0,Gt.useEffect)(()=>p.registerCommand(_e.KEY_ESCAPE_COMMAND,t=>c(t),2),[p,c]),null}function tE(m){let{editorRef:c}=m;const[p]=(0,Ki.useLexicalComposerContext)();return typeof c=="function"?c(p):typeof c=="object"&&(c.current=p),null}function My(m){let{className:c,autoFocus:p,onEscape:t,onChange:f,editorRef:r,placeholder:n="Type a comment...",onEditorClick:e=()=>{}}=m;const s={namespace:"Commenting",nodes:[],onError:i=>{throw i},theme:U2};return Gt.createElement(k2.LexicalComposer,{initialConfig:s},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:e},Gt.createElement(I2.PlainTextPlugin,{contentEditable:Gt.createElement(W2,{className:c}),placeholder:Gt.createElement(J2,null,n),ErrorBoundary:V2}),Gt.createElement(j2.OnChangePlugin,{onChange:f}),Gt.createElement(A2.HistoryPlugin,null),p!==!1&&Gt.createElement(w2.AutoFocusPlugin,null),Gt.createElement(Q2,{onEscape:t}),Gt.createElement(E2.ClearEditorPlugin,null),r!==void 0&&Gt.createElement(tE,{editorRef:r})))}function Dy(m,c){return(0,Gt.useCallback)((p,t)=>{p.read(()=>{m((0,Py.$rootTextContent)()),c(!(0,Py.$isRootTextContentEmpty)(t.isComposing(),!0))})},[c,m])}function eE(m){let{editor:c,cancelAddComment:p,submitAddComment:t}=m;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),s=(0,Gt.useRef)(null),i=(0,Gt.useMemo)(()=>({container:document.createElement("div"),elements:[]}),[]),l=(0,Gt.useRef)(null),o=Fy(),a=(0,Gt.useCallback)(()=>{c.getEditorState().read(()=>{const u=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(u)){l.current=u.clone();const g=u.anchor,h=u.focus,y=(0,Ta.createDOMRange)(c,g.getNode(),g.offset,h.getNode(),h.offset),v=s.current;if(y!==null&&v!==null){const{left:_,bottom:b,width:x}=y.getBoundingClientRect(),w=(0,Ta.createRectsFromDOMRange)(c,y);let S=w.length===1?_+x/2-125:_-125;S<10&&(S=10),v.style.left=`${S}px`,v.style.top=`${b+20+(window.pageYOffset||document.documentElement.scrollTop)}px`;const C=w.length,{container:k}=i,D=i.elements,N=D.length;for(let O=0;O<C;O++){const R=w[O];let A=D[O];A===void 0&&(A=document.createElement("span"),D[O]=A,k.appendChild(A));const U="255, 212, 0",q=`position:absolute;top:${R.top+(window.pageYOffset||document.documentElement.scrollTop)}px;left:${R.left}px;height:${R.height}px;width:${R.width}px;background-color:rgba(${U}, 0.3);pointer-events:none;z-index:5;`;A.style.cssText=q}for(let O=N-1;O>=C;O--){const R=D[O];k.removeChild(R),D.pop()}}}})},[c,i]);jy(()=>{a();const u=i.container,g=document.body;if(g!==null)return g.appendChild(u),()=>{g.removeChild(u)}},[i.container,a]),(0,Gt.useEffect)(()=>(window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}),[a]);const d=Dy(r,e);return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:s},Gt.createElement(My,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:u=>(u.preventDefault(),p(),!0),onChange:d}),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},Gt.createElement(Zi,{onClick:p,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),Gt.createElement(Zi,{onClick:()=>{if(n){let u=c.getEditorState().read(()=>{const g=l.current;return g?g.getTextContent():""});u.length>100&&(u=u.slice(0,99)+"…"),t(Z2(u,[Ry(f,o)]),!0,void 0,l.current),l.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function nE(m){let{submitAddComment:c,thread:p,placeholder:t}=m;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),s=(0,Gt.useRef)(null),i=Fy(),l=Dy(r,e);return Gt.createElement(Gt.Fragment,null,Gt.createElement(My,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:l,editorRef:s,placeholder:t}),Gt.createElement(Zi,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){c(Ry(f,i),!1,p);const o=s.current;o!==null&&o.dispatchCommand(_e.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},Gt.createElement(G2,null)))}function Ly(m){let{commentOrThread:c,deleteCommentOrThread:p,onClose:t,thread:f}=m;return Gt.createElement(Gt.Fragment,null,"Are you sure you want to delete this ",c.type,"?",Gt.createElement("div",{className:"Modal__content"},Gt.createElement(Zi,{onClick:()=>{p(c,f),t()}},"Delete")," ",Gt.createElement(Zi,{onClick:()=>{t()}},"Cancel")))}function By(m){let{comment:c,deleteComment:p,thread:t,rtf:f}=m;const r=Math.round((c.timeStamp-performance.now())/1e3),n=Math.round(r/60),[e,s]=Ny();return Gt.createElement("li",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment"},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Details"},Gt.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Author"},c.author),Gt.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Time"},"· ",r>-10?"Just now":f.format(n,"minute"))),Gt.createElement("p",{className:c.deleted?"CodoxCommentPlugin_CommentsPanel_DeletedComment":""},c.content),!c.deleted&&Gt.createElement(Gt.Fragment,null,Gt.createElement(Zi,{onClick:()=>{s("Delete Comment",i=>Gt.createElement(Ly,{commentOrThread:c,deleteCommentOrThread:p,thread:t,onClose:i}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(Iy,null)),e))}function rE(m){let{activeIDs:c,comments:p,deleteCommentOrThread:t,listRef:f,submitAddComment:r,markNodeMap:n}=m;const[e]=(0,Ki.useLexicalComposerContext)(),[s,i]=(0,Gt.useState)(0),[l,o]=Ny(),a=(0,Gt.useMemo)(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return(0,Gt.useEffect)(()=>{const d=setTimeout(()=>{i(s+1)},1e4);return()=>{clearTimeout(d)}},[s]),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List",ref:f},p.map(d=>{const u=d.codoxId;if(!u)return null;if(d.type==="thread"){const g=()=>{if(n.get(u)!==void 0&&(c===null||c.indexOf(u)===-1)){const h=document.activeElement;e.update(()=>{(0,_e.$setSelection)(null)},{onUpdate(){h!==null&&h.focus()}})}};return Gt.createElement("li",{key:u,onClick:g,className:`CodoxCommentPlugin_CommentsPanel_List_Thread ${n.has(u)?"interactive":""} ${c.indexOf(u)===-1?"":"active"}`},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_QuoteBox"},Gt.createElement("blockquote",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Quote"},"> ",Gt.createElement("span",null,d.quote)),Gt.createElement(Zi,{onClick:()=>{o("Delete Thread",h=>Gt.createElement(Ly,{commentOrThread:d,deleteCommentOrThread:t,onClose:h}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(Iy,null)),l),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},d.comments.map(h=>Gt.createElement(By,{key:h.codoxId,comment:h,deleteComment:t,thread:d,rtf:a}))),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},Gt.createElement(nE,{submitAddComment:r,thread:d,placeholder:"Reply to comment..."})))}return Gt.createElement(By,{key:u,comment:d,deleteComment:t,rtf:a})}))}function oE(m){let{activeIDs:c,deleteCommentOrThread:p,comments:t,submitAddComment:f,markNodeMap:r}=m;const n=(0,Gt.useRef)(null),e=t.length===0;return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel"},Gt.createElement("h2",{className:"CodoxCommentPlugin_CommentsPanel_Heading"},"Comments"),e?Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_Empty"},"No Comments"):Gt.createElement(rE,{activeIDs:c,comments:t,deleteCommentOrThread:p,listRef:n,submitAddComment:f,markNodeMap:r}))}function Fy(){const m=(0,my.useCollaborationContext)(),{yjsDocMap:c,name:p}=m;return p||"Playground User"}function iE(m){const[c]=(0,Ki.useLexicalComposerContext)(),p=Uw(),t=(0,Gt.useMemo)(()=>new Map,[]),[f,r]=(0,Gt.useState)(),[n,e]=(0,Gt.useState)([]),[s,i]=(0,Gt.useState)(!1),[l,o]=(0,Gt.useState)(!1);(0,Gt.useEffect)(()=>{!p.length&&l?o(!1):p.length},[p]);const a=(0,Gt.useCallback)(()=>{c.update(()=>{const g=(0,_e.$getSelection)();g!==null&&(g.dirty=!0)}),i(!1)},[c]),d=(0,Gt.useCallback)((g,h)=>{if(g.type==="comment"){if(ue.log("[deleteCommentOrThread]: type comment new values",{comment:g,thread:h,markNodeMap:t}),On.removeComment(h.codoxId,g.codoxId),!h)return;const y=h.codoxId,v=t.get(y);c.update(()=>{v?v.forEach((_,b)=>{const x=(0,_e.$getNodeByKey)(b);ue.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:x}),x&&x.markDirty()}):(0,_e.$getRoot)().markDirty(),(0,_e.$addUpdateTag)(ao.historic),(0,_e.$addUpdateTag)(Yl)})}else{ue.log("[deleteCommentOrThread]: type thread new values",{comment:g,markNodeMap:t});const y=h!==void 0?h.codoxId:g.codoxId,v=t.get(y);setTimeout(()=>{c.update(()=>{if(v)for(const _ of v){const b=(0,_e.$getNodeByKey)(_);ue.log("[deleteCommentOrThread]: type thread new values",{node:b}),(0,io.$isMarkNode)(b)&&(b.deleteID(y),b.getIDs().length===0&&(0,io.$unwrapMarkNode)(b))}else(0,_e.$getRoot)().markDirty(),ue.debug("[deleteCommentOrThread][refreshComments]");On.refreshComments(!0),(0,_e.$addUpdateTag)(Yl)})})}},[c,t]),u=(0,Gt.useCallback)((g,h,y,v)=>{if(ue.log("[submitAddComment]: new values",{commentOrThread:g,isInlineComment:h,thread:y,markNodeMap:t}),y?On.addComment(y.codoxId,g):On.addCommentThread(g),h)c.update(()=>{if((0,_e.$isRangeSelection)(v)){const _=v.isBackward(),b=g.codoxId;(0,io.$wrapSelectionInMarkNode)(v,_,b),(0,_e.$addUpdateTag)(Yl)}}),i(!1);else if(!h&&y){const _=y.codoxId,b=t.get(_);if(!b)return void On.removeComment(y.codoxId,g.codoxId);c.update(()=>{b.forEach((x,w)=>{let S=(0,_e.$getNodeByKey)(w);S&&S.markDirty()}),(0,_e.$addUpdateTag)(ao.historic),(0,_e.$addUpdateTag)(Yl)})}},[c]);return(0,Gt.useEffect)(()=>{const g=[];for(let h=0;h<n.length;h++){const y=n[h],v=t.get(y);if(v!==void 0)for(const _ of v){const b=c.getElementByKey(_);b!==null&&(b.classList.add("selected"),g.push(b),o(!0))}}return()=>{for(let h=0;h<g.length;h++)g[h].classList.remove("selected")}},[n,c,t]),(0,Gt.useEffect)(()=>{const g=new Map;return(0,Os.mergeRegister)((0,Os.registerNestedElementResolver)(c,io.MarkNode,h=>(0,io.$createMarkNode)(h.getIDs()),(h,y)=>{h.getIDs().forEach(v=>{y.addID(v)})}),c.registerMutationListener(io.MarkNode,h=>{c.getEditorState().read(()=>{for(const[y,v]of h){const _=(0,_e.$getNodeByKey)(y);let b=[];v==="destroyed"?b=g.get(y)||[]:(0,io.$isMarkNode)(_)&&(b=_.getIDs());for(let x=0;x<b.length;x++){const w=b[x];let S=t.get(w);g.set(y,b),v==="destroyed"?S!==void 0&&(S.delete(y),S.size===0&&t.delete(w)):(S===void 0&&(S=new Set,t.set(w,S)),S.has(y)||S.add(y))}}})}),c.registerUpdateListener(h=>{let{editorState:y,tags:v}=h;y.read(()=>{const _=(0,_e.$getSelection)();let b=!1,x=!1;if((0,_e.$isRangeSelection)(_)){const w=_.anchor.getNode();if((0,_e.$isTextNode)(w)){const S=(0,io.$getMarkIDs)(w,_.anchor.offset);S!==null&&(e(S),b=!0),_.isCollapsed()||(r(w.getKey()),x=!0)}}b||e(w=>w.length===0?w:[]),x||r(null),(0,_e.$isRangeSelection)(_)&&i(!1)})}),c.registerCommand(pp,()=>{const h=window.getSelection();return h!==null&&h.removeAllRanges(),i(!0),!0},_e.COMMAND_PRIORITY_EDITOR))},[c,t]),Gt.createElement(Gt.Fragment,null,s&&(0,Ds.createPortal)(Gt.createElement(eE,{editor:c,cancelAddComment:a,submitAddComment:u}),document.body),f!=null&&!s&&(0,Ds.createPortal)(Gt.createElement(X2,{anchorKey:f,editor:c,onAddComment:()=>{c.dispatchCommand(pp,void 0)}}),document.body),(0,Ds.createPortal)(Gt.createElement(Zi,{className:"CodoxCommentPlugin_ShowCommentsButton "+(l?"active":""),onClick:()=>o(!l),title:l?"Hide Comments":"Show Comments"},Gt.createElement(Y2,null)),document.body),l&&(0,Ds.createPortal)(Gt.createElement(oE,{comments:p,submitAddComment:u,deleteCommentOrThread:d,activeIDs:n,markNodeMap:t}),document.body))}var Wu=on(766),$s={};$s.styleTagTransform=ui(),$s.setAttributes=li(),$s.insert=si().bind(null,"head"),$s.domAPI=ai(),$s.insertStyleElement=ci(),ii()(Wu.A,$s),Wu.A&&Wu.A.locals&&Wu.A.locals;var Ju=on(225),Hs={};Hs.styleTagTransform=ui(),Hs.setAttributes=li(),Hs.insert=si().bind(null,"head"),Hs.domAPI=ai(),Hs.insertStyleElement=ci(),ii()(Ju.A,Hs),Ju.A&&Ju.A.locals&&Ju.A.locals;function aE(m){let{label:c,value:p,onChange:t,placeholder:f="","data-test-id":r,type:n="text"}=m;return Gt.createElement("div",{className:"CodoxInput__wrapper"},Gt.createElement("label",{className:"CodoxInput__label"},c),Gt.createElement("input",{type:n,className:"CodoxInput__input",placeholder:f,value:p,onChange:e=>{t(e.target.value)},"data-test-id":r}))}function zy(m,c){var p=Object.keys(m);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(m);c&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(m,f).enumerable})),p.push.apply(p,t)}return p}function Vu(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?zy(Object(p),!0).forEach(function(t){sE(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):zy(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function sE(m,c,p){return(c=lE(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function lE(m){var c=cE(m,"string");return typeof c=="symbol"?c:c+""}function cE(m,c){if(typeof m!="object"||!m)return m;var p=m[Symbol.toPrimitive];if(p!==void 0){var t=p.call(m,c||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(m)}let tc=!1;const uE=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],ec=214,Uy=150;function dE(m){let{color:c,onChange:p}=m;const[t,f]=(0,Gt.useState)(qs("hex",c)),[r,n]=(0,Gt.useState)(c),e=(0,Gt.useRef)(null),s=(0,Gt.useMemo)(()=>({x:t.hsv.s/100*ec,y:(100-t.hsv.v)/100*Uy}),[t.hsv.s,t.hsv.v]),i=(0,Gt.useMemo)(()=>({x:t.hsv.h/360*ec}),[t.hsv]);return(0,Gt.useEffect)(()=>{e.current!==null&&p&&n(t.hex)},[t,p]),(0,Gt.useEffect)(()=>{if(c===void 0)return;const l=qs("hex",c);f(l),n(l.hex)},[c]),Gt.createElement("div",{className:"codox-color-picker-wrapper",style:{width:ec},ref:e},Gt.createElement(aE,{label:"Hex",onChange:l=>{if(n(l),/^#[0-9A-Fa-f]{6}$/i.test(l)){const o=qs("hex",l);f(o)}},value:r}),Gt.createElement("div",{className:"codox-color-picker-basic-color"},uE.map(l=>Gt.createElement("button",{className:l===t.hex?" active":"",key:l,style:{backgroundColor:l},onClick:()=>(o=>{n(o);let a=qs("hex",o);f(a),p(a.hex,tc)})(l)}))),Gt.createElement($y,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`},onChange:l=>{let{x:o,y:a}=l;const d=qs("hsv",Vu(Vu({},t.hsv),{},{s:o/ec*100,v:100-a/Uy*100}));f(d),n(d.hex),p(d.hex,tc)}},Gt.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:t.hex,left:s.x,top:s.y}})),Gt.createElement($y,{className:"codox-color-picker-hue",onChange:l=>{let{x:o}=l;const a=qs("hsv",Vu(Vu({},t.hsv),{},{h:o/ec*360}));f(a),n(a.hex),p(a.hex,tc)}},Gt.createElement("div",{className:"codox-color-picker-hue_cursor",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`,left:i.x}})),Gt.createElement("div",{className:"codox-color-picker-color",style:{backgroundColor:t.hex}}))}function $y(m){let{className:c,style:p,onChange:t,children:f}=m;const r=(0,Gt.useRef)(null),n=(0,Gt.useRef)(!1),e=s=>{if(r.current){const{current:i}=r,{width:l,height:o,left:a,top:d}=i.getBoundingClientRect(),u=Hy(s.clientX-a,l,0),g=Hy(s.clientY-d,o,0);t({x:u,y:g})}};return Gt.createElement("div",{ref:r,className:c,style:p,onMouseDown:s=>{if(s.button!==0)return;e(s);const i=o=>{n.current=!0,tc=!0,e(o)},l=o=>{n.current&&(tc=!1),document.removeEventListener("mousemove",i,!1),document.removeEventListener("mouseup",l,!1),e(o),n.current=!1};document.addEventListener("mousemove",i,!1),document.addEventListener("mouseup",l,!1)}},f)}function Hy(m,c,p){return m>c?c:m<p?p:m}function qy(m){if(!m.startsWith("#")){const c=document.createElement("canvas").getContext("2d");if(!c)throw new Error("2d context not supported or canvas already initialized");return c.fillStyle=m,c.fillStyle}return m.length===4||m.length===5?m=m.split("").map((c,p)=>p?c+c:"#").join(""):m.length===7||m.length===9?m:"#000000"}function Wy(m){const c=(m.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(p,t,f,r)=>"#"+t+t+f+f+r+r).substring(1).match(/.{2}/g)||[]).map(p=>parseInt(p,16));return{b:c[2],g:c[1],r:c[0]}}function Ep(m){let{r:c,g:p,b:t}=m;c/=255,p/=255,t/=255;const f=Math.max(c,p,t),r=f-Math.min(c,p,t);return{h:r?60*(f===c?(p-t)/r+(p<t?6:0):f===p?2+(t-c)/r:4+(c-p)/r):0,s:f?r/f*100:0,v:100*f}}function fE(m){let{h:c,s:p,v:t}=m;p/=100,t/=100;const f=~~(c/60),r=c/60-f,n=t*(1-p),e=t*(1-p*r),s=t*(1-p*(1-r)),i=f%6,l=Math.round(255*[t,e,n,n,s,t][i]),o=Math.round(255*[s,t,t,e,n,n][i]);return{b:Math.round(255*[n,n,s,t,t,e][i]),g:o,r:l}}function Jy(m){let{b:c,g:p,r:t}=m;return"#"+[t,p,c].map(f=>f.toString(16).padStart(2,"0")).join("")}function qs(m,c){let p=qy("#121212"),t=Wy(p),f=Ep(t);return m==="hex"?(p=qy(c),t=Wy(p),f=Ep(t)):m==="rgb"?(t=c,p=Jy(t),f=Ep(t)):m==="hsv"&&(f=c,t=fE(f),p=Jy(t)),{hex:p,hsv:f,rgb:t}}const pE=Gt.createContext(null),Vy=4;function hE(m){let{children:c,dropDownRef:p,onClose:t,dropdownClassName:f}=m;const[r,n]=(0,Gt.useState)(),[e,s]=(0,Gt.useState)(),i=(0,Gt.useCallback)(o=>{n(a=>a?[...a,o]:[o])},[n]),l=(0,Gt.useMemo)(()=>({registerItem:i}),[i]);return(0,Gt.useEffect)(()=>{r&&!e&&s(r[0]),e&&e.current&&e.current.focus()},[r,e]),Gt.createElement(pE.Provider,{value:l},Gt.createElement("div",{className:f,ref:p,onKeyDown:o=>{if(!r)return;const a=o.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(a)&&o.preventDefault(),a==="Escape"||a==="Tab"?t():a==="ArrowUp"?s(d=>{if(!d)return r[0];const u=r.indexOf(d)-1;return r[u===-1?r.length-1:u]}):a==="ArrowDown"&&s(d=>d?r[r.indexOf(d)+1]:r[0])}},c))}function gE(m){let{disabled:c=!1,buttonLabel:p,buttonAriaLabel:t,buttonClassName:f,buttonIconClassName:r,children:n,stopCloseOnClickSelf:e,dropdownClassName:s,buttonLabelClassName:i,dropdownChevronClassName:l}=m;const o=(0,Gt.useRef)(null),a=(0,Gt.useRef)(null),[d,u]=(0,Gt.useState)(!1);return(0,Gt.useEffect)(()=>{const g=a.current,h=o.current;if(d&&g!==null&&h!==null){const{top:y,left:v}=g.getBoundingClientRect();h.style.top=`${y+g.offsetHeight+Vy}px`,h.style.left=`${Math.min(v,window.innerWidth-h.offsetWidth-20)}px`}},[o,a,d]),(0,Gt.useEffect)(()=>{const g=a.current;if(g!==null&&d){const h=y=>{const v=y.target;e&&o.current&&o.current.contains(v)||g.contains(v)||u(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[o,a,d,e]),(0,Gt.useEffect)(()=>{const g=()=>{if(d){const h=a.current,y=o.current;if(h!==null&&y!==null){const{top:v}=h.getBoundingClientRect(),_=v+h.offsetHeight+Vy;_!==y.getBoundingClientRect().top&&(y.style.top=`${_}px`)}}};return document.addEventListener("scroll",g),()=>{document.removeEventListener("scroll",g)}},[a,o,d]),Gt.createElement(Gt.Fragment,null,Gt.createElement("button",{type:"button",disabled:c,"aria-label":t||p,className:f,onClick:()=>u(!d),ref:a},r&&Gt.createElement("span",{className:r}),p&&Gt.createElement("span",{className:i},p),Gt.createElement("i",{className:l})),d&&(0,Ds.createPortal)(Gt.createElement(hE,{dropDownRef:o,onClose:()=>{u(!1),a&&a.current&&a.current.focus()},dropdownClassName:s},n),document.body))}const mE=["disabled","stopCloseOnClickSelf","color","onChange"];function Cp(){return Cp=Object.assign?Object.assign.bind():function(m){for(var c=1;c<arguments.length;c++){var p=arguments[c];for(var t in p)({}).hasOwnProperty.call(p,t)&&(m[t]=p[t])}return m},Cp.apply(null,arguments)}function yE(m,c){if(m==null)return{};var p,t,f=vE(m,c);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(m);for(t=0;t<r.length;t++)p=r[t],c.indexOf(p)>=0||{}.propertyIsEnumerable.call(m,p)&&(f[p]=m[p])}return f}function vE(m,c){if(m==null)return{};var p={};for(var t in m)if({}.hasOwnProperty.call(m,t)){if(c.indexOf(t)>=0)continue;p[t]=m[t]}return p}function Ky(m){let{disabled:c=!1,stopCloseOnClickSelf:p=!0,color:t,onChange:f}=m,r=yE(m,mE);return Gt.createElement(gE,Cp({},r,{disabled:c,stopCloseOnClickSelf:p}),Gt.createElement(dE,{color:t,onChange:f}))}const bE=m=>{let{onColorChange:c,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=m;const[i]=(0,Ki.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,d]=(0,Gt.useState)("");(0,Gt.useEffect)(()=>(0,Os.mergeRegister)(i.registerEditableListener(g=>{o(g)}),i.registerUpdateListener(g=>{let{editorState:h}=g;h.read(()=>{const y=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(y)){let v=(0,Ta.$getSelectionStyleValueForProperty)(y,"color");v!==a&&(d(v||""),c(v))}})})),[i]);const u=(0,Gt.useCallback)((g,h)=>{i.update(()=>{const y=(0,_e.$getSelection)();y!==null&&(0,Ta.$patchStyleText)(y,{color:g})})},[i]);return Gt.createElement(Ky,{disabled:!l,color:a,onChange:u,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},_E=bE,xE=m=>{let{onColorChange:c,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=m;const[i]=(0,Ki.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,d]=(0,Gt.useState)("#fff");(0,Gt.useEffect)(()=>(0,Os.mergeRegister)(i.registerEditableListener(g=>{o(g)}),i.registerUpdateListener(g=>{let{editorState:h}=g;h.read(()=>{const y=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(y)){let v=(0,Ta.$getSelectionStyleValueForProperty)(y,"background-color");v!==a&&(d(v||""),c(v))}})})),[i]);const u=(0,Gt.useCallback)((g,h)=>{i.update(()=>{const y=(0,_e.$getSelection)();y!==null&&(0,Ta.$patchStyleText)(y,{"background-color":g})})},[i]);return Gt.createElement(Ky,{disabled:!l,color:a,onChange:u,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},wE=xE;var SE=qi.yy;qi._U,qi.a8,qi.Vs,qi.Cn;var EE=qi.gK,CE=qi.vv;function kE(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}var Ku=kE(function(m){const c=new URLSearchParams;c.append("code",m);for(let p=1;p<arguments.length;p++)c.append("v",arguments[p]);throw Error(`Minified Lexical error #${m}; visit https://lexical.dev/docs/error?${c} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function OE({hasCellMerge:m=!0,hasCellBackgroundColor:c=!0,hasTabHandler:p=!0}){const[t]=hr();return se.useEffect(()=>(t.hasNodes([wo,$i,ql])||Ku(10),oo(t.registerCommand(Tx,({columns:f,rows:r,includeHeaders:n})=>{const e=E0(Number(r),Number(f),n);Km(e);const s=e.getFirstDescendant();return Pe(s)&&s.select(),!0},an),t.registerNodeTransform(wo,f=>{const[r]=T0(f,null,null),n=r.reduce((e,s)=>Math.max(e,s.length),0);for(let e=0;e<r.length;++e){const s=r[e].length;if(s===n)continue;const i=r[e][s-1].cell;for(let l=s;l<n;++l){const o=ri(0);o.append(jn()),i!==null?i.insertAfter(o):Gm(i,o)}}}))),[t]),se.useEffect(()=>{const f=new Map,r=e=>{const s=e.getKey(),i=t.getElementByKey(s);if(i&&!f.has(s)){const l=Ux(e,i,t,p);f.set(s,l)}};t.getEditorState().read(()=>{const e=Ig(wo);for(const s of e)Mn(s)&&r(s)});const n=t.registerMutationListener(wo,e=>{for(const[s,i]of e)if(i==="created")t.getEditorState().read(()=>{const l=Gn(s);Mn(l)&&r(l)});else if(i==="destroyed"){const l=f.get(s);l!==void 0&&(l.removeListeners(),f.delete(s))}});return()=>{n();for(const[,e]of f)e.removeListeners()}},[t,p]),se.useEffect(()=>{if(!m)return t.registerNodeTransform($i,f=>{if(f.getColSpan()>1||f.getRowSpan()>1){const[,,r]=Gr(f),[n]=Io(r,f,f),e=n.length,s=n[0].length;let i=r.getFirstChild();cr(i)||Ku(175);const l=[];for(let o=0;o<e;o++){o!==0&&(i=i.getNextSibling(),cr(i)||Ku(175));let a=null;for(let d=0;d<s;d++){const u=n[o][d],g=u.cell;if(u.startRow===o&&u.startColumn===d)a=g,l.push(g);else if(g.getColSpan()>1||g.getRowSpan()>1){rn(g)||Ku(176);const h=ri(g.__headerState);a!==null?a.insertAfter(h):Gm(i,h)}}}for(const o of l)o.setColSpan(1),o.setRowSpan(1)}})},[t,m]),se.useEffect(()=>{if(!c)return t.registerNodeTransform($i,f=>{f.getBackgroundColor()!==null&&f.setBackgroundColor(null)})},[t,c,m]),null}const dO="",TE={autocomplete:"PlaygroundEditorTheme__autocomplete",blockCursor:"PlaygroundEditorTheme__blockCursor",characterLimit:"PlaygroundEditorTheme__characterLimit",code:"PlaygroundEditorTheme__code",codeHighlight:{atrule:"PlaygroundEditorTheme__tokenAttr",attr:"PlaygroundEditorTheme__tokenAttr",boolean:"PlaygroundEditorTheme__tokenProperty",builtin:"PlaygroundEditorTheme__tokenSelector",cdata:"PlaygroundEditorTheme__tokenComment",char:"PlaygroundEditorTheme__tokenSelector",class:"PlaygroundEditorTheme__tokenFunction","class-name":"PlaygroundEditorTheme__tokenFunction",comment:"PlaygroundEditorTheme__tokenComment",constant:"PlaygroundEditorTheme__tokenProperty",deleted:"PlaygroundEditorTheme__tokenProperty",doctype:"PlaygroundEditorTheme__tokenComment",entity:"PlaygroundEditorTheme__tokenOperator",function:"PlaygroundEditorTheme__tokenFunction",important:"PlaygroundEditorTheme__tokenVariable",inserted:"PlaygroundEditorTheme__tokenSelector",keyword:"PlaygroundEditorTheme__tokenAttr",namespace:"PlaygroundEditorTheme__tokenVariable",number:"PlaygroundEditorTheme__tokenProperty",operator:"PlaygroundEditorTheme__tokenOperator",prolog:"PlaygroundEditorTheme__tokenComment",property:"PlaygroundEditorTheme__tokenProperty",punctuation:"PlaygroundEditorTheme__tokenPunctuation",regex:"PlaygroundEditorTheme__tokenVariable",selector:"PlaygroundEditorTheme__tokenSelector",string:"PlaygroundEditorTheme__tokenSelector",symbol:"PlaygroundEditorTheme__tokenProperty",tag:"PlaygroundEditorTheme__tokenProperty",url:"PlaygroundEditorTheme__tokenOperator",variable:"PlaygroundEditorTheme__tokenVariable"},embedBlock:{base:"PlaygroundEditorTheme__embedBlock",focus:"PlaygroundEditorTheme__embedBlockFocus"},hashtag:"PlaygroundEditorTheme__hashtag",heading:{h1:"PlaygroundEditorTheme__h1",h2:"PlaygroundEditorTheme__h2",h3:"PlaygroundEditorTheme__h3",h4:"PlaygroundEditorTheme__h4",h5:"PlaygroundEditorTheme__h5",h6:"PlaygroundEditorTheme__h6"},hr:"PlaygroundEditorTheme__hr",image:"editor-image",indent:"PlaygroundEditorTheme__indent",inlineImage:"inline-editor-image",layoutContainer:"PlaygroundEditorTheme__layoutContainer",layoutItem:"PlaygroundEditorTheme__layoutItem",link:"PlaygroundEditorTheme__link",list:{checklist:"PlaygroundEditorTheme__checklist",listitem:"PlaygroundEditorTheme__listItem",listitemChecked:"PlaygroundEditorTheme__listItemChecked",listitemUnchecked:"PlaygroundEditorTheme__listItemUnchecked",nested:{listitem:"PlaygroundEditorTheme__nestedListItem"},olDepth:["PlaygroundEditorTheme__ol1","PlaygroundEditorTheme__ol2","PlaygroundEditorTheme__ol3","PlaygroundEditorTheme__ol4","PlaygroundEditorTheme__ol5"],ul:"PlaygroundEditorTheme__ul"},ltr:"PlaygroundEditorTheme__ltr",mark:"PlaygroundEditorTheme__mark",markOverlap:"PlaygroundEditorTheme__markOverlap",paragraph:"PlaygroundEditorTheme__paragraph",quote:"PlaygroundEditorTheme__quote",rtl:"PlaygroundEditorTheme__rtl",table:"PlaygroundEditorTheme__table",tableCell:"PlaygroundEditorTheme__tableCell",tableCellActionButton:"PlaygroundEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"PlaygroundEditorTheme__tableCellActionButtonContainer",tableCellEditing:"PlaygroundEditorTheme__tableCellEditing",tableCellHeader:"PlaygroundEditorTheme__tableCellHeader",tableCellPrimarySelected:"PlaygroundEditorTheme__tableCellPrimarySelected",tableCellResizer:"PlaygroundEditorTheme__tableCellResizer",tableCellSelected:"PlaygroundEditorTheme__tableCellSelected",tableCellSortedIndicator:"PlaygroundEditorTheme__tableCellSortedIndicator",tableResizeRuler:"PlaygroundEditorTheme__tableCellResizeRuler",tableRowStriping:"PlaygroundEditorTheme__tableRowStriping",tableSelected:"PlaygroundEditorTheme__tableSelected",tableSelection:"PlaygroundEditorTheme__tableSelection",text:{bold:"PlaygroundEditorTheme__textBold",code:"PlaygroundEditorTheme__textCode",italic:"PlaygroundEditorTheme__textItalic",strikethrough:"PlaygroundEditorTheme__textStrikethrough",subscript:"PlaygroundEditorTheme__textSubscript",superscript:"PlaygroundEditorTheme__textSuperscript",underline:"PlaygroundEditorTheme__textUnderline",underlineStrikethrough:"PlaygroundEditorTheme__textUnderlineStrikethrough"}},AE="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE1IDE1IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMDAwMDEgOC4zMzMzM0wxLjkwMDAxIDEzLjhMMS4xMDAwMSAxMy4yTDUuMzc1MDEgNy41TDEuMTAwMDEgMS44TDEuOTAwMDEgMS4yTDYuMDAwMDEgNi42NjY2N0wxMC4xIDEuMkwxMC45IDEuOEw2LjYyNTAxIDcuNUwxMC45IDEzLjJMMTAuMSAxMy44TDYuMDAwMDEgOC4zMzMzM1pNMTIgMTIuNUMxMiAxMS42NzE2IDEyLjY3MTYgMTEgMTMuNSAxMUgxMy43OTI5QzE0LjQ1OTYgMTEgMTUgMTEuNTQwNCAxNSAxMi4yMDcxQzE1IDEyLjUyNzMgMTQuODcyOCAxMi44MzQzIDE0LjY0NjUgMTMuMDYwN0wxMy43MDcxIDE0SDE1VjE1SDEyLjVDMTIuMjk3OCAxNSAxMi4xMTU1IDE0Ljg3ODIgMTIuMDM4MSAxNC42OTEzQzExLjk2MDcgMTQuNTA0NSAxMi4wMDM1IDE0LjI4OTQgMTIuMTQ2NSAxNC4xNDY0TDEzLjkzOTMgMTIuMzUzNkMxMy45NzgyIDEyLjMxNDcgMTQgMTIuMjYyIDE0IDEyLjIwNzFDMTQgMTIuMDkyNyAxMy45MDczIDEyIDEzLjc5MjkgMTJIMTMuNUMxMy4yMjM5IDEyIDEzIDEyLjIyMzkgMTMgMTIuNUgxMloiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+",PE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDQgNTEyLjM2Ij48cGF0aCBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik00OTkuNDMgMjMxLjM2SDM2OC40Yy0yLjUzIDAtNC41OC0yLjA1LTQuNTgtNC41N3YtOC4xMWMwLTEuMjYuNTItMi40IDEuMzQtMy4yMmw3MS41Ny04Mi41M2M2LjczLTcuNzUgMTIuNTctMTQuOTcgMTcuNDgtMjEuNjggNC44OC02LjY0IDguODMtMTIuNzQgMTEuODUtMTguMjggMi45Ny01LjQzIDUuMTgtMTAuNjEgNi42NC0xNS41NSAxLjQyLTQuODUgMi4xMy05LjUzIDIuMTMtMTQgMC0xNC42OC0zLjk4LTI2LjA1LTExLjkyLTM0LjA5LTMuOTItMy45Ni04Ljc1LTYuOTMtMTQuNDktOC45Mi01Ljk1LTIuMDMtMTIuOTEtMy4wNS0yMC44Ny0zLjA1LTguNDUgMC0xNS44OCAxLjIxLTIyLjI5IDMuNjItNi4yNyAyLjM2LTExLjYzIDUuOTItMTYuMDcgMTAuNjNhNDcuODg0IDQ3Ljg4NCAwIDAgMC0xMC4xNCAxNi42Yy0yLjI3IDYuMjktMy40MSAxMy4zOS0zLjQxIDIxLjI2IDAgMi41Mi0yLjA1IDQuNTctNC41NyA0LjU3aC02Ljg5Yy0yLjA1IDAtMy44LTEuMzYtNC4zNy0zLjI0bC0uMjctLjgyYy0uMTgtLjU2LS4yNS0xLjEzLS4yMi0xLjY3LS4yMy05LjMyIDEuMTQtMTcuOTkgNC4xMi0yNS45NyAzLjAyLTguMTMgNy42OC0xNS41NCAxMy45NC0yMi4xOSA2LjI2LTYuNyAxMy42My0xMS43NiAyMi4xLTE1LjEzQzQwNy44NCAxLjY4IDQxNy4yIDAgNDI3LjU1IDBjOS41OSAwIDE4LjI2IDEuMzggMjYuMDMgNC4xMyA3Ljg2IDIuNzkgMTQuNzcgNyAyMC43MiAxMi42MSA2LjAyIDUuNjMgMTAuNTUgMTIuNCAxMy41NSAyMC4yOCAyLjk2IDcuNzUgNC40NSAxNi41NiA0LjQ1IDI2LjQgMCA2LjUtMS4wNyAxMy4wOC0zLjE3IDE5LjY5bC0uMTQuMzhjLTIuMDkgNi40Ni01LjE3IDEyLjk3LTkuMiAxOS40OWwtLjE0LjIxYy00LjA4IDYuNTEtOC45IDEzLjQzLTE0LjQzIDIwLjc0LTUuNTYgNy4zMy0xMS45NiAxNS4yMy0xOS4yMiAyMy42N2wtNTYuOTEgNjYuNTFoMTEwLjM0YzIuNTIgMCA0LjU3IDIuMDUgNC41NyA0LjU3djguMTFjMCAyLjUyLTIuMDUgNC41Ny00LjU3IDQuNTd6bS0zMjcuMjUgNjguNzUgMTM3Ljk2LTE2Ny43NmMuODktMS4wNyAyLjMtMS42NSAzLjc0LTEuNjVsMjAuMTMtLjAyYzIuNTIgMCA0LjU3IDEuNzQgNC41NyAzLjg4IDAgLjkxLS4zNyAxLjc1LS45OCAyLjQxTDE4OC4zMiAzMTcuNjYgMzQ0LjEgNTA2LjI0YzEuNDUgMS43NS45NSA0LjE3LTEuMSA1LjQtLjguNDgtMS43Mi43MS0yLjYzLjcxbC0yMC4xMy4wMWMtMS43IDAtMy4xOC0uNzktMy45Ny0xLjk2bC0xNDQuMS0xNzUuMkwyOC4yMyA1MTAuNjljLS44OCAxLjA3LTIuMyAxLjY0LTMuNzMgMS42NWwtMTkuOTMuMDJjLTIuNTIgMC00LjU3LTEuNzQtNC41Ny0zLjg5IDAtLjkuMzctMS43NC45OC0yLjRsMTU1LjY1LTE4OC40TDYuOSAxMzYuOGMtMS40NS0xLjc1LS45NS00LjE4IDEuMTEtNS40MS43OS0uNDcgMS43MS0uNyAyLjYyLS43bDIwLjQ0LS4wMWMxLjYzIDAgMy4wNi43MiAzLjg3IDEuODFsMTM3LjI0IDE2Ny42MnoiLz48L3N2Zz4=",Gy=Bn.createContext(null),Yy=4;function Ws({children:m,className:c,onClick:p,title:t}){const f=se.useRef(null),r=Bn.useContext(Gy);if(r===null)throw new Error("DropDownItem must be used within a DropDown");const{registerItem:n}=r;return se.useEffect(()=>{f&&f.current&&n(f)},[f,n]),ie.jsx("button",{className:c,onClick:p,ref:f,title:t,type:"button",children:m})}function jE({children:m,dropDownRef:c,onClose:p}){const[t,f]=se.useState(),[r,n]=se.useState(),e=se.useCallback(l=>{f(o=>o?[...o,l]:[l])},[f]),s=l=>{if(!t)return;const o=l.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(o)&&l.preventDefault(),o==="Escape"||o==="Tab"?p():o==="ArrowUp"?n(a=>{if(!a)return t[0];const d=t.indexOf(a)-1;return t[d===-1?t.length-1:d]}):o==="ArrowDown"&&n(a=>a?t[t.indexOf(a)+1]:t[0])},i=se.useMemo(()=>({registerItem:e}),[e]);return se.useEffect(()=>{t&&!r&&n(t[0]),r&&r.current&&r.current.focus()},[t,r]),ie.jsx(Gy.Provider,{value:i,children:ie.jsx("div",{className:"dropdown",ref:c,onKeyDown:s,children:m})})}function Zy({disabled:m=!1,buttonLabel:c,buttonAriaLabel:p,buttonClassName:t,buttonIconClassName:f,children:r,stopCloseOnClickSelf:n}){const e=se.useRef(null),s=se.useRef(null),[i,l]=se.useState(!1),o=()=>{l(!1),s&&s.current&&s.current.focus()};return se.useEffect(()=>{const a=s.current,d=e.current;if(i&&a!==null&&d!==null){const{top:u,left:g}=a.getBoundingClientRect();d.style.top=`${u+a.offsetHeight+Yy}px`,d.style.left=`${Math.min(g,window.innerWidth-d.offsetWidth-20)}px`}},[e,s,i]),se.useEffect(()=>{const a=s.current;if(a!==null&&i){const d=u=>{const g=u.target;n&&e.current&&e.current.contains(g)||a.contains(g)||l(!1)};return document.addEventListener("click",d),()=>{document.removeEventListener("click",d)}}},[e,s,i,n]),se.useEffect(()=>{const a=()=>{if(i){const d=s.current,u=e.current;if(d!==null&&u!==null){const{top:g}=d.getBoundingClientRect(),h=g+d.offsetHeight+Yy;h!==u.getBoundingClientRect().top&&(u.style.top=`${h}px`)}}};return document.addEventListener("scroll",a),()=>{document.removeEventListener("scroll",a)}},[s,e,i]),ie.jsxs(ie.Fragment,{children:[ie.jsxs("button",{type:"button",disabled:m,"aria-label":p||c,className:t,onClick:()=>l(!i),ref:s,children:[f&&ie.jsx("span",{className:f}),c&&ie.jsx("span",{className:"text dropdown-button-text",children:c}),ie.jsx("i",{className:"chevron-down"})]}),i&&Jr.createPortal(ie.jsx(jE,{dropDownRef:e,onClose:o,children:r}),document.body)]})}function Xy(){return ie.jsx("div",{className:"divider"})}const kp=8,Op=72,Js={h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",paragraph:"Normal"},NE=({selectionFontSize:m,disabled:c,editor:p,blockType:t,styleConfig:f,isenterPressed:r,currentElementClick:n,currentElementSelect:e})=>{const[s,i]=Bn.useState(m),[l,o]=Bn.useState(t),[a,d]=Bn.useState(""),u=x=>{p.update(()=>{if(p.isEditable()){const w=Ce();w!==null&&Um(w,x)}})},g=x=>{i(x.target.value)},h=()=>{const x=Number(s);if(!isNaN(x)){const w=Math.min(Math.max(x,kp),Op);i(String(w)),u({"font-size":`${w}px`})}},y=x=>{const w=f[l].fontSize,S=x?Math.min(w+2,Op):Math.max(w-2,kp);i(String(S)),u({"font-size":`${l}px`})},v=x=>{p.update(()=>{const w=Ce();ve(w)&&z_(w,()=>jn())})},_=x=>{d(x),p.update(()=>{const k=Ce();ve(k)&&$_(k,()=>Ss(x))});let w;switch(x){case"h1":w=0;break;case"h2":w=1;break;case"h3":w=2;break;case"paragraph":w=3;break;default:w=0}const S=f.heading[w];i(String(S.fontSize)),d(x),o(x);const C={title:`${S.title}`,"font-size":`${S.fontSize}px`,color:S.fontColor,"font-family":S.fontFamily,"margin-bottom":`${S.trailingSpace}em`,"font-weight":S.bold==="Yes"?"bold":"normal","font-style":S.italic==="Yes"?"italic":"normal","line-height":`${S.lineSpacing}em`,"text-align":S.alignment||"left"};u(C)},b=()=>{o("paragraph"),u({}),i("11"),v()};return Bn.useEffect(()=>{r&&r==="Enter"&&b()},[r]),Bn.useEffect(()=>{const x=()=>{p.update(()=>{const w=Ce();if(w!==null){const C=w.getNodes()[0];if(!Pe(C)){const k=C.getType();k in Js&&o(k)}}})};return p.registerUpdateListener(x),()=>{p.registerUpdateListener(x)}},[p]),Bn.useEffect(()=>{switch(n.tagName){case"P":o("paragraph"),i("11");break;case"H1":console.log("H1"),o("h1"),i(f.heading.find(x=>x.title==="Heading1").fontSize);break;case"H2":o("h2"),i(f.heading.find(x=>x.title==="Heading2").fontSize);break;case"H3":o("h3"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"default":o("paragraph"),i("11"),console.log("default");break}},[n]),Bn.useEffect(()=>{switch(e.trim(" ")){case"Heading1":o("h1"),i(f.heading.find(x=>x.title==="Heading1").fontSize);break;case"Heading2":o("h2"),i(f.heading.find(x=>x.title==="Heading2").fontSize);break;case"Heading3":o("h3"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"paragraph":o("paragraph"),i("11"),console.log("Setting to default paragraph");break;default:console.warn("Unknown element type:",e);break}},[e]),ie.jsxs(ie.Fragment,{children:[ie.jsx("button",{type:"button",disabled:c,onClick:()=>y(!1),className:"toolbar-item font-decrement"}),ie.jsx("input",{type:"number",value:s,disabled:c,readOnly:!0,className:"toolbar-item font-size-input",min:kp,max:Op,onChange:g,onBlur:h}),ie.jsx("button",{type:"button",disabled:c,onClick:()=>y(!0),className:"toolbar-item font-increment"}),ie.jsx(Xy,{}),ie.jsxs("div",{className:"symbol-dropdown cust-head-dropDown",children:[ie.jsxs(Zy,{disabled:c,buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"Formatting options for text style",buttonIconClassName:"icon block-type "+l,buttonLabel:Js[l],children:[ie.jsxs(Ws,{className:`item ${l==="paragraph"?"active":""}`,onClick:()=>v(),children:[ie.jsx("i",{className:"icon paragraph"}),ie.jsx("span",{className:"text",children:Js.paragraph})]}),ie.jsxs(Ws,{className:`item ${l==="h1"?"active":""}`,onClick:()=>_("h1"),children:[ie.jsx("i",{className:"icon h1"}),ie.jsx("span",{className:"text",children:Js.h1})]}),ie.jsxs(Ws,{className:`item ${l==="h2"?"active":""}`,onClick:()=>_("h2"),children:[ie.jsx("i",{className:"icon h2"}),ie.jsx("span",{className:"text",children:Js.h2})]}),ie.jsxs(Ws,{className:`item ${l==="h3"?"active":""}`,onClick:()=>_("h3"),children:[ie.jsx("i",{className:"icon h3"}),ie.jsx("span",{className:"text",children:Js.h3})]})]}),ie.jsx(Xy,{})]})]})},IE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuMS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIyIEZvbnRpY29ucywgSW5jLi0tPjxwYXRoIGQ9Ik0wIDI1NkMwIDExNC42IDExNC42IDAgMjU2IDBzMjU2IDExNC42IDI1NiAyNTYtMTE0LjYgMjU2LTI1NiAyNTZTMCAzOTcuNCAwIDI1NnptMTc1LTQ3LjkgNDcuMSA0N0wxNzUgMzAzYy05LjMgOS40LTkuMyAyNC42IDAgMzMuMSA5LjQgMTAuMiAyNC42IDEwLjIgMzMuMSAwbDQ3LTQ2LjIgNDcuOSA0Ni4yYzkuNCAxMC4yIDI0LjYgMTAuMiAzMy4xIDAgMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMWwtNDYuMi00Ny45IDQ2LjItNDdjMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMS04LjUtOS4zLTIzLjctOS4zLTMzLjEgMGwtNDcuOSA0Ny4xLTQ3LTQ3LjFjLTguNS05LjMtMjMuNy05LjMtMzMuMSAwLTkuMyA5LjQtOS4zIDI0LjYgMCAzMy4xeiIvPjwvc3ZnPg==",RE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGFibGUiPjxwYXRoIGQ9Ik0wIDJhMiAyIDAgMCAxIDItMmgxMmEyIDIgMCAwIDEgMiAydjEyYTIgMiAwIDAgMS0yIDJIMmEyIDIgMCAwIDEtMi0yVjJ6bTE1IDJoLTR2M2g0VjR6bTAgNGgtNHYzaDRWOHptMCA0aC00djNoM2ExIDEgMCAwIDAgMS0xdi0yem0tNSAzdi0zSDZ2M2g0em0tNSAwdi0zSDF2MmExIDEgMCAwIDAgMSAxaDN6bS00LTRoNFY4SDF2M3ptMC00aDRWNEgxdjN6bTUtM3YzaDRWNEg2em00IDRINnYzaDRWOHoiLz48L3N2Zz4=";function ME(){const[m,c]=se.useState("4"),[p,t]=se.useState("4"),[f,r]=se.useState(!1),[n,e]=se.useState(),[s]=hr(),i=()=>{!m||!p||(s.update(()=>{const l=E0(m,p,!0),o=Km(l);e(o)}),r(!1))};return ie.jsxs(ie.Fragment,{children:[ie.jsx("button",{title:"Table",className:"toolbar-item ",onClick:()=>r(!0),children:ie.jsx("img",{className:"add-toolbar-table-icon",src:RE,alt:"Add Table"})}),f&&ie.jsx("div",{className:"modal-overlay",children:ie.jsxs("div",{className:"modal-content",children:[ie.jsx("h3",{children:"Select Table Dimensions"}),ie.jsx("button",{className:"modal-buttons-close",onClick:()=>r(!1),children:ie.jsx("img",{src:IE,height:16,width:16,style:{margin:"0 0 29px 10px"}})}),ie.jsxs("div",{className:"select-table-container",children:[ie.jsx("label",{children:"Rows"}),ie.jsx("input",{type:"number",value:m,onChange:l=>c(Number(l.target.value))})]}),ie.jsxs("div",{className:"select-table-container",children:[ie.jsx("label",{children:"Column"}),ie.jsx("input",{type:"number",value:p,onChange:l=>t(Number(l.target.value))})]}),ie.jsx("div",{children:ie.jsx("div",{className:"modal-buttons",children:ie.jsx("button",{className:"toolbar-item",onClick:i,children:"Confirm"})})})]})})]})}const DE=[{letter:"",uppercase:"A",lowercase:"α"},{letter:"Beta",uppercase:"Β",lowercase:"β"},{letter:"Gamma",uppercase:"Γ",lowercase:"γ"},{letter:"Delta",uppercase:"Δ",lowercase:"δ"},{letter:"Epsilon",uppercase:"Ε",lowercase:"ε"},{letter:"Zeta",uppercase:"Ζ",lowercase:"ζ"},{letter:" Eta ",uppercase:"Η",lowercase:"η"},{letter:"Theta",uppercase:"Θ",lowercase:"θ"},{letter:"Iota",uppercase:"Ι",lowercase:"ι"},{letter:"Kappa",uppercase:"Κ",lowercase:"κ"}];function LE(){const[m]=hr(),[c,p]=se.useState(!1),t=f=>{m.update(()=>{var n;const r=Ce();if(ve(r)){const e=r.anchor.getNode();let s="inherit";if(e instanceof Ri){const l=e.getStyle();s=((n=l==null?void 0:l.match(/font-size:\s*(\S+);/))==null?void 0:n[1])||s}const i=nr(f);r.insertNodes([i])}}),p(!1)};return ie.jsx("div",{className:"symbol-dropdown cust-head-dropDown",children:ie.jsx(Zy,{buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"For appying Symbols",buttonLabel:"Symbols",children:ie.jsx("div",{className:"symbol-Flex-container",children:DE.map(({letter:f,uppercase:r,lowercase:n})=>ie.jsxs("div",{className:"symbol-items",children:[ie.jsx(Ws,{className:"terr",onClick:()=>t(n),children:n}),ie.jsx(Ws,{className:"terr",onClick:()=>t(r),children:r})]},f))})})})}const Qy="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNCAxMkgyME0xMiA0VjIwIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==",tv="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNiAxMkwxOCAxMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4=";var BE=typeof global=="object"&&global&&global.Object===Object&&global;const FE=BE;var zE=typeof self=="object"&&self&&self.Object===Object&&self,UE=FE||zE||Function("return this")();const ev=UE;var $E=ev.Symbol;const Gu=$E;var nv=Object.prototype,HE=nv.hasOwnProperty,qE=nv.toString,nc=Gu?Gu.toStringTag:void 0;function WE(m){var c=HE.call(m,nc),p=m[nc];try{m[nc]=void 0;var t=!0}catch{}var f=qE.call(m);return t&&(c?m[nc]=p:delete m[nc]),f}var JE=Object.prototype,VE=JE.toString;function KE(m){return VE.call(m)}var GE="[object Null]",YE="[object Undefined]",rv=Gu?Gu.toStringTag:void 0;function ZE(m){return m==null?m===void 0?YE:GE:rv&&rv in Object(m)?WE(m):KE(m)}function XE(m){return m!=null&&typeof m=="object"}var QE="[object Symbol]";function tC(m){return typeof m=="symbol"||XE(m)&&ZE(m)==QE}var eC=/\s/;function nC(m){for(var c=m.length;c--&&eC.test(m.charAt(c)););return c}var rC=/^\s+/;function oC(m){return m&&m.slice(0,nC(m)+1).replace(rC,"")}function Tp(m){var c=typeof m;return m!=null&&(c=="object"||c=="function")}var ov=0/0,iC=/^[-+]0x[0-9a-f]+$/i,aC=/^0b[01]+$/i,sC=/^0o[0-7]+$/i,lC=parseInt;function iv(m){if(typeof m=="number")return m;if(tC(m))return ov;if(Tp(m)){var c=typeof m.valueOf=="function"?m.valueOf():m;m=Tp(c)?c+"":c}if(typeof m!="string")return m===0?m:+m;m=oC(m);var p=aC.test(m);return p||sC.test(m)?lC(m.slice(2),p?2:8):iC.test(m)?ov:+m}var cC=function(){return ev.Date.now()};const Ap=cC;var uC="Expected a function",dC=Math.max,fC=Math.min;function pC(m,c,p){var t,f,r,n,e,s,i=0,l=!1,o=!1,a=!0;if(typeof m!="function")throw new TypeError(uC);c=iv(c)||0,Tp(p)&&(l=!!p.leading,o="maxWait"in p,r=o?dC(iv(p.maxWait)||0,c):r,a="trailing"in p?!!p.trailing:a);function d(w){var S=t,C=f;return t=f=void 0,i=w,n=m.apply(C,S),n}function u(w){return i=w,e=setTimeout(y,c),l?d(w):n}function g(w){var S=w-s,C=w-i,k=c-S;return o?fC(k,r-C):k}function h(w){var S=w-s,C=w-i;return s===void 0||S>=c||S<0||o&&C>=r}function y(){var w=Ap();if(h(w))return v(w);e=setTimeout(y,g(w))}function v(w){return e=void 0,a&&t?d(w):(t=f=void 0,n)}function _(){e!==void 0&&clearTimeout(e),i=0,t=s=f=e=void 0}function b(){return e===void 0?n:v(Ap())}function x(){var w=Ap(),S=h(w);if(t=arguments,f=this,s=w,S){if(e===void 0)return u(s);if(o)return clearTimeout(e),e=setTimeout(y,c),d(s)}return e===void 0&&(e=setTimeout(y,c)),n}return x.cancel=_,x.flush=b,x}function hC(m,c,p){const t=se.useRef(null);return t.current=m,se.useMemo(()=>pC((...f)=>{t.current&&t.current(...f)},c,{maxWait:p}),[c,p])}const av=20;function gC({anchorElem:m}){const[c]=hr(),p=wu(),[t,f]=se.useState(!1),[r,n]=se.useState(!1),[e,s]=se.useState(!1),[i,l]=se.useState({}),o=se.useRef(new Set),a=se.useRef(null),d=hC(y=>{const{isOutside:v,tableDOMNode:_}=mC(y);if(v){f(!1),n(!1);return}if(!_)return;a.current=_;let b=null,x=null,w=null;if(c.update(()=>{var C;const S=sr(_);if(rn(S)){const k=bn(S,D=>Mn(D));if(!Mn(k))return;if(w=c.getElementByKey(k==null?void 0:k.getKey()),w){const D=k.getChildrenSize(),N=(C=k.getChildAtIndex(0))==null?void 0:C.getChildrenSize(),O=Ix(S),R=k0(S);O===D-1?b=S:R===N-1&&(x=S)}}}),w){const{width:S,y:C,right:k,left:D,bottom:N,height:O}=w.getBoundingClientRect(),{y:R,left:A}=m.getBoundingClientRect();b?(n(!1),f(!0),l({height:av,left:D-A,top:N-R+5,width:S})):x&&(n(!0),f(!1),l({height:O,left:k-A+5,top:C-R,width:av}))}},50,250),u=se.useMemo(()=>new ResizeObserver(()=>{f(!1),n(!1)}),[]);se.useEffect(()=>{if(e)return document.addEventListener("mousemove",d),()=>{f(!1),n(!1),d.cancel(),document.removeEventListener("mousemove",d)}},[e,d]),se.useEffect(()=>oo(c.registerMutationListener(wo,y=>{c.getEditorState().read(()=>{for(const[v,_]of y){const b=c.getElementByKey(v);switch(_){case"created":o.current.add(v),s(o.current.size>0),b&&u.observe(b);break;case"destroyed":o.current.delete(v),s(o.current.size>0),u.disconnect(),o.current.forEach(x=>{const w=c.getElementByKey(x);w&&u.observe(w)});break}}})})),[c,u]);const g=y=>{c.update(()=>{if(a.current){const v=sr(a.current);v==null||v.selectEnd(),y?(Rx(),f(!1)):(Mx(),n(!1))}})},h=y=>{c.update(()=>{if(a.current){const v=sr(a.current);v==null||v.selectEnd(),y?(Dx(),f(!1)):(Lx(),n(!1))}})};return p?ie.jsxs(ie.Fragment,{children:[t&&ie.jsxs("div",{children:[ie.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%",padding:"20px"},onClick:()=>g(!0),children:ie.jsx("img",{src:Qy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),ie.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%"},onClick:()=>h(!0),children:ie.jsx("img",{src:tv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]}),r&&ie.jsxs("div",{className:"table-add-row-flex-container",children:[ie.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%",padding:"20px"},onClick:()=>g(!1),children:ie.jsx("img",{src:Qy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),ie.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%"},onClick:()=>h(!1),children:ie.jsx("img",{src:tv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]})]}):null}function mC(m){const c=m.target;if(c&&c instanceof HTMLElement){const p=c.closest("td.PlaygroundEditorTheme__tableCell, th.PlaygroundEditorTheme__tableCell");return{isOutside:!(p||c.closest("button.PlaygroundEditorTheme__tableAddRows")||c.closest("button.PlaygroundEditorTheme__tableAddColumns")||c.closest("div.TableCellResizer__resizer")),tableDOMNode:p}}else return{isOutside:!0,tableDOMNode:null}}function yC({anchorElem:m=document.body}){return wu()?Jr.createPortal(ie.jsx(gC,{anchorElem:m}),m):null}const rc=1;function Yu(){return ie.jsx("div",{className:"divider"})}function vC({renderOnlineUsers:m,styleConfig:c}){const[p]=hr(),t=se.useRef(null),[f,r]=se.useState(!1),[n,e]=se.useState(!1),[s,i]=se.useState(!1),[l,o]=se.useState(!1),[a,d]=se.useState(!1),[u,g]=se.useState(!1),[h,y]=se.useState(!1),[v,_]=se.useState(!1),[b,x]=se.useState("11px"),[w,S]=se.useState(()=>p.isEditable()),[C,k]=se.useState(""),[D,N]=se.useState(""),[O,R]=se.useState(""),A=se.useCallback(()=>{const U=Ce();ve(U)&&(i(U.hasFormat("bold")),o(U.hasFormat("italic")),d(U.hasFormat("underline")),g(U.hasFormat("strikethrough")),y(U.hasFormat("subscript")),_(U.hasFormat("superscript")),x(Hm(U,"font-size","11px")))},[]);return se.useEffect(()=>oo(p.registerUpdateListener(({editorState:U})=>{U.read(()=>{A()})}),p.registerCommand(Yo,U=>{k("");const q=Ce();let H=["Heading1","Heading2","Heading3","paragraph"],M="";return q&&q.style&&(q.style.split(";")[0]&&H.includes(q.style.split(";")[0].split(":")[1].trim(""))&&(M=q.style.split(";")[0].split(":")[1].trim("")),q.style.split(";")[1]&&H.includes(q.style.split(";")[1].split(":")[1].trim(""))&&(M=q.style.split(";")[1].split(":")[1].trim("")),q.style.split(";")[2]&&H.includes(q.style.split(";")[2].split(":")[1].trim(""))&&(M=q.style.split(";")[2].split(":")[1].trim("")),q.style.split(";")[3]&&H.includes(q.style.split(";")[3].split(":")[1].trim(""))&&(M=q.style.split(";")[3].split(":")[1].trim(""))),console.log("SELECTION_CHANGE_COMMAND",q&&q.style&&M),R(q&&q.style?M:"paragraph"),A(),!1},rc),p.registerCommand(as,U=>(r(U),!1),rc),p.registerCommand(is,U=>(e(U),!1),rc),p.registerCommand(Jd,U=>(N(U.target),!1),rc),p.registerCommand(rs,U=>(k(U.code),!1),rc)),[p,A]),ie.jsxs("div",{className:"toolbar",ref:t,children:[ie.jsx("button",{disabled:!f,onClick:()=>{p.dispatchCommand(wl,void 0)},className:"toolbar-item spaced","aria-label":"Undo",children:ie.jsx("i",{className:"format undo"})}),ie.jsx("button",{disabled:!n,onClick:()=>{p.dispatchCommand(Sl,void 0)},className:"toolbar-item","aria-label":"Redo",children:ie.jsx("i",{className:"format redo"})}),ie.jsx(Yu,{}),ie.jsx(NE,{currentElementClick:D,selectionFontSize:b.slice(0,-2),editor:p,disabled:!w,blockType:"paragraph",styleConfig:c,isenterPressed:C,currentElementSelect:O}),ie.jsx(Yu,{}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"bold")},className:"toolbar-item spaced "+(s?"active":""),"aria-label":"Format Bold",children:ie.jsx("i",{className:"format bold"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"italic")},className:"toolbar-item spaced "+(l?"active":""),"aria-label":"Format Italics",children:ie.jsx("i",{className:"format italic"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"underline")},className:"toolbar-item spaced "+(a?"active":""),"aria-label":"Format Underline",children:ie.jsx("i",{className:"format underline"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"strikethrough")},className:"toolbar-item spaced "+(u?"active":""),"aria-label":"Format Strikethrough",children:ie.jsx("i",{className:"format strikethrough"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"superscript")},className:"toolbar-item spaced "+(v?"active":""),"aria-label":"Format SuperScript",children:ie.jsx("img",{src:PE,height:16,width:16,style:{marginTop:"1px"}})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"subscript")},className:"toolbar-item spaced "+(h?"active":""),"aria-label":"Format SubScript",children:ie.jsx("img",{src:AE,height:16,width:16,style:{marginTop:"1px"}})}),ie.jsx(Yu,{}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(os,"left")},className:"toolbar-item spaced","aria-label":"Left Align",children:ie.jsx("i",{className:"format left-align"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(os,"center")},className:"toolbar-item spaced","aria-label":"Center Align",children:ie.jsx("i",{className:"format center-align"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(os,"right")},className:"toolbar-item spaced","aria-label":"Right Align",children:ie.jsx("i",{className:"format right-align"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(os,"justify")},className:"toolbar-item","aria-label":"Justify Align",children:ie.jsx("i",{className:"format justify-align"})}),ie.jsx(Yu,{}),ie.jsx(ME,{}),ie.jsx(LE,{}),ie.jsx(yC,{}),ie.jsx("div",{className:"avtar-outer-div",children:m()})]})}var Pp={exports:{}},Sn={};/** @license React v16.13.1
1429
+ `,A.append(q),_=q}!R&&w.width<1&&r.length>1&&(A.style.width="3px")}v.forEach(x=>{this.hoverList.push([x,_,e])})});this.remoteSelections=[],this.isEditingInProgress=!1,this.hoverList=[],this.trackedNodesKeys=new Set,this.remoteSelectionDOMsMap={},this.activeEditorsKeys={},this.keyboardBindedListener=this._keyboardEventsListener.bind(this),this.mouseBindedListener=this._mouseEventsListener.bind(this),this.resizeBindedListener=this._resizeEventListener.bind(this),this.hideInUI=!1}_mouseEventsListener(c){let p=!1,t=c.target,f=!1,r=3;for(;r&&t;){if(t.__codox_track){p=!0;break}if(t.__lexicalEditor){p=!0,f=!0;break}t=t.parentNode,r--}if(!p)return;let n=null;for(let i in this.activeEditorsKeys){if(t[`__lexicalKey_${i}`]){n=i;break}t.__lexicalEditor&&(n=t.__lexicalEditor._key)}if(!n)return;let e=f?"root":t[`__lexicalKey_${n}`];if(!e||!this.trackedNodesKeys.has(`${e}__${n}`))return;let s=new Set;for(let i=0;i<this.hoverList.length;i++){let l=this.hoverList[i],[o,a,d]=l;if(s.has(d))continue;let u=rr.isMousePositionWithinElementCords(c,o);c.type===Sr.mouseover&&u&&(a.style.animation=this.isEditingInProgress?rr.tooltipAnimations.hideAtOnce:rr.tooltipAnimations.showAtOnce,s.add(d)),c.type===Sr.mouseout&&(a.style.animation=rr.tooltipAnimations.hideWithDelay,s.add(d)),c.type===Sr.mousemove&&u&&(a.style.animation=this.isEditingInProgress?rr.tooltipAnimations.hideAtOnce:rr.tooltipAnimations.showAtOnce,s.add(d))}}_keyboardEventsListener(c){c.type===Sr.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),c.type===Sr.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(c){Se.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(Sr.keypress,this.keyboardBindedListener),window.addEventListener(Sr.keyup,this.keyboardBindedListener),window.addEventListener(Sr.resize,this.resizeBindedListener),window.addEventListener(Sr.scroll,this.resizeBindedListener);for(const c of G0)window.addEventListener(c,this.mouseBindedListener)}unmount(){window.removeEventListener(Sr.keypress,this.keyboardBindedListener),window.removeEventListener(Sr.keyup,this.keyboardBindedListener),window.removeEventListener(Sr.resize,this.resizeBindedListener),window.removeEventListener(Sr.scroll,this.resizeBindedListener);for(const c of G0)window.removeEventListener(c,this.mouseBindedListener);this.gcPrevPaintedRemoteSelections()}shouldUpdateRemoteSelections(){return!0}gcPrevPaintedRemoteSelections(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];for(let p in this.remoteSelectionDOMsMap)this.remoteSelectionDOMsMap[p].remove();this.hoverList=[],this.trackedNodesKeys=new Set,this.remoteSelections=c||[],this.remoteSelectionDOMsMap={},this.activeEditorsKeys={}}paintRemoteSelections(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];this.gcPrevPaintedRemoteSelections(c);let p=Se.getMainEditorState();p.read&&p.read(()=>{for(let t of this.remoteSelections)if(gp.validateJSONSelection(t,dp.remote))if($e.isNestedSelectionJSON(t)){let{nestedSelectionJSON:f,nestedEditor:r}=$e.getNestedSelectionJSONFromMainSelectionJSON(t);if(!r)continue;r.getEditorState().read(()=>{let n=$e.JSONToLexical(f);if(n)try{this.paintSingleRemoteSelection({editor:r,selectionJSON:t,lexicalSelection:n,selectedNodes:n.getNodes(),isBackward:n.isBackward()})}catch(e){ue.warn("[PAINT REMOTE SELECTION] failed for nested editor - ",{error:e,nestedSelectionJSON:f,fullSelection:t,lexicalSelection:n})}else ue.error("DEBUGGER: [paintRemoteSelections] nested selection from json to lexical is null: ",{selection:t,nestedSelectionJSON:f,lexicalSelection:n})})}else{let f=$e.JSONToLexical(t);if(!f){ue.error("DEBUGGER: [paintRemoteSelections] selection from json to lexical is null: ",{selection:t,lexicalSelection:f});continue}try{this.paintSingleRemoteSelection({editor:Se.getMainEditor(),selectionJSON:t,lexicalSelection:f,selectedNodes:f.getNodes(),isBackward:f.isBackward()})}catch(r){ue.warn("[PAINT REMOTE SELECTION] failed - ",{error:r,fullSelection:t,lexicalSelection:f})}}})}updateRemoteSelections(){let c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";this.shouldUpdateRemoteSelections(c)&&(ue.log("[updateRemoteSelections] "+p,{newRemoteSelections:c}),Promise.resolve().then(()=>{this.paintRemoteSelections(c),this.hideInUI&&this.hideRemoteSelectionsFromUI()}))}clear(){this.gcPrevPaintedRemoteSelections()}getCurrentRemoteSelections(){return this.remoteSelections}hideRemoteSelectionsFromUI(){this.hideInUI||(this.hideInUI=!0);const c=document.querySelectorAll(".codox_remote_selection");for(let p of c)p.classList.add("hidden_codox_remote_selection")}showHiddenRemoteSelectionsInUI(){this.hideInUI=!1;const c=document.querySelectorAll(".hidden_codox_remote_selection");for(let p of c)p.classList.remove("hidden_codox_remote_selection")}}const So=new OS;function TS(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(m=>m===Oa.editorState)}function Du(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,p=Se.getMainEditorNodesClassesMap();const{klass:t}=p.get(m.type)||{};if(!t)return;const f=t.importJSON(m);if(m.children&&m.children.length)for(const r of m.children)Du(r,f);return c&&c.getChildrenSize&&c.splice(c.getChildrenSize(),0,[f]),f}function Lu(m){if(m.getChildren)for(let c of m.getChildren())Lu(c);m.remove()}function py(m){m.__parent=null,m.__next=null,m.__prev=null}function hy(m,c){return!!Se.isLexicalEditorInstance(m)&&!(typeof c!="object"||!c.editorState||(m.update(()=>{try{let p=(0,_e.$getSelection)();const t=m.parseEditorState(c.editorState);if(t.isEmpty())return(0,_e.$getRoot)().clear(),!0;(0,_e.$setSelection)(p),m.setEditorState(t)}catch(p){ue.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",p)}}),0))}function AS(m,c){let p=c;for(const t of m)p=p[t];return p}function Aa(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,p=arguments.length>2&&arguments[2]!==void 0&&arguments[2],t=null,f=AS(m,p?c:Se.getMainEditorState().toJSON());return f&&(t=Pa(f)?(0,_e.$getRoot)():Nn.get(f.codoxId)),t||ue.debug("[WARNING][getLexicalNodeByPathOutOfJSONState] lexical node not found: ",{jsonNode:f,lexicalNode:t,pathArray:m,currentStateJSON:Se.getMainEditorState().toJSON(),newStateJSON:c,codoxNodes:Nn.nodesToArray(),searchInNewState:p}),t||(p?t:Aa(m,c,!0))}function gy(m){ue.log("[applyFullLexicalStateReplace] clear current state and apply new");const c=(0,_e.$getRoot)();c.clear();let p=Se.getMainEditorNodesClassesMap();function t(f){const r=p.get(f.type).klass.importJSON(f);if(f.children)for(const n of f.children)r.append(t(n));return r}for(const f of m.root.children)c.append(t(f))}function PS(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(c.length){ue.log("[applyDeltasToLexicalState] Original Deltas: ",{newStateJSON:m,deltas:JSON.parse(JSON.stringify(c))});for(const p of c){let{p:t}=p;const f=t[t.length-1],r=f==="children",n=typeof f=="number",e=!n&&!r,s=TS(t),i=s!==-1,l=p.hasOwnProperty("lm")&&typeof p.lm=="number";if(t.length)if(i){let o=s-1,a=Aa(t.slice(0,o),m);if(a){let d=t.slice(0,s),u=m;for(const h of d)u=u[h];let g=Gl(t[o]);hy(a.getWritable()[g],u)}}else{if(r){let o=p.oi;if(!o){ue.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi attr expected for path",{delta:p});continue}if(o.some(d=>!(!d.hasOwnProperty("text")||typeof d.text=="string"))){ue.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi children contain invalid text value",{delta:p});continue}t.length=t.length-1;let a=Aa(t,m);if(!a)continue;if(o.some(d=>!!d.codoxDId)){try{a=a.getWritable()}catch(h){ue.debug("[applyDeltasToLexicalState][shouldUpdateLeaves] getWritable error: ",{err:h,delta:p,fullStateJSON:m});continue}let d={};for(let h of a.getChildren())h.codoxDId?d[h.codoxDId]=h:Lu(h);let u=[],g=["codoxDId","codoxId","__key","__parent","__prev","__next"];for(let h=0;h<o.length;h++){let y=o[h],v=h===0,_=h===o.length-1,b=null,x=h>=0?u[h-1]:null;if(y.codoxDId){let w=d[y.codoxDId];if(w){w=w.getWritable();let S=Du(y);if(ue.debug("[DELTA_DECORATOR_UPDATE]: ",{exisingDecorator:w,tmpDecorator:S}),!S){ue.debug("[DELTA_DECORATOR_UPDATE] UPADATE SKIPPED: ",{exisingDecorator:w,tmpDecorator:S});continue}for(let C in S)if(S.hasOwnProperty(C)&&!g.includes(C))if(Se.isLexicalEditorInstance(S[C])){let k={editorState:S[C].getEditorState().toJSON()};hy(w[C],k)}else{let k=up(C),D=y[k];if(D===w[C]||!y.hasOwnProperty(k))continue;let N=D!==void 0&&S[C]!==D?D:S[C];k!=="height"&&k!=="width"||S[C]==="inherit"&&D===0&&(N=S[C]),w[C]=N}S.remove(),py(w),b=w,delete d[y.codoxDId]}}b||(b=Du(y),b.codoxDId&&b.__type==="excalidraw"&&b.__data==="[]"&&(b.__data="{}")),b=b.getWritable(),u.push(b),b.__parent=a.__key,v?(a.__first=b.__key,b.__prev=null,_&&(a.__last=b.__key)):_?(a.__last=b.__key,b.__next=null,b.__prev=x.__key,x.__next=b.__key):(b.__prev=x.__key,x.__next=b.__key),a.__size=u.length}for(let h in d){let y=d[h];y=y.getWritable(),py(y),Lu(y),delete d[h]}}else{let d=o.map(u=>Du(u));a.splice(0,a.getChildrenSize(),d)}}if(n){if(p.ld){const o=p.ld,a=Nn.get(o.codoxId);a.getChildrenSize&&a.getChildrenSize()?Lu(a):a.remove()}if(p.li){let o=Se.getMainEditorNodesClassesMap();const a=p.li,d=o.get(a.type).klass.importJSON(a);if(t.length===1&&t[0]==="root")(0,_e.$getRoot)().splice(0,0,[d]);else{const u=t[t.length-1];t.length=t.length-2;let g=Aa(t,m);g&&g.splice(u,0,[d])}if(a.children&&a.children.length){let u=function(g,h){const y=o.get(g.type).klass.importJSON(g);if(h.splice(h.getChildrenSize(),0,[y]),g.children&&g.children.length)for(const v of g.children)u(v,y)};for(const g of a.children)u(g,d)}}if(p.oi||p.od){let{p:o,oi:a,od:d}=p,u=Aa(o,m);if(u)try{let g=u.getWritable();if(a){let h=Object.keys(a);for(let y of h)g[Gl(y)]=a[y]}if(d){let h=Object.keys(d);for(let y of h)delete g[Gl(y)]}}catch(g){ue.debug("[applyDeltasToLexicalState][delta oi/od] getWritable error: ",{err:g,delta:p})}}if(l){let{p:o,lm:a}=p,d=o[o.length-1],u=a,g=u<d,h=Aa(o,m);if(h){let y=h.getParent().getChildren(),v=y[d],_=y[u];g?_.insertBefore(v):_.insertAfter(v)}}}if(e){const o=t[t.length-1];let a=Gl(o);t.length=t.length-1;let d,u=Aa(t,m);if(!u){ue.error("Missing node when update node attr from delta: ",{path:t,delta:p,fullStateJSON:m,currentEditorState:Se.getMainEditorState().toJSON()});continue}try{d=u.getWritable()}catch(h){ue.debug("[applyDeltasToLexicalState][shouldUpdateBlockAttr] getWritable error: ",{err:h,delta:p})}if(!d)continue;let g=p.oi;if(o==="format"&&(g=Aw(g)),o==="direction"&&(u.hasOwnProperty(a)||(a="__dir")),!d.hasOwnProperty(a)){let h=Object.keys(d);for(let y of h){let v=up(y);if(o.startsWith(v)){a=y;break}}}d[a]=g}}else if(p.oi&&p.oi.root)return gy(p.oi)}}else ue.log("[applyDeltasToLexicalState] stop, no deltas: ",c)}function jS(m){let c=m.clipboardData.getData(jw.paste),p=!1;try{c=JSON.parse(c),typeof c=="object"&&c.nodes&&Array.isArray(c.nodes)&&(p=!0)}catch{return!1}if(!p)return!1;if(p){Nn.clearPastedIds();const t=f=>{if(f.codoxId&&Nn.addPastedId(f.codoxId),f.children&&f.children.length)for(const r of f.children)t(r)};for(const f of c.nodes)t(f)}return!1}var NS=m=>{var c={};return on.d(c,m),c};const my=NS({useCollaborationContext:()=>Wx});var IS=m=>{var c={};return on.d(c,m),c};const Ki=IS({LexicalComposerContext:()=>Kf,useLexicalComposerContext:()=>hr});class yy{constructor(){this.blacklist=Object.keys(Y0).reduce((c,p)=>{let t=Y0[p];return c[p]=t.reduce((f,r)=>(f[r]=r,f),{}),c},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(c){return c instanceof _e.TextNode||c instanceof _e.ParagraphNode||c instanceof _e.RootNode}setClientCallback(c){this._clientCallback=c}removeClientCallback(){this._clientCallback=null}invokeClientCallback(){this._clientCallback&&this._clientCallback()}trackBlacklisted(c){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>2?arguments[2]:void 0;if(mp||p!==Yr.created||this._isBlacklistedFound||!c||!c.__type||this._shouldSkipNode(c))return;let f=t||Se.getMainEditorState(),r=c.__type,n=this.blacklist[r];n&&f.read(()=>{let e=c.getParent();for(;e!==null;){let s=e?e.__type:null;if(!s)return;if(n[s])return ue.warn("[ContentNestingsWatcher][trackBlacklisted] FOUND: ",{targetNode:c,targetType:r,parent:e,parentType:s,mutationType:p}),void(this._isBlacklistedFound=!0);e=e.getParent()}})}trackBlacklistedInNestedEditor(c){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>3?arguments[3]:void 0;if(p!==Yr.created||this._isBlacklistedFound||this._shouldSkipNode(c))return;let f=t.__type,r=c.__type;if(!f||!r)return;let n=this.blacklist[r];n&&n[f]&&(this._isBlacklistedFound=!0,ue.warn("[ContentNestingsWatcher][trackBlacklistedInNestedEditor] FOUND: ",{targetNode:c,targetType:r,rootNode:t,rootType:f,mutationType:p}))}isBlacklistedFound(){let c=this._isBlacklistedFound;return c&&(this._isBlacklistedFound=!1),c}}const RS=new yy,Gi=RS,MS=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function DS(m,c){if(m==null)return{};var p,t,f=LS(m,c);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(m);for(t=0;t<r.length;t++)p=r[t],c.indexOf(p)>=0||{}.propertyIsEnumerable.call(m,p)&&(f[p]=m[p])}return f}function LS(m,c){if(m==null)return{};var p={};for(var t in m)if({}.hasOwnProperty.call(m,t)){if(c.indexOf(t)>=0)continue;p[t]=m[t]}return p}class BS{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(c,p){let t=!1;return function(f){let{editorState:r,prevEditorState:n,dirtyElements:e,dirtyLeaves:s}=f,i=(DS(f,MS),Se.getMainEditor()),l=Se.getMainEditorState(),o=r.toJSON(),a=n.toJSON(),d=hp(o,a),u=r._selection,g=n._selection,h=!1,y=null,v=Se.isOnlySelectionChanged(e,s),_=c[p];if(ue.debug("[NESTED EDITOR LISTENER] invoked: ",{lexicalNode:c,key:c.__key,onlySelectionChanged:v,newEditorStateJSON:o,prevEditorStateJSON:a,isSameState:d,lexicalSelection:u,prevLexicalSelection:g,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,nestedEditorKey:_._key}),Gi.isBlacklistedFound())return t=!0,ue.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),Se.scanLexicalNodeForNestedEditorAttribute(c)?(_.update(()=>{try{const b=_.parseEditorState(a);if(b.isEmpty())return(0,_e.$getRoot)().clear(),!0;_.setEditorState(b)}catch(b){ue.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",b)}}),void Gi.invokeClientCallback()):void 0;if(t)t=!1;else{if(c.codoxId||c.codoxDId){let b=null;l.read(()=>{b=$e.getNodeAncestorsCodoxIds(c),!c.codoxId&&c.codoxDId&&b.push(c.codoxDId)}),r.read(()=>{let x=up(p),w=$e.lexicalToJSONNested(u,x,b);y=Se.getCurrentNestedSelectionJSON(),h=$e.equalSelectionsJSON(y,w),h||Se.setNestedSelectionJSON(w)})}d&&h||i.update(()=>{try{ue.debug("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE",{mainTags:i._updateTags,nestedTags:_&&_._updateTags,isSameState:d,isSameSelection:h,onlyNestedSelectionChanged:v,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,lexicalNode:c,lexicalSelection:u,prevLexicalSelection:g,mainEditorTags:i._updateTags,mainEditorTagsSize:i._updateTags.size}),Se.addUpdateTag({fromNestedEditor:!0}),c.markDirty()}catch(b){ue.error("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE - ERROR: ",b)}})}}}_isNestedEditorManaged(c){return!!this.nestedEditorsListenersMap[c]}gc(){for(let c in this.nestedEditorsListenersMap)if(!Se.getLexicalNodeByKey(c)){let p=this.nestedEditorsListenersMap[c];p&&p(),delete this.nestedEditorsListenersMap[c]}}manageNestedEditorInLexicalNode(c){if(this._isNestedEditorManaged(c.getKey()))return;let p=Se.scanLexicalNodeForNestedEditorAttribute(c);if(p){let t=c[p],f=this._createNestedEditorUpdatesListener(c,p),r=[];t._nodes.forEach((s,i,l)=>{let{klass:o}=s,a=t.registerMutationListener(o,d=>{for(let[u,g]of d)if(g===Yr.created){let h=t.getEditorState()._nodeMap.get(u);h&&Gi.trackBlacklistedInNestedEditor(h,g,t.getEditorState(),c)}});r.push(a)});let n=(0,Os.mergeRegister)(t.registerUpdateListener(f),...r),e=c.getKey();this.nestedEditorsListenersMap[e]=n}}gcNestedEditorListenerInLexicalNode(c){let p=c.getKey(),t=this.nestedEditorsListenersMap[p];t&&(t(),delete this.nestedEditorsListenersMap[p])}manageNestedEditorInClonedLexicalNode(c,p){let t=c.getKey();t!==p.getKey()&&this._isNestedEditorManaged(t)&&(this.gcNestedEditorListenerInLexicalNode(c),this.manageNestedEditorInLexicalNode(p))}setNestedEditorSelection(c){let{nestedSelectionJSON:p,nestedEditor:t}=$e.getNestedSelectionJSONFromMainSelectionJSON(c);if(!t)return!1;let f=!0;return t.update(()=>{try{let r=$e.JSONToLexical(p);(0,_e.$setSelection)(r),ue.debug("[setNestedEditorSelection]: lexical nested selection: ",r)}catch(r){ue.error("[setNestedEditorSelection] set nested selection error: ",r),f=!1}}),f}clearListeners(){for(let c in this.nestedEditorsListenersMap){let p=this.nestedEditorsListenersMap[c];p&&p(),delete this.nestedEditorsListenersMap[c]}}}const FS=new BS,di=FS,zS=function(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let p=(0,_e.createEditor)({namespace:"validation",nodes:[...c],onError:e=>{throw e},parentEditor:null});const t=new yy,f=p.parseEditorState(m);if(f.isEmpty())return;p.setEditorState(f);let r=p.getEditorState();const n=r._nodeMap[Symbol.iterator]();for(const e of n){let[s,i]=e;if(i&&(t.trackBlacklisted(i,Yr.created,r),t.isBlacklistedFound()))throw new Error(Nw)}}catch(p){throw p}};class US{constructor(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}_scanForCellHeaderState(c,p,t,f){if(p.length<f)return null;let r,n=p.some(s=>s.__headerState===Ji.BOTH||s.__headerState===Ji.ROW),e=c.some((s,i)=>{if(s.__size<f)return!1;let l=s.getChildAtIndex(t);return!(!l||l.__headerState!==Ji.BOTH&&l.__headerState!==Ji.COLUMN)});return n&&e?r=Ji.BOTH:n&&!e?r=Ji.ROW:e&&!n&&(r=Ji.COLUMN),r}_isValidCellChildren(c){for(let p of c)if(Is(p)||!Ns(p)&&Tn(p))return!1;return!0}_createEmptyCell(){let c=(0,An.$createTableCellNode)();return c.append((0,_e.$createParagraphNode)()),c}_wrapInvalidCellChildrenIntoParagraph(c){let p=(0,_e.$createParagraphNode)().getWritable(),t=c.getChildren();(c=c.getWritable()).__first=p.__key,c.__last=p.__key,c.__size=1,p.__parent=c.__key,t.forEach((f,r)=>{(f=f.getWritable()).__parent=null,p.append(f)})}_createFixAction_APPEND_CELLS_TO_ROW(c,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - APPEND_CELLS_TO_ROW] invoked: ",{rowKey:c,numOfCellsToAppend:p});let t=(0,_e.$getNodeByKey)(c);for(;p;){let f=(0,An.$createTableCellNode)().append((0,_e.$createParagraphNode)());f.setRowSpan(1).setColSpan(1),t.append(f),p--}}}_createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(c){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - ADD_PARAGRAPH_TO_EMPTY_CELL] invoked: ",{cellKey:c}),(0,_e.$getNodeByKey)(c).append((0,_e.$createParagraphNode)())}}_createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(c){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_CELL_CHILDREN_IN_PARAGRAPH] invoked: ",{cellKey:c});let p=(0,_e.$getNodeByKey)(c);this._wrapInvalidCellChildrenIntoParagraph(p)}}_createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(c){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - ADD_ROW_CELL_TO_EMPTY_TABLE_NODE] invoked: ",{tableKey:c});let p=(0,_e.$getNodeByKey)(c),t=(0,An.$createTableRowNode)();t.append(this._createEmptyCell()),p.append(t)}}_createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(c,p){return()=>{for(p||(p=1);p;)(0,_e.$getNodeByKey)(c).append(this._createEmptyCell()),p--}}_createFixAction_WRAP_INVALID_ROW_NODE(c,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_ROW_NODE] invoked: ",{tableKey:c,rowKey:p});let t=(0,_e.$getNodeByKey)(c);if(!t)return;let f=(0,_e.$getNodeByKey)(p);if(!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling();f.__parent=null,f.__prev=null,f.__next=null;let e=(0,An.$createTableRowNode)();if((0,An.$isTableCellNode)(f))f.getChildren().length?this._isValidCellChildren()||this._wrapInvalidCellChildrenIntoParagraph(f):f.append((0,_e.$createParagraphNode)()),e.append(f);else{let s=this._isValidCellChildren([f]),i=(0,An.$createTableCellNode)();if(e.append(i),s)i.append(f);else{let l=(0,_e.$createParagraphNode)();l.append(f),i.append(l)}}e.__parent=t.__key,t.__first===f.__key&&(t.__first=e.__key),t.__last===f.__key&&(t.__last=e.__key),r&&(r=r.getWritable(),r.__next=e.__key,e.__prev=r.__key),n&&(n=n.getWritable(),n.__prev=e.__key,e.__next=n.__key)}}_createFixAction_WRAP_INVALID_CELL_NODE(c,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_CELL_NODE] invoked: ",{rowKey:c,cellKey:p});let t=(0,_e.$getNodeByKey)(c);if(!t)return;let f=(0,_e.$getNodeByKey)(p);if(f.remove(),f=(0,_e.$createParagraphNode)(),!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling(),e=(0,An.$createTableCellNode)();if(e.__parent=t.__key,t.__first===f.__key&&(t.__first=e.__key),t.__last===f.__key&&(t.__last=e.__key),r&&(r=r.getWritable(),r.__next=e.__key,e.__prev=r.__key),n&&(n=n.getWritable(),n.__prev=e.__key,e.__next=n.__key),f.__parent=null,f.__prev=null,f.__next=null,this._isValidCellChildren([f]))e.append(f);else{let s=(0,_e.$createParagraphNode)();s.append(f),e.append(s)}}}_createFixAction_APPLY_HEADER_STATE_TO_CELL(c,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - APPLY_HEADER_STATE_TO_CELL] invoked: ",{cellKey:c,headerStateToApply:p});let t=(0,_e.$getNodeByKey)(c);t&&(t=t.getWritable(),t.__headerState=p)}}clear(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}tableRemoveEventListener(c){let p=Se.getMainEditorState()._selection;if(ue.debug(`[${c}]`,{selection:p}),!(0,_e.$isRangeSelection)(p))return;let t=[];try{let f=Se.getLexicalNodeByKey(p.anchor.key),r=Se.getLexicalNodeByKey(p.focus.key);f&&r&&(t=p.isBackward()?r.getNodesBetween(f):f.getNodesBetween(r))}catch(f){ue.warn("[TablesValidator][tableRemoveEventListener] get range selection nodes internal lexical error: ",f)}t.forEach(f=>{(0,An.$isTableNode)(f)&&this.removeCandidateTableKeys.add(f.__key)})}tableNodeRemoveListener(c){this.removeCandidateTableKeys.has(c)&&this.removeCandidateTableKeys.delete(c)}shouldGCRemovedTables(){return!!this.removeCandidateTableKeys.size}gcRemovedTables(){ue.debug("[TablesValidator][gcRemovedTable] candidate table keys ",{tableKeys:this.removeCandidateTableKeys}),Se.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(c=>{let p=(0,_e.$getNodeByKey)(c);p&&p.remove()}),this.removeCandidateTableKeys.clear(),(0,_e.$addUpdateTag)(ao.historic)})}tableUpdateListener(c){this.validateTableCandidateKeys.add(c)}tableRowNodeChangesListener(c){let p=arguments.length>1&&arguments[1]!==void 0&&arguments[1],t=Se.getLexicalNodeByKey(c);if(!t)return void(p&&ue.debug("[TablesValidator][tableRowNodeChangesListener] no row node found in lexical: ",{tableRowNodeKey:c}));let f=t.__parent;f?this.validateTableCandidateKeys.add(f):ue.debug("[tableRowNodeChangesListener] no parent table for row node found in lexical: ",{rowNode:t})}tableCellNodeChangesListener(c){let p=Se.getLexicalNodeByKey(c);if(!p||!p.__parent)return;let t=Se.getLexicalNodeByKey(p.__parent);t&&t.__parent&&this.validateTableCandidateKeys.add(t.__parent)}shouldValidateUpdatedTables(){return!!this.validateTableCandidateKeys.size}validateUpdatedTables(){let c=Array.from(this.validateTableCandidateKeys);return Se.getMainEditorState().read(()=>{for(let p of c){let t=Se.getLexicalNodeByKey(p);if(!t)continue;let f=t.getChildren();if(!f.length){this.tableFixActions.push(this._createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(p));continue}let r=0;f.forEach(i=>{i.__size>r&&(r=i.__size)});let n=[],e=f.map((i,l)=>{if(!(0,An.$isTableRowNode)(i))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_ROW_NODE(p,i.__key)),"invalid_row_node";let o=i.getChildren();if(!o.length&&!n.length)return this.tableFixActions.push(this._createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(i.__key,r)),"empty_row_should_add_cell";if(!o.length&&n.length)return n=[],"empty_row_should_be_empty";let a=0;if(n.length){let u=[];n.forEach(g=>{let[h,y]=g;a+=y,h--,h&&u.push([h,y])}),n=[...u]}let d=o.map((u,g)=>{if(!(0,An.$isTableCellNode)(u))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_CELL_NODE(i.__key,u.__key)),a++,"invalid_cell_node_should_wrap_in_cell";let h,y=u.getChildren(),v=!y.length;if(v?this.tableFixActions.push(this._createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(u.__key)):(h=this._isValidCellChildren(y),h||this.tableFixActions.push(this._createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(u.__key))),u.__rowSpan>1){let _=u.__rowSpan,b=u.__colSpan;n.push([_-1,b])}if(a+=u.__colSpan,u.__headerState===Ji.NO_STATUS){let _=this._scanForCellHeaderState(f,o,g,r);_&&this.tableFixActions.push(this._createFixAction_APPLY_HEADER_STATE_TO_CELL(u.__key,_))}return{cellKey:u.__key,rowKey:i.__key,tableKey:p,colSpan:u.__colSpan,rowSpan:u.__rowSpan,headerState:u.__headerState,childrenAreValid:h,isEmptyCell:v}});if(a<r){let u=r-a;this.tableFixActions.push(this._createFixAction_APPEND_CELLS_TO_ROW(i.__key,u))}return{realRowLength:a,rowKey:i.__key,tableKey:p,cells:d}}),s=!this.tableFixActions.length;ue[s?"debug":"warn"](`[TablesValidator][validateUpdatedTables] IS TABLE VALID: ${s}`,{tableNodeKey:p,tableValidationMatrix:e,requiredRowLength:r}),this.validateTableCandidateKeys.delete(p)}}),!this.tableFixActions.length}shouldFixTablesStructure(){return!!this.tableFixActions.length}fixTablesStructure(){if(!this.tableFixActions.length)return;let c=Se.getMainEditor();ue.log("[TablesValidator][fixTablesStructure]: fix actions to apply - count: ",this.tableFixActions.length),c.update(()=>{for(let p of this.tableFixActions)p();this.tableFixActions=[],(0,_e.$addUpdateTag)(ao.historic)})}ensureDocTablesAreValid(c){return this.shouldGCRemovedTables()?(ue.warn("[TablesValidator][GARBAGE COLLECT TABLE NODES AFTER TABLE REMOVAL ATTEMPT]"),this.gcRemovedTables(),!1):!(this.shouldValidateUpdatedTables()&&(ue.debug("[TablesValidator][shouldValidateUpdatedTables] invoked"),!this.validateUpdatedTables()))||(ue.warn("[TablesValidator][shouldValidateUpdatedTables] INVALID LEXICAL TABLE(S) STRUCTURE FOUND - FIXING",{state:JSON.parse(JSON.stringify(c.toJSON()))}),this.fixTablesStructure(),!1)}}const Ro=new US,$S=["contentChanged"],HS=["state","remoteSelection"];function vy(m,c){var p=Object.keys(m);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(m);c&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(m,f).enumerable})),p.push.apply(p,t)}return p}function Ps(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?vy(Object(p),!0).forEach(function(t){qS(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):vy(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function qS(m,c,p){return(c=WS(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function WS(m){var c=JS(m,"string");return typeof c=="symbol"?c:c+""}function JS(m,c){if(typeof m!="object"||!m)return m;var p=m[Symbol.toPrimitive];if(p!==void 0){var t=p.call(m,c||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(m)}function by(m,c){if(m==null)return{};var p,t,f=VS(m,c);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(m);for(t=0;t<r.length;t++)p=r[t],c.indexOf(p)>=0||{}.propertyIsEnumerable.call(m,p)&&(f[p]=m[p])}return f}function VS(m,c){if(m==null)return{};var p={};for(var t in m)if({}.hasOwnProperty.call(m,t)){if(c.indexOf(t)>=0)continue;p[t]=m[t]}return p}const mp={DEBUG:!1,VERSION:"1.0.2",NAME:"@codoxhq/lexical-provider",SDKUI_SOURCE_PATH:"../../../sdkui/dist-production2/codox.bundle.js"}.LOCAL==="true";ue.info("MODE: ","production");const KS=m=>async()=>{const{state:c,timestamp:p}=await m();if(!Se.isValidJSONState(c))throw new Error("Invalid state received from fetchDocOnNetworkReconnect hook");const{commentThreads:t,root:f}=c,r={content:{comments:t,root:f},timestamp:p};return ue.info("[decorateFetchOnReconnctHook] hook invoked: ",{returnObj:r}),r};let Bu=0,fi=null,yp=!1,Eo={},vp={};const GS=(0,Gt.forwardRef)((m,c)=>{let{onBlacklistedInsert:p}=m;const t=(0,Gt.useContext)(Ki.LexicalComposerContext);if(!t)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[f]=(0,Ki.useLexicalComposerContext)(),r=(0,my.useCollaborationContext)();(0,Gt.useEffect)(()=>{if(ue.debug("[INIT] lexical context check: ",{lexicalContext:t,editor:f}),!f)return;ue.log("[useEffect][editor] Editor instance changed: ",{editor:f,key:f._key}),Se.setMainEditor(f),Nn.gcAbandonedNodes(),di.gc(),Ro.clear(),ue.log("[useEffect][editor] subscribe to editor changes");const v=(0,Os.mergeRegister)(f.registerUpdateListener(g),f.registerCommand(_e.PASTE_COMMAND,jS,_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.UNDO_COMMAND,()=>{Se.setUndoInvoked(!0)},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.REDO_COMMAND,()=>{Se.setRedoInvoked(!0)},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.KEY_DELETE_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("KEY_DELETE_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.KEY_BACKSPACE_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.CUT_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("CUT_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),...h());So.mount(),Se.alignStateSelectionJSONsFromLatestEditor(),ue.debug("New editor mounted: ",{isCodoxStarted:Se.isCodoxStarted,codoxLexicalEditorManager:Se,nestedEditorsProcessor:di});let _=f._onError;return f._onError=b=>{ue.error("[ERROR HANDLER WRAPPER] error from editor: ",b),_&&_(b),u()},p&&Gi.setClientCallback(p),()=>{Se.getMainEditorKey()&&(ue.debug("Unmount prev editor"),v(),Se.removeMainEditor(),So.unmount(),Se.clearJSONs(),On.clear(),Ro.clear(),Se.isCodoxStarted&&(ue.debug("EDITOR USE_EFFECT stopping codox"),n(),Se.setIsCodoxStarted(!1)),Gi.removeClientCallback())}},[f]);const n=()=>{Se.isCodoxStarted&&(ue.log("[stopCodoxInstance] stopping codox"),Se.setIsCodoxStarted(!1),mp||oi().stop(),Se.clearJSONs(),Nn.clearAll(),So.clear(),On.resetComments(),di.clearListeners())},e=async v=>{ue.debug("[startCodoxInstance] invoked"),oi().createNewInstance(),ue.debug("[startCodoxInstance] instance created");for(let O in vp)oi().instance.on(O,vp[O]);if(ue.debug("[startCodoxInstance] events subscribed"),Eo=v,fi=Eo.docId,!fi)return ue.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:fi});let _=On.initialCommentsExist();ue.debug("[startCodoxInstance] initCommentsExist: ",_),_&&(On.activateInitialComments(f,Nn),ue.log("[activateInitialComments] "));let b=Se.getMainEditorState().toJSON();if(!Se.isValidJSONState(b))throw ue.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:fi,initJSONState:b}),new Error("start codox skipped - invalid init state");ue.log("[startCodoxInstance] starting codox with: ",{docId:fi,initJSONState:b,config:Eo,codoxComments:On}),Se.currentContentStateJSON||Se.setCurrentContentStateJSON(b),Se.isCodoxStarted&&n();let{username:x,apiKey:w,getServerState:S,domain:C="",demo:k=!1,hooks:D}=Eo;D&&D.fetchDocOnNetworkReconnect&&(D.fetchDocOnNetworkReconnect=KS(D.fetchDocOnNetworkReconnect));const N=by(D,$S);await oi().start(oi().createConfig(Ps(Ps({},Eo),{},{docId:fi,username:x,apiKey:w,domain:C,hooks:Ps({syncState:l,getState:i,getServerState:async()=>await S(fi)},N),editorInstanceHooks:{getSelection:()=>Se.getCurrentActiveSelectionJSON(),setSelection:O=>o(O),getState:i,setState:O=>{const{root:R,comments:A}=O;ue.info("DEBUG: EDITOR INSTANCE setState:",{fullState:O}),a({state:{root:R},selection:Se.getCurrentActiveSelectionJSON()},So.getCurrentRemoteSelections()),On.setAllComments(A)},enableEditor:()=>{Se.disableEditorReadOnlyMode()},disableEditor:()=>{Se.enableEditorReadOnlyMode(),So.updateRemoteSelections([])},getContent:()=>{let O=Se.composeFullStateWithRootAndComments();return ue.info("[getContent]: ",O),{state:O}}},appServer:Eo.appServer,demo:k}))),ue.log("[startCodoxInstance] codox started - first sync invoking"),Se.setIsCodoxStarted(!0),r.clientID=Eo.username,r.name=Eo.username,d()},s=()=>{let v=Se.composeFullStateWithRootAndComments({directlyFromEditor:!0});e(v)},i=()=>({state:Ps(Ps({},Se.getMainEditorState().toJSON()),{},{comments:On.getAllComments()}),docId:fi}),l=v=>{if(!Se.isCodoxStarted)return;ue.log("[SYNC_STATE]: Before sync payload = ",v);const _=oi().sync({meta:v}),{state:b,remoteSelection:x=[]}=_,w=by(_,HS);if(ue.log("[SYNC_STATE]: After sync",{state:b,remoteSelection:x,rest:w}),!b)return ue.error("[SYNC_STATE] abort apply - synced state is not valid - restarting codox"),s();const S=b.state;ue.log("[SYNC_STATE] synced state: ",{synced:JSON.parse(JSON.stringify(S))});let{stateFromSync:C,commentsFromSync:k}=Se.extractStateAndCommentsFromSynced(S);if(!Se.isValidJSONState(C.state))return ue.error("[SYNC_STATE] - invalid state from sync - local update skipped - restarting codox",{contentState:C.state}),s();a(C,x),On.setAllComments(k)},o=v=>{if(!Se.isCodoxStarted||(ue.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:v}),!gp.validateJSONSelection(v,dp.local)))return;let _=Se.getCurrentActiveSelectionJSON();if($e.equalSelectionsJSON(_,v))return void ue.log("[setLocalSelectionFromSync] STOP - local and synced selections are equal");let b=$e.isNestedSelectionJSON(v);f.update(()=>{ue.log("[setLocalSelectionFromSync] json selection to apply: ",{syncedSelectionJSON:v});const x=$e.JSONToLexical(v);if(ue.log("[setLocalSelectionFromSync] lexical selection to apply: ",x),b){let w=di.setNestedEditorSelection(v);Se.setNestedSelectionJSON(w?v:null)}else(0,_e.$setSelection)(x),Se.setMainSelectionJSON(v);ue.log("[setLocalSelectionFromSync] selection updated. latest selection: ",{latestSelectionJSON:Se.getCurrentActiveSelectionJSON()})})},a=function(){let{state:v,selection:_,stateReplace:b}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",S=Se.getCurrentContentStateJSON();ue.log("[updateEditor] invoked: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:JSON.parse(JSON.stringify(v)),newSelectionJSON:_,remoteSelection:x,stateReplace:b,editor:f}),_===void 0&&ue.error("SELECTION FROm SYNC IS UNDEFINED - will default prev selection",_);const C=hp(S,v),k=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),_);f.update(()=>{if(Se.addUpdateTag({isSameState:C,isSameSelection:k,updateTag:w}),b)ue.log("[updateEditor] invoke full stateReplace after sync"),gy(v),S=Se.setCurrentContentStateJSON(v),(0,_e.$addUpdateTag)("codox_sync_state_changes"),ue.log("[updateEditor] state updated: ",S);else{ue.log("[updateEditor] invoke deltas diff");let N=oi().diff(S,v,{keyNames:{default:"codoxId"}});ue.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:v,deltas:N&&JSON.parse(JSON.stringify(N))}),N&&N.length&&(ue.log("[updateEditor] apply deltas to lexical state"),PS(v,N),S=Se.setCurrentContentStateJSON(v),(0,_e.$addUpdateTag)("codox_sync_state_changes"),ue.log("[updateEditor] state updated: ",S))}let D=$e.isNestedSelectionJSON(_);if(gp.validateJSONSelection(_,dp.local)||(_=Se.getCurrentActiveSelectionJSON()),D){let N=di.setNestedEditorSelection(_);Se.setNestedSelectionJSON(N?_:null),ue.log("[updateEditor] nested selection updated",N?_:null)}else if(_!==void 0){const N=$e.JSONToLexical(_);ue.log("[updateEditor] updated selection to apply: ",{isSameSelection:k,newSelectionJSON:_,lexicalSelection:N}),(0,_e.$setSelection)(N),Se.setMainSelectionJSON(_),ue.log("[updateEditor] selection updated",_)}},{onUpdate:()=>{C||So.updateRemoteSelections(x,"from onUpdate hook")}}),C&&So.updateRemoteSelections(x,"from direct updateEditor")},d=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";if(!Se.isCodoxStarted)return;ue.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:v});let _=Se.composeFullStateWithRootAndComments();const b={docId:fi,state:{state:_,selection:Se.getCurrentActiveSelectionJSON()}};ue.log("[codoxSync]: Before sync",{local:b,upd_call_counter:v}),ue.log("[codoxSync]: Before sync state",JSON.parse(JSON.stringify(b.state)));let{state:x,remoteSelection:w=[],changes:S}=oi().sync({state:b,meta:{}});if(ue.log("[codoxSync]: After sync",{afterSyncState:JSON.parse(JSON.stringify(x)),remoteSelection:w,changes:S}),!x)return ue.error("[codoxSync] abort apply - synced state is not valid - restarting codox "),s();const C=x.state;ue.log("[codoxSync]: synced state: ",JSON.parse(JSON.stringify(C)),v);let{stateFromSync:k,commentsFromSync:D}=Se.extractStateAndCommentsFromSynced(C);if(!Se.isValidJSONState(k.state))return ue.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:k.state}),s();a(k,w),On.setAllComments(D)},u=()=>{ue.warn("[rollbackStateDuringUpdateError] rollback invoked"),ue.log("[rollbackStateDuringUpdateError] values: ",{prevState:Se.getPrevContentStateJSON(),currentState:Se.getCurrentContentStateJSON(),prevSelection:Se.getPrevMainSelectionJSON(),currentSelection:Se.getCurrentActiveSelectionJSON(),codoxComments:On});let v=Se.getPrevContentStateJSON(),_=Se.getPrevMainSelectionJSON();a({state:v,selection:_},So.getCurrentRemoteSelections(),ao.historic);let b=Se.undoInvoked(),x=Se.redoInvoked();On.gcAbandonedNodeKeys(Se.getMainEditorState()._nodeMap),b&&f.dispatchCommand(_e.CAN_REDO_COMMAND,!1),x&&f.dispatchCommand(_e.CAN_UNDO_COMMAND,!1)},g=v=>{let{editorState:_,prevEditorState:b,tags:x,dirtyElements:w,dirtyLeaves:S}=v;if(yp)return yp=!1,void ue.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(Gi.isBlacklistedFound())return yp=!0,ue.warn("[editorUpdatesListener] BLACKLISTED CHANGES FOUND - revert back to prev state"),((V,K)=>{let z=null,F=null;K.read(()=>{z=$e.lexicalToJSON(K._selection),F=K.toJSON()});let T=null,j=null;V.read(()=>{let L=(0,_e.$getSelection)();j=$e.lexicalToJSON(L),T=V.toJSON()}),Se.setCurrentContentStateJSON(T),Se.setMainSelectionJSON(j),a({state:F,selection:z},So.getCurrentRemoteSelections(),ao.historic),f.dispatchCommand(_e.CAN_REDO_COMMAND,!1),f.dispatchCommand(_e.CAN_UNDO_COMMAND,!1)})(_,b),void Gi.invokeClientCallback();if(!Ro.ensureDocTablesAreValid(_))return;Bu++,ue.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:Bu,isCodoxStarted:Se.isCodoxStarted});let C=Se.isOnlySelectionChanged(w,S),k=null,D=null,N=null,O=null,R=Se.getCurrentContentStateJSON(),A=x.has("codox_sync_state_changes"),U=x.has(Yl),q=Se.undoInvoked(),H=Se.redoInvoked(),M=Se.canUndo(),W=Se.canRedo();k=_.toJSON(),D=b.toJSON(),b.read(()=>{O=$e.lexicalToJSON(b._selection)}),_.read(()=>{let V=(0,_e.$getSelection)();N=$e.lexicalToJSON(V);let K=$e.JSONToLexical(N),z=V===null&&K===null||V.is(K);ue.log("[editorUpdatesListener] new values: ",{newContentStateJSON:k,currentContentStateJSON:JSON.parse(JSON.stringify(R)),prevContentStateJSON:JSON.parse(JSON.stringify(D)),currentCommentsJSON:JSON.parse(JSON.stringify(On.getAllComments())),newSelectionJSON:JSON.parse(JSON.stringify(N)),currentMainSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentMainSelectionJSON())),currentNestedSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentNestedSelectionJSON())),currentActiveSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentActiveSelectionJSON())),lexicalSelection:V,convertedBackMainSelection:K,isMainSelectionConvertionCorrect:z,nodes:f._editorState._nodeMap,fullEditor:f,codoxNodesMap:Nn.toArray(),codoxComments:On,isUpdateFromSync:A,isUpdateFromComments:U,tags:x,onlySelectionChanged:C,undoInvoked:q,redoInvoked:H,canUndo:M,canRedo:W})});let G=hp(R,k),I=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),N);ue.log("[editorUpdatesListener] compares: ",{isStateSame:G,isSelectionSame:I});let $=G&&I&&!U;if(!G||U||A){let V=Ps({},G?R:k),K=On.getAllComments();K.length&&(V.commentThreads=K);let z={source:A?Z0.remote:Z0.local,content:V};Eo.hooks&&Eo.hooks.contentChanged&&Eo.hooks.contentChanged(z),oi().instance.emit("content_changed",z)}if($)ue.log("[editorUpdatesListener] STOP - state and selection and comments are same ",Bu);else if(Se.undoInvoked()&&Se.setUndoInvoked(!1),Se.redoInvoked()&&Se.setRedoInvoked(!1),Se.setCurrentContentStateJSON(k),Se.setPrevContentStateJSON(D),Se.setMainSelectionJSON(N),Se.setPrevMainSelectionJSON(O),mp){let V=Se.getCurrentActiveSelectionJSON();a({state:Se.getCurrentContentStateJSON(),selection:V},[])}else d(Bu)},h=()=>{let v=[];return Se.getMainEditorNodesClassesMap().forEach((_,b,x)=>{let{klass:w}=_,S=f.registerMutationListener(w,C=>{for(let[k,D]of C){if(!Yr[D])continue;const N=Se.getLexicalNodeByKey(k);if(D===Yr.created&&N&&Gi.trackBlacklisted(N,D),w.name===An.TableNode.name&&(D===Yr.destroyed?Ro.tableNodeRemoveListener(k):Ro.tableUpdateListener(k)),w.name===An.TableRowNode.name&&D!==Yr.destroyed&&Ro.tableRowNodeChangesListener(k,D===Yr.updated),w.name===An.TableCellNode.name&&D===Yr.updated&&Ro.tableCellNodeChangesListener(k),w.name===io.MarkNode.name&&(ue.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:k,node:N,mutationType:D,codoxComments:On}),D===Yr.destroyed?On.removeRelatedNodeKey(k):N&&On.addRelatedNodeKey(N.__key,N.__ids,D===Yr.created)),N&&N.codoxId){if(D===Yr.destroyed)return void(N.codoxId&&Nn.remove(N.codoxId));Oy(N)||ue.warn("[MutationListener Error] duplicating codoxId detected - such codoxId already exists in codoxNodesMap - updating node ref to latest: ",{mutationType:D,node:N}),Nn.add(N.codoxId,N)}}v.push(S)})}),v},y={start:e,stop:n,on:(v,_)=>{ue.info(`Subscribing client to codox ${v} event`),vp[v]=_},cursor:{hide:()=>{So.hideRemoteSelectionsFromUI()},show:()=>{So.showHiddenRemoteSelectionsInUI()}},initComments:v=>{On.setInitialComments(v)}};return(0,Gt.useImperativeHandle)(c,()=>y),null}),YS=GS,ZS=["comments"];function _y(m,c){var p=Object.keys(m);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(m);c&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(m,f).enumerable})),p.push.apply(p,t)}return p}function bp(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?_y(Object(p),!0).forEach(function(t){XS(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):_y(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function XS(m,c,p){return(c=QS(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function QS(m){var c=t2(m,"string");return typeof c=="symbol"?c:c+""}function t2(m,c){if(typeof m!="object"||!m)return m;var p=m[Symbol.toPrimitive];if(p!==void 0){var t=p.call(m,c||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(m)}function e2(m,c){if(m==null)return{};var p,t,f=n2(m,c);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(m);for(t=0;t<r.length;t++)p=r[t],c.indexOf(p)>=0||{}.propertyIsEnumerable.call(m,p)&&(f[p]=m[p])}return f}function n2(m,c){if(m==null)return{};var p={};for(var t in m)if({}.hasOwnProperty.call(m,t)){if(c.indexOf(t)>=0)continue;p[t]=m[t]}return p}class r2 extends K0{constructor(){super(),this.mainEditor=null,this.mainEditorKey=null,this.currentContentStateJSON=null,this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null,this._isCodoxStarted=!1,this.prevContentStateJSON=null,this.prevMainSelectionJSON=null,this._undoInvoked=!1,this._redoInvoked=!1,this._canUndo=!1,this._canRedo=!1}setCanUndo(c){this._canUndo=c}setCanRedo(c){this._canRedo=c}canUndo(){return this._canUndo}canRedo(){return this._canRedo}setUndoInvoked(c){this._undoInvoked=c}setRedoInvoked(c){this._redoInvoked=c}undoInvoked(){return this._undoInvoked}redoInvoked(){return this._redoInvoked}setIsCodoxStarted(){let c=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this._isCodoxStarted=c}get isCodoxStarted(){return this._isCodoxStarted}getMainEditorKey(){return this.mainEditorKey}setMainEditor(c){this.mainEditor=c,this.mainEditorKey=c._key}clearJSONs(){ue.debug("[CodoxLexicalEditorManager][clearJSONs] invoked"),this.currentContentStateJSON=null,this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null,this.prevContentStateJSON=null,this.prevMainSelectionJSON=null}removeMainEditor(){this.mainEditor=null,this.mainEditorKey=null,this._undoInvoked=!1,this._redoInvoked=!1,this._canUndo=!1,this._canRedo=!1,super.clear()}getMainEditor(){return this.mainEditor}alignStateSelectionJSONsFromLatestEditor(){this.getMainEditorState().read(()=>{this.setCurrentContentStateJSON(this.getMainEditorState().toJSON()),this.setMainSelectionJSON($e.lexicalToJSON((0,_e.$getSelection)()))})}mainEditorExists(){return!!this.mainEditor}getMainEditorState(){return this.mainEditor?this.mainEditor.getEditorState():{}}getMainEditorNodesClassesMap(){return this.mainEditor?this.mainEditor._nodes:new Map}getLexicalNodeByKey(c){return this.mainEditor?this.getMainEditorState()._nodeMap.get(c):null}isLexicalEditorInstance(c){return c&&typeof c=="object"&&!!c.setEditorState}setCurrentContentStateJSON(c){return this.currentContentStateJSON=c,this.currentContentStateJSON}getCurrentContentStateJSON(){return this.currentContentStateJSON}setPrevContentStateJSON(c){this.prevContentStateJSON=c}getPrevContentStateJSON(){return this.prevContentStateJSON}setMainSelectionJSON(c){this.currentMainSelectionJSON=c,this.currentMainSelectionJSON&&this.currentNestedSelectionJSON&&(this.currentNestedSelectionJSON=null)}setNestedSelectionJSON(c){this.currentNestedSelectionJSON=c,this.currentNestedSelectionJSON&&this.currentMainSelectionJSON&&(this.currentMainSelectionJSON=null)}getCurrentMainSelectionJSON(){return this.currentMainSelectionJSON}getCurrentNestedSelectionJSON(){return this.currentNestedSelectionJSON}getCurrentActiveSelectionJSON(){return!this.currentMainSelectionJSON&&this.currentNestedSelectionJSON?this.currentNestedSelectionJSON:this.currentMainSelectionJSON}clearSelectionJSON(){this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null}setPrevMainSelectionJSON(c){this.prevMainSelectionJSON=c}getPrevMainSelectionJSON(){return this.prevMainSelectionJSON}extractStateAndCommentsFromSynced(c){let{state:{comments:p},selection:t,stateReplace:f}=c;return{stateFromSync:{state:bp({},e2(c.state,ZS)),selection:t,stateReplace:f},commentsFromSync:p}}composeFullStateWithRootAndComments(){let{directlyFromEditor:c=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return bp(bp({},c?this.getMainEditorState().toJSON():this.currentContentStateJSON),{},{comments:On.getAllComments()})}isValidJSONState(c){let p=!1;try{if(!c)throw new Error("State is undefined");if(!c.root)throw new Error("State 'root' node is missing");let t=this.getMainEditorNodesClassesMap(),f=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",e=r,s=t.get(e.type);if(!s)throw new Error(`Node with type "${e.type}" is not registered in editor`);let{klass:i}=s;if(n==="root"){let l=i.prototype instanceof _e.ElementNode,o=i.prototype instanceof _e.DecoratorNode;if(!l&&!o)throw new Error("State root node can have only element nodes as children")}if(e.children)for(let l of e.children)f(l,e.type)};f(c.root),p=!0}catch(t){ue.error("[isValidJSONState] invalid state found: ",t.message),p=!1}return p}scanLexicalNodeForNestedEditorAttribute(c){for(let p in c){let t=c[p];if(this.isLexicalEditorInstance(t))return p}return""}isOnlySelectionChanged(c,p){return c.size===0&&p.size===0}addUpdateTag(){let{isSameState:c,isSameSelection:p,fromNestedEditor:t=!1,updateTag:f=""}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return f?(ue.log(`[addUpdateTag] explicit add of tag "${f}" `),void(0,_e.$addUpdateTag)(f)):t?(ue.log(`[addUpdateTag] add "${ao.historic}" tag - change invoked by nested editor`),void(0,_e.$addUpdateTag)(ao.historic)):void(c?(ue.log(`[addUpdateTag] add "${ao.historic}" tag - state is same`),(0,_e.$addUpdateTag)(ao.historic)):(ue.log(`[addUpdateTag] add "${ao.historyMerge}" tag - state is different`),(0,_e.$addUpdateTag)(ao.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const o2=new r2,Se=o2;class i2{constructor(){this._nodesMap=new Map,this._pastedNodesCodoxIds=new Set}get size(){return this._nodesMap.size}add(c,p){this._nodesMap.set(c,p)}get(c){return this._nodesMap.get(c)||null}remove(c){this._nodesMap.delete(c)}has(c){return this._nodesMap.has(c)}nodesToArray(){return Array.from(this._nodesMap.values())}keysToArray(){return Array.from(this._nodesMap.keys())}toArray(){return Array.from(this._nodesMap.entries())}addPastedId(c){this._pastedNodesCodoxIds.add(c)}removePastedId(c){this._pastedNodesCodoxIds.delete(c)}hasPastedId(c){return this._pastedNodesCodoxIds.has(c)}clearPastedIds(){this._pastedNodesCodoxIds.size>0&&this._pastedNodesCodoxIds.clear()}isEmptyPastedIds(){return this._pastedNodesCodoxIds.size===0}getPastedIdsSize(){return this._pastedNodesCodoxIds.size}clearAll(){this._nodesMap.clear(),this._pastedNodesCodoxIds.clear()}gcAbandonedNodes(){let c=Se.getMainEditorState();if(!c._nodeMap)return;let p=this.nodesToArray();for(let t of p)c._nodeMap.has(t.__key)||this.remove(t.codoxId)}}const a2=new i2,Nn=a2;function xy(m,c){var p=Object.keys(m);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(m);c&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(m,f).enumerable})),p.push.apply(p,t)}return p}function wy(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?xy(Object(p),!0).forEach(function(t){s2(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):xy(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function s2(m,c,p){return(c=l2(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function l2(m){var c=c2(m,"string");return typeof c=="symbol"?c:c+""}function c2(m,c){if(typeof m!="object"||!m)return m;var p=m[Symbol.toPrimitive];if(p!==void 0){var t=p.call(m,c||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(m)}const _p=()=>yw(),Sy=m=>typeof m=="number";function js(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const p=function(){for(var t=arguments.length,f=new Array(t),r=0;r<t;r++)f[r]=arguments[r];return m.apply(this,f)};return Object.defineProperty(p,"name",{value:c,writable:!0}),p}const Pa=m=>m.__type==="root"||m.type==="root",Ey=m=>Pa(m.getParent()),Wn=m=>m.__type===Nu.text||m.type===Nu.text||m.hasOwnProperty("__text")||m.hasOwnProperty("text"),Ns=m=>(0,_e.$isElementNode)(m),Is=m=>(0,An.$isTableNode)(m)||(0,An.$isTableRowNode)(m)||(0,An.$isTableCellNode)(m),u2=m=>!m.getChildren,Cy=m=>!!m.getChildren,Tn=m=>(0,_e.$isDecoratorNode)(m),Xl=m=>(0,cw.$isLinkNode)(m),Ql=m=>m.__type==="mark"||m.type==="mark",xp=m=>(0,_e.$isLineBreakNode)(m),Yi=m=>Wn(m)||xp(m),wp=m=>m.__type===Nu.horizontalrule||m.type===Nu.horizontalrule,ky=m=>{if(Yi(m)||Xl(m)||Ql(m))return!1;if(!m.__parent||m.__parent==="root"||(0,_e.$isParagraphNode)(m))return!0;let c=m.getParent().getChildren();return c.length===1&&c[0].__key===m.__key?!((Tn(m)||Xl(m)||Ql(m))&&!wp(m)):!c.some(p=>{let t=wp(p);return p.__key!==m.__key&&(Yi(p)||Tn(p)&&!t||Xl(p)||Ql(p))})},Oy=m=>{const c=Nn.get(m.codoxId);return!c||m.__key===c.__key},Rs=function(m){const c=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||_p();m.codoxId=c,Nn.add(c,m)},Ty=m=>{Nn.remove(m.codoxId),delete m.codoxId},d2=m=>{if(!Cy(m)||!m.getChildrenSize())return;const c=m.getChildren();if(c.some(f=>!!(0,_e.$isParagraphNode)(f)))return;let p=!1,t=[];for(let f of c)(Yi(f)||Tn(f)||Xl(f)||Ql(f))&&!p&&(wp(f)||(p=!0)),(Cy(f)||Tn(f))&&t.push(f);for(let f of t)p||f.codoxId?p&&f.codoxId&&(f=f.getWritable(),Ty(f)):(f=f.getWritable(),Rs(f))},f2=m=>{const c=wy({},m);for(const p in m)m[p]===void 0&&m.hasOwnProperty(p)&&delete c[p];return c},p2=m=>{const c=`__nativeCreateDOM_${m.name}`;m.prototype[c]=js(m.prototype.createDOM,c),m.prototype.createDOM=function(p,t){if(ky(this))if(this.codoxId){if(!Oy(this)){let r=Nn.get(this.codoxId);r.__type===this.__type&&this.isAttached()&&!r.isAttached()?(ue.warn("[createDOM][Non-unique codoxId] overwrite abandoned existing node with latest: ",{latestNode:this,existingNode:r}),Nn.add(this.codoxId,this)):Rs(this)}}else Rs(this);else this.codoxId&&Ty(this);Tn(this)&&!this.codoxDId&&(this.codoxDId=_p()),di.manageNestedEditorInLexicalNode(this);let f=this[c](p,t);return f.__codox_track=!0,f}},h2=m=>{const c=`__nativeUpdateDOM_${m.name}`;return m.prototype[c]=js(m.prototype.updateDOM,c),m.prototype.updateDOM=function(){const p=this[c](...arguments);return d2(this),p},m},g2=m=>{const c=`__nativeRemove_${m.name}`;return m.prototype[c]=js(m.prototype.remove,c),m.prototype.remove=function(){const p=this.codoxId;return p&&Nn.remove(p),di.gcNestedEditorListenerInLexicalNode(this),this[c](...arguments)},m},m2=m=>{const c=`__nativeExportJSON_${m.name}`;m.prototype[c]=js(m.prototype.exportJSON,c),m.prototype.exportJSON=function(){const p=this[c]();return this.codoxId&&(p.codoxId=this.codoxId),this.codoxDId&&(p.codoxDId=this.codoxDId),Wn(this)&&Sy(p.format)&&this.hasFormat&&(p.format=Tw(this)),f2(p)}},y2=m=>{const c="__nativeImportJSON";m[c]=js(m.importJSON,c),m.importJSON=function(p){const t=wy({},p);Wn(t)&&!Sy(t.format)&&(t.format=Ow(t.format));const f=m[c](t);di.manageNestedEditorInLexicalNode(f);const r=ky(f);return r&&t.codoxId&&(Nn.hasPastedId(t.codoxId)&&Nn.has(t.codoxId)?(Nn.removePastedId(t.codoxId),Rs(f)):Rs(f,t.codoxId)),r&&!f.codoxId&&Rs(f),t.codoxDId&&(f.codoxDId=t.codoxDId),f}},v2=m=>{const c="__nativeClone";m[c]=js(m.clone,c),m.clone=function(p){const t=m[c](p);return p.codoxId&&(t.codoxId=p.codoxId),p.codoxDId&&(t.codoxDId=p.codoxDId),di.manageNestedEditorInClonedLexicalNode(p,t),t}},b2=m=>{let c=!1,p=!1,t=!1,f=!1;m.forEach(n=>{n.name===_e.TextNode.name?c=!0:n.name===_e.ParagraphNode.name?p=!0:n.name===_e.LineBreakNode.name?t=!0:n.name===io.MarkNode.name&&(f=!0)});let r=[];return c||r.push(_e.TextNode),p||r.push(_e.ParagraphNode),t||r.push(_e.LineBreakNode),f||r.push(io.MarkNode),r.length?[...r,...m]:m},_2=function(){return b2(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(m=>(m.hasOwnProperty("__isCodoxExtended")||(p2(m),h2(m),m2(m),g2(m),y2(m),v2(m),Object.defineProperty(m,"__isCodoxExtended",{value:!0,writable:!1})),m))};var Fu=on(777),Ms={};Ms.styleTagTransform=ui(),Ms.setAttributes=li(),Ms.insert=si().bind(null,"head"),Ms.domAPI=ai(),Ms.insertStyleElement=ci(),ii()(Fu.A,Ms),Fu.A&&Fu.A.locals&&Fu.A.locals;var x2=m=>{var c={};return on.d(c,m),c};const w2=x2({AutoFocusPlugin:()=>Im});var S2=m=>{var c={};return on.d(c,m),c};const E2=S2({ClearEditorPlugin:()=>Vx});var C2=m=>{var c={};return on.d(c,m),c};const k2=C2({LexicalComposer:()=>Nm});var O2=m=>{var c={};return on.d(c,m),c};const Ay=O2({default:()=>Gx});var T2=m=>{var c={};return on.d(c,m),c};const A2=T2({HistoryPlugin:()=>Xm});var P2=m=>{var c={};return on.d(c,m),c};const j2=P2({OnChangePlugin:()=>$0});var N2=m=>{var c={};return on.d(c,m),c};const I2=N2({PlainTextPlugin:()=>ow});var R2=m=>{var c={};return on.d(c,m),c};const Py=R2({$isRootTextContentEmpty:()=>t0,$rootTextContent:()=>Qm});var M2=m=>{var c={};return on.d(c,m),c};const Ds=M2({createPortal:()=>_1.createPortal}),D2=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,L2=D2?Gt.useLayoutEffect:Gt.useEffect,jy=L2;var zu=on(253),Ls={};Ls.styleTagTransform=ui(),Ls.setAttributes=li(),Ls.insert=si().bind(null,"head"),Ls.domAPI=ai(),Ls.insertStyleElement=ci(),ii()(zu.A,Ls),zu.A&&zu.A.locals&&zu.A.locals;function B2(m){let{onClose:c,children:p,title:t,closeOnClickOutside:f}=m;const r=(0,Gt.useRef)(null);return(0,Gt.useEffect)(()=>{r.current!==null&&r.current.focus()},[]),(0,Gt.useEffect)(()=>{let n=null;const e=l=>{l.key==="Escape"&&c()},s=l=>{const o=l.target;r.current!==null&&!r.current.contains(o)&&f&&c()},i=r.current;return i!==null&&(n=i.parentElement,n!==null&&n.addEventListener("click",s)),window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),n!==null&&(n==null||n.removeEventListener("click",s))}},[f,c]),Gt.createElement("div",{className:"Modal__overlay",role:"dialog"},Gt.createElement("div",{className:"Modal__modal",tabIndex:-1,ref:r},Gt.createElement("h2",{className:"Modal__title"},t),Gt.createElement("button",{className:"Modal__closeButton","aria-label":"Close modal",type:"button",onClick:c},"X"),Gt.createElement("div",{className:"Modal__content"},p)))}function F2(m){let{onClose:c,children:p,title:t,closeOnClickOutside:f=!1}=m;return(0,Ds.createPortal)(Gt.createElement(B2,{onClose:c,title:t,closeOnClickOutside:f},p),document.body)}function Ny(){const[m,c]=(0,Gt.useState)(null),p=(0,Gt.useCallback)(()=>{c(null)},[]),t=(0,Gt.useMemo)(()=>{if(m===null)return null;const{title:r,content:n,closeOnClickOutside:e}=m;return Gt.createElement(F2,{onClose:p,title:r,closeOnClickOutside:e},n)},[m,p]),f=(0,Gt.useCallback)(function(r,n){c({closeOnClickOutside:arguments.length>2&&arguments[2]!==void 0&&arguments[2],content:n(p),title:r})},[p]);return[t,f]}var Uu=on(191),Bs={};Bs.styleTagTransform=ui(),Bs.setAttributes=li(),Bs.insert=si().bind(null,"head"),Bs.domAPI=ai(),Bs.insertStyleElement=ci(),ii()(Uu.A,Bs),Uu.A&&Uu.A.locals&&Uu.A.locals;const z2={blockCursor:"CommentEditorTheme__blockCursor",characterLimit:"CommentEditorTheme__characterLimit",code:"CommentEditorTheme__code",codeHighlight:{atrule:"CommentEditorTheme__tokenAttr",attr:"CommentEditorTheme__tokenAttr",boolean:"CommentEditorTheme__tokenProperty",builtin:"CommentEditorTheme__tokenSelector",cdata:"CommentEditorTheme__tokenComment",char:"CommentEditorTheme__tokenSelector",class:"CommentEditorTheme__tokenFunction","class-name":"CommentEditorTheme__tokenFunction",comment:"CommentEditorTheme__tokenComment",constant:"CommentEditorTheme__tokenProperty",deleted:"CommentEditorTheme__tokenProperty",doctype:"CommentEditorTheme__tokenComment",entity:"CommentEditorTheme__tokenOperator",function:"CommentEditorTheme__tokenFunction",important:"CommentEditorTheme__tokenVariable",inserted:"CommentEditorTheme__tokenSelector",keyword:"CommentEditorTheme__tokenAttr",namespace:"CommentEditorTheme__tokenVariable",number:"CommentEditorTheme__tokenProperty",operator:"CommentEditorTheme__tokenOperator",prolog:"CommentEditorTheme__tokenComment",property:"CommentEditorTheme__tokenProperty",punctuation:"CommentEditorTheme__tokenPunctuation",regex:"CommentEditorTheme__tokenVariable",selector:"CommentEditorTheme__tokenSelector",string:"CommentEditorTheme__tokenSelector",symbol:"CommentEditorTheme__tokenProperty",tag:"CommentEditorTheme__tokenProperty",url:"CommentEditorTheme__tokenOperator",variable:"CommentEditorTheme__tokenVariable"},embedBlock:{base:"CommentEditorTheme__embedBlock",focus:"CommentEditorTheme__embedBlockFocus"},hashtag:"CommentEditorTheme__hashtag",heading:{h1:"CommentEditorTheme__h1",h2:"CommentEditorTheme__h2",h3:"CommentEditorTheme__h3",h4:"CommentEditorTheme__h4",h5:"CommentEditorTheme__h5",h6:"CommentEditorTheme__h6"},image:"editor-image",indent:"CommentEditorTheme__indent",inlineImage:"inline-editor-image",layoutContainer:"CommentEditorTheme__layoutContainer",layoutItem:"CommentEditorTheme__layoutItem",link:"CommentEditorTheme__link",list:{checklist:"CommentEditorTheme__checklist",listitem:"CommentEditorTheme__listItem",listitemChecked:"CommentEditorTheme__listItemChecked",listitemUnchecked:"CommentEditorTheme__listItemUnchecked",nested:{listitem:"CommentEditorTheme__nestedListItem"},olDepth:["CommentEditorTheme__ol1","CommentEditorTheme__ol2","CommentEditorTheme__ol3","CommentEditorTheme__ol4","CommentEditorTheme__ol5"],ul:"CommentEditorTheme__ul"},ltr:"CommentEditorTheme__ltr",mark:"CommentEditorTheme__mark",markOverlap:"CommentEditorTheme__markOverlap",paragraph:"CommentEditorTheme__paragraph",quote:"CommentEditorTheme__quote",rtl:"CommentEditorTheme__rtl",table:"CommentEditorTheme__table",tableCell:"CommentEditorTheme__tableCell",tableCellActionButton:"CommentEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"CommentEditorTheme__tableCellActionButtonContainer",tableCellEditing:"CommentEditorTheme__tableCellEditing",tableCellHeader:"CommentEditorTheme__tableCellHeader",tableCellPrimarySelected:"CommentEditorTheme__tableCellPrimarySelected",tableCellResizer:"CommentEditorTheme__tableCellResizer",tableCellSelected:"CommentEditorTheme__tableCellSelected",tableCellSortedIndicator:"CommentEditorTheme__tableCellSortedIndicator",tableResizeRuler:"CommentEditorTheme__tableCellResizeRuler",tableSelected:"CommentEditorTheme__tableSelected",tableSelection:"CommentEditorTheme__tableSelection",text:{bold:"CommentEditorTheme__textBold",code:"CommentEditorTheme__textCode",italic:"CommentEditorTheme__textItalic",strikethrough:"CommentEditorTheme__textStrikethrough",subscript:"CommentEditorTheme__textSubscript",superscript:"CommentEditorTheme__textSuperscript",underline:"CommentEditorTheme__textUnderline",underlineStrikethrough:"CommentEditorTheme__textUnderlineStrikethrough"}},U2=z2;var $u=on(72),Fs={};Fs.styleTagTransform=ui(),Fs.setAttributes=li(),Fs.insert=si().bind(null,"head"),Fs.domAPI=ai(),Fs.insertStyleElement=ci(),ii()($u.A,Fs),$u.A&&$u.A.locals&&$u.A.locals;function $2(){for(var m=arguments.length,c=new Array(m),p=0;p<m;p++)c[p]=arguments[p];return c.filter(Boolean).join(" ")}function Sp(){return Sp=Object.assign?Object.assign.bind():function(m){for(var c=1;c<arguments.length;c++){var p=arguments[c];for(var t in p)({}).hasOwnProperty.call(p,t)&&(m[t]=p[t])}return m},Sp.apply(null,arguments)}function Zi(m){let{"data-test-id":c,children:p,className:t,onClick:f,disabled:r,small:n,title:e}=m;return Gt.createElement("button",Sp({disabled:r,className:$2("Button__root",r&&"Button__disabled",n&&"Button__small",t),onClick:f,title:e,"aria-label":e},c&&{"data-test-id":c}),p)}var Hu=on(129),zs={};zs.styleTagTransform=ui(),zs.setAttributes=li(),zs.insert=si().bind(null,"head"),zs.domAPI=ai(),zs.insertStyleElement=ci(),ii()(Hu.A,zs),Hu.A&&Hu.A.locals&&Hu.A.locals;var H2=m=>{var c={};return on.d(c,m),c};const q2=H2({ContentEditable:()=>Rm});function W2(m){let{className:c}=m;return Gt.createElement(q2.ContentEditable,{className:c||"ContentEditable__root"})}var qu=on(457),Us={};Us.styleTagTransform=ui(),Us.setAttributes=li(),Us.insert=si().bind(null,"head"),Us.domAPI=ai(),Us.insertStyleElement=ci(),ii()(qu.A,Us),qu.A&&qu.A.locals&&qu.A.locals;function J2(m){let{children:c,className:p}=m;return Gt.createElement("div",{className:p||"Placeholder__root"},c)}const V2=Ay.default.LexicalErrorBoundary||Ay.default,K2=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"#050505",className:"codox-add-comment-right"},Gt.createElement("path",{d:"M14 1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H4.414A2 2 0 0 0 3 11.586l-2 2V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12.793a.5.5 0 0 0 .854.353l2.853-2.853A1 1 0 0 1 4.414 12H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"}),Gt.createElement("path",{d:"M3 3.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 6a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 6zm0 2.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"})),Iy=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"currentColor",className:"codox-remove-comment"},Gt.createElement("path",{d:"M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5ZM11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H2.506a.58.58 0 0 0-.01 0H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1h-.995a.59.59 0 0 0-.01 0H11Zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5h9.916Zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47ZM8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5Z"})),G2=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",className:"codox-add-comment"},Gt.createElement("path",{d:"M15.854.146a.5.5 0 0 1 .11.54l-5.819 14.547a.75.75 0 0 1-1.329.124l-3.178-4.995L.643 7.184a.75.75 0 0 1 .124-1.33L15.314.037a.5.5 0 0 1 .54.11ZM6.636 10.07l2.761 4.338L14.13 2.576 6.636 10.07Zm6.787-8.201L1.591 6.602l4.339 2.76 7.494-7.493Z"})),Y2=()=>Gt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",fill:"#0000008c",className:"codox-hide-show-comments"},Gt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M13 5.885v1.166a3.95 3.95 0 0 1-3.949 3.95H6.917a.748.748 0 0 0-.45.15l-1.345 1.007a.752.752 0 0 0-.032 1.181A2.933 2.933 0 0 0 6.95 14h2.716l2.534 1.901a.506.506 0 0 0 .524.047A.501.501 0 0 0 13 15.5V14h.051a2.949 2.949 0 0 0 2.95-2.949v-3.05a3.002 3.002 0 0 0-2.002-2.83.756.756 0 0 0-.999.714"}),Gt.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.05 1H2.95A2.952 2.952 0 0 0 0 3.949v3.102A2.952 2.952 0 0 0 2.949 10H3v1.5a.502.502 0 0 0 .8.4L6.334 10H9.05A2.952 2.952 0 0 0 12 7.05V3.95A2.952 2.952 0 0 0 9.05 1"}));function Ry(m,c,p){let t=arguments.length>3&&arguments[3]!==void 0?arguments[3]:performance.now(),f=arguments.length>4&&arguments[4]!==void 0&&arguments[4];return On.createNewCommentObj({content:m,author:c,codoxId:p,timeStamp:t,deleted:f})}function Z2(m,c,p){return On.createNewThreadObj({quote:m,comments:c,codoxId:p})}function X2(m){let{anchorKey:c,editor:p,onAddComment:t}=m;const f=(0,Gt.useRef)(null),r=(0,Gt.useCallback)(()=>{const n=f.current,e=p.getRootElement(),s=p.getElementByKey(c);if(n!==null&&e!==null&&s!==null){const{right:i}=e.getBoundingClientRect(),{top:l}=s.getBoundingClientRect();n.style.left=i-20+"px",n.style.top=l-30+"px"}},[c,p]);return(0,Gt.useEffect)(()=>(window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}),[p,r]),jy(()=>{r()},[c,p,r]),Gt.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:f},Gt.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:t},Gt.createElement(K2,null)))}function Q2(m){let{onEscape:c}=m;const[p]=(0,Ki.useLexicalComposerContext)();return(0,Gt.useEffect)(()=>p.registerCommand(_e.KEY_ESCAPE_COMMAND,t=>c(t),2),[p,c]),null}function tE(m){let{editorRef:c}=m;const[p]=(0,Ki.useLexicalComposerContext)();return typeof c=="function"?c(p):typeof c=="object"&&(c.current=p),null}function My(m){let{className:c,autoFocus:p,onEscape:t,onChange:f,editorRef:r,placeholder:n="Type a comment...",onEditorClick:e=()=>{}}=m;const s={namespace:"Commenting",nodes:[],onError:i=>{throw i},theme:U2};return Gt.createElement(k2.LexicalComposer,{initialConfig:s},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:e},Gt.createElement(I2.PlainTextPlugin,{contentEditable:Gt.createElement(W2,{className:c}),placeholder:Gt.createElement(J2,null,n),ErrorBoundary:V2}),Gt.createElement(j2.OnChangePlugin,{onChange:f}),Gt.createElement(A2.HistoryPlugin,null),p!==!1&&Gt.createElement(w2.AutoFocusPlugin,null),Gt.createElement(Q2,{onEscape:t}),Gt.createElement(E2.ClearEditorPlugin,null),r!==void 0&&Gt.createElement(tE,{editorRef:r})))}function Dy(m,c){return(0,Gt.useCallback)((p,t)=>{p.read(()=>{m((0,Py.$rootTextContent)()),c(!(0,Py.$isRootTextContentEmpty)(t.isComposing(),!0))})},[c,m])}function eE(m){let{editor:c,cancelAddComment:p,submitAddComment:t}=m;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),s=(0,Gt.useRef)(null),i=(0,Gt.useMemo)(()=>({container:document.createElement("div"),elements:[]}),[]),l=(0,Gt.useRef)(null),o=Fy(),a=(0,Gt.useCallback)(()=>{c.getEditorState().read(()=>{const u=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(u)){l.current=u.clone();const g=u.anchor,h=u.focus,y=(0,Ta.createDOMRange)(c,g.getNode(),g.offset,h.getNode(),h.offset),v=s.current;if(y!==null&&v!==null){const{left:_,bottom:b,width:x}=y.getBoundingClientRect(),w=(0,Ta.createRectsFromDOMRange)(c,y);let S=w.length===1?_+x/2-125:_-125;S<10&&(S=10),v.style.left=`${S}px`,v.style.top=`${b+20+(window.pageYOffset||document.documentElement.scrollTop)}px`;const C=w.length,{container:k}=i,D=i.elements,N=D.length;for(let O=0;O<C;O++){const R=w[O];let A=D[O];A===void 0&&(A=document.createElement("span"),D[O]=A,k.appendChild(A));const U="255, 212, 0",q=`position:absolute;top:${R.top+(window.pageYOffset||document.documentElement.scrollTop)}px;left:${R.left}px;height:${R.height}px;width:${R.width}px;background-color:rgba(${U}, 0.3);pointer-events:none;z-index:5;`;A.style.cssText=q}for(let O=N-1;O>=C;O--){const R=D[O];k.removeChild(R),D.pop()}}}})},[c,i]);jy(()=>{a();const u=i.container,g=document.body;if(g!==null)return g.appendChild(u),()=>{g.removeChild(u)}},[i.container,a]),(0,Gt.useEffect)(()=>(window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}),[a]);const d=Dy(r,e);return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:s},Gt.createElement(My,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:u=>(u.preventDefault(),p(),!0),onChange:d}),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},Gt.createElement(Zi,{onClick:p,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),Gt.createElement(Zi,{onClick:()=>{if(n){let u=c.getEditorState().read(()=>{const g=l.current;return g?g.getTextContent():""});u.length>100&&(u=u.slice(0,99)+"…"),t(Z2(u,[Ry(f,o)]),!0,void 0,l.current),l.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function nE(m){let{submitAddComment:c,thread:p,placeholder:t}=m;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),s=(0,Gt.useRef)(null),i=Fy(),l=Dy(r,e);return Gt.createElement(Gt.Fragment,null,Gt.createElement(My,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:l,editorRef:s,placeholder:t}),Gt.createElement(Zi,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){c(Ry(f,i),!1,p);const o=s.current;o!==null&&o.dispatchCommand(_e.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},Gt.createElement(G2,null)))}function Ly(m){let{commentOrThread:c,deleteCommentOrThread:p,onClose:t,thread:f}=m;return Gt.createElement(Gt.Fragment,null,"Are you sure you want to delete this ",c.type,"?",Gt.createElement("div",{className:"Modal__content"},Gt.createElement(Zi,{onClick:()=>{p(c,f),t()}},"Delete")," ",Gt.createElement(Zi,{onClick:()=>{t()}},"Cancel")))}function By(m){let{comment:c,deleteComment:p,thread:t,rtf:f}=m;const r=Math.round((c.timeStamp-performance.now())/1e3),n=Math.round(r/60),[e,s]=Ny();return Gt.createElement("li",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment"},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Details"},Gt.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Author"},c.author),Gt.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Time"},"· ",r>-10?"Just now":f.format(n,"minute"))),Gt.createElement("p",{className:c.deleted?"CodoxCommentPlugin_CommentsPanel_DeletedComment":""},c.content),!c.deleted&&Gt.createElement(Gt.Fragment,null,Gt.createElement(Zi,{onClick:()=>{s("Delete Comment",i=>Gt.createElement(Ly,{commentOrThread:c,deleteCommentOrThread:p,thread:t,onClose:i}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(Iy,null)),e))}function rE(m){let{activeIDs:c,comments:p,deleteCommentOrThread:t,listRef:f,submitAddComment:r,markNodeMap:n}=m;const[e]=(0,Ki.useLexicalComposerContext)(),[s,i]=(0,Gt.useState)(0),[l,o]=Ny(),a=(0,Gt.useMemo)(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return(0,Gt.useEffect)(()=>{const d=setTimeout(()=>{i(s+1)},1e4);return()=>{clearTimeout(d)}},[s]),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List",ref:f},p.map(d=>{const u=d.codoxId;if(!u)return null;if(d.type==="thread"){const g=()=>{if(n.get(u)!==void 0&&(c===null||c.indexOf(u)===-1)){const h=document.activeElement;e.update(()=>{(0,_e.$setSelection)(null)},{onUpdate(){h!==null&&h.focus()}})}};return Gt.createElement("li",{key:u,onClick:g,className:`CodoxCommentPlugin_CommentsPanel_List_Thread ${n.has(u)?"interactive":""} ${c.indexOf(u)===-1?"":"active"}`},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_QuoteBox"},Gt.createElement("blockquote",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Quote"},"> ",Gt.createElement("span",null,d.quote)),Gt.createElement(Zi,{onClick:()=>{o("Delete Thread",h=>Gt.createElement(Ly,{commentOrThread:d,deleteCommentOrThread:t,onClose:h}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(Iy,null)),l),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},d.comments.map(h=>Gt.createElement(By,{key:h.codoxId,comment:h,deleteComment:t,thread:d,rtf:a}))),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},Gt.createElement(nE,{submitAddComment:r,thread:d,placeholder:"Reply to comment..."})))}return Gt.createElement(By,{key:u,comment:d,deleteComment:t,rtf:a})}))}function oE(m){let{activeIDs:c,deleteCommentOrThread:p,comments:t,submitAddComment:f,markNodeMap:r}=m;const n=(0,Gt.useRef)(null),e=t.length===0;return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel"},Gt.createElement("h2",{className:"CodoxCommentPlugin_CommentsPanel_Heading"},"Comments"),e?Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_Empty"},"No Comments"):Gt.createElement(rE,{activeIDs:c,comments:t,deleteCommentOrThread:p,listRef:n,submitAddComment:f,markNodeMap:r}))}function Fy(){const m=(0,my.useCollaborationContext)(),{yjsDocMap:c,name:p}=m;return p||"Playground User"}function iE(m){const[c]=(0,Ki.useLexicalComposerContext)(),p=Uw(),t=(0,Gt.useMemo)(()=>new Map,[]),[f,r]=(0,Gt.useState)(),[n,e]=(0,Gt.useState)([]),[s,i]=(0,Gt.useState)(!1),[l,o]=(0,Gt.useState)(!1);(0,Gt.useEffect)(()=>{!p.length&&l?o(!1):p.length},[p]);const a=(0,Gt.useCallback)(()=>{c.update(()=>{const g=(0,_e.$getSelection)();g!==null&&(g.dirty=!0)}),i(!1)},[c]),d=(0,Gt.useCallback)((g,h)=>{if(g.type==="comment"){if(ue.log("[deleteCommentOrThread]: type comment new values",{comment:g,thread:h,markNodeMap:t}),On.removeComment(h.codoxId,g.codoxId),!h)return;const y=h.codoxId,v=t.get(y);c.update(()=>{v?v.forEach((_,b)=>{const x=(0,_e.$getNodeByKey)(b);ue.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:x}),x&&x.markDirty()}):(0,_e.$getRoot)().markDirty(),(0,_e.$addUpdateTag)(ao.historic),(0,_e.$addUpdateTag)(Yl)})}else{ue.log("[deleteCommentOrThread]: type thread new values",{comment:g,markNodeMap:t});const y=h!==void 0?h.codoxId:g.codoxId,v=t.get(y);setTimeout(()=>{c.update(()=>{if(v)for(const _ of v){const b=(0,_e.$getNodeByKey)(_);ue.log("[deleteCommentOrThread]: type thread new values",{node:b}),(0,io.$isMarkNode)(b)&&(b.deleteID(y),b.getIDs().length===0&&(0,io.$unwrapMarkNode)(b))}else(0,_e.$getRoot)().markDirty(),ue.debug("[deleteCommentOrThread][refreshComments]");On.refreshComments(!0),(0,_e.$addUpdateTag)(Yl)})})}},[c,t]),u=(0,Gt.useCallback)((g,h,y,v)=>{if(ue.log("[submitAddComment]: new values",{commentOrThread:g,isInlineComment:h,thread:y,markNodeMap:t}),y?On.addComment(y.codoxId,g):On.addCommentThread(g),h)c.update(()=>{if((0,_e.$isRangeSelection)(v)){const _=v.isBackward(),b=g.codoxId;(0,io.$wrapSelectionInMarkNode)(v,_,b),(0,_e.$addUpdateTag)(Yl)}}),i(!1);else if(!h&&y){const _=y.codoxId,b=t.get(_);if(!b)return void On.removeComment(y.codoxId,g.codoxId);c.update(()=>{b.forEach((x,w)=>{let S=(0,_e.$getNodeByKey)(w);S&&S.markDirty()}),(0,_e.$addUpdateTag)(ao.historic),(0,_e.$addUpdateTag)(Yl)})}},[c]);return(0,Gt.useEffect)(()=>{const g=[];for(let h=0;h<n.length;h++){const y=n[h],v=t.get(y);if(v!==void 0)for(const _ of v){const b=c.getElementByKey(_);b!==null&&(b.classList.add("selected"),g.push(b),o(!0))}}return()=>{for(let h=0;h<g.length;h++)g[h].classList.remove("selected")}},[n,c,t]),(0,Gt.useEffect)(()=>{const g=new Map;return(0,Os.mergeRegister)((0,Os.registerNestedElementResolver)(c,io.MarkNode,h=>(0,io.$createMarkNode)(h.getIDs()),(h,y)=>{h.getIDs().forEach(v=>{y.addID(v)})}),c.registerMutationListener(io.MarkNode,h=>{c.getEditorState().read(()=>{for(const[y,v]of h){const _=(0,_e.$getNodeByKey)(y);let b=[];v==="destroyed"?b=g.get(y)||[]:(0,io.$isMarkNode)(_)&&(b=_.getIDs());for(let x=0;x<b.length;x++){const w=b[x];let S=t.get(w);g.set(y,b),v==="destroyed"?S!==void 0&&(S.delete(y),S.size===0&&t.delete(w)):(S===void 0&&(S=new Set,t.set(w,S)),S.has(y)||S.add(y))}}})}),c.registerUpdateListener(h=>{let{editorState:y,tags:v}=h;y.read(()=>{const _=(0,_e.$getSelection)();let b=!1,x=!1;if((0,_e.$isRangeSelection)(_)){const w=_.anchor.getNode();if((0,_e.$isTextNode)(w)){const S=(0,io.$getMarkIDs)(w,_.anchor.offset);S!==null&&(e(S),b=!0),_.isCollapsed()||(r(w.getKey()),x=!0)}}b||e(w=>w.length===0?w:[]),x||r(null),(0,_e.$isRangeSelection)(_)&&i(!1)})}),c.registerCommand(pp,()=>{const h=window.getSelection();return h!==null&&h.removeAllRanges(),i(!0),!0},_e.COMMAND_PRIORITY_EDITOR))},[c,t]),Gt.createElement(Gt.Fragment,null,s&&(0,Ds.createPortal)(Gt.createElement(eE,{editor:c,cancelAddComment:a,submitAddComment:u}),document.body),f!=null&&!s&&(0,Ds.createPortal)(Gt.createElement(X2,{anchorKey:f,editor:c,onAddComment:()=>{c.dispatchCommand(pp,void 0)}}),document.body),(0,Ds.createPortal)(Gt.createElement(Zi,{className:"CodoxCommentPlugin_ShowCommentsButton "+(l?"active":""),onClick:()=>o(!l),title:l?"Hide Comments":"Show Comments"},Gt.createElement(Y2,null)),document.body),l&&(0,Ds.createPortal)(Gt.createElement(oE,{comments:p,submitAddComment:u,deleteCommentOrThread:d,activeIDs:n,markNodeMap:t}),document.body))}var Wu=on(766),$s={};$s.styleTagTransform=ui(),$s.setAttributes=li(),$s.insert=si().bind(null,"head"),$s.domAPI=ai(),$s.insertStyleElement=ci(),ii()(Wu.A,$s),Wu.A&&Wu.A.locals&&Wu.A.locals;var Ju=on(225),Hs={};Hs.styleTagTransform=ui(),Hs.setAttributes=li(),Hs.insert=si().bind(null,"head"),Hs.domAPI=ai(),Hs.insertStyleElement=ci(),ii()(Ju.A,Hs),Ju.A&&Ju.A.locals&&Ju.A.locals;function aE(m){let{label:c,value:p,onChange:t,placeholder:f="","data-test-id":r,type:n="text"}=m;return Gt.createElement("div",{className:"CodoxInput__wrapper"},Gt.createElement("label",{className:"CodoxInput__label"},c),Gt.createElement("input",{type:n,className:"CodoxInput__input",placeholder:f,value:p,onChange:e=>{t(e.target.value)},"data-test-id":r}))}function zy(m,c){var p=Object.keys(m);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(m);c&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(m,f).enumerable})),p.push.apply(p,t)}return p}function Vu(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?zy(Object(p),!0).forEach(function(t){sE(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):zy(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function sE(m,c,p){return(c=lE(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function lE(m){var c=cE(m,"string");return typeof c=="symbol"?c:c+""}function cE(m,c){if(typeof m!="object"||!m)return m;var p=m[Symbol.toPrimitive];if(p!==void 0){var t=p.call(m,c||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(m)}let tc=!1;const uE=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],ec=214,Uy=150;function dE(m){let{color:c,onChange:p}=m;const[t,f]=(0,Gt.useState)(qs("hex",c)),[r,n]=(0,Gt.useState)(c),e=(0,Gt.useRef)(null),s=(0,Gt.useMemo)(()=>({x:t.hsv.s/100*ec,y:(100-t.hsv.v)/100*Uy}),[t.hsv.s,t.hsv.v]),i=(0,Gt.useMemo)(()=>({x:t.hsv.h/360*ec}),[t.hsv]);return(0,Gt.useEffect)(()=>{e.current!==null&&p&&n(t.hex)},[t,p]),(0,Gt.useEffect)(()=>{if(c===void 0)return;const l=qs("hex",c);f(l),n(l.hex)},[c]),Gt.createElement("div",{className:"codox-color-picker-wrapper",style:{width:ec},ref:e},Gt.createElement(aE,{label:"Hex",onChange:l=>{if(n(l),/^#[0-9A-Fa-f]{6}$/i.test(l)){const o=qs("hex",l);f(o)}},value:r}),Gt.createElement("div",{className:"codox-color-picker-basic-color"},uE.map(l=>Gt.createElement("button",{className:l===t.hex?" active":"",key:l,style:{backgroundColor:l},onClick:()=>(o=>{n(o);let a=qs("hex",o);f(a),p(a.hex,tc)})(l)}))),Gt.createElement($y,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`},onChange:l=>{let{x:o,y:a}=l;const d=qs("hsv",Vu(Vu({},t.hsv),{},{s:o/ec*100,v:100-a/Uy*100}));f(d),n(d.hex),p(d.hex,tc)}},Gt.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:t.hex,left:s.x,top:s.y}})),Gt.createElement($y,{className:"codox-color-picker-hue",onChange:l=>{let{x:o}=l;const a=qs("hsv",Vu(Vu({},t.hsv),{},{h:o/ec*360}));f(a),n(a.hex),p(a.hex,tc)}},Gt.createElement("div",{className:"codox-color-picker-hue_cursor",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`,left:i.x}})),Gt.createElement("div",{className:"codox-color-picker-color",style:{backgroundColor:t.hex}}))}function $y(m){let{className:c,style:p,onChange:t,children:f}=m;const r=(0,Gt.useRef)(null),n=(0,Gt.useRef)(!1),e=s=>{if(r.current){const{current:i}=r,{width:l,height:o,left:a,top:d}=i.getBoundingClientRect(),u=Hy(s.clientX-a,l,0),g=Hy(s.clientY-d,o,0);t({x:u,y:g})}};return Gt.createElement("div",{ref:r,className:c,style:p,onMouseDown:s=>{if(s.button!==0)return;e(s);const i=o=>{n.current=!0,tc=!0,e(o)},l=o=>{n.current&&(tc=!1),document.removeEventListener("mousemove",i,!1),document.removeEventListener("mouseup",l,!1),e(o),n.current=!1};document.addEventListener("mousemove",i,!1),document.addEventListener("mouseup",l,!1)}},f)}function Hy(m,c,p){return m>c?c:m<p?p:m}function qy(m){if(!m.startsWith("#")){const c=document.createElement("canvas").getContext("2d");if(!c)throw new Error("2d context not supported or canvas already initialized");return c.fillStyle=m,c.fillStyle}return m.length===4||m.length===5?m=m.split("").map((c,p)=>p?c+c:"#").join(""):m.length===7||m.length===9?m:"#000000"}function Wy(m){const c=(m.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(p,t,f,r)=>"#"+t+t+f+f+r+r).substring(1).match(/.{2}/g)||[]).map(p=>parseInt(p,16));return{b:c[2],g:c[1],r:c[0]}}function Ep(m){let{r:c,g:p,b:t}=m;c/=255,p/=255,t/=255;const f=Math.max(c,p,t),r=f-Math.min(c,p,t);return{h:r?60*(f===c?(p-t)/r+(p<t?6:0):f===p?2+(t-c)/r:4+(c-p)/r):0,s:f?r/f*100:0,v:100*f}}function fE(m){let{h:c,s:p,v:t}=m;p/=100,t/=100;const f=~~(c/60),r=c/60-f,n=t*(1-p),e=t*(1-p*r),s=t*(1-p*(1-r)),i=f%6,l=Math.round(255*[t,e,n,n,s,t][i]),o=Math.round(255*[s,t,t,e,n,n][i]);return{b:Math.round(255*[n,n,s,t,t,e][i]),g:o,r:l}}function Jy(m){let{b:c,g:p,r:t}=m;return"#"+[t,p,c].map(f=>f.toString(16).padStart(2,"0")).join("")}function qs(m,c){let p=qy("#121212"),t=Wy(p),f=Ep(t);return m==="hex"?(p=qy(c),t=Wy(p),f=Ep(t)):m==="rgb"?(t=c,p=Jy(t),f=Ep(t)):m==="hsv"&&(f=c,t=fE(f),p=Jy(t)),{hex:p,hsv:f,rgb:t}}const pE=Gt.createContext(null),Vy=4;function hE(m){let{children:c,dropDownRef:p,onClose:t,dropdownClassName:f}=m;const[r,n]=(0,Gt.useState)(),[e,s]=(0,Gt.useState)(),i=(0,Gt.useCallback)(o=>{n(a=>a?[...a,o]:[o])},[n]),l=(0,Gt.useMemo)(()=>({registerItem:i}),[i]);return(0,Gt.useEffect)(()=>{r&&!e&&s(r[0]),e&&e.current&&e.current.focus()},[r,e]),Gt.createElement(pE.Provider,{value:l},Gt.createElement("div",{className:f,ref:p,onKeyDown:o=>{if(!r)return;const a=o.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(a)&&o.preventDefault(),a==="Escape"||a==="Tab"?t():a==="ArrowUp"?s(d=>{if(!d)return r[0];const u=r.indexOf(d)-1;return r[u===-1?r.length-1:u]}):a==="ArrowDown"&&s(d=>d?r[r.indexOf(d)+1]:r[0])}},c))}function gE(m){let{disabled:c=!1,buttonLabel:p,buttonAriaLabel:t,buttonClassName:f,buttonIconClassName:r,children:n,stopCloseOnClickSelf:e,dropdownClassName:s,buttonLabelClassName:i,dropdownChevronClassName:l}=m;const o=(0,Gt.useRef)(null),a=(0,Gt.useRef)(null),[d,u]=(0,Gt.useState)(!1);return(0,Gt.useEffect)(()=>{const g=a.current,h=o.current;if(d&&g!==null&&h!==null){const{top:y,left:v}=g.getBoundingClientRect();h.style.top=`${y+g.offsetHeight+Vy}px`,h.style.left=`${Math.min(v,window.innerWidth-h.offsetWidth-20)}px`}},[o,a,d]),(0,Gt.useEffect)(()=>{const g=a.current;if(g!==null&&d){const h=y=>{const v=y.target;e&&o.current&&o.current.contains(v)||g.contains(v)||u(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[o,a,d,e]),(0,Gt.useEffect)(()=>{const g=()=>{if(d){const h=a.current,y=o.current;if(h!==null&&y!==null){const{top:v}=h.getBoundingClientRect(),_=v+h.offsetHeight+Vy;_!==y.getBoundingClientRect().top&&(y.style.top=`${_}px`)}}};return document.addEventListener("scroll",g),()=>{document.removeEventListener("scroll",g)}},[a,o,d]),Gt.createElement(Gt.Fragment,null,Gt.createElement("button",{type:"button",disabled:c,"aria-label":t||p,className:f,onClick:()=>u(!d),ref:a},r&&Gt.createElement("span",{className:r}),p&&Gt.createElement("span",{className:i},p),Gt.createElement("i",{className:l})),d&&(0,Ds.createPortal)(Gt.createElement(hE,{dropDownRef:o,onClose:()=>{u(!1),a&&a.current&&a.current.focus()},dropdownClassName:s},n),document.body))}const mE=["disabled","stopCloseOnClickSelf","color","onChange"];function Cp(){return Cp=Object.assign?Object.assign.bind():function(m){for(var c=1;c<arguments.length;c++){var p=arguments[c];for(var t in p)({}).hasOwnProperty.call(p,t)&&(m[t]=p[t])}return m},Cp.apply(null,arguments)}function yE(m,c){if(m==null)return{};var p,t,f=vE(m,c);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(m);for(t=0;t<r.length;t++)p=r[t],c.indexOf(p)>=0||{}.propertyIsEnumerable.call(m,p)&&(f[p]=m[p])}return f}function vE(m,c){if(m==null)return{};var p={};for(var t in m)if({}.hasOwnProperty.call(m,t)){if(c.indexOf(t)>=0)continue;p[t]=m[t]}return p}function Ky(m){let{disabled:c=!1,stopCloseOnClickSelf:p=!0,color:t,onChange:f}=m,r=yE(m,mE);return Gt.createElement(gE,Cp({},r,{disabled:c,stopCloseOnClickSelf:p}),Gt.createElement(dE,{color:t,onChange:f}))}const bE=m=>{let{onColorChange:c,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=m;const[i]=(0,Ki.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,d]=(0,Gt.useState)("");(0,Gt.useEffect)(()=>(0,Os.mergeRegister)(i.registerEditableListener(g=>{o(g)}),i.registerUpdateListener(g=>{let{editorState:h}=g;h.read(()=>{const y=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(y)){let v=(0,Ta.$getSelectionStyleValueForProperty)(y,"color");v!==a&&(d(v||""),c(v))}})})),[i]);const u=(0,Gt.useCallback)((g,h)=>{i.update(()=>{const y=(0,_e.$getSelection)();y!==null&&(0,Ta.$patchStyleText)(y,{color:g})})},[i]);return Gt.createElement(Ky,{disabled:!l,color:a,onChange:u,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},_E=bE,xE=m=>{let{onColorChange:c,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=m;const[i]=(0,Ki.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,d]=(0,Gt.useState)("#fff");(0,Gt.useEffect)(()=>(0,Os.mergeRegister)(i.registerEditableListener(g=>{o(g)}),i.registerUpdateListener(g=>{let{editorState:h}=g;h.read(()=>{const y=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(y)){let v=(0,Ta.$getSelectionStyleValueForProperty)(y,"background-color");v!==a&&(d(v||""),c(v))}})})),[i]);const u=(0,Gt.useCallback)((g,h)=>{i.update(()=>{const y=(0,_e.$getSelection)();y!==null&&(0,Ta.$patchStyleText)(y,{"background-color":g})})},[i]);return Gt.createElement(Ky,{disabled:!l,color:a,onChange:u,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},wE=xE;var SE=qi.yy;qi._U,qi.a8,qi.Vs,qi.Cn;var EE=qi.gK,CE=qi.vv;function kE(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}var Ku=kE(function(m){const c=new URLSearchParams;c.append("code",m);for(let p=1;p<arguments.length;p++)c.append("v",arguments[p]);throw Error(`Minified Lexical error #${m}; visit https://lexical.dev/docs/error?${c} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function OE({hasCellMerge:m=!0,hasCellBackgroundColor:c=!0,hasTabHandler:p=!0}){const[t]=hr();return se.useEffect(()=>(t.hasNodes([wo,$i,ql])||Ku(10),oo(t.registerCommand(Tx,({columns:f,rows:r,includeHeaders:n})=>{const e=E0(Number(r),Number(f),n);Km(e);const s=e.getFirstDescendant();return Pe(s)&&s.select(),!0},an),t.registerNodeTransform(wo,f=>{const[r]=T0(f,null,null),n=r.reduce((e,s)=>Math.max(e,s.length),0);for(let e=0;e<r.length;++e){const s=r[e].length;if(s===n)continue;const i=r[e][s-1].cell;for(let l=s;l<n;++l){const o=ri(0);o.append(jn()),i!==null?i.insertAfter(o):Gm(i,o)}}}))),[t]),se.useEffect(()=>{const f=new Map,r=e=>{const s=e.getKey(),i=t.getElementByKey(s);if(i&&!f.has(s)){const l=Ux(e,i,t,p);f.set(s,l)}};t.getEditorState().read(()=>{const e=Ig(wo);for(const s of e)Mn(s)&&r(s)});const n=t.registerMutationListener(wo,e=>{for(const[s,i]of e)if(i==="created")t.getEditorState().read(()=>{const l=Gn(s);Mn(l)&&r(l)});else if(i==="destroyed"){const l=f.get(s);l!==void 0&&(l.removeListeners(),f.delete(s))}});return()=>{n();for(const[,e]of f)e.removeListeners()}},[t,p]),se.useEffect(()=>{if(!m)return t.registerNodeTransform($i,f=>{if(f.getColSpan()>1||f.getRowSpan()>1){const[,,r]=Gr(f),[n]=Io(r,f,f),e=n.length,s=n[0].length;let i=r.getFirstChild();cr(i)||Ku(175);const l=[];for(let o=0;o<e;o++){o!==0&&(i=i.getNextSibling(),cr(i)||Ku(175));let a=null;for(let d=0;d<s;d++){const u=n[o][d],g=u.cell;if(u.startRow===o&&u.startColumn===d)a=g,l.push(g);else if(g.getColSpan()>1||g.getRowSpan()>1){rn(g)||Ku(176);const h=ri(g.__headerState);a!==null?a.insertAfter(h):Gm(i,h)}}}for(const o of l)o.setColSpan(1),o.setRowSpan(1)}})},[t,m]),se.useEffect(()=>{if(!c)return t.registerNodeTransform($i,f=>{f.getBackgroundColor()!==null&&f.setBackgroundColor(null)})},[t,c,m]),null}const dO="",TE={autocomplete:"PlaygroundEditorTheme__autocomplete",blockCursor:"PlaygroundEditorTheme__blockCursor",characterLimit:"PlaygroundEditorTheme__characterLimit",code:"PlaygroundEditorTheme__code",codeHighlight:{atrule:"PlaygroundEditorTheme__tokenAttr",attr:"PlaygroundEditorTheme__tokenAttr",boolean:"PlaygroundEditorTheme__tokenProperty",builtin:"PlaygroundEditorTheme__tokenSelector",cdata:"PlaygroundEditorTheme__tokenComment",char:"PlaygroundEditorTheme__tokenSelector",class:"PlaygroundEditorTheme__tokenFunction","class-name":"PlaygroundEditorTheme__tokenFunction",comment:"PlaygroundEditorTheme__tokenComment",constant:"PlaygroundEditorTheme__tokenProperty",deleted:"PlaygroundEditorTheme__tokenProperty",doctype:"PlaygroundEditorTheme__tokenComment",entity:"PlaygroundEditorTheme__tokenOperator",function:"PlaygroundEditorTheme__tokenFunction",important:"PlaygroundEditorTheme__tokenVariable",inserted:"PlaygroundEditorTheme__tokenSelector",keyword:"PlaygroundEditorTheme__tokenAttr",namespace:"PlaygroundEditorTheme__tokenVariable",number:"PlaygroundEditorTheme__tokenProperty",operator:"PlaygroundEditorTheme__tokenOperator",prolog:"PlaygroundEditorTheme__tokenComment",property:"PlaygroundEditorTheme__tokenProperty",punctuation:"PlaygroundEditorTheme__tokenPunctuation",regex:"PlaygroundEditorTheme__tokenVariable",selector:"PlaygroundEditorTheme__tokenSelector",string:"PlaygroundEditorTheme__tokenSelector",symbol:"PlaygroundEditorTheme__tokenProperty",tag:"PlaygroundEditorTheme__tokenProperty",url:"PlaygroundEditorTheme__tokenOperator",variable:"PlaygroundEditorTheme__tokenVariable"},embedBlock:{base:"PlaygroundEditorTheme__embedBlock",focus:"PlaygroundEditorTheme__embedBlockFocus"},hashtag:"PlaygroundEditorTheme__hashtag",heading:{h1:"PlaygroundEditorTheme__h1",h2:"PlaygroundEditorTheme__h2",h3:"PlaygroundEditorTheme__h3",h4:"PlaygroundEditorTheme__h4",h5:"PlaygroundEditorTheme__h5",h6:"PlaygroundEditorTheme__h6"},hr:"PlaygroundEditorTheme__hr",image:"editor-image",indent:"PlaygroundEditorTheme__indent",inlineImage:"inline-editor-image",layoutContainer:"PlaygroundEditorTheme__layoutContainer",layoutItem:"PlaygroundEditorTheme__layoutItem",link:"PlaygroundEditorTheme__link",list:{checklist:"PlaygroundEditorTheme__checklist",listitem:"PlaygroundEditorTheme__listItem",listitemChecked:"PlaygroundEditorTheme__listItemChecked",listitemUnchecked:"PlaygroundEditorTheme__listItemUnchecked",nested:{listitem:"PlaygroundEditorTheme__nestedListItem"},olDepth:["PlaygroundEditorTheme__ol1","PlaygroundEditorTheme__ol2","PlaygroundEditorTheme__ol3","PlaygroundEditorTheme__ol4","PlaygroundEditorTheme__ol5"],ul:"PlaygroundEditorTheme__ul"},ltr:"PlaygroundEditorTheme__ltr",mark:"PlaygroundEditorTheme__mark",markOverlap:"PlaygroundEditorTheme__markOverlap",paragraph:"PlaygroundEditorTheme__paragraph",quote:"PlaygroundEditorTheme__quote",rtl:"PlaygroundEditorTheme__rtl",table:"PlaygroundEditorTheme__table",tableCell:"PlaygroundEditorTheme__tableCell",tableCellActionButton:"PlaygroundEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"PlaygroundEditorTheme__tableCellActionButtonContainer",tableCellEditing:"PlaygroundEditorTheme__tableCellEditing",tableCellHeader:"PlaygroundEditorTheme__tableCellHeader",tableCellPrimarySelected:"PlaygroundEditorTheme__tableCellPrimarySelected",tableCellResizer:"PlaygroundEditorTheme__tableCellResizer",tableCellSelected:"PlaygroundEditorTheme__tableCellSelected",tableCellSortedIndicator:"PlaygroundEditorTheme__tableCellSortedIndicator",tableResizeRuler:"PlaygroundEditorTheme__tableCellResizeRuler",tableRowStriping:"PlaygroundEditorTheme__tableRowStriping",tableSelected:"PlaygroundEditorTheme__tableSelected",tableSelection:"PlaygroundEditorTheme__tableSelection",text:{bold:"PlaygroundEditorTheme__textBold",code:"PlaygroundEditorTheme__textCode",italic:"PlaygroundEditorTheme__textItalic",strikethrough:"PlaygroundEditorTheme__textStrikethrough",subscript:"PlaygroundEditorTheme__textSubscript",superscript:"PlaygroundEditorTheme__textSuperscript",underline:"PlaygroundEditorTheme__textUnderline",underlineStrikethrough:"PlaygroundEditorTheme__textUnderlineStrikethrough"}},AE="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE1IDE1IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMDAwMDEgOC4zMzMzM0wxLjkwMDAxIDEzLjhMMS4xMDAwMSAxMy4yTDUuMzc1MDEgNy41TDEuMTAwMDEgMS44TDEuOTAwMDEgMS4yTDYuMDAwMDEgNi42NjY2N0wxMC4xIDEuMkwxMC45IDEuOEw2LjYyNTAxIDcuNUwxMC45IDEzLjJMMTAuMSAxMy44TDYuMDAwMDEgOC4zMzMzM1pNMTIgMTIuNUMxMiAxMS42NzE2IDEyLjY3MTYgMTEgMTMuNSAxMUgxMy43OTI5QzE0LjQ1OTYgMTEgMTUgMTEuNTQwNCAxNSAxMi4yMDcxQzE1IDEyLjUyNzMgMTQuODcyOCAxMi44MzQzIDE0LjY0NjUgMTMuMDYwN0wxMy43MDcxIDE0SDE1VjE1SDEyLjVDMTIuMjk3OCAxNSAxMi4xMTU1IDE0Ljg3ODIgMTIuMDM4MSAxNC42OTEzQzExLjk2MDcgMTQuNTA0NSAxMi4wMDM1IDE0LjI4OTQgMTIuMTQ2NSAxNC4xNDY0TDEzLjkzOTMgMTIuMzUzNkMxMy45NzgyIDEyLjMxNDcgMTQgMTIuMjYyIDE0IDEyLjIwNzFDMTQgMTIuMDkyNyAxMy45MDczIDEyIDEzLjc5MjkgMTJIMTMuNUMxMy4yMjM5IDEyIDEzIDEyLjIyMzkgMTMgMTIuNUgxMloiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+",PE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDQgNTEyLjM2Ij48cGF0aCBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik00OTkuNDMgMjMxLjM2SDM2OC40Yy0yLjUzIDAtNC41OC0yLjA1LTQuNTgtNC41N3YtOC4xMWMwLTEuMjYuNTItMi40IDEuMzQtMy4yMmw3MS41Ny04Mi41M2M2LjczLTcuNzUgMTIuNTctMTQuOTcgMTcuNDgtMjEuNjggNC44OC02LjY0IDguODMtMTIuNzQgMTEuODUtMTguMjggMi45Ny01LjQzIDUuMTgtMTAuNjEgNi42NC0xNS41NSAxLjQyLTQuODUgMi4xMy05LjUzIDIuMTMtMTQgMC0xNC42OC0zLjk4LTI2LjA1LTExLjkyLTM0LjA5LTMuOTItMy45Ni04Ljc1LTYuOTMtMTQuNDktOC45Mi01Ljk1LTIuMDMtMTIuOTEtMy4wNS0yMC44Ny0zLjA1LTguNDUgMC0xNS44OCAxLjIxLTIyLjI5IDMuNjItNi4yNyAyLjM2LTExLjYzIDUuOTItMTYuMDcgMTAuNjNhNDcuODg0IDQ3Ljg4NCAwIDAgMC0xMC4xNCAxNi42Yy0yLjI3IDYuMjktMy40MSAxMy4zOS0zLjQxIDIxLjI2IDAgMi41Mi0yLjA1IDQuNTctNC41NyA0LjU3aC02Ljg5Yy0yLjA1IDAtMy44LTEuMzYtNC4zNy0zLjI0bC0uMjctLjgyYy0uMTgtLjU2LS4yNS0xLjEzLS4yMi0xLjY3LS4yMy05LjMyIDEuMTQtMTcuOTkgNC4xMi0yNS45NyAzLjAyLTguMTMgNy42OC0xNS41NCAxMy45NC0yMi4xOSA2LjI2LTYuNyAxMy42My0xMS43NiAyMi4xLTE1LjEzQzQwNy44NCAxLjY4IDQxNy4yIDAgNDI3LjU1IDBjOS41OSAwIDE4LjI2IDEuMzggMjYuMDMgNC4xMyA3Ljg2IDIuNzkgMTQuNzcgNyAyMC43MiAxMi42MSA2LjAyIDUuNjMgMTAuNTUgMTIuNCAxMy41NSAyMC4yOCAyLjk2IDcuNzUgNC40NSAxNi41NiA0LjQ1IDI2LjQgMCA2LjUtMS4wNyAxMy4wOC0zLjE3IDE5LjY5bC0uMTQuMzhjLTIuMDkgNi40Ni01LjE3IDEyLjk3LTkuMiAxOS40OWwtLjE0LjIxYy00LjA4IDYuNTEtOC45IDEzLjQzLTE0LjQzIDIwLjc0LTUuNTYgNy4zMy0xMS45NiAxNS4yMy0xOS4yMiAyMy42N2wtNTYuOTEgNjYuNTFoMTEwLjM0YzIuNTIgMCA0LjU3IDIuMDUgNC41NyA0LjU3djguMTFjMCAyLjUyLTIuMDUgNC41Ny00LjU3IDQuNTd6bS0zMjcuMjUgNjguNzUgMTM3Ljk2LTE2Ny43NmMuODktMS4wNyAyLjMtMS42NSAzLjc0LTEuNjVsMjAuMTMtLjAyYzIuNTIgMCA0LjU3IDEuNzQgNC41NyAzLjg4IDAgLjkxLS4zNyAxLjc1LS45OCAyLjQxTDE4OC4zMiAzMTcuNjYgMzQ0LjEgNTA2LjI0YzEuNDUgMS43NS45NSA0LjE3LTEuMSA1LjQtLjguNDgtMS43Mi43MS0yLjYzLjcxbC0yMC4xMy4wMWMtMS43IDAtMy4xOC0uNzktMy45Ny0xLjk2bC0xNDQuMS0xNzUuMkwyOC4yMyA1MTAuNjljLS44OCAxLjA3LTIuMyAxLjY0LTMuNzMgMS42NWwtMTkuOTMuMDJjLTIuNTIgMC00LjU3LTEuNzQtNC41Ny0zLjg5IDAtLjkuMzctMS43NC45OC0yLjRsMTU1LjY1LTE4OC40TDYuOSAxMzYuOGMtMS40NS0xLjc1LS45NS00LjE4IDEuMTEtNS40MS43OS0uNDcgMS43MS0uNyAyLjYyLS43bDIwLjQ0LS4wMWMxLjYzIDAgMy4wNi43MiAzLjg3IDEuODFsMTM3LjI0IDE2Ny42MnoiLz48L3N2Zz4=",Gy=Bn.createContext(null),Yy=4;function Ws({children:m,className:c,onClick:p,title:t}){const f=se.useRef(null),r=Bn.useContext(Gy);if(r===null)throw new Error("DropDownItem must be used within a DropDown");const{registerItem:n}=r;return se.useEffect(()=>{f&&f.current&&n(f)},[f,n]),ie.jsx("button",{className:c,onClick:p,ref:f,title:t,type:"button",children:m})}function jE({children:m,dropDownRef:c,onClose:p}){const[t,f]=se.useState(),[r,n]=se.useState(),e=se.useCallback(l=>{f(o=>o?[...o,l]:[l])},[f]),s=l=>{if(!t)return;const o=l.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(o)&&l.preventDefault(),o==="Escape"||o==="Tab"?p():o==="ArrowUp"?n(a=>{if(!a)return t[0];const d=t.indexOf(a)-1;return t[d===-1?t.length-1:d]}):o==="ArrowDown"&&n(a=>a?t[t.indexOf(a)+1]:t[0])},i=se.useMemo(()=>({registerItem:e}),[e]);return se.useEffect(()=>{t&&!r&&n(t[0]),r&&r.current&&r.current.focus()},[t,r]),ie.jsx(Gy.Provider,{value:i,children:ie.jsx("div",{className:"dropdown",ref:c,onKeyDown:s,children:m})})}function Zy({disabled:m=!1,buttonLabel:c,buttonAriaLabel:p,buttonClassName:t,buttonIconClassName:f,children:r,stopCloseOnClickSelf:n}){const e=se.useRef(null),s=se.useRef(null),[i,l]=se.useState(!1),o=()=>{l(!1),s&&s.current&&s.current.focus()};return se.useEffect(()=>{const a=s.current,d=e.current;if(i&&a!==null&&d!==null){const{top:u,left:g}=a.getBoundingClientRect();d.style.top=`${u+a.offsetHeight+Yy}px`,d.style.left=`${Math.min(g,window.innerWidth-d.offsetWidth-20)}px`}},[e,s,i]),se.useEffect(()=>{const a=s.current;if(a!==null&&i){const d=u=>{const g=u.target;n&&e.current&&e.current.contains(g)||a.contains(g)||l(!1)};return document.addEventListener("click",d),()=>{document.removeEventListener("click",d)}}},[e,s,i,n]),se.useEffect(()=>{const a=()=>{if(i){const d=s.current,u=e.current;if(d!==null&&u!==null){const{top:g}=d.getBoundingClientRect(),h=g+d.offsetHeight+Yy;h!==u.getBoundingClientRect().top&&(u.style.top=`${h}px`)}}};return document.addEventListener("scroll",a),()=>{document.removeEventListener("scroll",a)}},[s,e,i]),ie.jsxs(ie.Fragment,{children:[ie.jsxs("button",{type:"button",disabled:m,"aria-label":p||c,className:t,onClick:()=>l(!i),ref:s,children:[f&&ie.jsx("span",{className:f}),c&&ie.jsx("span",{className:"text dropdown-button-text",children:c}),ie.jsx("i",{className:"chevron-down"})]}),i&&Jr.createPortal(ie.jsx(jE,{dropDownRef:e,onClose:o,children:r}),document.body)]})}function Xy(){return ie.jsx("div",{className:"divider"})}const kp=8,Op=72,Js={h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",paragraph:"Normal"},NE=({selectionFontSize:m,disabled:c,editor:p,blockType:t,styleConfig:f,isenterPressed:r,currentElementClick:n,currentElementSelect:e})=>{const[s,i]=Bn.useState(m),[l,o]=Bn.useState(t),[a,d]=Bn.useState(""),u=x=>{p.update(()=>{if(p.isEditable()){const w=Ce();w!==null&&Um(w,x)}})},g=x=>{i(x.target.value)},h=()=>{const x=Number(s);if(!isNaN(x)){const w=Math.min(Math.max(x,kp),Op);i(String(w)),u({"font-size":`${w}px`})}},y=x=>{const w=f&&f[l]?f[l].fontSize:"10px",S=x?Math.min(w+2,Op):Math.max(w-2,kp);i(String(S)),u({"font-size":`${l}px`})},v=x=>{p.update(()=>{const w=Ce();ve(w)&&z_(w,()=>jn())})},_=x=>{d(x),p.update(()=>{const k=Ce();ve(k)&&$_(k,()=>Ss(x))});let w;switch(x){case"h1":w=0;break;case"h2":w=1;break;case"h3":w=2;break;case"paragraph":w=3;break;default:w=0}const S=f.heading[w];i(String(S?S.fontSize:"10")),d(x),o(x);const C={title:`${S.title}`,"font-size":`${S?S.fontSize:"11"}px`,color:S.fontColor,"font-family":S.fontFamily,"margin-bottom":`${S.trailingSpace}em`,"font-weight":S.bold==="Yes"?"bold":"normal","font-style":S.italic==="Yes"?"italic":"normal","line-height":`${S.lineSpacing}em`,"text-align":S.alignment||"left"};u(C)},b=()=>{o("paragraph"),u({}),i("11"),v()};return Bn.useEffect(()=>{r&&r==="Enter"&&b()},[r]),Bn.useEffect(()=>{const x=()=>{p.update(()=>{const w=Ce();if(w!==null){const C=w.getNodes()[0];if(!Pe(C)){const k=C.getType();k in Js&&o(k)}}})};return p.registerUpdateListener(x),()=>{p.registerUpdateListener(x)}},[p]),Bn.useEffect(()=>{switch(n.tagName){case"P":o("paragraph"),i("11");break;case"H1":o("h1"),i(f.heading.find(x=>x.title==="Heading1").fontSize);break;case"H2":o("h2"),i(f.heading.find(x=>x.title==="Heading2").fontSize);break;case"H3":o("h3"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"default":o("paragraph"),i("11");break}},[n]),Bn.useEffect(()=>{switch(e.trim(" ")){case"Heading1":o("h1"),i(f.heading.find(x=>x.title==="Heading1").fontSize);break;case"Heading2":o("h2"),i(f.heading.find(x=>x.title==="Heading2").fontSize);break;case"Heading3":o("h3"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"paragraph":o("paragraph"),i("11");break;default:console.warn("Unknown element type:",e);break}},[e]),ie.jsxs(ie.Fragment,{children:[ie.jsx("button",{type:"button",disabled:c,onClick:()=>y(!1),className:"toolbar-item font-decrement"}),ie.jsx("input",{type:"number",value:s,disabled:c,readOnly:!0,className:"toolbar-item font-size-input",min:kp,max:Op,onChange:g,onBlur:h}),ie.jsx("button",{type:"button",disabled:c,onClick:()=>y(!0),className:"toolbar-item font-increment"}),ie.jsx(Xy,{}),ie.jsxs("div",{className:"symbol-dropdown cust-head-dropDown",children:[ie.jsxs(Zy,{disabled:c,buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"Formatting options for text style",buttonIconClassName:"icon block-type "+l,buttonLabel:Js[l],children:[ie.jsxs(Ws,{className:`item ${l==="paragraph"?"active":""}`,onClick:()=>v(),children:[ie.jsx("i",{className:"icon paragraph"}),ie.jsx("span",{className:"text",children:Js.paragraph})]}),ie.jsxs(Ws,{className:`item ${l==="h1"?"active":""}`,onClick:()=>_("h1"),children:[ie.jsx("i",{className:"icon h1"}),ie.jsx("span",{className:"text",children:Js.h1})]}),ie.jsxs(Ws,{className:`item ${l==="h2"?"active":""}`,onClick:()=>_("h2"),children:[ie.jsx("i",{className:"icon h2"}),ie.jsx("span",{className:"text",children:Js.h2})]}),ie.jsxs(Ws,{className:`item ${l==="h3"?"active":""}`,onClick:()=>_("h3"),children:[ie.jsx("i",{className:"icon h3"}),ie.jsx("span",{className:"text",children:Js.h3})]})]}),ie.jsx(Xy,{})]})]})},IE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuMS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIyIEZvbnRpY29ucywgSW5jLi0tPjxwYXRoIGQ9Ik0wIDI1NkMwIDExNC42IDExNC42IDAgMjU2IDBzMjU2IDExNC42IDI1NiAyNTYtMTE0LjYgMjU2LTI1NiAyNTZTMCAzOTcuNCAwIDI1NnptMTc1LTQ3LjkgNDcuMSA0N0wxNzUgMzAzYy05LjMgOS40LTkuMyAyNC42IDAgMzMuMSA5LjQgMTAuMiAyNC42IDEwLjIgMzMuMSAwbDQ3LTQ2LjIgNDcuOSA0Ni4yYzkuNCAxMC4yIDI0LjYgMTAuMiAzMy4xIDAgMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMWwtNDYuMi00Ny45IDQ2LjItNDdjMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMS04LjUtOS4zLTIzLjctOS4zLTMzLjEgMGwtNDcuOSA0Ny4xLTQ3LTQ3LjFjLTguNS05LjMtMjMuNy05LjMtMzMuMSAwLTkuMyA5LjQtOS4zIDI0LjYgMCAzMy4xeiIvPjwvc3ZnPg==",RE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGFibGUiPjxwYXRoIGQ9Ik0wIDJhMiAyIDAgMCAxIDItMmgxMmEyIDIgMCAwIDEgMiAydjEyYTIgMiAwIDAgMS0yIDJIMmEyIDIgMCAwIDEtMi0yVjJ6bTE1IDJoLTR2M2g0VjR6bTAgNGgtNHYzaDRWOHptMCA0aC00djNoM2ExIDEgMCAwIDAgMS0xdi0yem0tNSAzdi0zSDZ2M2g0em0tNSAwdi0zSDF2MmExIDEgMCAwIDAgMSAxaDN6bS00LTRoNFY4SDF2M3ptMC00aDRWNEgxdjN6bTUtM3YzaDRWNEg2em00IDRINnYzaDRWOHoiLz48L3N2Zz4=";function ME(){const[m,c]=se.useState("4"),[p,t]=se.useState("4"),[f,r]=se.useState(!1),[n,e]=se.useState(),[s]=hr(),i=()=>{!m||!p||(s.update(()=>{const l=E0(m,p,!0),o=Km(l);e(o)}),r(!1))};return ie.jsxs(ie.Fragment,{children:[ie.jsx("button",{title:"Table",className:"toolbar-item ",onClick:()=>r(!0),children:ie.jsx("img",{className:"add-toolbar-table-icon",src:RE,alt:"Add Table"})}),f&&ie.jsx("div",{className:"modal-overlay",children:ie.jsxs("div",{className:"modal-content",children:[ie.jsx("h3",{children:"Select Table Dimensions"}),ie.jsx("button",{className:"modal-buttons-close",onClick:()=>r(!1),children:ie.jsx("img",{src:IE,height:16,width:16,style:{margin:"0 0 29px 10px"}})}),ie.jsxs("div",{className:"select-table-container",children:[ie.jsx("label",{children:"Rows"}),ie.jsx("input",{type:"number",value:m,onChange:l=>c(Number(l.target.value))})]}),ie.jsxs("div",{className:"select-table-container",children:[ie.jsx("label",{children:"Column"}),ie.jsx("input",{type:"number",value:p,onChange:l=>t(Number(l.target.value))})]}),ie.jsx("div",{children:ie.jsx("div",{className:"modal-buttons",children:ie.jsx("button",{className:"toolbar-item",onClick:i,children:"Confirm"})})})]})})]})}const DE=[{letter:"",uppercase:"A",lowercase:"α"},{letter:"Beta",uppercase:"Β",lowercase:"β"},{letter:"Gamma",uppercase:"Γ",lowercase:"γ"},{letter:"Delta",uppercase:"Δ",lowercase:"δ"},{letter:"Epsilon",uppercase:"Ε",lowercase:"ε"},{letter:"Zeta",uppercase:"Ζ",lowercase:"ζ"},{letter:" Eta ",uppercase:"Η",lowercase:"η"},{letter:"Theta",uppercase:"Θ",lowercase:"θ"},{letter:"Iota",uppercase:"Ι",lowercase:"ι"},{letter:"Kappa",uppercase:"Κ",lowercase:"κ"}];function LE(){const[m]=hr(),[c,p]=se.useState(!1),t=f=>{m.update(()=>{var n;const r=Ce();if(ve(r)){const e=r.anchor.getNode();let s="inherit";if(e instanceof Ri){const l=e.getStyle();s=((n=l==null?void 0:l.match(/font-size:\s*(\S+);/))==null?void 0:n[1])||s}const i=nr(f);r.insertNodes([i])}}),p(!1)};return ie.jsx("div",{className:"symbol-dropdown cust-head-dropDown",children:ie.jsx(Zy,{buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"For appying Symbols",buttonLabel:"Symbols",children:ie.jsx("div",{className:"symbol-Flex-container",children:DE.map(({letter:f,uppercase:r,lowercase:n})=>ie.jsxs("div",{className:"symbol-items",children:[ie.jsx(Ws,{className:"terr",onClick:()=>t(n),children:n}),ie.jsx(Ws,{className:"terr",onClick:()=>t(r),children:r})]},f))})})})}const Qy="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNCAxMkgyME0xMiA0VjIwIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==",tv="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNiAxMkwxOCAxMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4=";var BE=typeof global=="object"&&global&&global.Object===Object&&global;const FE=BE;var zE=typeof self=="object"&&self&&self.Object===Object&&self,UE=FE||zE||Function("return this")();const ev=UE;var $E=ev.Symbol;const Gu=$E;var nv=Object.prototype,HE=nv.hasOwnProperty,qE=nv.toString,nc=Gu?Gu.toStringTag:void 0;function WE(m){var c=HE.call(m,nc),p=m[nc];try{m[nc]=void 0;var t=!0}catch{}var f=qE.call(m);return t&&(c?m[nc]=p:delete m[nc]),f}var JE=Object.prototype,VE=JE.toString;function KE(m){return VE.call(m)}var GE="[object Null]",YE="[object Undefined]",rv=Gu?Gu.toStringTag:void 0;function ZE(m){return m==null?m===void 0?YE:GE:rv&&rv in Object(m)?WE(m):KE(m)}function XE(m){return m!=null&&typeof m=="object"}var QE="[object Symbol]";function tC(m){return typeof m=="symbol"||XE(m)&&ZE(m)==QE}var eC=/\s/;function nC(m){for(var c=m.length;c--&&eC.test(m.charAt(c)););return c}var rC=/^\s+/;function oC(m){return m&&m.slice(0,nC(m)+1).replace(rC,"")}function Tp(m){var c=typeof m;return m!=null&&(c=="object"||c=="function")}var ov=0/0,iC=/^[-+]0x[0-9a-f]+$/i,aC=/^0b[01]+$/i,sC=/^0o[0-7]+$/i,lC=parseInt;function iv(m){if(typeof m=="number")return m;if(tC(m))return ov;if(Tp(m)){var c=typeof m.valueOf=="function"?m.valueOf():m;m=Tp(c)?c+"":c}if(typeof m!="string")return m===0?m:+m;m=oC(m);var p=aC.test(m);return p||sC.test(m)?lC(m.slice(2),p?2:8):iC.test(m)?ov:+m}var cC=function(){return ev.Date.now()};const Ap=cC;var uC="Expected a function",dC=Math.max,fC=Math.min;function pC(m,c,p){var t,f,r,n,e,s,i=0,l=!1,o=!1,a=!0;if(typeof m!="function")throw new TypeError(uC);c=iv(c)||0,Tp(p)&&(l=!!p.leading,o="maxWait"in p,r=o?dC(iv(p.maxWait)||0,c):r,a="trailing"in p?!!p.trailing:a);function d(w){var S=t,C=f;return t=f=void 0,i=w,n=m.apply(C,S),n}function u(w){return i=w,e=setTimeout(y,c),l?d(w):n}function g(w){var S=w-s,C=w-i,k=c-S;return o?fC(k,r-C):k}function h(w){var S=w-s,C=w-i;return s===void 0||S>=c||S<0||o&&C>=r}function y(){var w=Ap();if(h(w))return v(w);e=setTimeout(y,g(w))}function v(w){return e=void 0,a&&t?d(w):(t=f=void 0,n)}function _(){e!==void 0&&clearTimeout(e),i=0,t=s=f=e=void 0}function b(){return e===void 0?n:v(Ap())}function x(){var w=Ap(),S=h(w);if(t=arguments,f=this,s=w,S){if(e===void 0)return u(s);if(o)return clearTimeout(e),e=setTimeout(y,c),d(s)}return e===void 0&&(e=setTimeout(y,c)),n}return x.cancel=_,x.flush=b,x}function hC(m,c,p){const t=se.useRef(null);return t.current=m,se.useMemo(()=>pC((...f)=>{t.current&&t.current(...f)},c,{maxWait:p}),[c,p])}const av=20;function gC({anchorElem:m}){const[c]=hr(),p=wu(),[t,f]=se.useState(!1),[r,n]=se.useState(!1),[e,s]=se.useState(!1),[i,l]=se.useState({}),o=se.useRef(new Set),a=se.useRef(null),d=hC(y=>{const{isOutside:v,tableDOMNode:_}=mC(y);if(v){f(!1),n(!1);return}if(!_)return;a.current=_;let b=null,x=null,w=null;if(c.update(()=>{var C;const S=sr(_);if(rn(S)){const k=bn(S,D=>Mn(D));if(!Mn(k))return;if(w=c.getElementByKey(k==null?void 0:k.getKey()),w){const D=k.getChildrenSize(),N=(C=k.getChildAtIndex(0))==null?void 0:C.getChildrenSize(),O=Ix(S),R=k0(S);O===D-1?b=S:R===N-1&&(x=S)}}}),w){const{width:S,y:C,right:k,left:D,bottom:N,height:O}=w.getBoundingClientRect(),{y:R,left:A}=m.getBoundingClientRect();b?(n(!1),f(!0),l({height:av,left:D-A,top:N-R+5,width:S})):x&&(n(!0),f(!1),l({height:O,left:k-A+5,top:C-R,width:av}))}},50,250),u=se.useMemo(()=>new ResizeObserver(()=>{f(!1),n(!1)}),[]);se.useEffect(()=>{if(e)return document.addEventListener("mousemove",d),()=>{f(!1),n(!1),d.cancel(),document.removeEventListener("mousemove",d)}},[e,d]),se.useEffect(()=>oo(c.registerMutationListener(wo,y=>{c.getEditorState().read(()=>{for(const[v,_]of y){const b=c.getElementByKey(v);switch(_){case"created":o.current.add(v),s(o.current.size>0),b&&u.observe(b);break;case"destroyed":o.current.delete(v),s(o.current.size>0),u.disconnect(),o.current.forEach(x=>{const w=c.getElementByKey(x);w&&u.observe(w)});break}}})})),[c,u]);const g=y=>{c.update(()=>{if(a.current){const v=sr(a.current);v==null||v.selectEnd(),y?(Rx(),f(!1)):(Mx(),n(!1))}})},h=y=>{c.update(()=>{if(a.current){const v=sr(a.current);v==null||v.selectEnd(),y?(Dx(),f(!1)):(Lx(),n(!1))}})};return p?ie.jsxs(ie.Fragment,{children:[t&&ie.jsxs("div",{children:[ie.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%",padding:"20px"},onClick:()=>g(!0),children:ie.jsx("img",{src:Qy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),ie.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%"},onClick:()=>h(!0),children:ie.jsx("img",{src:tv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]}),r&&ie.jsxs("div",{className:"table-add-row-flex-container",children:[ie.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%",padding:"20px"},onClick:()=>g(!1),children:ie.jsx("img",{src:Qy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),ie.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%"},onClick:()=>h(!1),children:ie.jsx("img",{src:tv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]})]}):null}function mC(m){const c=m.target;if(c&&c instanceof HTMLElement){const p=c.closest("td.PlaygroundEditorTheme__tableCell, th.PlaygroundEditorTheme__tableCell");return{isOutside:!(p||c.closest("button.PlaygroundEditorTheme__tableAddRows")||c.closest("button.PlaygroundEditorTheme__tableAddColumns")||c.closest("div.TableCellResizer__resizer")),tableDOMNode:p}}else return{isOutside:!0,tableDOMNode:null}}function yC({anchorElem:m=document.body}){return wu()?Jr.createPortal(ie.jsx(gC,{anchorElem:m}),m):null}const rc=1;function Yu(){return ie.jsx("div",{className:"divider"})}function vC({renderOnlineUsers:m,styleConfig:c}){const[p]=hr(),t=se.useRef(null),[f,r]=se.useState(!1),[n,e]=se.useState(!1),[s,i]=se.useState(!1),[l,o]=se.useState(!1),[a,d]=se.useState(!1),[u,g]=se.useState(!1),[h,y]=se.useState(!1),[v,_]=se.useState(!1),[b,x]=se.useState("11px"),[w,S]=se.useState(()=>p.isEditable()),[C,k]=se.useState(""),[D,N]=se.useState(""),[O,R]=se.useState(""),A=se.useCallback(()=>{const U=Ce();ve(U)&&(i(U.hasFormat("bold")),o(U.hasFormat("italic")),d(U.hasFormat("underline")),g(U.hasFormat("strikethrough")),y(U.hasFormat("subscript")),_(U.hasFormat("superscript")),x(Hm(U,"font-size","11px")))},[]);return se.useEffect(()=>oo(p.registerUpdateListener(({editorState:U})=>{U.read(()=>{A()})}),p.registerCommand(Yo,U=>{k("");const q=Ce();let H=["Heading1","Heading2","Heading3","paragraph"],M="";return q&&q.style&&(q.style.split(";")[0]&&H.includes(q.style.split(";")[0].split(":")[1].trim(""))&&(M=q.style.split(";")[0].split(":")[1].trim("")),q.style.split(";")[1]&&H.includes(q.style.split(";")[1].split(":")[1].trim(""))&&(M=q.style.split(";")[1].split(":")[1].trim("")),q.style.split(";")[2]&&H.includes(q.style.split(";")[2].split(":")[1].trim(""))&&(M=q.style.split(";")[2].split(":")[1].trim("")),q.style.split(";")[3]&&H.includes(q.style.split(";")[3].split(":")[1].trim(""))&&(M=q.style.split(";")[3].split(":")[1].trim(""))),R(q&&q.style?M:"paragraph"),A(),!1},rc),p.registerCommand(as,U=>(r(U),!1),rc),p.registerCommand(is,U=>(e(U),!1),rc),p.registerCommand(Jd,U=>(N(U.target),!1),rc),p.registerCommand(rs,U=>(k(U.code),!1),rc)),[p,A]),ie.jsxs("div",{className:"toolbar",ref:t,children:[ie.jsx("button",{disabled:!f,onClick:()=>{p.dispatchCommand(wl,void 0)},className:"toolbar-item spaced","aria-label":"Undo",children:ie.jsx("i",{className:"format undo"})}),ie.jsx("button",{disabled:!n,onClick:()=>{p.dispatchCommand(Sl,void 0)},className:"toolbar-item","aria-label":"Redo",children:ie.jsx("i",{className:"format redo"})}),ie.jsx(Yu,{}),ie.jsx(NE,{currentElementClick:D,selectionFontSize:b.slice(0,-2),editor:p,disabled:!w,blockType:"paragraph",styleConfig:c,isenterPressed:C,currentElementSelect:O}),ie.jsx(Yu,{}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"bold")},className:"toolbar-item spaced "+(s?"active":""),"aria-label":"Format Bold",children:ie.jsx("i",{className:"format bold"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"italic")},className:"toolbar-item spaced "+(l?"active":""),"aria-label":"Format Italics",children:ie.jsx("i",{className:"format italic"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"underline")},className:"toolbar-item spaced "+(a?"active":""),"aria-label":"Format Underline",children:ie.jsx("i",{className:"format underline"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"strikethrough")},className:"toolbar-item spaced "+(u?"active":""),"aria-label":"Format Strikethrough",children:ie.jsx("i",{className:"format strikethrough"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"superscript")},className:"toolbar-item spaced "+(v?"active":""),"aria-label":"Format SuperScript",children:ie.jsx("img",{src:PE,height:16,width:16,style:{marginTop:"1px"}})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(Tr,"subscript")},className:"toolbar-item spaced "+(h?"active":""),"aria-label":"Format SubScript",children:ie.jsx("img",{src:AE,height:16,width:16,style:{marginTop:"1px"}})}),ie.jsx(Yu,{}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(os,"left")},className:"toolbar-item spaced","aria-label":"Left Align",children:ie.jsx("i",{className:"format left-align"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(os,"center")},className:"toolbar-item spaced","aria-label":"Center Align",children:ie.jsx("i",{className:"format center-align"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(os,"right")},className:"toolbar-item spaced","aria-label":"Right Align",children:ie.jsx("i",{className:"format right-align"})}),ie.jsx("button",{onClick:()=>{p.dispatchCommand(os,"justify")},className:"toolbar-item","aria-label":"Justify Align",children:ie.jsx("i",{className:"format justify-align"})}),ie.jsx(Yu,{}),ie.jsx(ME,{}),ie.jsx(LE,{}),ie.jsx(yC,{}),ie.jsx("div",{className:"avtar-outer-div",children:m()})]})}var Pp={exports:{}},Sn={};/** @license React v16.13.1
1430
1430
  * react-is.production.min.js
1431
1431
  *
1432
1432
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -1521,9 +1521,10 @@ See https://s-c.sh/2BAXzed for more info.`),window["__styled-components-init__"]
1521
1521
  `+t),m.appendChild(f));return m}const Tk=se.forwardRef(function({treeTypeButtonClassName:m,timeTravelButtonClassName:c,timeTravelPanelSliderClassName:p,timeTravelPanelButtonClassName:t,viewClassName:f,timeTravelPanelClassName:r,editorState:n,setEditorState:e,setEditorReadOnly:s,generateContent:i},l){const[o,a]=se.useState([]),[d,u]=se.useState(""),[g,h]=se.useState(!1),[y,v]=se.useState(!1),_=se.useRef(0),b=se.useRef(null),[x,w]=se.useState(!1),[S,C]=se.useState(!1),[k,D]=se.useState(!1),N=se.useRef(),O=se.useRef(0),R=se.useCallback(U=>{const q=++O.current;i(U).then(H=>{q===O.current&&u(H)}).catch(H=>{q===O.current&&u(`Error rendering tree: ${H.message}
1522
1522
 
1523
1523
  Stack:
1524
- ${H.stack}`)})},[i]);se.useEffect(()=>{!k&&n._nodeMap.size>1e3&&(C(!0),!k)||N.current!==n&&(N.current=n,R(y),g||a(U=>[...U,[Date.now(),n]]))},[n,R,y,k,g]);const A=o.length;return se.useEffect(()=>{if(x){let U;const q=()=>{const H=_.current;if(H===A-1)return void w(!1);const M=o[H][0],W=o[H+1][0];U=setTimeout(()=>{_.current++;const G=_.current,I=b.current;I!==null&&(I.value=String(G)),e(o[G][1]),q()},W-M)};return q(),()=>{clearTimeout(U)}}},[o,x,A,e]),ie.jsxs("div",{className:f,children:[!k&&S?ie.jsxs("div",{style:{padding:20},children:[ie.jsx("span",{style:{marginRight:20},children:"Detected large EditorState, this can impact debugging performance."}),ie.jsx("button",{onClick:()=>{D(!0)},style:{background:"transparent",border:"1px solid white",color:"white",cursor:"pointer",padding:5},children:"Show full tree"})]}):null,k?null:ie.jsx("button",{onClick:()=>(R(!y),void v(!y)),className:m,type:"button",children:y?"Tree":"Export DOM"}),!g&&(k||!S)&&A>2&&ie.jsx("button",{onClick:()=>{s(!0),_.current=A-1,h(!0)},className:c,type:"button",children:"Time Travel"}),(k||!S)&&ie.jsx("pre",{ref:l,children:d}),g&&(k||!S)&&ie.jsxs("div",{className:r,children:[ie.jsx("button",{className:t,onClick:()=>{_.current===A-1&&(_.current=1),w(!x)},type:"button",children:x?"Pause":"Play"}),ie.jsx("input",{className:p,ref:b,onChange:U=>{const q=Number(U.target.value),H=o[q];H&&(_.current=q,e(H[1]))},type:"range",min:"1",max:A-1}),ie.jsx("button",{className:t,onClick:()=>{s(!1);const U=o.length-1,q=o[U];e(q[1]);const H=b.current;H!==null&&(H.value=String(U)),h(!1),w(!1)},type:"button",children:"Exit"})]})]})});function Ak(m,c){const p=new Set;let t=0;for(const[f]of m._commands)p.add(m.registerCommand(f,r=>(c(n=>{t+=1;const e=[...n];return e.push({index:t,payload:r,type:f.type?f.type:"UNKNOWN"}),e.length>10&&e.shift(),e}),!1),Kr));return()=>p.forEach(f=>f())}function Pk(m){const[c,p]=se.useState([]);return se.useEffect(()=>Ak(m,p),[m]),se.useMemo(()=>c,[c])}function jk({treeTypeButtonClassName:m,timeTravelButtonClassName:c,timeTravelPanelSliderClassName:p,timeTravelPanelButtonClassName:t,viewClassName:f,timeTravelPanelClassName:r,editor:n,customPrintNode:e}){const s=Bn.createRef(),[i,l]=se.useState(n.getEditorState()),o=Pk(n);return se.useEffect(()=>oo(n.registerUpdateListener(({editorState:a})=>{l(a)}),n.registerEditableListener(()=>{l(n.getEditorState())})),[n]),se.useEffect(()=>{const a=s.current;if(a!==null)return a.__lexicalEditor=n,()=>{a.__lexicalEditor=null}},[n,s]),ie.jsx(Tk,{treeTypeButtonClassName:m,timeTravelButtonClassName:c,timeTravelPanelSliderClassName:p,timeTravelPanelButtonClassName:t,viewClassName:f,timeTravelPanelClassName:r,setEditorReadOnly:a=>{const d=n.getRootElement();d!=null&&(d.contentEditable=a?"false":"true")},editorState:i,setEditorState:a=>n.setEditorState(a),generateContent:async function(a){return wk(n,o,a,e)},ref:s})}function Nk(){const[m]=hr();return ie.jsx(jk,{viewClassName:"tree-view-output",treeTypeButtonClassName:"debug-treetype-button",timeTravelPanelClassName:"debug-timetravel-panel",timeTravelButtonClassName:"debug-timetravel-button",timeTravelPanelSliderClassName:"debug-timetravel-panel-slider",timeTravelPanelButtonClassName:"debug-timetravel-panel-button",editor:m})}const Ik=({initialHtml:m,onHtmlChanged:c})=>{const[p]=hr(),[t,f]=se.useState(!0);return se.useEffect(()=>{!m||!t||(f(!1),p.update(()=>{const n=new DOMParser().parseFromString(m,"text/html"),e=r0(p,n);ym(e)}))},[]),ie.jsx($0,{onChange:r=>{console.log("editorState",r),r.read(()=>{c(Qf(p))})}})},Hp=EE([...[wo,ql,$i,Eu]]);function Rk(){return ie.jsx("div",{className:"editor-placeholder"})}const Mk={namespace:"React.js Demo",nodes:Hp,onError(m){throw m},theme:TE},Dk=()=>ie.jsx(ie.Fragment,{children:"hello"});function Lk({collabApiKey:m,styleConfig:c,userObj:p,docId:t}){const[f,r]=se.useState(!1),[n,e]=se.useState([]),[s,i]=se.useState({root:null}),{userId:l,userName:o,userEmail:a}=p,{pageMargin:d}=c||{},u=se.useRef();se.useState("");const h={docId:t,apiKey:m,user:{name:o,id:l,email:a},hooks:{contentChanged:({source:S,content:C})=>{},usersUpdate:S=>{e(S)}}},y=()=>{u.current&&u.current.start(h).then(()=>{console.log("[Lexical Demo][codox.start] success"),r(!0)}).catch(S=>console.log("[Lexical Demo][codox.start] error",S))};se.useEffect(()=>()=>{v()},[]);const v=()=>{u.current&&u.current.stop(),r(!1)};let _={root:{children:[{children:[],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,showUI:!0}],direction:"ltr",format:"",indent:0,type:"root",version:1}};se.useEffect(()=>{(async()=>{if(!t)return;f&&v();let S=_;if(S)try{CE(S,Hp),i(S)}catch(C){console.error("[APP] error: ",C)}})()},[t]),se.useEffect(()=>{s&&t&&!f&&y()},[s,t,f]),se.useMemo(()=>({editorState:s?JSON.stringify({root:s.root}):null,namespace:"Playground",nodes:Hp,onError:S=>{throw S},theme:{}}),[s]);const b=()=>{let S=[],C=[];return n&&n.length>0&&n.map((k,D)=>{C.includes(k.name)||(C.push(k.name),S.push(ie.jsxs("div",{title:k.email,className:`avatarStyle avatar-color-${D+1}`,children:[" ",k.name&&k.name[0],k.name&&k.name[4]]},D)))}),ie.jsx("div",{className:"flexContainer",children:S})},x=Pv.div`
1524
+ ${H.stack}`)})},[i]);se.useEffect(()=>{!k&&n._nodeMap.size>1e3&&(C(!0),!k)||N.current!==n&&(N.current=n,R(y),g||a(U=>[...U,[Date.now(),n]]))},[n,R,y,k,g]);const A=o.length;return se.useEffect(()=>{if(x){let U;const q=()=>{const H=_.current;if(H===A-1)return void w(!1);const M=o[H][0],W=o[H+1][0];U=setTimeout(()=>{_.current++;const G=_.current,I=b.current;I!==null&&(I.value=String(G)),e(o[G][1]),q()},W-M)};return q(),()=>{clearTimeout(U)}}},[o,x,A,e]),ie.jsxs("div",{className:f,children:[!k&&S?ie.jsxs("div",{style:{padding:20},children:[ie.jsx("span",{style:{marginRight:20},children:"Detected large EditorState, this can impact debugging performance."}),ie.jsx("button",{onClick:()=>{D(!0)},style:{background:"transparent",border:"1px solid white",color:"white",cursor:"pointer",padding:5},children:"Show full tree"})]}):null,k?null:ie.jsx("button",{onClick:()=>(R(!y),void v(!y)),className:m,type:"button",children:y?"Tree":"Export DOM"}),!g&&(k||!S)&&A>2&&ie.jsx("button",{onClick:()=>{s(!0),_.current=A-1,h(!0)},className:c,type:"button",children:"Time Travel"}),(k||!S)&&ie.jsx("pre",{ref:l,children:d}),g&&(k||!S)&&ie.jsxs("div",{className:r,children:[ie.jsx("button",{className:t,onClick:()=>{_.current===A-1&&(_.current=1),w(!x)},type:"button",children:x?"Pause":"Play"}),ie.jsx("input",{className:p,ref:b,onChange:U=>{const q=Number(U.target.value),H=o[q];H&&(_.current=q,e(H[1]))},type:"range",min:"1",max:A-1}),ie.jsx("button",{className:t,onClick:()=>{s(!1);const U=o.length-1,q=o[U];e(q[1]);const H=b.current;H!==null&&(H.value=String(U)),h(!1),w(!1)},type:"button",children:"Exit"})]})]})});function Ak(m,c){const p=new Set;let t=0;for(const[f]of m._commands)p.add(m.registerCommand(f,r=>(c(n=>{t+=1;const e=[...n];return e.push({index:t,payload:r,type:f.type?f.type:"UNKNOWN"}),e.length>10&&e.shift(),e}),!1),Kr));return()=>p.forEach(f=>f())}function Pk(m){const[c,p]=se.useState([]);return se.useEffect(()=>Ak(m,p),[m]),se.useMemo(()=>c,[c])}function jk({treeTypeButtonClassName:m,timeTravelButtonClassName:c,timeTravelPanelSliderClassName:p,timeTravelPanelButtonClassName:t,viewClassName:f,timeTravelPanelClassName:r,editor:n,customPrintNode:e}){const s=Bn.createRef(),[i,l]=se.useState(n.getEditorState()),o=Pk(n);return se.useEffect(()=>oo(n.registerUpdateListener(({editorState:a})=>{l(a)}),n.registerEditableListener(()=>{l(n.getEditorState())})),[n]),se.useEffect(()=>{const a=s.current;if(a!==null)return a.__lexicalEditor=n,()=>{a.__lexicalEditor=null}},[n,s]),ie.jsx(Tk,{treeTypeButtonClassName:m,timeTravelButtonClassName:c,timeTravelPanelSliderClassName:p,timeTravelPanelButtonClassName:t,viewClassName:f,timeTravelPanelClassName:r,setEditorReadOnly:a=>{const d=n.getRootElement();d!=null&&(d.contentEditable=a?"false":"true")},editorState:i,setEditorState:a=>n.setEditorState(a),generateContent:async function(a){return wk(n,o,a,e)},ref:s})}function Nk(){const[m]=hr();return ie.jsx(jk,{viewClassName:"tree-view-output",treeTypeButtonClassName:"debug-treetype-button",timeTravelPanelClassName:"debug-timetravel-panel",timeTravelButtonClassName:"debug-timetravel-button",timeTravelPanelSliderClassName:"debug-timetravel-panel-slider",timeTravelPanelButtonClassName:"debug-timetravel-panel-button",editor:m})}const Ik=({initialHtml:m,onHtmlChanged:c})=>{const[p]=hr(),[t,f]=se.useState(!0);return se.useEffect(()=>{!m||!t||(f(!1),p.update(()=>{const n=new DOMParser().parseFromString(m,"text/html"),e=r0(p,n);ym(e)}))},[]),ie.jsx($0,{onChange:r=>{r.read(()=>{c(Qf(p))})}})},Hp=EE([...[wo,ql,$i,Eu]]);function Rk(){return ie.jsx("div",{className:"editor-placeholder"})}const Mk={namespace:"React.js Demo",nodes:Hp,onError(m){throw m},theme:TE},Dk=()=>ie.jsx(ie.Fragment,{children:"hello"});function Lk({collabApiKey:m,styleConfig:c,userObj:p,docId:t}){const[f,r]=se.useState(!1),[n,e]=se.useState([]),[s,i]=se.useState({root:null}),{userId:l,userName:o,userEmail:a}=p,{pageMargin:d}=c||{},u=se.useRef();se.useState("");const h={docId:t,apiKey:m,user:{name:o,id:l,email:a},showCursor:!1,cursorAlwaysOn:!1,showPointer:!1,hooks:{contentChanged:({source:S,content:C})=>{},usersUpdate:S=>{e(S)}}},y=()=>{u.current&&u.current.start(h).then(()=>{console.log("[Lexical Demo][codox.start] success"),r(!0)}).catch(S=>console.log("[Lexical Demo][codox.start] error",S))};se.useEffect(()=>()=>{v()},[]);const v=()=>{u.current&&u.current.stop(),r(!1)};let _={root:{children:[{children:[],direction:"ltr",format:"",indent:0,type:"paragraph",version:1,textFormat:0,showUI:!0}],direction:"ltr",format:"",indent:0,type:"root",version:1}};se.useEffect(()=>{(async()=>{if(!t)return;f&&v();let S=_;if(S)try{CE(S,Hp),i(S)}catch(C){console.error("[APP] error: ",C)}})()},[t]),se.useEffect(()=>{s&&t&&!f&&y()},[s,t,f]),se.useMemo(()=>({editorState:s?JSON.stringify({root:s.root}):null,namespace:"Playground",nodes:Hp,onError:S=>{throw S},theme:{}}),[s]);const b=()=>{let S=[],C=[];return n&&n.length>0&&n.map((k,D)=>{C.includes(k.name)||(C.push(k.name),S.push(ie.jsxs("div",{title:k.email,className:`avatarStyle avatar-color-${D+1}`,children:[" ",k.name&&k.name[0],k.name&&k.name[4]]},D)))}),ie.jsx("div",{className:"flexContainer",children:S})},x=Pv.div`
1525
1525
  padding: ${d||"56px"};
1526
1526
  `,w=Pv.div`
1527
1527
  opacity: 0;
1528
+ height: "20px";
1528
1529
  `;return se.useEffect(()=>{(async()=>{const S=!!m,C=!!p,k=!!c;console.log(S&&C&&k?"All three conditions are met.":S&&C||S&&k||C&&k?"Any two of the three conditions are met.":S||C||k?"Any one of the three conditions is met.":"None of the three conditions are met.")})()},[m,p,c]),ie.jsx("div",{children:ie.jsx(Nm,{initialConfig:Mk,children:ie.jsxs("div",{className:"editor-container",children:[ie.jsx(vC,{renderOnlineUsers:b,styleConfig:c}),ie.jsxs("div",{className:"editor-inner",children:[ie.jsx(xx,{contentEditable:ie.jsx(x,{children:ie.jsx(Rm,{className:"editor-input"})}),placeholder:ie.jsx(Rk,{}),ErrorBoundary:Dk}),ie.jsx(SE,{ref:u}),ie.jsx(Xm,{}),ie.jsx(OE,{}),ie.jsx(Ik,{onHtmlChanged:S=>console.log(S),initialHtml:""}),ie.jsx(w,{children:ie.jsx(Nk,{})}),ie.jsx(Im,{})]})]})})})}Br.Editor=Lk,Object.defineProperty(Br,Symbol.toStringTag,{value:"Module"})});
1529
1530
  //# sourceMappingURL=index.umd.js.map