sykpcomposer 0.0.75 → 0.0.76
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.es.js +5 -10
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
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?nr.tooltipAnimations.hideAtOnce:nr.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=nr.isMousePositionWithinElementCords(c,o);c.type===wr.mouseover&&u&&(a.style.animation=this.isEditingInProgress?nr.tooltipAnimations.hideAtOnce:nr.tooltipAnimations.showAtOnce,s.add(d)),c.type===wr.mouseout&&(a.style.animation=nr.tooltipAnimations.hideWithDelay,s.add(d)),c.type===wr.mousemove&&u&&(a.style.animation=this.isEditingInProgress?nr.tooltipAnimations.hideAtOnce:nr.tooltipAnimations.showAtOnce,s.add(d))}}_keyboardEventsListener(c){c.type===wr.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),c.type===wr.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(c){Se.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(wr.keypress,this.keyboardBindedListener),window.addEventListener(wr.keyup,this.keyboardBindedListener),window.addEventListener(wr.resize,this.resizeBindedListener),window.addEventListener(wr.scroll,this.resizeBindedListener);for(const c of H0)window.addEventListener(c,this.mouseBindedListener)}unmount(){window.removeEventListener(wr.keypress,this.keyboardBindedListener),window.removeEventListener(wr.keyup,this.keyboardBindedListener),window.removeEventListener(wr.resize,this.resizeBindedListener),window.removeEventListener(wr.scroll,this.resizeBindedListener);for(const c of H0)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(fp.validateJSONSelection(t,lp.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){le.warn("[PAINT REMOTE SELECTION] failed for nested editor - ",{error:e,nestedSelectionJSON:f,fullSelection:t,lexicalSelection:n})}else le.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){le.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){le.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)&&(le.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 vS;function bS(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(m=>m===ka.editorState)}function Ru(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)Ru(r,f);return c&&c.getChildrenSize&&c.splice(c.getChildrenSize(),0,[f]),f}function Mu(m){if(m.getChildren)for(let c of m.getChildren())Mu(c);m.remove()}function sy(m){m.__parent=null,m.__next=null,m.__prev=null}function ly(m,c){return!!Se.isLexicalEditorInstance(m)&&!(typeof c!="object"||!c.editorState||(m.update(()=>{try{let p=(0,be.$getSelection)();const t=m.parseEditorState(c.editorState);if(t.isEmpty())return(0,be.$getRoot)().clear(),!0;(0,be.$setSelection)(p),m.setEditorState(t)}catch(p){le.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",p)}}),0))}function _S(m,c){let p=c;for(const t of m)p=p[t];return p}function Ta(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=_S(m,p?c:Se.getMainEditorState().toJSON());return f&&(t=Aa(f)?(0,be.$getRoot)():Nn.get(f.codoxId)),t||le.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:Ta(m,c,!0))}function cy(m){le.log("[applyFullLexicalStateReplace] clear current state and apply new");const c=(0,be.$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 xS(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(c.length){le.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=bS(t),i=s!==-1,l=p.hasOwnProperty("lm")&&typeof p.lm=="number";if(t.length)if(i){let o=s-1,a=Ta(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=Vl(t[o]);ly(a.getWritable()[g],u)}}else{if(r){let o=p.oi;if(!o){le.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi attr expected for path",{delta:p});continue}if(o.some(d=>!(!d.hasOwnProperty("text")||typeof d.text=="string"))){le.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi children contain invalid text value",{delta:p});continue}t.length=t.length-1;let a=Ta(t,m);if(!a)continue;if(o.some(d=>!!d.codoxDId)){try{a=a.getWritable()}catch(h){le.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:Mu(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=Ru(y);if(le.debug("[DELTA_DECORATOR_UPDATE]: ",{exisingDecorator:w,tmpDecorator:S}),!S){le.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()};ly(w[C],k)}else{let k=sp(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(),sy(w),b=w,delete d[y.codoxDId]}}b||(b=Ru(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(),sy(y),Mu(y),delete d[h]}}else{let d=o.map(u=>Ru(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()?Mu(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,be.$getRoot)().splice(0,0,[d]);else{const u=t[t.length-1];t.length=t.length-2;let g=Ta(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=Ta(o,m);if(u)try{let g=u.getWritable();if(a){let h=Object.keys(a);for(let y of h)g[Vl(y)]=a[y]}if(d){let h=Object.keys(d);for(let y of h)delete g[Vl(y)]}}catch(g){le.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=Ta(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=Vl(o);t.length=t.length-1;let d,u=Ta(t,m);if(!u){le.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){le.debug("[applyDeltasToLexicalState][shouldUpdateBlockAttr] getWritable error: ",{err:h,delta:p})}if(!d)continue;let g=p.oi;if(o==="format"&&(g=_w(g)),o==="direction"&&(u.hasOwnProperty(a)||(a="__dir")),!d.hasOwnProperty(a)){let h=Object.keys(d);for(let y of h){let v=sp(y);if(o.startsWith(v)){a=y;break}}}d[a]=g}}else if(p.oi&&p.oi.root)return cy(p.oi)}}else le.log("[applyDeltasToLexicalState] stop, no deltas: ",c)}function wS(m){let c=m.clipboardData.getData(ww.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 SS=m=>{var c={};return on.d(c,m),c};const uy=SS({useCollaborationContext:()=>Mx});var ES=m=>{var c={};return on.d(c,m),c};const qi=ES({LexicalComposerContext:()=>Jf,useLexicalComposerContext:()=>Nr});class dy{constructor(){this.blacklist=Object.keys(q0).reduce((c,p)=>{let t=q0[p];return c[p]=t.reduce((f,r)=>(f[r]=r,f),{}),c},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(c){return c instanceof be.TextNode||c instanceof be.ParagraphNode||c instanceof be.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(pp||p!==Kr.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 le.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!==Kr.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,le.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 CS=new dy,Wi=CS,kS=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function OS(m,c){if(m==null)return{};var p,t,f=TS(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 TS(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 AS{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(c,p){let t=!1;return function(f){let{editorState:r,prevEditorState:n,dirtyElements:e,dirtyLeaves:s}=f,i=(OS(f,kS),Se.getMainEditor()),l=Se.getMainEditorState(),o=r.toJSON(),a=n.toJSON(),d=dp(o,a),u=r._selection,g=n._selection,h=!1,y=null,v=Se.isOnlySelectionChanged(e,s),_=c[p];if(le.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}),Wi.isBlacklistedFound())return t=!0,le.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),Se.scanLexicalNodeForNestedEditorAttribute(c)?(_.update(()=>{try{const b=_.parseEditorState(a);if(b.isEmpty())return(0,be.$getRoot)().clear(),!0;_.setEditorState(b)}catch(b){le.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",b)}}),void Wi.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=sp(p),w=$e.lexicalToJSONNested(u,x,b);y=Se.getCurrentNestedSelectionJSON(),h=$e.equalSelectionsJSON(y,w),h||Se.setNestedSelectionJSON(w)})}d&&h||i.update(()=>{try{le.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){le.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===Kr.created){let h=t.getEditorState()._nodeMap.get(u);h&&Wi.trackBlacklistedInNestedEditor(h,g,t.getEditorState(),c)}});r.push(a)});let n=(0,ks.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,be.$setSelection)(r),le.debug("[setNestedEditorSelection]: lexical nested selection: ",r)}catch(r){le.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 PS=new AS,ui=PS,jS=function(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let p=(0,be.createEditor)({namespace:"validation",nodes:[...c],onError:e=>{throw e},parentEditor:null});const t=new dy,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,Kr.created,r),t.isBlacklistedFound()))throw new Error(Sw)}}catch(p){throw p}};class NS{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===$i.BOTH||s.__headerState===$i.ROW),e=c.some((s,i)=>{if(s.__size<f)return!1;let l=s.getChildAtIndex(t);return!(!l||l.__headerState!==$i.BOTH&&l.__headerState!==$i.COLUMN)});return n&&e?r=$i.BOTH:n&&!e?r=$i.ROW:e&&!n&&(r=$i.COLUMN),r}_isValidCellChildren(c){for(let p of c)if(Ns(p)||!js(p)&&Tn(p))return!1;return!0}_createEmptyCell(){let c=(0,An.$createTableCellNode)();return c.append((0,be.$createParagraphNode)()),c}_wrapInvalidCellChildrenIntoParagraph(c){let p=(0,be.$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()=>{le.debug("[TablesValidator][FIX TABLE ACTION - APPEND_CELLS_TO_ROW] invoked: ",{rowKey:c,numOfCellsToAppend:p});let t=(0,be.$getNodeByKey)(c);for(;p;){let f=(0,An.$createTableCellNode)().append((0,be.$createParagraphNode)());f.setRowSpan(1).setColSpan(1),t.append(f),p--}}}_createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(c){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - ADD_PARAGRAPH_TO_EMPTY_CELL] invoked: ",{cellKey:c}),(0,be.$getNodeByKey)(c).append((0,be.$createParagraphNode)())}}_createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(c){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_CELL_CHILDREN_IN_PARAGRAPH] invoked: ",{cellKey:c});let p=(0,be.$getNodeByKey)(c);this._wrapInvalidCellChildrenIntoParagraph(p)}}_createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(c){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - ADD_ROW_CELL_TO_EMPTY_TABLE_NODE] invoked: ",{tableKey:c});let p=(0,be.$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,be.$getNodeByKey)(c).append(this._createEmptyCell()),p--}}_createFixAction_WRAP_INVALID_ROW_NODE(c,p){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_ROW_NODE] invoked: ",{tableKey:c,rowKey:p});let t=(0,be.$getNodeByKey)(c);if(!t)return;let f=(0,be.$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,be.$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,be.$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()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_CELL_NODE] invoked: ",{rowKey:c,cellKey:p});let t=(0,be.$getNodeByKey)(c);if(!t)return;let f=(0,be.$getNodeByKey)(p);if(f.remove(),f=(0,be.$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,be.$createParagraphNode)();s.append(f),e.append(s)}}}_createFixAction_APPLY_HEADER_STATE_TO_CELL(c,p){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - APPLY_HEADER_STATE_TO_CELL] invoked: ",{cellKey:c,headerStateToApply:p});let t=(0,be.$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(le.debug(`[${c}]`,{selection:p}),!(0,be.$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){le.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(){le.debug("[TablesValidator][gcRemovedTable] candidate table keys ",{tableKeys:this.removeCandidateTableKeys}),Se.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(c=>{let p=(0,be.$getNodeByKey)(c);p&&p.remove()}),this.removeCandidateTableKeys.clear(),(0,be.$addUpdateTag)(io.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&&le.debug("[TablesValidator][tableRowNodeChangesListener] no row node found in lexical: ",{tableRowNodeKey:c}));let f=t.__parent;f?this.validateTableCandidateKeys.add(f):le.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===$i.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;le[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();le.log("[TablesValidator][fixTablesStructure]: fix actions to apply - count: ",this.tableFixActions.length),c.update(()=>{for(let p of this.tableFixActions)p();this.tableFixActions=[],(0,be.$addUpdateTag)(io.historic)})}ensureDocTablesAreValid(c){return this.shouldGCRemovedTables()?(le.warn("[TablesValidator][GARBAGE COLLECT TABLE NODES AFTER TABLE REMOVAL ATTEMPT]"),this.gcRemovedTables(),!1):!(this.shouldValidateUpdatedTables()&&(le.debug("[TablesValidator][shouldValidateUpdatedTables] invoked"),!this.validateUpdatedTables()))||(le.warn("[TablesValidator][shouldValidateUpdatedTables] INVALID LEXICAL TABLE(S) STRUCTURE FOUND - FIXING",{state:JSON.parse(JSON.stringify(c.toJSON()))}),this.fixTablesStructure(),!1)}}const Ro=new NS,IS=["contentChanged"],RS=["state","remoteSelection"];function fy(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 As(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?fy(Object(p),!0).forEach(function(t){MS(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):fy(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function MS(m,c,p){return(c=DS(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function DS(m){var c=LS(m,"string");return typeof c=="symbol"?c:c+""}function LS(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 py(m,c){if(m==null)return{};var p,t,f=BS(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 BS(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 pp={DEBUG:!1,VERSION:"1.0.2",NAME:"@codoxhq/lexical-provider",SDKUI_SOURCE_PATH:"../../../sdkui/dist-production2/codox.bundle.js"}.LOCAL==="true";le.info("MODE: ","production");const FS=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 le.info("[decorateFetchOnReconnctHook] hook invoked: ",{returnObj:r}),r};let Du=0,di=null,hp=!1,Eo={},gp={};const zS=(0,Gt.forwardRef)((m,c)=>{let{onBlacklistedInsert:p}=m;const t=(0,Gt.useContext)(qi.LexicalComposerContext);if(!t)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[f]=(0,qi.useLexicalComposerContext)(),r=(0,uy.useCollaborationContext)();(0,Gt.useEffect)(()=>{if(le.debug("[INIT] lexical context check: ",{lexicalContext:t,editor:f}),!f)return;le.log("[useEffect][editor] Editor instance changed: ",{editor:f,key:f._key}),Se.setMainEditor(f),Nn.gcAbandonedNodes(),ui.gc(),Ro.clear(),le.log("[useEffect][editor] subscribe to editor changes");const v=(0,ks.mergeRegister)(f.registerUpdateListener(g),f.registerCommand(be.PASTE_COMMAND,wS,be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.UNDO_COMMAND,()=>{Se.setUndoInvoked(!0)},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.REDO_COMMAND,()=>{Se.setRedoInvoked(!0)},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.KEY_DELETE_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("KEY_DELETE_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.KEY_BACKSPACE_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.CUT_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("CUT_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),...h());So.mount(),Se.alignStateSelectionJSONsFromLatestEditor(),le.debug("New editor mounted: ",{isCodoxStarted:Se.isCodoxStarted,codoxLexicalEditorManager:Se,nestedEditorsProcessor:ui});let _=f._onError;return f._onError=b=>{le.error("[ERROR HANDLER WRAPPER] error from editor: ",b),_&&_(b),u()},p&&Wi.setClientCallback(p),()=>{Se.getMainEditorKey()&&(le.debug("Unmount prev editor"),v(),Se.removeMainEditor(),So.unmount(),Se.clearJSONs(),On.clear(),Ro.clear(),Se.isCodoxStarted&&(le.debug("EDITOR USE_EFFECT stopping codox"),n(),Se.setIsCodoxStarted(!1)),Wi.removeClientCallback())}},[f]);const n=()=>{Se.isCodoxStarted&&(le.log("[stopCodoxInstance] stopping codox"),Se.setIsCodoxStarted(!1),pp||ri().stop(),Se.clearJSONs(),Nn.clearAll(),So.clear(),On.resetComments(),ui.clearListeners())},e=async v=>{le.debug("[startCodoxInstance] invoked"),ri().createNewInstance(),le.debug("[startCodoxInstance] instance created");for(let O in gp)ri().instance.on(O,gp[O]);if(le.debug("[startCodoxInstance] events subscribed"),Eo=v,di=Eo.docId,!di)return le.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:di});let _=On.initialCommentsExist();le.debug("[startCodoxInstance] initCommentsExist: ",_),_&&(On.activateInitialComments(f,Nn),le.log("[activateInitialComments] "));let b=Se.getMainEditorState().toJSON();if(!Se.isValidJSONState(b))throw le.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:di,initJSONState:b}),new Error("start codox skipped - invalid init state");le.log("[startCodoxInstance] starting codox with: ",{docId:di,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=FS(D.fetchDocOnNetworkReconnect));const N=py(D,IS);await ri().start(ri().createConfig(As(As({},Eo),{},{docId:di,username:x,apiKey:w,domain:C,hooks:As({syncState:l,getState:i,getServerState:async()=>await S(di)},N),editorInstanceHooks:{getSelection:()=>Se.getCurrentActiveSelectionJSON(),setSelection:O=>o(O),getState:i,setState:O=>{const{root:R,comments:A}=O;le.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 le.info("[getContent]: ",O),{state:O}}},appServer:Eo.appServer,demo:k}))),le.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:As(As({},Se.getMainEditorState().toJSON()),{},{comments:On.getAllComments()}),docId:di}),l=v=>{if(!Se.isCodoxStarted)return;le.log("[SYNC_STATE]: Before sync payload = ",v);const _=ri().sync({meta:v}),{state:b,remoteSelection:x=[]}=_,w=py(_,RS);if(le.log("[SYNC_STATE]: After sync",{state:b,remoteSelection:x,rest:w}),!b)return le.error("[SYNC_STATE] abort apply - synced state is not valid - restarting codox"),s();const S=b.state;le.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 le.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||(le.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:v}),!fp.validateJSONSelection(v,lp.local)))return;let _=Se.getCurrentActiveSelectionJSON();if($e.equalSelectionsJSON(_,v))return void le.log("[setLocalSelectionFromSync] STOP - local and synced selections are equal");let b=$e.isNestedSelectionJSON(v);f.update(()=>{le.log("[setLocalSelectionFromSync] json selection to apply: ",{syncedSelectionJSON:v});const x=$e.JSONToLexical(v);if(le.log("[setLocalSelectionFromSync] lexical selection to apply: ",x),b){let w=ui.setNestedEditorSelection(v);Se.setNestedSelectionJSON(w?v:null)}else(0,be.$setSelection)(x),Se.setMainSelectionJSON(v);le.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();le.log("[updateEditor] invoked: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:JSON.parse(JSON.stringify(v)),newSelectionJSON:_,remoteSelection:x,stateReplace:b,editor:f}),_===void 0&&le.error("SELECTION FROm SYNC IS UNDEFINED - will default prev selection",_);const C=dp(S,v),k=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),_);f.update(()=>{if(Se.addUpdateTag({isSameState:C,isSameSelection:k,updateTag:w}),b)le.log("[updateEditor] invoke full stateReplace after sync"),cy(v),S=Se.setCurrentContentStateJSON(v),(0,be.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S);else{le.log("[updateEditor] invoke deltas diff");let N=ri().diff(S,v,{keyNames:{default:"codoxId"}});le.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:v,deltas:N&&JSON.parse(JSON.stringify(N))}),N&&N.length&&(le.log("[updateEditor] apply deltas to lexical state"),xS(v,N),S=Se.setCurrentContentStateJSON(v),(0,be.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S))}let D=$e.isNestedSelectionJSON(_);if(fp.validateJSONSelection(_,lp.local)||(_=Se.getCurrentActiveSelectionJSON()),D){let N=ui.setNestedEditorSelection(_);Se.setNestedSelectionJSON(N?_:null),le.log("[updateEditor] nested selection updated",N?_:null)}else if(_!==void 0){const N=$e.JSONToLexical(_);le.log("[updateEditor] updated selection to apply: ",{isSameSelection:k,newSelectionJSON:_,lexicalSelection:N}),(0,be.$setSelection)(N),Se.setMainSelectionJSON(_),le.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;le.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:v});let _=Se.composeFullStateWithRootAndComments();const b={docId:di,state:{state:_,selection:Se.getCurrentActiveSelectionJSON()}};le.log("[codoxSync]: Before sync",{local:b,upd_call_counter:v}),le.log("[codoxSync]: Before sync state",JSON.parse(JSON.stringify(b.state)));let{state:x,remoteSelection:w=[],changes:S}=ri().sync({state:b,meta:{}});if(le.log("[codoxSync]: After sync",{afterSyncState:JSON.parse(JSON.stringify(x)),remoteSelection:w,changes:S}),!x)return le.error("[codoxSync] abort apply - synced state is not valid - restarting codox "),s();const C=x.state;le.log("[codoxSync]: synced state: ",JSON.parse(JSON.stringify(C)),v);let{stateFromSync:k,commentsFromSync:D}=Se.extractStateAndCommentsFromSynced(C);if(!Se.isValidJSONState(k.state))return le.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:k.state}),s();a(k,w),On.setAllComments(D)},u=()=>{le.warn("[rollbackStateDuringUpdateError] rollback invoked"),le.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(),io.historic);let b=Se.undoInvoked(),x=Se.redoInvoked();On.gcAbandonedNodeKeys(Se.getMainEditorState()._nodeMap),b&&f.dispatchCommand(be.CAN_REDO_COMMAND,!1),x&&f.dispatchCommand(be.CAN_UNDO_COMMAND,!1)},g=v=>{let{editorState:_,prevEditorState:b,tags:x,dirtyElements:w,dirtyLeaves:S}=v;if(hp)return hp=!1,void le.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(Wi.isBlacklistedFound())return hp=!0,le.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,be.$getSelection)();j=$e.lexicalToJSON(L),T=V.toJSON()}),Se.setCurrentContentStateJSON(T),Se.setMainSelectionJSON(j),a({state:F,selection:z},So.getCurrentRemoteSelections(),io.historic),f.dispatchCommand(be.CAN_REDO_COMMAND,!1),f.dispatchCommand(be.CAN_UNDO_COMMAND,!1)})(_,b),void Wi.invokeClientCallback();if(!Ro.ensureDocTablesAreValid(_))return;Du++,le.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:Du,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(Kl),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,be.$getSelection)();N=$e.lexicalToJSON(V);let K=$e.JSONToLexical(N),z=V===null&&K===null||V.is(K);le.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=dp(R,k),I=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),N);le.log("[editorUpdatesListener] compares: ",{isStateSame:G,isSelectionSame:I});let $=G&&I&&!U;if(!G||U||A){let V=As({},G?R:k),K=On.getAllComments();K.length&&(V.commentThreads=K);let z={source:A?W0.remote:W0.local,content:V};Eo.hooks&&Eo.hooks.contentChanged&&Eo.hooks.contentChanged(z),ri().instance.emit("content_changed",z)}if($)le.log("[editorUpdatesListener] STOP - state and selection and comments are same ",Du);else if(Se.undoInvoked()&&Se.setUndoInvoked(!1),Se.redoInvoked()&&Se.setRedoInvoked(!1),Se.setCurrentContentStateJSON(k),Se.setPrevContentStateJSON(D),Se.setMainSelectionJSON(N),Se.setPrevMainSelectionJSON(O),pp){let V=Se.getCurrentActiveSelectionJSON();a({state:Se.getCurrentContentStateJSON(),selection:V},[])}else d(Du)},h=()=>{let v=[];return Se.getMainEditorNodesClassesMap().forEach((_,b,x)=>{let{klass:w}=_,S=f.registerMutationListener(w,C=>{for(let[k,D]of C){if(!Kr[D])continue;const N=Se.getLexicalNodeByKey(k);if(D===Kr.created&&N&&Wi.trackBlacklisted(N,D),w.name===An.TableNode.name&&(D===Kr.destroyed?Ro.tableNodeRemoveListener(k):Ro.tableUpdateListener(k)),w.name===An.TableRowNode.name&&D!==Kr.destroyed&&Ro.tableRowNodeChangesListener(k,D===Kr.updated),w.name===An.TableCellNode.name&&D===Kr.updated&&Ro.tableCellNodeChangesListener(k),w.name===oo.MarkNode.name&&(le.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:k,node:N,mutationType:D,codoxComments:On}),D===Kr.destroyed?On.removeRelatedNodeKey(k):N&&On.addRelatedNodeKey(N.__key,N.__ids,D===Kr.created)),N&&N.codoxId){if(D===Kr.destroyed)return void(N.codoxId&&Nn.remove(N.codoxId));xy(N)||le.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,_)=>{le.info(`Subscribing client to codox ${v} event`),gp[v]=_},cursor:{hide:()=>{So.hideRemoteSelectionsFromUI()},show:()=>{So.showHiddenRemoteSelectionsInUI()}},initComments:v=>{On.setInitialComments(v)}};return(0,Gt.useImperativeHandle)(c,()=>y),null}),US=zS,$S=["comments"];function hy(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 mp(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?hy(Object(p),!0).forEach(function(t){HS(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):hy(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function HS(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=WS(m,"string");return typeof c=="symbol"?c:c+""}function WS(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 JS(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}class KS extends $0{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(){le.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,be.$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:mp({},JS(c.state,$S)),selection:t,stateReplace:f},commentsFromSync:p}}composeFullStateWithRootAndComments(){let{directlyFromEditor:c=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return mp(mp({},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 be.ElementNode,o=i.prototype instanceof be.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){le.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?(le.log(`[addUpdateTag] explicit add of tag "${f}" `),void(0,be.$addUpdateTag)(f)):t?(le.log(`[addUpdateTag] add "${io.historic}" tag - change invoked by nested editor`),void(0,be.$addUpdateTag)(io.historic)):void(c?(le.log(`[addUpdateTag] add "${io.historic}" tag - state is same`),(0,be.$addUpdateTag)(io.historic)):(le.log(`[addUpdateTag] add "${io.historyMerge}" tag - state is different`),(0,be.$addUpdateTag)(io.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const GS=new KS,Se=GS;class YS{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 ZS=new YS,Nn=ZS;function gy(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 my(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?gy(Object(p),!0).forEach(function(t){XS(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):gy(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)}const yp=()=>lw(),yy=m=>typeof m=="number";function Ps(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 Aa=m=>m.__type==="root"||m.type==="root",vy=m=>Aa(m.getParent()),Wn=m=>m.__type===Pu.text||m.type===Pu.text||m.hasOwnProperty("__text")||m.hasOwnProperty("text"),js=m=>(0,be.$isElementNode)(m),Ns=m=>(0,An.$isTableNode)(m)||(0,An.$isTableRowNode)(m)||(0,An.$isTableCellNode)(m),e2=m=>!m.getChildren,by=m=>!!m.getChildren,Tn=m=>(0,be.$isDecoratorNode)(m),Yl=m=>(0,tw.$isLinkNode)(m),Zl=m=>m.__type==="mark"||m.type==="mark",vp=m=>(0,be.$isLineBreakNode)(m),Ji=m=>Wn(m)||vp(m),bp=m=>m.__type===Pu.horizontalrule||m.type===Pu.horizontalrule,_y=m=>{if(Ji(m)||Yl(m)||Zl(m))return!1;if(!m.__parent||m.__parent==="root"||(0,be.$isParagraphNode)(m))return!0;let c=m.getParent().getChildren();return c.length===1&&c[0].__key===m.__key?!((Tn(m)||Yl(m)||Zl(m))&&!bp(m)):!c.some(p=>{let t=bp(p);return p.__key!==m.__key&&(Ji(p)||Tn(p)&&!t||Yl(p)||Zl(p))})},xy=m=>{const c=Nn.get(m.codoxId);return!c||m.__key===c.__key},Is=function(m){const c=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||yp();m.codoxId=c,Nn.add(c,m)},wy=m=>{Nn.remove(m.codoxId),delete m.codoxId},n2=m=>{if(!by(m)||!m.getChildrenSize())return;const c=m.getChildren();if(c.some(f=>!!(0,be.$isParagraphNode)(f)))return;let p=!1,t=[];for(let f of c)(Ji(f)||Tn(f)||Yl(f)||Zl(f))&&!p&&(bp(f)||(p=!0)),(by(f)||Tn(f))&&t.push(f);for(let f of t)p||f.codoxId?p&&f.codoxId&&(f=f.getWritable(),wy(f)):(f=f.getWritable(),Is(f))},r2=m=>{const c=my({},m);for(const p in m)m[p]===void 0&&m.hasOwnProperty(p)&&delete c[p];return c},o2=m=>{const c=`__nativeCreateDOM_${m.name}`;m.prototype[c]=Ps(m.prototype.createDOM,c),m.prototype.createDOM=function(p,t){if(_y(this))if(this.codoxId){if(!xy(this)){let r=Nn.get(this.codoxId);r.__type===this.__type&&this.isAttached()&&!r.isAttached()?(le.warn("[createDOM][Non-unique codoxId] overwrite abandoned existing node with latest: ",{latestNode:this,existingNode:r}),Nn.add(this.codoxId,this)):Is(this)}}else Is(this);else this.codoxId&&wy(this);Tn(this)&&!this.codoxDId&&(this.codoxDId=yp()),ui.manageNestedEditorInLexicalNode(this);let f=this[c](p,t);return f.__codox_track=!0,f}},i2=m=>{const c=`__nativeUpdateDOM_${m.name}`;return m.prototype[c]=Ps(m.prototype.updateDOM,c),m.prototype.updateDOM=function(){const p=this[c](...arguments);return n2(this),p},m},a2=m=>{const c=`__nativeRemove_${m.name}`;return m.prototype[c]=Ps(m.prototype.remove,c),m.prototype.remove=function(){const p=this.codoxId;return p&&Nn.remove(p),ui.gcNestedEditorListenerInLexicalNode(this),this[c](...arguments)},m},s2=m=>{const c=`__nativeExportJSON_${m.name}`;m.prototype[c]=Ps(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)&&yy(p.format)&&this.hasFormat&&(p.format=bw(this)),r2(p)}},l2=m=>{const c="__nativeImportJSON";m[c]=Ps(m.importJSON,c),m.importJSON=function(p){const t=my({},p);Wn(t)&&!yy(t.format)&&(t.format=vw(t.format));const f=m[c](t);ui.manageNestedEditorInLexicalNode(f);const r=_y(f);return r&&t.codoxId&&(Nn.hasPastedId(t.codoxId)&&Nn.has(t.codoxId)?(Nn.removePastedId(t.codoxId),Is(f)):Is(f,t.codoxId)),r&&!f.codoxId&&Is(f),t.codoxDId&&(f.codoxDId=t.codoxDId),f}},c2=m=>{const c="__nativeClone";m[c]=Ps(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),ui.manageNestedEditorInClonedLexicalNode(p,t),t}},u2=m=>{let c=!1,p=!1,t=!1,f=!1;m.forEach(n=>{n.name===be.TextNode.name?c=!0:n.name===be.ParagraphNode.name?p=!0:n.name===be.LineBreakNode.name?t=!0:n.name===oo.MarkNode.name&&(f=!0)});let r=[];return c||r.push(be.TextNode),p||r.push(be.ParagraphNode),t||r.push(be.LineBreakNode),f||r.push(oo.MarkNode),r.length?[...r,...m]:m},d2=function(){return u2(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(m=>(m.hasOwnProperty("__isCodoxExtended")||(o2(m),i2(m),s2(m),a2(m),l2(m),c2(m),Object.defineProperty(m,"__isCodoxExtended",{value:!0,writable:!1})),m))};var Lu=on(777),Rs={};Rs.styleTagTransform=ci(),Rs.setAttributes=si(),Rs.insert=ai().bind(null,"head"),Rs.domAPI=ii(),Rs.insertStyleElement=li(),oi()(Lu.A,Rs),Lu.A&&Lu.A.locals&&Lu.A.locals;var f2=m=>{var c={};return on.d(c,m),c};const p2=f2({AutoFocusPlugin:()=>Pm});var h2=m=>{var c={};return on.d(c,m),c};const g2=h2({ClearEditorPlugin:()=>Lx});var m2=m=>{var c={};return on.d(c,m),c};const y2=m2({LexicalComposer:()=>Am});var v2=m=>{var c={};return on.d(c,m),c};const Sy=v2({default:()=>Fx});var b2=m=>{var c={};return on.d(c,m),c};const _2=b2({HistoryPlugin:()=>Gm});var x2=m=>{var c={};return on.d(c,m),c};const w2=x2({OnChangePlugin:()=>Ux});var S2=m=>{var c={};return on.d(c,m),c};const E2=S2({PlainTextPlugin:()=>Gx});var C2=m=>{var c={};return on.d(c,m),c};const Ey=C2({$isRootTextContentEmpty:()=>Zm,$rootTextContent:()=>Ym});var k2=m=>{var c={};return on.d(c,m),c};const Ms=k2({createPortal:()=>a1.createPortal}),O2=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,T2=O2?Gt.useLayoutEffect:Gt.useEffect,Cy=T2;var Bu=on(253),Ds={};Ds.styleTagTransform=ci(),Ds.setAttributes=si(),Ds.insert=ai().bind(null,"head"),Ds.domAPI=ii(),Ds.insertStyleElement=li(),oi()(Bu.A,Ds),Bu.A&&Bu.A.locals&&Bu.A.locals;function A2(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 P2(m){let{onClose:c,children:p,title:t,closeOnClickOutside:f=!1}=m;return(0,Ms.createPortal)(Gt.createElement(A2,{onClose:c,title:t,closeOnClickOutside:f},p),document.body)}function ky(){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(P2,{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 Fu=on(191),Ls={};Ls.styleTagTransform=ci(),Ls.setAttributes=si(),Ls.insert=ai().bind(null,"head"),Ls.domAPI=ii(),Ls.insertStyleElement=li(),oi()(Fu.A,Ls),Fu.A&&Fu.A.locals&&Fu.A.locals;const j2={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"}},N2=j2;var zu=on(72),Bs={};Bs.styleTagTransform=ci(),Bs.setAttributes=si(),Bs.insert=ai().bind(null,"head"),Bs.domAPI=ii(),Bs.insertStyleElement=li(),oi()(zu.A,Bs),zu.A&&zu.A.locals&&zu.A.locals;function I2(){for(var m=arguments.length,c=new Array(m),p=0;p<m;p++)c[p]=arguments[p];return c.filter(Boolean).join(" ")}function _p(){return _p=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},_p.apply(null,arguments)}function Vi(m){let{"data-test-id":c,children:p,className:t,onClick:f,disabled:r,small:n,title:e}=m;return Gt.createElement("button",_p({disabled:r,className:I2("Button__root",r&&"Button__disabled",n&&"Button__small",t),onClick:f,title:e,"aria-label":e},c&&{"data-test-id":c}),p)}var Uu=on(129),Fs={};Fs.styleTagTransform=ci(),Fs.setAttributes=si(),Fs.insert=ai().bind(null,"head"),Fs.domAPI=ii(),Fs.insertStyleElement=li(),oi()(Uu.A,Fs),Uu.A&&Uu.A.locals&&Uu.A.locals;var R2=m=>{var c={};return on.d(c,m),c};const M2=R2({ContentEditable:()=>jm});function D2(m){let{className:c}=m;return Gt.createElement(M2.ContentEditable,{className:c||"ContentEditable__root"})}var $u=on(457),zs={};zs.styleTagTransform=ci(),zs.setAttributes=si(),zs.insert=ai().bind(null,"head"),zs.domAPI=ii(),zs.insertStyleElement=li(),oi()($u.A,zs),$u.A&&$u.A.locals&&$u.A.locals;function L2(m){let{children:c,className:p}=m;return Gt.createElement("div",{className:p||"Placeholder__root"},c)}const B2=Sy.default.LexicalErrorBoundary||Sy.default,F2=()=>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"})),Oy=()=>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"})),z2=()=>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"})),U2=()=>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 Ty(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 $2(m,c,p){return On.createNewThreadObj({quote:m,comments:c,codoxId:p})}function H2(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]),Cy(()=>{r()},[c,p,r]),Gt.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:f},Gt.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:t},Gt.createElement(F2,null)))}function q2(m){let{onEscape:c}=m;const[p]=(0,qi.useLexicalComposerContext)();return(0,Gt.useEffect)(()=>p.registerCommand(be.KEY_ESCAPE_COMMAND,t=>c(t),2),[p,c]),null}function W2(m){let{editorRef:c}=m;const[p]=(0,qi.useLexicalComposerContext)();return typeof c=="function"?c(p):typeof c=="object"&&(c.current=p),null}function Ay(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:N2};return Gt.createElement(y2.LexicalComposer,{initialConfig:s},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:e},Gt.createElement(E2.PlainTextPlugin,{contentEditable:Gt.createElement(D2,{className:c}),placeholder:Gt.createElement(L2,null,n),ErrorBoundary:B2}),Gt.createElement(w2.OnChangePlugin,{onChange:f}),Gt.createElement(_2.HistoryPlugin,null),p!==!1&&Gt.createElement(p2.AutoFocusPlugin,null),Gt.createElement(q2,{onEscape:t}),Gt.createElement(g2.ClearEditorPlugin,null),r!==void 0&&Gt.createElement(W2,{editorRef:r})))}function Py(m,c){return(0,Gt.useCallback)((p,t)=>{p.read(()=>{m((0,Ey.$rootTextContent)()),c(!(0,Ey.$isRootTextContentEmpty)(t.isComposing(),!0))})},[c,m])}function J2(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=Iy(),a=(0,Gt.useCallback)(()=>{c.getEditorState().read(()=>{const u=(0,be.$getSelection)();if((0,be.$isRangeSelection)(u)){l.current=u.clone();const g=u.anchor,h=u.focus,y=(0,Oa.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,Oa.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]);Cy(()=>{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=Py(r,e);return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:s},Gt.createElement(Ay,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:u=>(u.preventDefault(),p(),!0),onChange:d}),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},Gt.createElement(Vi,{onClick:p,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),Gt.createElement(Vi,{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($2(u,[Ty(f,o)]),!0,void 0,l.current),l.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function V2(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=Iy(),l=Py(r,e);return Gt.createElement(Gt.Fragment,null,Gt.createElement(Ay,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:l,editorRef:s,placeholder:t}),Gt.createElement(Vi,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){c(Ty(f,i),!1,p);const o=s.current;o!==null&&o.dispatchCommand(be.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},Gt.createElement(z2,null)))}function jy(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(Vi,{onClick:()=>{p(c,f),t()}},"Delete")," ",Gt.createElement(Vi,{onClick:()=>{t()}},"Cancel")))}function Ny(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]=ky();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(Vi,{onClick:()=>{s("Delete Comment",i=>Gt.createElement(jy,{commentOrThread:c,deleteCommentOrThread:p,thread:t,onClose:i}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(Oy,null)),e))}function K2(m){let{activeIDs:c,comments:p,deleteCommentOrThread:t,listRef:f,submitAddComment:r,markNodeMap:n}=m;const[e]=(0,qi.useLexicalComposerContext)(),[s,i]=(0,Gt.useState)(0),[l,o]=ky(),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,be.$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(Vi,{onClick:()=>{o("Delete Thread",h=>Gt.createElement(jy,{commentOrThread:d,deleteCommentOrThread:t,onClose:h}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(Oy,null)),l),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},d.comments.map(h=>Gt.createElement(Ny,{key:h.codoxId,comment:h,deleteComment:t,thread:d,rtf:a}))),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},Gt.createElement(V2,{submitAddComment:r,thread:d,placeholder:"Reply to comment..."})))}return Gt.createElement(Ny,{key:u,comment:d,deleteComment:t,rtf:a})}))}function G2(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(K2,{activeIDs:c,comments:t,deleteCommentOrThread:p,listRef:n,submitAddComment:f,markNodeMap:r}))}function Iy(){const m=(0,uy.useCollaborationContext)(),{yjsDocMap:c,name:p}=m;return p||"Playground User"}function Y2(m){const[c]=(0,qi.useLexicalComposerContext)(),p=Nw(),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,be.$getSelection)();g!==null&&(g.dirty=!0)}),i(!1)},[c]),d=(0,Gt.useCallback)((g,h)=>{if(g.type==="comment"){if(le.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,be.$getNodeByKey)(b);le.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:x}),x&&x.markDirty()}):(0,be.$getRoot)().markDirty(),(0,be.$addUpdateTag)(io.historic),(0,be.$addUpdateTag)(Kl)})}else{le.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,be.$getNodeByKey)(_);le.log("[deleteCommentOrThread]: type thread new values",{node:b}),(0,oo.$isMarkNode)(b)&&(b.deleteID(y),b.getIDs().length===0&&(0,oo.$unwrapMarkNode)(b))}else(0,be.$getRoot)().markDirty(),le.debug("[deleteCommentOrThread][refreshComments]");On.refreshComments(!0),(0,be.$addUpdateTag)(Kl)})})}},[c,t]),u=(0,Gt.useCallback)((g,h,y,v)=>{if(le.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,be.$isRangeSelection)(v)){const _=v.isBackward(),b=g.codoxId;(0,oo.$wrapSelectionInMarkNode)(v,_,b),(0,be.$addUpdateTag)(Kl)}}),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,be.$getNodeByKey)(w);S&&S.markDirty()}),(0,be.$addUpdateTag)(io.historic),(0,be.$addUpdateTag)(Kl)})}},[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,ks.mergeRegister)((0,ks.registerNestedElementResolver)(c,oo.MarkNode,h=>(0,oo.$createMarkNode)(h.getIDs()),(h,y)=>{h.getIDs().forEach(v=>{y.addID(v)})}),c.registerMutationListener(oo.MarkNode,h=>{c.getEditorState().read(()=>{for(const[y,v]of h){const _=(0,be.$getNodeByKey)(y);let b=[];v==="destroyed"?b=g.get(y)||[]:(0,oo.$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,be.$getSelection)();let b=!1,x=!1;if((0,be.$isRangeSelection)(_)){const w=_.anchor.getNode();if((0,be.$isTextNode)(w)){const S=(0,oo.$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,be.$isRangeSelection)(_)&&i(!1)})}),c.registerCommand(up,()=>{const h=window.getSelection();return h!==null&&h.removeAllRanges(),i(!0),!0},be.COMMAND_PRIORITY_EDITOR))},[c,t]),Gt.createElement(Gt.Fragment,null,s&&(0,Ms.createPortal)(Gt.createElement(J2,{editor:c,cancelAddComment:a,submitAddComment:u}),document.body),f!=null&&!s&&(0,Ms.createPortal)(Gt.createElement(H2,{anchorKey:f,editor:c,onAddComment:()=>{c.dispatchCommand(up,void 0)}}),document.body),(0,Ms.createPortal)(Gt.createElement(Vi,{className:"CodoxCommentPlugin_ShowCommentsButton "+(l?"active":""),onClick:()=>o(!l),title:l?"Hide Comments":"Show Comments"},Gt.createElement(U2,null)),document.body),l&&(0,Ms.createPortal)(Gt.createElement(G2,{comments:p,submitAddComment:u,deleteCommentOrThread:d,activeIDs:n,markNodeMap:t}),document.body))}var Hu=on(766),Us={};Us.styleTagTransform=ci(),Us.setAttributes=si(),Us.insert=ai().bind(null,"head"),Us.domAPI=ii(),Us.insertStyleElement=li(),oi()(Hu.A,Us),Hu.A&&Hu.A.locals&&Hu.A.locals;var qu=on(225),$s={};$s.styleTagTransform=ci(),$s.setAttributes=si(),$s.insert=ai().bind(null,"head"),$s.domAPI=ii(),$s.insertStyleElement=li(),oi()(qu.A,$s),qu.A&&qu.A.locals&&qu.A.locals;function Z2(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 Ry(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 Wu(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?Ry(Object(p),!0).forEach(function(t){X2(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):Ry(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function X2(m,c,p){return(c=Q2(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function Q2(m){var c=tE(m,"string");return typeof c=="symbol"?c:c+""}function tE(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 Xl=!1;const eE=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],Ql=214,My=150;function nE(m){let{color:c,onChange:p}=m;const[t,f]=(0,Gt.useState)(Hs("hex",c)),[r,n]=(0,Gt.useState)(c),e=(0,Gt.useRef)(null),s=(0,Gt.useMemo)(()=>({x:t.hsv.s/100*Ql,y:(100-t.hsv.v)/100*My}),[t.hsv.s,t.hsv.v]),i=(0,Gt.useMemo)(()=>({x:t.hsv.h/360*Ql}),[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=Hs("hex",c);f(l),n(l.hex)},[c]),Gt.createElement("div",{className:"codox-color-picker-wrapper",style:{width:Ql},ref:e},Gt.createElement(Z2,{label:"Hex",onChange:l=>{if(n(l),/^#[0-9A-Fa-f]{6}$/i.test(l)){const o=Hs("hex",l);f(o)}},value:r}),Gt.createElement("div",{className:"codox-color-picker-basic-color"},eE.map(l=>Gt.createElement("button",{className:l===t.hex?" active":"",key:l,style:{backgroundColor:l},onClick:()=>(o=>{n(o);let a=Hs("hex",o);f(a),p(a.hex,Xl)})(l)}))),Gt.createElement(Dy,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`},onChange:l=>{let{x:o,y:a}=l;const d=Hs("hsv",Wu(Wu({},t.hsv),{},{s:o/Ql*100,v:100-a/My*100}));f(d),n(d.hex),p(d.hex,Xl)}},Gt.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:t.hex,left:s.x,top:s.y}})),Gt.createElement(Dy,{className:"codox-color-picker-hue",onChange:l=>{let{x:o}=l;const a=Hs("hsv",Wu(Wu({},t.hsv),{},{h:o/Ql*360}));f(a),n(a.hex),p(a.hex,Xl)}},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 Dy(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=Ly(s.clientX-a,l,0),g=Ly(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,Xl=!0,e(o)},l=o=>{n.current&&(Xl=!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 Ly(m,c,p){return m>c?c:m<p?p:m}function By(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 Fy(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 xp(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 rE(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 zy(m){let{b:c,g:p,r:t}=m;return"#"+[t,p,c].map(f=>f.toString(16).padStart(2,"0")).join("")}function Hs(m,c){let p=By("#121212"),t=Fy(p),f=xp(t);return m==="hex"?(p=By(c),t=Fy(p),f=xp(t)):m==="rgb"?(t=c,p=zy(t),f=xp(t)):m==="hsv"&&(f=c,t=rE(f),p=zy(t)),{hex:p,hsv:f,rgb:t}}const oE=Gt.createContext(null),Uy=4;function iE(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(oE.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 aE(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+Uy}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+Uy;_!==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,Ms.createPortal)(Gt.createElement(iE,{dropDownRef:o,onClose:()=>{u(!1),a&&a.current&&a.current.focus()},dropdownClassName:s},n),document.body))}const sE=["disabled","stopCloseOnClickSelf","color","onChange"];function wp(){return wp=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},wp.apply(null,arguments)}function lE(m,c){if(m==null)return{};var p,t,f=cE(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 cE(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 $y(m){let{disabled:c=!1,stopCloseOnClickSelf:p=!0,color:t,onChange:f}=m,r=lE(m,sE);return Gt.createElement(aE,wp({},r,{disabled:c,stopCloseOnClickSelf:p}),Gt.createElement(nE,{color:t,onChange:f}))}const uE=m=>{let{onColorChange:c,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=m;const[i]=(0,qi.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,d]=(0,Gt.useState)("");(0,Gt.useEffect)(()=>(0,ks.mergeRegister)(i.registerEditableListener(g=>{o(g)}),i.registerUpdateListener(g=>{let{editorState:h}=g;h.read(()=>{const y=(0,be.$getSelection)();if((0,be.$isRangeSelection)(y)){let v=(0,Oa.$getSelectionStyleValueForProperty)(y,"color");v!==a&&(d(v||""),c(v))}})})),[i]);const u=(0,Gt.useCallback)((g,h)=>{i.update(()=>{const y=(0,be.$getSelection)();y!==null&&(0,Oa.$patchStyleText)(y,{color:g})})},[i]);return Gt.createElement($y,{disabled:!l,color:a,onChange:u,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},dE=uE,fE=m=>{let{onColorChange:c,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=m;const[i]=(0,qi.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,d]=(0,Gt.useState)("#fff");(0,Gt.useEffect)(()=>(0,ks.mergeRegister)(i.registerEditableListener(g=>{o(g)}),i.registerUpdateListener(g=>{let{editorState:h}=g;h.read(()=>{const y=(0,be.$getSelection)();if((0,be.$isRangeSelection)(y)){let v=(0,Oa.$getSelectionStyleValueForProperty)(y,"background-color");v!==a&&(d(v||""),c(v))}})})),[i]);const u=(0,Gt.useCallback)((g,h)=>{i.update(()=>{const y=(0,be.$getSelection)();y!==null&&(0,Oa.$patchStyleText)(y,{"background-color":g})})},[i]);return Gt.createElement($y,{disabled:!l,color:a,onChange:u,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},pE=fE;var hE=zi.yy;zi._U,zi.a8,zi.Vs,zi.Cn;var gE=zi.gK,mE=zi.vv;function yE(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}var Ju=yE(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 vE({hasCellMerge:m=!0,hasCellBackgroundColor:c=!0,hasTabHandler:p=!0}){const[t]=Nr();return we.useEffect(()=>(t.hasNodes([wo,Bi,$l])||Ju(10),_o(t.registerCommand(vx,({columns:f,rows:r,includeHeaders:n})=>{const e=b0(Number(r),Number(f),n);Wm(e);const s=e.getFirstDescendant();return je(s)&&s.select(),!0},an),t.registerNodeTransform(wo,f=>{const[r]=S0(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=ni(0);o.append(jn()),i!==null?i.insertAfter(o):Jm(i,o)}}}))),[t]),we.useEffect(()=>{const f=new Map,r=e=>{const s=e.getKey(),i=t.getElementByKey(s);if(i&&!f.has(s)){const l=jx(e,i,t,p);f.set(s,l)}};t.getEditorState().read(()=>{const e=jg(wo);for(const s of e)Rn(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);Rn(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]),we.useEffect(()=>{if(!m)return t.registerNodeTransform(Bi,f=>{if(f.getColSpan()>1||f.getRowSpan()>1){const[,,r]=Vr(f),[n]=Io(r,f,f),e=n.length,s=n[0].length;let i=r.getFirstChild();cr(i)||Ju(175);const l=[];for(let o=0;o<e;o++){o!==0&&(i=i.getNextSibling(),cr(i)||Ju(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)||Ju(176);const h=ni(g.__headerState);a!==null?a.insertAfter(h):Jm(i,h)}}}for(const o of l)o.setColSpan(1),o.setRowSpan(1)}})},[t,m]),we.useEffect(()=>{if(!c)return t.registerNodeTransform(Bi,f=>{f.getBackgroundColor()!==null&&f.setBackgroundColor(null)})},[t,c,m]),null}const zk="",bE={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"}},_E="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE1IDE1IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMDAwMDEgOC4zMzMzM0wxLjkwMDAxIDEzLjhMMS4xMDAwMSAxMy4yTDUuMzc1MDEgNy41TDEuMTAwMDEgMS44TDEuOTAwMDEgMS4yTDYuMDAwMDEgNi42NjY2N0wxMC4xIDEuMkwxMC45IDEuOEw2LjYyNTAxIDcuNUwxMC45IDEzLjJMMTAuMSAxMy44TDYuMDAwMDEgOC4zMzMzM1pNMTIgMTIuNUMxMiAxMS42NzE2IDEyLjY3MTYgMTEgMTMuNSAxMUgxMy43OTI5QzE0LjQ1OTYgMTEgMTUgMTEuNTQwNCAxNSAxMi4yMDcxQzE1IDEyLjUyNzMgMTQuODcyOCAxMi44MzQzIDE0LjY0NjUgMTMuMDYwN0wxMy43MDcxIDE0SDE1VjE1SDEyLjVDMTIuMjk3OCAxNSAxMi4xMTU1IDE0Ljg3ODIgMTIuMDM4MSAxNC42OTEzQzExLjk2MDcgMTQuNTA0NSAxMi4wMDM1IDE0LjI4OTQgMTIuMTQ2NSAxNC4xNDY0TDEzLjkzOTMgMTIuMzUzNkMxMy45NzgyIDEyLjMxNDcgMTQgMTIuMjYyIDE0IDEyLjIwNzFDMTQgMTIuMDkyNyAxMy45MDczIDEyIDEzLjc5MjkgMTJIMTMuNUMxMy4yMjM5IDEyIDEzIDEyLjIyMzkgMTMgMTIuNUgxMloiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+",xE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDQgNTEyLjM2Ij48cGF0aCBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik00OTkuNDMgMjMxLjM2SDM2OC40Yy0yLjUzIDAtNC41OC0yLjA1LTQuNTgtNC41N3YtOC4xMWMwLTEuMjYuNTItMi40IDEuMzQtMy4yMmw3MS41Ny04Mi41M2M2LjczLTcuNzUgMTIuNTctMTQuOTcgMTcuNDgtMjEuNjggNC44OC02LjY0IDguODMtMTIuNzQgMTEuODUtMTguMjggMi45Ny01LjQzIDUuMTgtMTAuNjEgNi42NC0xNS41NSAxLjQyLTQuODUgMi4xMy05LjUzIDIuMTMtMTQgMC0xNC42OC0zLjk4LTI2LjA1LTExLjkyLTM0LjA5LTMuOTItMy45Ni04Ljc1LTYuOTMtMTQuNDktOC45Mi01Ljk1LTIuMDMtMTIuOTEtMy4wNS0yMC44Ny0zLjA1LTguNDUgMC0xNS44OCAxLjIxLTIyLjI5IDMuNjItNi4yNyAyLjM2LTExLjYzIDUuOTItMTYuMDcgMTAuNjNhNDcuODg0IDQ3Ljg4NCAwIDAgMC0xMC4xNCAxNi42Yy0yLjI3IDYuMjktMy40MSAxMy4zOS0zLjQxIDIxLjI2IDAgMi41Mi0yLjA1IDQuNTctNC41NyA0LjU3aC02Ljg5Yy0yLjA1IDAtMy44LTEuMzYtNC4zNy0zLjI0bC0uMjctLjgyYy0uMTgtLjU2LS4yNS0xLjEzLS4yMi0xLjY3LS4yMy05LjMyIDEuMTQtMTcuOTkgNC4xMi0yNS45NyAzLjAyLTguMTMgNy42OC0xNS41NCAxMy45NC0yMi4xOSA2LjI2LTYuNyAxMy42My0xMS43NiAyMi4xLTE1LjEzQzQwNy44NCAxLjY4IDQxNy4yIDAgNDI3LjU1IDBjOS41OSAwIDE4LjI2IDEuMzggMjYuMDMgNC4xMyA3Ljg2IDIuNzkgMTQuNzcgNyAyMC43MiAxMi42MSA2LjAyIDUuNjMgMTAuNTUgMTIuNCAxMy41NSAyMC4yOCAyLjk2IDcuNzUgNC40NSAxNi41NiA0LjQ1IDI2LjQgMCA2LjUtMS4wNyAxMy4wOC0zLjE3IDE5LjY5bC0uMTQuMzhjLTIuMDkgNi40Ni01LjE3IDEyLjk3LTkuMiAxOS40OWwtLjE0LjIxYy00LjA4IDYuNTEtOC45IDEzLjQzLTE0LjQzIDIwLjc0LTUuNTYgNy4zMy0xMS45NiAxNS4yMy0xOS4yMiAyMy42N2wtNTYuOTEgNjYuNTFoMTEwLjM0YzIuNTIgMCA0LjU3IDIuMDUgNC41NyA0LjU3djguMTFjMCAyLjUyLTIuMDUgNC41Ny00LjU3IDQuNTd6bS0zMjcuMjUgNjguNzUgMTM3Ljk2LTE2Ny43NmMuODktMS4wNyAyLjMtMS42NSAzLjc0LTEuNjVsMjAuMTMtLjAyYzIuNTIgMCA0LjU3IDEuNzQgNC41NyAzLjg4IDAgLjkxLS4zNyAxLjc1LS45OCAyLjQxTDE4OC4zMiAzMTcuNjYgMzQ0LjEgNTA2LjI0YzEuNDUgMS43NS45NSA0LjE3LTEuMSA1LjQtLjguNDgtMS43Mi43MS0yLjYzLjcxbC0yMC4xMy4wMWMtMS43IDAtMy4xOC0uNzktMy45Ny0xLjk2bC0xNDQuMS0xNzUuMkwyOC4yMyA1MTAuNjljLS44OCAxLjA3LTIuMyAxLjY0LTMuNzMgMS42NWwtMTkuOTMuMDJjLTIuNTIgMC00LjU3LTEuNzQtNC41Ny0zLjg5IDAtLjkuMzctMS43NC45OC0yLjRsMTU1LjY1LTE4OC40TDYuOSAxMzYuOGMtMS40NS0xLjc1LS45NS00LjE4IDEuMTEtNS40MS43OS0uNDcgMS43MS0uNyAyLjYyLS43bDIwLjQ0LS4wMWMxLjYzIDAgMy4wNi43MiAzLjg3IDEuODFsMTM3LjI0IDE2Ny42MnoiLz48L3N2Zz4=",Hy=Un.createContext(null),qy=4;function Vu({children:m,className:c,onClick:p,title:t}){const f=we.useRef(null),r=Un.useContext(Hy);if(r===null)throw new Error("DropDownItem must be used within a DropDown");const{registerItem:n}=r;return we.useEffect(()=>{f&&f.current&&n(f)},[f,n]),he.jsx("button",{className:c,onClick:p,ref:f,title:t,type:"button",children:m})}function wE({children:m,dropDownRef:c,onClose:p}){const[t,f]=we.useState(),[r,n]=we.useState(),e=we.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=we.useMemo(()=>({registerItem:e}),[e]);return we.useEffect(()=>{t&&!r&&n(t[0]),r&&r.current&&r.current.focus()},[t,r]),he.jsx(Hy.Provider,{value:i,children:he.jsx("div",{className:"dropdown",ref:c,onKeyDown:s,children:m})})}function SE({disabled:m=!1,buttonLabel:c,buttonAriaLabel:p,buttonClassName:t,buttonIconClassName:f,children:r,stopCloseOnClickSelf:n}){const e=we.useRef(null),s=we.useRef(null),[i,l]=we.useState(!1),o=()=>{l(!1),s&&s.current&&s.current.focus()};return we.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+qy}px`,d.style.left=`${Math.min(g,window.innerWidth-d.offsetWidth-20)}px`}},[e,s,i]),we.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]),we.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+qy;h!==u.getBoundingClientRect().top&&(u.style.top=`${h}px`)}}};return document.addEventListener("scroll",a),()=>{document.removeEventListener("scroll",a)}},[s,e,i]),he.jsxs(he.Fragment,{children:[he.jsxs("button",{type:"button",disabled:m,"aria-label":p||c,className:t,onClick:()=>l(!i),ref:s,children:[f&&he.jsx("span",{className:f}),c&&he.jsx("span",{className:"text dropdown-button-text",children:c}),he.jsx("i",{className:"chevron-down"})]}),i&&Wr.createPortal(he.jsx(wE,{dropDownRef:e,onClose:o,children:r}),document.body)]})}function Wy(){return he.jsx("div",{className:"divider"})}const Sp=8,Ep=72,qs={h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",paragraph:"Normal"},EE=({selectionFontSize:m,disabled:c,editor:p,blockType:t,styleConfig:f,isenterPressed:r,currentElementClick:n,currentElementSelect:e})=>{const[s,i]=Un.useState(m),[l,o]=Un.useState(t),[a,d]=Un.useState(""),u=x=>{p.update(()=>{if(p.isEditable()){const w=Ce();w!==null&&Bm(w,x)}})},g=x=>{i(x.target.value)},h=()=>{const x=Number(s);if(!isNaN(x)){const w=Math.min(Math.max(x,Sp),Ep);i(String(w)),u({"font-size":`${w}px`})}},y=x=>{const w=f[l].fontSize,S=x?Math.min(w+2,Ep):Math.max(w-2,Sp);i(String(S)),u({"font-size":`${l}px`})},v=x=>{p.update(()=>{const w=Ce();ve(w)&&O_(w,()=>jn())})},_=x=>{d(x),p.update(()=>{const C=Ce();ve(C)&&A_(C,()=>ws(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),u({title:`${S.title}`,"font-size":`${S.fontSize}px`,color:S.fontColor,"font-family":S.fontFamily,"line-height":`${1+S.leadingSpace}em`,"margin-bottom":`${S.trailingSpace}em`})},b=()=>{o("paragraph"),u({"font-size":"11px"}),i("11"),v()};return Un.useEffect(()=>{r&&r==="Enter"&&b()},[r]),Un.useEffect(()=>{const x=()=>{p.update(()=>{const w=Ce();if(w!==null){const C=w.getNodes()[0];if(!je(C)){const k=C.getType();k in qs&&o(k)}}})};return p.registerUpdateListener(x),()=>{p.registerUpdateListener(x)}},[p]),Un.useEffect(()=>{switch(n.tagName){case"P":o("paragraph");break;case"H1":console.log("H1"),o("h1");break;case"H2":o("h2");break;case"H3":o("h3");break;case"default":o("paragraph"),console.log("default");break}},[n]),Un.useEffect(()=>{switch(e.trim(" ")){case"Heading1":console.log("Setting current heading to h1"),o("h1");break;case"Heading2":o("h2");break;case"Heading3":o("h3");break;case"default":case"paragraph":o("paragraph"),console.log("Setting to default paragraph");break;default:console.warn("Unknown element type:",e);break}},[e]),he.jsxs(he.Fragment,{children:[he.jsx("button",{type:"button",disabled:c,onClick:()=>y(!1),className:"toolbar-item font-decrement"}),he.jsx("input",{type:"number",value:s,disabled:c,readOnly:!0,className:"toolbar-item font-size-input",min:Sp,max:Ep,onChange:g,onBlur:h}),he.jsx("button",{type:"button",disabled:c,onClick:()=>y(!0),className:"toolbar-item font-increment"}),he.jsx(Wy,{}),he.jsxs("div",{className:"symbol-dropdown cust-head-dropDown",children:[he.jsxs(SE,{disabled:c,buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"Formatting options for text style",buttonIconClassName:"icon block-type "+l,buttonLabel:qs[l],children:[he.jsxs(Vu,{className:`item ${l==="paragraph"?"active":""}`,onClick:()=>v(),children:[he.jsx("i",{className:"icon paragraph"}),he.jsx("span",{className:"text",children:qs.paragraph})]}),he.jsxs(Vu,{className:`item ${l==="h1"?"active":""}`,onClick:()=>_("h1"),children:[he.jsx("i",{className:"icon h1"}),he.jsx("span",{className:"text",children:qs.h1})]}),he.jsxs(Vu,{className:`item ${l==="h2"?"active":""}`,onClick:()=>_("h2"),children:[he.jsx("i",{className:"icon h2"}),he.jsx("span",{className:"text",children:qs.h2})]}),he.jsxs(Vu,{className:`item ${l==="h3"?"active":""}`,onClick:()=>_("h3"),children:[he.jsx("i",{className:"icon h3"}),he.jsx("span",{className:"text",children:qs.h3})]})]}),he.jsx(Wy,{})]})]})},CE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuMS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIyIEZvbnRpY29ucywgSW5jLi0tPjxwYXRoIGQ9Ik0wIDI1NkMwIDExNC42IDExNC42IDAgMjU2IDBzMjU2IDExNC42IDI1NiAyNTYtMTE0LjYgMjU2LTI1NiAyNTZTMCAzOTcuNCAwIDI1NnptMTc1LTQ3LjkgNDcuMSA0N0wxNzUgMzAzYy05LjMgOS40LTkuMyAyNC42IDAgMzMuMSA5LjQgMTAuMiAyNC42IDEwLjIgMzMuMSAwbDQ3LTQ2LjIgNDcuOSA0Ni4yYzkuNCAxMC4yIDI0LjYgMTAuMiAzMy4xIDAgMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMWwtNDYuMi00Ny45IDQ2LjItNDdjMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMS04LjUtOS4zLTIzLjctOS4zLTMzLjEgMGwtNDcuOSA0Ny4xLTQ3LTQ3LjFjLTguNS05LjMtMjMuNy05LjMtMzMuMSAwLTkuMyA5LjQtOS4zIDI0LjYgMCAzMy4xeiIvPjwvc3ZnPg==",kE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGFibGUiPjxwYXRoIGQ9Ik0wIDJhMiAyIDAgMCAxIDItMmgxMmEyIDIgMCAwIDEgMiAydjEyYTIgMiAwIDAgMS0yIDJIMmEyIDIgMCAwIDEtMi0yVjJ6bTE1IDJoLTR2M2g0VjR6bTAgNGgtNHYzaDRWOHptMCA0aC00djNoM2ExIDEgMCAwIDAgMS0xdi0yem0tNSAzdi0zSDZ2M2g0em0tNSAwdi0zSDF2MmExIDEgMCAwIDAgMSAxaDN6bS00LTRoNFY4SDF2M3ptMC00aDRWNEgxdjN6bTUtM3YzaDRWNEg2em00IDRINnYzaDRWOHoiLz48L3N2Zz4=";function OE(){const[m,c]=we.useState("4"),[p,t]=we.useState("4"),[f,r]=we.useState(!1),[n,e]=we.useState(),[s]=Nr(),i=()=>{!m||!p||(s.update(()=>{const l=b0(m,p,!0),o=Wm(l);e(o)}),r(!1))};return he.jsxs(he.Fragment,{children:[he.jsx("button",{className:"toolbar-item ",onClick:()=>r(!0),children:he.jsx("img",{className:"add-toolbar-table-icon",src:kE,alt:"Add Table"})}),f&&he.jsx("div",{className:"modal-overlay",children:he.jsxs("div",{className:"modal-content",children:[he.jsx("h3",{children:"Select Table Dimensions"}),he.jsx("button",{className:"modal-buttons-close",onClick:()=>r(!1),children:he.jsx("img",{src:CE,height:16,width:16,style:{margin:"0 0 29px 10px"}})}),he.jsxs("div",{className:"select-table-container",children:[he.jsx("label",{children:"Rows"}),he.jsx("input",{type:"number",value:m,onChange:l=>c(Number(l.target.value))})]}),he.jsxs("div",{className:"select-table-container",children:[he.jsx("label",{children:"Column"}),he.jsx("input",{type:"number",value:p,onChange:l=>t(Number(l.target.value))})]}),he.jsx("div",{children:he.jsx("div",{className:"modal-buttons",children:he.jsx("button",{className:"toolbar-item",onClick:i,children:"Confirm"})})})]})})]})}const Jy="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNCAxMkgyME0xMiA0VjIwIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==",Vy="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNiAxMkwxOCAxMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4=";var TE=typeof global=="object"&&global&&global.Object===Object&&global;const AE=TE;var PE=typeof self=="object"&&self&&self.Object===Object&&self,jE=AE||PE||Function("return this")();const Ky=jE;var NE=Ky.Symbol;const Ku=NE;var Gy=Object.prototype,IE=Gy.hasOwnProperty,RE=Gy.toString,tc=Ku?Ku.toStringTag:void 0;function ME(m){var c=IE.call(m,tc),p=m[tc];try{m[tc]=void 0;var t=!0}catch{}var f=RE.call(m);return t&&(c?m[tc]=p:delete m[tc]),f}var DE=Object.prototype,LE=DE.toString;function BE(m){return LE.call(m)}var FE="[object Null]",zE="[object Undefined]",Yy=Ku?Ku.toStringTag:void 0;function UE(m){return m==null?m===void 0?zE:FE:Yy&&Yy in Object(m)?ME(m):BE(m)}function $E(m){return m!=null&&typeof m=="object"}var HE="[object Symbol]";function qE(m){return typeof m=="symbol"||$E(m)&&UE(m)==HE}var WE=/\s/;function JE(m){for(var c=m.length;c--&&WE.test(m.charAt(c)););return c}var VE=/^\s+/;function KE(m){return m&&m.slice(0,JE(m)+1).replace(VE,"")}function Cp(m){var c=typeof m;return m!=null&&(c=="object"||c=="function")}var Zy=0/0,GE=/^[-+]0x[0-9a-f]+$/i,YE=/^0b[01]+$/i,ZE=/^0o[0-7]+$/i,XE=parseInt;function Xy(m){if(typeof m=="number")return m;if(qE(m))return Zy;if(Cp(m)){var c=typeof m.valueOf=="function"?m.valueOf():m;m=Cp(c)?c+"":c}if(typeof m!="string")return m===0?m:+m;m=KE(m);var p=YE.test(m);return p||ZE.test(m)?XE(m.slice(2),p?2:8):GE.test(m)?Zy:+m}var QE=function(){return Ky.Date.now()};const kp=QE;var tC="Expected a function",eC=Math.max,nC=Math.min;function rC(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(tC);c=Xy(c)||0,Cp(p)&&(l=!!p.leading,o="maxWait"in p,r=o?eC(Xy(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?nC(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=kp();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(kp())}function x(){var w=kp(),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 oC(m,c,p){const t=we.useRef(null);return t.current=m,we.useMemo(()=>rC((...f)=>{t.current&&t.current(...f)},c,{maxWait:p}),[c,p])}const Qy=20;function iC({anchorElem:m}){const[c]=Nr(),p=_u(),[t,f]=we.useState(!1),[r,n]=we.useState(!1),[e,s]=we.useState(!1),[i,l]=we.useState({}),o=we.useRef(new Set),a=we.useRef(null),d=oC(y=>{const{isOutside:v,tableDOMNode:_}=aC(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=ar(_);if(rn(S)){const k=bn(S,D=>Rn(D));if(!Rn(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=Sx(S),R=x0(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:Qy,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:Qy}))}},50,250),u=we.useMemo(()=>new ResizeObserver(()=>{f(!1),n(!1)}),[]);we.useEffect(()=>{if(e)return document.addEventListener("mousemove",d),()=>{f(!1),n(!1),d.cancel(),document.removeEventListener("mousemove",d)}},[e,d]),we.useEffect(()=>_o(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=ar(a.current);v==null||v.selectEnd(),y?(Ex(),f(!1)):(Cx(),n(!1))}})},h=y=>{c.update(()=>{if(a.current){const v=ar(a.current);v==null||v.selectEnd(),y?(kx(),f(!1)):(Ox(),n(!1))}})};return p?he.jsxs(he.Fragment,{children:[t&&he.jsxs("div",{children:[he.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%",padding:"20px"},onClick:()=>g(!0),children:he.jsx("img",{src:Jy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),he.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%"},onClick:()=>h(!0),children:he.jsx("img",{src:Vy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]}),r&&he.jsxs("div",{className:"table-add-row-flex-container",children:[he.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%",padding:"20px"},onClick:()=>g(!1),children:he.jsx("img",{src:Jy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),he.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%"},onClick:()=>h(!1),children:he.jsx("img",{src:Vy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]})]}):null}function aC(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 sC({anchorElem:m=document.body}){return _u()?Wr.createPortal(he.jsx(iC,{anchorElem:m}),m):null}const ec=1;function Op(){return he.jsx("div",{className:"divider"})}function lC({renderOnlineUsers:m,styleConfig:c}){const[p]=Nr(),t=we.useRef(null),[f,r]=we.useState(!1),[n,e]=we.useState(!1),[s,i]=we.useState(!1),[l,o]=we.useState(!1),[a,d]=we.useState(!1),[u,g]=we.useState(!1),[h,y]=we.useState(!1),[v,_]=we.useState(!1),[b,x]=we.useState("11px"),[w,S]=we.useState(()=>p.isEditable()),[C,k]=we.useState(""),[D,N]=we.useState(""),[O,R]=we.useState(""),A=we.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(zm(U,"font-size","11px")))},[]);return we.useEffect(()=>_o(p.registerUpdateListener(({editorState:U})=>{U.read(()=>{A()})}),p.registerCommand(Go,U=>{k("");const q=Ce();return console.log("SELECTION_CHANGE_COMMAND",q&&q.style&&q.style.split(";")[0].split(":")[1]),R(q&&q.style?q.style.split(";")[0].split(":")[1]:"paragraph"),A(),!1},ec),p.registerCommand(is,U=>(r(U),!1),ec),p.registerCommand(os,U=>(e(U),!1),ec),p.registerCommand(qd,U=>(N(U.target),!1),ec),p.registerCommand(ns,U=>(k(U.code),!1),ec)),[p,A]),he.jsxs("div",{className:"toolbar",ref:t,children:[he.jsx("button",{disabled:!f,onClick:()=>{p.dispatchCommand(_l,void 0)},className:"toolbar-item spaced","aria-label":"Undo",children:he.jsx("i",{className:"format undo"})}),he.jsx("button",{disabled:!n,onClick:()=>{p.dispatchCommand(xl,void 0)},className:"toolbar-item","aria-label":"Redo",children:he.jsx("i",{className:"format redo"})}),he.jsx(Op,{}),he.jsx(EE,{currentElementClick:D,selectionFontSize:b.slice(0,-2),editor:p,disabled:!w,blockType:"paragraph",styleConfig:c,isenterPressed:C,currentElementSelect:O}),he.jsx(Op,{}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"bold")},className:"toolbar-item spaced "+(s?"active":""),"aria-label":"Format Bold",children:he.jsx("i",{className:"format bold"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"italic")},className:"toolbar-item spaced "+(l?"active":""),"aria-label":"Format Italics",children:he.jsx("i",{className:"format italic"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"underline")},className:"toolbar-item spaced "+(a?"active":""),"aria-label":"Format Underline",children:he.jsx("i",{className:"format underline"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"strikethrough")},className:"toolbar-item spaced "+(u?"active":""),"aria-label":"Format Strikethrough",children:he.jsx("i",{className:"format strikethrough"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"superscript")},className:"toolbar-item spaced "+(v?"active":""),"aria-label":"Format SuperScript",children:he.jsx("img",{src:xE,height:16,width:16,style:{marginTop:"1px"}})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"subscript")},className:"toolbar-item spaced "+(h?"active":""),"aria-label":"Format SubScript",children:he.jsx("img",{src:_E,height:16,width:16,style:{marginTop:"1px"}})}),he.jsx(Op,{}),he.jsx("button",{onClick:()=>{p.dispatchCommand(rs,"left")},className:"toolbar-item spaced","aria-label":"Left Align",children:he.jsx("i",{className:"format left-align"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(rs,"center")},className:"toolbar-item spaced","aria-label":"Center Align",children:he.jsx("i",{className:"format center-align"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(rs,"right")},className:"toolbar-item spaced","aria-label":"Right Align",children:he.jsx("i",{className:"format right-align"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(rs,"justify")},className:"toolbar-item","aria-label":"Justify Align",children:he.jsx("i",{className:"format justify-align"})}),he.jsx(OE,{}),he.jsx(sC,{}),he.jsx("div",{className:"avtar-outer-div",children:m()})]})}var Tp={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=nr.isMousePositionWithinElementCords(c,o);c.type===wr.mouseover&&u&&(a.style.animation=this.isEditingInProgress?nr.tooltipAnimations.hideAtOnce:nr.tooltipAnimations.showAtOnce,s.add(d)),c.type===wr.mouseout&&(a.style.animation=nr.tooltipAnimations.hideWithDelay,s.add(d)),c.type===wr.mousemove&&u&&(a.style.animation=this.isEditingInProgress?nr.tooltipAnimations.hideAtOnce:nr.tooltipAnimations.showAtOnce,s.add(d))}}_keyboardEventsListener(c){c.type===wr.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),c.type===wr.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(c){Se.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(wr.keypress,this.keyboardBindedListener),window.addEventListener(wr.keyup,this.keyboardBindedListener),window.addEventListener(wr.resize,this.resizeBindedListener),window.addEventListener(wr.scroll,this.resizeBindedListener);for(const c of H0)window.addEventListener(c,this.mouseBindedListener)}unmount(){window.removeEventListener(wr.keypress,this.keyboardBindedListener),window.removeEventListener(wr.keyup,this.keyboardBindedListener),window.removeEventListener(wr.resize,this.resizeBindedListener),window.removeEventListener(wr.scroll,this.resizeBindedListener);for(const c of H0)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(fp.validateJSONSelection(t,lp.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){le.warn("[PAINT REMOTE SELECTION] failed for nested editor - ",{error:e,nestedSelectionJSON:f,fullSelection:t,lexicalSelection:n})}else le.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){le.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){le.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)&&(le.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 vS;function bS(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(m=>m===ka.editorState)}function Ru(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)Ru(r,f);return c&&c.getChildrenSize&&c.splice(c.getChildrenSize(),0,[f]),f}function Mu(m){if(m.getChildren)for(let c of m.getChildren())Mu(c);m.remove()}function sy(m){m.__parent=null,m.__next=null,m.__prev=null}function ly(m,c){return!!Se.isLexicalEditorInstance(m)&&!(typeof c!="object"||!c.editorState||(m.update(()=>{try{let p=(0,be.$getSelection)();const t=m.parseEditorState(c.editorState);if(t.isEmpty())return(0,be.$getRoot)().clear(),!0;(0,be.$setSelection)(p),m.setEditorState(t)}catch(p){le.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",p)}}),0))}function _S(m,c){let p=c;for(const t of m)p=p[t];return p}function Ta(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=_S(m,p?c:Se.getMainEditorState().toJSON());return f&&(t=Aa(f)?(0,be.$getRoot)():Nn.get(f.codoxId)),t||le.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:Ta(m,c,!0))}function cy(m){le.log("[applyFullLexicalStateReplace] clear current state and apply new");const c=(0,be.$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 xS(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(c.length){le.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=bS(t),i=s!==-1,l=p.hasOwnProperty("lm")&&typeof p.lm=="number";if(t.length)if(i){let o=s-1,a=Ta(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=Vl(t[o]);ly(a.getWritable()[g],u)}}else{if(r){let o=p.oi;if(!o){le.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi attr expected for path",{delta:p});continue}if(o.some(d=>!(!d.hasOwnProperty("text")||typeof d.text=="string"))){le.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi children contain invalid text value",{delta:p});continue}t.length=t.length-1;let a=Ta(t,m);if(!a)continue;if(o.some(d=>!!d.codoxDId)){try{a=a.getWritable()}catch(h){le.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:Mu(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=Ru(y);if(le.debug("[DELTA_DECORATOR_UPDATE]: ",{exisingDecorator:w,tmpDecorator:S}),!S){le.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()};ly(w[C],k)}else{let k=sp(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(),sy(w),b=w,delete d[y.codoxDId]}}b||(b=Ru(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(),sy(y),Mu(y),delete d[h]}}else{let d=o.map(u=>Ru(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()?Mu(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,be.$getRoot)().splice(0,0,[d]);else{const u=t[t.length-1];t.length=t.length-2;let g=Ta(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=Ta(o,m);if(u)try{let g=u.getWritable();if(a){let h=Object.keys(a);for(let y of h)g[Vl(y)]=a[y]}if(d){let h=Object.keys(d);for(let y of h)delete g[Vl(y)]}}catch(g){le.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=Ta(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=Vl(o);t.length=t.length-1;let d,u=Ta(t,m);if(!u){le.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){le.debug("[applyDeltasToLexicalState][shouldUpdateBlockAttr] getWritable error: ",{err:h,delta:p})}if(!d)continue;let g=p.oi;if(o==="format"&&(g=_w(g)),o==="direction"&&(u.hasOwnProperty(a)||(a="__dir")),!d.hasOwnProperty(a)){let h=Object.keys(d);for(let y of h){let v=sp(y);if(o.startsWith(v)){a=y;break}}}d[a]=g}}else if(p.oi&&p.oi.root)return cy(p.oi)}}else le.log("[applyDeltasToLexicalState] stop, no deltas: ",c)}function wS(m){let c=m.clipboardData.getData(ww.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 SS=m=>{var c={};return on.d(c,m),c};const uy=SS({useCollaborationContext:()=>Mx});var ES=m=>{var c={};return on.d(c,m),c};const qi=ES({LexicalComposerContext:()=>Jf,useLexicalComposerContext:()=>Nr});class dy{constructor(){this.blacklist=Object.keys(q0).reduce((c,p)=>{let t=q0[p];return c[p]=t.reduce((f,r)=>(f[r]=r,f),{}),c},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(c){return c instanceof be.TextNode||c instanceof be.ParagraphNode||c instanceof be.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(pp||p!==Kr.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 le.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!==Kr.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,le.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 CS=new dy,Wi=CS,kS=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function OS(m,c){if(m==null)return{};var p,t,f=TS(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 TS(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 AS{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(c,p){let t=!1;return function(f){let{editorState:r,prevEditorState:n,dirtyElements:e,dirtyLeaves:s}=f,i=(OS(f,kS),Se.getMainEditor()),l=Se.getMainEditorState(),o=r.toJSON(),a=n.toJSON(),d=dp(o,a),u=r._selection,g=n._selection,h=!1,y=null,v=Se.isOnlySelectionChanged(e,s),_=c[p];if(le.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}),Wi.isBlacklistedFound())return t=!0,le.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),Se.scanLexicalNodeForNestedEditorAttribute(c)?(_.update(()=>{try{const b=_.parseEditorState(a);if(b.isEmpty())return(0,be.$getRoot)().clear(),!0;_.setEditorState(b)}catch(b){le.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",b)}}),void Wi.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=sp(p),w=$e.lexicalToJSONNested(u,x,b);y=Se.getCurrentNestedSelectionJSON(),h=$e.equalSelectionsJSON(y,w),h||Se.setNestedSelectionJSON(w)})}d&&h||i.update(()=>{try{le.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){le.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===Kr.created){let h=t.getEditorState()._nodeMap.get(u);h&&Wi.trackBlacklistedInNestedEditor(h,g,t.getEditorState(),c)}});r.push(a)});let n=(0,ks.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,be.$setSelection)(r),le.debug("[setNestedEditorSelection]: lexical nested selection: ",r)}catch(r){le.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 PS=new AS,ui=PS,jS=function(m){let c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let p=(0,be.createEditor)({namespace:"validation",nodes:[...c],onError:e=>{throw e},parentEditor:null});const t=new dy,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,Kr.created,r),t.isBlacklistedFound()))throw new Error(Sw)}}catch(p){throw p}};class NS{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===$i.BOTH||s.__headerState===$i.ROW),e=c.some((s,i)=>{if(s.__size<f)return!1;let l=s.getChildAtIndex(t);return!(!l||l.__headerState!==$i.BOTH&&l.__headerState!==$i.COLUMN)});return n&&e?r=$i.BOTH:n&&!e?r=$i.ROW:e&&!n&&(r=$i.COLUMN),r}_isValidCellChildren(c){for(let p of c)if(Ns(p)||!js(p)&&Tn(p))return!1;return!0}_createEmptyCell(){let c=(0,An.$createTableCellNode)();return c.append((0,be.$createParagraphNode)()),c}_wrapInvalidCellChildrenIntoParagraph(c){let p=(0,be.$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()=>{le.debug("[TablesValidator][FIX TABLE ACTION - APPEND_CELLS_TO_ROW] invoked: ",{rowKey:c,numOfCellsToAppend:p});let t=(0,be.$getNodeByKey)(c);for(;p;){let f=(0,An.$createTableCellNode)().append((0,be.$createParagraphNode)());f.setRowSpan(1).setColSpan(1),t.append(f),p--}}}_createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(c){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - ADD_PARAGRAPH_TO_EMPTY_CELL] invoked: ",{cellKey:c}),(0,be.$getNodeByKey)(c).append((0,be.$createParagraphNode)())}}_createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(c){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_CELL_CHILDREN_IN_PARAGRAPH] invoked: ",{cellKey:c});let p=(0,be.$getNodeByKey)(c);this._wrapInvalidCellChildrenIntoParagraph(p)}}_createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(c){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - ADD_ROW_CELL_TO_EMPTY_TABLE_NODE] invoked: ",{tableKey:c});let p=(0,be.$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,be.$getNodeByKey)(c).append(this._createEmptyCell()),p--}}_createFixAction_WRAP_INVALID_ROW_NODE(c,p){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_ROW_NODE] invoked: ",{tableKey:c,rowKey:p});let t=(0,be.$getNodeByKey)(c);if(!t)return;let f=(0,be.$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,be.$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,be.$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()=>{le.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_CELL_NODE] invoked: ",{rowKey:c,cellKey:p});let t=(0,be.$getNodeByKey)(c);if(!t)return;let f=(0,be.$getNodeByKey)(p);if(f.remove(),f=(0,be.$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,be.$createParagraphNode)();s.append(f),e.append(s)}}}_createFixAction_APPLY_HEADER_STATE_TO_CELL(c,p){return()=>{le.debug("[TablesValidator][FIX TABLE ACTION - APPLY_HEADER_STATE_TO_CELL] invoked: ",{cellKey:c,headerStateToApply:p});let t=(0,be.$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(le.debug(`[${c}]`,{selection:p}),!(0,be.$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){le.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(){le.debug("[TablesValidator][gcRemovedTable] candidate table keys ",{tableKeys:this.removeCandidateTableKeys}),Se.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(c=>{let p=(0,be.$getNodeByKey)(c);p&&p.remove()}),this.removeCandidateTableKeys.clear(),(0,be.$addUpdateTag)(io.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&&le.debug("[TablesValidator][tableRowNodeChangesListener] no row node found in lexical: ",{tableRowNodeKey:c}));let f=t.__parent;f?this.validateTableCandidateKeys.add(f):le.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===$i.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;le[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();le.log("[TablesValidator][fixTablesStructure]: fix actions to apply - count: ",this.tableFixActions.length),c.update(()=>{for(let p of this.tableFixActions)p();this.tableFixActions=[],(0,be.$addUpdateTag)(io.historic)})}ensureDocTablesAreValid(c){return this.shouldGCRemovedTables()?(le.warn("[TablesValidator][GARBAGE COLLECT TABLE NODES AFTER TABLE REMOVAL ATTEMPT]"),this.gcRemovedTables(),!1):!(this.shouldValidateUpdatedTables()&&(le.debug("[TablesValidator][shouldValidateUpdatedTables] invoked"),!this.validateUpdatedTables()))||(le.warn("[TablesValidator][shouldValidateUpdatedTables] INVALID LEXICAL TABLE(S) STRUCTURE FOUND - FIXING",{state:JSON.parse(JSON.stringify(c.toJSON()))}),this.fixTablesStructure(),!1)}}const Ro=new NS,IS=["contentChanged"],RS=["state","remoteSelection"];function fy(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 As(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?fy(Object(p),!0).forEach(function(t){MS(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):fy(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function MS(m,c,p){return(c=DS(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function DS(m){var c=LS(m,"string");return typeof c=="symbol"?c:c+""}function LS(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 py(m,c){if(m==null)return{};var p,t,f=BS(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 BS(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 pp={DEBUG:!1,VERSION:"1.0.2",NAME:"@codoxhq/lexical-provider",SDKUI_SOURCE_PATH:"../../../sdkui/dist-production2/codox.bundle.js"}.LOCAL==="true";le.info("MODE: ","production");const FS=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 le.info("[decorateFetchOnReconnctHook] hook invoked: ",{returnObj:r}),r};let Du=0,di=null,hp=!1,Eo={},gp={};const zS=(0,Gt.forwardRef)((m,c)=>{let{onBlacklistedInsert:p}=m;const t=(0,Gt.useContext)(qi.LexicalComposerContext);if(!t)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[f]=(0,qi.useLexicalComposerContext)(),r=(0,uy.useCollaborationContext)();(0,Gt.useEffect)(()=>{if(le.debug("[INIT] lexical context check: ",{lexicalContext:t,editor:f}),!f)return;le.log("[useEffect][editor] Editor instance changed: ",{editor:f,key:f._key}),Se.setMainEditor(f),Nn.gcAbandonedNodes(),ui.gc(),Ro.clear(),le.log("[useEffect][editor] subscribe to editor changes");const v=(0,ks.mergeRegister)(f.registerUpdateListener(g),f.registerCommand(be.PASTE_COMMAND,wS,be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.UNDO_COMMAND,()=>{Se.setUndoInvoked(!0)},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.REDO_COMMAND,()=>{Se.setRedoInvoked(!0)},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.KEY_DELETE_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("KEY_DELETE_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.KEY_BACKSPACE_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),f.registerCommand(be.CUT_COMMAND,(b,x)=>{Ro.tableRemoveEventListener("CUT_COMMAND")},be.COMMAND_PRIORITY_CRITICAL),...h());So.mount(),Se.alignStateSelectionJSONsFromLatestEditor(),le.debug("New editor mounted: ",{isCodoxStarted:Se.isCodoxStarted,codoxLexicalEditorManager:Se,nestedEditorsProcessor:ui});let _=f._onError;return f._onError=b=>{le.error("[ERROR HANDLER WRAPPER] error from editor: ",b),_&&_(b),u()},p&&Wi.setClientCallback(p),()=>{Se.getMainEditorKey()&&(le.debug("Unmount prev editor"),v(),Se.removeMainEditor(),So.unmount(),Se.clearJSONs(),On.clear(),Ro.clear(),Se.isCodoxStarted&&(le.debug("EDITOR USE_EFFECT stopping codox"),n(),Se.setIsCodoxStarted(!1)),Wi.removeClientCallback())}},[f]);const n=()=>{Se.isCodoxStarted&&(le.log("[stopCodoxInstance] stopping codox"),Se.setIsCodoxStarted(!1),pp||ri().stop(),Se.clearJSONs(),Nn.clearAll(),So.clear(),On.resetComments(),ui.clearListeners())},e=async v=>{le.debug("[startCodoxInstance] invoked"),ri().createNewInstance(),le.debug("[startCodoxInstance] instance created");for(let O in gp)ri().instance.on(O,gp[O]);if(le.debug("[startCodoxInstance] events subscribed"),Eo=v,di=Eo.docId,!di)return le.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:di});let _=On.initialCommentsExist();le.debug("[startCodoxInstance] initCommentsExist: ",_),_&&(On.activateInitialComments(f,Nn),le.log("[activateInitialComments] "));let b=Se.getMainEditorState().toJSON();if(!Se.isValidJSONState(b))throw le.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:di,initJSONState:b}),new Error("start codox skipped - invalid init state");le.log("[startCodoxInstance] starting codox with: ",{docId:di,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=FS(D.fetchDocOnNetworkReconnect));const N=py(D,IS);await ri().start(ri().createConfig(As(As({},Eo),{},{docId:di,username:x,apiKey:w,domain:C,hooks:As({syncState:l,getState:i,getServerState:async()=>await S(di)},N),editorInstanceHooks:{getSelection:()=>Se.getCurrentActiveSelectionJSON(),setSelection:O=>o(O),getState:i,setState:O=>{const{root:R,comments:A}=O;le.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 le.info("[getContent]: ",O),{state:O}}},appServer:Eo.appServer,demo:k}))),le.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:As(As({},Se.getMainEditorState().toJSON()),{},{comments:On.getAllComments()}),docId:di}),l=v=>{if(!Se.isCodoxStarted)return;le.log("[SYNC_STATE]: Before sync payload = ",v);const _=ri().sync({meta:v}),{state:b,remoteSelection:x=[]}=_,w=py(_,RS);if(le.log("[SYNC_STATE]: After sync",{state:b,remoteSelection:x,rest:w}),!b)return le.error("[SYNC_STATE] abort apply - synced state is not valid - restarting codox"),s();const S=b.state;le.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 le.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||(le.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:v}),!fp.validateJSONSelection(v,lp.local)))return;let _=Se.getCurrentActiveSelectionJSON();if($e.equalSelectionsJSON(_,v))return void le.log("[setLocalSelectionFromSync] STOP - local and synced selections are equal");let b=$e.isNestedSelectionJSON(v);f.update(()=>{le.log("[setLocalSelectionFromSync] json selection to apply: ",{syncedSelectionJSON:v});const x=$e.JSONToLexical(v);if(le.log("[setLocalSelectionFromSync] lexical selection to apply: ",x),b){let w=ui.setNestedEditorSelection(v);Se.setNestedSelectionJSON(w?v:null)}else(0,be.$setSelection)(x),Se.setMainSelectionJSON(v);le.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();le.log("[updateEditor] invoked: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:JSON.parse(JSON.stringify(v)),newSelectionJSON:_,remoteSelection:x,stateReplace:b,editor:f}),_===void 0&&le.error("SELECTION FROm SYNC IS UNDEFINED - will default prev selection",_);const C=dp(S,v),k=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),_);f.update(()=>{if(Se.addUpdateTag({isSameState:C,isSameSelection:k,updateTag:w}),b)le.log("[updateEditor] invoke full stateReplace after sync"),cy(v),S=Se.setCurrentContentStateJSON(v),(0,be.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S);else{le.log("[updateEditor] invoke deltas diff");let N=ri().diff(S,v,{keyNames:{default:"codoxId"}});le.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:v,deltas:N&&JSON.parse(JSON.stringify(N))}),N&&N.length&&(le.log("[updateEditor] apply deltas to lexical state"),xS(v,N),S=Se.setCurrentContentStateJSON(v),(0,be.$addUpdateTag)("codox_sync_state_changes"),le.log("[updateEditor] state updated: ",S))}let D=$e.isNestedSelectionJSON(_);if(fp.validateJSONSelection(_,lp.local)||(_=Se.getCurrentActiveSelectionJSON()),D){let N=ui.setNestedEditorSelection(_);Se.setNestedSelectionJSON(N?_:null),le.log("[updateEditor] nested selection updated",N?_:null)}else if(_!==void 0){const N=$e.JSONToLexical(_);le.log("[updateEditor] updated selection to apply: ",{isSameSelection:k,newSelectionJSON:_,lexicalSelection:N}),(0,be.$setSelection)(N),Se.setMainSelectionJSON(_),le.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;le.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:v});let _=Se.composeFullStateWithRootAndComments();const b={docId:di,state:{state:_,selection:Se.getCurrentActiveSelectionJSON()}};le.log("[codoxSync]: Before sync",{local:b,upd_call_counter:v}),le.log("[codoxSync]: Before sync state",JSON.parse(JSON.stringify(b.state)));let{state:x,remoteSelection:w=[],changes:S}=ri().sync({state:b,meta:{}});if(le.log("[codoxSync]: After sync",{afterSyncState:JSON.parse(JSON.stringify(x)),remoteSelection:w,changes:S}),!x)return le.error("[codoxSync] abort apply - synced state is not valid - restarting codox "),s();const C=x.state;le.log("[codoxSync]: synced state: ",JSON.parse(JSON.stringify(C)),v);let{stateFromSync:k,commentsFromSync:D}=Se.extractStateAndCommentsFromSynced(C);if(!Se.isValidJSONState(k.state))return le.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:k.state}),s();a(k,w),On.setAllComments(D)},u=()=>{le.warn("[rollbackStateDuringUpdateError] rollback invoked"),le.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(),io.historic);let b=Se.undoInvoked(),x=Se.redoInvoked();On.gcAbandonedNodeKeys(Se.getMainEditorState()._nodeMap),b&&f.dispatchCommand(be.CAN_REDO_COMMAND,!1),x&&f.dispatchCommand(be.CAN_UNDO_COMMAND,!1)},g=v=>{let{editorState:_,prevEditorState:b,tags:x,dirtyElements:w,dirtyLeaves:S}=v;if(hp)return hp=!1,void le.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(Wi.isBlacklistedFound())return hp=!0,le.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,be.$getSelection)();j=$e.lexicalToJSON(L),T=V.toJSON()}),Se.setCurrentContentStateJSON(T),Se.setMainSelectionJSON(j),a({state:F,selection:z},So.getCurrentRemoteSelections(),io.historic),f.dispatchCommand(be.CAN_REDO_COMMAND,!1),f.dispatchCommand(be.CAN_UNDO_COMMAND,!1)})(_,b),void Wi.invokeClientCallback();if(!Ro.ensureDocTablesAreValid(_))return;Du++,le.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:Du,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(Kl),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,be.$getSelection)();N=$e.lexicalToJSON(V);let K=$e.JSONToLexical(N),z=V===null&&K===null||V.is(K);le.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=dp(R,k),I=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),N);le.log("[editorUpdatesListener] compares: ",{isStateSame:G,isSelectionSame:I});let $=G&&I&&!U;if(!G||U||A){let V=As({},G?R:k),K=On.getAllComments();K.length&&(V.commentThreads=K);let z={source:A?W0.remote:W0.local,content:V};Eo.hooks&&Eo.hooks.contentChanged&&Eo.hooks.contentChanged(z),ri().instance.emit("content_changed",z)}if($)le.log("[editorUpdatesListener] STOP - state and selection and comments are same ",Du);else if(Se.undoInvoked()&&Se.setUndoInvoked(!1),Se.redoInvoked()&&Se.setRedoInvoked(!1),Se.setCurrentContentStateJSON(k),Se.setPrevContentStateJSON(D),Se.setMainSelectionJSON(N),Se.setPrevMainSelectionJSON(O),pp){let V=Se.getCurrentActiveSelectionJSON();a({state:Se.getCurrentContentStateJSON(),selection:V},[])}else d(Du)},h=()=>{let v=[];return Se.getMainEditorNodesClassesMap().forEach((_,b,x)=>{let{klass:w}=_,S=f.registerMutationListener(w,C=>{for(let[k,D]of C){if(!Kr[D])continue;const N=Se.getLexicalNodeByKey(k);if(D===Kr.created&&N&&Wi.trackBlacklisted(N,D),w.name===An.TableNode.name&&(D===Kr.destroyed?Ro.tableNodeRemoveListener(k):Ro.tableUpdateListener(k)),w.name===An.TableRowNode.name&&D!==Kr.destroyed&&Ro.tableRowNodeChangesListener(k,D===Kr.updated),w.name===An.TableCellNode.name&&D===Kr.updated&&Ro.tableCellNodeChangesListener(k),w.name===oo.MarkNode.name&&(le.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:k,node:N,mutationType:D,codoxComments:On}),D===Kr.destroyed?On.removeRelatedNodeKey(k):N&&On.addRelatedNodeKey(N.__key,N.__ids,D===Kr.created)),N&&N.codoxId){if(D===Kr.destroyed)return void(N.codoxId&&Nn.remove(N.codoxId));xy(N)||le.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,_)=>{le.info(`Subscribing client to codox ${v} event`),gp[v]=_},cursor:{hide:()=>{So.hideRemoteSelectionsFromUI()},show:()=>{So.showHiddenRemoteSelectionsInUI()}},initComments:v=>{On.setInitialComments(v)}};return(0,Gt.useImperativeHandle)(c,()=>y),null}),US=zS,$S=["comments"];function hy(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 mp(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?hy(Object(p),!0).forEach(function(t){HS(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):hy(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function HS(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=WS(m,"string");return typeof c=="symbol"?c:c+""}function WS(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 JS(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}class KS extends $0{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(){le.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,be.$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:mp({},JS(c.state,$S)),selection:t,stateReplace:f},commentsFromSync:p}}composeFullStateWithRootAndComments(){let{directlyFromEditor:c=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return mp(mp({},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 be.ElementNode,o=i.prototype instanceof be.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){le.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?(le.log(`[addUpdateTag] explicit add of tag "${f}" `),void(0,be.$addUpdateTag)(f)):t?(le.log(`[addUpdateTag] add "${io.historic}" tag - change invoked by nested editor`),void(0,be.$addUpdateTag)(io.historic)):void(c?(le.log(`[addUpdateTag] add "${io.historic}" tag - state is same`),(0,be.$addUpdateTag)(io.historic)):(le.log(`[addUpdateTag] add "${io.historyMerge}" tag - state is different`),(0,be.$addUpdateTag)(io.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const GS=new KS,Se=GS;class YS{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 ZS=new YS,Nn=ZS;function gy(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 my(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?gy(Object(p),!0).forEach(function(t){XS(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):gy(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)}const yp=()=>lw(),yy=m=>typeof m=="number";function Ps(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 Aa=m=>m.__type==="root"||m.type==="root",vy=m=>Aa(m.getParent()),Wn=m=>m.__type===Pu.text||m.type===Pu.text||m.hasOwnProperty("__text")||m.hasOwnProperty("text"),js=m=>(0,be.$isElementNode)(m),Ns=m=>(0,An.$isTableNode)(m)||(0,An.$isTableRowNode)(m)||(0,An.$isTableCellNode)(m),e2=m=>!m.getChildren,by=m=>!!m.getChildren,Tn=m=>(0,be.$isDecoratorNode)(m),Yl=m=>(0,tw.$isLinkNode)(m),Zl=m=>m.__type==="mark"||m.type==="mark",vp=m=>(0,be.$isLineBreakNode)(m),Ji=m=>Wn(m)||vp(m),bp=m=>m.__type===Pu.horizontalrule||m.type===Pu.horizontalrule,_y=m=>{if(Ji(m)||Yl(m)||Zl(m))return!1;if(!m.__parent||m.__parent==="root"||(0,be.$isParagraphNode)(m))return!0;let c=m.getParent().getChildren();return c.length===1&&c[0].__key===m.__key?!((Tn(m)||Yl(m)||Zl(m))&&!bp(m)):!c.some(p=>{let t=bp(p);return p.__key!==m.__key&&(Ji(p)||Tn(p)&&!t||Yl(p)||Zl(p))})},xy=m=>{const c=Nn.get(m.codoxId);return!c||m.__key===c.__key},Is=function(m){const c=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||yp();m.codoxId=c,Nn.add(c,m)},wy=m=>{Nn.remove(m.codoxId),delete m.codoxId},n2=m=>{if(!by(m)||!m.getChildrenSize())return;const c=m.getChildren();if(c.some(f=>!!(0,be.$isParagraphNode)(f)))return;let p=!1,t=[];for(let f of c)(Ji(f)||Tn(f)||Yl(f)||Zl(f))&&!p&&(bp(f)||(p=!0)),(by(f)||Tn(f))&&t.push(f);for(let f of t)p||f.codoxId?p&&f.codoxId&&(f=f.getWritable(),wy(f)):(f=f.getWritable(),Is(f))},r2=m=>{const c=my({},m);for(const p in m)m[p]===void 0&&m.hasOwnProperty(p)&&delete c[p];return c},o2=m=>{const c=`__nativeCreateDOM_${m.name}`;m.prototype[c]=Ps(m.prototype.createDOM,c),m.prototype.createDOM=function(p,t){if(_y(this))if(this.codoxId){if(!xy(this)){let r=Nn.get(this.codoxId);r.__type===this.__type&&this.isAttached()&&!r.isAttached()?(le.warn("[createDOM][Non-unique codoxId] overwrite abandoned existing node with latest: ",{latestNode:this,existingNode:r}),Nn.add(this.codoxId,this)):Is(this)}}else Is(this);else this.codoxId&&wy(this);Tn(this)&&!this.codoxDId&&(this.codoxDId=yp()),ui.manageNestedEditorInLexicalNode(this);let f=this[c](p,t);return f.__codox_track=!0,f}},i2=m=>{const c=`__nativeUpdateDOM_${m.name}`;return m.prototype[c]=Ps(m.prototype.updateDOM,c),m.prototype.updateDOM=function(){const p=this[c](...arguments);return n2(this),p},m},a2=m=>{const c=`__nativeRemove_${m.name}`;return m.prototype[c]=Ps(m.prototype.remove,c),m.prototype.remove=function(){const p=this.codoxId;return p&&Nn.remove(p),ui.gcNestedEditorListenerInLexicalNode(this),this[c](...arguments)},m},s2=m=>{const c=`__nativeExportJSON_${m.name}`;m.prototype[c]=Ps(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)&&yy(p.format)&&this.hasFormat&&(p.format=bw(this)),r2(p)}},l2=m=>{const c="__nativeImportJSON";m[c]=Ps(m.importJSON,c),m.importJSON=function(p){const t=my({},p);Wn(t)&&!yy(t.format)&&(t.format=vw(t.format));const f=m[c](t);ui.manageNestedEditorInLexicalNode(f);const r=_y(f);return r&&t.codoxId&&(Nn.hasPastedId(t.codoxId)&&Nn.has(t.codoxId)?(Nn.removePastedId(t.codoxId),Is(f)):Is(f,t.codoxId)),r&&!f.codoxId&&Is(f),t.codoxDId&&(f.codoxDId=t.codoxDId),f}},c2=m=>{const c="__nativeClone";m[c]=Ps(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),ui.manageNestedEditorInClonedLexicalNode(p,t),t}},u2=m=>{let c=!1,p=!1,t=!1,f=!1;m.forEach(n=>{n.name===be.TextNode.name?c=!0:n.name===be.ParagraphNode.name?p=!0:n.name===be.LineBreakNode.name?t=!0:n.name===oo.MarkNode.name&&(f=!0)});let r=[];return c||r.push(be.TextNode),p||r.push(be.ParagraphNode),t||r.push(be.LineBreakNode),f||r.push(oo.MarkNode),r.length?[...r,...m]:m},d2=function(){return u2(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(m=>(m.hasOwnProperty("__isCodoxExtended")||(o2(m),i2(m),s2(m),a2(m),l2(m),c2(m),Object.defineProperty(m,"__isCodoxExtended",{value:!0,writable:!1})),m))};var Lu=on(777),Rs={};Rs.styleTagTransform=ci(),Rs.setAttributes=si(),Rs.insert=ai().bind(null,"head"),Rs.domAPI=ii(),Rs.insertStyleElement=li(),oi()(Lu.A,Rs),Lu.A&&Lu.A.locals&&Lu.A.locals;var f2=m=>{var c={};return on.d(c,m),c};const p2=f2({AutoFocusPlugin:()=>Pm});var h2=m=>{var c={};return on.d(c,m),c};const g2=h2({ClearEditorPlugin:()=>Lx});var m2=m=>{var c={};return on.d(c,m),c};const y2=m2({LexicalComposer:()=>Am});var v2=m=>{var c={};return on.d(c,m),c};const Sy=v2({default:()=>Fx});var b2=m=>{var c={};return on.d(c,m),c};const _2=b2({HistoryPlugin:()=>Gm});var x2=m=>{var c={};return on.d(c,m),c};const w2=x2({OnChangePlugin:()=>Ux});var S2=m=>{var c={};return on.d(c,m),c};const E2=S2({PlainTextPlugin:()=>Gx});var C2=m=>{var c={};return on.d(c,m),c};const Ey=C2({$isRootTextContentEmpty:()=>Zm,$rootTextContent:()=>Ym});var k2=m=>{var c={};return on.d(c,m),c};const Ms=k2({createPortal:()=>a1.createPortal}),O2=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,T2=O2?Gt.useLayoutEffect:Gt.useEffect,Cy=T2;var Bu=on(253),Ds={};Ds.styleTagTransform=ci(),Ds.setAttributes=si(),Ds.insert=ai().bind(null,"head"),Ds.domAPI=ii(),Ds.insertStyleElement=li(),oi()(Bu.A,Ds),Bu.A&&Bu.A.locals&&Bu.A.locals;function A2(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 P2(m){let{onClose:c,children:p,title:t,closeOnClickOutside:f=!1}=m;return(0,Ms.createPortal)(Gt.createElement(A2,{onClose:c,title:t,closeOnClickOutside:f},p),document.body)}function ky(){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(P2,{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 Fu=on(191),Ls={};Ls.styleTagTransform=ci(),Ls.setAttributes=si(),Ls.insert=ai().bind(null,"head"),Ls.domAPI=ii(),Ls.insertStyleElement=li(),oi()(Fu.A,Ls),Fu.A&&Fu.A.locals&&Fu.A.locals;const j2={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"}},N2=j2;var zu=on(72),Bs={};Bs.styleTagTransform=ci(),Bs.setAttributes=si(),Bs.insert=ai().bind(null,"head"),Bs.domAPI=ii(),Bs.insertStyleElement=li(),oi()(zu.A,Bs),zu.A&&zu.A.locals&&zu.A.locals;function I2(){for(var m=arguments.length,c=new Array(m),p=0;p<m;p++)c[p]=arguments[p];return c.filter(Boolean).join(" ")}function _p(){return _p=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},_p.apply(null,arguments)}function Vi(m){let{"data-test-id":c,children:p,className:t,onClick:f,disabled:r,small:n,title:e}=m;return Gt.createElement("button",_p({disabled:r,className:I2("Button__root",r&&"Button__disabled",n&&"Button__small",t),onClick:f,title:e,"aria-label":e},c&&{"data-test-id":c}),p)}var Uu=on(129),Fs={};Fs.styleTagTransform=ci(),Fs.setAttributes=si(),Fs.insert=ai().bind(null,"head"),Fs.domAPI=ii(),Fs.insertStyleElement=li(),oi()(Uu.A,Fs),Uu.A&&Uu.A.locals&&Uu.A.locals;var R2=m=>{var c={};return on.d(c,m),c};const M2=R2({ContentEditable:()=>jm});function D2(m){let{className:c}=m;return Gt.createElement(M2.ContentEditable,{className:c||"ContentEditable__root"})}var $u=on(457),zs={};zs.styleTagTransform=ci(),zs.setAttributes=si(),zs.insert=ai().bind(null,"head"),zs.domAPI=ii(),zs.insertStyleElement=li(),oi()($u.A,zs),$u.A&&$u.A.locals&&$u.A.locals;function L2(m){let{children:c,className:p}=m;return Gt.createElement("div",{className:p||"Placeholder__root"},c)}const B2=Sy.default.LexicalErrorBoundary||Sy.default,F2=()=>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"})),Oy=()=>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"})),z2=()=>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"})),U2=()=>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 Ty(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 $2(m,c,p){return On.createNewThreadObj({quote:m,comments:c,codoxId:p})}function H2(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]),Cy(()=>{r()},[c,p,r]),Gt.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:f},Gt.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:t},Gt.createElement(F2,null)))}function q2(m){let{onEscape:c}=m;const[p]=(0,qi.useLexicalComposerContext)();return(0,Gt.useEffect)(()=>p.registerCommand(be.KEY_ESCAPE_COMMAND,t=>c(t),2),[p,c]),null}function W2(m){let{editorRef:c}=m;const[p]=(0,qi.useLexicalComposerContext)();return typeof c=="function"?c(p):typeof c=="object"&&(c.current=p),null}function Ay(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:N2};return Gt.createElement(y2.LexicalComposer,{initialConfig:s},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:e},Gt.createElement(E2.PlainTextPlugin,{contentEditable:Gt.createElement(D2,{className:c}),placeholder:Gt.createElement(L2,null,n),ErrorBoundary:B2}),Gt.createElement(w2.OnChangePlugin,{onChange:f}),Gt.createElement(_2.HistoryPlugin,null),p!==!1&&Gt.createElement(p2.AutoFocusPlugin,null),Gt.createElement(q2,{onEscape:t}),Gt.createElement(g2.ClearEditorPlugin,null),r!==void 0&&Gt.createElement(W2,{editorRef:r})))}function Py(m,c){return(0,Gt.useCallback)((p,t)=>{p.read(()=>{m((0,Ey.$rootTextContent)()),c(!(0,Ey.$isRootTextContentEmpty)(t.isComposing(),!0))})},[c,m])}function J2(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=Iy(),a=(0,Gt.useCallback)(()=>{c.getEditorState().read(()=>{const u=(0,be.$getSelection)();if((0,be.$isRangeSelection)(u)){l.current=u.clone();const g=u.anchor,h=u.focus,y=(0,Oa.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,Oa.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]);Cy(()=>{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=Py(r,e);return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:s},Gt.createElement(Ay,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:u=>(u.preventDefault(),p(),!0),onChange:d}),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},Gt.createElement(Vi,{onClick:p,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),Gt.createElement(Vi,{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($2(u,[Ty(f,o)]),!0,void 0,l.current),l.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function V2(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=Iy(),l=Py(r,e);return Gt.createElement(Gt.Fragment,null,Gt.createElement(Ay,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:l,editorRef:s,placeholder:t}),Gt.createElement(Vi,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){c(Ty(f,i),!1,p);const o=s.current;o!==null&&o.dispatchCommand(be.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},Gt.createElement(z2,null)))}function jy(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(Vi,{onClick:()=>{p(c,f),t()}},"Delete")," ",Gt.createElement(Vi,{onClick:()=>{t()}},"Cancel")))}function Ny(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]=ky();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(Vi,{onClick:()=>{s("Delete Comment",i=>Gt.createElement(jy,{commentOrThread:c,deleteCommentOrThread:p,thread:t,onClose:i}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(Oy,null)),e))}function K2(m){let{activeIDs:c,comments:p,deleteCommentOrThread:t,listRef:f,submitAddComment:r,markNodeMap:n}=m;const[e]=(0,qi.useLexicalComposerContext)(),[s,i]=(0,Gt.useState)(0),[l,o]=ky(),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,be.$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(Vi,{onClick:()=>{o("Delete Thread",h=>Gt.createElement(jy,{commentOrThread:d,deleteCommentOrThread:t,onClose:h}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(Oy,null)),l),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},d.comments.map(h=>Gt.createElement(Ny,{key:h.codoxId,comment:h,deleteComment:t,thread:d,rtf:a}))),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},Gt.createElement(V2,{submitAddComment:r,thread:d,placeholder:"Reply to comment..."})))}return Gt.createElement(Ny,{key:u,comment:d,deleteComment:t,rtf:a})}))}function G2(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(K2,{activeIDs:c,comments:t,deleteCommentOrThread:p,listRef:n,submitAddComment:f,markNodeMap:r}))}function Iy(){const m=(0,uy.useCollaborationContext)(),{yjsDocMap:c,name:p}=m;return p||"Playground User"}function Y2(m){const[c]=(0,qi.useLexicalComposerContext)(),p=Nw(),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,be.$getSelection)();g!==null&&(g.dirty=!0)}),i(!1)},[c]),d=(0,Gt.useCallback)((g,h)=>{if(g.type==="comment"){if(le.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,be.$getNodeByKey)(b);le.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:x}),x&&x.markDirty()}):(0,be.$getRoot)().markDirty(),(0,be.$addUpdateTag)(io.historic),(0,be.$addUpdateTag)(Kl)})}else{le.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,be.$getNodeByKey)(_);le.log("[deleteCommentOrThread]: type thread new values",{node:b}),(0,oo.$isMarkNode)(b)&&(b.deleteID(y),b.getIDs().length===0&&(0,oo.$unwrapMarkNode)(b))}else(0,be.$getRoot)().markDirty(),le.debug("[deleteCommentOrThread][refreshComments]");On.refreshComments(!0),(0,be.$addUpdateTag)(Kl)})})}},[c,t]),u=(0,Gt.useCallback)((g,h,y,v)=>{if(le.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,be.$isRangeSelection)(v)){const _=v.isBackward(),b=g.codoxId;(0,oo.$wrapSelectionInMarkNode)(v,_,b),(0,be.$addUpdateTag)(Kl)}}),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,be.$getNodeByKey)(w);S&&S.markDirty()}),(0,be.$addUpdateTag)(io.historic),(0,be.$addUpdateTag)(Kl)})}},[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,ks.mergeRegister)((0,ks.registerNestedElementResolver)(c,oo.MarkNode,h=>(0,oo.$createMarkNode)(h.getIDs()),(h,y)=>{h.getIDs().forEach(v=>{y.addID(v)})}),c.registerMutationListener(oo.MarkNode,h=>{c.getEditorState().read(()=>{for(const[y,v]of h){const _=(0,be.$getNodeByKey)(y);let b=[];v==="destroyed"?b=g.get(y)||[]:(0,oo.$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,be.$getSelection)();let b=!1,x=!1;if((0,be.$isRangeSelection)(_)){const w=_.anchor.getNode();if((0,be.$isTextNode)(w)){const S=(0,oo.$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,be.$isRangeSelection)(_)&&i(!1)})}),c.registerCommand(up,()=>{const h=window.getSelection();return h!==null&&h.removeAllRanges(),i(!0),!0},be.COMMAND_PRIORITY_EDITOR))},[c,t]),Gt.createElement(Gt.Fragment,null,s&&(0,Ms.createPortal)(Gt.createElement(J2,{editor:c,cancelAddComment:a,submitAddComment:u}),document.body),f!=null&&!s&&(0,Ms.createPortal)(Gt.createElement(H2,{anchorKey:f,editor:c,onAddComment:()=>{c.dispatchCommand(up,void 0)}}),document.body),(0,Ms.createPortal)(Gt.createElement(Vi,{className:"CodoxCommentPlugin_ShowCommentsButton "+(l?"active":""),onClick:()=>o(!l),title:l?"Hide Comments":"Show Comments"},Gt.createElement(U2,null)),document.body),l&&(0,Ms.createPortal)(Gt.createElement(G2,{comments:p,submitAddComment:u,deleteCommentOrThread:d,activeIDs:n,markNodeMap:t}),document.body))}var Hu=on(766),Us={};Us.styleTagTransform=ci(),Us.setAttributes=si(),Us.insert=ai().bind(null,"head"),Us.domAPI=ii(),Us.insertStyleElement=li(),oi()(Hu.A,Us),Hu.A&&Hu.A.locals&&Hu.A.locals;var qu=on(225),$s={};$s.styleTagTransform=ci(),$s.setAttributes=si(),$s.insert=ai().bind(null,"head"),$s.domAPI=ii(),$s.insertStyleElement=li(),oi()(qu.A,$s),qu.A&&qu.A.locals&&qu.A.locals;function Z2(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 Ry(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 Wu(m){for(var c=1;c<arguments.length;c++){var p=arguments[c]!=null?arguments[c]:{};c%2?Ry(Object(p),!0).forEach(function(t){X2(m,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(p)):Ry(Object(p)).forEach(function(t){Object.defineProperty(m,t,Object.getOwnPropertyDescriptor(p,t))})}return m}function X2(m,c,p){return(c=Q2(c))in m?Object.defineProperty(m,c,{value:p,enumerable:!0,configurable:!0,writable:!0}):m[c]=p,m}function Q2(m){var c=tE(m,"string");return typeof c=="symbol"?c:c+""}function tE(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 Xl=!1;const eE=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],Ql=214,My=150;function nE(m){let{color:c,onChange:p}=m;const[t,f]=(0,Gt.useState)(Hs("hex",c)),[r,n]=(0,Gt.useState)(c),e=(0,Gt.useRef)(null),s=(0,Gt.useMemo)(()=>({x:t.hsv.s/100*Ql,y:(100-t.hsv.v)/100*My}),[t.hsv.s,t.hsv.v]),i=(0,Gt.useMemo)(()=>({x:t.hsv.h/360*Ql}),[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=Hs("hex",c);f(l),n(l.hex)},[c]),Gt.createElement("div",{className:"codox-color-picker-wrapper",style:{width:Ql},ref:e},Gt.createElement(Z2,{label:"Hex",onChange:l=>{if(n(l),/^#[0-9A-Fa-f]{6}$/i.test(l)){const o=Hs("hex",l);f(o)}},value:r}),Gt.createElement("div",{className:"codox-color-picker-basic-color"},eE.map(l=>Gt.createElement("button",{className:l===t.hex?" active":"",key:l,style:{backgroundColor:l},onClick:()=>(o=>{n(o);let a=Hs("hex",o);f(a),p(a.hex,Xl)})(l)}))),Gt.createElement(Dy,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`},onChange:l=>{let{x:o,y:a}=l;const d=Hs("hsv",Wu(Wu({},t.hsv),{},{s:o/Ql*100,v:100-a/My*100}));f(d),n(d.hex),p(d.hex,Xl)}},Gt.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:t.hex,left:s.x,top:s.y}})),Gt.createElement(Dy,{className:"codox-color-picker-hue",onChange:l=>{let{x:o}=l;const a=Hs("hsv",Wu(Wu({},t.hsv),{},{h:o/Ql*360}));f(a),n(a.hex),p(a.hex,Xl)}},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 Dy(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=Ly(s.clientX-a,l,0),g=Ly(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,Xl=!0,e(o)},l=o=>{n.current&&(Xl=!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 Ly(m,c,p){return m>c?c:m<p?p:m}function By(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 Fy(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 xp(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 rE(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 zy(m){let{b:c,g:p,r:t}=m;return"#"+[t,p,c].map(f=>f.toString(16).padStart(2,"0")).join("")}function Hs(m,c){let p=By("#121212"),t=Fy(p),f=xp(t);return m==="hex"?(p=By(c),t=Fy(p),f=xp(t)):m==="rgb"?(t=c,p=zy(t),f=xp(t)):m==="hsv"&&(f=c,t=rE(f),p=zy(t)),{hex:p,hsv:f,rgb:t}}const oE=Gt.createContext(null),Uy=4;function iE(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(oE.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 aE(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+Uy}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+Uy;_!==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,Ms.createPortal)(Gt.createElement(iE,{dropDownRef:o,onClose:()=>{u(!1),a&&a.current&&a.current.focus()},dropdownClassName:s},n),document.body))}const sE=["disabled","stopCloseOnClickSelf","color","onChange"];function wp(){return wp=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},wp.apply(null,arguments)}function lE(m,c){if(m==null)return{};var p,t,f=cE(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 cE(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 $y(m){let{disabled:c=!1,stopCloseOnClickSelf:p=!0,color:t,onChange:f}=m,r=lE(m,sE);return Gt.createElement(aE,wp({},r,{disabled:c,stopCloseOnClickSelf:p}),Gt.createElement(nE,{color:t,onChange:f}))}const uE=m=>{let{onColorChange:c,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=m;const[i]=(0,qi.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,d]=(0,Gt.useState)("");(0,Gt.useEffect)(()=>(0,ks.mergeRegister)(i.registerEditableListener(g=>{o(g)}),i.registerUpdateListener(g=>{let{editorState:h}=g;h.read(()=>{const y=(0,be.$getSelection)();if((0,be.$isRangeSelection)(y)){let v=(0,Oa.$getSelectionStyleValueForProperty)(y,"color");v!==a&&(d(v||""),c(v))}})})),[i]);const u=(0,Gt.useCallback)((g,h)=>{i.update(()=>{const y=(0,be.$getSelection)();y!==null&&(0,Oa.$patchStyleText)(y,{color:g})})},[i]);return Gt.createElement($y,{disabled:!l,color:a,onChange:u,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},dE=uE,fE=m=>{let{onColorChange:c,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:s}=m;const[i]=(0,qi.useLexicalComposerContext)(),[l,o]=(0,Gt.useState)(()=>i.isEditable()),[a,d]=(0,Gt.useState)("#fff");(0,Gt.useEffect)(()=>(0,ks.mergeRegister)(i.registerEditableListener(g=>{o(g)}),i.registerUpdateListener(g=>{let{editorState:h}=g;h.read(()=>{const y=(0,be.$getSelection)();if((0,be.$isRangeSelection)(y)){let v=(0,Oa.$getSelectionStyleValueForProperty)(y,"background-color");v!==a&&(d(v||""),c(v))}})})),[i]);const u=(0,Gt.useCallback)((g,h)=>{i.update(()=>{const y=(0,be.$getSelection)();y!==null&&(0,Oa.$patchStyleText)(y,{"background-color":g})})},[i]);return Gt.createElement($y,{disabled:!l,color:a,onChange:u,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:s||""})},pE=fE;var hE=zi.yy;zi._U,zi.a8,zi.Vs,zi.Cn;var gE=zi.gK,mE=zi.vv;function yE(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}var Ju=yE(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 vE({hasCellMerge:m=!0,hasCellBackgroundColor:c=!0,hasTabHandler:p=!0}){const[t]=Nr();return we.useEffect(()=>(t.hasNodes([wo,Bi,$l])||Ju(10),_o(t.registerCommand(vx,({columns:f,rows:r,includeHeaders:n})=>{const e=b0(Number(r),Number(f),n);Wm(e);const s=e.getFirstDescendant();return je(s)&&s.select(),!0},an),t.registerNodeTransform(wo,f=>{const[r]=S0(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=ni(0);o.append(jn()),i!==null?i.insertAfter(o):Jm(i,o)}}}))),[t]),we.useEffect(()=>{const f=new Map,r=e=>{const s=e.getKey(),i=t.getElementByKey(s);if(i&&!f.has(s)){const l=jx(e,i,t,p);f.set(s,l)}};t.getEditorState().read(()=>{const e=jg(wo);for(const s of e)Rn(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);Rn(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]),we.useEffect(()=>{if(!m)return t.registerNodeTransform(Bi,f=>{if(f.getColSpan()>1||f.getRowSpan()>1){const[,,r]=Vr(f),[n]=Io(r,f,f),e=n.length,s=n[0].length;let i=r.getFirstChild();cr(i)||Ju(175);const l=[];for(let o=0;o<e;o++){o!==0&&(i=i.getNextSibling(),cr(i)||Ju(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)||Ju(176);const h=ni(g.__headerState);a!==null?a.insertAfter(h):Jm(i,h)}}}for(const o of l)o.setColSpan(1),o.setRowSpan(1)}})},[t,m]),we.useEffect(()=>{if(!c)return t.registerNodeTransform(Bi,f=>{f.getBackgroundColor()!==null&&f.setBackgroundColor(null)})},[t,c,m]),null}const zk="",bE={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"}},_E="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE1IDE1IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMDAwMDEgOC4zMzMzM0wxLjkwMDAxIDEzLjhMMS4xMDAwMSAxMy4yTDUuMzc1MDEgNy41TDEuMTAwMDEgMS44TDEuOTAwMDEgMS4yTDYuMDAwMDEgNi42NjY2N0wxMC4xIDEuMkwxMC45IDEuOEw2LjYyNTAxIDcuNUwxMC45IDEzLjJMMTAuMSAxMy44TDYuMDAwMDEgOC4zMzMzM1pNMTIgMTIuNUMxMiAxMS42NzE2IDEyLjY3MTYgMTEgMTMuNSAxMUgxMy43OTI5QzE0LjQ1OTYgMTEgMTUgMTEuNTQwNCAxNSAxMi4yMDcxQzE1IDEyLjUyNzMgMTQuODcyOCAxMi44MzQzIDE0LjY0NjUgMTMuMDYwN0wxMy43MDcxIDE0SDE1VjE1SDEyLjVDMTIuMjk3OCAxNSAxMi4xMTU1IDE0Ljg3ODIgMTIuMDM4MSAxNC42OTEzQzExLjk2MDcgMTQuNTA0NSAxMi4wMDM1IDE0LjI4OTQgMTIuMTQ2NSAxNC4xNDY0TDEzLjkzOTMgMTIuMzUzNkMxMy45NzgyIDEyLjMxNDcgMTQgMTIuMjYyIDE0IDEyLjIwNzFDMTQgMTIuMDkyNyAxMy45MDczIDEyIDEzLjc5MjkgMTJIMTMuNUMxMy4yMjM5IDEyIDEzIDEyLjIyMzkgMTMgMTIuNUgxMloiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+",xE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDQgNTEyLjM2Ij48cGF0aCBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik00OTkuNDMgMjMxLjM2SDM2OC40Yy0yLjUzIDAtNC41OC0yLjA1LTQuNTgtNC41N3YtOC4xMWMwLTEuMjYuNTItMi40IDEuMzQtMy4yMmw3MS41Ny04Mi41M2M2LjczLTcuNzUgMTIuNTctMTQuOTcgMTcuNDgtMjEuNjggNC44OC02LjY0IDguODMtMTIuNzQgMTEuODUtMTguMjggMi45Ny01LjQzIDUuMTgtMTAuNjEgNi42NC0xNS41NSAxLjQyLTQuODUgMi4xMy05LjUzIDIuMTMtMTQgMC0xNC42OC0zLjk4LTI2LjA1LTExLjkyLTM0LjA5LTMuOTItMy45Ni04Ljc1LTYuOTMtMTQuNDktOC45Mi01Ljk1LTIuMDMtMTIuOTEtMy4wNS0yMC44Ny0zLjA1LTguNDUgMC0xNS44OCAxLjIxLTIyLjI5IDMuNjItNi4yNyAyLjM2LTExLjYzIDUuOTItMTYuMDcgMTAuNjNhNDcuODg0IDQ3Ljg4NCAwIDAgMC0xMC4xNCAxNi42Yy0yLjI3IDYuMjktMy40MSAxMy4zOS0zLjQxIDIxLjI2IDAgMi41Mi0yLjA1IDQuNTctNC41NyA0LjU3aC02Ljg5Yy0yLjA1IDAtMy44LTEuMzYtNC4zNy0zLjI0bC0uMjctLjgyYy0uMTgtLjU2LS4yNS0xLjEzLS4yMi0xLjY3LS4yMy05LjMyIDEuMTQtMTcuOTkgNC4xMi0yNS45NyAzLjAyLTguMTMgNy42OC0xNS41NCAxMy45NC0yMi4xOSA2LjI2LTYuNyAxMy42My0xMS43NiAyMi4xLTE1LjEzQzQwNy44NCAxLjY4IDQxNy4yIDAgNDI3LjU1IDBjOS41OSAwIDE4LjI2IDEuMzggMjYuMDMgNC4xMyA3Ljg2IDIuNzkgMTQuNzcgNyAyMC43MiAxMi42MSA2LjAyIDUuNjMgMTAuNTUgMTIuNCAxMy41NSAyMC4yOCAyLjk2IDcuNzUgNC40NSAxNi41NiA0LjQ1IDI2LjQgMCA2LjUtMS4wNyAxMy4wOC0zLjE3IDE5LjY5bC0uMTQuMzhjLTIuMDkgNi40Ni01LjE3IDEyLjk3LTkuMiAxOS40OWwtLjE0LjIxYy00LjA4IDYuNTEtOC45IDEzLjQzLTE0LjQzIDIwLjc0LTUuNTYgNy4zMy0xMS45NiAxNS4yMy0xOS4yMiAyMy42N2wtNTYuOTEgNjYuNTFoMTEwLjM0YzIuNTIgMCA0LjU3IDIuMDUgNC41NyA0LjU3djguMTFjMCAyLjUyLTIuMDUgNC41Ny00LjU3IDQuNTd6bS0zMjcuMjUgNjguNzUgMTM3Ljk2LTE2Ny43NmMuODktMS4wNyAyLjMtMS42NSAzLjc0LTEuNjVsMjAuMTMtLjAyYzIuNTIgMCA0LjU3IDEuNzQgNC41NyAzLjg4IDAgLjkxLS4zNyAxLjc1LS45OCAyLjQxTDE4OC4zMiAzMTcuNjYgMzQ0LjEgNTA2LjI0YzEuNDUgMS43NS45NSA0LjE3LTEuMSA1LjQtLjguNDgtMS43Mi43MS0yLjYzLjcxbC0yMC4xMy4wMWMtMS43IDAtMy4xOC0uNzktMy45Ny0xLjk2bC0xNDQuMS0xNzUuMkwyOC4yMyA1MTAuNjljLS44OCAxLjA3LTIuMyAxLjY0LTMuNzMgMS42NWwtMTkuOTMuMDJjLTIuNTIgMC00LjU3LTEuNzQtNC41Ny0zLjg5IDAtLjkuMzctMS43NC45OC0yLjRsMTU1LjY1LTE4OC40TDYuOSAxMzYuOGMtMS40NS0xLjc1LS45NS00LjE4IDEuMTEtNS40MS43OS0uNDcgMS43MS0uNyAyLjYyLS43bDIwLjQ0LS4wMWMxLjYzIDAgMy4wNi43MiAzLjg3IDEuODFsMTM3LjI0IDE2Ny42MnoiLz48L3N2Zz4=",Hy=Un.createContext(null),qy=4;function Vu({children:m,className:c,onClick:p,title:t}){const f=we.useRef(null),r=Un.useContext(Hy);if(r===null)throw new Error("DropDownItem must be used within a DropDown");const{registerItem:n}=r;return we.useEffect(()=>{f&&f.current&&n(f)},[f,n]),he.jsx("button",{className:c,onClick:p,ref:f,title:t,type:"button",children:m})}function wE({children:m,dropDownRef:c,onClose:p}){const[t,f]=we.useState(),[r,n]=we.useState(),e=we.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=we.useMemo(()=>({registerItem:e}),[e]);return we.useEffect(()=>{t&&!r&&n(t[0]),r&&r.current&&r.current.focus()},[t,r]),he.jsx(Hy.Provider,{value:i,children:he.jsx("div",{className:"dropdown",ref:c,onKeyDown:s,children:m})})}function SE({disabled:m=!1,buttonLabel:c,buttonAriaLabel:p,buttonClassName:t,buttonIconClassName:f,children:r,stopCloseOnClickSelf:n}){const e=we.useRef(null),s=we.useRef(null),[i,l]=we.useState(!1),o=()=>{l(!1),s&&s.current&&s.current.focus()};return we.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+qy}px`,d.style.left=`${Math.min(g,window.innerWidth-d.offsetWidth-20)}px`}},[e,s,i]),we.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]),we.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+qy;h!==u.getBoundingClientRect().top&&(u.style.top=`${h}px`)}}};return document.addEventListener("scroll",a),()=>{document.removeEventListener("scroll",a)}},[s,e,i]),he.jsxs(he.Fragment,{children:[he.jsxs("button",{type:"button",disabled:m,"aria-label":p||c,className:t,onClick:()=>l(!i),ref:s,children:[f&&he.jsx("span",{className:f}),c&&he.jsx("span",{className:"text dropdown-button-text",children:c}),he.jsx("i",{className:"chevron-down"})]}),i&&Wr.createPortal(he.jsx(wE,{dropDownRef:e,onClose:o,children:r}),document.body)]})}function Wy(){return he.jsx("div",{className:"divider"})}const Sp=8,Ep=72,qs={h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",paragraph:"Normal"},EE=({selectionFontSize:m,disabled:c,editor:p,blockType:t,styleConfig:f,isenterPressed:r,currentElementClick:n,currentElementSelect:e})=>{const[s,i]=Un.useState(m),[l,o]=Un.useState(t),[a,d]=Un.useState(""),u=x=>{p.update(()=>{if(p.isEditable()){const w=Ce();w!==null&&Bm(w,x)}})},g=x=>{i(x.target.value)},h=()=>{const x=Number(s);if(!isNaN(x)){const w=Math.min(Math.max(x,Sp),Ep);i(String(w)),u({"font-size":`${w}px`})}},y=x=>{const w=f[l].fontSize,S=x?Math.min(w+2,Ep):Math.max(w-2,Sp);i(String(S)),u({"font-size":`${l}px`})},v=x=>{p.update(()=>{const w=Ce();ve(w)&&O_(w,()=>jn())})},_=x=>{d(x),p.update(()=>{const k=Ce();ve(k)&&A_(k,()=>ws(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,"line-height":`${1+S.leadingSpace}em`,"margin-bottom":`${S.trailingSpace}em`};u(C)},b=()=>{o("paragraph"),u({"font-size":"11px"}),i("11"),v()};return Un.useEffect(()=>{r&&r==="Enter"&&b()},[r]),Un.useEffect(()=>{const x=()=>{p.update(()=>{const w=Ce();if(w!==null){const C=w.getNodes()[0];if(!je(C)){const k=C.getType();k in qs&&o(k)}}})};return p.registerUpdateListener(x),()=>{p.registerUpdateListener(x)}},[p]),Un.useEffect(()=>{switch(n.tagName){case"P":o("paragraph");break;case"H1":console.log("H1"),o("h1");break;case"H2":o("h2");break;case"H3":o("h3");break;case"default":o("paragraph"),console.log("default");break}},[n]),Un.useEffect(()=>{switch(e.trim(" ")){case"Heading1":console.log("Setting current heading to h1"),o("h1");break;case"Heading2":o("h2");break;case"Heading3":o("h3");break;case"default":case"paragraph":o("paragraph"),console.log("Setting to default paragraph");break;default:console.warn("Unknown element type:",e);break}},[e]),he.jsxs(he.Fragment,{children:[he.jsx("button",{type:"button",disabled:c,onClick:()=>y(!1),className:"toolbar-item font-decrement"}),he.jsx("input",{type:"number",value:s,disabled:c,readOnly:!0,className:"toolbar-item font-size-input",min:Sp,max:Ep,onChange:g,onBlur:h}),he.jsx("button",{type:"button",disabled:c,onClick:()=>y(!0),className:"toolbar-item font-increment"}),he.jsx(Wy,{}),he.jsxs("div",{className:"symbol-dropdown cust-head-dropDown",children:[he.jsxs(SE,{disabled:c,buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"Formatting options for text style",buttonIconClassName:"icon block-type "+l,buttonLabel:qs[l],children:[he.jsxs(Vu,{className:`item ${l==="paragraph"?"active":""}`,onClick:()=>v(),children:[he.jsx("i",{className:"icon paragraph"}),he.jsx("span",{className:"text",children:qs.paragraph})]}),he.jsxs(Vu,{className:`item ${l==="h1"?"active":""}`,onClick:()=>_("h1"),children:[he.jsx("i",{className:"icon h1"}),he.jsx("span",{className:"text",children:qs.h1})]}),he.jsxs(Vu,{className:`item ${l==="h2"?"active":""}`,onClick:()=>_("h2"),children:[he.jsx("i",{className:"icon h2"}),he.jsx("span",{className:"text",children:qs.h2})]}),he.jsxs(Vu,{className:`item ${l==="h3"?"active":""}`,onClick:()=>_("h3"),children:[he.jsx("i",{className:"icon h3"}),he.jsx("span",{className:"text",children:qs.h3})]})]}),he.jsx(Wy,{})]})]})},CE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuMS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIyIEZvbnRpY29ucywgSW5jLi0tPjxwYXRoIGQ9Ik0wIDI1NkMwIDExNC42IDExNC42IDAgMjU2IDBzMjU2IDExNC42IDI1NiAyNTYtMTE0LjYgMjU2LTI1NiAyNTZTMCAzOTcuNCAwIDI1NnptMTc1LTQ3LjkgNDcuMSA0N0wxNzUgMzAzYy05LjMgOS40LTkuMyAyNC42IDAgMzMuMSA5LjQgMTAuMiAyNC42IDEwLjIgMzMuMSAwbDQ3LTQ2LjIgNDcuOSA0Ni4yYzkuNCAxMC4yIDI0LjYgMTAuMiAzMy4xIDAgMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMWwtNDYuMi00Ny45IDQ2LjItNDdjMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMS04LjUtOS4zLTIzLjctOS4zLTMzLjEgMGwtNDcuOSA0Ny4xLTQ3LTQ3LjFjLTguNS05LjMtMjMuNy05LjMtMzMuMSAwLTkuMyA5LjQtOS4zIDI0LjYgMCAzMy4xeiIvPjwvc3ZnPg==",kE="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGFibGUiPjxwYXRoIGQ9Ik0wIDJhMiAyIDAgMCAxIDItMmgxMmEyIDIgMCAwIDEgMiAydjEyYTIgMiAwIDAgMS0yIDJIMmEyIDIgMCAwIDEtMi0yVjJ6bTE1IDJoLTR2M2g0VjR6bTAgNGgtNHYzaDRWOHptMCA0aC00djNoM2ExIDEgMCAwIDAgMS0xdi0yem0tNSAzdi0zSDZ2M2g0em0tNSAwdi0zSDF2MmExIDEgMCAwIDAgMSAxaDN6bS00LTRoNFY4SDF2M3ptMC00aDRWNEgxdjN6bTUtM3YzaDRWNEg2em00IDRINnYzaDRWOHoiLz48L3N2Zz4=";function OE(){const[m,c]=we.useState("4"),[p,t]=we.useState("4"),[f,r]=we.useState(!1),[n,e]=we.useState(),[s]=Nr(),i=()=>{!m||!p||(s.update(()=>{const l=b0(m,p,!0),o=Wm(l);e(o)}),r(!1))};return he.jsxs(he.Fragment,{children:[he.jsx("button",{className:"toolbar-item ",onClick:()=>r(!0),children:he.jsx("img",{className:"add-toolbar-table-icon",src:kE,alt:"Add Table"})}),f&&he.jsx("div",{className:"modal-overlay",children:he.jsxs("div",{className:"modal-content",children:[he.jsx("h3",{children:"Select Table Dimensions"}),he.jsx("button",{className:"modal-buttons-close",onClick:()=>r(!1),children:he.jsx("img",{src:CE,height:16,width:16,style:{margin:"0 0 29px 10px"}})}),he.jsxs("div",{className:"select-table-container",children:[he.jsx("label",{children:"Rows"}),he.jsx("input",{type:"number",value:m,onChange:l=>c(Number(l.target.value))})]}),he.jsxs("div",{className:"select-table-container",children:[he.jsx("label",{children:"Column"}),he.jsx("input",{type:"number",value:p,onChange:l=>t(Number(l.target.value))})]}),he.jsx("div",{children:he.jsx("div",{className:"modal-buttons",children:he.jsx("button",{className:"toolbar-item",onClick:i,children:"Confirm"})})})]})})]})}const Jy="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNCAxMkgyME0xMiA0VjIwIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==",Vy="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNiAxMkwxOCAxMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4=";var TE=typeof global=="object"&&global&&global.Object===Object&&global;const AE=TE;var PE=typeof self=="object"&&self&&self.Object===Object&&self,jE=AE||PE||Function("return this")();const Ky=jE;var NE=Ky.Symbol;const Ku=NE;var Gy=Object.prototype,IE=Gy.hasOwnProperty,RE=Gy.toString,tc=Ku?Ku.toStringTag:void 0;function ME(m){var c=IE.call(m,tc),p=m[tc];try{m[tc]=void 0;var t=!0}catch{}var f=RE.call(m);return t&&(c?m[tc]=p:delete m[tc]),f}var DE=Object.prototype,LE=DE.toString;function BE(m){return LE.call(m)}var FE="[object Null]",zE="[object Undefined]",Yy=Ku?Ku.toStringTag:void 0;function UE(m){return m==null?m===void 0?zE:FE:Yy&&Yy in Object(m)?ME(m):BE(m)}function $E(m){return m!=null&&typeof m=="object"}var HE="[object Symbol]";function qE(m){return typeof m=="symbol"||$E(m)&&UE(m)==HE}var WE=/\s/;function JE(m){for(var c=m.length;c--&&WE.test(m.charAt(c)););return c}var VE=/^\s+/;function KE(m){return m&&m.slice(0,JE(m)+1).replace(VE,"")}function Cp(m){var c=typeof m;return m!=null&&(c=="object"||c=="function")}var Zy=0/0,GE=/^[-+]0x[0-9a-f]+$/i,YE=/^0b[01]+$/i,ZE=/^0o[0-7]+$/i,XE=parseInt;function Xy(m){if(typeof m=="number")return m;if(qE(m))return Zy;if(Cp(m)){var c=typeof m.valueOf=="function"?m.valueOf():m;m=Cp(c)?c+"":c}if(typeof m!="string")return m===0?m:+m;m=KE(m);var p=YE.test(m);return p||ZE.test(m)?XE(m.slice(2),p?2:8):GE.test(m)?Zy:+m}var QE=function(){return Ky.Date.now()};const kp=QE;var tC="Expected a function",eC=Math.max,nC=Math.min;function rC(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(tC);c=Xy(c)||0,Cp(p)&&(l=!!p.leading,o="maxWait"in p,r=o?eC(Xy(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?nC(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=kp();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(kp())}function x(){var w=kp(),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 oC(m,c,p){const t=we.useRef(null);return t.current=m,we.useMemo(()=>rC((...f)=>{t.current&&t.current(...f)},c,{maxWait:p}),[c,p])}const Qy=20;function iC({anchorElem:m}){const[c]=Nr(),p=_u(),[t,f]=we.useState(!1),[r,n]=we.useState(!1),[e,s]=we.useState(!1),[i,l]=we.useState({}),o=we.useRef(new Set),a=we.useRef(null),d=oC(y=>{const{isOutside:v,tableDOMNode:_}=aC(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=ar(_);if(rn(S)){const k=bn(S,D=>Rn(D));if(!Rn(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=Sx(S),R=x0(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:Qy,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:Qy}))}},50,250),u=we.useMemo(()=>new ResizeObserver(()=>{f(!1),n(!1)}),[]);we.useEffect(()=>{if(e)return document.addEventListener("mousemove",d),()=>{f(!1),n(!1),d.cancel(),document.removeEventListener("mousemove",d)}},[e,d]),we.useEffect(()=>_o(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=ar(a.current);v==null||v.selectEnd(),y?(Ex(),f(!1)):(Cx(),n(!1))}})},h=y=>{c.update(()=>{if(a.current){const v=ar(a.current);v==null||v.selectEnd(),y?(kx(),f(!1)):(Ox(),n(!1))}})};return p?he.jsxs(he.Fragment,{children:[t&&he.jsxs("div",{children:[he.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%",padding:"20px"},onClick:()=>g(!0),children:he.jsx("img",{src:Jy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),he.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%"},onClick:()=>h(!0),children:he.jsx("img",{src:Vy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]}),r&&he.jsxs("div",{className:"table-add-row-flex-container",children:[he.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%",padding:"20px"},onClick:()=>g(!1),children:he.jsx("img",{src:Jy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),he.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%"},onClick:()=>h(!1),children:he.jsx("img",{src:Vy,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]})]}):null}function aC(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 sC({anchorElem:m=document.body}){return _u()?Wr.createPortal(he.jsx(iC,{anchorElem:m}),m):null}const ec=1;function Op(){return he.jsx("div",{className:"divider"})}function lC({renderOnlineUsers:m,styleConfig:c}){const[p]=Nr(),t=we.useRef(null),[f,r]=we.useState(!1),[n,e]=we.useState(!1),[s,i]=we.useState(!1),[l,o]=we.useState(!1),[a,d]=we.useState(!1),[u,g]=we.useState(!1),[h,y]=we.useState(!1),[v,_]=we.useState(!1),[b,x]=we.useState("11px"),[w,S]=we.useState(()=>p.isEditable()),[C,k]=we.useState(""),[D,N]=we.useState(""),[O,R]=we.useState(""),A=we.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(zm(U,"font-size","11px")))},[]);return we.useEffect(()=>_o(p.registerUpdateListener(({editorState:U})=>{U.read(()=>{A()})}),p.registerCommand(Go,U=>{k("");const q=Ce();return console.log("SELECTION_CHANGE_COMMAND",q&&q.style&&q.style.split(";")[0].split(":")[1]),R(q&&q.style?q.style.split(";")[0].split(":")[1]:"paragraph"),A(),!1},ec),p.registerCommand(is,U=>(r(U),!1),ec),p.registerCommand(os,U=>(e(U),!1),ec),p.registerCommand(qd,U=>(N(U.target),!1),ec),p.registerCommand(ns,U=>(k(U.code),!1),ec)),[p,A]),he.jsxs("div",{className:"toolbar",ref:t,children:[he.jsx("button",{disabled:!f,onClick:()=>{p.dispatchCommand(_l,void 0)},className:"toolbar-item spaced","aria-label":"Undo",children:he.jsx("i",{className:"format undo"})}),he.jsx("button",{disabled:!n,onClick:()=>{p.dispatchCommand(xl,void 0)},className:"toolbar-item","aria-label":"Redo",children:he.jsx("i",{className:"format redo"})}),he.jsx(Op,{}),he.jsx(EE,{currentElementClick:D,selectionFontSize:b.slice(0,-2),editor:p,disabled:!w,blockType:"paragraph",styleConfig:c,isenterPressed:C,currentElementSelect:O}),he.jsx(Op,{}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"bold")},className:"toolbar-item spaced "+(s?"active":""),"aria-label":"Format Bold",children:he.jsx("i",{className:"format bold"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"italic")},className:"toolbar-item spaced "+(l?"active":""),"aria-label":"Format Italics",children:he.jsx("i",{className:"format italic"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"underline")},className:"toolbar-item spaced "+(a?"active":""),"aria-label":"Format Underline",children:he.jsx("i",{className:"format underline"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"strikethrough")},className:"toolbar-item spaced "+(u?"active":""),"aria-label":"Format Strikethrough",children:he.jsx("i",{className:"format strikethrough"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"superscript")},className:"toolbar-item spaced "+(v?"active":""),"aria-label":"Format SuperScript",children:he.jsx("img",{src:xE,height:16,width:16,style:{marginTop:"1px"}})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(Or,"subscript")},className:"toolbar-item spaced "+(h?"active":""),"aria-label":"Format SubScript",children:he.jsx("img",{src:_E,height:16,width:16,style:{marginTop:"1px"}})}),he.jsx(Op,{}),he.jsx("button",{onClick:()=>{p.dispatchCommand(rs,"left")},className:"toolbar-item spaced","aria-label":"Left Align",children:he.jsx("i",{className:"format left-align"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(rs,"center")},className:"toolbar-item spaced","aria-label":"Center Align",children:he.jsx("i",{className:"format center-align"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(rs,"right")},className:"toolbar-item spaced","aria-label":"Right Align",children:he.jsx("i",{className:"format right-align"})}),he.jsx("button",{onClick:()=>{p.dispatchCommand(rs,"justify")},className:"toolbar-item","aria-label":"Justify Align",children:he.jsx("i",{className:"format justify-align"})}),he.jsx(OE,{}),he.jsx(sC,{}),he.jsx("div",{className:"avtar-outer-div",children:m()})]})}var Tp={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.
|