@simoncomputing/mui-bueno-v2 0.35.1 → 0.35.2
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/CHANGELOG.md +7 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +4 -3
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
11
11
|
- Minor increment --> singlular/minor changes. Minimal breaking changes.
|
|
12
12
|
- Patch increment --> singlular/minor changes. Zero breaking changes.
|
|
13
13
|
|
|
14
|
+
## [0.35.2] - 2026-07-21
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- `MultiAutocomplete` (`Diff`)
|
|
19
|
+
- Fixed comma delimiting of `MultiAutocomplete` value in diff mode (`mode="comma"`)
|
|
20
|
+
|
|
14
21
|
## [0.35.1] - 2026-07-20
|
|
15
22
|
|
|
16
23
|
### Fixed
|
package/dist/index.cjs.js
CHANGED
|
@@ -352,7 +352,7 @@ img.ProseMirror-separator {
|
|
|
352
352
|
*
|
|
353
353
|
* This source code is licensed under the MIT license found in the
|
|
354
354
|
* LICENSE file in the root directory of this source tree.
|
|
355
|
-
*/var bk;function cQ(){return bk||(bk=1,process.env.NODE_ENV!=="production"&&(function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=J,e=Xh;function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,l=t.useDebugValue;function u(f,p,m,b,v){var y=i(null),x;y.current===null?(x={hasValue:!1,value:null},y.current=x):x=y.current;var C=a(function(){var O=!1,R,P,j=function(z){if(!O){O=!0,R=z;var L=b(z);if(v!==void 0&&x.hasValue){var A=x.value;if(v(A,L))return P=A,A}return P=L,L}var _=R,I=P;if(r(_,z))return I;var B=b(z);return v!==void 0&&v(I,B)?I:(R=z,P=B,B)},F=m===void 0?null:m,M=function(){return j(p())},$=F===null?void 0:function(){return j(F())};return[M,$]},[p,m,b,v]),k=C[0],T=C[1],S=o(f,k,T);return s(function(){x.hasValue=!0,x.value=S},[S]),l(S),S}Dy.useSyncExternalStoreWithSelector=u,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)})()),Dy}process.env.NODE_ENV==="production"?a0.exports=lQ():a0.exports=cQ();var uQ=a0.exports;const dQ=typeof window<"u"?J.useLayoutEffect:J.useEffect;class fQ{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(o=>o())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function pQ(t){var e;const[n]=J.useState(()=>new fQ(t.editor)),r=uQ.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:aQ);return dQ(()=>n.watch(t.editor),[t.editor,n]),J.useDebugValue(r),r}const vk=process.env.NODE_ENV!=="production",l0=typeof window>"u",hQ=l0||!!(typeof window<"u"&&window.next);class Hv{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return l0||hQ?(vk&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&l0&&vk)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onBeforeCreate)===null||i===void 0?void 0:i.call(o,...r)},onBlur:(...r)=>{var o,i;return(i=(o=this.options.current).onBlur)===null||i===void 0?void 0:i.call(o,...r)},onCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onCreate)===null||i===void 0?void 0:i.call(o,...r)},onDestroy:(...r)=>{var o,i;return(i=(o=this.options.current).onDestroy)===null||i===void 0?void 0:i.call(o,...r)},onFocus:(...r)=>{var o,i;return(i=(o=this.options.current).onFocus)===null||i===void 0?void 0:i.call(o,...r)},onSelectionUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onSelectionUpdate)===null||i===void 0?void 0:i.call(o,...r)},onTransaction:(...r)=>{var o,i;return(i=(o=this.options.current).onTransaction)===null||i===void 0?void 0:i.call(o,...r)},onUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onUpdate)===null||i===void 0?void 0:i.call(o,...r)},onContentError:(...r)=>{var o,i;return(i=(o=this.options.current).onContentError)===null||i===void 0?void 0:i.call(o,...r)},onDrop:(...r)=>{var o,i;return(i=(o=this.options.current).onDrop)===null||i===void 0?void 0:i.call(o,...r)},onPaste:(...r)=>{var o,i;return(i=(o=this.options.current).onPaste)===null||i===void 0?void 0:i.call(o,...r)}};return new K7(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((o,i)=>{var s;return o===((s=n.extensions)===null||s===void 0?void 0:s[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Hv.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,o)=>r===e[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function F2(t={},e=[]){const n=J.useRef(t);n.current=t;const[r]=J.useState(()=>new Hv(n)),o=Xh.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return J.useDebugValue(o),J.useEffect(r.onRender(e)),pQ({editor:o,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&i===0?0:i+1}),o}const mQ=J.createContext({editor:null});mQ.Consumer;const V2=J.createContext({onDragStart:void 0}),z2=()=>J.useContext(V2),gQ=t=>{const e=t.as||"div",{nodeViewContentRef:n}=z2();return J.createElement(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style}})},Wv=J.forwardRef((t,e)=>{const{onDragStart:n}=z2(),r=t.as||"div";return J.createElement(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function xk(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function wk(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function yQ(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function bQ(t){if(xk(t)||wk(t))return!0;if(yQ(t)){const e=t.type;if(e)return xk(e)||wk(e)}return!1}function vQ(){try{if(J.version)return parseInt(J.version.split(".")[0],10)>=19}catch{}return!1}class H2{constructor(e,{editor:n,props:r={},as:o="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=n,this.props=r,this.element=document.createElement(o),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?ea.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var e;const n=this.component,r=this.props,o=this.editor,i=vQ(),s=bQ(n),a={...r};a.ref&&!(i||s)&&delete a.ref,!a.ref&&(i||s)&&(a.ref=l=>{this.ref=l}),this.reactElement=J.createElement(n,{...a}),(e=o==null?void 0:o.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const n=this.editor;(e=n==null?void 0:n.contentComponent)===null||e===void 0||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach(n=>{this.element.setAttribute(n,e[n])})}}class xQ extends Y7{constructor(e,n,r){if(super(e,n,r),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const o=this.dom.querySelector("[data-node-view-content]");if(!o)return;o.appendChild(this.contentDOMElement)}}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(u={})=>this.updateAttributes(u),deleteNode:()=>this.deleteNode(),ref:J.createRef()};if(!this.component.displayName){const u=f=>f.charAt(0).toUpperCase()+f.substring(1);this.component.displayName=u(this.extension.name)}const o={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:u=>{u&&this.contentDOMElement&&u.firstChild!==this.contentDOMElement&&(u.hasAttribute("data-node-view-wrapper")&&u.removeAttribute("data-node-view-wrapper"),u.appendChild(this.contentDOMElement))}},i=this.component,s=J.memo(u=>J.createElement(V2.Provider,{value:o},J.createElement(i,u)));s.displayName="ReactNodeView";let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new H2(s,{editor:this.editor,props:e,as:a,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:n}=this.editor.state.selection,r=this.getPos();if(typeof r=="number")if(e<=r&&n>=r+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,n,r){const o=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=n,this.innerDecorations=r,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:n,oldInnerDecorations:a,innerDecorations:r,updateProps:()=>o({node:e,decorations:n,innerDecorations:r})})}return e===this.node&&this.decorations===n&&this.innerDecorations===r||(this.node=e,this.decorations=n,this.innerDecorations=r,o({node:e,decorations:n,innerDecorations:r})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){const n=this.editor.extensionManager.attributes,r=up(this.node,n);e=this.options.attrs({node:this.node,HTMLAttributes:r})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function Uv(t,e){return n=>n.editor.contentComponent?new xQ(t,n,e):{}}const Lc=Zt("HeadingWithAnchorComponent",["root","container","link","linkIcon"]),Ku=qt("HeadingWithAnchorComponent"),wQ=oe(Wv,{name:Ku,slot:"root",overridesResolver:(t,e)=>e.root,shouldForwardProp:t=>t!=="ownerState"&&t!=="theme"&&t!=="sx"})({[`&:hover .${Lc.link}`]:{opacity:100}}),CQ=oe("span",{name:Ku,slot:"container",overridesResolver:(t,e)=>e.container})({display:"inline-block",position:"relative"}),SQ=oe("a",{name:Ku,slot:"link",overridesResolver:(t,e)=>e.link})(({theme:t})=>({position:"absolute",left:-21,color:`${t.palette.text.secondary} !important`,opacity:0,transition:t.transitions.create("opacity"),textDecoration:"none",outline:"none",[t.breakpoints.down("sm")]:{left:-18},'.ProseMirror[contenteditable="true"] &':{display:"none"}})),TQ=oe(Kh,{name:Ku,slot:"linkIcon",overridesResolver:(t,e)=>e.linkIcon})(({theme:t})=>({transform:"rotate(-45deg)",fontSize:"1.25rem",[t.breakpoints.down("sm")]:{fontSize:"1.15rem"}}));function kQ(t){const e=rt({props:t,name:Ku}),{editor:n,node:r,extension:o,classes:i={},sx:s}=e,u=`h${o.options.levels.includes(r.attrs.level)?r.attrs.level:o.options.levels[0]}`,f=J.useMemo(()=>rv(n.schema),[n.schema]),p=mX(W_(r,{textSerializers:f}));return g.jsx(wQ,{as:u,id:p,...o.options.HTMLAttributes,className:ye([Lc.root,i.root]),style:{textAlign:r.attrs.textAlign},sx:s,children:g.jsxs(CQ,{className:ye([Lc.container,i.container]),children:[g.jsx(SQ,{href:`#${p}`,contentEditable:!1,className:ye([Lc.link,i.link]),children:g.jsx(TQ,{className:ye([Lc.linkIcon,i.linkIcon])})}),g.jsx(gQ,{as:"span"})]})})}const EQ=oR.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),scrollToAnchorOnMount:!0}},onCreate(){this.options.scrollToAnchorOnMount&&setTimeout(()=>{OQ(this.editor)})},addNodeView(){return Uv(kQ)}});function OQ(t){if(t.isDestroyed||!("heading"in t.storage))return;const n=window.location.hash.slice(1);if(!n)return;const r=window.document.getElementById(n);r&&t.view.dom.contains(r)&&r.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})}var ur;(function(t){t[t.HIDDEN=0]="HIDDEN",t[t.VIEW_LINK_DETAILS=1]="VIEW_LINK_DETAILS",t[t.EDIT_LINK=2]="EDIT_LINK"})(ur||(ur={}));const MQ=gn.create({name:"linkBubbleMenuHandler",addStorage(){return{state:ur.HIDDEN,bubbleMenuOptions:void 0}},addCommands(){return{openLinkBubbleMenu:(t={})=>({editor:e,chain:n,dispatch:r})=>{const o=this.storage.state;let i;return e.isActive("link")?(o!==ur.VIEW_LINK_DETAILS&&n().extendMarkRange("link").focus().run(),i=ur.VIEW_LINK_DETAILS):i=ur.EDIT_LINK,r&&(this.storage.state=i,this.storage.bubbleMenuOptions=t),!0},editLinkInBubbleMenu:()=>({dispatch:t})=>{const e=this.storage.state,n=ur.EDIT_LINK;return e===n?!1:(t&&(this.storage.state=n),!0)},closeLinkBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.state===ur.HIDDEN?!1:(t.focus(),e&&(this.storage.state=ur.HIDDEN),!0)}},onSelectionUpdate(){this.storage.state===ur.EDIT_LINK?this.editor.commands.closeLinkBubbleMenu():this.storage.state===ur.VIEW_LINK_DETAILS&&!this.editor.isActive("link")&&this.editor.commands.closeLinkBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-u":()=>(this.editor.commands.openLinkBubbleMenu(),!0)}},addProseMirrorPlugins(){return[new on({key:new On("handleClickLinkForMenu"),props:{handleClick:(t,e,n)=>{const r=sv(t.state,"link");return n.target.closest("a")&&r.href&&this.storage.state===ur.HIDDEN?this.editor.commands.openLinkBubbleMenu():this.editor.commands.closeLinkBubbleMenu(),!1}}})]}}),_Q=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,RQ=rn.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Tt(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[K_({find:_Q,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}});var Ay={},Ck;function IQ(){return Ck||(Ck=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=y2();function n(r,o=0,i={}){const{leading:s=!0,trailing:a=!0}=i;return e.debounce(r,o,{leading:s,maxWait:o,trailing:a})}t.throttle=n})(Ay)),Ay}var Py,Sk;function DQ(){return Sk||(Sk=1,Py=IQ().throttle),Py}var AQ=DQ();const PQ=Qn(AQ),pf=Zt("ResizableImageComponent",["imageContainer","image","imageSelected","resizer"]),NQ=Zt("ResizableImageResizer",["root"]),W2=qt("ResizableImageResizer"),jQ=oe("div",{name:W2,slot:"root",overridesResolver:(t,e)=>e.root})(({theme:t})=>({position:"absolute",bottom:-3,right:-3,width:12,height:12,background:t.palette.primary.main,cursor:"nwse-resize"}));function $Q(t){const e=rt({props:t,name:W2}),{onResize:n,className:r,mouseDown:o,setMouseDown:i,classes:s={},sx:a}=e;J.useEffect(()=>{if(!o)return;const u=f=>{n(f)};return window.addEventListener("mousemove",u),()=>{window.removeEventListener("mousemove",u)}},[o,n]),J.useEffect(()=>{const u=()=>{i(!1)};return window.addEventListener("mouseup",u),()=>{window.removeEventListener("mouseup",u)}},[i]);const l=J.useCallback(u=>{u.preventDefault(),u.stopPropagation(),i(!0)},[i]);return g.jsx(jQ,{className:ye([NQ.root,r,s.root]),onMouseDown:l,sx:a})}const LQ=15,Zh=qt("ResizableImageComponent"),BQ=oe("div",{name:Zh,slot:"imageContainer",overridesResolver:(t,e)=>e.imageContainer})(()=>({display:"inline-flex",position:"relative"})),FQ=oe("img",{name:Zh,slot:"image",overridesResolver:(t,e)=>[e.image,t.ownerState.selectedOrResizing&&e.imageSelected]})(({theme:t,ownerState:e})=>({display:"block",...e.selectedOrResizing&&{outline:`3px solid ${t.palette.primary.main}`}})),VQ=oe($Q,{name:Zh,slot:"resizer",overridesResolver:(t,e)=>e.resizer})(()=>({'.ProseMirror[contenteditable="false"] &':{display:"none"}}));function zQ(t){var e,n,r;const o=rt({props:t,name:Zh}),{node:i,selected:s,updateAttributes:a,extension:l,classes:u={},sx:f}=o,{attrs:p}=i,m=J.useRef(null),[b,v]=J.useState(!1),y=s||b,x={selected:s,selectedOrResizing:y},C=J.useMemo(()=>PQ(T=>{if(!m.current)return;const S=m.current.getBoundingClientRect(),O=T.clientX-S.x,R=T.clientY-S.y,P=Math.max(O,S.width/S.height*R,LQ);a({width:Math.round(P)})},50,{trailing:!0}),[a]),k=l.options.ChildComponent;return g.jsx(Wv,{style:{textAlign:p.textAlign,width:"100%"},as:l.options.inline?"span":"div",sx:f,children:g.jsxs(BQ,{className:ye([pf.imageContainer,u.imageContainer]),children:[g.jsx(FQ,{ref:m,src:p.src,height:"auto",width:p.width?p.width:void 0,alt:(e=p.alt)!==null&&e!==void 0?e:void 0,title:(n=p.title)!==null&&n!==void 0?n:void 0,className:ye([pf.image,u.image,y&&"ProseMirror-selectednode",y&&[pf.imageSelected,u.imageSelected]]),style:{maxWidth:p.width?void 0:"auto",aspectRatio:(r=p.aspectRatio)!==null&&r!==void 0?r:void 0},ownerState:x,"data-drag-handle":!0,onLoad:T=>{const S={};p.width||(S.width=T.currentTarget.naturalWidth),p.aspectRatio||(S.aspectRatio=String(T.currentTarget.naturalWidth/T.currentTarget.naturalHeight)),(S.width||S.aspectRatio)&&a(S)}}),y&&g.jsx(VQ,{onResize:C,className:ye([pf.resizer,u.resizer]),mouseDown:b,setMouseDown:v}),k&&g.jsx(k,{...o})]})})}const HQ=RQ.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),isAllowedImgSrc:e=>!!e}},addAttributes(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),width:{default:null,renderHTML:e=>({width:e.width}),parseHTML:e=>e.getAttribute("width")},aspectRatio:{default:null,renderHTML:e=>e.aspectRatio?{style:`aspect-ratio: ${e.aspectRatio}`}:{},parseHTML:e=>e.style.aspectRatio}}},renderHTML({HTMLAttributes:t}){return["img",Tt({height:"auto"},this.options.HTMLAttributes,t)]},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])',getAttrs:t=>{if(!(t instanceof Element))return!1;const e=t.getAttribute("src");return this.options.isAllowedImgSrc(e)&&null}}]},addInputRules(){var t;const e=(t=this.parent)===null||t===void 0?void 0:t.call(this);if(!e)return[];const n=r=>{const[,,o,i,s]=r;return{src:i,alt:o,title:s}};return e.map(r=>new ju({find:r.find,handler:o=>{const i=n(o.match);if(this.options.isAllowedImgSrc(i.src))return r.handler(o)}}))},addNodeView(){return Uv(zQ)}});let c0,u0;if(typeof WeakMap<"u"){let t=new WeakMap;c0=e=>t.get(e),u0=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;c0=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},u0=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var mn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,o=e/this.width|0;let i=r+1,s=o+1;for(let a=1;i<this.width&&this.map[e+a]==n;a++)i++;for(let a=1;s<this.height&&this.map[e+this.width*a]==n;a++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:r,top:o,bottom:i}=this.findCell(t),{left:s,right:a,top:l,bottom:u}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(o,l),right:Math.max(r,a),bottom:Math.max(i,u)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const a=(t+1)*this.width;for(;s<a&&this.map[s]<o;)s++;return s==a?i-1:this.map[s]}o=i}}static get(t){return c0(t)||u0(t,WQ(t))}};function WQ(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=UQ(t),n=t.childCount,r=[];let o=0,i=null;const s=[];for(let u=0,f=e*n;u<f;u++)r[u]=0;for(let u=0,f=0;u<n;u++){const p=t.child(u);f++;for(let v=0;;v++){for(;o<r.length&&r[o]!=0;)o++;if(v==p.childCount)break;const y=p.child(v),{colspan:x,rowspan:C,colwidth:k}=y.attrs;for(let T=0;T<C;T++){if(T+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:C-T});break}const S=o+T*e;for(let O=0;O<x;O++){r[S+O]==0?r[S+O]=f:(i||(i=[])).push({type:"collision",row:u,pos:f,n:x-O});const R=k&&k[O];if(R){const P=(S+O)%e*2,j=s[P];j==null||j!=R&&s[P+1]==1?(s[P]=R,s[P+1]=1):j==R&&s[P+1]++}}}o+=x,f+=y.nodeSize}const m=(u+1)*e;let b=0;for(;o<m;)r[o++]==0&&b++;b&&(i||(i=[])).push({type:"missing",row:u,n:b}),f++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const a=new mn(e,n,r,i);let l=!1;for(let u=0;!l&&u<s.length;u+=2)s[u]!=null&&s[u+1]<n&&(l=!0);return l&&qQ(a,s,t),a}function UQ(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const o=t.child(r);let i=0;if(n)for(let s=0;s<r;s++){const a=t.child(s);for(let l=0;l<a.childCount;l++){const u=a.child(l);s+u.attrs.rowspan>r&&(i+=u.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const a=o.child(s);i+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function qQ(t,e,n){t.problems||(t.problems=[]);const r={};for(let o=0;o<t.map.length;o++){const i=t.map[o];if(r[i])continue;r[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let a=null;const l=s.attrs;for(let u=0;u<l.colspan;u++){const f=e[(o+u)%t.width*2];f!=null&&(!l.colwidth||l.colwidth[u]!=f)&&((a||(a=KQ(l)))[u]=f)}a&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function KQ(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function ir(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}const ls=new On("selectingCells");function Xl(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function YQ(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Io(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Qh(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Xl(e.$head)||GQ(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function GQ(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function d0(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function JQ(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function qv(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function U2(t,e,n){const r=t.node(-1),o=mn.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function Ta(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function q2(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function XQ(t,e,n){const r=ir(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var zt=class wi extends nt{constructor(e,n=e){const r=e.node(-1),o=mn.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),a=e.node(0),l=o.cellsInRect(s).filter(f=>f!=n.pos-i);l.unshift(n.pos-i);const u=l.map(f=>{const p=r.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=i+f+1;return new LM(a.resolve(m),a.resolve(m+p.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(d0(r)&&d0(o)&&qv(r,o)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?wi.rowSelection(r,o):i&&this.isColSelection()?wi.colSelection(r,o):new wi(r,o)}return Je.between(r,o)}content(){const e=this.$anchorCell.node(-1),n=mn.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let l=o.top;l<o.bottom;l++){const u=[];for(let f=l*n.width+o.left,p=o.left;p<o.right;p++,f++){const m=n.map[f];if(i[m])continue;i[m]=!0;const b=n.findCell(m);let v=e.nodeAt(m);if(!v)throw new RangeError(`No cell with offset ${m} found`);const y=o.left-b.left,x=b.right-o.right;if(y>0||x>0){let C=v.attrs;if(y>0&&(C=Ta(C,0,y)),x>0&&(C=Ta(C,C.colspan-x,x)),b.left<o.left){if(v=v.type.createAndFill(C),!v)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(C)}`)}else v=v.type.create(C,v.content)}if(b.top<o.top||b.bottom>o.bottom){const C={...v.attrs,rowspan:Math.min(b.bottom,o.bottom)-Math.max(b.top,o.top)};b.top<o.top?v=v.type.createAndFill(C):v=v.type.create(C,v.content)}u.push(v)}s.push(e.child(l).copy(Oe.from(u)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new $e(Oe.from(a),1,1)}replace(e,n=$e.empty){const r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:a,$to:l}=o[s],u=e.mapping.slice(r);e.replace(u.map(a.pos),u.map(l.pos),s?$e.empty:n)}const i=nt.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new $e(Oe.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=mn.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),o=mn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(i+o.map[s.left])),a.bottom<o.height&&(n=l.resolve(i+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(i+o.map[a.left])),s.bottom<o.height&&(e=l.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new wi(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=mn.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,a=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==n.width}eq(e){return e instanceof wi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),o=mn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(i+o.map[s.top*o.width])),a.right<o.width&&(n=l.resolve(i+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(i+o.map[a.top*o.width])),s.right<o.width&&(e=l.resolve(i+o.map[o.width*(s.top+1)-1]))),new wi(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new wi(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new wi(e.resolve(n),e.resolve(r))}getBookmark(){return new ZQ(this.$anchorCell.pos,this.$headCell.pos)}};zt.prototype.visible=!1;nt.jsonID("cell",zt);var ZQ=class K2{constructor(e,n){this.anchor=e,this.head=n}map(e){return new K2(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&qv(n,r)?new zt(n,r):nt.near(r,1)}};function QQ(t){if(!(t.selection instanceof zt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Zn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Xt.create(t.doc,e)}function eee({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function tee({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){const i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function nee(t,e,n){const r=(e||t).selection,o=(e||t).doc;let i,s;if(r instanceof Ge&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=zt.create(o,r.from);else if(s=="row"){const a=o.resolve(r.from+1);i=zt.rowSelection(a,a)}else if(!n){const a=mn.get(r.node),l=r.from+1,u=l+a.map[a.width*a.height-1];i=zt.create(o,l+1,u)}}else r instanceof Je&&eee(r)?i=Je.create(o,r.from):r instanceof Je&&tee(r)&&(i=Je.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const ree=new On("fix-tables");function Y2(t,e,n,r){const o=t.childCount,i=e.childCount;e:for(let s=0,a=0;s<i;s++){const l=e.child(s);for(let u=a,f=Math.min(o,s+3);u<f;u++)if(t.child(u)==l){a=u+1,n+=l.nodeSize;continue e}r(l,n),a<o&&t.child(a).sameMarkup(l)?Y2(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function G2(t,e){let n;const r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=oee(t,o,i,n))};return e?e.doc!=t.doc&&Y2(e.doc,t.doc,0,r):t.doc.descendants(r),n}function oee(t,e,n,r){const o=mn.get(e);if(!o.problems)return r;r||(r=t.tr);const i=[];for(let l=0;l<o.height;l++)i.push(0);for(let l=0;l<o.problems.length;l++){const u=o.problems[l];if(u.type=="collision"){const f=e.nodeAt(u.pos);if(!f)continue;const p=f.attrs;for(let m=0;m<p.rowspan;m++)i[u.row+m]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,Ta(p,p.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){const f=r.mapping.map(n);r.delete(f,f+e.nodeSize)}}let s,a;for(let l=0;l<i.length;l++)i[l]&&(s==null&&(s=l),a=l);for(let l=0,u=n+1;l<o.height;l++){const f=e.child(l),p=u+f.nodeSize,m=i[l];if(m>0){let b="cell";f.firstChild&&(b=f.firstChild.type.spec.tableRole);const v=[];for(let x=0;x<m;x++){const C=ir(t.schema)[b].createAndFill();C&&v.push(C)}const y=(l==0||s==l-1)&&a==l?u+1:p-1;r.insert(r.mapping.map(y),v)}u=p}return r.setMeta(ree,{fixTables:!0})}function oi(t){const e=t.selection,n=Qh(t),r=n.node(-1),o=n.start(-1),i=mn.get(r);return{...e instanceof zt?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function J2(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;XQ(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+o;if(o>0&&o<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],u=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,q2(u.attrs,o-e.colCount(l))),s+=u.attrs.rowspan-1}else{const l=i==null?ir(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,u=e.positionAt(s,o,r);t.insert(t.mapping.map(n+u),l.createAndFill())}}return t}function iee(t,e){if(!Io(t))return!1;if(e){const n=oi(t);e(J2(t.tr,n,n.left))}return!0}function see(t,e){if(!Io(t))return!1;if(e){const n=oi(t);e(J2(t.tr,n,n.right))}return!0}function aee(t,{map:e,table:n,tableStart:r},o){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+o,l=e.map[a],u=n.nodeAt(l),f=u.attrs;if(o>0&&e.map[a-1]==l||o<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(i).map(r+l),null,Ta(f,o-e.colCount(l)));else{const p=t.mapping.slice(i).map(r+l);t.delete(p,p+u.nodeSize)}s+=f.rowspan}}function lee(t,e){if(!Io(t))return!1;if(e){const n=oi(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;aee(r,n,o),o!=n.left;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=mn.get(i)}e(r)}return!0}function cee(t,e,n){var r;const o=ir(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function X2(t,{map:e,tableStart:n,table:r},o){let i=n;for(let u=0;u<o;u++)i+=r.child(u).nodeSize;const s=[];let a=o>0?-1:0;cee(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let u=0,f=e.width*o;u<e.width;u++,f++)if(o>0&&o<e.height&&e.map[f]==e.map[f-e.width]){const p=e.map[f],m=r.nodeAt(p).attrs;t.setNodeMarkup(n+p,null,{...m,rowspan:m.rowspan+1}),u+=m.colspan-1}else{var l;const p=a==null?ir(r.type.schema).cell:(l=r.nodeAt(e.map[f+a*e.width]))===null||l===void 0?void 0:l.type,m=p==null?void 0:p.createAndFill();m&&s.push(m)}return t.insert(i,ir(r.type.schema).row.create(null,s)),t}function uee(t,e){if(!Io(t))return!1;if(e){const n=oi(t);e(X2(t.tr,n,n.top))}return!0}function dee(t,e){if(!Io(t))return!1;if(e){const n=oi(t);e(X2(t.tr,n,n.bottom))}return!0}function fee(t,{map:e,table:n,tableStart:r},o){let i=0;for(let u=0;u<o;u++)i+=n.child(u).nodeSize;const s=i+n.child(o).nodeSize,a=t.mapping.maps.length;t.delete(i+r,s+r);const l=new Set;for(let u=0,f=o*e.width;u<e.width;u++,f++){const p=e.map[f];if(!l.has(p)){if(l.add(p),o>0&&p==e.map[f-e.width]){const m=n.nodeAt(p).attrs;t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m,rowspan:m.rowspan-1}),u+=m.colspan-1}else if(o<e.height&&p==e.map[f+e.width]){const m=n.nodeAt(p),b=m.attrs,v=m.type.create({...b,rowspan:m.attrs.rowspan-1},m.content),y=e.positionAt(o+1,u,n);t.insert(t.mapping.slice(a).map(r+y),v),u+=b.colspan-1}}}}function pee(t,e){if(!Io(t))return!1;if(e){const n=oi(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;fee(r,n,o),o!=n.top;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=mn.get(n.table)}e(r)}return!0}function Tk(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function hee({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,a=o+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[a]==n[a+1])return!0;i+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function kk(t,e){const n=t.selection;if(!(n instanceof zt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=oi(t),{map:o}=r;if(hee(o,r))return!1;if(e){const i=t.tr,s={};let a=Oe.empty,l,u;for(let f=r.top;f<r.bottom;f++)for(let p=r.left;p<r.right;p++){const m=o.map[f*o.width+p],b=r.table.nodeAt(m);if(!(s[m]||!b))if(s[m]=!0,l==null)l=m,u=b;else{Tk(b)||(a=a.append(b.content));const v=i.mapping.map(m+r.tableStart);i.delete(v,v+b.nodeSize)}}if(l==null||u==null)return!0;if(i.setNodeMarkup(l+r.tableStart,null,{...q2(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const f=l+1+u.content.size,p=Tk(u)?l+1:f;i.replaceWith(p+r.tableStart,f+r.tableStart,a)}i.setSelection(new zt(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function Ek(t,e){const n=ir(t.schema);return mee(({node:r})=>n[r.type.spec.tableRole])(t,e)}function mee(t){return(e,n)=>{const r=e.selection;let o,i;if(r instanceof zt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=YQ(r.$from),!o)return!1;i=(s=Xl(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let a=o.attrs;const l=[],u=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const f=oi(e),p=e.tr;for(let b=0;b<f.right-f.left;b++)l.push(u?{...a,colwidth:u&&u[b]?[u[b]]:null}:a);let m;for(let b=f.top;b<f.bottom;b++){let v=f.map.positionAt(b,f.left,f.table);b==f.top&&(v+=o.nodeSize);for(let y=f.left,x=0;y<f.right;y++,x++)y==f.left&&b==f.top||p.insert(m=p.mapping.map(v+f.tableStart,1),t({node:o,row:b,col:y}).createAndFill(l[x]))}p.setNodeMarkup(i,t({node:o,row:f.top,col:f.left}),l[0]),r instanceof zt&&p.setSelection(new zt(p.doc.resolve(r.$anchorCell.pos),m?p.doc.resolve(m):void 0)),n(p)}return!0}}function gee(t,e){return function(n,r){if(!Io(n))return!1;const o=Qh(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof zt?n.selection.forEachCell((s,a)=>{s.attrs[t]!==e&&i.setNodeMarkup(a,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function yee(t){return function(e,n){if(!Io(e))return!1;if(n){const r=ir(e.schema),o=oi(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=s.map(l=>o.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[l],r.cell,a[l].attrs);if(i.steps.length===0)for(let l=0;l<s.length;l++)i.setNodeMarkup(o.tableStart+s[l],r.header_cell,a[l].attrs);n(i)}return!0}}function Ok(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function Eu(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?yee(t):function(n,r){if(!Io(n))return!1;if(r){const o=ir(n.schema),i=oi(n),s=n.tr,a=Ok("row",i,o),l=Ok("column",i,o),u=(t==="column"?a:t==="row"&&l)?1:0,f=t=="column"?{left:0,top:u,right:1,bottom:i.map.height}:t=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,p=t=="column"?l?o.cell:o.header_cell:t=="row"?a?o.cell:o.header_cell:o.cell;i.map.cellsInRect(f).forEach(m=>{const b=m+i.tableStart,v=s.doc.nodeAt(b);v&&s.setNodeMarkup(b,p,v.attrs)}),r(s)}return!0}}Eu("row",{useDeprecatedLogic:!0});Eu("column",{useDeprecatedLogic:!0});const bee=Eu("cell",{useDeprecatedLogic:!0});function vee(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){const i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function Mk(t){return function(e,n){if(!Io(e))return!1;const r=vee(Qh(e),t);if(r==null)return!1;if(n){const o=e.doc.resolve(r);n(e.tr.setSelection(Je.between(o,JQ(o))).scrollIntoView())}return!0}}function xee(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function hf(t,e){const n=t.selection;if(!(n instanceof zt))return!1;if(e){const r=t.tr,o=ir(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new $e(o,0,0))}),r.docChanged&&e(r)}return!0}function wee(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let u=e.child(l).content;const f=l?0:Math.max(0,n-1),p=l<e.childCount-1?0:Math.max(0,r-1);(f||p)&&(u=f0(ir(s).row,new $e(u,f,p)).content),a.push(u)}else if(i=="cell"||i=="header_cell")a.push(n||r?f0(ir(s).row,new $e(e,n,r)).content:e);else return null;return Cee(s,a)}function Cee(t,e){const n=[];for(let o=0;o<e.length;o++){const i=e[o];for(let s=i.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=i.child(s).attrs;for(let u=o;u<o+a;u++)n[u]=(n[u]||0)+l}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(Oe.empty),n[o]<r){const i=ir(t).cell.createAndFill(),s=[];for(let a=n[o];a<r;a++)s.push(i);e[o]=e[o].append(Oe.from(s))}return{height:e.length,width:r,rows:e}}function f0(t,e){const n=t.createAndFill();return new L0(n).replace(0,n.content.size,e).doc}function See({width:t,height:e,rows:n},r,o){if(t!=r){const i=[],s=[];for(let a=0;a<n.length;a++){const l=n[a],u=[];for(let f=i[a]||0,p=0;f<r;p++){let m=l.child(p%l.childCount);f+m.attrs.colspan>r&&(m=m.type.createChecked(Ta(m.attrs,m.attrs.colspan,f+m.attrs.colspan-r),m.content)),u.push(m),f+=m.attrs.colspan;for(let b=1;b<m.attrs.rowspan;b++)i[a+b]=(i[a+b]||0)+m.attrs.colspan}s.push(Oe.from(u))}n=s,t=r}if(e!=o){const i=[];for(let s=0,a=0;s<o;s++,a++){const l=[],u=n[a%e];for(let f=0;f<u.childCount;f++){let p=u.child(f);s+p.attrs.rowspan>o&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,o-p.attrs.rowspan)},p.content)),l.push(p)}i.push(Oe.from(l))}n=i,e=o}return{width:t,height:e,rows:n}}function Tee(t,e,n,r,o,i,s){const a=t.doc.type.schema,l=ir(a);let u,f;if(o>e.width)for(let p=0,m=0;p<e.height;p++){const b=n.child(p);m+=b.nodeSize;const v=[];let y;b.lastChild==null||b.lastChild.type==l.cell?y=u||(u=l.cell.createAndFill()):y=f||(f=l.header_cell.createAndFill());for(let x=e.width;x<o;x++)v.push(y);t.insert(t.mapping.slice(s).map(m-1+r),v)}if(i>e.height){const p=[];for(let v=0,y=(e.height-1)*e.width;v<Math.max(e.width,o);v++){const x=v>=e.width?!1:n.nodeAt(e.map[y+v]).type==l.header_cell;p.push(x?f||(f=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const m=l.row.create(null,Oe.from(p)),b=[];for(let v=e.height;v<i;v++)b.push(m);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),b)}return!!(u||f)}function _k(t,e,n,r,o,i,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let u=o;u<i;u++){const f=s*e.width+u,p=e.map[f];if(e.map[f-e.width]==p){l=!0;const m=n.nodeAt(p),{top:b,left:v}=e.findCell(p);t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m.attrs,rowspan:s-b}),t.insert(t.mapping.slice(a).map(e.positionAt(s,v,n)),m.type.createAndFill({...m.attrs,rowspan:b+m.attrs.rowspan-s})),u+=m.attrs.colspan-1}}return l}function Rk(t,e,n,r,o,i,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let u=o;u<i;u++){const f=u*e.width+s,p=e.map[f];if(e.map[f-1]==p){l=!0;const m=n.nodeAt(p),b=e.colCount(p),v=t.mapping.slice(a).map(p+r);t.setNodeMarkup(v,null,Ta(m.attrs,s-b,m.attrs.colspan-(s-b))),t.insert(v+m.nodeSize,m.type.createAndFill(Ta(m.attrs,0,s-b))),u+=m.attrs.rowspan-1}}return l}function Ik(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=mn.get(i);const{top:a,left:l}=r,u=l+o.width,f=a+o.height,p=t.tr;let m=0;function b(){if(i=n?p.doc.nodeAt(n-1):p.doc,!i)throw new Error("No table found");s=mn.get(i),m=p.mapping.maps.length}Tee(p,s,i,n,u,f,m)&&b(),_k(p,s,i,n,l,u,a,m)&&b(),_k(p,s,i,n,l,u,f,m)&&b(),Rk(p,s,i,n,a,f,l,m)&&b(),Rk(p,s,i,n,a,f,u,m)&&b();for(let v=a;v<f;v++){const y=s.positionAt(v,l,i),x=s.positionAt(v,u,i);p.replace(p.mapping.slice(m).map(y+n),p.mapping.slice(m).map(x+n),new $e(o.rows[v-a],0,0))}b(),p.setSelection(new zt(p.doc.resolve(n+s.positionAt(a,l,i)),p.doc.resolve(n+s.positionAt(f-1,u-1,i)))),e(p)}const kee=G0({ArrowLeft:mf("horiz",-1),ArrowRight:mf("horiz",1),ArrowUp:mf("vert",-1),ArrowDown:mf("vert",1),"Shift-ArrowLeft":gf("horiz",-1),"Shift-ArrowRight":gf("horiz",1),"Shift-ArrowUp":gf("vert",-1),"Shift-ArrowDown":gf("vert",1),Backspace:hf,"Mod-Backspace":hf,Delete:hf,"Mod-Delete":hf});function Nf(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function mf(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;if(i instanceof zt)return Nf(n,r,nt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const s=Z2(o,t,e);if(s==null)return!1;if(t=="horiz")return Nf(n,r,nt.near(n.doc.resolve(i.head+e),e));{const a=n.doc.resolve(s),l=U2(a,t,e);let u;return l?u=nt.near(l,1):e<0?u=nt.near(n.doc.resolve(a.before(-1)),-1):u=nt.near(n.doc.resolve(a.after(-1)),1),Nf(n,r,u)}}}function gf(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof zt)s=i;else{const l=Z2(o,t,e);if(l==null)return!1;s=new zt(n.doc.resolve(l))}const a=U2(s.$headCell,t,e);return a?Nf(n,r,new zt(s.$anchorCell,a)):!1}}function Eee(t,e){const n=t.state.doc,r=Xl(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new zt(r))),!0):!1}function Oee(t,e,n){if(!Io(t.state))return!1;let r=wee(n);const o=t.state.selection;if(o instanceof zt){r||(r={width:1,height:1,rows:[Oe.from(f0(ir(t.state.schema).cell,n))]});const i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),a=mn.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=See(r,a.right-a.left,a.bottom-a.top),Ik(t.state,t.dispatch,s,a,r),!0}else if(r){const i=Qh(t.state),s=i.start(-1);return Ik(t.state,t.dispatch,s,mn.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function Mee(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Dk(t,e.target);let o;if(e.shiftKey&&t.state.selection instanceof zt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Xl(t.state.selection.$anchor))!=null&&((n=Ny(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(l,u){let f=Ny(t,u);const p=ls.getState(t.state)==null;if(!f||!qv(l,f))if(p)f=l;else return;const m=new zt(l,f);if(p||!t.state.selection.eq(m)){const b=t.state.tr.setSelection(m);p&&b.setMeta(ls,l.pos),t.dispatch(b)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),ls.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ls,-1))}function a(l){const u=l,f=ls.getState(t.state);let p;if(f!=null)p=t.state.doc.resolve(f);else if(Dk(t,u.target)!=r&&(p=Ny(t,e),!p))return s();p&&i(p,u)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function Z2(t,e,n){if(!(t.state.selection instanceof Je))return null;const{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const s=r.before(o),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?s:null}}return null}function Dk(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ny(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;const r=n.inside>=0?n.inside:n.pos;return Xl(t.state.doc.resolve(r))}var _ee=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),p0(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,p0(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function p0(t,e,n,r,o,i){let s=0,a=!0,l=e.firstChild;const u=t.firstChild;if(u){for(let p=0,m=0;p<u.childCount;p++){const{colspan:b,colwidth:v}=u.child(p).attrs;for(let y=0;y<b;y++,m++){const x=o==m?i:v&&v[y],C=x?x+"px":"";if(s+=x||r,x||(a=!1),l)l.style.width!=C&&(l.style.width=C),l=l.nextSibling;else{const k=document.createElement("col");k.style.width=C,e.appendChild(k)}}}for(;l;){var f;const p=l.nextSibling;(f=l.parentNode)===null||f===void 0||f.removeChild(l),l=p}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const Lr=new On("tableColumnResizing");function Q2({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=_ee,lastColumnResizable:o=!0}={}){const i=new on({key:Lr,state:{init(s,a){var l;const u=(l=i.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,f=ir(a.schema).table.name;return r&&u&&(u[f]=(p,m)=>new r(p,n,m)),new Ree(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=Lr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{Iee(s,a,t,o)},mouseleave:s=>{Dee(s)},mousedown:(s,a)=>{Aee(s,a,e,n)}},decorations:s=>{const a=Lr.getState(s);if(a&&a.activeHandle>-1)return Lee(s,a.activeHandle)},nodeViews:{}}});return i}var Ree=class jf{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new jf(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new jf(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return d0(e.doc.resolve(o))||(o=-1),new jf(o,n.dragging)}return n}};function Iee(t,e,n,r){if(!t.editable)return;const o=Lr.getState(t.state);if(o&&!o.dragging){const i=Nee(e.target);let s=-1;if(i){const{left:a,right:l}=i.getBoundingClientRect();e.clientX-a<=n?s=Ak(t,e,"left",n):l-e.clientX<=n&&(s=Ak(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){const a=t.state.doc.resolve(s),l=a.node(-1),u=mn.get(l),f=a.start(-1);if(u.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==u.width-1)return}eI(t,s)}}}function Dee(t){if(!t.editable)return;const e=Lr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&eI(t,-1)}function Aee(t,e,n,r){var o;if(!t.editable)return!1;const i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Lr.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=Pee(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:l}}));function u(p){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",f);const m=Lr.getState(t.state);m!=null&&m.dragging&&(jee(t,m.activeHandle,Pk(m.dragging,p,n)),t.dispatch(t.state.tr.setMeta(Lr,{setDragging:null})))}function f(p){if(!p.which)return u(p);const m=Lr.getState(t.state);if(m&&m.dragging){const b=Pk(m.dragging,p,n);Nk(t,m.activeHandle,b,r)}}return Nk(t,s.activeHandle,l,r),i.addEventListener("mouseup",u),i.addEventListener("mousemove",f),e.preventDefault(),!0}function Pee(t,e,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(s-=r[l],a--);return s/a}function Nee(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Ak(t,e,n,r){const o=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:s}=i,a=Xl(t.state.doc.resolve(s));if(!a)return-1;if(n=="right")return a.pos;const l=mn.get(a.node(-1)),u=a.start(-1),f=l.map.indexOf(a.pos-u);return f%l.width==0?-1:u+l.map[f-1]}function Pk(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function eI(t,e){t.dispatch(t.state.tr.setMeta(Lr,{setHandle:e}))}function jee(t,e,n){const r=t.state.doc.resolve(e),o=r.node(-1),i=mn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let u=0;u<i.height;u++){const f=u*i.width+a;if(u&&i.map[f]==i.map[f-i.width])continue;const p=i.map[f],m=o.nodeAt(p).attrs,b=m.colspan==1?0:a-i.colCount(p);if(m.colwidth&&m.colwidth[b]==n)continue;const v=m.colwidth?m.colwidth.slice():$ee(m.colspan);v[b]=n,l.setNodeMarkup(s+p,null,{...m,colwidth:v})}l.docChanged&&t.dispatch(l)}function Nk(t,e,n,r){const o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),a=mn.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let l=t.domAtPos(o.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&p0(i,l.firstChild,l,r,a,n)}function $ee(t){return Array(t).fill(0)}function Lee(t,e){const n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return Xt.empty;const i=mn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){const f=a+u*i.width;if((a==i.width-1||i.map[f]!=i.map[f+1])&&(u==0||i.map[f]!=i.map[f-i.width])){var l;const p=i.map[f],m=s+p+o.nodeAt(p).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((l=Lr.getState(t))===null||l===void 0)&&l.dragging&&n.push(Zn.node(s+p,s+p+o.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),n.push(Zn.widget(m,b))}}return Xt.create(t.doc,n)}function tI({allowTableNodeSelection:t=!1}={}){return new on({key:ls,state:{init(){return null},apply(e,n){const r=e.getMeta(ls);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:QQ,handleDOMEvents:{mousedown:Mee},createSelectionBetween(e){return ls.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Eee,handleKeyDown:kee,handlePaste:Oee},appendTransaction(e,n,r){return nee(r,G2(r,n),t)}})}function h0(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function jk(t,e,n,r,o,i){var s;let a=0,l=!0,u=e.firstChild;const f=t.firstChild;if(f!==null)for(let p=0,m=0;p<f.childCount;p+=1){const{colspan:b,colwidth:v}=f.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=o===m?i:v&&v[y],C=x?`${x}px`:"";if(a+=x||r,x||(l=!1),u){if(u.style.width!==C){const[k,T]=h0(r,x);u.style.setProperty(k,T)}u=u.nextSibling}else{const k=document.createElement("col"),[T,S]=h0(r,x);k.style.setProperty(T,S),e.appendChild(k)}}}for(;u;){const p=u.nextSibling;(s=u.parentNode)===null||s===void 0||s.removeChild(u),u=p}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class Bee{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),jk(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,jk(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function Fee(t,e,n,r){let o=0,i=!0;const s=[],a=t.firstChild;if(!a)return{};for(let p=0,m=0;p<a.childCount;p+=1){const{colspan:b,colwidth:v}=a.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=n===m?r:v&&v[y];o+=x||e,x||(i=!1);const[C,k]=h0(e,x);s.push(["col",{style:`${C}: ${k}`}])}}const l=i?`${o}px`:"",u=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:u}}function $k(t,e){return t.createAndFill()}function Vee(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function zee(t,e,n,r,o){const i=Vee(t),s=[],a=[];for(let u=0;u<n;u+=1){const f=$k(i.cell);if(f&&a.push(f),r){const p=$k(i.header_cell);p&&s.push(p)}}const l=[];for(let u=0;u<e;u+=1)l.push(i.row.createChecked(null,r&&u===0?s:a));return i.table.createChecked(null,l)}function Hee(t){return t instanceof zt}const yf=({editor:t})=>{const{selection:e}=t.state;if(!Hee(e))return!1;let n=0;const r=ov(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},Wee=rn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Bee,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=Fee(t,this.options.cellMinWidth),i=["table",Tt(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{const s=zee(i.schema,t,e,n);if(o){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Je.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>iee(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>see(t,e),deleteColumn:()=>({state:t,dispatch:e})=>lee(t,e),addRowBefore:()=>({state:t,dispatch:e})=>uee(t,e),addRowAfter:()=>({state:t,dispatch:e})=>dee(t,e),deleteRow:()=>({state:t,dispatch:e})=>pee(t,e),deleteTable:()=>({state:t,dispatch:e})=>xee(t,e),mergeCells:()=>({state:t,dispatch:e})=>kk(t,e),splitCell:()=>({state:t,dispatch:e})=>Ek(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Eu("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Eu("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>bee(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>kk(t,e)?!0:Ek(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>gee(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Mk(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Mk(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&G2(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=zt.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:yf,"Mod-Backspace":yf,Delete:yf,"Mod-Delete":yf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Q2({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],tI({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:pt(We(t,"tableRole",e))}}}),Uee=Wee.extend({addProseMirrorPlugins(){return[...this.options.resizable?[Q2({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],tI({allowTableNodeSelection:this.options.allowTableNodeSelection})]}}),Xs=Zt("FieldContainer",["root","outlined","standard","focused","disabled","notchedOutline"]),Kv=qt("FieldContainer"),qee=oe(Bv,{name:Kv,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard,t.ownerState.focused&&e.focused,t.ownerState.disabled&&e.disabled]})(({theme:t,ownerState:e})=>({...e.variant==="outlined"&&{borderRadius:t.shape.borderRadius,padding:1,position:"relative",...!e.focused&&!e.disabled&&{[`&:hover .${Xs.notchedOutline}`]:{borderColor:t.palette.text.primary}}}})),Kee=oe("div",{name:Kv,slot:"notchedOutline",overridesResolver:(t,e)=>e.notchedOutline})(({theme:t,ownerState:e})=>({position:"absolute",inset:0,borderRadius:"inherit",borderColor:t.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)",borderStyle:"solid",borderWidth:1,pointerEvents:"none",overflow:"hidden",zIndex:gp.NOTCHED_OUTLINE,...e.focused&&{borderColor:t.palette.primary.main,borderWidth:2},...e.disabled&&{borderColor:t.palette.action.disabled}}));function Yee(t){const e=rt({props:t,name:Kv}),{variant:n="outlined",children:r,focused:o,disabled:i,classes:s={},className:a,sx:l,...u}=e,f={variant:n,focused:o,disabled:i};return g.jsxs(qee,{...u,className:ye([Xs.root,a,s.root,n==="outlined"?[Xs.outlined,s.outlined]:[Xs.standard,s.standard],o&&[Xs.focused,s.focused],i&&[Xs.disabled,s.disabled]]),sx:l,ownerState:f,children:[r,n==="outlined"&&g.jsx(Kee,{ownerState:f,className:ye([Xs.notchedOutline,s.notchedOutline]),"aria-hidden":!0})]})}function nI({editor:t,wait:e=250}){const[n,r]=J.useState(!!(t!=null&&t.isFocused)),o=J.useMemo(()=>b2(i=>{r(i)},e),[e]);return J.useEffect(()=>{const i=!!(t!=null&&t.isFocused);return o(i),i&&o.flush(),()=>{o.cancel()}},[t==null?void 0:t.isFocused,o]),n}function rI(t,e){const n=J.useRef(e);J.useEffect(()=>{n.current=e},[e]),J.useEffect(()=>{function r(o){t===o.key&&n.current(o)}return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[t])}function Gee(t){return qe("MuiDialogActions",t)}He("MuiDialogActions",["root","spacing"]);const Jee=t=>{const{classes:e,disableSpacing:n}=t;return Ue({root:["root",!n&&"spacing"]},Gee,e)},Xee=oe("div",{name:"MuiDialogActions",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,!n.disableSpacing&&e.spacing]}})({display:"flex",alignItems:"center",padding:8,justifyContent:"flex-end",flex:"0 0 auto",variants:[{props:({ownerState:t})=>!t.disableSpacing,style:{"& > :not(style) ~ :not(style)":{marginLeft:8}}}]}),em=D.forwardRef(function(e,n){const r=mt({props:e,name:"MuiDialogActions"}),{className:o,disableSpacing:i=!1,...s}=r,a={...r,disableSpacing:i},l=Jee(a);return g.jsx(Xee,{className:ye(l.root,o),ownerState:a,ref:n,...s})});process.env.NODE_ENV!=="production"&&(em.propTypes={children:c.node,classes:c.object,className:c.string,disableSpacing:c.bool,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object])});function Zee({editor:t,onCancel:e,onSave:n,labels:r,formatHref:o=hX}){var i,s,a,l,u,f;const p=t.isActive("link")?t.getAttributes("link").href:"",m=$u(t.state.selection.$from,Mo("link",t.schema)),b=m?t.state.doc.textBetween(m.from,m.to):"",v=t.state.doc.textBetween(t.state.selection.$from.pos,t.state.selection.$to.pos),y=b||v,[x,C]=J.useState(y),[k,T]=J.useState(p),S=J.useRef(null),O=J.useRef(null),R=!p,P=(i=r==null?void 0:r.editLinkAddTitle)!==null&&i!==void 0?i:"Add link",j=(s=r==null?void 0:r.editLinkEditTitle)!==null&&s!==void 0?s:"Edit link",F=R?P:j;J.useEffect(()=>{var L,A;!R||!y?(L=S.current)===null||L===void 0||L.focus({preventScroll:!0}):(A=O.current)===null||A===void 0||A.focus({preventScroll:!0})},[R,y]),rI("Escape",e);function M(){O.current&&T(o(O.current.value))}const[$,z]=J.useState(!1);return g.jsxs("form",{onSubmit:L=>{var A,_,I,B;L.preventDefault(),L.stopPropagation(),z(!0);const W=(_=(A=S.current)===null||A===void 0?void 0:A.value)!==null&&_!==void 0?_:"",K=(B=(I=O.current)===null||I===void 0?void 0:I.value)!==null&&B!==void 0?B:"";n({text:W,link:K}),z(!1)},autoComplete:"off",children:[g.jsx(Ro,{variant:"h6",children:F}),g.jsx(Su,{inputRef:S,value:x,disabled:$,onChange:L=>{C(L.target.value)},label:(a=r==null?void 0:r.editLinkTextInputLabel)!==null&&a!==void 0?a:"Text",margin:"normal",size:"small",fullWidth:!0,required:!0}),g.jsx(Su,{inputRef:O,value:k,onChange:L=>{T(L.target.value)},disabled:$,label:(l=r==null?void 0:r.editLinkHrefInputLabel)!==null&&l!==void 0?l:"Link",margin:"dense",size:"small",type:"text",onBlur:M,onKeyDown:L=>{L.key==="Enter"&&M()},fullWidth:!0,required:!0}),g.jsxs(em,{sx:{px:0},children:[g.jsx(so,{onClick:e,variant:"outlined",size:"small",children:(u=r==null?void 0:r.editLinkCancelButtonLabel)!==null&&u!==void 0?u:"Cancel"}),g.jsx(so,{type:"submit",color:"primary",variant:"outlined",size:"small",disabled:$,children:(f=r==null?void 0:r.editLinkSaveButtonLabel)!==null&&f!==void 0?f:"Save"})]})]})}const jy=Zt("LinkBubbleMenu",["root","paper","content"]);function Qee(t){return qe("MuiLink",t)}const ete=He("MuiLink",["root","underlineNone","underlineHover","underlineAlways","button","focusVisible"]),tte=({theme:t,ownerState:e})=>{const n=e.color,r=ds(t,`palette.${n}.main`,!1)||ds(t,`palette.${n}`,!1)||e.color,o=ds(t,`palette.${n}.mainChannel`)||ds(t,`palette.${n}Channel`);return"vars"in t&&o?`rgba(${o} / 0.4)`:ot(r,.4)},Lk={primary:!0,secondary:!0,error:!0,info:!0,success:!0,warning:!0,textPrimary:!0,textSecondary:!0,textDisabled:!0},nte=t=>{const{classes:e,component:n,focusVisible:r,underline:o}=t,i={root:["root",`underline${Pe(o)}`,n==="button"&&"button",r&&"focusVisible"]};return Ue(i,Qee,e)},rte=oe(Ro,{name:"MuiLink",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[`underline${Pe(n.underline)}`],n.component==="button"&&e.button]}})(vt(({theme:t})=>({variants:[{props:{underline:"none"},style:{textDecoration:"none"}},{props:{underline:"hover"},style:{textDecoration:"none","&:hover":{textDecoration:"underline"}}},{props:{underline:"always"},style:{textDecoration:"underline","&:hover":{textDecorationColor:"inherit"}}},{props:({underline:e,ownerState:n})=>e==="always"&&n.color!=="inherit",style:{textDecorationColor:"var(--Link-underlineColor)"}},...Object.entries(t.palette).filter(Ln()).map(([e])=>({props:{underline:"always",color:e},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette[e].mainChannel} / 0.4)`:ot(t.palette[e].main,.4)}})),{props:{underline:"always",color:"textPrimary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.primaryChannel} / 0.4)`:ot(t.palette.text.primary,.4)}},{props:{underline:"always",color:"textSecondary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.secondaryChannel} / 0.4)`:ot(t.palette.text.secondary,.4)}},{props:{underline:"always",color:"textDisabled"},style:{"--Link-underlineColor":(t.vars||t).palette.text.disabled}},{props:{component:"button"},style:{position:"relative",WebkitTapHighlightColor:"transparent",backgroundColor:"transparent",outline:0,border:0,margin:0,borderRadius:0,padding:0,cursor:"pointer",userSelect:"none",verticalAlign:"middle",MozAppearance:"none",WebkitAppearance:"none","&::-moz-focus-inner":{borderStyle:"none"},[`&.${ete.focusVisible}`]:{outline:"auto"}}}]}))),oI=D.forwardRef(function(e,n){const r=mt({props:e,name:"MuiLink"}),o=Oo(),{className:i,color:s="primary",component:a="a",onBlur:l,onFocus:u,TypographyClasses:f,underline:p="always",variant:m="inherit",sx:b,...v}=r,[y,x]=D.useState(!1),C=O=>{El(O.target)||x(!1),l&&l(O)},k=O=>{El(O.target)&&x(!0),u&&u(O)},T={...r,color:s,component:a,focusVisible:y,underline:p,variant:m},S=nte(T);return g.jsx(rte,{color:s,className:ye(S.root,i),classes:f,component:a,onBlur:C,onFocus:k,ref:n,ownerState:T,variant:m,...v,sx:[...Lk[s]===void 0?[{color:s}]:[],...Array.isArray(b)?b:[b]],style:{...v.style,...p==="always"&&s!=="inherit"&&!Lk[s]&&{"--Link-underlineColor":tte({theme:o,ownerState:T})}}})});process.env.NODE_ENV!=="production"&&(oI.propTypes={children:c.node,classes:c.object,className:c.string,color:c.oneOfType([c.oneOf(["primary","secondary","success","error","info","warning","textPrimary","textSecondary","textDisabled"]),c.string]),component:Hl,onBlur:c.func,onFocus:c.func,style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),TypographyClasses:c.object,underline:c.oneOf(["always","hover","none"]),variant:c.oneOfType([c.oneOf(["body1","body2","button","caption","h1","h2","h3","h4","h5","h6","inherit","overline","subtitle1","subtitle2"]),c.string])});var $y={},Ly={},Bk;function ote(){return Bk||(Bk=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(Ly)),Ly}var Fk;function ite(){return Fk||(Fk=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ote(),n=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/;function r(i,s){i=i!=null?`${i}`:"";let a=30,l="...";e.isObject(s)&&(a=o(s.length),l="omission"in s?`${s.omission}`:"...");let u=i.length;const f=Array.from(l).length,p=Math.max(a-f,0);let m;if(n.test(i)&&(m=Array.from(i),u=m.length),a>=u)return i;if(u<=f)return l;let v=m===void 0?i.slice(0,p):m==null?void 0:m.slice(0,p).join("");const y=s==null?void 0:s.separator;if(!y)return v+=l,v;const x=y instanceof RegExp?y.source:y,C="u"+(y instanceof RegExp?y.flags.replace("u",""):""),k=new RegExp(`(?<result>.*(?:(?!${x}).))(?:${x})`,C).exec(v);return(k!=null&&k.groups?k.groups.result:v)+l}function o(i){return i==null?30:i<=0?0:i}t.truncate=r})($y)),$y}var By,Vk;function ste(){return Vk||(Vk=1,By=ite().truncate),By}var ate=ste();const lte=Qn(ate),Fy=Zt("ViewLinkMenuContent",["root","linkPreviewText"]),Yv=qt("ViewLinkMenuContent"),cte=oe("div",{name:Yv,slot:"root",overridesResolver:(t,e)=>e.root})({}),zk=oe("div",{name:Yv,slot:"linkPreviewText",overridesResolver:(t,e)=>e.linkPreviewText})({overflowWrap:"anywhere"});function ute(t){var e,n,r;const o=rt({props:t,name:Yv}),{editor:i,onCancel:s,onEdit:a,onRemove:l,labels:u,classes:f={},sx:p}=o,m=$u(i.state.selection.$to,Mo("link",i.schema)),b=m?i.state.doc.textBetween(m.from,m.to):"",v=(e=i.getAttributes("link").href)!==null&&e!==void 0?e:"";return rI("Escape",s),g.jsxs(cte,{className:ye([Fy.root,f.root]),sx:p,children:[g.jsx(zk,{className:ye([Fy.linkPreviewText,f.linkPreviewText]),children:lte(b,{length:50,omission:"…"})}),g.jsx(zk,{className:ye([Fy.linkPreviewText,f.linkPreviewText]),children:g.jsx(oI,{href:v,target:"_blank",rel:"noopener",children:gX(v,50)})}),g.jsxs(em,{sx:{px:0},children:[g.jsx(so,{onClick:a,color:"primary",variant:"outlined",size:"small",children:(n=u==null?void 0:u.viewLinkEditButtonLabel)!==null&&n!==void 0?n:"Edit"}),g.jsx(so,{onClick:l,color:"error",variant:"outlined",size:"small",children:(r=u==null?void 0:u.viewLinkRemoveButtonLabel)!==null&&r!==void 0?r:"Remove"})]})]})}const iI=qt("LinkBubbleMenu"),dte=oe("div",{name:iI,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({padding:t.spacing(1.5,2,.5)}));function fte(t){const e=rt({props:t,name:iI}),{labels:n,formatHref:r,classes:o={},sx:i,...s}=e,a=kt();if(!(a!=null&&a.isEditable))return null;if(!("linkBubbleMenuHandler"in a.storage))throw new Error("You must add the LinkBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const l=a.storage.linkBubbleMenuHandler,u=l.state;let f=null;return u===ur.VIEW_LINK_DETAILS?f=g.jsx(ute,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onEdit:a.commands.editLinkInBubbleMenu,onRemove:()=>{a.chain().unsetLink().setTextSelection(a.state.selection.to).focus().run()},labels:n}):u===ur.EDIT_LINK&&(f=g.jsx(Zee,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onSave:({text:p,link:m})=>{a.chain().extendMarkRange("link").insertContent({type:"text",marks:[{type:"link",attrs:{href:m}}],text:p}).setLink({href:m}).focus().run(),a.commands.closeLinkBubbleMenu()},labels:n,formatHref:r})),g.jsx(wv,{editor:a,open:u!==ur.HIDDEN,...l.bubbleMenuOptions,...s,classes:{root:ye([jy.root,o.root]),paper:ye([jy.paper,o.paper])},sx:i,children:g.jsx(dte,{className:ye([jy.content,o.content]),children:f})})}function pte(t){return qe("MuiCollapse",t)}He("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const hte=t=>{const{orientation:e,classes:n}=t,r={root:["root",`${e}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${e}`],wrapperInner:["wrapperInner",`${e}`]};return Ue(r,pte,n)},mte=oe("div",{name:"MuiCollapse",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.orientation],n.state==="entered"&&e.entered,n.state==="exited"&&!n.in&&n.collapsedSize==="0px"&&e.hidden]}})(vt(({theme:t})=>({height:0,overflow:"hidden",transition:t.transitions.create("height"),variants:[{props:{orientation:"horizontal"},style:{height:"auto",width:0,transition:t.transitions.create("width")}},{props:{state:"entered"},style:{height:"auto",overflow:"visible"}},{props:{state:"entered",orientation:"horizontal"},style:{width:"auto"}},{props:({ownerState:e})=>e.state==="exited"&&!e.in&&e.collapsedSize==="0px",style:{visibility:"hidden"}}]}))),gte=oe("div",{name:"MuiCollapse",slot:"Wrapper",overridesResolver:(t,e)=>e.wrapper})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),yte=oe("div",{name:"MuiCollapse",slot:"WrapperInner",overridesResolver:(t,e)=>e.wrapperInner})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),Sp=D.forwardRef(function(e,n){const r=mt({props:e,name:"MuiCollapse"}),{addEndListener:o,children:i,className:s,collapsedSize:a="0px",component:l,easing:u,in:f,onEnter:p,onEntered:m,onEntering:b,onExit:v,onExited:y,onExiting:x,orientation:C="vertical",style:k,timeout:T=GO.standard,TransitionComponent:S=zr,...O}=r,R={...r,orientation:C,collapsedSize:a},P=hte(R),j=Oo(),F=ta(),M=D.useRef(null),$=D.useRef(),z=typeof a=="number"?`${a}px`:a,L=C==="horizontal",A=L?"width":"height",_=D.useRef(null),I=Et(n,_),B=te=>ce=>{if(te){const ne=_.current;ce===void 0?te(ne):te(ne,ce)}},W=()=>M.current?M.current[L?"clientWidth":"clientHeight"]:0,K=B((te,ce)=>{M.current&&L&&(M.current.style.position="absolute"),te.style[A]=z,p&&p(te,ce)}),U=B((te,ce)=>{const ne=W();M.current&&L&&(M.current.style.position="");const{duration:re,easing:le}=Pl({style:k,timeout:T,easing:u},{mode:"enter"});if(T==="auto"){const ge=j.transitions.getAutoHeightDuration(ne);te.style.transitionDuration=`${ge}ms`,$.current=ge}else te.style.transitionDuration=typeof re=="string"?re:`${re}ms`;te.style[A]=`${ne}px`,te.style.transitionTimingFunction=le,b&&b(te,ce)}),Y=B((te,ce)=>{te.style[A]="auto",m&&m(te,ce)}),fe=B(te=>{te.style[A]=`${W()}px`,v&&v(te)}),ue=B(y),pe=B(te=>{const ce=W(),{duration:ne,easing:re}=Pl({style:k,timeout:T,easing:u},{mode:"exit"});if(T==="auto"){const le=j.transitions.getAutoHeightDuration(ce);te.style.transitionDuration=`${le}ms`,$.current=le}else te.style.transitionDuration=typeof ne=="string"?ne:`${ne}ms`;te.style[A]=z,te.style.transitionTimingFunction=re,x&&x(te)}),Z=te=>{T==="auto"&&F.start($.current||0,te),o&&o(_.current,te)};return g.jsx(S,{in:f,onEnter:K,onEntered:Y,onEntering:U,onExit:fe,onExited:ue,onExiting:pe,addEndListener:Z,nodeRef:_,timeout:T==="auto"?null:T,...O,children:(te,{ownerState:ce,...ne})=>g.jsx(mte,{as:l,className:ye(P.root,s,{entered:P.entered,exited:!f&&z==="0px"&&P.hidden}[te]),style:{[L?"minWidth":"minHeight"]:z,...k},ref:I,ownerState:{...R,state:te},...ne,children:g.jsx(gte,{ownerState:{...R,state:te},className:P.wrapper,ref:M,children:g.jsx(yte,{ownerState:{...R,state:te},className:P.wrapperInner,children:i})})})})});process.env.NODE_ENV!=="production"&&(Sp.propTypes={addEndListener:c.func,children:c.node,classes:c.object,className:c.string,collapsedSize:c.oneOfType([c.number,c.string]),component:Hl,easing:c.oneOfType([c.shape({enter:c.string,exit:c.string}),c.string]),in:c.bool,onEnter:c.func,onEntered:c.func,onEntering:c.func,onExit:c.func,onExited:c.func,onExiting:c.func,orientation:c.oneOf(["horizontal","vertical"]),style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),timeout:c.oneOfType([c.oneOf(["auto"]),c.number,c.shape({appear:c.number,enter:c.number,exit:c.number})])});Sp&&(Sp.muiSupportAuto=!0);const bf=Zt("MenuBar",["root","sticky","nonSticky","content"]),Gv=qt("MenuBar"),bte=oe(Sp,{name:Gv,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.disableSticky?e.nonSticky:e.sticky]})(({theme:t,ownerState:e})=>({borderBottomColor:t.palette.divider,borderBottomStyle:"solid",borderBottomWidth:1,...e.disableSticky?{}:{position:"sticky",top:e.stickyOffset,zIndex:gp.MENU_BAR,background:t.palette.background.default}})),vte=oe("div",{name:Gv,slot:"content",overridesResolver:(t,e)=>e.content})({});function xte(t){const e=rt({props:t,name:Gv}),{hide:n,disableSticky:r,stickyOffset:o=0,children:i,className:s,classes:a={},unmountOnExit:l=!0,sx:u,...f}=e,p={hide:n,disableSticky:r,stickyOffset:o,unmountOnExit:l};return g.jsx(bte,{...f,in:!n,unmountOnExit:l,className:ye([bf.root,a.root,r?[bf.nonSticky,a.nonSticky]:[bf.sticky,a.sticky],s]),ownerState:p,sx:u,children:g.jsx(vte,{className:ye([bf.content,a.content]),ownerState:p,children:i})})}const Vy=Zt("RichTextContent",["root","readonly","editable"]),sI=qt("RichTextContent"),wte=oe(iQ,{name:sI,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.editable?e.editable:e.readonly]})(({theme:t,ownerState:e})=>e.disableDefaultStyles?{}:{"& .ProseMirror":{...Da(t)}});function aI(t){const e=rt({props:t,name:sI}),{innerRef:n,className:r,classes:o={},disableDefaultStyles:i=!1,sx:s}=e,a=kt(),l=!!(a!=null&&a.isEditable),u={editable:l,disableDefaultStyles:i},f=J.useMemo(()=>ye([Vy.root,r,o.root,l?[Vy.editable,o.editable]:[Vy.readonly,o.readonly]]),[r,o.root,o.editable,o.readonly,l]);return g.jsx(wte,{editor:a,...n?{innerRef:n}:{},ownerState:u,className:f,sx:s})}function lI({editor:t,children:e}){return g.jsx(vR.Provider,{value:t,children:e})}const zo=Zt("RichTextField",["root","standard","outlined","menuBar","menuBarContent","content"]),cI=qt("RichTextField"),Cte=oe(Yee,{name:cI,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard]})(({theme:t,ownerState:e})=>({...e.variant==="standard"&&{[`& .${zo.content}`]:{padding:t.spacing(1.5,0)},[`& .${zo.menuBarContent}`]:{padding:t.spacing(1,0)}},...e.variant==="outlined"&&{[`& .${zo.content}`]:{padding:t.spacing(1.5)},[`& .${zo.menuBarContent}`]:{padding:t.spacing(1,1.5)}}}));function Ste(t){var e,n;const r=rt({props:t,name:cI}),{variant:o="outlined",controls:i,disableDebounceRenderControls:s=!1,disabled:a,className:l,classes:u={},footer:f,MenuBarProps:p,RichTextContentProps:m,sx:b,...v}=r,y=kt(),x={variant:o,disabled:a,disableDebounceRenderControls:s},C=nI({editor:y});return g.jsxs(Cte,{...v,variant:o,focused:!a&&C,disabled:a,className:ye([zo.root,u.root,o==="outlined"?[zo.outlined,u.outlined]:[zo.standard,u.standard],l]),ownerState:x,sx:b,children:[i&&g.jsx(xte,{...p,classes:{...p==null?void 0:p.classes,root:ye([zo.menuBar,u.menuBar,(e=p==null?void 0:p.classes)===null||e===void 0?void 0:e.root]),content:ye([zo.menuBarContent,u.menuBarContent,(n=p==null?void 0:p.classes)===null||n===void 0?void 0:n.content])},children:s?i:g.jsx(Lv,{children:i})}),g.jsx(aI,{...m,className:ye([zo.content,u.content,m==null?void 0:m.className])}),f]})}const uI=J.forwardRef(function({className:e,renderControls:n,RichTextFieldProps:r={},sx:o,children:i,editorDependencies:s=[],editable:a=!0,shouldRerenderOnTransaction:l=!0,...u},f){const p={editable:a,shouldRerenderOnTransaction:l,...u},m=F2(p,s);return J.useImperativeHandle(f,()=>({editor:m}),[m]),J.useEffect(()=>{!m||m.isDestroyed||m.isEditable===a||queueMicrotask(()=>{m.setEditable(a)})},[a,m]),g.jsxs(lI,{editor:m,children:[g.jsx(Ste,{disabled:!a,controls:n==null?void 0:n(m),className:e,sx:o,...r}),i==null?void 0:i(m)]})});function Tte({RichTextContentProps:t,sx:e,...n}){const r=F2({...n,editable:!1}),o=J.useRef(n.content);return J.useEffect(()=>{!r||r.isDestroyed||n.content===void 0||n.content===o.current||queueMicrotask(()=>{n.content!==void 0&&r.commands.setContent(n.content)})},[n.content,r]),J.useEffect(()=>{o.current=n.content},[n.content]),g.jsx(lI,{editor:r,children:g.jsx(aI,{sx:e,...t})})}function dI(t){return t.content?g.jsx(Tte,{...t}):null}const zy=Zt("TableBubbleMenu",["root","paper","content"]),fI=qt("TableBubbleMenu"),kte=oe(wZ,{name:fI,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({maxWidth:"90vw",padding:t.spacing(.5,1)}));function Ete(t){const e=rt({props:t,name:fI}),{disableDebounce:n=!1,DebounceProps:r,labels:o,classes:i={},...s}=e,a=kt(),l=nI({editor:a}),u=J.useMemo(()=>a?{getBoundingClientRect:()=>{const p=a.isActive("table")?ov(a.state.selection.$anchor,y=>y.type.name==="table"):null;if(p){const y=a.view.nodeDOM(p.pos),x=y==null?void 0:y.querySelector("table");if(x)return x.getBoundingClientRect()}const{ranges:m}=a.state.selection,b=Math.min(...m.map(y=>y.$from.pos)),v=Math.max(...m.map(y=>y.$to.pos));return q_(a.view,b,v)}}:null,[a]);if(!(a!=null&&a.isEditable))return null;const f=g.jsx(kte,{className:ye([zy.content,i.content]),labels:o});return g.jsx(wv,{editor:a,open:l&&a.isActive("table"),anchorEl:u,placement:"top-start",fallbackPlacements:["bottom-start","top","bottom","top-end","bottom-end"],flipPadding:{top:35,left:8,right:8,bottom:-1/0},...s,classes:{root:ye([zy.root,i.root]),paper:ye([zy.paper,i.paper])},children:n?f:g.jsx(Lv,{...r,children:f})})}const Jv=Or.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Tt(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),pI=Or.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Tt(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Hy,Hk;function Ote(){return Hk||(Hk=1,Hy=(function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(r,o,i){n.o(r,o)||Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:i})},n.r=function(r){Object.defineProperty(r,"__esModule",{value:!0})},n.n=function(r){var o=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(o,"a",o),o},n.o=function(r,o){return Object.prototype.hasOwnProperty.call(r,o)},n.p="/dist/",n(n.s=1)})([function(t,e,n){n.r(e);var r={equal:0,delete:1,insert:2,none:3,replace:4};class o{constructor(A,_,I){this.startInOld=A,this.startInNew=_,this.size=I}get endInOld(){return this.startInOld+this.size}get endInNew(){return this.startInNew+this.size}}class i{constructor(){this.blockSize=0,this.repeatingWordsAccuracy=0,this.ignoreWhitespaceDifferences=!1}}const s=/^\s*<\/?[^>]+>\s*$/,a=/<[^\s>]+/,l=/^(\s| )+$/,u=/[\w\#@]+/,f=["<img"];function p(L){return!f.some(A=>L!==null&&L.startsWith(A))&&s.test(L)}function m(L,A,_){return["<",A,' class="',_,'">',L,"</",A,">"].join("")}function b(L){return L==="<"}function v(L){return L==="&"}function y(L){return L===";"}function x(L){return l.test(L)}function C(L){return p(L)?(function(A){return A=a.exec(A)[0]+(A.endsWith("/>")?"/>":">")})(L):L}function k(L){return u.test(L)}function T(L,A,_){return L.push(A),L.length>_&&L.shift(),L.length!==_?null:L.join("")}class S{constructor(A,_,I,B,W,K,U){this.oldWords=A,this.newWords=_,this.startInOld=I,this.endInOld=B,this.startInNew=W,this.endInNew=K,this.options=U}indexNewWords(){this.wordIndices=new Map;let A=[];for(let _=this.startInNew;_<this.endInNew;_++){let I=T(A,this.normalizeForIndex(this.newWords[_]),this.options.blockSize);I!==null&&(this.wordIndices.has(I)?this.wordIndices.get(I).push(_):this.wordIndices.set(I,[_]))}}normalizeForIndex(A){return A=C(A),this.options.IgnoreWhiteSpaceDifferences&&x(A)?" ":A}findMatch(){if(this.indexNewWords(),this.removeRepeatingWords(),this.wordIndices.length===0)return null;let A=this.startInOld,_=this.startInNew,I=0,B=new Map;const W=this.options.blockSize;let K=[];for(let U=this.startInOld;U<this.endInOld;U++){let Y=T(K,this.normalizeForIndex(this.oldWords[U]),W);if(Y===null)continue;let fe=new Map;if(this.wordIndices.has(Y)){for(let ue of this.wordIndices.get(Y)){let pe=(B.has(ue-1)?B.get(ue-1):0)+1;fe.set(ue,pe),pe>I&&(A=U-pe-W+2,_=ue-pe-W+2,I=pe)}B=fe}else B=fe}return I!==0?new o(A,_,I+W-1):null}removeRepeatingWords(){let A=this.newWords.length+this.options.repeatingWordsAccuracy,_=Array.from(this.wordIndices.entries()).filter(I=>I[1].length>A).map(I=>I[0]);for(let I of _)this.wordIndices.delete(I)}}class O{constructor(A,_,I,B,W){this.action=A,this.startInOld=_,this.endInOld=I,this.startInNew=B,this.endInNew=W}}var R={character:0,tag:1,whitespace:2,entity:3};function P(L,A){let _={mode:R.character,currentWord:[],words:[]},I=(function(Y,fe){let ue=new Map;if(fe===null)return ue;for(let pe of fe){let Z;for(;(Z=pe.exec(Y))!==null;){if(ue.has(Z.index))throw new Error("One or more block expressions result in a text sequence that overlaps. Current expression: "+pe.toString());ue.set(Z.index,Z.index+Z[0].length)}}return ue})(L,A),B=!!I.size,W=!1,K=-1;for(let Y=0;Y<L.length;Y++){var U=L[Y];if(B&&(K===index&&(K=-1,W=!1),I.has(index)&&(W=!0,K=I.get(index)),W)){_.currentWord.push(U),_.mode=R.character;continue}switch(_.mode){case R.character:b(U)?j(_,"<",R.tag):v(U)?j(_,U,R.entity):x(U)?j(_,U,R.whitespace):k(U)&&(_.currentWord.length===0||k(_.currentWord[_.currentWord.length-1]))?_.currentWord.push(U):j(_,U,R.character);break;case R.tag:U===">"?(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.currentWord=[],_.mode=x(U)?R.whitespace:R.character):_.currentWord.push(U);break;case R.whitespace:b(U)?j(_,U,R.tag):v(U)?j(_,U,R.entity):x(U)?_.currentWord.push(U):j(_,U,R.character);break;case R.entity:if(b(U))j(_,U,R.tag);else if(x(U))j(_,U,R.whitespace);else if(y(U)){let fe=!0;if(_.currentWord.length!==0&&(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.words.length>2&&x(_.words[_.words.length-2])&&x(_.words[_.words.length-1]))){let ue=_.words[_.words.length-2],pe=_.words[_.words.length-1];_.words.splice(_.words.length-2,2),_.currentWord=[(ue+pe).split()],_.mode=R.whitespace,fe=!1}fe&&(_.currentWord=[],_.mode=R.character)}else k(U)?_.currentWord.push(U):j(_,U,R.character)}}return _.currentWord.length!==0&&_.words.push(_.currentWord.join("")),_.words}function j(L,A,_){L.currentWord.length!==0&&L.words.push(L.currentWord.join("")),L.currentWord=[A],L.mode=_}const F=4,M=new Map([["</strong>",0],["</em>",0],["</b>",0],["</i>",0],["</big>",0],["</small>",0],["</u>",0],["</sub>",0],["</strike>",0],["</s>",0]]),$=/<((strong)|(b)|(i)|(em)|(big)|(small)|(u)|(sub)|(sup)|(strike)|(s))[\>\s]+/gi;class z{constructor(A,_){this.content=[],this.newText=_,this.oldText=A,this.specialTagDiffStack=[],this.newWords=[],this.oldWords=[],this.matchGranularity=0,this.blockExpressions=[],this.repeatingWordsAccuracy=1,this.ignoreWhiteSpaceDifferences=!1,this.orphanMatchThreshold=0}build(){if(this.oldText===this.newText)return this.newText;this.splitInputsIntoWords(),this.matchGranularity=Math.min(F,this.oldWords.length,this.newWords.length);let A=this.operations();for(let _ of A)this.performOperation(_);return this.content.join("")}addBlockExpression(A){this.blockExpressions.push(A)}splitInputsIntoWords(){this.oldWords=P(this.oldText,this.blockExpressions),this.oldText=null,this.newWords=P(this.newText,this.blockExpressions),this.newText=null}performOperation(A){switch(A.action){case r.equal:this.processEqualOperation(A);break;case r.delete:this.processDeleteOperation(A,"diffdel");break;case r.insert:this.processInsertOperation(A,"diffins");break;case r.none:break;case r.replace:this.processReplaceOperation(A)}}processReplaceOperation(A){this.processDeleteOperation(A,"diffmod"),this.processInsertOperation(A,"diffmod")}processInsertOperation(A,_){let I=this.newWords.filter((B,W)=>W>=A.startInNew&&W<A.endInNew);this.insertTag("ins",_,I)}processDeleteOperation(A,_){let I=this.oldWords.filter((B,W)=>W>=A.startInOld&&W<A.endInOld);this.insertTag("del",_,I)}processEqualOperation(A){let _=this.newWords.filter((I,B)=>B>=A.startInNew&&B<A.endInNew);this.content.push(_.join(""))}insertTag(A,_,I){for(;I.length;){let B=this.extractConsecutiveWords(I,U=>!p(U)),W="",K=!1;if(B.length!==0){let U=m(B.join(""),A,_);this.content.push(U)}else{if($.test(I[0])){if(this.specialTagDiffStack.push(I[0]),W='<ins class="mod">',A==="del")for(I.shift();I.length>0&&$.test(I[0]);)I.shift()}else if(M.has(I[0])){let U=this.specialTagDiffStack.length===0?null:this.specialTagDiffStack.pop();if(U!==null&&U===I[0].replace(/\//g,"")&&(W="</ins>",K=!0),A==="del")for(I.shift();I.length>0&&M.has(I[0]);)I.shift()}if(I.length===0&&W.length===0)break;K?this.content.push(W+this.extractConsecutiveWords(I,p).join("")):this.content.push(this.extractConsecutiveWords(I,p).join("")+W)}}}extractConsecutiveWords(A,_){let I=null;for(let B=0;B<A.length;B++){let W=A[B];if(B===0&&W===" "&&(A[B]=" "),!_(W)){I=B;break}}if(I!==null){let B=A.filter((W,K)=>K>=0&&K<I);return I>0&&A.splice(0,I),B}{let B=A.filter((W,K)=>K>=0&&K<A.length);return A.splice(0,A.length),B}}operations(){let A=0,_=0,I=[],B=this.matchingBlocks();B.push(new o(this.oldWords.length,this.newWords.length,0));let W=this.removeOrphans(B);for(let K of W){let U,Y=A===K.startInOld,fe=_===K.startInNew;(U=Y||fe?Y&&!fe?r.insert:Y?r.none:r.delete:r.replace)!==r.none&&I.push(new O(U,A,K.startInOld,_,K.startInNew)),K.length!==0&&I.push(new O(r.equal,K.startInOld,K.endInOld,K.startInNew,K.endInNew)),A=K.endInOld,_=K.endInNew}return I}*removeOrphans(A){let _=null,I=null;for(let B of A){if(I===null){_=new o(0,0,0),I=B;continue}if(_.endInOld===I.startInOld&&_.endInNew===I.startInNew||I.endInOld===B.startInOld&&I.endInNew===B.startInNew){yield I,_=I,I=B;continue}let W=(Y,fe)=>Y+fe.length,K=this.oldWords.slice(_.endInOld,B.startInOld).reduce(W,0),U=this.newWords.slice(_.endInNew,B.startInNew).reduce(W,0);this.newWords.slice(I.startInNew,I.endInNew).reduce(W,0)>Math.max(K,U)*this.orphanMatchThreshold&&(yield I),_=I,I=B}yield I}matchingBlocks(){let A=[];return this.findMatchingBlocks(0,this.oldWords.length,0,this.newWords.length,A),A}findMatchingBlocks(A,_,I,B,W){let K=this.findMatch(A,_,I,B);K!==null&&(A<K.startInOld&&I<K.startInNew&&this.findMatchingBlocks(A,K.startInOld,I,K.startInNew,W),W.push(K),K.endInOld<_&&K.endInNew<B&&this.findMatchingBlocks(K.endInOld,_,K.endInNew,B,W))}findMatch(A,_,I,B){for(let W=this.matchGranularity;W>0;W--){let K=new i;K.blockSize=W,K.repeatingWordsAccuracy=this.repeatingWordsAccuracy,K.ignoreWhitespaceDifferences=this.ignoreWhiteSpaceDifferences;let U=new S(this.oldWords,this.newWords,A,_,I,B,K).findMatch();if(U!==null)return U}return null}}z.execute=function(L,A){return new z(L,A).build()},e.default=z},function(t,e,n){t.exports=n(0)}])),Hy}var Mte=Ote();const _te=Qn(Mte),Tp="rgba(194, 249, 112, .5)",kp="rgba(196, 77,86,0.3)",hI=t=>{const{beforeTxt:e="",afterTxt:n="",mode:r="sentence"}=t,o=Rte(e,n,r);return g.jsx(dI,{content:o,extensions:[yR,Jv,bR.configure({multicolor:!0}),pI]})},Rte=(t,e,n)=>{switch(n){case"sentence":return Dte(t,e);case"word":return Ite(t,e);case"html":return Pte(t,e);case"comma":return Ate(t,e)}},Xv=(t,e)=>{if(!t.added&&!t.removed)return t.value;const n=t.added?Tp:kp,r=t.added?"u":"s";return`<${r}><mark key={${e}} data-color="${n}" style={{ backgroundColor: ${n}, color: "inherit"}}>${t.value}</mark></${r}>`},Wk=t=>t.split(",").map(e=>e.trim()),Ite=(t,e)=>jU(t,e).map(Xv).join(""),Dte=(t,e)=>FU(t,e).map(Xv).join(""),Ate=(t,e)=>HU(Wk(t),Wk(e)).map(Xv).join(", "),Pte=(t,e)=>{let n=_te.execute(t,e);return n=n.replaceAll(/<ins class="(diffmod|diffins)">/g,`<u><mark data-color="${Tp}" style={{ backgroundColor: ${Tp}, color: "inherit" }}>`),n=n.replaceAll("</ins>","</mark></u>"),n=n.replaceAll(/<del class="(diffmod|diffdel)">/g,`<s><mark data-color="${kp}" style={{ backgroundColor: ${kp}, color: "inherit" }}>`),n=n.replaceAll("</del>","</mark></s>"),n},Fi=t=>{const{label:e,value:n,readOnlyValue:r,staticLabel:o,staticLabelProps:i,showDiff:s=!1,diffSnapshot:a,diffMode:l,...u}=t,f=()=>s?g.jsx(hI,{beforeTxt:a,afterTxt:n,mode:l,...u}):r||g.jsx(V.Typography,{"data-testid":"read-only-value",children:n});return g.jsxs(V.Box,{width:"100%",mb:"8px",children:[o?g.jsx(V.Typography,{...i,children:e}):g.jsx(V.InputLabel,{children:e}),f()]})},mI=t=>{const{name:e,label:n=Fn(e),options:r=[],filterSelectedOptions:o=!0,variant:i="outlined",staticLabel:s=!1,staticLabelProps:a={fontSize:".9em",color:"#808080"},readOnly:l,margin:u="dense",fullWidth:f=!0,required:p,onChange:m,clearOnSelect:b=!1,onInputChange:v,getOptionLabel:y=B=>typeof B=="string"?B:String(B),isOptionEqualToValue:x=(B,W)=>JSON.stringify(B)===JSON.stringify(W),useFieldAsValue:C,errorMode:k="normal",...T}=t,[S,O,R]=Ht.useField(e),{setValue:P}=R,{error:j}=O,[F,M]=D.useState(""),$={...pr(T,["useFieldAsValue","errorMode"]),getOptionLabel:y,options:r,filterSelectedOptions:o,isOptionEqualToValue:x,renderInput:B=>g.jsx(V.TextField,{...B,variant:i,label:s?void 0:n,error:!!j,required:p}),onChange:(B,W,K,U)=>{b?(M(""),P(null)):P(C?W?W[C]:null:W),m&&m(B,W,K,U)},onInputChange:(B,W,K)=>{M(W),v&&v(B,W,K)},fullWidth:!0,inputValue:F,value:C?r.find(B=>B[C]===S.value)||null:S.value,slotProps:{paper:{elevation:8,sx:{borderRadius:2}}}},z=B=>{if(B==null)return"";if(C){const W=r.find(K=>K[C]===B);return W?y(W):""}return y(B)},L=_a(),A=l??L,{showDiff:_,getPreviousValue:I}=Ra();return A||_?g.jsx(Fi,{label:n,value:z(S.value),staticLabel:s,staticLabelProps:a,showDiff:_,diffSnapshot:z(I(e))}):g.jsxs(V.FormControl,{margin:u,fullWidth:f,required:p,children:[s&&g.jsx(V.Typography,{...a,children:n}),g.jsxs(V.Box,{children:[g.jsx(V.Autocomplete,{...$}),g.jsx(Mr,{name:e,id:`${e}-err`,errorMode:k})]})]})};var Bc={exports:{}};/**
|
|
355
|
+
*/var bk;function cQ(){return bk||(bk=1,process.env.NODE_ENV!=="production"&&(function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=J,e=Xh;function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,l=t.useDebugValue;function u(f,p,m,b,v){var y=i(null),x;y.current===null?(x={hasValue:!1,value:null},y.current=x):x=y.current;var C=a(function(){var O=!1,R,P,j=function(z){if(!O){O=!0,R=z;var L=b(z);if(v!==void 0&&x.hasValue){var A=x.value;if(v(A,L))return P=A,A}return P=L,L}var _=R,I=P;if(r(_,z))return I;var B=b(z);return v!==void 0&&v(I,B)?I:(R=z,P=B,B)},F=m===void 0?null:m,M=function(){return j(p())},$=F===null?void 0:function(){return j(F())};return[M,$]},[p,m,b,v]),k=C[0],T=C[1],S=o(f,k,T);return s(function(){x.hasValue=!0,x.value=S},[S]),l(S),S}Dy.useSyncExternalStoreWithSelector=u,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)})()),Dy}process.env.NODE_ENV==="production"?a0.exports=lQ():a0.exports=cQ();var uQ=a0.exports;const dQ=typeof window<"u"?J.useLayoutEffect:J.useEffect;class fQ{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(o=>o())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function pQ(t){var e;const[n]=J.useState(()=>new fQ(t.editor)),r=uQ.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:aQ);return dQ(()=>n.watch(t.editor),[t.editor,n]),J.useDebugValue(r),r}const vk=process.env.NODE_ENV!=="production",l0=typeof window>"u",hQ=l0||!!(typeof window<"u"&&window.next);class Hv{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return l0||hQ?(vk&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&l0&&vk)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onBeforeCreate)===null||i===void 0?void 0:i.call(o,...r)},onBlur:(...r)=>{var o,i;return(i=(o=this.options.current).onBlur)===null||i===void 0?void 0:i.call(o,...r)},onCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onCreate)===null||i===void 0?void 0:i.call(o,...r)},onDestroy:(...r)=>{var o,i;return(i=(o=this.options.current).onDestroy)===null||i===void 0?void 0:i.call(o,...r)},onFocus:(...r)=>{var o,i;return(i=(o=this.options.current).onFocus)===null||i===void 0?void 0:i.call(o,...r)},onSelectionUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onSelectionUpdate)===null||i===void 0?void 0:i.call(o,...r)},onTransaction:(...r)=>{var o,i;return(i=(o=this.options.current).onTransaction)===null||i===void 0?void 0:i.call(o,...r)},onUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onUpdate)===null||i===void 0?void 0:i.call(o,...r)},onContentError:(...r)=>{var o,i;return(i=(o=this.options.current).onContentError)===null||i===void 0?void 0:i.call(o,...r)},onDrop:(...r)=>{var o,i;return(i=(o=this.options.current).onDrop)===null||i===void 0?void 0:i.call(o,...r)},onPaste:(...r)=>{var o,i;return(i=(o=this.options.current).onPaste)===null||i===void 0?void 0:i.call(o,...r)}};return new K7(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((o,i)=>{var s;return o===((s=n.extensions)===null||s===void 0?void 0:s[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Hv.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,o)=>r===e[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function F2(t={},e=[]){const n=J.useRef(t);n.current=t;const[r]=J.useState(()=>new Hv(n)),o=Xh.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return J.useDebugValue(o),J.useEffect(r.onRender(e)),pQ({editor:o,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&i===0?0:i+1}),o}const mQ=J.createContext({editor:null});mQ.Consumer;const V2=J.createContext({onDragStart:void 0}),z2=()=>J.useContext(V2),gQ=t=>{const e=t.as||"div",{nodeViewContentRef:n}=z2();return J.createElement(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style}})},Wv=J.forwardRef((t,e)=>{const{onDragStart:n}=z2(),r=t.as||"div";return J.createElement(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function xk(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function wk(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function yQ(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function bQ(t){if(xk(t)||wk(t))return!0;if(yQ(t)){const e=t.type;if(e)return xk(e)||wk(e)}return!1}function vQ(){try{if(J.version)return parseInt(J.version.split(".")[0],10)>=19}catch{}return!1}class H2{constructor(e,{editor:n,props:r={},as:o="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=n,this.props=r,this.element=document.createElement(o),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?ea.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var e;const n=this.component,r=this.props,o=this.editor,i=vQ(),s=bQ(n),a={...r};a.ref&&!(i||s)&&delete a.ref,!a.ref&&(i||s)&&(a.ref=l=>{this.ref=l}),this.reactElement=J.createElement(n,{...a}),(e=o==null?void 0:o.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const n=this.editor;(e=n==null?void 0:n.contentComponent)===null||e===void 0||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach(n=>{this.element.setAttribute(n,e[n])})}}class xQ extends Y7{constructor(e,n,r){if(super(e,n,r),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const o=this.dom.querySelector("[data-node-view-content]");if(!o)return;o.appendChild(this.contentDOMElement)}}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(u={})=>this.updateAttributes(u),deleteNode:()=>this.deleteNode(),ref:J.createRef()};if(!this.component.displayName){const u=f=>f.charAt(0).toUpperCase()+f.substring(1);this.component.displayName=u(this.extension.name)}const o={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:u=>{u&&this.contentDOMElement&&u.firstChild!==this.contentDOMElement&&(u.hasAttribute("data-node-view-wrapper")&&u.removeAttribute("data-node-view-wrapper"),u.appendChild(this.contentDOMElement))}},i=this.component,s=J.memo(u=>J.createElement(V2.Provider,{value:o},J.createElement(i,u)));s.displayName="ReactNodeView";let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new H2(s,{editor:this.editor,props:e,as:a,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:n}=this.editor.state.selection,r=this.getPos();if(typeof r=="number")if(e<=r&&n>=r+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,n,r){const o=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=n,this.innerDecorations=r,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:n,oldInnerDecorations:a,innerDecorations:r,updateProps:()=>o({node:e,decorations:n,innerDecorations:r})})}return e===this.node&&this.decorations===n&&this.innerDecorations===r||(this.node=e,this.decorations=n,this.innerDecorations=r,o({node:e,decorations:n,innerDecorations:r})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){const n=this.editor.extensionManager.attributes,r=up(this.node,n);e=this.options.attrs({node:this.node,HTMLAttributes:r})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function Uv(t,e){return n=>n.editor.contentComponent?new xQ(t,n,e):{}}const Lc=Zt("HeadingWithAnchorComponent",["root","container","link","linkIcon"]),Ku=qt("HeadingWithAnchorComponent"),wQ=oe(Wv,{name:Ku,slot:"root",overridesResolver:(t,e)=>e.root,shouldForwardProp:t=>t!=="ownerState"&&t!=="theme"&&t!=="sx"})({[`&:hover .${Lc.link}`]:{opacity:100}}),CQ=oe("span",{name:Ku,slot:"container",overridesResolver:(t,e)=>e.container})({display:"inline-block",position:"relative"}),SQ=oe("a",{name:Ku,slot:"link",overridesResolver:(t,e)=>e.link})(({theme:t})=>({position:"absolute",left:-21,color:`${t.palette.text.secondary} !important`,opacity:0,transition:t.transitions.create("opacity"),textDecoration:"none",outline:"none",[t.breakpoints.down("sm")]:{left:-18},'.ProseMirror[contenteditable="true"] &':{display:"none"}})),TQ=oe(Kh,{name:Ku,slot:"linkIcon",overridesResolver:(t,e)=>e.linkIcon})(({theme:t})=>({transform:"rotate(-45deg)",fontSize:"1.25rem",[t.breakpoints.down("sm")]:{fontSize:"1.15rem"}}));function kQ(t){const e=rt({props:t,name:Ku}),{editor:n,node:r,extension:o,classes:i={},sx:s}=e,u=`h${o.options.levels.includes(r.attrs.level)?r.attrs.level:o.options.levels[0]}`,f=J.useMemo(()=>rv(n.schema),[n.schema]),p=mX(W_(r,{textSerializers:f}));return g.jsx(wQ,{as:u,id:p,...o.options.HTMLAttributes,className:ye([Lc.root,i.root]),style:{textAlign:r.attrs.textAlign},sx:s,children:g.jsxs(CQ,{className:ye([Lc.container,i.container]),children:[g.jsx(SQ,{href:`#${p}`,contentEditable:!1,className:ye([Lc.link,i.link]),children:g.jsx(TQ,{className:ye([Lc.linkIcon,i.linkIcon])})}),g.jsx(gQ,{as:"span"})]})})}const EQ=oR.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),scrollToAnchorOnMount:!0}},onCreate(){this.options.scrollToAnchorOnMount&&setTimeout(()=>{OQ(this.editor)})},addNodeView(){return Uv(kQ)}});function OQ(t){if(t.isDestroyed||!("heading"in t.storage))return;const n=window.location.hash.slice(1);if(!n)return;const r=window.document.getElementById(n);r&&t.view.dom.contains(r)&&r.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})}var ur;(function(t){t[t.HIDDEN=0]="HIDDEN",t[t.VIEW_LINK_DETAILS=1]="VIEW_LINK_DETAILS",t[t.EDIT_LINK=2]="EDIT_LINK"})(ur||(ur={}));const MQ=gn.create({name:"linkBubbleMenuHandler",addStorage(){return{state:ur.HIDDEN,bubbleMenuOptions:void 0}},addCommands(){return{openLinkBubbleMenu:(t={})=>({editor:e,chain:n,dispatch:r})=>{const o=this.storage.state;let i;return e.isActive("link")?(o!==ur.VIEW_LINK_DETAILS&&n().extendMarkRange("link").focus().run(),i=ur.VIEW_LINK_DETAILS):i=ur.EDIT_LINK,r&&(this.storage.state=i,this.storage.bubbleMenuOptions=t),!0},editLinkInBubbleMenu:()=>({dispatch:t})=>{const e=this.storage.state,n=ur.EDIT_LINK;return e===n?!1:(t&&(this.storage.state=n),!0)},closeLinkBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.state===ur.HIDDEN?!1:(t.focus(),e&&(this.storage.state=ur.HIDDEN),!0)}},onSelectionUpdate(){this.storage.state===ur.EDIT_LINK?this.editor.commands.closeLinkBubbleMenu():this.storage.state===ur.VIEW_LINK_DETAILS&&!this.editor.isActive("link")&&this.editor.commands.closeLinkBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-u":()=>(this.editor.commands.openLinkBubbleMenu(),!0)}},addProseMirrorPlugins(){return[new on({key:new On("handleClickLinkForMenu"),props:{handleClick:(t,e,n)=>{const r=sv(t.state,"link");return n.target.closest("a")&&r.href&&this.storage.state===ur.HIDDEN?this.editor.commands.openLinkBubbleMenu():this.editor.commands.closeLinkBubbleMenu(),!1}}})]}}),_Q=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,RQ=rn.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Tt(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[K_({find:_Q,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}});var Ay={},Ck;function IQ(){return Ck||(Ck=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=y2();function n(r,o=0,i={}){const{leading:s=!0,trailing:a=!0}=i;return e.debounce(r,o,{leading:s,maxWait:o,trailing:a})}t.throttle=n})(Ay)),Ay}var Py,Sk;function DQ(){return Sk||(Sk=1,Py=IQ().throttle),Py}var AQ=DQ();const PQ=Qn(AQ),pf=Zt("ResizableImageComponent",["imageContainer","image","imageSelected","resizer"]),NQ=Zt("ResizableImageResizer",["root"]),W2=qt("ResizableImageResizer"),jQ=oe("div",{name:W2,slot:"root",overridesResolver:(t,e)=>e.root})(({theme:t})=>({position:"absolute",bottom:-3,right:-3,width:12,height:12,background:t.palette.primary.main,cursor:"nwse-resize"}));function $Q(t){const e=rt({props:t,name:W2}),{onResize:n,className:r,mouseDown:o,setMouseDown:i,classes:s={},sx:a}=e;J.useEffect(()=>{if(!o)return;const u=f=>{n(f)};return window.addEventListener("mousemove",u),()=>{window.removeEventListener("mousemove",u)}},[o,n]),J.useEffect(()=>{const u=()=>{i(!1)};return window.addEventListener("mouseup",u),()=>{window.removeEventListener("mouseup",u)}},[i]);const l=J.useCallback(u=>{u.preventDefault(),u.stopPropagation(),i(!0)},[i]);return g.jsx(jQ,{className:ye([NQ.root,r,s.root]),onMouseDown:l,sx:a})}const LQ=15,Zh=qt("ResizableImageComponent"),BQ=oe("div",{name:Zh,slot:"imageContainer",overridesResolver:(t,e)=>e.imageContainer})(()=>({display:"inline-flex",position:"relative"})),FQ=oe("img",{name:Zh,slot:"image",overridesResolver:(t,e)=>[e.image,t.ownerState.selectedOrResizing&&e.imageSelected]})(({theme:t,ownerState:e})=>({display:"block",...e.selectedOrResizing&&{outline:`3px solid ${t.palette.primary.main}`}})),VQ=oe($Q,{name:Zh,slot:"resizer",overridesResolver:(t,e)=>e.resizer})(()=>({'.ProseMirror[contenteditable="false"] &':{display:"none"}}));function zQ(t){var e,n,r;const o=rt({props:t,name:Zh}),{node:i,selected:s,updateAttributes:a,extension:l,classes:u={},sx:f}=o,{attrs:p}=i,m=J.useRef(null),[b,v]=J.useState(!1),y=s||b,x={selected:s,selectedOrResizing:y},C=J.useMemo(()=>PQ(T=>{if(!m.current)return;const S=m.current.getBoundingClientRect(),O=T.clientX-S.x,R=T.clientY-S.y,P=Math.max(O,S.width/S.height*R,LQ);a({width:Math.round(P)})},50,{trailing:!0}),[a]),k=l.options.ChildComponent;return g.jsx(Wv,{style:{textAlign:p.textAlign,width:"100%"},as:l.options.inline?"span":"div",sx:f,children:g.jsxs(BQ,{className:ye([pf.imageContainer,u.imageContainer]),children:[g.jsx(FQ,{ref:m,src:p.src,height:"auto",width:p.width?p.width:void 0,alt:(e=p.alt)!==null&&e!==void 0?e:void 0,title:(n=p.title)!==null&&n!==void 0?n:void 0,className:ye([pf.image,u.image,y&&"ProseMirror-selectednode",y&&[pf.imageSelected,u.imageSelected]]),style:{maxWidth:p.width?void 0:"auto",aspectRatio:(r=p.aspectRatio)!==null&&r!==void 0?r:void 0},ownerState:x,"data-drag-handle":!0,onLoad:T=>{const S={};p.width||(S.width=T.currentTarget.naturalWidth),p.aspectRatio||(S.aspectRatio=String(T.currentTarget.naturalWidth/T.currentTarget.naturalHeight)),(S.width||S.aspectRatio)&&a(S)}}),y&&g.jsx(VQ,{onResize:C,className:ye([pf.resizer,u.resizer]),mouseDown:b,setMouseDown:v}),k&&g.jsx(k,{...o})]})})}const HQ=RQ.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),isAllowedImgSrc:e=>!!e}},addAttributes(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),width:{default:null,renderHTML:e=>({width:e.width}),parseHTML:e=>e.getAttribute("width")},aspectRatio:{default:null,renderHTML:e=>e.aspectRatio?{style:`aspect-ratio: ${e.aspectRatio}`}:{},parseHTML:e=>e.style.aspectRatio}}},renderHTML({HTMLAttributes:t}){return["img",Tt({height:"auto"},this.options.HTMLAttributes,t)]},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])',getAttrs:t=>{if(!(t instanceof Element))return!1;const e=t.getAttribute("src");return this.options.isAllowedImgSrc(e)&&null}}]},addInputRules(){var t;const e=(t=this.parent)===null||t===void 0?void 0:t.call(this);if(!e)return[];const n=r=>{const[,,o,i,s]=r;return{src:i,alt:o,title:s}};return e.map(r=>new ju({find:r.find,handler:o=>{const i=n(o.match);if(this.options.isAllowedImgSrc(i.src))return r.handler(o)}}))},addNodeView(){return Uv(zQ)}});let c0,u0;if(typeof WeakMap<"u"){let t=new WeakMap;c0=e=>t.get(e),u0=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;c0=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},u0=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var mn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,o=e/this.width|0;let i=r+1,s=o+1;for(let a=1;i<this.width&&this.map[e+a]==n;a++)i++;for(let a=1;s<this.height&&this.map[e+this.width*a]==n;a++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:r,top:o,bottom:i}=this.findCell(t),{left:s,right:a,top:l,bottom:u}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(o,l),right:Math.max(r,a),bottom:Math.max(i,u)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const a=(t+1)*this.width;for(;s<a&&this.map[s]<o;)s++;return s==a?i-1:this.map[s]}o=i}}static get(t){return c0(t)||u0(t,WQ(t))}};function WQ(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=UQ(t),n=t.childCount,r=[];let o=0,i=null;const s=[];for(let u=0,f=e*n;u<f;u++)r[u]=0;for(let u=0,f=0;u<n;u++){const p=t.child(u);f++;for(let v=0;;v++){for(;o<r.length&&r[o]!=0;)o++;if(v==p.childCount)break;const y=p.child(v),{colspan:x,rowspan:C,colwidth:k}=y.attrs;for(let T=0;T<C;T++){if(T+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:C-T});break}const S=o+T*e;for(let O=0;O<x;O++){r[S+O]==0?r[S+O]=f:(i||(i=[])).push({type:"collision",row:u,pos:f,n:x-O});const R=k&&k[O];if(R){const P=(S+O)%e*2,j=s[P];j==null||j!=R&&s[P+1]==1?(s[P]=R,s[P+1]=1):j==R&&s[P+1]++}}}o+=x,f+=y.nodeSize}const m=(u+1)*e;let b=0;for(;o<m;)r[o++]==0&&b++;b&&(i||(i=[])).push({type:"missing",row:u,n:b}),f++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const a=new mn(e,n,r,i);let l=!1;for(let u=0;!l&&u<s.length;u+=2)s[u]!=null&&s[u+1]<n&&(l=!0);return l&&qQ(a,s,t),a}function UQ(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const o=t.child(r);let i=0;if(n)for(let s=0;s<r;s++){const a=t.child(s);for(let l=0;l<a.childCount;l++){const u=a.child(l);s+u.attrs.rowspan>r&&(i+=u.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const a=o.child(s);i+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function qQ(t,e,n){t.problems||(t.problems=[]);const r={};for(let o=0;o<t.map.length;o++){const i=t.map[o];if(r[i])continue;r[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let a=null;const l=s.attrs;for(let u=0;u<l.colspan;u++){const f=e[(o+u)%t.width*2];f!=null&&(!l.colwidth||l.colwidth[u]!=f)&&((a||(a=KQ(l)))[u]=f)}a&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function KQ(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function ir(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}const ls=new On("selectingCells");function Xl(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function YQ(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Io(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Qh(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Xl(e.$head)||GQ(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function GQ(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function d0(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function JQ(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function qv(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function U2(t,e,n){const r=t.node(-1),o=mn.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function Ta(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function q2(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function XQ(t,e,n){const r=ir(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var zt=class wi extends nt{constructor(e,n=e){const r=e.node(-1),o=mn.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),a=e.node(0),l=o.cellsInRect(s).filter(f=>f!=n.pos-i);l.unshift(n.pos-i);const u=l.map(f=>{const p=r.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=i+f+1;return new LM(a.resolve(m),a.resolve(m+p.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if(d0(r)&&d0(o)&&qv(r,o)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?wi.rowSelection(r,o):i&&this.isColSelection()?wi.colSelection(r,o):new wi(r,o)}return Je.between(r,o)}content(){const e=this.$anchorCell.node(-1),n=mn.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let l=o.top;l<o.bottom;l++){const u=[];for(let f=l*n.width+o.left,p=o.left;p<o.right;p++,f++){const m=n.map[f];if(i[m])continue;i[m]=!0;const b=n.findCell(m);let v=e.nodeAt(m);if(!v)throw new RangeError(`No cell with offset ${m} found`);const y=o.left-b.left,x=b.right-o.right;if(y>0||x>0){let C=v.attrs;if(y>0&&(C=Ta(C,0,y)),x>0&&(C=Ta(C,C.colspan-x,x)),b.left<o.left){if(v=v.type.createAndFill(C),!v)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(C)}`)}else v=v.type.create(C,v.content)}if(b.top<o.top||b.bottom>o.bottom){const C={...v.attrs,rowspan:Math.min(b.bottom,o.bottom)-Math.max(b.top,o.top)};b.top<o.top?v=v.type.createAndFill(C):v=v.type.create(C,v.content)}u.push(v)}s.push(e.child(l).copy(Oe.from(u)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new $e(Oe.from(a),1,1)}replace(e,n=$e.empty){const r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:a,$to:l}=o[s],u=e.mapping.slice(r);e.replace(u.map(a.pos),u.map(l.pos),s?$e.empty:n)}const i=nt.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new $e(Oe.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=mn.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),o=mn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(i+o.map[s.left])),a.bottom<o.height&&(n=l.resolve(i+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(i+o.map[a.left])),s.bottom<o.height&&(e=l.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new wi(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=mn.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,a=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==n.width}eq(e){return e instanceof wi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),o=mn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(i+o.map[s.top*o.width])),a.right<o.width&&(n=l.resolve(i+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(i+o.map[a.top*o.width])),s.right<o.width&&(e=l.resolve(i+o.map[o.width*(s.top+1)-1]))),new wi(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new wi(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new wi(e.resolve(n),e.resolve(r))}getBookmark(){return new ZQ(this.$anchorCell.pos,this.$headCell.pos)}};zt.prototype.visible=!1;nt.jsonID("cell",zt);var ZQ=class K2{constructor(e,n){this.anchor=e,this.head=n}map(e){return new K2(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&qv(n,r)?new zt(n,r):nt.near(r,1)}};function QQ(t){if(!(t.selection instanceof zt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Zn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Xt.create(t.doc,e)}function eee({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function tee({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){const i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function nee(t,e,n){const r=(e||t).selection,o=(e||t).doc;let i,s;if(r instanceof Ge&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=zt.create(o,r.from);else if(s=="row"){const a=o.resolve(r.from+1);i=zt.rowSelection(a,a)}else if(!n){const a=mn.get(r.node),l=r.from+1,u=l+a.map[a.width*a.height-1];i=zt.create(o,l+1,u)}}else r instanceof Je&&eee(r)?i=Je.create(o,r.from):r instanceof Je&&tee(r)&&(i=Je.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const ree=new On("fix-tables");function Y2(t,e,n,r){const o=t.childCount,i=e.childCount;e:for(let s=0,a=0;s<i;s++){const l=e.child(s);for(let u=a,f=Math.min(o,s+3);u<f;u++)if(t.child(u)==l){a=u+1,n+=l.nodeSize;continue e}r(l,n),a<o&&t.child(a).sameMarkup(l)?Y2(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function G2(t,e){let n;const r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=oee(t,o,i,n))};return e?e.doc!=t.doc&&Y2(e.doc,t.doc,0,r):t.doc.descendants(r),n}function oee(t,e,n,r){const o=mn.get(e);if(!o.problems)return r;r||(r=t.tr);const i=[];for(let l=0;l<o.height;l++)i.push(0);for(let l=0;l<o.problems.length;l++){const u=o.problems[l];if(u.type=="collision"){const f=e.nodeAt(u.pos);if(!f)continue;const p=f.attrs;for(let m=0;m<p.rowspan;m++)i[u.row+m]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,Ta(p,p.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){const f=r.mapping.map(n);r.delete(f,f+e.nodeSize)}}let s,a;for(let l=0;l<i.length;l++)i[l]&&(s==null&&(s=l),a=l);for(let l=0,u=n+1;l<o.height;l++){const f=e.child(l),p=u+f.nodeSize,m=i[l];if(m>0){let b="cell";f.firstChild&&(b=f.firstChild.type.spec.tableRole);const v=[];for(let x=0;x<m;x++){const C=ir(t.schema)[b].createAndFill();C&&v.push(C)}const y=(l==0||s==l-1)&&a==l?u+1:p-1;r.insert(r.mapping.map(y),v)}u=p}return r.setMeta(ree,{fixTables:!0})}function oi(t){const e=t.selection,n=Qh(t),r=n.node(-1),o=n.start(-1),i=mn.get(r);return{...e instanceof zt?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function J2(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;XQ(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+o;if(o>0&&o<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],u=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,q2(u.attrs,o-e.colCount(l))),s+=u.attrs.rowspan-1}else{const l=i==null?ir(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,u=e.positionAt(s,o,r);t.insert(t.mapping.map(n+u),l.createAndFill())}}return t}function iee(t,e){if(!Io(t))return!1;if(e){const n=oi(t);e(J2(t.tr,n,n.left))}return!0}function see(t,e){if(!Io(t))return!1;if(e){const n=oi(t);e(J2(t.tr,n,n.right))}return!0}function aee(t,{map:e,table:n,tableStart:r},o){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+o,l=e.map[a],u=n.nodeAt(l),f=u.attrs;if(o>0&&e.map[a-1]==l||o<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(i).map(r+l),null,Ta(f,o-e.colCount(l)));else{const p=t.mapping.slice(i).map(r+l);t.delete(p,p+u.nodeSize)}s+=f.rowspan}}function lee(t,e){if(!Io(t))return!1;if(e){const n=oi(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;aee(r,n,o),o!=n.left;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=mn.get(i)}e(r)}return!0}function cee(t,e,n){var r;const o=ir(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function X2(t,{map:e,tableStart:n,table:r},o){let i=n;for(let u=0;u<o;u++)i+=r.child(u).nodeSize;const s=[];let a=o>0?-1:0;cee(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let u=0,f=e.width*o;u<e.width;u++,f++)if(o>0&&o<e.height&&e.map[f]==e.map[f-e.width]){const p=e.map[f],m=r.nodeAt(p).attrs;t.setNodeMarkup(n+p,null,{...m,rowspan:m.rowspan+1}),u+=m.colspan-1}else{var l;const p=a==null?ir(r.type.schema).cell:(l=r.nodeAt(e.map[f+a*e.width]))===null||l===void 0?void 0:l.type,m=p==null?void 0:p.createAndFill();m&&s.push(m)}return t.insert(i,ir(r.type.schema).row.create(null,s)),t}function uee(t,e){if(!Io(t))return!1;if(e){const n=oi(t);e(X2(t.tr,n,n.top))}return!0}function dee(t,e){if(!Io(t))return!1;if(e){const n=oi(t);e(X2(t.tr,n,n.bottom))}return!0}function fee(t,{map:e,table:n,tableStart:r},o){let i=0;for(let u=0;u<o;u++)i+=n.child(u).nodeSize;const s=i+n.child(o).nodeSize,a=t.mapping.maps.length;t.delete(i+r,s+r);const l=new Set;for(let u=0,f=o*e.width;u<e.width;u++,f++){const p=e.map[f];if(!l.has(p)){if(l.add(p),o>0&&p==e.map[f-e.width]){const m=n.nodeAt(p).attrs;t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m,rowspan:m.rowspan-1}),u+=m.colspan-1}else if(o<e.height&&p==e.map[f+e.width]){const m=n.nodeAt(p),b=m.attrs,v=m.type.create({...b,rowspan:m.attrs.rowspan-1},m.content),y=e.positionAt(o+1,u,n);t.insert(t.mapping.slice(a).map(r+y),v),u+=b.colspan-1}}}}function pee(t,e){if(!Io(t))return!1;if(e){const n=oi(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;fee(r,n,o),o!=n.top;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=mn.get(n.table)}e(r)}return!0}function Tk(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function hee({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,a=o+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[a]==n[a+1])return!0;i+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function kk(t,e){const n=t.selection;if(!(n instanceof zt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=oi(t),{map:o}=r;if(hee(o,r))return!1;if(e){const i=t.tr,s={};let a=Oe.empty,l,u;for(let f=r.top;f<r.bottom;f++)for(let p=r.left;p<r.right;p++){const m=o.map[f*o.width+p],b=r.table.nodeAt(m);if(!(s[m]||!b))if(s[m]=!0,l==null)l=m,u=b;else{Tk(b)||(a=a.append(b.content));const v=i.mapping.map(m+r.tableStart);i.delete(v,v+b.nodeSize)}}if(l==null||u==null)return!0;if(i.setNodeMarkup(l+r.tableStart,null,{...q2(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const f=l+1+u.content.size,p=Tk(u)?l+1:f;i.replaceWith(p+r.tableStart,f+r.tableStart,a)}i.setSelection(new zt(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function Ek(t,e){const n=ir(t.schema);return mee(({node:r})=>n[r.type.spec.tableRole])(t,e)}function mee(t){return(e,n)=>{const r=e.selection;let o,i;if(r instanceof zt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=YQ(r.$from),!o)return!1;i=(s=Xl(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let a=o.attrs;const l=[],u=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const f=oi(e),p=e.tr;for(let b=0;b<f.right-f.left;b++)l.push(u?{...a,colwidth:u&&u[b]?[u[b]]:null}:a);let m;for(let b=f.top;b<f.bottom;b++){let v=f.map.positionAt(b,f.left,f.table);b==f.top&&(v+=o.nodeSize);for(let y=f.left,x=0;y<f.right;y++,x++)y==f.left&&b==f.top||p.insert(m=p.mapping.map(v+f.tableStart,1),t({node:o,row:b,col:y}).createAndFill(l[x]))}p.setNodeMarkup(i,t({node:o,row:f.top,col:f.left}),l[0]),r instanceof zt&&p.setSelection(new zt(p.doc.resolve(r.$anchorCell.pos),m?p.doc.resolve(m):void 0)),n(p)}return!0}}function gee(t,e){return function(n,r){if(!Io(n))return!1;const o=Qh(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof zt?n.selection.forEachCell((s,a)=>{s.attrs[t]!==e&&i.setNodeMarkup(a,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function yee(t){return function(e,n){if(!Io(e))return!1;if(n){const r=ir(e.schema),o=oi(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=s.map(l=>o.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[l],r.cell,a[l].attrs);if(i.steps.length===0)for(let l=0;l<s.length;l++)i.setNodeMarkup(o.tableStart+s[l],r.header_cell,a[l].attrs);n(i)}return!0}}function Ok(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function Eu(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?yee(t):function(n,r){if(!Io(n))return!1;if(r){const o=ir(n.schema),i=oi(n),s=n.tr,a=Ok("row",i,o),l=Ok("column",i,o),u=(t==="column"?a:t==="row"&&l)?1:0,f=t=="column"?{left:0,top:u,right:1,bottom:i.map.height}:t=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,p=t=="column"?l?o.cell:o.header_cell:t=="row"?a?o.cell:o.header_cell:o.cell;i.map.cellsInRect(f).forEach(m=>{const b=m+i.tableStart,v=s.doc.nodeAt(b);v&&s.setNodeMarkup(b,p,v.attrs)}),r(s)}return!0}}Eu("row",{useDeprecatedLogic:!0});Eu("column",{useDeprecatedLogic:!0});const bee=Eu("cell",{useDeprecatedLogic:!0});function vee(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){const i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function Mk(t){return function(e,n){if(!Io(e))return!1;const r=vee(Qh(e),t);if(r==null)return!1;if(n){const o=e.doc.resolve(r);n(e.tr.setSelection(Je.between(o,JQ(o))).scrollIntoView())}return!0}}function xee(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function hf(t,e){const n=t.selection;if(!(n instanceof zt))return!1;if(e){const r=t.tr,o=ir(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new $e(o,0,0))}),r.docChanged&&e(r)}return!0}function wee(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let u=e.child(l).content;const f=l?0:Math.max(0,n-1),p=l<e.childCount-1?0:Math.max(0,r-1);(f||p)&&(u=f0(ir(s).row,new $e(u,f,p)).content),a.push(u)}else if(i=="cell"||i=="header_cell")a.push(n||r?f0(ir(s).row,new $e(e,n,r)).content:e);else return null;return Cee(s,a)}function Cee(t,e){const n=[];for(let o=0;o<e.length;o++){const i=e[o];for(let s=i.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=i.child(s).attrs;for(let u=o;u<o+a;u++)n[u]=(n[u]||0)+l}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(Oe.empty),n[o]<r){const i=ir(t).cell.createAndFill(),s=[];for(let a=n[o];a<r;a++)s.push(i);e[o]=e[o].append(Oe.from(s))}return{height:e.length,width:r,rows:e}}function f0(t,e){const n=t.createAndFill();return new L0(n).replace(0,n.content.size,e).doc}function See({width:t,height:e,rows:n},r,o){if(t!=r){const i=[],s=[];for(let a=0;a<n.length;a++){const l=n[a],u=[];for(let f=i[a]||0,p=0;f<r;p++){let m=l.child(p%l.childCount);f+m.attrs.colspan>r&&(m=m.type.createChecked(Ta(m.attrs,m.attrs.colspan,f+m.attrs.colspan-r),m.content)),u.push(m),f+=m.attrs.colspan;for(let b=1;b<m.attrs.rowspan;b++)i[a+b]=(i[a+b]||0)+m.attrs.colspan}s.push(Oe.from(u))}n=s,t=r}if(e!=o){const i=[];for(let s=0,a=0;s<o;s++,a++){const l=[],u=n[a%e];for(let f=0;f<u.childCount;f++){let p=u.child(f);s+p.attrs.rowspan>o&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,o-p.attrs.rowspan)},p.content)),l.push(p)}i.push(Oe.from(l))}n=i,e=o}return{width:t,height:e,rows:n}}function Tee(t,e,n,r,o,i,s){const a=t.doc.type.schema,l=ir(a);let u,f;if(o>e.width)for(let p=0,m=0;p<e.height;p++){const b=n.child(p);m+=b.nodeSize;const v=[];let y;b.lastChild==null||b.lastChild.type==l.cell?y=u||(u=l.cell.createAndFill()):y=f||(f=l.header_cell.createAndFill());for(let x=e.width;x<o;x++)v.push(y);t.insert(t.mapping.slice(s).map(m-1+r),v)}if(i>e.height){const p=[];for(let v=0,y=(e.height-1)*e.width;v<Math.max(e.width,o);v++){const x=v>=e.width?!1:n.nodeAt(e.map[y+v]).type==l.header_cell;p.push(x?f||(f=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const m=l.row.create(null,Oe.from(p)),b=[];for(let v=e.height;v<i;v++)b.push(m);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),b)}return!!(u||f)}function _k(t,e,n,r,o,i,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let u=o;u<i;u++){const f=s*e.width+u,p=e.map[f];if(e.map[f-e.width]==p){l=!0;const m=n.nodeAt(p),{top:b,left:v}=e.findCell(p);t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m.attrs,rowspan:s-b}),t.insert(t.mapping.slice(a).map(e.positionAt(s,v,n)),m.type.createAndFill({...m.attrs,rowspan:b+m.attrs.rowspan-s})),u+=m.attrs.colspan-1}}return l}function Rk(t,e,n,r,o,i,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let u=o;u<i;u++){const f=u*e.width+s,p=e.map[f];if(e.map[f-1]==p){l=!0;const m=n.nodeAt(p),b=e.colCount(p),v=t.mapping.slice(a).map(p+r);t.setNodeMarkup(v,null,Ta(m.attrs,s-b,m.attrs.colspan-(s-b))),t.insert(v+m.nodeSize,m.type.createAndFill(Ta(m.attrs,0,s-b))),u+=m.attrs.rowspan-1}}return l}function Ik(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=mn.get(i);const{top:a,left:l}=r,u=l+o.width,f=a+o.height,p=t.tr;let m=0;function b(){if(i=n?p.doc.nodeAt(n-1):p.doc,!i)throw new Error("No table found");s=mn.get(i),m=p.mapping.maps.length}Tee(p,s,i,n,u,f,m)&&b(),_k(p,s,i,n,l,u,a,m)&&b(),_k(p,s,i,n,l,u,f,m)&&b(),Rk(p,s,i,n,a,f,l,m)&&b(),Rk(p,s,i,n,a,f,u,m)&&b();for(let v=a;v<f;v++){const y=s.positionAt(v,l,i),x=s.positionAt(v,u,i);p.replace(p.mapping.slice(m).map(y+n),p.mapping.slice(m).map(x+n),new $e(o.rows[v-a],0,0))}b(),p.setSelection(new zt(p.doc.resolve(n+s.positionAt(a,l,i)),p.doc.resolve(n+s.positionAt(f-1,u-1,i)))),e(p)}const kee=G0({ArrowLeft:mf("horiz",-1),ArrowRight:mf("horiz",1),ArrowUp:mf("vert",-1),ArrowDown:mf("vert",1),"Shift-ArrowLeft":gf("horiz",-1),"Shift-ArrowRight":gf("horiz",1),"Shift-ArrowUp":gf("vert",-1),"Shift-ArrowDown":gf("vert",1),Backspace:hf,"Mod-Backspace":hf,Delete:hf,"Mod-Delete":hf});function Nf(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function mf(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;if(i instanceof zt)return Nf(n,r,nt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const s=Z2(o,t,e);if(s==null)return!1;if(t=="horiz")return Nf(n,r,nt.near(n.doc.resolve(i.head+e),e));{const a=n.doc.resolve(s),l=U2(a,t,e);let u;return l?u=nt.near(l,1):e<0?u=nt.near(n.doc.resolve(a.before(-1)),-1):u=nt.near(n.doc.resolve(a.after(-1)),1),Nf(n,r,u)}}}function gf(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof zt)s=i;else{const l=Z2(o,t,e);if(l==null)return!1;s=new zt(n.doc.resolve(l))}const a=U2(s.$headCell,t,e);return a?Nf(n,r,new zt(s.$anchorCell,a)):!1}}function Eee(t,e){const n=t.state.doc,r=Xl(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new zt(r))),!0):!1}function Oee(t,e,n){if(!Io(t.state))return!1;let r=wee(n);const o=t.state.selection;if(o instanceof zt){r||(r={width:1,height:1,rows:[Oe.from(f0(ir(t.state.schema).cell,n))]});const i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),a=mn.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=See(r,a.right-a.left,a.bottom-a.top),Ik(t.state,t.dispatch,s,a,r),!0}else if(r){const i=Qh(t.state),s=i.start(-1);return Ik(t.state,t.dispatch,s,mn.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function Mee(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Dk(t,e.target);let o;if(e.shiftKey&&t.state.selection instanceof zt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Xl(t.state.selection.$anchor))!=null&&((n=Ny(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(l,u){let f=Ny(t,u);const p=ls.getState(t.state)==null;if(!f||!qv(l,f))if(p)f=l;else return;const m=new zt(l,f);if(p||!t.state.selection.eq(m)){const b=t.state.tr.setSelection(m);p&&b.setMeta(ls,l.pos),t.dispatch(b)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),ls.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ls,-1))}function a(l){const u=l,f=ls.getState(t.state);let p;if(f!=null)p=t.state.doc.resolve(f);else if(Dk(t,u.target)!=r&&(p=Ny(t,e),!p))return s();p&&i(p,u)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function Z2(t,e,n){if(!(t.state.selection instanceof Je))return null;const{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const s=r.before(o),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?s:null}}return null}function Dk(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ny(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;const r=n.inside>=0?n.inside:n.pos;return Xl(t.state.doc.resolve(r))}var _ee=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),p0(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,p0(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function p0(t,e,n,r,o,i){let s=0,a=!0,l=e.firstChild;const u=t.firstChild;if(u){for(let p=0,m=0;p<u.childCount;p++){const{colspan:b,colwidth:v}=u.child(p).attrs;for(let y=0;y<b;y++,m++){const x=o==m?i:v&&v[y],C=x?x+"px":"";if(s+=x||r,x||(a=!1),l)l.style.width!=C&&(l.style.width=C),l=l.nextSibling;else{const k=document.createElement("col");k.style.width=C,e.appendChild(k)}}}for(;l;){var f;const p=l.nextSibling;(f=l.parentNode)===null||f===void 0||f.removeChild(l),l=p}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const Lr=new On("tableColumnResizing");function Q2({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=_ee,lastColumnResizable:o=!0}={}){const i=new on({key:Lr,state:{init(s,a){var l;const u=(l=i.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,f=ir(a.schema).table.name;return r&&u&&(u[f]=(p,m)=>new r(p,n,m)),new Ree(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=Lr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{Iee(s,a,t,o)},mouseleave:s=>{Dee(s)},mousedown:(s,a)=>{Aee(s,a,e,n)}},decorations:s=>{const a=Lr.getState(s);if(a&&a.activeHandle>-1)return Lee(s,a.activeHandle)},nodeViews:{}}});return i}var Ree=class jf{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new jf(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new jf(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return d0(e.doc.resolve(o))||(o=-1),new jf(o,n.dragging)}return n}};function Iee(t,e,n,r){if(!t.editable)return;const o=Lr.getState(t.state);if(o&&!o.dragging){const i=Nee(e.target);let s=-1;if(i){const{left:a,right:l}=i.getBoundingClientRect();e.clientX-a<=n?s=Ak(t,e,"left",n):l-e.clientX<=n&&(s=Ak(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){const a=t.state.doc.resolve(s),l=a.node(-1),u=mn.get(l),f=a.start(-1);if(u.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==u.width-1)return}eI(t,s)}}}function Dee(t){if(!t.editable)return;const e=Lr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&eI(t,-1)}function Aee(t,e,n,r){var o;if(!t.editable)return!1;const i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Lr.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=Pee(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:l}}));function u(p){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",f);const m=Lr.getState(t.state);m!=null&&m.dragging&&(jee(t,m.activeHandle,Pk(m.dragging,p,n)),t.dispatch(t.state.tr.setMeta(Lr,{setDragging:null})))}function f(p){if(!p.which)return u(p);const m=Lr.getState(t.state);if(m&&m.dragging){const b=Pk(m.dragging,p,n);Nk(t,m.activeHandle,b,r)}}return Nk(t,s.activeHandle,l,r),i.addEventListener("mouseup",u),i.addEventListener("mousemove",f),e.preventDefault(),!0}function Pee(t,e,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(s-=r[l],a--);return s/a}function Nee(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Ak(t,e,n,r){const o=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:s}=i,a=Xl(t.state.doc.resolve(s));if(!a)return-1;if(n=="right")return a.pos;const l=mn.get(a.node(-1)),u=a.start(-1),f=l.map.indexOf(a.pos-u);return f%l.width==0?-1:u+l.map[f-1]}function Pk(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function eI(t,e){t.dispatch(t.state.tr.setMeta(Lr,{setHandle:e}))}function jee(t,e,n){const r=t.state.doc.resolve(e),o=r.node(-1),i=mn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let u=0;u<i.height;u++){const f=u*i.width+a;if(u&&i.map[f]==i.map[f-i.width])continue;const p=i.map[f],m=o.nodeAt(p).attrs,b=m.colspan==1?0:a-i.colCount(p);if(m.colwidth&&m.colwidth[b]==n)continue;const v=m.colwidth?m.colwidth.slice():$ee(m.colspan);v[b]=n,l.setNodeMarkup(s+p,null,{...m,colwidth:v})}l.docChanged&&t.dispatch(l)}function Nk(t,e,n,r){const o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),a=mn.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let l=t.domAtPos(o.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&p0(i,l.firstChild,l,r,a,n)}function $ee(t){return Array(t).fill(0)}function Lee(t,e){const n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return Xt.empty;const i=mn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){const f=a+u*i.width;if((a==i.width-1||i.map[f]!=i.map[f+1])&&(u==0||i.map[f]!=i.map[f-i.width])){var l;const p=i.map[f],m=s+p+o.nodeAt(p).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((l=Lr.getState(t))===null||l===void 0)&&l.dragging&&n.push(Zn.node(s+p,s+p+o.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),n.push(Zn.widget(m,b))}}return Xt.create(t.doc,n)}function tI({allowTableNodeSelection:t=!1}={}){return new on({key:ls,state:{init(){return null},apply(e,n){const r=e.getMeta(ls);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:QQ,handleDOMEvents:{mousedown:Mee},createSelectionBetween(e){return ls.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Eee,handleKeyDown:kee,handlePaste:Oee},appendTransaction(e,n,r){return nee(r,G2(r,n),t)}})}function h0(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function jk(t,e,n,r,o,i){var s;let a=0,l=!0,u=e.firstChild;const f=t.firstChild;if(f!==null)for(let p=0,m=0;p<f.childCount;p+=1){const{colspan:b,colwidth:v}=f.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=o===m?i:v&&v[y],C=x?`${x}px`:"";if(a+=x||r,x||(l=!1),u){if(u.style.width!==C){const[k,T]=h0(r,x);u.style.setProperty(k,T)}u=u.nextSibling}else{const k=document.createElement("col"),[T,S]=h0(r,x);k.style.setProperty(T,S),e.appendChild(k)}}}for(;u;){const p=u.nextSibling;(s=u.parentNode)===null||s===void 0||s.removeChild(u),u=p}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class Bee{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),jk(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,jk(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function Fee(t,e,n,r){let o=0,i=!0;const s=[],a=t.firstChild;if(!a)return{};for(let p=0,m=0;p<a.childCount;p+=1){const{colspan:b,colwidth:v}=a.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=n===m?r:v&&v[y];o+=x||e,x||(i=!1);const[C,k]=h0(e,x);s.push(["col",{style:`${C}: ${k}`}])}}const l=i?`${o}px`:"",u=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:u}}function $k(t,e){return t.createAndFill()}function Vee(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function zee(t,e,n,r,o){const i=Vee(t),s=[],a=[];for(let u=0;u<n;u+=1){const f=$k(i.cell);if(f&&a.push(f),r){const p=$k(i.header_cell);p&&s.push(p)}}const l=[];for(let u=0;u<e;u+=1)l.push(i.row.createChecked(null,r&&u===0?s:a));return i.table.createChecked(null,l)}function Hee(t){return t instanceof zt}const yf=({editor:t})=>{const{selection:e}=t.state;if(!Hee(e))return!1;let n=0;const r=ov(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},Wee=rn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Bee,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=Fee(t,this.options.cellMinWidth),i=["table",Tt(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{const s=zee(i.schema,t,e,n);if(o){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Je.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>iee(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>see(t,e),deleteColumn:()=>({state:t,dispatch:e})=>lee(t,e),addRowBefore:()=>({state:t,dispatch:e})=>uee(t,e),addRowAfter:()=>({state:t,dispatch:e})=>dee(t,e),deleteRow:()=>({state:t,dispatch:e})=>pee(t,e),deleteTable:()=>({state:t,dispatch:e})=>xee(t,e),mergeCells:()=>({state:t,dispatch:e})=>kk(t,e),splitCell:()=>({state:t,dispatch:e})=>Ek(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Eu("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Eu("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>bee(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>kk(t,e)?!0:Ek(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>gee(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Mk(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Mk(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&G2(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=zt.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:yf,"Mod-Backspace":yf,Delete:yf,"Mod-Delete":yf}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Q2({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],tI({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:pt(We(t,"tableRole",e))}}}),Uee=Wee.extend({addProseMirrorPlugins(){return[...this.options.resizable?[Q2({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],tI({allowTableNodeSelection:this.options.allowTableNodeSelection})]}}),Xs=Zt("FieldContainer",["root","outlined","standard","focused","disabled","notchedOutline"]),Kv=qt("FieldContainer"),qee=oe(Bv,{name:Kv,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard,t.ownerState.focused&&e.focused,t.ownerState.disabled&&e.disabled]})(({theme:t,ownerState:e})=>({...e.variant==="outlined"&&{borderRadius:t.shape.borderRadius,padding:1,position:"relative",...!e.focused&&!e.disabled&&{[`&:hover .${Xs.notchedOutline}`]:{borderColor:t.palette.text.primary}}}})),Kee=oe("div",{name:Kv,slot:"notchedOutline",overridesResolver:(t,e)=>e.notchedOutline})(({theme:t,ownerState:e})=>({position:"absolute",inset:0,borderRadius:"inherit",borderColor:t.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)",borderStyle:"solid",borderWidth:1,pointerEvents:"none",overflow:"hidden",zIndex:gp.NOTCHED_OUTLINE,...e.focused&&{borderColor:t.palette.primary.main,borderWidth:2},...e.disabled&&{borderColor:t.palette.action.disabled}}));function Yee(t){const e=rt({props:t,name:Kv}),{variant:n="outlined",children:r,focused:o,disabled:i,classes:s={},className:a,sx:l,...u}=e,f={variant:n,focused:o,disabled:i};return g.jsxs(qee,{...u,className:ye([Xs.root,a,s.root,n==="outlined"?[Xs.outlined,s.outlined]:[Xs.standard,s.standard],o&&[Xs.focused,s.focused],i&&[Xs.disabled,s.disabled]]),sx:l,ownerState:f,children:[r,n==="outlined"&&g.jsx(Kee,{ownerState:f,className:ye([Xs.notchedOutline,s.notchedOutline]),"aria-hidden":!0})]})}function nI({editor:t,wait:e=250}){const[n,r]=J.useState(!!(t!=null&&t.isFocused)),o=J.useMemo(()=>b2(i=>{r(i)},e),[e]);return J.useEffect(()=>{const i=!!(t!=null&&t.isFocused);return o(i),i&&o.flush(),()=>{o.cancel()}},[t==null?void 0:t.isFocused,o]),n}function rI(t,e){const n=J.useRef(e);J.useEffect(()=>{n.current=e},[e]),J.useEffect(()=>{function r(o){t===o.key&&n.current(o)}return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[t])}function Gee(t){return qe("MuiDialogActions",t)}He("MuiDialogActions",["root","spacing"]);const Jee=t=>{const{classes:e,disableSpacing:n}=t;return Ue({root:["root",!n&&"spacing"]},Gee,e)},Xee=oe("div",{name:"MuiDialogActions",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,!n.disableSpacing&&e.spacing]}})({display:"flex",alignItems:"center",padding:8,justifyContent:"flex-end",flex:"0 0 auto",variants:[{props:({ownerState:t})=>!t.disableSpacing,style:{"& > :not(style) ~ :not(style)":{marginLeft:8}}}]}),em=D.forwardRef(function(e,n){const r=mt({props:e,name:"MuiDialogActions"}),{className:o,disableSpacing:i=!1,...s}=r,a={...r,disableSpacing:i},l=Jee(a);return g.jsx(Xee,{className:ye(l.root,o),ownerState:a,ref:n,...s})});process.env.NODE_ENV!=="production"&&(em.propTypes={children:c.node,classes:c.object,className:c.string,disableSpacing:c.bool,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object])});function Zee({editor:t,onCancel:e,onSave:n,labels:r,formatHref:o=hX}){var i,s,a,l,u,f;const p=t.isActive("link")?t.getAttributes("link").href:"",m=$u(t.state.selection.$from,Mo("link",t.schema)),b=m?t.state.doc.textBetween(m.from,m.to):"",v=t.state.doc.textBetween(t.state.selection.$from.pos,t.state.selection.$to.pos),y=b||v,[x,C]=J.useState(y),[k,T]=J.useState(p),S=J.useRef(null),O=J.useRef(null),R=!p,P=(i=r==null?void 0:r.editLinkAddTitle)!==null&&i!==void 0?i:"Add link",j=(s=r==null?void 0:r.editLinkEditTitle)!==null&&s!==void 0?s:"Edit link",F=R?P:j;J.useEffect(()=>{var L,A;!R||!y?(L=S.current)===null||L===void 0||L.focus({preventScroll:!0}):(A=O.current)===null||A===void 0||A.focus({preventScroll:!0})},[R,y]),rI("Escape",e);function M(){O.current&&T(o(O.current.value))}const[$,z]=J.useState(!1);return g.jsxs("form",{onSubmit:L=>{var A,_,I,B;L.preventDefault(),L.stopPropagation(),z(!0);const W=(_=(A=S.current)===null||A===void 0?void 0:A.value)!==null&&_!==void 0?_:"",K=(B=(I=O.current)===null||I===void 0?void 0:I.value)!==null&&B!==void 0?B:"";n({text:W,link:K}),z(!1)},autoComplete:"off",children:[g.jsx(Ro,{variant:"h6",children:F}),g.jsx(Su,{inputRef:S,value:x,disabled:$,onChange:L=>{C(L.target.value)},label:(a=r==null?void 0:r.editLinkTextInputLabel)!==null&&a!==void 0?a:"Text",margin:"normal",size:"small",fullWidth:!0,required:!0}),g.jsx(Su,{inputRef:O,value:k,onChange:L=>{T(L.target.value)},disabled:$,label:(l=r==null?void 0:r.editLinkHrefInputLabel)!==null&&l!==void 0?l:"Link",margin:"dense",size:"small",type:"text",onBlur:M,onKeyDown:L=>{L.key==="Enter"&&M()},fullWidth:!0,required:!0}),g.jsxs(em,{sx:{px:0},children:[g.jsx(so,{onClick:e,variant:"outlined",size:"small",children:(u=r==null?void 0:r.editLinkCancelButtonLabel)!==null&&u!==void 0?u:"Cancel"}),g.jsx(so,{type:"submit",color:"primary",variant:"outlined",size:"small",disabled:$,children:(f=r==null?void 0:r.editLinkSaveButtonLabel)!==null&&f!==void 0?f:"Save"})]})]})}const jy=Zt("LinkBubbleMenu",["root","paper","content"]);function Qee(t){return qe("MuiLink",t)}const ete=He("MuiLink",["root","underlineNone","underlineHover","underlineAlways","button","focusVisible"]),tte=({theme:t,ownerState:e})=>{const n=e.color,r=ds(t,`palette.${n}.main`,!1)||ds(t,`palette.${n}`,!1)||e.color,o=ds(t,`palette.${n}.mainChannel`)||ds(t,`palette.${n}Channel`);return"vars"in t&&o?`rgba(${o} / 0.4)`:ot(r,.4)},Lk={primary:!0,secondary:!0,error:!0,info:!0,success:!0,warning:!0,textPrimary:!0,textSecondary:!0,textDisabled:!0},nte=t=>{const{classes:e,component:n,focusVisible:r,underline:o}=t,i={root:["root",`underline${Pe(o)}`,n==="button"&&"button",r&&"focusVisible"]};return Ue(i,Qee,e)},rte=oe(Ro,{name:"MuiLink",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[`underline${Pe(n.underline)}`],n.component==="button"&&e.button]}})(vt(({theme:t})=>({variants:[{props:{underline:"none"},style:{textDecoration:"none"}},{props:{underline:"hover"},style:{textDecoration:"none","&:hover":{textDecoration:"underline"}}},{props:{underline:"always"},style:{textDecoration:"underline","&:hover":{textDecorationColor:"inherit"}}},{props:({underline:e,ownerState:n})=>e==="always"&&n.color!=="inherit",style:{textDecorationColor:"var(--Link-underlineColor)"}},...Object.entries(t.palette).filter(Ln()).map(([e])=>({props:{underline:"always",color:e},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette[e].mainChannel} / 0.4)`:ot(t.palette[e].main,.4)}})),{props:{underline:"always",color:"textPrimary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.primaryChannel} / 0.4)`:ot(t.palette.text.primary,.4)}},{props:{underline:"always",color:"textSecondary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.secondaryChannel} / 0.4)`:ot(t.palette.text.secondary,.4)}},{props:{underline:"always",color:"textDisabled"},style:{"--Link-underlineColor":(t.vars||t).palette.text.disabled}},{props:{component:"button"},style:{position:"relative",WebkitTapHighlightColor:"transparent",backgroundColor:"transparent",outline:0,border:0,margin:0,borderRadius:0,padding:0,cursor:"pointer",userSelect:"none",verticalAlign:"middle",MozAppearance:"none",WebkitAppearance:"none","&::-moz-focus-inner":{borderStyle:"none"},[`&.${ete.focusVisible}`]:{outline:"auto"}}}]}))),oI=D.forwardRef(function(e,n){const r=mt({props:e,name:"MuiLink"}),o=Oo(),{className:i,color:s="primary",component:a="a",onBlur:l,onFocus:u,TypographyClasses:f,underline:p="always",variant:m="inherit",sx:b,...v}=r,[y,x]=D.useState(!1),C=O=>{El(O.target)||x(!1),l&&l(O)},k=O=>{El(O.target)&&x(!0),u&&u(O)},T={...r,color:s,component:a,focusVisible:y,underline:p,variant:m},S=nte(T);return g.jsx(rte,{color:s,className:ye(S.root,i),classes:f,component:a,onBlur:C,onFocus:k,ref:n,ownerState:T,variant:m,...v,sx:[...Lk[s]===void 0?[{color:s}]:[],...Array.isArray(b)?b:[b]],style:{...v.style,...p==="always"&&s!=="inherit"&&!Lk[s]&&{"--Link-underlineColor":tte({theme:o,ownerState:T})}}})});process.env.NODE_ENV!=="production"&&(oI.propTypes={children:c.node,classes:c.object,className:c.string,color:c.oneOfType([c.oneOf(["primary","secondary","success","error","info","warning","textPrimary","textSecondary","textDisabled"]),c.string]),component:Hl,onBlur:c.func,onFocus:c.func,style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),TypographyClasses:c.object,underline:c.oneOf(["always","hover","none"]),variant:c.oneOfType([c.oneOf(["body1","body2","button","caption","h1","h2","h3","h4","h5","h6","inherit","overline","subtitle1","subtitle2"]),c.string])});var $y={},Ly={},Bk;function ote(){return Bk||(Bk=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(Ly)),Ly}var Fk;function ite(){return Fk||(Fk=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ote(),n=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/;function r(i,s){i=i!=null?`${i}`:"";let a=30,l="...";e.isObject(s)&&(a=o(s.length),l="omission"in s?`${s.omission}`:"...");let u=i.length;const f=Array.from(l).length,p=Math.max(a-f,0);let m;if(n.test(i)&&(m=Array.from(i),u=m.length),a>=u)return i;if(u<=f)return l;let v=m===void 0?i.slice(0,p):m==null?void 0:m.slice(0,p).join("");const y=s==null?void 0:s.separator;if(!y)return v+=l,v;const x=y instanceof RegExp?y.source:y,C="u"+(y instanceof RegExp?y.flags.replace("u",""):""),k=new RegExp(`(?<result>.*(?:(?!${x}).))(?:${x})`,C).exec(v);return(k!=null&&k.groups?k.groups.result:v)+l}function o(i){return i==null?30:i<=0?0:i}t.truncate=r})($y)),$y}var By,Vk;function ste(){return Vk||(Vk=1,By=ite().truncate),By}var ate=ste();const lte=Qn(ate),Fy=Zt("ViewLinkMenuContent",["root","linkPreviewText"]),Yv=qt("ViewLinkMenuContent"),cte=oe("div",{name:Yv,slot:"root",overridesResolver:(t,e)=>e.root})({}),zk=oe("div",{name:Yv,slot:"linkPreviewText",overridesResolver:(t,e)=>e.linkPreviewText})({overflowWrap:"anywhere"});function ute(t){var e,n,r;const o=rt({props:t,name:Yv}),{editor:i,onCancel:s,onEdit:a,onRemove:l,labels:u,classes:f={},sx:p}=o,m=$u(i.state.selection.$to,Mo("link",i.schema)),b=m?i.state.doc.textBetween(m.from,m.to):"",v=(e=i.getAttributes("link").href)!==null&&e!==void 0?e:"";return rI("Escape",s),g.jsxs(cte,{className:ye([Fy.root,f.root]),sx:p,children:[g.jsx(zk,{className:ye([Fy.linkPreviewText,f.linkPreviewText]),children:lte(b,{length:50,omission:"…"})}),g.jsx(zk,{className:ye([Fy.linkPreviewText,f.linkPreviewText]),children:g.jsx(oI,{href:v,target:"_blank",rel:"noopener",children:gX(v,50)})}),g.jsxs(em,{sx:{px:0},children:[g.jsx(so,{onClick:a,color:"primary",variant:"outlined",size:"small",children:(n=u==null?void 0:u.viewLinkEditButtonLabel)!==null&&n!==void 0?n:"Edit"}),g.jsx(so,{onClick:l,color:"error",variant:"outlined",size:"small",children:(r=u==null?void 0:u.viewLinkRemoveButtonLabel)!==null&&r!==void 0?r:"Remove"})]})]})}const iI=qt("LinkBubbleMenu"),dte=oe("div",{name:iI,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({padding:t.spacing(1.5,2,.5)}));function fte(t){const e=rt({props:t,name:iI}),{labels:n,formatHref:r,classes:o={},sx:i,...s}=e,a=kt();if(!(a!=null&&a.isEditable))return null;if(!("linkBubbleMenuHandler"in a.storage))throw new Error("You must add the LinkBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const l=a.storage.linkBubbleMenuHandler,u=l.state;let f=null;return u===ur.VIEW_LINK_DETAILS?f=g.jsx(ute,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onEdit:a.commands.editLinkInBubbleMenu,onRemove:()=>{a.chain().unsetLink().setTextSelection(a.state.selection.to).focus().run()},labels:n}):u===ur.EDIT_LINK&&(f=g.jsx(Zee,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onSave:({text:p,link:m})=>{a.chain().extendMarkRange("link").insertContent({type:"text",marks:[{type:"link",attrs:{href:m}}],text:p}).setLink({href:m}).focus().run(),a.commands.closeLinkBubbleMenu()},labels:n,formatHref:r})),g.jsx(wv,{editor:a,open:u!==ur.HIDDEN,...l.bubbleMenuOptions,...s,classes:{root:ye([jy.root,o.root]),paper:ye([jy.paper,o.paper])},sx:i,children:g.jsx(dte,{className:ye([jy.content,o.content]),children:f})})}function pte(t){return qe("MuiCollapse",t)}He("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const hte=t=>{const{orientation:e,classes:n}=t,r={root:["root",`${e}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${e}`],wrapperInner:["wrapperInner",`${e}`]};return Ue(r,pte,n)},mte=oe("div",{name:"MuiCollapse",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.orientation],n.state==="entered"&&e.entered,n.state==="exited"&&!n.in&&n.collapsedSize==="0px"&&e.hidden]}})(vt(({theme:t})=>({height:0,overflow:"hidden",transition:t.transitions.create("height"),variants:[{props:{orientation:"horizontal"},style:{height:"auto",width:0,transition:t.transitions.create("width")}},{props:{state:"entered"},style:{height:"auto",overflow:"visible"}},{props:{state:"entered",orientation:"horizontal"},style:{width:"auto"}},{props:({ownerState:e})=>e.state==="exited"&&!e.in&&e.collapsedSize==="0px",style:{visibility:"hidden"}}]}))),gte=oe("div",{name:"MuiCollapse",slot:"Wrapper",overridesResolver:(t,e)=>e.wrapper})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),yte=oe("div",{name:"MuiCollapse",slot:"WrapperInner",overridesResolver:(t,e)=>e.wrapperInner})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),Sp=D.forwardRef(function(e,n){const r=mt({props:e,name:"MuiCollapse"}),{addEndListener:o,children:i,className:s,collapsedSize:a="0px",component:l,easing:u,in:f,onEnter:p,onEntered:m,onEntering:b,onExit:v,onExited:y,onExiting:x,orientation:C="vertical",style:k,timeout:T=GO.standard,TransitionComponent:S=zr,...O}=r,R={...r,orientation:C,collapsedSize:a},P=hte(R),j=Oo(),F=ta(),M=D.useRef(null),$=D.useRef(),z=typeof a=="number"?`${a}px`:a,L=C==="horizontal",A=L?"width":"height",_=D.useRef(null),I=Et(n,_),B=te=>ce=>{if(te){const ne=_.current;ce===void 0?te(ne):te(ne,ce)}},W=()=>M.current?M.current[L?"clientWidth":"clientHeight"]:0,K=B((te,ce)=>{M.current&&L&&(M.current.style.position="absolute"),te.style[A]=z,p&&p(te,ce)}),U=B((te,ce)=>{const ne=W();M.current&&L&&(M.current.style.position="");const{duration:re,easing:le}=Pl({style:k,timeout:T,easing:u},{mode:"enter"});if(T==="auto"){const ge=j.transitions.getAutoHeightDuration(ne);te.style.transitionDuration=`${ge}ms`,$.current=ge}else te.style.transitionDuration=typeof re=="string"?re:`${re}ms`;te.style[A]=`${ne}px`,te.style.transitionTimingFunction=le,b&&b(te,ce)}),Y=B((te,ce)=>{te.style[A]="auto",m&&m(te,ce)}),fe=B(te=>{te.style[A]=`${W()}px`,v&&v(te)}),ue=B(y),pe=B(te=>{const ce=W(),{duration:ne,easing:re}=Pl({style:k,timeout:T,easing:u},{mode:"exit"});if(T==="auto"){const le=j.transitions.getAutoHeightDuration(ce);te.style.transitionDuration=`${le}ms`,$.current=le}else te.style.transitionDuration=typeof ne=="string"?ne:`${ne}ms`;te.style[A]=z,te.style.transitionTimingFunction=re,x&&x(te)}),Z=te=>{T==="auto"&&F.start($.current||0,te),o&&o(_.current,te)};return g.jsx(S,{in:f,onEnter:K,onEntered:Y,onEntering:U,onExit:fe,onExited:ue,onExiting:pe,addEndListener:Z,nodeRef:_,timeout:T==="auto"?null:T,...O,children:(te,{ownerState:ce,...ne})=>g.jsx(mte,{as:l,className:ye(P.root,s,{entered:P.entered,exited:!f&&z==="0px"&&P.hidden}[te]),style:{[L?"minWidth":"minHeight"]:z,...k},ref:I,ownerState:{...R,state:te},...ne,children:g.jsx(gte,{ownerState:{...R,state:te},className:P.wrapper,ref:M,children:g.jsx(yte,{ownerState:{...R,state:te},className:P.wrapperInner,children:i})})})})});process.env.NODE_ENV!=="production"&&(Sp.propTypes={addEndListener:c.func,children:c.node,classes:c.object,className:c.string,collapsedSize:c.oneOfType([c.number,c.string]),component:Hl,easing:c.oneOfType([c.shape({enter:c.string,exit:c.string}),c.string]),in:c.bool,onEnter:c.func,onEntered:c.func,onEntering:c.func,onExit:c.func,onExited:c.func,onExiting:c.func,orientation:c.oneOf(["horizontal","vertical"]),style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),timeout:c.oneOfType([c.oneOf(["auto"]),c.number,c.shape({appear:c.number,enter:c.number,exit:c.number})])});Sp&&(Sp.muiSupportAuto=!0);const bf=Zt("MenuBar",["root","sticky","nonSticky","content"]),Gv=qt("MenuBar"),bte=oe(Sp,{name:Gv,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.disableSticky?e.nonSticky:e.sticky]})(({theme:t,ownerState:e})=>({borderBottomColor:t.palette.divider,borderBottomStyle:"solid",borderBottomWidth:1,...e.disableSticky?{}:{position:"sticky",top:e.stickyOffset,zIndex:gp.MENU_BAR,background:t.palette.background.default}})),vte=oe("div",{name:Gv,slot:"content",overridesResolver:(t,e)=>e.content})({});function xte(t){const e=rt({props:t,name:Gv}),{hide:n,disableSticky:r,stickyOffset:o=0,children:i,className:s,classes:a={},unmountOnExit:l=!0,sx:u,...f}=e,p={hide:n,disableSticky:r,stickyOffset:o,unmountOnExit:l};return g.jsx(bte,{...f,in:!n,unmountOnExit:l,className:ye([bf.root,a.root,r?[bf.nonSticky,a.nonSticky]:[bf.sticky,a.sticky],s]),ownerState:p,sx:u,children:g.jsx(vte,{className:ye([bf.content,a.content]),ownerState:p,children:i})})}const Vy=Zt("RichTextContent",["root","readonly","editable"]),sI=qt("RichTextContent"),wte=oe(iQ,{name:sI,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.editable?e.editable:e.readonly]})(({theme:t,ownerState:e})=>e.disableDefaultStyles?{}:{"& .ProseMirror":{...Da(t)}});function aI(t){const e=rt({props:t,name:sI}),{innerRef:n,className:r,classes:o={},disableDefaultStyles:i=!1,sx:s}=e,a=kt(),l=!!(a!=null&&a.isEditable),u={editable:l,disableDefaultStyles:i},f=J.useMemo(()=>ye([Vy.root,r,o.root,l?[Vy.editable,o.editable]:[Vy.readonly,o.readonly]]),[r,o.root,o.editable,o.readonly,l]);return g.jsx(wte,{editor:a,...n?{innerRef:n}:{},ownerState:u,className:f,sx:s})}function lI({editor:t,children:e}){return g.jsx(vR.Provider,{value:t,children:e})}const zo=Zt("RichTextField",["root","standard","outlined","menuBar","menuBarContent","content"]),cI=qt("RichTextField"),Cte=oe(Yee,{name:cI,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard]})(({theme:t,ownerState:e})=>({...e.variant==="standard"&&{[`& .${zo.content}`]:{padding:t.spacing(1.5,0)},[`& .${zo.menuBarContent}`]:{padding:t.spacing(1,0)}},...e.variant==="outlined"&&{[`& .${zo.content}`]:{padding:t.spacing(1.5)},[`& .${zo.menuBarContent}`]:{padding:t.spacing(1,1.5)}}}));function Ste(t){var e,n;const r=rt({props:t,name:cI}),{variant:o="outlined",controls:i,disableDebounceRenderControls:s=!1,disabled:a,className:l,classes:u={},footer:f,MenuBarProps:p,RichTextContentProps:m,sx:b,...v}=r,y=kt(),x={variant:o,disabled:a,disableDebounceRenderControls:s},C=nI({editor:y});return g.jsxs(Cte,{...v,variant:o,focused:!a&&C,disabled:a,className:ye([zo.root,u.root,o==="outlined"?[zo.outlined,u.outlined]:[zo.standard,u.standard],l]),ownerState:x,sx:b,children:[i&&g.jsx(xte,{...p,classes:{...p==null?void 0:p.classes,root:ye([zo.menuBar,u.menuBar,(e=p==null?void 0:p.classes)===null||e===void 0?void 0:e.root]),content:ye([zo.menuBarContent,u.menuBarContent,(n=p==null?void 0:p.classes)===null||n===void 0?void 0:n.content])},children:s?i:g.jsx(Lv,{children:i})}),g.jsx(aI,{...m,className:ye([zo.content,u.content,m==null?void 0:m.className])}),f]})}const uI=J.forwardRef(function({className:e,renderControls:n,RichTextFieldProps:r={},sx:o,children:i,editorDependencies:s=[],editable:a=!0,shouldRerenderOnTransaction:l=!0,...u},f){const p={editable:a,shouldRerenderOnTransaction:l,...u},m=F2(p,s);return J.useImperativeHandle(f,()=>({editor:m}),[m]),J.useEffect(()=>{!m||m.isDestroyed||m.isEditable===a||queueMicrotask(()=>{m.setEditable(a)})},[a,m]),g.jsxs(lI,{editor:m,children:[g.jsx(Ste,{disabled:!a,controls:n==null?void 0:n(m),className:e,sx:o,...r}),i==null?void 0:i(m)]})});function Tte({RichTextContentProps:t,sx:e,...n}){const r=F2({...n,editable:!1}),o=J.useRef(n.content);return J.useEffect(()=>{!r||r.isDestroyed||n.content===void 0||n.content===o.current||queueMicrotask(()=>{n.content!==void 0&&r.commands.setContent(n.content)})},[n.content,r]),J.useEffect(()=>{o.current=n.content},[n.content]),g.jsx(lI,{editor:r,children:g.jsx(aI,{sx:e,...t})})}function dI(t){return t.content?g.jsx(Tte,{...t}):null}const zy=Zt("TableBubbleMenu",["root","paper","content"]),fI=qt("TableBubbleMenu"),kte=oe(wZ,{name:fI,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({maxWidth:"90vw",padding:t.spacing(.5,1)}));function Ete(t){const e=rt({props:t,name:fI}),{disableDebounce:n=!1,DebounceProps:r,labels:o,classes:i={},...s}=e,a=kt(),l=nI({editor:a}),u=J.useMemo(()=>a?{getBoundingClientRect:()=>{const p=a.isActive("table")?ov(a.state.selection.$anchor,y=>y.type.name==="table"):null;if(p){const y=a.view.nodeDOM(p.pos),x=y==null?void 0:y.querySelector("table");if(x)return x.getBoundingClientRect()}const{ranges:m}=a.state.selection,b=Math.min(...m.map(y=>y.$from.pos)),v=Math.max(...m.map(y=>y.$to.pos));return q_(a.view,b,v)}}:null,[a]);if(!(a!=null&&a.isEditable))return null;const f=g.jsx(kte,{className:ye([zy.content,i.content]),labels:o});return g.jsx(wv,{editor:a,open:l&&a.isActive("table"),anchorEl:u,placement:"top-start",fallbackPlacements:["bottom-start","top","bottom","top-end","bottom-end"],flipPadding:{top:35,left:8,right:8,bottom:-1/0},...s,classes:{root:ye([zy.root,i.root]),paper:ye([zy.paper,i.paper])},children:n?f:g.jsx(Lv,{...r,children:f})})}const Jv=Or.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Tt(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),pI=Or.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Tt(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Hy,Hk;function Ote(){return Hk||(Hk=1,Hy=(function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(r,o,i){n.o(r,o)||Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:i})},n.r=function(r){Object.defineProperty(r,"__esModule",{value:!0})},n.n=function(r){var o=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(o,"a",o),o},n.o=function(r,o){return Object.prototype.hasOwnProperty.call(r,o)},n.p="/dist/",n(n.s=1)})([function(t,e,n){n.r(e);var r={equal:0,delete:1,insert:2,none:3,replace:4};class o{constructor(A,_,I){this.startInOld=A,this.startInNew=_,this.size=I}get endInOld(){return this.startInOld+this.size}get endInNew(){return this.startInNew+this.size}}class i{constructor(){this.blockSize=0,this.repeatingWordsAccuracy=0,this.ignoreWhitespaceDifferences=!1}}const s=/^\s*<\/?[^>]+>\s*$/,a=/<[^\s>]+/,l=/^(\s| )+$/,u=/[\w\#@]+/,f=["<img"];function p(L){return!f.some(A=>L!==null&&L.startsWith(A))&&s.test(L)}function m(L,A,_){return["<",A,' class="',_,'">',L,"</",A,">"].join("")}function b(L){return L==="<"}function v(L){return L==="&"}function y(L){return L===";"}function x(L){return l.test(L)}function C(L){return p(L)?(function(A){return A=a.exec(A)[0]+(A.endsWith("/>")?"/>":">")})(L):L}function k(L){return u.test(L)}function T(L,A,_){return L.push(A),L.length>_&&L.shift(),L.length!==_?null:L.join("")}class S{constructor(A,_,I,B,W,K,U){this.oldWords=A,this.newWords=_,this.startInOld=I,this.endInOld=B,this.startInNew=W,this.endInNew=K,this.options=U}indexNewWords(){this.wordIndices=new Map;let A=[];for(let _=this.startInNew;_<this.endInNew;_++){let I=T(A,this.normalizeForIndex(this.newWords[_]),this.options.blockSize);I!==null&&(this.wordIndices.has(I)?this.wordIndices.get(I).push(_):this.wordIndices.set(I,[_]))}}normalizeForIndex(A){return A=C(A),this.options.IgnoreWhiteSpaceDifferences&&x(A)?" ":A}findMatch(){if(this.indexNewWords(),this.removeRepeatingWords(),this.wordIndices.length===0)return null;let A=this.startInOld,_=this.startInNew,I=0,B=new Map;const W=this.options.blockSize;let K=[];for(let U=this.startInOld;U<this.endInOld;U++){let Y=T(K,this.normalizeForIndex(this.oldWords[U]),W);if(Y===null)continue;let fe=new Map;if(this.wordIndices.has(Y)){for(let ue of this.wordIndices.get(Y)){let pe=(B.has(ue-1)?B.get(ue-1):0)+1;fe.set(ue,pe),pe>I&&(A=U-pe-W+2,_=ue-pe-W+2,I=pe)}B=fe}else B=fe}return I!==0?new o(A,_,I+W-1):null}removeRepeatingWords(){let A=this.newWords.length+this.options.repeatingWordsAccuracy,_=Array.from(this.wordIndices.entries()).filter(I=>I[1].length>A).map(I=>I[0]);for(let I of _)this.wordIndices.delete(I)}}class O{constructor(A,_,I,B,W){this.action=A,this.startInOld=_,this.endInOld=I,this.startInNew=B,this.endInNew=W}}var R={character:0,tag:1,whitespace:2,entity:3};function P(L,A){let _={mode:R.character,currentWord:[],words:[]},I=(function(Y,fe){let ue=new Map;if(fe===null)return ue;for(let pe of fe){let Z;for(;(Z=pe.exec(Y))!==null;){if(ue.has(Z.index))throw new Error("One or more block expressions result in a text sequence that overlaps. Current expression: "+pe.toString());ue.set(Z.index,Z.index+Z[0].length)}}return ue})(L,A),B=!!I.size,W=!1,K=-1;for(let Y=0;Y<L.length;Y++){var U=L[Y];if(B&&(K===index&&(K=-1,W=!1),I.has(index)&&(W=!0,K=I.get(index)),W)){_.currentWord.push(U),_.mode=R.character;continue}switch(_.mode){case R.character:b(U)?j(_,"<",R.tag):v(U)?j(_,U,R.entity):x(U)?j(_,U,R.whitespace):k(U)&&(_.currentWord.length===0||k(_.currentWord[_.currentWord.length-1]))?_.currentWord.push(U):j(_,U,R.character);break;case R.tag:U===">"?(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.currentWord=[],_.mode=x(U)?R.whitespace:R.character):_.currentWord.push(U);break;case R.whitespace:b(U)?j(_,U,R.tag):v(U)?j(_,U,R.entity):x(U)?_.currentWord.push(U):j(_,U,R.character);break;case R.entity:if(b(U))j(_,U,R.tag);else if(x(U))j(_,U,R.whitespace);else if(y(U)){let fe=!0;if(_.currentWord.length!==0&&(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.words.length>2&&x(_.words[_.words.length-2])&&x(_.words[_.words.length-1]))){let ue=_.words[_.words.length-2],pe=_.words[_.words.length-1];_.words.splice(_.words.length-2,2),_.currentWord=[(ue+pe).split()],_.mode=R.whitespace,fe=!1}fe&&(_.currentWord=[],_.mode=R.character)}else k(U)?_.currentWord.push(U):j(_,U,R.character)}}return _.currentWord.length!==0&&_.words.push(_.currentWord.join("")),_.words}function j(L,A,_){L.currentWord.length!==0&&L.words.push(L.currentWord.join("")),L.currentWord=[A],L.mode=_}const F=4,M=new Map([["</strong>",0],["</em>",0],["</b>",0],["</i>",0],["</big>",0],["</small>",0],["</u>",0],["</sub>",0],["</strike>",0],["</s>",0]]),$=/<((strong)|(b)|(i)|(em)|(big)|(small)|(u)|(sub)|(sup)|(strike)|(s))[\>\s]+/gi;class z{constructor(A,_){this.content=[],this.newText=_,this.oldText=A,this.specialTagDiffStack=[],this.newWords=[],this.oldWords=[],this.matchGranularity=0,this.blockExpressions=[],this.repeatingWordsAccuracy=1,this.ignoreWhiteSpaceDifferences=!1,this.orphanMatchThreshold=0}build(){if(this.oldText===this.newText)return this.newText;this.splitInputsIntoWords(),this.matchGranularity=Math.min(F,this.oldWords.length,this.newWords.length);let A=this.operations();for(let _ of A)this.performOperation(_);return this.content.join("")}addBlockExpression(A){this.blockExpressions.push(A)}splitInputsIntoWords(){this.oldWords=P(this.oldText,this.blockExpressions),this.oldText=null,this.newWords=P(this.newText,this.blockExpressions),this.newText=null}performOperation(A){switch(A.action){case r.equal:this.processEqualOperation(A);break;case r.delete:this.processDeleteOperation(A,"diffdel");break;case r.insert:this.processInsertOperation(A,"diffins");break;case r.none:break;case r.replace:this.processReplaceOperation(A)}}processReplaceOperation(A){this.processDeleteOperation(A,"diffmod"),this.processInsertOperation(A,"diffmod")}processInsertOperation(A,_){let I=this.newWords.filter((B,W)=>W>=A.startInNew&&W<A.endInNew);this.insertTag("ins",_,I)}processDeleteOperation(A,_){let I=this.oldWords.filter((B,W)=>W>=A.startInOld&&W<A.endInOld);this.insertTag("del",_,I)}processEqualOperation(A){let _=this.newWords.filter((I,B)=>B>=A.startInNew&&B<A.endInNew);this.content.push(_.join(""))}insertTag(A,_,I){for(;I.length;){let B=this.extractConsecutiveWords(I,U=>!p(U)),W="",K=!1;if(B.length!==0){let U=m(B.join(""),A,_);this.content.push(U)}else{if($.test(I[0])){if(this.specialTagDiffStack.push(I[0]),W='<ins class="mod">',A==="del")for(I.shift();I.length>0&&$.test(I[0]);)I.shift()}else if(M.has(I[0])){let U=this.specialTagDiffStack.length===0?null:this.specialTagDiffStack.pop();if(U!==null&&U===I[0].replace(/\//g,"")&&(W="</ins>",K=!0),A==="del")for(I.shift();I.length>0&&M.has(I[0]);)I.shift()}if(I.length===0&&W.length===0)break;K?this.content.push(W+this.extractConsecutiveWords(I,p).join("")):this.content.push(this.extractConsecutiveWords(I,p).join("")+W)}}}extractConsecutiveWords(A,_){let I=null;for(let B=0;B<A.length;B++){let W=A[B];if(B===0&&W===" "&&(A[B]=" "),!_(W)){I=B;break}}if(I!==null){let B=A.filter((W,K)=>K>=0&&K<I);return I>0&&A.splice(0,I),B}{let B=A.filter((W,K)=>K>=0&&K<A.length);return A.splice(0,A.length),B}}operations(){let A=0,_=0,I=[],B=this.matchingBlocks();B.push(new o(this.oldWords.length,this.newWords.length,0));let W=this.removeOrphans(B);for(let K of W){let U,Y=A===K.startInOld,fe=_===K.startInNew;(U=Y||fe?Y&&!fe?r.insert:Y?r.none:r.delete:r.replace)!==r.none&&I.push(new O(U,A,K.startInOld,_,K.startInNew)),K.length!==0&&I.push(new O(r.equal,K.startInOld,K.endInOld,K.startInNew,K.endInNew)),A=K.endInOld,_=K.endInNew}return I}*removeOrphans(A){let _=null,I=null;for(let B of A){if(I===null){_=new o(0,0,0),I=B;continue}if(_.endInOld===I.startInOld&&_.endInNew===I.startInNew||I.endInOld===B.startInOld&&I.endInNew===B.startInNew){yield I,_=I,I=B;continue}let W=(Y,fe)=>Y+fe.length,K=this.oldWords.slice(_.endInOld,B.startInOld).reduce(W,0),U=this.newWords.slice(_.endInNew,B.startInNew).reduce(W,0);this.newWords.slice(I.startInNew,I.endInNew).reduce(W,0)>Math.max(K,U)*this.orphanMatchThreshold&&(yield I),_=I,I=B}yield I}matchingBlocks(){let A=[];return this.findMatchingBlocks(0,this.oldWords.length,0,this.newWords.length,A),A}findMatchingBlocks(A,_,I,B,W){let K=this.findMatch(A,_,I,B);K!==null&&(A<K.startInOld&&I<K.startInNew&&this.findMatchingBlocks(A,K.startInOld,I,K.startInNew,W),W.push(K),K.endInOld<_&&K.endInNew<B&&this.findMatchingBlocks(K.endInOld,_,K.endInNew,B,W))}findMatch(A,_,I,B){for(let W=this.matchGranularity;W>0;W--){let K=new i;K.blockSize=W,K.repeatingWordsAccuracy=this.repeatingWordsAccuracy,K.ignoreWhitespaceDifferences=this.ignoreWhiteSpaceDifferences;let U=new S(this.oldWords,this.newWords,A,_,I,B,K).findMatch();if(U!==null)return U}return null}}z.execute=function(L,A){return new z(L,A).build()},e.default=z},function(t,e,n){t.exports=n(0)}])),Hy}var Mte=Ote();const _te=Qn(Mte),Tp="rgba(194, 249, 112, .5)",kp="rgba(196, 77,86,0.3)",hI=t=>{const{beforeTxt:e="",afterTxt:n="",mode:r="sentence"}=t,o=Rte(e,n,r);return g.jsx(dI,{content:o,extensions:[yR,Jv,bR.configure({multicolor:!0}),pI]})},Rte=(t,e,n)=>{switch(n){case"sentence":return Dte(t,e);case"word":return Ite(t,e);case"html":return Pte(t,e);case"comma":return Ate(t,e)}},Xv=(t,e)=>{const n=Array.isArray(t.value)?t.value.join(", "):t.value;if(!t.added&&!t.removed)return n;const r=t.added?Tp:kp,o=t.added?"u":"s";return`<${o}><mark key={${e}} data-color="${r}" style={{ backgroundColor: ${r}, color: "inherit"}}>${n}</mark></${o}>`},Wk=t=>t.split(",").map(e=>e.trim()),Ite=(t,e)=>jU(t,e).map(Xv).join(""),Dte=(t,e)=>FU(t,e).map(Xv).join(""),Ate=(t,e)=>HU(Wk(t),Wk(e)).map(Xv).join(", "),Pte=(t,e)=>{let n=_te.execute(t,e);return n=n.replaceAll(/<ins class="(diffmod|diffins)">/g,`<u><mark data-color="${Tp}" style={{ backgroundColor: ${Tp}, color: "inherit" }}>`),n=n.replaceAll("</ins>","</mark></u>"),n=n.replaceAll(/<del class="(diffmod|diffdel)">/g,`<s><mark data-color="${kp}" style={{ backgroundColor: ${kp}, color: "inherit" }}>`),n=n.replaceAll("</del>","</mark></s>"),n},Fi=t=>{const{label:e,value:n,readOnlyValue:r,staticLabel:o,staticLabelProps:i,showDiff:s=!1,diffSnapshot:a,diffMode:l,...u}=t,f=()=>s?g.jsx(hI,{beforeTxt:a,afterTxt:n,mode:l,...u}):r||g.jsx(V.Typography,{"data-testid":"read-only-value",children:n});return g.jsxs(V.Box,{width:"100%",mb:"8px",children:[o?g.jsx(V.Typography,{...i,children:e}):g.jsx(V.InputLabel,{children:e}),f()]})},mI=t=>{const{name:e,label:n=Fn(e),options:r=[],filterSelectedOptions:o=!0,variant:i="outlined",staticLabel:s=!1,staticLabelProps:a={fontSize:".9em",color:"#808080"},readOnly:l,margin:u="dense",fullWidth:f=!0,required:p,onChange:m,clearOnSelect:b=!1,onInputChange:v,getOptionLabel:y=B=>typeof B=="string"?B:String(B),isOptionEqualToValue:x=(B,W)=>JSON.stringify(B)===JSON.stringify(W),useFieldAsValue:C,errorMode:k="normal",...T}=t,[S,O,R]=Ht.useField(e),{setValue:P}=R,{error:j}=O,[F,M]=D.useState(""),$={...pr(T,["useFieldAsValue","errorMode"]),getOptionLabel:y,options:r,filterSelectedOptions:o,isOptionEqualToValue:x,renderInput:B=>g.jsx(V.TextField,{...B,variant:i,label:s?void 0:n,error:!!j,required:p}),onChange:(B,W,K,U)=>{b?(M(""),P(null)):P(C?W?W[C]:null:W),m&&m(B,W,K,U)},onInputChange:(B,W,K)=>{M(W),v&&v(B,W,K)},fullWidth:!0,inputValue:F,value:C?r.find(B=>B[C]===S.value)||null:S.value,slotProps:{paper:{elevation:8,sx:{borderRadius:2}}}},z=B=>{if(B==null)return"";if(C){const W=r.find(K=>K[C]===B);return W?y(W):""}return y(B)},L=_a(),A=l??L,{showDiff:_,getPreviousValue:I}=Ra();return A||_?g.jsx(Fi,{label:n,value:z(S.value),staticLabel:s,staticLabelProps:a,showDiff:_,diffSnapshot:z(I(e))}):g.jsxs(V.FormControl,{margin:u,fullWidth:f,required:p,children:[s&&g.jsx(V.Typography,{...a,children:n}),g.jsxs(V.Box,{children:[g.jsx(V.Autocomplete,{...$}),g.jsx(Mr,{name:e,id:`${e}-err`,errorMode:k})]})]})};var Bc={exports:{}};/**
|
|
356
356
|
* @license
|
|
357
357
|
* Lodash <https://lodash.com/>
|
|
358
358
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
package/dist/index.es.js
CHANGED
|
@@ -39234,9 +39234,10 @@ const qne = /* @__PURE__ */ lr(Une), Yp = "rgba(194, 249, 112, .5)", Gp = "rgba(
|
|
|
39234
39234
|
return Xne(t, e);
|
|
39235
39235
|
}
|
|
39236
39236
|
}, P1 = (t, e) => {
|
|
39237
|
-
|
|
39238
|
-
|
|
39239
|
-
|
|
39237
|
+
const n = Array.isArray(t.value) ? t.value.join(", ") : t.value;
|
|
39238
|
+
if (!t.added && !t.removed) return n;
|
|
39239
|
+
const r = t.added ? Yp : Gp, o = t.added ? "u" : "s";
|
|
39240
|
+
return `<${o}><mark key={${e}} data-color="${r}" style={{ backgroundColor: ${r}, color: "inherit"}}>${n}</mark></${o}>`;
|
|
39240
39241
|
}, ME = (t) => t.split(",").map((e) => e.trim()), Gne = (t, e) => Qq(t, e).map(P1).join(""), Jne = (t, e) => rK(t, e).map(P1).join(""), Xne = (t, e) => sK(ME(t), ME(e)).map(P1).join(", "), Zne = (t, e) => {
|
|
39241
39242
|
let n = qne.execute(t, e);
|
|
39242
39243
|
return n = n.replaceAll(
|
package/dist/index.umd.js
CHANGED
|
@@ -353,7 +353,7 @@ img.ProseMirror-separator {
|
|
|
353
353
|
*
|
|
354
354
|
* This source code is licensed under the MIT license found in the
|
|
355
355
|
* LICENSE file in the root directory of this source tree.
|
|
356
|
-
*/var xO;function T9(){return xO||(xO=1,process.env.NODE_ENV!=="production"&&(function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=J,e=Xf;function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,l=t.useDebugValue;function u(f,p,m,b,v){var y=i(null),x;y.current===null?(x={hasValue:!1,value:null},y.current=x):x=y.current;var S=a(function(){var O=!1,I,N,L=function(H){if(!O){O=!0,I=H;var F=b(H);if(v!==void 0&&x.hasValue){var P=x.value;if(v(P,F))return N=P,P}return N=F,F}var _=I,D=N;if(r(_,H))return D;var R=b(H);return v!==void 0&&v(D,R)?D:(I=H,N=R,R)},V=m===void 0?null:m,M=function(){return L(p())},B=V===null?void 0:function(){return L(V())};return[M,B]},[p,m,b,v]),k=S[0],T=S[1],C=o(f,k,T);return s(function(){x.hasValue=!0,x.value=C},[C]),l(C),C}Eb.useSyncExternalStoreWithSelector=u,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)})()),Eb}process.env.NODE_ENV==="production"?Tb.exports=C9():Tb.exports=T9();var k9=Tb.exports;const E9=typeof window<"u"?J.useLayoutEffect:J.useEffect;class O9{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(o=>o())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function M9(t){var e;const[n]=J.useState(()=>new O9(t.editor)),r=k9.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:S9);return E9(()=>n.watch(t.editor),[t.editor,n]),J.useDebugValue(r),r}const wO=process.env.NODE_ENV!=="production",Ob=typeof window>"u",_9=Ob||!!(typeof window<"u"&&window.next);class Mb{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Ob||_9?(wO&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Ob&&wO)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onBeforeCreate)===null||i===void 0?void 0:i.call(o,...r)},onBlur:(...r)=>{var o,i;return(i=(o=this.options.current).onBlur)===null||i===void 0?void 0:i.call(o,...r)},onCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onCreate)===null||i===void 0?void 0:i.call(o,...r)},onDestroy:(...r)=>{var o,i;return(i=(o=this.options.current).onDestroy)===null||i===void 0?void 0:i.call(o,...r)},onFocus:(...r)=>{var o,i;return(i=(o=this.options.current).onFocus)===null||i===void 0?void 0:i.call(o,...r)},onSelectionUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onSelectionUpdate)===null||i===void 0?void 0:i.call(o,...r)},onTransaction:(...r)=>{var o,i;return(i=(o=this.options.current).onTransaction)===null||i===void 0?void 0:i.call(o,...r)},onUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onUpdate)===null||i===void 0?void 0:i.call(o,...r)},onContentError:(...r)=>{var o,i;return(i=(o=this.options.current).onContentError)===null||i===void 0?void 0:i.call(o,...r)},onDrop:(...r)=>{var o,i;return(i=(o=this.options.current).onDrop)===null||i===void 0?void 0:i.call(o,...r)},onPaste:(...r)=>{var o,i;return(i=(o=this.options.current).onPaste)===null||i===void 0?void 0:i.call(o,...r)}};return new l3(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((o,i)=>{var s;return o===((s=n.extensions)===null||s===void 0?void 0:s[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Mb.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,o)=>r===e[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function SO(t={},e=[]){const n=J.useRef(t);n.current=t;const[r]=J.useState(()=>new Mb(n)),o=Xf.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return J.useDebugValue(o),J.useEffect(r.onRender(e)),M9({editor:o,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&i===0?0:i+1}),o}J.createContext({editor:null}).Consumer;const CO=J.createContext({onDragStart:void 0}),TO=()=>J.useContext(CO),I9=t=>{const e=t.as||"div",{nodeViewContentRef:n}=TO();return J.createElement(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style}})},_b=J.forwardRef((t,e)=>{const{onDragStart:n}=TO(),r=t.as||"div";return J.createElement(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function kO(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function EO(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function D9(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function A9(t){if(kO(t)||EO(t))return!0;if(D9(t)){const e=t.type;if(e)return kO(e)||EO(e)}return!1}function P9(){try{if(J.version)return parseInt(J.version.split(".")[0],10)>=19}catch{}return!1}class OO{constructor(e,{editor:n,props:r={},as:o="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=n,this.props=r,this.element=document.createElement(o),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?Ps.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var e;const n=this.component,r=this.props,o=this.editor,i=P9(),s=A9(n),a={...r};a.ref&&!(i||s)&&delete a.ref,!a.ref&&(i||s)&&(a.ref=l=>{this.ref=l}),this.reactElement=J.createElement(n,{...a}),(e=o==null?void 0:o.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const n=this.editor;(e=n==null?void 0:n.contentComponent)===null||e===void 0||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach(n=>{this.element.setAttribute(n,e[n])})}}class N9 extends c3{constructor(e,n,r){if(super(e,n,r),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const o=this.dom.querySelector("[data-node-view-content]");if(!o)return;o.appendChild(this.contentDOMElement)}}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(u={})=>this.updateAttributes(u),deleteNode:()=>this.deleteNode(),ref:J.createRef()};if(!this.component.displayName){const u=f=>f.charAt(0).toUpperCase()+f.substring(1);this.component.displayName=u(this.extension.name)}const o={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:u=>{u&&this.contentDOMElement&&u.firstChild!==this.contentDOMElement&&(u.hasAttribute("data-node-view-wrapper")&&u.removeAttribute("data-node-view-wrapper"),u.appendChild(this.contentDOMElement))}},i=this.component,s=J.memo(u=>J.createElement(CO.Provider,{value:o},J.createElement(i,u)));s.displayName="ReactNodeView";let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new OO(s,{editor:this.editor,props:e,as:a,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:n}=this.editor.state.selection,r=this.getPos();if(typeof r=="number")if(e<=r&&n>=r+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,n,r){const o=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=n,this.innerDecorations=r,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:n,oldInnerDecorations:a,innerDecorations:r,updateProps:()=>o({node:e,decorations:n,innerDecorations:r})})}return e===this.node&&this.decorations===n&&this.innerDecorations===r||(this.node=e,this.decorations=n,this.innerDecorations=r,o({node:e,decorations:n,innerDecorations:r})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){const n=this.editor.extensionManager.attributes,r=Zd(this.node,n);e=this.options.attrs({node:this.node,HTMLAttributes:r})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function Ib(t,e){return n=>n.editor.contentComponent?new N9(t,n,e):{}}const lu=Xt("HeadingWithAnchorComponent",["root","container","link","linkIcon"]),cu=Ut("HeadingWithAnchorComponent"),$9=oe(_b,{name:cu,slot:"root",overridesResolver:(t,e)=>e.root,shouldForwardProp:t=>t!=="ownerState"&&t!=="theme"&&t!=="sx"})({[`&:hover .${lu.link}`]:{opacity:100}}),L9=oe("span",{name:cu,slot:"container",overridesResolver:(t,e)=>e.container})({display:"inline-block",position:"relative"}),B9=oe("a",{name:cu,slot:"link",overridesResolver:(t,e)=>e.link})(({theme:t})=>({position:"absolute",left:-21,color:`${t.palette.text.secondary} !important`,opacity:0,transition:t.transitions.create("opacity"),textDecoration:"none",outline:"none",[t.breakpoints.down("sm")]:{left:-18},'.ProseMirror[contenteditable="true"] &':{display:"none"}})),F9=oe(Hf,{name:cu,slot:"linkIcon",overridesResolver:(t,e)=>e.linkIcon})(({theme:t})=>({transform:"rotate(-45deg)",fontSize:"1.25rem",[t.breakpoints.down("sm")]:{fontSize:"1.15rem"}}));function R9(t){const e=rt({props:t,name:cu}),{editor:n,node:r,extension:o,classes:i={},sx:s}=e,u=`h${o.options.levels.includes(r.attrs.level)?r.attrs.level:o.options.levels[0]}`,f=J.useMemo(()=>jg(n.schema),[n.schema]),p=I6(oT(r,{textSerializers:f}));return g.jsx($9,{as:u,id:p,...o.options.HTMLAttributes,className:ge([lu.root,i.root]),style:{textAlign:r.attrs.textAlign},sx:s,children:g.jsxs(L9,{className:ge([lu.container,i.container]),children:[g.jsx(B9,{href:`#${p}`,contentEditable:!1,className:ge([lu.link,i.link]),children:g.jsx(F9,{className:ge([lu.linkIcon,i.linkIcon])})}),g.jsx(I9,{as:"span"})]})})}const z9=ST.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),scrollToAnchorOnMount:!0}},onCreate(){this.options.scrollToAnchorOnMount&&setTimeout(()=>{V9(this.editor)})},addNodeView(){return Ib(R9)}});function V9(t){if(t.isDestroyed||!("heading"in t.storage))return;const n=window.location.hash.slice(1);if(!n)return;const r=window.document.getElementById(n);r&&t.view.dom.contains(r)&&r.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})}var fr;(function(t){t[t.HIDDEN=0]="HIDDEN",t[t.VIEW_LINK_DETAILS=1]="VIEW_LINK_DETAILS",t[t.EDIT_LINK=2]="EDIT_LINK"})(fr||(fr={}));const H9=cn.create({name:"linkBubbleMenuHandler",addStorage(){return{state:fr.HIDDEN,bubbleMenuOptions:void 0}},addCommands(){return{openLinkBubbleMenu:(t={})=>({editor:e,chain:n,dispatch:r})=>{const o=this.storage.state;let i;return e.isActive("link")?(o!==fr.VIEW_LINK_DETAILS&&n().extendMarkRange("link").focus().run(),i=fr.VIEW_LINK_DETAILS):i=fr.EDIT_LINK,r&&(this.storage.state=i,this.storage.bubbleMenuOptions=t),!0},editLinkInBubbleMenu:()=>({dispatch:t})=>{const e=this.storage.state,n=fr.EDIT_LINK;return e===n?!1:(t&&(this.storage.state=n),!0)},closeLinkBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.state===fr.HIDDEN?!1:(t.focus(),e&&(this.storage.state=fr.HIDDEN),!0)}},onSelectionUpdate(){this.storage.state===fr.EDIT_LINK?this.editor.commands.closeLinkBubbleMenu():this.storage.state===fr.VIEW_LINK_DETAILS&&!this.editor.isActive("link")&&this.editor.commands.closeLinkBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-u":()=>(this.editor.commands.openLinkBubbleMenu(),!0)}},addProseMirrorPlugins(){return[new en({key:new On("handleClickLinkForMenu"),props:{handleClick:(t,e,n)=>{const r=Yg(t.state,"link");return n.target.closest("a")&&r.href&&this.storage.state===fr.HIDDEN?this.editor.commands.openLinkBubbleMenu():this.editor.commands.closeLinkBubbleMenu(),!1}}})]}}),W9=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,j9=tn.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Ct(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[cT({find:W9,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}});var Db={},MO;function U9(){return MO||(MO=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ME();function n(r,o=0,i={}){const{leading:s=!0,trailing:a=!0}=i;return e.debounce(r,o,{leading:s,maxWait:o,trailing:a})}t.throttle=n})(Db)),Db}var Ab,_O;function q9(){return _O||(_O=1,Ab=U9().throttle),Ab}var K9=q9();const Y9=Un(K9),Zf=Xt("ResizableImageComponent",["imageContainer","image","imageSelected","resizer"]),G9=Xt("ResizableImageResizer",["root"]),IO=Ut("ResizableImageResizer"),J9=oe("div",{name:IO,slot:"root",overridesResolver:(t,e)=>e.root})(({theme:t})=>({position:"absolute",bottom:-3,right:-3,width:12,height:12,background:t.palette.primary.main,cursor:"nwse-resize"}));function X9(t){const e=rt({props:t,name:IO}),{onResize:n,className:r,mouseDown:o,setMouseDown:i,classes:s={},sx:a}=e;J.useEffect(()=>{if(!o)return;const u=f=>{n(f)};return window.addEventListener("mousemove",u),()=>{window.removeEventListener("mousemove",u)}},[o,n]),J.useEffect(()=>{const u=()=>{i(!1)};return window.addEventListener("mouseup",u),()=>{window.removeEventListener("mouseup",u)}},[i]);const l=J.useCallback(u=>{u.preventDefault(),u.stopPropagation(),i(!0)},[i]);return g.jsx(J9,{className:ge([G9.root,r,s.root]),onMouseDown:l,sx:a})}const Z9=15,Qf=Ut("ResizableImageComponent"),Q9=oe("div",{name:Qf,slot:"imageContainer",overridesResolver:(t,e)=>e.imageContainer})(()=>({display:"inline-flex",position:"relative"})),e8=oe("img",{name:Qf,slot:"image",overridesResolver:(t,e)=>[e.image,t.ownerState.selectedOrResizing&&e.imageSelected]})(({theme:t,ownerState:e})=>({display:"block",...e.selectedOrResizing&&{outline:`3px solid ${t.palette.primary.main}`}})),t8=oe(X9,{name:Qf,slot:"resizer",overridesResolver:(t,e)=>e.resizer})(()=>({'.ProseMirror[contenteditable="false"] &':{display:"none"}}));function n8(t){var e,n,r;const o=rt({props:t,name:Qf}),{node:i,selected:s,updateAttributes:a,extension:l,classes:u={},sx:f}=o,{attrs:p}=i,m=J.useRef(null),[b,v]=J.useState(!1),y=s||b,x={selected:s,selectedOrResizing:y},S=J.useMemo(()=>Y9(T=>{if(!m.current)return;const C=m.current.getBoundingClientRect(),O=T.clientX-C.x,I=T.clientY-C.y,N=Math.max(O,C.width/C.height*I,Z9);a({width:Math.round(N)})},50,{trailing:!0}),[a]),k=l.options.ChildComponent;return g.jsx(_b,{style:{textAlign:p.textAlign,width:"100%"},as:l.options.inline?"span":"div",sx:f,children:g.jsxs(Q9,{className:ge([Zf.imageContainer,u.imageContainer]),children:[g.jsx(e8,{ref:m,src:p.src,height:"auto",width:p.width?p.width:void 0,alt:(e=p.alt)!==null&&e!==void 0?e:void 0,title:(n=p.title)!==null&&n!==void 0?n:void 0,className:ge([Zf.image,u.image,y&&"ProseMirror-selectednode",y&&[Zf.imageSelected,u.imageSelected]]),style:{maxWidth:p.width?void 0:"auto",aspectRatio:(r=p.aspectRatio)!==null&&r!==void 0?r:void 0},ownerState:x,"data-drag-handle":!0,onLoad:T=>{const C={};p.width||(C.width=T.currentTarget.naturalWidth),p.aspectRatio||(C.aspectRatio=String(T.currentTarget.naturalWidth/T.currentTarget.naturalHeight)),(C.width||C.aspectRatio)&&a(C)}}),y&&g.jsx(t8,{onResize:S,className:ge([Zf.resizer,u.resizer]),mouseDown:b,setMouseDown:v}),k&&g.jsx(k,{...o})]})})}const r8=j9.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),isAllowedImgSrc:e=>!!e}},addAttributes(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),width:{default:null,renderHTML:e=>({width:e.width}),parseHTML:e=>e.getAttribute("width")},aspectRatio:{default:null,renderHTML:e=>e.aspectRatio?{style:`aspect-ratio: ${e.aspectRatio}`}:{},parseHTML:e=>e.style.aspectRatio}}},renderHTML({HTMLAttributes:t}){return["img",Ct({height:"auto"},this.options.HTMLAttributes,t)]},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])',getAttrs:t=>{if(!(t instanceof Element))return!1;const e=t.getAttribute("src");return this.options.isAllowedImgSrc(e)&&null}}]},addInputRules(){var t;const e=(t=this.parent)===null||t===void 0?void 0:t.call(this);if(!e)return[];const n=r=>{const[,,o,i,s]=r;return{src:i,alt:o,title:s}};return e.map(r=>new Ec({find:r.find,handler:o=>{const i=n(o.match);if(this.options.isAllowedImgSrc(i.src))return r.handler(o)}}))},addNodeView(){return Ib(n8)}});let Pb,Nb;if(typeof WeakMap<"u"){let t=new WeakMap;Pb=e=>t.get(e),Nb=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Pb=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},Nb=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var fn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,o=e/this.width|0;let i=r+1,s=o+1;for(let a=1;i<this.width&&this.map[e+a]==n;a++)i++;for(let a=1;s<this.height&&this.map[e+this.width*a]==n;a++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:r,top:o,bottom:i}=this.findCell(t),{left:s,right:a,top:l,bottom:u}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(o,l),right:Math.max(r,a),bottom:Math.max(i,u)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const a=(t+1)*this.width;for(;s<a&&this.map[s]<o;)s++;return s==a?i-1:this.map[s]}o=i}}static get(t){return Pb(t)||Nb(t,o8(t))}};function o8(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=i8(t),n=t.childCount,r=[];let o=0,i=null;const s=[];for(let u=0,f=e*n;u<f;u++)r[u]=0;for(let u=0,f=0;u<n;u++){const p=t.child(u);f++;for(let v=0;;v++){for(;o<r.length&&r[o]!=0;)o++;if(v==p.childCount)break;const y=p.child(v),{colspan:x,rowspan:S,colwidth:k}=y.attrs;for(let T=0;T<S;T++){if(T+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:S-T});break}const C=o+T*e;for(let O=0;O<x;O++){r[C+O]==0?r[C+O]=f:(i||(i=[])).push({type:"collision",row:u,pos:f,n:x-O});const I=k&&k[O];if(I){const N=(C+O)%e*2,L=s[N];L==null||L!=I&&s[N+1]==1?(s[N]=I,s[N+1]=1):L==I&&s[N+1]++}}}o+=x,f+=y.nodeSize}const m=(u+1)*e;let b=0;for(;o<m;)r[o++]==0&&b++;b&&(i||(i=[])).push({type:"missing",row:u,n:b}),f++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const a=new fn(e,n,r,i);let l=!1;for(let u=0;!l&&u<s.length;u+=2)s[u]!=null&&s[u+1]<n&&(l=!0);return l&&s8(a,s,t),a}function i8(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const o=t.child(r);let i=0;if(n)for(let s=0;s<r;s++){const a=t.child(s);for(let l=0;l<a.childCount;l++){const u=a.child(l);s+u.attrs.rowspan>r&&(i+=u.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const a=o.child(s);i+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function s8(t,e,n){t.problems||(t.problems=[]);const r={};for(let o=0;o<t.map.length;o++){const i=t.map[o];if(r[i])continue;r[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let a=null;const l=s.attrs;for(let u=0;u<l.colspan;u++){const f=e[(o+u)%t.width*2];f!=null&&(!l.colwidth||l.colwidth[u]!=f)&&((a||(a=a8(l)))[u]=f)}a&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function a8(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function or(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}const ys=new On("selectingCells");function El(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function l8(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Eo(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function ep(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=El(e.$head)||c8(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function c8(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function $b(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function u8(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Lb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function DO(t,e,n){const r=t.node(-1),o=fn.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function pa(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function AO(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function d8(t,e,n){const r=or(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var Wt=class Wi extends nt{constructor(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),a=e.node(0),l=o.cellsInRect(s).filter(f=>f!=n.pos-i);l.unshift(n.pos-i);const u=l.map(f=>{const p=r.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=i+f+1;return new aS(a.resolve(m),a.resolve(m+p.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if($b(r)&&$b(o)&&Lb(r,o)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Wi.rowSelection(r,o):i&&this.isColSelection()?Wi.colSelection(r,o):new Wi(r,o)}return Xe.between(r,o)}content(){const e=this.$anchorCell.node(-1),n=fn.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let l=o.top;l<o.bottom;l++){const u=[];for(let f=l*n.width+o.left,p=o.left;p<o.right;p++,f++){const m=n.map[f];if(i[m])continue;i[m]=!0;const b=n.findCell(m);let v=e.nodeAt(m);if(!v)throw new RangeError(`No cell with offset ${m} found`);const y=o.left-b.left,x=b.right-o.right;if(y>0||x>0){let S=v.attrs;if(y>0&&(S=pa(S,0,y)),x>0&&(S=pa(S,S.colspan-x,x)),b.left<o.left){if(v=v.type.createAndFill(S),!v)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(S)}`)}else v=v.type.create(S,v.content)}if(b.top<o.top||b.bottom>o.bottom){const S={...v.attrs,rowspan:Math.min(b.bottom,o.bottom)-Math.max(b.top,o.top)};b.top<o.top?v=v.type.createAndFill(S):v=v.type.create(S,v.content)}u.push(v)}s.push(e.child(l).copy(Oe.from(u)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new Fe(Oe.from(a),1,1)}replace(e,n=Fe.empty){const r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:a,$to:l}=o[s],u=e.mapping.slice(r);e.replace(u.map(a.pos),u.map(l.pos),s?Fe.empty:n)}const i=nt.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Fe(Oe.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=fn.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(i+o.map[s.left])),a.bottom<o.height&&(n=l.resolve(i+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(i+o.map[a.left])),s.bottom<o.height&&(e=l.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new Wi(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=fn.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,a=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==n.width}eq(e){return e instanceof Wi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(i+o.map[s.top*o.width])),a.right<o.width&&(n=l.resolve(i+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(i+o.map[a.top*o.width])),s.right<o.width&&(e=l.resolve(i+o.map[o.width*(s.top+1)-1]))),new Wi(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Wi(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Wi(e.resolve(n),e.resolve(r))}getBookmark(){return new f8(this.$anchorCell.pos,this.$headCell.pos)}};Wt.prototype.visible=!1,nt.jsonID("cell",Wt);var f8=class TP{constructor(e,n){this.anchor=e,this.head=n}map(e){return new TP(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Lb(n,r)?new Wt(n,r):nt.near(r,1)}};function p8(t){if(!(t.selection instanceof Wt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Yn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Jt.create(t.doc,e)}function h8({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function m8({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){const i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function g8(t,e,n){const r=(e||t).selection,o=(e||t).doc;let i,s;if(r instanceof Je&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=Wt.create(o,r.from);else if(s=="row"){const a=o.resolve(r.from+1);i=Wt.rowSelection(a,a)}else if(!n){const a=fn.get(r.node),l=r.from+1,u=l+a.map[a.width*a.height-1];i=Wt.create(o,l+1,u)}}else r instanceof Xe&&h8(r)?i=Xe.create(o,r.from):r instanceof Xe&&m8(r)&&(i=Xe.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const y8=new On("fix-tables");function PO(t,e,n,r){const o=t.childCount,i=e.childCount;e:for(let s=0,a=0;s<i;s++){const l=e.child(s);for(let u=a,f=Math.min(o,s+3);u<f;u++)if(t.child(u)==l){a=u+1,n+=l.nodeSize;continue e}r(l,n),a<o&&t.child(a).sameMarkup(l)?PO(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function NO(t,e){let n;const r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=b8(t,o,i,n))};return e?e.doc!=t.doc&&PO(e.doc,t.doc,0,r):t.doc.descendants(r),n}function b8(t,e,n,r){const o=fn.get(e);if(!o.problems)return r;r||(r=t.tr);const i=[];for(let l=0;l<o.height;l++)i.push(0);for(let l=0;l<o.problems.length;l++){const u=o.problems[l];if(u.type=="collision"){const f=e.nodeAt(u.pos);if(!f)continue;const p=f.attrs;for(let m=0;m<p.rowspan;m++)i[u.row+m]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,pa(p,p.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){const f=r.mapping.map(n);r.delete(f,f+e.nodeSize)}}let s,a;for(let l=0;l<i.length;l++)i[l]&&(s==null&&(s=l),a=l);for(let l=0,u=n+1;l<o.height;l++){const f=e.child(l),p=u+f.nodeSize,m=i[l];if(m>0){let b="cell";f.firstChild&&(b=f.firstChild.type.spec.tableRole);const v=[];for(let x=0;x<m;x++){const S=or(t.schema)[b].createAndFill();S&&v.push(S)}const y=(l==0||s==l-1)&&a==l?u+1:p-1;r.insert(r.mapping.map(y),v)}u=p}return r.setMeta(y8,{fixTables:!0})}function Ko(t){const e=t.selection,n=ep(t),r=n.node(-1),o=n.start(-1),i=fn.get(r);return{...e instanceof Wt?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function $O(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;d8(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+o;if(o>0&&o<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],u=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,AO(u.attrs,o-e.colCount(l))),s+=u.attrs.rowspan-1}else{const l=i==null?or(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,u=e.positionAt(s,o,r);t.insert(t.mapping.map(n+u),l.createAndFill())}}return t}function v8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e($O(t.tr,n,n.left))}return!0}function x8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e($O(t.tr,n,n.right))}return!0}function w8(t,{map:e,table:n,tableStart:r},o){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+o,l=e.map[a],u=n.nodeAt(l),f=u.attrs;if(o>0&&e.map[a-1]==l||o<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(i).map(r+l),null,pa(f,o-e.colCount(l)));else{const p=t.mapping.slice(i).map(r+l);t.delete(p,p+u.nodeSize)}s+=f.rowspan}}function S8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;w8(r,n,o),o!=n.left;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=fn.get(i)}e(r)}return!0}function C8(t,e,n){var r;const o=or(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function LO(t,{map:e,tableStart:n,table:r},o){let i=n;for(let u=0;u<o;u++)i+=r.child(u).nodeSize;const s=[];let a=o>0?-1:0;C8(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let u=0,f=e.width*o;u<e.width;u++,f++)if(o>0&&o<e.height&&e.map[f]==e.map[f-e.width]){const p=e.map[f],m=r.nodeAt(p).attrs;t.setNodeMarkup(n+p,null,{...m,rowspan:m.rowspan+1}),u+=m.colspan-1}else{var l;const p=a==null?or(r.type.schema).cell:(l=r.nodeAt(e.map[f+a*e.width]))===null||l===void 0?void 0:l.type,m=p==null?void 0:p.createAndFill();m&&s.push(m)}return t.insert(i,or(r.type.schema).row.create(null,s)),t}function T8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e(LO(t.tr,n,n.top))}return!0}function k8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e(LO(t.tr,n,n.bottom))}return!0}function E8(t,{map:e,table:n,tableStart:r},o){let i=0;for(let u=0;u<o;u++)i+=n.child(u).nodeSize;const s=i+n.child(o).nodeSize,a=t.mapping.maps.length;t.delete(i+r,s+r);const l=new Set;for(let u=0,f=o*e.width;u<e.width;u++,f++){const p=e.map[f];if(!l.has(p)){if(l.add(p),o>0&&p==e.map[f-e.width]){const m=n.nodeAt(p).attrs;t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m,rowspan:m.rowspan-1}),u+=m.colspan-1}else if(o<e.height&&p==e.map[f+e.width]){const m=n.nodeAt(p),b=m.attrs,v=m.type.create({...b,rowspan:m.attrs.rowspan-1},m.content),y=e.positionAt(o+1,u,n);t.insert(t.mapping.slice(a).map(r+y),v),u+=b.colspan-1}}}}function O8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;E8(r,n,o),o!=n.top;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=fn.get(n.table)}e(r)}return!0}function BO(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function M8({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,a=o+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[a]==n[a+1])return!0;i+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function FO(t,e){const n=t.selection;if(!(n instanceof Wt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Ko(t),{map:o}=r;if(M8(o,r))return!1;if(e){const i=t.tr,s={};let a=Oe.empty,l,u;for(let f=r.top;f<r.bottom;f++)for(let p=r.left;p<r.right;p++){const m=o.map[f*o.width+p],b=r.table.nodeAt(m);if(!(s[m]||!b))if(s[m]=!0,l==null)l=m,u=b;else{BO(b)||(a=a.append(b.content));const v=i.mapping.map(m+r.tableStart);i.delete(v,v+b.nodeSize)}}if(l==null||u==null)return!0;if(i.setNodeMarkup(l+r.tableStart,null,{...AO(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const f=l+1+u.content.size,p=BO(u)?l+1:f;i.replaceWith(p+r.tableStart,f+r.tableStart,a)}i.setSelection(new Wt(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function RO(t,e){const n=or(t.schema);return _8(({node:r})=>n[r.type.spec.tableRole])(t,e)}function _8(t){return(e,n)=>{const r=e.selection;let o,i;if(r instanceof Wt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=l8(r.$from),!o)return!1;i=(s=El(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let a=o.attrs;const l=[],u=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const f=Ko(e),p=e.tr;for(let b=0;b<f.right-f.left;b++)l.push(u?{...a,colwidth:u&&u[b]?[u[b]]:null}:a);let m;for(let b=f.top;b<f.bottom;b++){let v=f.map.positionAt(b,f.left,f.table);b==f.top&&(v+=o.nodeSize);for(let y=f.left,x=0;y<f.right;y++,x++)y==f.left&&b==f.top||p.insert(m=p.mapping.map(v+f.tableStart,1),t({node:o,row:b,col:y}).createAndFill(l[x]))}p.setNodeMarkup(i,t({node:o,row:f.top,col:f.left}),l[0]),r instanceof Wt&&p.setSelection(new Wt(p.doc.resolve(r.$anchorCell.pos),m?p.doc.resolve(m):void 0)),n(p)}return!0}}function I8(t,e){return function(n,r){if(!Eo(n))return!1;const o=ep(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Wt?n.selection.forEachCell((s,a)=>{s.attrs[t]!==e&&i.setNodeMarkup(a,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function D8(t){return function(e,n){if(!Eo(e))return!1;if(n){const r=or(e.schema),o=Ko(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=s.map(l=>o.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[l],r.cell,a[l].attrs);if(i.steps.length===0)for(let l=0;l<s.length;l++)i.setNodeMarkup(o.tableStart+s[l],r.header_cell,a[l].attrs);n(i)}return!0}}function zO(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function uu(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?D8(t):function(n,r){if(!Eo(n))return!1;if(r){const o=or(n.schema),i=Ko(n),s=n.tr,a=zO("row",i,o),l=zO("column",i,o),u=(t==="column"?a:t==="row"&&l)?1:0,f=t=="column"?{left:0,top:u,right:1,bottom:i.map.height}:t=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,p=t=="column"?l?o.cell:o.header_cell:t=="row"?a?o.cell:o.header_cell:o.cell;i.map.cellsInRect(f).forEach(m=>{const b=m+i.tableStart,v=s.doc.nodeAt(b);v&&s.setNodeMarkup(b,p,v.attrs)}),r(s)}return!0}}uu("row",{useDeprecatedLogic:!0}),uu("column",{useDeprecatedLogic:!0});const A8=uu("cell",{useDeprecatedLogic:!0});function P8(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){const i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function VO(t){return function(e,n){if(!Eo(e))return!1;const r=P8(ep(e),t);if(r==null)return!1;if(n){const o=e.doc.resolve(r);n(e.tr.setSelection(Xe.between(o,u8(o))).scrollIntoView())}return!0}}function N8(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function tp(t,e){const n=t.selection;if(!(n instanceof Wt))return!1;if(e){const r=t.tr,o=or(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new Fe(o,0,0))}),r.docChanged&&e(r)}return!0}function $8(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let u=e.child(l).content;const f=l?0:Math.max(0,n-1),p=l<e.childCount-1?0:Math.max(0,r-1);(f||p)&&(u=Bb(or(s).row,new Fe(u,f,p)).content),a.push(u)}else if(i=="cell"||i=="header_cell")a.push(n||r?Bb(or(s).row,new Fe(e,n,r)).content:e);else return null;return L8(s,a)}function L8(t,e){const n=[];for(let o=0;o<e.length;o++){const i=e[o];for(let s=i.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=i.child(s).attrs;for(let u=o;u<o+a;u++)n[u]=(n[u]||0)+l}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(Oe.empty),n[o]<r){const i=or(t).cell.createAndFill(),s=[];for(let a=n[o];a<r;a++)s.push(i);e[o]=e[o].append(Oe.from(s))}return{height:e.length,width:r,rows:e}}function Bb(t,e){const n=t.createAndFill();return new og(n).replace(0,n.content.size,e).doc}function B8({width:t,height:e,rows:n},r,o){if(t!=r){const i=[],s=[];for(let a=0;a<n.length;a++){const l=n[a],u=[];for(let f=i[a]||0,p=0;f<r;p++){let m=l.child(p%l.childCount);f+m.attrs.colspan>r&&(m=m.type.createChecked(pa(m.attrs,m.attrs.colspan,f+m.attrs.colspan-r),m.content)),u.push(m),f+=m.attrs.colspan;for(let b=1;b<m.attrs.rowspan;b++)i[a+b]=(i[a+b]||0)+m.attrs.colspan}s.push(Oe.from(u))}n=s,t=r}if(e!=o){const i=[];for(let s=0,a=0;s<o;s++,a++){const l=[],u=n[a%e];for(let f=0;f<u.childCount;f++){let p=u.child(f);s+p.attrs.rowspan>o&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,o-p.attrs.rowspan)},p.content)),l.push(p)}i.push(Oe.from(l))}n=i,e=o}return{width:t,height:e,rows:n}}function F8(t,e,n,r,o,i,s){const a=t.doc.type.schema,l=or(a);let u,f;if(o>e.width)for(let p=0,m=0;p<e.height;p++){const b=n.child(p);m+=b.nodeSize;const v=[];let y;b.lastChild==null||b.lastChild.type==l.cell?y=u||(u=l.cell.createAndFill()):y=f||(f=l.header_cell.createAndFill());for(let x=e.width;x<o;x++)v.push(y);t.insert(t.mapping.slice(s).map(m-1+r),v)}if(i>e.height){const p=[];for(let v=0,y=(e.height-1)*e.width;v<Math.max(e.width,o);v++){const x=v>=e.width?!1:n.nodeAt(e.map[y+v]).type==l.header_cell;p.push(x?f||(f=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const m=l.row.create(null,Oe.from(p)),b=[];for(let v=e.height;v<i;v++)b.push(m);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),b)}return!!(u||f)}function HO(t,e,n,r,o,i,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let u=o;u<i;u++){const f=s*e.width+u,p=e.map[f];if(e.map[f-e.width]==p){l=!0;const m=n.nodeAt(p),{top:b,left:v}=e.findCell(p);t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m.attrs,rowspan:s-b}),t.insert(t.mapping.slice(a).map(e.positionAt(s,v,n)),m.type.createAndFill({...m.attrs,rowspan:b+m.attrs.rowspan-s})),u+=m.attrs.colspan-1}}return l}function WO(t,e,n,r,o,i,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let u=o;u<i;u++){const f=u*e.width+s,p=e.map[f];if(e.map[f-1]==p){l=!0;const m=n.nodeAt(p),b=e.colCount(p),v=t.mapping.slice(a).map(p+r);t.setNodeMarkup(v,null,pa(m.attrs,s-b,m.attrs.colspan-(s-b))),t.insert(v+m.nodeSize,m.type.createAndFill(pa(m.attrs,0,s-b))),u+=m.attrs.rowspan-1}}return l}function jO(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=fn.get(i);const{top:a,left:l}=r,u=l+o.width,f=a+o.height,p=t.tr;let m=0;function b(){if(i=n?p.doc.nodeAt(n-1):p.doc,!i)throw new Error("No table found");s=fn.get(i),m=p.mapping.maps.length}F8(p,s,i,n,u,f,m)&&b(),HO(p,s,i,n,l,u,a,m)&&b(),HO(p,s,i,n,l,u,f,m)&&b(),WO(p,s,i,n,a,f,l,m)&&b(),WO(p,s,i,n,a,f,u,m)&&b();for(let v=a;v<f;v++){const y=s.positionAt(v,l,i),x=s.positionAt(v,u,i);p.replace(p.mapping.slice(m).map(y+n),p.mapping.slice(m).map(x+n),new Fe(o.rows[v-a],0,0))}b(),p.setSelection(new Wt(p.doc.resolve(n+s.positionAt(a,l,i)),p.doc.resolve(n+s.positionAt(f-1,u-1,i)))),e(p)}const R8=$g({ArrowLeft:rp("horiz",-1),ArrowRight:rp("horiz",1),ArrowUp:rp("vert",-1),ArrowDown:rp("vert",1),"Shift-ArrowLeft":op("horiz",-1),"Shift-ArrowRight":op("horiz",1),"Shift-ArrowUp":op("vert",-1),"Shift-ArrowDown":op("vert",1),Backspace:tp,"Mod-Backspace":tp,Delete:tp,"Mod-Delete":tp});function np(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function rp(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;if(i instanceof Wt)return np(n,r,nt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const s=UO(o,t,e);if(s==null)return!1;if(t=="horiz")return np(n,r,nt.near(n.doc.resolve(i.head+e),e));{const a=n.doc.resolve(s),l=DO(a,t,e);let u;return l?u=nt.near(l,1):e<0?u=nt.near(n.doc.resolve(a.before(-1)),-1):u=nt.near(n.doc.resolve(a.after(-1)),1),np(n,r,u)}}}function op(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof Wt)s=i;else{const l=UO(o,t,e);if(l==null)return!1;s=new Wt(n.doc.resolve(l))}const a=DO(s.$headCell,t,e);return a?np(n,r,new Wt(s.$anchorCell,a)):!1}}function z8(t,e){const n=t.state.doc,r=El(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Wt(r))),!0):!1}function V8(t,e,n){if(!Eo(t.state))return!1;let r=$8(n);const o=t.state.selection;if(o instanceof Wt){r||(r={width:1,height:1,rows:[Oe.from(Bb(or(t.state.schema).cell,n))]});const i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),a=fn.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=B8(r,a.right-a.left,a.bottom-a.top),jO(t.state,t.dispatch,s,a,r),!0}else if(r){const i=ep(t.state),s=i.start(-1);return jO(t.state,t.dispatch,s,fn.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function H8(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=qO(t,e.target);let o;if(e.shiftKey&&t.state.selection instanceof Wt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=El(t.state.selection.$anchor))!=null&&((n=Fb(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(l,u){let f=Fb(t,u);const p=ys.getState(t.state)==null;if(!f||!Lb(l,f))if(p)f=l;else return;const m=new Wt(l,f);if(p||!t.state.selection.eq(m)){const b=t.state.tr.setSelection(m);p&&b.setMeta(ys,l.pos),t.dispatch(b)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),ys.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ys,-1))}function a(l){const u=l,f=ys.getState(t.state);let p;if(f!=null)p=t.state.doc.resolve(f);else if(qO(t,u.target)!=r&&(p=Fb(t,e),!p))return s();p&&i(p,u)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function UO(t,e,n){if(!(t.state.selection instanceof Xe))return null;const{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const s=r.before(o),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?s:null}}return null}function qO(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Fb(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;const r=n.inside>=0?n.inside:n.pos;return El(t.state.doc.resolve(r))}var W8=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Rb(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Rb(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Rb(t,e,n,r,o,i){let s=0,a=!0,l=e.firstChild;const u=t.firstChild;if(u){for(let p=0,m=0;p<u.childCount;p++){const{colspan:b,colwidth:v}=u.child(p).attrs;for(let y=0;y<b;y++,m++){const x=o==m?i:v&&v[y],S=x?x+"px":"";if(s+=x||r,x||(a=!1),l)l.style.width!=S&&(l.style.width=S),l=l.nextSibling;else{const k=document.createElement("col");k.style.width=S,e.appendChild(k)}}}for(;l;){var f;const p=l.nextSibling;(f=l.parentNode)===null||f===void 0||f.removeChild(l),l=p}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const Lr=new On("tableColumnResizing");function KO({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=W8,lastColumnResizable:o=!0}={}){const i=new en({key:Lr,state:{init(s,a){var l;const u=(l=i.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,f=or(a.schema).table.name;return r&&u&&(u[f]=(p,m)=>new r(p,n,m)),new j8(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=Lr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{U8(s,a,t,o)},mouseleave:s=>{q8(s)},mousedown:(s,a)=>{K8(s,a,e,n)}},decorations:s=>{const a=Lr.getState(s);if(a&&a.activeHandle>-1)return Z8(s,a.activeHandle)},nodeViews:{}}});return i}var j8=class xm{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new xm(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new xm(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return $b(e.doc.resolve(o))||(o=-1),new xm(o,n.dragging)}return n}};function U8(t,e,n,r){if(!t.editable)return;const o=Lr.getState(t.state);if(o&&!o.dragging){const i=G8(e.target);let s=-1;if(i){const{left:a,right:l}=i.getBoundingClientRect();e.clientX-a<=n?s=YO(t,e,"left",n):l-e.clientX<=n&&(s=YO(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){const a=t.state.doc.resolve(s),l=a.node(-1),u=fn.get(l),f=a.start(-1);if(u.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==u.width-1)return}JO(t,s)}}}function q8(t){if(!t.editable)return;const e=Lr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&JO(t,-1)}function K8(t,e,n,r){var o;if(!t.editable)return!1;const i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Lr.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=Y8(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:l}}));function u(p){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",f);const m=Lr.getState(t.state);m!=null&&m.dragging&&(J8(t,m.activeHandle,GO(m.dragging,p,n)),t.dispatch(t.state.tr.setMeta(Lr,{setDragging:null})))}function f(p){if(!p.which)return u(p);const m=Lr.getState(t.state);if(m&&m.dragging){const b=GO(m.dragging,p,n);XO(t,m.activeHandle,b,r)}}return XO(t,s.activeHandle,l,r),i.addEventListener("mouseup",u),i.addEventListener("mousemove",f),e.preventDefault(),!0}function Y8(t,e,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(s-=r[l],a--);return s/a}function G8(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function YO(t,e,n,r){const o=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:s}=i,a=El(t.state.doc.resolve(s));if(!a)return-1;if(n=="right")return a.pos;const l=fn.get(a.node(-1)),u=a.start(-1),f=l.map.indexOf(a.pos-u);return f%l.width==0?-1:u+l.map[f-1]}function GO(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function JO(t,e){t.dispatch(t.state.tr.setMeta(Lr,{setHandle:e}))}function J8(t,e,n){const r=t.state.doc.resolve(e),o=r.node(-1),i=fn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let u=0;u<i.height;u++){const f=u*i.width+a;if(u&&i.map[f]==i.map[f-i.width])continue;const p=i.map[f],m=o.nodeAt(p).attrs,b=m.colspan==1?0:a-i.colCount(p);if(m.colwidth&&m.colwidth[b]==n)continue;const v=m.colwidth?m.colwidth.slice():X8(m.colspan);v[b]=n,l.setNodeMarkup(s+p,null,{...m,colwidth:v})}l.docChanged&&t.dispatch(l)}function XO(t,e,n,r){const o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),a=fn.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let l=t.domAtPos(o.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Rb(i,l.firstChild,l,r,a,n)}function X8(t){return Array(t).fill(0)}function Z8(t,e){const n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return Jt.empty;const i=fn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){const f=a+u*i.width;if((a==i.width-1||i.map[f]!=i.map[f+1])&&(u==0||i.map[f]!=i.map[f-i.width])){var l;const p=i.map[f],m=s+p+o.nodeAt(p).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((l=Lr.getState(t))===null||l===void 0)&&l.dragging&&n.push(Yn.node(s+p,s+p+o.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),n.push(Yn.widget(m,b))}}return Jt.create(t.doc,n)}function ZO({allowTableNodeSelection:t=!1}={}){return new en({key:ys,state:{init(){return null},apply(e,n){const r=e.getMeta(ys);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:p8,handleDOMEvents:{mousedown:H8},createSelectionBetween(e){return ys.getState(e.state)!=null?e.state.selection:null},handleTripleClick:z8,handleKeyDown:R8,handlePaste:V8},appendTransaction(e,n,r){return g8(r,NO(r,n),t)}})}function zb(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function QO(t,e,n,r,o,i){var s;let a=0,l=!0,u=e.firstChild;const f=t.firstChild;if(f!==null)for(let p=0,m=0;p<f.childCount;p+=1){const{colspan:b,colwidth:v}=f.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=o===m?i:v&&v[y],S=x?`${x}px`:"";if(a+=x||r,x||(l=!1),u){if(u.style.width!==S){const[k,T]=zb(r,x);u.style.setProperty(k,T)}u=u.nextSibling}else{const k=document.createElement("col"),[T,C]=zb(r,x);k.style.setProperty(T,C),e.appendChild(k)}}}for(;u;){const p=u.nextSibling;(s=u.parentNode)===null||s===void 0||s.removeChild(u),u=p}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class Q8{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),QO(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,QO(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function e7(t,e,n,r){let o=0,i=!0;const s=[],a=t.firstChild;if(!a)return{};for(let p=0,m=0;p<a.childCount;p+=1){const{colspan:b,colwidth:v}=a.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=n===m?r:v&&v[y];o+=x||e,x||(i=!1);const[S,k]=zb(e,x);s.push(["col",{style:`${S}: ${k}`}])}}const l=i?`${o}px`:"",u=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:u}}function eM(t,e){return t.createAndFill()}function t7(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function n7(t,e,n,r,o){const i=t7(t),s=[],a=[];for(let u=0;u<n;u+=1){const f=eM(i.cell);if(f&&a.push(f),r){const p=eM(i.header_cell);p&&s.push(p)}}const l=[];for(let u=0;u<e;u+=1)l.push(i.row.createChecked(null,r&&u===0?s:a));return i.table.createChecked(null,l)}function r7(t){return t instanceof Wt}const ip=({editor:t})=>{const{selection:e}=t.state;if(!r7(e))return!1;let n=0;const r=qg(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},o7=tn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Q8,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=e7(t,this.options.cellMinWidth),i=["table",Ct(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{const s=n7(i.schema,t,e,n);if(o){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Xe.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>v8(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>x8(t,e),deleteColumn:()=>({state:t,dispatch:e})=>S8(t,e),addRowBefore:()=>({state:t,dispatch:e})=>T8(t,e),addRowAfter:()=>({state:t,dispatch:e})=>k8(t,e),deleteRow:()=>({state:t,dispatch:e})=>O8(t,e),deleteTable:()=>({state:t,dispatch:e})=>N8(t,e),mergeCells:()=>({state:t,dispatch:e})=>FO(t,e),splitCell:()=>({state:t,dispatch:e})=>RO(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>uu("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>uu("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>A8(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>FO(t,e)?!0:RO(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>I8(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>VO(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>VO(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&NO(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Wt.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ip,"Mod-Backspace":ip,Delete:ip,"Mod-Delete":ip}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[KO({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ZO({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:ft(Ue(t,"tableRole",e))}}}).extend({addProseMirrorPlugins(){return[...this.options.resizable?[KO({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ZO({allowTableNodeSelection:this.options.allowTableNodeSelection})]}}),ha=Xt("FieldContainer",["root","outlined","standard","focused","disabled","notchedOutline"]),Vb=Ut("FieldContainer"),i7=oe(ab,{name:Vb,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard,t.ownerState.focused&&e.focused,t.ownerState.disabled&&e.disabled]})(({theme:t,ownerState:e})=>({...e.variant==="outlined"&&{borderRadius:t.shape.borderRadius,padding:1,position:"relative",...!e.focused&&!e.disabled&&{[`&:hover .${ha.notchedOutline}`]:{borderColor:t.palette.text.primary}}}})),s7=oe("div",{name:Vb,slot:"notchedOutline",overridesResolver:(t,e)=>e.notchedOutline})(({theme:t,ownerState:e})=>({position:"absolute",inset:0,borderRadius:"inherit",borderColor:t.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)",borderStyle:"solid",borderWidth:1,pointerEvents:"none",overflow:"hidden",zIndex:xf.NOTCHED_OUTLINE,...e.focused&&{borderColor:t.palette.primary.main,borderWidth:2},...e.disabled&&{borderColor:t.palette.action.disabled}}));function a7(t){const e=rt({props:t,name:Vb}),{variant:n="outlined",children:r,focused:o,disabled:i,classes:s={},className:a,sx:l,...u}=e,f={variant:n,focused:o,disabled:i};return g.jsxs(i7,{...u,className:ge([ha.root,a,s.root,n==="outlined"?[ha.outlined,s.outlined]:[ha.standard,s.standard],o&&[ha.focused,s.focused],i&&[ha.disabled,s.disabled]]),sx:l,ownerState:f,children:[r,n==="outlined"&&g.jsx(s7,{ownerState:f,className:ge([ha.notchedOutline,s.notchedOutline]),"aria-hidden":!0})]})}function tM({editor:t,wait:e=250}){const[n,r]=J.useState(!!(t!=null&&t.isFocused)),o=J.useMemo(()=>IE(i=>{r(i)},e),[e]);return J.useEffect(()=>{const i=!!(t!=null&&t.isFocused);return o(i),i&&o.flush(),()=>{o.cancel()}},[t==null?void 0:t.isFocused,o]),n}function nM(t,e){const n=J.useRef(e);J.useEffect(()=>{n.current=e},[e]),J.useEffect(()=>{function r(o){t===o.key&&n.current(o)}return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[t])}function l7(t){return Ke("MuiDialogActions",t)}je("MuiDialogActions",["root","spacing"]);const c7=t=>{const{classes:e,disableSpacing:n}=t;return qe({root:["root",!n&&"spacing"]},l7,e)},u7=oe("div",{name:"MuiDialogActions",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,!n.disableSpacing&&e.spacing]}})({display:"flex",alignItems:"center",padding:8,justifyContent:"flex-end",flex:"0 0 auto",variants:[{props:({ownerState:t})=>!t.disableSpacing,style:{"& > :not(style) ~ :not(style)":{marginLeft:8}}}]}),sp=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiDialogActions"}),{className:o,disableSpacing:i=!1,...s}=r,a={...r,disableSpacing:i},l=c7(a);return g.jsx(u7,{className:ge(l.root,o),ownerState:a,ref:n,...s})});process.env.NODE_ENV!=="production"&&(sp.propTypes={children:c.node,classes:c.object,className:c.string,disableSpacing:c.bool,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object])});function d7({editor:t,onCancel:e,onSave:n,labels:r,formatHref:o=_6}){var i,s,a,l,u,f;const p=t.isActive("link")?t.getAttributes("link").href:"",m=Oc(t.state.selection.$from,So("link",t.schema)),b=m?t.state.doc.textBetween(m.from,m.to):"",v=t.state.doc.textBetween(t.state.selection.$from.pos,t.state.selection.$to.pos),y=b||v,[x,S]=J.useState(y),[k,T]=J.useState(p),C=J.useRef(null),O=J.useRef(null),I=!p,N=(i=r==null?void 0:r.editLinkAddTitle)!==null&&i!==void 0?i:"Add link",L=(s=r==null?void 0:r.editLinkEditTitle)!==null&&s!==void 0?s:"Edit link",V=I?N:L;J.useEffect(()=>{var F,P;!I||!y?(F=C.current)===null||F===void 0||F.focus({preventScroll:!0}):(P=O.current)===null||P===void 0||P.focus({preventScroll:!0})},[I,y]),nM("Escape",e);function M(){O.current&&T(o(O.current.value))}const[B,H]=J.useState(!1);return g.jsxs("form",{onSubmit:F=>{var P,_,D,R;F.preventDefault(),F.stopPropagation(),H(!0);const j=(_=(P=C.current)===null||P===void 0?void 0:P.value)!==null&&_!==void 0?_:"",K=(R=(D=O.current)===null||D===void 0?void 0:D.value)!==null&&R!==void 0?R:"";n({text:j,link:K}),H(!1)},autoComplete:"off",children:[g.jsx(ko,{variant:"h6",children:V}),g.jsx(Xc,{inputRef:C,value:x,disabled:B,onChange:F=>{S(F.target.value)},label:(a=r==null?void 0:r.editLinkTextInputLabel)!==null&&a!==void 0?a:"Text",margin:"normal",size:"small",fullWidth:!0,required:!0}),g.jsx(Xc,{inputRef:O,value:k,onChange:F=>{T(F.target.value)},disabled:B,label:(l=r==null?void 0:r.editLinkHrefInputLabel)!==null&&l!==void 0?l:"Link",margin:"dense",size:"small",type:"text",onBlur:M,onKeyDown:F=>{F.key==="Enter"&&M()},fullWidth:!0,required:!0}),g.jsxs(sp,{sx:{px:0},children:[g.jsx(no,{onClick:e,variant:"outlined",size:"small",children:(u=r==null?void 0:r.editLinkCancelButtonLabel)!==null&&u!==void 0?u:"Cancel"}),g.jsx(no,{type:"submit",color:"primary",variant:"outlined",size:"small",disabled:B,children:(f=r==null?void 0:r.editLinkSaveButtonLabel)!==null&&f!==void 0?f:"Save"})]})]})}const Hb=Xt("LinkBubbleMenu",["root","paper","content"]);function f7(t){return Ke("MuiLink",t)}const p7=je("MuiLink",["root","underlineNone","underlineHover","underlineAlways","button","focusVisible"]),h7=({theme:t,ownerState:e})=>{const n=e.color,r=qi(t,`palette.${n}.main`,!1)||qi(t,`palette.${n}`,!1)||e.color,o=qi(t,`palette.${n}.mainChannel`)||qi(t,`palette.${n}Channel`);return"vars"in t&&o?`rgba(${o} / 0.4)`:it(r,.4)},rM={primary:!0,secondary:!0,error:!0,info:!0,success:!0,warning:!0,textPrimary:!0,textSecondary:!0,textDisabled:!0},m7=t=>{const{classes:e,component:n,focusVisible:r,underline:o}=t,i={root:["root",`underline${Ne(o)}`,n==="button"&&"button",r&&"focusVisible"]};return qe(i,f7,e)},g7=oe(ko,{name:"MuiLink",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[`underline${Ne(n.underline)}`],n.component==="button"&&e.button]}})(bt(({theme:t})=>({variants:[{props:{underline:"none"},style:{textDecoration:"none"}},{props:{underline:"hover"},style:{textDecoration:"none","&:hover":{textDecoration:"underline"}}},{props:{underline:"always"},style:{textDecoration:"underline","&:hover":{textDecorationColor:"inherit"}}},{props:({underline:e,ownerState:n})=>e==="always"&&n.color!=="inherit",style:{textDecorationColor:"var(--Link-underlineColor)"}},...Object.entries(t.palette).filter(Hn()).map(([e])=>({props:{underline:"always",color:e},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette[e].mainChannel} / 0.4)`:it(t.palette[e].main,.4)}})),{props:{underline:"always",color:"textPrimary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.primaryChannel} / 0.4)`:it(t.palette.text.primary,.4)}},{props:{underline:"always",color:"textSecondary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.secondaryChannel} / 0.4)`:it(t.palette.text.secondary,.4)}},{props:{underline:"always",color:"textDisabled"},style:{"--Link-underlineColor":(t.vars||t).palette.text.disabled}},{props:{component:"button"},style:{position:"relative",WebkitTapHighlightColor:"transparent",backgroundColor:"transparent",outline:0,border:0,margin:0,borderRadius:0,padding:0,cursor:"pointer",userSelect:"none",verticalAlign:"middle",MozAppearance:"none",WebkitAppearance:"none","&::-moz-focus-inner":{borderStyle:"none"},[`&.${p7.focusVisible}`]:{outline:"auto"}}}]}))),oM=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiLink"}),o=wo(),{className:i,color:s="primary",component:a="a",onBlur:l,onFocus:u,TypographyClasses:f,underline:p="always",variant:m="inherit",sx:b,...v}=r,[y,x]=A.useState(!1),S=O=>{Fa(O.target)||x(!1),l&&l(O)},k=O=>{Fa(O.target)&&x(!0),u&&u(O)},T={...r,color:s,component:a,focusVisible:y,underline:p,variant:m},C=m7(T);return g.jsx(g7,{color:s,className:ge(C.root,i),classes:f,component:a,onBlur:S,onFocus:k,ref:n,ownerState:T,variant:m,...v,sx:[...rM[s]===void 0?[{color:s}]:[],...Array.isArray(b)?b:[b]],style:{...v.style,...p==="always"&&s!=="inherit"&&!rM[s]&&{"--Link-underlineColor":h7({theme:o,ownerState:T})}}})});process.env.NODE_ENV!=="production"&&(oM.propTypes={children:c.node,classes:c.object,className:c.string,color:c.oneOfType([c.oneOf(["primary","secondary","success","error","info","warning","textPrimary","textSecondary","textDisabled"]),c.string]),component:Ba,onBlur:c.func,onFocus:c.func,style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),TypographyClasses:c.object,underline:c.oneOf(["always","hover","none"]),variant:c.oneOfType([c.oneOf(["body1","body2","button","caption","h1","h2","h3","h4","h5","h6","inherit","overline","subtitle1","subtitle2"]),c.string])});var Wb={},jb={},iM;function y7(){return iM||(iM=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(jb)),jb}var sM;function b7(){return sM||(sM=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=y7(),n=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/;function r(i,s){i=i!=null?`${i}`:"";let a=30,l="...";e.isObject(s)&&(a=o(s.length),l="omission"in s?`${s.omission}`:"...");let u=i.length;const f=Array.from(l).length,p=Math.max(a-f,0);let m;if(n.test(i)&&(m=Array.from(i),u=m.length),a>=u)return i;if(u<=f)return l;let v=m===void 0?i.slice(0,p):m==null?void 0:m.slice(0,p).join("");const y=s==null?void 0:s.separator;if(!y)return v+=l,v;const x=y instanceof RegExp?y.source:y,S="u"+(y instanceof RegExp?y.flags.replace("u",""):""),k=new RegExp(`(?<result>.*(?:(?!${x}).))(?:${x})`,S).exec(v);return(k!=null&&k.groups?k.groups.result:v)+l}function o(i){return i==null?30:i<=0?0:i}t.truncate=r})(Wb)),Wb}var Ub,aM;function v7(){return aM||(aM=1,Ub=b7().truncate),Ub}var x7=v7();const w7=Un(x7),qb=Xt("ViewLinkMenuContent",["root","linkPreviewText"]),Kb=Ut("ViewLinkMenuContent"),S7=oe("div",{name:Kb,slot:"root",overridesResolver:(t,e)=>e.root})({}),lM=oe("div",{name:Kb,slot:"linkPreviewText",overridesResolver:(t,e)=>e.linkPreviewText})({overflowWrap:"anywhere"});function C7(t){var e,n,r;const o=rt({props:t,name:Kb}),{editor:i,onCancel:s,onEdit:a,onRemove:l,labels:u,classes:f={},sx:p}=o,m=Oc(i.state.selection.$to,So("link",i.schema)),b=m?i.state.doc.textBetween(m.from,m.to):"",v=(e=i.getAttributes("link").href)!==null&&e!==void 0?e:"";return nM("Escape",s),g.jsxs(S7,{className:ge([qb.root,f.root]),sx:p,children:[g.jsx(lM,{className:ge([qb.linkPreviewText,f.linkPreviewText]),children:w7(b,{length:50,omission:"…"})}),g.jsx(lM,{className:ge([qb.linkPreviewText,f.linkPreviewText]),children:g.jsx(oM,{href:v,target:"_blank",rel:"noopener",children:D6(v,50)})}),g.jsxs(sp,{sx:{px:0},children:[g.jsx(no,{onClick:a,color:"primary",variant:"outlined",size:"small",children:(n=u==null?void 0:u.viewLinkEditButtonLabel)!==null&&n!==void 0?n:"Edit"}),g.jsx(no,{onClick:l,color:"error",variant:"outlined",size:"small",children:(r=u==null?void 0:u.viewLinkRemoveButtonLabel)!==null&&r!==void 0?r:"Remove"})]})]})}const cM=Ut("LinkBubbleMenu"),T7=oe("div",{name:cM,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({padding:t.spacing(1.5,2,.5)}));function k7(t){const e=rt({props:t,name:cM}),{labels:n,formatHref:r,classes:o={},sx:i,...s}=e,a=Tt();if(!(a!=null&&a.isEditable))return null;if(!("linkBubbleMenuHandler"in a.storage))throw new Error("You must add the LinkBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const l=a.storage.linkBubbleMenuHandler,u=l.state;let f=null;return u===fr.VIEW_LINK_DETAILS?f=g.jsx(C7,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onEdit:a.commands.editLinkInBubbleMenu,onRemove:()=>{a.chain().unsetLink().setTextSelection(a.state.selection.to).focus().run()},labels:n}):u===fr.EDIT_LINK&&(f=g.jsx(d7,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onSave:({text:p,link:m})=>{a.chain().extendMarkRange("link").insertContent({type:"text",marks:[{type:"link",attrs:{href:m}}],text:p}).setLink({href:m}).focus().run(),a.commands.closeLinkBubbleMenu()},labels:n,formatHref:r})),g.jsx(Sy,{editor:a,open:u!==fr.HIDDEN,...l.bubbleMenuOptions,...s,classes:{root:ge([Hb.root,o.root]),paper:ge([Hb.paper,o.paper])},sx:i,children:g.jsx(T7,{className:ge([Hb.content,o.content]),children:f})})}function E7(t){return Ke("MuiCollapse",t)}je("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const O7=t=>{const{orientation:e,classes:n}=t,r={root:["root",`${e}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${e}`],wrapperInner:["wrapperInner",`${e}`]};return qe(r,E7,n)},M7=oe("div",{name:"MuiCollapse",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.orientation],n.state==="entered"&&e.entered,n.state==="exited"&&!n.in&&n.collapsedSize==="0px"&&e.hidden]}})(bt(({theme:t})=>({height:0,overflow:"hidden",transition:t.transitions.create("height"),variants:[{props:{orientation:"horizontal"},style:{height:"auto",width:0,transition:t.transitions.create("width")}},{props:{state:"entered"},style:{height:"auto",overflow:"visible"}},{props:{state:"entered",orientation:"horizontal"},style:{width:"auto"}},{props:({ownerState:e})=>e.state==="exited"&&!e.in&&e.collapsedSize==="0px",style:{visibility:"hidden"}}]}))),_7=oe("div",{name:"MuiCollapse",slot:"Wrapper",overridesResolver:(t,e)=>e.wrapper})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),I7=oe("div",{name:"MuiCollapse",slot:"WrapperInner",overridesResolver:(t,e)=>e.wrapperInner})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),ap=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiCollapse"}),{addEndListener:o,children:i,className:s,collapsedSize:a="0px",component:l,easing:u,in:f,onEnter:p,onEntered:m,onEntering:b,onExit:v,onExited:y,onExiting:x,orientation:S="vertical",style:k,timeout:T=nw.standard,TransitionComponent:C=Pr,...O}=r,I={...r,orientation:S,collapsedSize:a},N=O7(I),L=wo(),V=$s(),M=A.useRef(null),B=A.useRef(),H=typeof a=="number"?`${a}px`:a,F=S==="horizontal",P=F?"width":"height",_=A.useRef(null),D=Ot(n,_),R=te=>ce=>{if(te){const ne=_.current;ce===void 0?te(ne):te(ne,ce)}},j=()=>M.current?M.current[F?"clientWidth":"clientHeight"]:0,K=R((te,ce)=>{M.current&&F&&(M.current.style.position="absolute"),te.style[P]=H,p&&p(te,ce)}),U=R((te,ce)=>{const ne=j();M.current&&F&&(M.current.style.position="");const{duration:re,easing:le}=ul({style:k,timeout:T,easing:u},{mode:"enter"});if(T==="auto"){const ye=L.transitions.getAutoHeightDuration(ne);te.style.transitionDuration=`${ye}ms`,B.current=ye}else te.style.transitionDuration=typeof re=="string"?re:`${re}ms`;te.style[P]=`${ne}px`,te.style.transitionTimingFunction=le,b&&b(te,ce)}),Y=R((te,ce)=>{te.style[P]="auto",m&&m(te,ce)}),fe=R(te=>{te.style[P]=`${j()}px`,v&&v(te)}),ue=R(y),pe=R(te=>{const ce=j(),{duration:ne,easing:re}=ul({style:k,timeout:T,easing:u},{mode:"exit"});if(T==="auto"){const le=L.transitions.getAutoHeightDuration(ce);te.style.transitionDuration=`${le}ms`,B.current=le}else te.style.transitionDuration=typeof ne=="string"?ne:`${ne}ms`;te.style[P]=H,te.style.transitionTimingFunction=re,x&&x(te)}),Z=te=>{T==="auto"&&V.start(B.current||0,te),o&&o(_.current,te)};return g.jsx(C,{in:f,onEnter:K,onEntered:Y,onEntering:U,onExit:fe,onExited:ue,onExiting:pe,addEndListener:Z,nodeRef:_,timeout:T==="auto"?null:T,...O,children:(te,{ownerState:ce,...ne})=>g.jsx(M7,{as:l,className:ge(N.root,s,{entered:N.entered,exited:!f&&H==="0px"&&N.hidden}[te]),style:{[F?"minWidth":"minHeight"]:H,...k},ref:D,ownerState:{...I,state:te},...ne,children:g.jsx(_7,{ownerState:{...I,state:te},className:N.wrapper,ref:M,children:g.jsx(I7,{ownerState:{...I,state:te},className:N.wrapperInner,children:i})})})})});process.env.NODE_ENV!=="production"&&(ap.propTypes={addEndListener:c.func,children:c.node,classes:c.object,className:c.string,collapsedSize:c.oneOfType([c.number,c.string]),component:Ba,easing:c.oneOfType([c.shape({enter:c.string,exit:c.string}),c.string]),in:c.bool,onEnter:c.func,onEntered:c.func,onEntering:c.func,onExit:c.func,onExited:c.func,onExiting:c.func,orientation:c.oneOf(["horizontal","vertical"]),style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),timeout:c.oneOfType([c.oneOf(["auto"]),c.number,c.shape({appear:c.number,enter:c.number,exit:c.number})])}),ap&&(ap.muiSupportAuto=!0);const lp=Xt("MenuBar",["root","sticky","nonSticky","content"]),Yb=Ut("MenuBar"),D7=oe(ap,{name:Yb,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.disableSticky?e.nonSticky:e.sticky]})(({theme:t,ownerState:e})=>({borderBottomColor:t.palette.divider,borderBottomStyle:"solid",borderBottomWidth:1,...e.disableSticky?{}:{position:"sticky",top:e.stickyOffset,zIndex:xf.MENU_BAR,background:t.palette.background.default}})),A7=oe("div",{name:Yb,slot:"content",overridesResolver:(t,e)=>e.content})({});function P7(t){const e=rt({props:t,name:Yb}),{hide:n,disableSticky:r,stickyOffset:o=0,children:i,className:s,classes:a={},unmountOnExit:l=!0,sx:u,...f}=e,p={hide:n,disableSticky:r,stickyOffset:o,unmountOnExit:l};return g.jsx(D7,{...f,in:!n,unmountOnExit:l,className:ge([lp.root,a.root,r?[lp.nonSticky,a.nonSticky]:[lp.sticky,a.sticky],s]),ownerState:p,sx:u,children:g.jsx(A7,{className:ge([lp.content,a.content]),ownerState:p,children:i})})}const Gb=Xt("RichTextContent",["root","readonly","editable"]),uM=Ut("RichTextContent"),N7=oe(x9,{name:uM,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.editable?e.editable:e.readonly]})(({theme:t,ownerState:e})=>e.disableDefaultStyles?{}:{"& .ProseMirror":{...ca(t)}});function dM(t){const e=rt({props:t,name:uM}),{innerRef:n,className:r,classes:o={},disableDefaultStyles:i=!1,sx:s}=e,a=Tt(),l=!!(a!=null&&a.isEditable),u={editable:l,disableDefaultStyles:i},f=J.useMemo(()=>ge([Gb.root,r,o.root,l?[Gb.editable,o.editable]:[Gb.readonly,o.readonly]]),[r,o.root,o.editable,o.readonly,l]);return g.jsx(N7,{editor:a,...n?{innerRef:n}:{},ownerState:u,className:f,sx:s})}function fM({editor:t,children:e}){return g.jsx(qT.Provider,{value:t,children:e})}const Yo=Xt("RichTextField",["root","standard","outlined","menuBar","menuBarContent","content"]),pM=Ut("RichTextField"),$7=oe(a7,{name:pM,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard]})(({theme:t,ownerState:e})=>({...e.variant==="standard"&&{[`& .${Yo.content}`]:{padding:t.spacing(1.5,0)},[`& .${Yo.menuBarContent}`]:{padding:t.spacing(1,0)}},...e.variant==="outlined"&&{[`& .${Yo.content}`]:{padding:t.spacing(1.5)},[`& .${Yo.menuBarContent}`]:{padding:t.spacing(1,1.5)}}}));function L7(t){var e,n;const r=rt({props:t,name:pM}),{variant:o="outlined",controls:i,disableDebounceRenderControls:s=!1,disabled:a,className:l,classes:u={},footer:f,MenuBarProps:p,RichTextContentProps:m,sx:b,...v}=r,y=Tt(),x={variant:o,disabled:a,disableDebounceRenderControls:s},S=tM({editor:y});return g.jsxs($7,{...v,variant:o,focused:!a&&S,disabled:a,className:ge([Yo.root,u.root,o==="outlined"?[Yo.outlined,u.outlined]:[Yo.standard,u.standard],l]),ownerState:x,sx:b,children:[i&&g.jsx(P7,{...p,classes:{...p==null?void 0:p.classes,root:ge([Yo.menuBar,u.menuBar,(e=p==null?void 0:p.classes)===null||e===void 0?void 0:e.root]),content:ge([Yo.menuBarContent,u.menuBarContent,(n=p==null?void 0:p.classes)===null||n===void 0?void 0:n.content])},children:s?i:g.jsx(ob,{children:i})}),g.jsx(dM,{...m,className:ge([Yo.content,u.content,m==null?void 0:m.className])}),f]})}const hM=J.forwardRef(function({className:e,renderControls:n,RichTextFieldProps:r={},sx:o,children:i,editorDependencies:s=[],editable:a=!0,shouldRerenderOnTransaction:l=!0,...u},f){const p={editable:a,shouldRerenderOnTransaction:l,...u},m=SO(p,s);return J.useImperativeHandle(f,()=>({editor:m}),[m]),J.useEffect(()=>{!m||m.isDestroyed||m.isEditable===a||queueMicrotask(()=>{m.setEditable(a)})},[a,m]),g.jsxs(fM,{editor:m,children:[g.jsx(L7,{disabled:!a,controls:n==null?void 0:n(m),className:e,sx:o,...r}),i==null?void 0:i(m)]})});function B7({RichTextContentProps:t,sx:e,...n}){const r=SO({...n,editable:!1}),o=J.useRef(n.content);return J.useEffect(()=>{!r||r.isDestroyed||n.content===void 0||n.content===o.current||queueMicrotask(()=>{n.content!==void 0&&r.commands.setContent(n.content)})},[n.content,r]),J.useEffect(()=>{o.current=n.content},[n.content]),g.jsx(fM,{editor:r,children:g.jsx(dM,{sx:e,...t})})}function mM(t){return t.content?g.jsx(B7,{...t}):null}const Jb=Xt("TableBubbleMenu",["root","paper","content"]),gM=Ut("TableBubbleMenu"),F7=oe(Lj,{name:gM,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({maxWidth:"90vw",padding:t.spacing(.5,1)}));function R7(t){const e=rt({props:t,name:gM}),{disableDebounce:n=!1,DebounceProps:r,labels:o,classes:i={},...s}=e,a=Tt(),l=tM({editor:a}),u=J.useMemo(()=>a?{getBoundingClientRect:()=>{const p=a.isActive("table")?qg(a.state.selection.$anchor,y=>y.type.name==="table"):null;if(p){const y=a.view.nodeDOM(p.pos),x=y==null?void 0:y.querySelector("table");if(x)return x.getBoundingClientRect()}const{ranges:m}=a.state.selection,b=Math.min(...m.map(y=>y.$from.pos)),v=Math.max(...m.map(y=>y.$to.pos));return aT(a.view,b,v)}}:null,[a]);if(!(a!=null&&a.isEditable))return null;const f=g.jsx(F7,{className:ge([Jb.content,i.content]),labels:o});return g.jsx(Sy,{editor:a,open:l&&a.isActive("table"),anchorEl:u,placement:"top-start",fallbackPlacements:["bottom-start","top","bottom","top-end","bottom-end"],flipPadding:{top:35,left:8,right:8,bottom:-1/0},...s,classes:{root:ge([Jb.root,i.root]),paper:ge([Jb.paper,i.paper])},children:n?f:g.jsx(ob,{...r,children:f})})}const Xb=vr.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Ct(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),yM=vr.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Ct(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Zb,bM;function z7(){return bM||(bM=1,Zb=(function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(r,o,i){n.o(r,o)||Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:i})},n.r=function(r){Object.defineProperty(r,"__esModule",{value:!0})},n.n=function(r){var o=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(o,"a",o),o},n.o=function(r,o){return Object.prototype.hasOwnProperty.call(r,o)},n.p="/dist/",n(n.s=1)})([function(t,e,n){n.r(e);var r={equal:0,delete:1,insert:2,none:3,replace:4};class o{constructor(P,_,D){this.startInOld=P,this.startInNew=_,this.size=D}get endInOld(){return this.startInOld+this.size}get endInNew(){return this.startInNew+this.size}}class i{constructor(){this.blockSize=0,this.repeatingWordsAccuracy=0,this.ignoreWhitespaceDifferences=!1}}const s=/^\s*<\/?[^>]+>\s*$/,a=/<[^\s>]+/,l=/^(\s| )+$/,u=/[\w\#@]+/,f=["<img"];function p(F){return!f.some(P=>F!==null&&F.startsWith(P))&&s.test(F)}function m(F,P,_){return["<",P,' class="',_,'">',F,"</",P,">"].join("")}function b(F){return F==="<"}function v(F){return F==="&"}function y(F){return F===";"}function x(F){return l.test(F)}function S(F){return p(F)?(function(P){return P=a.exec(P)[0]+(P.endsWith("/>")?"/>":">")})(F):F}function k(F){return u.test(F)}function T(F,P,_){return F.push(P),F.length>_&&F.shift(),F.length!==_?null:F.join("")}class C{constructor(P,_,D,R,j,K,U){this.oldWords=P,this.newWords=_,this.startInOld=D,this.endInOld=R,this.startInNew=j,this.endInNew=K,this.options=U}indexNewWords(){this.wordIndices=new Map;let P=[];for(let _=this.startInNew;_<this.endInNew;_++){let D=T(P,this.normalizeForIndex(this.newWords[_]),this.options.blockSize);D!==null&&(this.wordIndices.has(D)?this.wordIndices.get(D).push(_):this.wordIndices.set(D,[_]))}}normalizeForIndex(P){return P=S(P),this.options.IgnoreWhiteSpaceDifferences&&x(P)?" ":P}findMatch(){if(this.indexNewWords(),this.removeRepeatingWords(),this.wordIndices.length===0)return null;let P=this.startInOld,_=this.startInNew,D=0,R=new Map;const j=this.options.blockSize;let K=[];for(let U=this.startInOld;U<this.endInOld;U++){let Y=T(K,this.normalizeForIndex(this.oldWords[U]),j);if(Y===null)continue;let fe=new Map;if(this.wordIndices.has(Y)){for(let ue of this.wordIndices.get(Y)){let pe=(R.has(ue-1)?R.get(ue-1):0)+1;fe.set(ue,pe),pe>D&&(P=U-pe-j+2,_=ue-pe-j+2,D=pe)}R=fe}else R=fe}return D!==0?new o(P,_,D+j-1):null}removeRepeatingWords(){let P=this.newWords.length+this.options.repeatingWordsAccuracy,_=Array.from(this.wordIndices.entries()).filter(D=>D[1].length>P).map(D=>D[0]);for(let D of _)this.wordIndices.delete(D)}}class O{constructor(P,_,D,R,j){this.action=P,this.startInOld=_,this.endInOld=D,this.startInNew=R,this.endInNew=j}}var I={character:0,tag:1,whitespace:2,entity:3};function N(F,P){let _={mode:I.character,currentWord:[],words:[]},D=(function(Y,fe){let ue=new Map;if(fe===null)return ue;for(let pe of fe){let Z;for(;(Z=pe.exec(Y))!==null;){if(ue.has(Z.index))throw new Error("One or more block expressions result in a text sequence that overlaps. Current expression: "+pe.toString());ue.set(Z.index,Z.index+Z[0].length)}}return ue})(F,P),R=!!D.size,j=!1,K=-1;for(let Y=0;Y<F.length;Y++){var U=F[Y];if(R&&(K===index&&(K=-1,j=!1),D.has(index)&&(j=!0,K=D.get(index)),j)){_.currentWord.push(U),_.mode=I.character;continue}switch(_.mode){case I.character:b(U)?L(_,"<",I.tag):v(U)?L(_,U,I.entity):x(U)?L(_,U,I.whitespace):k(U)&&(_.currentWord.length===0||k(_.currentWord[_.currentWord.length-1]))?_.currentWord.push(U):L(_,U,I.character);break;case I.tag:U===">"?(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.currentWord=[],_.mode=x(U)?I.whitespace:I.character):_.currentWord.push(U);break;case I.whitespace:b(U)?L(_,U,I.tag):v(U)?L(_,U,I.entity):x(U)?_.currentWord.push(U):L(_,U,I.character);break;case I.entity:if(b(U))L(_,U,I.tag);else if(x(U))L(_,U,I.whitespace);else if(y(U)){let fe=!0;if(_.currentWord.length!==0&&(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.words.length>2&&x(_.words[_.words.length-2])&&x(_.words[_.words.length-1]))){let ue=_.words[_.words.length-2],pe=_.words[_.words.length-1];_.words.splice(_.words.length-2,2),_.currentWord=[(ue+pe).split()],_.mode=I.whitespace,fe=!1}fe&&(_.currentWord=[],_.mode=I.character)}else k(U)?_.currentWord.push(U):L(_,U,I.character)}}return _.currentWord.length!==0&&_.words.push(_.currentWord.join("")),_.words}function L(F,P,_){F.currentWord.length!==0&&F.words.push(F.currentWord.join("")),F.currentWord=[P],F.mode=_}const V=4,M=new Map([["</strong>",0],["</em>",0],["</b>",0],["</i>",0],["</big>",0],["</small>",0],["</u>",0],["</sub>",0],["</strike>",0],["</s>",0]]),B=/<((strong)|(b)|(i)|(em)|(big)|(small)|(u)|(sub)|(sup)|(strike)|(s))[\>\s]+/gi;class H{constructor(P,_){this.content=[],this.newText=_,this.oldText=P,this.specialTagDiffStack=[],this.newWords=[],this.oldWords=[],this.matchGranularity=0,this.blockExpressions=[],this.repeatingWordsAccuracy=1,this.ignoreWhiteSpaceDifferences=!1,this.orphanMatchThreshold=0}build(){if(this.oldText===this.newText)return this.newText;this.splitInputsIntoWords(),this.matchGranularity=Math.min(V,this.oldWords.length,this.newWords.length);let P=this.operations();for(let _ of P)this.performOperation(_);return this.content.join("")}addBlockExpression(P){this.blockExpressions.push(P)}splitInputsIntoWords(){this.oldWords=N(this.oldText,this.blockExpressions),this.oldText=null,this.newWords=N(this.newText,this.blockExpressions),this.newText=null}performOperation(P){switch(P.action){case r.equal:this.processEqualOperation(P);break;case r.delete:this.processDeleteOperation(P,"diffdel");break;case r.insert:this.processInsertOperation(P,"diffins");break;case r.none:break;case r.replace:this.processReplaceOperation(P)}}processReplaceOperation(P){this.processDeleteOperation(P,"diffmod"),this.processInsertOperation(P,"diffmod")}processInsertOperation(P,_){let D=this.newWords.filter((R,j)=>j>=P.startInNew&&j<P.endInNew);this.insertTag("ins",_,D)}processDeleteOperation(P,_){let D=this.oldWords.filter((R,j)=>j>=P.startInOld&&j<P.endInOld);this.insertTag("del",_,D)}processEqualOperation(P){let _=this.newWords.filter((D,R)=>R>=P.startInNew&&R<P.endInNew);this.content.push(_.join(""))}insertTag(P,_,D){for(;D.length;){let R=this.extractConsecutiveWords(D,U=>!p(U)),j="",K=!1;if(R.length!==0){let U=m(R.join(""),P,_);this.content.push(U)}else{if(B.test(D[0])){if(this.specialTagDiffStack.push(D[0]),j='<ins class="mod">',P==="del")for(D.shift();D.length>0&&B.test(D[0]);)D.shift()}else if(M.has(D[0])){let U=this.specialTagDiffStack.length===0?null:this.specialTagDiffStack.pop();if(U!==null&&U===D[0].replace(/\//g,"")&&(j="</ins>",K=!0),P==="del")for(D.shift();D.length>0&&M.has(D[0]);)D.shift()}if(D.length===0&&j.length===0)break;K?this.content.push(j+this.extractConsecutiveWords(D,p).join("")):this.content.push(this.extractConsecutiveWords(D,p).join("")+j)}}}extractConsecutiveWords(P,_){let D=null;for(let R=0;R<P.length;R++){let j=P[R];if(R===0&&j===" "&&(P[R]=" "),!_(j)){D=R;break}}if(D!==null){let R=P.filter((j,K)=>K>=0&&K<D);return D>0&&P.splice(0,D),R}{let R=P.filter((j,K)=>K>=0&&K<P.length);return P.splice(0,P.length),R}}operations(){let P=0,_=0,D=[],R=this.matchingBlocks();R.push(new o(this.oldWords.length,this.newWords.length,0));let j=this.removeOrphans(R);for(let K of j){let U,Y=P===K.startInOld,fe=_===K.startInNew;(U=Y||fe?Y&&!fe?r.insert:Y?r.none:r.delete:r.replace)!==r.none&&D.push(new O(U,P,K.startInOld,_,K.startInNew)),K.length!==0&&D.push(new O(r.equal,K.startInOld,K.endInOld,K.startInNew,K.endInNew)),P=K.endInOld,_=K.endInNew}return D}*removeOrphans(P){let _=null,D=null;for(let R of P){if(D===null){_=new o(0,0,0),D=R;continue}if(_.endInOld===D.startInOld&&_.endInNew===D.startInNew||D.endInOld===R.startInOld&&D.endInNew===R.startInNew){yield D,_=D,D=R;continue}let j=(Y,fe)=>Y+fe.length,K=this.oldWords.slice(_.endInOld,R.startInOld).reduce(j,0),U=this.newWords.slice(_.endInNew,R.startInNew).reduce(j,0);this.newWords.slice(D.startInNew,D.endInNew).reduce(j,0)>Math.max(K,U)*this.orphanMatchThreshold&&(yield D),_=D,D=R}yield D}matchingBlocks(){let P=[];return this.findMatchingBlocks(0,this.oldWords.length,0,this.newWords.length,P),P}findMatchingBlocks(P,_,D,R,j){let K=this.findMatch(P,_,D,R);K!==null&&(P<K.startInOld&&D<K.startInNew&&this.findMatchingBlocks(P,K.startInOld,D,K.startInNew,j),j.push(K),K.endInOld<_&&K.endInNew<R&&this.findMatchingBlocks(K.endInOld,_,K.endInNew,R,j))}findMatch(P,_,D,R){for(let j=this.matchGranularity;j>0;j--){let K=new i;K.blockSize=j,K.repeatingWordsAccuracy=this.repeatingWordsAccuracy,K.ignoreWhitespaceDifferences=this.ignoreWhiteSpaceDifferences;let U=new C(this.oldWords,this.newWords,P,_,D,R,K).findMatch();if(U!==null)return U}return null}}H.execute=function(F,P){return new H(F,P).build()},e.default=H},function(t,e,n){t.exports=n(0)}])),Zb}var V7=z7();const H7=Un(V7),cp="rgba(194, 249, 112, .5)",up="rgba(196, 77,86,0.3)",vM=t=>{const{beforeTxt:e="",afterTxt:n="",mode:r="sentence"}=t,o=W7(e,n,r);return g.jsx(mM,{content:o,extensions:[RT,Xb,UT.configure({multicolor:!0}),yM]})},W7=(t,e,n)=>{switch(n){case"sentence":return U7(t,e);case"word":return j7(t,e);case"html":return K7(t,e);case"comma":return q7(t,e)}},Qb=(t,e)=>{if(!t.added&&!t.removed)return t.value;const n=t.added?cp:up,r=t.added?"u":"s";return`<${r}><mark key={${e}} data-color="${n}" style={{ backgroundColor: ${n}, color: "inherit"}}>${t.value}</mark></${r}>`},xM=t=>t.split(",").map(e=>e.trim()),j7=(t,e)=>X3(t,e).map(Qb).join(""),U7=(t,e)=>t4(t,e).map(Qb).join(""),q7=(t,e)=>o4(xM(t),xM(e)).map(Qb).join(", "),K7=(t,e)=>{let n=H7.execute(t,e);return n=n.replaceAll(/<ins class="(diffmod|diffins)">/g,`<u><mark data-color="${cp}" style={{ backgroundColor: ${cp}, color: "inherit" }}>`),n=n.replaceAll("</ins>","</mark></u>"),n=n.replaceAll(/<del class="(diffmod|diffdel)">/g,`<s><mark data-color="${up}" style={{ backgroundColor: ${up}, color: "inherit" }}>`),n=n.replaceAll("</del>","</mark></s>"),n},Ti=t=>{const{label:e,value:n,readOnlyValue:r,staticLabel:o,staticLabelProps:i,showDiff:s=!1,diffSnapshot:a,diffMode:l,...u}=t,f=()=>s?g.jsx(vM,{beforeTxt:a,afterTxt:n,mode:l,...u}):r||g.jsx(z.Typography,{"data-testid":"read-only-value",children:n});return g.jsxs(z.Box,{width:"100%",mb:"8px",children:[o?g.jsx(z.Typography,{...i,children:e}):g.jsx(z.InputLabel,{children:e}),f()]})},wM=t=>{const{name:e,label:n=Ln(e),options:r=[],filterSelectedOptions:o=!0,variant:i="outlined",staticLabel:s=!1,staticLabelProps:a={fontSize:".9em",color:"#808080"},readOnly:l,margin:u="dense",fullWidth:f=!0,required:p,onChange:m,clearOnSelect:b=!1,onInputChange:v,getOptionLabel:y=R=>typeof R=="string"?R:String(R),isOptionEqualToValue:x=(R,j)=>JSON.stringify(R)===JSON.stringify(j),useFieldAsValue:S,errorMode:k="normal",...T}=t,[C,O,I]=Ht.useField(e),{setValue:N}=I,{error:L}=O,[V,M]=A.useState(""),B={...lr(T,["useFieldAsValue","errorMode"]),getOptionLabel:y,options:r,filterSelectedOptions:o,isOptionEqualToValue:x,renderInput:R=>g.jsx(z.TextField,{...R,variant:i,label:s?void 0:n,error:!!L,required:p}),onChange:(R,j,K,U)=>{b?(M(""),N(null)):N(S?j?j[S]:null:j),m&&m(R,j,K,U)},onInputChange:(R,j,K)=>{M(j),v&&v(R,j,K)},fullWidth:!0,inputValue:V,value:S?r.find(R=>R[S]===C.value)||null:C.value,slotProps:{paper:{elevation:8,sx:{borderRadius:2}}}},H=R=>{if(R==null)return"";if(S){const j=r.find(K=>K[S]===R);return j?y(j):""}return y(R)},F=Vs(),P=l??F,{showDiff:_,getPreviousValue:D}=Hs();return P||_?g.jsx(Ti,{label:n,value:H(C.value),staticLabel:s,staticLabelProps:a,showDiff:_,diffSnapshot:H(D(e))}):g.jsxs(z.FormControl,{margin:u,fullWidth:f,required:p,children:[s&&g.jsx(z.Typography,{...a,children:n}),g.jsxs(z.Box,{children:[g.jsx(z.Autocomplete,{...B}),g.jsx(yr,{name:e,id:`${e}-err`,errorMode:k})]})]})};var du={exports:{}};/**
|
|
356
|
+
*/var xO;function T9(){return xO||(xO=1,process.env.NODE_ENV!=="production"&&(function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var t=J,e=Xf;function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,i=t.useRef,s=t.useEffect,a=t.useMemo,l=t.useDebugValue;function u(f,p,m,b,v){var y=i(null),x;y.current===null?(x={hasValue:!1,value:null},y.current=x):x=y.current;var S=a(function(){var O=!1,I,N,L=function(H){if(!O){O=!0,I=H;var F=b(H);if(v!==void 0&&x.hasValue){var P=x.value;if(v(P,F))return N=P,P}return N=F,F}var _=I,D=N;if(r(_,H))return D;var R=b(H);return v!==void 0&&v(D,R)?D:(I=H,N=R,R)},V=m===void 0?null:m,M=function(){return L(p())},B=V===null?void 0:function(){return L(V())};return[M,B]},[p,m,b,v]),k=S[0],T=S[1],C=o(f,k,T);return s(function(){x.hasValue=!0,x.value=C},[C]),l(C),C}Eb.useSyncExternalStoreWithSelector=u,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)})()),Eb}process.env.NODE_ENV==="production"?Tb.exports=C9():Tb.exports=T9();var k9=Tb.exports;const E9=typeof window<"u"?J.useLayoutEffect:J.useEffect;class O9{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const n=()=>{this.transactionNumber+=1,this.subscribers.forEach(o=>o())},r=this.editor;return r.on("transaction",n),()=>{r.off("transaction",n)}}}}function M9(t){var e;const[n]=J.useState(()=>new O9(t.editor)),r=k9.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:S9);return E9(()=>n.watch(t.editor),[t.editor,n]),J.useDebugValue(r),r}const wO=process.env.NODE_ENV!=="production",Ob=typeof window>"u",_9=Ob||!!(typeof window<"u"&&window.next);class Mb{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Ob||_9?(wO&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Ob&&wO)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onBeforeCreate)===null||i===void 0?void 0:i.call(o,...r)},onBlur:(...r)=>{var o,i;return(i=(o=this.options.current).onBlur)===null||i===void 0?void 0:i.call(o,...r)},onCreate:(...r)=>{var o,i;return(i=(o=this.options.current).onCreate)===null||i===void 0?void 0:i.call(o,...r)},onDestroy:(...r)=>{var o,i;return(i=(o=this.options.current).onDestroy)===null||i===void 0?void 0:i.call(o,...r)},onFocus:(...r)=>{var o,i;return(i=(o=this.options.current).onFocus)===null||i===void 0?void 0:i.call(o,...r)},onSelectionUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onSelectionUpdate)===null||i===void 0?void 0:i.call(o,...r)},onTransaction:(...r)=>{var o,i;return(i=(o=this.options.current).onTransaction)===null||i===void 0?void 0:i.call(o,...r)},onUpdate:(...r)=>{var o,i;return(i=(o=this.options.current).onUpdate)===null||i===void 0?void 0:i.call(o,...r)},onContentError:(...r)=>{var o,i;return(i=(o=this.options.current).onContentError)===null||i===void 0?void 0:i.call(o,...r)},onDrop:(...r)=>{var o,i;return(i=(o=this.options.current).onDrop)===null||i===void 0?void 0:i.call(o,...r)},onPaste:(...r)=>{var o,i;return(i=(o=this.options.current).onPaste)===null||i===void 0?void 0:i.call(o,...r)}};return new l3(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((o,i)=>{var s;return o===((s=n.extensions)===null||s===void 0?void 0:s[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Mb.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,o)=>r===e[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function SO(t={},e=[]){const n=J.useRef(t);n.current=t;const[r]=J.useState(()=>new Mb(n)),o=Xf.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return J.useDebugValue(o),J.useEffect(r.onRender(e)),M9({editor:o,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&i===0?0:i+1}),o}J.createContext({editor:null}).Consumer;const CO=J.createContext({onDragStart:void 0}),TO=()=>J.useContext(CO),I9=t=>{const e=t.as||"div",{nodeViewContentRef:n}=TO();return J.createElement(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style}})},_b=J.forwardRef((t,e)=>{const{onDragStart:n}=TO(),r=t.as||"div";return J.createElement(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function kO(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function EO(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function D9(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function A9(t){if(kO(t)||EO(t))return!0;if(D9(t)){const e=t.type;if(e)return kO(e)||EO(e)}return!1}function P9(){try{if(J.version)return parseInt(J.version.split(".")[0],10)>=19}catch{}return!1}class OO{constructor(e,{editor:n,props:r={},as:o="div",className:i=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=n,this.props=r,this.element=document.createElement(o),this.element.classList.add("react-renderer"),i&&this.element.classList.add(...i.split(" ")),this.editor.isInitialized?Ps.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var e;const n=this.component,r=this.props,o=this.editor,i=P9(),s=A9(n),a={...r};a.ref&&!(i||s)&&delete a.ref,!a.ref&&(i||s)&&(a.ref=l=>{this.ref=l}),this.reactElement=J.createElement(n,{...a}),(e=o==null?void 0:o.contentComponent)===null||e===void 0||e.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e;const n=this.editor;(e=n==null?void 0:n.contentComponent)===null||e===void 0||e.removeRenderer(this.id)}updateAttributes(e){Object.keys(e).forEach(n=>{this.element.setAttribute(n,e[n])})}}class N9 extends c3{constructor(e,n,r){if(super(e,n,r),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const o=this.dom.querySelector("[data-node-view-content]");if(!o)return;o.appendChild(this.contentDOMElement)}}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(u={})=>this.updateAttributes(u),deleteNode:()=>this.deleteNode(),ref:J.createRef()};if(!this.component.displayName){const u=f=>f.charAt(0).toUpperCase()+f.substring(1);this.component.displayName=u(this.extension.name)}const o={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:u=>{u&&this.contentDOMElement&&u.firstChild!==this.contentDOMElement&&(u.hasAttribute("data-node-view-wrapper")&&u.removeAttribute("data-node-view-wrapper"),u.appendChild(this.contentDOMElement))}},i=this.component,s=J.memo(u=>J.createElement(CO.Provider,{value:o},J.createElement(i,u)));s.displayName="ReactNodeView";let a=this.node.isInline?"span":"div";this.options.as&&(a=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new OO(s,{editor:this.editor,props:e,as:a,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:n}=this.editor.state.selection,r=this.getPos();if(typeof r=="number")if(e<=r&&n>=r+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,n,r){const o=i=>{this.renderer.updateProps(i),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations,a=this.innerDecorations;return this.node=e,this.decorations=n,this.innerDecorations=r,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:n,oldInnerDecorations:a,innerDecorations:r,updateProps:()=>o({node:e,decorations:n,innerDecorations:r})})}return e===this.node&&this.decorations===n&&this.innerDecorations===r||(this.node=e,this.decorations=n,this.innerDecorations=r,o({node:e,decorations:n,innerDecorations:r})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let e={};if(typeof this.options.attrs=="function"){const n=this.editor.extensionManager.attributes,r=Zd(this.node,n);e=this.options.attrs({node:this.node,HTMLAttributes:r})}else e=this.options.attrs;this.renderer.updateAttributes(e)}}}function Ib(t,e){return n=>n.editor.contentComponent?new N9(t,n,e):{}}const lu=Xt("HeadingWithAnchorComponent",["root","container","link","linkIcon"]),cu=Ut("HeadingWithAnchorComponent"),$9=oe(_b,{name:cu,slot:"root",overridesResolver:(t,e)=>e.root,shouldForwardProp:t=>t!=="ownerState"&&t!=="theme"&&t!=="sx"})({[`&:hover .${lu.link}`]:{opacity:100}}),L9=oe("span",{name:cu,slot:"container",overridesResolver:(t,e)=>e.container})({display:"inline-block",position:"relative"}),B9=oe("a",{name:cu,slot:"link",overridesResolver:(t,e)=>e.link})(({theme:t})=>({position:"absolute",left:-21,color:`${t.palette.text.secondary} !important`,opacity:0,transition:t.transitions.create("opacity"),textDecoration:"none",outline:"none",[t.breakpoints.down("sm")]:{left:-18},'.ProseMirror[contenteditable="true"] &':{display:"none"}})),F9=oe(Hf,{name:cu,slot:"linkIcon",overridesResolver:(t,e)=>e.linkIcon})(({theme:t})=>({transform:"rotate(-45deg)",fontSize:"1.25rem",[t.breakpoints.down("sm")]:{fontSize:"1.15rem"}}));function R9(t){const e=rt({props:t,name:cu}),{editor:n,node:r,extension:o,classes:i={},sx:s}=e,u=`h${o.options.levels.includes(r.attrs.level)?r.attrs.level:o.options.levels[0]}`,f=J.useMemo(()=>jg(n.schema),[n.schema]),p=I6(oT(r,{textSerializers:f}));return g.jsx($9,{as:u,id:p,...o.options.HTMLAttributes,className:ge([lu.root,i.root]),style:{textAlign:r.attrs.textAlign},sx:s,children:g.jsxs(L9,{className:ge([lu.container,i.container]),children:[g.jsx(B9,{href:`#${p}`,contentEditable:!1,className:ge([lu.link,i.link]),children:g.jsx(F9,{className:ge([lu.linkIcon,i.linkIcon])})}),g.jsx(I9,{as:"span"})]})})}const z9=ST.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),scrollToAnchorOnMount:!0}},onCreate(){this.options.scrollToAnchorOnMount&&setTimeout(()=>{V9(this.editor)})},addNodeView(){return Ib(R9)}});function V9(t){if(t.isDestroyed||!("heading"in t.storage))return;const n=window.location.hash.slice(1);if(!n)return;const r=window.document.getElementById(n);r&&t.view.dom.contains(r)&&r.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})}var fr;(function(t){t[t.HIDDEN=0]="HIDDEN",t[t.VIEW_LINK_DETAILS=1]="VIEW_LINK_DETAILS",t[t.EDIT_LINK=2]="EDIT_LINK"})(fr||(fr={}));const H9=cn.create({name:"linkBubbleMenuHandler",addStorage(){return{state:fr.HIDDEN,bubbleMenuOptions:void 0}},addCommands(){return{openLinkBubbleMenu:(t={})=>({editor:e,chain:n,dispatch:r})=>{const o=this.storage.state;let i;return e.isActive("link")?(o!==fr.VIEW_LINK_DETAILS&&n().extendMarkRange("link").focus().run(),i=fr.VIEW_LINK_DETAILS):i=fr.EDIT_LINK,r&&(this.storage.state=i,this.storage.bubbleMenuOptions=t),!0},editLinkInBubbleMenu:()=>({dispatch:t})=>{const e=this.storage.state,n=fr.EDIT_LINK;return e===n?!1:(t&&(this.storage.state=n),!0)},closeLinkBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.state===fr.HIDDEN?!1:(t.focus(),e&&(this.storage.state=fr.HIDDEN),!0)}},onSelectionUpdate(){this.storage.state===fr.EDIT_LINK?this.editor.commands.closeLinkBubbleMenu():this.storage.state===fr.VIEW_LINK_DETAILS&&!this.editor.isActive("link")&&this.editor.commands.closeLinkBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-u":()=>(this.editor.commands.openLinkBubbleMenu(),!0)}},addProseMirrorPlugins(){return[new en({key:new On("handleClickLinkForMenu"),props:{handleClick:(t,e,n)=>{const r=Yg(t.state,"link");return n.target.closest("a")&&r.href&&this.storage.state===fr.HIDDEN?this.editor.commands.openLinkBubbleMenu():this.editor.commands.closeLinkBubbleMenu(),!1}}})]}}),W9=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,j9=tn.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Ct(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[cT({find:W9,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}});var Db={},MO;function U9(){return MO||(MO=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ME();function n(r,o=0,i={}){const{leading:s=!0,trailing:a=!0}=i;return e.debounce(r,o,{leading:s,maxWait:o,trailing:a})}t.throttle=n})(Db)),Db}var Ab,_O;function q9(){return _O||(_O=1,Ab=U9().throttle),Ab}var K9=q9();const Y9=Un(K9),Zf=Xt("ResizableImageComponent",["imageContainer","image","imageSelected","resizer"]),G9=Xt("ResizableImageResizer",["root"]),IO=Ut("ResizableImageResizer"),J9=oe("div",{name:IO,slot:"root",overridesResolver:(t,e)=>e.root})(({theme:t})=>({position:"absolute",bottom:-3,right:-3,width:12,height:12,background:t.palette.primary.main,cursor:"nwse-resize"}));function X9(t){const e=rt({props:t,name:IO}),{onResize:n,className:r,mouseDown:o,setMouseDown:i,classes:s={},sx:a}=e;J.useEffect(()=>{if(!o)return;const u=f=>{n(f)};return window.addEventListener("mousemove",u),()=>{window.removeEventListener("mousemove",u)}},[o,n]),J.useEffect(()=>{const u=()=>{i(!1)};return window.addEventListener("mouseup",u),()=>{window.removeEventListener("mouseup",u)}},[i]);const l=J.useCallback(u=>{u.preventDefault(),u.stopPropagation(),i(!0)},[i]);return g.jsx(J9,{className:ge([G9.root,r,s.root]),onMouseDown:l,sx:a})}const Z9=15,Qf=Ut("ResizableImageComponent"),Q9=oe("div",{name:Qf,slot:"imageContainer",overridesResolver:(t,e)=>e.imageContainer})(()=>({display:"inline-flex",position:"relative"})),e8=oe("img",{name:Qf,slot:"image",overridesResolver:(t,e)=>[e.image,t.ownerState.selectedOrResizing&&e.imageSelected]})(({theme:t,ownerState:e})=>({display:"block",...e.selectedOrResizing&&{outline:`3px solid ${t.palette.primary.main}`}})),t8=oe(X9,{name:Qf,slot:"resizer",overridesResolver:(t,e)=>e.resizer})(()=>({'.ProseMirror[contenteditable="false"] &':{display:"none"}}));function n8(t){var e,n,r;const o=rt({props:t,name:Qf}),{node:i,selected:s,updateAttributes:a,extension:l,classes:u={},sx:f}=o,{attrs:p}=i,m=J.useRef(null),[b,v]=J.useState(!1),y=s||b,x={selected:s,selectedOrResizing:y},S=J.useMemo(()=>Y9(T=>{if(!m.current)return;const C=m.current.getBoundingClientRect(),O=T.clientX-C.x,I=T.clientY-C.y,N=Math.max(O,C.width/C.height*I,Z9);a({width:Math.round(N)})},50,{trailing:!0}),[a]),k=l.options.ChildComponent;return g.jsx(_b,{style:{textAlign:p.textAlign,width:"100%"},as:l.options.inline?"span":"div",sx:f,children:g.jsxs(Q9,{className:ge([Zf.imageContainer,u.imageContainer]),children:[g.jsx(e8,{ref:m,src:p.src,height:"auto",width:p.width?p.width:void 0,alt:(e=p.alt)!==null&&e!==void 0?e:void 0,title:(n=p.title)!==null&&n!==void 0?n:void 0,className:ge([Zf.image,u.image,y&&"ProseMirror-selectednode",y&&[Zf.imageSelected,u.imageSelected]]),style:{maxWidth:p.width?void 0:"auto",aspectRatio:(r=p.aspectRatio)!==null&&r!==void 0?r:void 0},ownerState:x,"data-drag-handle":!0,onLoad:T=>{const C={};p.width||(C.width=T.currentTarget.naturalWidth),p.aspectRatio||(C.aspectRatio=String(T.currentTarget.naturalWidth/T.currentTarget.naturalHeight)),(C.width||C.aspectRatio)&&a(C)}}),y&&g.jsx(t8,{onResize:S,className:ge([Zf.resizer,u.resizer]),mouseDown:b,setMouseDown:v}),k&&g.jsx(k,{...o})]})})}const r8=j9.extend({addOptions(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),isAllowedImgSrc:e=>!!e}},addAttributes(){var t;return{...(t=this.parent)===null||t===void 0?void 0:t.call(this),width:{default:null,renderHTML:e=>({width:e.width}),parseHTML:e=>e.getAttribute("width")},aspectRatio:{default:null,renderHTML:e=>e.aspectRatio?{style:`aspect-ratio: ${e.aspectRatio}`}:{},parseHTML:e=>e.style.aspectRatio}}},renderHTML({HTMLAttributes:t}){return["img",Ct({height:"auto"},this.options.HTMLAttributes,t)]},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])',getAttrs:t=>{if(!(t instanceof Element))return!1;const e=t.getAttribute("src");return this.options.isAllowedImgSrc(e)&&null}}]},addInputRules(){var t;const e=(t=this.parent)===null||t===void 0?void 0:t.call(this);if(!e)return[];const n=r=>{const[,,o,i,s]=r;return{src:i,alt:o,title:s}};return e.map(r=>new Ec({find:r.find,handler:o=>{const i=n(o.match);if(this.options.isAllowedImgSrc(i.src))return r.handler(o)}}))},addNodeView(){return Ib(n8)}});let Pb,Nb;if(typeof WeakMap<"u"){let t=new WeakMap;Pb=e=>t.get(e),Nb=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Pb=r=>{for(let o=0;o<t.length;o+=2)if(t[o]==r)return t[o+1]},Nb=(r,o)=>(n==10&&(n=0),t[n++]=r,t[n++]=o)}var fn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,o=e/this.width|0;let i=r+1,s=o+1;for(let a=1;i<this.width&&this.map[e+a]==n;a++)i++;for(let a=1;s<this.height&&this.map[e+this.width*a]==n;a++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:o,top:i,bottom:s}=this.findCell(t);return e=="horiz"?(n<0?r==0:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?i==0:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(t,e){const{left:n,right:r,top:o,bottom:i}=this.findCell(t),{left:s,right:a,top:l,bottom:u}=this.findCell(e);return{left:Math.min(n,s),top:Math.min(o,l),right:Math.max(r,a),bottom:Math.max(i,u)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let o=t.left;o<t.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,!(o==t.left&&o&&this.map[i-1]==s||r==t.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(t,e,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==t){let s=e+t*this.width;const a=(t+1)*this.width;for(;s<a&&this.map[s]<o;)s++;return s==a?i-1:this.map[s]}o=i}}static get(t){return Pb(t)||Nb(t,o8(t))}};function o8(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=i8(t),n=t.childCount,r=[];let o=0,i=null;const s=[];for(let u=0,f=e*n;u<f;u++)r[u]=0;for(let u=0,f=0;u<n;u++){const p=t.child(u);f++;for(let v=0;;v++){for(;o<r.length&&r[o]!=0;)o++;if(v==p.childCount)break;const y=p.child(v),{colspan:x,rowspan:S,colwidth:k}=y.attrs;for(let T=0;T<S;T++){if(T+u>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:f,n:S-T});break}const C=o+T*e;for(let O=0;O<x;O++){r[C+O]==0?r[C+O]=f:(i||(i=[])).push({type:"collision",row:u,pos:f,n:x-O});const I=k&&k[O];if(I){const N=(C+O)%e*2,L=s[N];L==null||L!=I&&s[N+1]==1?(s[N]=I,s[N+1]=1):L==I&&s[N+1]++}}}o+=x,f+=y.nodeSize}const m=(u+1)*e;let b=0;for(;o<m;)r[o++]==0&&b++;b&&(i||(i=[])).push({type:"missing",row:u,n:b}),f++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const a=new fn(e,n,r,i);let l=!1;for(let u=0;!l&&u<s.length;u+=2)s[u]!=null&&s[u+1]<n&&(l=!0);return l&&s8(a,s,t),a}function i8(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const o=t.child(r);let i=0;if(n)for(let s=0;s<r;s++){const a=t.child(s);for(let l=0;l<a.childCount;l++){const u=a.child(l);s+u.attrs.rowspan>r&&(i+=u.attrs.colspan)}}for(let s=0;s<o.childCount;s++){const a=o.child(s);i+=a.attrs.colspan,a.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function s8(t,e,n){t.problems||(t.problems=[]);const r={};for(let o=0;o<t.map.length;o++){const i=t.map[o];if(r[i])continue;r[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let a=null;const l=s.attrs;for(let u=0;u<l.colspan;u++){const f=e[(o+u)%t.width*2];f!=null&&(!l.colwidth||l.colwidth[u]!=f)&&((a||(a=a8(l)))[u]=f)}a&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function a8(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function or(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],o=r.spec.tableRole;o&&(e[o]=r)}}return e}const ys=new On("selectingCells");function El(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function l8(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Eo(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function ep(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=El(e.$head)||c8(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function c8(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function $b(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function u8(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Lb(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function DO(t,e,n){const r=t.node(-1),o=fn.get(r),i=t.start(-1),s=o.nextCell(t.pos-i,e,n);return s==null?null:t.node(0).resolve(i+s)}function pa(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function AO(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<n;o++)r.colwidth.splice(e,0,0)}return r}function d8(t,e,n){const r=or(e.type.schema).header_cell;for(let o=0;o<t.height;o++)if(e.nodeAt(t.map[n+o*t.width]).type!=r)return!1;return!0}var Wt=class Wi extends nt{constructor(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,n.pos-i),a=e.node(0),l=o.cellsInRect(s).filter(f=>f!=n.pos-i);l.unshift(n.pos-i);const u=l.map(f=>{const p=r.nodeAt(f);if(!p)throw new RangeError(`No cell with offset ${f} found`);const m=i+f+1;return new aS(a.resolve(m),a.resolve(m+p.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),o=e.resolve(n.map(this.$headCell.pos));if($b(r)&&$b(o)&&Lb(r,o)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Wi.rowSelection(r,o):i&&this.isColSelection()?Wi.colSelection(r,o):new Wi(r,o)}return Xe.between(r,o)}content(){const e=this.$anchorCell.node(-1),n=fn.get(e),r=this.$anchorCell.start(-1),o=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let l=o.top;l<o.bottom;l++){const u=[];for(let f=l*n.width+o.left,p=o.left;p<o.right;p++,f++){const m=n.map[f];if(i[m])continue;i[m]=!0;const b=n.findCell(m);let v=e.nodeAt(m);if(!v)throw new RangeError(`No cell with offset ${m} found`);const y=o.left-b.left,x=b.right-o.right;if(y>0||x>0){let S=v.attrs;if(y>0&&(S=pa(S,0,y)),x>0&&(S=pa(S,S.colspan-x,x)),b.left<o.left){if(v=v.type.createAndFill(S),!v)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(S)}`)}else v=v.type.create(S,v.content)}if(b.top<o.top||b.bottom>o.bottom){const S={...v.attrs,rowspan:Math.min(b.bottom,o.bottom)-Math.max(b.top,o.top)};b.top<o.top?v=v.type.createAndFill(S):v=v.type.create(S,v.content)}u.push(v)}s.push(e.child(l).copy(Oe.from(u)))}const a=this.isColSelection()&&this.isRowSelection()?e:s;return new Fe(Oe.from(a),1,1)}replace(e,n=Fe.empty){const r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){const{$from:a,$to:l}=o[s],u=e.mapping.slice(r);e.replace(u.map(a.pos),u.map(l.pos),s?Fe.empty:n)}const i=nt.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Fe(Oe.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=fn.get(n),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(n.nodeAt(i[s]),o+i[s])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.top<=a.top?(s.top>0&&(e=l.resolve(i+o.map[s.left])),a.bottom<o.height&&(n=l.resolve(i+o.map[o.width*(o.height-1)+a.right-1]))):(a.top>0&&(n=l.resolve(i+o.map[a.left])),s.bottom<o.height&&(e=l.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new Wi(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=fn.get(e),r=this.$anchorCell.start(-1),o=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;const s=o+this.$anchorCell.nodeAfter.attrs.colspan,a=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,a)==n.width}eq(e){return e instanceof Wi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),o=fn.get(r),i=e.start(-1),s=o.findCell(e.pos-i),a=o.findCell(n.pos-i),l=e.node(0);return s.left<=a.left?(s.left>0&&(e=l.resolve(i+o.map[s.top*o.width])),a.right<o.width&&(n=l.resolve(i+o.map[o.width*(a.top+1)-1]))):(a.left>0&&(n=l.resolve(i+o.map[a.top*o.width])),s.right<o.width&&(e=l.resolve(i+o.map[o.width*(s.top+1)-1]))),new Wi(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Wi(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Wi(e.resolve(n),e.resolve(r))}getBookmark(){return new f8(this.$anchorCell.pos,this.$headCell.pos)}};Wt.prototype.visible=!1,nt.jsonID("cell",Wt);var f8=class TP{constructor(e,n){this.anchor=e,this.head=n}map(e){return new TP(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Lb(n,r)?new Wt(n,r):nt.near(r,1)}};function p8(t){if(!(t.selection instanceof Wt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Yn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Jt.create(t.doc,e)}function h8({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,o=t.depth;for(;o>=0&&!(t.after(o+1)<t.end(o));o--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(o).type.spec.tableRole)}function m8({$from:t,$to:e}){let n,r;for(let o=t.depth;o>0;o--){const i=t.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function g8(t,e,n){const r=(e||t).selection,o=(e||t).doc;let i,s;if(r instanceof Je&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=Wt.create(o,r.from);else if(s=="row"){const a=o.resolve(r.from+1);i=Wt.rowSelection(a,a)}else if(!n){const a=fn.get(r.node),l=r.from+1,u=l+a.map[a.width*a.height-1];i=Wt.create(o,l+1,u)}}else r instanceof Xe&&h8(r)?i=Xe.create(o,r.from):r instanceof Xe&&m8(r)&&(i=Xe.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const y8=new On("fix-tables");function PO(t,e,n,r){const o=t.childCount,i=e.childCount;e:for(let s=0,a=0;s<i;s++){const l=e.child(s);for(let u=a,f=Math.min(o,s+3);u<f;u++)if(t.child(u)==l){a=u+1,n+=l.nodeSize;continue e}r(l,n),a<o&&t.child(a).sameMarkup(l)?PO(t.child(a),l,n+1,r):l.nodesBetween(0,l.content.size,r,n+1),n+=l.nodeSize}}function NO(t,e){let n;const r=(o,i)=>{o.type.spec.tableRole=="table"&&(n=b8(t,o,i,n))};return e?e.doc!=t.doc&&PO(e.doc,t.doc,0,r):t.doc.descendants(r),n}function b8(t,e,n,r){const o=fn.get(e);if(!o.problems)return r;r||(r=t.tr);const i=[];for(let l=0;l<o.height;l++)i.push(0);for(let l=0;l<o.problems.length;l++){const u=o.problems[l];if(u.type=="collision"){const f=e.nodeAt(u.pos);if(!f)continue;const p=f.attrs;for(let m=0;m<p.rowspan;m++)i[u.row+m]+=u.n;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,pa(p,p.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,rowspan:f.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){const f=e.nodeAt(u.pos);if(!f)continue;r.setNodeMarkup(r.mapping.map(n+1+u.pos),null,{...f.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){const f=r.mapping.map(n);r.delete(f,f+e.nodeSize)}}let s,a;for(let l=0;l<i.length;l++)i[l]&&(s==null&&(s=l),a=l);for(let l=0,u=n+1;l<o.height;l++){const f=e.child(l),p=u+f.nodeSize,m=i[l];if(m>0){let b="cell";f.firstChild&&(b=f.firstChild.type.spec.tableRole);const v=[];for(let x=0;x<m;x++){const S=or(t.schema)[b].createAndFill();S&&v.push(S)}const y=(l==0||s==l-1)&&a==l?u+1:p-1;r.insert(r.mapping.map(y),v)}u=p}return r.setMeta(y8,{fixTables:!0})}function Ko(t){const e=t.selection,n=ep(t),r=n.node(-1),o=n.start(-1),i=fn.get(r);return{...e instanceof Wt?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function $O(t,{map:e,tableStart:n,table:r},o){let i=o>0?-1:0;d8(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){const a=s*e.width+o;if(o>0&&o<e.width&&e.map[a-1]==e.map[a]){const l=e.map[a],u=r.nodeAt(l);t.setNodeMarkup(t.mapping.map(n+l),null,AO(u.attrs,o-e.colCount(l))),s+=u.attrs.rowspan-1}else{const l=i==null?or(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,u=e.positionAt(s,o,r);t.insert(t.mapping.map(n+u),l.createAndFill())}}return t}function v8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e($O(t.tr,n,n.left))}return!0}function x8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e($O(t.tr,n,n.right))}return!0}function w8(t,{map:e,table:n,tableStart:r},o){const i=t.mapping.maps.length;for(let s=0;s<e.height;){const a=s*e.width+o,l=e.map[a],u=n.nodeAt(l),f=u.attrs;if(o>0&&e.map[a-1]==l||o<e.width-1&&e.map[a+1]==l)t.setNodeMarkup(t.mapping.slice(i).map(r+l),null,pa(f,o-e.colCount(l)));else{const p=t.mapping.slice(i).map(r+l);t.delete(p,p+u.nodeSize)}s+=f.rowspan}}function S8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let o=n.right-1;w8(r,n,o),o!=n.left;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=fn.get(i)}e(r)}return!0}function C8(t,e,n){var r;const o=or(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function LO(t,{map:e,tableStart:n,table:r},o){let i=n;for(let u=0;u<o;u++)i+=r.child(u).nodeSize;const s=[];let a=o>0?-1:0;C8(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let u=0,f=e.width*o;u<e.width;u++,f++)if(o>0&&o<e.height&&e.map[f]==e.map[f-e.width]){const p=e.map[f],m=r.nodeAt(p).attrs;t.setNodeMarkup(n+p,null,{...m,rowspan:m.rowspan+1}),u+=m.colspan-1}else{var l;const p=a==null?or(r.type.schema).cell:(l=r.nodeAt(e.map[f+a*e.width]))===null||l===void 0?void 0:l.type,m=p==null?void 0:p.createAndFill();m&&s.push(m)}return t.insert(i,or(r.type.schema).row.create(null,s)),t}function T8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e(LO(t.tr,n,n.top))}return!0}function k8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t);e(LO(t.tr,n,n.bottom))}return!0}function E8(t,{map:e,table:n,tableStart:r},o){let i=0;for(let u=0;u<o;u++)i+=n.child(u).nodeSize;const s=i+n.child(o).nodeSize,a=t.mapping.maps.length;t.delete(i+r,s+r);const l=new Set;for(let u=0,f=o*e.width;u<e.width;u++,f++){const p=e.map[f];if(!l.has(p)){if(l.add(p),o>0&&p==e.map[f-e.width]){const m=n.nodeAt(p).attrs;t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m,rowspan:m.rowspan-1}),u+=m.colspan-1}else if(o<e.height&&p==e.map[f+e.width]){const m=n.nodeAt(p),b=m.attrs,v=m.type.create({...b,rowspan:m.attrs.rowspan-1},m.content),y=e.positionAt(o+1,u,n);t.insert(t.mapping.slice(a).map(r+y),v),u+=b.colspan-1}}}}function O8(t,e){if(!Eo(t))return!1;if(e){const n=Ko(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let o=n.bottom-1;E8(r,n,o),o!=n.top;o--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=fn.get(n.table)}e(r)}return!0}function BO(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function M8({width:t,height:e,map:n},r){let o=r.top*t+r.left,i=o,s=(r.bottom-1)*t+r.left,a=o+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[a]==n[a+1])return!0;i+=t,a+=t}for(let l=r.left;l<r.right;l++){if(r.top>0&&n[o]==n[o-t]||r.bottom<e&&n[s]==n[s+t])return!0;o++,s++}return!1}function FO(t,e){const n=t.selection;if(!(n instanceof Wt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Ko(t),{map:o}=r;if(M8(o,r))return!1;if(e){const i=t.tr,s={};let a=Oe.empty,l,u;for(let f=r.top;f<r.bottom;f++)for(let p=r.left;p<r.right;p++){const m=o.map[f*o.width+p],b=r.table.nodeAt(m);if(!(s[m]||!b))if(s[m]=!0,l==null)l=m,u=b;else{BO(b)||(a=a.append(b.content));const v=i.mapping.map(m+r.tableStart);i.delete(v,v+b.nodeSize)}}if(l==null||u==null)return!0;if(i.setNodeMarkup(l+r.tableStart,null,{...AO(u.attrs,u.attrs.colspan,r.right-r.left-u.attrs.colspan),rowspan:r.bottom-r.top}),a.size>0){const f=l+1+u.content.size,p=BO(u)?l+1:f;i.replaceWith(p+r.tableStart,f+r.tableStart,a)}i.setSelection(new Wt(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function RO(t,e){const n=or(t.schema);return _8(({node:r})=>n[r.type.spec.tableRole])(t,e)}function _8(t){return(e,n)=>{const r=e.selection;let o,i;if(r instanceof Wt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=l8(r.$from),!o)return!1;i=(s=El(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let a=o.attrs;const l=[],u=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});const f=Ko(e),p=e.tr;for(let b=0;b<f.right-f.left;b++)l.push(u?{...a,colwidth:u&&u[b]?[u[b]]:null}:a);let m;for(let b=f.top;b<f.bottom;b++){let v=f.map.positionAt(b,f.left,f.table);b==f.top&&(v+=o.nodeSize);for(let y=f.left,x=0;y<f.right;y++,x++)y==f.left&&b==f.top||p.insert(m=p.mapping.map(v+f.tableStart,1),t({node:o,row:b,col:y}).createAndFill(l[x]))}p.setNodeMarkup(i,t({node:o,row:f.top,col:f.left}),l[0]),r instanceof Wt&&p.setSelection(new Wt(p.doc.resolve(r.$anchorCell.pos),m?p.doc.resolve(m):void 0)),n(p)}return!0}}function I8(t,e){return function(n,r){if(!Eo(n))return!1;const o=ep(n);if(o.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Wt?n.selection.forEachCell((s,a)=>{s.attrs[t]!==e&&i.setNodeMarkup(a,null,{...s.attrs,[t]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function D8(t){return function(e,n){if(!Eo(e))return!1;if(n){const r=or(e.schema),o=Ko(e),i=e.tr,s=o.map.cellsInRect(t=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:t=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),a=s.map(l=>o.table.nodeAt(l));for(let l=0;l<s.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[l],r.cell,a[l].attrs);if(i.steps.length===0)for(let l=0;l<s.length;l++)i.setNodeMarkup(o.tableStart+s[l],r.header_cell,a[l].attrs);n(i)}return!0}}function zO(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const i=e.table.nodeAt(r[o]);if(i&&i.type!==n.header_cell)return!1}return!0}function uu(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?D8(t):function(n,r){if(!Eo(n))return!1;if(r){const o=or(n.schema),i=Ko(n),s=n.tr,a=zO("row",i,o),l=zO("column",i,o),u=(t==="column"?a:t==="row"&&l)?1:0,f=t=="column"?{left:0,top:u,right:1,bottom:i.map.height}:t=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,p=t=="column"?l?o.cell:o.header_cell:t=="row"?a?o.cell:o.header_cell:o.cell;i.map.cellsInRect(f).forEach(m=>{const b=m+i.tableStart,v=s.doc.nodeAt(b);v&&s.setNodeMarkup(b,p,v.attrs)}),r(s)}return!0}}uu("row",{useDeprecatedLogic:!0}),uu("column",{useDeprecatedLogic:!0});const A8=uu("cell",{useDeprecatedLogic:!0});function P8(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,o=t.before();r>=0;r--){const i=t.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),o=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function VO(t){return function(e,n){if(!Eo(e))return!1;const r=P8(ep(e),t);if(r==null)return!1;if(n){const o=e.doc.resolve(r);n(e.tr.setSelection(Xe.between(o,u8(o))).scrollIntoView())}return!0}}function N8(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function tp(t,e){const n=t.selection;if(!(n instanceof Wt))return!1;if(e){const r=t.tr,o=or(t.schema).cell.createAndFill().content;n.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new Fe(o,0,0))}),r.docChanged&&e(r)}return!0}function $8(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let u=e.child(l).content;const f=l?0:Math.max(0,n-1),p=l<e.childCount-1?0:Math.max(0,r-1);(f||p)&&(u=Bb(or(s).row,new Fe(u,f,p)).content),a.push(u)}else if(i=="cell"||i=="header_cell")a.push(n||r?Bb(or(s).row,new Fe(e,n,r)).content:e);else return null;return L8(s,a)}function L8(t,e){const n=[];for(let o=0;o<e.length;o++){const i=e[o];for(let s=i.childCount-1;s>=0;s--){const{rowspan:a,colspan:l}=i.child(s).attrs;for(let u=o;u<o+a;u++)n[u]=(n[u]||0)+l}}let r=0;for(let o=0;o<n.length;o++)r=Math.max(r,n[o]);for(let o=0;o<n.length;o++)if(o>=e.length&&e.push(Oe.empty),n[o]<r){const i=or(t).cell.createAndFill(),s=[];for(let a=n[o];a<r;a++)s.push(i);e[o]=e[o].append(Oe.from(s))}return{height:e.length,width:r,rows:e}}function Bb(t,e){const n=t.createAndFill();return new og(n).replace(0,n.content.size,e).doc}function B8({width:t,height:e,rows:n},r,o){if(t!=r){const i=[],s=[];for(let a=0;a<n.length;a++){const l=n[a],u=[];for(let f=i[a]||0,p=0;f<r;p++){let m=l.child(p%l.childCount);f+m.attrs.colspan>r&&(m=m.type.createChecked(pa(m.attrs,m.attrs.colspan,f+m.attrs.colspan-r),m.content)),u.push(m),f+=m.attrs.colspan;for(let b=1;b<m.attrs.rowspan;b++)i[a+b]=(i[a+b]||0)+m.attrs.colspan}s.push(Oe.from(u))}n=s,t=r}if(e!=o){const i=[];for(let s=0,a=0;s<o;s++,a++){const l=[],u=n[a%e];for(let f=0;f<u.childCount;f++){let p=u.child(f);s+p.attrs.rowspan>o&&(p=p.type.create({...p.attrs,rowspan:Math.max(1,o-p.attrs.rowspan)},p.content)),l.push(p)}i.push(Oe.from(l))}n=i,e=o}return{width:t,height:e,rows:n}}function F8(t,e,n,r,o,i,s){const a=t.doc.type.schema,l=or(a);let u,f;if(o>e.width)for(let p=0,m=0;p<e.height;p++){const b=n.child(p);m+=b.nodeSize;const v=[];let y;b.lastChild==null||b.lastChild.type==l.cell?y=u||(u=l.cell.createAndFill()):y=f||(f=l.header_cell.createAndFill());for(let x=e.width;x<o;x++)v.push(y);t.insert(t.mapping.slice(s).map(m-1+r),v)}if(i>e.height){const p=[];for(let v=0,y=(e.height-1)*e.width;v<Math.max(e.width,o);v++){const x=v>=e.width?!1:n.nodeAt(e.map[y+v]).type==l.header_cell;p.push(x?f||(f=l.header_cell.createAndFill()):u||(u=l.cell.createAndFill()))}const m=l.row.create(null,Oe.from(p)),b=[];for(let v=e.height;v<i;v++)b.push(m);t.insert(t.mapping.slice(s).map(r+n.nodeSize-2),b)}return!!(u||f)}function HO(t,e,n,r,o,i,s,a){if(s==0||s==e.height)return!1;let l=!1;for(let u=o;u<i;u++){const f=s*e.width+u,p=e.map[f];if(e.map[f-e.width]==p){l=!0;const m=n.nodeAt(p),{top:b,left:v}=e.findCell(p);t.setNodeMarkup(t.mapping.slice(a).map(p+r),null,{...m.attrs,rowspan:s-b}),t.insert(t.mapping.slice(a).map(e.positionAt(s,v,n)),m.type.createAndFill({...m.attrs,rowspan:b+m.attrs.rowspan-s})),u+=m.attrs.colspan-1}}return l}function WO(t,e,n,r,o,i,s,a){if(s==0||s==e.width)return!1;let l=!1;for(let u=o;u<i;u++){const f=u*e.width+s,p=e.map[f];if(e.map[f-1]==p){l=!0;const m=n.nodeAt(p),b=e.colCount(p),v=t.mapping.slice(a).map(p+r);t.setNodeMarkup(v,null,pa(m.attrs,s-b,m.attrs.colspan-(s-b))),t.insert(v+m.nodeSize,m.type.createAndFill(pa(m.attrs,0,s-b))),u+=m.attrs.rowspan-1}}return l}function jO(t,e,n,r,o){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let s=fn.get(i);const{top:a,left:l}=r,u=l+o.width,f=a+o.height,p=t.tr;let m=0;function b(){if(i=n?p.doc.nodeAt(n-1):p.doc,!i)throw new Error("No table found");s=fn.get(i),m=p.mapping.maps.length}F8(p,s,i,n,u,f,m)&&b(),HO(p,s,i,n,l,u,a,m)&&b(),HO(p,s,i,n,l,u,f,m)&&b(),WO(p,s,i,n,a,f,l,m)&&b(),WO(p,s,i,n,a,f,u,m)&&b();for(let v=a;v<f;v++){const y=s.positionAt(v,l,i),x=s.positionAt(v,u,i);p.replace(p.mapping.slice(m).map(y+n),p.mapping.slice(m).map(x+n),new Fe(o.rows[v-a],0,0))}b(),p.setSelection(new Wt(p.doc.resolve(n+s.positionAt(a,l,i)),p.doc.resolve(n+s.positionAt(f-1,u-1,i)))),e(p)}const R8=$g({ArrowLeft:rp("horiz",-1),ArrowRight:rp("horiz",1),ArrowUp:rp("vert",-1),ArrowDown:rp("vert",1),"Shift-ArrowLeft":op("horiz",-1),"Shift-ArrowRight":op("horiz",1),"Shift-ArrowUp":op("vert",-1),"Shift-ArrowDown":op("vert",1),Backspace:tp,"Mod-Backspace":tp,Delete:tp,"Mod-Delete":tp});function np(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function rp(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;if(i instanceof Wt)return np(n,r,nt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const s=UO(o,t,e);if(s==null)return!1;if(t=="horiz")return np(n,r,nt.near(n.doc.resolve(i.head+e),e));{const a=n.doc.resolve(s),l=DO(a,t,e);let u;return l?u=nt.near(l,1):e<0?u=nt.near(n.doc.resolve(a.before(-1)),-1):u=nt.near(n.doc.resolve(a.after(-1)),1),np(n,r,u)}}}function op(t,e){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof Wt)s=i;else{const l=UO(o,t,e);if(l==null)return!1;s=new Wt(n.doc.resolve(l))}const a=DO(s.$headCell,t,e);return a?np(n,r,new Wt(s.$anchorCell,a)):!1}}function z8(t,e){const n=t.state.doc,r=El(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Wt(r))),!0):!1}function V8(t,e,n){if(!Eo(t.state))return!1;let r=$8(n);const o=t.state.selection;if(o instanceof Wt){r||(r={width:1,height:1,rows:[Oe.from(Bb(or(t.state.schema).cell,n))]});const i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),a=fn.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=B8(r,a.right-a.left,a.bottom-a.top),jO(t.state,t.dispatch,s,a,r),!0}else if(r){const i=ep(t.state),s=i.start(-1);return jO(t.state,t.dispatch,s,fn.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function H8(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=qO(t,e.target);let o;if(e.shiftKey&&t.state.selection instanceof Wt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=El(t.state.selection.$anchor))!=null&&((n=Fb(t,e))===null||n===void 0?void 0:n.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(l,u){let f=Fb(t,u);const p=ys.getState(t.state)==null;if(!f||!Lb(l,f))if(p)f=l;else return;const m=new Wt(l,f);if(p||!t.state.selection.eq(m)){const b=t.state.tr.setSelection(m);p&&b.setMeta(ys,l.pos),t.dispatch(b)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",a),ys.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ys,-1))}function a(l){const u=l,f=ys.getState(t.state);let p;if(f!=null)p=t.state.doc.resolve(f);else if(qO(t,u.target)!=r&&(p=Fb(t,e),!p))return s();p&&i(p,u)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",a)}function UO(t,e,n){if(!(t.state.selection instanceof Xe))return null;const{$head:r}=t.state.selection;for(let o=r.depth-1;o>=0;o--){const i=r.node(o);if((n<0?r.index(o):r.indexAfter(o))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const s=r.before(o),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?s:null}}return null}function qO(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Fb(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;const r=n.inside>=0?n.inside:n.pos;return El(t.state.doc.resolve(r))}var W8=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Rb(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Rb(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Rb(t,e,n,r,o,i){let s=0,a=!0,l=e.firstChild;const u=t.firstChild;if(u){for(let p=0,m=0;p<u.childCount;p++){const{colspan:b,colwidth:v}=u.child(p).attrs;for(let y=0;y<b;y++,m++){const x=o==m?i:v&&v[y],S=x?x+"px":"";if(s+=x||r,x||(a=!1),l)l.style.width!=S&&(l.style.width=S),l=l.nextSibling;else{const k=document.createElement("col");k.style.width=S,e.appendChild(k)}}}for(;l;){var f;const p=l.nextSibling;(f=l.parentNode)===null||f===void 0||f.removeChild(l),l=p}a?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const Lr=new On("tableColumnResizing");function KO({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=W8,lastColumnResizable:o=!0}={}){const i=new en({key:Lr,state:{init(s,a){var l;const u=(l=i.spec)===null||l===void 0||(l=l.props)===null||l===void 0?void 0:l.nodeViews,f=or(a.schema).table.name;return r&&u&&(u[f]=(p,m)=>new r(p,n,m)),new j8(-1,!1)},apply(s,a){return a.apply(s)}},props:{attributes:s=>{const a=Lr.getState(s);return a&&a.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,a)=>{U8(s,a,t,o)},mouseleave:s=>{q8(s)},mousedown:(s,a)=>{K8(s,a,e,n)}},decorations:s=>{const a=Lr.getState(s);if(a&&a.activeHandle>-1)return Z8(s,a.activeHandle)},nodeViews:{}}});return i}var j8=class xm{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Lr);if(r&&r.setHandle!=null)return new xm(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new xm(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let o=e.mapping.map(n.activeHandle,-1);return $b(e.doc.resolve(o))||(o=-1),new xm(o,n.dragging)}return n}};function U8(t,e,n,r){if(!t.editable)return;const o=Lr.getState(t.state);if(o&&!o.dragging){const i=G8(e.target);let s=-1;if(i){const{left:a,right:l}=i.getBoundingClientRect();e.clientX-a<=n?s=YO(t,e,"left",n):l-e.clientX<=n&&(s=YO(t,e,"right",n))}if(s!=o.activeHandle){if(!r&&s!==-1){const a=t.state.doc.resolve(s),l=a.node(-1),u=fn.get(l),f=a.start(-1);if(u.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==u.width-1)return}JO(t,s)}}}function q8(t){if(!t.editable)return;const e=Lr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&JO(t,-1)}function K8(t,e,n,r){var o;if(!t.editable)return!1;const i=(o=t.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=Lr.getState(t.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const a=t.state.doc.nodeAt(s.activeHandle),l=Y8(t,s.activeHandle,a.attrs);t.dispatch(t.state.tr.setMeta(Lr,{setDragging:{startX:e.clientX,startWidth:l}}));function u(p){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",f);const m=Lr.getState(t.state);m!=null&&m.dragging&&(J8(t,m.activeHandle,GO(m.dragging,p,n)),t.dispatch(t.state.tr.setMeta(Lr,{setDragging:null})))}function f(p){if(!p.which)return u(p);const m=Lr.getState(t.state);if(m&&m.dragging){const b=GO(m.dragging,p,n);XO(t,m.activeHandle,b,r)}}return XO(t,s.activeHandle,l,r),i.addEventListener("mouseup",u),i.addEventListener("mousemove",f),e.preventDefault(),!0}function Y8(t,e,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=t.domAtPos(e);let s=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let l=0;l<n;l++)r[l]&&(s-=r[l],a--);return s/a}function G8(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function YO(t,e,n,r){const o=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:s}=i,a=El(t.state.doc.resolve(s));if(!a)return-1;if(n=="right")return a.pos;const l=fn.get(a.node(-1)),u=a.start(-1),f=l.map.indexOf(a.pos-u);return f%l.width==0?-1:u+l.map[f-1]}function GO(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function JO(t,e){t.dispatch(t.state.tr.setMeta(Lr,{setHandle:e}))}function J8(t,e,n){const r=t.state.doc.resolve(e),o=r.node(-1),i=fn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=t.state.tr;for(let u=0;u<i.height;u++){const f=u*i.width+a;if(u&&i.map[f]==i.map[f-i.width])continue;const p=i.map[f],m=o.nodeAt(p).attrs,b=m.colspan==1?0:a-i.colCount(p);if(m.colwidth&&m.colwidth[b]==n)continue;const v=m.colwidth?m.colwidth.slice():X8(m.colspan);v[b]=n,l.setNodeMarkup(s+p,null,{...m,colwidth:v})}l.docChanged&&t.dispatch(l)}function XO(t,e,n,r){const o=t.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),a=fn.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let l=t.domAtPos(o.start(-1)).node;for(;l&&l.nodeName!="TABLE";)l=l.parentNode;l&&Rb(i,l.firstChild,l,r,a,n)}function X8(t){return Array(t).fill(0)}function Z8(t,e){const n=[],r=t.doc.resolve(e),o=r.node(-1);if(!o)return Jt.empty;const i=fn.get(o),s=r.start(-1),a=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){const f=a+u*i.width;if((a==i.width-1||i.map[f]!=i.map[f+1])&&(u==0||i.map[f]!=i.map[f-i.width])){var l;const p=i.map[f],m=s+p+o.nodeAt(p).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((l=Lr.getState(t))===null||l===void 0)&&l.dragging&&n.push(Yn.node(s+p,s+p+o.nodeAt(p).nodeSize,{class:"column-resize-dragging"})),n.push(Yn.widget(m,b))}}return Jt.create(t.doc,n)}function ZO({allowTableNodeSelection:t=!1}={}){return new en({key:ys,state:{init(){return null},apply(e,n){const r=e.getMeta(ys);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:o,pos:i}=e.mapping.mapResult(n);return o?null:i}},props:{decorations:p8,handleDOMEvents:{mousedown:H8},createSelectionBetween(e){return ys.getState(e.state)!=null?e.state.selection:null},handleTripleClick:z8,handleKeyDown:R8,handlePaste:V8},appendTransaction(e,n,r){return g8(r,NO(r,n),t)}})}function zb(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function QO(t,e,n,r,o,i){var s;let a=0,l=!0,u=e.firstChild;const f=t.firstChild;if(f!==null)for(let p=0,m=0;p<f.childCount;p+=1){const{colspan:b,colwidth:v}=f.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=o===m?i:v&&v[y],S=x?`${x}px`:"";if(a+=x||r,x||(l=!1),u){if(u.style.width!==S){const[k,T]=zb(r,x);u.style.setProperty(k,T)}u=u.nextSibling}else{const k=document.createElement("col"),[T,C]=zb(r,x);k.style.setProperty(T,C),e.appendChild(k)}}}for(;u;){const p=u.nextSibling;(s=u.parentNode)===null||s===void 0||s.removeChild(u),u=p}l?(n.style.width=`${a}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${a}px`)}class Q8{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),QO(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,QO(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function e7(t,e,n,r){let o=0,i=!0;const s=[],a=t.firstChild;if(!a)return{};for(let p=0,m=0;p<a.childCount;p+=1){const{colspan:b,colwidth:v}=a.child(p).attrs;for(let y=0;y<b;y+=1,m+=1){const x=n===m?r:v&&v[y];o+=x||e,x||(i=!1);const[S,k]=zb(e,x);s.push(["col",{style:`${S}: ${k}`}])}}const l=i?`${o}px`:"",u=i?"":`${o}px`;return{colgroup:["colgroup",{},...s],tableWidth:l,tableMinWidth:u}}function eM(t,e){return t.createAndFill()}function t7(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function n7(t,e,n,r,o){const i=t7(t),s=[],a=[];for(let u=0;u<n;u+=1){const f=eM(i.cell);if(f&&a.push(f),r){const p=eM(i.header_cell);p&&s.push(p)}}const l=[];for(let u=0;u<e;u+=1)l.push(i.row.createChecked(null,r&&u===0?s:a));return i.table.createChecked(null,l)}function r7(t){return t instanceof Wt}const ip=({editor:t})=>{const{selection:e}=t.state;if(!r7(e))return!1;let n=0;const r=qg(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},o7=tn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:Q8,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:o}=e7(t,this.options.cellMinWidth),i=["table",Ct(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:o,editor:i})=>{const s=n7(i.schema,t,e,n);if(o){const a=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(Xe.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>v8(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>x8(t,e),deleteColumn:()=>({state:t,dispatch:e})=>S8(t,e),addRowBefore:()=>({state:t,dispatch:e})=>T8(t,e),addRowAfter:()=>({state:t,dispatch:e})=>k8(t,e),deleteRow:()=>({state:t,dispatch:e})=>O8(t,e),deleteTable:()=>({state:t,dispatch:e})=>N8(t,e),mergeCells:()=>({state:t,dispatch:e})=>FO(t,e),splitCell:()=>({state:t,dispatch:e})=>RO(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>uu("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>uu("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>A8(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>FO(t,e)?!0:RO(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>I8(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>VO(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>VO(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&NO(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Wt.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ip,"Mod-Backspace":ip,Delete:ip,"Mod-Delete":ip}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[KO({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ZO({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:ft(Ue(t,"tableRole",e))}}}).extend({addProseMirrorPlugins(){return[...this.options.resizable?[KO({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ZO({allowTableNodeSelection:this.options.allowTableNodeSelection})]}}),ha=Xt("FieldContainer",["root","outlined","standard","focused","disabled","notchedOutline"]),Vb=Ut("FieldContainer"),i7=oe(ab,{name:Vb,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard,t.ownerState.focused&&e.focused,t.ownerState.disabled&&e.disabled]})(({theme:t,ownerState:e})=>({...e.variant==="outlined"&&{borderRadius:t.shape.borderRadius,padding:1,position:"relative",...!e.focused&&!e.disabled&&{[`&:hover .${ha.notchedOutline}`]:{borderColor:t.palette.text.primary}}}})),s7=oe("div",{name:Vb,slot:"notchedOutline",overridesResolver:(t,e)=>e.notchedOutline})(({theme:t,ownerState:e})=>({position:"absolute",inset:0,borderRadius:"inherit",borderColor:t.palette.mode==="light"?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)",borderStyle:"solid",borderWidth:1,pointerEvents:"none",overflow:"hidden",zIndex:xf.NOTCHED_OUTLINE,...e.focused&&{borderColor:t.palette.primary.main,borderWidth:2},...e.disabled&&{borderColor:t.palette.action.disabled}}));function a7(t){const e=rt({props:t,name:Vb}),{variant:n="outlined",children:r,focused:o,disabled:i,classes:s={},className:a,sx:l,...u}=e,f={variant:n,focused:o,disabled:i};return g.jsxs(i7,{...u,className:ge([ha.root,a,s.root,n==="outlined"?[ha.outlined,s.outlined]:[ha.standard,s.standard],o&&[ha.focused,s.focused],i&&[ha.disabled,s.disabled]]),sx:l,ownerState:f,children:[r,n==="outlined"&&g.jsx(s7,{ownerState:f,className:ge([ha.notchedOutline,s.notchedOutline]),"aria-hidden":!0})]})}function tM({editor:t,wait:e=250}){const[n,r]=J.useState(!!(t!=null&&t.isFocused)),o=J.useMemo(()=>IE(i=>{r(i)},e),[e]);return J.useEffect(()=>{const i=!!(t!=null&&t.isFocused);return o(i),i&&o.flush(),()=>{o.cancel()}},[t==null?void 0:t.isFocused,o]),n}function nM(t,e){const n=J.useRef(e);J.useEffect(()=>{n.current=e},[e]),J.useEffect(()=>{function r(o){t===o.key&&n.current(o)}return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[t])}function l7(t){return Ke("MuiDialogActions",t)}je("MuiDialogActions",["root","spacing"]);const c7=t=>{const{classes:e,disableSpacing:n}=t;return qe({root:["root",!n&&"spacing"]},l7,e)},u7=oe("div",{name:"MuiDialogActions",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,!n.disableSpacing&&e.spacing]}})({display:"flex",alignItems:"center",padding:8,justifyContent:"flex-end",flex:"0 0 auto",variants:[{props:({ownerState:t})=>!t.disableSpacing,style:{"& > :not(style) ~ :not(style)":{marginLeft:8}}}]}),sp=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiDialogActions"}),{className:o,disableSpacing:i=!1,...s}=r,a={...r,disableSpacing:i},l=c7(a);return g.jsx(u7,{className:ge(l.root,o),ownerState:a,ref:n,...s})});process.env.NODE_ENV!=="production"&&(sp.propTypes={children:c.node,classes:c.object,className:c.string,disableSpacing:c.bool,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object])});function d7({editor:t,onCancel:e,onSave:n,labels:r,formatHref:o=_6}){var i,s,a,l,u,f;const p=t.isActive("link")?t.getAttributes("link").href:"",m=Oc(t.state.selection.$from,So("link",t.schema)),b=m?t.state.doc.textBetween(m.from,m.to):"",v=t.state.doc.textBetween(t.state.selection.$from.pos,t.state.selection.$to.pos),y=b||v,[x,S]=J.useState(y),[k,T]=J.useState(p),C=J.useRef(null),O=J.useRef(null),I=!p,N=(i=r==null?void 0:r.editLinkAddTitle)!==null&&i!==void 0?i:"Add link",L=(s=r==null?void 0:r.editLinkEditTitle)!==null&&s!==void 0?s:"Edit link",V=I?N:L;J.useEffect(()=>{var F,P;!I||!y?(F=C.current)===null||F===void 0||F.focus({preventScroll:!0}):(P=O.current)===null||P===void 0||P.focus({preventScroll:!0})},[I,y]),nM("Escape",e);function M(){O.current&&T(o(O.current.value))}const[B,H]=J.useState(!1);return g.jsxs("form",{onSubmit:F=>{var P,_,D,R;F.preventDefault(),F.stopPropagation(),H(!0);const j=(_=(P=C.current)===null||P===void 0?void 0:P.value)!==null&&_!==void 0?_:"",K=(R=(D=O.current)===null||D===void 0?void 0:D.value)!==null&&R!==void 0?R:"";n({text:j,link:K}),H(!1)},autoComplete:"off",children:[g.jsx(ko,{variant:"h6",children:V}),g.jsx(Xc,{inputRef:C,value:x,disabled:B,onChange:F=>{S(F.target.value)},label:(a=r==null?void 0:r.editLinkTextInputLabel)!==null&&a!==void 0?a:"Text",margin:"normal",size:"small",fullWidth:!0,required:!0}),g.jsx(Xc,{inputRef:O,value:k,onChange:F=>{T(F.target.value)},disabled:B,label:(l=r==null?void 0:r.editLinkHrefInputLabel)!==null&&l!==void 0?l:"Link",margin:"dense",size:"small",type:"text",onBlur:M,onKeyDown:F=>{F.key==="Enter"&&M()},fullWidth:!0,required:!0}),g.jsxs(sp,{sx:{px:0},children:[g.jsx(no,{onClick:e,variant:"outlined",size:"small",children:(u=r==null?void 0:r.editLinkCancelButtonLabel)!==null&&u!==void 0?u:"Cancel"}),g.jsx(no,{type:"submit",color:"primary",variant:"outlined",size:"small",disabled:B,children:(f=r==null?void 0:r.editLinkSaveButtonLabel)!==null&&f!==void 0?f:"Save"})]})]})}const Hb=Xt("LinkBubbleMenu",["root","paper","content"]);function f7(t){return Ke("MuiLink",t)}const p7=je("MuiLink",["root","underlineNone","underlineHover","underlineAlways","button","focusVisible"]),h7=({theme:t,ownerState:e})=>{const n=e.color,r=qi(t,`palette.${n}.main`,!1)||qi(t,`palette.${n}`,!1)||e.color,o=qi(t,`palette.${n}.mainChannel`)||qi(t,`palette.${n}Channel`);return"vars"in t&&o?`rgba(${o} / 0.4)`:it(r,.4)},rM={primary:!0,secondary:!0,error:!0,info:!0,success:!0,warning:!0,textPrimary:!0,textSecondary:!0,textDisabled:!0},m7=t=>{const{classes:e,component:n,focusVisible:r,underline:o}=t,i={root:["root",`underline${Ne(o)}`,n==="button"&&"button",r&&"focusVisible"]};return qe(i,f7,e)},g7=oe(ko,{name:"MuiLink",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[`underline${Ne(n.underline)}`],n.component==="button"&&e.button]}})(bt(({theme:t})=>({variants:[{props:{underline:"none"},style:{textDecoration:"none"}},{props:{underline:"hover"},style:{textDecoration:"none","&:hover":{textDecoration:"underline"}}},{props:{underline:"always"},style:{textDecoration:"underline","&:hover":{textDecorationColor:"inherit"}}},{props:({underline:e,ownerState:n})=>e==="always"&&n.color!=="inherit",style:{textDecorationColor:"var(--Link-underlineColor)"}},...Object.entries(t.palette).filter(Hn()).map(([e])=>({props:{underline:"always",color:e},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette[e].mainChannel} / 0.4)`:it(t.palette[e].main,.4)}})),{props:{underline:"always",color:"textPrimary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.primaryChannel} / 0.4)`:it(t.palette.text.primary,.4)}},{props:{underline:"always",color:"textSecondary"},style:{"--Link-underlineColor":t.vars?`rgba(${t.vars.palette.text.secondaryChannel} / 0.4)`:it(t.palette.text.secondary,.4)}},{props:{underline:"always",color:"textDisabled"},style:{"--Link-underlineColor":(t.vars||t).palette.text.disabled}},{props:{component:"button"},style:{position:"relative",WebkitTapHighlightColor:"transparent",backgroundColor:"transparent",outline:0,border:0,margin:0,borderRadius:0,padding:0,cursor:"pointer",userSelect:"none",verticalAlign:"middle",MozAppearance:"none",WebkitAppearance:"none","&::-moz-focus-inner":{borderStyle:"none"},[`&.${p7.focusVisible}`]:{outline:"auto"}}}]}))),oM=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiLink"}),o=wo(),{className:i,color:s="primary",component:a="a",onBlur:l,onFocus:u,TypographyClasses:f,underline:p="always",variant:m="inherit",sx:b,...v}=r,[y,x]=A.useState(!1),S=O=>{Fa(O.target)||x(!1),l&&l(O)},k=O=>{Fa(O.target)&&x(!0),u&&u(O)},T={...r,color:s,component:a,focusVisible:y,underline:p,variant:m},C=m7(T);return g.jsx(g7,{color:s,className:ge(C.root,i),classes:f,component:a,onBlur:S,onFocus:k,ref:n,ownerState:T,variant:m,...v,sx:[...rM[s]===void 0?[{color:s}]:[],...Array.isArray(b)?b:[b]],style:{...v.style,...p==="always"&&s!=="inherit"&&!rM[s]&&{"--Link-underlineColor":h7({theme:o,ownerState:T})}}})});process.env.NODE_ENV!=="production"&&(oM.propTypes={children:c.node,classes:c.object,className:c.string,color:c.oneOfType([c.oneOf(["primary","secondary","success","error","info","warning","textPrimary","textSecondary","textDisabled"]),c.string]),component:Ba,onBlur:c.func,onFocus:c.func,style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),TypographyClasses:c.object,underline:c.oneOf(["always","hover","none"]),variant:c.oneOfType([c.oneOf(["body1","body2","button","caption","h1","h2","h3","h4","h5","h6","inherit","overline","subtitle1","subtitle2"]),c.string])});var Wb={},jb={},iM;function y7(){return iM||(iM=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n!==null&&(typeof n=="object"||typeof n=="function")}t.isObject=e})(jb)),jb}var sM;function b7(){return sM||(sM=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=y7(),n=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/;function r(i,s){i=i!=null?`${i}`:"";let a=30,l="...";e.isObject(s)&&(a=o(s.length),l="omission"in s?`${s.omission}`:"...");let u=i.length;const f=Array.from(l).length,p=Math.max(a-f,0);let m;if(n.test(i)&&(m=Array.from(i),u=m.length),a>=u)return i;if(u<=f)return l;let v=m===void 0?i.slice(0,p):m==null?void 0:m.slice(0,p).join("");const y=s==null?void 0:s.separator;if(!y)return v+=l,v;const x=y instanceof RegExp?y.source:y,S="u"+(y instanceof RegExp?y.flags.replace("u",""):""),k=new RegExp(`(?<result>.*(?:(?!${x}).))(?:${x})`,S).exec(v);return(k!=null&&k.groups?k.groups.result:v)+l}function o(i){return i==null?30:i<=0?0:i}t.truncate=r})(Wb)),Wb}var Ub,aM;function v7(){return aM||(aM=1,Ub=b7().truncate),Ub}var x7=v7();const w7=Un(x7),qb=Xt("ViewLinkMenuContent",["root","linkPreviewText"]),Kb=Ut("ViewLinkMenuContent"),S7=oe("div",{name:Kb,slot:"root",overridesResolver:(t,e)=>e.root})({}),lM=oe("div",{name:Kb,slot:"linkPreviewText",overridesResolver:(t,e)=>e.linkPreviewText})({overflowWrap:"anywhere"});function C7(t){var e,n,r;const o=rt({props:t,name:Kb}),{editor:i,onCancel:s,onEdit:a,onRemove:l,labels:u,classes:f={},sx:p}=o,m=Oc(i.state.selection.$to,So("link",i.schema)),b=m?i.state.doc.textBetween(m.from,m.to):"",v=(e=i.getAttributes("link").href)!==null&&e!==void 0?e:"";return nM("Escape",s),g.jsxs(S7,{className:ge([qb.root,f.root]),sx:p,children:[g.jsx(lM,{className:ge([qb.linkPreviewText,f.linkPreviewText]),children:w7(b,{length:50,omission:"…"})}),g.jsx(lM,{className:ge([qb.linkPreviewText,f.linkPreviewText]),children:g.jsx(oM,{href:v,target:"_blank",rel:"noopener",children:D6(v,50)})}),g.jsxs(sp,{sx:{px:0},children:[g.jsx(no,{onClick:a,color:"primary",variant:"outlined",size:"small",children:(n=u==null?void 0:u.viewLinkEditButtonLabel)!==null&&n!==void 0?n:"Edit"}),g.jsx(no,{onClick:l,color:"error",variant:"outlined",size:"small",children:(r=u==null?void 0:u.viewLinkRemoveButtonLabel)!==null&&r!==void 0?r:"Remove"})]})]})}const cM=Ut("LinkBubbleMenu"),T7=oe("div",{name:cM,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({padding:t.spacing(1.5,2,.5)}));function k7(t){const e=rt({props:t,name:cM}),{labels:n,formatHref:r,classes:o={},sx:i,...s}=e,a=Tt();if(!(a!=null&&a.isEditable))return null;if(!("linkBubbleMenuHandler"in a.storage))throw new Error("You must add the LinkBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const l=a.storage.linkBubbleMenuHandler,u=l.state;let f=null;return u===fr.VIEW_LINK_DETAILS?f=g.jsx(C7,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onEdit:a.commands.editLinkInBubbleMenu,onRemove:()=>{a.chain().unsetLink().setTextSelection(a.state.selection.to).focus().run()},labels:n}):u===fr.EDIT_LINK&&(f=g.jsx(d7,{editor:a,onCancel:a.commands.closeLinkBubbleMenu,onSave:({text:p,link:m})=>{a.chain().extendMarkRange("link").insertContent({type:"text",marks:[{type:"link",attrs:{href:m}}],text:p}).setLink({href:m}).focus().run(),a.commands.closeLinkBubbleMenu()},labels:n,formatHref:r})),g.jsx(Sy,{editor:a,open:u!==fr.HIDDEN,...l.bubbleMenuOptions,...s,classes:{root:ge([Hb.root,o.root]),paper:ge([Hb.paper,o.paper])},sx:i,children:g.jsx(T7,{className:ge([Hb.content,o.content]),children:f})})}function E7(t){return Ke("MuiCollapse",t)}je("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const O7=t=>{const{orientation:e,classes:n}=t,r={root:["root",`${e}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${e}`],wrapperInner:["wrapperInner",`${e}`]};return qe(r,E7,n)},M7=oe("div",{name:"MuiCollapse",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.orientation],n.state==="entered"&&e.entered,n.state==="exited"&&!n.in&&n.collapsedSize==="0px"&&e.hidden]}})(bt(({theme:t})=>({height:0,overflow:"hidden",transition:t.transitions.create("height"),variants:[{props:{orientation:"horizontal"},style:{height:"auto",width:0,transition:t.transitions.create("width")}},{props:{state:"entered"},style:{height:"auto",overflow:"visible"}},{props:{state:"entered",orientation:"horizontal"},style:{width:"auto"}},{props:({ownerState:e})=>e.state==="exited"&&!e.in&&e.collapsedSize==="0px",style:{visibility:"hidden"}}]}))),_7=oe("div",{name:"MuiCollapse",slot:"Wrapper",overridesResolver:(t,e)=>e.wrapper})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),I7=oe("div",{name:"MuiCollapse",slot:"WrapperInner",overridesResolver:(t,e)=>e.wrapperInner})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),ap=A.forwardRef(function(e,n){const r=mt({props:e,name:"MuiCollapse"}),{addEndListener:o,children:i,className:s,collapsedSize:a="0px",component:l,easing:u,in:f,onEnter:p,onEntered:m,onEntering:b,onExit:v,onExited:y,onExiting:x,orientation:S="vertical",style:k,timeout:T=nw.standard,TransitionComponent:C=Pr,...O}=r,I={...r,orientation:S,collapsedSize:a},N=O7(I),L=wo(),V=$s(),M=A.useRef(null),B=A.useRef(),H=typeof a=="number"?`${a}px`:a,F=S==="horizontal",P=F?"width":"height",_=A.useRef(null),D=Ot(n,_),R=te=>ce=>{if(te){const ne=_.current;ce===void 0?te(ne):te(ne,ce)}},j=()=>M.current?M.current[F?"clientWidth":"clientHeight"]:0,K=R((te,ce)=>{M.current&&F&&(M.current.style.position="absolute"),te.style[P]=H,p&&p(te,ce)}),U=R((te,ce)=>{const ne=j();M.current&&F&&(M.current.style.position="");const{duration:re,easing:le}=ul({style:k,timeout:T,easing:u},{mode:"enter"});if(T==="auto"){const ye=L.transitions.getAutoHeightDuration(ne);te.style.transitionDuration=`${ye}ms`,B.current=ye}else te.style.transitionDuration=typeof re=="string"?re:`${re}ms`;te.style[P]=`${ne}px`,te.style.transitionTimingFunction=le,b&&b(te,ce)}),Y=R((te,ce)=>{te.style[P]="auto",m&&m(te,ce)}),fe=R(te=>{te.style[P]=`${j()}px`,v&&v(te)}),ue=R(y),pe=R(te=>{const ce=j(),{duration:ne,easing:re}=ul({style:k,timeout:T,easing:u},{mode:"exit"});if(T==="auto"){const le=L.transitions.getAutoHeightDuration(ce);te.style.transitionDuration=`${le}ms`,B.current=le}else te.style.transitionDuration=typeof ne=="string"?ne:`${ne}ms`;te.style[P]=H,te.style.transitionTimingFunction=re,x&&x(te)}),Z=te=>{T==="auto"&&V.start(B.current||0,te),o&&o(_.current,te)};return g.jsx(C,{in:f,onEnter:K,onEntered:Y,onEntering:U,onExit:fe,onExited:ue,onExiting:pe,addEndListener:Z,nodeRef:_,timeout:T==="auto"?null:T,...O,children:(te,{ownerState:ce,...ne})=>g.jsx(M7,{as:l,className:ge(N.root,s,{entered:N.entered,exited:!f&&H==="0px"&&N.hidden}[te]),style:{[F?"minWidth":"minHeight"]:H,...k},ref:D,ownerState:{...I,state:te},...ne,children:g.jsx(_7,{ownerState:{...I,state:te},className:N.wrapper,ref:M,children:g.jsx(I7,{ownerState:{...I,state:te},className:N.wrapperInner,children:i})})})})});process.env.NODE_ENV!=="production"&&(ap.propTypes={addEndListener:c.func,children:c.node,classes:c.object,className:c.string,collapsedSize:c.oneOfType([c.number,c.string]),component:Ba,easing:c.oneOfType([c.shape({enter:c.string,exit:c.string}),c.string]),in:c.bool,onEnter:c.func,onEntered:c.func,onEntering:c.func,onExit:c.func,onExited:c.func,onExiting:c.func,orientation:c.oneOf(["horizontal","vertical"]),style:c.object,sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),timeout:c.oneOfType([c.oneOf(["auto"]),c.number,c.shape({appear:c.number,enter:c.number,exit:c.number})])}),ap&&(ap.muiSupportAuto=!0);const lp=Xt("MenuBar",["root","sticky","nonSticky","content"]),Yb=Ut("MenuBar"),D7=oe(ap,{name:Yb,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.disableSticky?e.nonSticky:e.sticky]})(({theme:t,ownerState:e})=>({borderBottomColor:t.palette.divider,borderBottomStyle:"solid",borderBottomWidth:1,...e.disableSticky?{}:{position:"sticky",top:e.stickyOffset,zIndex:xf.MENU_BAR,background:t.palette.background.default}})),A7=oe("div",{name:Yb,slot:"content",overridesResolver:(t,e)=>e.content})({});function P7(t){const e=rt({props:t,name:Yb}),{hide:n,disableSticky:r,stickyOffset:o=0,children:i,className:s,classes:a={},unmountOnExit:l=!0,sx:u,...f}=e,p={hide:n,disableSticky:r,stickyOffset:o,unmountOnExit:l};return g.jsx(D7,{...f,in:!n,unmountOnExit:l,className:ge([lp.root,a.root,r?[lp.nonSticky,a.nonSticky]:[lp.sticky,a.sticky],s]),ownerState:p,sx:u,children:g.jsx(A7,{className:ge([lp.content,a.content]),ownerState:p,children:i})})}const Gb=Xt("RichTextContent",["root","readonly","editable"]),uM=Ut("RichTextContent"),N7=oe(x9,{name:uM,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.editable?e.editable:e.readonly]})(({theme:t,ownerState:e})=>e.disableDefaultStyles?{}:{"& .ProseMirror":{...ca(t)}});function dM(t){const e=rt({props:t,name:uM}),{innerRef:n,className:r,classes:o={},disableDefaultStyles:i=!1,sx:s}=e,a=Tt(),l=!!(a!=null&&a.isEditable),u={editable:l,disableDefaultStyles:i},f=J.useMemo(()=>ge([Gb.root,r,o.root,l?[Gb.editable,o.editable]:[Gb.readonly,o.readonly]]),[r,o.root,o.editable,o.readonly,l]);return g.jsx(N7,{editor:a,...n?{innerRef:n}:{},ownerState:u,className:f,sx:s})}function fM({editor:t,children:e}){return g.jsx(qT.Provider,{value:t,children:e})}const Yo=Xt("RichTextField",["root","standard","outlined","menuBar","menuBarContent","content"]),pM=Ut("RichTextField"),$7=oe(a7,{name:pM,slot:"root",overridesResolver:(t,e)=>[e.root,t.ownerState.variant==="outlined"&&e.outlined,t.ownerState.variant==="standard"&&e.standard]})(({theme:t,ownerState:e})=>({...e.variant==="standard"&&{[`& .${Yo.content}`]:{padding:t.spacing(1.5,0)},[`& .${Yo.menuBarContent}`]:{padding:t.spacing(1,0)}},...e.variant==="outlined"&&{[`& .${Yo.content}`]:{padding:t.spacing(1.5)},[`& .${Yo.menuBarContent}`]:{padding:t.spacing(1,1.5)}}}));function L7(t){var e,n;const r=rt({props:t,name:pM}),{variant:o="outlined",controls:i,disableDebounceRenderControls:s=!1,disabled:a,className:l,classes:u={},footer:f,MenuBarProps:p,RichTextContentProps:m,sx:b,...v}=r,y=Tt(),x={variant:o,disabled:a,disableDebounceRenderControls:s},S=tM({editor:y});return g.jsxs($7,{...v,variant:o,focused:!a&&S,disabled:a,className:ge([Yo.root,u.root,o==="outlined"?[Yo.outlined,u.outlined]:[Yo.standard,u.standard],l]),ownerState:x,sx:b,children:[i&&g.jsx(P7,{...p,classes:{...p==null?void 0:p.classes,root:ge([Yo.menuBar,u.menuBar,(e=p==null?void 0:p.classes)===null||e===void 0?void 0:e.root]),content:ge([Yo.menuBarContent,u.menuBarContent,(n=p==null?void 0:p.classes)===null||n===void 0?void 0:n.content])},children:s?i:g.jsx(ob,{children:i})}),g.jsx(dM,{...m,className:ge([Yo.content,u.content,m==null?void 0:m.className])}),f]})}const hM=J.forwardRef(function({className:e,renderControls:n,RichTextFieldProps:r={},sx:o,children:i,editorDependencies:s=[],editable:a=!0,shouldRerenderOnTransaction:l=!0,...u},f){const p={editable:a,shouldRerenderOnTransaction:l,...u},m=SO(p,s);return J.useImperativeHandle(f,()=>({editor:m}),[m]),J.useEffect(()=>{!m||m.isDestroyed||m.isEditable===a||queueMicrotask(()=>{m.setEditable(a)})},[a,m]),g.jsxs(fM,{editor:m,children:[g.jsx(L7,{disabled:!a,controls:n==null?void 0:n(m),className:e,sx:o,...r}),i==null?void 0:i(m)]})});function B7({RichTextContentProps:t,sx:e,...n}){const r=SO({...n,editable:!1}),o=J.useRef(n.content);return J.useEffect(()=>{!r||r.isDestroyed||n.content===void 0||n.content===o.current||queueMicrotask(()=>{n.content!==void 0&&r.commands.setContent(n.content)})},[n.content,r]),J.useEffect(()=>{o.current=n.content},[n.content]),g.jsx(fM,{editor:r,children:g.jsx(dM,{sx:e,...t})})}function mM(t){return t.content?g.jsx(B7,{...t}):null}const Jb=Xt("TableBubbleMenu",["root","paper","content"]),gM=Ut("TableBubbleMenu"),F7=oe(Lj,{name:gM,slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>({maxWidth:"90vw",padding:t.spacing(.5,1)}));function R7(t){const e=rt({props:t,name:gM}),{disableDebounce:n=!1,DebounceProps:r,labels:o,classes:i={},...s}=e,a=Tt(),l=tM({editor:a}),u=J.useMemo(()=>a?{getBoundingClientRect:()=>{const p=a.isActive("table")?qg(a.state.selection.$anchor,y=>y.type.name==="table"):null;if(p){const y=a.view.nodeDOM(p.pos),x=y==null?void 0:y.querySelector("table");if(x)return x.getBoundingClientRect()}const{ranges:m}=a.state.selection,b=Math.min(...m.map(y=>y.$from.pos)),v=Math.max(...m.map(y=>y.$to.pos));return aT(a.view,b,v)}}:null,[a]);if(!(a!=null&&a.isEditable))return null;const f=g.jsx(F7,{className:ge([Jb.content,i.content]),labels:o});return g.jsx(Sy,{editor:a,open:l&&a.isActive("table"),anchorEl:u,placement:"top-start",fallbackPlacements:["bottom-start","top","bottom","top-end","bottom-end"],flipPadding:{top:35,left:8,right:8,bottom:-1/0},...s,classes:{root:ge([Jb.root,i.root]),paper:ge([Jb.paper,i.paper])},children:n?f:g.jsx(ob,{...r,children:f})})}const Xb=vr.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Ct(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),yM=vr.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Ct(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Zb,bM;function z7(){return bM||(bM=1,Zb=(function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(r,o,i){n.o(r,o)||Object.defineProperty(r,o,{configurable:!1,enumerable:!0,get:i})},n.r=function(r){Object.defineProperty(r,"__esModule",{value:!0})},n.n=function(r){var o=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(o,"a",o),o},n.o=function(r,o){return Object.prototype.hasOwnProperty.call(r,o)},n.p="/dist/",n(n.s=1)})([function(t,e,n){n.r(e);var r={equal:0,delete:1,insert:2,none:3,replace:4};class o{constructor(P,_,D){this.startInOld=P,this.startInNew=_,this.size=D}get endInOld(){return this.startInOld+this.size}get endInNew(){return this.startInNew+this.size}}class i{constructor(){this.blockSize=0,this.repeatingWordsAccuracy=0,this.ignoreWhitespaceDifferences=!1}}const s=/^\s*<\/?[^>]+>\s*$/,a=/<[^\s>]+/,l=/^(\s| )+$/,u=/[\w\#@]+/,f=["<img"];function p(F){return!f.some(P=>F!==null&&F.startsWith(P))&&s.test(F)}function m(F,P,_){return["<",P,' class="',_,'">',F,"</",P,">"].join("")}function b(F){return F==="<"}function v(F){return F==="&"}function y(F){return F===";"}function x(F){return l.test(F)}function S(F){return p(F)?(function(P){return P=a.exec(P)[0]+(P.endsWith("/>")?"/>":">")})(F):F}function k(F){return u.test(F)}function T(F,P,_){return F.push(P),F.length>_&&F.shift(),F.length!==_?null:F.join("")}class C{constructor(P,_,D,R,j,K,U){this.oldWords=P,this.newWords=_,this.startInOld=D,this.endInOld=R,this.startInNew=j,this.endInNew=K,this.options=U}indexNewWords(){this.wordIndices=new Map;let P=[];for(let _=this.startInNew;_<this.endInNew;_++){let D=T(P,this.normalizeForIndex(this.newWords[_]),this.options.blockSize);D!==null&&(this.wordIndices.has(D)?this.wordIndices.get(D).push(_):this.wordIndices.set(D,[_]))}}normalizeForIndex(P){return P=S(P),this.options.IgnoreWhiteSpaceDifferences&&x(P)?" ":P}findMatch(){if(this.indexNewWords(),this.removeRepeatingWords(),this.wordIndices.length===0)return null;let P=this.startInOld,_=this.startInNew,D=0,R=new Map;const j=this.options.blockSize;let K=[];for(let U=this.startInOld;U<this.endInOld;U++){let Y=T(K,this.normalizeForIndex(this.oldWords[U]),j);if(Y===null)continue;let fe=new Map;if(this.wordIndices.has(Y)){for(let ue of this.wordIndices.get(Y)){let pe=(R.has(ue-1)?R.get(ue-1):0)+1;fe.set(ue,pe),pe>D&&(P=U-pe-j+2,_=ue-pe-j+2,D=pe)}R=fe}else R=fe}return D!==0?new o(P,_,D+j-1):null}removeRepeatingWords(){let P=this.newWords.length+this.options.repeatingWordsAccuracy,_=Array.from(this.wordIndices.entries()).filter(D=>D[1].length>P).map(D=>D[0]);for(let D of _)this.wordIndices.delete(D)}}class O{constructor(P,_,D,R,j){this.action=P,this.startInOld=_,this.endInOld=D,this.startInNew=R,this.endInNew=j}}var I={character:0,tag:1,whitespace:2,entity:3};function N(F,P){let _={mode:I.character,currentWord:[],words:[]},D=(function(Y,fe){let ue=new Map;if(fe===null)return ue;for(let pe of fe){let Z;for(;(Z=pe.exec(Y))!==null;){if(ue.has(Z.index))throw new Error("One or more block expressions result in a text sequence that overlaps. Current expression: "+pe.toString());ue.set(Z.index,Z.index+Z[0].length)}}return ue})(F,P),R=!!D.size,j=!1,K=-1;for(let Y=0;Y<F.length;Y++){var U=F[Y];if(R&&(K===index&&(K=-1,j=!1),D.has(index)&&(j=!0,K=D.get(index)),j)){_.currentWord.push(U),_.mode=I.character;continue}switch(_.mode){case I.character:b(U)?L(_,"<",I.tag):v(U)?L(_,U,I.entity):x(U)?L(_,U,I.whitespace):k(U)&&(_.currentWord.length===0||k(_.currentWord[_.currentWord.length-1]))?_.currentWord.push(U):L(_,U,I.character);break;case I.tag:U===">"?(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.currentWord=[],_.mode=x(U)?I.whitespace:I.character):_.currentWord.push(U);break;case I.whitespace:b(U)?L(_,U,I.tag):v(U)?L(_,U,I.entity):x(U)?_.currentWord.push(U):L(_,U,I.character);break;case I.entity:if(b(U))L(_,U,I.tag);else if(x(U))L(_,U,I.whitespace);else if(y(U)){let fe=!0;if(_.currentWord.length!==0&&(_.currentWord.push(U),_.words.push(_.currentWord.join("")),_.words.length>2&&x(_.words[_.words.length-2])&&x(_.words[_.words.length-1]))){let ue=_.words[_.words.length-2],pe=_.words[_.words.length-1];_.words.splice(_.words.length-2,2),_.currentWord=[(ue+pe).split()],_.mode=I.whitespace,fe=!1}fe&&(_.currentWord=[],_.mode=I.character)}else k(U)?_.currentWord.push(U):L(_,U,I.character)}}return _.currentWord.length!==0&&_.words.push(_.currentWord.join("")),_.words}function L(F,P,_){F.currentWord.length!==0&&F.words.push(F.currentWord.join("")),F.currentWord=[P],F.mode=_}const V=4,M=new Map([["</strong>",0],["</em>",0],["</b>",0],["</i>",0],["</big>",0],["</small>",0],["</u>",0],["</sub>",0],["</strike>",0],["</s>",0]]),B=/<((strong)|(b)|(i)|(em)|(big)|(small)|(u)|(sub)|(sup)|(strike)|(s))[\>\s]+/gi;class H{constructor(P,_){this.content=[],this.newText=_,this.oldText=P,this.specialTagDiffStack=[],this.newWords=[],this.oldWords=[],this.matchGranularity=0,this.blockExpressions=[],this.repeatingWordsAccuracy=1,this.ignoreWhiteSpaceDifferences=!1,this.orphanMatchThreshold=0}build(){if(this.oldText===this.newText)return this.newText;this.splitInputsIntoWords(),this.matchGranularity=Math.min(V,this.oldWords.length,this.newWords.length);let P=this.operations();for(let _ of P)this.performOperation(_);return this.content.join("")}addBlockExpression(P){this.blockExpressions.push(P)}splitInputsIntoWords(){this.oldWords=N(this.oldText,this.blockExpressions),this.oldText=null,this.newWords=N(this.newText,this.blockExpressions),this.newText=null}performOperation(P){switch(P.action){case r.equal:this.processEqualOperation(P);break;case r.delete:this.processDeleteOperation(P,"diffdel");break;case r.insert:this.processInsertOperation(P,"diffins");break;case r.none:break;case r.replace:this.processReplaceOperation(P)}}processReplaceOperation(P){this.processDeleteOperation(P,"diffmod"),this.processInsertOperation(P,"diffmod")}processInsertOperation(P,_){let D=this.newWords.filter((R,j)=>j>=P.startInNew&&j<P.endInNew);this.insertTag("ins",_,D)}processDeleteOperation(P,_){let D=this.oldWords.filter((R,j)=>j>=P.startInOld&&j<P.endInOld);this.insertTag("del",_,D)}processEqualOperation(P){let _=this.newWords.filter((D,R)=>R>=P.startInNew&&R<P.endInNew);this.content.push(_.join(""))}insertTag(P,_,D){for(;D.length;){let R=this.extractConsecutiveWords(D,U=>!p(U)),j="",K=!1;if(R.length!==0){let U=m(R.join(""),P,_);this.content.push(U)}else{if(B.test(D[0])){if(this.specialTagDiffStack.push(D[0]),j='<ins class="mod">',P==="del")for(D.shift();D.length>0&&B.test(D[0]);)D.shift()}else if(M.has(D[0])){let U=this.specialTagDiffStack.length===0?null:this.specialTagDiffStack.pop();if(U!==null&&U===D[0].replace(/\//g,"")&&(j="</ins>",K=!0),P==="del")for(D.shift();D.length>0&&M.has(D[0]);)D.shift()}if(D.length===0&&j.length===0)break;K?this.content.push(j+this.extractConsecutiveWords(D,p).join("")):this.content.push(this.extractConsecutiveWords(D,p).join("")+j)}}}extractConsecutiveWords(P,_){let D=null;for(let R=0;R<P.length;R++){let j=P[R];if(R===0&&j===" "&&(P[R]=" "),!_(j)){D=R;break}}if(D!==null){let R=P.filter((j,K)=>K>=0&&K<D);return D>0&&P.splice(0,D),R}{let R=P.filter((j,K)=>K>=0&&K<P.length);return P.splice(0,P.length),R}}operations(){let P=0,_=0,D=[],R=this.matchingBlocks();R.push(new o(this.oldWords.length,this.newWords.length,0));let j=this.removeOrphans(R);for(let K of j){let U,Y=P===K.startInOld,fe=_===K.startInNew;(U=Y||fe?Y&&!fe?r.insert:Y?r.none:r.delete:r.replace)!==r.none&&D.push(new O(U,P,K.startInOld,_,K.startInNew)),K.length!==0&&D.push(new O(r.equal,K.startInOld,K.endInOld,K.startInNew,K.endInNew)),P=K.endInOld,_=K.endInNew}return D}*removeOrphans(P){let _=null,D=null;for(let R of P){if(D===null){_=new o(0,0,0),D=R;continue}if(_.endInOld===D.startInOld&&_.endInNew===D.startInNew||D.endInOld===R.startInOld&&D.endInNew===R.startInNew){yield D,_=D,D=R;continue}let j=(Y,fe)=>Y+fe.length,K=this.oldWords.slice(_.endInOld,R.startInOld).reduce(j,0),U=this.newWords.slice(_.endInNew,R.startInNew).reduce(j,0);this.newWords.slice(D.startInNew,D.endInNew).reduce(j,0)>Math.max(K,U)*this.orphanMatchThreshold&&(yield D),_=D,D=R}yield D}matchingBlocks(){let P=[];return this.findMatchingBlocks(0,this.oldWords.length,0,this.newWords.length,P),P}findMatchingBlocks(P,_,D,R,j){let K=this.findMatch(P,_,D,R);K!==null&&(P<K.startInOld&&D<K.startInNew&&this.findMatchingBlocks(P,K.startInOld,D,K.startInNew,j),j.push(K),K.endInOld<_&&K.endInNew<R&&this.findMatchingBlocks(K.endInOld,_,K.endInNew,R,j))}findMatch(P,_,D,R){for(let j=this.matchGranularity;j>0;j--){let K=new i;K.blockSize=j,K.repeatingWordsAccuracy=this.repeatingWordsAccuracy,K.ignoreWhitespaceDifferences=this.ignoreWhiteSpaceDifferences;let U=new C(this.oldWords,this.newWords,P,_,D,R,K).findMatch();if(U!==null)return U}return null}}H.execute=function(F,P){return new H(F,P).build()},e.default=H},function(t,e,n){t.exports=n(0)}])),Zb}var V7=z7();const H7=Un(V7),cp="rgba(194, 249, 112, .5)",up="rgba(196, 77,86,0.3)",vM=t=>{const{beforeTxt:e="",afterTxt:n="",mode:r="sentence"}=t,o=W7(e,n,r);return g.jsx(mM,{content:o,extensions:[RT,Xb,UT.configure({multicolor:!0}),yM]})},W7=(t,e,n)=>{switch(n){case"sentence":return U7(t,e);case"word":return j7(t,e);case"html":return K7(t,e);case"comma":return q7(t,e)}},Qb=(t,e)=>{const n=Array.isArray(t.value)?t.value.join(", "):t.value;if(!t.added&&!t.removed)return n;const r=t.added?cp:up,o=t.added?"u":"s";return`<${o}><mark key={${e}} data-color="${r}" style={{ backgroundColor: ${r}, color: "inherit"}}>${n}</mark></${o}>`},xM=t=>t.split(",").map(e=>e.trim()),j7=(t,e)=>X3(t,e).map(Qb).join(""),U7=(t,e)=>t4(t,e).map(Qb).join(""),q7=(t,e)=>o4(xM(t),xM(e)).map(Qb).join(", "),K7=(t,e)=>{let n=H7.execute(t,e);return n=n.replaceAll(/<ins class="(diffmod|diffins)">/g,`<u><mark data-color="${cp}" style={{ backgroundColor: ${cp}, color: "inherit" }}>`),n=n.replaceAll("</ins>","</mark></u>"),n=n.replaceAll(/<del class="(diffmod|diffdel)">/g,`<s><mark data-color="${up}" style={{ backgroundColor: ${up}, color: "inherit" }}>`),n=n.replaceAll("</del>","</mark></s>"),n},Ti=t=>{const{label:e,value:n,readOnlyValue:r,staticLabel:o,staticLabelProps:i,showDiff:s=!1,diffSnapshot:a,diffMode:l,...u}=t,f=()=>s?g.jsx(vM,{beforeTxt:a,afterTxt:n,mode:l,...u}):r||g.jsx(z.Typography,{"data-testid":"read-only-value",children:n});return g.jsxs(z.Box,{width:"100%",mb:"8px",children:[o?g.jsx(z.Typography,{...i,children:e}):g.jsx(z.InputLabel,{children:e}),f()]})},wM=t=>{const{name:e,label:n=Ln(e),options:r=[],filterSelectedOptions:o=!0,variant:i="outlined",staticLabel:s=!1,staticLabelProps:a={fontSize:".9em",color:"#808080"},readOnly:l,margin:u="dense",fullWidth:f=!0,required:p,onChange:m,clearOnSelect:b=!1,onInputChange:v,getOptionLabel:y=R=>typeof R=="string"?R:String(R),isOptionEqualToValue:x=(R,j)=>JSON.stringify(R)===JSON.stringify(j),useFieldAsValue:S,errorMode:k="normal",...T}=t,[C,O,I]=Ht.useField(e),{setValue:N}=I,{error:L}=O,[V,M]=A.useState(""),B={...lr(T,["useFieldAsValue","errorMode"]),getOptionLabel:y,options:r,filterSelectedOptions:o,isOptionEqualToValue:x,renderInput:R=>g.jsx(z.TextField,{...R,variant:i,label:s?void 0:n,error:!!L,required:p}),onChange:(R,j,K,U)=>{b?(M(""),N(null)):N(S?j?j[S]:null:j),m&&m(R,j,K,U)},onInputChange:(R,j,K)=>{M(j),v&&v(R,j,K)},fullWidth:!0,inputValue:V,value:S?r.find(R=>R[S]===C.value)||null:C.value,slotProps:{paper:{elevation:8,sx:{borderRadius:2}}}},H=R=>{if(R==null)return"";if(S){const j=r.find(K=>K[S]===R);return j?y(j):""}return y(R)},F=Vs(),P=l??F,{showDiff:_,getPreviousValue:D}=Hs();return P||_?g.jsx(Ti,{label:n,value:H(C.value),staticLabel:s,staticLabelProps:a,showDiff:_,diffSnapshot:H(D(e))}):g.jsxs(z.FormControl,{margin:u,fullWidth:f,required:p,children:[s&&g.jsx(z.Typography,{...a,children:n}),g.jsxs(z.Box,{children:[g.jsx(z.Autocomplete,{...B}),g.jsx(yr,{name:e,id:`${e}-err`,errorMode:k})]})]})};var du={exports:{}};/**
|
|
357
357
|
* @license
|
|
358
358
|
* Lodash <https://lodash.com/>
|
|
359
359
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|