@simoncomputing/mui-bueno-v2 0.35.2 → 0.35.4
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 +14 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +62 -31
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
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)=>{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:{}};/**
|
|
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).filter(Boolean),Wk(e).filter(Boolean)).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/>
|
|
@@ -404,5 +404,5 @@ The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rg
|
|
|
404
404
|
3. "-" cannot repeat`);Ut.customSchemes.push([t,e])}function Ace(){Ut.scanner=kce(Ut.customSchemes);for(let t=0;t<Ut.tokenQueue.length;t++)Ut.tokenQueue[t][1]({scanner:Ut.scanner});Ut.parser=Mce(Ut.scanner.tokens);for(let t=0;t<Ut.pluginQueue.length;t++)Ut.pluginQueue[t][1]({scanner:Ut.scanner,parser:Ut.parser});return Ut.initialized=!0,Ut}function kx(t){return Ut.initialized||Ace(),_ce(Ut.parser.start,t,PD(Ut.scanner.start,t))}kx.scan=PD;function jD(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Tx(n),o=kx(t),i=[];for(let s=0;s<o.length;s++){const a=o[s];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}const Ex="[\0- -\u2029 ]",Pce=new RegExp(Ex),Nce=new RegExp(`${Ex}$`),jce=new RegExp(Ex,"g");function $ce(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function Lce(t){return new on({key:new On("autolink"),appendTransaction:(e,n,r)=>{const o=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),i=e.some(u=>u.getMeta("preventAutolink"));if(!o||i)return;const{tr:s}=r,a=c7(n.doc,[...e]);if(m7(a).forEach(({newRange:u})=>{const f=d7(r.doc,u,b=>b.isTextblock);let p,m;if(f.length>1)p=f[0],m=r.doc.textBetween(p.pos,p.pos+p.node.nodeSize,void 0," ");else if(f.length){const b=r.doc.textBetween(u.from,u.to," "," ");if(!Nce.test(b))return;p=f[0],m=r.doc.textBetween(p.pos,u.to,void 0," ")}if(p&&m){const b=m.split(Pce).filter(Boolean);if(b.length<=0)return!1;const v=b[b.length-1],y=p.pos+m.lastIndexOf(v);if(!v)return!1;const x=kx(v).map(C=>C.toObject(t.defaultProtocol));if(!$ce(x))return!1;x.filter(C=>C.isLink).map(C=>({...C,from:y+C.start+1,to:y+C.end+1})).filter(C=>r.schema.marks.code?!r.doc.rangeHasMark(C.from,C.to,r.schema.marks.code):!0).filter(C=>t.validate(C.value)).filter(C=>t.shouldAutoLink(C.value)).forEach(C=>{av(C.from,C.to,r.doc).some(k=>k.mark.type===t.type)||s.addMark(C.from,C.to,t.type.create({href:C.href}))})}}),!!s.steps.length)return s}})}function Bce(t){return new on({key:new On("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=r.target;const a=[];for(;s.nodeName!=="DIV";)a.push(s),s=s.parentNode;if(!a.find(m=>m.nodeName==="A"))return!1;const l=sv(e.state,t.type.name),u=r.target,f=(o=u==null?void 0:u.href)!==null&&o!==void 0?o:l.href,p=(i=u==null?void 0:u.target)!==null&&i!==void 0?i:l.target;return u&&f?(window.open(f,p),!0):!1}}})}function Fce(t){return new on({key:new On("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:o}=e,{selection:i}=o,{empty:s}=i;if(s)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const l=jD(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!l?!1:t.editor.commands.setMark(t.type,{href:l.href})}}})}function Ks(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(jce,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Vce=Or.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){YE(t);return}YE(t.scheme,t.optionalSlashes)})},onDestroy(){Dce()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Ks(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ks(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Ks(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Tt(this.options.HTMLAttributes,t),0]:["a",Tt(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ks(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ks(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Ts({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,o=jD(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!Ks(s,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(Lce({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Ks(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(Bce({type:this.type})),this.options.linkOnPaste&&t.push(Fce({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}});function zce(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:a}=t,l=r&&!o,u=J7(n),f=new RegExp(`\\s${u}$`),p=s?"^":"",m=o?"":u,b=l?new RegExp(`${p}${u}.*?(?=\\s${m}|$)`,"gm"):new RegExp(`${p}(?:^)?${u}[^\\s${m}]*`,"gm"),v=((e=a.nodeBefore)===null||e===void 0?void 0:e.isText)&&a.nodeBefore.text;if(!v)return null;const y=a.pos-v.length,x=Array.from(v.matchAll(b)).pop();if(!x||x.input===void 0||x.index===void 0)return null;const C=x.input.slice(Math.max(0,x.index-1),x.index),k=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(C);if(i!==null&&!k)return null;const T=y+x.index;let S=T+x[0].length;return l&&f.test(v.slice(S-1,S+1))&&(x[0]+=" ",S+=1),T<a.pos&&S>=a.pos?{range:{from:T,to:S},query:x[0].slice(n.length),text:x[0]}:null}const Hce=new On("suggestion");function Wce({pluginKey:t=Hce,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:u="",decorationEmptyClass:f="is-empty",command:p=()=>null,items:m=()=>[],render:b=()=>({}),allow:v=()=>!0,findSuggestionMatch:y=zce}){let x;const C=b==null?void 0:b(),k=new on({key:t,view(){return{update:async(T,S)=>{var O,R,P,j,F,M,$;const z=(O=this.key)===null||O===void 0?void 0:O.getState(S),L=(R=this.key)===null||R===void 0?void 0:R.getState(T.state),A=z.active&&L.active&&z.range.from!==L.range.from,_=!z.active&&L.active,I=z.active&&!L.active,B=!_&&!I&&z.query!==L.query,W=_||A&&B,K=B||A,U=I||A&&B;if(!W&&!K&&!U)return;const Y=U&&!W?z:L,fe=T.dom.querySelector(`[data-decoration-id="${Y.decorationId}"]`);x={editor:e,range:Y.range,query:Y.query,text:Y.text,items:[],command:ue=>p({editor:e,range:Y.range,props:ue}),decorationNode:fe,clientRect:fe?()=>{var ue;const{decorationId:pe}=(ue=this.key)===null||ue===void 0?void 0:ue.getState(e.state),Z=T.dom.querySelector(`[data-decoration-id="${pe}"]`);return(Z==null?void 0:Z.getBoundingClientRect())||null}:null},W&&((P=C==null?void 0:C.onBeforeStart)===null||P===void 0||P.call(C,x)),K&&((j=C==null?void 0:C.onBeforeUpdate)===null||j===void 0||j.call(C,x)),(K||W)&&(x.items=await m({editor:e,query:Y.query})),U&&((F=C==null?void 0:C.onExit)===null||F===void 0||F.call(C,x)),K&&((M=C==null?void 0:C.onUpdate)===null||M===void 0||M.call(C,x)),W&&(($=C==null?void 0:C.onStart)===null||$===void 0||$.call(C,x))},destroy:()=>{var T;x&&((T=C==null?void 0:C.onExit)===null||T===void 0||T.call(C,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(T,S,O,R){const{isEditable:P}=e,{composing:j}=e.view,{selection:F}=T,{empty:M,from:$}=F,z={...S};if(z.composing=j,P&&(M||e.view.composing)){($<S.range.from||$>S.range.to)&&!j&&!S.composing&&(z.active=!1);const L=y({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:i,startOfLine:s,$position:F.$from}),A=`id_${Math.floor(Math.random()*4294967295)}`;L&&v({editor:e,state:R,range:L.range,isActive:S.active})?(z.active=!0,z.decorationId=S.decorationId?S.decorationId:A,z.range=L.range,z.query=L.query,z.text=L.text):z.active=!1}else z.active=!1;return z.active||(z.decorationId=null,z.range={from:0,to:0},z.query=null,z.text=null),z}},props:{handleKeyDown(T,S){var O;const{active:R,range:P}=k.getState(T.state);return R&&((O=C==null?void 0:C.onKeyDown)===null||O===void 0?void 0:O.call(C,{view:T,event:S,range:P}))||!1},decorations(T){const{active:S,range:O,decorationId:R,query:P}=k.getState(T);if(!S)return null;const j=!(P!=null&&P.length),F=[l];return j&&F.push(f),Xt.create(T.doc,[Zn.inline(O.from,O.to,{nodeName:a,class:F.join(" "),"data-decoration-id":R,"data-decoration-content":u})])}}});return k}function Uce({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const o=new On;return{editor:t,char:r,pluginKey:o,command:({editor:i,range:s,props:a})=>{var l,u,f;const p=i.view.state.selection.$to.nodeAfter;((l=p==null?void 0:p.text)===null||l===void 0?void 0:l.startsWith(" "))&&(s.to+=1),i.chain().focus().insertContentAt(s,[{type:n,attrs:{...a,mentionSuggestionChar:r}},{type:"text",text:" "}]).run(),(f=(u=i.view.dom.ownerDocument.defaultView)===null||u===void 0?void 0:u.getSelection())===null||f===void 0||f.collapseToEnd()},allow:({state:i,range:s})=>{const a=i.doc.resolve(s.from),l=i.schema.nodes[n];return!!a.parent.type.contentMatch.matchType(l)},...e}}function $D(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Uce({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function GE(t,e){const n=$D(t),r=n.find(o=>o.char===e);return r||(n.length?n[0]:null)}const qce=rn.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){var n,r;return`${(n=e==null?void 0:e.char)!==null&&n!==void 0?n:"@"}${(r=t.attrs.label)!==null&&r!==void 0?r:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){var r,o;return["span",Tt(this.HTMLAttributes,t.HTMLAttributes),`${(r=n==null?void 0:n.char)!==null&&r!==void 0?r:"@"}${(o=e.attrs.label)!==null&&o!==void 0?o:e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){const n=GE(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Tt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=Tt({"data-type":this.name},this.options.HTMLAttributes,e);const o=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof o=="string"?["span",Tt({"data-type":this.name},this.options.HTMLAttributes,e),o]:o},renderText({node:t}){const e={options:this.options,node:t,suggestion:GE(this,t.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel(e)):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:r}=e,{empty:o,anchor:i}=r;if(!o)return!1;e.doc.nodesBetween(i-1,i,(l,u)=>{if(l.type.name===this.name)return n=!0,t.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",u,u+l.nodeSize),!1});let s=new Ri,a=0;return e.doc.nodesBetween(i-1,i,(l,u)=>{if(l.type.name===this.name)return n=!0,s=l,a=u,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":s.attrs.mentionSuggestionChar,a,a+s.nodeSize),n})}},addProseMirrorPlugins(){return $D(this).map(Wce)}}),LD=gn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new on({key:new On("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((s,a)=>{const l=r>=a&&r<=a+s.nodeSize,u=!s.isLeaf&&Ph(s);if((l||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const p=Zn.node(a,a+s.nodeSize,{class:f.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:a,hasAnchor:l}):this.options.placeholder});o.push(p)}return this.options.includeChildren}),Xt.create(t,o)}}})]}}),Kce=Or.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",Tt(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Yce=rn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Tt(this.options.HTMLAttributes,t),0]}}),Gce=rn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Tt(this.options.HTMLAttributes,t),0]}}),Jce=rn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Tt(this.options.HTMLAttributes,t),0]}}),Xce=/^\s*(\[([( |x])?\])\s$/,Zce=rn.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Tt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const o=document.createElement("li"),i=document.createElement("label"),s=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),u=()=>{var f,p;a.ariaLabel=((p=(f=this.options.a11y)===null||f===void 0?void 0:f.checkboxLabel)===null||p===void 0?void 0:p.call(f,t,a.checked))||`Task item checkbox for ${t.textContent||"empty task item"}`};return u(),i.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",f=>f.preventDefault()),a.addEventListener("change",f=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:p}=f.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:m})=>{const b=n();if(typeof b!="number")return!1;const v=m.doc.nodeAt(b);return m.setNodeMarkup(b,void 0,{...v==null?void 0:v.attrs,checked:p}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,p)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([f,p])=>{o.setAttribute(f,p)}),o.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,i.append(a,s),o.append(i,l),Object.entries(e).forEach(([f,p])=>{o.setAttribute(f,p)}),{dom:o,contentDOM:l,update:f=>f.type!==this.type?!1:(o.dataset.checked=f.attrs.checked,a.checked=f.attrs.checked,u(),!0)}}},addInputRules(){return[Al({find:Xce,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Qce=rn.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Tt(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),eue=gn.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),BD=J.forwardRef((t,e)=>{const[n,r]=J.useState(0),o=l=>{if(l>=t.items.length)return;const u=t.items[l],f={id:u.id,label:u.mentionLabel};t.command(f)},i=()=>{r((n+t.items.length-1)%t.items.length)},s=()=>{r((n+1)%t.items.length)},a=()=>{o(n)};return J.useEffect(()=>r(0),[t.items]),J.useImperativeHandle(e,()=>({onKeyDown:({event:l})=>l.key==="ArrowUp"?(i(),!0):l.key==="ArrowDown"?(s(),!0):l.key==="Enter"?(a(),!0):!1})),t.items.length>0?g.jsx(V.Paper,{elevation:5,children:g.jsx(V.List,{dense:!0,sx:{overflow:"hidden"},children:t.items.map((l,u)=>g.jsx(V.ListItem,{disablePadding:!0,children:g.jsx(V.ListItemButton,{selected:u===n,onClick:()=>o(u),children:l.mentionLabel})},l.id))})}):null});BD.displayName="SuggestionList";const JE={bottom:0,height:0,left:0,right:0,top:0,width:0,x:0,y:0,toJSON(){return{}}},tue={items:async({query:t})=>Promise.resolve(["Lea Thompson","Cyndi Lauper","Tom Cruise","Madonna","Jerry Hall","Joan Collins","Winona Ryder","Christina Applegate","Alyssa Milano","Molly Ringwald","Ally Sheedy","Debbie Harry","Olivia Newton-John","Elton John","Michael J. Fox","Axl Rose","Emilio Estevez","Ralph Macchio","Rob Lowe","Jennifer Grey","Mickey Rourke","John Cusack","Matthew Broderick","Justine Bateman","Lisa Bonet","Benicio Monserrate Rafael del Toro Sánchez"].map((e,n)=>({mentionLabel:e,id:n.toString()})).filter(e=>e.mentionLabel.toLowerCase().startsWith(t.toLowerCase())).slice(0,5)),render:()=>{let t,e;return{onStart:n=>{t=new H2(BD,{props:n,editor:n.editor}),e=qu("body",{getReferenceClientRect:()=>{var r;return((r=n.clientRect)==null?void 0:r.call(n))??JE},appendTo:()=>document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})[0]},onUpdate(n){t==null||t.updateProps(n),e==null||e.setProps({getReferenceClientRect:()=>{var r;return((r=n.clientRect)==null?void 0:r.call(n))??JE}})},onKeyDown(n){return n.event.key==="Escape"?(e==null||e.hide(),!0):t!=null&&t.ref?t.ref.onKeyDown(n):!1},onExit(){e==null||e.destroy(),t==null||t.destroy(),e=void 0,t=void 0}}}},nue=Vce.extend({inclusive:!1}),rue=Kce.extend({excludes:"superscript"}),oue=pI.extend({excludes:"subscript"});function iue({placeholder:t}={}){return J.useMemo(()=>[Uee.configure({resizable:!0}),Jce,Gce,Yce,J_,Z_,Q_,rR,fR,pR,hR,rue,oue,gR,G_,Y_,X_,dR,Jv,mR,nue.configure({autolink:!0,linkOnPaste:!0,openOnClick:!1}),MQ,nR,EQ,eue.configure({types:["heading","paragraph","image"]}),hce,mce,gce,CZ,bR.configure({multicolor:!0}),uR,HQ,eR,Qce,Zce.configure({nested:!0}),qce.configure({suggestion:tue}),LD.configure({placeholder:t}),cR],[t])}function XE(t){return Array.from(t).filter(e=>(e.type||"").toLowerCase().startsWith("image/"))}const sue=t=>{const e=iue({placeholder:"Add your own content here..."});if(t.renderContentOnly)return g.jsx(dI,{content:t.renderContentOnly,extensions:e});const{name:n,label:r,labelProps:o={fontSize:"0.9em",color:"#808080",fontWeight:"400"},onUploadFiles:i,readOnly:s=!1}=t,[a,l,u]=Ht.useField({name:n}),{setValue:f}=u,{value:p}=a;J.useEffect(()=>{var C,k,T;(T=(k=(C=m==null?void 0:m.current)==null?void 0:C.editor)==null?void 0:k.commands)==null||T.setContent(p)},[p]);const m=J.useRef(null),b=J.useCallback((C,k)=>{var S;const T=(S=m.current)==null?void 0:S.editor;if(!(!T||!i))if(i instanceof Promise)i(C).then(O=>{t0({images:O,editor:T,position:k})});else{const O=i(C);t0({images:O,editor:T,position:k})}},[]),v=J.useCallback((C,k,T,S)=>{var R;if(!(k instanceof DragEvent)||!k.dataTransfer)return!1;const O=XE(k.dataTransfer.files);if(O.length>0){const P=(R=C.posAtCoords({left:k.clientX,top:k.clientY}))==null?void 0:R.pos;return b(O,P),k.preventDefault(),!0}return!1},[b]),y=J.useCallback((C,k,T)=>{if(!k.clipboardData)return!1;const S=XE(k.clipboardData.files);return S.length>0?(b(S),!0):!1},[b]),x=g.jsx(V.Box,{sx:{"& .ProseMirror":{"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:s?0:50}}},children:g.jsx(uI,{ref:m,extensions:e,content:p,editable:!s,editorProps:{handleDrop:v,handlePaste:y},renderControls:s?void 0:()=>g.jsx(fce,{onUploadFiles:i}),onBlur:()=>{var C,k;return f(((k=(C=m.current)==null?void 0:C.editor)==null?void 0:k.getHTML())??"")},RichTextFieldProps:{variant:"outlined",MenuBarProps:{hide:s}},children:()=>g.jsxs(g.Fragment,{children:[g.jsx(fte,{}),g.jsx(Ete,{})]})})});return g.jsxs(V.Box,{display:"flex",flexDirection:"column",children:[r&&g.jsx(V.Typography,{...o,children:r}),x]})},ZE=t=>{const{colSpan:e,isExpanded:n,renderExpand:r,obj:o,asMobileCard:i=!1,reRenderExpand:s=!1}=t,[a,l]=J.useState(!1),[u,f]=J.useState(void 0);J.useEffect(()=>{n&&(!a||s)&&(l(!0),f(r(o)))},[n,o]);const p={"&:last-child > td":{borderBottom:"unset"}};return i?g.jsx(V.Collapse,{in:n,children:u}):g.jsx(V.TableRow,{sx:p,children:g.jsx(V.TableCell,{sx:{paddingBottom:0,paddingTop:0},colSpan:e,children:g.jsx(V.Collapse,{in:n,children:u})})})},Ox=({isLoading:t,children:e})=>{const[n,r]=J.useState(!1);return J.useEffect(()=>{let o,i;return t?o=setTimeout(()=>r(!0),300):n?i=setTimeout(()=>r(!1),200):(o&&clearTimeout(o),r(!1)),()=>{o&&clearTimeout(o),i&&clearTimeout(i)}},[t,n]),g.jsxs(V.Box,{position:"relative","data-testid":`loading-overlay_${t?"active":"inactive"}`,children:[e,g.jsx(V.Box,{sx:{position:"absolute",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(255,255,255,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,pointerEvents:n?"auto":"none",opacity:n?1:0,transition:"opacity 0.3s ease"},children:g.jsx(V.CircularProgress,{})})]})},Ko=t=>{const{gap:e=1,alignItems:n="center",...r}=t;return g.jsx(V.Box,{display:"flex",flexDirection:"row",gap:e,alignItems:n,...r})},Ru=t=>{const{gap:e=1,...n}=t;return g.jsx(V.Box,{display:"flex",flexDirection:"column",gap:e,...n})};function FD({icon:t,children:e,sx:n,...r}){return e?g.jsx(V.Tooltip,{title:e,children:g.jsx(t,{"data-testid":"MBv2_table-tooltip",fontSize:"small",sx:n??{ml:.5},...r})}):null}function VD(t){return g.jsx(FD,{icon:Sne,...t})}const Mx=t=>{const{id:e,getRowKey:n=me=>"id"in me&&(typeof me.id=="string"||typeof me.id=="number")&&me.id!=null?me.id:(console.warn(`Table: "id" not found or undefined in ${JSON.stringify(me)}. If provided, id must have a value and be type string or number. Please implement the Table.getRowKey prop so Table knows how to uniquely identify this row.`),String(JSON.stringify(me))),columns:r,data:o=[],onRowClick:i,onRowClickObj:s,checkedKeys:a,setCheckedKeys:l,renderExpand:u,sortField:f,sortOrder:p,onSortChange:m,allowSortCols:b,fixedLayout:v=!1,className:y,emptyTableMsg:x="No items to display",errorTableMsg:C,retryCallback:k,isLoading:T=!1,disableMobileCards:S=!1,highlightSelectedRow:O=!1,selectedRowColor:R,selectedRowKey:P,headerRowStyle:j={},stickyHeader:F,reRenderExpand:M=!1,expandOnRowClick:$=!1,tooltipProps:z={},...L}=t,{palette:A}=V.useTheme(),_=A.grey[A.mode=="dark"?600:50],[I,B]=J.useState(void 0),[W,K]=J.useState(typeof O=="string"||typeof O=="number"?O:void 0);aue(t);const U=me=>{me!==f?m&&m(me,"asc"):m&&m(f,p==="asc"?"desc":"asc")},Y=me=>f===me?p:null,fe=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),ue=r.filter(me=>!me.hideCol&&(!fe||!me.hideOnMobile));u&&!fe&&ue.unshift({key:"MBv2_Expandable_Column",fieldName:"id",label:"",render:(me,je)=>{const Ie=n(je),gt=I===Ie;return g.jsx(V.IconButton,{"data-testid":"expand-collapse-btn","aria-label":gt?"collapse row":"expand row",size:"small",onClick:()=>X(Ie),children:gt?g.jsx(Lf,{"data-testid":"collapse-up"}):g.jsx(ib,{"data-testid":"expand-down"})})}}),a&&l&&ue.unshift({key:"MBv2_Checkbox_Column",fieldName:"id",label:"",hideOnMobile:!0,render:(me,je)=>{const Ie=n(je);return g.jsx(V.Checkbox,{onChange:()=>{const gt=a.includes(Ie);l(gt?a.filter(lt=>lt!==Ie):[...a,Ie])},checked:a.includes(Ie)})}});const pe=m!==void 0,Z=me=>pe?b?b.includes(me):!0:!1,te=g.jsxs(V.Box,{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"row",children:[g.jsx(Tne,{})," ",x]}),ce=g.jsxs(V.Box,{"data-testid":"table-fetch-error-msg",display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"row",children:[g.jsx(nM,{color:"error"})," ",C,k&&g.jsx(V.Button,{variant:"text",onClick:k,children:"Retry?"})]}),ne=()=>{if(C)return g.jsx(V.TableRow,{children:g.jsx(V.TableCell,{colSpan:r.length,align:"center",sx:{borderBottom:"unset"},children:ce})});if(o.length===0)return g.jsx(V.TableRow,{children:g.jsx(V.TableCell,{colSpan:r.length,align:"center",sx:{borderBottom:"unset"},children:te})})},re=()=>{if(C)return ce;if(o.length===0)return te},le=me=>{O&&K(me)},ge=me=>{const je=n(me);if((i||s)&&(i==null||i(je),s==null||s(me),le(je)),u&&$){const Ie=I===je?void 0:je;B(Ie),le(Ie)}},X=me=>{const je=I===me?void 0:me;B(je),le(je)},ee=me=>{if(!u)return;const je=I===n(me);return g.jsxs(g.Fragment,{children:[g.jsxs(V.Button,{"data-testid":"show-more-less-btn",variant:"text",onClick:()=>X(n(me)),children:[je?g.jsx(Lf,{}):g.jsx(ib,{})," Show"," ",je?"Less":"More"]}),g.jsx(ZE,{colSpan:r.length,isExpanded:n(me)===I,obj:me,renderExpand:Ie=>u(Ie),asMobileCard:!0})]})},ie=R??_,we=me=>{const Ie=(O?W:P)===n(me)?ie:"inherit",gt=i||s||$;return{cursor:gt?"pointer":"default",backgroundColor:Ie,...u?{"& > td":{borderBottom:"unset"}}:{"&:last-child td":{borderBottom:"unset"}},...gt&&{"&:hover":{backgroundColor:Ie===ie?Uie(Ie,.1):ie}}}},Se=me=>g.jsx(VD,{...z,children:me}),De=(me,je)=>{const Ie=me.find(lt=>lt.key==="MBv2_Checkbox_Column"),gt=ue.filter(lt=>lt.key!=="MBv2_Checkbox_Column");return g.jsxs(Ko,{alignItems:"flex-start",children:[Ie&&g.jsx(Ru,{children:Tl(Ie,je,fe)}),g.jsxs(Ru,{width:"100%",children:[g.jsx("table",{className:"MBv2_Table_Stack",children:g.jsx("tbody",{className:"MBv2_Table_Stack_Body",children:gt.map(lt=>g.jsxs("tr",{className:"MBv2_Table_Stack_Row",children:[g.jsxs("td",{className:`MBv2_Table_Stack_Cell_Label MBv2_Table_Stack_Col_${wn(lt)}`,style:{textWrap:"nowrap"},children:[lt.label??Fn(wn(lt)),Se(lt.tooltip)]}),g.jsx("td",{className:`MBv2_Table_Stack_Cell_Value MBv2_Table_Stack_Val_${wn(lt)}`,style:{paddingLeft:"10px"},children:Tl(lt,je,fe)})]},`row-${n(je)}-${wn(lt)}`))})}),ee(je)]})]})},Me=()=>g.jsxs("div",{...e?{id:`mobile-table-${e}`}:{},className:y,"data-testid":"mui-table-mobile",children:[pe&&g.jsxs(g.Fragment,{children:[g.jsxs(V.Box,{display:"flex",className:"MBv2_Table_Stack_Sort",children:[g.jsx(V.TextField,{select:!0,sx:{flexGrow:1},size:"small",value:f??"",label:"Sort By...",onChange:me=>U(me.target.value),fullWidth:!0,children:ue.map(me=>{if(Z(wn(me)))return g.jsx(V.MenuItem,{value:wn(me),children:me.label??Fn(wn(me))},`rowHeader-${wn(me)}`)})}),g.jsx(V.IconButton,{onClick:()=>{f&&U(f)},children:g.jsx(Dne,{className:`sort-icon-${p}`})})]}),g.jsx(V.Divider,{sx:{margin:"10px 0"}})]}),re()??o.map(me=>g.jsx(V.Card,{className:"MBv2_Table_Stack_Container",sx:{margin:"5px 0",padding:"5px",overflowX:"auto",...we(me)},onClick:()=>ge(me),"data-testid":`card-${n(me)}`,children:De(ue,me)},n(me)))]}),Re=()=>g.jsx(V.TableContainer,{component:V.Card,"data-testid":"mui-table",...e?{tableId:`table-${e}`}:{},className:y,style:F?{maxHeight:F,overflow:"auto"}:{},children:g.jsxs(V.Table,{stickyHeader:F!=="undefined",style:{tableLayout:v?"fixed":"auto"},className:"MBv2_Table",sx:j?{"& .MuiTableCell-head":{...j}}:{},...L,children:[g.jsx(V.TableHead,{className:"MBv2_Table_Head",children:g.jsx(V.TableRow,{className:"MBv2_Table_Head_Row",children:ue.map((me,je)=>{const Ie=Z(wn(me));return g.jsx(V.TableCell,{width:Array.isArray(v)?v[je]:"auto",sx:me.tableCellSx??{},children:g.jsx(V.Box,{style:{display:"flex",alignItems:"center"},children:g.jsxs(V.Box,{sx:[Ie&&{"&:hover":{cursor:"pointer",backgroundColor:A.mode==="dark"?"#222222":"#ededed",borderRadius:2}}],style:{display:"flex",alignItems:"center",padding:"5px",paddingLeft:"6px",marginLeft:"-6px"},onClick:Ie?()=>U(wn(me)):void 0,children:[g.jsx("strong",{className:"MBv2_Table_Col_Label",style:{wordBreak:"normal"},"data-testid":"column-title",children:me.label??Fn(wn(me))}),Se(me.tooltip),Ie&&Y(wn(me))==="asc"&&g.jsx(Lf,{style:{marginLeft:"5px"}}),Ie&&Y(wn(me))==="desc"&&g.jsx(ib,{style:{marginLeft:"5px"}}),Ie&&Y(wn(me))!=="asc"&&Y(wn(me))!=="desc"&&g.jsx(Rne,{style:{marginLeft:"5px"}})]})})},`rowHeader-${wn(me)}`)})})}),g.jsx(V.TableBody,{className:"MBv2_Table_Body",children:ne()??o.map(me=>g.jsxs(J.Fragment,{children:[g.jsx(V.TableRow,{"data-testid":`row-${n(me)}`,className:"MBv2_Table_Body_Row",onClick:()=>ge(me),sx:we(me),children:ue.map(je=>g.jsx(V.TableCell,{className:`MBv2_Table_Body_Cell MBv2_Table_Body_Col_${wn(je)}`,children:Tl(je,me,fe)},`row-${n(me)}-${wn(je)}`))}),u&&g.jsx(ZE,{colSpan:ue.length,isExpanded:n(me)===I,obj:me,renderExpand:je=>u(je),reRenderExpand:M})]},n(me)))})]})});return g.jsx(Ox,{isLoading:T,children:fe&&!S?Me():Re()})},aue=t=>{const{fixedLayout:e,checkedKeys:n,setCheckedKeys:r,renderExpand:o,columns:i,expandOnRowClick:s,onRowClick:a,onRowClickObj:l,selectedRowKey:u,highlightSelectedRow:f}=t,p="Table component:";Array.isArray(e)&&(!o&&e.length!==i.length&&console.warn(`${p} Length of "fixedLayout" is not equal to the length of "columns". Got=${e.length}. Expected=${i.length}`),o&&e.length!==i.length+1&&console.warn(`${p} Length of "fixedLayout" is not equal to the length of "columns"+1. Make sure you're including a percentage for the expand/collapse column AND each column in "columns".`)),s&&!o&&console.warn(`${p} renderExpand should be defined when expandOnRowClick is defined`),a&&l&&console.warn(`${p} 'onRowClick' and 'onRowClickObj' are both defined. Only one should be defined.`),(n||r)&&o&&console.warn(`${p} checkedKeys/setCheckedKeys & renderExpand cannot both be defined`),n&&!r&&console.warn(`${p} if checkedKeys is defined, setCheckedKeys must also be defined`),!n&&r&&console.warn(`${p} if setCheckedKeys is defined, checkedKeys must also be defined`);const m=i.map(y=>wn(y)),b=m.filter((y,x)=>m.indexOf(y)!==x),v=[...new Set(b)];v.length>0&&console.warn(`${p} duplicate key/fieldName found in 'columns': ${v.join(", ")}. Make sure to define a unique 'key' if you have multiple column definitions with the same 'fieldName'.`),f&&u&&console.warn(`${p} must choose 'highlightSelectedRow' (uncontrolled) or 'selectedRowKey' (controlled)`)},wn=t=>t.key??t.fieldName,lue=(t,e)=>e.split(".").reduce((n,r)=>{if(n&&typeof n=="object")return n[r]},t),Tl=(t,e,n=!1)=>{const r=lue(e,t.fieldName);return t.render?t.render(r,e,n):r},zD=t=>{const{paginationState:e,onPageChange:n,onRowsPerPageChange:r,hidePaginationControls:o=!1,rowsPerPageOptions:i=[5,10,25],...s}=t,{pageNo:a,pageSize:l,totalCount:u,sortField:f,sortOrder:p}=e,m=x=>{n(x)},b=x=>{r(parseInt(x.target.value,10))},v=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),y=!t.data||t.data&&t.data.length===0;return g.jsxs(V.Box,{children:[g.jsx(Mx,{sortOrder:p,sortField:f,...s}),!o&&!y&&g.jsx(V.TablePagination,{"data-testid":"pagination-controls",component:"div",rowsPerPageOptions:v?[]:i,count:u,rowsPerPage:l,page:a,onPageChange:(x,C)=>m(C),onRowsPerPageChange:b,sx:{flexGrow:1,marginRight:{xs:0,md:15}}})]})},QE=()=>({height:window.innerHeight,width:window.innerWidth}),HD=()=>{const[t,e]=J.useState(QE());return J.useEffect(()=>{const n=()=>{e(QE())};return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),t},Sr=t=>{const{name:e="button",color:n="primary",fullWidthOnMobile:r=!0,type:o="button",variant:i="contained"}=t,{width:s}=HD(),a=["locationInBar","closeDialog","fullWidthOnMobile"],l=r&&s<600;return g.jsx(V.Button,{role:"button",name:e,color:n,variant:i,type:o,fullWidth:t.fullWidth?!0:l,...pr({...t},a)})},cue=t=>{const{citation:e,anchorEl:n,onDeleteCitation:r,onClose:o}=t;if(r)return g.jsx(V.Popper,{open:e!==null,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},children:e&&g.jsxs(V.Box,{component:V.Paper,p:1,display:"flex",gap:1,boxShadow:9,"data-testid":`citation-table_delete-prompt-${e.id}`,children:[g.jsxs(V.Typography,{variant:"body2",children:["Are you sure you want to delete this ",e.fileName?"attachment":"citation","?"]}),g.jsxs(V.Box,{display:"flex",flexDirection:"row",children:[g.jsx(Sr,{size:"small",variant:"text",onClick:o,"data-testid":`citation-table_delete-prompt-${e.id}-noBtn`,children:"No"}),g.jsx(Sr,{size:"small",color:"error",startIcon:g.jsx(Zv,{}),onClick:()=>r(e.id).finally(o),"data-testid":`citation-table_delete-prompt-${e.id}-yesBtn`,children:"Yes"})]})]})})},uue=t=>{const{citation:e,anchorEl:n,onClose:r,open:o}=t;return g.jsx(V.Popper,{open:o,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},children:e&&g.jsxs(V.Box,{component:V.Paper,p:1,display:"flex",gap:1,boxShadow:9,"data-testid":`citation-table_launch-link-prompt-${e.id}`,flexDirection:"column",alignItems:"end",children:[g.jsxs(V.Typography,{variant:"body2",sx:{wordBreak:"break-all",maxWidth:"350px"},children:["Are you sure you want to go to ",g.jsx("br",{}),g.jsx("b",{children:e.url}),"?"]}),g.jsxs(V.Box,{display:"flex",flexDirection:"row",children:[g.jsx(Sr,{size:"small",variant:"text",onClick:r,"data-testid":`citation-table_launch-prompt-${e.id}-noBtn`,children:"No"}),g.jsx(Sr,{size:"small",startIcon:g.jsx(ex,{}),onClick:()=>{window.open(e.url,"_blank","noopener,noreferrer"),r()},"data-testid":`citation-table_launch-prompt-${e.id}-yesBtn`,children:"Yes"})]})]})})};function T0({canLaunchUrl:t,citation:e,asLink:n}){const r=J.useRef(null),[o,i]=J.useState(!1),s=()=>{i(!1)};return!t||e.fileName?null:g.jsxs(g.Fragment,{children:[n?g.jsx(V.Link,{ref:r,component:"button",sx:{cursor:"pointer"},type:"button",onClick:()=>i(!0),children:e.url}):g.jsx(V.Tooltip,{title:"Open URL",children:g.jsx(V.IconButton,{ref:r,color:"primary",onClick:()=>{i(!0)},"data-testid":`citation-table_launch-link-btn-${e.id}`,sx:{visibility:t!=null&&t(e)?"visible":"hidden"},children:g.jsx(ex,{})})}),g.jsx(uue,{citation:e,anchorEl:r.current,onClose:s,open:o})]})}function WD({onDownloadAttachment:t,citation:e}){if(!(!t||!e.fileName))return g.jsx(V.Tooltip,{title:"Download",children:g.jsx(V.IconButton,{color:"primary",onClick:()=>t==null?void 0:t(e),"data-testid":`citation-table_download-btn-${e.id}`,children:g.jsx(wne,{})})})}function UD({onPreviewAttachment:t,citation:e}){if(!t||!e.fileName)return;const n=["pdf","png","jpg","jpeg","gif","bmp","svg","webp","mp3","wav","mp4","webm","html","htm","txt","xml","json","csv"],r=e.fileName.split(".").pop();if(!(!r||!n.includes(r)))return g.jsx(V.Tooltip,{title:"View File",children:g.jsx(V.IconButton,{color:"primary",onClick:()=>t==null?void 0:t(e),"data-testid":`citation-table_view-file-btn-${e.id}`,children:g.jsx(ex,{})})})}const _x=(t,e=30)=>ka.truncate(t,{length:e,omission:"..."}),due=t=>{const{refreshKey:e,title:n,onCancel:r,onNewCitation:o,onNewAttachment:i,onEditCitation:s,onEditAttachment:a,onViewCitation:l,onViewAttachment:u,onDeleteCitation:f,onDownloadAttachment:p,onPreviewAttachment:m,onSelect:b,getCitationsPaginated:v,selectedIds:y,setSelectedIds:x,onError:C=()=>{},condenseTable:k=!1,canSelect:T=!1,canLaunchUrl:S,addlActions:O,readOnly:R=!1,showCloseBtn:P=!1,canSearch:j=!1}=t,F=!!t.canCreate&&!R,M=!!a&&!!s&&!R,$=!!u&&!!l&&R&&k,z=!!f&&!R,{palette:L}=V.useTheme(),[A,_]=J.useState([]),[I,B]=J.useState(!1),[W,K]=J.useState(!0),[U,Y]=J.useState(null),[fe,ue]=J.useState(null),[pe,Z]=J.useState({pageNo:0,pageSize:k?5:10,totalCount:0,search:j?"":void 0}),te=()=>{B(!1),K(!0),v({pageNo:pe.pageNo,pageSize:pe.pageSize,search:pe.search},y).then(Re=>(_(Re.data),Z(me=>({...me,totalCount:Re.totalCount})),Re)).catch(Re=>{C(Re),B(!0),_([])}).finally(()=>K(!1))};J.useEffect(te,[pe.pageNo,pe.pageSize,e,pe.search]);const ce=()=>{ue(null),Y(null)},ne=g.jsx(Sr,{variant:T?"outlined":"contained",size:T?"small":"medium",onClick:o,startIcon:g.jsx(Kh,{}),children:"Add Citation"}),re=g.jsx(Sr,{variant:T?"outlined":"contained",size:T?"small":"medium",onClick:i,startIcon:g.jsx(TI,{}),children:"Add Attachment"}),le=Re=>{if(!(!M&&!$)){if(M)return g.jsx(V.Tooltip,{title:"Edit",children:g.jsx(V.IconButton,{color:"primary",onClick:()=>Re.fileName?a(Re.id):s(Re.id),"data-testid":`citation-table_edit-btn-${Re.id}`,children:g.jsx(Cne,{})})});if($)return g.jsx(V.Tooltip,{title:"View",children:g.jsx(V.IconButton,{color:"primary",onClick:()=>Re.fileName?u(Re.id):l(Re.id),"data-testid":`citation-table_view-btn-${Re.id}`,children:g.jsx(Ane,{})})})}},ge=Re=>{if(!(!z||R))return g.jsx(V.Tooltip,{title:"Delete",children:g.jsx(V.IconButton,{color:"error",onClick:me=>{ue(Re),Y(me.currentTarget)},"data-testid":`citation-table_delete-btn-${Re.id}`,children:g.jsx(Zv,{})})})},X=Re=>g.jsx(T0,{citation:Re,canLaunchUrl:S}),ee=Re=>g.jsx(UD,{citation:Re,onPreviewAttachment:m}),ie=Re=>g.jsx(WD,{citation:Re,onDownloadAttachment:p}),we=$||M||z||S||m||p||O,Se=[...qD(L,k),{fieldName:"id",key:"Action",label:"Action",hideCol:!we,render:(Re,me)=>g.jsxs(V.Box,{display:"flex",flexDirection:"row-reverse",children:[O==null?void 0:O(me),ge(me),le(me),ee(me),X(me),ie(me)]})}],De=J.useCallback(Re=>{Z(me=>({...me,pageNo:0,search:Re}))},[]),Me=()=>j?g.jsx(OI,{onSearch:De}):null;return g.jsxs(Ru,{children:[g.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[g.jsx(V.Typography,{variant:k?"h6":"h2",children:n}),!T&&F&&g.jsxs(V.Box,{display:"flex",flexDirection:"row",gap:1,children:[ne,re]}),P&&g.jsx(V.IconButton,{onClick:r,children:g.jsx(tm,{})})]}),Me(),g.jsx(zD,{"data-testid":"citation-table",size:k?"x-small":"medium",isLoading:W,columns:Se,data:A,paginationState:pe,onPageChange:Re=>Z(me=>({...me,pageNo:Re})),onRowsPerPageChange:Re=>Z(me=>({...me,pageSize:Re,pageNo:0})),errorTableMsg:I?"Failed to load citations.":void 0,retryCallback:te,setCheckedKeys:T?x:void 0,checkedKeys:T?y:void 0}),T&&g.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",children:[g.jsx(V.Box,{display:"flex",flexDirection:"row",gap:".25rem",children:F&&g.jsxs(g.Fragment,{children:[ne,re]})}),!R&&g.jsxs(V.Box,{display:"flex",flexDirection:"row",gap:".25rem",children:[g.jsx(Sr,{variant:"outlined",size:"small",onClick:r,children:"Cancel"}),g.jsxs(Sr,{variant:"contained",size:"small",onClick:()=>b(y),children:["Select",y.length>0&&` (${y.length})`]})]})]}),g.jsx(cue,{citation:fe,anchorEl:U,onDeleteCitation:f,onClose:ce})]})},eO=(t,e)=>{const n=t?_x(e):e,r=n==null?void 0:n.endsWith("...");return g.jsx("span",{style:{wordBreak:"break-all"},children:r?g.jsx(V.Tooltip,{title:e,children:g.jsx("span",{children:n})}):e})},qD=(t,e=!1)=>[{fieldName:"fileName",key:"CitationOrAttachment",label:"Type",render:(n,r)=>g.jsx(V.Tooltip,{title:n?"Attachment":"URL",children:n?g.jsx(TI,{sx:{color:t.grey[500],marginTop:"4px"},"data-testid":`attachment-icon-${r.id}`}):g.jsx(Kh,{sx:{color:t.grey[500],marginTop:"6px"},"data-testid":`url-icon-${r.id}`})}),ignoreDiff:!0},{fieldName:"title",render:n=>eO(e,n)},{fieldName:"fileName",key:"URL/File Name",label:"URL/Other Identifier/File Name",render:(n,r)=>eO(e,n||r.url),isEqual:(n,r)=>n.fileName&&r.fileName?n.fileName===r.fileName:n.url===r.url},{fieldName:"source",hideCol:e},{fieldName:"details",hideCol:e},{fieldName:"accessedAt",hideCol:e,render:(n,r)=>{if(!r.fileName)return(n==null?void 0:n.slice(0,10))??""}},{fieldName:"classification",hideCol:e}];var hb,tO;function fue(){if(tO)return hb;tO=1;function t(C){this._maxSize=C,this.clear()}t.prototype.clear=function(){this._size=0,this._values=Object.create(null)},t.prototype.get=function(C){return this._values[C]},t.prototype.set=function(C,k){return this._size>=this._maxSize&&this.clear(),C in this._values||this._size++,this._values[C]=k};var e=/[^.^\]^[]+|(?=\[\]|\.\.)/g,n=/^\d+$/,r=/^\d/,o=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,i=/^\s*(['"]?)(.*?)(\1)\s*$/,s=512,a=new t(s),l=new t(s),u=new t(s);hb={Cache:t,split:p,normalizePath:f,setter:function(C){var k=f(C);return l.get(C)||l.set(C,function(S,O){for(var R=0,P=k.length,j=S;R<P-1;){var F=k[R];if(F==="__proto__"||F==="constructor"||F==="prototype")return S;j=j[k[R++]]}j[k[R]]=O})},getter:function(C,k){var T=f(C);return u.get(C)||u.set(C,function(O){for(var R=0,P=T.length;R<P;)if(O!=null||!k)O=O[T[R++]];else return;return O})},join:function(C){return C.reduce(function(k,T){return k+(b(T)||n.test(T)?"["+T+"]":(k?".":"")+T)},"")},forEach:function(C,k,T){m(Array.isArray(C)?C:p(C),k,T)}};function f(C){return a.get(C)||a.set(C,p(C).map(function(k){return k.replace(i,"$2")}))}function p(C){return C.match(e)||[""]}function m(C,k,T){var S=C.length,O,R,P,j;for(R=0;R<S;R++)O=C[R],O&&(x(O)&&(O='"'+O+'"'),j=b(O),P=!j&&/^\d+$/.test(O),k.call(T,O,j,P,R,C))}function b(C){return typeof C=="string"&&C&&["'",'"'].indexOf(C.charAt(0))!==-1}function v(C){return C.match(r)&&!C.match(n)}function y(C){return o.test(C)}function x(C){return!b(C)&&(v(C)||y(C))}return hb}var ha=fue(),mb,nO;function pue(){if(nO)return mb;nO=1;const t=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,e=f=>f.match(t)||[],n=f=>f[0].toUpperCase()+f.slice(1),r=(f,p)=>e(f).join(p).toLowerCase(),o=f=>e(f).reduce((p,m)=>`${p}${p?m[0].toUpperCase()+m.slice(1).toLowerCase():m.toLowerCase()}`,"");return mb={words:e,upperFirst:n,camelCase:o,pascalCase:f=>n(o(f)),snakeCase:f=>r(f,"_"),kebabCase:f=>r(f,"-"),sentenceCase:f=>n(r(f," ")),titleCase:f=>e(f).map(n).join(" ")},mb}var gb=pue(),Tf={exports:{}},rO;function hue(){if(rO)return Tf.exports;rO=1,Tf.exports=function(o){return t(e(o),o)},Tf.exports.array=t;function t(o,i){var s=o.length,a=new Array(s),l={},u=s,f=n(i),p=r(o);for(i.forEach(function(b){if(!p.has(b[0])||!p.has(b[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});u--;)l[u]||m(o[u],u,new Set);return a;function m(b,v,y){if(y.has(b)){var x;try{x=", node was:"+JSON.stringify(b)}catch{x=""}throw new Error("Cyclic dependency"+x)}if(!p.has(b))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(b));if(!l[v]){l[v]=!0;var C=f.get(b)||new Set;if(C=Array.from(C),v=C.length){y.add(b);do{var k=C[--v];m(k,p.get(k),y)}while(v);y.delete(b)}a[--s]=b}}}function e(o){for(var i=new Set,s=0,a=o.length;s<a;s++){var l=o[s];i.add(l[0]),i.add(l[1])}return Array.from(i)}function n(o){for(var i=new Map,s=0,a=o.length;s<a;s++){var l=o[s];i.has(l[0])||i.set(l[0],new Set),i.has(l[1])||i.set(l[1],new Set),i.get(l[0]).add(l[1])}return i}function r(o){for(var i=new Map,s=0,a=o.length;s<a;s++)i.set(o[s],s);return i}return Tf.exports}var mue=hue();const gue=Qn(mue),yue=Object.prototype.toString,bue=Error.prototype.toString,vue=RegExp.prototype.toString,xue=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",wue=/^Symbol\((.*)\)(.*)$/;function Cue(t){return t!=+t?"NaN":t===0&&1/t<0?"-0":""+t}function oO(t,e=!1){if(t==null||t===!0||t===!1)return""+t;const n=typeof t;if(n==="number")return Cue(t);if(n==="string")return e?`"${t}"`:t;if(n==="function")return"[Function "+(t.name||"anonymous")+"]";if(n==="symbol")return xue.call(t).replace(wue,"Symbol($1)");const r=yue.call(t).slice(8,-1);return r==="Date"?isNaN(t.getTime())?""+t:t.toISOString(t):r==="Error"||t instanceof Error?"["+bue.call(t)+"]":r==="RegExp"?vue.call(t):null}function Cs(t,e){let n=oO(t,e);return n!==null?n:JSON.stringify(t,function(r,o){let i=oO(this[r],e);return i!==null?i:o},2)}function KD(t){return t==null?[]:[].concat(t)}let YD,GD,JD,Sue=/\$\{\s*(\w+)\s*\}/g;YD=Symbol.toStringTag;class iO{constructor(e,n,r,o){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[YD]="Error",this.name="ValidationError",this.value=n,this.path=r,this.type=o,this.errors=[],this.inner=[],KD(e).forEach(i=>{if(fr.isError(i)){this.errors.push(...i.errors);const s=i.inner.length?i.inner:[i];this.inner.push(...s)}else this.errors.push(i)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}}GD=Symbol.hasInstance;JD=Symbol.toStringTag;class fr extends Error{static formatError(e,n){const r=n.label||n.path||"this";return n=Object.assign({},n,{path:r,originalPath:n.path}),typeof e=="string"?e.replace(Sue,(o,i)=>Cs(n[i])):typeof e=="function"?e(n):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,n,r,o,i){const s=new iO(e,n,r,o);if(i)return s;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[JD]="Error",this.name=s.name,this.message=s.message,this.type=s.type,this.value=s.value,this.path=s.path,this.errors=s.errors,this.inner=s.inner,Error.captureStackTrace&&Error.captureStackTrace(this,fr)}static[GD](e){return iO[Symbol.hasInstance](e)||super[Symbol.hasInstance](e)}}let Fo={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:t,type:e,value:n,originalValue:r})=>{const o=r!=null&&r!==n?` (cast from the value \`${Cs(r,!0)}\`).`:".";return e!=="mixed"?`${t} must be a \`${e}\` type, but the final value was: \`${Cs(n,!0)}\``+o:`${t} must match the configured type. The validated value was: \`${Cs(n,!0)}\``+o}},xr={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},Tue={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},k0={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},kue={isValue:"${path} field must be ${value}"},Yf={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"},Eue={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},Oue={notType:t=>{const{path:e,value:n,spec:r}=t,o=r.types.length;if(Array.isArray(n)){if(n.length<o)return`${e} tuple value has too few items, expected a length of ${o} but got ${n.length} for value: \`${Cs(n,!0)}\``;if(n.length>o)return`${e} tuple value has too many items, expected a length of ${o} but got ${n.length} for value: \`${Cs(n,!0)}\``}return fr.formatError(Fo.notType,t)}};Object.assign(Object.create(null),{mixed:Fo,string:xr,number:Tue,date:k0,object:Yf,array:Eue,boolean:kue,tuple:Oue});const Rx=t=>t&&t.__isYupSchema__;class ih{static fromOptions(e,n){if(!n.then&&!n.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:r,then:o,otherwise:i}=n,s=typeof r=="function"?r:(...a)=>a.every(l=>l===r);return new ih(e,(a,l)=>{var u;let f=s(...a)?o:i;return(u=f==null?void 0:f(l))!=null?u:l})}constructor(e,n){this.fn=void 0,this.refs=e,this.refs=e,this.fn=n}resolve(e,n){let r=this.refs.map(i=>i.getValue(n==null?void 0:n.value,n==null?void 0:n.parent,n==null?void 0:n.context)),o=this.fn(r,e,n);if(o===void 0||o===e)return e;if(!Rx(o))throw new TypeError("conditions must return a schema object");return o.resolve(n)}}const kf={context:"$",value:"."};class Pa{constructor(e,n={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===kf.context,this.isValue=this.key[0]===kf.value,this.isSibling=!this.isContext&&!this.isValue;let r=this.isContext?kf.context:this.isValue?kf.value:"";this.path=this.key.slice(r.length),this.getter=this.path&&ha.getter(this.path,!0),this.map=n.map}getValue(e,n,r){let o=this.isContext?r:this.isValue?e:n;return this.getter&&(o=this.getter(o||{})),this.map&&(o=this.map(o)),o}cast(e,n){return this.getValue(e,n==null?void 0:n.parent,n==null?void 0:n.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}Pa.prototype.__isYupRef=!0;const aa=t=>t==null;function sl(t){function e({value:n,path:r="",options:o,originalValue:i,schema:s},a,l){const{name:u,test:f,params:p,message:m,skipAbsent:b}=t;let{parent:v,context:y,abortEarly:x=s.spec.abortEarly,disableStackTrace:C=s.spec.disableStackTrace}=o;const k={value:n,parent:v,context:y};function T($={}){const z=XD(Object.assign({value:n,originalValue:i,label:s.spec.label,path:$.path||r,spec:s.spec,disableStackTrace:$.disableStackTrace||C},p,$.params),k),L=new fr(fr.formatError($.message||m,z),n,z.path,$.type||u,z.disableStackTrace);return L.params=z,L}const S=x?a:l;let O={path:r,parent:v,type:u,from:o.from,createError:T,resolve($){return ZD($,k)},options:o,originalValue:i,schema:s};const R=$=>{fr.isError($)?S($):$?l(null):S(T())},P=$=>{fr.isError($)?S($):a($)};if(b&&aa(n))return R(!0);let F;try{var M;if(F=f.call(O,n,O),typeof((M=F)==null?void 0:M.then)=="function"){if(o.sync)throw new Error(`Validation test of type: "${O.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(F).then(R,P)}}catch($){P($);return}R(F)}return e.OPTIONS=t,e}function XD(t,e){if(!t)return t;for(const n of Object.keys(t))t[n]=ZD(t[n],e);return t}function ZD(t,e){return Pa.isRef(t)?t.getValue(e.value,e.parent,e.context):t}function Mue(t,e,n,r=n){let o,i,s;return e?(ha.forEach(e,(a,l,u)=>{let f=l?a.slice(1,a.length-1):a;t=t.resolve({context:r,parent:o,value:n});let p=t.type==="tuple",m=u?parseInt(f,10):0;if(t.innerType||p){if(p&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${s}" must contain an index to the tuple element, e.g. "${s}[0]"`);if(n&&m>=n.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);o=n,n=n&&n[m],t=p?t.spec.types[m]:t.innerType}if(!u){if(!t.fields||!t.fields[f])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${s} which is a type: "${t.type}")`);o=n,n=n&&n[f],t=t.fields[f]}i=f,s=l?"["+a+"]":"."+a}),{schema:t,parent:o,parentPath:i}):{parent:o,parentPath:e,schema:t}}class sh extends Set{describe(){const e=[];for(const n of this.values())e.push(Pa.isRef(n)?n.describe():n);return e}resolveAll(e){let n=[];for(const r of this.values())n.push(e(r));return n}clone(){return new sh(this.values())}merge(e,n){const r=this.clone();return e.forEach(o=>r.add(o)),n.forEach(o=>r.delete(o)),r}}function gl(t,e=new Map){if(Rx(t)||!t||typeof t!="object")return t;if(e.has(t))return e.get(t);let n;if(t instanceof Date)n=new Date(t.getTime()),e.set(t,n);else if(t instanceof RegExp)n=new RegExp(t),e.set(t,n);else if(Array.isArray(t)){n=new Array(t.length),e.set(t,n);for(let r=0;r<t.length;r++)n[r]=gl(t[r],e)}else if(t instanceof Map){n=new Map,e.set(t,n);for(const[r,o]of t.entries())n.set(r,gl(o,e))}else if(t instanceof Set){n=new Set,e.set(t,n);for(const r of t)n.add(gl(r,e))}else if(t instanceof Object){n={},e.set(t,n);for(const[r,o]of Object.entries(t))n[r]=gl(o,e)}else throw Error(`Unable to clone ${t}`);return n}function _ue(t){if(!(t!=null&&t.length))return;const e=[];let n="",r=!1,o=!1;for(let i=0;i<t.length;i++){const s=t[i];if(s==="["&&!o){n&&(e.push(...n.split(".").filter(Boolean)),n=""),r=!0;continue}if(s==="]"&&!o){n&&(/^\d+$/.test(n)?e.push(n):e.push(n.replace(/^"|"$/g,"")),n=""),r=!1;continue}if(s==='"'){o=!o;continue}if(s==="."&&!r&&!o){n&&(e.push(n),n="");continue}n+=s}return n&&e.push(...n.split(".").filter(Boolean)),e}function Rue(t,e){const n=e?`${e}.${t.path}`:t.path;return t.errors.map(r=>({message:r,path:_ue(n)}))}function QD(t,e){var n;if(!((n=t.inner)!=null&&n.length)&&t.errors.length)return Rue(t,e);const r=e?`${e}.${t.path}`:t.path;return t.inner.flatMap(o=>QD(o,r))}class ti{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new sh,this._blacklist=new sh,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(Fo.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},e==null?void 0:e.spec),this.withMutation(n=>{n.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const n=Object.create(Object.getPrototypeOf(this));return n.type=this.type,n._typeCheck=this._typeCheck,n._whitelist=this._whitelist.clone(),n._blacklist=this._blacklist.clone(),n.internalTests=Object.assign({},this.internalTests),n.exclusiveTests=Object.assign({},this.exclusiveTests),n.deps=[...this.deps],n.conditions=[...this.conditions],n.tests=[...this.tests],n.transforms=[...this.transforms],n.spec=gl(Object.assign({},this.spec,e)),n}label(e){let n=this.clone();return n.spec.label=e,n}meta(...e){if(e.length===0)return this.spec.meta;let n=this.clone();return n.spec.meta=Object.assign(n.spec.meta||{},e[0]),n}withMutation(e){let n=this._mutate;this._mutate=!0;let r=e(this);return this._mutate=n,r}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let n=this,r=e.clone();const o=Object.assign({},n.spec,r.spec);return r.spec=o,r.internalTests=Object.assign({},n.internalTests,r.internalTests),r._whitelist=n._whitelist.merge(e._whitelist,e._blacklist),r._blacklist=n._blacklist.merge(e._blacklist,e._whitelist),r.tests=n.tests,r.exclusiveTests=n.exclusiveTests,r.withMutation(i=>{e.tests.forEach(s=>{i.test(s.OPTIONS)})}),r.transforms=[...n.transforms,...r.transforms],r}isType(e){return e==null?!!(this.spec.nullable&&e===null||this.spec.optional&&e===void 0):this._typeCheck(e)}resolve(e){let n=this;if(n.conditions.length){let r=n.conditions;n=n.clone(),n.conditions=[],n=r.reduce((o,i)=>i.resolve(o,e),n),n=n.resolve(e)}return n}resolveOptions(e){var n,r,o,i;return Object.assign({},e,{from:e.from||[],strict:(n=e.strict)!=null?n:this.spec.strict,abortEarly:(r=e.abortEarly)!=null?r:this.spec.abortEarly,recursive:(o=e.recursive)!=null?o:this.spec.recursive,disableStackTrace:(i=e.disableStackTrace)!=null?i:this.spec.disableStackTrace})}cast(e,n={}){let r=this.resolve(Object.assign({},n,{value:e})),o=n.assert==="ignore-optionality",i=r._cast(e,n);if(n.assert!==!1&&!r.isType(i)){if(o&&aa(i))return i;let s=Cs(e),a=Cs(i);throw new TypeError(`The value of ${n.path||"field"} could not be cast to a value that satisfies the schema type: "${r.type}".
|
|
405
405
|
|
|
406
406
|
attempted value: ${s}
|
|
407
|
-
`+(a!==s?`result of cast: ${a}`:""))}return i}_cast(e,n){let r=e===void 0?e:this.transforms.reduce((o,i)=>i.call(this,o,e,this,n),e);return r===void 0&&(r=this.getDefault(n)),r}_validate(e,n={},r,o){let{path:i,originalValue:s=e,strict:a=this.spec.strict}=n,l=e;a||(l=this._cast(l,Object.assign({assert:!1},n)));let u=[];for(let f of Object.values(this.internalTests))f&&u.push(f);this.runTests({path:i,value:l,originalValue:s,options:n,tests:u},r,f=>{if(f.length)return o(f,l);this.runTests({path:i,value:l,originalValue:s,options:n,tests:this.tests},r,o)})}runTests(e,n,r){let o=!1,{tests:i,value:s,originalValue:a,path:l,options:u}=e,f=y=>{o||(o=!0,n(y,s))},p=y=>{o||(o=!0,r(y,s))},m=i.length,b=[];if(!m)return p([]);let v={value:s,originalValue:a,path:l,options:u,schema:this};for(let y=0;y<i.length;y++){const x=i[y];x(v,f,function(k){k&&(Array.isArray(k)?b.push(...k):b.push(k)),--m<=0&&p(b)})}}asNestedTest({key:e,index:n,parent:r,parentPath:o,originalParent:i,options:s}){const a=e??n;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof a=="number";let u=r[a];const f=Object.assign({},s,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[l?"index":"key"]:a,path:l||a.includes(".")?`${o||""}[${l?a:`"${a}"`}]`:(o?`${o}.`:"")+e});return(p,m,b)=>this.resolve(f)._validate(u,f,m,b)}validate(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return new Promise((s,a)=>o._validate(e,n,(l,u)=>{fr.isError(l)&&(l.value=u),a(l)},(l,u)=>{l.length?a(new fr(l,u,void 0,void 0,i)):s(u)}))}validateSync(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i,s=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return o._validate(e,Object.assign({},n,{sync:!0}),(a,l)=>{throw fr.isError(a)&&(a.value=l),a},(a,l)=>{if(a.length)throw new fr(a,e,void 0,void 0,s);i=l}),i}isValid(e,n){return this.validate(e,n).then(()=>!0,r=>{if(fr.isError(r))return!1;throw r})}isValidSync(e,n){try{return this.validateSync(e,n),!0}catch(r){if(fr.isError(r))return!1;throw r}}_getDefault(e){let n=this.spec.default;return n==null?n:typeof n=="function"?n.call(this,e):gl(n)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,n){const r=this.clone({nullable:e});return r.internalTests.nullable=sl({message:n,name:"nullable",test(o){return o===null?this.schema.spec.nullable:!0}}),r}optionality(e,n){const r=this.clone({optional:e});return r.internalTests.optionality=sl({message:n,name:"optionality",test(o){return o===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=Fo.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=Fo.notNull){return this.nullability(!1,e)}required(e=Fo.required){return this.clone().withMutation(n=>n.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let n=this.clone();return n.transforms.push(e),n}test(...e){let n;if(e.length===1?typeof e[0]=="function"?n={test:e[0]}:n=e[0]:e.length===2?n={name:e[0],test:e[1]}:n={name:e[0],message:e[1],test:e[2]},n.message===void 0&&(n.message=Fo.default),typeof n.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),o=sl(n),i=n.exclusive||n.name&&r.exclusiveTests[n.name]===!0;if(n.exclusive&&!n.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return n.name&&(r.exclusiveTests[n.name]=!!n.exclusive),r.tests=r.tests.filter(s=>!(s.OPTIONS.name===n.name&&(i||s.OPTIONS.test===o.OPTIONS.test))),r.tests.push(o),r}when(e,n){!Array.isArray(e)&&typeof e!="string"&&(n=e,e=".");let r=this.clone(),o=KD(e).map(i=>new Pa(i));return o.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof n=="function"?new ih(o,n):ih.fromOptions(o,n)),r}typeError(e){let n=this.clone();return n.internalTests.typeError=sl({message:e,name:"typeError",skipAbsent:!0,test(r){return this.schema._typeCheck(r)?!0:this.createError({params:{type:this.schema.type}})}}),n}oneOf(e,n=Fo.oneOf){let r=this.clone();return e.forEach(o=>{r._whitelist.add(o),r._blacklist.delete(o)}),r.internalTests.whiteList=sl({message:n,name:"oneOf",skipAbsent:!0,test(o){let i=this.schema._whitelist,s=i.resolveAll(this.resolve);return s.includes(o)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:s}})}}),r}notOneOf(e,n=Fo.notOneOf){let r=this.clone();return e.forEach(o=>{r._blacklist.add(o),r._whitelist.delete(o)}),r.internalTests.blacklist=sl({message:n,name:"notOneOf",test(o){let i=this.schema._blacklist,s=i.resolveAll(this.resolve);return s.includes(o)?this.createError({params:{values:Array.from(i).join(", "),resolved:s}}):!0}}),r}strip(e=!0){let n=this.clone();return n.spec.strip=e,n}describe(e){const n=(e?this.resolve(e):this).clone(),{label:r,meta:o,optional:i,nullable:s}=n.spec;return{meta:o,label:r,optional:i,nullable:s,default:n.getDefault(e),type:n.type,oneOf:n._whitelist.describe(),notOneOf:n._blacklist.describe(),tests:n.tests.filter((l,u,f)=>f.findIndex(p=>p.OPTIONS.name===l.OPTIONS.name)===u).map(l=>{const u=l.OPTIONS.params&&e?XD(Object.assign({},l.OPTIONS.params),e):l.OPTIONS.params;return{name:l.OPTIONS.name,params:u}})}}get"~standard"(){const e=this;return{version:1,vendor:"yup",async validate(r){try{return{value:await e.validate(r,{abortEarly:!1})}}catch(o){if(o instanceof fr)return{issues:QD(o)};throw o}}}}}ti.prototype.__isYupSchema__=!0;for(const t of["validate","validateSync"])ti.prototype[`${t}At`]=function(e,n,r={}){const{parent:o,parentPath:i,schema:s}=Mue(this,e,n,r.context);return s[t](o&&o[i],Object.assign({},r,{parent:o,path:e}))};for(const t of["equals","is"])ti.prototype[t]=ti.prototype.oneOf;for(const t of["not","nope"])ti.prototype[t]=ti.prototype.notOneOf;const Iue=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function Due(t){const e=E0(t);if(!e)return Date.parse?Date.parse(t):Number.NaN;if(e.z===void 0&&e.plusMinus===void 0)return new Date(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond).valueOf();let n=0;return e.z!=="Z"&&e.plusMinus!==void 0&&(n=e.hourOffset*60+e.minuteOffset,e.plusMinus==="+"&&(n=0-n)),Date.UTC(e.year,e.month,e.day,e.hour,e.minute+n,e.second,e.millisecond)}function E0(t){var e,n;const r=Iue.exec(t);return r?{year:xi(r[1]),month:xi(r[2],1)-1,day:xi(r[3],1),hour:xi(r[4]),minute:xi(r[5]),second:xi(r[6]),millisecond:r[7]?xi(r[7].substring(0,3)):0,precision:(e=(n=r[7])==null?void 0:n.length)!=null?e:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:xi(r[10]),minuteOffset:xi(r[11])}:null}function xi(t,e=0){return Number(t)||e}let Aue=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Pue=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,Nue=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,jue="^\\d{4}-\\d{2}-\\d{2}",$ue="\\d{2}:\\d{2}:\\d{2}",Lue="(([+-]\\d{2}(:?\\d{2})?)|Z)",Bue=new RegExp(`${jue}T${$ue}(\\.\\d+)?${Lue}$`),Fue=t=>aa(t)||t===t.trim(),Vue={}.toString();function kl(){return new eA}class eA extends ti{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,n)=>{if(!this.spec.coerce||this.isType(e)||Array.isArray(e))return e;const r=e!=null&&e.toString?e.toString():e;return r===Vue?e:r})})}required(e){return super.required(e).withMutation(n=>n.test({message:e||Fo.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(n=>n.OPTIONS.name!=="required"),e))}length(e,n=xr.length){return this.test({message:n,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,n=xr.min){return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,n=xr.max){return this.test({name:"max",exclusive:!0,message:n,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,n){let r=!1,o,i;return n&&(typeof n=="object"?{excludeEmptyString:r=!1,message:o,name:i}=n:o=n),this.test({name:i||"matches",message:o||xr.matches,params:{regex:e},skipAbsent:!0,test:s=>s===""&&r||s.search(e)!==-1})}email(e=xr.email){return this.matches(Aue,{name:"email",message:e,excludeEmptyString:!0})}url(e=xr.url){return this.matches(Pue,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=xr.uuid){return this.matches(Nue,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let n="",r,o;return e&&(typeof e=="object"?{message:n="",allowOffset:r=!1,precision:o=void 0}=e:n=e),this.matches(Bue,{name:"datetime",message:n||xr.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:n||xr.datetime_offset,params:{allowOffset:r},skipAbsent:!0,test:i=>{if(!i||r)return!0;const s=E0(i);return s?!!s.z:!1}}).test({name:"datetime_precision",message:n||xr.datetime_precision,params:{precision:o},skipAbsent:!0,test:i=>{if(!i||o==null)return!0;const s=E0(i);return s?s.precision===o:!1}})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=xr.trim){return this.transform(n=>n!=null?n.trim():n).test({message:e,name:"trim",test:Fue})}lowercase(e=xr.lowercase){return this.transform(n=>aa(n)?n:n.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>aa(n)||n===n.toLowerCase()})}uppercase(e=xr.uppercase){return this.transform(n=>aa(n)?n:n.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>aa(n)||n===n.toUpperCase()})}}kl.prototype=eA.prototype;let tA=new Date(""),zue=t=>Object.prototype.toString.call(t)==="[object Date]";function Ix(){return new Zu}class Zu extends ti{constructor(){super({type:"date",check(e){return zue(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,n)=>!this.spec.coerce||this.isType(e)||e===null?e:(e=Due(e),isNaN(e)?Zu.INVALID_DATE:new Date(e)))})}prepareParam(e,n){let r;if(Pa.isRef(e))r=e;else{let o=this.cast(e);if(!this._typeCheck(o))throw new TypeError(`\`${n}\` must be a Date or a value that can be \`cast()\` to a Date`);r=o}return r}min(e,n=k0.min){let r=this.prepareParam(e,"min");return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(o){return o>=this.resolve(r)}})}max(e,n=k0.max){let r=this.prepareParam(e,"max");return this.test({message:n,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(o){return o<=this.resolve(r)}})}}Zu.INVALID_DATE=tA;Ix.prototype=Zu.prototype;Ix.INVALID_DATE=tA;function Hue(t,e=[]){let n=[],r=new Set,o=new Set(e.map(([s,a])=>`${s}-${a}`));function i(s,a){let l=ha.split(s)[0];r.add(l),o.has(`${a}-${l}`)||n.push([a,l])}for(const s of Object.keys(t)){let a=t[s];r.add(s),Pa.isRef(a)&&a.isSibling?i(a.path,s):Rx(a)&&"deps"in a&&a.deps.forEach(l=>i(l,s))}return gue.array(Array.from(r),n).reverse()}function sO(t,e){let n=1/0;return t.some((r,o)=>{var i;if((i=e.path)!=null&&i.includes(r))return n=o,!0}),n}function nA(t){return(e,n)=>sO(t,e)-sO(t,n)}const Wue=(t,e,n)=>{if(typeof t!="string")return t;let r=t;try{r=JSON.parse(t)}catch{}return n.isType(r)?r:t};function Gf(t){if("fields"in t){const e={};for(const[n,r]of Object.entries(t.fields))e[n]=Gf(r);return t.setFields(e)}if(t.type==="array"){const e=t.optional();return e.innerType&&(e.innerType=Gf(e.innerType)),e}return t.type==="tuple"?t.optional().clone({types:t.spec.types.map(Gf)}):"optional"in t?t.optional():t}const Uue=(t,e)=>{const n=[...ha.normalizePath(e)];if(n.length===1)return n[0]in t;let r=n.pop(),o=ha.getter(ha.join(n),!0)(t);return!!(o&&r in o)};let aO=t=>Object.prototype.toString.call(t)==="[object Object]";function lO(t,e){let n=Object.keys(t.fields);return Object.keys(e).filter(r=>n.indexOf(r)===-1)}const que=nA([]);function Dx(t){return new rA(t)}class rA extends ti{constructor(e){super({type:"object",check(n){return aO(n)||typeof n=="function"}}),this.fields=Object.create(null),this._sortErrors=que,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,n={}){var r;let o=super._cast(e,n);if(o===void 0)return this.getDefault(n);if(!this._typeCheck(o))return o;let i=this.fields,s=(r=n.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(o).filter(p=>!this._nodes.includes(p))),l={},u=Object.assign({},n,{parent:l,__validating:n.__validating||!1}),f=!1;for(const p of a){let m=i[p],b=p in o,v=o[p];if(m){let y;u.path=(n.path?`${n.path}.`:"")+p,m=m.resolve({value:v,context:n.context,parent:l});let x=m instanceof ti?m.spec:void 0,C=x==null?void 0:x.strict;if(x!=null&&x.strip){f=f||p in o;continue}y=!n.__validating||!C?m.cast(v,u):v,y!==void 0&&(l[p]=y)}else b&&!s&&(l[p]=v);(b!==p in l||l[p]!==v)&&(f=!0)}return f?l:o}_validate(e,n={},r,o){let{from:i=[],originalValue:s=e,recursive:a=this.spec.recursive}=n;n.from=[{schema:this,value:s},...i],n.__validating=!0,n.originalValue=s,super._validate(e,n,r,(l,u)=>{if(!a||!aO(u)){o(l,u);return}s=s||u;let f=[];for(let p of this._nodes){let m=this.fields[p];!m||Pa.isRef(m)||f.push(m.asNestedTest({options:n,key:p,parent:u,parentPath:n.path,originalParent:s}))}this.runTests({tests:f,value:u,originalValue:s,options:n},r,p=>{o(p.sort(this._sortErrors).concat(l),u)})})}clone(e){const n=super.clone(e);return n.fields=Object.assign({},this.fields),n._nodes=this._nodes,n._excludedEdges=this._excludedEdges,n._sortErrors=this._sortErrors,n}concat(e){let n=super.concat(e),r=n.fields;for(let[o,i]of Object.entries(this.fields)){const s=r[o];r[o]=s===void 0?i:s}return n.withMutation(o=>o.setFields(r,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let n={};return this._nodes.forEach(r=>{var o;const i=this.fields[r];let s=e;(o=s)!=null&&o.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[r]})),n[r]=i&&"getDefault"in i?i.getDefault(s):void 0}),n}setFields(e,n){let r=this.clone();return r.fields=e,r._nodes=Hue(e,n),r._sortErrors=nA(Object.keys(e)),n&&(r._excludedEdges=n),r}shape(e,n=[]){return this.clone().withMutation(r=>{let o=r._excludedEdges;return n.length&&(Array.isArray(n[0])||(n=[n]),o=[...r._excludedEdges,...n]),r.setFields(Object.assign(r.fields,e),o)})}partial(){const e={};for(const[n,r]of Object.entries(this.fields))e[n]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return Gf(this)}pick(e){const n={};for(const r of e)this.fields[r]&&(n[r]=this.fields[r]);return this.setFields(n,this._excludedEdges.filter(([r,o])=>e.includes(r)&&e.includes(o)))}omit(e){const n=[];for(const r of Object.keys(this.fields))e.includes(r)||n.push(r);return this.pick(n)}from(e,n,r){let o=ha.getter(e,!0);return this.transform(i=>{if(!i)return i;let s=i;return Uue(i,e)&&(s=Object.assign({},i),r||delete s[e],s[n]=o(i)),s})}json(){return this.transform(Wue)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||Yf.exact,test(n){if(n==null)return!0;const r=lO(this.schema,n);return r.length===0||this.createError({params:{properties:r.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,n=Yf.noUnknown){typeof e!="boolean"&&(n=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:n,test(o){if(o==null)return!0;const i=lO(this.schema,o);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,n=Yf.noUnknown){return this.noUnknown(!e,n)}transformKeys(e){return this.transform(n=>{if(!n)return n;const r={};for(const o of Object.keys(n))r[e(o)]=n[o];return r})}camelCase(){return this.transformKeys(gb.camelCase)}snakeCase(){return this.transformKeys(gb.snakeCase)}constantCase(){return this.transformKeys(e=>gb.snakeCase(e).toUpperCase())}describe(e){const n=(e?this.resolve(e):this).clone(),r=super.describe(e);r.fields={};for(const[i,s]of Object.entries(n.fields)){var o;let a=e;(o=a)!=null&&o.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[i]})),r.fields[i]=s.describe(a)}return r}}Dx.prototype=rA.prototype;const Kue=t=>{const{open:e,anchorEl:n,onGenerateCitation:r,onClose:o}=t;return g.jsx(V.Popper,{open:e,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},sx:{maxWidth:"500px"},children:g.jsxs(Ru,{component:V.Paper,p:1,boxShadow:9,gap:.25,children:[g.jsx(V.Typography,{variant:"body1",children:"Paste in a preformatted citation"}),g.jsx(V.Typography,{variant:"body2",color:"text.secondary",fontStyle:"italic",fontSize:".8em",children:"For best results, ensure your citations use a vertical bar ( | ) to separate the title, source, url, etc. Incomplete citations are allowed but may result in incompletely filled fields."}),g.jsx(Ht.Formik,{initialValues:{pasteExistingCitation:""},onSubmit:({pasteExistingCitation:i})=>{r(Jue(i)),o()},children:({values:i,submitForm:s,setFieldValue:a})=>g.jsxs(Ko,{flexWrap:"wrap",justifyContent:"flex-end",children:[g.jsx(CI,{name:"pasteExistingCitation",errorMode:"collapse",label:"",placeholder:"Scientific News Today | How to Organize Your Workspace for Maximum Efficiency | https://mock-news-site.com | ACCESSED 2 JAN 2026 | Public Source",endIcon:g.jsx(V.Tooltip,{title:"Paste from Clipboard",children:g.jsx(V.IconButton,{"data-testid":"paste-content-button",onClick:()=>{navigator.clipboard.readText().then(l=>a("pasteExistingCitation",l))},children:g.jsx(xne,{})})})}),g.jsxs(Ko,{children:[g.jsx(Sr,{size:"small",variant:"outlined",onClick:o,"data-testid":"citation-table_paste-prompt_cancel",children:"Cancel"}),g.jsx(Sr,{size:"small",type:"submit",onClick:s,"data-testid":"citation-table_paste-prompt_submit",disabled:!i.pasteExistingCitation,children:"Prefill Citation"})]})]})})]})})},Yue=["https://","http://","www."],Gue=new RegExp(Yue.join("|")),Jue=t=>{const e=t.replace(/\.\s*$/,"").split("|").map(f=>f.trim()).filter(Boolean),n=e.findIndex(f=>f.match(Gue)),r=e.findIndex(f=>f.toUpperCase().startsWith("ACCESSED")),o=e.findIndex(f=>/\bSOURCE\b/.test(f.toUpperCase()));let s=[n,r,o].find(f=>f!==-1)??e.length;const a=s-1,l=s-2;return{type:"Url",source:Ef(e,l),title:Ef(e,a),url:Ef(e,n),accessedAt:Xue(e,r),classification:Zue(e,o),details:Ef(e,o)}},Ef=(t,e)=>e<0||e>=t.length?"":t[e],Xue=(t,e)=>e<0||e>=t.length?"":lce(t[e].toUpperCase().replace(/^ACCESSED\s+/,"")),Zue=(t,e)=>e<0||e>=t.length?"":t[e].toUpperCase().includes("PUBLIC")?"Public Source":"Proprietary Source",oA=t=>{const{loading:e=!1,type:n="submit",size:r="medium",...o}=t,s={small:16,medium:20,large:24}[r];return g.jsx(Sr,{type:n,disabled:e,size:r,startIcon:e?g.jsx(V.CircularProgress,{size:s,color:"inherit"}):null,...o})},iA=t=>{const{onCancel:e,onViewCitationTable:n,readOnly:r=!1,showViewAllCitationsBtn:o=!1,isLoading:i,onSaveClicked:s}=t;return r&&!o?null:r?g.jsx(V.DialogActions,{sx:{px:0},children:g.jsx(V.Button,{onClick:n,size:"small",variant:"outlined",children:"Back To Table"})}):g.jsxs(V.DialogActions,{sx:{px:0,justifyContent:"space-between"},children:[g.jsx(V.Box,{children:o&&g.jsx(V.Button,{onClick:n,size:"small",variant:"outlined",children:"View All Citations"})}),g.jsxs(Ko,{children:[g.jsx(V.Button,{onClick:e,variant:"outlined",size:"small",children:"Cancel"}),g.jsx(oA,{size:"small",loading:i,type:"button",onClick:s,children:"Save"})]})]})},Que=t=>{const{onSave:e,onCancel:n,onViewCitationTable:r,onClose:o,modifyCitation:i,readOnly:s=!1,showViewAllCitationsBtn:a=!1,canLaunchUrl:l}=t,u=J.useRef(null),[f,p]=J.useState(!1),[m,b]=J.useState(!1),v=J.useRef(null),[y,x]=J.useState(!1),[C,k]=J.useState({type:"Url",source:"",title:"",accessedAt:null,url:"",classification:"",details:""});J.useEffect(()=>{i&&k({...i,type:"Url"})},[]);const T={disabled:f,margin:"none",readOnly:s},S=!s;return g.jsxs(V.Box,{minWidth:"400px",maxWidth:"500px",children:[g.jsxs(Ko,{justifyContent:"space-between",children:[g.jsxs(Ko,{gap:2,children:[g.jsxs(V.Typography,{variant:"h6",margin:"10px 0",children:[s?"View":"Edit"," Citation"]}),S&&g.jsx(V.Button,{variant:"outlined",size:"small",ref:v,onClick:()=>x(!0),children:"Paste & Prefill"})]}),g.jsx(V.IconButton,{onClick:o,children:g.jsx(tm,{})})]}),g.jsx(Ht.Formik,{innerRef:u,enableReinitialize:!0,initialValues:C,onSubmit:async O=>{p(!0),e(O).catch(R=>{throw p(!1),R}).finally(()=>p(!1))},validationSchema:Dx({title:kl().required("Title is required"),accessedAt:Ix().required("Accessed At is required"),url:kl().required("URL is required"),classification:kl().required("Classification is required")}),validateOnBlur:m,validateOnChange:m,children:({submitForm:O,setValues:R,values:P})=>g.jsxs(Ht.Form,{autoComplete:"off",children:[g.jsxs(V.Box,{display:"flex",flexDirection:"column",gap:s?1:0,alignItems:"flex-start",children:[g.jsx(_i,{...T,name:"title",required:!0}),g.jsx(_i,{...T,name:"source"}),g.jsx(_i,{...T,name:"details",label:"Details (e.g. Source Description)"}),g.jsx(Ip,{...T,name:"accessedAt",required:!0,isDatePicker:!0}),s&&(l!=null&&l(P))?g.jsx(g.Fragment,{children:g.jsx(Fi,{label:"URL / Other Identifier",readOnlyValue:g.jsx(T0,{citation:P,canLaunchUrl:l,asLink:!0}),value:P.url??""})}):g.jsx(_i,{...T,name:"url",label:"URL / Other Identifier",required:!0,endIcon:g.jsx(T0,{citation:P,canLaunchUrl:l})}),g.jsx(wI,{...T,name:"classification",row:!0,required:!0,radios:ede})]}),g.jsx(iA,{isLoading:f,onSaveClicked:()=>{b(!0),O()},readOnly:s,showViewAllCitationsBtn:a,onViewCitationTable:r,onCancel:n}),g.jsx(Kue,{open:y,onGenerateCitation:j=>{R(j,!0)},anchorEl:v.current,onClose:()=>x(!1)})]})})]})},ede=[{label:"Public Source",value:"Public Source",helperText:"URL is accessible to anyone from any location without special permissions. You can safely access this URL on any computer, including public or shared devices."},{label:"Proprietary Source",value:"Proprietary Source",helperText:"For private, sensitive, or access-controlled content. Use a VPN, or take extra precautions, when accessing to protect your privacy."}],tde=t=>{const{onSave:e,onCancel:n,onViewCitationTable:r,onClose:o,modifyCitation:i,readOnly:s=!1,showViewAllCitationsBtn:a=!1,onDownloadAttachment:l,onPreviewAttachment:u}=t,f=J.useRef(null),[p,m]=J.useState(!1),[b,v]=J.useState(!1),[y,x]=J.useState({type:"Attachment",title:"",file:void 0,fileName:""});return J.useEffect(()=>{i&&x({...i,type:"Attachment",file:void 0})},[]),g.jsxs(V.Box,{minWidth:"400px",maxWidth:"500px",children:[g.jsxs(V.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[g.jsxs(V.Typography,{variant:"h6",margin:"10px 0",children:[s?"View":"Edit"," Attachment"]}),g.jsx(V.IconButton,{onClick:o,children:g.jsx(tm,{})})]}),g.jsx(Ht.Formik,{innerRef:f,enableReinitialize:!0,initialValues:y,validationSchema:Dx().shape({title:kl().required("Title is required"),fileName:kl().required("A file is required")}),validateOnBlur:b,validateOnChange:b,onSubmit:async C=>{m(!0),e(C).catch(k=>{throw m(!1),k}).finally(()=>m(!1))},children:({values:C,setFieldValue:k,handleSubmit:T})=>{var O;const S=!s&&!C.id;return J.useEffect(()=>{var R,P;(R=C.file)!=null&&R.name&&k("fileName",(P=C.file)==null?void 0:P.name)},[(O=C.file)==null?void 0:O.name]),g.jsxs(Ht.Form,{autoComplete:"off",children:[g.jsx(_i,{name:"title",disabled:p,required:!0,margin:"none",readOnly:s}),g.jsxs(V.Box,{marginTop:S?1:0,children:[g.jsxs(Ko,{alignItems:"flex-start",children:[S&&g.jsx(bI,{name:"file",errorMode:"hidden"}),g.jsxs(Ko,{alignItems:"flex-end",children:[g.jsx(_i,{readOnly:!0,name:"fileName",label:S?"":"File Name"}),!S&&g.jsxs(Ko,{children:[g.jsx(WD,{citation:C,onDownloadAttachment:l}),g.jsx(UD,{citation:C,onPreviewAttachment:u})]})]})]}),g.jsx(Mr,{name:"fileName"})]}),g.jsx(iA,{isLoading:p,onSaveClicked:()=>{v(!0),T()},readOnly:s,showViewAllCitationsBtn:a,onViewCitationTable:r,onCancel:n})]})}})]})},Qu=t=>{const{open:e=!1,onClose:n,title:r,children:o,actions:i,closeBtnLabel:s,closeButtonPosition:a,closeButtonProps:l={},disableDismiss:u=!1,...f}=t;if(!e)return null;const p=a==="bottom"||a==="top-and-bottom",m=a==="top"||a==="top-and-bottom",b=()=>{if(s&&p)return g.jsx(V.Button,{className:"MBv2_Modal_Close",onClick:t.onClose,...l,children:s})},v=()=>{if(i)return g.jsx(V.DialogActions,{className:"MBv2_Modal_Actions",children:g.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",gap:"0.25rem",children:[g.jsx(V.Box,{children:b()}),g.jsxs(V.Box,{display:"flex",gap:".25rem",children:[...i]})]})});if(s&&p)return g.jsx(V.DialogActions,{className:"MBv2_Modal_Actions",children:g.jsx(V.Box,{children:b()})})};return g.jsxs(V.Dialog,{className:"MBv2_Modal",open:e,onClose:()=>{u||n==null||n()},...f,children:[typeof r=="string"?g.jsx(V.DialogTitle,{className:"MBv2_Modal_Title",children:g.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[r,m&&g.jsx(V.IconButton,{"data-testid":"modal-header-close-btn",onClick:n,children:g.jsx(tm,{})})]})}):r,o&&(typeof o=="string"?g.jsx(V.DialogContent,{className:"MBv2_Modal_Content",children:g.jsx(V.DialogContentText,{className:"MBv2_Modal_Content_Text",children:o})}):o),v()]})};function nde(t){return qe("MuiAlert",t)}const cO=He("MuiAlert",["root","action","icon","message","filled","colorSuccess","colorInfo","colorWarning","colorError","filledSuccess","filledInfo","filledWarning","filledError","outlined","outlinedSuccess","outlinedInfo","outlinedWarning","outlinedError","standard","standardSuccess","standardInfo","standardWarning","standardError"]),rde=Ne(g.jsx("path",{d:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"}),"SuccessOutlined"),ode=Ne(g.jsx("path",{d:"M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),ide=Ne(g.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutline"),sde=Ne(g.jsx("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"}),"InfoOutlined"),ade=Ne(g.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close"),lde=t=>{const{variant:e,color:n,severity:r,classes:o}=t,i={root:["root",`color${Pe(n||r)}`,`${e}${Pe(n||r)}`,`${e}`],icon:["icon"],message:["message"],action:["action"]};return Ue(i,nde,o)},cde=oe(_s,{name:"MuiAlert",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.variant],e[`${n.variant}${Pe(n.color||n.severity)}`]]}})(vt(({theme:t})=>{const e=t.palette.mode==="light"?ya:Ml,n=t.palette.mode==="light"?Ml:ya;return{...t.typography.body2,backgroundColor:"transparent",display:"flex",padding:"6px 16px",variants:[...Object.entries(t.palette).filter(Ln(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"standard"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),backgroundColor:t.vars?t.vars.palette.Alert[`${r}StandardBg`]:n(t.palette[r].light,.9),[`& .${cO.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Ln(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"outlined"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),border:`1px solid ${(t.vars||t).palette[r].light}`,[`& .${cO.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Ln(["dark"])).map(([r])=>({props:{colorSeverity:r,variant:"filled"},style:{fontWeight:t.typography.fontWeightMedium,...t.vars?{color:t.vars.palette.Alert[`${r}FilledColor`],backgroundColor:t.vars.palette.Alert[`${r}FilledBg`]}:{backgroundColor:t.palette.mode==="dark"?t.palette[r].dark:t.palette[r].main,color:t.palette.getContrastText(t.palette[r].main)}}}))]}})),ude=oe("div",{name:"MuiAlert",slot:"Icon",overridesResolver:(t,e)=>e.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),dde=oe("div",{name:"MuiAlert",slot:"Message",overridesResolver:(t,e)=>e.message})({padding:"8px 0",minWidth:0,overflow:"auto"}),fde=oe("div",{name:"MuiAlert",slot:"Action",overridesResolver:(t,e)=>e.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),uO={success:g.jsx(rde,{fontSize:"inherit"}),warning:g.jsx(ode,{fontSize:"inherit"}),error:g.jsx(ide,{fontSize:"inherit"}),info:g.jsx(sde,{fontSize:"inherit"})},sA=D.forwardRef(function(e,n){const r=mt({props:e,name:"MuiAlert"}),{action:o,children:i,className:s,closeText:a="Close",color:l,components:u={},componentsProps:f={},icon:p,iconMapping:m=uO,onClose:b,role:v="alert",severity:y="success",slotProps:x={},slots:C={},variant:k="standard",...T}=r,S={...r,color:l,severity:y,variant:k,colorSeverity:l||y},O=lde(S),R={slots:{closeButton:u.CloseButton,closeIcon:u.CloseIcon,...C},slotProps:{...f,...x}},[P,j]=Mt("root",{ref:n,shouldForwardComponentProp:!0,className:ye(O.root,s),elementType:cde,externalForwardedProps:{...R,...T},ownerState:S,additionalProps:{role:v,elevation:0}}),[F,M]=Mt("icon",{className:O.icon,elementType:ude,externalForwardedProps:R,ownerState:S}),[$,z]=Mt("message",{className:O.message,elementType:dde,externalForwardedProps:R,ownerState:S}),[L,A]=Mt("action",{className:O.action,elementType:fde,externalForwardedProps:R,ownerState:S}),[_,I]=Mt("closeButton",{elementType:Zl,externalForwardedProps:R,ownerState:S}),[B,W]=Mt("closeIcon",{elementType:ade,externalForwardedProps:R,ownerState:S});return g.jsxs(P,{...j,children:[p!==!1?g.jsx(F,{...M,children:p||m[y]||uO[y]}):null,g.jsx($,{...z,children:i}),o!=null?g.jsx(L,{...A,children:o}):null,o==null&&b?g.jsx(L,{...A,children:g.jsx(_,{size:"small","aria-label":a,title:a,color:"inherit",onClick:b,...I,children:g.jsx(B,{fontSize:"small",...W})})}):null]})});process.env.NODE_ENV!=="production"&&(sA.propTypes={action:c.node,children:c.node,classes:c.object,className:c.string,closeText:c.string,color:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),components:c.shape({CloseButton:c.elementType,CloseIcon:c.elementType}),componentsProps:c.shape({closeButton:c.object,closeIcon:c.object}),icon:c.node,iconMapping:c.shape({error:c.node,info:c.node,success:c.node,warning:c.node}),onClose:c.func,role:c.string,severity:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),slotProps:c.shape({action:c.oneOfType([c.func,c.object]),closeButton:c.oneOfType([c.func,c.object]),closeIcon:c.oneOfType([c.func,c.object]),icon:c.oneOfType([c.func,c.object]),message:c.oneOfType([c.func,c.object]),root:c.oneOfType([c.func,c.object])}),slots:c.shape({action:c.elementType,closeButton:c.elementType,closeIcon:c.elementType,icon:c.elementType,message:c.elementType,root:c.elementType}),sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),variant:c.oneOfType([c.oneOf(["filled","outlined","standard"]),c.string])});const ed=t=>{var b;const{noIcon:e=!1,children:n,severity:r="success",variant:o="leftBorder",sx:i,title:s,...a}=t,{palette:l}=V.useTheme(),u=e?{icon:!1}:{},f=o==="leftBorder"?"standard":o,p=o==="leftBorder"?{...i,borderLeft:`4px solid ${(b=l[r])==null?void 0:b.main}`}:i,m=s?{icon:{sx:{mt:"6px"}}}:{};return g.jsxs(sA,{severity:r,variant:f,sx:p,slotProps:m,...u,...a,children:[s&&g.jsx(V.Typography,{variant:"h3",children:s}),n]})},aA=t=>g.jsx(ed,{severity:"error",...t}),lA=t=>g.jsx(ed,{severity:"success",...t}),pde=t=>{const{alert:e,setAlert:n}=t,r=()=>n(void 0);return g.jsxs(g.Fragment,{children:[(e==null?void 0:e.type)==="Error"&&g.jsx(aA,{"data-testid":"citation-menu-error",onClose:r,title:e.title,children:e.message.toString()}),(e==null?void 0:e.type)==="Success"&&g.jsx(lA,{"data-testid":"citation-menu-success",onClose:r,children:e.message})]})};function cA({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onPreviewAttachment:s,onSelectCitations:a,onClose:l,initialSelectedIds:u=[],onContentChange:f,onError:p=()=>{},renderAsPopup:m=!1,canSelect:b=!1,tableTitle:v="Attachments & Citations",addlActions:y,canLaunchUrl:x,readOnly:C,canSearch:k=!1}){const[T,S]=J.useState("Insert Citation/Attachment(s)"),[O,R]=J.useState(u),[P,j]=J.useState(void 0),[F,M]=J.useState(void 0),[$,z]=J.useState(!1),[L,A]=J.useState(!1),_=ee=>{M(void 0),S(ee)},[I,B]=J.useState(0);J.useEffect(()=>{f==null||f()},[T,F,f]);const W=(ee=!1)=>{(!m||ee)&&B(ie=>ie+1)},K=(ee,ie)=>{var Me;const we=typeof((Me=ie.response)==null?void 0:Me.data)=="string"&&ie.response.data,Se=typeof ie.message=="string"&&ie.message;M({type:"Error",title:ee,message:we??Se}),p(ie)},U=ee=>M({type:"Success",title:"",message:ee}),Y=async ee=>{if(T==="Insert Citation/Attachment(s)")throw Error("onSave called with invalid state");ee.id?await(n==null?void 0:n(ee).then(()=>{$?l():(_("Insert Citation/Attachment(s)"),W())}).catch(ie=>{K("Failed to update",ie)})):await(e==null?void 0:e(ee).then(ie=>{R([...O,ie.id]),_("Insert Citation/Attachment(s)"),W()}).catch(ie=>{K("Failed to create",ie)}))},fe=r&&(async ee=>r(ee).then(()=>{W(!0),R(O.filter(ie=>ie!==ee)),U("Successfully deleted")}).catch(ie=>K("Failed to delete",ie))),ue=o&&(ee=>{o(ee).then(ie=>{const we=!!ie.fileName;j(ie),_(we?"Attachment":"Citation")}).catch(ie=>{K("Failed to load",ie)}).finally(()=>A(!1))}),pe=n&&ue,Z=n&&ue,te=i&&(async ee=>i(ee).catch(ie=>{K(`Failed to download ${ee.fileName}`,ie)})),ce=s&&(async ee=>s(ee).catch(ie=>{K(`Failed to view ${ee.fileName}`,ie)})),ne=g.jsx(due,{refreshKey:I,getCitationsPaginated:(ee,ie)=>t(ee,ie).then(we=>(f==null||f(),we)),onCancel:l,onNewCitation:()=>{j(void 0),_("Citation")},onNewAttachment:()=>{j(void 0),_("Attachment")},onEditCitation:pe,onEditAttachment:Z,onViewCitation:ue,onViewAttachment:ue,onDeleteCitation:fe,onDownloadAttachment:te,onPreviewAttachment:ce,onSelect:a,setSelectedIds:R,selectedIds:O,onError:p,condenseTable:m,canSelect:b,title:v,addlActions:y,canCreate:!!e,canLaunchUrl:x,readOnly:C,showCloseBtn:m,canSearch:k}),re=g.jsx(Que,{modifyCitation:P,onSave:Y,onCancel:()=>$?l():_("Insert Citation/Attachment(s)"),onViewCitationTable:()=>{_("Insert Citation/Attachment(s)"),z(!1)},onClose:()=>m?l():_("Insert Citation/Attachment(s)"),readOnly:C,showViewAllCitationsBtn:C&&!$||!C&&$,canLaunchUrl:x}),le=g.jsx(tde,{onSave:Y,onCancel:()=>$?l():_("Insert Citation/Attachment(s)"),onViewCitationTable:()=>{_("Insert Citation/Attachment(s)"),z(!1)},onClose:()=>m?l():_("Insert Citation/Attachment(s)"),modifyCitation:P,readOnly:C,showViewAllCitationsBtn:C&&!$||!C&&$,onDownloadAttachment:te,onPreviewAttachment:ce}),ge=g.jsx(pde,{alert:F,setAlert:M});J.useEffect(()=>{m&&u.length===1&&ue&&(A(!0),z(!0),ue(u[0]))},[]);const X=()=>{switch(T){case"Insert Citation/Attachment(s)":return ne;case"Citation":return re;case"Attachment":return le}};return m?g.jsxs(V.Box,{children:[ge,g.jsx(V.Box,{paddingTop:"8px",children:g.jsx(Ox,{isLoading:L,children:X()})})]}):g.jsxs(V.Box,{width:"100%",children:[T==="Insert Citation/Attachment(s)"&&ge,g.jsx(V.Box,{paddingTop:"8px",children:ne}),g.jsx(Qu,{open:T!=="Insert Citation/Attachment(s)",children:g.jsxs(V.Box,{padding:"10px 20px",minWidth:"400px","data-testid":"citation-form-modal",children:[ge,T==="Citation"?re:le]})})]})}function uA({getSelectedCitationsPaginated:t,getCitationsPaginated:e,readOnly:n,initialSelectedIds:r=[],...o}){const i=(s,a)=>n?t(s,r):e(s,a);return g.jsx(cA,{renderAsPopup:!0,canSelect:!n,getCitationsPaginated:i,readOnly:n,tableTitle:`${n?"Selected":"Insert"} Citation/Attachment(s)`,initialSelectedIds:r,...o})}const hde=V.styled("div",{name:"CitationBubbleMenu",slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>{const e=t.palette.mode==="dark";return{padding:t.spacing(1.5,2,.5),backgroundColor:e?"#101010":"#f9f9f9",border:`1px solid ${t.palette.grey[e?700:200]}`}});function mde({getCitationsPaginated:t,getSelectedCitationsPaginated:e,onCreateCitation:n,onUpdateCitation:r,onDeleteCitation:o,getCitationById:i,onDownloadAttachment:s,onPreviewAttachment:a,canLaunchUrl:l,readOnly:u,canSearch:f,...p}){const m=kt();if(m&&!("citationBubbleMenuHandler"in(m==null?void 0:m.storage)))throw new Error("You must add the CitationBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const b=m==null?void 0:m.storage.citationBubbleMenuHandler,v=b.isOpen,y=b.selectedIds,x=b.selectedNodePos,C=O=>{m&&(O.length===0?m.commands.deleteCitation(x):y.length===0?m.commands.insertCitation({ids:O}):m.commands.updateCitation({ids:O},x))},k=O=>{C(O),m==null||m.commands.closeCitationBubbleMenu()},T=()=>{C(y),m==null||m.commands.closeCitationBubbleMenu()},S=J.useCallback(()=>{requestAnimationFrame(()=>{m!=null&&m.view&&m.view.dispatch(m.view.state.tr)})},[m]);return m?g.jsx(wv,{editor:m,open:v,...b.bubbleMenuOptions,...p,children:g.jsx(hde,{children:g.jsx(uA,{getCitationsPaginated:t,getSelectedCitationsPaginated:O=>e(O,y),onCreateCitation:n,onUpdateCitation:r,onDeleteCitation:o,getCitationById:i,onDownloadAttachment:s,onPreviewAttachment:a,onSelectCitations:k,onClose:T,initialSelectedIds:y,onContentChange:S,canLaunchUrl:l,readOnly:u,canSearch:f})})}):null}const gde=()=>gn.create({name:"citationBubbleMenuHandler",addStorage(){return{isOpen:!1,selectedIds:[],bubbleMenuOptions:void 0,selectedNodePos:0}},addCommands(){return{openCitationBubbleMenu:(t={},e)=>({editor:n,dispatch:r})=>{var a;const{doc:o}=n.state,i=o.nodeAt(e??0),s=((a=i==null?void 0:i.attrs)==null?void 0:a.ids)??[];return r&&(this.storage.isOpen=!0,this.storage.selectedIds=s,this.storage.bubbleMenuOptions=t,this.storage.selectedNodePos=e??0),!0},closeCitationBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.isOpen?(t.focus(),e&&(this.storage.isOpen=!1,this.storage.selectedIds=[],this.storage.selectedNodePos=0),!0):!1}},onSelectionUpdate(){this.storage.isOpen&&!this.editor.isActive("citation")&&this.editor.commands.closeCitationBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-c":()=>(this.editor.commands.openCitationBubbleMenu(),!0)}}});function yde(t){const e=kt(),n=J.useRef(null);return g.jsx(wt,{buttonRef:n,tooltipLabel:"Insert Citation/Attachment",tooltipShortcutKeys:["mod","Shift","C"],disabled:!(e!=null&&e.isEditable),onClick:()=>e==null?void 0:e.commands.openCitationBubbleMenu({anchorEl:n.current,placement:"bottom"}),...t,children:g.jsxs(V.Box,{display:"flex",flexDirection:"row",gap:"4px",alignItems:"center",children:[g.jsx(yne,{fontSize:"small"}),g.jsx(V.Typography,{variant:"body2",children:"Insert Citation/Attachment"})]})})}const dA=J.createContext(void 0),fA=()=>{const t=J.useContext(dA);if(!t)throw new Error("useSync must be used inside CitationFieldProvider");return t},bde=({node:t,HTMLAttributes:e,selected:n,extension:r,updateAttributes:o,deleteNode:i})=>{const s=t.attrs.ids||[],{citations:a,isLoaded:l}=fA(),[u,f]=J.useState(s?String(s):""),[p,m]=J.useState([]),b=r.options.citationMaxLength;if(J.useEffect(()=>{if(!l)return;const v=a.filter(C=>s.includes(C.id)),y=v.map(C=>_x(C.title,b)).join(", ");f(y),m(v);const x=v.map(C=>C.id);x.length===0?setTimeout(i,0):x.length!==s.length&&setTimeout(()=>o({ids:v.map(C=>C.id)}),0)},[a,s,l]),p.length!==0)return g.jsx(Wv,{as:"span",...e,"data-testid":"citation-node-component",children:g.jsx(V.Tooltip,{title:g.jsx(V.Box,{className:"citation-tooltip",children:p.map((v,y)=>{var k;const C=!!v.fileName?[v.title,v.fileName]:[v.title,v.source,v.details,(k=v.accessedAt)==null?void 0:k.slice(0,10),v.url,v.classification];return g.jsxs(V.Typography,{variant:"subtitle2",children:[C.filter(Boolean).join(" | "),y<p.length-1&&g.jsx(V.Divider,{className:"citation-tooltip-divider"})]},v.id)})}),slotProps:{tooltip:{sx:{maxWidth:500}}},children:g.jsx("a",{href:"#",onClick:v=>{v.preventDefault(),v.stopPropagation()},className:n?"selected-citation-link":"citation-link",children:u})})})},vde=rn.create({name:"citation",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes(){return{ids:{default:[],parseHTML:t=>{const e=t.getAttribute("ids");return e?e.split(",").map(n=>parseInt(n.trim(),10)).filter(n=>!isNaN(n)):[]},renderHTML:t=>({ids:Array.isArray(t.ids)?t.ids.join(","):""})}}},parseHTML(){return[{tag:"citation"}]},renderHTML({HTMLAttributes:t}){return["citation",Tt(t)]},addNodeView(){return Uv(bde)},addProseMirrorPlugins(){return[new on({props:{handleClickOn:(t,e,n,r,o,i)=>n&&n.type.name==="citation"?(this.editor.commands.openCitationBubbleMenu({},r),!0):!1}})]},addCommands(){return{insertCitation:t=>({commands:e})=>e.insertContent({type:"citation",attrs:t}),updateCitation:(t,e)=>({state:n,dispatch:r,tr:o})=>{const i=n.doc.nodeAt(e);return!i||i.type.name!=="citation"?!1:(o.setNodeMarkup(e,void 0,t),r&&r(o),!0)},deleteCitation:t=>({tr:e,dispatch:n})=>{if(typeof t!="number")return!1;const r=t,o=t+1;return n&&n(e.delete(r,o)),!0}}}});function dO({editor:t,canComment:e=!0,onComment:n,commentCount:r,commentResolved:o,...i}){const s=J.useRef(null);if(!n)return null;const a=o?g.jsx(n2,{sx:{width:14,height:14},"data-testid":"resolved-checkmark"}):r,l=o?"success":"primary",u=o?{"& .MuiBadge-badge":{padding:0,height:16,minWidth:16}}:{"& .MuiBadge-badge":{fontSize:14,height:16,minWidth:16}};return e?g.jsx(wt,{buttonRef:s,tooltipLabel:"Comments",onClick:()=>{if(!t)return;const{from:f,to:p}=t.state.selection,m=t.state.doc.textBetween(f,p,`
|
|
407
|
+
`+(a!==s?`result of cast: ${a}`:""))}return i}_cast(e,n){let r=e===void 0?e:this.transforms.reduce((o,i)=>i.call(this,o,e,this,n),e);return r===void 0&&(r=this.getDefault(n)),r}_validate(e,n={},r,o){let{path:i,originalValue:s=e,strict:a=this.spec.strict}=n,l=e;a||(l=this._cast(l,Object.assign({assert:!1},n)));let u=[];for(let f of Object.values(this.internalTests))f&&u.push(f);this.runTests({path:i,value:l,originalValue:s,options:n,tests:u},r,f=>{if(f.length)return o(f,l);this.runTests({path:i,value:l,originalValue:s,options:n,tests:this.tests},r,o)})}runTests(e,n,r){let o=!1,{tests:i,value:s,originalValue:a,path:l,options:u}=e,f=y=>{o||(o=!0,n(y,s))},p=y=>{o||(o=!0,r(y,s))},m=i.length,b=[];if(!m)return p([]);let v={value:s,originalValue:a,path:l,options:u,schema:this};for(let y=0;y<i.length;y++){const x=i[y];x(v,f,function(k){k&&(Array.isArray(k)?b.push(...k):b.push(k)),--m<=0&&p(b)})}}asNestedTest({key:e,index:n,parent:r,parentPath:o,originalParent:i,options:s}){const a=e??n;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const l=typeof a=="number";let u=r[a];const f=Object.assign({},s,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[l?"index":"key"]:a,path:l||a.includes(".")?`${o||""}[${l?a:`"${a}"`}]`:(o?`${o}.`:"")+e});return(p,m,b)=>this.resolve(f)._validate(u,f,m,b)}validate(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return new Promise((s,a)=>o._validate(e,n,(l,u)=>{fr.isError(l)&&(l.value=u),a(l)},(l,u)=>{l.length?a(new fr(l,u,void 0,void 0,i)):s(u)}))}validateSync(e,n){var r;let o=this.resolve(Object.assign({},n,{value:e})),i,s=(r=n==null?void 0:n.disableStackTrace)!=null?r:o.spec.disableStackTrace;return o._validate(e,Object.assign({},n,{sync:!0}),(a,l)=>{throw fr.isError(a)&&(a.value=l),a},(a,l)=>{if(a.length)throw new fr(a,e,void 0,void 0,s);i=l}),i}isValid(e,n){return this.validate(e,n).then(()=>!0,r=>{if(fr.isError(r))return!1;throw r})}isValidSync(e,n){try{return this.validateSync(e,n),!0}catch(r){if(fr.isError(r))return!1;throw r}}_getDefault(e){let n=this.spec.default;return n==null?n:typeof n=="function"?n.call(this,e):gl(n)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,n){const r=this.clone({nullable:e});return r.internalTests.nullable=sl({message:n,name:"nullable",test(o){return o===null?this.schema.spec.nullable:!0}}),r}optionality(e,n){const r=this.clone({optional:e});return r.internalTests.optionality=sl({message:n,name:"optionality",test(o){return o===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=Fo.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=Fo.notNull){return this.nullability(!1,e)}required(e=Fo.required){return this.clone().withMutation(n=>n.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let n=this.clone();return n.transforms.push(e),n}test(...e){let n;if(e.length===1?typeof e[0]=="function"?n={test:e[0]}:n=e[0]:e.length===2?n={name:e[0],test:e[1]}:n={name:e[0],message:e[1],test:e[2]},n.message===void 0&&(n.message=Fo.default),typeof n.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),o=sl(n),i=n.exclusive||n.name&&r.exclusiveTests[n.name]===!0;if(n.exclusive&&!n.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return n.name&&(r.exclusiveTests[n.name]=!!n.exclusive),r.tests=r.tests.filter(s=>!(s.OPTIONS.name===n.name&&(i||s.OPTIONS.test===o.OPTIONS.test))),r.tests.push(o),r}when(e,n){!Array.isArray(e)&&typeof e!="string"&&(n=e,e=".");let r=this.clone(),o=KD(e).map(i=>new Pa(i));return o.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof n=="function"?new ih(o,n):ih.fromOptions(o,n)),r}typeError(e){let n=this.clone();return n.internalTests.typeError=sl({message:e,name:"typeError",skipAbsent:!0,test(r){return this.schema._typeCheck(r)?!0:this.createError({params:{type:this.schema.type}})}}),n}oneOf(e,n=Fo.oneOf){let r=this.clone();return e.forEach(o=>{r._whitelist.add(o),r._blacklist.delete(o)}),r.internalTests.whiteList=sl({message:n,name:"oneOf",skipAbsent:!0,test(o){let i=this.schema._whitelist,s=i.resolveAll(this.resolve);return s.includes(o)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:s}})}}),r}notOneOf(e,n=Fo.notOneOf){let r=this.clone();return e.forEach(o=>{r._blacklist.add(o),r._whitelist.delete(o)}),r.internalTests.blacklist=sl({message:n,name:"notOneOf",test(o){let i=this.schema._blacklist,s=i.resolveAll(this.resolve);return s.includes(o)?this.createError({params:{values:Array.from(i).join(", "),resolved:s}}):!0}}),r}strip(e=!0){let n=this.clone();return n.spec.strip=e,n}describe(e){const n=(e?this.resolve(e):this).clone(),{label:r,meta:o,optional:i,nullable:s}=n.spec;return{meta:o,label:r,optional:i,nullable:s,default:n.getDefault(e),type:n.type,oneOf:n._whitelist.describe(),notOneOf:n._blacklist.describe(),tests:n.tests.filter((l,u,f)=>f.findIndex(p=>p.OPTIONS.name===l.OPTIONS.name)===u).map(l=>{const u=l.OPTIONS.params&&e?XD(Object.assign({},l.OPTIONS.params),e):l.OPTIONS.params;return{name:l.OPTIONS.name,params:u}})}}get"~standard"(){const e=this;return{version:1,vendor:"yup",async validate(r){try{return{value:await e.validate(r,{abortEarly:!1})}}catch(o){if(o instanceof fr)return{issues:QD(o)};throw o}}}}}ti.prototype.__isYupSchema__=!0;for(const t of["validate","validateSync"])ti.prototype[`${t}At`]=function(e,n,r={}){const{parent:o,parentPath:i,schema:s}=Mue(this,e,n,r.context);return s[t](o&&o[i],Object.assign({},r,{parent:o,path:e}))};for(const t of["equals","is"])ti.prototype[t]=ti.prototype.oneOf;for(const t of["not","nope"])ti.prototype[t]=ti.prototype.notOneOf;const Iue=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function Due(t){const e=E0(t);if(!e)return Date.parse?Date.parse(t):Number.NaN;if(e.z===void 0&&e.plusMinus===void 0)return new Date(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond).valueOf();let n=0;return e.z!=="Z"&&e.plusMinus!==void 0&&(n=e.hourOffset*60+e.minuteOffset,e.plusMinus==="+"&&(n=0-n)),Date.UTC(e.year,e.month,e.day,e.hour,e.minute+n,e.second,e.millisecond)}function E0(t){var e,n;const r=Iue.exec(t);return r?{year:xi(r[1]),month:xi(r[2],1)-1,day:xi(r[3],1),hour:xi(r[4]),minute:xi(r[5]),second:xi(r[6]),millisecond:r[7]?xi(r[7].substring(0,3)):0,precision:(e=(n=r[7])==null?void 0:n.length)!=null?e:void 0,z:r[8]||void 0,plusMinus:r[9]||void 0,hourOffset:xi(r[10]),minuteOffset:xi(r[11])}:null}function xi(t,e=0){return Number(t)||e}let Aue=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Pue=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,Nue=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,jue="^\\d{4}-\\d{2}-\\d{2}",$ue="\\d{2}:\\d{2}:\\d{2}",Lue="(([+-]\\d{2}(:?\\d{2})?)|Z)",Bue=new RegExp(`${jue}T${$ue}(\\.\\d+)?${Lue}$`),Fue=t=>aa(t)||t===t.trim(),Vue={}.toString();function kl(){return new eA}class eA extends ti{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,n)=>{if(!this.spec.coerce||this.isType(e)||Array.isArray(e))return e;const r=e!=null&&e.toString?e.toString():e;return r===Vue?e:r})})}required(e){return super.required(e).withMutation(n=>n.test({message:e||Fo.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(n=>n.OPTIONS.name!=="required"),e))}length(e,n=xr.length){return this.test({message:n,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,n=xr.min){return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,n=xr.max){return this.test({name:"max",exclusive:!0,message:n,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,n){let r=!1,o,i;return n&&(typeof n=="object"?{excludeEmptyString:r=!1,message:o,name:i}=n:o=n),this.test({name:i||"matches",message:o||xr.matches,params:{regex:e},skipAbsent:!0,test:s=>s===""&&r||s.search(e)!==-1})}email(e=xr.email){return this.matches(Aue,{name:"email",message:e,excludeEmptyString:!0})}url(e=xr.url){return this.matches(Pue,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=xr.uuid){return this.matches(Nue,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let n="",r,o;return e&&(typeof e=="object"?{message:n="",allowOffset:r=!1,precision:o=void 0}=e:n=e),this.matches(Bue,{name:"datetime",message:n||xr.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:n||xr.datetime_offset,params:{allowOffset:r},skipAbsent:!0,test:i=>{if(!i||r)return!0;const s=E0(i);return s?!!s.z:!1}}).test({name:"datetime_precision",message:n||xr.datetime_precision,params:{precision:o},skipAbsent:!0,test:i=>{if(!i||o==null)return!0;const s=E0(i);return s?s.precision===o:!1}})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=xr.trim){return this.transform(n=>n!=null?n.trim():n).test({message:e,name:"trim",test:Fue})}lowercase(e=xr.lowercase){return this.transform(n=>aa(n)?n:n.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>aa(n)||n===n.toLowerCase()})}uppercase(e=xr.uppercase){return this.transform(n=>aa(n)?n:n.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:n=>aa(n)||n===n.toUpperCase()})}}kl.prototype=eA.prototype;let tA=new Date(""),zue=t=>Object.prototype.toString.call(t)==="[object Date]";function Ix(){return new Zu}class Zu extends ti{constructor(){super({type:"date",check(e){return zue(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,n)=>!this.spec.coerce||this.isType(e)||e===null?e:(e=Due(e),isNaN(e)?Zu.INVALID_DATE:new Date(e)))})}prepareParam(e,n){let r;if(Pa.isRef(e))r=e;else{let o=this.cast(e);if(!this._typeCheck(o))throw new TypeError(`\`${n}\` must be a Date or a value that can be \`cast()\` to a Date`);r=o}return r}min(e,n=k0.min){let r=this.prepareParam(e,"min");return this.test({message:n,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(o){return o>=this.resolve(r)}})}max(e,n=k0.max){let r=this.prepareParam(e,"max");return this.test({message:n,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(o){return o<=this.resolve(r)}})}}Zu.INVALID_DATE=tA;Ix.prototype=Zu.prototype;Ix.INVALID_DATE=tA;function Hue(t,e=[]){let n=[],r=new Set,o=new Set(e.map(([s,a])=>`${s}-${a}`));function i(s,a){let l=ha.split(s)[0];r.add(l),o.has(`${a}-${l}`)||n.push([a,l])}for(const s of Object.keys(t)){let a=t[s];r.add(s),Pa.isRef(a)&&a.isSibling?i(a.path,s):Rx(a)&&"deps"in a&&a.deps.forEach(l=>i(l,s))}return gue.array(Array.from(r),n).reverse()}function sO(t,e){let n=1/0;return t.some((r,o)=>{var i;if((i=e.path)!=null&&i.includes(r))return n=o,!0}),n}function nA(t){return(e,n)=>sO(t,e)-sO(t,n)}const Wue=(t,e,n)=>{if(typeof t!="string")return t;let r=t;try{r=JSON.parse(t)}catch{}return n.isType(r)?r:t};function Gf(t){if("fields"in t){const e={};for(const[n,r]of Object.entries(t.fields))e[n]=Gf(r);return t.setFields(e)}if(t.type==="array"){const e=t.optional();return e.innerType&&(e.innerType=Gf(e.innerType)),e}return t.type==="tuple"?t.optional().clone({types:t.spec.types.map(Gf)}):"optional"in t?t.optional():t}const Uue=(t,e)=>{const n=[...ha.normalizePath(e)];if(n.length===1)return n[0]in t;let r=n.pop(),o=ha.getter(ha.join(n),!0)(t);return!!(o&&r in o)};let aO=t=>Object.prototype.toString.call(t)==="[object Object]";function lO(t,e){let n=Object.keys(t.fields);return Object.keys(e).filter(r=>n.indexOf(r)===-1)}const que=nA([]);function Dx(t){return new rA(t)}class rA extends ti{constructor(e){super({type:"object",check(n){return aO(n)||typeof n=="function"}}),this.fields=Object.create(null),this._sortErrors=que,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,n={}){var r;let o=super._cast(e,n);if(o===void 0)return this.getDefault(n);if(!this._typeCheck(o))return o;let i=this.fields,s=(r=n.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(o).filter(p=>!this._nodes.includes(p))),l={},u=Object.assign({},n,{parent:l,__validating:n.__validating||!1}),f=!1;for(const p of a){let m=i[p],b=p in o,v=o[p];if(m){let y;u.path=(n.path?`${n.path}.`:"")+p,m=m.resolve({value:v,context:n.context,parent:l});let x=m instanceof ti?m.spec:void 0,C=x==null?void 0:x.strict;if(x!=null&&x.strip){f=f||p in o;continue}y=!n.__validating||!C?m.cast(v,u):v,y!==void 0&&(l[p]=y)}else b&&!s&&(l[p]=v);(b!==p in l||l[p]!==v)&&(f=!0)}return f?l:o}_validate(e,n={},r,o){let{from:i=[],originalValue:s=e,recursive:a=this.spec.recursive}=n;n.from=[{schema:this,value:s},...i],n.__validating=!0,n.originalValue=s,super._validate(e,n,r,(l,u)=>{if(!a||!aO(u)){o(l,u);return}s=s||u;let f=[];for(let p of this._nodes){let m=this.fields[p];!m||Pa.isRef(m)||f.push(m.asNestedTest({options:n,key:p,parent:u,parentPath:n.path,originalParent:s}))}this.runTests({tests:f,value:u,originalValue:s,options:n},r,p=>{o(p.sort(this._sortErrors).concat(l),u)})})}clone(e){const n=super.clone(e);return n.fields=Object.assign({},this.fields),n._nodes=this._nodes,n._excludedEdges=this._excludedEdges,n._sortErrors=this._sortErrors,n}concat(e){let n=super.concat(e),r=n.fields;for(let[o,i]of Object.entries(this.fields)){const s=r[o];r[o]=s===void 0?i:s}return n.withMutation(o=>o.setFields(r,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let n={};return this._nodes.forEach(r=>{var o;const i=this.fields[r];let s=e;(o=s)!=null&&o.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[r]})),n[r]=i&&"getDefault"in i?i.getDefault(s):void 0}),n}setFields(e,n){let r=this.clone();return r.fields=e,r._nodes=Hue(e,n),r._sortErrors=nA(Object.keys(e)),n&&(r._excludedEdges=n),r}shape(e,n=[]){return this.clone().withMutation(r=>{let o=r._excludedEdges;return n.length&&(Array.isArray(n[0])||(n=[n]),o=[...r._excludedEdges,...n]),r.setFields(Object.assign(r.fields,e),o)})}partial(){const e={};for(const[n,r]of Object.entries(this.fields))e[n]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return Gf(this)}pick(e){const n={};for(const r of e)this.fields[r]&&(n[r]=this.fields[r]);return this.setFields(n,this._excludedEdges.filter(([r,o])=>e.includes(r)&&e.includes(o)))}omit(e){const n=[];for(const r of Object.keys(this.fields))e.includes(r)||n.push(r);return this.pick(n)}from(e,n,r){let o=ha.getter(e,!0);return this.transform(i=>{if(!i)return i;let s=i;return Uue(i,e)&&(s=Object.assign({},i),r||delete s[e],s[n]=o(i)),s})}json(){return this.transform(Wue)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||Yf.exact,test(n){if(n==null)return!0;const r=lO(this.schema,n);return r.length===0||this.createError({params:{properties:r.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,n=Yf.noUnknown){typeof e!="boolean"&&(n=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:n,test(o){if(o==null)return!0;const i=lO(this.schema,o);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,n=Yf.noUnknown){return this.noUnknown(!e,n)}transformKeys(e){return this.transform(n=>{if(!n)return n;const r={};for(const o of Object.keys(n))r[e(o)]=n[o];return r})}camelCase(){return this.transformKeys(gb.camelCase)}snakeCase(){return this.transformKeys(gb.snakeCase)}constantCase(){return this.transformKeys(e=>gb.snakeCase(e).toUpperCase())}describe(e){const n=(e?this.resolve(e):this).clone(),r=super.describe(e);r.fields={};for(const[i,s]of Object.entries(n.fields)){var o;let a=e;(o=a)!=null&&o.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[i]})),r.fields[i]=s.describe(a)}return r}}Dx.prototype=rA.prototype;const Kue=t=>{const{open:e,anchorEl:n,onGenerateCitation:r,onClose:o}=t;return g.jsx(V.Popper,{open:e,anchorEl:n,placement:"bottom-end",style:{zIndex:1300},sx:{maxWidth:"500px"},children:g.jsxs(Ru,{component:V.Paper,p:1,boxShadow:9,gap:.25,children:[g.jsx(V.Typography,{variant:"body1",children:"Paste in a preformatted citation"}),g.jsx(V.Typography,{variant:"body2",color:"text.secondary",fontStyle:"italic",fontSize:".8em",children:"For best results, ensure your citations use a vertical bar ( | ) to separate the title, source, url, etc. Incomplete citations are allowed but may result in incompletely filled fields."}),g.jsx(Ht.Formik,{initialValues:{pasteExistingCitation:""},onSubmit:({pasteExistingCitation:i})=>{r(Jue(i)),o()},children:({values:i,submitForm:s,setFieldValue:a})=>g.jsxs(Ko,{flexWrap:"wrap",justifyContent:"flex-end",children:[g.jsx(CI,{name:"pasteExistingCitation",errorMode:"collapse",label:"",placeholder:"Scientific News Today | How to Organize Your Workspace for Maximum Efficiency | https://mock-news-site.com | ACCESSED 2 JAN 2026 | Public Source",endIcon:g.jsx(V.Tooltip,{title:"Paste from Clipboard",children:g.jsx(V.IconButton,{"data-testid":"paste-content-button",onClick:()=>{navigator.clipboard.readText().then(l=>a("pasteExistingCitation",l))},children:g.jsx(xne,{})})})}),g.jsxs(Ko,{children:[g.jsx(Sr,{size:"small",variant:"outlined",onClick:o,"data-testid":"citation-table_paste-prompt_cancel",children:"Cancel"}),g.jsx(Sr,{size:"small",type:"submit",onClick:s,"data-testid":"citation-table_paste-prompt_submit",disabled:!i.pasteExistingCitation,children:"Prefill Citation"})]})]})})]})})},Yue=["https://","http://","www."],Gue=new RegExp(Yue.join("|")),Jue=t=>{const e=t.replace(/\.\s*$/,"").split("|").map(f=>f.trim()).filter(Boolean),n=e.findIndex(f=>f.match(Gue)),r=e.findIndex(f=>f.toUpperCase().startsWith("ACCESSED")),o=e.findIndex(f=>/\bSOURCE\b/.test(f.toUpperCase()));let s=[n,r,o].find(f=>f!==-1)??e.length;const a=s-1,l=s-2;return{type:"Url",source:Ef(e,l),title:Ef(e,a),url:Ef(e,n),accessedAt:Xue(e,r),classification:Zue(e,o),details:Ef(e,o)}},Ef=(t,e)=>e<0||e>=t.length?"":t[e],Xue=(t,e)=>e<0||e>=t.length?"":lce(t[e].toUpperCase().replace(/^ACCESSED\s+/,"")),Zue=(t,e)=>e<0||e>=t.length?"":t[e].toUpperCase().includes("PUBLIC")?"Public Source":"Proprietary Source",oA=t=>{const{loading:e=!1,type:n="submit",size:r="medium",...o}=t,s={small:16,medium:20,large:24}[r];return g.jsx(Sr,{type:n,disabled:e,size:r,startIcon:e?g.jsx(V.CircularProgress,{size:s,color:"inherit"}):null,...o})},iA=t=>{const{onCancel:e,onViewCitationTable:n,readOnly:r=!1,showViewAllCitationsBtn:o=!1,isLoading:i,onSaveClicked:s}=t;return r&&!o?null:r?g.jsx(V.DialogActions,{sx:{px:0},children:g.jsx(V.Button,{onClick:n,size:"small",variant:"outlined",children:"Back To Table"})}):g.jsxs(V.DialogActions,{sx:{px:0,justifyContent:"space-between"},children:[g.jsx(V.Box,{children:o&&g.jsx(V.Button,{onClick:n,size:"small",variant:"outlined",children:"View All Citations"})}),g.jsxs(Ko,{children:[g.jsx(V.Button,{onClick:e,variant:"outlined",size:"small",children:"Cancel"}),g.jsx(oA,{size:"small",loading:i,type:"button",onClick:s,children:"Save"})]})]})},Que=t=>{const{onSave:e,onCancel:n,onViewCitationTable:r,onClose:o,modifyCitation:i,readOnly:s=!1,showViewAllCitationsBtn:a=!1,canLaunchUrl:l}=t,u=J.useRef(null),[f,p]=J.useState(!1),[m,b]=J.useState(!1),v=J.useRef(null),[y,x]=J.useState(!1),[C,k]=J.useState({type:"Url",source:"",title:"",accessedAt:null,url:"",classification:"",details:""});J.useEffect(()=>{i&&k({...i,type:"Url"})},[]);const T={disabled:f,margin:"none",readOnly:s},S=!s;return g.jsxs(V.Box,{minWidth:"400px",maxWidth:"500px",children:[g.jsxs(Ko,{justifyContent:"space-between",children:[g.jsxs(Ko,{gap:2,children:[g.jsxs(V.Typography,{variant:"h6",margin:"10px 0",children:[s?"View":"Edit"," Citation"]}),S&&g.jsx(V.Button,{variant:"outlined",size:"small",ref:v,onClick:()=>x(!0),children:"Paste & Prefill"})]}),g.jsx(V.IconButton,{onClick:o,children:g.jsx(tm,{})})]}),g.jsx(Ht.Formik,{innerRef:u,enableReinitialize:!0,initialValues:C,onSubmit:async O=>{p(!0),e(O).catch(R=>{throw p(!1),R}).finally(()=>p(!1))},validationSchema:Dx({title:kl().required("Title is required"),accessedAt:Ix().required("Accessed At is required"),url:kl().required("URL is required"),classification:kl().required("Classification is required")}),validateOnBlur:m,validateOnChange:m,children:({submitForm:O,setValues:R,values:P})=>g.jsxs(Ht.Form,{autoComplete:"off",children:[g.jsxs(V.Box,{display:"flex",flexDirection:"column",gap:s?1:0,alignItems:"flex-start",children:[g.jsx(_i,{...T,name:"title",required:!0}),g.jsx(_i,{...T,name:"source"}),g.jsx(_i,{...T,name:"details",label:"Details (e.g. Source Description)"}),g.jsx(Ip,{...T,name:"accessedAt",required:!0,isDatePicker:!0}),s&&(l!=null&&l(P))?g.jsx(g.Fragment,{children:g.jsx(Fi,{label:"URL / Other Identifier",readOnlyValue:g.jsx(T0,{citation:P,canLaunchUrl:l,asLink:!0}),value:P.url??""})}):g.jsx(_i,{...T,name:"url",label:"URL / Other Identifier",required:!0,endIcon:g.jsx(T0,{citation:P,canLaunchUrl:l})}),g.jsx(wI,{...T,name:"classification",row:!0,required:!0,radios:ede})]}),g.jsx(iA,{isLoading:f,onSaveClicked:()=>{b(!0),O()},readOnly:s,showViewAllCitationsBtn:a,onViewCitationTable:r,onCancel:n}),g.jsx(Kue,{open:y,onGenerateCitation:j=>{R(j,!0)},anchorEl:v.current,onClose:()=>x(!1)})]})})]})},ede=[{label:"Public Source",value:"Public Source",helperText:"URL is accessible to anyone from any location without special permissions. You can safely access this URL on any computer, including public or shared devices."},{label:"Proprietary Source",value:"Proprietary Source",helperText:"For private, sensitive, or access-controlled content. Use a VPN, or take extra precautions, when accessing to protect your privacy."}],tde=t=>{const{onSave:e,onCancel:n,onViewCitationTable:r,onClose:o,modifyCitation:i,readOnly:s=!1,showViewAllCitationsBtn:a=!1,onDownloadAttachment:l,onPreviewAttachment:u}=t,f=J.useRef(null),[p,m]=J.useState(!1),[b,v]=J.useState(!1),[y,x]=J.useState({type:"Attachment",title:"",file:void 0,fileName:""});return J.useEffect(()=>{i&&x({...i,type:"Attachment",file:void 0})},[]),g.jsxs(V.Box,{minWidth:"400px",maxWidth:"500px",children:[g.jsxs(V.Box,{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",children:[g.jsxs(V.Typography,{variant:"h6",margin:"10px 0",children:[s?"View":"Edit"," Attachment"]}),g.jsx(V.IconButton,{onClick:o,children:g.jsx(tm,{})})]}),g.jsx(Ht.Formik,{innerRef:f,enableReinitialize:!0,initialValues:y,validationSchema:Dx().shape({title:kl().required("Title is required"),fileName:kl().required("A file is required")}),validateOnBlur:b,validateOnChange:b,onSubmit:async C=>{m(!0),e(C).catch(k=>{throw m(!1),k}).finally(()=>m(!1))},children:({values:C,setFieldValue:k,handleSubmit:T})=>{var O;const S=!s&&!C.id;return J.useEffect(()=>{var R,P;(R=C.file)!=null&&R.name&&k("fileName",(P=C.file)==null?void 0:P.name)},[(O=C.file)==null?void 0:O.name]),g.jsxs(Ht.Form,{autoComplete:"off",children:[g.jsx(_i,{name:"title",disabled:p,required:!0,margin:"none",readOnly:s}),g.jsxs(V.Box,{marginTop:S?1:0,children:[g.jsxs(Ko,{alignItems:"flex-start",children:[S&&g.jsx(bI,{name:"file",errorMode:"hidden"}),g.jsxs(Ko,{alignItems:"flex-end",children:[g.jsx(_i,{readOnly:!0,name:"fileName",label:S?"":"File Name"}),!S&&g.jsxs(Ko,{children:[g.jsx(WD,{citation:C,onDownloadAttachment:l}),g.jsx(UD,{citation:C,onPreviewAttachment:u})]})]})]}),g.jsx(Mr,{name:"fileName"})]}),g.jsx(iA,{isLoading:p,onSaveClicked:()=>{v(!0),T()},readOnly:s,showViewAllCitationsBtn:a,onViewCitationTable:r,onCancel:n})]})}})]})},Qu=t=>{const{open:e=!1,onClose:n,title:r,children:o,actions:i,closeBtnLabel:s,closeButtonPosition:a,closeButtonProps:l={},disableDismiss:u=!1,...f}=t;if(!e)return null;const p=a==="bottom"||a==="top-and-bottom",m=a==="top"||a==="top-and-bottom",b=()=>{if(s&&p)return g.jsx(V.Button,{className:"MBv2_Modal_Close",onClick:t.onClose,...l,children:s})},v=()=>{if(i)return g.jsx(V.DialogActions,{className:"MBv2_Modal_Actions",children:g.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",gap:"0.25rem",children:[g.jsx(V.Box,{children:b()}),g.jsxs(V.Box,{display:"flex",gap:".25rem",children:[...i]})]})});if(s&&p)return g.jsx(V.DialogActions,{className:"MBv2_Modal_Actions",children:g.jsx(V.Box,{children:b()})})};return g.jsxs(V.Dialog,{className:"MBv2_Modal",open:e,onClose:()=>{u||n==null||n()},...f,children:[typeof r=="string"?g.jsx(V.DialogTitle,{className:"MBv2_Modal_Title",children:g.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[r,m&&g.jsx(V.IconButton,{"data-testid":"modal-header-close-btn",onClick:n,children:g.jsx(tm,{})})]})}):r,o&&(typeof o=="string"?g.jsx(V.DialogContent,{className:"MBv2_Modal_Content",children:g.jsx(V.DialogContentText,{className:"MBv2_Modal_Content_Text",children:o})}):o),v()]})};function nde(t){return qe("MuiAlert",t)}const cO=He("MuiAlert",["root","action","icon","message","filled","colorSuccess","colorInfo","colorWarning","colorError","filledSuccess","filledInfo","filledWarning","filledError","outlined","outlinedSuccess","outlinedInfo","outlinedWarning","outlinedError","standard","standardSuccess","standardInfo","standardWarning","standardError"]),rde=Ne(g.jsx("path",{d:"M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z"}),"SuccessOutlined"),ode=Ne(g.jsx("path",{d:"M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z"}),"ReportProblemOutlined"),ide=Ne(g.jsx("path",{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"}),"ErrorOutline"),sde=Ne(g.jsx("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z"}),"InfoOutlined"),ade=Ne(g.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close"),lde=t=>{const{variant:e,color:n,severity:r,classes:o}=t,i={root:["root",`color${Pe(n||r)}`,`${e}${Pe(n||r)}`,`${e}`],icon:["icon"],message:["message"],action:["action"]};return Ue(i,nde,o)},cde=oe(_s,{name:"MuiAlert",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:n}=t;return[e.root,e[n.variant],e[`${n.variant}${Pe(n.color||n.severity)}`]]}})(vt(({theme:t})=>{const e=t.palette.mode==="light"?ya:Ml,n=t.palette.mode==="light"?Ml:ya;return{...t.typography.body2,backgroundColor:"transparent",display:"flex",padding:"6px 16px",variants:[...Object.entries(t.palette).filter(Ln(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"standard"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),backgroundColor:t.vars?t.vars.palette.Alert[`${r}StandardBg`]:n(t.palette[r].light,.9),[`& .${cO.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Ln(["light"])).map(([r])=>({props:{colorSeverity:r,variant:"outlined"},style:{color:t.vars?t.vars.palette.Alert[`${r}Color`]:e(t.palette[r].light,.6),border:`1px solid ${(t.vars||t).palette[r].light}`,[`& .${cO.icon}`]:t.vars?{color:t.vars.palette.Alert[`${r}IconColor`]}:{color:t.palette[r].main}}})),...Object.entries(t.palette).filter(Ln(["dark"])).map(([r])=>({props:{colorSeverity:r,variant:"filled"},style:{fontWeight:t.typography.fontWeightMedium,...t.vars?{color:t.vars.palette.Alert[`${r}FilledColor`],backgroundColor:t.vars.palette.Alert[`${r}FilledBg`]}:{backgroundColor:t.palette.mode==="dark"?t.palette[r].dark:t.palette[r].main,color:t.palette.getContrastText(t.palette[r].main)}}}))]}})),ude=oe("div",{name:"MuiAlert",slot:"Icon",overridesResolver:(t,e)=>e.icon})({marginRight:12,padding:"7px 0",display:"flex",fontSize:22,opacity:.9}),dde=oe("div",{name:"MuiAlert",slot:"Message",overridesResolver:(t,e)=>e.message})({padding:"8px 0",minWidth:0,overflow:"auto"}),fde=oe("div",{name:"MuiAlert",slot:"Action",overridesResolver:(t,e)=>e.action})({display:"flex",alignItems:"flex-start",padding:"4px 0 0 16px",marginLeft:"auto",marginRight:-8}),uO={success:g.jsx(rde,{fontSize:"inherit"}),warning:g.jsx(ode,{fontSize:"inherit"}),error:g.jsx(ide,{fontSize:"inherit"}),info:g.jsx(sde,{fontSize:"inherit"})},sA=D.forwardRef(function(e,n){const r=mt({props:e,name:"MuiAlert"}),{action:o,children:i,className:s,closeText:a="Close",color:l,components:u={},componentsProps:f={},icon:p,iconMapping:m=uO,onClose:b,role:v="alert",severity:y="success",slotProps:x={},slots:C={},variant:k="standard",...T}=r,S={...r,color:l,severity:y,variant:k,colorSeverity:l||y},O=lde(S),R={slots:{closeButton:u.CloseButton,closeIcon:u.CloseIcon,...C},slotProps:{...f,...x}},[P,j]=Mt("root",{ref:n,shouldForwardComponentProp:!0,className:ye(O.root,s),elementType:cde,externalForwardedProps:{...R,...T},ownerState:S,additionalProps:{role:v,elevation:0}}),[F,M]=Mt("icon",{className:O.icon,elementType:ude,externalForwardedProps:R,ownerState:S}),[$,z]=Mt("message",{className:O.message,elementType:dde,externalForwardedProps:R,ownerState:S}),[L,A]=Mt("action",{className:O.action,elementType:fde,externalForwardedProps:R,ownerState:S}),[_,I]=Mt("closeButton",{elementType:Zl,externalForwardedProps:R,ownerState:S}),[B,W]=Mt("closeIcon",{elementType:ade,externalForwardedProps:R,ownerState:S});return g.jsxs(P,{...j,children:[p!==!1?g.jsx(F,{...M,children:p||m[y]||uO[y]}):null,g.jsx($,{...z,children:i}),o!=null?g.jsx(L,{...A,children:o}):null,o==null&&b?g.jsx(L,{...A,children:g.jsx(_,{size:"small","aria-label":a,title:a,color:"inherit",onClick:b,...I,children:g.jsx(B,{fontSize:"small",...W})})}):null]})});process.env.NODE_ENV!=="production"&&(sA.propTypes={action:c.node,children:c.node,classes:c.object,className:c.string,closeText:c.string,color:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),components:c.shape({CloseButton:c.elementType,CloseIcon:c.elementType}),componentsProps:c.shape({closeButton:c.object,closeIcon:c.object}),icon:c.node,iconMapping:c.shape({error:c.node,info:c.node,success:c.node,warning:c.node}),onClose:c.func,role:c.string,severity:c.oneOfType([c.oneOf(["error","info","success","warning"]),c.string]),slotProps:c.shape({action:c.oneOfType([c.func,c.object]),closeButton:c.oneOfType([c.func,c.object]),closeIcon:c.oneOfType([c.func,c.object]),icon:c.oneOfType([c.func,c.object]),message:c.oneOfType([c.func,c.object]),root:c.oneOfType([c.func,c.object])}),slots:c.shape({action:c.elementType,closeButton:c.elementType,closeIcon:c.elementType,icon:c.elementType,message:c.elementType,root:c.elementType}),sx:c.oneOfType([c.arrayOf(c.oneOfType([c.func,c.object,c.bool])),c.func,c.object]),variant:c.oneOfType([c.oneOf(["filled","outlined","standard"]),c.string])});const ed=t=>{var b;const{noIcon:e=!1,children:n,severity:r="success",variant:o="leftBorder",sx:i,title:s,...a}=t,{palette:l}=V.useTheme(),u=e?{icon:!1}:{},f=o==="leftBorder"?"standard":o,p=o==="leftBorder"?{...i,borderLeft:`4px solid ${(b=l[r])==null?void 0:b.main}`}:i,m=s?{icon:{sx:{mt:"6px"}}}:{};return g.jsxs(sA,{severity:r,variant:f,sx:p,slotProps:m,...u,...a,children:[s&&g.jsx(V.Typography,{variant:"h3",children:s}),n]})},aA=t=>g.jsx(ed,{severity:"error",...t}),lA=t=>g.jsx(ed,{severity:"success",...t}),pde=t=>{const{alert:e,setAlert:n}=t,r=()=>n(void 0);return g.jsxs(g.Fragment,{children:[(e==null?void 0:e.type)==="Error"&&g.jsx(aA,{"data-testid":"citation-menu-error",onClose:r,title:e.title,children:e.message.toString()}),(e==null?void 0:e.type)==="Success"&&g.jsx(lA,{"data-testid":"citation-menu-success",onClose:r,children:e.message})]})};function cA({getCitationsPaginated:t,onCreateCitation:e,onUpdateCitation:n,onDeleteCitation:r,getCitationById:o,onDownloadAttachment:i,onPreviewAttachment:s,onSelectCitations:a,onClose:l,initialSelectedIds:u=[],onContentChange:f,onError:p=()=>{},renderAsPopup:m=!1,canSelect:b=!1,tableTitle:v="Attachments & Citations",addlActions:y,canLaunchUrl:x,readOnly:C,canSearch:k=!1}){const[T,S]=J.useState("Insert Citation/Attachment(s)"),[O,R]=J.useState(u),[P,j]=J.useState(void 0),[F,M]=J.useState(void 0),[$,z]=J.useState(!1),[L,A]=J.useState(!1),_=ee=>{M(void 0),S(ee)},[I,B]=J.useState(0);J.useEffect(()=>{f==null||f()},[T,F,f]);const W=(ee=!1)=>{(!m||ee)&&B(ie=>ie+1)},K=(ee,ie)=>{var Me;const we=typeof((Me=ie.response)==null?void 0:Me.data)=="string"&&ie.response.data,Se=typeof ie.message=="string"&&ie.message;M({type:"Error",title:ee,message:we??Se}),p(ie)},U=ee=>M({type:"Success",title:"",message:ee}),Y=async ee=>{if(T==="Insert Citation/Attachment(s)")throw Error("onSave called with invalid state");ee.id?await(n==null?void 0:n(ee).then(()=>{$?l():(_("Insert Citation/Attachment(s)"),W())}).catch(ie=>{K("Failed to update",ie)})):await(e==null?void 0:e(ee).then(ie=>{R([...O,ie.id]),_("Insert Citation/Attachment(s)"),W()}).catch(ie=>{K("Failed to create",ie)}))},fe=r&&(async ee=>r(ee).then(()=>{W(!0),R(O.filter(ie=>ie!==ee)),U("Successfully deleted")}).catch(ie=>K("Failed to delete",ie))),ue=o&&(ee=>{o(ee).then(ie=>{const we=!!ie.fileName;j(ie),_(we?"Attachment":"Citation")}).catch(ie=>{K("Failed to load",ie)}).finally(()=>A(!1))}),pe=n&&ue,Z=n&&ue,te=i&&(async ee=>i(ee).catch(ie=>{K(`Failed to download ${ee.fileName}`,ie)})),ce=s&&(async ee=>s(ee).catch(ie=>{K(`Failed to view ${ee.fileName}`,ie)})),ne=g.jsx(due,{refreshKey:I,getCitationsPaginated:(ee,ie)=>t(ee,ie).then(we=>(f==null||f(),we)),onCancel:l,onNewCitation:()=>{j(void 0),_("Citation")},onNewAttachment:()=>{j(void 0),_("Attachment")},onEditCitation:pe,onEditAttachment:Z,onViewCitation:ue,onViewAttachment:ue,onDeleteCitation:fe,onDownloadAttachment:te,onPreviewAttachment:ce,onSelect:a,setSelectedIds:R,selectedIds:O,onError:p,condenseTable:m,canSelect:b,title:v,addlActions:y,canCreate:!!e,canLaunchUrl:x,readOnly:C,showCloseBtn:m,canSearch:k}),re=g.jsx(Que,{modifyCitation:P,onSave:Y,onCancel:()=>$?l():_("Insert Citation/Attachment(s)"),onViewCitationTable:()=>{_("Insert Citation/Attachment(s)"),z(!1)},onClose:()=>m?l():_("Insert Citation/Attachment(s)"),readOnly:C,showViewAllCitationsBtn:C&&!$||!C&&$,canLaunchUrl:x}),le=g.jsx(tde,{onSave:Y,onCancel:()=>$?l():_("Insert Citation/Attachment(s)"),onViewCitationTable:()=>{_("Insert Citation/Attachment(s)"),z(!1)},onClose:()=>m?l():_("Insert Citation/Attachment(s)"),modifyCitation:P,readOnly:C,showViewAllCitationsBtn:C&&!$||!C&&$,onDownloadAttachment:te,onPreviewAttachment:ce}),ge=g.jsx(pde,{alert:F,setAlert:M});J.useEffect(()=>{m&&u.length===1&&ue&&(A(!0),z(!0),ue(u[0]))},[]);const X=()=>{switch(T){case"Insert Citation/Attachment(s)":return ne;case"Citation":return re;case"Attachment":return le}};return m?g.jsxs(V.Box,{children:[ge,g.jsx(V.Box,{paddingTop:"8px",children:g.jsx(Ox,{isLoading:L,children:X()})})]}):g.jsxs(V.Box,{width:"100%",children:[T==="Insert Citation/Attachment(s)"&&ge,g.jsx(V.Box,{paddingTop:"8px",children:ne}),g.jsx(Qu,{open:T!=="Insert Citation/Attachment(s)",children:g.jsxs(V.Box,{padding:"10px 20px",minWidth:"400px","data-testid":"citation-form-modal",children:[ge,T==="Citation"?re:le]})})]})}function uA({getSelectedCitationsPaginated:t,getCitationsPaginated:e,readOnly:n,initialSelectedIds:r=[],...o}){const i=(s,a)=>n?t(s,r):e(s,a);return g.jsx(cA,{renderAsPopup:!0,canSelect:!n,getCitationsPaginated:i,readOnly:n,tableTitle:`${n?"Selected":"Insert"} Citation/Attachment(s)`,initialSelectedIds:r,...o})}const hde=V.styled("div",{name:"CitationBubbleMenu",slot:"content",overridesResolver:(t,e)=>e.content})(({theme:t})=>{const e=t.palette.mode==="dark";return{padding:t.spacing(1.5,2,.5),backgroundColor:e?"#101010":"#f9f9f9",border:`1px solid ${t.palette.grey[e?700:200]}`}});function mde({getCitationsPaginated:t,getSelectedCitationsPaginated:e,onCreateCitation:n,onUpdateCitation:r,onDeleteCitation:o,getCitationById:i,onDownloadAttachment:s,onPreviewAttachment:a,canLaunchUrl:l,readOnly:u,canSearch:f,...p}){const m=kt();if(m&&!("citationBubbleMenuHandler"in(m==null?void 0:m.storage)))throw new Error("You must add the CitationBubbleMenuHandler extension to the useEditor `extensions` array in order to use this component!");const b=m==null?void 0:m.storage.citationBubbleMenuHandler,v=b.isOpen,y=b.selectedIds,x=b.selectedNodePos,C=O=>{m&&(O.length===0?m.commands.deleteCitation(x):y.length===0?m.commands.insertCitation({ids:O}):m.commands.updateCitation({ids:O},x))},k=O=>{C(O),m==null||m.commands.closeCitationBubbleMenu()},T=()=>{C(y),m==null||m.commands.closeCitationBubbleMenu()},S=J.useCallback(()=>{requestAnimationFrame(()=>{m!=null&&m.view&&m.view.dispatch(m.view.state.tr)})},[m]);return m?g.jsx(wv,{editor:m,open:v,...b.bubbleMenuOptions,...p,children:g.jsx(hde,{children:g.jsx(uA,{getCitationsPaginated:t,getSelectedCitationsPaginated:O=>e(O,y),onCreateCitation:n,onUpdateCitation:r,onDeleteCitation:o,getCitationById:i,onDownloadAttachment:s,onPreviewAttachment:a,onSelectCitations:k,onClose:T,initialSelectedIds:y,onContentChange:S,canLaunchUrl:l,readOnly:u,canSearch:f})})}):null}const gde=()=>gn.create({name:"citationBubbleMenuHandler",addStorage(){return{isOpen:!1,selectedIds:[],bubbleMenuOptions:void 0,selectedNodePos:0}},addCommands(){return{openCitationBubbleMenu:(t={},e)=>({editor:n,dispatch:r})=>{var a;const{doc:o}=n.state,i=o.nodeAt(e??0),s=((a=i==null?void 0:i.attrs)==null?void 0:a.ids)??[];return r&&(this.storage.isOpen=!0,this.storage.selectedIds=s,this.storage.bubbleMenuOptions=t,this.storage.selectedNodePos=e??0),!0},closeCitationBubbleMenu:()=>({commands:t,dispatch:e})=>this.storage.isOpen?(t.focus(),e&&(this.storage.isOpen=!1,this.storage.selectedIds=[],this.storage.selectedNodePos=0),!0):!1}},onSelectionUpdate(){this.storage.isOpen&&!this.editor.isActive("citation")&&this.editor.commands.closeCitationBubbleMenu()},addKeyboardShortcuts(){return{"Mod-Shift-c":()=>(this.editor.commands.openCitationBubbleMenu(),!0)}}});function yde(t){const e=kt(),n=J.useRef(null);return g.jsx(wt,{buttonRef:n,tooltipLabel:"Insert Citation/Attachment",tooltipShortcutKeys:["mod","Shift","C"],disabled:!(e!=null&&e.isEditable),onClick:()=>e==null?void 0:e.commands.openCitationBubbleMenu({anchorEl:n.current,placement:"bottom"}),...t,children:g.jsxs(V.Box,{display:"flex",flexDirection:"row",gap:"4px",alignItems:"center",children:[g.jsx(yne,{fontSize:"small"}),g.jsx(V.Typography,{variant:"body2",children:"Insert Citation/Attachment"})]})})}const dA=J.createContext(void 0),fA=()=>{const t=J.useContext(dA);if(!t)throw new Error("useSync must be used inside CitationFieldProvider");return t},bde=({node:t,HTMLAttributes:e,selected:n,extension:r,updateAttributes:o,deleteNode:i})=>{const s=t.attrs.ids||[],{citations:a,isLoaded:l}=fA(),[u,f]=J.useState(s?String(s):""),[p,m]=J.useState([]),b=r.options.citationMaxLength;if(J.useEffect(()=>{if(!l)return;const v=a.filter(C=>s.includes(C.id)),y=v.map(C=>_x(C.title,b)).join(", ");f(y),m(v);const x=v.map(C=>C.id);x.length===0?setTimeout(i,0):x.length!==s.length&&setTimeout(()=>o({ids:v.map(C=>C.id)}),0)},[a,s,l]),p.length!==0)return g.jsx(Wv,{as:"span",...e,"data-testid":"citation-node-component","data-drag-handle":!0,onDragOver:v=>v.preventDefault(),onDrop:()=>{},children:g.jsx(V.Tooltip,{title:g.jsx(V.Box,{className:"citation-tooltip",children:p.map((v,y)=>{var k;const C=!!v.fileName?[v.title,v.fileName]:[v.title,v.source,v.details,(k=v.accessedAt)==null?void 0:k.slice(0,10),v.url,v.classification];return g.jsxs(V.Typography,{variant:"subtitle2",children:[C.filter(Boolean).join(" | "),y<p.length-1&&g.jsx(V.Divider,{className:"citation-tooltip-divider"})]},v.id)})}),slotProps:{tooltip:{sx:{maxWidth:500}}},children:g.jsx("a",{href:"#",onClick:v=>{v.preventDefault(),v.stopPropagation()},className:n?"selected-citation-link":"citation-link",children:u})})})},vde=rn.create({name:"citation",group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!0,addAttributes(){return{ids:{default:[],parseHTML:t=>{const e=t.getAttribute("ids");return e?e.split(",").map(n=>parseInt(n.trim(),10)).filter(n=>!isNaN(n)):[]},renderHTML:t=>({ids:Array.isArray(t.ids)?t.ids.join(","):""})}}},parseHTML(){return[{tag:"citation"}]},renderHTML({HTMLAttributes:t}){return["citation",Tt(t)]},addNodeView(){return Uv(bde)},addProseMirrorPlugins(){return[new on({props:{handleClickOn:(t,e,n,r,o,i)=>n&&n.type.name==="citation"?(this.editor.commands.openCitationBubbleMenu({},r),!0):!1},appendTransaction(t,e,n){if(!t.some(i=>i.docChanged))return null;let r=n.tr,o=!1;return n.doc.descendants((i,s)=>{if(i.type.name!=="citation")return;const a=s+i.nodeSize,l=n.doc.nodeAt(a);if(l&&l.type===i.type){const u=[...new Set([...i.attrs.ids,...l.attrs.ids])],f=i.type.create({...i.attrs,ids:u});return r.replaceWith(s,a+l.nodeSize,f),o=!0,!1}}),o?r:null}})]},addCommands(){return{insertCitation:t=>({commands:e})=>e.insertContent({type:"citation",attrs:t}),updateCitation:(t,e)=>({state:n,dispatch:r,tr:o})=>{const i=n.doc.nodeAt(e);return!i||i.type.name!=="citation"?!1:(o.setNodeMarkup(e,void 0,t),r&&r(o),!0)},deleteCitation:t=>({tr:e,dispatch:n})=>{if(typeof t!="number")return!1;const r=t,o=t+1;return n&&n(e.delete(r,o)),!0}}}});function dO({editor:t,canComment:e=!0,onComment:n,commentCount:r,commentResolved:o,...i}){const s=J.useRef(null);if(!n)return null;const a=o?g.jsx(n2,{sx:{width:14,height:14},"data-testid":"resolved-checkmark"}):r,l=o?"success":"primary",u=o?{"& .MuiBadge-badge":{padding:0,height:16,minWidth:16}}:{"& .MuiBadge-badge":{fontSize:14,height:16,minWidth:16}};return e?g.jsx(wt,{buttonRef:s,tooltipLabel:"Comments",onClick:()=>{if(!t)return;const{from:f,to:p}=t.state.selection,m=t.state.doc.textBetween(f,p,`
|
|
408
408
|
`).trim();n(m)},...i,children:g.jsx(V.Box,{display:"flex",flexDirection:"row",gap:"4px",alignItems:"center",children:g.jsx(V.Badge,{"data-testid":"comment-button-badge",badgeContent:a,color:l,sx:u,children:g.jsx(_ne,{sx:{fontSize:"22px"}})})})}):null}const xde=t=>{var Z;const{name:e,label:n=Fn(e),hideLabel:r=!1,required:o=!1,readOnly:i,margin:s="dense",citationMaxLength:a=24,getCitationsPaginated:l,getSelectedCitationsPaginated:u,onCreateCitation:f,onUpdateCitation:p,onDeleteCitation:m,getCitationById:b,onDownloadAttachment:v,onPreviewAttachment:y,onError:x=()=>{},placeholder:C="Start typing here...",errorMode:k="normal",canLaunchUrl:T,canSearch:S=!1,redoUndo:O=!1}=t,R=[yR.configure({code:!1,codeBlock:!1,heading:!1,blockquote:!1,horizontalRule:!1,strike:!1}),Jv,LD.configure({placeholder:C}),gde(),vde.configure({citationMaxLength:a})],[P,j,F]=Ht.useField({name:e}),{setValue:M}=F,{value:$}=P,{addUpdateCitation:z,deleteCitation:L,batchUpdate:A,citations:_}=fA();J.useEffect(()=>{var ne;const te=(ne=I==null?void 0:I.current)==null?void 0:ne.editor;if(!te)return;te.getHTML()!==$&&setTimeout(()=>{te.commands.setContent($)},0)},[$]);const I=J.useRef(null),B={normal:{marginTop:"16px",marginBottom:"8px"},dense:{marginTop:"8px",marginBottom:"4px"},none:{margin:0}},W=(te=void 0)=>{var re,le;const ce=((le=(re=I.current)==null?void 0:re.editor)==null?void 0:le.getHTML())??"",ne=!ce.replace(/<\/?p>|<br>/g,"").trim();M(ne?"":ce,te)},K=J.useMemo(()=>ka.debounce(()=>W(!1),500),[M]),U=_a(),{showDiff:Y,getPreviousValue:fe}=Ra(),ue=i??U;if(Y){const te=fe(e)??"",ce=$,ne=/<citation\s+ids="([^"]*)"><\/citation>/g,re=(X,ee)=>{const ie=ee.split(",").map(Number);return`<sup>${_.filter(we=>ie.includes(we.id)).map(we=>_x(we.title,a))}</sup>`},le=te.replace(ne,re),ge=ce.replace(ne,re);return g.jsx(Fi,{label:n,value:ge,showDiff:!0,diffSnapshot:le,mode:"html"})}const pe=ka.pick(t,["canComment","onComment","commentCount","commentResolved"]);return g.jsxs(V.Box,{id:`citation-field_${e}`,sx:{"& .ProseMirror":{"& h1, & h2, & h3, & h4, & h5, & h6":{scrollMarginTop:ue?0:50}},".MuiTiptap-RichTextContent-readonly ":{padding:0}},...B[s],display:"flex",flexDirection:"column",width:"100%",children:[g.jsxs(V.Box,{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[!r&&g.jsx(V.InputLabel,{htmlFor:`citation-field_${e}`,required:!i&&o,children:n}),i&&g.jsx(dO,{...pe,editor:(Z=I==null?void 0:I.current)==null?void 0:Z.editor})]}),g.jsx(uI,{ref:I,extensions:R,content:$,editable:!ue,renderControls:()=>{var te;return g.jsxs(xp,{justifyContent:"space-between",children:[g.jsxs(xp,{children:[g.jsx(yde,{}),g.jsx(In,{}),g.jsx(h2,{}),g.jsx(v2,{}),g.jsx(C2,{}),g.jsx(In,{}),g.jsx(x2,{}),g.jsx(m2,{})]}),g.jsx(dO,{...pe,editor:(te=I==null?void 0:I.current)==null?void 0:te.editor})]})},onBlur:()=>W(),onUpdate:K,RichTextFieldProps:{variant:ue?"standard":"outlined",MenuBarProps:{hide:ue},footer:O&&g.jsxs(V.Stack,{direction:"row",spacing:2,sx:{borderTop:te=>`1px solid ${te.palette.divider}`,p:1},children:[g.jsx(S2,{}),g.jsx(w2,{})]})},children:()=>g.jsx(mde,{getCitationsPaginated:(te,ce)=>l(te,ce).then(ne=>(A(ne.data),ne)),getSelectedCitationsPaginated:u,onCreateCitation:f&&(te=>f(te).then(ce=>(z(ce),ce))),onUpdateCitation:p&&(te=>p(te).then(ce=>(z(ce),ce))),onDeleteCitation:m&&(te=>m(te).then(()=>L(te))),getCitationById:b,onDownloadAttachment:v,onPreviewAttachment:y,onError:x,canLaunchUrl:T,readOnly:ue,canSearch:S})}),g.jsx(Mr,{name:e,id:`${e}-err`,errorMode:k})]})},wde=t=>g.jsx(yI,{name:t.name,label:"Not Applicable",errorMode:"hidden"}),Cde=t=>{const{name:e="submit"}=t;return g.jsx(Sr,{name:e,type:"submit",...t})},Sde=t=>{const{label:e="Return to Top",icon:n=Lf,scrollThresholdPx:r=100}=t,o=V.useScrollTrigger({threshold:r}),i=J.useCallback(()=>{window.scrollTo({top:0,behavior:"smooth"})},[]);return g.jsx(V.Zoom,{in:o,children:g.jsx(V.Box,{sx:{position:"fixed",bottom:32,right:32,zIndex:1},children:g.jsxs(V.Fab,{onClick:i,color:"primary",size:"small",variant:"extended","aria-label":"Scroll back to top",children:[g.jsx(n,{fontSize:"medium"}),e]})})})},pA=t=>{const{label:e,menuOptions:n=[],icon:r}=t,o=To.useNavigate(),[i,s]=D.useState(null),a=!!i,l=p=>{s(p.currentTarget)},u=()=>{s(null)};if(n.length===0)return null;const f=r&&!e;return g.jsxs(g.Fragment,{children:[g.jsx(V.Button,{startIcon:f?void 0:r,variant:"outlined",color:"inherit",sx:{minWidth:0,...f&&{paddingLeft:"6px",paddingRight:"6px"}},onClick:l,children:f?r:e}),g.jsx(V.Menu,{anchorEl:i,open:a,onClick:u,children:n.map(p=>g.jsxs(V.MenuItem,{...zl(p,o),children:[p.icon&&g.jsx(V.ListItemIcon,{children:p.icon}),g.jsx(V.ListItemText,{primary:p.label})]},p.label))})]})},Tde=()=>{const{values:t,errors:e,status:n}=Ht.useFormikContext(),{palette:r}=V.useTheme();return g.jsx(V.Paper,{style:{backgroundColor:r.mode==="dark"?"#303030":"#f0f0f0",margin:"10px 0"},children:g.jsxs(V.List,{children:[g.jsxs(V.ListItem,{children:[g.jsx(V.Typography,{display:"block",variant:"h6",children:"Values"}),g.jsx("br",{}),g.jsx(V.Divider,{variant:"inset"}),g.jsx("pre",{children:JSON.stringify(t,null,2)})]}),g.jsx(V.Divider,{variant:"inset",component:"li"}),g.jsxs(V.ListItem,{id:"testing",children:[g.jsx(V.Typography,{display:"block",variant:"h6",children:"Errors"}),g.jsx("br",{}),g.jsx(V.Divider,{variant:"inset"}),g.jsx("pre",{children:JSON.stringify(e,null,2)})]}),g.jsxs(V.ListItem,{children:[g.jsx(V.Typography,{display:"block",variant:"h6",children:"Status"}),g.jsx("br",{}),g.jsx(V.Divider,{variant:"inset"}),g.jsx("pre",{children:JSON.stringify(n,null,2)})]})]})})},kde=t=>{const{steps:e,orientation:n,inlineLabel:r=n=="vertical",isResponsive:o=!1}=t,{width:i}=HD();let s=!r,a=n;o&&(n&&console.warn("Stepper: Ignoring orientation. isResponsive is set to true, so the orientation is determined automatically based on the window size."),a=i<600?"vertical":"horizontal",a=="vertical"?s=!1:s=!r),n=="vertical"&&!r&&(console.warn("Stepper: ignoring inlineLabel={false}. Must use inline labels when orientation is vertical"),s=!1);const l=["steps","inlineLabel","orientation","isResponsive"],u={alternativeLabel:s,orientation:a,...pr({...t},l)};return g.jsx(V.Stepper,{...u,children:e.map(f=>g.jsx(V.Step,{children:g.jsx(V.StepLabel,{children:f})},f))})},Ede=t=>{const{name:e,label:n=Fn(e),labelProps:r={fontSize:"1.1em",color:"#808080",fontWeight:"600"},initialState:o,renderFormGroup:i,addButtonContent:s="Add Another",removeButtonContent:a=t.removePosition==="right"?g.jsx(EI,{}):"Remove",variant:l="card",addButtonSx:u,removeButtonSx:f,allowRemoveAll:p=!1,readOnly:m=!1,emptyListMsg:b="None",showDivider:v=!1,removePosition:y="bottom"}=t,[x]=Ht.useField({name:e}),{value:C}=x,k=T=>({display:"flex",flexDirection:T==="bottom"?"column":"row",alignItems:T==="bottom"?"flex-start":"center"});return g.jsxs(V.FormControl,{fullWidth:!0,children:[g.jsx(V.Typography,{...r,children:n}),m&&x.value.length===0?g.jsx(V.Typography,{children:b}):g.jsx(Ht.FieldArray,{name:e,render:T=>g.jsxs("div",{children:[C.map((S,O)=>g.jsx(J.Fragment,{children:g.jsx(Ode,{variant:l,content:g.jsxs(V.Box,{"data-testid":"form-group-container",sx:typeof y=="string"?k(y):{...y},children:[g.jsxs(V.Box,{width:"100%",children:[i(`${e}.${O}`,O),v&&O!==C.length-1&&g.jsx(V.Divider,{"data-testid":"divider"})]}),!m&&C.length>(p?0:1)&&g.jsx(V.Button,{"data-testid":"repeatable-form-group_remove-btn",sx:f,onClick:()=>T.remove(O),children:a})]})})},`${e}-${O}`)),!m&&g.jsx(V.Button,{"data-testid":"repeatable-form-group_add-btn",onClick:()=>T.push(o),sx:u,children:s})]})})]})},Ode=({variant:t,content:e})=>{switch(t){case"card":return g.jsx(V.Card,{"data-testid":"repeatable-form-group_card",sx:{padding:"8px",marginBottom:"8px"},children:g.jsx(V.CardContent,{children:e})});case"elevatedCard":return g.jsx(V.Card,{"data-testid":"repeatable-form-group_elevated-card",elevation:4,sx:{border:"unset",padding:"8px",marginBottom:"8px"},children:g.jsx(V.CardContent,{children:e})});case"none":return e}},Mde=t=>{const{confirmBtnLabel:e,onConfirm:n,confirmButtonProps:r={color:"primary",variant:"contained"},closeBtnLabel:o="Cancel",closeButtonPosition:i="bottom",...s}=t;return g.jsx(Qu,{actions:[g.jsx(V.Button,{className:"MBv2_ConfirmationModal_ConfirmBtn",onClick:n,...r,children:e})],closeBtnLabel:o,closeButtonPosition:i,...s})},_de=t=>{const{closeBtnLabel:e="OK",closeButtonPosition:n="bottom",closeButtonProps:r={color:"primary",variant:"contained"},...o}=t;return g.jsx(Qu,{closeBtnLabel:e,closeButtonPosition:n,closeButtonProps:r,...o})},Rde=t=>{const{primaryBtnLabel:e,onPrimaryAction:n,primaryActionProps:r={color:"primary",variant:"contained"},secondaryBtnLabel:o,onSecondaryAction:i,secondaryActionProps:s={color:"primary",variant:"outlined"},closeBtnLabel:a="Cancel",closeButtonPosition:l="bottom",...u}=t;return g.jsx(Qu,{actions:[g.jsx(V.Button,{className:"MBv2_DecisionModal_SecondaryAction",onClick:i,...s,children:o}),g.jsx(V.Button,{className:"MBv2_DecisionModal_PrimaryAction",onClick:n,...r,children:e})],closeBtnLabel:a,closeButtonPosition:l,...u})},Ide={added:{icon:mne,label:"Added",color:"success"},deleted:{icon:EI,label:"Deleted",color:"error"},modified:{icon:bne,label:"Modified",color:"info"},unmodified:{label:"Unmodified",color:"default"}},Dde=(t,e)=>g.jsxs(g.Fragment,{children:[g.jsx(V.Box,{"data-testid":"diff-table-cell-removed",sx:{backgroundColor:kp},children:g.jsx("s",{children:t})}),g.jsx(V.Box,{"data-testid":"diff-table-cell-added",sx:{backgroundColor:Tp},children:g.jsx("u",{children:e})})]}),Ade=(t,e,n,r=!1)=>{var i;let o={};for(const s of t)if(!s.ignoreDiff){const a=Tl(s,e,r),l=Tl(s,n,r);(((i=s.isEqual)==null?void 0:i.call(s,e,n))??gI.isEqual(a,l))||(o[wn(s)]=Dde(a,l))}return o},hA=(t,e,n,r=!1,o)=>{const i=[],s=[];let a=0,l=0;for(e.sort((u,f)=>u.id-f.id),n.sort((u,f)=>u.id-f.id);a<e.length&&l<n.length;){const u=e[a],f=n[l];if(u.id===f.id){const p=Ade(t,u,f,r);(o==null?void 0:o(u,f))??Object.keys(p).length===0?s.push({...f,changeType:"unmodified"}):i.push({...f,changeType:"modified",modifiedDiff:p}),a++,l++}else u.id<f.id?(i.push({...u,changeType:"deleted"}),a++):(i.push({...f,changeType:"added"}),l++)}for(;a<e.length;)i.push({...e[a],changeType:"deleted"}),a++;for(;l<n.length;)i.push({...n[l],changeType:"added"}),l++;return{dataDiff:i,dataUnmodified:s}},mA=t=>{const{beforeData:e,afterData:n,columns:r,isEqual:o,size:i,isMobileScreen:s}=t;t.renderExpand!=null&&o==null&&console.warn("DiffTable: isEqual prop should be provided when renderExpand is provided");const{dataDiff:a,dataUnmodified:l}=hA(r,e,n,s,o);return{columns:[{fieldName:"changeType",render:f=>{const p=Ide[f];return g.jsx(V.Chip,{color:p.color,size:i=="small"||i=="x-small"?"small":"medium",label:g.jsxs(V.Typography,{children:[p.icon&&g.jsx(P0,{icon:p.icon}),p.label]})})}},...r.map(f=>({...f,render:(p,m)=>{var b;return((b=m.modifiedDiff)==null?void 0:b[wn(f)])??Tl(f,m,s)}}))],data:a,unmodifiedData:l,renderExpand:t.renderExpand?f=>{const p=e.find(m=>m.id===f.id);return g.jsx(sM,{previousSnapshot:p,currentSnapshot:f,showDiff:f.changeType==="modified",children:t.renderExpand(f)})}:void 0}},gA=({columns:t,data:e,unmodifiedData:n=[],emptyTableMsg:r="No changes to display",renderExpand:o,size:i})=>{const[s,a]=J.useState(!1),l=()=>a(!s),u=`${s?"Hide":"Show"} ${n.length} unmodified row${n.length>1?"s":""}`;return g.jsxs(V.Box,{children:[g.jsx(Mx,{columns:t,data:[...e,...s?n:[]],emptyTableMsg:r,renderExpand:o,size:i}),n.length>0&&g.jsx(V.Box,{children:g.jsx(V.Button,{onClick:l,children:u})})]})},Pde=t=>{const{emptyTableMsg:e="No changes to display",...n}=t,r=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),o="beforeData"in n?mA({...n,isMobileScreen:r}):n;return g.jsx(gA,{...o,size:t.size})},Nde=t=>{const{featureMenuOptions:e=[],copyright:n,logo:r,sx:o={},fontColor:i="primary"}=t,{palette:s}=V.useTheme(),a=To.useNavigate();return g.jsxs(V.Box,{className:"MBv2_Footer",sx:{backgroundColor:s.mode==="dark"?"#222222":"#ededed",padding:"25px 30px",...o},children:[g.jsx(V.Box,{className:"MBv2_Footer_Logo",sx:{display:"flex",gap:2,alignItems:"center",paddingBottom:1},children:typeof r=="string"?g.jsx("img",{draggable:"false",src:r,style:{width:"200px"},alt:"logo"}):r}),g.jsxs(V.Box,{display:"flex",justifyContent:"space-between",flexWrap:"wrap",className:"MBv2_Footer_Nav_Links_Container",gap:2,children:[g.jsx(V.Box,{sx:{flexGrow:1},className:"MBv2_Footer_Nav_Links",display:"flex",flexDirection:"row",justifyContent:"flex-start",gap:3,children:e==null?void 0:e.map(l=>g.jsx(V.Link,{"data-testid":l.label,sx:{cursor:"pointer",fontSize:15},color:i,...zl(l,a),children:l.label},l.label))}),n&&g.jsx(V.Typography,{style:{fontSize:15},"data-testid":"copyright",className:"MBv2_Footer_Copyright",color:i,children:n})]})]})},yA=t=>{const{menuOptionLists:e,anchor:n="left",children:r}=t,{pathname:o}=To.useLocation(),i=To.useNavigate(),[s,a]=J.useState(!1),l=(m,b)=>g.jsx(V.MenuList,{children:m.map(v=>g.jsxs(V.MenuItem,{...zl(v,i,()=>a(!1)),children:[v.icon&&g.jsx(V.ListItemIcon,{children:v.icon}),g.jsx(V.ListItemText,{primary:v.label})]},`mobile-drawer-group-${b}-item-${v.path}`))}),f=(()=>{if(e){const m=e.filter(b=>b&&b.length>0);return m.length===0?null:m.map((b,v)=>g.jsxs(J.Fragment,{children:[l(b,v),v<m.length-1&&g.jsx(V.Divider,{})]},`mobile-drawer-group-${v}`))}return r?g.jsx(V.Box,{role:"presentation",onClick:()=>a(!1),children:r}):null})(),p=f??!1;return J.useEffect(()=>{a(!1)},[o]),p&&g.jsxs(g.Fragment,{children:[g.jsx(V.IconButton,{onClick:()=>a(!0),color:"inherit",title:"Menu",children:g.jsx(Ene,{})}),g.jsx(V.Drawer,{"data-testid":"mobile-drawer",anchor:n,open:s,onClose:()=>a(!1),children:g.jsx(V.Box,{sx:{width:300},display:"flex",flexDirection:"column",justifyContent:"space-between",children:g.jsx(V.Box,{display:"flex",justifyContent:"start",flexDirection:"column",children:f})})})]})},bA=t=>{const{env:e,isProd:n}=t;return n?null:g.jsx(V.Paper,{sx:{borderRadius:0,display:"flex",alignItems:"center",justifyContent:"center"},children:g.jsxs(V.Typography,{variant:"h6",color:"error",children:[e," Environment - Test Data Only"]})})},vA=t=>{const{displayName:e,userMenuOptions:n}=t;return g.jsx(pA,{label:e,menuOptions:n,icon:g.jsx(Mne,{})})},vm=t=>{const{menuOptions:e,orientation:n="horizontal",activeTabIdx:r,sx:o=n=="vertical"?{"& .MuiTabs-indicator":{left:0}}:void 0,slotProps:i={indicator:{sx:n=="horizontal"?{height:4}:{width:4}}}}=t,{palette:s}=V.useTheme(),a=To.useNavigate();return g.jsx(V.Tabs,{orientation:n,value:r??!1,sx:o,slotProps:i,children:e.map((l,u)=>g.jsx(V.Tab,{icon:l.icon,label:l.label,value:u,...zl(l,a),sx:{alignItems:n=="vertical"?"flex-start":void 0,borderBottom:n=="vertical"?"1px solid":void 0,borderColor:"divider","&.Mui-selected":{backgroundColor:n=="vertical"?s.grey[s.mode=="dark"?800:50]:void 0,color:"inherit"}}},l.label))})},xA=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t;return e.length>0&&g.jsx(V.Paper,{sx:{pl:4,pr:4,borderRadius:0},"data-testid":"navBar",children:g.jsx(vm,{menuOptions:e,activeTabIdx:n,sx:r})})},wA=t=>{const{onToggle:e}=t,{palette:n}=V.useTheme(),r=n.mode==="dark";return g.jsx(V.IconButton,{onClick:e,color:"inherit",title:"Dark Mode Toggle",children:r?g.jsx(kI,{}):g.jsx(SI,{})})},jde=t=>{const{envInfo:e,headerRef:n,logo:r,featureMenuOptions:o=[],userMenuOptions:i=[],onToggleDarkMode:s,quickLinks:a=[],displayName:l,banner:u,position:f="fixed",children:p,sx:m,navBarSx:b}=t,v=To.useNavigate(),y=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),{palette:x}=V.useTheme(),{pathname:C}=To.useLocation(),k=x.mode==="dark",[T,S]=D.useState(void 0);D.useEffect(()=>{const P=o.findIndex(j=>j.path&&C.startsWith(j.path));S(P>=0?P:void 0)},[C,o]);const O=s&&g.jsx(wA,{onToggle:s}),R=s&&(y||!y&&l)?[{icon:k?g.jsx(kI,{}):g.jsx(SI,{}),label:`Switch to ${k?"Light":"Dark"} mode`,onClick:s},...i]:i;return g.jsxs(V.AppBar,{ref:n,position:f,sx:m,elevation:4,children:[e&&g.jsx(bA,{...e}),u,g.jsxs(V.Toolbar,{sx:{color:"white",display:"flex",justifyContent:"space-between",gap:2},children:[g.jsx(V.Button,{disableRipple:!0,component:To.Link,to:"/",children:r&&typeof r=="string"?g.jsx("img",{draggable:"false",src:r,style:{width:"200px",filter:"brightness(0) invert(1)"},alt:"logo"}):r}),g.jsxs(V.Box,{display:"flex",gap:2,alignItems:"center",children:[!l&&!y&&O,y&&g.jsx(yA,{menuOptionLists:[o,a,R],anchor:"right"}),!y&&g.jsxs(g.Fragment,{children:[g.jsx(V.Box,{display:"flex",gap:0,children:a==null?void 0:a.map((P,j)=>g.jsxs(V.Box,{display:"flex",alignItems:"center",children:[j>0&&g.jsx(V.Typography,{className:"quickLink-divider",color:x.primary.contrastText,children:"|"}),g.jsx(V.Button,{variant:"text",sx:{color:"white"},...zl(P,v),children:g.jsxs(V.Box,{display:"flex",gap:"3px",alignItems:"center",children:[P.icon,P.label]})})]},P.label))}),p,l&&g.jsx(vA,{displayName:l,userMenuOptions:R})]})]})]}),!y&&g.jsx(xA,{featureMenuOptions:o,activeTabIdx:T,sx:b})]})},$de=t=>{const{sx:e,menuOptions:n=[]}=t,{pathname:r}=To.useLocation(),o=V.useMediaQuery(V.useTheme().breakpoints.down("sm")),[i,s]=J.useState(void 0);return J.useEffect(()=>{const a=n.findIndex(l=>l.path&&r.startsWith(l.path))??-1;s(a>=0?a:void 0)},[r,n]),!o&&n.length>0&&g.jsx(V.Box,{sx:e,children:g.jsx(V.Card,{sx:{height:"100%",width:200},children:g.jsx(vm,{orientation:"vertical",menuOptions:n,activeTabIdx:i})})})},Lde=t=>{const{featureMenuOptions:e=[],activeTabIdx:n,sx:r}=t,{palette:o}=V.useTheme();return e.length>0&&g.jsx(vm,{menuOptions:e,activeTabIdx:n,sx:{margin:"8px",backgroundColor:o.primary.dark,borderRadius:"8px","& .MuiTab-root":{color:o.secondary.light,flexDirection:"row",gap:"2px","& .MuiTab-icon":{marginBottom:"unset"},minHeight:"58px"},"& .MuiTab-root.Mui-selected":{color:o.primary.contrastText,fontSize:"120%"},"& .MuiTabs-indicator":{display:"none"},...r}})},Bde=({children:t,getCitations:e})=>{const[n,r]=J.useState([]),[o,i]=J.useState(!1);J.useEffect(()=>{(async()=>e().then(f=>{r(p=>{const m=new Set(p.map(v=>v.id));return[...p.filter(v=>!m.has(v.id)),...f]}),i(!0)}).catch(f=>{console.error(`Error fetching citations: ${f==null?void 0:f.toString()}`)}))()},[]);const s=J.useCallback(u=>{r(f=>{const p=f.map(v=>{const y=u.find(x=>x.id===v.id);return y||v}),m=new Set(f.map(v=>v.id)),b=u.filter(v=>!m.has(v.id));return[...p,...b]})},[]),a=J.useCallback(u=>{const f=n.findIndex(p=>p.id===u.id);r(f!==-1?p=>{const m=[...p];return m[f]=u,m}:[...n,u])},[n]),l=J.useCallback(u=>r(n.filter(f=>f.id!==u)),[n]);return g.jsx(dA.Provider,{value:{citations:n,isLoaded:o,addUpdateCitation:a,deleteCitation:l,batchUpdate:s},children:t})},Fde=t=>g.jsx(ed,{severity:"info",...t}),Vde=t=>g.jsx(ed,{severity:"warning",...t}),CA=t=>{const{crumbs:e}=t,n=To.useNavigate(),r=e.map(o=>({label:o.label,onClick:()=>{var i;o.path?n(o.path):(i=o.onClick)==null||i.call(o)}}));return g.jsx(V.Breadcrumbs,{"aria-label":"breadcrumb",separator:g.jsx(One,{}),sx:{marginBottom:2},children:r.map(({label:o,...i},s)=>s<e.length-1?g.jsx(V.Link,{color:"primary",sx:{cursor:"pointer",fontWeight:"600"},underline:"hover",...zl(i,n),children:o},o):g.jsx(V.Typography,{color:"text.primary",children:o},o))})},zde=t=>{const{title:e,message:n,type:r,onClose:o,autoHideDuration:i,variant:s="leftBorder",elevation:a=6}=t,l=Hde(r);return g.jsx(V.Snackbar,{"data-testid":"message-snackbar",anchorOrigin:{vertical:"bottom",horizontal:"right"},open:!0,onClose:u=>{u==null&&o()},autoHideDuration:i,children:g.jsx(ed,{"data-testid":"message-snackbar-alert",severity:l,iconMapping:{info:fO(r),warning:fO(r)},onClose:o,elevation:a,variant:s,children:n?g.jsxs(g.Fragment,{children:[g.jsx(V.AlertTitle,{"data-testid":"alertTitle",sx:{fontWeight:"bold"},children:e}),n]}):e})})},Hde=t=>t=="logout"?"info":t=="timeout"?"warning":t,fO=t=>{if(t=="timeout")return g.jsx(hne,{});if(t=="logout")return g.jsx(kne,{})},Wde=t=>{Ude(t);const{title:e,createButtonLabel:n="Add Item",showAddButton:r=!1,onAdd:o=()=>alert("Not implemented yet"),breadcrumbs:i=[],children:s,sx:a={},bottomGutter:l=!1}=t,u=V.useMediaQuery(V.useTheme().breakpoints.down("sm"));return!e&&(!r||!n)?null:g.jsxs(V.Box,{"data-testid":"MBv2-Page-Header",sx:{...a,...l&&{marginBottom:"4px"}},children:[i.length>0&&g.jsx(CA,{crumbs:i}),g.jsxs(V.Box,{className:"MBv2_PageHeader_Header",display:"flex",flexDirection:u?"column":"row",justifyContent:"space-between",alignItems:"center",gap:1,children:[g.jsxs(V.Box,{className:"MBv2_PageHeader_TitleAndCreateBtn",display:"flex",flexDirection:"row",justifyContent:u||!s?"space-between":"start",alignItems:"center",width:"100%",gap:1,children:[typeof e=="string"?g.jsx(V.Typography,{className:"MBv2_PageHeader_Title",variant:"h2",children:e}):e,r&&g.jsxs(Sr,{className:"MBv2_PageHeader_CreateBtn",onClick:()=>o(),children:[g.jsx(gne,{style:{marginRight:"0.5rem"}}),n]})]}),s&&g.jsx(V.Box,{width:u?"100%":"50%",children:s})]})]})},Ude=t=>{const{showAddButton:e,onAdd:n,createButtonLabel:r}=t,o="PageHeader component:";e&&!n&&console.warn(`${o} "showAddButton" is true but "onAdd" is not defined.`),e&&!r&&console.warn(`${o} "showAddButton" is true but "createButtonLabel" is not defined`)},qde=t=>{const{title:e,titleIcon:n,fullWidthIcon:r=!1,children:o,actionLabel:i,action:s,sx:a}=t,l=V.useMediaQuery(V.useTheme().breakpoints.down("sm"));return g.jsxs(V.Card,{sx:a||{padding:"30px 40px",display:"flex",flexDirection:"column",gap:"1rem"},children:[n&&g.jsx(V.Box,{className:"MBv2_SingleActionCard_Img",sx:[r?{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"20px",marginBottom:"10px"}:{display:"inline"}],children:n}),g.jsx(V.Typography,{variant:"h1",display:"inline",fontSize:"calc(20px + .9vw)",className:"MBv2_SingleActionCard_Title",children:e}),o,g.jsx(V.Button,{variant:"contained",color:"primary",onClick:s,fullWidth:l,className:"MBv2_SingleActionCard_ActionButton",children:i})]})},Kde=t=>{const{title:e="Loading...",message:n}=t;return g.jsxs(V.Box,{className:"loading-page",sx:{gap:2},"data-testid":"loading-page",children:[g.jsxs(V.Box,{className:"text-content",children:[g.jsx(V.Typography,{variant:"h1","data-testid":"title",children:e}),n&&g.jsx(V.Typography,{"data-testid":"message",children:n})]}),g.jsx(V.CircularProgress,{size:75,"data-testid":"loading-spinner"})]})};function Yde({...t}){return g.jsx(cA,{onSelectCitations:()=>{},onClose:()=>{},...t})}const Gde=t=>{const{size:e="small"}=t;let n=`${e}px`;switch(e){case"x-small":n="6px";break;case"small":n="10px";break;case"medium":n="14px";break;case"large":n="18px";break;case"x-large":n="22px";break}return g.jsx(V.Box,{height:n})},Jde=t=>{const{text:e,indent:n=!1}=t;return e?g.jsx(V.Box,{component:"blockquote",sx:{borderLeft:"4px solid",borderColor:"primary.main",pl:1,bgcolor:"action.hover",m:0,ml:n?3:0},children:g.jsxs(V.Typography,{variant:"h6",component:"p",fontStyle:"italic",fontWeight:600,gutterBottom:!0,children:['"',e,'"']})}):null};exports.AlertModal=_de;exports.Autocomplete=mI;exports.Blockquote=Jde;exports.Breadcrumbs=CA;exports.Button=Sr;exports.Checkbox=yI;exports.CheckboxGroup=Bte;exports.CitationField=xde;exports.CitationFieldProvider=Bde;exports.CitationManager=Yde;exports.Column=Ru;exports.ConfirmationModal=Mde;exports.DarkModeToggle=wA;exports.DateField=Ip;exports.DateRangeField=dce;exports.DecisionModal=Rde;exports.Diff=hI;exports.DiffProvider=sM;exports.DiffTable=Pde;exports.DiffTableView=gA;exports.Drawer=yA;exports.DynamicAutocomplete=$te;exports.EnvironmentBanner=bA;exports.ErrorAlert=aA;exports.FileList=zte;exports.FileUpload=bI;exports.FloatingNavBar=Lde;exports.Footer=Nde;exports.FormDebugger=Tde;exports.Header=jde;exports.HelpTooltip=VD;exports.IconTooltip=FD;exports.InfoAlert=Fde;exports.LoadingButton=oA;exports.LoadingIndicator=Kde;exports.LoadingOverlay=Ox;exports.Location=une;exports.MenuButton=pA;exports.Modal=Qu;exports.MultiAutocomplete=Lte;exports.NavBar=xA;exports.NotApplicableCheckbox=wde;exports.PageHeader=Wde;exports.PaginatedTable=zD;exports.ProfileMenu=vA;exports.RadioGroup=wI;exports.RangeSlider=dne;exports.ReadOnly=Fi;exports.ReadOnlyProvider=oM;exports.RepeatableFormGroup=Ede;exports.RichTextField=sue;exports.Row=Ko;exports.ScrollToTop=Sde;exports.SearchField=OI;exports.Select=fne;exports.SelectableCitationManager=uA;exports.Sidebar=$de;exports.SingleActionCard=qde;exports.Snackbar=zde;exports.Spacer=Gde;exports.Stepper=kde;exports.Submit=Cde;exports.SuccessAlert=lA;exports.Switch=pne;exports.Table=Mx;exports.Tabs=vm;exports.TextArea=CI;exports.TextField=_i;exports.TextIcon=P0;exports.ValidationError=Mr;exports.WarningAlert=Vde;exports.baseCitationTableColumns=qD;exports.buildDiffData=hA;exports.buildTableDiff=mA;exports.createAppTheme=t4;exports.useDiff=Ra;exports.useReadOnly=_a;
|