sykpcomposer 0.0.90 → 0.0.91
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 +6 -6
- 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?ar.tooltipAnimations.hideAtOnce:ar.tooltipAnimations.hideWithDelay};
|
|
1427
1427
|
left: ${n?"0px":"100%"};
|
|
1428
1428
|
z-index: 10;
|
|
1429
|
-
`,P.append(q),_=q}!R&&x.width<1&&r.length>1&&(P.style.width="3px")}v.forEach(w=>{this.hoverList.push([w,_,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(s){let p=!1,t=s.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 l=new Set;for(let i=0;i<this.hoverList.length;i++){let c=this.hoverList[i],[o,a,u]=c;if(l.has(u))continue;let d=ar.isMousePositionWithinElementCords(s,o);s.type===kr.mouseover&&d&&(a.style.animation=this.isEditingInProgress?ar.tooltipAnimations.hideAtOnce:ar.tooltipAnimations.showAtOnce,l.add(u)),s.type===kr.mouseout&&(a.style.animation=ar.tooltipAnimations.hideWithDelay,l.add(u)),s.type===kr.mousemove&&d&&(a.style.animation=this.isEditingInProgress?ar.tooltipAnimations.hideAtOnce:ar.tooltipAnimations.showAtOnce,l.add(u))}}_keyboardEventsListener(s){s.type===kr.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),s.type===kr.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(s){Se.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(kr.keypress,this.keyboardBindedListener),window.addEventListener(kr.keyup,this.keyboardBindedListener),window.addEventListener(kr.resize,this.resizeBindedListener),window.addEventListener(kr.scroll,this.resizeBindedListener);for(const s of my)window.addEventListener(s,this.mouseBindedListener)}unmount(){window.removeEventListener(kr.keypress,this.keyboardBindedListener),window.removeEventListener(kr.keyup,this.keyboardBindedListener),window.removeEventListener(kr.resize,this.resizeBindedListener),window.removeEventListener(kr.scroll,this.resizeBindedListener);for(const s of my)window.removeEventListener(s,this.mouseBindedListener);this.gcPrevPaintedRemoteSelections()}shouldUpdateRemoteSelections(){return!0}gcPrevPaintedRemoteSelections(){let s=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=s||[],this.remoteSelectionDOMsMap={},this.activeEditorsKeys={}}paintRemoteSelections(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];this.gcPrevPaintedRemoteSelections(s);let p=Se.getMainEditorState();p.read&&p.read(()=>{for(let t of this.remoteSelections)if(Pp.validateJSONSelection(t,kp.remote))if($e.isNestedSelectionJSON(t)){let{nestedSelectionJSON:f,nestedEditor:r}=$e.getNestedSelectionJSONFromMainSelectionJSON(t);if(!r)continue;r.getEditorState().read(()=>{let n=$e.JSONToLexical(f);if(n)try{this.paintSingleRemoteSelection({editor:r,selectionJSON:t,lexicalSelection:n,selectedNodes:n.getNodes(),isBackward:n.isBackward()})}catch(e){ue.warn("[PAINT REMOTE SELECTION] failed for nested editor - ",{error:e,nestedSelectionJSON:f,fullSelection:t,lexicalSelection:n})}else ue.error("DEBUGGER: [paintRemoteSelections] nested selection from json to lexical is null: ",{selection:t,nestedSelectionJSON:f,lexicalSelection:n})})}else{let f=$e.JSONToLexical(t);if(!f){ue.error("DEBUGGER: [paintRemoteSelections] selection from json to lexical is null: ",{selection:t,lexicalSelection:f});continue}try{this.paintSingleRemoteSelection({editor:Se.getMainEditor(),selectionJSON:t,lexicalSelection:f,selectedNodes:f.getNodes(),isBackward:f.isBackward()})}catch(r){ue.warn("[PAINT REMOTE SELECTION] failed - ",{error:r,fullSelection:t,lexicalSelection:f})}}})}updateRemoteSelections(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";this.shouldUpdateRemoteSelections(s)&&(ue.log("[updateRemoteSelections] "+p,{newRemoteSelections:s}),Promise.resolve().then(()=>{this.paintRemoteSelections(s),this.hideInUI&&this.hideRemoteSelectionsFromUI()}))}clear(){this.gcPrevPaintedRemoteSelections()}getCurrentRemoteSelections(){return this.remoteSelections}hideRemoteSelectionsFromUI(){this.hideInUI||(this.hideInUI=!0);const s=document.querySelectorAll(".codox_remote_selection");for(let p of s)p.classList.add("hidden_codox_remote_selection")}showHiddenRemoteSelectionsInUI(){this.hideInUI=!1;const s=document.querySelectorAll(".hidden_codox_remote_selection");for(let p of s)p.classList.remove("hidden_codox_remote_selection")}}const Oo=new hE;function gE(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(g=>g===Ma.editorState)}function Zu(g){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,p=Se.getMainEditorNodesClassesMap();const{klass:t}=p.get(g.type)||{};if(!t)return;const f=t.importJSON(g);if(g.children&&g.children.length)for(const r of g.children)Zu(r,f);return s&&s.getChildrenSize&&s.splice(s.getChildrenSize(),0,[f]),f}function Xu(g){if(g.getChildren)for(let s of g.getChildren())Xu(s);g.remove()}function Ry(g){g.__parent=null,g.__next=null,g.__prev=null}function My(g,s){return!!Se.isLexicalEditorInstance(g)&&!(typeof s!="object"||!s.editorState||(g.update(()=>{try{let p=(0,_e.$getSelection)();const t=g.parseEditorState(s.editorState);if(t.isEmpty())return(0,_e.$getRoot)().clear(),!0;(0,_e.$setSelection)(p),g.setEditorState(t)}catch(p){ue.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",p)}}),0))}function mE(g,s){let p=s;for(const t of g)p=p[t];return p}function La(g){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,p=arguments.length>2&&arguments[2]!==void 0&&arguments[2],t=null,f=mE(g,p?s:Se.getMainEditorState().toJSON());return f&&(t=Ba(f)?(0,_e.$getRoot)():In.get(f.codoxId)),t||ue.debug("[WARNING][getLexicalNodeByPathOutOfJSONState] lexical node not found: ",{jsonNode:f,lexicalNode:t,pathArray:g,currentStateJSON:Se.getMainEditorState().toJSON(),newStateJSON:s,codoxNodes:In.nodesToArray(),searchInNewState:p}),t||(p?t:La(g,s,!0))}function Dy(g){ue.log("[applyFullLexicalStateReplace] clear current state and apply new");const s=(0,_e.$getRoot)();s.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 g.root.children)s.append(t(f))}function yE(g){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(s.length){ue.log("[applyDeltasToLexicalState] Original Deltas: ",{newStateJSON:g,deltas:JSON.parse(JSON.stringify(s))});for(const p of s){let{p:t}=p;const f=t[t.length-1],r=f==="children",n=typeof f=="number",e=!n&&!r,l=gE(t),i=l!==-1,c=p.hasOwnProperty("lm")&&typeof p.lm=="number";if(t.length)if(i){let o=l-1,a=La(t.slice(0,o),g);if(a){let u=t.slice(0,l),d=g;for(const h of u)d=d[h];let m=ac(t[o]);My(a.getWritable()[m],d)}}else{if(r){let o=p.oi;if(!o){ue.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi attr expected for path",{delta:p});continue}if(o.some(u=>!(!u.hasOwnProperty("text")||typeof u.text=="string"))){ue.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi children contain invalid text value",{delta:p});continue}t.length=t.length-1;let a=La(t,g);if(!a)continue;if(o.some(u=>!!u.codoxDId)){try{a=a.getWritable()}catch(h){ue.debug("[applyDeltasToLexicalState][shouldUpdateLeaves] getWritable error: ",{err:h,delta:p,fullStateJSON:g});continue}let u={};for(let h of a.getChildren())h.codoxDId?u[h.codoxDId]=h:Xu(h);let d=[],m=["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,w=h>=0?d[h-1]:null;if(y.codoxDId){let x=u[y.codoxDId];if(x){x=x.getWritable();let S=Zu(y);if(ue.debug("[DELTA_DECORATOR_UPDATE]: ",{exisingDecorator:x,tmpDecorator:S}),!S){ue.debug("[DELTA_DECORATOR_UPDATE] UPADATE SKIPPED: ",{exisingDecorator:x,tmpDecorator:S});continue}for(let C in S)if(S.hasOwnProperty(C)&&!m.includes(C))if(Se.isLexicalEditorInstance(S[C])){let k={editorState:S[C].getEditorState().toJSON()};My(x[C],k)}else{let k=Cp(C),D=y[k];if(D===x[C]||!y.hasOwnProperty(k))continue;let I=D!==void 0&&S[C]!==D?D:S[C];k!=="height"&&k!=="width"||S[C]==="inherit"&&D===0&&(I=S[C]),x[C]=I}S.remove(),Ry(x),b=x,delete u[y.codoxDId]}}b||(b=Zu(y),b.codoxDId&&b.__type==="excalidraw"&&b.__data==="[]"&&(b.__data="{}")),b=b.getWritable(),d.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=w.__key,w.__next=b.__key):(b.__prev=w.__key,w.__next=b.__key),a.__size=d.length}for(let h in u){let y=u[h];y=y.getWritable(),Ry(y),Xu(y),delete u[h]}}else{let u=o.map(d=>Zu(d));a.splice(0,a.getChildrenSize(),u)}}if(n){if(p.ld){const o=p.ld,a=In.get(o.codoxId);a.getChildrenSize&&a.getChildrenSize()?Xu(a):a.remove()}if(p.li){let o=Se.getMainEditorNodesClassesMap();const a=p.li,u=o.get(a.type).klass.importJSON(a);if(t.length===1&&t[0]==="root")(0,_e.$getRoot)().splice(0,0,[u]);else{const d=t[t.length-1];t.length=t.length-2;let m=La(t,g);m&&m.splice(d,0,[u])}if(a.children&&a.children.length){let d=function(m,h){const y=o.get(m.type).klass.importJSON(m);if(h.splice(h.getChildrenSize(),0,[y]),m.children&&m.children.length)for(const v of m.children)d(v,y)};for(const m of a.children)d(m,u)}}if(p.oi||p.od){let{p:o,oi:a,od:u}=p,d=La(o,g);if(d)try{let m=d.getWritable();if(a){let h=Object.keys(a);for(let y of h)m[ac(y)]=a[y]}if(u){let h=Object.keys(u);for(let y of h)delete m[ac(y)]}}catch(m){ue.debug("[applyDeltasToLexicalState][delta oi/od] getWritable error: ",{err:m,delta:p})}}if(c){let{p:o,lm:a}=p,u=o[o.length-1],d=a,m=d<u,h=La(o,g);if(h){let y=h.getParent().getChildren(),v=y[u],_=y[d];m?_.insertBefore(v):_.insertAfter(v)}}}if(e){const o=t[t.length-1];let a=ac(o);t.length=t.length-1;let u,d=La(t,g);if(!d){ue.error("Missing node when update node attr from delta: ",{path:t,delta:p,fullStateJSON:g,currentEditorState:Se.getMainEditorState().toJSON()});continue}try{u=d.getWritable()}catch(h){ue.debug("[applyDeltasToLexicalState][shouldUpdateBlockAttr] getWritable error: ",{err:h,delta:p})}if(!u)continue;let m=p.oi;if(o==="format"&&(m=mS(m)),o==="direction"&&(d.hasOwnProperty(a)||(a="__dir")),!u.hasOwnProperty(a)){let h=Object.keys(u);for(let y of h){let v=Cp(y);if(o.startsWith(v)){a=y;break}}}u[a]=m}}else if(p.oi&&p.oi.root)return Dy(p.oi)}}else ue.log("[applyDeltasToLexicalState] stop, no deltas: ",s)}function vE(g){let s=g.clipboardData.getData(vS.paste),p=!1;try{s=JSON.parse(s),typeof s=="object"&&s.nodes&&Array.isArray(s.nodes)&&(p=!0)}catch{return!1}if(!p)return!1;if(p){In.clearPastedIds();const t=f=>{if(f.codoxId&&In.addPastedId(f.codoxId),f.children&&f.children.length)for(const r of f.children)t(r)};for(const f of s.nodes)t(f)}return!1}var bE=g=>{var s={};return on.d(s,g),s};const Ly=bE({useCollaborationContext:()=>jw});var _E=g=>{var s={};return on.d(s,g),s};const ta=_E({LexicalComposerContext:()=>up,useLexicalComposerContext:()=>_r});class By{constructor(){this.blacklist=Object.keys(yy).reduce((s,p)=>{let t=yy[p];return s[p]=t.reduce((f,r)=>(f[r]=r,f),{}),s},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(s){return s instanceof _e.TextNode||s instanceof _e.ParagraphNode||s instanceof _e.RootNode}setClientCallback(s){this._clientCallback=s}removeClientCallback(){this._clientCallback=null}invokeClientCallback(){this._clientCallback&&this._clientCallback()}trackBlacklisted(s){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>2?arguments[2]:void 0;if(jp||p!==to.created||this._isBlacklistedFound||!s||!s.__type||this._shouldSkipNode(s))return;let f=t||Se.getMainEditorState(),r=s.__type,n=this.blacklist[r];n&&f.read(()=>{let e=s.getParent();for(;e!==null;){let l=e?e.__type:null;if(!l)return;if(n[l])return ue.warn("[ContentNestingsWatcher][trackBlacklisted] FOUND: ",{targetNode:s,targetType:r,parent:e,parentType:l,mutationType:p}),void(this._isBlacklistedFound=!0);e=e.getParent()}})}trackBlacklistedInNestedEditor(s){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>3?arguments[3]:void 0;if(p!==to.created||this._isBlacklistedFound||this._shouldSkipNode(s))return;let f=t.__type,r=s.__type;if(!f||!r)return;let n=this.blacklist[r];n&&n[f]&&(this._isBlacklistedFound=!0,ue.warn("[ContentNestingsWatcher][trackBlacklistedInNestedEditor] FOUND: ",{targetNode:s,targetType:r,rootNode:t,rootType:f,mutationType:p}))}isBlacklistedFound(){let s=this._isBlacklistedFound;return s&&(this._isBlacklistedFound=!1),s}}const xE=new By,ea=xE,wE=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function SE(g,s){if(g==null)return{};var p,t,f=EE(g,s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(g);for(t=0;t<r.length;t++)p=r[t],s.indexOf(p)>=0||{}.propertyIsEnumerable.call(g,p)&&(f[p]=g[p])}return f}function EE(g,s){if(g==null)return{};var p={};for(var t in g)if({}.hasOwnProperty.call(g,t)){if(s.indexOf(t)>=0)continue;p[t]=g[t]}return p}class CE{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(s,p){let t=!1;return function(f){let{editorState:r,prevEditorState:n,dirtyElements:e,dirtyLeaves:l}=f,i=(SE(f,wE),Se.getMainEditor()),c=Se.getMainEditorState(),o=r.toJSON(),a=n.toJSON(),u=Ap(o,a),d=r._selection,m=n._selection,h=!1,y=null,v=Se.isOnlySelectionChanged(e,l),_=s[p];if(ue.debug("[NESTED EDITOR LISTENER] invoked: ",{lexicalNode:s,key:s.__key,onlySelectionChanged:v,newEditorStateJSON:o,prevEditorStateJSON:a,isSameState:u,lexicalSelection:d,prevLexicalSelection:m,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,nestedEditorKey:_._key}),ea.isBlacklistedFound())return t=!0,ue.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),Se.scanLexicalNodeForNestedEditorAttribute(s)?(_.update(()=>{try{const b=_.parseEditorState(a);if(b.isEmpty())return(0,_e.$getRoot)().clear(),!0;_.setEditorState(b)}catch(b){ue.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",b)}}),void ea.invokeClientCallback()):void 0;if(t)t=!1;else{if(s.codoxId||s.codoxDId){let b=null;c.read(()=>{b=$e.getNodeAncestorsCodoxIds(s),!s.codoxId&&s.codoxDId&&b.push(s.codoxDId)}),r.read(()=>{let w=Cp(p),x=$e.lexicalToJSONNested(d,w,b);y=Se.getCurrentNestedSelectionJSON(),h=$e.equalSelectionsJSON(y,x),h||Se.setNestedSelectionJSON(x)})}u&&h||i.update(()=>{try{ue.debug("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE",{mainTags:i._updateTags,nestedTags:_&&_._updateTags,isSameState:u,isSameSelection:h,onlyNestedSelectionChanged:v,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,lexicalNode:s,lexicalSelection:d,prevLexicalSelection:m,mainEditorTags:i._updateTags,mainEditorTagsSize:i._updateTags.size}),Se.addUpdateTag({fromNestedEditor:!0}),s.markDirty()}catch(b){ue.error("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE - ERROR: ",b)}})}}}_isNestedEditorManaged(s){return!!this.nestedEditorsListenersMap[s]}gc(){for(let s in this.nestedEditorsListenersMap)if(!Se.getLexicalNodeByKey(s)){let p=this.nestedEditorsListenersMap[s];p&&p(),delete this.nestedEditorsListenersMap[s]}}manageNestedEditorInLexicalNode(s){if(this._isNestedEditorManaged(s.getKey()))return;let p=Se.scanLexicalNodeForNestedEditorAttribute(s);if(p){let t=s[p],f=this._createNestedEditorUpdatesListener(s,p),r=[];t._nodes.forEach((l,i,c)=>{let{klass:o}=l,a=t.registerMutationListener(o,u=>{for(let[d,m]of u)if(m===to.created){let h=t.getEditorState()._nodeMap.get(d);h&&ea.trackBlacklistedInNestedEditor(h,m,t.getEditorState(),s)}});r.push(a)});let n=(0,Ds.mergeRegister)(t.registerUpdateListener(f),...r),e=s.getKey();this.nestedEditorsListenersMap[e]=n}}gcNestedEditorListenerInLexicalNode(s){let p=s.getKey(),t=this.nestedEditorsListenersMap[p];t&&(t(),delete this.nestedEditorsListenersMap[p])}manageNestedEditorInClonedLexicalNode(s,p){let t=s.getKey();t!==p.getKey()&&this._isNestedEditorManaged(t)&&(this.gcNestedEditorListenerInLexicalNode(s),this.manageNestedEditorInLexicalNode(p))}setNestedEditorSelection(s){let{nestedSelectionJSON:p,nestedEditor:t}=$e.getNestedSelectionJSONFromMainSelectionJSON(s);if(!t)return!1;let f=!0;return t.update(()=>{try{let r=$e.JSONToLexical(p);(0,_e.$setSelection)(r),ue.debug("[setNestedEditorSelection]: lexical nested selection: ",r)}catch(r){ue.error("[setNestedEditorSelection] set nested selection error: ",r),f=!1}}),f}clearListeners(){for(let s in this.nestedEditorsListenersMap){let p=this.nestedEditorsListenersMap[s];p&&p(),delete this.nestedEditorsListenersMap[s]}}}const kE=new CE,gi=kE,OE=function(g){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let p=(0,_e.createEditor)({namespace:"validation",nodes:[...s],onError:e=>{throw e},parentEditor:null});const t=new By,f=p.parseEditorState(g);if(f.isEmpty())return;p.setEditorState(f);let r=p.getEditorState();const n=r._nodeMap[Symbol.iterator]();for(const e of n){let[l,i]=e;if(i&&(t.trackBlacklisted(i,to.created,r),t.isBlacklistedFound()))throw new Error(bS)}}catch(p){throw p}};class TE{constructor(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}_scanForCellHeaderState(s,p,t,f){if(p.length<f)return null;let r,n=p.some(l=>l.__headerState===Xi.BOTH||l.__headerState===Xi.ROW),e=s.some((l,i)=>{if(l.__size<f)return!1;let c=l.getChildAtIndex(t);return!(!c||c.__headerState!==Xi.BOTH&&c.__headerState!==Xi.COLUMN)});return n&&e?r=Xi.BOTH:n&&!e?r=Xi.ROW:e&&!n&&(r=Xi.COLUMN),r}_isValidCellChildren(s){for(let p of s)if($s(p)||!Us(p)&&Tn(p))return!1;return!0}_createEmptyCell(){let s=(0,Pn.$createTableCellNode)();return s.append((0,_e.$createParagraphNode)()),s}_wrapInvalidCellChildrenIntoParagraph(s){let p=(0,_e.$createParagraphNode)().getWritable(),t=s.getChildren();(s=s.getWritable()).__first=p.__key,s.__last=p.__key,s.__size=1,p.__parent=s.__key,t.forEach((f,r)=>{(f=f.getWritable()).__parent=null,p.append(f)})}_createFixAction_APPEND_CELLS_TO_ROW(s,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - APPEND_CELLS_TO_ROW] invoked: ",{rowKey:s,numOfCellsToAppend:p});let t=(0,_e.$getNodeByKey)(s);for(;p;){let f=(0,Pn.$createTableCellNode)().append((0,_e.$createParagraphNode)());f.setRowSpan(1).setColSpan(1),t.append(f),p--}}}_createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(s){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - ADD_PARAGRAPH_TO_EMPTY_CELL] invoked: ",{cellKey:s}),(0,_e.$getNodeByKey)(s).append((0,_e.$createParagraphNode)())}}_createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(s){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_CELL_CHILDREN_IN_PARAGRAPH] invoked: ",{cellKey:s});let p=(0,_e.$getNodeByKey)(s);this._wrapInvalidCellChildrenIntoParagraph(p)}}_createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(s){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - ADD_ROW_CELL_TO_EMPTY_TABLE_NODE] invoked: ",{tableKey:s});let p=(0,_e.$getNodeByKey)(s),t=(0,Pn.$createTableRowNode)();t.append(this._createEmptyCell()),p.append(t)}}_createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(s,p){return()=>{for(p||(p=1);p;)(0,_e.$getNodeByKey)(s).append(this._createEmptyCell()),p--}}_createFixAction_WRAP_INVALID_ROW_NODE(s,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_ROW_NODE] invoked: ",{tableKey:s,rowKey:p});let t=(0,_e.$getNodeByKey)(s);if(!t)return;let f=(0,_e.$getNodeByKey)(p);if(!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling();f.__parent=null,f.__prev=null,f.__next=null;let e=(0,Pn.$createTableRowNode)();if((0,Pn.$isTableCellNode)(f))f.getChildren().length?this._isValidCellChildren()||this._wrapInvalidCellChildrenIntoParagraph(f):f.append((0,_e.$createParagraphNode)()),e.append(f);else{let l=this._isValidCellChildren([f]),i=(0,Pn.$createTableCellNode)();if(e.append(i),l)i.append(f);else{let c=(0,_e.$createParagraphNode)();c.append(f),i.append(c)}}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(s,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_CELL_NODE] invoked: ",{rowKey:s,cellKey:p});let t=(0,_e.$getNodeByKey)(s);if(!t)return;let f=(0,_e.$getNodeByKey)(p);if(f.remove(),f=(0,_e.$createParagraphNode)(),!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling(),e=(0,Pn.$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 l=(0,_e.$createParagraphNode)();l.append(f),e.append(l)}}}_createFixAction_APPLY_HEADER_STATE_TO_CELL(s,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - APPLY_HEADER_STATE_TO_CELL] invoked: ",{cellKey:s,headerStateToApply:p});let t=(0,_e.$getNodeByKey)(s);t&&(t=t.getWritable(),t.__headerState=p)}}clear(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}tableRemoveEventListener(s){let p=Se.getMainEditorState()._selection;if(ue.debug(`[${s}]`,{selection:p}),!(0,_e.$isRangeSelection)(p))return;let t=[];try{let f=Se.getLexicalNodeByKey(p.anchor.key),r=Se.getLexicalNodeByKey(p.focus.key);f&&r&&(t=p.isBackward()?r.getNodesBetween(f):f.getNodesBetween(r))}catch(f){ue.warn("[TablesValidator][tableRemoveEventListener] get range selection nodes internal lexical error: ",f)}t.forEach(f=>{(0,Pn.$isTableNode)(f)&&this.removeCandidateTableKeys.add(f.__key)})}tableNodeRemoveListener(s){this.removeCandidateTableKeys.has(s)&&this.removeCandidateTableKeys.delete(s)}shouldGCRemovedTables(){return!!this.removeCandidateTableKeys.size}gcRemovedTables(){ue.debug("[TablesValidator][gcRemovedTable] candidate table keys ",{tableKeys:this.removeCandidateTableKeys}),Se.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(s=>{let p=(0,_e.$getNodeByKey)(s);p&&p.remove()}),this.removeCandidateTableKeys.clear(),(0,_e.$addUpdateTag)(uo.historic)})}tableUpdateListener(s){this.validateTableCandidateKeys.add(s)}tableRowNodeChangesListener(s){let p=arguments.length>1&&arguments[1]!==void 0&&arguments[1],t=Se.getLexicalNodeByKey(s);if(!t)return void(p&&ue.debug("[TablesValidator][tableRowNodeChangesListener] no row node found in lexical: ",{tableRowNodeKey:s}));let f=t.__parent;f?this.validateTableCandidateKeys.add(f):ue.debug("[tableRowNodeChangesListener] no parent table for row node found in lexical: ",{rowNode:t})}tableCellNodeChangesListener(s){let p=Se.getLexicalNodeByKey(s);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 s=Array.from(this.validateTableCandidateKeys);return Se.getMainEditorState().read(()=>{for(let p of s){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,c)=>{if(!(0,Pn.$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 d=[];n.forEach(m=>{let[h,y]=m;a+=y,h--,h&&d.push([h,y])}),n=[...d]}let u=o.map((d,m)=>{if(!(0,Pn.$isTableCellNode)(d))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_CELL_NODE(i.__key,d.__key)),a++,"invalid_cell_node_should_wrap_in_cell";let h,y=d.getChildren(),v=!y.length;if(v?this.tableFixActions.push(this._createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(d.__key)):(h=this._isValidCellChildren(y),h||this.tableFixActions.push(this._createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(d.__key))),d.__rowSpan>1){let _=d.__rowSpan,b=d.__colSpan;n.push([_-1,b])}if(a+=d.__colSpan,d.__headerState===Xi.NO_STATUS){let _=this._scanForCellHeaderState(f,o,m,r);_&&this.tableFixActions.push(this._createFixAction_APPLY_HEADER_STATE_TO_CELL(d.__key,_))}return{cellKey:d.__key,rowKey:i.__key,tableKey:p,colSpan:d.__colSpan,rowSpan:d.__rowSpan,headerState:d.__headerState,childrenAreValid:h,isEmptyCell:v}});if(a<r){let d=r-a;this.tableFixActions.push(this._createFixAction_APPEND_CELLS_TO_ROW(i.__key,d))}return{realRowLength:a,rowKey:i.__key,tableKey:p,cells:u}}),l=!this.tableFixActions.length;ue[l?"debug":"warn"](`[TablesValidator][validateUpdatedTables] IS TABLE VALID: ${l}`,{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 s=Se.getMainEditor();ue.log("[TablesValidator][fixTablesStructure]: fix actions to apply - count: ",this.tableFixActions.length),s.update(()=>{for(let p of this.tableFixActions)p();this.tableFixActions=[],(0,_e.$addUpdateTag)(uo.historic)})}ensureDocTablesAreValid(s){return this.shouldGCRemovedTables()?(ue.warn("[TablesValidator][GARBAGE COLLECT TABLE NODES AFTER TABLE REMOVAL ATTEMPT]"),this.gcRemovedTables(),!1):!(this.shouldValidateUpdatedTables()&&(ue.debug("[TablesValidator][shouldValidateUpdatedTables] invoked"),!this.validateUpdatedTables()))||(ue.warn("[TablesValidator][shouldValidateUpdatedTables] INVALID LEXICAL TABLE(S) STRUCTURE FOUND - FIXING",{state:JSON.parse(JSON.stringify(s.toJSON()))}),this.fixTablesStructure(),!1)}}const Fo=new TE,AE=["contentChanged"],PE=["state","remoteSelection"];function Fy(g,s){var p=Object.keys(g);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(g);s&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(g,f).enumerable})),p.push.apply(p,t)}return p}function Fs(g){for(var s=1;s<arguments.length;s++){var p=arguments[s]!=null?arguments[s]:{};s%2?Fy(Object(p),!0).forEach(function(t){jE(g,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(p)):Fy(Object(p)).forEach(function(t){Object.defineProperty(g,t,Object.getOwnPropertyDescriptor(p,t))})}return g}function jE(g,s,p){return(s=NE(s))in g?Object.defineProperty(g,s,{value:p,enumerable:!0,configurable:!0,writable:!0}):g[s]=p,g}function NE(g){var s=IE(g,"string");return typeof s=="symbol"?s:s+""}function IE(g,s){if(typeof g!="object"||!g)return g;var p=g[Symbol.toPrimitive];if(p!==void 0){var t=p.call(g,s||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(g)}function zy(g,s){if(g==null)return{};var p,t,f=RE(g,s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(g);for(t=0;t<r.length;t++)p=r[t],s.indexOf(p)>=0||{}.propertyIsEnumerable.call(g,p)&&(f[p]=g[p])}return f}function RE(g,s){if(g==null)return{};var p={};for(var t in g)if({}.hasOwnProperty.call(g,t)){if(s.indexOf(t)>=0)continue;p[t]=g[t]}return p}const jp={DEBUG:!1,VERSION:"1.0.2",NAME:"@codoxhq/lexical-provider",SDKUI_SOURCE_PATH:"../../../sdkui/dist-production2/codox.bundle.js"}.LOCAL==="true";ue.info("MODE: ","production");const ME=g=>async()=>{const{state:s,timestamp:p}=await g();if(!Se.isValidJSONState(s))throw new Error("Invalid state received from fetchDocOnNetworkReconnect hook");const{commentThreads:t,root:f}=s,r={content:{comments:t,root:f},timestamp:p};return ue.info("[decorateFetchOnReconnctHook] hook invoked: ",{returnObj:r}),r};let Qu=0,mi=null,Np=!1,To={},Ip={};const DE=(0,Gt.forwardRef)((g,s)=>{let{onBlacklistedInsert:p}=g;const t=(0,Gt.useContext)(ta.LexicalComposerContext);if(!t)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[f]=(0,ta.useLexicalComposerContext)(),r=(0,Ly.useCollaborationContext)();(0,Gt.useEffect)(()=>{if(ue.debug("[INIT] lexical context check: ",{lexicalContext:t,editor:f}),!f)return;ue.log("[useEffect][editor] Editor instance changed: ",{editor:f,key:f._key}),Se.setMainEditor(f),In.gcAbandonedNodes(),gi.gc(),Fo.clear(),ue.log("[useEffect][editor] subscribe to editor changes");const v=(0,Ds.mergeRegister)(f.registerUpdateListener(m),f.registerCommand(_e.PASTE_COMMAND,vE,_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.UNDO_COMMAND,()=>{Se.setUndoInvoked(!0)},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.REDO_COMMAND,()=>{Se.setRedoInvoked(!0)},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.KEY_DELETE_COMMAND,(b,w)=>{Fo.tableRemoveEventListener("KEY_DELETE_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.KEY_BACKSPACE_COMMAND,(b,w)=>{Fo.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.CUT_COMMAND,(b,w)=>{Fo.tableRemoveEventListener("CUT_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),...h());Oo.mount(),Se.alignStateSelectionJSONsFromLatestEditor(),ue.debug("New editor mounted: ",{isCodoxStarted:Se.isCodoxStarted,codoxLexicalEditorManager:Se,nestedEditorsProcessor:gi});let _=f._onError;return f._onError=b=>{ue.error("[ERROR HANDLER WRAPPER] error from editor: ",b),_&&_(b),d()},p&&ea.setClientCallback(p),()=>{Se.getMainEditorKey()&&(ue.debug("Unmount prev editor"),v(),Se.removeMainEditor(),Oo.unmount(),Se.clearJSONs(),On.clear(),Fo.clear(),Se.isCodoxStarted&&(ue.debug("EDITOR USE_EFFECT stopping codox"),n(),Se.setIsCodoxStarted(!1)),ea.removeClientCallback())}},[f]);const n=()=>{Se.isCodoxStarted&&(ue.log("[stopCodoxInstance] stopping codox"),Se.setIsCodoxStarted(!1),jp||li().stop(),Se.clearJSONs(),In.clearAll(),Oo.clear(),On.resetComments(),gi.clearListeners())},e=async v=>{ue.debug("[startCodoxInstance] invoked"),li().createNewInstance(),ue.debug("[startCodoxInstance] instance created");for(let T in Ip)li().instance.on(T,Ip[T]);if(ue.debug("[startCodoxInstance] events subscribed"),To=v,mi=To.docId,!mi)return ue.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:mi});let _=On.initialCommentsExist();ue.debug("[startCodoxInstance] initCommentsExist: ",_),_&&(On.activateInitialComments(f,In),ue.log("[activateInitialComments] "));let b=Se.getMainEditorState().toJSON();if(!Se.isValidJSONState(b))throw ue.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:mi,initJSONState:b}),new Error("start codox skipped - invalid init state");ue.log("[startCodoxInstance] starting codox with: ",{docId:mi,initJSONState:b,config:To,codoxComments:On}),Se.currentContentStateJSON||Se.setCurrentContentStateJSON(b),Se.isCodoxStarted&&n();let{username:w,apiKey:x,getServerState:S,domain:C="",demo:k=!1,hooks:D}=To;D&&D.fetchDocOnNetworkReconnect&&(D.fetchDocOnNetworkReconnect=ME(D.fetchDocOnNetworkReconnect));const I=zy(D,AE);await li().start(li().createConfig(Fs(Fs({},To),{},{docId:mi,username:w,apiKey:x,domain:C,hooks:Fs({syncState:c,getState:i,getServerState:async()=>await S(mi)},I),editorInstanceHooks:{getSelection:()=>Se.getCurrentActiveSelectionJSON(),setSelection:T=>o(T),getState:i,setState:T=>{const{root:R,comments:P}=T;ue.info("DEBUG: EDITOR INSTANCE setState:",{fullState:T}),a({state:{root:R},selection:Se.getCurrentActiveSelectionJSON()},Oo.getCurrentRemoteSelections()),On.setAllComments(P)},enableEditor:()=>{Se.disableEditorReadOnlyMode()},disableEditor:()=>{Se.enableEditorReadOnlyMode(),Oo.updateRemoteSelections([])},getContent:()=>{let T=Se.composeFullStateWithRootAndComments();return ue.info("[getContent]: ",T),{state:T}}},appServer:To.appServer,demo:k}))),ue.log("[startCodoxInstance] codox started - first sync invoking"),Se.setIsCodoxStarted(!0),r.clientID=To.username,r.name=To.username,u()},l=()=>{let v=Se.composeFullStateWithRootAndComments({directlyFromEditor:!0});e(v)},i=()=>({state:Fs(Fs({},Se.getMainEditorState().toJSON()),{},{comments:On.getAllComments()}),docId:mi}),c=v=>{if(!Se.isCodoxStarted)return;ue.log("[SYNC_STATE]: Before sync payload = ",v);const _=li().sync({meta:v}),{state:b,remoteSelection:w=[]}=_,x=zy(_,PE);if(ue.log("[SYNC_STATE]: After sync",{state:b,remoteSelection:w,rest:x}),!b)return ue.error("[SYNC_STATE] abort apply - synced state is not valid - restarting codox"),l();const S=b.state;ue.log("[SYNC_STATE] synced state: ",{synced:JSON.parse(JSON.stringify(S))});let{stateFromSync:C,commentsFromSync:k}=Se.extractStateAndCommentsFromSynced(S);if(!Se.isValidJSONState(C.state))return ue.error("[SYNC_STATE] - invalid state from sync - local update skipped - restarting codox",{contentState:C.state}),l();a(C,w),On.setAllComments(k)},o=v=>{if(!Se.isCodoxStarted||(ue.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:v}),!Pp.validateJSONSelection(v,kp.local)))return;let _=Se.getCurrentActiveSelectionJSON();if($e.equalSelectionsJSON(_,v))return void ue.log("[setLocalSelectionFromSync] STOP - local and synced selections are equal");let b=$e.isNestedSelectionJSON(v);f.update(()=>{ue.log("[setLocalSelectionFromSync] json selection to apply: ",{syncedSelectionJSON:v});const w=$e.JSONToLexical(v);if(ue.log("[setLocalSelectionFromSync] lexical selection to apply: ",w),b){let x=gi.setNestedEditorSelection(v);Se.setNestedSelectionJSON(x?v:null)}else(0,_e.$setSelection)(w),Se.setMainSelectionJSON(v);ue.log("[setLocalSelectionFromSync] selection updated. latest selection: ",{latestSelectionJSON:Se.getCurrentActiveSelectionJSON()})})},a=function(){let{state:v,selection:_,stateReplace:b}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",S=Se.getCurrentContentStateJSON();ue.log("[updateEditor] invoked: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:JSON.parse(JSON.stringify(v)),newSelectionJSON:_,remoteSelection:w,stateReplace:b,editor:f}),_===void 0&&ue.error("SELECTION FROm SYNC IS UNDEFINED - will default prev selection",_);const C=Ap(S,v),k=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),_);f.update(()=>{if(Se.addUpdateTag({isSameState:C,isSameSelection:k,updateTag:x}),b)ue.log("[updateEditor] invoke full stateReplace after sync"),Dy(v),S=Se.setCurrentContentStateJSON(v),(0,_e.$addUpdateTag)("codox_sync_state_changes"),ue.log("[updateEditor] state updated: ",S);else{ue.log("[updateEditor] invoke deltas diff");let I=li().diff(S,v,{keyNames:{default:"codoxId"}});ue.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:v,deltas:I&&JSON.parse(JSON.stringify(I))}),I&&I.length&&(ue.log("[updateEditor] apply deltas to lexical state"),yE(v,I),S=Se.setCurrentContentStateJSON(v),(0,_e.$addUpdateTag)("codox_sync_state_changes"),ue.log("[updateEditor] state updated: ",S))}let D=$e.isNestedSelectionJSON(_);if(Pp.validateJSONSelection(_,kp.local)||(_=Se.getCurrentActiveSelectionJSON()),D){let I=gi.setNestedEditorSelection(_);Se.setNestedSelectionJSON(I?_:null),ue.log("[updateEditor] nested selection updated",I?_:null)}else if(_!==void 0){const I=$e.JSONToLexical(_);ue.log("[updateEditor] updated selection to apply: ",{isSameSelection:k,newSelectionJSON:_,lexicalSelection:I}),(0,_e.$setSelection)(I),Se.setMainSelectionJSON(_),ue.log("[updateEditor] selection updated",_)}},{onUpdate:()=>{C||Oo.updateRemoteSelections(w,"from onUpdate hook")}}),C&&Oo.updateRemoteSelections(w,"from direct updateEditor")},u=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";if(!Se.isCodoxStarted)return;ue.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:v});let _=Se.composeFullStateWithRootAndComments();const b={docId:mi,state:{state:_,selection:Se.getCurrentActiveSelectionJSON()}};ue.log("[codoxSync]: Before sync",{local:b,upd_call_counter:v}),ue.log("[codoxSync]: Before sync state",JSON.parse(JSON.stringify(b.state)));let{state:w,remoteSelection:x=[],changes:S}=li().sync({state:b,meta:{}});if(ue.log("[codoxSync]: After sync",{afterSyncState:JSON.parse(JSON.stringify(w)),remoteSelection:x,changes:S}),!w)return ue.error("[codoxSync] abort apply - synced state is not valid - restarting codox "),l();const C=w.state;ue.log("[codoxSync]: synced state: ",JSON.parse(JSON.stringify(C)),v);let{stateFromSync:k,commentsFromSync:D}=Se.extractStateAndCommentsFromSynced(C);if(!Se.isValidJSONState(k.state))return ue.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:k.state}),l();a(k,x),On.setAllComments(D)},d=()=>{ue.warn("[rollbackStateDuringUpdateError] rollback invoked"),ue.log("[rollbackStateDuringUpdateError] values: ",{prevState:Se.getPrevContentStateJSON(),currentState:Se.getCurrentContentStateJSON(),prevSelection:Se.getPrevMainSelectionJSON(),currentSelection:Se.getCurrentActiveSelectionJSON(),codoxComments:On});let v=Se.getPrevContentStateJSON(),_=Se.getPrevMainSelectionJSON();a({state:v,selection:_},Oo.getCurrentRemoteSelections(),uo.historic);let b=Se.undoInvoked(),w=Se.redoInvoked();On.gcAbandonedNodeKeys(Se.getMainEditorState()._nodeMap),b&&f.dispatchCommand(_e.CAN_REDO_COMMAND,!1),w&&f.dispatchCommand(_e.CAN_UNDO_COMMAND,!1)},m=v=>{let{editorState:_,prevEditorState:b,tags:w,dirtyElements:x,dirtyLeaves:S}=v;if(Np)return Np=!1,void ue.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(ea.isBlacklistedFound())return Np=!0,ue.warn("[editorUpdatesListener] BLACKLISTED CHANGES FOUND - revert back to prev state"),((J,G)=>{let z=null,F=null;G.read(()=>{z=$e.lexicalToJSON(G._selection),F=G.toJSON()});let O=null,j=null;J.read(()=>{let L=(0,_e.$getSelection)();j=$e.lexicalToJSON(L),O=J.toJSON()}),Se.setCurrentContentStateJSON(O),Se.setMainSelectionJSON(j),a({state:F,selection:z},Oo.getCurrentRemoteSelections(),uo.historic),f.dispatchCommand(_e.CAN_REDO_COMMAND,!1),f.dispatchCommand(_e.CAN_UNDO_COMMAND,!1)})(_,b),void ea.invokeClientCallback();if(!Fo.ensureDocTablesAreValid(_))return;Qu++,ue.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:Qu,isCodoxStarted:Se.isCodoxStarted});let C=Se.isOnlySelectionChanged(x,S),k=null,D=null,I=null,T=null,R=Se.getCurrentContentStateJSON(),P=w.has("codox_sync_state_changes"),$=w.has(sc),q=Se.undoInvoked(),H=Se.redoInvoked(),M=Se.canUndo(),W=Se.canRedo();k=_.toJSON(),D=b.toJSON(),b.read(()=>{T=$e.lexicalToJSON(b._selection)}),_.read(()=>{let J=(0,_e.$getSelection)();I=$e.lexicalToJSON(J);let G=$e.JSONToLexical(I),z=J===null&&G===null||J.is(G);ue.log("[editorUpdatesListener] new values: ",{newContentStateJSON:k,currentContentStateJSON:JSON.parse(JSON.stringify(R)),prevContentStateJSON:JSON.parse(JSON.stringify(D)),currentCommentsJSON:JSON.parse(JSON.stringify(On.getAllComments())),newSelectionJSON:JSON.parse(JSON.stringify(I)),currentMainSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentMainSelectionJSON())),currentNestedSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentNestedSelectionJSON())),currentActiveSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentActiveSelectionJSON())),lexicalSelection:J,convertedBackMainSelection:G,isMainSelectionConvertionCorrect:z,nodes:f._editorState._nodeMap,fullEditor:f,codoxNodesMap:In.toArray(),codoxComments:On,isUpdateFromSync:P,isUpdateFromComments:$,tags:w,onlySelectionChanged:C,undoInvoked:q,redoInvoked:H,canUndo:M,canRedo:W})});let V=Ap(R,k),A=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),I);ue.log("[editorUpdatesListener] compares: ",{isStateSame:V,isSelectionSame:A});let U=V&&A&&!$;if(!V||$||P){let J=Fs({},V?R:k),G=On.getAllComments();G.length&&(J.commentThreads=G);let z={source:P?vy.remote:vy.local,content:J};To.hooks&&To.hooks.contentChanged&&To.hooks.contentChanged(z),li().instance.emit("content_changed",z)}if(U)ue.log("[editorUpdatesListener] STOP - state and selection and comments are same ",Qu);else if(Se.undoInvoked()&&Se.setUndoInvoked(!1),Se.redoInvoked()&&Se.setRedoInvoked(!1),Se.setCurrentContentStateJSON(k),Se.setPrevContentStateJSON(D),Se.setMainSelectionJSON(I),Se.setPrevMainSelectionJSON(T),jp){let J=Se.getCurrentActiveSelectionJSON();a({state:Se.getCurrentContentStateJSON(),selection:J},[])}else u(Qu)},h=()=>{let v=[];return Se.getMainEditorNodesClassesMap().forEach((_,b,w)=>{let{klass:x}=_,S=f.registerMutationListener(x,C=>{for(let[k,D]of C){if(!to[D])continue;const I=Se.getLexicalNodeByKey(k);if(D===to.created&&I&&ea.trackBlacklisted(I,D),x.name===Pn.TableNode.name&&(D===to.destroyed?Fo.tableNodeRemoveListener(k):Fo.tableUpdateListener(k)),x.name===Pn.TableRowNode.name&&D!==to.destroyed&&Fo.tableRowNodeChangesListener(k,D===to.updated),x.name===Pn.TableCellNode.name&&D===to.updated&&Fo.tableCellNodeChangesListener(k),x.name===co.MarkNode.name&&(ue.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:k,node:I,mutationType:D,codoxComments:On}),D===to.destroyed?On.removeRelatedNodeKey(k):I&&On.addRelatedNodeKey(I.__key,I.__ids,D===to.created)),I&&I.codoxId){if(D===to.destroyed)return void(I.codoxId&&In.remove(I.codoxId));Ky(I)||ue.warn("[MutationListener Error] duplicating codoxId detected - such codoxId already exists in codoxNodesMap - updating node ref to latest: ",{mutationType:D,node:I}),In.add(I.codoxId,I)}}v.push(S)})}),v},y={start:e,stop:n,on:(v,_)=>{ue.info(`Subscribing client to codox ${v} event`),Ip[v]=_},cursor:{hide:()=>{Oo.hideRemoteSelectionsFromUI()},show:()=>{Oo.showHiddenRemoteSelectionsInUI()}},initComments:v=>{On.setInitialComments(v)}};return(0,Gt.useImperativeHandle)(s,()=>y),null}),LE=DE,BE=["comments"];function Uy(g,s){var p=Object.keys(g);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(g);s&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(g,f).enumerable})),p.push.apply(p,t)}return p}function Rp(g){for(var s=1;s<arguments.length;s++){var p=arguments[s]!=null?arguments[s]:{};s%2?Uy(Object(p),!0).forEach(function(t){FE(g,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(p)):Uy(Object(p)).forEach(function(t){Object.defineProperty(g,t,Object.getOwnPropertyDescriptor(p,t))})}return g}function FE(g,s,p){return(s=zE(s))in g?Object.defineProperty(g,s,{value:p,enumerable:!0,configurable:!0,writable:!0}):g[s]=p,g}function zE(g){var s=UE(g,"string");return typeof s=="symbol"?s:s+""}function UE(g,s){if(typeof g!="object"||!g)return g;var p=g[Symbol.toPrimitive];if(p!==void 0){var t=p.call(g,s||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(g)}function $E(g,s){if(g==null)return{};var p,t,f=HE(g,s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(g);for(t=0;t<r.length;t++)p=r[t],s.indexOf(p)>=0||{}.propertyIsEnumerable.call(g,p)&&(f[p]=g[p])}return f}function HE(g,s){if(g==null)return{};var p={};for(var t in g)if({}.hasOwnProperty.call(g,t)){if(s.indexOf(t)>=0)continue;p[t]=g[t]}return p}class qE extends gy{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(s){this._canUndo=s}setCanRedo(s){this._canRedo=s}canUndo(){return this._canUndo}canRedo(){return this._canRedo}setUndoInvoked(s){this._undoInvoked=s}setRedoInvoked(s){this._redoInvoked=s}undoInvoked(){return this._undoInvoked}redoInvoked(){return this._redoInvoked}setIsCodoxStarted(){let s=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this._isCodoxStarted=s}get isCodoxStarted(){return this._isCodoxStarted}getMainEditorKey(){return this.mainEditorKey}setMainEditor(s){this.mainEditor=s,this.mainEditorKey=s._key}clearJSONs(){ue.debug("[CodoxLexicalEditorManager][clearJSONs] invoked"),this.currentContentStateJSON=null,this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null,this.prevContentStateJSON=null,this.prevMainSelectionJSON=null}removeMainEditor(){this.mainEditor=null,this.mainEditorKey=null,this._undoInvoked=!1,this._redoInvoked=!1,this._canUndo=!1,this._canRedo=!1,super.clear()}getMainEditor(){return this.mainEditor}alignStateSelectionJSONsFromLatestEditor(){this.getMainEditorState().read(()=>{this.setCurrentContentStateJSON(this.getMainEditorState().toJSON()),this.setMainSelectionJSON($e.lexicalToJSON((0,_e.$getSelection)()))})}mainEditorExists(){return!!this.mainEditor}getMainEditorState(){return this.mainEditor?this.mainEditor.getEditorState():{}}getMainEditorNodesClassesMap(){return this.mainEditor?this.mainEditor._nodes:new Map}getLexicalNodeByKey(s){return this.mainEditor?this.getMainEditorState()._nodeMap.get(s):null}isLexicalEditorInstance(s){return s&&typeof s=="object"&&!!s.setEditorState}setCurrentContentStateJSON(s){return this.currentContentStateJSON=s,this.currentContentStateJSON}getCurrentContentStateJSON(){return this.currentContentStateJSON}setPrevContentStateJSON(s){this.prevContentStateJSON=s}getPrevContentStateJSON(){return this.prevContentStateJSON}setMainSelectionJSON(s){this.currentMainSelectionJSON=s,this.currentMainSelectionJSON&&this.currentNestedSelectionJSON&&(this.currentNestedSelectionJSON=null)}setNestedSelectionJSON(s){this.currentNestedSelectionJSON=s,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(s){this.prevMainSelectionJSON=s}getPrevMainSelectionJSON(){return this.prevMainSelectionJSON}extractStateAndCommentsFromSynced(s){let{state:{comments:p},selection:t,stateReplace:f}=s;return{stateFromSync:{state:Rp({},$E(s.state,BE)),selection:t,stateReplace:f},commentsFromSync:p}}composeFullStateWithRootAndComments(){let{directlyFromEditor:s=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Rp(Rp({},s?this.getMainEditorState().toJSON():this.currentContentStateJSON),{},{comments:On.getAllComments()})}isValidJSONState(s){let p=!1;try{if(!s)throw new Error("State is undefined");if(!s.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,l=t.get(e.type);if(!l)throw new Error(`Node with type "${e.type}" is not registered in editor`);let{klass:i}=l;if(n==="root"){let c=i.prototype instanceof _e.ElementNode,o=i.prototype instanceof _e.DecoratorNode;if(!c&&!o)throw new Error("State root node can have only element nodes as children")}if(e.children)for(let c of e.children)f(c,e.type)};f(s.root),p=!0}catch(t){ue.error("[isValidJSONState] invalid state found: ",t.message),p=!1}return p}scanLexicalNodeForNestedEditorAttribute(s){for(let p in s){let t=s[p];if(this.isLexicalEditorInstance(t))return p}return""}isOnlySelectionChanged(s,p){return s.size===0&&p.size===0}addUpdateTag(){let{isSameState:s,isSameSelection:p,fromNestedEditor:t=!1,updateTag:f=""}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return f?(ue.log(`[addUpdateTag] explicit add of tag "${f}" `),void(0,_e.$addUpdateTag)(f)):t?(ue.log(`[addUpdateTag] add "${uo.historic}" tag - change invoked by nested editor`),void(0,_e.$addUpdateTag)(uo.historic)):void(s?(ue.log(`[addUpdateTag] add "${uo.historic}" tag - state is same`),(0,_e.$addUpdateTag)(uo.historic)):(ue.log(`[addUpdateTag] add "${uo.historyMerge}" tag - state is different`),(0,_e.$addUpdateTag)(uo.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const WE=new qE,Se=WE;class JE{constructor(){this._nodesMap=new Map,this._pastedNodesCodoxIds=new Set}get size(){return this._nodesMap.size}add(s,p){this._nodesMap.set(s,p)}get(s){return this._nodesMap.get(s)||null}remove(s){this._nodesMap.delete(s)}has(s){return this._nodesMap.has(s)}nodesToArray(){return Array.from(this._nodesMap.values())}keysToArray(){return Array.from(this._nodesMap.keys())}toArray(){return Array.from(this._nodesMap.entries())}addPastedId(s){this._pastedNodesCodoxIds.add(s)}removePastedId(s){this._pastedNodesCodoxIds.delete(s)}hasPastedId(s){return this._pastedNodesCodoxIds.has(s)}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 s=Se.getMainEditorState();if(!s._nodeMap)return;let p=this.nodesToArray();for(let t of p)s._nodeMap.has(t.__key)||this.remove(t.codoxId)}}const VE=new JE,In=VE;function $y(g,s){var p=Object.keys(g);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(g);s&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(g,f).enumerable})),p.push.apply(p,t)}return p}function Hy(g){for(var s=1;s<arguments.length;s++){var p=arguments[s]!=null?arguments[s]:{};s%2?$y(Object(p),!0).forEach(function(t){KE(g,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(p)):$y(Object(p)).forEach(function(t){Object.defineProperty(g,t,Object.getOwnPropertyDescriptor(p,t))})}return g}function KE(g,s,p){return(s=GE(s))in g?Object.defineProperty(g,s,{value:p,enumerable:!0,configurable:!0,writable:!0}):g[s]=p,g}function GE(g){var s=YE(g,"string");return typeof s=="symbol"?s:s+""}function YE(g,s){if(typeof g!="object"||!g)return g;var p=g[Symbol.toPrimitive];if(p!==void 0){var t=p.call(g,s||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(g)}const Mp=()=>oS(),qy=g=>typeof g=="number";function zs(g){let s=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 g.apply(this,f)};return Object.defineProperty(p,"name",{value:s,writable:!0}),p}const Ba=g=>g.__type==="root"||g.type==="root",Wy=g=>Ba(g.getParent()),Kn=g=>g.__type===Vu.text||g.type===Vu.text||g.hasOwnProperty("__text")||g.hasOwnProperty("text"),Us=g=>(0,_e.$isElementNode)(g),$s=g=>(0,Pn.$isTableNode)(g)||(0,Pn.$isTableRowNode)(g)||(0,Pn.$isTableCellNode)(g),ZE=g=>!g.getChildren,Jy=g=>!!g.getChildren,Tn=g=>(0,_e.$isDecoratorNode)(g),cc=g=>(0,Yw.$isLinkNode)(g),uc=g=>g.__type==="mark"||g.type==="mark",Dp=g=>(0,_e.$isLineBreakNode)(g),na=g=>Kn(g)||Dp(g),Lp=g=>g.__type===Vu.horizontalrule||g.type===Vu.horizontalrule,Vy=g=>{if(na(g)||cc(g)||uc(g))return!1;if(!g.__parent||g.__parent==="root"||(0,_e.$isParagraphNode)(g))return!0;let s=g.getParent().getChildren();return s.length===1&&s[0].__key===g.__key?!((Tn(g)||cc(g)||uc(g))&&!Lp(g)):!s.some(p=>{let t=Lp(p);return p.__key!==g.__key&&(na(p)||Tn(p)&&!t||cc(p)||uc(p))})},Ky=g=>{const s=In.get(g.codoxId);return!s||g.__key===s.__key},Hs=function(g){const s=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||Mp();g.codoxId=s,In.add(s,g)},Gy=g=>{In.remove(g.codoxId),delete g.codoxId},XE=g=>{if(!Jy(g)||!g.getChildrenSize())return;const s=g.getChildren();if(s.some(f=>!!(0,_e.$isParagraphNode)(f)))return;let p=!1,t=[];for(let f of s)(na(f)||Tn(f)||cc(f)||uc(f))&&!p&&(Lp(f)||(p=!0)),(Jy(f)||Tn(f))&&t.push(f);for(let f of t)p||f.codoxId?p&&f.codoxId&&(f=f.getWritable(),Gy(f)):(f=f.getWritable(),Hs(f))},QE=g=>{const s=Hy({},g);for(const p in g)g[p]===void 0&&g.hasOwnProperty(p)&&delete s[p];return s},t2=g=>{const s=`__nativeCreateDOM_${g.name}`;g.prototype[s]=zs(g.prototype.createDOM,s),g.prototype.createDOM=function(p,t){if(Vy(this))if(this.codoxId){if(!Ky(this)){let r=In.get(this.codoxId);r.__type===this.__type&&this.isAttached()&&!r.isAttached()?(ue.warn("[createDOM][Non-unique codoxId] overwrite abandoned existing node with latest: ",{latestNode:this,existingNode:r}),In.add(this.codoxId,this)):Hs(this)}}else Hs(this);else this.codoxId&&Gy(this);Tn(this)&&!this.codoxDId&&(this.codoxDId=Mp()),gi.manageNestedEditorInLexicalNode(this);let f=this[s](p,t);return f.__codox_track=!0,f}},e2=g=>{const s=`__nativeUpdateDOM_${g.name}`;return g.prototype[s]=zs(g.prototype.updateDOM,s),g.prototype.updateDOM=function(){const p=this[s](...arguments);return XE(this),p},g},n2=g=>{const s=`__nativeRemove_${g.name}`;return g.prototype[s]=zs(g.prototype.remove,s),g.prototype.remove=function(){const p=this.codoxId;return p&&In.remove(p),gi.gcNestedEditorListenerInLexicalNode(this),this[s](...arguments)},g},r2=g=>{const s=`__nativeExportJSON_${g.name}`;g.prototype[s]=zs(g.prototype.exportJSON,s),g.prototype.exportJSON=function(){const p=this[s]();return this.codoxId&&(p.codoxId=this.codoxId),this.codoxDId&&(p.codoxDId=this.codoxDId),Kn(this)&&qy(p.format)&&this.hasFormat&&(p.format=gS(this)),QE(p)}},o2=g=>{const s="__nativeImportJSON";g[s]=zs(g.importJSON,s),g.importJSON=function(p){const t=Hy({},p);Kn(t)&&!qy(t.format)&&(t.format=hS(t.format));const f=g[s](t);gi.manageNestedEditorInLexicalNode(f);const r=Vy(f);return r&&t.codoxId&&(In.hasPastedId(t.codoxId)&&In.has(t.codoxId)?(In.removePastedId(t.codoxId),Hs(f)):Hs(f,t.codoxId)),r&&!f.codoxId&&Hs(f),t.codoxDId&&(f.codoxDId=t.codoxDId),f}},i2=g=>{const s="__nativeClone";g[s]=zs(g.clone,s),g.clone=function(p){const t=g[s](p);return p.codoxId&&(t.codoxId=p.codoxId),p.codoxDId&&(t.codoxDId=p.codoxDId),gi.manageNestedEditorInClonedLexicalNode(p,t),t}},a2=g=>{let s=!1,p=!1,t=!1,f=!1;g.forEach(n=>{n.name===_e.TextNode.name?s=!0:n.name===_e.ParagraphNode.name?p=!0:n.name===_e.LineBreakNode.name?t=!0:n.name===co.MarkNode.name&&(f=!0)});let r=[];return s||r.push(_e.TextNode),p||r.push(_e.ParagraphNode),t||r.push(_e.LineBreakNode),f||r.push(co.MarkNode),r.length?[...r,...g]:g},s2=function(){return a2(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(g=>(g.hasOwnProperty("__isCodoxExtended")||(t2(g),e2(g),r2(g),n2(g),o2(g),i2(g),Object.defineProperty(g,"__isCodoxExtended",{value:!0,writable:!1})),g))};var td=on(777),qs={};qs.styleTagTransform=hi(),qs.setAttributes=fi(),qs.insert=di().bind(null,"head"),qs.domAPI=ui(),qs.insertStyleElement=pi(),ci()(td.A,qs),td.A&&td.A.locals&&td.A.locals;var l2=g=>{var s={};return on.d(s,g),s};const c2=l2({AutoFocusPlugin:()=>r0});var u2=g=>{var s={};return on.d(s,g),s};const d2=u2({ClearEditorPlugin:()=>Iw});var f2=g=>{var s={};return on.d(s,g),s};const p2=f2({LexicalComposer:()=>n0});var h2=g=>{var s={};return on.d(s,g),s};const Yy=h2({default:()=>Mw});var g2=g=>{var s={};return on.d(s,g),s};const m2=g2({HistoryPlugin:()=>_0});var y2=g=>{var s={};return on.d(s,g),s};const v2=y2({OnChangePlugin:()=>Lw});var b2=g=>{var s={};return on.d(s,g),s};const _2=b2({PlainTextPlugin:()=>Ww});var x2=g=>{var s={};return on.d(s,g),s};const Zy=x2({$isRootTextContentEmpty:()=>w0,$rootTextContent:()=>x0});var w2=g=>{var s={};return on.d(s,g),s};const Ws=w2({createPortal:()=>i_.createPortal}),S2=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,E2=S2?Gt.useLayoutEffect:Gt.useEffect,Xy=E2;var ed=on(253),Js={};Js.styleTagTransform=hi(),Js.setAttributes=fi(),Js.insert=di().bind(null,"head"),Js.domAPI=ui(),Js.insertStyleElement=pi(),ci()(ed.A,Js),ed.A&&ed.A.locals&&ed.A.locals;function C2(g){let{onClose:s,children:p,title:t,closeOnClickOutside:f}=g;const r=(0,Gt.useRef)(null);return(0,Gt.useEffect)(()=>{r.current!==null&&r.current.focus()},[]),(0,Gt.useEffect)(()=>{let n=null;const e=c=>{c.key==="Escape"&&s()},l=c=>{const o=c.target;r.current!==null&&!r.current.contains(o)&&f&&s()},i=r.current;return i!==null&&(n=i.parentElement,n!==null&&n.addEventListener("click",l)),window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),n!==null&&(n==null||n.removeEventListener("click",l))}},[f,s]),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:s},"X"),Gt.createElement("div",{className:"Modal__content"},p)))}function k2(g){let{onClose:s,children:p,title:t,closeOnClickOutside:f=!1}=g;return(0,Ws.createPortal)(Gt.createElement(C2,{onClose:s,title:t,closeOnClickOutside:f},p),document.body)}function Qy(){const[g,s]=(0,Gt.useState)(null),p=(0,Gt.useCallback)(()=>{s(null)},[]),t=(0,Gt.useMemo)(()=>{if(g===null)return null;const{title:r,content:n,closeOnClickOutside:e}=g;return Gt.createElement(k2,{onClose:p,title:r,closeOnClickOutside:e},n)},[g,p]),f=(0,Gt.useCallback)(function(r,n){s({closeOnClickOutside:arguments.length>2&&arguments[2]!==void 0&&arguments[2],content:n(p),title:r})},[p]);return[t,f]}var nd=on(191),Vs={};Vs.styleTagTransform=hi(),Vs.setAttributes=fi(),Vs.insert=di().bind(null,"head"),Vs.domAPI=ui(),Vs.insertStyleElement=pi(),ci()(nd.A,Vs),nd.A&&nd.A.locals&&nd.A.locals;const O2={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"}},T2=O2;var rd=on(72),Ks={};Ks.styleTagTransform=hi(),Ks.setAttributes=fi(),Ks.insert=di().bind(null,"head"),Ks.domAPI=ui(),Ks.insertStyleElement=pi(),ci()(rd.A,Ks),rd.A&&rd.A.locals&&rd.A.locals;function A2(){for(var g=arguments.length,s=new Array(g),p=0;p<g;p++)s[p]=arguments[p];return s.filter(Boolean).join(" ")}function Bp(){return Bp=Object.assign?Object.assign.bind():function(g){for(var s=1;s<arguments.length;s++){var p=arguments[s];for(var t in p)({}).hasOwnProperty.call(p,t)&&(g[t]=p[t])}return g},Bp.apply(null,arguments)}function ra(g){let{"data-test-id":s,children:p,className:t,onClick:f,disabled:r,small:n,title:e}=g;return Gt.createElement("button",Bp({disabled:r,className:A2("Button__root",r&&"Button__disabled",n&&"Button__small",t),onClick:f,title:e,"aria-label":e},s&&{"data-test-id":s}),p)}var od=on(129),Gs={};Gs.styleTagTransform=hi(),Gs.setAttributes=fi(),Gs.insert=di().bind(null,"head"),Gs.domAPI=ui(),Gs.insertStyleElement=pi(),ci()(od.A,Gs),od.A&&od.A.locals&&od.A.locals;var P2=g=>{var s={};return on.d(s,g),s};const j2=P2({ContentEditable:()=>o0});function N2(g){let{className:s}=g;return Gt.createElement(j2.ContentEditable,{className:s||"ContentEditable__root"})}var id=on(457),Ys={};Ys.styleTagTransform=hi(),Ys.setAttributes=fi(),Ys.insert=di().bind(null,"head"),Ys.domAPI=ui(),Ys.insertStyleElement=pi(),ci()(id.A,Ys),id.A&&id.A.locals&&id.A.locals;function I2(g){let{children:s,className:p}=g;return Gt.createElement("div",{className:p||"Placeholder__root"},s)}const R2=Yy.default.LexicalErrorBoundary||Yy.default,M2=()=>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"})),tv=()=>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"})),D2=()=>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"})),L2=()=>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 ev(g,s,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:g,author:s,codoxId:p,timeStamp:t,deleted:f})}function B2(g,s,p){return On.createNewThreadObj({quote:g,comments:s,codoxId:p})}function F2(g){let{anchorKey:s,editor:p,onAddComment:t}=g;const f=(0,Gt.useRef)(null),r=(0,Gt.useCallback)(()=>{const n=f.current,e=p.getRootElement(),l=p.getElementByKey(s);if(n!==null&&e!==null&&l!==null){const{right:i}=e.getBoundingClientRect(),{top:c}=l.getBoundingClientRect();n.style.left=i-20+"px",n.style.top=c-30+"px"}},[s,p]);return(0,Gt.useEffect)(()=>(window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}),[p,r]),Xy(()=>{r()},[s,p,r]),Gt.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:f},Gt.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:t},Gt.createElement(M2,null)))}function z2(g){let{onEscape:s}=g;const[p]=(0,ta.useLexicalComposerContext)();return(0,Gt.useEffect)(()=>p.registerCommand(_e.KEY_ESCAPE_COMMAND,t=>s(t),2),[p,s]),null}function U2(g){let{editorRef:s}=g;const[p]=(0,ta.useLexicalComposerContext)();return typeof s=="function"?s(p):typeof s=="object"&&(s.current=p),null}function nv(g){let{className:s,autoFocus:p,onEscape:t,onChange:f,editorRef:r,placeholder:n="Type a comment...",onEditorClick:e=()=>{}}=g;const l={namespace:"Commenting",nodes:[],onError:i=>{throw i},theme:T2};return Gt.createElement(p2.LexicalComposer,{initialConfig:l},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:e},Gt.createElement(_2.PlainTextPlugin,{contentEditable:Gt.createElement(N2,{className:s}),placeholder:Gt.createElement(I2,null,n),ErrorBoundary:R2}),Gt.createElement(v2.OnChangePlugin,{onChange:f}),Gt.createElement(m2.HistoryPlugin,null),p!==!1&&Gt.createElement(c2.AutoFocusPlugin,null),Gt.createElement(z2,{onEscape:t}),Gt.createElement(d2.ClearEditorPlugin,null),r!==void 0&&Gt.createElement(U2,{editorRef:r})))}function rv(g,s){return(0,Gt.useCallback)((p,t)=>{p.read(()=>{g((0,Zy.$rootTextContent)()),s(!(0,Zy.$isRootTextContentEmpty)(t.isComposing(),!0))})},[s,g])}function $2(g){let{editor:s,cancelAddComment:p,submitAddComment:t}=g;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),l=(0,Gt.useRef)(null),i=(0,Gt.useMemo)(()=>({container:document.createElement("div"),elements:[]}),[]),c=(0,Gt.useRef)(null),o=av(),a=(0,Gt.useCallback)(()=>{s.getEditorState().read(()=>{const d=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(d)){c.current=d.clone();const m=d.anchor,h=d.focus,y=(0,Da.createDOMRange)(s,m.getNode(),m.offset,h.getNode(),h.offset),v=l.current;if(y!==null&&v!==null){const{left:_,bottom:b,width:w}=y.getBoundingClientRect(),x=(0,Da.createRectsFromDOMRange)(s,y);let S=x.length===1?_+w/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=x.length,{container:k}=i,D=i.elements,I=D.length;for(let T=0;T<C;T++){const R=x[T];let P=D[T];P===void 0&&(P=document.createElement("span"),D[T]=P,k.appendChild(P));const $="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(${$}, 0.3);pointer-events:none;z-index:5;`;P.style.cssText=q}for(let T=I-1;T>=C;T--){const R=D[T];k.removeChild(R),D.pop()}}}})},[s,i]);Xy(()=>{a();const d=i.container,m=document.body;if(m!==null)return m.appendChild(d),()=>{m.removeChild(d)}},[i.container,a]),(0,Gt.useEffect)(()=>(window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}),[a]);const u=rv(r,e);return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:l},Gt.createElement(nv,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:d=>(d.preventDefault(),p(),!0),onChange:u}),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},Gt.createElement(ra,{onClick:p,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),Gt.createElement(ra,{onClick:()=>{if(n){let d=s.getEditorState().read(()=>{const m=c.current;return m?m.getTextContent():""});d.length>100&&(d=d.slice(0,99)+"…"),t(B2(d,[ev(f,o)]),!0,void 0,c.current),c.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function H2(g){let{submitAddComment:s,thread:p,placeholder:t}=g;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),l=(0,Gt.useRef)(null),i=av(),c=rv(r,e);return Gt.createElement(Gt.Fragment,null,Gt.createElement(nv,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:c,editorRef:l,placeholder:t}),Gt.createElement(ra,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){s(ev(f,i),!1,p);const o=l.current;o!==null&&o.dispatchCommand(_e.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},Gt.createElement(D2,null)))}function ov(g){let{commentOrThread:s,deleteCommentOrThread:p,onClose:t,thread:f}=g;return Gt.createElement(Gt.Fragment,null,"Are you sure you want to delete this ",s.type,"?",Gt.createElement("div",{className:"Modal__content"},Gt.createElement(ra,{onClick:()=>{p(s,f),t()}},"Delete")," ",Gt.createElement(ra,{onClick:()=>{t()}},"Cancel")))}function iv(g){let{comment:s,deleteComment:p,thread:t,rtf:f}=g;const r=Math.round((s.timeStamp-performance.now())/1e3),n=Math.round(r/60),[e,l]=Qy();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"},s.author),Gt.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Time"},"· ",r>-10?"Just now":f.format(n,"minute"))),Gt.createElement("p",{className:s.deleted?"CodoxCommentPlugin_CommentsPanel_DeletedComment":""},s.content),!s.deleted&&Gt.createElement(Gt.Fragment,null,Gt.createElement(ra,{onClick:()=>{l("Delete Comment",i=>Gt.createElement(ov,{commentOrThread:s,deleteCommentOrThread:p,thread:t,onClose:i}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(tv,null)),e))}function q2(g){let{activeIDs:s,comments:p,deleteCommentOrThread:t,listRef:f,submitAddComment:r,markNodeMap:n}=g;const[e]=(0,ta.useLexicalComposerContext)(),[l,i]=(0,Gt.useState)(0),[c,o]=Qy(),a=(0,Gt.useMemo)(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return(0,Gt.useEffect)(()=>{const u=setTimeout(()=>{i(l+1)},1e4);return()=>{clearTimeout(u)}},[l]),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List",ref:f},p.map(u=>{const d=u.codoxId;if(!d)return null;if(u.type==="thread"){const m=()=>{if(n.get(d)!==void 0&&(s===null||s.indexOf(d)===-1)){const h=document.activeElement;e.update(()=>{(0,_e.$setSelection)(null)},{onUpdate(){h!==null&&h.focus()}})}};return Gt.createElement("li",{key:d,onClick:m,className:`CodoxCommentPlugin_CommentsPanel_List_Thread ${n.has(d)?"interactive":""} ${s.indexOf(d)===-1?"":"active"}`},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_QuoteBox"},Gt.createElement("blockquote",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Quote"},"> ",Gt.createElement("span",null,u.quote)),Gt.createElement(ra,{onClick:()=>{o("Delete Thread",h=>Gt.createElement(ov,{commentOrThread:u,deleteCommentOrThread:t,onClose:h}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(tv,null)),c),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},u.comments.map(h=>Gt.createElement(iv,{key:h.codoxId,comment:h,deleteComment:t,thread:u,rtf:a}))),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},Gt.createElement(H2,{submitAddComment:r,thread:u,placeholder:"Reply to comment..."})))}return Gt.createElement(iv,{key:d,comment:u,deleteComment:t,rtf:a})}))}function W2(g){let{activeIDs:s,deleteCommentOrThread:p,comments:t,submitAddComment:f,markNodeMap:r}=g;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(q2,{activeIDs:s,comments:t,deleteCommentOrThread:p,listRef:n,submitAddComment:f,markNodeMap:r}))}function av(){const g=(0,Ly.useCollaborationContext)(),{yjsDocMap:s,name:p}=g;return p||"Playground User"}function J2(g){const[s]=(0,ta.useLexicalComposerContext)(),p=TS(),t=(0,Gt.useMemo)(()=>new Map,[]),[f,r]=(0,Gt.useState)(),[n,e]=(0,Gt.useState)([]),[l,i]=(0,Gt.useState)(!1),[c,o]=(0,Gt.useState)(!1);(0,Gt.useEffect)(()=>{!p.length&&c?o(!1):p.length},[p]);const a=(0,Gt.useCallback)(()=>{s.update(()=>{const m=(0,_e.$getSelection)();m!==null&&(m.dirty=!0)}),i(!1)},[s]),u=(0,Gt.useCallback)((m,h)=>{if(m.type==="comment"){if(ue.log("[deleteCommentOrThread]: type comment new values",{comment:m,thread:h,markNodeMap:t}),On.removeComment(h.codoxId,m.codoxId),!h)return;const y=h.codoxId,v=t.get(y);s.update(()=>{v?v.forEach((_,b)=>{const w=(0,_e.$getNodeByKey)(b);ue.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:w}),w&&w.markDirty()}):(0,_e.$getRoot)().markDirty(),(0,_e.$addUpdateTag)(uo.historic),(0,_e.$addUpdateTag)(sc)})}else{ue.log("[deleteCommentOrThread]: type thread new values",{comment:m,markNodeMap:t});const y=h!==void 0?h.codoxId:m.codoxId,v=t.get(y);setTimeout(()=>{s.update(()=>{if(v)for(const _ of v){const b=(0,_e.$getNodeByKey)(_);ue.log("[deleteCommentOrThread]: type thread new values",{node:b}),(0,co.$isMarkNode)(b)&&(b.deleteID(y),b.getIDs().length===0&&(0,co.$unwrapMarkNode)(b))}else(0,_e.$getRoot)().markDirty(),ue.debug("[deleteCommentOrThread][refreshComments]");On.refreshComments(!0),(0,_e.$addUpdateTag)(sc)})})}},[s,t]),d=(0,Gt.useCallback)((m,h,y,v)=>{if(ue.log("[submitAddComment]: new values",{commentOrThread:m,isInlineComment:h,thread:y,markNodeMap:t}),y?On.addComment(y.codoxId,m):On.addCommentThread(m),h)s.update(()=>{if((0,_e.$isRangeSelection)(v)){const _=v.isBackward(),b=m.codoxId;(0,co.$wrapSelectionInMarkNode)(v,_,b),(0,_e.$addUpdateTag)(sc)}}),i(!1);else if(!h&&y){const _=y.codoxId,b=t.get(_);if(!b)return void On.removeComment(y.codoxId,m.codoxId);s.update(()=>{b.forEach((w,x)=>{let S=(0,_e.$getNodeByKey)(x);S&&S.markDirty()}),(0,_e.$addUpdateTag)(uo.historic),(0,_e.$addUpdateTag)(sc)})}},[s]);return(0,Gt.useEffect)(()=>{const m=[];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=s.getElementByKey(_);b!==null&&(b.classList.add("selected"),m.push(b),o(!0))}}return()=>{for(let h=0;h<m.length;h++)m[h].classList.remove("selected")}},[n,s,t]),(0,Gt.useEffect)(()=>{const m=new Map;return(0,Ds.mergeRegister)((0,Ds.registerNestedElementResolver)(s,co.MarkNode,h=>(0,co.$createMarkNode)(h.getIDs()),(h,y)=>{h.getIDs().forEach(v=>{y.addID(v)})}),s.registerMutationListener(co.MarkNode,h=>{s.getEditorState().read(()=>{for(const[y,v]of h){const _=(0,_e.$getNodeByKey)(y);let b=[];v==="destroyed"?b=m.get(y)||[]:(0,co.$isMarkNode)(_)&&(b=_.getIDs());for(let w=0;w<b.length;w++){const x=b[w];let S=t.get(x);m.set(y,b),v==="destroyed"?S!==void 0&&(S.delete(y),S.size===0&&t.delete(x)):(S===void 0&&(S=new Set,t.set(x,S)),S.has(y)||S.add(y))}}})}),s.registerUpdateListener(h=>{let{editorState:y,tags:v}=h;y.read(()=>{const _=(0,_e.$getSelection)();let b=!1,w=!1;if((0,_e.$isRangeSelection)(_)){const x=_.anchor.getNode();if((0,_e.$isTextNode)(x)){const S=(0,co.$getMarkIDs)(x,_.anchor.offset);S!==null&&(e(S),b=!0),_.isCollapsed()||(r(x.getKey()),w=!0)}}b||e(x=>x.length===0?x:[]),w||r(null),(0,_e.$isRangeSelection)(_)&&i(!1)})}),s.registerCommand(Tp,()=>{const h=window.getSelection();return h!==null&&h.removeAllRanges(),i(!0),!0},_e.COMMAND_PRIORITY_EDITOR))},[s,t]),Gt.createElement(Gt.Fragment,null,l&&(0,Ws.createPortal)(Gt.createElement($2,{editor:s,cancelAddComment:a,submitAddComment:d}),document.body),f!=null&&!l&&(0,Ws.createPortal)(Gt.createElement(F2,{anchorKey:f,editor:s,onAddComment:()=>{s.dispatchCommand(Tp,void 0)}}),document.body),(0,Ws.createPortal)(Gt.createElement(ra,{className:"CodoxCommentPlugin_ShowCommentsButton "+(c?"active":""),onClick:()=>o(!c),title:c?"Hide Comments":"Show Comments"},Gt.createElement(L2,null)),document.body),c&&(0,Ws.createPortal)(Gt.createElement(W2,{comments:p,submitAddComment:d,deleteCommentOrThread:u,activeIDs:n,markNodeMap:t}),document.body))}var ad=on(766),Zs={};Zs.styleTagTransform=hi(),Zs.setAttributes=fi(),Zs.insert=di().bind(null,"head"),Zs.domAPI=ui(),Zs.insertStyleElement=pi(),ci()(ad.A,Zs),ad.A&&ad.A.locals&&ad.A.locals;var sd=on(225),Xs={};Xs.styleTagTransform=hi(),Xs.setAttributes=fi(),Xs.insert=di().bind(null,"head"),Xs.domAPI=ui(),Xs.insertStyleElement=pi(),ci()(sd.A,Xs),sd.A&&sd.A.locals&&sd.A.locals;function V2(g){let{label:s,value:p,onChange:t,placeholder:f="","data-test-id":r,type:n="text"}=g;return Gt.createElement("div",{className:"CodoxInput__wrapper"},Gt.createElement("label",{className:"CodoxInput__label"},s),Gt.createElement("input",{type:n,className:"CodoxInput__input",placeholder:f,value:p,onChange:e=>{t(e.target.value)},"data-test-id":r}))}function sv(g,s){var p=Object.keys(g);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(g);s&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(g,f).enumerable})),p.push.apply(p,t)}return p}function ld(g){for(var s=1;s<arguments.length;s++){var p=arguments[s]!=null?arguments[s]:{};s%2?sv(Object(p),!0).forEach(function(t){K2(g,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(p)):sv(Object(p)).forEach(function(t){Object.defineProperty(g,t,Object.getOwnPropertyDescriptor(p,t))})}return g}function K2(g,s,p){return(s=G2(s))in g?Object.defineProperty(g,s,{value:p,enumerable:!0,configurable:!0,writable:!0}):g[s]=p,g}function G2(g){var s=Y2(g,"string");return typeof s=="symbol"?s:s+""}function Y2(g,s){if(typeof g!="object"||!g)return g;var p=g[Symbol.toPrimitive];if(p!==void 0){var t=p.call(g,s||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(g)}let dc=!1;const Z2=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],fc=214,lv=150;function X2(g){let{color:s,onChange:p}=g;const[t,f]=(0,Gt.useState)(Qs("hex",s)),[r,n]=(0,Gt.useState)(s),e=(0,Gt.useRef)(null),l=(0,Gt.useMemo)(()=>({x:t.hsv.s/100*fc,y:(100-t.hsv.v)/100*lv}),[t.hsv.s,t.hsv.v]),i=(0,Gt.useMemo)(()=>({x:t.hsv.h/360*fc}),[t.hsv]);return(0,Gt.useEffect)(()=>{e.current!==null&&p&&n(t.hex)},[t,p]),(0,Gt.useEffect)(()=>{if(s===void 0)return;const c=Qs("hex",s);f(c),n(c.hex)},[s]),Gt.createElement("div",{className:"codox-color-picker-wrapper",style:{width:fc},ref:e},Gt.createElement(V2,{label:"Hex",onChange:c=>{if(n(c),/^#[0-9A-Fa-f]{6}$/i.test(c)){const o=Qs("hex",c);f(o)}},value:r}),Gt.createElement("div",{className:"codox-color-picker-basic-color"},Z2.map(c=>Gt.createElement("button",{className:c===t.hex?" active":"",key:c,style:{backgroundColor:c},onClick:()=>(o=>{n(o);let a=Qs("hex",o);f(a),p(a.hex,dc)})(c)}))),Gt.createElement(cv,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`},onChange:c=>{let{x:o,y:a}=c;const u=Qs("hsv",ld(ld({},t.hsv),{},{s:o/fc*100,v:100-a/lv*100}));f(u),n(u.hex),p(u.hex,dc)}},Gt.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:t.hex,left:l.x,top:l.y}})),Gt.createElement(cv,{className:"codox-color-picker-hue",onChange:c=>{let{x:o}=c;const a=Qs("hsv",ld(ld({},t.hsv),{},{h:o/fc*360}));f(a),n(a.hex),p(a.hex,dc)}},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 cv(g){let{className:s,style:p,onChange:t,children:f}=g;const r=(0,Gt.useRef)(null),n=(0,Gt.useRef)(!1),e=l=>{if(r.current){const{current:i}=r,{width:c,height:o,left:a,top:u}=i.getBoundingClientRect(),d=uv(l.clientX-a,c,0),m=uv(l.clientY-u,o,0);t({x:d,y:m})}};return Gt.createElement("div",{ref:r,className:s,style:p,onMouseDown:l=>{if(l.button!==0)return;e(l);const i=o=>{n.current=!0,dc=!0,e(o)},c=o=>{n.current&&(dc=!1),document.removeEventListener("mousemove",i,!1),document.removeEventListener("mouseup",c,!1),e(o),n.current=!1};document.addEventListener("mousemove",i,!1),document.addEventListener("mouseup",c,!1)}},f)}function uv(g,s,p){return g>s?s:g<p?p:g}function dv(g){if(!g.startsWith("#")){const s=document.createElement("canvas").getContext("2d");if(!s)throw new Error("2d context not supported or canvas already initialized");return s.fillStyle=g,s.fillStyle}return g.length===4||g.length===5?g=g.split("").map((s,p)=>p?s+s:"#").join(""):g.length===7||g.length===9?g:"#000000"}function fv(g){const s=(g.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:s[2],g:s[1],r:s[0]}}function Fp(g){let{r:s,g:p,b:t}=g;s/=255,p/=255,t/=255;const f=Math.max(s,p,t),r=f-Math.min(s,p,t);return{h:r?60*(f===s?(p-t)/r+(p<t?6:0):f===p?2+(t-s)/r:4+(s-p)/r):0,s:f?r/f*100:0,v:100*f}}function Q2(g){let{h:s,s:p,v:t}=g;p/=100,t/=100;const f=~~(s/60),r=s/60-f,n=t*(1-p),e=t*(1-p*r),l=t*(1-p*(1-r)),i=f%6,c=Math.round(255*[t,e,n,n,l,t][i]),o=Math.round(255*[l,t,t,e,n,n][i]);return{b:Math.round(255*[n,n,l,t,t,e][i]),g:o,r:c}}function pv(g){let{b:s,g:p,r:t}=g;return"#"+[t,p,s].map(f=>f.toString(16).padStart(2,"0")).join("")}function Qs(g,s){let p=dv("#121212"),t=fv(p),f=Fp(t);return g==="hex"?(p=dv(s),t=fv(p),f=Fp(t)):g==="rgb"?(t=s,p=pv(t),f=Fp(t)):g==="hsv"&&(f=s,t=Q2(f),p=pv(t)),{hex:p,hsv:f,rgb:t}}const tC=Gt.createContext(null),hv=4;function eC(g){let{children:s,dropDownRef:p,onClose:t,dropdownClassName:f}=g;const[r,n]=(0,Gt.useState)(),[e,l]=(0,Gt.useState)(),i=(0,Gt.useCallback)(o=>{n(a=>a?[...a,o]:[o])},[n]),c=(0,Gt.useMemo)(()=>({registerItem:i}),[i]);return(0,Gt.useEffect)(()=>{r&&!e&&l(r[0]),e&&e.current&&e.current.focus()},[r,e]),Gt.createElement(tC.Provider,{value:c},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"?l(u=>{if(!u)return r[0];const d=r.indexOf(u)-1;return r[d===-1?r.length-1:d]}):a==="ArrowDown"&&l(u=>u?r[r.indexOf(u)+1]:r[0])}},s))}function nC(g){let{disabled:s=!1,buttonLabel:p,buttonAriaLabel:t,buttonClassName:f,buttonIconClassName:r,children:n,stopCloseOnClickSelf:e,dropdownClassName:l,buttonLabelClassName:i,dropdownChevronClassName:c}=g;const o=(0,Gt.useRef)(null),a=(0,Gt.useRef)(null),[u,d]=(0,Gt.useState)(!1);return(0,Gt.useEffect)(()=>{const m=a.current,h=o.current;if(u&&m!==null&&h!==null){const{top:y,left:v}=m.getBoundingClientRect();h.style.top=`${y+m.offsetHeight+hv}px`,h.style.left=`${Math.min(v,window.innerWidth-h.offsetWidth-20)}px`}},[o,a,u]),(0,Gt.useEffect)(()=>{const m=a.current;if(m!==null&&u){const h=y=>{const v=y.target;e&&o.current&&o.current.contains(v)||m.contains(v)||d(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[o,a,u,e]),(0,Gt.useEffect)(()=>{const m=()=>{if(u){const h=a.current,y=o.current;if(h!==null&&y!==null){const{top:v}=h.getBoundingClientRect(),_=v+h.offsetHeight+hv;_!==y.getBoundingClientRect().top&&(y.style.top=`${_}px`)}}};return document.addEventListener("scroll",m),()=>{document.removeEventListener("scroll",m)}},[a,o,u]),Gt.createElement(Gt.Fragment,null,Gt.createElement("button",{type:"button",disabled:s,"aria-label":t||p,className:f,onClick:()=>d(!u),ref:a},r&&Gt.createElement("span",{className:r}),p&&Gt.createElement("span",{className:i},p),Gt.createElement("i",{className:c})),u&&(0,Ws.createPortal)(Gt.createElement(eC,{dropDownRef:o,onClose:()=>{d(!1),a&&a.current&&a.current.focus()},dropdownClassName:l},n),document.body))}const rC=["disabled","stopCloseOnClickSelf","color","onChange"];function zp(){return zp=Object.assign?Object.assign.bind():function(g){for(var s=1;s<arguments.length;s++){var p=arguments[s];for(var t in p)({}).hasOwnProperty.call(p,t)&&(g[t]=p[t])}return g},zp.apply(null,arguments)}function oC(g,s){if(g==null)return{};var p,t,f=iC(g,s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(g);for(t=0;t<r.length;t++)p=r[t],s.indexOf(p)>=0||{}.propertyIsEnumerable.call(g,p)&&(f[p]=g[p])}return f}function iC(g,s){if(g==null)return{};var p={};for(var t in g)if({}.hasOwnProperty.call(g,t)){if(s.indexOf(t)>=0)continue;p[t]=g[t]}return p}function gv(g){let{disabled:s=!1,stopCloseOnClickSelf:p=!0,color:t,onChange:f}=g,r=oC(g,rC);return Gt.createElement(nC,zp({},r,{disabled:s,stopCloseOnClickSelf:p}),Gt.createElement(X2,{color:t,onChange:f}))}const aC=g=>{let{onColorChange:s,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:l}=g;const[i]=(0,ta.useLexicalComposerContext)(),[c,o]=(0,Gt.useState)(()=>i.isEditable()),[a,u]=(0,Gt.useState)("");(0,Gt.useEffect)(()=>(0,Ds.mergeRegister)(i.registerEditableListener(m=>{o(m)}),i.registerUpdateListener(m=>{let{editorState:h}=m;h.read(()=>{const y=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(y)){let v=(0,Da.$getSelectionStyleValueForProperty)(y,"color");v!==a&&(u(v||""),s(v))}})})),[i]);const d=(0,Gt.useCallback)((m,h)=>{i.update(()=>{const y=(0,_e.$getSelection)();y!==null&&(0,Da.$patchStyleText)(y,{color:m})})},[i]);return Gt.createElement(gv,{disabled:!c,color:a,onChange:d,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:l||""})},sC=aC,lC=g=>{let{onColorChange:s,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:l}=g;const[i]=(0,ta.useLexicalComposerContext)(),[c,o]=(0,Gt.useState)(()=>i.isEditable()),[a,u]=(0,Gt.useState)("#fff");(0,Gt.useEffect)(()=>(0,Ds.mergeRegister)(i.registerEditableListener(m=>{o(m)}),i.registerUpdateListener(m=>{let{editorState:h}=m;h.read(()=>{const y=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(y)){let v=(0,Da.$getSelectionStyleValueForProperty)(y,"background-color");v!==a&&(u(v||""),s(v))}})})),[i]);const d=(0,Gt.useCallback)((m,h)=>{i.update(()=>{const y=(0,_e.$getSelection)();y!==null&&(0,Da.$patchStyleText)(y,{"background-color":m})})},[i]);return Gt.createElement(gv,{disabled:!c,color:a,onChange:d,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:l||""})},cC=lC;var uC=Yi.yy;Yi._U,Yi.a8,Yi.Vs,Yi.Cn;var dC=Yi.gK,fC=Yi.vv;function pC(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}var cd=pC(function(g){const s=new URLSearchParams;s.append("code",g);for(let p=1;p<arguments.length;p++)s.append("v",arguments[p]);throw Error(`Minified Lexical error #${g}; visit https://lexical.dev/docs/error?${s} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function hC({hasCellMerge:g=!0,hasCellBackgroundColor:s=!0,hasTabHandler:p=!0}){const[t]=_r();return se.useEffect(()=>(t.hasNodes([ko,Ki,ec])||cd(10),lo(t.registerCommand(hw,({columns:f,rows:r,includeHeaders:n})=>{const e=J0(Number(r),Number(f),n);m0(e);const l=e.getFirstDescendant();return Pe(l)&&l.select(),!0},an),t.registerNodeTransform(ko,f=>{const[r]=Y0(f,null,null),n=r.reduce((e,l)=>Math.max(e,l.length),0);for(let e=0;e<r.length;++e){const l=r[e].length;if(l===n)continue;const i=r[e][l-1].cell;for(let c=l;c<n;++c){const o=si(0);o.append(Mn()),i!==null?i.insertAfter(o):y0(i,o)}}}))),[t]),se.useEffect(()=>{const f=new Map,r=e=>{const l=e.getKey(),i=t.getElementByKey(l);if(i&&!f.has(l)){const c=Ow(e,i,t,p);f.set(l,c)}};t.getEditorState().read(()=>{const e=om(ko);for(const l of e)Dn(l)&&r(l)});const n=t.registerMutationListener(ko,e=>{for(const[l,i]of e)if(i==="created")t.getEditorState().read(()=>{const c=Xn(l);Dn(c)&&r(c)});else if(i==="destroyed"){const c=f.get(l);c!==void 0&&(c.removeListeners(),f.delete(l))}});return()=>{n();for(const[,e]of f)e.removeListeners()}},[t,p]),se.useEffect(()=>{if(!g)return t.registerNodeTransform(Ki,f=>{if(f.getColSpan()>1||f.getRowSpan()>1){const[,,r]=Qr(f),[n]=Bo(r,f,f),e=n.length,l=n[0].length;let i=r.getFirstChild();fr(i)||cd(175);const c=[];for(let o=0;o<e;o++){o!==0&&(i=i.getNextSibling(),fr(i)||cd(175));let a=null;for(let u=0;u<l;u++){const d=n[o][u],m=d.cell;if(d.startRow===o&&d.startColumn===u)a=m,c.push(m);else if(m.getColSpan()>1||m.getRowSpan()>1){rn(m)||cd(176);const h=si(m.__headerState);a!==null?a.insertAfter(h):y0(i,h)}}}for(const o of c)o.setColSpan(1),o.setRowSpan(1)}})},[t,g]),se.useEffect(()=>{if(!s)return t.registerNodeTransform(Ki,f=>{f.getBackgroundColor()!==null&&f.setBackgroundColor(null)})},[t,s,g]),null}const $T="",gC={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"},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"}},mC="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE1IDE1IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMDAwMDEgOC4zMzMzM0wxLjkwMDAxIDEzLjhMMS4xMDAwMSAxMy4yTDUuMzc1MDEgNy41TDEuMTAwMDEgMS44TDEuOTAwMDEgMS4yTDYuMDAwMDEgNi42NjY2N0wxMC4xIDEuMkwxMC45IDEuOEw2LjYyNTAxIDcuNUwxMC45IDEzLjJMMTAuMSAxMy44TDYuMDAwMDEgOC4zMzMzM1pNMTIgMTIuNUMxMiAxMS42NzE2IDEyLjY3MTYgMTEgMTMuNSAxMUgxMy43OTI5QzE0LjQ1OTYgMTEgMTUgMTEuNTQwNCAxNSAxMi4yMDcxQzE1IDEyLjUyNzMgMTQuODcyOCAxMi44MzQzIDE0LjY0NjUgMTMuMDYwN0wxMy43MDcxIDE0SDE1VjE1SDEyLjVDMTIuMjk3OCAxNSAxMi4xMTU1IDE0Ljg3ODIgMTIuMDM4MSAxNC42OTEzQzExLjk2MDcgMTQuNTA0NSAxMi4wMDM1IDE0LjI4OTQgMTIuMTQ2NSAxNC4xNDY0TDEzLjkzOTMgMTIuMzUzNkMxMy45NzgyIDEyLjMxNDcgMTQgMTIuMjYyIDE0IDEyLjIwNzFDMTQgMTIuMDkyNyAxMy45MDczIDEyIDEzLjc5MjkgMTJIMTMuNUMxMy4yMjM5IDEyIDEzIDEyLjIyMzkgMTMgMTIuNUgxMloiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+",yC="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDQgNTEyLjM2Ij48cGF0aCBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik00OTkuNDMgMjMxLjM2SDM2OC40Yy0yLjUzIDAtNC41OC0yLjA1LTQuNTgtNC41N3YtOC4xMWMwLTEuMjYuNTItMi40IDEuMzQtMy4yMmw3MS41Ny04Mi41M2M2LjczLTcuNzUgMTIuNTctMTQuOTcgMTcuNDgtMjEuNjggNC44OC02LjY0IDguODMtMTIuNzQgMTEuODUtMTguMjggMi45Ny01LjQzIDUuMTgtMTAuNjEgNi42NC0xNS41NSAxLjQyLTQuODUgMi4xMy05LjUzIDIuMTMtMTQgMC0xNC42OC0zLjk4LTI2LjA1LTExLjkyLTM0LjA5LTMuOTItMy45Ni04Ljc1LTYuOTMtMTQuNDktOC45Mi01Ljk1LTIuMDMtMTIuOTEtMy4wNS0yMC44Ny0zLjA1LTguNDUgMC0xNS44OCAxLjIxLTIyLjI5IDMuNjItNi4yNyAyLjM2LTExLjYzIDUuOTItMTYuMDcgMTAuNjNhNDcuODg0IDQ3Ljg4NCAwIDAgMC0xMC4xNCAxNi42Yy0yLjI3IDYuMjktMy40MSAxMy4zOS0zLjQxIDIxLjI2IDAgMi41Mi0yLjA1IDQuNTctNC41NyA0LjU3aC02Ljg5Yy0yLjA1IDAtMy44LTEuMzYtNC4zNy0zLjI0bC0uMjctLjgyYy0uMTgtLjU2LS4yNS0xLjEzLS4yMi0xLjY3LS4yMy05LjMyIDEuMTQtMTcuOTkgNC4xMi0yNS45NyAzLjAyLTguMTMgNy42OC0xNS41NCAxMy45NC0yMi4xOSA2LjI2LTYuNyAxMy42My0xMS43NiAyMi4xLTE1LjEzQzQwNy44NCAxLjY4IDQxNy4yIDAgNDI3LjU1IDBjOS41OSAwIDE4LjI2IDEuMzggMjYuMDMgNC4xMyA3Ljg2IDIuNzkgMTQuNzcgNyAyMC43MiAxMi42MSA2LjAyIDUuNjMgMTAuNTUgMTIuNCAxMy41NSAyMC4yOCAyLjk2IDcuNzUgNC40NSAxNi41NiA0LjQ1IDI2LjQgMCA2LjUtMS4wNyAxMy4wOC0zLjE3IDE5LjY5bC0uMTQuMzhjLTIuMDkgNi40Ni01LjE3IDEyLjk3LTkuMiAxOS40OWwtLjE0LjIxYy00LjA4IDYuNTEtOC45IDEzLjQzLTE0LjQzIDIwLjc0LTUuNTYgNy4zMy0xMS45NiAxNS4yMy0xOS4yMiAyMy42N2wtNTYuOTEgNjYuNTFoMTEwLjM0YzIuNTIgMCA0LjU3IDIuMDUgNC41NyA0LjU3djguMTFjMCAyLjUyLTIuMDUgNC41Ny00LjU3IDQuNTd6bS0zMjcuMjUgNjguNzUgMTM3Ljk2LTE2Ny43NmMuODktMS4wNyAyLjMtMS42NSAzLjc0LTEuNjVsMjAuMTMtLjAyYzIuNTIgMCA0LjU3IDEuNzQgNC41NyAzLjg4IDAgLjkxLS4zNyAxLjc1LS45OCAyLjQxTDE4OC4zMiAzMTcuNjYgMzQ0LjEgNTA2LjI0YzEuNDUgMS43NS45NSA0LjE3LTEuMSA1LjQtLjguNDgtMS43Mi43MS0yLjYzLjcxbC0yMC4xMy4wMWMtMS43IDAtMy4xOC0uNzktMy45Ny0xLjk2bC0xNDQuMS0xNzUuMkwyOC4yMyA1MTAuNjljLS44OCAxLjA3LTIuMyAxLjY0LTMuNzMgMS42NWwtMTkuOTMuMDJjLTIuNTIgMC00LjU3LTEuNzQtNC41Ny0zLjg5IDAtLjkuMzctMS43NC45OC0yLjRsMTU1LjY1LTE4OC40TDYuOSAxMzYuOGMtMS40NS0xLjc1LS45NS00LjE4IDEuMTEtNS40MS43OS0uNDcgMS43MS0uNyAyLjYyLS43bDIwLjQ0LS4wMWMxLjYzIDAgMy4wNi43MiAzLjg3IDEuODFsMTM3LjI0IDE2Ny42MnoiLz48L3N2Zz4=",mv=Nn.createContext(null),yv=4;function oa({children:g,className:s,onClick:p,title:t}){const f=se.useRef(null),r=Nn.useContext(mv);if(r===null)throw new Error("DropDownItem must be used within a DropDown");const{registerItem:n}=r;return se.useEffect(()=>{f&&f.current&&n(f)},[f,n]),ee.jsx("button",{className:s,onClick:p,ref:f,title:t,type:"button",children:g})}function vC({children:g,dropDownRef:s,onClose:p}){const[t,f]=se.useState(),[r,n]=se.useState(),e=se.useCallback(c=>{f(o=>o?[...o,c]:[c])},[f]),l=c=>{if(!t)return;const o=c.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(o)&&c.preventDefault(),o==="Escape"||o==="Tab"?p():o==="ArrowUp"?n(a=>{if(!a)return t[0];const u=t.indexOf(a)-1;return t[u===-1?t.length-1:u]}):o==="ArrowDown"&&n(a=>a?t[t.indexOf(a)+1]:t[0])},i=se.useMemo(()=>({registerItem:e}),[e]);return se.useEffect(()=>{t&&!r&&n(t[0]),r&&r.current&&r.current.focus()},[t,r]),ee.jsx(mv.Provider,{value:i,children:ee.jsx("div",{className:"dropdown",ref:s,onKeyDown:l,children:g})})}function vv({disabled:g=!1,buttonLabel:s,buttonAriaLabel:p,buttonClassName:t,buttonIconClassName:f,children:r,stopCloseOnClickSelf:n}){const e=se.useRef(null),l=se.useRef(null),[i,c]=se.useState(!1),o=()=>{c(!1),l&&l.current&&l.current.focus()};return se.useEffect(()=>{const a=l.current,u=e.current;if(i&&a!==null&&u!==null){const{top:d,left:m}=a.getBoundingClientRect();u.style.top=`${d+a.offsetHeight+yv}px`,u.style.left=`${Math.min(m,window.innerWidth-u.offsetWidth-20)}px`}},[e,l,i]),se.useEffect(()=>{const a=l.current;if(a!==null&&i){const u=d=>{const m=d.target;n&&e.current&&e.current.contains(m)||a.contains(m)||c(!1)};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}}},[e,l,i,n]),se.useEffect(()=>{const a=()=>{if(i){const u=l.current,d=e.current;if(u!==null&&d!==null){const{top:m}=u.getBoundingClientRect(),h=m+u.offsetHeight+yv;h!==d.getBoundingClientRect().top&&(d.style.top=`${h}px`)}}};return document.addEventListener("scroll",a),()=>{document.removeEventListener("scroll",a)}},[l,e,i]),ee.jsxs(ee.Fragment,{children:[ee.jsxs("button",{type:"button",disabled:g,"aria-label":p||s,className:t,onClick:()=>c(!i),ref:l,children:[f&&ee.jsx("span",{className:f}),s&&ee.jsx("span",{className:"text dropdown-button-text",children:s}),ee.jsx("i",{className:"chevron-down"})]}),i&&Yr.createPortal(ee.jsx(vC,{dropDownRef:e,onClose:o,children:r}),document.body)]})}function bv(){return ee.jsx("div",{className:"divider"})}const _v=8,xv=72,ia={h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",paragraph:"Normal"},bC=({selectionFontSize:g,disabled:s,editor:p,blockType:t,styleConfig:f,isenterPressed:r,currentElementClick:n,currentElementSelect:e})=>{const[l,i]=Nn.useState(g),[c,o]=Nn.useState(t),[a,u]=Nn.useState("");Nn.useState([]);const[d,m]=Nn.useState(""),h=x=>{x&&x.title&&p.update(()=>{if(p.isEditable()){const S=Ce();S&&u0(S,x)}})},y=x=>{i(x.target.value)},v=()=>{const x=Number(l);if(!isNaN(x)){const S=Math.min(Math.max(x,_v),xv);i(String(S)),h({"font-size":`${S}px`})}},_=x=>{u(x),p.update(()=>{const k=Ce();ve(k)&&Ox(k,()=>Ns(x))});const{heading:S}=f;let C=null;if(S)switch(x){case"h1":C=S.find(k=>k.title==="Heading1").fontSize;break;case"h2":C=S.find(k=>k.title==="Heading2").fontSize;break;case"h3":C=S.find(k=>k.title==="Heading3").fontSize;break;case"h3":C=S.find(k=>k.title==="Heading4").fontSize;break;case"h3":C=S.find(k=>k.title==="Heading5").fontSize;break;case"paragraph":C=11;break;default:C=11}i(C),u(x),o(x)},b=()=>{i("11")};Nn.useEffect(()=>{r&&r==="Enter"&&b()},[r]),Nn.useEffect(()=>{const x=()=>{p.update(()=>{const S=Ce();if(S!==null){const k=S.getNodes()[0];if(!Pe(k)){const D=k.getType();D in ia&&o(D)}}})};return p.registerUpdateListener(x),()=>{p.registerUpdateListener(x)}},[p]);const w=x=>{if(["Heading1","Heading2","Heading3","Heading4","Heading5"].includes(x)){let C=f.heading.find(D=>D.title===x);i(C.fontSize);const k={title:`${C.title}`,"font-size":`${C.fontSize}px`,color:C.fontColor,"font-family":C.fontFamily,"margin-bottom":`${C.trailingSpace}em`,"font-weight":C.bold==="Yes"?"bold":"normal","font-style":C.italic==="Yes"?"italic":"normal","line-height":`${C.lineSpacing}em`,"text-align":C.alignment||"left"};h(k)}else d||i("11")};return Nn.useEffect(()=>{switch(n.tagName){case"P":i("11"),w(d);break;case"H1":o("h1"),i(f.heading.find(x=>x.title==="Heading1").fontSize);break;case"H2":o("h2"),i(f.heading.find(x=>x.title==="Heading2").fontSize);break;case"H3":o("h3"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"H4":o("h4"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"H5":o("h5"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"default":o("paragraph"),i("11");break}},[n]),Nn.useEffect(()=>{switch(e||o("paragraph"),e&&e.trim(" ")){case"P":i("11"),o("paragraph"),w(d);break;case"h1":o("h1"),i(f.heading.find(x=>x.title==="Heading1").fontSize);break;case"h2":o("h2"),i(f.heading.find(x=>x.title==="Heading2").fontSize);break;case"h3":o("h3"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"h4":o("h4"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"h5":o("h5"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"default":o("paragraph"),i("11");break}},[e]),ee.jsxs(ee.Fragment,{children:[ee.jsx("input",{type:"number",value:l,disabled:s,readOnly:!0,className:"toolbar-item font-size-input",min:_v,max:xv,onChange:y,onBlur:v}),ee.jsx(bv,{}),f&&f.heading?ee.jsxs("div",{className:"symbol-dropdown cust-head-dropDown",children:[ee.jsxs(vv,{disabled:s,buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"Formatting options for text style",buttonIconClassName:"icon block-type "+c,buttonLabel:ia[c],children:[ee.jsxs(oa,{className:`item ${c==="paragraph"?"active":""}`,onClick:()=>_("paragraph"),children:[ee.jsx("i",{className:"icon paragraph"}),ee.jsx("span",{className:"text",children:ia.paragraph})]}),f.heading&&f.heading.find(x=>x.title==="Heading1")&&ee.jsxs(oa,{className:`item ${c==="h1"?"active":""}`,onClick:()=>_("h1"),children:[ee.jsx("i",{className:"icon h1"}),ee.jsx("span",{className:"text",children:ia.h1})]}),f.heading&&f.heading.find(x=>x.title==="Heading2")&&ee.jsxs(oa,{className:`item ${c==="h2"?"active":""}`,onClick:()=>_("h2"),children:[ee.jsx("i",{className:"icon h2"}),ee.jsx("span",{className:"text",children:ia.h2})]}),f.heading&&f.heading.find(x=>x.title==="Heading3")&&ee.jsxs(oa,{className:`item ${c==="h3"?"active":""}`,onClick:()=>_("h3"),children:[ee.jsx("i",{className:"icon h3"}),ee.jsx("span",{className:"text",children:ia.h3})]}),f.heading&&f.heading.find(x=>x.title==="Heading4")&&ee.jsxs(oa,{className:`item ${c==="h4"?"active":""}`,onClick:()=>_("h4"),children:[ee.jsx("i",{className:"icon h4"}),ee.jsx("span",{className:"text",children:ia.h4})]}),f.heading&&f.heading.find(x=>x.title==="Heading5")&&ee.jsxs(oa,{className:`item ${c==="h5"?"active":""}`,onClick:()=>_("h5"),children:[ee.jsx("i",{className:"icon h5"}),ee.jsx("span",{className:"text",children:ia.h5})]})]}),ee.jsx(bv,{})]}):""]})},_C="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuMS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIyIEZvbnRpY29ucywgSW5jLi0tPjxwYXRoIGQ9Ik0wIDI1NkMwIDExNC42IDExNC42IDAgMjU2IDBzMjU2IDExNC42IDI1NiAyNTYtMTE0LjYgMjU2LTI1NiAyNTZTMCAzOTcuNCAwIDI1NnptMTc1LTQ3LjkgNDcuMSA0N0wxNzUgMzAzYy05LjMgOS40LTkuMyAyNC42IDAgMzMuMSA5LjQgMTAuMiAyNC42IDEwLjIgMzMuMSAwbDQ3LTQ2LjIgNDcuOSA0Ni4yYzkuNCAxMC4yIDI0LjYgMTAuMiAzMy4xIDAgMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMWwtNDYuMi00Ny45IDQ2LjItNDdjMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMS04LjUtOS4zLTIzLjctOS4zLTMzLjEgMGwtNDcuOSA0Ny4xLTQ3LTQ3LjFjLTguNS05LjMtMjMuNy05LjMtMzMuMSAwLTkuMyA5LjQtOS4zIDI0LjYgMCAzMy4xeiIvPjwvc3ZnPg==",xC="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGFibGUiPjxwYXRoIGQ9Ik0wIDJhMiAyIDAgMCAxIDItMmgxMmEyIDIgMCAwIDEgMiAydjEyYTIgMiAwIDAgMS0yIDJIMmEyIDIgMCAwIDEtMi0yVjJ6bTE1IDJoLTR2M2g0VjR6bTAgNGgtNHYzaDRWOHptMCA0aC00djNoM2ExIDEgMCAwIDAgMS0xdi0yem0tNSAzdi0zSDZ2M2g0em0tNSAwdi0zSDF2MmExIDEgMCAwIDAgMSAxaDN6bS00LTRoNFY4SDF2M3ptMC00aDRWNEgxdjN6bTUtM3YzaDRWNEg2em00IDRINnYzaDRWOHoiLz48L3N2Zz4=";function wC(){const[g,s]=se.useState("4"),[p,t]=se.useState("4"),[f,r]=se.useState(!1),[n,e]=se.useState(),[l]=_r(),i=()=>{!g||!p||(l.update(()=>{const c=J0(g,p,!0),o=m0(c);e(o)}),r(!1))};return ee.jsxs(ee.Fragment,{children:[ee.jsx("button",{title:"Table",className:"toolbar-item ",onClick:()=>r(!0),children:ee.jsx("img",{className:"add-toolbar-table-icon",src:xC,alt:"Add Table"})}),f&&ee.jsx("div",{className:"modal-overlay",children:ee.jsxs("div",{className:"modal-content",children:[ee.jsx("h3",{children:"Select Table Dimensions"}),ee.jsx("button",{className:"modal-buttons-close",onClick:()=>r(!1),children:ee.jsx("img",{src:_C,height:16,width:16,style:{margin:"0 0 29px 10px"}})}),ee.jsxs("div",{className:"select-table-container",children:[ee.jsx("label",{children:"Rows"}),ee.jsx("input",{type:"number",value:g,onChange:c=>s(Number(c.target.value))})]}),ee.jsxs("div",{className:"select-table-container",children:[ee.jsx("label",{children:"Column"}),ee.jsx("input",{type:"number",value:p,onChange:c=>t(Number(c.target.value))})]}),ee.jsx("div",{children:ee.jsx("div",{className:"modal-buttons",children:ee.jsx("button",{className:"toolbar-item",onClick:i,children:"Confirm"})})})]})})]})}const SC=[{letter:"",uppercase:"A",lowercase:"α"},{letter:"Beta",uppercase:"Β",lowercase:"β"},{letter:"Gamma",uppercase:"Γ",lowercase:"γ"},{letter:"Delta",uppercase:"Δ",lowercase:"δ"},{letter:"Epsilon",uppercase:"Ε",lowercase:"ε"},{letter:"Zeta",uppercase:"Ζ",lowercase:"ζ"},{letter:" Eta ",uppercase:"Η",lowercase:"η"},{letter:"Theta",uppercase:"Θ",lowercase:"θ"},{letter:"Iota",uppercase:"Ι",lowercase:"ι"},{letter:"Kappa",uppercase:"Κ",lowercase:"κ"}];function EC(){const[g]=_r(),[s,p]=se.useState(!1),t=f=>{g.update(()=>{var n;const r=Ce();if(ve(r)){const e=r.anchor.getNode();let l="inherit";if(e instanceof zi){const c=e.getStyle();l=((n=c==null?void 0:c.match(/font-size:\s*(\S+);/))==null?void 0:n[1])||l}const i=ir(f);r.insertNodes([i])}}),p(!1)};return ee.jsx("div",{className:"symbol-dropdown cust-head-dropDown",children:ee.jsx(vv,{buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"For appying Symbols",buttonLabel:"Symbols",children:ee.jsx("div",{className:"symbol-Flex-container",children:SC.map(({letter:f,uppercase:r,lowercase:n})=>ee.jsxs("div",{className:"symbol-items",children:[ee.jsx(oa,{className:"terr",onClick:()=>t(n),children:n}),ee.jsx(oa,{className:"terr",onClick:()=>t(r),children:r})]},f))})})})}const wv="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNCAxMkgyME0xMiA0VjIwIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==",Sv="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNiAxMkwxOCAxMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4=";var CC=typeof global=="object"&&global&&global.Object===Object&&global;const kC=CC;var OC=typeof self=="object"&&self&&self.Object===Object&&self,TC=kC||OC||Function("return this")();const Ev=TC;var AC=Ev.Symbol;const ud=AC;var Cv=Object.prototype,PC=Cv.hasOwnProperty,jC=Cv.toString,pc=ud?ud.toStringTag:void 0;function NC(g){var s=PC.call(g,pc),p=g[pc];try{g[pc]=void 0;var t=!0}catch{}var f=jC.call(g);return t&&(s?g[pc]=p:delete g[pc]),f}var IC=Object.prototype,RC=IC.toString;function MC(g){return RC.call(g)}var DC="[object Null]",LC="[object Undefined]",kv=ud?ud.toStringTag:void 0;function BC(g){return g==null?g===void 0?LC:DC:kv&&kv in Object(g)?NC(g):MC(g)}function FC(g){return g!=null&&typeof g=="object"}var zC="[object Symbol]";function UC(g){return typeof g=="symbol"||FC(g)&&BC(g)==zC}var $C=/\s/;function HC(g){for(var s=g.length;s--&&$C.test(g.charAt(s)););return s}var qC=/^\s+/;function WC(g){return g&&g.slice(0,HC(g)+1).replace(qC,"")}function Up(g){var s=typeof g;return g!=null&&(s=="object"||s=="function")}var Ov=0/0,JC=/^[-+]0x[0-9a-f]+$/i,VC=/^0b[01]+$/i,KC=/^0o[0-7]+$/i,GC=parseInt;function Tv(g){if(typeof g=="number")return g;if(UC(g))return Ov;if(Up(g)){var s=typeof g.valueOf=="function"?g.valueOf():g;g=Up(s)?s+"":s}if(typeof g!="string")return g===0?g:+g;g=WC(g);var p=VC.test(g);return p||KC.test(g)?GC(g.slice(2),p?2:8):JC.test(g)?Ov:+g}var YC=function(){return Ev.Date.now()};const $p=YC;var ZC="Expected a function",XC=Math.max,QC=Math.min;function tk(g,s,p){var t,f,r,n,e,l,i=0,c=!1,o=!1,a=!0;if(typeof g!="function")throw new TypeError(ZC);s=Tv(s)||0,Up(p)&&(c=!!p.leading,o="maxWait"in p,r=o?XC(Tv(p.maxWait)||0,s):r,a="trailing"in p?!!p.trailing:a);function u(x){var S=t,C=f;return t=f=void 0,i=x,n=g.apply(C,S),n}function d(x){return i=x,e=setTimeout(y,s),c?u(x):n}function m(x){var S=x-l,C=x-i,k=s-S;return o?QC(k,r-C):k}function h(x){var S=x-l,C=x-i;return l===void 0||S>=s||S<0||o&&C>=r}function y(){var x=$p();if(h(x))return v(x);e=setTimeout(y,m(x))}function v(x){return e=void 0,a&&t?u(x):(t=f=void 0,n)}function _(){e!==void 0&&clearTimeout(e),i=0,t=l=f=e=void 0}function b(){return e===void 0?n:v($p())}function w(){var x=$p(),S=h(x);if(t=arguments,f=this,l=x,S){if(e===void 0)return d(l);if(o)return clearTimeout(e),e=setTimeout(y,s),u(l)}return e===void 0&&(e=setTimeout(y,s)),n}return w.cancel=_,w.flush=b,w}function ek(g,s,p){const t=se.useRef(null);return t.current=g,se.useMemo(()=>tk((...f)=>{t.current&&t.current(...f)},s,{maxWait:p}),[s,p])}const Av=20;function nk({anchorElem:g}){const[s]=_r(),p=Lu(),[t,f]=se.useState(!1),[r,n]=se.useState(!1),[e,l]=se.useState(!1),[i,c]=se.useState({}),o=se.useRef(new Set),a=se.useRef(null),u=ek(y=>{const{isOutside:v,tableDOMNode:_}=rk(y);if(v){f(!1),n(!1);return}if(!_)return;a.current=_;let b=null,w=null,x=null;if(s.update(()=>{var C;const S=ur(_);if(rn(S)){const k=_n(S,D=>Dn(D));if(!Dn(k))return;if(x=s.getElementByKey(k==null?void 0:k.getKey()),x){const D=k.getChildrenSize(),I=(C=k.getChildAtIndex(0))==null?void 0:C.getChildrenSize(),T=bw(S),R=K0(S);T===D-1?b=S:R===I-1&&(w=S)}}}),x){const{width:S,y:C,right:k,left:D,bottom:I,height:T}=x.getBoundingClientRect(),{y:R,left:P}=g.getBoundingClientRect();b?(n(!1),f(!0),c({height:Av,left:D-P,top:I-R+5,width:S})):w&&(n(!0),f(!1),c({height:T,left:k-P+5,top:C-R,width:Av}))}},50,250),d=se.useMemo(()=>new ResizeObserver(()=>{f(!1),n(!1)}),[]);se.useEffect(()=>{if(e)return document.addEventListener("mousemove",u),()=>{f(!1),n(!1),u.cancel(),document.removeEventListener("mousemove",u)}},[e,u]),se.useEffect(()=>lo(s.registerMutationListener(ko,y=>{s.getEditorState().read(()=>{for(const[v,_]of y){const b=s.getElementByKey(v);switch(_){case"created":o.current.add(v),l(o.current.size>0),b&&d.observe(b);break;case"destroyed":o.current.delete(v),l(o.current.size>0),d.disconnect(),o.current.forEach(w=>{const x=s.getElementByKey(w);x&&d.observe(x)});break}}})})),[s,d]);const m=y=>{s.update(()=>{if(a.current){const v=ur(a.current);v==null||v.selectEnd(),y?(_w(),f(!1)):(xw(),n(!1))}})},h=y=>{s.update(()=>{if(a.current){const v=ur(a.current);v==null||v.selectEnd(),y?(ww(),f(!1)):(Sw(),n(!1))}})};return p?ee.jsxs(ee.Fragment,{children:[t&&ee.jsxs("div",{children:[ee.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%",padding:"20px"},onClick:()=>m(!0),children:ee.jsx("img",{src:wv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),ee.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%"},onClick:()=>h(!0),children:ee.jsx("img",{src:Sv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]}),r&&ee.jsxs("div",{className:"table-add-row-flex-container",children:[ee.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%",padding:"20px"},onClick:()=>m(!1),children:ee.jsx("img",{src:wv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),ee.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%"},onClick:()=>h(!1),children:ee.jsx("img",{src:Sv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]})]}):null}function rk(g){const s=g.target;if(s&&s instanceof HTMLElement){const p=s.closest("td.PlaygroundEditorTheme__tableCell, th.PlaygroundEditorTheme__tableCell");return{isOutside:!(p||s.closest("button.PlaygroundEditorTheme__tableAddRows")||s.closest("button.PlaygroundEditorTheme__tableAddColumns")||s.closest("div.TableCellResizer__resizer")),tableDOMNode:p}}else return{isOutside:!0,tableDOMNode:null}}function ok({anchorElem:g=document.body}){return Lu()?Yr.createPortal(ee.jsx(nk,{anchorElem:g}),g):null}const hc=1;function dd(){return ee.jsx("div",{className:"divider"})}function ik({renderOnlineUsers:g,styleConfig:s}){const[p]=_r(),t=se.useRef(null),[f,r]=se.useState(!1),[n,e]=se.useState(!1),[l,i]=se.useState(!1),[c,o]=se.useState(!1),[a,u]=se.useState(!1),[d,m]=se.useState(!1),[h,y]=se.useState(!1),[v,_]=se.useState(!1),[b,w]=se.useState("11px"),[x,S]=se.useState(()=>p.isEditable()),[C,k]=se.useState(""),[D,I]=se.useState(""),[T,R]=se.useState(""),P=se.useCallback(()=>{const $=Ce();ve($)&&(i($.hasFormat("bold")),o($.hasFormat("italic")),u($.hasFormat("underline")),m($.hasFormat("strikethrough")),y($.hasFormat("subscript")),_($.hasFormat("superscript")),w(f0($,"font-size","11px")))},[]);return se.useEffect(()=>lo(p.registerUpdateListener(({editorState:$})=>{$.read(()=>{P()})}),p.registerCommand(ei,($,q)=>{var W;const H=(W=Ce())==null?void 0:W.getNodes()[0].__parent;return p.getEditorState()._nodeMap.forEach((V,A)=>{A===H&&R(V.__tag)}),P(),!1},hc),p.registerCommand(cf,$=>(I($.target),!1),hc),p.registerCommand(gs,$=>(r($),!1),hc),p.registerCommand(hs,$=>(e($),!1),hc),p.registerCommand(fs,$=>(k($.code),!1),hc)),[p,P]),ee.jsxs("div",{className:"toolbar",ref:t,children:[ee.jsx("button",{disabled:!f,onClick:()=>{p.dispatchCommand(Il,void 0)},className:"toolbar-item spaced","aria-label":"Undo",children:ee.jsx("i",{className:"format undo"})}),ee.jsx("button",{disabled:!n,onClick:()=>{p.dispatchCommand(Rl,void 0)},className:"toolbar-item","aria-label":"Redo",children:ee.jsx("i",{className:"format redo"})}),ee.jsx(dd,{}),ee.jsx(bC,{currentElementClick:D,selectionFontSize:b.slice(0,-2),editor:p,disabled:!x,blockType:"paragraph",styleConfig:s,isenterPressed:C,currentElementSelect:T}),ee.jsx(dd,{}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"bold")},className:"toolbar-item spaced "+(l?"active":""),"aria-label":"Format Bold",children:ee.jsx("i",{className:"format bold"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"italic")},className:"toolbar-item spaced "+(c?"active":""),"aria-label":"Format Italics",children:ee.jsx("i",{className:"format italic"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"underline")},className:"toolbar-item spaced "+(a?"active":""),"aria-label":"Format Underline",children:ee.jsx("i",{className:"format underline"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"strikethrough")},className:"toolbar-item spaced "+(d?"active":""),"aria-label":"Format Strikethrough",children:ee.jsx("i",{className:"format strikethrough"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"superscript")},className:"toolbar-item spaced "+(v?"active":""),"aria-label":"Format SuperScript",children:ee.jsx("img",{src:yC,height:16,width:16,style:{marginTop:"1px"}})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"subscript")},className:"toolbar-item spaced "+(h?"active":""),"aria-label":"Format SubScript",children:ee.jsx("img",{src:mC,height:16,width:16,style:{marginTop:"1px"}})}),ee.jsx(dd,{}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(ps,"left")},className:"toolbar-item spaced","aria-label":"Left Align",children:ee.jsx("i",{className:"format left-align"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(ps,"center")},className:"toolbar-item spaced","aria-label":"Center Align",children:ee.jsx("i",{className:"format center-align"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(ps,"right")},className:"toolbar-item spaced","aria-label":"Right Align",children:ee.jsx("i",{className:"format right-align"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(ps,"justify")},className:"toolbar-item","aria-label":"Justify Align",children:ee.jsx("i",{className:"format justify-align"})}),ee.jsx(dd,{}),ee.jsx(wC,{}),ee.jsx(EC,{}),ee.jsx(ok,{}),ee.jsx("div",{className:"avtar-outer-div",children:g()})]})}var Hp={exports:{}},En={};/** @license React v16.13.1
|
|
1429
|
+
`,P.append(q),_=q}!R&&x.width<1&&r.length>1&&(P.style.width="3px")}v.forEach(w=>{this.hoverList.push([w,_,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(s){let p=!1,t=s.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 l=new Set;for(let i=0;i<this.hoverList.length;i++){let c=this.hoverList[i],[o,a,u]=c;if(l.has(u))continue;let d=ar.isMousePositionWithinElementCords(s,o);s.type===kr.mouseover&&d&&(a.style.animation=this.isEditingInProgress?ar.tooltipAnimations.hideAtOnce:ar.tooltipAnimations.showAtOnce,l.add(u)),s.type===kr.mouseout&&(a.style.animation=ar.tooltipAnimations.hideWithDelay,l.add(u)),s.type===kr.mousemove&&d&&(a.style.animation=this.isEditingInProgress?ar.tooltipAnimations.hideAtOnce:ar.tooltipAnimations.showAtOnce,l.add(u))}}_keyboardEventsListener(s){s.type===kr.keypress&&(this.isEditingInProgress||(this.isEditingInProgress=!0)),s.type===kr.keyup&&this.isEditingInProgress&&(this.isEditingInProgress=!1)}_resizeEventListener(s){Se.mainEditorExists()&&this.paintRemoteSelections(this.remoteSelections)}mount(){window.addEventListener(kr.keypress,this.keyboardBindedListener),window.addEventListener(kr.keyup,this.keyboardBindedListener),window.addEventListener(kr.resize,this.resizeBindedListener),window.addEventListener(kr.scroll,this.resizeBindedListener);for(const s of my)window.addEventListener(s,this.mouseBindedListener)}unmount(){window.removeEventListener(kr.keypress,this.keyboardBindedListener),window.removeEventListener(kr.keyup,this.keyboardBindedListener),window.removeEventListener(kr.resize,this.resizeBindedListener),window.removeEventListener(kr.scroll,this.resizeBindedListener);for(const s of my)window.removeEventListener(s,this.mouseBindedListener);this.gcPrevPaintedRemoteSelections()}shouldUpdateRemoteSelections(){return!0}gcPrevPaintedRemoteSelections(){let s=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=s||[],this.remoteSelectionDOMsMap={},this.activeEditorsKeys={}}paintRemoteSelections(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];this.gcPrevPaintedRemoteSelections(s);let p=Se.getMainEditorState();p.read&&p.read(()=>{for(let t of this.remoteSelections)if(Pp.validateJSONSelection(t,kp.remote))if($e.isNestedSelectionJSON(t)){let{nestedSelectionJSON:f,nestedEditor:r}=$e.getNestedSelectionJSONFromMainSelectionJSON(t);if(!r)continue;r.getEditorState().read(()=>{let n=$e.JSONToLexical(f);if(n)try{this.paintSingleRemoteSelection({editor:r,selectionJSON:t,lexicalSelection:n,selectedNodes:n.getNodes(),isBackward:n.isBackward()})}catch(e){ue.warn("[PAINT REMOTE SELECTION] failed for nested editor - ",{error:e,nestedSelectionJSON:f,fullSelection:t,lexicalSelection:n})}else ue.error("DEBUGGER: [paintRemoteSelections] nested selection from json to lexical is null: ",{selection:t,nestedSelectionJSON:f,lexicalSelection:n})})}else{let f=$e.JSONToLexical(t);if(!f){ue.error("DEBUGGER: [paintRemoteSelections] selection from json to lexical is null: ",{selection:t,lexicalSelection:f});continue}try{this.paintSingleRemoteSelection({editor:Se.getMainEditor(),selectionJSON:t,lexicalSelection:f,selectedNodes:f.getNodes(),isBackward:f.isBackward()})}catch(r){ue.warn("[PAINT REMOTE SELECTION] failed - ",{error:r,fullSelection:t,lexicalSelection:f})}}})}updateRemoteSelections(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";this.shouldUpdateRemoteSelections(s)&&(ue.log("[updateRemoteSelections] "+p,{newRemoteSelections:s}),Promise.resolve().then(()=>{this.paintRemoteSelections(s),this.hideInUI&&this.hideRemoteSelectionsFromUI()}))}clear(){this.gcPrevPaintedRemoteSelections()}getCurrentRemoteSelections(){return this.remoteSelections}hideRemoteSelectionsFromUI(){this.hideInUI||(this.hideInUI=!0);const s=document.querySelectorAll(".codox_remote_selection");for(let p of s)p.classList.add("hidden_codox_remote_selection")}showHiddenRemoteSelectionsInUI(){this.hideInUI=!1;const s=document.querySelectorAll(".hidden_codox_remote_selection");for(let p of s)p.classList.remove("hidden_codox_remote_selection")}}const Oo=new hE;function gE(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).findIndex(g=>g===Ma.editorState)}function Zu(g){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,p=Se.getMainEditorNodesClassesMap();const{klass:t}=p.get(g.type)||{};if(!t)return;const f=t.importJSON(g);if(g.children&&g.children.length)for(const r of g.children)Zu(r,f);return s&&s.getChildrenSize&&s.splice(s.getChildrenSize(),0,[f]),f}function Xu(g){if(g.getChildren)for(let s of g.getChildren())Xu(s);g.remove()}function Ry(g){g.__parent=null,g.__next=null,g.__prev=null}function My(g,s){return!!Se.isLexicalEditorInstance(g)&&!(typeof s!="object"||!s.editorState||(g.update(()=>{try{let p=(0,_e.$getSelection)();const t=g.parseEditorState(s.editorState);if(t.isEmpty())return(0,_e.$getRoot)().clear(),!0;(0,_e.$setSelection)(p),g.setEditorState(t)}catch(p){ue.error("[stateUpdates][updateNestedEditorState] update nested state and selection error: ",p)}}),0))}function mE(g,s){let p=s;for(const t of g)p=p[t];return p}function La(g){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,p=arguments.length>2&&arguments[2]!==void 0&&arguments[2],t=null,f=mE(g,p?s:Se.getMainEditorState().toJSON());return f&&(t=Ba(f)?(0,_e.$getRoot)():In.get(f.codoxId)),t||ue.debug("[WARNING][getLexicalNodeByPathOutOfJSONState] lexical node not found: ",{jsonNode:f,lexicalNode:t,pathArray:g,currentStateJSON:Se.getMainEditorState().toJSON(),newStateJSON:s,codoxNodes:In.nodesToArray(),searchInNewState:p}),t||(p?t:La(g,s,!0))}function Dy(g){ue.log("[applyFullLexicalStateReplace] clear current state and apply new");const s=(0,_e.$getRoot)();s.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 g.root.children)s.append(t(f))}function yE(g){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];if(s.length){ue.log("[applyDeltasToLexicalState] Original Deltas: ",{newStateJSON:g,deltas:JSON.parse(JSON.stringify(s))});for(const p of s){let{p:t}=p;const f=t[t.length-1],r=f==="children",n=typeof f=="number",e=!n&&!r,l=gE(t),i=l!==-1,c=p.hasOwnProperty("lm")&&typeof p.lm=="number";if(t.length)if(i){let o=l-1,a=La(t.slice(0,o),g);if(a){let u=t.slice(0,l),d=g;for(const h of u)d=d[h];let m=ac(t[o]);My(a.getWritable()[m],d)}}else{if(r){let o=p.oi;if(!o){ue.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi attr expected for path",{delta:p});continue}if(o.some(u=>!(!u.hasOwnProperty("text")||typeof u.text=="string"))){ue.warn("[applyDeltasToLexicalState][====WARNING====] SKIPPED. Delta oi children contain invalid text value",{delta:p});continue}t.length=t.length-1;let a=La(t,g);if(!a)continue;if(o.some(u=>!!u.codoxDId)){try{a=a.getWritable()}catch(h){ue.debug("[applyDeltasToLexicalState][shouldUpdateLeaves] getWritable error: ",{err:h,delta:p,fullStateJSON:g});continue}let u={};for(let h of a.getChildren())h.codoxDId?u[h.codoxDId]=h:Xu(h);let d=[],m=["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,w=h>=0?d[h-1]:null;if(y.codoxDId){let x=u[y.codoxDId];if(x){x=x.getWritable();let S=Zu(y);if(ue.debug("[DELTA_DECORATOR_UPDATE]: ",{exisingDecorator:x,tmpDecorator:S}),!S){ue.debug("[DELTA_DECORATOR_UPDATE] UPADATE SKIPPED: ",{exisingDecorator:x,tmpDecorator:S});continue}for(let C in S)if(S.hasOwnProperty(C)&&!m.includes(C))if(Se.isLexicalEditorInstance(S[C])){let k={editorState:S[C].getEditorState().toJSON()};My(x[C],k)}else{let k=Cp(C),D=y[k];if(D===x[C]||!y.hasOwnProperty(k))continue;let I=D!==void 0&&S[C]!==D?D:S[C];k!=="height"&&k!=="width"||S[C]==="inherit"&&D===0&&(I=S[C]),x[C]=I}S.remove(),Ry(x),b=x,delete u[y.codoxDId]}}b||(b=Zu(y),b.codoxDId&&b.__type==="excalidraw"&&b.__data==="[]"&&(b.__data="{}")),b=b.getWritable(),d.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=w.__key,w.__next=b.__key):(b.__prev=w.__key,w.__next=b.__key),a.__size=d.length}for(let h in u){let y=u[h];y=y.getWritable(),Ry(y),Xu(y),delete u[h]}}else{let u=o.map(d=>Zu(d));a.splice(0,a.getChildrenSize(),u)}}if(n){if(p.ld){const o=p.ld,a=In.get(o.codoxId);a.getChildrenSize&&a.getChildrenSize()?Xu(a):a.remove()}if(p.li){let o=Se.getMainEditorNodesClassesMap();const a=p.li,u=o.get(a.type).klass.importJSON(a);if(t.length===1&&t[0]==="root")(0,_e.$getRoot)().splice(0,0,[u]);else{const d=t[t.length-1];t.length=t.length-2;let m=La(t,g);m&&m.splice(d,0,[u])}if(a.children&&a.children.length){let d=function(m,h){const y=o.get(m.type).klass.importJSON(m);if(h.splice(h.getChildrenSize(),0,[y]),m.children&&m.children.length)for(const v of m.children)d(v,y)};for(const m of a.children)d(m,u)}}if(p.oi||p.od){let{p:o,oi:a,od:u}=p,d=La(o,g);if(d)try{let m=d.getWritable();if(a){let h=Object.keys(a);for(let y of h)m[ac(y)]=a[y]}if(u){let h=Object.keys(u);for(let y of h)delete m[ac(y)]}}catch(m){ue.debug("[applyDeltasToLexicalState][delta oi/od] getWritable error: ",{err:m,delta:p})}}if(c){let{p:o,lm:a}=p,u=o[o.length-1],d=a,m=d<u,h=La(o,g);if(h){let y=h.getParent().getChildren(),v=y[u],_=y[d];m?_.insertBefore(v):_.insertAfter(v)}}}if(e){const o=t[t.length-1];let a=ac(o);t.length=t.length-1;let u,d=La(t,g);if(!d){ue.error("Missing node when update node attr from delta: ",{path:t,delta:p,fullStateJSON:g,currentEditorState:Se.getMainEditorState().toJSON()});continue}try{u=d.getWritable()}catch(h){ue.debug("[applyDeltasToLexicalState][shouldUpdateBlockAttr] getWritable error: ",{err:h,delta:p})}if(!u)continue;let m=p.oi;if(o==="format"&&(m=mS(m)),o==="direction"&&(d.hasOwnProperty(a)||(a="__dir")),!u.hasOwnProperty(a)){let h=Object.keys(u);for(let y of h){let v=Cp(y);if(o.startsWith(v)){a=y;break}}}u[a]=m}}else if(p.oi&&p.oi.root)return Dy(p.oi)}}else ue.log("[applyDeltasToLexicalState] stop, no deltas: ",s)}function vE(g){let s=g.clipboardData.getData(vS.paste),p=!1;try{s=JSON.parse(s),typeof s=="object"&&s.nodes&&Array.isArray(s.nodes)&&(p=!0)}catch{return!1}if(!p)return!1;if(p){In.clearPastedIds();const t=f=>{if(f.codoxId&&In.addPastedId(f.codoxId),f.children&&f.children.length)for(const r of f.children)t(r)};for(const f of s.nodes)t(f)}return!1}var bE=g=>{var s={};return on.d(s,g),s};const Ly=bE({useCollaborationContext:()=>jw});var _E=g=>{var s={};return on.d(s,g),s};const ta=_E({LexicalComposerContext:()=>up,useLexicalComposerContext:()=>_r});class By{constructor(){this.blacklist=Object.keys(yy).reduce((s,p)=>{let t=yy[p];return s[p]=t.reduce((f,r)=>(f[r]=r,f),{}),s},{}),this._isBlacklistedFound=!1,this._clientCallback=null}_shouldSkipNode(s){return s instanceof _e.TextNode||s instanceof _e.ParagraphNode||s instanceof _e.RootNode}setClientCallback(s){this._clientCallback=s}removeClientCallback(){this._clientCallback=null}invokeClientCallback(){this._clientCallback&&this._clientCallback()}trackBlacklisted(s){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>2?arguments[2]:void 0;if(jp||p!==to.created||this._isBlacklistedFound||!s||!s.__type||this._shouldSkipNode(s))return;let f=t||Se.getMainEditorState(),r=s.__type,n=this.blacklist[r];n&&f.read(()=>{let e=s.getParent();for(;e!==null;){let l=e?e.__type:null;if(!l)return;if(n[l])return ue.warn("[ContentNestingsWatcher][trackBlacklisted] FOUND: ",{targetNode:s,targetType:r,parent:e,parentType:l,mutationType:p}),void(this._isBlacklistedFound=!0);e=e.getParent()}})}trackBlacklistedInNestedEditor(s){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>3?arguments[3]:void 0;if(p!==to.created||this._isBlacklistedFound||this._shouldSkipNode(s))return;let f=t.__type,r=s.__type;if(!f||!r)return;let n=this.blacklist[r];n&&n[f]&&(this._isBlacklistedFound=!0,ue.warn("[ContentNestingsWatcher][trackBlacklistedInNestedEditor] FOUND: ",{targetNode:s,targetType:r,rootNode:t,rootType:f,mutationType:p}))}isBlacklistedFound(){let s=this._isBlacklistedFound;return s&&(this._isBlacklistedFound=!1),s}}const xE=new By,ea=xE,wE=["editorState","prevEditorState","dirtyElements","dirtyLeaves"];function SE(g,s){if(g==null)return{};var p,t,f=EE(g,s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(g);for(t=0;t<r.length;t++)p=r[t],s.indexOf(p)>=0||{}.propertyIsEnumerable.call(g,p)&&(f[p]=g[p])}return f}function EE(g,s){if(g==null)return{};var p={};for(var t in g)if({}.hasOwnProperty.call(g,t)){if(s.indexOf(t)>=0)continue;p[t]=g[t]}return p}class CE{constructor(){this.nestedEditorsListenersMap={}}_createNestedEditorUpdatesListener(s,p){let t=!1;return function(f){let{editorState:r,prevEditorState:n,dirtyElements:e,dirtyLeaves:l}=f,i=(SE(f,wE),Se.getMainEditor()),c=Se.getMainEditorState(),o=r.toJSON(),a=n.toJSON(),u=Ap(o,a),d=r._selection,m=n._selection,h=!1,y=null,v=Se.isOnlySelectionChanged(e,l),_=s[p];if(ue.debug("[NESTED EDITOR LISTENER] invoked: ",{lexicalNode:s,key:s.__key,onlySelectionChanged:v,newEditorStateJSON:o,prevEditorStateJSON:a,isSameState:u,lexicalSelection:d,prevLexicalSelection:m,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,nestedEditorKey:_._key}),ea.isBlacklistedFound())return t=!0,ue.debug("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - revert to prev state"),Se.scanLexicalNodeForNestedEditorAttribute(s)?(_.update(()=>{try{const b=_.parseEditorState(a);if(b.isEmpty())return(0,_e.$getRoot)().clear(),!0;_.setEditorState(b)}catch(b){ue.error("[NESTED EDITOR LISTENER] BLACKLISTED FOUND - ROLLBACK ERROR: ",b)}}),void ea.invokeClientCallback()):void 0;if(t)t=!1;else{if(s.codoxId||s.codoxDId){let b=null;c.read(()=>{b=$e.getNodeAncestorsCodoxIds(s),!s.codoxId&&s.codoxDId&&b.push(s.codoxDId)}),r.read(()=>{let w=Cp(p),x=$e.lexicalToJSONNested(d,w,b);y=Se.getCurrentNestedSelectionJSON(),h=$e.equalSelectionsJSON(y,x),h||Se.setNestedSelectionJSON(x)})}u&&h||i.update(()=>{try{ue.debug("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE",{mainTags:i._updateTags,nestedTags:_&&_._updateTags,isSameState:u,isSameSelection:h,onlyNestedSelectionChanged:v,mainDirtyLeaves:i._dirtyLeaves.size,mainDirtyElements:i._dirtyElements.size,nestedDirtyLeaves:_._dirtyLeaves.size,nestedDirtyElements:_._dirtyElements.size,lexicalNode:s,lexicalSelection:d,prevLexicalSelection:m,mainEditorTags:i._updateTags,mainEditorTagsSize:i._updateTags.size}),Se.addUpdateTag({fromNestedEditor:!0}),s.markDirty()}catch(b){ue.error("[NESTED EDITOR LISTENER] MARKING DIRTY TO TRIGGER UPDATE - ERROR: ",b)}})}}}_isNestedEditorManaged(s){return!!this.nestedEditorsListenersMap[s]}gc(){for(let s in this.nestedEditorsListenersMap)if(!Se.getLexicalNodeByKey(s)){let p=this.nestedEditorsListenersMap[s];p&&p(),delete this.nestedEditorsListenersMap[s]}}manageNestedEditorInLexicalNode(s){if(this._isNestedEditorManaged(s.getKey()))return;let p=Se.scanLexicalNodeForNestedEditorAttribute(s);if(p){let t=s[p],f=this._createNestedEditorUpdatesListener(s,p),r=[];t._nodes.forEach((l,i,c)=>{let{klass:o}=l,a=t.registerMutationListener(o,u=>{for(let[d,m]of u)if(m===to.created){let h=t.getEditorState()._nodeMap.get(d);h&&ea.trackBlacklistedInNestedEditor(h,m,t.getEditorState(),s)}});r.push(a)});let n=(0,Ds.mergeRegister)(t.registerUpdateListener(f),...r),e=s.getKey();this.nestedEditorsListenersMap[e]=n}}gcNestedEditorListenerInLexicalNode(s){let p=s.getKey(),t=this.nestedEditorsListenersMap[p];t&&(t(),delete this.nestedEditorsListenersMap[p])}manageNestedEditorInClonedLexicalNode(s,p){let t=s.getKey();t!==p.getKey()&&this._isNestedEditorManaged(t)&&(this.gcNestedEditorListenerInLexicalNode(s),this.manageNestedEditorInLexicalNode(p))}setNestedEditorSelection(s){let{nestedSelectionJSON:p,nestedEditor:t}=$e.getNestedSelectionJSONFromMainSelectionJSON(s);if(!t)return!1;let f=!0;return t.update(()=>{try{let r=$e.JSONToLexical(p);(0,_e.$setSelection)(r),ue.debug("[setNestedEditorSelection]: lexical nested selection: ",r)}catch(r){ue.error("[setNestedEditorSelection] set nested selection error: ",r),f=!1}}),f}clearListeners(){for(let s in this.nestedEditorsListenersMap){let p=this.nestedEditorsListenersMap[s];p&&p(),delete this.nestedEditorsListenersMap[s]}}}const kE=new CE,gi=kE,OE=function(g){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];try{let p=(0,_e.createEditor)({namespace:"validation",nodes:[...s],onError:e=>{throw e},parentEditor:null});const t=new By,f=p.parseEditorState(g);if(f.isEmpty())return;p.setEditorState(f);let r=p.getEditorState();const n=r._nodeMap[Symbol.iterator]();for(const e of n){let[l,i]=e;if(i&&(t.trackBlacklisted(i,to.created,r),t.isBlacklistedFound()))throw new Error(bS)}}catch(p){throw p}};class TE{constructor(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}_scanForCellHeaderState(s,p,t,f){if(p.length<f)return null;let r,n=p.some(l=>l.__headerState===Xi.BOTH||l.__headerState===Xi.ROW),e=s.some((l,i)=>{if(l.__size<f)return!1;let c=l.getChildAtIndex(t);return!(!c||c.__headerState!==Xi.BOTH&&c.__headerState!==Xi.COLUMN)});return n&&e?r=Xi.BOTH:n&&!e?r=Xi.ROW:e&&!n&&(r=Xi.COLUMN),r}_isValidCellChildren(s){for(let p of s)if($s(p)||!Us(p)&&Tn(p))return!1;return!0}_createEmptyCell(){let s=(0,Pn.$createTableCellNode)();return s.append((0,_e.$createParagraphNode)()),s}_wrapInvalidCellChildrenIntoParagraph(s){let p=(0,_e.$createParagraphNode)().getWritable(),t=s.getChildren();(s=s.getWritable()).__first=p.__key,s.__last=p.__key,s.__size=1,p.__parent=s.__key,t.forEach((f,r)=>{(f=f.getWritable()).__parent=null,p.append(f)})}_createFixAction_APPEND_CELLS_TO_ROW(s,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - APPEND_CELLS_TO_ROW] invoked: ",{rowKey:s,numOfCellsToAppend:p});let t=(0,_e.$getNodeByKey)(s);for(;p;){let f=(0,Pn.$createTableCellNode)().append((0,_e.$createParagraphNode)());f.setRowSpan(1).setColSpan(1),t.append(f),p--}}}_createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(s){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - ADD_PARAGRAPH_TO_EMPTY_CELL] invoked: ",{cellKey:s}),(0,_e.$getNodeByKey)(s).append((0,_e.$createParagraphNode)())}}_createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(s){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_CELL_CHILDREN_IN_PARAGRAPH] invoked: ",{cellKey:s});let p=(0,_e.$getNodeByKey)(s);this._wrapInvalidCellChildrenIntoParagraph(p)}}_createFixAction_ADD_ROW_CELL_TO_TABLE_NODE(s){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - ADD_ROW_CELL_TO_EMPTY_TABLE_NODE] invoked: ",{tableKey:s});let p=(0,_e.$getNodeByKey)(s),t=(0,Pn.$createTableRowNode)();t.append(this._createEmptyCell()),p.append(t)}}_createFixAction_ADD_CELL_TO_EMPTY_ROW_NODE(s,p){return()=>{for(p||(p=1);p;)(0,_e.$getNodeByKey)(s).append(this._createEmptyCell()),p--}}_createFixAction_WRAP_INVALID_ROW_NODE(s,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_ROW_NODE] invoked: ",{tableKey:s,rowKey:p});let t=(0,_e.$getNodeByKey)(s);if(!t)return;let f=(0,_e.$getNodeByKey)(p);if(!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling();f.__parent=null,f.__prev=null,f.__next=null;let e=(0,Pn.$createTableRowNode)();if((0,Pn.$isTableCellNode)(f))f.getChildren().length?this._isValidCellChildren()||this._wrapInvalidCellChildrenIntoParagraph(f):f.append((0,_e.$createParagraphNode)()),e.append(f);else{let l=this._isValidCellChildren([f]),i=(0,Pn.$createTableCellNode)();if(e.append(i),l)i.append(f);else{let c=(0,_e.$createParagraphNode)();c.append(f),i.append(c)}}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(s,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - WRAP_INVALID_CELL_NODE] invoked: ",{rowKey:s,cellKey:p});let t=(0,_e.$getNodeByKey)(s);if(!t)return;let f=(0,_e.$getNodeByKey)(p);if(f.remove(),f=(0,_e.$createParagraphNode)(),!f)return;t=t.getWritable(),f=f.getWritable();let r=f.getPreviousSibling(),n=f.getNextSibling(),e=(0,Pn.$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 l=(0,_e.$createParagraphNode)();l.append(f),e.append(l)}}}_createFixAction_APPLY_HEADER_STATE_TO_CELL(s,p){return()=>{ue.debug("[TablesValidator][FIX TABLE ACTION - APPLY_HEADER_STATE_TO_CELL] invoked: ",{cellKey:s,headerStateToApply:p});let t=(0,_e.$getNodeByKey)(s);t&&(t=t.getWritable(),t.__headerState=p)}}clear(){this.removeCandidateTableKeys=new Set,this.validateTableCandidateKeys=new Set,this.tableFixActions=[]}tableRemoveEventListener(s){let p=Se.getMainEditorState()._selection;if(ue.debug(`[${s}]`,{selection:p}),!(0,_e.$isRangeSelection)(p))return;let t=[];try{let f=Se.getLexicalNodeByKey(p.anchor.key),r=Se.getLexicalNodeByKey(p.focus.key);f&&r&&(t=p.isBackward()?r.getNodesBetween(f):f.getNodesBetween(r))}catch(f){ue.warn("[TablesValidator][tableRemoveEventListener] get range selection nodes internal lexical error: ",f)}t.forEach(f=>{(0,Pn.$isTableNode)(f)&&this.removeCandidateTableKeys.add(f.__key)})}tableNodeRemoveListener(s){this.removeCandidateTableKeys.has(s)&&this.removeCandidateTableKeys.delete(s)}shouldGCRemovedTables(){return!!this.removeCandidateTableKeys.size}gcRemovedTables(){ue.debug("[TablesValidator][gcRemovedTable] candidate table keys ",{tableKeys:this.removeCandidateTableKeys}),Se.getMainEditor().update(()=>{Array.from(this.removeCandidateTableKeys).forEach(s=>{let p=(0,_e.$getNodeByKey)(s);p&&p.remove()}),this.removeCandidateTableKeys.clear(),(0,_e.$addUpdateTag)(uo.historic)})}tableUpdateListener(s){this.validateTableCandidateKeys.add(s)}tableRowNodeChangesListener(s){let p=arguments.length>1&&arguments[1]!==void 0&&arguments[1],t=Se.getLexicalNodeByKey(s);if(!t)return void(p&&ue.debug("[TablesValidator][tableRowNodeChangesListener] no row node found in lexical: ",{tableRowNodeKey:s}));let f=t.__parent;f?this.validateTableCandidateKeys.add(f):ue.debug("[tableRowNodeChangesListener] no parent table for row node found in lexical: ",{rowNode:t})}tableCellNodeChangesListener(s){let p=Se.getLexicalNodeByKey(s);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 s=Array.from(this.validateTableCandidateKeys);return Se.getMainEditorState().read(()=>{for(let p of s){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,c)=>{if(!(0,Pn.$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 d=[];n.forEach(m=>{let[h,y]=m;a+=y,h--,h&&d.push([h,y])}),n=[...d]}let u=o.map((d,m)=>{if(!(0,Pn.$isTableCellNode)(d))return this.tableFixActions.push(this._createFixAction_WRAP_INVALID_CELL_NODE(i.__key,d.__key)),a++,"invalid_cell_node_should_wrap_in_cell";let h,y=d.getChildren(),v=!y.length;if(v?this.tableFixActions.push(this._createFixAction_ADD_PARAGRAPH_TO_EMPTY_CELL(d.__key)):(h=this._isValidCellChildren(y),h||this.tableFixActions.push(this._createFixAction_WRAP_CELL_CHILDREN_IN_PARAGRAPH(d.__key))),d.__rowSpan>1){let _=d.__rowSpan,b=d.__colSpan;n.push([_-1,b])}if(a+=d.__colSpan,d.__headerState===Xi.NO_STATUS){let _=this._scanForCellHeaderState(f,o,m,r);_&&this.tableFixActions.push(this._createFixAction_APPLY_HEADER_STATE_TO_CELL(d.__key,_))}return{cellKey:d.__key,rowKey:i.__key,tableKey:p,colSpan:d.__colSpan,rowSpan:d.__rowSpan,headerState:d.__headerState,childrenAreValid:h,isEmptyCell:v}});if(a<r){let d=r-a;this.tableFixActions.push(this._createFixAction_APPEND_CELLS_TO_ROW(i.__key,d))}return{realRowLength:a,rowKey:i.__key,tableKey:p,cells:u}}),l=!this.tableFixActions.length;ue[l?"debug":"warn"](`[TablesValidator][validateUpdatedTables] IS TABLE VALID: ${l}`,{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 s=Se.getMainEditor();ue.log("[TablesValidator][fixTablesStructure]: fix actions to apply - count: ",this.tableFixActions.length),s.update(()=>{for(let p of this.tableFixActions)p();this.tableFixActions=[],(0,_e.$addUpdateTag)(uo.historic)})}ensureDocTablesAreValid(s){return this.shouldGCRemovedTables()?(ue.warn("[TablesValidator][GARBAGE COLLECT TABLE NODES AFTER TABLE REMOVAL ATTEMPT]"),this.gcRemovedTables(),!1):!(this.shouldValidateUpdatedTables()&&(ue.debug("[TablesValidator][shouldValidateUpdatedTables] invoked"),!this.validateUpdatedTables()))||(ue.warn("[TablesValidator][shouldValidateUpdatedTables] INVALID LEXICAL TABLE(S) STRUCTURE FOUND - FIXING",{state:JSON.parse(JSON.stringify(s.toJSON()))}),this.fixTablesStructure(),!1)}}const Fo=new TE,AE=["contentChanged"],PE=["state","remoteSelection"];function Fy(g,s){var p=Object.keys(g);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(g);s&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(g,f).enumerable})),p.push.apply(p,t)}return p}function Fs(g){for(var s=1;s<arguments.length;s++){var p=arguments[s]!=null?arguments[s]:{};s%2?Fy(Object(p),!0).forEach(function(t){jE(g,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(p)):Fy(Object(p)).forEach(function(t){Object.defineProperty(g,t,Object.getOwnPropertyDescriptor(p,t))})}return g}function jE(g,s,p){return(s=NE(s))in g?Object.defineProperty(g,s,{value:p,enumerable:!0,configurable:!0,writable:!0}):g[s]=p,g}function NE(g){var s=IE(g,"string");return typeof s=="symbol"?s:s+""}function IE(g,s){if(typeof g!="object"||!g)return g;var p=g[Symbol.toPrimitive];if(p!==void 0){var t=p.call(g,s||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(g)}function zy(g,s){if(g==null)return{};var p,t,f=RE(g,s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(g);for(t=0;t<r.length;t++)p=r[t],s.indexOf(p)>=0||{}.propertyIsEnumerable.call(g,p)&&(f[p]=g[p])}return f}function RE(g,s){if(g==null)return{};var p={};for(var t in g)if({}.hasOwnProperty.call(g,t)){if(s.indexOf(t)>=0)continue;p[t]=g[t]}return p}const jp={DEBUG:!1,VERSION:"1.0.2",NAME:"@codoxhq/lexical-provider",SDKUI_SOURCE_PATH:"../../../sdkui/dist-production2/codox.bundle.js"}.LOCAL==="true";ue.info("MODE: ","production");const ME=g=>async()=>{const{state:s,timestamp:p}=await g();if(!Se.isValidJSONState(s))throw new Error("Invalid state received from fetchDocOnNetworkReconnect hook");const{commentThreads:t,root:f}=s,r={content:{comments:t,root:f},timestamp:p};return ue.info("[decorateFetchOnReconnctHook] hook invoked: ",{returnObj:r}),r};let Qu=0,mi=null,Np=!1,To={},Ip={};const DE=(0,Gt.forwardRef)((g,s)=>{let{onBlacklistedInsert:p}=g;const t=(0,Gt.useContext)(ta.LexicalComposerContext);if(!t)throw new Error("[CodoxCollabPlugin] CodoxCollabPlugin must be inited inside <LexicalComposer> component - LexicalComposerContext is missing");const[f]=(0,ta.useLexicalComposerContext)(),r=(0,Ly.useCollaborationContext)();(0,Gt.useEffect)(()=>{if(ue.debug("[INIT] lexical context check: ",{lexicalContext:t,editor:f}),!f)return;ue.log("[useEffect][editor] Editor instance changed: ",{editor:f,key:f._key}),Se.setMainEditor(f),In.gcAbandonedNodes(),gi.gc(),Fo.clear(),ue.log("[useEffect][editor] subscribe to editor changes");const v=(0,Ds.mergeRegister)(f.registerUpdateListener(m),f.registerCommand(_e.PASTE_COMMAND,vE,_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.UNDO_COMMAND,()=>{Se.setUndoInvoked(!0)},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.REDO_COMMAND,()=>{Se.setRedoInvoked(!0)},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.KEY_DELETE_COMMAND,(b,w)=>{Fo.tableRemoveEventListener("KEY_DELETE_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.KEY_BACKSPACE_COMMAND,(b,w)=>{Fo.tableRemoveEventListener("KEY_BACKSPACE_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),f.registerCommand(_e.CUT_COMMAND,(b,w)=>{Fo.tableRemoveEventListener("CUT_COMMAND")},_e.COMMAND_PRIORITY_CRITICAL),...h());Oo.mount(),Se.alignStateSelectionJSONsFromLatestEditor(),ue.debug("New editor mounted: ",{isCodoxStarted:Se.isCodoxStarted,codoxLexicalEditorManager:Se,nestedEditorsProcessor:gi});let _=f._onError;return f._onError=b=>{ue.error("[ERROR HANDLER WRAPPER] error from editor: ",b),_&&_(b),d()},p&&ea.setClientCallback(p),()=>{Se.getMainEditorKey()&&(ue.debug("Unmount prev editor"),v(),Se.removeMainEditor(),Oo.unmount(),Se.clearJSONs(),On.clear(),Fo.clear(),Se.isCodoxStarted&&(ue.debug("EDITOR USE_EFFECT stopping codox"),n(),Se.setIsCodoxStarted(!1)),ea.removeClientCallback())}},[f]);const n=()=>{Se.isCodoxStarted&&(ue.log("[stopCodoxInstance] stopping codox"),Se.setIsCodoxStarted(!1),jp||li().stop(),Se.clearJSONs(),In.clearAll(),Oo.clear(),On.resetComments(),gi.clearListeners())},e=async v=>{ue.debug("[startCodoxInstance] invoked"),li().createNewInstance(),ue.debug("[startCodoxInstance] instance created");for(let T in Ip)li().instance.on(T,Ip[T]);if(ue.debug("[startCodoxInstance] events subscribed"),To=v,mi=To.docId,!mi)return ue.error("[startCodoxInstance] - start codox skipped - docId is missing",{docId:mi});let _=On.initialCommentsExist();ue.debug("[startCodoxInstance] initCommentsExist: ",_),_&&(On.activateInitialComments(f,In),ue.log("[activateInitialComments] "));let b=Se.getMainEditorState().toJSON();if(!Se.isValidJSONState(b))throw ue.error("[startCodoxInstance] - start codox skipped - invalid init state",{docId:mi,initJSONState:b}),new Error("start codox skipped - invalid init state");ue.log("[startCodoxInstance] starting codox with: ",{docId:mi,initJSONState:b,config:To,codoxComments:On}),Se.currentContentStateJSON||Se.setCurrentContentStateJSON(b),Se.isCodoxStarted&&n();let{username:w,apiKey:x,getServerState:S,domain:C="",demo:k=!1,hooks:D}=To;D&&D.fetchDocOnNetworkReconnect&&(D.fetchDocOnNetworkReconnect=ME(D.fetchDocOnNetworkReconnect));const I=zy(D,AE);await li().start(li().createConfig(Fs(Fs({},To),{},{docId:mi,username:w,apiKey:x,domain:C,hooks:Fs({syncState:c,getState:i,getServerState:async()=>await S(mi)},I),editorInstanceHooks:{getSelection:()=>Se.getCurrentActiveSelectionJSON(),setSelection:T=>o(T),getState:i,setState:T=>{const{root:R,comments:P}=T;ue.info("DEBUG: EDITOR INSTANCE setState:",{fullState:T}),a({state:{root:R},selection:Se.getCurrentActiveSelectionJSON()},Oo.getCurrentRemoteSelections()),On.setAllComments(P)},enableEditor:()=>{Se.disableEditorReadOnlyMode()},disableEditor:()=>{Se.enableEditorReadOnlyMode(),Oo.updateRemoteSelections([])},getContent:()=>{let T=Se.composeFullStateWithRootAndComments();return ue.info("[getContent]: ",T),{state:T}}},appServer:To.appServer,demo:k}))),ue.log("[startCodoxInstance] codox started - first sync invoking"),Se.setIsCodoxStarted(!0),r.clientID=To.username,r.name=To.username,u()},l=()=>{let v=Se.composeFullStateWithRootAndComments({directlyFromEditor:!0});e(v)},i=()=>({state:Fs(Fs({},Se.getMainEditorState().toJSON()),{},{comments:On.getAllComments()}),docId:mi}),c=v=>{if(!Se.isCodoxStarted)return;ue.log("[SYNC_STATE]: Before sync payload = ",v);const _=li().sync({meta:v}),{state:b,remoteSelection:w=[]}=_,x=zy(_,PE);if(ue.log("[SYNC_STATE]: After sync",{state:b,remoteSelection:w,rest:x}),!b)return ue.error("[SYNC_STATE] abort apply - synced state is not valid - restarting codox"),l();const S=b.state;ue.log("[SYNC_STATE] synced state: ",{synced:JSON.parse(JSON.stringify(S))});let{stateFromSync:C,commentsFromSync:k}=Se.extractStateAndCommentsFromSynced(S);if(!Se.isValidJSONState(C.state))return ue.error("[SYNC_STATE] - invalid state from sync - local update skipped - restarting codox",{contentState:C.state}),l();a(C,w),On.setAllComments(k)},o=v=>{if(!Se.isCodoxStarted||(ue.log("[setLocalSelectionFromSync] synced selection: ",{syncedSelectionJSON:v}),!Pp.validateJSONSelection(v,kp.local)))return;let _=Se.getCurrentActiveSelectionJSON();if($e.equalSelectionsJSON(_,v))return void ue.log("[setLocalSelectionFromSync] STOP - local and synced selections are equal");let b=$e.isNestedSelectionJSON(v);f.update(()=>{ue.log("[setLocalSelectionFromSync] json selection to apply: ",{syncedSelectionJSON:v});const w=$e.JSONToLexical(v);if(ue.log("[setLocalSelectionFromSync] lexical selection to apply: ",w),b){let x=gi.setNestedEditorSelection(v);Se.setNestedSelectionJSON(x?v:null)}else(0,_e.$setSelection)(w),Se.setMainSelectionJSON(v);ue.log("[setLocalSelectionFromSync] selection updated. latest selection: ",{latestSelectionJSON:Se.getCurrentActiveSelectionJSON()})})},a=function(){let{state:v,selection:_,stateReplace:b}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],x=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",S=Se.getCurrentContentStateJSON();ue.log("[updateEditor] invoked: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:JSON.parse(JSON.stringify(v)),newSelectionJSON:_,remoteSelection:w,stateReplace:b,editor:f}),_===void 0&&ue.error("SELECTION FROm SYNC IS UNDEFINED - will default prev selection",_);const C=Ap(S,v),k=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),_);f.update(()=>{if(Se.addUpdateTag({isSameState:C,isSameSelection:k,updateTag:x}),b)ue.log("[updateEditor] invoke full stateReplace after sync"),Dy(v),S=Se.setCurrentContentStateJSON(v),(0,_e.$addUpdateTag)("codox_sync_state_changes"),ue.log("[updateEditor] state updated: ",S);else{ue.log("[updateEditor] invoke deltas diff");let I=li().diff(S,v,{keyNames:{default:"codoxId"}});ue.log("JSON_DIFF_ANALYSIS: ",{currentContentStateJSON:JSON.parse(JSON.stringify(S)),newStateJSON:v,deltas:I&&JSON.parse(JSON.stringify(I))}),I&&I.length&&(ue.log("[updateEditor] apply deltas to lexical state"),yE(v,I),S=Se.setCurrentContentStateJSON(v),(0,_e.$addUpdateTag)("codox_sync_state_changes"),ue.log("[updateEditor] state updated: ",S))}let D=$e.isNestedSelectionJSON(_);if(Pp.validateJSONSelection(_,kp.local)||(_=Se.getCurrentActiveSelectionJSON()),D){let I=gi.setNestedEditorSelection(_);Se.setNestedSelectionJSON(I?_:null),ue.log("[updateEditor] nested selection updated",I?_:null)}else if(_!==void 0){const I=$e.JSONToLexical(_);ue.log("[updateEditor] updated selection to apply: ",{isSameSelection:k,newSelectionJSON:_,lexicalSelection:I}),(0,_e.$setSelection)(I),Se.setMainSelectionJSON(_),ue.log("[updateEditor] selection updated",_)}},{onUpdate:()=>{C||Oo.updateRemoteSelections(w,"from onUpdate hook")}}),C&&Oo.updateRemoteSelections(w,"from direct updateEditor")},u=function(){let v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";if(!Se.isCodoxStarted)return;ue.log("[invokeSync] SYNC INVOKED ",{upd_call_counter:v});let _=Se.composeFullStateWithRootAndComments();const b={docId:mi,state:{state:_,selection:Se.getCurrentActiveSelectionJSON()}};ue.log("[codoxSync]: Before sync",{local:b,upd_call_counter:v}),ue.log("[codoxSync]: Before sync state",JSON.parse(JSON.stringify(b.state)));let{state:w,remoteSelection:x=[],changes:S}=li().sync({state:b,meta:{}});if(ue.log("[codoxSync]: After sync",{afterSyncState:JSON.parse(JSON.stringify(w)),remoteSelection:x,changes:S}),!w)return ue.error("[codoxSync] abort apply - synced state is not valid - restarting codox "),l();const C=w.state;ue.log("[codoxSync]: synced state: ",JSON.parse(JSON.stringify(C)),v);let{stateFromSync:k,commentsFromSync:D}=Se.extractStateAndCommentsFromSynced(C);if(!Se.isValidJSONState(k.state))return ue.error("[invokeSync] - invalid state from sync - local update skipped - restarting codox",{contentState:k.state}),l();a(k,x),On.setAllComments(D)},d=()=>{ue.warn("[rollbackStateDuringUpdateError] rollback invoked"),ue.log("[rollbackStateDuringUpdateError] values: ",{prevState:Se.getPrevContentStateJSON(),currentState:Se.getCurrentContentStateJSON(),prevSelection:Se.getPrevMainSelectionJSON(),currentSelection:Se.getCurrentActiveSelectionJSON(),codoxComments:On});let v=Se.getPrevContentStateJSON(),_=Se.getPrevMainSelectionJSON();a({state:v,selection:_},Oo.getCurrentRemoteSelections(),uo.historic);let b=Se.undoInvoked(),w=Se.redoInvoked();On.gcAbandonedNodeKeys(Se.getMainEditorState()._nodeMap),b&&f.dispatchCommand(_e.CAN_REDO_COMMAND,!1),w&&f.dispatchCommand(_e.CAN_UNDO_COMMAND,!1)},m=v=>{let{editorState:_,prevEditorState:b,tags:w,dirtyElements:x,dirtyLeaves:S}=v;if(Np)return Np=!1,void ue.debug("[editorUpdatesListener] invoked blacklisted queued selection change - stop");if(ea.isBlacklistedFound())return Np=!0,ue.warn("[editorUpdatesListener] BLACKLISTED CHANGES FOUND - revert back to prev state"),((J,G)=>{let z=null,F=null;G.read(()=>{z=$e.lexicalToJSON(G._selection),F=G.toJSON()});let O=null,j=null;J.read(()=>{let L=(0,_e.$getSelection)();j=$e.lexicalToJSON(L),O=J.toJSON()}),Se.setCurrentContentStateJSON(O),Se.setMainSelectionJSON(j),a({state:F,selection:z},Oo.getCurrentRemoteSelections(),uo.historic),f.dispatchCommand(_e.CAN_REDO_COMMAND,!1),f.dispatchCommand(_e.CAN_UNDO_COMMAND,!1)})(_,b),void ea.invokeClientCallback();if(!Fo.ensureDocTablesAreValid(_))return;Qu++,ue.log("[editorUpdatesListener] invoked by lexical. call counter: ",{upd_call_counter:Qu,isCodoxStarted:Se.isCodoxStarted});let C=Se.isOnlySelectionChanged(x,S),k=null,D=null,I=null,T=null,R=Se.getCurrentContentStateJSON(),P=w.has("codox_sync_state_changes"),$=w.has(sc),q=Se.undoInvoked(),H=Se.redoInvoked(),M=Se.canUndo(),W=Se.canRedo();k=_.toJSON(),D=b.toJSON(),b.read(()=>{T=$e.lexicalToJSON(b._selection)}),_.read(()=>{let J=(0,_e.$getSelection)();I=$e.lexicalToJSON(J);let G=$e.JSONToLexical(I),z=J===null&&G===null||J.is(G);ue.log("[editorUpdatesListener] new values: ",{newContentStateJSON:k,currentContentStateJSON:JSON.parse(JSON.stringify(R)),prevContentStateJSON:JSON.parse(JSON.stringify(D)),currentCommentsJSON:JSON.parse(JSON.stringify(On.getAllComments())),newSelectionJSON:JSON.parse(JSON.stringify(I)),currentMainSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentMainSelectionJSON())),currentNestedSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentNestedSelectionJSON())),currentActiveSelectionJSON:JSON.parse(JSON.stringify(Se.getCurrentActiveSelectionJSON())),lexicalSelection:J,convertedBackMainSelection:G,isMainSelectionConvertionCorrect:z,nodes:f._editorState._nodeMap,fullEditor:f,codoxNodesMap:In.toArray(),codoxComments:On,isUpdateFromSync:P,isUpdateFromComments:$,tags:w,onlySelectionChanged:C,undoInvoked:q,redoInvoked:H,canUndo:M,canRedo:W})});let V=Ap(R,k),A=$e.equalSelectionsJSON(Se.getCurrentActiveSelectionJSON(),I);ue.log("[editorUpdatesListener] compares: ",{isStateSame:V,isSelectionSame:A});let U=V&&A&&!$;if(!V||$||P){let J=Fs({},V?R:k),G=On.getAllComments();G.length&&(J.commentThreads=G);let z={source:P?vy.remote:vy.local,content:J};To.hooks&&To.hooks.contentChanged&&To.hooks.contentChanged(z),li().instance.emit("content_changed",z)}if(U)ue.log("[editorUpdatesListener] STOP - state and selection and comments are same ",Qu);else if(Se.undoInvoked()&&Se.setUndoInvoked(!1),Se.redoInvoked()&&Se.setRedoInvoked(!1),Se.setCurrentContentStateJSON(k),Se.setPrevContentStateJSON(D),Se.setMainSelectionJSON(I),Se.setPrevMainSelectionJSON(T),jp){let J=Se.getCurrentActiveSelectionJSON();a({state:Se.getCurrentContentStateJSON(),selection:J},[])}else u(Qu)},h=()=>{let v=[];return Se.getMainEditorNodesClassesMap().forEach((_,b,w)=>{let{klass:x}=_,S=f.registerMutationListener(x,C=>{for(let[k,D]of C){if(!to[D])continue;const I=Se.getLexicalNodeByKey(k);if(D===to.created&&I&&ea.trackBlacklisted(I,D),x.name===Pn.TableNode.name&&(D===to.destroyed?Fo.tableNodeRemoveListener(k):Fo.tableUpdateListener(k)),x.name===Pn.TableRowNode.name&&D!==to.destroyed&&Fo.tableRowNodeChangesListener(k,D===to.updated),x.name===Pn.TableCellNode.name&&D===to.updated&&Fo.tableCellNodeChangesListener(k),x.name===co.MarkNode.name&&(ue.debug("[MUTATION LISTENER] MARK node: ",{nodeKey:k,node:I,mutationType:D,codoxComments:On}),D===to.destroyed?On.removeRelatedNodeKey(k):I&&On.addRelatedNodeKey(I.__key,I.__ids,D===to.created)),I&&I.codoxId){if(D===to.destroyed)return void(I.codoxId&&In.remove(I.codoxId));Ky(I)||ue.warn("[MutationListener Error] duplicating codoxId detected - such codoxId already exists in codoxNodesMap - updating node ref to latest: ",{mutationType:D,node:I}),In.add(I.codoxId,I)}}v.push(S)})}),v},y={start:e,stop:n,on:(v,_)=>{ue.info(`Subscribing client to codox ${v} event`),Ip[v]=_},cursor:{hide:()=>{Oo.hideRemoteSelectionsFromUI()},show:()=>{Oo.showHiddenRemoteSelectionsInUI()}},initComments:v=>{On.setInitialComments(v)}};return(0,Gt.useImperativeHandle)(s,()=>y),null}),LE=DE,BE=["comments"];function Uy(g,s){var p=Object.keys(g);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(g);s&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(g,f).enumerable})),p.push.apply(p,t)}return p}function Rp(g){for(var s=1;s<arguments.length;s++){var p=arguments[s]!=null?arguments[s]:{};s%2?Uy(Object(p),!0).forEach(function(t){FE(g,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(p)):Uy(Object(p)).forEach(function(t){Object.defineProperty(g,t,Object.getOwnPropertyDescriptor(p,t))})}return g}function FE(g,s,p){return(s=zE(s))in g?Object.defineProperty(g,s,{value:p,enumerable:!0,configurable:!0,writable:!0}):g[s]=p,g}function zE(g){var s=UE(g,"string");return typeof s=="symbol"?s:s+""}function UE(g,s){if(typeof g!="object"||!g)return g;var p=g[Symbol.toPrimitive];if(p!==void 0){var t=p.call(g,s||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(g)}function $E(g,s){if(g==null)return{};var p,t,f=HE(g,s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(g);for(t=0;t<r.length;t++)p=r[t],s.indexOf(p)>=0||{}.propertyIsEnumerable.call(g,p)&&(f[p]=g[p])}return f}function HE(g,s){if(g==null)return{};var p={};for(var t in g)if({}.hasOwnProperty.call(g,t)){if(s.indexOf(t)>=0)continue;p[t]=g[t]}return p}class qE extends gy{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(s){this._canUndo=s}setCanRedo(s){this._canRedo=s}canUndo(){return this._canUndo}canRedo(){return this._canRedo}setUndoInvoked(s){this._undoInvoked=s}setRedoInvoked(s){this._redoInvoked=s}undoInvoked(){return this._undoInvoked}redoInvoked(){return this._redoInvoked}setIsCodoxStarted(){let s=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this._isCodoxStarted=s}get isCodoxStarted(){return this._isCodoxStarted}getMainEditorKey(){return this.mainEditorKey}setMainEditor(s){this.mainEditor=s,this.mainEditorKey=s._key}clearJSONs(){ue.debug("[CodoxLexicalEditorManager][clearJSONs] invoked"),this.currentContentStateJSON=null,this.currentMainSelectionJSON=null,this.currentNestedSelectionJSON=null,this.prevContentStateJSON=null,this.prevMainSelectionJSON=null}removeMainEditor(){this.mainEditor=null,this.mainEditorKey=null,this._undoInvoked=!1,this._redoInvoked=!1,this._canUndo=!1,this._canRedo=!1,super.clear()}getMainEditor(){return this.mainEditor}alignStateSelectionJSONsFromLatestEditor(){this.getMainEditorState().read(()=>{this.setCurrentContentStateJSON(this.getMainEditorState().toJSON()),this.setMainSelectionJSON($e.lexicalToJSON((0,_e.$getSelection)()))})}mainEditorExists(){return!!this.mainEditor}getMainEditorState(){return this.mainEditor?this.mainEditor.getEditorState():{}}getMainEditorNodesClassesMap(){return this.mainEditor?this.mainEditor._nodes:new Map}getLexicalNodeByKey(s){return this.mainEditor?this.getMainEditorState()._nodeMap.get(s):null}isLexicalEditorInstance(s){return s&&typeof s=="object"&&!!s.setEditorState}setCurrentContentStateJSON(s){return this.currentContentStateJSON=s,this.currentContentStateJSON}getCurrentContentStateJSON(){return this.currentContentStateJSON}setPrevContentStateJSON(s){this.prevContentStateJSON=s}getPrevContentStateJSON(){return this.prevContentStateJSON}setMainSelectionJSON(s){this.currentMainSelectionJSON=s,this.currentMainSelectionJSON&&this.currentNestedSelectionJSON&&(this.currentNestedSelectionJSON=null)}setNestedSelectionJSON(s){this.currentNestedSelectionJSON=s,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(s){this.prevMainSelectionJSON=s}getPrevMainSelectionJSON(){return this.prevMainSelectionJSON}extractStateAndCommentsFromSynced(s){let{state:{comments:p},selection:t,stateReplace:f}=s;return{stateFromSync:{state:Rp({},$E(s.state,BE)),selection:t,stateReplace:f},commentsFromSync:p}}composeFullStateWithRootAndComments(){let{directlyFromEditor:s=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Rp(Rp({},s?this.getMainEditorState().toJSON():this.currentContentStateJSON),{},{comments:On.getAllComments()})}isValidJSONState(s){let p=!1;try{if(!s)throw new Error("State is undefined");if(!s.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,l=t.get(e.type);if(!l)throw new Error(`Node with type "${e.type}" is not registered in editor`);let{klass:i}=l;if(n==="root"){let c=i.prototype instanceof _e.ElementNode,o=i.prototype instanceof _e.DecoratorNode;if(!c&&!o)throw new Error("State root node can have only element nodes as children")}if(e.children)for(let c of e.children)f(c,e.type)};f(s.root),p=!0}catch(t){ue.error("[isValidJSONState] invalid state found: ",t.message),p=!1}return p}scanLexicalNodeForNestedEditorAttribute(s){for(let p in s){let t=s[p];if(this.isLexicalEditorInstance(t))return p}return""}isOnlySelectionChanged(s,p){return s.size===0&&p.size===0}addUpdateTag(){let{isSameState:s,isSameSelection:p,fromNestedEditor:t=!1,updateTag:f=""}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return f?(ue.log(`[addUpdateTag] explicit add of tag "${f}" `),void(0,_e.$addUpdateTag)(f)):t?(ue.log(`[addUpdateTag] add "${uo.historic}" tag - change invoked by nested editor`),void(0,_e.$addUpdateTag)(uo.historic)):void(s?(ue.log(`[addUpdateTag] add "${uo.historic}" tag - state is same`),(0,_e.$addUpdateTag)(uo.historic)):(ue.log(`[addUpdateTag] add "${uo.historyMerge}" tag - state is different`),(0,_e.$addUpdateTag)(uo.historyMerge)))}enableEditorReadOnlyMode(){this.mainEditor&&this.mainEditor.isEditable()&&this.mainEditor.setEditable(!1)}disableEditorReadOnlyMode(){this.mainEditor&&(this.mainEditor.isEditable()||this.mainEditor.setEditable(!0))}}const WE=new qE,Se=WE;class JE{constructor(){this._nodesMap=new Map,this._pastedNodesCodoxIds=new Set}get size(){return this._nodesMap.size}add(s,p){this._nodesMap.set(s,p)}get(s){return this._nodesMap.get(s)||null}remove(s){this._nodesMap.delete(s)}has(s){return this._nodesMap.has(s)}nodesToArray(){return Array.from(this._nodesMap.values())}keysToArray(){return Array.from(this._nodesMap.keys())}toArray(){return Array.from(this._nodesMap.entries())}addPastedId(s){this._pastedNodesCodoxIds.add(s)}removePastedId(s){this._pastedNodesCodoxIds.delete(s)}hasPastedId(s){return this._pastedNodesCodoxIds.has(s)}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 s=Se.getMainEditorState();if(!s._nodeMap)return;let p=this.nodesToArray();for(let t of p)s._nodeMap.has(t.__key)||this.remove(t.codoxId)}}const VE=new JE,In=VE;function $y(g,s){var p=Object.keys(g);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(g);s&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(g,f).enumerable})),p.push.apply(p,t)}return p}function Hy(g){for(var s=1;s<arguments.length;s++){var p=arguments[s]!=null?arguments[s]:{};s%2?$y(Object(p),!0).forEach(function(t){KE(g,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(p)):$y(Object(p)).forEach(function(t){Object.defineProperty(g,t,Object.getOwnPropertyDescriptor(p,t))})}return g}function KE(g,s,p){return(s=GE(s))in g?Object.defineProperty(g,s,{value:p,enumerable:!0,configurable:!0,writable:!0}):g[s]=p,g}function GE(g){var s=YE(g,"string");return typeof s=="symbol"?s:s+""}function YE(g,s){if(typeof g!="object"||!g)return g;var p=g[Symbol.toPrimitive];if(p!==void 0){var t=p.call(g,s||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(g)}const Mp=()=>oS(),qy=g=>typeof g=="number";function zs(g){let s=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 g.apply(this,f)};return Object.defineProperty(p,"name",{value:s,writable:!0}),p}const Ba=g=>g.__type==="root"||g.type==="root",Wy=g=>Ba(g.getParent()),Kn=g=>g.__type===Vu.text||g.type===Vu.text||g.hasOwnProperty("__text")||g.hasOwnProperty("text"),Us=g=>(0,_e.$isElementNode)(g),$s=g=>(0,Pn.$isTableNode)(g)||(0,Pn.$isTableRowNode)(g)||(0,Pn.$isTableCellNode)(g),ZE=g=>!g.getChildren,Jy=g=>!!g.getChildren,Tn=g=>(0,_e.$isDecoratorNode)(g),cc=g=>(0,Yw.$isLinkNode)(g),uc=g=>g.__type==="mark"||g.type==="mark",Dp=g=>(0,_e.$isLineBreakNode)(g),na=g=>Kn(g)||Dp(g),Lp=g=>g.__type===Vu.horizontalrule||g.type===Vu.horizontalrule,Vy=g=>{if(na(g)||cc(g)||uc(g))return!1;if(!g.__parent||g.__parent==="root"||(0,_e.$isParagraphNode)(g))return!0;let s=g.getParent().getChildren();return s.length===1&&s[0].__key===g.__key?!((Tn(g)||cc(g)||uc(g))&&!Lp(g)):!s.some(p=>{let t=Lp(p);return p.__key!==g.__key&&(na(p)||Tn(p)&&!t||cc(p)||uc(p))})},Ky=g=>{const s=In.get(g.codoxId);return!s||g.__key===s.__key},Hs=function(g){const s=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||Mp();g.codoxId=s,In.add(s,g)},Gy=g=>{In.remove(g.codoxId),delete g.codoxId},XE=g=>{if(!Jy(g)||!g.getChildrenSize())return;const s=g.getChildren();if(s.some(f=>!!(0,_e.$isParagraphNode)(f)))return;let p=!1,t=[];for(let f of s)(na(f)||Tn(f)||cc(f)||uc(f))&&!p&&(Lp(f)||(p=!0)),(Jy(f)||Tn(f))&&t.push(f);for(let f of t)p||f.codoxId?p&&f.codoxId&&(f=f.getWritable(),Gy(f)):(f=f.getWritable(),Hs(f))},QE=g=>{const s=Hy({},g);for(const p in g)g[p]===void 0&&g.hasOwnProperty(p)&&delete s[p];return s},t2=g=>{const s=`__nativeCreateDOM_${g.name}`;g.prototype[s]=zs(g.prototype.createDOM,s),g.prototype.createDOM=function(p,t){if(Vy(this))if(this.codoxId){if(!Ky(this)){let r=In.get(this.codoxId);r.__type===this.__type&&this.isAttached()&&!r.isAttached()?(ue.warn("[createDOM][Non-unique codoxId] overwrite abandoned existing node with latest: ",{latestNode:this,existingNode:r}),In.add(this.codoxId,this)):Hs(this)}}else Hs(this);else this.codoxId&&Gy(this);Tn(this)&&!this.codoxDId&&(this.codoxDId=Mp()),gi.manageNestedEditorInLexicalNode(this);let f=this[s](p,t);return f.__codox_track=!0,f}},e2=g=>{const s=`__nativeUpdateDOM_${g.name}`;return g.prototype[s]=zs(g.prototype.updateDOM,s),g.prototype.updateDOM=function(){const p=this[s](...arguments);return XE(this),p},g},n2=g=>{const s=`__nativeRemove_${g.name}`;return g.prototype[s]=zs(g.prototype.remove,s),g.prototype.remove=function(){const p=this.codoxId;return p&&In.remove(p),gi.gcNestedEditorListenerInLexicalNode(this),this[s](...arguments)},g},r2=g=>{const s=`__nativeExportJSON_${g.name}`;g.prototype[s]=zs(g.prototype.exportJSON,s),g.prototype.exportJSON=function(){const p=this[s]();return this.codoxId&&(p.codoxId=this.codoxId),this.codoxDId&&(p.codoxDId=this.codoxDId),Kn(this)&&qy(p.format)&&this.hasFormat&&(p.format=gS(this)),QE(p)}},o2=g=>{const s="__nativeImportJSON";g[s]=zs(g.importJSON,s),g.importJSON=function(p){const t=Hy({},p);Kn(t)&&!qy(t.format)&&(t.format=hS(t.format));const f=g[s](t);gi.manageNestedEditorInLexicalNode(f);const r=Vy(f);return r&&t.codoxId&&(In.hasPastedId(t.codoxId)&&In.has(t.codoxId)?(In.removePastedId(t.codoxId),Hs(f)):Hs(f,t.codoxId)),r&&!f.codoxId&&Hs(f),t.codoxDId&&(f.codoxDId=t.codoxDId),f}},i2=g=>{const s="__nativeClone";g[s]=zs(g.clone,s),g.clone=function(p){const t=g[s](p);return p.codoxId&&(t.codoxId=p.codoxId),p.codoxDId&&(t.codoxDId=p.codoxDId),gi.manageNestedEditorInClonedLexicalNode(p,t),t}},a2=g=>{let s=!1,p=!1,t=!1,f=!1;g.forEach(n=>{n.name===_e.TextNode.name?s=!0:n.name===_e.ParagraphNode.name?p=!0:n.name===_e.LineBreakNode.name?t=!0:n.name===co.MarkNode.name&&(f=!0)});let r=[];return s||r.push(_e.TextNode),p||r.push(_e.ParagraphNode),t||r.push(_e.LineBreakNode),f||r.push(co.MarkNode),r.length?[...r,...g]:g},s2=function(){return a2(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).map(g=>(g.hasOwnProperty("__isCodoxExtended")||(t2(g),e2(g),r2(g),n2(g),o2(g),i2(g),Object.defineProperty(g,"__isCodoxExtended",{value:!0,writable:!1})),g))};var td=on(777),qs={};qs.styleTagTransform=hi(),qs.setAttributes=fi(),qs.insert=di().bind(null,"head"),qs.domAPI=ui(),qs.insertStyleElement=pi(),ci()(td.A,qs),td.A&&td.A.locals&&td.A.locals;var l2=g=>{var s={};return on.d(s,g),s};const c2=l2({AutoFocusPlugin:()=>r0});var u2=g=>{var s={};return on.d(s,g),s};const d2=u2({ClearEditorPlugin:()=>Iw});var f2=g=>{var s={};return on.d(s,g),s};const p2=f2({LexicalComposer:()=>n0});var h2=g=>{var s={};return on.d(s,g),s};const Yy=h2({default:()=>Mw});var g2=g=>{var s={};return on.d(s,g),s};const m2=g2({HistoryPlugin:()=>_0});var y2=g=>{var s={};return on.d(s,g),s};const v2=y2({OnChangePlugin:()=>Lw});var b2=g=>{var s={};return on.d(s,g),s};const _2=b2({PlainTextPlugin:()=>Ww});var x2=g=>{var s={};return on.d(s,g),s};const Zy=x2({$isRootTextContentEmpty:()=>w0,$rootTextContent:()=>x0});var w2=g=>{var s={};return on.d(s,g),s};const Ws=w2({createPortal:()=>i_.createPortal}),S2=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,E2=S2?Gt.useLayoutEffect:Gt.useEffect,Xy=E2;var ed=on(253),Js={};Js.styleTagTransform=hi(),Js.setAttributes=fi(),Js.insert=di().bind(null,"head"),Js.domAPI=ui(),Js.insertStyleElement=pi(),ci()(ed.A,Js),ed.A&&ed.A.locals&&ed.A.locals;function C2(g){let{onClose:s,children:p,title:t,closeOnClickOutside:f}=g;const r=(0,Gt.useRef)(null);return(0,Gt.useEffect)(()=>{r.current!==null&&r.current.focus()},[]),(0,Gt.useEffect)(()=>{let n=null;const e=c=>{c.key==="Escape"&&s()},l=c=>{const o=c.target;r.current!==null&&!r.current.contains(o)&&f&&s()},i=r.current;return i!==null&&(n=i.parentElement,n!==null&&n.addEventListener("click",l)),window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e),n!==null&&(n==null||n.removeEventListener("click",l))}},[f,s]),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:s},"X"),Gt.createElement("div",{className:"Modal__content"},p)))}function k2(g){let{onClose:s,children:p,title:t,closeOnClickOutside:f=!1}=g;return(0,Ws.createPortal)(Gt.createElement(C2,{onClose:s,title:t,closeOnClickOutside:f},p),document.body)}function Qy(){const[g,s]=(0,Gt.useState)(null),p=(0,Gt.useCallback)(()=>{s(null)},[]),t=(0,Gt.useMemo)(()=>{if(g===null)return null;const{title:r,content:n,closeOnClickOutside:e}=g;return Gt.createElement(k2,{onClose:p,title:r,closeOnClickOutside:e},n)},[g,p]),f=(0,Gt.useCallback)(function(r,n){s({closeOnClickOutside:arguments.length>2&&arguments[2]!==void 0&&arguments[2],content:n(p),title:r})},[p]);return[t,f]}var nd=on(191),Vs={};Vs.styleTagTransform=hi(),Vs.setAttributes=fi(),Vs.insert=di().bind(null,"head"),Vs.domAPI=ui(),Vs.insertStyleElement=pi(),ci()(nd.A,Vs),nd.A&&nd.A.locals&&nd.A.locals;const O2={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"}},T2=O2;var rd=on(72),Ks={};Ks.styleTagTransform=hi(),Ks.setAttributes=fi(),Ks.insert=di().bind(null,"head"),Ks.domAPI=ui(),Ks.insertStyleElement=pi(),ci()(rd.A,Ks),rd.A&&rd.A.locals&&rd.A.locals;function A2(){for(var g=arguments.length,s=new Array(g),p=0;p<g;p++)s[p]=arguments[p];return s.filter(Boolean).join(" ")}function Bp(){return Bp=Object.assign?Object.assign.bind():function(g){for(var s=1;s<arguments.length;s++){var p=arguments[s];for(var t in p)({}).hasOwnProperty.call(p,t)&&(g[t]=p[t])}return g},Bp.apply(null,arguments)}function ra(g){let{"data-test-id":s,children:p,className:t,onClick:f,disabled:r,small:n,title:e}=g;return Gt.createElement("button",Bp({disabled:r,className:A2("Button__root",r&&"Button__disabled",n&&"Button__small",t),onClick:f,title:e,"aria-label":e},s&&{"data-test-id":s}),p)}var od=on(129),Gs={};Gs.styleTagTransform=hi(),Gs.setAttributes=fi(),Gs.insert=di().bind(null,"head"),Gs.domAPI=ui(),Gs.insertStyleElement=pi(),ci()(od.A,Gs),od.A&&od.A.locals&&od.A.locals;var P2=g=>{var s={};return on.d(s,g),s};const j2=P2({ContentEditable:()=>o0});function N2(g){let{className:s}=g;return Gt.createElement(j2.ContentEditable,{className:s||"ContentEditable__root"})}var id=on(457),Ys={};Ys.styleTagTransform=hi(),Ys.setAttributes=fi(),Ys.insert=di().bind(null,"head"),Ys.domAPI=ui(),Ys.insertStyleElement=pi(),ci()(id.A,Ys),id.A&&id.A.locals&&id.A.locals;function I2(g){let{children:s,className:p}=g;return Gt.createElement("div",{className:p||"Placeholder__root"},s)}const R2=Yy.default.LexicalErrorBoundary||Yy.default,M2=()=>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"})),tv=()=>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"})),D2=()=>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"})),L2=()=>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 ev(g,s,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:g,author:s,codoxId:p,timeStamp:t,deleted:f})}function B2(g,s,p){return On.createNewThreadObj({quote:g,comments:s,codoxId:p})}function F2(g){let{anchorKey:s,editor:p,onAddComment:t}=g;const f=(0,Gt.useRef)(null),r=(0,Gt.useCallback)(()=>{const n=f.current,e=p.getRootElement(),l=p.getElementByKey(s);if(n!==null&&e!==null&&l!==null){const{right:i}=e.getBoundingClientRect(),{top:c}=l.getBoundingClientRect();n.style.left=i-20+"px",n.style.top=c-30+"px"}},[s,p]);return(0,Gt.useEffect)(()=>(window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}),[p,r]),Xy(()=>{r()},[s,p,r]),Gt.createElement("div",{className:"CodoxCommentPlugin_AddCommentBox",ref:f},Gt.createElement("button",{className:"CodoxCommentPlugin_AddCommentBox_button",onClick:t},Gt.createElement(M2,null)))}function z2(g){let{onEscape:s}=g;const[p]=(0,ta.useLexicalComposerContext)();return(0,Gt.useEffect)(()=>p.registerCommand(_e.KEY_ESCAPE_COMMAND,t=>s(t),2),[p,s]),null}function U2(g){let{editorRef:s}=g;const[p]=(0,ta.useLexicalComposerContext)();return typeof s=="function"?s(p):typeof s=="object"&&(s.current=p),null}function nv(g){let{className:s,autoFocus:p,onEscape:t,onChange:f,editorRef:r,placeholder:n="Type a comment...",onEditorClick:e=()=>{}}=g;const l={namespace:"Commenting",nodes:[],onError:i=>{throw i},theme:T2};return Gt.createElement(p2.LexicalComposer,{initialConfig:l},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_EditorContainer",onClick:e},Gt.createElement(_2.PlainTextPlugin,{contentEditable:Gt.createElement(N2,{className:s}),placeholder:Gt.createElement(I2,null,n),ErrorBoundary:R2}),Gt.createElement(v2.OnChangePlugin,{onChange:f}),Gt.createElement(m2.HistoryPlugin,null),p!==!1&&Gt.createElement(c2.AutoFocusPlugin,null),Gt.createElement(z2,{onEscape:t}),Gt.createElement(d2.ClearEditorPlugin,null),r!==void 0&&Gt.createElement(U2,{editorRef:r})))}function rv(g,s){return(0,Gt.useCallback)((p,t)=>{p.read(()=>{g((0,Zy.$rootTextContent)()),s(!(0,Zy.$isRootTextContentEmpty)(t.isComposing(),!0))})},[s,g])}function $2(g){let{editor:s,cancelAddComment:p,submitAddComment:t}=g;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),l=(0,Gt.useRef)(null),i=(0,Gt.useMemo)(()=>({container:document.createElement("div"),elements:[]}),[]),c=(0,Gt.useRef)(null),o=av(),a=(0,Gt.useCallback)(()=>{s.getEditorState().read(()=>{const d=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(d)){c.current=d.clone();const m=d.anchor,h=d.focus,y=(0,Da.createDOMRange)(s,m.getNode(),m.offset,h.getNode(),h.offset),v=l.current;if(y!==null&&v!==null){const{left:_,bottom:b,width:w}=y.getBoundingClientRect(),x=(0,Da.createRectsFromDOMRange)(s,y);let S=x.length===1?_+w/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=x.length,{container:k}=i,D=i.elements,I=D.length;for(let T=0;T<C;T++){const R=x[T];let P=D[T];P===void 0&&(P=document.createElement("span"),D[T]=P,k.appendChild(P));const $="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(${$}, 0.3);pointer-events:none;z-index:5;`;P.style.cssText=q}for(let T=I-1;T>=C;T--){const R=D[T];k.removeChild(R),D.pop()}}}})},[s,i]);Xy(()=>{a();const d=i.container,m=document.body;if(m!==null)return m.appendChild(d),()=>{m.removeChild(d)}},[i.container,a]),(0,Gt.useEffect)(()=>(window.addEventListener("resize",a),()=>{window.removeEventListener("resize",a)}),[a]);const u=rv(r,e);return Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox",ref:l},Gt.createElement(nv,{className:"CodoxCommentPlugin_CommentInputBox_Editor",onEscape:d=>(d.preventDefault(),p(),!0),onChange:u}),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentInputBox_Buttons"},Gt.createElement(ra,{onClick:p,className:"CodoxCommentPlugin_CommentInputBox_Button"},"Cancel"),Gt.createElement(ra,{onClick:()=>{if(n){let d=s.getEditorState().read(()=>{const m=c.current;return m?m.getTextContent():""});d.length>100&&(d=d.slice(0,99)+"…"),t(B2(d,[ev(f,o)]),!0,void 0,c.current),c.current=null}},disabled:!n,className:"CodoxCommentPlugin_CommentInputBox_Button primary"},"Comment")))}function H2(g){let{submitAddComment:s,thread:p,placeholder:t}=g;const[f,r]=(0,Gt.useState)(""),[n,e]=(0,Gt.useState)(!1),l=(0,Gt.useRef)(null),i=av(),c=rv(r,e);return Gt.createElement(Gt.Fragment,null,Gt.createElement(nv,{className:"CodoxCommentPlugin_CommentsPanel_Editor",autoFocus:!1,onEscape:()=>!0,onChange:c,editorRef:l,placeholder:t}),Gt.createElement(ra,{className:"CodoxCommentPlugin_CommentsPanel_SendButton",onClick:()=>{if(n){s(ev(f,i),!1,p);const o=l.current;o!==null&&o.dispatchCommand(_e.CLEAR_EDITOR_COMMAND,void 0)}},disabled:!n},Gt.createElement(D2,null)))}function ov(g){let{commentOrThread:s,deleteCommentOrThread:p,onClose:t,thread:f}=g;return Gt.createElement(Gt.Fragment,null,"Are you sure you want to delete this ",s.type,"?",Gt.createElement("div",{className:"Modal__content"},Gt.createElement(ra,{onClick:()=>{p(s,f),t()}},"Delete")," ",Gt.createElement(ra,{onClick:()=>{t()}},"Cancel")))}function iv(g){let{comment:s,deleteComment:p,thread:t,rtf:f}=g;const r=Math.round((s.timeStamp-performance.now())/1e3),n=Math.round(r/60),[e,l]=Qy();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"},s.author),Gt.createElement("span",{className:"CodoxCommentPlugin_CommentsPanel_List_Comment_Time"},"· ",r>-10?"Just now":f.format(n,"minute"))),Gt.createElement("p",{className:s.deleted?"CodoxCommentPlugin_CommentsPanel_DeletedComment":""},s.content),!s.deleted&&Gt.createElement(Gt.Fragment,null,Gt.createElement(ra,{onClick:()=>{l("Delete Comment",i=>Gt.createElement(ov,{commentOrThread:s,deleteCommentOrThread:p,thread:t,onClose:i}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(tv,null)),e))}function q2(g){let{activeIDs:s,comments:p,deleteCommentOrThread:t,listRef:f,submitAddComment:r,markNodeMap:n}=g;const[e]=(0,ta.useLexicalComposerContext)(),[l,i]=(0,Gt.useState)(0),[c,o]=Qy(),a=(0,Gt.useMemo)(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return(0,Gt.useEffect)(()=>{const u=setTimeout(()=>{i(l+1)},1e4);return()=>{clearTimeout(u)}},[l]),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List",ref:f},p.map(u=>{const d=u.codoxId;if(!d)return null;if(u.type==="thread"){const m=()=>{if(n.get(d)!==void 0&&(s===null||s.indexOf(d)===-1)){const h=document.activeElement;e.update(()=>{(0,_e.$setSelection)(null)},{onUpdate(){h!==null&&h.focus()}})}};return Gt.createElement("li",{key:d,onClick:m,className:`CodoxCommentPlugin_CommentsPanel_List_Thread ${n.has(d)?"interactive":""} ${s.indexOf(d)===-1?"":"active"}`},Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_QuoteBox"},Gt.createElement("blockquote",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Quote"},"> ",Gt.createElement("span",null,u.quote)),Gt.createElement(ra,{onClick:()=>{o("Delete Thread",h=>Gt.createElement(ov,{commentOrThread:u,deleteCommentOrThread:t,onClose:h}))},className:"CodoxCommentPlugin_CommentsPanel_List_DeleteButton"},Gt.createElement(tv,null)),c),Gt.createElement("ul",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Comments"},u.comments.map(h=>Gt.createElement(iv,{key:h.codoxId,comment:h,deleteComment:t,thread:u,rtf:a}))),Gt.createElement("div",{className:"CodoxCommentPlugin_CommentsPanel_List_Thread_Editor"},Gt.createElement(H2,{submitAddComment:r,thread:u,placeholder:"Reply to comment..."})))}return Gt.createElement(iv,{key:d,comment:u,deleteComment:t,rtf:a})}))}function W2(g){let{activeIDs:s,deleteCommentOrThread:p,comments:t,submitAddComment:f,markNodeMap:r}=g;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(q2,{activeIDs:s,comments:t,deleteCommentOrThread:p,listRef:n,submitAddComment:f,markNodeMap:r}))}function av(){const g=(0,Ly.useCollaborationContext)(),{yjsDocMap:s,name:p}=g;return p||"Playground User"}function J2(g){const[s]=(0,ta.useLexicalComposerContext)(),p=TS(),t=(0,Gt.useMemo)(()=>new Map,[]),[f,r]=(0,Gt.useState)(),[n,e]=(0,Gt.useState)([]),[l,i]=(0,Gt.useState)(!1),[c,o]=(0,Gt.useState)(!1);(0,Gt.useEffect)(()=>{!p.length&&c?o(!1):p.length},[p]);const a=(0,Gt.useCallback)(()=>{s.update(()=>{const m=(0,_e.$getSelection)();m!==null&&(m.dirty=!0)}),i(!1)},[s]),u=(0,Gt.useCallback)((m,h)=>{if(m.type==="comment"){if(ue.log("[deleteCommentOrThread]: type comment new values",{comment:m,thread:h,markNodeMap:t}),On.removeComment(h.codoxId,m.codoxId),!h)return;const y=h.codoxId,v=t.get(y);s.update(()=>{v?v.forEach((_,b)=>{const w=(0,_e.$getNodeByKey)(b);ue.log("[deleteCommentOrThread]: type comment new values",{lexicalNode:w}),w&&w.markDirty()}):(0,_e.$getRoot)().markDirty(),(0,_e.$addUpdateTag)(uo.historic),(0,_e.$addUpdateTag)(sc)})}else{ue.log("[deleteCommentOrThread]: type thread new values",{comment:m,markNodeMap:t});const y=h!==void 0?h.codoxId:m.codoxId,v=t.get(y);setTimeout(()=>{s.update(()=>{if(v)for(const _ of v){const b=(0,_e.$getNodeByKey)(_);ue.log("[deleteCommentOrThread]: type thread new values",{node:b}),(0,co.$isMarkNode)(b)&&(b.deleteID(y),b.getIDs().length===0&&(0,co.$unwrapMarkNode)(b))}else(0,_e.$getRoot)().markDirty(),ue.debug("[deleteCommentOrThread][refreshComments]");On.refreshComments(!0),(0,_e.$addUpdateTag)(sc)})})}},[s,t]),d=(0,Gt.useCallback)((m,h,y,v)=>{if(ue.log("[submitAddComment]: new values",{commentOrThread:m,isInlineComment:h,thread:y,markNodeMap:t}),y?On.addComment(y.codoxId,m):On.addCommentThread(m),h)s.update(()=>{if((0,_e.$isRangeSelection)(v)){const _=v.isBackward(),b=m.codoxId;(0,co.$wrapSelectionInMarkNode)(v,_,b),(0,_e.$addUpdateTag)(sc)}}),i(!1);else if(!h&&y){const _=y.codoxId,b=t.get(_);if(!b)return void On.removeComment(y.codoxId,m.codoxId);s.update(()=>{b.forEach((w,x)=>{let S=(0,_e.$getNodeByKey)(x);S&&S.markDirty()}),(0,_e.$addUpdateTag)(uo.historic),(0,_e.$addUpdateTag)(sc)})}},[s]);return(0,Gt.useEffect)(()=>{const m=[];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=s.getElementByKey(_);b!==null&&(b.classList.add("selected"),m.push(b),o(!0))}}return()=>{for(let h=0;h<m.length;h++)m[h].classList.remove("selected")}},[n,s,t]),(0,Gt.useEffect)(()=>{const m=new Map;return(0,Ds.mergeRegister)((0,Ds.registerNestedElementResolver)(s,co.MarkNode,h=>(0,co.$createMarkNode)(h.getIDs()),(h,y)=>{h.getIDs().forEach(v=>{y.addID(v)})}),s.registerMutationListener(co.MarkNode,h=>{s.getEditorState().read(()=>{for(const[y,v]of h){const _=(0,_e.$getNodeByKey)(y);let b=[];v==="destroyed"?b=m.get(y)||[]:(0,co.$isMarkNode)(_)&&(b=_.getIDs());for(let w=0;w<b.length;w++){const x=b[w];let S=t.get(x);m.set(y,b),v==="destroyed"?S!==void 0&&(S.delete(y),S.size===0&&t.delete(x)):(S===void 0&&(S=new Set,t.set(x,S)),S.has(y)||S.add(y))}}})}),s.registerUpdateListener(h=>{let{editorState:y,tags:v}=h;y.read(()=>{const _=(0,_e.$getSelection)();let b=!1,w=!1;if((0,_e.$isRangeSelection)(_)){const x=_.anchor.getNode();if((0,_e.$isTextNode)(x)){const S=(0,co.$getMarkIDs)(x,_.anchor.offset);S!==null&&(e(S),b=!0),_.isCollapsed()||(r(x.getKey()),w=!0)}}b||e(x=>x.length===0?x:[]),w||r(null),(0,_e.$isRangeSelection)(_)&&i(!1)})}),s.registerCommand(Tp,()=>{const h=window.getSelection();return h!==null&&h.removeAllRanges(),i(!0),!0},_e.COMMAND_PRIORITY_EDITOR))},[s,t]),Gt.createElement(Gt.Fragment,null,l&&(0,Ws.createPortal)(Gt.createElement($2,{editor:s,cancelAddComment:a,submitAddComment:d}),document.body),f!=null&&!l&&(0,Ws.createPortal)(Gt.createElement(F2,{anchorKey:f,editor:s,onAddComment:()=>{s.dispatchCommand(Tp,void 0)}}),document.body),(0,Ws.createPortal)(Gt.createElement(ra,{className:"CodoxCommentPlugin_ShowCommentsButton "+(c?"active":""),onClick:()=>o(!c),title:c?"Hide Comments":"Show Comments"},Gt.createElement(L2,null)),document.body),c&&(0,Ws.createPortal)(Gt.createElement(W2,{comments:p,submitAddComment:d,deleteCommentOrThread:u,activeIDs:n,markNodeMap:t}),document.body))}var ad=on(766),Zs={};Zs.styleTagTransform=hi(),Zs.setAttributes=fi(),Zs.insert=di().bind(null,"head"),Zs.domAPI=ui(),Zs.insertStyleElement=pi(),ci()(ad.A,Zs),ad.A&&ad.A.locals&&ad.A.locals;var sd=on(225),Xs={};Xs.styleTagTransform=hi(),Xs.setAttributes=fi(),Xs.insert=di().bind(null,"head"),Xs.domAPI=ui(),Xs.insertStyleElement=pi(),ci()(sd.A,Xs),sd.A&&sd.A.locals&&sd.A.locals;function V2(g){let{label:s,value:p,onChange:t,placeholder:f="","data-test-id":r,type:n="text"}=g;return Gt.createElement("div",{className:"CodoxInput__wrapper"},Gt.createElement("label",{className:"CodoxInput__label"},s),Gt.createElement("input",{type:n,className:"CodoxInput__input",placeholder:f,value:p,onChange:e=>{t(e.target.value)},"data-test-id":r}))}function sv(g,s){var p=Object.keys(g);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(g);s&&(t=t.filter(function(f){return Object.getOwnPropertyDescriptor(g,f).enumerable})),p.push.apply(p,t)}return p}function ld(g){for(var s=1;s<arguments.length;s++){var p=arguments[s]!=null?arguments[s]:{};s%2?sv(Object(p),!0).forEach(function(t){K2(g,t,p[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(p)):sv(Object(p)).forEach(function(t){Object.defineProperty(g,t,Object.getOwnPropertyDescriptor(p,t))})}return g}function K2(g,s,p){return(s=G2(s))in g?Object.defineProperty(g,s,{value:p,enumerable:!0,configurable:!0,writable:!0}):g[s]=p,g}function G2(g){var s=Y2(g,"string");return typeof s=="symbol"?s:s+""}function Y2(g,s){if(typeof g!="object"||!g)return g;var p=g[Symbol.toPrimitive];if(p!==void 0){var t=p.call(g,s||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(g)}let dc=!1;const Z2=["#d0021b","#f5a623","#f8e71c","#8b572a","#7ed321","#417505","#bd10e0","#9013fe","#4a90e2","#50e3c2","#b8e986","#000000","#4a4a4a","#9b9b9b","#ffffff"],fc=214,lv=150;function X2(g){let{color:s,onChange:p}=g;const[t,f]=(0,Gt.useState)(Qs("hex",s)),[r,n]=(0,Gt.useState)(s),e=(0,Gt.useRef)(null),l=(0,Gt.useMemo)(()=>({x:t.hsv.s/100*fc,y:(100-t.hsv.v)/100*lv}),[t.hsv.s,t.hsv.v]),i=(0,Gt.useMemo)(()=>({x:t.hsv.h/360*fc}),[t.hsv]);return(0,Gt.useEffect)(()=>{e.current!==null&&p&&n(t.hex)},[t,p]),(0,Gt.useEffect)(()=>{if(s===void 0)return;const c=Qs("hex",s);f(c),n(c.hex)},[s]),Gt.createElement("div",{className:"codox-color-picker-wrapper",style:{width:fc},ref:e},Gt.createElement(V2,{label:"Hex",onChange:c=>{if(n(c),/^#[0-9A-Fa-f]{6}$/i.test(c)){const o=Qs("hex",c);f(o)}},value:r}),Gt.createElement("div",{className:"codox-color-picker-basic-color"},Z2.map(c=>Gt.createElement("button",{className:c===t.hex?" active":"",key:c,style:{backgroundColor:c},onClick:()=>(o=>{n(o);let a=Qs("hex",o);f(a),p(a.hex,dc)})(c)}))),Gt.createElement(cv,{className:"codox-color-picker-saturation",style:{backgroundColor:`hsl(${t.hsv.h}, 100%, 50%)`},onChange:c=>{let{x:o,y:a}=c;const u=Qs("hsv",ld(ld({},t.hsv),{},{s:o/fc*100,v:100-a/lv*100}));f(u),n(u.hex),p(u.hex,dc)}},Gt.createElement("div",{className:"codox-color-picker-saturation_cursor",style:{backgroundColor:t.hex,left:l.x,top:l.y}})),Gt.createElement(cv,{className:"codox-color-picker-hue",onChange:c=>{let{x:o}=c;const a=Qs("hsv",ld(ld({},t.hsv),{},{h:o/fc*360}));f(a),n(a.hex),p(a.hex,dc)}},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 cv(g){let{className:s,style:p,onChange:t,children:f}=g;const r=(0,Gt.useRef)(null),n=(0,Gt.useRef)(!1),e=l=>{if(r.current){const{current:i}=r,{width:c,height:o,left:a,top:u}=i.getBoundingClientRect(),d=uv(l.clientX-a,c,0),m=uv(l.clientY-u,o,0);t({x:d,y:m})}};return Gt.createElement("div",{ref:r,className:s,style:p,onMouseDown:l=>{if(l.button!==0)return;e(l);const i=o=>{n.current=!0,dc=!0,e(o)},c=o=>{n.current&&(dc=!1),document.removeEventListener("mousemove",i,!1),document.removeEventListener("mouseup",c,!1),e(o),n.current=!1};document.addEventListener("mousemove",i,!1),document.addEventListener("mouseup",c,!1)}},f)}function uv(g,s,p){return g>s?s:g<p?p:g}function dv(g){if(!g.startsWith("#")){const s=document.createElement("canvas").getContext("2d");if(!s)throw new Error("2d context not supported or canvas already initialized");return s.fillStyle=g,s.fillStyle}return g.length===4||g.length===5?g=g.split("").map((s,p)=>p?s+s:"#").join(""):g.length===7||g.length===9?g:"#000000"}function fv(g){const s=(g.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:s[2],g:s[1],r:s[0]}}function Fp(g){let{r:s,g:p,b:t}=g;s/=255,p/=255,t/=255;const f=Math.max(s,p,t),r=f-Math.min(s,p,t);return{h:r?60*(f===s?(p-t)/r+(p<t?6:0):f===p?2+(t-s)/r:4+(s-p)/r):0,s:f?r/f*100:0,v:100*f}}function Q2(g){let{h:s,s:p,v:t}=g;p/=100,t/=100;const f=~~(s/60),r=s/60-f,n=t*(1-p),e=t*(1-p*r),l=t*(1-p*(1-r)),i=f%6,c=Math.round(255*[t,e,n,n,l,t][i]),o=Math.round(255*[l,t,t,e,n,n][i]);return{b:Math.round(255*[n,n,l,t,t,e][i]),g:o,r:c}}function pv(g){let{b:s,g:p,r:t}=g;return"#"+[t,p,s].map(f=>f.toString(16).padStart(2,"0")).join("")}function Qs(g,s){let p=dv("#121212"),t=fv(p),f=Fp(t);return g==="hex"?(p=dv(s),t=fv(p),f=Fp(t)):g==="rgb"?(t=s,p=pv(t),f=Fp(t)):g==="hsv"&&(f=s,t=Q2(f),p=pv(t)),{hex:p,hsv:f,rgb:t}}const tC=Gt.createContext(null),hv=4;function eC(g){let{children:s,dropDownRef:p,onClose:t,dropdownClassName:f}=g;const[r,n]=(0,Gt.useState)(),[e,l]=(0,Gt.useState)(),i=(0,Gt.useCallback)(o=>{n(a=>a?[...a,o]:[o])},[n]),c=(0,Gt.useMemo)(()=>({registerItem:i}),[i]);return(0,Gt.useEffect)(()=>{r&&!e&&l(r[0]),e&&e.current&&e.current.focus()},[r,e]),Gt.createElement(tC.Provider,{value:c},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"?l(u=>{if(!u)return r[0];const d=r.indexOf(u)-1;return r[d===-1?r.length-1:d]}):a==="ArrowDown"&&l(u=>u?r[r.indexOf(u)+1]:r[0])}},s))}function nC(g){let{disabled:s=!1,buttonLabel:p,buttonAriaLabel:t,buttonClassName:f,buttonIconClassName:r,children:n,stopCloseOnClickSelf:e,dropdownClassName:l,buttonLabelClassName:i,dropdownChevronClassName:c}=g;const o=(0,Gt.useRef)(null),a=(0,Gt.useRef)(null),[u,d]=(0,Gt.useState)(!1);return(0,Gt.useEffect)(()=>{const m=a.current,h=o.current;if(u&&m!==null&&h!==null){const{top:y,left:v}=m.getBoundingClientRect();h.style.top=`${y+m.offsetHeight+hv}px`,h.style.left=`${Math.min(v,window.innerWidth-h.offsetWidth-20)}px`}},[o,a,u]),(0,Gt.useEffect)(()=>{const m=a.current;if(m!==null&&u){const h=y=>{const v=y.target;e&&o.current&&o.current.contains(v)||m.contains(v)||d(!1)};return document.addEventListener("click",h),()=>{document.removeEventListener("click",h)}}},[o,a,u,e]),(0,Gt.useEffect)(()=>{const m=()=>{if(u){const h=a.current,y=o.current;if(h!==null&&y!==null){const{top:v}=h.getBoundingClientRect(),_=v+h.offsetHeight+hv;_!==y.getBoundingClientRect().top&&(y.style.top=`${_}px`)}}};return document.addEventListener("scroll",m),()=>{document.removeEventListener("scroll",m)}},[a,o,u]),Gt.createElement(Gt.Fragment,null,Gt.createElement("button",{type:"button",disabled:s,"aria-label":t||p,className:f,onClick:()=>d(!u),ref:a},r&&Gt.createElement("span",{className:r}),p&&Gt.createElement("span",{className:i},p),Gt.createElement("i",{className:c})),u&&(0,Ws.createPortal)(Gt.createElement(eC,{dropDownRef:o,onClose:()=>{d(!1),a&&a.current&&a.current.focus()},dropdownClassName:l},n),document.body))}const rC=["disabled","stopCloseOnClickSelf","color","onChange"];function zp(){return zp=Object.assign?Object.assign.bind():function(g){for(var s=1;s<arguments.length;s++){var p=arguments[s];for(var t in p)({}).hasOwnProperty.call(p,t)&&(g[t]=p[t])}return g},zp.apply(null,arguments)}function oC(g,s){if(g==null)return{};var p,t,f=iC(g,s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(g);for(t=0;t<r.length;t++)p=r[t],s.indexOf(p)>=0||{}.propertyIsEnumerable.call(g,p)&&(f[p]=g[p])}return f}function iC(g,s){if(g==null)return{};var p={};for(var t in g)if({}.hasOwnProperty.call(g,t)){if(s.indexOf(t)>=0)continue;p[t]=g[t]}return p}function gv(g){let{disabled:s=!1,stopCloseOnClickSelf:p=!0,color:t,onChange:f}=g,r=oC(g,rC);return Gt.createElement(nC,zp({},r,{disabled:s,stopCloseOnClickSelf:p}),Gt.createElement(X2,{color:t,onChange:f}))}const aC=g=>{let{onColorChange:s,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:l}=g;const[i]=(0,ta.useLexicalComposerContext)(),[c,o]=(0,Gt.useState)(()=>i.isEditable()),[a,u]=(0,Gt.useState)("");(0,Gt.useEffect)(()=>(0,Ds.mergeRegister)(i.registerEditableListener(m=>{o(m)}),i.registerUpdateListener(m=>{let{editorState:h}=m;h.read(()=>{const y=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(y)){let v=(0,Da.$getSelectionStyleValueForProperty)(y,"color");v!==a&&(u(v||""),s(v))}})})),[i]);const d=(0,Gt.useCallback)((m,h)=>{i.update(()=>{const y=(0,_e.$getSelection)();y!==null&&(0,Da.$patchStyleText)(y,{color:m})})},[i]);return Gt.createElement(gv,{disabled:!c,color:a,onChange:d,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:l||""})},sC=aC,lC=g=>{let{onColorChange:s,buttonClassName:p,buttonIconClassName:t,buttonAriaLabel:f,buttonLabel:r,dropdownClassName:n,buttonLabelClassName:e,dropdownChevronClassName:l}=g;const[i]=(0,ta.useLexicalComposerContext)(),[c,o]=(0,Gt.useState)(()=>i.isEditable()),[a,u]=(0,Gt.useState)("#fff");(0,Gt.useEffect)(()=>(0,Ds.mergeRegister)(i.registerEditableListener(m=>{o(m)}),i.registerUpdateListener(m=>{let{editorState:h}=m;h.read(()=>{const y=(0,_e.$getSelection)();if((0,_e.$isRangeSelection)(y)){let v=(0,Da.$getSelectionStyleValueForProperty)(y,"background-color");v!==a&&(u(v||""),s(v))}})})),[i]);const d=(0,Gt.useCallback)((m,h)=>{i.update(()=>{const y=(0,_e.$getSelection)();y!==null&&(0,Da.$patchStyleText)(y,{"background-color":m})})},[i]);return Gt.createElement(gv,{disabled:!c,color:a,onChange:d,buttonClassName:p||"",buttonIconClassName:t||"",buttonAriaLabel:f||"",buttonLabel:r||"",dropdownClassName:n||"",buttonLabelClassName:e||"",dropdownChevronClassName:l||""})},cC=lC;var uC=Yi.yy;Yi._U,Yi.a8,Yi.Vs,Yi.Cn;var dC=Yi.gK,fC=Yi.vv;function pC(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}var cd=pC(function(g){const s=new URLSearchParams;s.append("code",g);for(let p=1;p<arguments.length;p++)s.append("v",arguments[p]);throw Error(`Minified Lexical error #${g}; visit https://lexical.dev/docs/error?${s} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function hC({hasCellMerge:g=!0,hasCellBackgroundColor:s=!0,hasTabHandler:p=!0}){const[t]=_r();return se.useEffect(()=>(t.hasNodes([ko,Ki,ec])||cd(10),lo(t.registerCommand(hw,({columns:f,rows:r,includeHeaders:n})=>{const e=J0(Number(r),Number(f),n);m0(e);const l=e.getFirstDescendant();return Pe(l)&&l.select(),!0},an),t.registerNodeTransform(ko,f=>{const[r]=Y0(f,null,null),n=r.reduce((e,l)=>Math.max(e,l.length),0);for(let e=0;e<r.length;++e){const l=r[e].length;if(l===n)continue;const i=r[e][l-1].cell;for(let c=l;c<n;++c){const o=si(0);o.append(Mn()),i!==null?i.insertAfter(o):y0(i,o)}}}))),[t]),se.useEffect(()=>{const f=new Map,r=e=>{const l=e.getKey(),i=t.getElementByKey(l);if(i&&!f.has(l)){const c=Ow(e,i,t,p);f.set(l,c)}};t.getEditorState().read(()=>{const e=om(ko);for(const l of e)Dn(l)&&r(l)});const n=t.registerMutationListener(ko,e=>{for(const[l,i]of e)if(i==="created")t.getEditorState().read(()=>{const c=Xn(l);Dn(c)&&r(c)});else if(i==="destroyed"){const c=f.get(l);c!==void 0&&(c.removeListeners(),f.delete(l))}});return()=>{n();for(const[,e]of f)e.removeListeners()}},[t,p]),se.useEffect(()=>{if(!g)return t.registerNodeTransform(Ki,f=>{if(f.getColSpan()>1||f.getRowSpan()>1){const[,,r]=Qr(f),[n]=Bo(r,f,f),e=n.length,l=n[0].length;let i=r.getFirstChild();fr(i)||cd(175);const c=[];for(let o=0;o<e;o++){o!==0&&(i=i.getNextSibling(),fr(i)||cd(175));let a=null;for(let u=0;u<l;u++){const d=n[o][u],m=d.cell;if(d.startRow===o&&d.startColumn===u)a=m,c.push(m);else if(m.getColSpan()>1||m.getRowSpan()>1){rn(m)||cd(176);const h=si(m.__headerState);a!==null?a.insertAfter(h):y0(i,h)}}}for(const o of c)o.setColSpan(1),o.setRowSpan(1)}})},[t,g]),se.useEffect(()=>{if(!s)return t.registerNodeTransform(Ki,f=>{f.getBackgroundColor()!==null&&f.setBackgroundColor(null)})},[t,s,g]),null}const $T="",gC={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"},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"}},mC="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDE1IDE1IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMDAwMDEgOC4zMzMzM0wxLjkwMDAxIDEzLjhMMS4xMDAwMSAxMy4yTDUuMzc1MDEgNy41TDEuMTAwMDEgMS44TDEuOTAwMDEgMS4yTDYuMDAwMDEgNi42NjY2N0wxMC4xIDEuMkwxMC45IDEuOEw2LjYyNTAxIDcuNUwxMC45IDEzLjJMMTAuMSAxMy44TDYuMDAwMDEgOC4zMzMzM1pNMTIgMTIuNUMxMiAxMS42NzE2IDEyLjY3MTYgMTEgMTMuNSAxMUgxMy43OTI5QzE0LjQ1OTYgMTEgMTUgMTEuNTQwNCAxNSAxMi4yMDcxQzE1IDEyLjUyNzMgMTQuODcyOCAxMi44MzQzIDE0LjY0NjUgMTMuMDYwN0wxMy43MDcxIDE0SDE1VjE1SDEyLjVDMTIuMjk3OCAxNSAxMi4xMTU1IDE0Ljg3ODIgMTIuMDM4MSAxNC42OTEzQzExLjk2MDcgMTQuNTA0NSAxMi4wMDM1IDE0LjI4OTQgMTIuMTQ2NSAxNC4xNDY0TDEzLjkzOTMgMTIuMzUzNkMxMy45NzgyIDEyLjMxNDcgMTQgMTIuMjYyIDE0IDEyLjIwNzFDMTQgMTIuMDkyNyAxMy45MDczIDEyIDEzLjc5MjkgMTJIMTMuNUMxMy4yMjM5IDEyIDEzIDEyLjIyMzkgMTMgMTIuNUgxMloiIGZpbGw9IiMwMDAwMDAiLz4KPC9zdmc+",yC="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDQgNTEyLjM2Ij48cGF0aCBmaWxsLXJ1bGU9Im5vbnplcm8iIGQ9Ik00OTkuNDMgMjMxLjM2SDM2OC40Yy0yLjUzIDAtNC41OC0yLjA1LTQuNTgtNC41N3YtOC4xMWMwLTEuMjYuNTItMi40IDEuMzQtMy4yMmw3MS41Ny04Mi41M2M2LjczLTcuNzUgMTIuNTctMTQuOTcgMTcuNDgtMjEuNjggNC44OC02LjY0IDguODMtMTIuNzQgMTEuODUtMTguMjggMi45Ny01LjQzIDUuMTgtMTAuNjEgNi42NC0xNS41NSAxLjQyLTQuODUgMi4xMy05LjUzIDIuMTMtMTQgMC0xNC42OC0zLjk4LTI2LjA1LTExLjkyLTM0LjA5LTMuOTItMy45Ni04Ljc1LTYuOTMtMTQuNDktOC45Mi01Ljk1LTIuMDMtMTIuOTEtMy4wNS0yMC44Ny0zLjA1LTguNDUgMC0xNS44OCAxLjIxLTIyLjI5IDMuNjItNi4yNyAyLjM2LTExLjYzIDUuOTItMTYuMDcgMTAuNjNhNDcuODg0IDQ3Ljg4NCAwIDAgMC0xMC4xNCAxNi42Yy0yLjI3IDYuMjktMy40MSAxMy4zOS0zLjQxIDIxLjI2IDAgMi41Mi0yLjA1IDQuNTctNC41NyA0LjU3aC02Ljg5Yy0yLjA1IDAtMy44LTEuMzYtNC4zNy0zLjI0bC0uMjctLjgyYy0uMTgtLjU2LS4yNS0xLjEzLS4yMi0xLjY3LS4yMy05LjMyIDEuMTQtMTcuOTkgNC4xMi0yNS45NyAzLjAyLTguMTMgNy42OC0xNS41NCAxMy45NC0yMi4xOSA2LjI2LTYuNyAxMy42My0xMS43NiAyMi4xLTE1LjEzQzQwNy44NCAxLjY4IDQxNy4yIDAgNDI3LjU1IDBjOS41OSAwIDE4LjI2IDEuMzggMjYuMDMgNC4xMyA3Ljg2IDIuNzkgMTQuNzcgNyAyMC43MiAxMi42MSA2LjAyIDUuNjMgMTAuNTUgMTIuNCAxMy41NSAyMC4yOCAyLjk2IDcuNzUgNC40NSAxNi41NiA0LjQ1IDI2LjQgMCA2LjUtMS4wNyAxMy4wOC0zLjE3IDE5LjY5bC0uMTQuMzhjLTIuMDkgNi40Ni01LjE3IDEyLjk3LTkuMiAxOS40OWwtLjE0LjIxYy00LjA4IDYuNTEtOC45IDEzLjQzLTE0LjQzIDIwLjc0LTUuNTYgNy4zMy0xMS45NiAxNS4yMy0xOS4yMiAyMy42N2wtNTYuOTEgNjYuNTFoMTEwLjM0YzIuNTIgMCA0LjU3IDIuMDUgNC41NyA0LjU3djguMTFjMCAyLjUyLTIuMDUgNC41Ny00LjU3IDQuNTd6bS0zMjcuMjUgNjguNzUgMTM3Ljk2LTE2Ny43NmMuODktMS4wNyAyLjMtMS42NSAzLjc0LTEuNjVsMjAuMTMtLjAyYzIuNTIgMCA0LjU3IDEuNzQgNC41NyAzLjg4IDAgLjkxLS4zNyAxLjc1LS45OCAyLjQxTDE4OC4zMiAzMTcuNjYgMzQ0LjEgNTA2LjI0YzEuNDUgMS43NS45NSA0LjE3LTEuMSA1LjQtLjguNDgtMS43Mi43MS0yLjYzLjcxbC0yMC4xMy4wMWMtMS43IDAtMy4xOC0uNzktMy45Ny0xLjk2bC0xNDQuMS0xNzUuMkwyOC4yMyA1MTAuNjljLS44OCAxLjA3LTIuMyAxLjY0LTMuNzMgMS42NWwtMTkuOTMuMDJjLTIuNTIgMC00LjU3LTEuNzQtNC41Ny0zLjg5IDAtLjkuMzctMS43NC45OC0yLjRsMTU1LjY1LTE4OC40TDYuOSAxMzYuOGMtMS40NS0xLjc1LS45NS00LjE4IDEuMTEtNS40MS43OS0uNDcgMS43MS0uNyAyLjYyLS43bDIwLjQ0LS4wMWMxLjYzIDAgMy4wNi43MiAzLjg3IDEuODFsMTM3LjI0IDE2Ny42MnoiLz48L3N2Zz4=",mv=Nn.createContext(null),yv=4;function oa({children:g,className:s,onClick:p,title:t}){const f=se.useRef(null),r=Nn.useContext(mv);if(r===null)throw new Error("DropDownItem must be used within a DropDown");const{registerItem:n}=r;return se.useEffect(()=>{f&&f.current&&n(f)},[f,n]),ee.jsx("button",{className:s,onClick:p,ref:f,title:t,type:"button",children:g})}function vC({children:g,dropDownRef:s,onClose:p}){const[t,f]=se.useState(),[r,n]=se.useState(),e=se.useCallback(c=>{f(o=>o?[...o,c]:[c])},[f]),l=c=>{if(!t)return;const o=c.key;["Escape","ArrowUp","ArrowDown","Tab"].includes(o)&&c.preventDefault(),o==="Escape"||o==="Tab"?p():o==="ArrowUp"?n(a=>{if(!a)return t[0];const u=t.indexOf(a)-1;return t[u===-1?t.length-1:u]}):o==="ArrowDown"&&n(a=>a?t[t.indexOf(a)+1]:t[0])},i=se.useMemo(()=>({registerItem:e}),[e]);return se.useEffect(()=>{t&&!r&&n(t[0]),r&&r.current&&r.current.focus()},[t,r]),ee.jsx(mv.Provider,{value:i,children:ee.jsx("div",{className:"dropdown",ref:s,onKeyDown:l,children:g})})}function vv({disabled:g=!1,buttonLabel:s,buttonAriaLabel:p,buttonClassName:t,buttonIconClassName:f,children:r,stopCloseOnClickSelf:n}){const e=se.useRef(null),l=se.useRef(null),[i,c]=se.useState(!1),o=()=>{c(!1),l&&l.current&&l.current.focus()};return se.useEffect(()=>{const a=l.current,u=e.current;if(i&&a!==null&&u!==null){const{top:d,left:m}=a.getBoundingClientRect();u.style.top=`${d+a.offsetHeight+yv}px`,u.style.left=`${Math.min(m,window.innerWidth-u.offsetWidth-20)}px`}},[e,l,i]),se.useEffect(()=>{const a=l.current;if(a!==null&&i){const u=d=>{const m=d.target;n&&e.current&&e.current.contains(m)||a.contains(m)||c(!1)};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}}},[e,l,i,n]),se.useEffect(()=>{const a=()=>{if(i){const u=l.current,d=e.current;if(u!==null&&d!==null){const{top:m}=u.getBoundingClientRect(),h=m+u.offsetHeight+yv;h!==d.getBoundingClientRect().top&&(d.style.top=`${h}px`)}}};return document.addEventListener("scroll",a),()=>{document.removeEventListener("scroll",a)}},[l,e,i]),ee.jsxs(ee.Fragment,{children:[ee.jsxs("button",{type:"button",disabled:g,"aria-label":p||s,className:t,onClick:()=>c(!i),ref:l,children:[f&&ee.jsx("span",{className:f}),s&&ee.jsx("span",{className:"text dropdown-button-text",children:s}),ee.jsx("i",{className:"chevron-down"})]}),i&&Yr.createPortal(ee.jsx(vC,{dropDownRef:e,onClose:o,children:r}),document.body)]})}function bv(){return ee.jsx("div",{className:"divider"})}const _v=8,xv=72,ia={h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",paragraph:"Normal"},bC=({selectionFontSize:g,disabled:s,editor:p,blockType:t,styleConfig:f,isenterPressed:r,currentElementClick:n,currentElementSelect:e})=>{const[l,i]=Nn.useState(g),[c,o]=Nn.useState(t),[a,u]=Nn.useState("");Nn.useState([]);const[d,m]=Nn.useState(""),h=x=>{x&&x.title&&p.update(()=>{if(p.isEditable()){const S=Ce();S&&u0(S,x)}})},y=x=>{i(x.target.value)},v=()=>{const x=Number(l);if(!isNaN(x)){const S=Math.min(Math.max(x,_v),xv);i(String(S)),h({"font-size":`${S}px`})}},_=x=>{u(x),p.update(()=>{const k=Ce();ve(k)&&Ox(k,()=>Ns(x))});const{heading:S}=f;let C=null;if(S)switch(x){case"h1":C=S.find(k=>k.title==="Heading1").fontSize;break;case"h2":C=S.find(k=>k.title==="Heading2").fontSize;break;case"h3":C=S.find(k=>k.title==="Heading3").fontSize;break;case"h4":C=S.find(k=>k.title==="Heading4").fontSize;break;case"h5":C=S.find(k=>k.title==="Heading5").fontSize;break;case"paragraph":C=11;break;default:C=11}i(C),u(x),o(x)},b=()=>{i("11")};Nn.useEffect(()=>{r&&r==="Enter"&&b()},[r]),Nn.useEffect(()=>{const x=()=>{p.update(()=>{const S=Ce();if(S!==null){const k=S.getNodes()[0];if(!Pe(k)){const D=k.getType();D in ia&&o(D)}}})};return p.registerUpdateListener(x),()=>{p.registerUpdateListener(x)}},[p]);const w=x=>{if(["Heading1","Heading2","Heading3","Heading4","Heading5"].includes(x)){let C=f.heading.find(D=>D.title===x);i(C.fontSize);const k={title:`${C.title}`,"font-size":`${C.fontSize}px`,color:C.fontColor,"font-family":C.fontFamily,"margin-bottom":`${C.trailingSpace}em`,"font-weight":C.bold==="Yes"?"bold":"normal","font-style":C.italic==="Yes"?"italic":"normal","line-height":`${C.lineSpacing}em`,"text-align":C.alignment||"left"};h(k)}else d||i("11")};return Nn.useEffect(()=>{switch(n.tagName){case"P":i("11"),w(d);break;case"H1":o("h1"),i(f.heading.find(x=>x.title==="Heading1").fontSize);break;case"H2":o("h2"),i(f.heading.find(x=>x.title==="Heading2").fontSize);break;case"H3":o("h3"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"H4":o("h4"),i(f.heading.find(x=>x.title==="Heading4").fontSize);break;case"H5":o("h5"),i(f.heading.find(x=>x.title==="Heading5").fontSize);break;case"default":o("paragraph"),i("11");break}},[n]),Nn.useEffect(()=>{switch(e||o("paragraph"),e&&e.trim(" ")){case"P":i("11"),o("paragraph"),w(d);break;case"h1":o("h1"),i(f.heading.find(x=>x.title==="Heading1").fontSize);break;case"h2":o("h2"),i(f.heading.find(x=>x.title==="Heading2").fontSize);break;case"h3":o("h3"),i(f.heading.find(x=>x.title==="Heading3").fontSize);break;case"h4":o("h4"),i(f.heading.find(x=>x.title==="Heading4").fontSize);break;case"h5":o("h5"),i(f.heading.find(x=>x.title==="Heading5").fontSize);break;case"default":o("paragraph"),i("11");break}},[e]),ee.jsxs(ee.Fragment,{children:[ee.jsx("input",{type:"number",value:l,disabled:s,readOnly:!0,className:"toolbar-item font-size-input",min:_v,max:xv,onChange:y,onBlur:v}),ee.jsx(bv,{}),f&&f.heading?ee.jsxs("div",{className:"symbol-dropdown cust-head-dropDown",children:[ee.jsxs(vv,{disabled:s,buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"Formatting options for text style",buttonIconClassName:"icon block-type "+c,buttonLabel:ia[c],children:[ee.jsxs(oa,{className:`item ${c==="paragraph"?"active":""}`,onClick:()=>_("paragraph"),children:[ee.jsx("i",{className:"icon paragraph"}),ee.jsx("span",{className:"text",children:ia.paragraph})]}),f.heading&&f.heading.find(x=>x.title==="Heading1")&&ee.jsxs(oa,{className:`item ${c==="h1"?"active":""}`,onClick:()=>_("h1"),children:[ee.jsx("i",{className:"icon h1"}),ee.jsx("span",{className:"text",children:ia.h1})]}),f.heading&&f.heading.find(x=>x.title==="Heading2")&&ee.jsxs(oa,{className:`item ${c==="h2"?"active":""}`,onClick:()=>_("h2"),children:[ee.jsx("i",{className:"icon h2"}),ee.jsx("span",{className:"text",children:ia.h2})]}),f.heading&&f.heading.find(x=>x.title==="Heading3")&&ee.jsxs(oa,{className:`item ${c==="h3"?"active":""}`,onClick:()=>_("h3"),children:[ee.jsx("i",{className:"icon h3"}),ee.jsx("span",{className:"text",children:ia.h3})]}),f.heading&&f.heading.find(x=>x.title==="Heading4")&&ee.jsxs(oa,{className:`item ${c==="h4"?"active":""}`,onClick:()=>_("h4"),children:[ee.jsx("i",{className:"icon h4"}),ee.jsx("span",{className:"text",children:ia.h4})]}),f.heading&&f.heading.find(x=>x.title==="Heading5")&&ee.jsxs(oa,{className:`item ${c==="h5"?"active":""}`,onClick:()=>_("h5"),children:[ee.jsx("i",{className:"icon h5"}),ee.jsx("span",{className:"text",children:ia.h5})]})]}),ee.jsx(bv,{})]}):""]})},_C="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48IS0tISBGb250IEF3ZXNvbWUgUHJvIDYuMS4xIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlIChDb21tZXJjaWFsIExpY2Vuc2UpIENvcHlyaWdodCAyMDIyIEZvbnRpY29ucywgSW5jLi0tPjxwYXRoIGQ9Ik0wIDI1NkMwIDExNC42IDExNC42IDAgMjU2IDBzMjU2IDExNC42IDI1NiAyNTYtMTE0LjYgMjU2LTI1NiAyNTZTMCAzOTcuNCAwIDI1NnptMTc1LTQ3LjkgNDcuMSA0N0wxNzUgMzAzYy05LjMgOS40LTkuMyAyNC42IDAgMzMuMSA5LjQgMTAuMiAyNC42IDEwLjIgMzMuMSAwbDQ3LTQ2LjIgNDcuOSA0Ni4yYzkuNCAxMC4yIDI0LjYgMTAuMiAzMy4xIDAgMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMWwtNDYuMi00Ny45IDQ2LjItNDdjMTAuMi04LjUgMTAuMi0yMy43IDAtMzMuMS04LjUtOS4zLTIzLjctOS4zLTMzLjEgMGwtNDcuOSA0Ny4xLTQ3LTQ3LjFjLTguNS05LjMtMjMuNy05LjMtMzMuMSAwLTkuMyA5LjQtOS4zIDI0LjYgMCAzMy4xeiIvPjwvc3ZnPg==",xC="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iY3VycmVudENvbG9yIiBjbGFzcz0iYmkgYmktdGFibGUiPjxwYXRoIGQ9Ik0wIDJhMiAyIDAgMCAxIDItMmgxMmEyIDIgMCAwIDEgMiAydjEyYTIgMiAwIDAgMS0yIDJIMmEyIDIgMCAwIDEtMi0yVjJ6bTE1IDJoLTR2M2g0VjR6bTAgNGgtNHYzaDRWOHptMCA0aC00djNoM2ExIDEgMCAwIDAgMS0xdi0yem0tNSAzdi0zSDZ2M2g0em0tNSAwdi0zSDF2MmExIDEgMCAwIDAgMSAxaDN6bS00LTRoNFY4SDF2M3ptMC00aDRWNEgxdjN6bTUtM3YzaDRWNEg2em00IDRINnYzaDRWOHoiLz48L3N2Zz4=";function wC(){const[g,s]=se.useState("4"),[p,t]=se.useState("4"),[f,r]=se.useState(!1),[n,e]=se.useState(),[l]=_r(),i=()=>{!g||!p||(l.update(()=>{const c=J0(g,p,!0),o=m0(c);e(o)}),r(!1))};return ee.jsxs(ee.Fragment,{children:[ee.jsx("button",{title:"Table",className:"toolbar-item ",onClick:()=>r(!0),children:ee.jsx("img",{className:"add-toolbar-table-icon",src:xC,alt:"Add Table"})}),f&&ee.jsx("div",{className:"modal-overlay",children:ee.jsxs("div",{className:"modal-content",children:[ee.jsx("h3",{children:"Select Table Dimensions"}),ee.jsx("button",{className:"modal-buttons-close",onClick:()=>r(!1),children:ee.jsx("img",{src:_C,height:16,width:16,style:{margin:"0 0 29px 10px"}})}),ee.jsxs("div",{className:"select-table-container",children:[ee.jsx("label",{children:"Rows"}),ee.jsx("input",{type:"number",value:g,onChange:c=>s(Number(c.target.value))})]}),ee.jsxs("div",{className:"select-table-container",children:[ee.jsx("label",{children:"Column"}),ee.jsx("input",{type:"number",value:p,onChange:c=>t(Number(c.target.value))})]}),ee.jsx("div",{children:ee.jsx("div",{className:"modal-buttons",children:ee.jsx("button",{className:"toolbar-item",onClick:i,children:"Confirm"})})})]})})]})}const SC=[{letter:"",uppercase:"A",lowercase:"α"},{letter:"Beta",uppercase:"Β",lowercase:"β"},{letter:"Gamma",uppercase:"Γ",lowercase:"γ"},{letter:"Delta",uppercase:"Δ",lowercase:"δ"},{letter:"Epsilon",uppercase:"Ε",lowercase:"ε"},{letter:"Zeta",uppercase:"Ζ",lowercase:"ζ"},{letter:" Eta ",uppercase:"Η",lowercase:"η"},{letter:"Theta",uppercase:"Θ",lowercase:"θ"},{letter:"Iota",uppercase:"Ι",lowercase:"ι"},{letter:"Kappa",uppercase:"Κ",lowercase:"κ"}];function EC(){const[g]=_r(),[s,p]=se.useState(!1),t=f=>{g.update(()=>{var n;const r=Ce();if(ve(r)){const e=r.anchor.getNode();let l="inherit";if(e instanceof zi){const c=e.getStyle();l=((n=c==null?void 0:c.match(/font-size:\s*(\S+);/))==null?void 0:n[1])||l}const i=ir(f);r.insertNodes([i])}}),p(!1)};return ee.jsx("div",{className:"symbol-dropdown cust-head-dropDown",children:ee.jsx(vv,{buttonClassName:"toolbar-item block-controls",buttonAriaLabel:"For appying Symbols",buttonLabel:"Symbols",children:ee.jsx("div",{className:"symbol-Flex-container",children:SC.map(({letter:f,uppercase:r,lowercase:n})=>ee.jsxs("div",{className:"symbol-items",children:[ee.jsx(oa,{className:"terr",onClick:()=>t(n),children:n}),ee.jsx(oa,{className:"terr",onClick:()=>t(r),children:r})]},f))})})})}const wv="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNCAxMkgyME0xMiA0VjIwIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==",Sv="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNNiAxMkwxOCAxMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8L3N2Zz4=";var CC=typeof global=="object"&&global&&global.Object===Object&&global;const kC=CC;var OC=typeof self=="object"&&self&&self.Object===Object&&self,TC=kC||OC||Function("return this")();const Ev=TC;var AC=Ev.Symbol;const ud=AC;var Cv=Object.prototype,PC=Cv.hasOwnProperty,jC=Cv.toString,pc=ud?ud.toStringTag:void 0;function NC(g){var s=PC.call(g,pc),p=g[pc];try{g[pc]=void 0;var t=!0}catch{}var f=jC.call(g);return t&&(s?g[pc]=p:delete g[pc]),f}var IC=Object.prototype,RC=IC.toString;function MC(g){return RC.call(g)}var DC="[object Null]",LC="[object Undefined]",kv=ud?ud.toStringTag:void 0;function BC(g){return g==null?g===void 0?LC:DC:kv&&kv in Object(g)?NC(g):MC(g)}function FC(g){return g!=null&&typeof g=="object"}var zC="[object Symbol]";function UC(g){return typeof g=="symbol"||FC(g)&&BC(g)==zC}var $C=/\s/;function HC(g){for(var s=g.length;s--&&$C.test(g.charAt(s)););return s}var qC=/^\s+/;function WC(g){return g&&g.slice(0,HC(g)+1).replace(qC,"")}function Up(g){var s=typeof g;return g!=null&&(s=="object"||s=="function")}var Ov=0/0,JC=/^[-+]0x[0-9a-f]+$/i,VC=/^0b[01]+$/i,KC=/^0o[0-7]+$/i,GC=parseInt;function Tv(g){if(typeof g=="number")return g;if(UC(g))return Ov;if(Up(g)){var s=typeof g.valueOf=="function"?g.valueOf():g;g=Up(s)?s+"":s}if(typeof g!="string")return g===0?g:+g;g=WC(g);var p=VC.test(g);return p||KC.test(g)?GC(g.slice(2),p?2:8):JC.test(g)?Ov:+g}var YC=function(){return Ev.Date.now()};const $p=YC;var ZC="Expected a function",XC=Math.max,QC=Math.min;function tk(g,s,p){var t,f,r,n,e,l,i=0,c=!1,o=!1,a=!0;if(typeof g!="function")throw new TypeError(ZC);s=Tv(s)||0,Up(p)&&(c=!!p.leading,o="maxWait"in p,r=o?XC(Tv(p.maxWait)||0,s):r,a="trailing"in p?!!p.trailing:a);function u(x){var S=t,C=f;return t=f=void 0,i=x,n=g.apply(C,S),n}function d(x){return i=x,e=setTimeout(y,s),c?u(x):n}function m(x){var S=x-l,C=x-i,k=s-S;return o?QC(k,r-C):k}function h(x){var S=x-l,C=x-i;return l===void 0||S>=s||S<0||o&&C>=r}function y(){var x=$p();if(h(x))return v(x);e=setTimeout(y,m(x))}function v(x){return e=void 0,a&&t?u(x):(t=f=void 0,n)}function _(){e!==void 0&&clearTimeout(e),i=0,t=l=f=e=void 0}function b(){return e===void 0?n:v($p())}function w(){var x=$p(),S=h(x);if(t=arguments,f=this,l=x,S){if(e===void 0)return d(l);if(o)return clearTimeout(e),e=setTimeout(y,s),u(l)}return e===void 0&&(e=setTimeout(y,s)),n}return w.cancel=_,w.flush=b,w}function ek(g,s,p){const t=se.useRef(null);return t.current=g,se.useMemo(()=>tk((...f)=>{t.current&&t.current(...f)},s,{maxWait:p}),[s,p])}const Av=20;function nk({anchorElem:g}){const[s]=_r(),p=Lu(),[t,f]=se.useState(!1),[r,n]=se.useState(!1),[e,l]=se.useState(!1),[i,c]=se.useState({}),o=se.useRef(new Set),a=se.useRef(null),u=ek(y=>{const{isOutside:v,tableDOMNode:_}=rk(y);if(v){f(!1),n(!1);return}if(!_)return;a.current=_;let b=null,w=null,x=null;if(s.update(()=>{var C;const S=ur(_);if(rn(S)){const k=_n(S,D=>Dn(D));if(!Dn(k))return;if(x=s.getElementByKey(k==null?void 0:k.getKey()),x){const D=k.getChildrenSize(),I=(C=k.getChildAtIndex(0))==null?void 0:C.getChildrenSize(),T=bw(S),R=K0(S);T===D-1?b=S:R===I-1&&(w=S)}}}),x){const{width:S,y:C,right:k,left:D,bottom:I,height:T}=x.getBoundingClientRect(),{y:R,left:P}=g.getBoundingClientRect();b?(n(!1),f(!0),c({height:Av,left:D-P,top:I-R+5,width:S})):w&&(n(!0),f(!1),c({height:T,left:k-P+5,top:C-R,width:Av}))}},50,250),d=se.useMemo(()=>new ResizeObserver(()=>{f(!1),n(!1)}),[]);se.useEffect(()=>{if(e)return document.addEventListener("mousemove",u),()=>{f(!1),n(!1),u.cancel(),document.removeEventListener("mousemove",u)}},[e,u]),se.useEffect(()=>lo(s.registerMutationListener(ko,y=>{s.getEditorState().read(()=>{for(const[v,_]of y){const b=s.getElementByKey(v);switch(_){case"created":o.current.add(v),l(o.current.size>0),b&&d.observe(b);break;case"destroyed":o.current.delete(v),l(o.current.size>0),d.disconnect(),o.current.forEach(w=>{const x=s.getElementByKey(w);x&&d.observe(x)});break}}})})),[s,d]);const m=y=>{s.update(()=>{if(a.current){const v=ur(a.current);v==null||v.selectEnd(),y?(_w(),f(!1)):(xw(),n(!1))}})},h=y=>{s.update(()=>{if(a.current){const v=ur(a.current);v==null||v.selectEnd(),y?(ww(),f(!1)):(Sw(),n(!1))}})};return p?ee.jsxs(ee.Fragment,{children:[t&&ee.jsxs("div",{children:[ee.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%",padding:"20px"},onClick:()=>m(!0),children:ee.jsx("img",{src:wv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),ee.jsx("button",{className:"PlaygroundEditorTheme__tableAddRows",style:{...i,flex:"50%"},onClick:()=>h(!0),children:ee.jsx("img",{src:Sv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]}),r&&ee.jsxs("div",{className:"table-add-row-flex-container",children:[ee.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%",padding:"20px"},onClick:()=>m(!1),children:ee.jsx("img",{src:wv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})}),ee.jsx("button",{className:"PlaygroundEditorTheme__tableAddColumns table-add-row-flex-children",style:{...i,flex:"50%"},onClick:()=>h(!1),children:ee.jsx("img",{src:Sv,height:14,width:14,style:{color:"grey",marginLeft:"-3px"}})})]})]}):null}function rk(g){const s=g.target;if(s&&s instanceof HTMLElement){const p=s.closest("td.PlaygroundEditorTheme__tableCell, th.PlaygroundEditorTheme__tableCell");return{isOutside:!(p||s.closest("button.PlaygroundEditorTheme__tableAddRows")||s.closest("button.PlaygroundEditorTheme__tableAddColumns")||s.closest("div.TableCellResizer__resizer")),tableDOMNode:p}}else return{isOutside:!0,tableDOMNode:null}}function ok({anchorElem:g=document.body}){return Lu()?Yr.createPortal(ee.jsx(nk,{anchorElem:g}),g):null}const hc=1;function dd(){return ee.jsx("div",{className:"divider"})}function ik({renderOnlineUsers:g,styleConfig:s}){const[p]=_r(),t=se.useRef(null),[f,r]=se.useState(!1),[n,e]=se.useState(!1),[l,i]=se.useState(!1),[c,o]=se.useState(!1),[a,u]=se.useState(!1),[d,m]=se.useState(!1),[h,y]=se.useState(!1),[v,_]=se.useState(!1),[b,w]=se.useState("11px"),[x,S]=se.useState(()=>p.isEditable()),[C,k]=se.useState(""),[D,I]=se.useState(""),[T,R]=se.useState(""),P=se.useCallback(()=>{const $=Ce();ve($)&&(i($.hasFormat("bold")),o($.hasFormat("italic")),u($.hasFormat("underline")),m($.hasFormat("strikethrough")),y($.hasFormat("subscript")),_($.hasFormat("superscript")),w(f0($,"font-size","11px")))},[]);return se.useEffect(()=>lo(p.registerUpdateListener(({editorState:$})=>{$.read(()=>{P()})}),p.registerCommand(ei,($,q)=>{var W;const H=(W=Ce())==null?void 0:W.getNodes()[0].__parent;return p.getEditorState()._nodeMap.forEach((V,A)=>{A===H&&R(V.__tag)}),P(),!1},hc),p.registerCommand(cf,$=>(I($.target),!1),hc),p.registerCommand(gs,$=>(r($),!1),hc),p.registerCommand(hs,$=>(e($),!1),hc),p.registerCommand(fs,$=>(k($.code),!1),hc)),[p,P]),ee.jsxs("div",{className:"toolbar",ref:t,children:[ee.jsx("button",{disabled:!f,onClick:()=>{p.dispatchCommand(Il,void 0)},className:"toolbar-item spaced","aria-label":"Undo",children:ee.jsx("i",{className:"format undo"})}),ee.jsx("button",{disabled:!n,onClick:()=>{p.dispatchCommand(Rl,void 0)},className:"toolbar-item","aria-label":"Redo",children:ee.jsx("i",{className:"format redo"})}),ee.jsx(dd,{}),ee.jsx(bC,{currentElementClick:D,selectionFontSize:b.slice(0,-2),editor:p,disabled:!x,blockType:"paragraph",styleConfig:s,isenterPressed:C,currentElementSelect:T}),ee.jsx(dd,{}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"bold")},className:"toolbar-item spaced "+(l?"active":""),"aria-label":"Format Bold",children:ee.jsx("i",{className:"format bold"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"italic")},className:"toolbar-item spaced "+(c?"active":""),"aria-label":"Format Italics",children:ee.jsx("i",{className:"format italic"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"underline")},className:"toolbar-item spaced "+(a?"active":""),"aria-label":"Format Underline",children:ee.jsx("i",{className:"format underline"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"strikethrough")},className:"toolbar-item spaced "+(d?"active":""),"aria-label":"Format Strikethrough",children:ee.jsx("i",{className:"format strikethrough"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"superscript")},className:"toolbar-item spaced "+(v?"active":""),"aria-label":"Format SuperScript",children:ee.jsx("img",{src:yC,height:16,width:16,style:{marginTop:"1px"}})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(jr,"subscript")},className:"toolbar-item spaced "+(h?"active":""),"aria-label":"Format SubScript",children:ee.jsx("img",{src:mC,height:16,width:16,style:{marginTop:"1px"}})}),ee.jsx(dd,{}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(ps,"left")},className:"toolbar-item spaced","aria-label":"Left Align",children:ee.jsx("i",{className:"format left-align"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(ps,"center")},className:"toolbar-item spaced","aria-label":"Center Align",children:ee.jsx("i",{className:"format center-align"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(ps,"right")},className:"toolbar-item spaced","aria-label":"Right Align",children:ee.jsx("i",{className:"format right-align"})}),ee.jsx("button",{onClick:()=>{p.dispatchCommand(ps,"justify")},className:"toolbar-item","aria-label":"Justify Align",children:ee.jsx("i",{className:"format justify-align"})}),ee.jsx(dd,{}),ee.jsx(wC,{}),ee.jsx(EC,{}),ee.jsx(ok,{}),ee.jsx("div",{className:"avtar-outer-div",children:g()})]})}var Hp={exports:{}},En={};/** @license React v16.13.1
|
|
1430
1430
|
* react-is.production.min.js
|
|
1431
1431
|
*
|
|
1432
1432
|
* Copyright (c) Facebook, Inc. and its affiliates.
|