import{P as L,a as H,N as it,S as F,T as I,E as Te}from"./prosemirror-state-uun2nC1-.js";import{t as ne}from"./tippy.js-oaMRTIk4.js";import{d as At,r as Pt,h as Ot,i as at,j as lt,k as Ce,n as Ee,u as Ae,s as Pe,m as re,l as Oe,p as Kt,q as Le,t as $e}from"./@vue-Sgq8mdZ5.js";import{E as He,D as se,a as oe}from"./prosemirror-view-BtjlLnuq.js";import{d as Ie}from"./prosemirror-dropcursor-0ZiixSQi.js";import{g as Be}from"./prosemirror-gapcursor-DkKd42oZ.js";import{u as Re,r as Ne,h as _e}from"./prosemirror-history--ABMEIV0.js";import{r as qt,f as ie,t as De,a as je}from"./linkifyjs-CkylhtGF.js";import{k as Fe}from"./prosemirror-keymap-CSJ3vuZO.js";import{F as tt,S as ze,a as ae,D as bt,b as le,N as Ke}from"./prosemirror-model-Cj-E63TS.js";import{T as qe,f as We,c as Lt,l as Ve,j as ce,a as et,R as Ue,b as Ge}from"./prosemirror-transform-pzx0UxE8.js";import{c as Je,d as Ye,e as Qe,j as Xe,a as Ze,b as tn,f as en,g as nn,h as rn,l as sn,i as on,n as an,s as ln,k as cn,m as dn,o as un,p as pn,q as Wt,w as fn}from"./prosemirror-commands-CVeR_z2l.js";import{l as hn,s as mn,w as gn}from"./prosemirror-schema-list-B2oCB6Ze.js";import{c as yn}from"./zeed-dom-CGlyyIGP.js";function ct(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}class dt{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:n,state:r}=this,{view:s}=n,{tr:i}=r,o=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([a,l])=>[a,(...u)=>{const d=l(...u)(o);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,a=[],l=!!t,c=t||i.tr,u=()=>(!l&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),a.every(p=>p===!0)),d={...Object.fromEntries(Object.entries(r).map(([p,f])=>[p,(...g)=>{const y=this.buildProps(c,n),m=f(...g)(y);return a.push(m),d}])),run:u};return d}createCan(t){const{rawCommands:n,state:r}=this,s=!1,i=t||r.tr,o=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(n).map(([l,c])=>[l,(...u)=>c(...u)({...o,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}buildProps(t,n=!0){const{rawCommands:r,editor:s,state:i}=this,{view:o}=s,a={tr:t,editor:s,view:o,state:ct({state:i,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t,n),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)(a)]))}};return a}}class vn{constructor(){this.callbacks={}}on(t,n){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(n),this}emit(t,...n){const r=this.callbacks[t];return r&&r.forEach(s=>s.apply(this,n)),this}off(t,n){const r=this.callbacks[t];return r&&(n?this.callbacks[t]=r.filter(s=>s!==n):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}function b(e,t,n){return e.config[t]===void 0&&e.parent?b(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?b(e.parent,t,n):null}):e.config[t]}function ut(e){const t=e.filter(s=>s.type==="extension"),n=e.filter(s=>s.type==="node"),r=e.filter(s=>s.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:r}}function de(e){const t=[],{nodeExtensions:n,markExtensions:r}=ut(e),s=[...n,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage,extensions:s},l=b(o,"addGlobalAttributes",a);if(!l)return;l().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([p,f])=>{t.push({type:d,name:p,attribute:{...i,...f}})})})})}),s.forEach(o=>{const a={name:o.name,options:o.options,storage:o.storage},l=b(o,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([u,d])=>{const p={...i,...d};typeof(p==null?void 0:p.default)=="function"&&(p.default=p.default()),p!=null&&p.isRequired&&(p==null?void 0:p.default)===void 0&&delete p.default,t.push({type:o.name,name:u,attribute:p})})}),t}function A(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function C(...e){return e.filter(t=>!!t).reduce((t,n)=>{const r={...t};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const a=i?i.split(" "):[],l=r[s]?r[s].split(" "):[],c=a.filter(u=>!l.includes(u));r[s]=[...l,...c].join(" ")}else if(s==="style"){const a=i?i.split(";").map(u=>u.trim()).filter(Boolean):[],l=r[s]?r[s].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{const[d,p]=u.split(":").map(f=>f.trim());c.set(d,p)}),a.forEach(u=>{const[d,p]=u.split(":").map(f=>f.trim());c.set(d,p)}),r[s]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[s]=i}),r},{})}function St(e,t){return t.filter(n=>n.type===e.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(e.attrs)||{}:{[n.name]:e.attrs[n.name]}).reduce((n,r)=>C(n,r),{})}function ue(e){return typeof e=="function"}function k(e,t=void 0,...n){return ue(e)?t?e.bind(t)(...n):e(...n):e}function bn(e={}){return Object.keys(e).length===0&&e.constructor===Object}function kn(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function Vt(e,t){return"style"in e?e:{...e,getAttrs:n=>{const r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;const s=t.reduce((i,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(n):kn(n.getAttribute(o.name));return a==null?i:{...i,[o.name]:a}},{});return{...r,...s}}}}function Ut(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>t==="attrs"&&bn(n)?!1:n!=null))}function pe(e,t){var n;const r=de(e),{nodeExtensions:s,markExtensions:i}=ut(e),o=(n=s.find(c=>b(c,"topNode")))===null||n===void 0?void 0:n.name,a=Object.fromEntries(s.map(c=>{const u=r.filter(m=>m.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:t},p=e.reduce((m,v)=>{const M=b(v,"extendNodeSchema",d);return{...m,...M?M(c):{}}},{}),f=Ut({...p,content:k(b(c,"content",d)),marks:k(b(c,"marks",d)),group:k(b(c,"group",d)),inline:k(b(c,"inline",d)),atom:k(b(c,"atom",d)),selectable:k(b(c,"selectable",d)),draggable:k(b(c,"draggable",d)),code:k(b(c,"code",d)),whitespace:k(b(c,"whitespace",d)),defining:k(b(c,"defining",d)),isolating:k(b(c,"isolating",d)),attrs:Object.fromEntries(u.map(m=>{var v;return[m.name,{default:(v=m==null?void 0:m.attribute)===null||v===void 0?void 0:v.default}]}))}),h=k(b(c,"parseHTML",d));h&&(f.parseDOM=h.map(m=>Vt(m,u)));const g=b(c,"renderHTML",d);g&&(f.toDOM=m=>g({node:m,HTMLAttributes:St(m,u)}));const y=b(c,"renderText",d);return y&&(f.toText=y),[c.name,f]})),l=Object.fromEntries(i.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:t},p=e.reduce((y,m)=>{const v=b(m,"extendMarkSchema",d);return{...y,...v?v(c):{}}},{}),f=Ut({...p,inclusive:k(b(c,"inclusive",d)),excludes:k(b(c,"excludes",d)),group:k(b(c,"group",d)),spanning:k(b(c,"spanning",d)),code:k(b(c,"code",d)),attrs:Object.fromEntries(u.map(y=>{var m;return[y.name,{default:(m=y==null?void 0:y.attribute)===null||m===void 0?void 0:m.default}]}))}),h=k(b(c,"parseHTML",d));h&&(f.parseDOM=h.map(y=>Vt(y,u)));const g=b(c,"renderHTML",d);return g&&(f.toDOM=y=>g({mark:y,HTMLAttributes:St(y,u)})),[c.name,f]}));return new ae({topNode:o,nodes:a,marks:l})}function kt(e,t){return t.nodes[e]||t.marks[e]||null}function Gt(e,t){return Array.isArray(t)?t.some(n=>(typeof n=="string"?n:n.name)===e.name):t}const Mn=(e,t=500)=>{let n="";const r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(s,i,o,a)=>{var l,c;const u=((c=(l=s.type.spec).toText)===null||c===void 0?void 0:c.call(l,{node:s,pos:i,parent:o,index:a}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),n};function $t(e){return Object.prototype.toString.call(e)==="[object RegExp]"}class pt{constructor(t){this.find=t.find,this.handler=t.handler}}const wn=(e,t)=>{if($t(t))return t.exec(e);const n=t(e);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Q(e){var t;const{editor:n,from:r,to:s,text:i,rules:o,plugin:a}=e,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||!((t=c.nodeBefore||c.nodeAfter)===null||t===void 0)&&t.marks.find(p=>p.type.spec.code))return!1;let u=!1;const d=Mn(c)+i;return o.forEach(p=>{if(u)return;const f=wn(d,p.find);if(!f)return;const h=l.state.tr,g=ct({state:l.state,transaction:h}),y={from:r-(f[0].length-i.length),to:s},{commands:m,chain:v,can:M}=new dt({editor:n,state:g});p.handler({state:g,range:y,match:f,commands:m,chain:v,can:M})===null||!h.steps.length||(h.setMeta(a,{transform:h,from:r,to:s,text:i}),l.dispatch(h),u=!0)}),u}function Sn(e){const{editor:t,rules:n}=e,r=new L({state:{init(){return null},apply(s,i){const o=s.getMeta(r);if(o)return o;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{const{from:c,text:u}=a,d=c+u.length;Q({editor:t,from:c,to:d,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,a){return Q({editor:t,from:i,to:o,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&Q({editor:t,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?Q({editor:t,from:o.pos,to:o.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function xn(e){return Object.prototype.toString.call(e).slice(8,-1)}function X(e){return xn(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function ft(e,t){const n={...e};return X(e)&&X(t)&&Object.keys(t).forEach(r=>{X(t[r])&&X(e[r])?n[r]=ft(e[r],t[r]):n[r]=t[r]}),n}class R{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=k(b(this,"addOptions",{name:this.name}))),this.storage=k(b(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new R(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>ft(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new R(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=k(b(n,"addOptions",{name:n.name})),n.storage=k(b(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:r}=t.state,s=t.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const l=o.find(c=>(c==null?void 0:c.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",s.pos),t.view.dispatch(r),!0}return!1}}function Tn(e){return typeof e=="number"}class Cn{constructor(t){this.find=t.find,this.handler=t.handler}}const En=(e,t,n)=>{if($t(t))return[...e.matchAll(t)];const r=t(e,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=e,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function An(e){const{editor:t,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:a}=e,{commands:l,chain:c,can:u}=new dt({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,s,(f,h)=>{if(!f.isTextblock||f.type.spec.code)return;const g=Math.max(r,h),y=Math.min(s,h+f.content.size),m=f.textBetween(g-h,y-h,void 0,"￼");En(m,i.find,o).forEach(M=>{if(M.index===void 0)return;const S=g+M.index+1,T=S+M[0].length,w={from:n.tr.mapping.map(S),to:n.tr.mapping.map(T)},E=i.handler({state:n,range:w,match:M,commands:l,chain:c,can:u,pasteEvent:o,dropEvent:a});d.push(E)})}),d.every(f=>f!==null)}const Pn=e=>{var t;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=n.clipboardData)===null||t===void 0||t.setData("text/html",e),n};function On(e){const{editor:t,rules:n}=e;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a=typeof DragEvent<"u"?new DragEvent("drop"):null;const l=({state:u,from:d,to:p,rule:f,pasteEvt:h})=>{const g=u.tr,y=ct({state:u,transaction:g});if(!(!An({editor:t,state:y,from:Math.max(d-1,0),to:p.b-1,rule:f,pasteEvent:h,dropEvent:a})||!g.steps.length))return a=typeof DragEvent<"u"?new DragEvent("drop"):null,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g};return n.map(u=>new L({view(d){const p=f=>{var h;r=!((h=d.dom.parentElement)===null||h===void 0)&&h.contains(f.target)?d.dom.parentElement:null};return window.addEventListener("dragstart",p),{destroy(){window.removeEventListener("dragstart",p)}}},props:{handleDOMEvents:{drop:(d,p)=>(i=r===d.dom.parentElement,a=p,!1),paste:(d,p)=>{var f;const h=(f=p.clipboardData)===null||f===void 0?void 0:f.getData("text/html");return o=p,s=!!(h!=null&&h.includes("data-pm-slice")),!1}}},appendTransaction:(d,p,f)=>{const h=d[0],g=h.getMeta("uiEvent")==="paste"&&!s,y=h.getMeta("uiEvent")==="drop"&&!i,m=h.getMeta("applyPasteRules"),v=!!m;if(!g&&!y&&!v)return;if(v){const{from:T,text:w}=m,E=T+w.length,O=Pn(w);return l({rule:u,state:f,from:T,to:{b:E},pasteEvt:O})}const M=p.doc.content.findDiffStart(f.doc.content),S=p.doc.content.findDiffEnd(f.doc.content);if(!(!Tn(M)||!S||M===S.b))return l({rule:u,state:f,from:M,to:S,pasteEvt:o})}}))}function Ln(e){const t=e.filter((n,r)=>e.indexOf(n)!==r);return Array.from(new Set(t))}class j{constructor(t,n){this.splittableMarks=[],this.editor=n,this.extensions=j.resolve(t),this.schema=pe(this.extensions,n),this.setupExtensions()}static resolve(t){const n=j.sort(j.flatten(t)),r=Ln(n.map(s=>s.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),n}static flatten(t){return t.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},s=b(n,"addExtensions",r);return s?[n,...this.flatten(s())]:n}).flat(10)}static sort(t){return t.sort((r,s)=>{const i=b(r,"priority")||100,o=b(s,"priority")||100;return i>o?-1:i<o?1:0})}get commands(){return this.extensions.reduce((t,n)=>{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:kt(n.name,this.schema)},s=b(n,"addCommands",r);return s?{...t,...s()}:t},{})}get plugins(){const{editor:t}=this,n=j.sort([...this.extensions].reverse()),r=[],s=[],i=n.map(o=>{const a={name:o.name,options:o.options,storage:o.storage,editor:t,type:kt(o.name,this.schema)},l=[],c=b(o,"addKeyboardShortcuts",a);let u={};if(o.type==="mark"&&b(o,"exitable",a)&&(u.ArrowRight=()=>R.handleExit({editor:t,mark:o})),c){const g=Object.fromEntries(Object.entries(c()).map(([y,m])=>[y,()=>m({editor:t})]));u={...u,...g}}const d=Fe(u);l.push(d);const p=b(o,"addInputRules",a);Gt(o,t.options.enableInputRules)&&p&&r.push(...p());const f=b(o,"addPasteRules",a);Gt(o,t.options.enablePasteRules)&&f&&s.push(...f());const h=b(o,"addProseMirrorPlugins",a);if(h){const g=h();l.push(...g)}return l}).flat();return[Sn({editor:t,rules:r}),...On({editor:t,rules:s}),...i]}get attributes(){return de(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:n}=ut(this.extensions);return Object.fromEntries(n.filter(r=>!!b(r,"addNodeView")).map(r=>{const s=this.attributes.filter(l=>l.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:t,type:A(r.name,this.schema)},o=b(r,"addNodeView",i);if(!o)return[];const a=(l,c,u,d,p)=>{const f=St(l,s);return o()({node:l,view:c,getPos:u,decorations:d,innerDecorations:p,editor:t,extension:r,HTMLAttributes:f})};return[r.name,a]}))}setupExtensions(){this.extensions.forEach(t=>{var n;this.editor.extensionStorage[t.name]=t.storage;const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:kt(t.name,this.schema)};t.type==="mark"&&(!((n=k(b(t,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(t.name);const s=b(t,"onBeforeCreate",r),i=b(t,"onCreate",r),o=b(t,"onUpdate",r),a=b(t,"onSelectionUpdate",r),l=b(t,"onTransaction",r),c=b(t,"onFocus",r),u=b(t,"onBlur",r),d=b(t,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}}class P{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=k(b(this,"addOptions",{name:this.name}))),this.storage=k(b(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new P(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>ft(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new P({...this.config,...t});return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=k(b(n,"addOptions",{name:n.name})),n.storage=k(b(n,"addStorage",{name:n.name,options:n.options})),n}}function fe(e,t,n){const{from:r,to:s}=t,{blockSeparator:i=`

`,textSerializers:o={}}=n||{};let a="";return e.nodesBetween(r,s,(l,c,u,d)=>{var p;l.isBlock&&c>r&&(a+=i);const f=o==null?void 0:o[l.type.name];if(f)return u&&(a+=f({node:l,pos:c,parent:u,index:d,range:t})),!1;l.isText&&(a+=(p=l==null?void 0:l.text)===null||p===void 0?void 0:p.slice(Math.max(r,c)-c,s-c))}),a}function he(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}const $n=P.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new L({key:new H("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:s}=t,{ranges:i}=s,o=Math.min(...i.map(u=>u.$from.pos)),a=Math.max(...i.map(u=>u.$to.pos)),l=he(n);return fe(r,{from:o,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),Hn=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),In=(e=!1)=>({commands:t})=>t.setContent("",e),Bn=()=>({state:e,tr:t,dispatch:n})=>{const{selection:r}=t,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{e.doc.nodesBetween(i.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:u}=t,d=c.resolve(u.map(l)),p=c.resolve(u.map(l+a.nodeSize)),f=d.blockRange(p);if(!f)return;const h=Ve(f);if(a.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());t.setNodeMarkup(f.start,g)}(h||h===0)&&t.lift(f,h)})}),!0},Rn=e=>t=>e(t),Nn=()=>({state:e,dispatch:t})=>Je(e,t),_n=(e,t)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);const o=r.mapping.map(t);return r.insert(o,i.content),r.setSelection(new I(r.doc.resolve(o-1))),!0},Dn=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;const s=e.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(t){const a=s.before(i),l=s.after(i);e.delete(a,l).scrollIntoView()}return!0}return!1},jn=e=>({tr:t,state:n,dispatch:r})=>{const s=A(e,n.schema),i=t.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const l=i.before(o),c=i.after(o);t.delete(l,c).scrollIntoView()}return!0}return!1},Fn=e=>({tr:t,dispatch:n})=>{const{from:r,to:s}=e;return n&&t.delete(r,s),!0},zn=()=>({state:e,dispatch:t})=>Ye(e,t),Kn=()=>({commands:e})=>e.keyboardShortcut("Enter"),qn=()=>({state:e,dispatch:t})=>Qe(e,t);function rt(e,t,n={strict:!0}){const r=Object.keys(t);return r.length?r.every(s=>n.strict?t[s]===e[s]:$t(t[s])?t[s].test(e[s]):t[s]===e[s]):!0}function xt(e,t,n={}){return e.find(r=>r.type===t&&rt(r.attrs,n))}function Wn(e,t,n={}){return!!xt(e,t,n)}function Ht(e,t,n={}){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(e.parentOffset===r.offset&&r.offset!==0&&(r=e.parent.childBefore(e.parentOffset)),!r.node)return;const s=xt([...r.node.marks],t,n);if(!s)return;let i=r.index,o=e.start()+r.offset,a=i+1,l=o+r.node.nodeSize;for(xt([...r.node.marks],t,n);i>0&&s.isInSet(e.parent.child(i-1).marks);)i-=1,o-=e.parent.child(i).nodeSize;for(;a<e.parent.childCount&&Wn([...e.parent.child(a).marks],t,n);)l+=e.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function _(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const Vn=(e,t={})=>({tr:n,state:r,dispatch:s})=>{const i=_(e,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:u}=a;if(s){const d=Ht(l,i,t);if(d&&d.from<=c&&d.to>=u){const p=I.create(o,d.from,d.to);n.setSelection(p)}}return!0},Un=e=>t=>{const n=typeof e=="function"?e(t):e;for(let r=0;r<n.length;r+=1)if(n[r](t))return!0;return!1};function It(e){return e instanceof I}function N(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function me(e,t=null){if(!t)return null;const n=F.atStart(e),r=F.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return r;const s=n.from,i=r.to;return t==="all"?I.create(e,N(0,s,i),N(e.content.size,s,i)):I.create(e,N(t,s,i),N(t,s,i))}function Bt(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Gn=(e=null,t={})=>({editor:n,view:r,tr:s,dispatch:i})=>{t={scrollIntoView:!0,...t};const o=()=>{Bt()&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t!=null&&t.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&e===null||e===!1)return!0;if(i&&e===null&&!It(n.state.selection))return o(),!0;const a=me(s.doc,e)||n.state.selection,l=n.state.selection.eq(a);return i&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},Jn=(e,t)=>n=>e.every((r,s)=>t(r,{...n,index:s})),Yn=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),ge=e=>{const t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){const r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&ge(r)}return e};function Z(e){const t=`<body>${e}</body>`,n=new window.DOMParser().parseFromString(t,"text/html").body;return ge(n)}function st(e,t,n){n={slice:!0,parseOptions:{},...n};const r=typeof e=="object"&&e!==null,s=typeof e=="string";if(r)try{if(Array.isArray(e)&&e.length>0)return tt.fromArray(e.map(a=>t.nodeFromJSON(a)));const o=t.nodeFromJSON(e);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",i),st("",t,n)}if(s){if(n.errorOnInvalidContent){let o=!1,a="";const l=new ae({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?bt.fromSchema(l).parseSlice(Z(e),n.parseOptions):bt.fromSchema(l).parse(Z(e),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const i=bt.fromSchema(t);return n.slice?i.parseSlice(Z(e),n.parseOptions).content:i.parse(Z(e),n.parseOptions)}return st("",t,n)}function Qn(e,t,n){const r=e.steps.length-1;if(r<t)return;const s=e.steps[r];if(!(s instanceof Ue||s instanceof Ge))return;const i=e.mapping.maps[r];let o=0;i.forEach((a,l,c,u)=>{o===0&&(o=u)}),e.setSelection(F.near(e.doc.resolve(o),n))}const Xn=e=>!("type"in e),Zn=(e,t,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;try{a=st(t,i.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions},errorOnInvalidContent:(o=n.errorOnInvalidContent)!==null&&o!==void 0?o:i.options.enableContentCheck})}catch(h){return i.emit("contentError",{editor:i,error:h,disableCollaboration:()=>{console.error("[tiptap error]: Unable to disable collaboration at this point in time")}}),!1}let{from:l,to:c}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((Xn(a)?a:[a]).forEach(h=>{h.check(),u=u?h.isText&&h.marks.length===0:!1,d=d?h.isBlock:!1}),l===c&&d){const{parent:h}=r.doc.resolve(l);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(l-=1,c+=1)}let f;u?(Array.isArray(t)?f=t.map(h=>h.text||"").join(""):typeof t=="object"&&t&&t.text?f=t.text:f=t,r.insertText(f,l,c)):(f=a,r.replaceWith(l,c,f)),n.updateSelection&&Qn(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:f}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:f})}return!0},tr=()=>({state:e,dispatch:t})=>Xe(e,t),er=()=>({state:e,dispatch:t})=>Ze(e,t),nr=()=>({state:e,dispatch:t})=>tn(e,t),rr=()=>({state:e,dispatch:t})=>en(e,t),sr=()=>({state:e,dispatch:t,tr:n})=>{try{const r=ce(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},or=()=>({state:e,dispatch:t,tr:n})=>{try{const r=ce(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},ir=()=>({state:e,dispatch:t})=>nn(e,t),ar=()=>({state:e,dispatch:t})=>rn(e,t);function ye(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function lr(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let a=0;a<t.length-1;a+=1){const l=t[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))Bt()||ye()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}const cr=e=>({editor:t,view:n,tr:r,dispatch:s})=>{const i=lr(e).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l==null||l.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function G(e,t,n={}){const{from:r,to:s,empty:i}=e.selection,o=t?A(t,e.schema):null,a=[];e.doc.nodesBetween(r,s,(d,p)=>{if(d.isText)return;const f=Math.max(r,p),h=Math.min(s,p+d.nodeSize);a.push({node:d,from:f,to:h})});const l=s-r,c=a.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>rt(d.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((d,p)=>d+p.to-p.from,0)>=l}const dr=(e,t={})=>({state:n,dispatch:r})=>{const s=A(e,n.schema);return G(n,s,t)?sn(n,r):!1},ur=()=>({state:e,dispatch:t})=>on(e,t),pr=e=>({state:t,dispatch:n})=>{const r=A(e,t.schema);return hn(r)(t,n)},fr=()=>({state:e,dispatch:t})=>an(e,t);function ht(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Jt(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((r,s)=>(n.includes(s)||(r[s]=e[s]),r),{})}const hr=(e,t)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const a=ht(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(i=A(e,r.schema)),a==="mark"&&(o=_(e,r.schema)),s&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,u)=>{i&&i===c.type&&n.setNodeMarkup(u,void 0,Jt(c.attrs,t)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&n.addMark(u,u+c.nodeSize,o.create(Jt(d.attrs,t)))})})}),!0):!1},mr=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),gr=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),yr=()=>({state:e,dispatch:t})=>ln(e,t),vr=()=>({state:e,dispatch:t})=>cn(e,t),br=()=>({state:e,dispatch:t})=>dn(e,t),kr=()=>({state:e,dispatch:t})=>un(e,t),Mr=()=>({state:e,dispatch:t})=>pn(e,t);function Tt(e,t,n={},r={}){return st(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}const wr=(e,t=!1,n={},r={})=>({editor:s,tr:i,dispatch:o,commands:a})=>{var l,c;const{doc:u}=i;if(n.preserveWhitespace!=="full"){const d=Tt(e,s.schema,n,{errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:s.options.enableContentCheck});return o&&i.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!t),!0}return o&&i.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:u.content.size},e,{parseOptions:n,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:s.options.enableContentCheck})};function Rt(e,t){const n=_(t,e.schema),{from:r,to:s,empty:i}=e.selection,o=[];i?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,s,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function Sr(e,t){const n=new qe(e);return t.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function xr(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Tr(e,t,n){const r=[];return e.nodesBetween(t.from,t.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function Cr(e,t){for(let n=e.depth;n>0;n-=1){const r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function Nt(e){return t=>Cr(t.$from,e)}function Er(e,t){const n=le.fromSchema(t).serializeFragment(e),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Ar(e,t){const n=j.resolve(e);return pe(n,t)}function Pr(e,t){const n={from:0,to:e.content.size};return fe(e,n,t)}function Or(e,t){const n=A(t,e.schema),{from:r,to:s}=e.selection,i=[];e.doc.nodesBetween(r,s,a=>{i.push(a)});const o=i.reverse().find(a=>a.type.name===n.name);return o?{...o.attrs}:{}}function ve(e,t){const n=ht(typeof t=="string"?t:t.name,e.schema);return n==="node"?Or(e,t):n==="mark"?Rt(e,t):{}}function Lr(e,t=JSON.stringify){const n={};return e.filter(r=>{const s=t(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function $r(e){const t=Lr(e);return t.length===1?t:t.filter((n,r)=>!t.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Hr(e){const{mapping:t,steps:n}=e,r=[];return t.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((a,l)=>{o.push({from:a,to:l})});else{const{from:a,to:l}=n[i];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{const c=t.slice(i).map(a,-1),u=t.slice(i).map(l),d=t.invert().map(c,-1),p=t.invert().map(u);r.push({oldRange:{from:d,to:p},newRange:{from:c,to:u}})})}),$r(r)}function _t(e,t,n){const r=[];return e===t?n.resolve(e).marks().forEach(s=>{const i=n.resolve(e),o=Ht(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(e,t,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}function nt(e,t,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=e.find(i=>i.type===t&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}function Ct(e,t,n={}){const{empty:r,ranges:s}=e.selection,i=t?_(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>rt(d.attrs,n,{strict:!1}));let o=0;const a=[];if(s.forEach(({$from:d,$to:p})=>{const f=d.pos,h=p.pos;e.doc.nodesBetween(f,h,(g,y)=>{if(!g.isText&&!g.marks.length)return;const m=Math.max(f,y),v=Math.min(h,y+g.nodeSize),M=v-m;o+=M,a.push(...g.marks.map(S=>({mark:S,from:m,to:v})))})}),o===0)return!1;const l=a.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>rt(d.mark.attrs,n,{strict:!1})).reduce((d,p)=>d+p.to-p.from,0),c=a.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,p)=>d+p.to-p.from,0);return(l>0?l+c:l)>=o}function Ir(e,t,n={}){if(!t)return G(e,null,n)||Ct(e,null,n);const r=ht(t,e.schema);return r==="node"?G(e,t,n):r==="mark"?Ct(e,t,n):!1}function Yt(e,t){const{nodeExtensions:n}=ut(t),r=n.find(o=>o.name===e);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=k(b(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function mt(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(e.type.name==="hardBreak")return!0;if(e.isText)return/^\s*$/m.test((r=e.text)!==null&&r!==void 0?r:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let s=!0;return e.content.forEach(i=>{s!==!1&&(mt(i,{ignoreWhitespace:n,checkChildren:t})||(s=!1))}),s}return!1}function be(e){return e instanceof it}function ke(e,t,n){const s=e.state.doc.content.size,i=N(t,0,s),o=N(n,0,s),a=e.coordsAtPos(i),l=e.coordsAtPos(o,-1),c=Math.min(a.top,l.top),u=Math.max(a.bottom,l.bottom),d=Math.min(a.left,l.left),p=Math.max(a.right,l.right),f=p-d,h=u-c,m={top:c,bottom:u,left:d,right:p,width:f,height:h,x:d,y:c};return{...m,toJSON:()=>m}}function Br(e,t,n){var r;const{selection:s}=t;let i=null;if(It(s)&&(i=s.$cursor),i){const a=(r=e.storedMarks)!==null&&r!==void 0?r:i.marks();return!!n.isInSet(a)||!a.some(l=>l.type.excludes(n))}const{ranges:o}=s;return o.some(({$from:a,$to:l})=>{let c=a.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(a.pos,l.pos,(u,d,p)=>{if(c)return!1;if(u.isInline){const f=!p||p.type.allowsMarkType(n),h=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=f&&h}return!c}),c})}const Rr=(e,t={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:a}=i,l=_(e,r.schema);if(s)if(o){const c=Rt(r,l);n.addStoredMark(l.create({...c,...t}))}else a.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(p,f)=>{const h=Math.max(f,u),g=Math.min(f+p.nodeSize,d);p.marks.find(m=>m.type===l)?p.marks.forEach(m=>{l===m.type&&n.addMark(h,g,l.create({...m.attrs,...t}))}):n.addMark(h,g,l.create(t))})});return Br(r,n,l)},Nr=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),_r=(e,t={})=>({state:n,dispatch:r,chain:s})=>{const i=A(e,n.schema);return i.isTextblock?s().command(({commands:o})=>Wt(i,t)(n)?!0:o.clearNodes()).command(({state:o})=>Wt(i,t)(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Dr=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,s=N(e,0,r.content.size),i=it.create(r,s);t.setSelection(i)}return!0},jr=e=>({tr:t,dispatch:n})=>{if(n){const{doc:r}=t,{from:s,to:i}=typeof e=="number"?{from:e,to:e}:e,o=I.atStart(r).from,a=I.atEnd(r).to,l=N(s,o,a),c=N(i,o,a),u=I.create(r,l,c);t.setSelection(u)}return!0},Fr=e=>({state:t,dispatch:n})=>{const r=A(e,t.schema);return mn(r)(t,n)};function Qt(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const r=n.filter(s=>t==null?void 0:t.includes(s.type.name));e.tr.ensureMarks(r)}}const zr=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=t,{$from:a,$to:l}=i,c=s.extensionManager.attributes,u=nt(c,a.node().type.name,a.node().attrs);if(i instanceof it&&i.node.isBlock)return!a.parentOffset||!et(o,a.pos)?!1:(r&&(e&&Qt(n,s.extensionManager.splittableMarks),t.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,p=a.depth===0?void 0:xr(a.node(-1).contentMatchAt(a.indexAfter(-1)));let f=d&&p?[{type:p,attrs:u}]:void 0,h=et(t.doc,t.mapping.map(a.pos),1,f);if(!f&&!h&&et(t.doc,t.mapping.map(a.pos),1,p?[{type:p}]:void 0)&&(h=!0,f=p?[{type:p,attrs:u}]:void 0),r){if(h&&(i instanceof I&&t.deleteSelection(),t.split(t.mapping.map(a.pos),1,f),p&&!d&&!a.parentOffset&&a.parent.type!==p)){const g=t.mapping.map(a.before()),y=t.doc.resolve(g);a.node(-1).canReplaceWith(y.index(),y.index()+1,p)&&t.setNodeMarkup(t.mapping.map(a.before()),p)}e&&Qt(n,s.extensionManager.splittableMarks),t.scrollIntoView()}return h},Kr=(e,t={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const a=A(e,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const d=l.node(-1);if(d.type!==a)return!1;const p=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){let m=tt.empty;const v=l.index(-1)?1:l.index(-2)?2:3;for(let O=l.depth-v;O>=l.depth-3;O-=1)m=tt.from(l.node(O).copy(m));const M=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,S={...nt(p,l.node().type.name,l.node().attrs),...t},T=((o=a.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(S))||void 0;m=m.append(tt.from(a.createAndFill(null,T)||void 0));const w=l.before(l.depth-(v-1));n.replace(w,l.after(-M),new ze(m,4-v,0));let E=-1;n.doc.nodesBetween(w,n.doc.content.size,(O,x)=>{if(E>-1)return!1;O.isTextblock&&O.content.size===0&&(E=x+1)}),E>-1&&n.setSelection(I.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const f=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,h={...nt(p,d.type.name,d.attrs),...t},g={...nt(p,l.node().type.name,l.node().attrs),...t};n.delete(l.pos,c.pos);const y=f?[{type:a,attrs:h},{type:f,attrs:g}]:[{type:a,attrs:h}];if(!et(n.doc,l.pos,2))return!1;if(s){const{selection:m,storedMarks:v}=r,{splittableMarks:M}=i.extensionManager,S=v||m.$to.parentOffset&&m.$from.marks();if(n.split(l.pos,2,y).scrollIntoView(),!S||!s)return!0;const T=S.filter(w=>M.includes(w.type.name));n.ensureMarks(T)}return!0},Mt=(e,t)=>{const n=Nt(o=>o.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=e.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&Lt(e.doc,n.pos)&&e.join(n.pos),!0},wt=(e,t)=>{const n=Nt(o=>o.type===t)(e.selection);if(!n)return!0;const r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=e.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&Lt(e.doc,r)&&e.join(r),!0},qr=(e,t,n,r={})=>({editor:s,tr:i,state:o,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:d,splittableMarks:p}=s.extensionManager,f=A(e,o.schema),h=A(t,o.schema),{selection:g,storedMarks:y}=o,{$from:m,$to:v}=g,M=m.blockRange(v),S=y||g.$to.parentOffset&&g.$from.marks();if(!M)return!1;const T=Nt(w=>Yt(w.type.name,d))(g);if(M.depth>=1&&T&&M.depth-T.depth<=1){if(T.node.type===f)return c.liftListItem(h);if(Yt(T.node.type.name,d)&&f.validContent(T.node.content)&&a)return l().command(()=>(i.setNodeMarkup(T.pos,f),!0)).command(()=>Mt(i,f)).command(()=>wt(i,f)).run()}return!n||!S||!a?l().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>Mt(i,f)).command(()=>wt(i,f)).run():l().command(()=>{const w=u().wrapInList(f,r),E=S.filter(O=>p.includes(O.type.name));return i.ensureMarks(E),w?!0:c.clearNodes()}).wrapInList(f,r).command(()=>Mt(i,f)).command(()=>wt(i,f)).run()},Wr=(e,t={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=_(e,r.schema);return Ct(r,o,t)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,t)},Vr=(e,t,n={})=>({state:r,commands:s})=>{const i=A(e,r.schema),o=A(t,r.schema),a=G(r,i,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?s.setNode(o,l):s.setNode(i,{...l,...n})},Ur=(e,t={})=>({state:n,commands:r})=>{const s=A(e,n.schema);return G(n,s,t)?r.lift(s):r.wrapIn(s,t)},Gr=()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(e))){if(t){const o=e.tr,a=i.transform;for(let l=a.steps.length-1;l>=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(i.text){const l=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,e.schema.text(i.text,l))}else o.delete(i.from,i.to)}return!0}}return!1},Jr=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:r,ranges:s}=n;return r||t&&s.forEach(i=>{e.removeMark(i.$from.pos,i.$to.pos)}),!0},Yr=(e,t={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=t,{selection:a}=n,l=_(e,r.schema),{$from:c,empty:u,ranges:d}=a;if(!s)return!0;if(u&&o){let{from:p,to:f}=a;const h=(i=c.marks().find(y=>y.type===l))===null||i===void 0?void 0:i.attrs,g=Ht(c,l,h);g&&(p=g.from,f=g.to),n.removeMark(p,f,l)}else d.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,l)});return n.removeStoredMark(l),!0},Qr=(e,t={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const a=ht(typeof e=="string"?e:e.name,r.schema);return a?(a==="node"&&(i=A(e,r.schema)),a==="mark"&&(o=_(e,r.schema)),s&&n.selection.ranges.forEach(l=>{const c=l.$from.pos,u=l.$to.pos;r.doc.nodesBetween(c,u,(d,p)=>{i&&i===d.type&&n.setNodeMarkup(p,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(f=>{if(o===f.type){const h=Math.max(p,c),g=Math.min(p+d.nodeSize,u);n.addMark(h,g,o.create({...f.attrs,...t}))}})})}),!0):!1},Xr=(e,t={})=>({state:n,dispatch:r})=>{const s=A(e,n.schema);return fn(s,t)(n,r)},Zr=(e,t={})=>({state:n,dispatch:r})=>{const s=A(e,n.schema);return gn(s,t)(n,r)};var ts=Object.freeze({__proto__:null,blur:Hn,clearContent:In,clearNodes:Bn,command:Rn,createParagraphNear:Nn,cut:_n,deleteCurrentNode:Dn,deleteNode:jn,deleteRange:Fn,deleteSelection:zn,enter:Kn,exitCode:qn,extendMarkRange:Vn,first:Un,focus:Gn,forEach:Jn,insertContent:Yn,insertContentAt:Zn,joinBackward:nr,joinDown:er,joinForward:rr,joinItemBackward:sr,joinItemForward:or,joinTextblockBackward:ir,joinTextblockForward:ar,joinUp:tr,keyboardShortcut:cr,lift:dr,liftEmptyBlock:ur,liftListItem:pr,newlineInCode:fr,resetAttributes:hr,scrollIntoView:mr,selectAll:gr,selectNodeBackward:yr,selectNodeForward:vr,selectParentNode:br,selectTextblockEnd:kr,selectTextblockStart:Mr,setContent:wr,setMark:Rr,setMeta:Nr,setNode:_r,setNodeSelection:Dr,setTextSelection:jr,sinkListItem:Fr,splitBlock:zr,splitListItem:Kr,toggleList:qr,toggleMark:Wr,toggleNode:Vr,toggleWrap:Ur,undoInputRule:Gr,unsetAllMarks:Jr,unsetMark:Yr,updateAttributes:Qr,wrapIn:Xr,wrapInList:Zr});const es=P.create({name:"commands",addCommands(){return{...ts}}}),ns=P.create({name:"drop",addProseMirrorPlugins(){return[new L({key:new H("tiptapDrop"),props:{handleDrop:(e,t,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),rs=P.create({name:"editable",addProseMirrorPlugins(){return[new L({key:new H("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ss=P.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new L({key:new H("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const r=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;const r=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(r),!1}}}})]}}),os=P.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:u,$anchor:d}=l,{pos:p,parent:f}=d,h=d.parent.isTextblock&&p>0?a.doc.resolve(p-1):d,g=h.parent.type.spec.isolating,y=d.pos-d.parentOffset,m=g&&h.parent.childCount===1?y===d.pos:F.atStart(c).from===p;return!u||!f.type.isTextblock||f.textContent.length||!m||m&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Bt()||ye()?i:s},addProseMirrorPlugins(){return[new L({key:new H("clearDocument"),appendTransaction:(e,t,n)=>{const r=e.some(g=>g.docChanged)&&!t.doc.eq(n.doc),s=e.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:a}=t.selection,l=F.atStart(t.doc).from,c=F.atEnd(t.doc).to;if(i||!(o===l&&a===c)||!mt(n.doc))return;const p=n.tr,f=ct({state:n,transaction:p}),{commands:h}=new dt({editor:this.editor,state:f});if(h.clearNodes(),!!p.steps.length)return p}})]}}),is=P.create({name:"paste",addProseMirrorPlugins(){return[new L({key:new H("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),as=P.create({name:"tabindex",addProseMirrorPlugins(){return[new L({key:new H("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class D{get name(){return this.node.type.name}constructor(t,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=t,this.editor=n,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!==null&&t!==void 0?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new D(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new D(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new D(t,this.editor)}get children(){const t=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=this.pos+r+1,o=this.resolvedPos.doc.resolve(i);if(!s&&o.depth<=this.depth)return;const a=new D(o,this.editor,s,s?n:null);s&&(a.actualDepth=this.depth+1),t.push(new D(o,this.editor,s,s?n:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===t)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let a=0;a<o.length;a+=1){const l=o[a];if(i[l]!==n[l])break}}else r=s;s=s.parent}return r}querySelector(t,n={}){return this.querySelectorAll(t,n,!0)[0]||null}querySelectorAll(t,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===t&&i.every(l=>n[l]===o.node.attrs[l])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(t,n,r))))}),s}setAttribute(t){const n=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,t).setTextSelection(n.from).run()}}const ls=`.ProseMirror {
  position: relative;
}

.ProseMirror {
  word-wrap: break-word;
  white-space: pre-wrap;
  white-space: break-spaces;
  -webkit-font-variant-ligatures: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
}

.ProseMirror [contenteditable="false"] {
  white-space: normal;
}

.ProseMirror [contenteditable="false"] [contenteditable="true"] {
  white-space: pre-wrap;
}

.ProseMirror pre {
  white-space: pre-wrap;
}

img.ProseMirror-separator {
  display: inline !important;
  border: none !important;
  margin: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

.ProseMirror-gapcursor {
  display: none;
  pointer-events: none;
  position: absolute;
  margin: 0;
}

.ProseMirror-gapcursor:after {
  content: "";
  display: block;
  position: absolute;
  top: -2px;
  width: 20px;
  border-top: 1px solid black;
  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}

@keyframes ProseMirror-cursor-blink {
  to {
    visibility: hidden;
  }
}

.ProseMirror-hideselection *::selection {
  background: transparent;
}

.ProseMirror-hideselection *::-moz-selection {
  background: transparent;
}

.ProseMirror-hideselection * {
  caret-color: transparent;
}

.ProseMirror-focused .ProseMirror-gapcursor {
  display: block;
}

.tippy-box[data-animation=fade][data-state=hidden] {
  opacity: 0
}`;function cs(e,t,n){const r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;const s=document.createElement("style");return t&&s.setAttribute("nonce",t),s.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),s.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(s),s}let ds=class extends vn{constructor(t={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:s})=>this.options.onDrop(n,r,s)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=cs(ls,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,n=!0){this.setOptions({editable:t}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,n){const r=ue(n)?n(t,[...this.state.plugins]):[...this.state.plugins,t],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(t){if(this.isDestroyed)return;const n=typeof t=="string"?`${t}$`:t.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(s=>!s.key.startsWith(n))});return this.view.updateState(r),r}createExtensionManager(){var t,n;const s=[...this.options.enableCoreExtensions?[rs,$n.configure({blockSeparator:(n=(t=this.options.coreExtensionOptions)===null||t===void 0?void 0:t.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),es,ss,os,as,ns,is].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new j(s,this)}createCommandManager(){this.commandManager=new dt({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){let t;try{t=Tt(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(i){if(!(i instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(i.message))throw i;this.emit("contentError",{editor:this,error:i,disableCollaboration:()=>{this.options.extensions=this.options.extensions.filter(o=>o.name!=="collaboration"),this.createExtensionManager()}}),t=Tt(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=me(t,this.options.autofocus);this.view=new He(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:Te.create({doc:t,selection:n||void 0})});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(o=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(o)});return}const n=this.state.apply(t),r=!this.state.selection.eq(n.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:n}),this.view.updateState(n),this.emit("transaction",{editor:this,transaction:t}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const s=t.getMeta("focus"),i=t.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:t}),i&&this.emit("blur",{editor:this,event:i.event,transaction:t}),!(!t.docChanged||t.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return ve(this.state,t)}isActive(t,n){const r=typeof t=="string"?t:null,s=typeof t=="string"?n:t;return Ir(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Er(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:n=`

`,textSerializers:r={}}=t||{};return Pr(this.state.doc,{blockSeparator:n,textSerializers:{...he(this.schema),...r}})}get isEmpty(){return mt(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const t=this.view.dom;t&&t.editor&&delete t.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var t;return!(!((t=this.view)===null||t===void 0)&&t.docView)}$node(t,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(t,n))||null}$nodes(t,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(t,n))||null}$pos(t){const n=this.state.doc.resolve(t);return new D(n,this)}get $doc(){return this.$pos(0)}};function q(e){return new pt({find:e.find,handler:({state:t,range:n,match:r})=>{const s=k(e.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=t,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),c=n.from+a.indexOf(o),u=c+o.length;if(_t(n.from,n.to,t.doc).filter(f=>f.mark.type.excluded.find(g=>g===e.type&&g!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+l,c);const p=n.from+l+o.length;i.addMark(n.from+l,p,e.type.create(s||{})),i.removeStoredMark(e.type)}}})}function Me(e){return new pt({find:e.find,handler:({state:t,range:n,match:r})=>{const s=k(e.getAttributes,void 0,r)||{},{tr:i}=t,o=n.from;let a=n.to;const l=e.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>a?u=a:a=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,o+r[0].length-1),i.replaceWith(u,a,l)}else if(r[0]){const c=e.type.isInline?o:o-1;i.insert(c,e.type.create(s)).delete(i.mapping.map(o),i.mapping.map(a))}i.scrollIntoView()}})}function Et(e){return new pt({find:e.find,handler:({state:t,range:n,match:r})=>{const s=t.doc.resolve(n.from),i=k(e.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,i)}})}function J(e){return new pt({find:e.find,handler:({state:t,range:n,match:r,chain:s})=>{const i=k(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),l=o.doc.resolve(n.from).blockRange(),c=l&&We(l,e.type,i);if(!c)return null;if(o.wrap(l,c),e.keepMarks&&e.editor){const{selection:d,storedMarks:p}=t,{splittableMarks:f}=e.editor.extensionManager,h=p||d.$to.parentOffset&&d.$from.marks();if(h){const g=h.filter(y=>f.includes(y.type.name));o.ensureMarks(g)}}if(e.keepAttributes){const d=e.type.name==="bulletList"||e.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,i).run()}const u=o.doc.resolve(n.from-1).nodeBefore;u&&u.type===e.type&&Lt(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,u))&&o.join(n.from-1)}})}class ${constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=k(b(this,"addOptions",{name:this.name}))),this.storage=k(b(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new $(t)}configure(t={}){const n=this.extend({...this.config,addOptions:()=>ft(this.options,t)});return n.name=this.name,n.parent=this.parent,n}extend(t={}){const n=new $(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=k(b(n,"addOptions",{name:n.name})),n.storage=k(b(n,"addStorage",{name:n.name,options:n.options})),n}}function z(e){return new Cn({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:s})=>{const i=k(e.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=t,a=r[r.length-1],l=r[0];let c=n.to;if(a){const u=l.search(/\S/),d=n.from+l.indexOf(a),p=d+a.length;if(_t(n.from,n.to,t.doc).filter(h=>h.mark.type.excluded.find(y=>y===e.type&&y!==h.mark.type)).filter(h=>h.to>d).length)return null;p<n.to&&o.delete(p,n.to),d>n.from&&o.delete(n.from+u,d),c=n.from+u+a.length,o.addMark(n.from+u,c,e.type.create(i||{})),o.removeStoredMark(e.type)}}})}function us(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}class ps{constructor({editor:t,element:n,view:r,tippyOptions:s={},updateDelay:i=250,shouldShow:o}){this.preventHide=!1,this.shouldShow=({view:a,state:l,from:c,to:u})=>{const{doc:d,selection:p}=l,{empty:f}=p,h=!d.textBetween(c,u).length&&It(l.selection),g=this.element.contains(document.activeElement);return!(!(a.hasFocus()||g)||f||h||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:a})=>{var l;if(this.preventHide){this.preventHide=!1;return}a!=null&&a.relatedTarget&&(!((l=this.element.parentNode)===null||l===void 0)&&l.contains(a.relatedTarget))||this.hide()},this.tippyBlurHandler=a=>{this.blurHandler({event:a})},this.handleDebouncedUpdate=(a,l)=>{const c=!(l!=null&&l.selection.eq(a.state.selection)),u=!(l!=null&&l.doc.eq(a.state.doc));!c&&!u||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(a,c,u,l)},this.updateDelay))},this.updateHandler=(a,l,c,u)=>{var d,p,f;const{state:h,composing:g}=a,{selection:y}=h;if(g||!l&&!c)return;this.createTooltip();const{ranges:v}=y,M=Math.min(...v.map(w=>w.$from.pos)),S=Math.max(...v.map(w=>w.$to.pos));if(!((d=this.shouldShow)===null||d===void 0?void 0:d.call(this,{editor:this.editor,view:a,state:h,oldState:u,from:M,to:S}))){this.hide();return}(p=this.tippy)===null||p===void 0||p.setProps({getReferenceClientRect:((f=this.tippyOptions)===null||f===void 0?void 0:f.getReferenceClientRect)||(()=>{if(be(h.selection)){let w=a.nodeDOM(M);const E=w.dataset.nodeViewWrapper?w:w.querySelector("[data-node-view-wrapper]");if(E&&(w=E.firstChild),w)return w.getBoundingClientRect()}return ke(a,M,S)})}),this.show()},this.editor=t,this.element=n,this.view=r,this.updateDelay=i,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=s,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:t}=this.editor.options,n=!!t.parentElement;this.tippy||!n||(this.tippy=ne(t,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(t,n){const{state:r}=t,s=r.selection.from!==r.selection.to;if(this.updateDelay>0&&s){this.handleDebouncedUpdate(t,n);return}const i=!(n!=null&&n.selection.eq(t.state.selection)),o=!(n!=null&&n.doc.eq(t.state.doc));this.updateHandler(t,i,o,n)}show(){var t;(t=this.tippy)===null||t===void 0||t.show()}hide(){var t;(t=this.tippy)===null||t===void 0||t.hide()}destroy(){var t,n;!((t=this.tippy)===null||t===void 0)&&t.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(n=this.tippy)===null||n===void 0||n.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const we=e=>new L({key:typeof e.pluginKey=="string"?new H(e.pluginKey):e.pluginKey,view:t=>new ps({view:t,...e})});P.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[we({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});class fs{constructor({editor:t,element:n,view:r,tippyOptions:s={},shouldShow:i}){this.preventHide=!1,this.shouldShow=({view:o,state:a})=>{const{selection:l}=a,{$anchor:c,empty:u}=l,d=c.depth===1,p=c.parent.isTextblock&&!c.parent.type.spec.code&&!c.parent.textContent;return!(!o.hasFocus()||!u||!d||!p||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:o})=>{var a;if(this.preventHide){this.preventHide=!1;return}o!=null&&o.relatedTarget&&(!((a=this.element.parentNode)===null||a===void 0)&&a.contains(o.relatedTarget))||this.hide()},this.tippyBlurHandler=o=>{this.blurHandler({event:o})},this.editor=t,this.element=n,this.view=r,i&&(this.shouldShow=i),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=s,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:t}=this.editor.options,n=!!t.parentElement;this.tippy||!n||(this.tippy=ne(t,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"right",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(t,n){var r,s,i;const{state:o}=t,{doc:a,selection:l}=o,{from:c,to:u}=l;if(n&&n.doc.eq(a)&&n.selection.eq(l))return;if(this.createTooltip(),!((r=this.shouldShow)===null||r===void 0?void 0:r.call(this,{editor:this.editor,view:t,state:o,oldState:n}))){this.hide();return}(s=this.tippy)===null||s===void 0||s.setProps({getReferenceClientRect:((i=this.tippyOptions)===null||i===void 0?void 0:i.getReferenceClientRect)||(()=>ke(t,c,u))}),this.show()}show(){var t;(t=this.tippy)===null||t===void 0||t.show()}hide(){var t;(t=this.tippy)===null||t===void 0||t.hide()}destroy(){var t,n;!((t=this.tippy)===null||t===void 0)&&t.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(n=this.tippy)===null||n===void 0||n.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const Se=e=>new L({key:typeof e.pluginKey=="string"?new H(e.pluginKey):e.pluginKey,view:t=>new fs({view:t,...e})});P.create({name:"floatingMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"floatingMenu",shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Se({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,shouldShow:this.options.shouldShow})]:[]}});const ko=At({name:"BubbleMenu",props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},tippyOptions:{type:Object,default:()=>({})},shouldShow:{type:Function,default:null}},setup(e,{slots:t}){const n=Pt(null);return Ot(()=>{const{updateDelay:r,editor:s,pluginKey:i,shouldShow:o,tippyOptions:a}=e;s.registerPlugin(we({updateDelay:r,editor:s,element:n.value,pluginKey:i,shouldShow:o,tippyOptions:a}))}),at(()=>{const{pluginKey:r,editor:s}=e;s.unregisterPlugin(r)}),()=>{var r;return lt("div",{ref:n},(r=t.default)===null||r===void 0?void 0:r.call(t))}}});function Xt(e){return $e((t,n)=>({get(){return t(),e},set(r){e=r,requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})})}}))}class hs extends ds{constructor(t={}){return super(t),this.contentComponent=null,this.appContext=null,this.reactiveState=Xt(this.view.state),this.reactiveExtensionStorage=Xt(this.extensionStorage),this.on("beforeTransaction",({nextState:n})=>{this.reactiveState.value=n,this.reactiveExtensionStorage.value=this.extensionStorage}),re(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(t,n){const r=super.registerPlugin(t,n);return this.reactiveState&&(this.reactiveState.value=r),r}unregisterPlugin(t){const n=super.unregisterPlugin(t);return this.reactiveState&&n&&(this.reactiveState.value=n),n}}const Mo=At({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(e){const t=Pt(),n=Le();return Ce(()=>{const r=e.editor;r&&r.options.element&&t.value&&Ee(()=>{if(!t.value||!r.options.element.firstChild)return;const s=Ae(t.value);t.value.append(...r.options.element.childNodes),r.contentComponent=n.ctx._,n&&(r.appContext={...n.appContext,provides:n.provides}),r.setOptions({element:s}),r.createNodeViews()})}),at(()=>{const r=e.editor;if(!r||(r.isDestroyed||r.view.setProps({nodeViews:{}}),r.contentComponent=null,r.appContext=null,!r.options.element.firstChild))return;const s=document.createElement("div");s.append(...r.options.element.childNodes),r.setOptions({element:s})}),{rootEl:t}},render(){return lt("div",{ref:e=>{this.rootEl=e}})}}),wo=At({name:"FloatingMenu",props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},tippyOptions:{type:Object,default:()=>({})},shouldShow:{type:Function,default:null}},setup(e,{slots:t}){const n=Pt(null);return Ot(()=>{const{pluginKey:r,editor:s,tippyOptions:i,shouldShow:o}=e;s.registerPlugin(Se({pluginKey:r,editor:s,element:n.value,tippyOptions:i,shouldShow:o}))}),at(()=>{const{pluginKey:r,editor:s}=e;s.unregisterPlugin(r)}),()=>{var r;return lt("div",{ref:n},(r=t.default)===null||r===void 0?void 0:r.call(t))}}}),So=(e={})=>{const t=Pe();return Ot(()=>{t.value=new hs(e)}),at(()=>{var n;(n=t.value)===null||n===void 0||n.destroy()}),t};class xo{constructor(t,{props:n={},editor:r}){this.editor=r,this.component=re(t),this.el=document.createElement("div"),this.props=Oe(n),this.renderedComponent=this.renderComponent()}get element(){return this.renderedComponent.el}get ref(){var t,n,r,s;return!((n=(t=this.renderedComponent.vNode)===null||t===void 0?void 0:t.component)===null||n===void 0)&&n.exposed?this.renderedComponent.vNode.component.exposed:(s=(r=this.renderedComponent.vNode)===null||r===void 0?void 0:r.component)===null||s===void 0?void 0:s.proxy}renderComponent(){let t=lt(this.component,this.props);return this.editor.appContext&&(t.appContext=this.editor.appContext),typeof document<"u"&&this.el&&Kt(t,this.el),{vNode:t,destroy:()=>{this.el&&Kt(null,this.el),this.el=null,t=null},el:this.el?this.el.firstElementChild:null}}updateProps(t={}){Object.entries(t).forEach(([n,r])=>{this.props[n]=r}),this.renderComponent()}destroy(){this.renderedComponent.destroy()}}function ms(e){var t;const{char:n,allowSpaces:r,allowedPrefixes:s,startOfLine:i,$position:o}=e,a=us(n),l=new RegExp(`\\s${a}$`),c=i?"^":"",u=r?new RegExp(`${c}${a}.*?(?=\\s${a}|$)`,"gm"):new RegExp(`${c}(?:^)?${a}[^\\s${a}]*`,"gm"),d=((t=o.nodeBefore)===null||t===void 0?void 0:t.isText)&&o.nodeBefore.text;if(!d)return null;const p=o.pos-d.length,f=Array.from(d.matchAll(u)).pop();if(!f||f.input===void 0||f.index===void 0)return null;const h=f.input.slice(Math.max(0,f.index-1),f.index),g=new RegExp(`^[${s==null?void 0:s.join("")}\0]?$`).test(h);if(s!==null&&!g)return null;const y=p+f.index;let m=y+f[0].length;return r&&l.test(d.slice(m-1,m+1))&&(f[0]+=" ",m+=1),y<o.pos&&m>=o.pos?{range:{from:y,to:m},query:f[0].slice(n.length),text:f[0]}:null}const gs=new H("suggestion");function ys({pluginKey:e=gs,editor:t,char:n="@",allowSpaces:r=!1,allowedPrefixes:s=[" "],startOfLine:i=!1,decorationTag:o="span",decorationClass:a="suggestion",command:l=()=>null,items:c=()=>[],render:u=()=>({}),allow:d=()=>!0,findSuggestionMatch:p=ms}){let f;const h=u==null?void 0:u(),g=new L({key:e,view(){return{update:async(y,m)=>{var v,M,S,T,w,E,O;const x=(v=this.key)===null||v===void 0?void 0:v.getState(m),B=(M=this.key)===null||M===void 0?void 0:M.getState(y.state),W=x.active&&B.active&&x.range.from!==B.range.from,jt=!x.active&&B.active,Ft=x.active&&!B.active,gt=!jt&&!Ft&&x.query!==B.query,V=jt||W&&gt,Y=gt||W,yt=Ft||W&&gt;if(!V&&!Y&&!yt)return;const K=yt&&!V?x:B,zt=y.dom.querySelector(`[data-decoration-id="${K.decorationId}"]`);f={editor:t,range:K.range,query:K.query,text:K.text,items:[],command:U=>l({editor:t,range:K.range,props:U}),decorationNode:zt,clientRect:zt?()=>{var U;const{decorationId:xe}=(U=this.key)===null||U===void 0?void 0:U.getState(t.state),vt=y.dom.querySelector(`[data-decoration-id="${xe}"]`);return(vt==null?void 0:vt.getBoundingClientRect())||null}:null},V&&((S=h==null?void 0:h.onBeforeStart)===null||S===void 0||S.call(h,f)),Y&&((T=h==null?void 0:h.onBeforeUpdate)===null||T===void 0||T.call(h,f)),(Y||V)&&(f.items=await c({editor:t,query:K.query})),yt&&((w=h==null?void 0:h.onExit)===null||w===void 0||w.call(h,f)),Y&&((E=h==null?void 0:h.onUpdate)===null||E===void 0||E.call(h,f)),V&&((O=h==null?void 0:h.onStart)===null||O===void 0||O.call(h,f))},destroy:()=>{var y;f&&((y=h==null?void 0:h.onExit)===null||y===void 0||y.call(h,f))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(y,m,v,M){const{isEditable:S}=t,{composing:T}=t.view,{selection:w}=y,{empty:E,from:O}=w,x={...m};if(x.composing=T,S&&(E||t.view.composing)){(O<m.range.from||O>m.range.to)&&!T&&!m.composing&&(x.active=!1);const B=p({char:n,allowSpaces:r,allowedPrefixes:s,startOfLine:i,$position:w.$from}),W=`id_${Math.floor(Math.random()*4294967295)}`;B&&d({editor:t,state:M,range:B.range,isActive:m.active})?(x.active=!0,x.decorationId=m.decorationId?m.decorationId:W,x.range=B.range,x.query=B.query,x.text=B.text):x.active=!1}else x.active=!1;return x.active||(x.decorationId=null,x.range={from:0,to:0},x.query=null,x.text=null),x}},props:{handleKeyDown(y,m){var v;const{active:M,range:S}=g.getState(y.state);return M&&((v=h==null?void 0:h.onKeyDown)===null||v===void 0?void 0:v.call(h,{view:y,event:m,range:S}))||!1},decorations(y){const{active:m,range:v,decorationId:M}=g.getState(y);return m?se.create(y.doc,[oe.inline(v.from,v.to,{nodeName:o,class:a,"data-decoration-id":M})]):null}}});return g}const vs=new H("mention"),To=$.create({name:"mention",addOptions(){return{HTMLAttributes:{},renderText({options:e,node:t}){var n;return`${e.suggestion.char}${(n=t.attrs.label)!==null&&n!==void 0?n:t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:e,node:t}){var n;return["span",C(this.HTMLAttributes,e.HTMLAttributes),`${e.suggestion.char}${(n=t.attrs.label)!==null&&n!==void 0?n:t.attrs.id}`]},suggestion:{char:"@",pluginKey:vs,command:({editor:e,range:t,props:n})=>{var r,s,i;const o=e.view.state.selection.$to.nodeAfter;((r=o==null?void 0:o.text)===null||r===void 0?void 0:r.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:this.name,attrs:n},{type:"text",text:" "}]).run(),(i=(s=e.view.dom.ownerDocument.defaultView)===null||s===void 0?void 0:s.getSelection())===null||i===void 0||i.collapseToEnd()},allow:({state:e,range:t})=>{const n=e.doc.resolve(t.from),r=e.schema.nodes[this.name];return!!n.parent.type.contentMatch.matchType(r)}}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-id"),renderHTML:e=>e.id?{"data-id":e.id}:{}},label:{default:null,parseHTML:e=>e.getAttribute("data-label"),renderHTML:e=>e.label?{"data-label":e.label}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:e,HTMLAttributes:t}){if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",C({"data-type":this.name},this.options.HTMLAttributes,t),this.options.renderLabel({options:this.options,node:e})];const n={...this.options};n.HTMLAttributes=C({"data-type":this.name},this.options.HTMLAttributes,t);const r=this.options.renderHTML({options:n,node:e});return typeof r=="string"?["span",C({"data-type":this.name},this.options.HTMLAttributes,t),r]:r},renderText({node:e}){return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel({options:this.options,node:e})):this.options.renderText({options:this.options,node:e})},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1;const{selection:r}=t,{empty:s,anchor:i}=r;return s?(t.doc.nodesBetween(i-1,i,(o,a)=>{if(o.type.name===this.name)return n=!0,e.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",a,a+o.nodeSize),!1}),n):!1})}},addProseMirrorPlugins(){return[ys({editor:this.editor,...this.options.suggestion})]}}),Co=P.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new L({key:new H("placeholder"),props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,s=[];if(!n)return null;const i=this.editor.isEmpty;return e.descendants((o,a)=>{const l=r>=a&&r<=a+o.nodeSize,c=!o.isLeaf&&mt(o);if((l||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];i&&u.push(this.options.emptyEditorClass);const d=oe.node(a,a+o.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:a,hasAnchor:l}):this.options.placeholder});s.push(d)}return this.options.includeChildren}),se.create(e,s)}}})]}}),bs=/^\s*>\s$/,ks=$.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",C(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[J({find:bs,type:this.type})]}}),Ms=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,ws=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ss=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,xs=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Ts=R.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",C(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[q({find:Ms,type:this.type}),q({find:Ss,type:this.type})]},addPasteRules(){return[z({find:ws,type:this.type}),z({find:xs,type:this.type})]}}),Dt=$.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",C(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ot=R.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["span",C(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:e,commands:t})=>{const n=Rt(e,this.type);return Object.entries(n).some(([,s])=>!!s)?!0:t.unsetMark(this.name)}}}}),Zt=/^\s*([-+*])\s$/,Cs=$.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:e}){return["ul",C(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Dt.name,this.editor.getAttributes(ot.name)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=J({find:Zt,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=J({find:Zt,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ot.name),editor:this.editor})),[e]}}),Es=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,As=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,Ps=R.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",C(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[q({find:Es,type:this.type})]},addPasteRules(){return[z({find:As,type:this.type})]}}),Os=/^```([a-z]+)?[\s\n]$/,Ls=/^~~~([a-z]+)?[\s\n]$/,$s=$.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;const{languageClassPrefix:n}=this.options,i=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",C(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:n}=t,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`

`);return!i||!o?!1:e.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:n,doc:r}=t,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const a=s.after();return a===void 0?!1:r.nodeAt(a)?e.commands.command(({tr:c})=>(c.setSelection(F.near(r.resolve(a))),!0)):e.commands.exitCode()}}},addInputRules(){return[Et({find:Os,type:this.type,getAttributes:e=>({language:e[1]})}),Et({find:Ls,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new L({key:new H("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const n=t.clipboardData.getData("text/plain"),r=t.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;if(!n||!i)return!1;const{tr:o,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,`
`));return o.replaceSelectionWith(this.type.create({language:i},l)),o.selection.$from.parent.type!==this.type&&o.setSelection(I.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),e.dispatch(o),!0}}})]}}),Hs=$.create({name:"doc",topNode:!0,content:"block+"}),Is=P.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Ie(this.options)]}}),Bs=P.create({name:"gapCursor",addProseMirrorPlugins(){return[Be()]},extendNodeSchema(e){var t;const n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=k(b(e,"allowGapCursor",n)))!==null&&t!==void 0?t:null}}}),Rs=$.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",C(this.options.HTMLAttributes,e)]},renderText(){return`
`},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:a}=r.extensionManager,l=i||s.$to.parentOffset&&s.$from.marks();return t().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&o){const d=l.filter(p=>a.includes(p.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Ns=$.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,C(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Et({find:new RegExp(`^(#{1,${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),_s=P.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Re(e,t),redo:()=>({state:e,dispatch:t})=>Ne(e,t)}},addProseMirrorPlugins(){return[_e(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Ds=$.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",C(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{const{selection:n}=t,{$from:r,$to:s}=n,i=e();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:s.pos},{type:this.name}):be(n)?i.insertContentAt(s.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:o,dispatch:a})=>{var l;if(a){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(I.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(it.create(o.doc,c.pos)):o.setSelection(I.create(o.doc,c.pos));else{const d=(l=c.parent.type.contentMatch.defaultType)===null||l===void 0?void 0:l.create();d&&(o.insert(u,d),o.setSelection(I.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Me({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),js=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Fs=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,zs=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Ks=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,qs=R.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",C(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[q({find:js,type:this.type}),q({find:zs,type:this.type})]},addPasteRules(){return[z({find:Fs,type:this.type}),z({find:Ks,type:this.type})]}}),te=/^(\d+)\.\s$/,Ws=$.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...n}=e;return t===1?["ol",C(this.options.HTMLAttributes,n),0]:["ol",C(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Dt.name,this.editor.getAttributes(ot.name)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=J({find:te,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=J({find:te,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(ot.name)}),joinPredicate:(t,n)=>n.childCount+n.attrs.start===+t[1],editor:this.editor})),[e]}}),Vs=$.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",C(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Us=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Gs=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Js=R.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",C(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[q({find:Us,type:this.type})]},addPasteRules(){return[z({find:Gs,type:this.type})]}}),Ys=$.create({name:"text",group:"inline"}),Eo=P.create({name:"starterKit",addExtensions(){var e,t,n,r,s,i,o,a,l,c,u,d,p,f,h,g,y,m;const v=[];return this.options.bold!==!1&&v.push(Ts.configure((e=this.options)===null||e===void 0?void 0:e.bold)),this.options.blockquote!==!1&&v.push(ks.configure((t=this.options)===null||t===void 0?void 0:t.blockquote)),this.options.bulletList!==!1&&v.push(Cs.configure((n=this.options)===null||n===void 0?void 0:n.bulletList)),this.options.code!==!1&&v.push(Ps.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&v.push($s.configure((s=this.options)===null||s===void 0?void 0:s.codeBlock)),this.options.document!==!1&&v.push(Hs.configure((i=this.options)===null||i===void 0?void 0:i.document)),this.options.dropcursor!==!1&&v.push(Is.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor)),this.options.gapcursor!==!1&&v.push(Bs.configure((a=this.options)===null||a===void 0?void 0:a.gapcursor)),this.options.hardBreak!==!1&&v.push(Rs.configure((l=this.options)===null||l===void 0?void 0:l.hardBreak)),this.options.heading!==!1&&v.push(Ns.configure((c=this.options)===null||c===void 0?void 0:c.heading)),this.options.history!==!1&&v.push(_s.configure((u=this.options)===null||u===void 0?void 0:u.history)),this.options.horizontalRule!==!1&&v.push(Ds.configure((d=this.options)===null||d===void 0?void 0:d.horizontalRule)),this.options.italic!==!1&&v.push(qs.configure((p=this.options)===null||p===void 0?void 0:p.italic)),this.options.listItem!==!1&&v.push(Dt.configure((f=this.options)===null||f===void 0?void 0:f.listItem)),this.options.orderedList!==!1&&v.push(Ws.configure((h=this.options)===null||h===void 0?void 0:h.orderedList)),this.options.paragraph!==!1&&v.push(Vs.configure((g=this.options)===null||g===void 0?void 0:g.paragraph)),this.options.strike!==!1&&v.push(Js.configure((y=this.options)===null||y===void 0?void 0:y.strike)),this.options.text!==!1&&v.push(Ys.configure((m=this.options)===null||m===void 0?void 0:m.text)),v}});function Qs(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?["()","[]"].includes(e[0].value+e[2].value):!1}function Xs(e){return new L({key:new H("autolink"),appendTransaction:(t,n,r)=>{const s=t.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=t.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,a=Sr(n.doc,[...t]);if(Hr(a).forEach(({newRange:c})=>{const u=Tr(r.doc,c,f=>f.isTextblock);let d,p;if(u.length>1?(d=u[0],p=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(d=u[0],p=r.doc.textBetween(d.pos,c.to,void 0," ")),d&&p){const f=p.split(" ").filter(m=>m!=="");if(f.length<=0)return!1;const h=f[f.length-1],g=d.pos+p.lastIndexOf(h);if(!h)return!1;const y=De(h).map(m=>m.toObject(e.defaultProtocol));if(!Qs(y))return!1;y.filter(m=>m.isLink).map(m=>({...m,from:g+m.start+1,to:g+m.end+1})).filter(m=>r.schema.marks.code?!r.doc.rangeHasMark(m.from,m.to,r.schema.marks.code):!0).filter(m=>e.validate(m.value)).forEach(m=>{_t(m.from,m.to,r.doc).some(v=>v.mark.type===e.type)||o.addMark(m.from,m.to,e.type.create({href:m.href}))})}}),!!o.steps.length)return o}})}function Zs(e){return new L({key:new H("handleClickLink"),props:{handleClick:(t,n,r)=>{var s,i;if(r.button!==0||!t.editable)return!1;let o=r.target;const a=[];for(;o.nodeName!=="DIV";)a.push(o),o=o.parentNode;if(!a.find(p=>p.nodeName==="A"))return!1;const l=ve(t.state,e.type.name),c=r.target,u=(s=c==null?void 0:c.href)!==null&&s!==void 0?s:l.href,d=(i=c==null?void 0:c.target)!==null&&i!==void 0?i:l.target;return c&&u?(window.open(u,d),!0):!1}}})}function to(e){return new L({key:new H("handlePasteLink"),props:{handlePaste:(t,n,r)=>{const{state:s}=t,{selection:i}=s,{empty:o}=i;if(o)return!1;let a="";r.content.forEach(c=>{a+=c.textContent});const l=ie(a,{defaultProtocol:e.defaultProtocol}).find(c=>c.isLink&&c.value===a);return!a||!l?!1:(e.editor.commands.setMark(e.type,{href:l.href}),!0)}}})}const eo=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function ee(e,t){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!e||e.replace(eo,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Ao=R.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.protocols.forEach(e=>{if(typeof e=="string"){qt(e);return}qt(e.scheme,e.optionalSlashes)})},onDestroy(){je()},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},validate:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.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:e=>{const t=e.getAttribute("href");return!t||!ee(t,this.options.protocols)?!1:null}}]},renderHTML({HTMLAttributes:e}){return ee(e.href,this.options.protocols)?["a",C(this.options.HTMLAttributes,e),0]:["a",C(this.options.HTMLAttributes,{...e,href:""}),0]},addCommands(){return{setLink:e=>({chain:t})=>t().setMark(this.name,e).setMeta("preventAutolink",!0).run(),toggleLink:e=>({chain:t})=>t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[z({find:e=>{const t=[];if(e){const{validate:n}=this.options,r=ie(e).filter(s=>s.isLink&&n(s.value));r.length&&r.forEach(s=>t.push({text:s.value,data:{href:s.href},index:s.start}))}return t},type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const e=[];return this.options.autolink&&e.push(Xs({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:this.options.validate})),this.options.openOnClick===!0&&e.push(Zs({type:this.type})),this.options.linkOnPaste&&e.push(to({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),no=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Po=$.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:e}){return["img",C(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[Me({find:no,type:this.type,getAttributes:e=>{const[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function ro(e,t,n){return le.fromSchema(t).serializeFragment(e.content,{document:yn()}).render()}function Oo(e,t){const n=Ar(t),r=Ke.fromJSON(n,e);return ro(r,n)}export{ko as B,Mo as E,wo as F,pt as I,Ao as L,To as M,$ as N,Cn as P,ys as S,xo as V,Eo as a,Co as b,Sr as c,Po as d,us as e,Tr as f,Hr as g,Oo as h,C as m,Me as n,So as u};
